@bhsd/codemirror-mediawiki 2.1.5 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.min.js CHANGED
@@ -1,16 +1,16 @@
1
- var hd=Object.defineProperty;var cd=(n,e)=>{for(var t in e)hd(n,t,{get:e[t],enumerable:!0})};var pa=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var G=(n,e,t)=>(pa(n,e,"read from private field"),t?t.call(n):e.get(n)),xt=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},ot=(n,e,t,i)=>(pa(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);var Q=class n{lineAt(e){if(e<0||e>this.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]=Si(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),yi.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Si(this,e,t);let i=[];return this.decompose(e,t,i,0),yi.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),r=new Zt(this),s=new Zt(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new Zt(this,e)}iterRange(e,t=this.length){return new Jn(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Xn(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]?n.empty:e.length<=32?new Ie(e):yi.from(Ie.split(e,[]))}},Ie=class n extends Q{constructor(e,t=fd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new Vs(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(ma(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Yn(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new n(l,o.length+s.length));else{let a=l.length>>1;i.push(new n(l.slice(0,a)),new n(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=Si(this,e,t);let r=Yn(this.text,Yn(i.text,ma(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):yi.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=`
2
- `){[e,t]=Si(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},yi=class n extends Q{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,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((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]=Si(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new n(c,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
- `){[e,t]=Si(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let p of e)i+=p.lines;if(i<32){let p=[];for(let g of e)g.flatten(p);return new Ie(p,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(p){let g;if(p.lines>s&&p instanceof n)for(let x of p.children)f(x);else p.lines>o&&(a>o||!a)?(u(),l.push(p)):p instanceof Ie&&a&&(g=c[c.length-1])instanceof Ie&&p.lines+g.lines<=32?(a+=p.lines,h+=p.length+1,c[c.length-1]=new Ie(g.text.concat(p.text),g.length+1+p.length)):(a+p.lines>r&&u(),a+=p.lines,h+=p.length+1,c.push(p))}function u(){a!=0&&(l.push(c.length==1?c[0]:n.from(c,h)),h=-1,a=c.length=0)}for(let p of e)f(p);return u(),l.length==1?l[0]:new n(l,t)}};Q.empty=new Ie([""],0);function fd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Yn(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function ma(n,e,t){return Yn(n,[""],e,t)}var Zt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?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,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof Ie?r.text.length:r.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((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
- `,this;e--}else if(r instanceof Ie){let a=r.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=r.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)}},Jn=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Zt(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:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.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!=""}},Xn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=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=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(Q.prototype[Symbol.iterator]=function(){return this.iter()},Zt.prototype[Symbol.iterator]=Jn.prototype[Symbol.iterator]=Xn.prototype[Symbol.iterator]=function(){return this});var Vs=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function Si(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}var wi="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;n<wi.length;n++)wi[n]+=wi[n-1];function ud(n){for(let e=1;e<wi.length;e+=2)if(wi[e]>n)return wi[e-1]<=n;return!1}function ga(n){return n>=127462&&n<=127487}var ba=8205;function be(n,e,t=!0,i=!0){return(t?Sa:dd)(n,e,i)}function Sa(n,e,t){if(e==n.length)return e;e&&Ca(n.charCodeAt(e))&&Aa(n.charCodeAt(e-1))&&e--;let i=$e(n,e);for(e+=St(i);e<n.length;){let r=$e(n,e);if(i==ba||r==ba||t&&ud(r))e+=St(r),i=r;else if(ga(r)){let s=0,o=e-2;for(;o>=0&&ga($e(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function dd(n,e,t){for(;e>0;){let i=Sa(n,e-2,t);if(i<e)return i;e--}return 0}function Ca(n){return n>=56320&&n<57344}function Aa(n){return n>=55296&&n<56320}function $e(n,e){let t=n.charCodeAt(e);if(!Aa(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Ca(i)?(t-55296<<10)+(i-56320)+65536:t}function ir(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function St(n){return n<65536?1:2}var Ws=/\r\n?|\n/,Ce=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Ce||(Ce={})),vt=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){js(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:Ta(this,e)}mapDesc(e,t=!1){return e.empty?this:qs(this,e,t)}mapPos(e,t=-1,i=Ce.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=Ce.Simple&&h>=e&&(i==Ce.TrackDel&&r<e&&h>e||i==Ce.TrackBefore&&r<e||i==Ce.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}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 n(e)}static create(e){return new n(e)}},De=class n extends vt{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 js(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return qs(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(Q.empty);i.push(o?e.slice(s,s+o):Q.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:Ta(this,e,!0)}map(e,t=!1){return e.empty?this:qs(this,e,t,!0)}iterChanges(e,t=!1){js(this,e,t)}get desc(){return vt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new Qt(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);Me(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Me(t,c,f),f>0&&Ot(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);Me(t,c,-1),Me(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:vt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&Me(r,t-o,-1);let f=new n(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof n){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:p}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let g=p?typeof p=="string"?Q.of(p.split(i||Ws)):p:Q.empty,x=g.length;if(f==u&&x==0)return;f<o&&a(),f>o&&Me(r,f-o,-1),Me(r,u-f,x),Ot(s,r,g),o=u}}return h(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(Q.empty);i[r]=Q.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function Me(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Ot(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(Q.empty);n.push(t)}}function js(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=Q.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function qs(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Qt(n),l=new Qt(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Me(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(Me(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Me(r,0,o.ins),s&&Ot(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=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.len<c)c-=l.len,l.next();else break;Me(r,h,a<o.i?o.ins:0),s&&a<o.i&&Ot(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?De.createSet(r,s):vt.create(r);throw new Error("Mismatched change set lengths")}}function Ta(n,e,t=!1){let i=[],r=t?[]:null,s=new Qt(n),o=new Qt(e);for(let l=!1;;){if(s.done&&o.done)return r?De.createSet(i,r):vt.create(i);if(s.ins==0)Me(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Me(i,0,o.ins,l),r&&Ot(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Me(i,a,c,l),r&&c&&Ot(r,i,o.text)}else o.ins==-1?(Me(i,s.off?0:s.len,a,l),r&&Ot(r,i,s.textBit(a))):(Me(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Ot(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}var Qt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Q.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Q.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)}},ki=class n{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,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return L.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return L.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}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 L.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},L=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.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 n(e.ranges.map(t=>ki.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.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,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return ki.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r!=null?r:16777215)<<6)}static range(e,t,i,r){let s=(i!=null?i:16777215)<<6|(r==null?7:Math.min(6,r));return t<e?ki.create(t,e,48|s):ki.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Ma(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Qs=0,I=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Qs++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:eo),!!e.static,e.enables)}of(e){return new xi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new xi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new xi(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function eo(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var xi=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Qs++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>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)||$s(f,c)){let p=i(f);if(l?!ka(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,u)=>{let p,g=u.config.address[s];if(g!=null){let x=er(u,g);if(this.dependencies.every(y=>y instanceof I?u.facet(y)===f.facet(y):y instanceof me?u.field(y,!1)==f.field(y,!1):!0)||(l?ka(p=i(f),x,r):r(p=i(f),x)))return f.values[o]=x,0}else p=i(f);return f.values[o]=p,1}}}};function ka(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function $s(n,e){let t=!1;for(let i of e)Xi(n,i)&1&&(t=!0);return t}function pd(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=er(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Xi(a,h);return a.values[o]=l(a),1},update(a,h){if(!$s(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=$s(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&eo(t,f))return a.values[o]=u,0;let p=l(a);return e.compare(p,u)?(a.values[o]=u,0):(a.values[o]=p,1)}}}var ya=I.define({static:!0}),me=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(Qs++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ya).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,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,ya.of({field:this,create:e})]}get extension(){return this}},Jt={lowest:4,low:3,default:2,high:1,highest:0};function Ji(n){return e=>new Zn(e,n)}var Et={highest:Ji(Jt.highest),high:Ji(Jt.high),default:Ji(Jt.default),low:Ji(Jt.low),lowest:Ji(Jt.lowest)},Zn=class{constructor(e,t){this.inner=e,this.prec=t}},Ct=class n{of(e){return new Zi(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Zi=class{constructor(e,t){this.compartment=e,this.inner=t}},Qn=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of md(e,t,o))u instanceof me?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(p=>u.slot(p));let c=i==null?void 0:i.config.facets;for(let u in s){let p=s[u],g=p[0].facet,x=c&&c[u]||[];if(p.every(y=>y.type==0))if(l[g.id]=a.length<<1|1,eo(x,p))a.push(i.facet(g));else{let y=g.combine(p.map(v=>v.value));a.push(i&&g.compare(y,i.facet(g))?i.facet(g):y)}else{for(let y of p)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=h.length<<1,h.push(v=>y.dynamicSlot(v)));l[g.id]=h.length<<1,h.push(y=>pd(y,g,p))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function md(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Zi&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof Zi){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),s(h,l)}else if(o instanceof Zn)s(o.inner,o.prec);else if(o instanceof me)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof xi)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,Jt.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.`);s(h,l)}}return s(n,Jt.default),i.reduce((o,l)=>o.concat(l))}function Xi(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 r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function er(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var La=I.define(),Ks=I.define({combine:n=>n.some(e=>e),static:!0}),Da=I.define({combine:n=>n.length?n[0]:void 0,static:!0}),Oa=I.define(),Ea=I.define(),Ba=I.define(),Pa=I.define({combine:n=>n.length?n[0]:!1}),Ne=class{constructor(e,t){this.type=e,this.value=t}static define(){return new _s}},_s=class{of(e){return new Ne(this,e)}},Gs=class{constructor(e){this.map=e}of(e){return new X(this,e)}},X=class n{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 n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Gs(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};X.reconfigure=X.define();X.appendConfig=X.define();var xe=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Ma(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,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(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};xe.time=Ne.define();xe.userEvent=Ne.define();xe.addToHistory=Ne.define();xe.remote=Ne.define();function gd(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Ra(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=De.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:X.mapEffects(n.effects,r).concat(X.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function Us(n,e,t){let i=e.selection,r=vi(e.annotations);return e.userEvent&&(r=r.concat(xe.userEvent.of(e.userEvent))),{changes:e.changes instanceof De?e.changes:De.of(e.changes||[],t,n.facet(Da)),selection:i&&(i instanceof L?i:L.single(i.anchor,i.head)),effects:vi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Ia(n,e,t){let i=Us(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Ra(i,Us(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=xe.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return kd(t?bd(r):r)}function bd(n){let e=n.startState,t=!0;for(let r of e.facet(Oa)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:gd(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=De.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=xe.create(e,r,n.selection&&n.selection.map(s),X.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Ea);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof xe?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof xe?n=s[0]:n=Ia(e,vi(s),!1)}return n}function kd(n){let e=n.startState,t=e.facet(Ba),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=Ra(i,Us(e,s,n.changes.newLength),!0))}return i==n?n:xe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var yd=[];function vi(n){return n==null?yd:Array.isArray(n)?n:[n]}var ue=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(ue||(ue={})),wd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ys;try{Ys=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function xd(n){if(Ys)return Ys.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||wd.test(t)))return!0}return!1}function vd(n){return e=>{if(!/\S/.test(e))return ue.Space;if(xd(e))return ue.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return ue.Word;return ue.Other}}var oe=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Xi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Xi(this,i),er(this,i)}update(...e){return Ia(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(Ct.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(X.reconfigure)?(t=null,i=l.value):l.is(X.appendConfig)&&(t=null,i=vi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Qn.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Ks)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(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:L.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=vi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=X.mapEffects(o,c).concat(X.mapEffects(vi(a.effects),f))}return{changes:r,selection:L.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof De?e:De.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return Q.of(e.split(this.facet(n.lineSeparator)||Ws))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Xi(this,t),er(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof me&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:L.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Qn.resolve(e.extensions||[],new Map),i=e.doc instanceof Q?e.doc:Q.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||Ws)),r=e.selection?e.selection instanceof L?e.selection:L.single(e.selection.anchor,e.selection.head):L.single(0);return Ma(r,i.length),t.staticFacet(Ks)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
5
- `}get readOnly(){return this.facet(Pa)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(La))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return vd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=be(t,o,!1);if(s(t.slice(a,o))!=ue.Word)break;o=a}for(;l<r;){let a=be(t,l);if(s(t.slice(l,a))!=ue.Word)break;l=a}return o==l?null:L.range(o+i,l+i)}};oe.allowMultipleSelections=Ks;oe.tabSize=I.define({combine:n=>n.length?n[0]:4});oe.lineSeparator=Da;oe.readOnly=Pa;oe.phrases=I.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});oe.languageData=La;oe.changeFilter=Oa;oe.transactionFilter=Ea;oe.transactionExtender=Ba;Ct.reconfigure=X.define();function ze(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var Ze=class{eq(e){return this==e}range(e,t=e){return Qi.create(e,t,this)}};Ze.prototype.startSide=Ze.prototype.endSide=0;Ze.prototype.point=!1;Ze.prototype.mapMode=Ce.TrackDel;var Qi=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function Js(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Xs=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[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,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,p;if(c==f){let g=t.mapPos(c,h.startSide,h.mapMode);if(g==null||(u=p=g,h.startSide!=h.endSide&&(p=t.mapPos(c,h.endSide),p<u)))continue}else if(u=t.mapPos(c,h.startSide),p=t.mapPos(f,h.endSide),u>p||u==p&&h.startSide>0&&h.endSide<=0)continue;(p-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,p-u)),i.push(h),r.push(u-o),s.push(p-o))}return{mapped:i.length?new n(r,s,i,l):null,pos:o}}},ie=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}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:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Js)),this.isEmpty)return t.length?n.of(t):this;let l=new tr(this,null,-1).goto(0),a=0,h=[],c=new lt;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(Qi.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?n.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),t.push(c),i.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new n(i,t,s||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return en.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return en.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=wa(o,l,i),h=new Xt(o,a,s),c=new Xt(l,a,s);i.iterGaps((f,u,p)=>xa(h,f,c,u,p,r)),i.empty&&i.length==0&&xa(h,0,c,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=wa(s,o),a=new Xt(s,l,0).goto(i),h=new Xt(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Zs(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,i,r,s=-1){let o=new Xt(e,null,s).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.pointFrom<t?c.length+1:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.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 lt;for(let r of e instanceof Qi?[e]:t?Sd(e):e)i.add(r.from,r.to,r.value);return i.finish()}};ie.empty=new ie([],[],null,-1);function Sd(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(Js(e,i)>0)return n.slice().sort(Js);e=i}return n}ie.empty.nextLayer=ie.empty;var lt=class n{finishChunk(e){this.chunks.push(new Xs(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 n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<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(ie.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=ie.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function wa(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}var tr=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},en=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new tr(o,t,i,s));return r.length==1?r[0]:new n(r)}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--)Hs(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--)Hs(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(),Hs(this.heap,0)}}};function Hs(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var Xt=class{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=en.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){Gn(this.active,e),Gn(this.activeTo,e),Gn(this.activeRank,e),this.minActive=va(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=s;)t++;Un(this.active,t,i),Un(this.activeTo,t,r),Un(this.activeRank,t,s),e&&Un(e,t,this.cursor.from),this.minActive=va(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Gn(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[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 xa(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,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))&&Zs(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,f,n.point,t.point):f>l&&!Zs(n.active,t.active)&&s.compareRange(l,f,n.active,t.active),c>o)break;l=c,h<=0&&n.next(),h>=0&&t.next()}}function Zs(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!n[t].eq(e[t]))return!1;return!0}function Gn(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function Un(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function va(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function Bt(n,e,t=n.length){let i=0;for(let r=0;r<t;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=be(n,r));return i}function Na(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=be(n,r)}return i===!0?-1:n.length}var to="\u037C",za=typeof Symbol=="undefined"?"__"+to:Symbol.for(to),io=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Fa=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},Ke=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(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 p in l){let g=l[p];if(/&/.test(p))s(p.split(/,\s*/).map(x=>o.map(y=>x.replace(/&/,y))).reduce((x,y)=>x.concat(y)),g,a);else if(g&&typeof g=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,c,u)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,x=>"-"+x.toLowerCase())+": "+g+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
6
- `)}static newName(){let e=Fa[za]||1;return Fa[za]=e+1,to+e.toString(36)}static mount(e,t,i){let r=e[io],s=i&&i.nonce;r?s&&r.setNonce(s):r=new no(e,s),r.mount(Array.isArray(t)?t:[t])}},Ha=new Map,no=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Ha.get(i);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[io]=s;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],Ha.set(i,this)}else{this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let s=e.head||e;s.insertBefore(this.styleTag,s.firstChild)}this.modules=[],e[io]=this}mount(e){let t=this.sheet,i=0,r=0;for(let s=0;s<e.length;s++){let o=e[s],l=this.modules.indexOf(o);if(l<r&&l>-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,o),t)for(let a=0;a<o.rules.length;a++)t.insertRule(o.rules[a],i++)}else{for(;r<l;)i+=this.modules[r++].rules.length;i+=o.rules.length,r++}}if(!t){let s="";for(let o=0;o<this.modules.length;o++)s+=this.modules[o].getRules()+`
7
- `;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var At={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ci={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Cd=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Ad=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ke=0;ke<10;ke++)At[48+ke]=At[96+ke]=String(ke);var ke;for(ke=1;ke<=24;ke++)At[ke+111]="F"+ke;var ke;for(ke=65;ke<=90;ke++)At[ke]=String.fromCharCode(ke+32),Ci[ke]=String.fromCharCode(ke);var ke;for(nr in At)Ci.hasOwnProperty(nr)||(Ci[nr]=At[nr]);var nr;function Va(n){var e=Cd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ad&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ci: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 br(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function uo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Td(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function dr(n,e){if(!e.anchorNode)return!1;try{return uo(n,e.anchorNode)}catch(t){return!1}}function dn(n){return n.nodeType==3?ei(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function kr(n,e,t,i){return t?Wa(n,e,t,i,-1)||Wa(n,e,t,i,1):!1}function pn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Wa(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Tt(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=pn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?Tt(n):0}else return!1}}function Tt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Yo(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Md(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Th(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,r,s,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,p=c==a.body,g=1,x=1;if(p)u=Md(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 M=c.getBoundingClientRect();({scaleX:g,scaleY:x}=Th(c,M)),u={left:M.left,right:M.left+c.clientWidth*g,top:M.top,bottom:M.top+c.clientHeight*x}}let y=0,v=0;if(r=="nearest")e.top<u.top?(v=-(u.top-e.top+o),t>0&&e.bottom>u.bottom+v&&(v=e.bottom-u.bottom+v+o)):e.bottom>u.bottom&&(v=e.bottom-u.bottom+o,t<0&&e.top-v<u.top&&(v=-(u.top+v-e.top+o)));else{let M=e.bottom-e.top,O=u.bottom-u.top;v=(r=="center"&&M<=O?e.top+M/2-O/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-O+o)-u.top}if(i=="nearest"?e.left<u.left?(y=-(u.left-e.left+s),t>0&&e.right>u.right+y&&(y=e.right-u.right+y+s)):e.right>u.right&&(y=e.right-u.right+s,t<0&&e.left<u.left+y&&(y=-(u.left+y-e.left+s))):y=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,y||v)if(p)h.scrollBy(y,v);else{let M=0,O=0;if(v){let R=c.scrollTop;c.scrollTop+=v/x,O=(c.scrollTop-R)*x}if(y){let R=c.scrollLeft;c.scrollLeft+=y/g,M=(c.scrollLeft-R)*g}e={left:e.left-M,top:e.top-O,right:e.right-M,bottom:e.bottom-O},M&&Math.abs(M-y)<1&&(i="nearest"),O&&Math.abs(O-v)<1&&(r="nearest")}if(p)break;c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Dd(n){let e=n.ownerDocument;for(let t=n.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var po=class{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?Tt(t):0),i,Math.min(e.focusOffset,i?Tt(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},Ai=null;function Mh(n){if(n.setActive)return n.setActive();if(Ai)return n.focus(Ai);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(Ai==null?{get preventScroll(){return Ai={preventScroll:!0},!0}}:void 0),!Ai){Ai=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],s=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=s&&(i.scrollLeft=s)}}}var ja;function ei(n,e,t=e){let i=ja||(ja=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Di(n,e,t){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0},r=new KeyboardEvent("keydown",i);r.synthetic=!0,n.dispatchEvent(r);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,n.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function Od(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Lh(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}function Ed(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Tt(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=Tt(t))}else{if(t==n)return!0;i=pn(t),t=t.parentNode}}function Dh(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}var Oe=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,pn(e),t)}static after(e,t){return new n(e.parentNode,pn(e)+1,t)}},Jo=[],de=class n{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:i.firstChild)){let l=n.get(s);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&s!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;s&&s!=o.dom;)s=qa(s);else i.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:i.firstChild,s&&t&&t.node==i&&(t.written=!0);s;)s=qa(s)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let r=Tt(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!n.get(i);)i=i.nextSibling;if(!i)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==i)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<this.children.length;a++){let f=this.children[a],u=h+f.length;if(h<e&&u>t)return f.domBoundsAround(e,t,h);if(u>=e&&r==-1&&(r=a,s=h),h>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?i+this.length:l,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&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=Jo){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&i.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...i);for(let r=0;r<i.length;r++)i[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new yr(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}};de.prototype.breakAfter=0;function qa(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var yr=class{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.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 Oh(n,e,t,i,r,s,o,l,a){let{children:h}=n,c=h.length?h[e]:null,f=s.length?s[s.length-1]:null,u=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!u&&s.length<2&&c.merge(t,r,s.length?f:null,t==0,l,a))){if(i<h.length){let p=h[i];p&&(r<p.length||p.breakAfter&&(f!=null&&f.breakAfter))?(e==i&&(p=p.split(r),r=0),!u&&f&&p.merge(0,r,f,!0,0,a)?s[s.length-1]=p:((r||p.children.length&&!p.children[0].length)&&p.merge(0,r,null,!1,0,a),s.push(p))):p!=null&&p.breakAfter&&(f?f.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,t>0&&(!o&&s.length&&c.merge(t,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(t<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(t,c.length,null,!1,l,0),e++));e<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&i<h.length&&!h[e-1].breakAfter&&h[i].merge(0,0,h[e-1],!1,l,a)&&e--,(e<i||s.length)&&n.replaceChildren(e,i,s)}}function Eh(n,e,t,i,r,s){let o=n.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:h,off:c}=o.findPos(e,-1),f=e-t;for(let u of i)f+=u.length;n.length+=f,Oh(n,h,c,l,a,i,0,r,s)}var Fe=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},mo=typeof document!="undefined"?document:{documentElement:{style:{}}},go=/Edge\/(\d+)/.exec(Fe.userAgent),Bh=/MSIE \d/.test(Fe.userAgent),bo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fe.userAgent),Pr=!!(Bh||bo||go),$a=!Pr&&/gecko\/(\d+)/i.test(Fe.userAgent),ro=!Pr&&/Chrome\/(\d+)/.exec(Fe.userAgent),Ka="webkitFontSmoothing"in mo.documentElement.style,Ph=!Pr&&/Apple Computer/.test(Fe.vendor),_a=Ph&&(/Mobile\/\w+/.test(Fe.userAgent)||Fe.maxTouchPoints>2),H={mac:_a||/Mac/.test(Fe.platform),windows:/Win/.test(Fe.platform),linux:/Linux|X11/.test(Fe.platform),ie:Pr,ie_version:Bh?mo.documentMode||6:bo?+bo[1]:go?+go[1]:0,gecko:$a,gecko_version:$a?+(/Firefox\/(\d+)/.exec(Fe.userAgent)||[0,0])[1]:0,chrome:!!ro,chrome_version:ro?+ro[1]:0,ios:_a,android:/Android\b/.test(Fe.userAgent),webkit:Ka,safari:Ph,webkit_version:Ka?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:mo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Bd=256,It=class n extends de{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 n)||this.length-(t-e)+i.length>Bd||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 n(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 Oe(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 Pd(this.dom,e,t)}},Nt=class n extends de{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let r of t)r.setParent(this)}setAttrs(e){if(Lh(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,r,s,o){return i&&(!(i instanceof n&&i.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(Eh(this,e,t,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],i=0,r=-1,s=0;for(let l of this.children){let a=i+l.length;a>e&&t.push(i<e?l.split(e-i):l),r<0&&i>=e&&(r=s),i=a,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new n(this.mark,t,o)}domAtPos(e){return Rh(this,e)}coordsAt(e,t){return Nh(this,e,t)}};function Pd(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?H.chrome||H.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=ei(n,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return H.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Yo(a,o<0):a||null}var mn=class n extends de{static create(e,t,i){return new n(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=n.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.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof n&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Q.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,r=this.posAtStart;return i?i.slice(r,r+this.length):Q.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Oe.before(this.dom):Oe.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 r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?r.length-1:0;s=r[l],!(e>0?l==0:l==r.length-1||s.top<s.bottom);l+=o?-1:1);return Yo(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},gn=class n extends de{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof n&&e.side==this.side}split(){return new n(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Oe.before(this.dom):Oe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Q.empty}get isHidden(){return!0}};It.prototype.children=mn.prototype.children=gn.prototype.children=Jo;function Rh(n,e){let t=n.dom,{children:i}=n,r=0;for(let s=0;r<i.length;r++){let o=i[r],l=s+o.length;if(!(l==s&&o.getSide()<=0)){if(e>s&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=l}}for(let s=r;s>0;s--){let o=i[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s<i.length;s++){let o=i[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new Oe(t,0)}function Ih(n,e,t){let i,{children:r}=n;t>0&&e instanceof Nt&&r.length&&(i=r[r.length-1])instanceof Nt&&i.mark.eq(e.mark)?Ih(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function Nh(n,e,t){let i=null,r=-1,s=null,o=-1;function l(h,c){for(let f=0,u=0;f<h.children.length&&u<=c;f++){let p=h.children[f],g=u+p.length;g>=c&&(p.children.length?l(p,c-u):(!s||s.isHidden&&t>0)&&(g>c||u==g&&p.getSide()>0)?(s=p,o=c-u):(u<c||u==g&&p.getSide()<0&&!p.isHidden)&&(i=p,r=c-u)),u=g}}l(n,e);let a=(t<0?i:s)||i||s;return a?a.coordsAt(Math.max(0,a==i?r:o),t):Rd(n)}function Rd(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=dn(e);return t[t.length-1]||null}function ko(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Ga=Object.create(null);function Xo(n,e,t){if(n==e)return!0;n||(n=Ga),e||(e=Ga);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function yo(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Id(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var Ae=class n extends de{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,r,s,o){if(i){if(!(i instanceof n))return!1;this.dom||i.transferDOM(this)}return r&&this.setDeco(i?i.attrs:null),Eh(this,e,t,i?i.children.slice():[],s,o),!0}split(e){let t=new n;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:r}=this.childPos(e);r&&(t.append(this.children[i].split(r),0),this.children[i].merge(r,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)t.append(this.children[s],0);for(;i>0&&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){Xo(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Ih(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=ko(t,this.attrs||{})),i&&(this.attrs=ko({class:i},this.attrs||{}))}domAtPos(e){return Rh(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Lh(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&&(yo(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&de.get(r)instanceof Nt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=de.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!H.ios||!this.children.some(s=>s instanceof It))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof It)||/[^ -~]/.test(i.text))return null;let r=dn(i.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=Nh(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=i.bottom-i.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(e){return!1}covers(){return!0}static find(e,t){for(let i=0,r=0;i<e.children.length;i++){let s=e.children[i],o=r+s.length;if(o>=t){if(s instanceof n)return s;if(o>t)break}r=o+s.breakAfter}return null}},Oi=class n extends de{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Oe.before(this.dom):Oe.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new n(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Jo}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.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Q.empty}domBoundsAround(){return null}become(e){return e instanceof n&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t==i?!1:e<0?t<0:i>0}},et=class{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}destroy(e){}},Qe=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Qe||(Qe={})),J=class extends Ze{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new bn(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 zt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=zh(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new zt(e,i,r,t,e.widget||null,!0)}static line(e){return new kn(e)}static set(e,t=!1){return ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};J.none=ie.empty;var bn=class n extends J{constructor(e){let{start:t,end:i}=zh(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 n&&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))&&Xo(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)}};bn.prototype.point=!1;var kn=class n extends J{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Xo(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)}};kn.prototype.mapMode=Ce.TrackBefore;kn.prototype.point=!0;var zt=class n extends J{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ce.TrackBefore:Ce.TrackAfter:Ce.TrackDel}get type(){return this.startSide!=this.endSide?Qe.WidgetRange:this.startSide<=0?Qe.WidgetBefore:Qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Nd(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)}};zt.prototype.point=!0;function zh(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 Nd(n,e){return n==e||!!(n&&e&&n.compare(e))}function wo(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var ln=class n{constructor(e,t,i,r){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=r,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 Oi&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ae),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(rr(new gn(-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 Oi)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:s,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=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(rr(new It(this.text.slice(this.textOff,this.textOff+r)),t),i),this.atCursorPos=!0,this.textOff+=r,e-=r,i=0}}span(e,t,i,r){this.buildText(t-e,i,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,i,r,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof zt){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 zt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Oi(i.widget||new wr("div"),l,i));else{let a=mn.create(i.widget||new wr("span"),l,l?0:i.startSide),h=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<t||i.startSide>0),c=!a.isEditable&&(e<t||s>r.length||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),h&&(f.append(rr(new gn(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(rr(a,r),s),this.atCursorPos=c,this.pendingBuffer=c?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.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=s)}static build(e,t,i,r,s){let o=new n(e,t,i,s);return o.openEnd=ie.spans(r,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function rr(n,e){for(let t of e)n=new Nt(t,[n],n.length);return n}var wr=class extends et{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}},Fh=I.define(),Hh=I.define(),Vh=I.define(),Wh=I.define(),xo=I.define(),jh=I.define(),qh=I.define(),$h=I.define({combine:n=>n.some(e=>e)}),zd=I.define({combine:n=>n.some(e=>e)}),an=class n{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(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 n(L.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},sr=X.define({map:(n,e)=>n.map(e)});function He(n,e,t){let i=n.facet(Wh);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)}var Rr=I.define({combine:n=>n.length?n[0]:!0}),Fd=0,nn=I.define(),ye=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.extension=s(this)}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n(Fd++,e,i,r,l=>{let a=[nn.of(l)];return o&&a.push(yn.of(h=>{let c=h.plugin(l);return c?o(c):J.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define(i=>new e(i),t)}},hn=class{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(He(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(r){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){He(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){He(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Kh=I.define(),Zo=I.define(),yn=I.define(),Qo=I.define(),_h=I.define();function Ua(n,e,t){let i=n.state.facet(_h);if(!i.length)return i;let r=i.map(o=>o instanceof Function?o(n):o),s=[];return ie.spans(r,e,t,{point(){},span(o,l,a,h){let c=s;for(let f=a.length-1;f>=0;f--,h--){let u=a[f].spec.bidiIsolate,p;if(u!=null)if(h>0&&c.length&&(p=c[c.length-1]).to==o&&p.direction==u)p.to=l,c=p.inner;else{let g={from:o,to:l,direction:u,inner:[]};c.push(g),c=g.inner}}}}),s}var Gh=I.define();function Uh(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(Gh)){let o=s(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&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var rn=I.define(),ft=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(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 r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0,l=0;;r++){let a=r==e.length?null:e[r],h=o-l,c=a?a.fromB:1e9;for(;s<t.length&&t[s]<c;){let f=t[s],u=t[s+1],p=Math.max(l,f),g=Math.min(c,u);if(p<=g&&new n(p+h,g+h,p,g).addToSet(i),u>c)break;s+=2}if(!a)return i;new n(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}},xr=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=De.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new ft(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(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}},ge=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(ge||(ge={})),wn=ge.LTR,Yh=ge.RTL;function Jh(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var Hd=Jh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Vd=Jh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),vo=Object.create(null),at=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);vo[e]=t,vo[t]=-e}function Wd(n){return n<=247?Hd[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?Vd[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var jd=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,ct=class{get dir(){return this.level%2?Yh:wn}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Xh(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Xh(i.inner,r.inner))return!1}return!0}var le=[];function qd(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=Wd(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),le[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=le[h];if(u==128)h<l-1&&c==le[h+1]&&c&24?u=le[h]=c:le[h]=256;else if(u==64){let p=h+1;for(;p<l&&le[p]==64;)p++;let g=h&&c==8||p<t&&le[p]==8?f==1?1:8:256;for(let x=h;x<p;x++)le[x]=g;h=p-1}else u==8&&f==1&&(le[h]=1);c=u,u&7&&(f=u)}}}function $d(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,p,g;f<c;f++)if(p=vo[u=n.charCodeAt(f)])if(p<0){for(let x=l-3;x>=0;x-=3)if(at[x+1]==-p){let y=at[x+2],v=y&2?r:y&4?y&1?s:r:0;v&&(le[f]=le[at[x]]=v),l=x;break}}else{if(at.length==189)break;at[l++]=f,at[l++]=u,at[l++]=a}else if((g=le[f])==2||g==1){let x=g==r;a=x?0:1;for(let y=l-3;y>=0;y-=3){let v=at[y+2];if(v&2)break;if(x)at[y+2]|=2;else{if(v&4)break;at[y+2]|=4}}}}}function Kd(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=le[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(le[c]==256)c++;else break;let f=s==1,u=(c<e?le[c]:i)==1,p=f==u?f?1:2:i;for(let g=c,x=r,y=x?t[x-1].to:n;g>a;)g==y&&(g=t[--x].from,y=x?t[x-1].to:n),le[--g]=p;a=c}else s=h,a++}}}function So(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let x=le[a];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h<s.length&&g==s[h].from){if(f)break e;let x=s[h];if(!c)for(let y=x.to,v=h+1;;){if(y==t)break e;if(v<s.length&&s[v].from==y)y=s[v++].to;else{if(le[y]==l)break e;break}}if(h++,u)u.push(x);else{x.from>a&&o.push(new ct(a,x.from,p));let y=x.direction==wn!=!(p%2);Co(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.to}g=x.to}else{if(g==t||(c?le[g]!=l:le[g]==l))break;g++}u?So(n,a,g,i+1,r,u,o):a<g&&o.push(new ct(a,g,p)),a=g}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let x=le[a-1];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h&&g==s[h-1].to){if(f)break e;let x=s[--h];if(!c)for(let y=x.from,v=h;;){if(y==e)break e;if(v&&s[v-1].to==y)y=s[--v].from;else{if(le[y-1]==l)break e;break}}if(u)u.push(x);else{x.to<a&&o.push(new ct(x.to,a,p));let y=x.direction==wn!=!(p%2);Co(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.from}g=x.from}else{if(g==e||(c?le[g-1]!=l:le[g-1]==l))break;g--}u?So(n,g,a,i+1,r,u,o):g<a&&o.push(new ct(g,a,p)),a=g}}function Co(n,e,t,i,r,s,o){let l=e%2?2:1;qd(n,r,s,i,l),$d(n,r,s,i,l),Kd(r,s,i,l),So(n,r,s,e,t,i,o)}function _d(n,e,t){if(!n)return[new ct(0,0,e==Yh?1:0)];if(e==wn&&!t.length&&!jd.test(n))return Zh(n.length);if(t.length)for(;n.length>le.length;)le[le.length]=256;let i=[],r=e==wn?0:1;return Co(n,r,r,t,0,n.length,i),i}function Zh(n){return[new ct(0,n,0)]}var Qh="";function Gd(n,e,t,i,r){var s;let o=i.head-n.from,l=-1;if(o==0){if(!r||!n.length)return null;e[0].level!=t&&(o=e[0].side(!1,t),l=0)}else if(o==n.length){if(r)return null;let u=e[e.length-1];u.level!=t&&(o=u.side(!0,t),l=e.length-1)}l<0&&(l=ct.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc));let a=e[l];o==a.side(r,t)&&(a=e[l+=r?1:-1],o=a.side(!r,t));let h=r==(a.dir==t),c=be(n.text,o,h);if(Qh=n.text.slice(Math.min(o,c),Math.max(o,c)),c>a.from&&c<a.to)return L.cursor(c+n.from,h?-1:1,a.level);let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return!f&&a.level!=t?L.cursor(r?n.to:n.from,r?-1:1,t):f&&f.level<a.level?L.cursor(f.side(!r,t)+n.from,r?1:-1,f.level):L.cursor(c+n.from,r?-1:1,a.level)}var vr=class extends de{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.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 Ae],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ft(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})=>c<this.minWidthFrom||h>this.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 r=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!ep(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?Yd(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new ft(h,c,e.changes.mapPos(h,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(H.ie||H.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=Zd(o,l,e.changes);return i=ft.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=H.chrome||H.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Oi&&o.widget instanceof Sr&&s.push(o.dom);r.updateGaps(s)}updateChildren(e,t,i){let r=i?i.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=r.length-1;;o--){let l=o>=0?r[o]:null;if(!l)break;let{fromA:a,toA:h,fromB:c,toB:f}=l,u,p,g,x;if(i&&i.range.fromB<f&&i.range.toB>c){let R=ln.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),F=ln.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);p=R.breakAtStart,g=R.openStart,x=F.openEnd;let q=this.compositionView(i);F.breakAtStart?q.breakAfter=1:F.content.length&&q.merge(q.length,q.length,F.content[0],!1,F.openStart,0)&&(q.breakAfter=F.content[0].breakAfter,F.content.shift()),R.content.length&&q.merge(0,0,R.content[R.content.length-1],!0,0,R.openEnd)&&R.content.pop(),u=R.content.concat(q).concat(F.content)}else({content:u,breakAtStart:p,openStart:g,openEnd:x}=ln.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:y,off:v}=s.findPos(h,1),{i:M,off:O}=s.findPos(a,-1);Oh(this,M,O,y,v,u,p,g,x)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new It(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Nt(r,[t],t.length);let i=new Ae;return i.append(t,0),i}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=de.get(s);l&&l!=o&&(l.dom=null),o.setDOM(s)},i=this.childPos(e.range.fromB,1),r=this.children[i.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)i=r.childPos(i.off,1),r=r.children[i.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&dr(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||t||s))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(H.gecko&&l.empty&&!this.hasComposition&&Ud(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=h=new Oe(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||!kr(a.node,a.offset,c.anchorNode,c.anchorOffset)||!kr(h.node,h.offset,c.focusNode,c.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(c.focusNode)&&Qd(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=br(this.view.root);if(f)if(l.empty){if(H.gecko){let u=Jd(a.node,a.offset);if(u&&u!=3){let p=tc(a.node,a.offset,u==1?1:-1);p&&(a=new Oe(p.node,p.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)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new Oe(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new Oe(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=br(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=Ae.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(r,s)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let r=e.offset;!i&&r<t.childNodes.length;r++){let s=de.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(0))}for(let r=e.offset-1;!i&&r>=0;r--){let s=de.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(s.length))}return i?new Oe(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=de.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<this.children.length-1;){let r=this.children[t];if(i<r.length||r instanceof Ae)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,r=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],a=s-l.breakAfter,h=a-l.length;if(a<e)break;h<=e&&(h<e||l.covers(-1))&&(a>e||l.covers(1))&&(!i||l instanceof Ae&&!(i instanceof Ae&&t>=0))&&(i=l,r=h),s=h}return i?i.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Ae))return null;for(;r.children.length;){let{i:l,off:a}=r.childPos(i,1);for(;;l++){if(l==r.children.length)return null;if((r=r.children[l]).length)break}i=a}if(!(r instanceof It))return null;let s=be(r.text,i);if(s==i)return null;let o=ei(r.dom,i,s).getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(l==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ge.LTR;for(let h=0,c=0;c<this.children.length;c++){let f=this.children[c],u=h+f.length;if(u>r)break;if(h>=i){let p=f.dom.getBoundingClientRect();if(t.push(p.height),o){let g=f.dom.lastChild,x=g?dn(g):[];if(x.length){let y=x[x.length-1],v=a?y.right-p.left:p.right-y.left;v>l&&(l=v,this.minWidth=s,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"?ge.RTL:ge.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ae){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,r;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 s=dn(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new yr(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(J.replace({widget:new Sr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return J.set(e)}updateDeco(){let e=this.view.state.facet(yn).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=Uh(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;Ld(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ge.LTR)}};function Ud(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}var Sr=class extends et{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function ec(n,e){let t=n.observer.selectionRange,i=t.focusNode&&tc(t.focusNode,t.focusOffset,0);if(!i)return null;let r=e-i.offset;return{from:r,to:r+i.node.nodeValue.length,node:i.node}}function Yd(n,e,t){let i=ec(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc,h=new ft(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let f=r.parentNode;;f=f.parentNode){let u=de.get(f);if(u instanceof Nt)c.push({node:f,deco:u.mark});else{if(u instanceof Ae||f.nodeName=="DIV"&&f.parentNode==n.contentDOM)return{range:h,text:r,marks:c,line:f};if(f!=n.contentDOM)c.push({node:f,deco:new bn({inclusive:!0,attributes:Id(f),tagName:f.tagName.toLowerCase()})});else return null}}}function tc(n,e,t){if(t<=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r>0)i=i.childNodes[r-1],r=Tt(i);else break}if(t>=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r<i.childNodes.length&&t>=0)i=i.childNodes[r],r=0;else break}return null}function Jd(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var Xd=class{constructor(){this.changes=[]}compareRange(e,t){wo(e,t,this.changes)}comparePoint(e,t){wo(e,t,this.changes)}};function Zd(n,e,t){let i=new Xd;return ie.compare(n,e,t,i),i.changes}function Qd(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function ep(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}function tp(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return L.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=be(r.text,s,!1):l=be(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=be(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=be(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return L.range(o+r.from,l+r.from)}function ip(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function np(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function so(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function Ya(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function Ja(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function Ao(n,e,t){let i,r,s,o,l=!1,a,h,c,f;for(let g=n.firstChild;g;g=g.nextSibling){let x=dn(g);for(let y=0;y<x.length;y++){let v=x[y];r&&so(r,v)&&(v=Ya(Ja(v,r.bottom),r.top));let M=ip(e,v),O=np(t,v);if(M==0&&O==0)return g.nodeType==3?Xa(g,e,t):Ao(g,e,t);if(!i||o>O||o==O&&s>M){i=g,r=v,s=M,o=O;let R=O?t<v.top?-1:1:M?e<v.left?-1:1:0;l=!R||(R>0?y<x.length-1:y>0)}M==0?t>v.bottom&&(!c||c.bottom<v.bottom)?(a=g,c=v):t<v.top&&(!f||f.top>v.top)&&(h=g,f=v):c&&so(c,v)?c=Ja(c,v.bottom):f&&so(f,v)&&(f=Ya(f,v.top))}}if(c&&c.bottom>=t?(i=a,r=c):f&&f.top<=t&&(i=h,r=f),!i)return{node:n,offset:0};let u=Math.max(r.left,Math.min(r.right,e));if(i.nodeType==3)return Xa(i,u,t);if(l&&i.contentEditable!="false")return Ao(i,u,t);let p=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(r.left+r.right)/2?1:0);return{node:n,offset:p}}function Xa(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let a=ei(n,l,l+1).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(c.top==c.bottom)continue;o||(o=e-c.left);let f=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f<s){let u=e>=(c.left+c.right)/2,p=u;if((H.chrome||H.gecko)&&ei(n,l).getBoundingClientRect().left==c.right&&(p=!u),f<=0)return{node:n,offset:l+(p?1:0)};r=l+(p?1:0),s=f}}}return{node:n,offset:r>-1?r:o>0?n.nodeValue.length:0}}function ic(n,e,t,i=-1){var r,s;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 R=n.viewState.heightOracle.textHeight/2,F=!1;a=n.elementAtHeight(u),a.type!=Qe.Text;)for(;u=i>0?a.bottom+R:a.top-R,!(u>=0&&u<=h);){if(F)return t?null:0;F=!0,i=-i}f=l+u;let p=a.from;if(p<n.viewport.from)return n.viewport.from==0?0:t?null:Za(n,o,a,c,f);if(p>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:Za(n,o,a,c,f);let g=n.dom.ownerDocument,x=n.root.elementFromPoint?n.root:g,y=x.elementFromPoint(c,f);y&&!n.contentDOM.contains(y)&&(y=null),y||(c=Math.max(o.left+1,Math.min(o.right-1,c)),y=x.elementFromPoint(c,f),y&&!n.contentDOM.contains(y)&&(y=null));let v,M=-1;if(y&&((r=n.docView.nearest(y))===null||r===void 0?void 0:r.isEditable)!=!1){if(g.caretPositionFromPoint){let R=g.caretPositionFromPoint(c,f);R&&({offsetNode:v,offset:M}=R)}else if(g.caretRangeFromPoint){let R=g.caretRangeFromPoint(c,f);R&&({startContainer:v,startOffset:M}=R,(!n.contentDOM.contains(v)||H.safari&&rp(v,M,c)||H.chrome&&sp(v,M,c))&&(v=void 0))}}if(!v||!n.docView.dom.contains(v)){let R=Ae.find(n.docView,p);if(!R)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:M}=Ao(R.dom,c,f))}let O=n.docView.nearest(v);if(!O)return null;if(O.isWidget&&((s=O.dom)===null||s===void 0?void 0:s.nodeType)==1){let R=O.dom.getBoundingClientRect();return e.y<R.top||e.y<=R.bottom&&e.x<=(R.left+R.right)/2?O.posAtStart:O.posAtEnd}else return O.localPosFromDOM(v,M)+O.posAtStart}function Za(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Na(o,s,n.state.tabSize)}function rp(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let r=n.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return ei(n,i-1,i).getBoundingClientRect().left>t}function sp(n,e,t){if(e!=0)return!1;for(let r=n;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let i=n.nodeType==1?n.getBoundingClientRect():ei(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function op(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==Qe.Text))return i}return t}function lp(n,e,t,i){let r=op(n,e.head),s=!i||r.type!=Qe.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==ge.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return L.cursor(a,t?-1:1)}return L.cursor(t?r.to:r.from,t?-1:1)}function Qa(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let h=Gd(r,s,o,l,t),c=Qh;if(!h){if(r.number==(t?n.state.doc.lines:1))return l;c=`
8
- `,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),h=L.cursor(t?r.from:r.to)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function ap(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==ue.Space&&(r=o),r==o}}function hp(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return L.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(r,e.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=i!=null?i:n.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let g=l+(u+p)*s,x=ic(n,{x:f,y:g},!1,s);if(g<a.top||g>a.bottom||(s<0?x<r:x>r)){let y=n.docView.coordsForChar(x),v=!y||g<y.top?-1:1;return L.cursor(x,v,void 0,o)}}}function pr(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||t||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function oo(n,e,t){let i=pr(n.state.facet(Qo).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:L.cursor(i,i<t.from?1:-1)}var To=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,H.safari&&e.contentDOM.addEventListener("input",()=>null),H.gecko&&Cp(e.contentDOM.ownerDocument)}handleEvent(e){!gp(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 r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=cp(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&rc.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),H.android&&H.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return H.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=nc.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||fp.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(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,Di(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:H.safari&&!H.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 eh(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){He(t.state,r)}}}function cp(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(eh(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(eh(i.value,o))}}for(let i in tt)t(i).handlers.push(tt[i]);for(let i in it)t(i).observers.push(it[i]);return e}var nc=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],fp="dthko",rc=[16,17,18,20,91,92,224,225],or=6;function lr(n){return Math.max(0,n)*.7+8}function up(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var Mo=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=Dd(e.contentDOM),this.atoms=e.state.facet(Qo).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(oe.allowMultipleSelections)&&dp(e,t),this.dragging=mp(e,t)&&ac(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&&up(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,r=0,s=((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=Uh(this.view);e.clientX-o.left<=s.left+or?i=-lr(s.left-e.clientX):e.clientX+o.right>=s.right-or&&(i=lr(e.clientX-s.right)),e.clientY-o.top<=s.top+or?r=-lr(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-or&&(r=lr(e.clientY-s.bottom)),this.setScrollSpeed(i,r)}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;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=pr(this.atoms,r.from,0);o!=r.from&&(s=L.cursor(o,-1))}else{let o=pr(this.atoms,r.from,-1),l=pr(this.atoms,r.to,1);(o!=r.from||l!=r.to)&&(s=L.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?L.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection)||i.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function dp(n,e){let t=n.state.facet(Fh);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function pp(n,e){let t=n.state.facet(Hh);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function mp(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=br(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function gp(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=de.get(t))&&i.ignoreEvent(e))return!1;return!0}var tt=Object.create(null),it=Object.create(null),sc=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function bp(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(),oc(n,t.value)},50)}function oc(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Lo!=null&&t.selection.ranges.every(a=>a.empty)&&Lo==s.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?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:L.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:L.cursor(a.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}it.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};tt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);it.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};it.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};tt.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(Vh))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=wp(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Mo(n,e,t,i)),i&&n.observer.ignore(()=>Mh(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function th(n,e,t,i){if(i==1)return L.cursor(e,t);if(i==2)return tp(n.state,e,t);{let r=Ae.find(n.docView,e),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,L.range(o,l)}}var lc=(n,e)=>n>=e.top&&n<=e.bottom,ih=(n,e,t)=>lc(e,t)&&n>=t.left&&n<=t.right;function kp(n,e,t,i){let r=Ae.find(n.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&ih(t,i,o))return-1;let l=r.coordsAt(s,1);return l&&ih(t,i,l)?1:o&&lc(i,o)?-1:1}function nh(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:kp(n,t,e.clientX,e.clientY)}}var yp=H.ie&&H.ie_version<=11,rh=null,sh=0,oh=0;function ac(n){if(!yp)return n.detail;let e=rh,t=oh;return rh=n,oh=Date.now(),sh=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(sh+1)%3:1}function wp(n,e){let t=nh(n,e),i=ac(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=nh(n,s),h,c=th(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=th(n,t.pos,t.bias,i),u=Math.min(f.from,c.from),p=Math.max(f.to,c.to);c=u<c.from?L.range(u,p):L.range(p,u)}return o?r.replaceRange(r.main.extend(c.from,c.to)):l&&i==1&&r.ranges.length>1&&(h=xp(r,a.pos))?h:l?r.addRange(c):L.create([c])}}}function xp(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return L.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}tt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=L.range(s,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};tt.dragend=n=>(n.inputState.draggedContent=null,!1);function lh(n,e,t,i){if(!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&pp(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}tt.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),r=0,s=()=>{++r==t.length&&lh(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return lh(n,e,i,!0),!0}return!1};tt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=sc?null:e.clipboardData;return t?(oc(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(bp(n),!1)};function vp(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 Sp(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}var Lo=null;tt.copy=tt.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=Sp(n.state);if(!t&&!r)return!1;Lo=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=sc?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(vp(n,t),!1)};var hc=Ne.define();function cc(n,e){let t=[];for(let i of n.facet(qh)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:hc.of(!0)}):null}function fc(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=cc(n.state,e);t?n.dispatch(t):n.update([])}},10)}it.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),fc(n)};it.blur=n=>{n.observer.clearSelectionRange(),fc(n)};it.compositionstart=it.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};it.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,H.chrome&&H.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};it.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};tt.beforeinput=(n,e)=>{var t;let i;if(H.chrome&&H.android&&(i=nc.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return!1};var ah=new Set;function Cp(n){ah.has(n)||(ah.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var hh=["pre-wrap","normal","pre-line","break-spaces"],Do=class{constructor(e){this.lineWrapping=e,this.doc=Q.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 hh.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=hh.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},Oo=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},ht=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof zt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ce=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(ce||(ce={})),mr=.001,Ve=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>mr&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,ce.ByPosNoHeight,i.setDoc(t),0,0),p=u.to>=h?u:s.lineAt(h,ce.ByPosNoHeight,i,0,0);for(f+=p.to-h,h=p.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,ce.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let g=Bo.build(i.setDoc(o),e,c,f);s=s.replace(a,h,g)}return s.updateHeight(i,0)}static empty(){return new _e(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*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,r-=l.size}else if(s>r*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,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Eo(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};Ve.prototype.size=1;var Cr=class extends Ve{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,r){return new ht(r,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,r,s){return this.blockAt(0,i,r,s)}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,i,r,s))}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},_e=class n extends Cr{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new ht(r,this.length,i,this.height,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof Rt&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Rt?r=new n(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ve.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.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:""})`}},Rt=class n extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new ht(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(s+h);return new ht(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==ce.ByHeight)return this.blockAt(e,i,r,s);if(t==ce.ByPosNoHeight){let{from:p,to:g}=i.doc.lineAt(e);return new ht(p,g-p,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new ht(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,s);for(let c=e,f=r;c<=t;){let u=i.doc.lineAt(c);if(c==e){let g=u.number-l;f+=a*g+h*(e-s-g)}let p=a+h*u.length;o(new ht(u.from,u.length,f,p,0)),f+=p,c=u.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++];a==-1?a=f:Math.abs(f-a)>=mr&&(a=-2);let u=new _e(c,f);u.outdated=!1,o.push(u),l+=c+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let h=Ve.of(o);return(a<0||Math.abs(h.height-this.height)>=mr||Math.abs(a-this.heightMetrics(e,t).perLine)>=mr)&&(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})`}},Eo=class extends Ve{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,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ce.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==ce.ByPosNoHeight?ce.ByPosNoHeight:ce.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(h)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,ce.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=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 r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&ch(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),ch(s,l)}return Ve.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ve.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,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function ch(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Rt&&(i=n[e+1])instanceof Rt&&n.splice(e-1,3,new Rt(t.length+1+i.length))}var Ap=5,Bo=class n{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),r=this.nodes[this.nodes.length-1];r instanceof _e?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new _e(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<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Cr(o,r,i)):(o||s||r>=Ap)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _e(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new Rt(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 _e)return e;let t=new _e(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 r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.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 _e)&&!this.isCovered?this.nodes.push(new _e(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof _e&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return ie.spans(t,i,r,s,0),s.finish(i)}};function Tp(n,e,t){let i=new Po;return ie.compare(n,e,t,i,0),i.changes}var Po=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&wo(e,t,this.changes,5)}};function Mp(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,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:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Lp(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var cn=class{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;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return J.replace({widget:new Ro(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Ro=class extends et{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Ar=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=fh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ge.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Zo).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Do(t),this.stateDeco=e.facet(yn).filter(i=>typeof i!="function"),this.heightMap=Ve.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle.setDoc(e.doc),[new ft(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=J.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 r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Ti(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?fh:new Io(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:sn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(yn).filter(c=>typeof c!="function");let r=e.changedRanges,s=ft.extendWithRanges(r,Tp(i,this.stateDeco,e?e.changes:De.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),s),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=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.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(zd)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ge.RTL:ge.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),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:R,scaleY:F}=Th(t,l);(this.scaleX!=R||this.scaleY!=F)&&(this.scaleX=R,this.scaleY=F,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&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=Dh(e.scrollDOM);let g=(this.printing?Lp:Mp)(t,this.paddingTop),x=g.top-this.pixelViewport.top,y=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let M=l.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let R=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(R)&&(o=!0),o||r.lineWrapping&&Math.abs(M-this.contentDOMWidth)>r.charWidth){let{lineHeight:F,charWidth:q,textHeight:w}=e.docView.measureTextSize();o=F>0&&r.refresh(s,F,q,w,M/q,R),o&&(e.docView.minWidth=0,h|=8)}x>0&&y>0?c=Math.max(x,y):x<0&&y<0&&(c=Math.min(x,y)),r.heightChanged=!1;for(let F of this.viewports){let q=F.from==this.viewport.from?R:e.docView.measureVisibleLineHeights(F);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle,[new ft(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Oo(F.from,q))}r.heightChanged&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||O)&&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)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Ti(r.lineAt(o-i*1e3,ce.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ce.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,ce.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new Ti(r.lineAt(u-1e3/2,ce.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,ce.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Ti(this.heightMap.lineAt(i,ce.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ce.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ce.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new cn(t.mapPos(r.from),t.mapPos(r.to),r.size));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=ge.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-h<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let y of g)if(y>h&&y<c){a(h,y-10,f,u),a(y+10,c,f,u);return}let x=Op(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)<s&&Math.abs(y.to-c)<s&&!g.some(v=>y.from<v&&y.to>v));if(!x){if(c<f.to&&t&&i&&t.visibleRanges.some(y=>y.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(L.cursor(c),!1,!0).head;y>h&&(c=y)}x=new cn(h,c,this.gapSize(f,h,c,u))}l.push(x)};for(let h of this.viewportLines){if(h.length<o)continue;let c=Dp(h.from,h.to,this.stateDeco);if(c.total<o)continue;let f=this.scrollTarget?this.scrollTarget.range.head:null,u,p;if(i){let g=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(f!=null){let v=hr(c,f),M=((this.visibleBottom-this.visibleTop)/2+g)/h.height;x=v-M,y=v+M}else x=(this.visibleTop-h.top-g)/h.height,y=(this.visibleBottom-h.top+g)/h.height;u=ar(c,x),p=ar(c,y)}else{let g=c.total*this.heightOracle.charWidth,x=r*this.heightOracle.charWidth,y,v;if(f!=null){let M=hr(c,f),O=((this.pixelViewport.right-this.pixelViewport.left)/2+x)/g;y=M-O,v=M+O}else y=(this.pixelViewport.left-x)/g,v=(this.pixelViewport.right+x)/g;u=ar(c,y),p=ar(c,v)}u>h.from&&a(h.from,u,h,c),p<h.to&&a(p,h.to,h,c)}return l}gapSize(e,t,i,r){let s=hr(r,i)-hr(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){cn.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=J.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];ie.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].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)||sn(this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return sn(this.heightMap.lineAt(this.scaler.fromDOM(e),ce.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 sn(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}},Ti=class{constructor(e,t){this.from=e,this.to=t}};function Dp(n,e,t){let i=[],r=n,s=0;return ie.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function ar({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function hr(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Op(n,e){for(let t of n)if(e(t))return t}var fh={toDOM(n){return n},fromDOM(n){return n},scale:1},Io=class{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,ce.ByPos,e,0,0).top,c=t.lineAt(a,ce.ByPos,e,0,0).bottom;return r+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}};function sn(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new ht(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>sn(r,e)):n._content)}var cr=I.define({combine:n=>n.join(" ")}),No=I.define({combine:n=>n.indexOf(!0)>-1}),zo=Ke.newName(),uc=Ke.newName(),dc=Ke.newName(),pc={"&light":"."+uc,"&dark":"."+dc};function Fo(n,e,t){return new Ke(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var Ep=Fo("."+zo,{"&":{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-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},pc),on="\uFFFF",Ho=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(oe.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=on}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let l=de.get(r),a=de.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:uh(r))||uh(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=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,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<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=s+o}}readNode(e){if(e.cmIgnore)return;let t=de.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.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+(Bp(e,i.node,i.offset)?t:0))}};function Bp(n,e,t){for(;;){if(!e||t<Tt(e))return!1;if(e==n)return!0;t=pn(e)+1,e=e.parentNode}}function uh(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}var Tr=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Vo=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=s||o?[]:Ip(e),a=new Ho(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Np(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!uo(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||!uo(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=L.single(h,a)}}};function mc(n,e){let t,{newSel:i}=e,r=n.state.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=r.from,h=null;(s===8||H.android&&e.text.length<l-o)&&(a=r.to,h="end");let c=Rp(n.state.doc.sliceString(o,l,on),e.text,a-o,h);c&&(H.chrome&&s==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==on+on&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:Q.of(e.text.slice(c.from,c.toB).split(on))})}else i&&(!n.hasFocus&&n.state.facet(Rr)||i.main.eq(r))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!r.empty&&i&&i.main.empty?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,r.to))}:(H.mac||H.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Q.of([" "])}):H.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
9
- `&&n.lineWrapping&&(i&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Q.of([" "])}),t){if(H.ios&&n.inputState.flushIOSKey()||H.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&Di(n.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&Di(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Di(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,a=()=>l||(l=Pp(n,t,i));return n.state.facet(jh).some(h=>h(n,t.from,t.to,o,a))||n.dispatch(a()),!0}else if(i&&!i.main.eq(r)){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 Pp(n,e,t){let i,r=n.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+a))}else{let l=r.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),c,f=t&&ec(n,t.main.head);if(f){let g=e.insert.length-(e.to-e.from);c={from:f.from,to:f.to-g}}else c=n.state.doc.lineAt(s.head);let u=s.to-e.to,p=s.to-s.from;i=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:l,range:a||g.map(l)};let x=g.to-u,y=x-h.length;if(g.to-g.from!=p||n.state.sliceDoc(y,x)!=h||g.to>=c.from&&g.from<=c.to)return{range:g};let v=r.changes({from:y,to:x,insert:e.insert}),M=g.to-s.to;return{changes:v,range:a?L.range(Math.max(0,a.anchor+M),Math.max(0,a.head+M)):g.map(v)}})}else i={changes:l,selection:a&&r.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)),r.update(i,{userEvent:o,scrollIntoView:!0})}function Rp(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Ip(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Tr(t,i)),(r!=t||s!=i)&&e.push(new Tr(r,s))),e}function Np(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?L.single(t+e,i+e):null}var zp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},lo=H.ie&&H.ie_version<=11,Wo=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new po,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.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(H.ie&&H.ie_version<=11||H.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()}),lo&&(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),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{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(){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,r=this.selectionRange;if(i.state.facet(Rr)?i.root.activeElement!=this.dom:!dr(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!i.state.selection.main.empty&&r.focusNode&&kr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=H.safari&&e.root.nodeType==11&&Td(this.dom.ownerDocument)==this.dom&&Fp(this.view)||br(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=dr(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Ed(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,zp),lo&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),lo&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Di(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){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,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!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:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&dr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Vo(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}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,r=mc(this.view,t);return this.view.state==i&&this.view.update([]),r}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=dh(t,e.previousSibling||e.target.previousSibling,-1),r=dh(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):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),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),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 r of this.scrollTargets)r.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 dh(n,e,t){for(;e;){let i=de.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Fp(n){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return kr(l.node,l.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}var z=class n{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);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(r=>t(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Od(e.parent)||document,this.viewState=new Ar(e.state||oe.create(e)),e.scrollTo&&e.scrollTo.is(sr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(nn).map(i=>new hn(i));for(let i of this.plugins)i.update(this);this.observer=new Wo(this),this.inputState=new To(this),this.inputState.ensureHandlers(this.plugins),this.docView=new vr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}dispatch(...e){let t=e.length==1&&e[0]instanceof xe?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,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(hc))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=cc(s,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(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(oe.phrases)!=this.state.facet(oe.phrases))return this.setState(s);r=xr.create(this,s,e),r.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:p}=u.state.selection;f=new an(p.empty?p:L.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of u.effects)p.is(sr)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Mr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(rn)!=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(r.startState.facet(cr)!=r.state.facet(cr)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let u of this.state.facet(xo))try{u(r)}catch(p){He(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!mc(this,c)&&h.force&&Di(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 Ar(e),this.plugins=e.facet(nn).map(i=>new hn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new vr(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(nn),i=e.state.facet(nn);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new hn(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-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,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Dh(i))s=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.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(p=>{try{return p.read(this)}catch(g){return He(this.state,g),ph}}),f=xr.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));for(let p=0;p<h.length;p++)if(c[p]!=ph)try{let g=h[p];g.write&&g.write(c[p],this)}catch(g){He(this.state,g)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let g=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(g>1||g<-1){r=r+g,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(xo))l(t)}get themeClasses(){return zo+" "+(this.state.facet(No)?dc:uc)+" "+this.state.facet(cr)}updateAttrs(){let e=mh(this,Kh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Rr)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),mh(this,Zo,t);let i=this.observer.ignore(()=>{let r=yo(this.contentDOM,this.contentAttrs,t),s=yo(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(rn);let e=this.state.facet(n.cspNonce);Ke.mount(this.root,this.styleModules.concat(Ep).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;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.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 oo(this,e,Qa(this,e,t,i))}moveByGroup(e,t){return oo(this,e,Qa(this,e,t,i=>ap(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return lp(this,e,t,i)}moveVertically(e,t,i){return oo(this,e,hp(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(),ic(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 r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[ct.find(s,e-r.from,-1,t)];return Yo(i,o.dir==ge.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($h)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Hp)return Zh(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Xh(s.isolates,i=Ua(this,e.from,e.to))))return s.order;i||(i=Ua(this,e.from,e.to));let r=_d(e.text,t,i);return this.bidiCache.push(new Mr(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Mh(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 sr.of(new an(typeof e=="number"?L.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 sr.of(new an(L.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return ye.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ye.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Ke.newName(),r=[cr.of(i),rn.of(Fo(`.${i}`,e))];return t&&t.dark&&r.push(No.of(!0)),r}static baseTheme(e){return Et.lowest(rn.of(Fo("."+zo,e,pc)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&de.get(i)||de.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}};z.styleModule=rn;z.inputHandler=jh;z.focusChangeEffect=qh;z.perLineTextDirection=$h;z.exceptionSink=Wh;z.updateListener=xo;z.editable=Rr;z.mouseSelectionStyle=Vh;z.dragMovesSelection=Hh;z.clickAddsSelectionRange=Fh;z.decorations=yn;z.atomicRanges=Qo;z.bidiIsolatedRanges=_h;z.scrollMargins=Gh;z.darkTheme=No;z.cspNonce=I.define({combine:n=>n.length?n[0]:""});z.contentAttributes=Zo;z.editorAttributes=Kh;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=X.define();var Hp=4096,ph={},Mr=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ge.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function mh(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&ko(o,t)}return t}var Vp=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Wp(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function fr(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var jp=Et.default(z.domEventHandlers({keydown(n,e){return kc(gc(e.state),n,e,"editor")}})),Ir=I.define({enables:jp}),gh=new WeakMap;function gc(n){let e=n.facet(Ir),t=gh.get(e);return t||gh.set(e,t=$p(e.reduce((i,r)=>i.concat(r),[]))),t}function bc(n,e,t){return kc(gc(n.state),e,n,t)}var Pt=null,qp=4e3;function $p(n,e=Vp){let t=Object.create(null),i=Object.create(null),r=(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")},s=(o,l,a,h,c)=>{var f,u;let p=t[o]||(t[o]=Object.create(null)),g=l.split(/ (?!$)/).map(v=>Wp(v,e));for(let v=1;v<g.length;v++){let M=g.slice(0,v).join(" ");r(M,!0),p[M]||(p[M]={preventDefault:!0,stopPropagation:!1,run:[O=>{let R=Pt={view:O,prefix:M,scope:o};return setTimeout(()=>{Pt==R&&(Pt=null)},qp),!0}]})}let x=g.join(" ");r(x,!1);let y=p[x]||(p[x]={preventDefault:!1,stopPropagation:!1,run:((u=(f=p._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&y.run.push(a),h&&(y.preventDefault=!0),c&&(y.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)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}function kc(n,e,t,i){let r=Va(e),s=$e(r,0),o=St(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;Pt&&Pt.view==t&&Pt.scope==i&&(l=Pt.prefix+" ",rc.indexOf(e.keyCode)<0&&(h=!0,Pt=null));let f=new Set,u=y=>{if(y){for(let v of y.run)if(!f.has(v)&&(f.add(v),v(t,e)))return y.stopPropagation&&(c=!0),!0;y.preventDefault&&(y.stopPropagation&&(c=!0),h=!0)}return!1},p=n[i],g,x;return p&&(u(p[l+fr(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&(g=At[e.keyCode])&&g!=r?(u(p[l+fr(g,e,!0)])||e.shiftKey&&(x=Ci[e.keyCode])!=r&&x!=g&&u(p[l+fr(x,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(p[l+fr(r,e,!0)])&&(a=!0),!a&&u(p._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),a}var Kp=!H.ios;var bh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Kp&&(bh[".cm-line"].caretColor="transparent !important",bh[".cm-content"]={caretColor:"transparent !important"});function kh(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function _p(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:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}var xn=class{constructor(e){let{regexp:t,decoration:i,decorate:r,boundary:s,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,r)this.addMatch=(l,a,h,c)=>r(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=s,this.maxLength=o}createDeco(e){let t=new lt,i=t.add.bind(t);for(let{from:r,to:s}of _p(e,this.maxLength))kh(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(i=Math.min(l,i),r=Math.max(a,r))}),e.viewportChanged||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),l=Math.min(s.to,r);if(l>o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(s.from,a.from),f=Math.min(s.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],p,g=(x,y,v)=>u.push(v.range(x,y));if(a==h)for(this.regexp.lastIndex=c-a.from;(p=this.regexp.exec(a.text))&&p.index<f-a.from;)this.addMatch(p,e,p.index+a.from,g);else kh(e.state.doc,this.regexp,c,f,(x,y)=>this.addMatch(y,e,x,g));t=t.update({filterFrom:c,filterTo:f,filter:(x,y)=>x<c||y>f,add:u})}}return t}},jo=/x/.unicode!=null?"gu":"g",Gp=new RegExp(`[\0-\b
10
- -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,jo),Up={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"},ao=null;function Yp(){var n;if(ao==null&&typeof document!="undefined"&&document.body){let e=document.body.style;ao=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return ao||!1}var gr=I.define({combine(n){let e=ze(n,{render:null,specialChars:Gp,addSpecialChars:null});return(e.replaceTabs=!Yp())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,jo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,jo)),e}});function yc(n={}){return[gr.of(n),Jp()]}var yh=null;function Jp(){return yh||(yh=ye.fromClass(class{constructor(n){this.view=n,this.decorations=J.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(gr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new xn({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=$e(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=Bt(o.text,l,i-o.from);return J.replace({widget:new $o((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=J.replace({widget:new qo(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(gr);n.startState.facet(gr)!=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}))}var Xp="\u2022";function Zp(n){return n>=32?Xp:n==10?"\u2424":String.fromCharCode(9216+n)}var qo=class extends et{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Zp(this.code),i=e.state.phrase("Control character")+" "+(Up[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}},$o=class extends et{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 wc(){return em}var Qp=J.line({class:"cm-activeLine"}),em=ye.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 r=n.lineBlockAt(i.head);r.from>e&&(t.push(Qp.range(r.from)),e=r.from)}return J.set(t)}},{decorations:n=>n.decorations});var tn="-10000px",Lr=class{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r),this.tooltipViews=this.tooltips.map(i)}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<s.length;a++){let h=s[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(a.dom.remove(),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function tm(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var ho=I.define({combine:n=>{var e,t,i;return{position:H.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||tm}}}),wh=new WeakMap,xc=ye.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(ho);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.manager=new Lr(n,vn,t=>this.createTooltip(t)),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(ho);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.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 r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=tn,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(n=t.destroy)===null||n===void 0||n.call(t);this.parent&&this.container.remove(),(e=this.intersectionObserver)===null||e===void 0||e.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:r}=this.manager.tooltipViews[0];if(H.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(this.view.scaleX!=1||this.view.scaleY!=1)i=!0;else if(r.style.top==tn&&r.style.left=="0px"){let s=r.getBoundingClientRect();i=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(i||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(e=r.width/this.parent.offsetWidth,t=r.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((r,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(ho).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:r,scaleY:s}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=n.pos[l],u=n.size[l];if(!f||f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1){c.style.top=tn;continue}let p=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,x=u.right-u.left,y=(e=wh.get(h))!==null&&e!==void 0?e:u.bottom-u.top,v=h.offset||nm,M=this.view.textDirection==ge.LTR,O=u.width>i.right-i.left?M?i.left:i.right-u.width:M?Math.min(f.left-(p?14:0)+v.x,i.right-x):Math.max(i.left,f.left-x+(p?14:0)-v.x),R=this.above[l];!a.strictSide&&(R?f.top-(u.bottom-u.top)-v.y<i.top:f.bottom+(u.bottom-u.top)+v.y>i.bottom)&&R==i.bottom-f.bottom>f.top-i.top&&(R=this.above[l]=!R);let F=(R?f.top-i.top:i.bottom-f.bottom)-g;if(F<y&&h.resize!==!1){if(F<this.view.defaultLineHeight){c.style.top=tn;continue}wh.set(h,y),c.style.height=(y=F)/s+"px"}else c.style.height&&(c.style.height="");let q=R?f.top-y-g-v.y:f.bottom+g+v.y,w=O+x;if(h.overlap!==!0)for(let D of o)D.left<w&&D.right>O&&D.top<q+y&&D.bottom>q&&(q=R?D.top-y-2-g:D.bottom+g+2);if(this.position=="absolute"?(c.style.top=(q-n.parent.top)/s+"px",c.style.left=(O-n.parent.left)/r+"px"):(c.style.top=q/s+"px",c.style.left=O/r+"px"),p){let D=f.left+(M?v.x:-v.x)-(O+14-7);p.style.left=D/r+"px"}h.overlap!==!0&&o.push({left:O,top:q,right:w,bottom:q+y}),c.classList.toggle("cm-tooltip-above",R),c.classList.toggle("cm-tooltip-below",!R),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=tn}},{eventObservers:{scroll(){this.maybeMeasure()}}}),im=z.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"}}}),nm={x:0,y:0},vn=I.define({enables:[xc,im]}),Dr=I.define(),Or=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Lr(e,Dr,t=>this.createHostedView(t))}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}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 r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)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")}},rm=vn.compute([Dr],n=>{let e=n.facet(Dr).filter(t=>t);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:Or.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Ko=class{constructor(e,t,i,r,s){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=s,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)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let r,s=1;if(i instanceof mn)r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let l=e.coordsAtPos(r);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),h=a&&a.dir==ge.RTL?-1:1;s=t.x<l.left?-h:h}let o=this.source(e,r,s);if(o!=null&&o.then){let l=this.pending={pos:r};o.then(a=>{this.pending==l&&(this.pending=null,a&&e.dispatch({effects:this.setHover.of(a)}))},a=>He(e.state,a,"hover tooltip"))}else o&&e.dispatch({effects:this.setHover.of(o)})}get tooltip(){let e=this.view.plugin(xc),t=e?e.manager.tooltips.findIndex(i=>i.create==Or.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t;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:i,tooltip:r}=this;if(i&&r&&!sm(r.dom,e)||this.pending){let{pos:s}=i||this.pending,o=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!om(this.view,s,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},ur=4;function sm(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-ur&&e.clientX<=t.right+ur&&e.clientY>=t.top-ur&&e.clientY<=t.bottom+ur}function om(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=n.posAtCoords({x:i,y:r},!1);return a>=e&&a<=t}function vc(n,e={}){let t=X.define(),i=me.define({create(){return null},update(r,s){if(r&&(e.hideOnChange&&(s.docChanged||s.selection)||e.hideOn&&e.hideOn(s,r)))return null;if(r&&s.docChanged){let o=s.changes.mapPos(r.pos,-1,Ce.TrackDel);if(o==null)return null;let l=Object.assign(Object.create(null),r);l.pos=o,r.end!=null&&(l.end=s.changes.mapPos(r.end)),r=l}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(lm)&&(r=null);return r},provide:r=>Dr.from(r)});return[i,ye.define(r=>new Ko(r,n,i,t,e.hoverTime||300)),rm]}var lm=X.define();var xh=I.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 ii(n,e){let t=n.plugin(Sc),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var Sc=ye.fromClass(class{constructor(n){this.input=n.state.facet(ti),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(xh);this.top=new Mi(n,!0,e.topContainer),this.bottom=new Mi(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(xh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Mi(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Mi(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(ti);if(t!=this.input){let i=t.filter(a=>a),r=[],s=[],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)),r.push(c),(c.top?s:o).push(c)}this.specs=i,this.panels=r,this.top.sync(s),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=>z.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Mi=class{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=vh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=vh(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 vh(n){let e=n.nextSibling;return n.remove(),e}var ti=I.define({enables:Sc}),Ge=class extends Ze{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Ge.prototype.elementClass="";Ge.prototype.toDOM=void 0;Ge.prototype.mapMode=Ce.TrackBefore;Ge.prototype.startSide=Ge.prototype.endSide=-1;Ge.prototype.point=!0;var co=I.define(),am={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},fn=I.define();function el(n){return[Cc(),fn.of(Object.assign(Object.assign({},am),n))]}var _o=I.define({combine:n=>n.some(e=>e)});function Cc(n){let e=[hm];return n&&n.fixed===!1&&e.push(_o.of(!0)),e}var hm=ye.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(fn).map(e=>new Er(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(_o),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+"px"),this.view.state.facet(_o)!=!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=ie.iter(this.view.state.facet(co),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Uo(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Qe.Text&&o){Go(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Qe.Text){Go(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(fn),t=n.state.facet(fn),i=n.docChanged||n.heightChanged||n.viewportChanged||!ie.eq(n.startState.facet(co),n.state.facet(co),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Er(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==ge.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function Sh(n){return Array.isArray(n)?n:[n]}function Go(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var Uo=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ie.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Br(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Go(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}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()}}},Er=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=Sh(t.markers(e)),t.initialSpacer&&(this.spacer=new Br(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=Sh(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!ie.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()}},Br=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),cm(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function cm(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var fm=I.define(),Li=I.define({combine(n){return ze(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return i}})}}),un=class extends Ge{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function fo(n,e){return n.state.facet(Li).formatNumber(e,n.state)}var um=fn.compute([Li],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(fm)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new un(fo(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Li)!=e.state.facet(Li),initialSpacer(e){return new un(fo(e,Ch(e.state.doc.lines)))},updateSpacer(e,t){let i=fo(t.view,Ch(t.view.state.doc.lines));return i==e.number?e:new un(i)},domEventHandlers:n.facet(Li).domEventHandlers}));function Ac(n={}){return[Li.of(n),Cc(),um]}function Ch(n){let e=9;for(;e<n;)e=e*10+9;return e}var Ah=new Map;function dm(n){let e=Ah.get(n);return e||Ah.set(n,e=J.mark({attributes:n===" "?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":n.replace(/ /g,"\xB7")}})),e}function Tc(n){return ye.define(e=>({decorations:n.createDeco(e),update(t){this.decorations=n.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}var pm=Tc(new xn({regexp:/\t| +/g,decoration:n=>dm(n[0]),boundary:/\S/}));function Mc(){return pm}var mm=Tc(new xn({regexp:/\s+$/g,decoration:J.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function Lc(){return mm}var gm=0,Sn=class{constructor(e,t){this.from=e,this.to=t}},Z=class{constructor(e={}){this.id=gm++,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=Ee.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};Z.closedBy=new Z({deserialize:n=>n.split(" ")});Z.openedBy=new Z({deserialize:n=>n.split(" ")});Z.group=new Z({deserialize:n=>n.split(" ")});Z.contextHash=new Z({perNode:!0});Z.lookAhead=new Z({perNode:!0});Z.mounted=new Z({perNode:!0});var Ei=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[Z.mounted.id]}},bm=Object.create(null),Ee=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):bm,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}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(Z.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 r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(Z.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};Ee.none=new Ee("",Object.create(null),0,8);var Fr=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);o&&(r||(r=Object.assign({},i.props)),r[o[0].id]=o[1])}t.push(r?new Ee(i.name,r,i.id,i.flags):i)}return new n(t)}},Nr=new WeakMap,Dc=new WeakMap,ve;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(ve||(ve={}));var pe=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Ei.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Tn(this.topNode,e)}cursorAt(e,t=0,i=0){let r=Nr.get(this)||this.topNode,s=new Tn(r);return s.moveTo(e,t),Nr.set(this,s._tree),s}get topNode(){return new ut(this,0,0,null)}resolve(e,t=0){let i=Cn(Nr.get(this)||this.topNode,e,t,!1);return Nr.set(this,i),i}resolveInner(e,t=0){let i=Cn(Dc.get(this)||this.topNode,e,t,!0);return Dc.set(this,i),i}resolveStack(e,t=0){return km(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&ve.IncludeAnonymous)>0;for(let a=this.cursor(o|ve.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!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:ll(Ee.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Ee.none,t,i,r)))}static build(e){return ym(e)}};pe.empty=new pe(Ee.none,[],[],0);var tl=class n{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 n(this.buffer,this.index)}},Ft=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Ee.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Bc(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let h=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,h)}return new n(s,o,this.set)}};function Bc(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Cn(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof ut&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:ve.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof ut&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var Hr=class{cursor(e=0){return new Tn(this,e)}getChild(e,t=null,i=null){let r=Oc(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Oc(this,e,t,i)}resolve(e,t=0){return Cn(this,e,t,!1)}resolveInner(e,t=0){return Cn(this,e,t,!0)}matchContext(e){return il(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},ut=class n extends Hr{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from;if(Bc(r,i,f,f+c.length)){if(c instanceof Ft){if(s&ve.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,r);if(u>-1)return new An(new nl(o,c,e,f),null,u)}else if(s&ve.IncludeAnonymous||!c.type.isAnonymous||ol(c)){let u;if(!(s&ve.IgnoreMounts)&&(u=Ei.get(c))&&!u.overlay)return new n(u.tree,f,e,o);let p=new n(c,f,e,o);return s&ve.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(s&ve.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 r;if(!(i&ve.IgnoreOverlays)&&(r=Ei.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:l}of r.overlay)if((t>0?o<=s:o<s)&&(t<0?l>=s:l>s))return new n(r.tree,r.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 Oc(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function il(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}var nl=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},An=class n extends Hr{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:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}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&ve.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}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 n(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 n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new pe(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Pc(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof ut&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new rl(r,t)}var rl=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Pc(this.heads)}};function km(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof ut?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=Ei.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new ut(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Cn(l,e,t,!1))}}return r?Pc(r):i}var Tn=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ut)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:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof ut?(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:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}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&ve.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ve.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ve.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 r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}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:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&ve.IncludeAnonymous||l instanceof Ft||!l.type.isAnonymous||ol(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<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new An(this.buffer,t,this.stack[r]);return this.bufferNode=new An(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return il(this.node,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return il(this.node,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function ol(n){return n.children.some(e=>e instanceof Ft||!e.type.isAnonymous||ol(e))}function ym(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new tl(t,t.length):t,a=i.types,h=0,c=0;function f(F,q,w,D,b,Y){let{id:$,start:U,end:K,size:k}=l,T=c;for(;k<0;)if(l.next(),k==-1){let j=s[$];w.push(j),D.push(U-F);return}else if(k==-3){h=$;return}else if(k==-4){c=$;return}else throw new RangeError(`Unrecognized record size: ${k}`);let A=a[$],V,ae,we=U-F;if(K-U<=r&&(ae=y(l.pos-q,b))){let j=new Uint16Array(ae.size-ae.skip),W=l.pos-ae.size,_=j.length;for(;l.pos>W;)_=v(ae.start,j,_);V=new Ft(j,K-ae.start,i),we=ae.start-F}else{let j=l.pos-k;l.next();let W=[],_=[],he=$>=o?$:-1,Mt=0,te=K;for(;l.pos>j;)he>=0&&l.id==he&&l.size>=0?(l.end<=te-r&&(g(W,_,U,Mt,l.end,te,he,T),Mt=W.length,te=l.end),l.next()):Y>2500?u(U,j,W,_):f(U,j,W,_,he,Y+1);if(he>=0&&Mt>0&&Mt<W.length&&g(W,_,U,Mt,U,te,he,T),W.reverse(),_.reverse(),he>-1&&Mt>0){let Te=p(A);V=ll(A,W,_,0,W.length,0,K-U,Te,Te)}else V=x(A,W,_,K-U,T-K)}w.push(V),D.push(we)}function u(F,q,w,D){let b=[],Y=0,$=-1;for(;l.pos>q;){let{id:U,start:K,end:k,size:T}=l;if(T>4)l.next();else{if($>-1&&K<$)break;$<0&&($=k-r),b.push(U,K,k),Y++,l.next()}}if(Y){let U=new Uint16Array(Y*4),K=b[b.length-2];for(let k=b.length-3,T=0;k>=0;k-=3)U[T++]=b[k],U[T++]=b[k+1]-K,U[T++]=b[k+2]-K,U[T++]=T;w.push(new Ft(U,b[2]-K,i)),D.push(K-F)}}function p(F){return(q,w,D)=>{let b=0,Y=q.length-1,$,U;if(Y>=0&&($=q[Y])instanceof pe){if(!Y&&$.type==F&&$.length==D)return $;(U=$.prop(Z.lookAhead))&&(b=w[Y]+$.length+U)}return x(F,q,w,D,b)}}function g(F,q,w,D,b,Y,$,U){let K=[],k=[];for(;F.length>D;)K.push(F.pop()),k.push(q.pop()+w-b);F.push(x(i.types[$],K,k,Y-b,U-Y)),q.push(b-w)}function x(F,q,w,D,b=0,Y){if(h){let $=[Z.contextHash,h];Y=Y?[$].concat(Y):[$]}if(b>25){let $=[Z.lookAhead,b];Y=Y?[$].concat(Y):[$]}return new pe(F,q,w,D,Y)}function y(F,q){let w=l.fork(),D=0,b=0,Y=0,$=w.end-r,U={size:0,start:0,skip:0};e:for(let K=w.pos-F;w.pos>K;){let k=w.size;if(w.id==q&&k>=0){U.size=D,U.start=b,U.skip=Y,Y+=4,D+=4,w.next();continue}let T=w.pos-k;if(k<0||T<K||w.start<$)break;let A=w.id>=o?4:0,V=w.start;for(w.next();w.pos>T;){if(w.size<0)if(w.size==-3)A+=4;else break e;else w.id>=o&&(A+=4);w.next()}b=V,D+=k,Y+=A}return(q<0||D==F)&&(U.size=D,U.start=b,U.skip=Y),U.size>4?U:void 0}function v(F,q,w){let{id:D,start:b,end:Y,size:$}=l;if(l.next(),$>=0&&D<o){let U=w;if($>4){let K=l.pos-($-4);for(;l.pos>K;)w=v(F,q,w)}q[--w]=U,q[--w]=Y-F,q[--w]=b-F,q[--w]=D}else $==-3?h=D:$==-4&&(c=D);return w}let M=[],O=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,M,O,-1,0);let R=(e=n.length)!==null&&e!==void 0?e:M.length?O[0]+M[0].length:0;return new pe(a[n.topID],M.reverse(),O.reverse(),R)}var Ec=new WeakMap;function zr(n,e){if(!n.isAnonymous||e instanceof Ft||e.type!=n)return 1;let t=Ec.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof pe)){t=1;break}t+=zr(n,i)}Ec.set(e,t)}return t}function ll(n,e,t,i,r,s,o,l,a){let h=0;for(let g=i;g<r;g++)h+=zr(n,e[g]);let c=Math.ceil(h*1.5/8),f=[],u=[];function p(g,x,y,v,M){for(let O=y;O<v;){let R=O,F=x[O],q=zr(n,g[O]);for(O++;O<v;O++){let w=zr(n,g[O]);if(q+w>=c)break;q+=w}if(O==R+1){if(q>c){let w=g[R];p(w.children,w.positions,0,w.children.length,x[R]+M);continue}f.push(g[R])}else{let w=x[O-1]+g[O-1].length-F;f.push(ll(n,g,x,R,O,F,w,null,a))}u.push(F+M-s)}}return p(e,t,i,r,0),(l||a)(f,u,o)}var ni=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?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 r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let p=Math.max(u.from,a)-h,g=Math.min(u.to,f)-h;u=p>=g?null:new n(p,g,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}},Mn=class{startParse(e,t,i){return typeof e=="string"&&(e=new sl(e)),i=i?i.length?i.map(r=>new Sn(r.from,r.to)):[new Sn(0,0)]:[new Sn(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},sl=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var bb=new Z({perNode:!0});var wm=0,Pe=class n{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=wm++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new n([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new qr;return t=>t.modified.indexOf(e)>-1?t:qr.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}},xm=0,qr=class n{constructor(){this.instances=[],this.id=xm++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&vm(t,l.modified));if(i)return i;let r=[],s=new Pe(r,e,t);for(let l of t)l.instances.push(s);let o=Sm(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function vm(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function Sm(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Nc(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Bi(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return zc.add(e)}var zc=new Z,Bi=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Bi.empty=new Bi([],2,null);function fl(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Cm(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function Fc(n,e,t,i=0,r=n.length){let s=new hl(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var hl=class{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,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(o)));let h=r,c=Am(e)||Bi.empty,f=Cm(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(Z.mounted);if(u&&u.overlay){let p=e.node.enter(u.overlay[0].from+l,1),g=this.highlighters.filter(y=>!y.scope||y.scope(u.tree.type)),x=e.firstChild();for(let y=0,v=l;;y++){let M=y<u.overlay.length?u.overlay[y]:null,O=M?M.from+l:a,R=Math.max(t,v),F=Math.min(i,O);if(R<F&&x)for(;e.from<F&&(this.highlightRange(e,R,F,r,s),this.startSpan(Math.min(F,e.to),h),!(e.to>=O||!e.nextSibling())););if(!M||O>i)break;v=M.to+l,v>t&&(this.highlightRange(p.cursor(),Math.max(t,M.from+l),Math.min(i,v),"",g),this.startSpan(Math.min(i,v),h))}x&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function Am(n){let e=n.type.prop(zc);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var E=Pe.define,Vr=E(),Ht=E(),Rc=E(Ht),Ic=E(Ht),Vt=E(),Wr=E(Vt),al=E(Vt),mt=E(),ri=E(mt),dt=E(),pt=E(),cl=E(),Ln=E(cl),jr=E(),P={comment:Vr,lineComment:E(Vr),blockComment:E(Vr),docComment:E(Vr),name:Ht,variableName:E(Ht),typeName:Rc,tagName:E(Rc),propertyName:Ic,attributeName:E(Ic),className:E(Ht),labelName:E(Ht),namespace:E(Ht),macroName:E(Ht),literal:Vt,string:Wr,docString:E(Wr),character:E(Wr),attributeValue:E(Wr),number:al,integer:E(al),float:E(al),bool:E(Vt),regexp:E(Vt),escape:E(Vt),color:E(Vt),url:E(Vt),keyword:dt,self:E(dt),null:E(dt),atom:E(dt),unit:E(dt),modifier:E(dt),operatorKeyword:E(dt),controlKeyword:E(dt),definitionKeyword:E(dt),moduleKeyword:E(dt),operator:pt,derefOperator:E(pt),arithmeticOperator:E(pt),logicOperator:E(pt),bitwiseOperator:E(pt),compareOperator:E(pt),updateOperator:E(pt),definitionOperator:E(pt),typeOperator:E(pt),controlOperator:E(pt),punctuation:cl,separator:E(cl),bracket:Ln,angleBracket:E(Ln),squareBracket:E(Ln),paren:E(Ln),brace:E(Ln),content:mt,heading:ri,heading1:E(ri),heading2:E(ri),heading3:E(ri),heading4:E(ri),heading5:E(ri),heading6:E(ri),contentSeparator:E(mt),list:E(mt),quote:E(mt),emphasis:E(mt),strong:E(mt),link:E(mt),monospace:E(mt),strikethrough:E(mt),inserted:E(),deleted:E(),changed:E(),invalid:E(),meta:jr,documentMeta:E(jr),annotation:E(jr),processingInstruction:E(jr),definition:Pe.defineModifier(),constant:Pe.defineModifier(),function:Pe.defineModifier(),standard:Pe.defineModifier(),local:Pe.defineModifier(),special:Pe.defineModifier()},wb=fl([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var ul,Pi=new Z;function Tm(n){return I.define({combine:n?e=>e.concat(n):void 0})}var Mm=new Z,We=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,oe.prototype.hasOwnProperty("tree")||Object.defineProperty(oe.prototype,"tree",{get(){return Be(this)}}),this.parser=t,this.extension=[Ri.of(this),oe.languageData.of((s,o,l)=>{let a=Hc(s,o,l),h=a.type.prop(Pi);if(!h)return[];let c=s.facet(h),f=a.type.prop(Mm);if(f){let u=a.resolve(o-a.from,l);for(let p of f)if(p.test(u,s)){let g=s.facet(p.facet);return p.type=="replace"?g:g.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return Hc(e,t,i).type.prop(Pi)==this.data}findRegions(e){let t=e.facet(Ri);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Pi)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(Z.mounted);if(l){if(l.tree.prop(Pi)==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+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof pe&&r(h,s.positions[a]+o)}};return r(Be(e),0),i}get allowsNesting(){return!0}};We.setState=X.define();function Hc(n,e,t){let i=n.facet(Ri),r=Be(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,ve.ExcludeBuffers))s.type.isTop&&(r=s);return r}function Be(n){let e=n.field(We.state,!1);return e?e.tree:pe.empty}var gl=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Dn=null,On=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],pe.empty,0,i,[],null)}startParse(){return this.parser.startParse(new gl(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=pe.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(ni.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=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(ni.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Dn;Dn=this;try{return e()}finally{Dn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Vc(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,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=ni.applyChanges(i,a),r=pe.empty,s=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);c<f&&l.push({from:c,to:f})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=Vc(this.fragments,r,s),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 Mn{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=Dn;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new pe(Ee.none,[],[],o-s)},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 Dn}};function Vc(n,e,t){return ni.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var En=class n{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 n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=On.create(e.facet(Ri).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};We.state=me.define({create:En.init,update(n,e){for(let t of e.effects)if(t.is(We.setState))return t.value;return e.startState.facet(Ri)!=e.state.facet(Ri)?En.init(e.state):n.apply(e)}});var Kc=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(Kc=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var dl=typeof navigator!="undefined"&&(!((ul=navigator.scheduling)===null||ul===void 0)&&ul.isInputPending)?()=>navigator.scheduling.isInputPending():null,Lm=ye.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(We.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(We.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Kc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(We.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!dl?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>dl&&dl()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:We.setState.of(new En(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>He(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()}}}),Ri=I.define({combine(n){return n.length?n[0]:null},enables:n=>[We.state,Lm,z.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Ii=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var _c=I.define(),jt=I.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 Wt(n){let e=n.facet(jt);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Fi(n,e){let t="",i=n.tabSize,r=n.facet(jt)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function _r(n,e){n instanceof oe&&(n=new si(n));for(let i of n.state.facet(_c)){let r=i(n,e);if(r!==void 0)return r}let t=Be(n.state);return t.length>=e?Om(n,t,e):null}var si=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Wt(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Bt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Dm=new Z;function Om(n,e,t){let i=e.resolveStack(t),r=i.node.enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o!=i.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Gc(i,n,t)}function Gc(n,e,t){for(let i=n;i;i=i.next){let r=Bm(i.node);if(r)return r(bl.create(e,t,i))}return 0}function Em(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Bm(n){let e=n.type.prop(Dm);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(Z.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>Nm(o,!0,1,void 0,s&&!Em(o)?r.from:void 0)}return n.parent==null?Pm:null}function Pm(){return 0}var bl=class n extends si{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 n(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(Rm(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Gc(this.context.next,this.base,this.pos)}};function Rm(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Im(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.from<o?t:null;l=a.to}}function Nm(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Im(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var zm=200;function Uc(){return oe.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,r=t.lineAt(i);if(i>r.from+zm)return n;let s=t.sliceString(r.from,i);if(!e.some(h=>h.test(s)))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=_r(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],p=Fi(o,f);u!=p&&a.push({from:c.from,to:c.from+u.length,insert:p})}return a.length?[n,{changes:a,sequential:!0}]:n})}var Ni=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=Ke.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof We?l=>l.prop(Pi)==o.data:o?l=>l==o:void 0,this.style=fl(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ke(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},kl=I.define(),Yc=I.define({combine(n){return n.length?[n[0]]:null}});function pl(n){let e=n.facet(kl);return e.length?e:n.facet(Yc)}function Gr(n,e){let t=[Fm],i;return n instanceof Ni&&(n.module&&t.push(z.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Yc.of(n)):i?t.push(kl.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(i=="dark")?[n]:[])):t.push(kl.of(n)),t}var yl=class{constructor(e){this.markCache=Object.create(null),this.tree=Be(e.state),this.decorations=this.buildDeco(e,pl(e.state))}update(e){let t=Be(e.state),i=pl(e.state),r=i!=pl(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i))}buildDeco(e,t){if(!t||!this.tree.length)return J.none;let i=new lt;for(let{from:r,to:s}of e.visibleRanges)Fc(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=J.mark({class:a})))},r,s);return i.finish()}},Fm=Et.high(ye.fromClass(yl,{decorations:n=>n.decorations})),Jc=Ni.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),Hm=z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Xc=1e4,Zc="()[]{}",Qc=I.define({combine(n){return ze(n,{afterCursor:!0,brackets:Zc,maxScanDistance:Xc,renderMatch:jm})}}),Vm=J.mark({class:"cm-matchingBracket"}),Wm=J.mark({class:"cm-nonmatchingBracket"});function jm(n){let e=[],t=n.matched?Vm:Wm;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}var qm=me.define({create(){return J.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(Qc);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=nt(e.state,r.head,-1,i)||r.head>0&&nt(e.state,r.head-1,1,i)||i.afterCursor&&(nt(e.state,r.head,1,i)||r.head<e.state.doc.length&&nt(e.state,r.head+1,-1,i));s&&(t=t.concat(i.renderMatch(s,e.state)))}return J.set(t,!0)},provide:n=>z.decorations.from(n)}),$m=[qm,Hm];function ef(n={}){return[Qc.of(n),$m]}var Km=new Z;function wl(n,e,t){let i=n.prop(e<0?Z.openedBy:Z.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function xl(n){let e=n.type.prop(Km);return e?e(n.node):n}function nt(n,e,t,i={}){let r=i.maxScanDistance||Xc,s=i.brackets||Zc,o=Be(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=wl(a.type,t,s);if(h&&a.from<a.to){let c=xl(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return _m(n,e,t,a,c,h,s)}}return Gm(n,e,t,o,l.type,r,s)}function _m(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.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&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=xl(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(wl(c.type,t,o))h++;else if(wl(c.type,-t,o)){if(h==0){let f=xl(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function Gm(n,e,t,i,r,s,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)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<=s;){let p=c.value;t<0&&(u+=p.length);let g=e+u*t;for(let x=t>0?0:p.length-1,y=t>0?p.length:-1;x!=y;x+=t){let v=o.indexOf(p[x]);if(!(v<0||i.resolveInner(g+x,1).type!=r))if(v%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:g+x,to:g+x+1},matched:v>>1==a>>1};f--}}t>0&&(u+=p.length)}return c.done?{start:h,matched:!1}:null}function Wc(n,e,t,i=0,r=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let s=r;for(let o=i;o<e;o++)n.charCodeAt(o)==9?s+=t-s%t:s++;return s}var $r=class{constructor(e,t,i,r){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Wc(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Wc(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let r=o=>i?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return r(s)==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}};function Um(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||Ym,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||Cl}}function Ym(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}var jc=new WeakMap,zi=class n extends We{constructor(e){let t=Tm(e.languageData),i=Um(e),r,s=new class extends Mn{createParse(o,l,a){return new vl(r,o,l,a)}};super(t,s,[_c.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=Qm(t),r=this,this.streamParser=i,this.stateAfter=new Z({perNode:!0}),this.tokenTable=e.tokenTable?new Kr(i.tokenTable):Zm}static define(e){return new n(e)}getIndent(e,t){let i=Be(e.state),r=i.resolve(t);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let s,{overrideIndentation:o}=e.options;o&&(s=jc.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let l=Sl(this,i,0,r.from,s!=null?s:t),a,h;if(l?(h=l.state,a=l.pos+1):(h=this.streamParser.startState(e.unit),a=0),t-a>1e4)return null;for(;a<t;){let f=e.state.doc.lineAt(a),u=Math.min(t,f.to);if(f.length){let p=o?o(f.from):-1,g=new $r(f.text,e.state.tabSize,e.unit,p<0?void 0:p);for(;g.pos<u-f.from;)nf(this.streamParser.token,g,h)}else this.streamParser.blankLine(h,e.unit);if(u==t)break;a=f.to+1}let c=e.lineAt(t);return o&&s==null&&jc.set(e.state,c.from),this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],e)}get allowsNesting(){return!1}};function Sl(n,e,t,i,r){let s=t>=i&&t+e.length<=r&&e.prop(n.stateAfter);if(s)return{state:n.streamParser.copyState(s),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof pe&&a<r&&Sl(n,l,a,i,r);if(h)return h}return null}function tf(n,e,t,i,r){if(r&&t<=0&&i>=e.length)return e;!r&&e.type==n.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],l=e.children[s],a;if(o<i&&l instanceof pe){if(!(a=tf(n,l,t-o,i-o,r)))break;return r?new pe(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function Jm(n,e,t,i){for(let r of e){let s=r.from+(r.openStart?25:0),o=r.to-(r.openEnd?25:0),l=s<=t&&o>t&&Sl(n,r.tree,0-r.offset,t,o),a;if(l&&(a=tf(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:a}}return{state:n.streamParser.startState(i?Wt(i):4),tree:pe.empty}}var vl=class{constructor(e,t,i,r){this.lang=e,this.input=t,this.fragments=i,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let s=On.get(),o=r[0].from,{state:l,tree:a}=Jm(e,i,o,s==null?void 0:s.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(Wt(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=On.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+2048);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
1
+ var md=Object.defineProperty;var gd=(n,e)=>{for(var t in e)md(n,t,{get:e[t],enumerable:!0})};var $s=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var _=(n,e,t)=>($s(n,e,"read from private field"),t?t.call(n):e.get(n)),Ze=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},lt=(n,e,t,i)=>($s(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);var ki=(n,e,t)=>($s(n,e,"access private method"),t);var Q=class n{lineAt(e){if(e<0||e>this.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]=Ci(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),wi.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ci(this,e,t);let i=[];return this.decompose(e,t,i,0),wi.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),r=new Qt(this),s=new Qt(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new Qt(this,e)}iterRange(e,t=this.length){return new Qn(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new er(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]?n.empty:e.length<=32?new Ie(e):wi.from(Ie.split(e,[]))}},Ie=class n extends Q{constructor(e,t=bd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new _s(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(xa(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Zn(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new n(l,o.length+s.length));else{let a=l.length>>1;i.push(new n(l.slice(0,a)),new n(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=Ci(this,e,t);let r=Zn(this.text,Zn(i.text,xa(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):wi.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=`
2
+ `){[e,t]=Ci(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},wi=class n extends Q{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,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((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]=Ci(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new n(c,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
+ `){[e,t]=Ci(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let p of e)i+=p.lines;if(i<32){let p=[];for(let g of e)g.flatten(p);return new Ie(p,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(p){let g;if(p.lines>s&&p instanceof n)for(let x of p.children)f(x);else p.lines>o&&(a>o||!a)?(u(),l.push(p)):p instanceof Ie&&a&&(g=c[c.length-1])instanceof Ie&&p.lines+g.lines<=32?(a+=p.lines,h+=p.length+1,c[c.length-1]=new Ie(g.text.concat(p.text),g.length+1+p.length)):(a+p.lines>r&&u(),a+=p.lines,h+=p.length+1,c.push(p))}function u(){a!=0&&(l.push(c.length==1?c[0]:n.from(c,h)),h=-1,a=c.length=0)}for(let p of e)f(p);return u(),l.length==1?l[0]:new n(l,t)}};Q.empty=new Ie([""],0);function bd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Zn(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function xa(n,e,t){return Zn(n,[""],e,t)}var Qt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?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,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof Ie?r.text.length:r.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((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
+ `,this;e--}else if(r instanceof Ie){let a=r.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=r.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)}},Qn=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Qt(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:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.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!=""}},er=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=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=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(Q.prototype[Symbol.iterator]=function(){return this.iter()},Qt.prototype[Symbol.iterator]=Qn.prototype[Symbol.iterator]=er.prototype[Symbol.iterator]=function(){return this});var _s=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function Ci(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}var xi="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;n<xi.length;n++)xi[n]+=xi[n-1];function kd(n){for(let e=1;e<xi.length;e+=2)if(xi[e]>n)return xi[e-1]<=n;return!1}function va(n){return n>=127462&&n<=127487}var Sa=8205;function be(n,e,t=!0,i=!0){return(t?Da:yd)(n,e,i)}function Da(n,e,t){if(e==n.length)return e;e&&Oa(n.charCodeAt(e))&&Ea(n.charCodeAt(e-1))&&e--;let i=$e(n,e);for(e+=St(i);e<n.length;){let r=$e(n,e);if(i==Sa||r==Sa||t&&kd(r))e+=St(r),i=r;else if(va(r)){let s=0,o=e-2;for(;o>=0&&va($e(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function yd(n,e,t){for(;e>0;){let i=Da(n,e-2,t);if(i<e)return i;e--}return 0}function Oa(n){return n>=56320&&n<57344}function Ea(n){return n>=55296&&n<56320}function $e(n,e){let t=n.charCodeAt(e);if(!Ea(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Oa(i)?(t-55296<<10)+(i-56320)+65536:t}function sr(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function St(n){return n<65536?1:2}var Gs=/\r\n?|\n/,Ce=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Ce||(Ce={})),vt=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){Us(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:Ba(this,e)}mapDesc(e,t=!1){return e.empty?this:Ys(this,e,t)}mapPos(e,t=-1,i=Ce.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=Ce.Simple&&h>=e&&(i==Ce.TrackDel&&r<e&&h>e||i==Ce.TrackBefore&&r<e||i==Ce.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}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 n(e)}static create(e){return new n(e)}},De=class n extends vt{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 Us(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Ys(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(Q.empty);i.push(o?e.slice(s,s+o):Q.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:Ba(this,e,!0)}map(e,t=!1){return e.empty?this:Ys(this,e,t,!0)}iterChanges(e,t=!1){Us(this,e,t)}get desc(){return vt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new ei(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);Me(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Me(t,c,f),f>0&&Et(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);Me(t,c,-1),Me(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:vt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&Me(r,t-o,-1);let f=new n(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof n){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:p}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let g=p?typeof p=="string"?Q.of(p.split(i||Gs)):p:Q.empty,x=g.length;if(f==u&&x==0)return;f<o&&a(),f>o&&Me(r,f-o,-1),Me(r,u-f,x),Et(s,r,g),o=u}}return h(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(Q.empty);i[r]=Q.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function Me(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Et(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(Q.empty);n.push(t)}}function Us(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=Q.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function Ys(n,e,t,i=!1){let r=[],s=i?[]:null,o=new ei(n),l=new ei(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Me(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(Me(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Me(r,0,o.ins),s&&Et(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=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.len<c)c-=l.len,l.next();else break;Me(r,h,a<o.i?o.ins:0),s&&a<o.i&&Et(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?De.createSet(r,s):vt.create(r);throw new Error("Mismatched change set lengths")}}function Ba(n,e,t=!1){let i=[],r=t?[]:null,s=new ei(n),o=new ei(e);for(let l=!1;;){if(s.done&&o.done)return r?De.createSet(i,r):vt.create(i);if(s.ins==0)Me(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Me(i,0,o.ins,l),r&&Et(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Me(i,a,c,l),r&&c&&Et(r,i,o.text)}else o.ins==-1?(Me(i,s.off?0:s.len,a,l),r&&Et(r,i,s.textBit(a))):(Me(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Et(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}var ei=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Q.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Q.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)}},yi=class n{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,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return L.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return L.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}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 L.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},L=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.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 n(e.ranges.map(t=>yi.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.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,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return yi.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r!=null?r:16777215)<<6)}static range(e,t,i,r){let s=(i!=null?i:16777215)<<6|(r==null?7:Math.min(6,r));return t<e?yi.create(t,e,48|s):yi.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Pa(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var so=0,I=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=so++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:oo),!!e.static,e.enables)}of(e){return new vi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new vi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new vi(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function oo(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var vi=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=so++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>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)||Js(f,c)){let p=i(f);if(l?!Ca(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,u)=>{let p,g=u.config.address[s];if(g!=null){let x=nr(u,g);if(this.dependencies.every(y=>y instanceof I?u.facet(y)===f.facet(y):y instanceof me?u.field(y,!1)==f.field(y,!1):!0)||(l?Ca(p=i(f),x,r):r(p=i(f),x)))return f.values[o]=x,0}else p=i(f);return f.values[o]=p,1}}}};function Ca(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function Js(n,e){let t=!1;for(let i of e)Qi(n,i)&1&&(t=!0);return t}function wd(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=nr(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Qi(a,h);return a.values[o]=l(a),1},update(a,h){if(!Js(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Js(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&oo(t,f))return a.values[o]=u,0;let p=l(a);return e.compare(p,u)?(a.values[o]=u,0):(a.values[o]=p,1)}}}var Aa=I.define({static:!0}),me=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(so++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Aa).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,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,Aa.of({field:this,create:e})]}get extension(){return this}},Xt={lowest:4,low:3,default:2,high:1,highest:0};function Zi(n){return e=>new tr(e,n)}var Bt={highest:Zi(Xt.highest),high:Zi(Xt.high),default:Zi(Xt.default),low:Zi(Xt.low),lowest:Zi(Xt.lowest)},tr=class{constructor(e,t){this.inner=e,this.prec=t}},Ct=class n{of(e){return new en(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},en=class{constructor(e,t){this.compartment=e,this.inner=t}},ir=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of xd(e,t,o))u instanceof me?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(p=>u.slot(p));let c=i==null?void 0:i.config.facets;for(let u in s){let p=s[u],g=p[0].facet,x=c&&c[u]||[];if(p.every(y=>y.type==0))if(l[g.id]=a.length<<1|1,oo(x,p))a.push(i.facet(g));else{let y=g.combine(p.map(v=>v.value));a.push(i&&g.compare(y,i.facet(g))?i.facet(g):y)}else{for(let y of p)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=h.length<<1,h.push(v=>y.dynamicSlot(v)));l[g.id]=h.length<<1,h.push(y=>wd(y,g,p))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function xd(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof en&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof en){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),s(h,l)}else if(o instanceof tr)s(o.inner,o.prec);else if(o instanceof me)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof vi)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,Xt.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.`);s(h,l)}}return s(n,Xt.default),i.reduce((o,l)=>o.concat(l))}function Qi(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 r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function nr(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Ra=I.define(),Xs=I.define({combine:n=>n.some(e=>e),static:!0}),Ia=I.define({combine:n=>n.length?n[0]:void 0,static:!0}),Na=I.define(),za=I.define(),Fa=I.define(),Ha=I.define({combine:n=>n.length?n[0]:!1}),Ne=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Zs}},Zs=class{of(e){return new Ne(this,e)}},Qs=class{constructor(e){this.map=e}of(e){return new X(this,e)}},X=class n{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 n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Qs(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};X.reconfigure=X.define();X.appendConfig=X.define();var xe=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Pa(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,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(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};xe.time=Ne.define();xe.userEvent=Ne.define();xe.addToHistory=Ne.define();xe.remote=Ne.define();function vd(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Va(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=De.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:X.mapEffects(n.effects,r).concat(X.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function eo(n,e,t){let i=e.selection,r=Si(e.annotations);return e.userEvent&&(r=r.concat(xe.userEvent.of(e.userEvent))),{changes:e.changes instanceof De?e.changes:De.of(e.changes||[],t,n.facet(Ia)),selection:i&&(i instanceof L?i:L.single(i.anchor,i.head)),effects:Si(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Wa(n,e,t){let i=eo(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Va(i,eo(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=xe.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Cd(t?Sd(r):r)}function Sd(n){let e=n.startState,t=!0;for(let r of e.facet(Na)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:vd(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=De.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=xe.create(e,r,n.selection&&n.selection.map(s),X.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(za);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof xe?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof xe?n=s[0]:n=Wa(e,Si(s),!1)}return n}function Cd(n){let e=n.startState,t=e.facet(Fa),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=Va(i,eo(e,s,n.changes.newLength),!0))}return i==n?n:xe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var Ad=[];function Si(n){return n==null?Ad:Array.isArray(n)?n:[n]}var ue=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(ue||(ue={})),Td=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,to;try{to=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function Md(n){if(to)return to.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||Td.test(t)))return!0}return!1}function Ld(n){return e=>{if(!/\S/.test(e))return ue.Space;if(Md(e))return ue.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return ue.Word;return ue.Other}}var oe=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Qi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Qi(this,i),nr(this,i)}update(...e){return Wa(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(Ct.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(X.reconfigure)?(t=null,i=l.value):l.is(X.appendConfig)&&(t=null,i=Si(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=ir.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Xs)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(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:L.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=Si(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=X.mapEffects(o,c).concat(X.mapEffects(Si(a.effects),f))}return{changes:r,selection:L.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof De?e:De.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return Q.of(e.split(this.facet(n.lineSeparator)||Gs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Qi(this,t),nr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof me&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:L.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=ir.resolve(e.extensions||[],new Map),i=e.doc instanceof Q?e.doc:Q.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||Gs)),r=e.selection?e.selection instanceof L?e.selection:L.single(e.selection.anchor,e.selection.head):L.single(0);return Pa(r,i.length),t.staticFacet(Xs)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
5
+ `}get readOnly(){return this.facet(Ha)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(Ra))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return Ld(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=be(t,o,!1);if(s(t.slice(a,o))!=ue.Word)break;o=a}for(;l<r;){let a=be(t,l);if(s(t.slice(l,a))!=ue.Word)break;l=a}return o==l?null:L.range(o+i,l+i)}};oe.allowMultipleSelections=Xs;oe.tabSize=I.define({combine:n=>n.length?n[0]:4});oe.lineSeparator=Ia;oe.readOnly=Ha;oe.phrases=I.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});oe.languageData=Ra;oe.changeFilter=Na;oe.transactionFilter=za;oe.transactionExtender=Fa;Ct.reconfigure=X.define();function ze(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var Qe=class{eq(e){return this==e}range(e,t=e){return tn.create(e,t,this)}};Qe.prototype.startSide=Qe.prototype.endSide=0;Qe.prototype.point=!1;Qe.prototype.mapMode=Ce.TrackDel;var tn=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function io(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var no=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[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,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,p;if(c==f){let g=t.mapPos(c,h.startSide,h.mapMode);if(g==null||(u=p=g,h.startSide!=h.endSide&&(p=t.mapPos(c,h.endSide),p<u)))continue}else if(u=t.mapPos(c,h.startSide),p=t.mapPos(f,h.endSide),u>p||u==p&&h.startSide>0&&h.endSide<=0)continue;(p-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,p-u)),i.push(h),r.push(u-o),s.push(p-o))}return{mapped:i.length?new n(r,s,i,l):null,pos:o}}},ie=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}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:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(io)),this.isEmpty)return t.length?n.of(t):this;let l=new rr(this,null,-1).goto(0),a=0,h=[],c=new at;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(tn.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?n.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),t.push(c),i.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new n(i,t,s||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return nn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return nn.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=Ta(o,l,i),h=new Zt(o,a,s),c=new Zt(l,a,s);i.iterGaps((f,u,p)=>Ma(h,f,c,u,p,r)),i.empty&&i.length==0&&Ma(h,0,c,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=Ta(s,o),a=new Zt(s,l,0).goto(i),h=new Zt(o,l,0).goto(i);for(;;){if(a.to!=h.to||!ro(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,i,r,s=-1){let o=new Zt(e,null,s).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.pointFrom<t?c.length+1:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.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 at;for(let r of e instanceof tn?[e]:t?Dd(e):e)i.add(r.from,r.to,r.value);return i.finish()}};ie.empty=new ie([],[],null,-1);function Dd(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(io(e,i)>0)return n.slice().sort(io);e=i}return n}ie.empty.nextLayer=ie.empty;var at=class n{finishChunk(e){this.chunks.push(new no(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 n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<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(ie.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=ie.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Ta(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}var rr=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},nn=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new rr(o,t,i,s));return r.length==1?r[0]:new n(r)}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--)Ks(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--)Ks(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(),Ks(this.heap,0)}}};function Ks(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var Zt=class{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=nn.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){Jn(this.active,e),Jn(this.activeTo,e),Jn(this.activeRank,e),this.minActive=La(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=s;)t++;Xn(this.active,t,i),Xn(this.activeTo,t,r),Xn(this.activeRank,t,s),e&&Xn(e,t,this.cursor.from),this.minActive=La(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Jn(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[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 Ma(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,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))&&ro(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,f,n.point,t.point):f>l&&!ro(n.active,t.active)&&s.compareRange(l,f,n.active,t.active),c>o)break;l=c,h<=0&&n.next(),h>=0&&t.next()}}function ro(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!n[t].eq(e[t]))return!1;return!0}function Jn(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function Xn(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function La(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function Pt(n,e,t=n.length){let i=0;for(let r=0;r<t;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=be(n,r));return i}function ja(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=be(n,r)}return i===!0?-1:n.length}var lo="\u037C",qa=typeof Symbol=="undefined"?"__"+lo:Symbol.for(lo),ao=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),$a=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},Ke=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(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 p in l){let g=l[p];if(/&/.test(p))s(p.split(/,\s*/).map(x=>o.map(y=>x.replace(/&/,y))).reduce((x,y)=>x.concat(y)),g,a);else if(g&&typeof g=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,c,u)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,x=>"-"+x.toLowerCase())+": "+g+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
6
+ `)}static newName(){let e=$a[qa]||1;return $a[qa]=e+1,lo+e.toString(36)}static mount(e,t,i){let r=e[ao],s=i&&i.nonce;r?s&&r.setNonce(s):r=new ho(e,s),r.mount(Array.isArray(t)?t:[t])}},Ka=new Map,ho=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Ka.get(i);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[ao]=s;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],Ka.set(i,this)}else{this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let s=e.head||e;s.insertBefore(this.styleTag,s.firstChild)}this.modules=[],e[ao]=this}mount(e){let t=this.sheet,i=0,r=0;for(let s=0;s<e.length;s++){let o=e[s],l=this.modules.indexOf(o);if(l<r&&l>-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,o),t)for(let a=0;a<o.rules.length;a++)t.insertRule(o.rules[a],i++)}else{for(;r<l;)i+=this.modules[r++].rules.length;i+=o.rules.length,r++}}if(!t){let s="";for(let o=0;o<this.modules.length;o++)s+=this.modules[o].getRules()+`
7
+ `;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var At={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ai={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Od=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Ed=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ke=0;ke<10;ke++)At[48+ke]=At[96+ke]=String(ke);var ke;for(ke=1;ke<=24;ke++)At[ke+111]="F"+ke;var ke;for(ke=65;ke<=90;ke++)At[ke]=String.fromCharCode(ke+32),Ai[ke]=String.fromCharCode(ke);var ke;for(or in At)Ai.hasOwnProperty(or)||(Ai[or]=At[or]);var or;function _a(n){var e=Od&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ed&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ai: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 wr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function yo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Bd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function gr(n,e){if(!e.anchorNode)return!1;try{return yo(n,e.anchorNode)}catch(t){return!1}}function mn(n){return n.nodeType==3?ti(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function xr(n,e,t,i){return t?Ga(n,e,t,i,-1)||Ga(n,e,t,i,1):!1}function gn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Ga(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Tt(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=gn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?Tt(n):0}else return!1}}function Tt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function tl(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Pd(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Bh(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 Rd(n,e,t,i,r,s,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,p=c==a.body,g=1,x=1;if(p)u=Pd(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 M=c.getBoundingClientRect();({scaleX:g,scaleY:x}=Bh(c,M)),u={left:M.left,right:M.left+c.clientWidth*g,top:M.top,bottom:M.top+c.clientHeight*x}}let y=0,v=0;if(r=="nearest")e.top<u.top?(v=-(u.top-e.top+o),t>0&&e.bottom>u.bottom+v&&(v=e.bottom-u.bottom+v+o)):e.bottom>u.bottom&&(v=e.bottom-u.bottom+o,t<0&&e.top-v<u.top&&(v=-(u.top+v-e.top+o)));else{let M=e.bottom-e.top,O=u.bottom-u.top;v=(r=="center"&&M<=O?e.top+M/2-O/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-O+o)-u.top}if(i=="nearest"?e.left<u.left?(y=-(u.left-e.left+s),t>0&&e.right>u.right+y&&(y=e.right-u.right+y+s)):e.right>u.right&&(y=e.right-u.right+s,t<0&&e.left<u.left+y&&(y=-(u.left+y-e.left+s))):y=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,y||v)if(p)h.scrollBy(y,v);else{let M=0,O=0;if(v){let R=c.scrollTop;c.scrollTop+=v/x,O=(c.scrollTop-R)*x}if(y){let R=c.scrollLeft;c.scrollLeft+=y/g,M=(c.scrollLeft-R)*g}e={left:e.left-M,top:e.top-O,right:e.right-M,bottom:e.bottom-O},M&&Math.abs(M-y)<1&&(i="nearest"),O&&Math.abs(O-v)<1&&(r="nearest")}if(p)break;c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Id(n){let e=n.ownerDocument;for(let t=n.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var wo=class{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?Tt(t):0),i,Math.min(e.focusOffset,i?Tt(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},Ti=null;function Ph(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;t<e.length;){let i=e[t++],r=e[t++],s=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=s&&(i.scrollLeft=s)}}}var Ua;function ti(n,e,t=e){let i=Ua||(Ua=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Oi(n,e,t){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0},r=new KeyboardEvent("keydown",i);r.synthetic=!0,n.dispatchEvent(r);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,n.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function Nd(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Rh(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}function zd(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Tt(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=Tt(t))}else{if(t==n)return!0;i=gn(t),t=t.parentNode}}function Ih(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}var Oe=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,gn(e),t)}static after(e,t){return new n(e.parentNode,gn(e)+1,t)}},il=[],de=class n{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:i.firstChild)){let l=n.get(s);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&s!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;s&&s!=o.dom;)s=Ya(s);else i.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:i.firstChild,s&&t&&t.node==i&&(t.written=!0);s;)s=Ya(s)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let r=Tt(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!n.get(i);)i=i.nextSibling;if(!i)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==i)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<this.children.length;a++){let f=this.children[a],u=h+f.length;if(h<e&&u>t)return f.domBoundsAround(e,t,h);if(u>=e&&r==-1&&(r=a,s=h),h>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?i+this.length:l,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&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=il){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&i.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...i);for(let r=0;r<i.length;r++)i[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new vr(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}};de.prototype.breakAfter=0;function Ya(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var vr=class{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.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 Nh(n,e,t,i,r,s,o,l,a){let{children:h}=n,c=h.length?h[e]:null,f=s.length?s[s.length-1]:null,u=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!u&&s.length<2&&c.merge(t,r,s.length?f:null,t==0,l,a))){if(i<h.length){let p=h[i];p&&(r<p.length||p.breakAfter&&(f!=null&&f.breakAfter))?(e==i&&(p=p.split(r),r=0),!u&&f&&p.merge(0,r,f,!0,0,a)?s[s.length-1]=p:((r||p.children.length&&!p.children[0].length)&&p.merge(0,r,null,!1,0,a),s.push(p))):p!=null&&p.breakAfter&&(f?f.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,t>0&&(!o&&s.length&&c.merge(t,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(t<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(t,c.length,null,!1,l,0),e++));e<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&i<h.length&&!h[e-1].breakAfter&&h[i].merge(0,0,h[e-1],!1,l,a)&&e--,(e<i||s.length)&&n.replaceChildren(e,i,s)}}function zh(n,e,t,i,r,s){let o=n.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:h,off:c}=o.findPos(e,-1),f=e-t;for(let u of i)f+=u.length;n.length+=f,Nh(n,h,c,l,a,i,0,r,s)}var Fe=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},xo=typeof document!="undefined"?document:{documentElement:{style:{}}},vo=/Edge\/(\d+)/.exec(Fe.userAgent),Fh=/MSIE \d/.test(Fe.userAgent),So=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fe.userAgent),Nr=!!(Fh||So||vo),Ja=!Nr&&/gecko\/(\d+)/i.test(Fe.userAgent),co=!Nr&&/Chrome\/(\d+)/.exec(Fe.userAgent),Xa="webkitFontSmoothing"in xo.documentElement.style,Hh=!Nr&&/Apple Computer/.test(Fe.vendor),Za=Hh&&(/Mobile\/\w+/.test(Fe.userAgent)||Fe.maxTouchPoints>2),H={mac:Za||/Mac/.test(Fe.platform),windows:/Win/.test(Fe.platform),linux:/Linux|X11/.test(Fe.platform),ie:Nr,ie_version:Fh?xo.documentMode||6:So?+So[1]:vo?+vo[1]:0,gecko:Ja,gecko_version:Ja?+(/Firefox\/(\d+)/.exec(Fe.userAgent)||[0,0])[1]:0,chrome:!!co,chrome_version:co?+co[1]:0,ios:Za,android:/Android\b/.test(Fe.userAgent),webkit:Xa,safari:Hh,webkit_version:Xa?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:xo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Fd=256,Nt=class n extends de{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 n)||this.length-(t-e)+i.length>Fd||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 n(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 Oe(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 Hd(this.dom,e,t)}},zt=class n extends de{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let r of t)r.setParent(this)}setAttrs(e){if(Rh(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,r,s,o){return i&&(!(i instanceof n&&i.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(zh(this,e,t,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],i=0,r=-1,s=0;for(let l of this.children){let a=i+l.length;a>e&&t.push(i<e?l.split(e-i):l),r<0&&i>=e&&(r=s),i=a,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new n(this.mark,t,o)}domAtPos(e){return Vh(this,e)}coordsAt(e,t){return jh(this,e,t)}};function Hd(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?H.chrome||H.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=ti(n,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return H.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?tl(a,o<0):a||null}var bn=class n extends de{static create(e,t,i){return new n(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=n.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.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof n&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Q.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,r=this.posAtStart;return i?i.slice(r,r+this.length):Q.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Oe.before(this.dom):Oe.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 r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?r.length-1:0;s=r[l],!(e>0?l==0:l==r.length-1||s.top<s.bottom);l+=o?-1:1);return tl(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},kn=class n extends de{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof n&&e.side==this.side}split(){return new n(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Oe.before(this.dom):Oe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Q.empty}get isHidden(){return!0}};Nt.prototype.children=bn.prototype.children=kn.prototype.children=il;function Vh(n,e){let t=n.dom,{children:i}=n,r=0;for(let s=0;r<i.length;r++){let o=i[r],l=s+o.length;if(!(l==s&&o.getSide()<=0)){if(e>s&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=l}}for(let s=r;s>0;s--){let o=i[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s<i.length;s++){let o=i[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new Oe(t,0)}function Wh(n,e,t){let i,{children:r}=n;t>0&&e instanceof zt&&r.length&&(i=r[r.length-1])instanceof zt&&i.mark.eq(e.mark)?Wh(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function jh(n,e,t){let i=null,r=-1,s=null,o=-1;function l(h,c){for(let f=0,u=0;f<h.children.length&&u<=c;f++){let p=h.children[f],g=u+p.length;g>=c&&(p.children.length?l(p,c-u):(!s||s.isHidden&&t>0)&&(g>c||u==g&&p.getSide()>0)?(s=p,o=c-u):(u<c||u==g&&p.getSide()<0&&!p.isHidden)&&(i=p,r=c-u)),u=g}}l(n,e);let a=(t<0?i:s)||i||s;return a?a.coordsAt(Math.max(0,a==i?r:o),t):Vd(n)}function Vd(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=mn(e);return t[t.length-1]||null}function Co(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Qa=Object.create(null);function nl(n,e,t){if(n==e)return!0;n||(n=Qa),e||(e=Qa);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function Ao(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Wd(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var Ae=class n extends de{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,r,s,o){if(i){if(!(i instanceof n))return!1;this.dom||i.transferDOM(this)}return r&&this.setDeco(i?i.attrs:null),zh(this,e,t,i?i.children.slice():[],s,o),!0}split(e){let t=new n;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:r}=this.childPos(e);r&&(t.append(this.children[i].split(r),0),this.children[i].merge(r,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)t.append(this.children[s],0);for(;i>0&&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){nl(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Wh(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=Co(t,this.attrs||{})),i&&(this.attrs=Co({class:i},this.attrs||{}))}domAtPos(e){return Vh(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Rh(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&&(Ao(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&de.get(r)instanceof zt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=de.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!H.ios||!this.children.some(s=>s instanceof Nt))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Nt)||/[^ -~]/.test(i.text))return null;let r=mn(i.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=jh(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=i.bottom-i.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(e){return!1}covers(){return!0}static find(e,t){for(let i=0,r=0;i<e.children.length;i++){let s=e.children[i],o=r+s.length;if(o>=t){if(s instanceof n)return s;if(o>t)break}r=o+s.breakAfter}return null}},Ei=class n extends de{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Oe.before(this.dom):Oe.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new n(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return il}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.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Q.empty}domBoundsAround(){return null}become(e){return e instanceof n&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t==i?!1:e<0?t<0:i>0}},tt=class{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}destroy(e){}},et=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(et||(et={})),J=class extends Qe{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new yn(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 Ft(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=qh(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Ft(e,i,r,t,e.widget||null,!0)}static line(e){return new wn(e)}static set(e,t=!1){return ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};J.none=ie.empty;var yn=class n extends J{constructor(e){let{start:t,end:i}=qh(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 n&&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))&&nl(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)}};yn.prototype.point=!1;var wn=class n extends J{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&nl(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)}};wn.prototype.mapMode=Ce.TrackBefore;wn.prototype.point=!0;var Ft=class n extends J{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ce.TrackBefore:Ce.TrackAfter:Ce.TrackDel}get type(){return this.startSide!=this.endSide?et.WidgetRange:this.startSide<=0?et.WidgetBefore:et.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&jd(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)}};Ft.prototype.point=!0;function qh(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 jd(n,e){return n==e||!!(n&&e&&n.compare(e))}function To(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var hn=class n{constructor(e,t,i,r){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=r,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 Ei&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ae),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(lr(new kn(-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 Ei)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:s,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=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(lr(new Nt(this.text.slice(this.textOff,this.textOff+r)),t),i),this.atCursorPos=!0,this.textOff+=r,e-=r,i=0}}span(e,t,i,r){this.buildText(t-e,i,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,i,r,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Ft){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 Ft)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Ei(i.widget||new Sr("div"),l,i));else{let a=bn.create(i.widget||new Sr("span"),l,l?0:i.startSide),h=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<t||i.startSide>0),c=!a.isEditable&&(e<t||s>r.length||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),h&&(f.append(lr(new kn(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(lr(a,r),s),this.atCursorPos=c,this.pendingBuffer=c?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.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=s)}static build(e,t,i,r,s){let o=new n(e,t,i,s);return o.openEnd=ie.spans(r,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function lr(n,e){for(let t of e)n=new zt(t,[n],n.length);return n}var Sr=class extends tt{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}},$h=I.define(),Kh=I.define(),_h=I.define(),Gh=I.define(),Mo=I.define(),Uh=I.define(),Yh=I.define(),Jh=I.define({combine:n=>n.some(e=>e)}),qd=I.define({combine:n=>n.some(e=>e)}),cn=class n{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(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 n(L.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ar=X.define({map:(n,e)=>n.map(e)});function He(n,e,t){let i=n.facet(Gh);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)}var zr=I.define({combine:n=>n.length?n[0]:!0}),$d=0,sn=I.define(),ye=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.extension=s(this)}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n($d++,e,i,r,l=>{let a=[sn.of(l)];return o&&a.push(xn.of(h=>{let c=h.plugin(l);return c?o(c):J.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define(i=>new e(i),t)}},fn=class{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(He(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(r){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){He(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){He(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Xh=I.define(),rl=I.define(),xn=I.define(),sl=I.define(),Zh=I.define();function eh(n,e,t){let i=n.state.facet(Zh);if(!i.length)return i;let r=i.map(o=>o instanceof Function?o(n):o),s=[];return ie.spans(r,e,t,{point(){},span(o,l,a,h){let c=s;for(let f=a.length-1;f>=0;f--,h--){let u=a[f].spec.bidiIsolate,p;if(u!=null)if(h>0&&c.length&&(p=c[c.length-1]).to==o&&p.direction==u)p.to=l,c=p.inner;else{let g={from:o,to:l,direction:u,inner:[]};c.push(g),c=g.inner}}}}),s}var Qh=I.define();function ec(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(Qh)){let o=s(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&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var on=I.define(),ut=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(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 r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0,l=0;;r++){let a=r==e.length?null:e[r],h=o-l,c=a?a.fromB:1e9;for(;s<t.length&&t[s]<c;){let f=t[s],u=t[s+1],p=Math.max(l,f),g=Math.min(c,u);if(p<=g&&new n(p+h,g+h,p,g).addToSet(i),u>c)break;s+=2}if(!a)return i;new n(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}},Cr=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=De.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new ut(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(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}},ge=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(ge||(ge={})),vn=ge.LTR,tc=ge.RTL;function ic(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var Kd=ic("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),_d=ic("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Lo=Object.create(null),ht=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);Lo[e]=t,Lo[t]=-e}function Gd(n){return n<=247?Kd[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?_d[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var Ud=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,ft=class{get dir(){return this.level%2?tc:vn}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function nc(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!nc(i.inner,r.inner))return!1}return!0}var le=[];function Yd(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=Gd(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),le[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=le[h];if(u==128)h<l-1&&c==le[h+1]&&c&24?u=le[h]=c:le[h]=256;else if(u==64){let p=h+1;for(;p<l&&le[p]==64;)p++;let g=h&&c==8||p<t&&le[p]==8?f==1?1:8:256;for(let x=h;x<p;x++)le[x]=g;h=p-1}else u==8&&f==1&&(le[h]=1);c=u,u&7&&(f=u)}}}function Jd(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,p,g;f<c;f++)if(p=Lo[u=n.charCodeAt(f)])if(p<0){for(let x=l-3;x>=0;x-=3)if(ht[x+1]==-p){let y=ht[x+2],v=y&2?r:y&4?y&1?s:r:0;v&&(le[f]=le[ht[x]]=v),l=x;break}}else{if(ht.length==189)break;ht[l++]=f,ht[l++]=u,ht[l++]=a}else if((g=le[f])==2||g==1){let x=g==r;a=x?0:1;for(let y=l-3;y>=0;y-=3){let v=ht[y+2];if(v&2)break;if(x)ht[y+2]|=2;else{if(v&4)break;ht[y+2]|=4}}}}}function Xd(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=le[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(le[c]==256)c++;else break;let f=s==1,u=(c<e?le[c]:i)==1,p=f==u?f?1:2:i;for(let g=c,x=r,y=x?t[x-1].to:n;g>a;)g==y&&(g=t[--x].from,y=x?t[x-1].to:n),le[--g]=p;a=c}else s=h,a++}}}function Do(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let x=le[a];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h<s.length&&g==s[h].from){if(f)break e;let x=s[h];if(!c)for(let y=x.to,v=h+1;;){if(y==t)break e;if(v<s.length&&s[v].from==y)y=s[v++].to;else{if(le[y]==l)break e;break}}if(h++,u)u.push(x);else{x.from>a&&o.push(new ft(a,x.from,p));let y=x.direction==vn!=!(p%2);Oo(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.to}g=x.to}else{if(g==t||(c?le[g]!=l:le[g]==l))break;g++}u?Do(n,a,g,i+1,r,u,o):a<g&&o.push(new ft(a,g,p)),a=g}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let x=le[a-1];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h&&g==s[h-1].to){if(f)break e;let x=s[--h];if(!c)for(let y=x.from,v=h;;){if(y==e)break e;if(v&&s[v-1].to==y)y=s[--v].from;else{if(le[y-1]==l)break e;break}}if(u)u.push(x);else{x.to<a&&o.push(new ft(x.to,a,p));let y=x.direction==vn!=!(p%2);Oo(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.from}g=x.from}else{if(g==e||(c?le[g-1]!=l:le[g-1]==l))break;g--}u?Do(n,g,a,i+1,r,u,o):g<a&&o.push(new ft(g,a,p)),a=g}}function Oo(n,e,t,i,r,s,o){let l=e%2?2:1;Yd(n,r,s,i,l),Jd(n,r,s,i,l),Xd(r,s,i,l),Do(n,r,s,e,t,i,o)}function Zd(n,e,t){if(!n)return[new ft(0,0,e==tc?1:0)];if(e==vn&&!t.length&&!Ud.test(n))return rc(n.length);if(t.length)for(;n.length>le.length;)le[le.length]=256;let i=[],r=e==vn?0:1;return Oo(n,r,r,t,0,n.length,i),i}function rc(n){return[new ft(0,n,0)]}var sc="";function Qd(n,e,t,i,r){var s;let o=i.head-n.from,l=-1;if(o==0){if(!r||!n.length)return null;e[0].level!=t&&(o=e[0].side(!1,t),l=0)}else if(o==n.length){if(r)return null;let u=e[e.length-1];u.level!=t&&(o=u.side(!0,t),l=e.length-1)}l<0&&(l=ft.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc));let a=e[l];o==a.side(r,t)&&(a=e[l+=r?1:-1],o=a.side(!r,t));let h=r==(a.dir==t),c=be(n.text,o,h);if(sc=n.text.slice(Math.min(o,c),Math.max(o,c)),c>a.from&&c<a.to)return L.cursor(c+n.from,h?-1:1,a.level);let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return!f&&a.level!=t?L.cursor(r?n.to:n.from,r?-1:1,t):f&&f.level<a.level?L.cursor(f.side(!r,t)+n.from,r?1:-1,f.level):L.cursor(c+n.from,r?-1:1,a.level)}var Ar=class extends de{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.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 Ae],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ut(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})=>c<this.minWidthFrom||h>this.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 r=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!op(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?tp(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new ut(h,c,e.changes.mapPos(h,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(H.ie||H.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=rp(o,l,e.changes);return i=ut.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=H.chrome||H.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Ei&&o.widget instanceof Tr&&s.push(o.dom);r.updateGaps(s)}updateChildren(e,t,i){let r=i?i.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=r.length-1;;o--){let l=o>=0?r[o]:null;if(!l)break;let{fromA:a,toA:h,fromB:c,toB:f}=l,u,p,g,x;if(i&&i.range.fromB<f&&i.range.toB>c){let R=hn.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),F=hn.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);p=R.breakAtStart,g=R.openStart,x=F.openEnd;let q=this.compositionView(i);F.breakAtStart?q.breakAfter=1:F.content.length&&q.merge(q.length,q.length,F.content[0],!1,F.openStart,0)&&(q.breakAfter=F.content[0].breakAfter,F.content.shift()),R.content.length&&q.merge(0,0,R.content[R.content.length-1],!0,0,R.openEnd)&&R.content.pop(),u=R.content.concat(q).concat(F.content)}else({content:u,breakAtStart:p,openStart:g,openEnd:x}=hn.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:y,off:v}=s.findPos(h,1),{i:M,off:O}=s.findPos(a,-1);Nh(this,M,O,y,v,u,p,g,x)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new Nt(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new zt(r,[t],t.length);let i=new Ae;return i.append(t,0),i}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=de.get(s);l&&l!=o&&(l.dom=null),o.setDOM(s)},i=this.childPos(e.range.fromB,1),r=this.children[i.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)i=r.childPos(i.off,1),r=r.children[i.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&gr(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||t||s))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(H.gecko&&l.empty&&!this.hasComposition&&ep(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=h=new Oe(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||!xr(a.node,a.offset,c.anchorNode,c.anchorOffset)||!xr(h.node,h.offset,c.focusNode,c.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(c.focusNode)&&sp(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=wr(this.view.root);if(f)if(l.empty){if(H.gecko){let u=ip(a.node,a.offset);if(u&&u!=3){let p=lc(a.node,a.offset,u==1?1:-1);p&&(a=new Oe(p.node,p.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)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new Oe(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new Oe(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=wr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=Ae.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(r,s)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let r=e.offset;!i&&r<t.childNodes.length;r++){let s=de.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(0))}for(let r=e.offset-1;!i&&r>=0;r--){let s=de.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(s.length))}return i?new Oe(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=de.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<this.children.length-1;){let r=this.children[t];if(i<r.length||r instanceof Ae)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,r=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],a=s-l.breakAfter,h=a-l.length;if(a<e)break;h<=e&&(h<e||l.covers(-1))&&(a>e||l.covers(1))&&(!i||l instanceof Ae&&!(i instanceof Ae&&t>=0))&&(i=l,r=h),s=h}return i?i.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Ae))return null;for(;r.children.length;){let{i:l,off:a}=r.childPos(i,1);for(;;l++){if(l==r.children.length)return null;if((r=r.children[l]).length)break}i=a}if(!(r instanceof Nt))return null;let s=be(r.text,i);if(s==i)return null;let o=ti(r.dom,i,s).getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(l==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ge.LTR;for(let h=0,c=0;c<this.children.length;c++){let f=this.children[c],u=h+f.length;if(u>r)break;if(h>=i){let p=f.dom.getBoundingClientRect();if(t.push(p.height),o){let g=f.dom.lastChild,x=g?mn(g):[];if(x.length){let y=x[x.length-1],v=a?y.right-p.left:p.right-y.left;v>l&&(l=v,this.minWidth=s,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"?ge.RTL:ge.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ae){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,r;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 s=mn(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new vr(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(J.replace({widget:new Tr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return J.set(e)}updateDeco(){let e=this.view.state.facet(xn).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=ec(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;Rd(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ge.LTR)}};function ep(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}var Tr=class extends tt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function oc(n,e){let t=n.observer.selectionRange,i=t.focusNode&&lc(t.focusNode,t.focusOffset,0);if(!i)return null;let r=e-i.offset;return{from:r,to:r+i.node.nodeValue.length,node:i.node}}function tp(n,e,t){let i=oc(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc,h=new ut(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let f=r.parentNode;;f=f.parentNode){let u=de.get(f);if(u instanceof zt)c.push({node:f,deco:u.mark});else{if(u instanceof Ae||f.nodeName=="DIV"&&f.parentNode==n.contentDOM)return{range:h,text:r,marks:c,line:f};if(f!=n.contentDOM)c.push({node:f,deco:new yn({inclusive:!0,attributes:Wd(f),tagName:f.tagName.toLowerCase()})});else return null}}}function lc(n,e,t){if(t<=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r>0)i=i.childNodes[r-1],r=Tt(i);else break}if(t>=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r<i.childNodes.length&&t>=0)i=i.childNodes[r],r=0;else break}return null}function ip(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var np=class{constructor(){this.changes=[]}compareRange(e,t){To(e,t,this.changes)}comparePoint(e,t){To(e,t,this.changes)}};function rp(n,e,t){let i=new np;return ie.compare(n,e,t,i),i.changes}function sp(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function op(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}function lp(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return L.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=be(r.text,s,!1):l=be(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=be(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=be(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return L.range(o+r.from,l+r.from)}function ap(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function hp(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function fo(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function th(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function ih(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function Eo(n,e,t){let i,r,s,o,l=!1,a,h,c,f;for(let g=n.firstChild;g;g=g.nextSibling){let x=mn(g);for(let y=0;y<x.length;y++){let v=x[y];r&&fo(r,v)&&(v=th(ih(v,r.bottom),r.top));let M=ap(e,v),O=hp(t,v);if(M==0&&O==0)return g.nodeType==3?nh(g,e,t):Eo(g,e,t);if(!i||o>O||o==O&&s>M){i=g,r=v,s=M,o=O;let R=O?t<v.top?-1:1:M?e<v.left?-1:1:0;l=!R||(R>0?y<x.length-1:y>0)}M==0?t>v.bottom&&(!c||c.bottom<v.bottom)?(a=g,c=v):t<v.top&&(!f||f.top>v.top)&&(h=g,f=v):c&&fo(c,v)?c=ih(c,v.bottom):f&&fo(f,v)&&(f=th(f,v.top))}}if(c&&c.bottom>=t?(i=a,r=c):f&&f.top<=t&&(i=h,r=f),!i)return{node:n,offset:0};let u=Math.max(r.left,Math.min(r.right,e));if(i.nodeType==3)return nh(i,u,t);if(l&&i.contentEditable!="false")return Eo(i,u,t);let p=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(r.left+r.right)/2?1:0);return{node:n,offset:p}}function nh(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let a=ti(n,l,l+1).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(c.top==c.bottom)continue;o||(o=e-c.left);let f=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f<s){let u=e>=(c.left+c.right)/2,p=u;if((H.chrome||H.gecko)&&ti(n,l).getBoundingClientRect().left==c.right&&(p=!u),f<=0)return{node:n,offset:l+(p?1:0)};r=l+(p?1:0),s=f}}}return{node:n,offset:r>-1?r:o>0?n.nodeValue.length:0}}function ac(n,e,t,i=-1){var r,s;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 R=n.viewState.heightOracle.textHeight/2,F=!1;a=n.elementAtHeight(u),a.type!=et.Text;)for(;u=i>0?a.bottom+R:a.top-R,!(u>=0&&u<=h);){if(F)return t?null:0;F=!0,i=-i}f=l+u;let p=a.from;if(p<n.viewport.from)return n.viewport.from==0?0:t?null:rh(n,o,a,c,f);if(p>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:rh(n,o,a,c,f);let g=n.dom.ownerDocument,x=n.root.elementFromPoint?n.root:g,y=x.elementFromPoint(c,f);y&&!n.contentDOM.contains(y)&&(y=null),y||(c=Math.max(o.left+1,Math.min(o.right-1,c)),y=x.elementFromPoint(c,f),y&&!n.contentDOM.contains(y)&&(y=null));let v,M=-1;if(y&&((r=n.docView.nearest(y))===null||r===void 0?void 0:r.isEditable)!=!1){if(g.caretPositionFromPoint){let R=g.caretPositionFromPoint(c,f);R&&({offsetNode:v,offset:M}=R)}else if(g.caretRangeFromPoint){let R=g.caretRangeFromPoint(c,f);R&&({startContainer:v,startOffset:M}=R,(!n.contentDOM.contains(v)||H.safari&&cp(v,M,c)||H.chrome&&fp(v,M,c))&&(v=void 0))}}if(!v||!n.docView.dom.contains(v)){let R=Ae.find(n.docView,p);if(!R)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:M}=Eo(R.dom,c,f))}let O=n.docView.nearest(v);if(!O)return null;if(O.isWidget&&((s=O.dom)===null||s===void 0?void 0:s.nodeType)==1){let R=O.dom.getBoundingClientRect();return e.y<R.top||e.y<=R.bottom&&e.x<=(R.left+R.right)/2?O.posAtStart:O.posAtEnd}else return O.localPosFromDOM(v,M)+O.posAtStart}function rh(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+ja(o,s,n.state.tabSize)}function cp(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let r=n.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return ti(n,i-1,i).getBoundingClientRect().left>t}function fp(n,e,t){if(e!=0)return!1;for(let r=n;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let i=n.nodeType==1?n.getBoundingClientRect():ti(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function up(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==et.Text))return i}return t}function dp(n,e,t,i){let r=up(n,e.head),s=!i||r.type!=et.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==ge.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return L.cursor(a,t?-1:1)}return L.cursor(t?r.to:r.from,t?-1:1)}function sh(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let h=Qd(r,s,o,l,t),c=sc;if(!h){if(r.number==(t?n.state.doc.lines:1))return l;c=`
8
+ `,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),h=L.cursor(t?r.from:r.to)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function pp(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==ue.Space&&(r=o),r==o}}function mp(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return L.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(r,e.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=i!=null?i:n.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let g=l+(u+p)*s,x=ac(n,{x:f,y:g},!1,s);if(g<a.top||g>a.bottom||(s<0?x<r:x>r)){let y=n.docView.coordsForChar(x),v=!y||g<y.top?-1:1;return L.cursor(x,v,void 0,o)}}}function br(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||t||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function uo(n,e,t){let i=br(n.state.facet(sl).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:L.cursor(i,i<t.from?1:-1)}var Bo=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,H.safari&&e.contentDOM.addEventListener("input",()=>null),H.gecko&&Op(e.contentDOM.ownerDocument)}handleEvent(e){!vp(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 r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=gp(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&cc.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),H.android&&H.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return H.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=hc.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||bp.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(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,Oi(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:H.safari&&!H.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 oh(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){He(t.state,r)}}}function gp(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(oh(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(oh(i.value,o))}}for(let i in it)t(i).handlers.push(it[i]);for(let i in nt)t(i).observers.push(nt[i]);return e}var hc=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],bp="dthko",cc=[16,17,18,20,91,92,224,225],hr=6;function cr(n){return Math.max(0,n)*.7+8}function kp(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var Po=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=Id(e.contentDOM),this.atoms=e.state.facet(sl).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(oe.allowMultipleSelections)&&yp(e,t),this.dragging=xp(e,t)&&pc(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&&kp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,r=0,s=((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=ec(this.view);e.clientX-o.left<=s.left+hr?i=-cr(s.left-e.clientX):e.clientX+o.right>=s.right-hr&&(i=cr(e.clientX-s.right)),e.clientY-o.top<=s.top+hr?r=-cr(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-hr&&(r=cr(e.clientY-s.bottom)),this.setScrollSpeed(i,r)}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;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=br(this.atoms,r.from,0);o!=r.from&&(s=L.cursor(o,-1))}else{let o=br(this.atoms,r.from,-1),l=br(this.atoms,r.to,1);(o!=r.from||l!=r.to)&&(s=L.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?L.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection)||i.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function yp(n,e){let t=n.state.facet($h);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function wp(n,e){let t=n.state.facet(Kh);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function xp(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=wr(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function vp(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=de.get(t))&&i.ignoreEvent(e))return!1;return!0}var it=Object.create(null),nt=Object.create(null),fc=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function Sp(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(),uc(n,t.value)},50)}function uc(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Ro!=null&&t.selection.ranges.every(a=>a.empty)&&Ro==s.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?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:L.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:L.cursor(a.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}nt.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};it.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);nt.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};nt.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};it.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(_h))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Tp(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Po(n,e,t,i)),i&&n.observer.ignore(()=>Ph(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function lh(n,e,t,i){if(i==1)return L.cursor(e,t);if(i==2)return lp(n.state,e,t);{let r=Ae.find(n.docView,e),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,L.range(o,l)}}var dc=(n,e)=>n>=e.top&&n<=e.bottom,ah=(n,e,t)=>dc(e,t)&&n>=t.left&&n<=t.right;function Cp(n,e,t,i){let r=Ae.find(n.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&ah(t,i,o))return-1;let l=r.coordsAt(s,1);return l&&ah(t,i,l)?1:o&&dc(i,o)?-1:1}function hh(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Cp(n,t,e.clientX,e.clientY)}}var Ap=H.ie&&H.ie_version<=11,ch=null,fh=0,uh=0;function pc(n){if(!Ap)return n.detail;let e=ch,t=uh;return ch=n,uh=Date.now(),fh=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(fh+1)%3:1}function Tp(n,e){let t=hh(n,e),i=pc(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=hh(n,s),h,c=lh(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=lh(n,t.pos,t.bias,i),u=Math.min(f.from,c.from),p=Math.max(f.to,c.to);c=u<c.from?L.range(u,p):L.range(p,u)}return o?r.replaceRange(r.main.extend(c.from,c.to)):l&&i==1&&r.ranges.length>1&&(h=Mp(r,a.pos))?h:l?r.addRange(c):L.create([c])}}}function Mp(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return L.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}it.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=L.range(s,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};it.dragend=n=>(n.inputState.draggedContent=null,!1);function dh(n,e,t,i){if(!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&wp(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}it.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),r=0,s=()=>{++r==t.length&&dh(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return dh(n,e,i,!0),!0}return!1};it.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=fc?null:e.clipboardData;return t?(uc(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(Sp(n),!1)};function Lp(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 Dp(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}var Ro=null;it.copy=it.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=Dp(n.state);if(!t&&!r)return!1;Ro=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=fc?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Lp(n,t),!1)};var mc=Ne.define();function gc(n,e){let t=[];for(let i of n.facet(Yh)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:mc.of(!0)}):null}function bc(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=gc(n.state,e);t?n.dispatch(t):n.update([])}},10)}nt.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),bc(n)};nt.blur=n=>{n.observer.clearSelectionRange(),bc(n)};nt.compositionstart=nt.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};nt.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,H.chrome&&H.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};nt.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};it.beforeinput=(n,e)=>{var t;let i;if(H.chrome&&H.android&&(i=hc.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return!1};var ph=new Set;function Op(n){ph.has(n)||(ph.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var mh=["pre-wrap","normal","pre-line","break-spaces"],Io=class{constructor(e){this.lineWrapping=e,this.doc=Q.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 mh.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=mh.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},No=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},ct=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?et.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Ft?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ce=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(ce||(ce={})),kr=.001,Ve=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>kr&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,ce.ByPosNoHeight,i.setDoc(t),0,0),p=u.to>=h?u:s.lineAt(h,ce.ByPosNoHeight,i,0,0);for(f+=p.to-h,h=p.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,ce.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let g=Fo.build(i.setDoc(o),e,c,f);s=s.replace(a,h,g)}return s.updateHeight(i,0)}static empty(){return new _e(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*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,r-=l.size}else if(s>r*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,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new zo(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};Ve.prototype.size=1;var Mr=class extends Ve{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,r){return new ct(r,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,r,s){return this.blockAt(0,i,r,s)}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,i,r,s))}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},_e=class n extends Mr{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new ct(r,this.length,i,this.height,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof It&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof It?r=new n(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ve.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.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:""})`}},It=class n extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new ct(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(s+h);return new ct(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==ce.ByHeight)return this.blockAt(e,i,r,s);if(t==ce.ByPosNoHeight){let{from:p,to:g}=i.doc.lineAt(e);return new ct(p,g-p,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new ct(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,s);for(let c=e,f=r;c<=t;){let u=i.doc.lineAt(c);if(c==e){let g=u.number-l;f+=a*g+h*(e-s-g)}let p=a+h*u.length;o(new ct(u.from,u.length,f,p,0)),f+=p,c=u.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++];a==-1?a=f:Math.abs(f-a)>=kr&&(a=-2);let u=new _e(c,f);u.outdated=!1,o.push(u),l+=c+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let h=Ve.of(o);return(a<0||Math.abs(h.height-this.height)>=kr||Math.abs(a-this.heightMetrics(e,t).perLine)>=kr)&&(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})`}},zo=class extends Ve{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,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ce.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==ce.ByPosNoHeight?ce.ByPosNoHeight:ce.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(h)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,ce.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=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 r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&gh(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),gh(s,l)}return Ve.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ve.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,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function gh(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof It&&(i=n[e+1])instanceof It&&n.splice(e-1,3,new It(t.length+1+i.length))}var Ep=5,Fo=class n{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),r=this.nodes[this.nodes.length-1];r instanceof _e?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new _e(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<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Mr(o,r,i)):(o||s||r>=Ep)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _e(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new It(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 _e)return e;let t=new _e(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 r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.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 _e)&&!this.isCovered?this.nodes.push(new _e(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof _e&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return ie.spans(t,i,r,s,0),s.finish(i)}};function Bp(n,e,t){let i=new Ho;return ie.compare(n,e,t,i,0),i.changes}var Ho=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&To(e,t,this.changes,5)}};function Pp(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,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:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Rp(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var un=class{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;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return J.replace({widget:new Vo(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Vo=class extends tt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Lr=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=bh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ge.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(rl).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Io(t),this.stateDeco=e.facet(xn).filter(i=>typeof i!="function"),this.heightMap=Ve.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle.setDoc(e.doc),[new ut(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=J.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 r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Mi(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?bh:new Wo(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:ln(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(xn).filter(c=>typeof c!="function");let r=e.changedRanges,s=ut.extendWithRanges(r,Bp(i,this.stateDeco,e?e.changes:De.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),s),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=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.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(qd)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ge.RTL:ge.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),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:R,scaleY:F}=Bh(t,l);(this.scaleX!=R||this.scaleY!=F)&&(this.scaleX=R,this.scaleY=F,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&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=Ih(e.scrollDOM);let g=(this.printing?Rp:Pp)(t,this.paddingTop),x=g.top-this.pixelViewport.top,y=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let M=l.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let R=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(R)&&(o=!0),o||r.lineWrapping&&Math.abs(M-this.contentDOMWidth)>r.charWidth){let{lineHeight:F,charWidth:q,textHeight:w}=e.docView.measureTextSize();o=F>0&&r.refresh(s,F,q,w,M/q,R),o&&(e.docView.minWidth=0,h|=8)}x>0&&y>0?c=Math.max(x,y):x<0&&y<0&&(c=Math.min(x,y)),r.heightChanged=!1;for(let F of this.viewports){let q=F.from==this.viewport.from?R:e.docView.measureVisibleLineHeights(F);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle,[new ut(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new No(F.from,q))}r.heightChanged&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||O)&&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)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Mi(r.lineAt(o-i*1e3,ce.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ce.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,ce.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new Mi(r.lineAt(u-1e3/2,ce.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,ce.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Mi(this.heightMap.lineAt(i,ce.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ce.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ce.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new un(t.mapPos(r.from),t.mapPos(r.to),r.size));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=ge.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-h<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let y of g)if(y>h&&y<c){a(h,y-10,f,u),a(y+10,c,f,u);return}let x=Np(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)<s&&Math.abs(y.to-c)<s&&!g.some(v=>y.from<v&&y.to>v));if(!x){if(c<f.to&&t&&i&&t.visibleRanges.some(y=>y.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(L.cursor(c),!1,!0).head;y>h&&(c=y)}x=new un(h,c,this.gapSize(f,h,c,u))}l.push(x)};for(let h of this.viewportLines){if(h.length<o)continue;let c=Ip(h.from,h.to,this.stateDeco);if(c.total<o)continue;let f=this.scrollTarget?this.scrollTarget.range.head:null,u,p;if(i){let g=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(f!=null){let v=ur(c,f),M=((this.visibleBottom-this.visibleTop)/2+g)/h.height;x=v-M,y=v+M}else x=(this.visibleTop-h.top-g)/h.height,y=(this.visibleBottom-h.top+g)/h.height;u=fr(c,x),p=fr(c,y)}else{let g=c.total*this.heightOracle.charWidth,x=r*this.heightOracle.charWidth,y,v;if(f!=null){let M=ur(c,f),O=((this.pixelViewport.right-this.pixelViewport.left)/2+x)/g;y=M-O,v=M+O}else y=(this.pixelViewport.left-x)/g,v=(this.pixelViewport.right+x)/g;u=fr(c,y),p=fr(c,v)}u>h.from&&a(h.from,u,h,c),p<h.to&&a(p,h.to,h,c)}return l}gapSize(e,t,i,r){let s=ur(r,i)-ur(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){un.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=J.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];ie.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].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)||ln(this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return ln(this.heightMap.lineAt(this.scaler.fromDOM(e),ce.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 ln(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}},Mi=class{constructor(e,t){this.from=e,this.to=t}};function Ip(n,e,t){let i=[],r=n,s=0;return ie.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function fr({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function ur(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Np(n,e){for(let t of n)if(e(t))return t}var bh={toDOM(n){return n},fromDOM(n){return n},scale:1},Wo=class{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,ce.ByPos,e,0,0).top,c=t.lineAt(a,ce.ByPos,e,0,0).bottom;return r+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}};function ln(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new ct(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>ln(r,e)):n._content)}var dr=I.define({combine:n=>n.join(" ")}),jo=I.define({combine:n=>n.indexOf(!0)>-1}),qo=Ke.newName(),kc=Ke.newName(),yc=Ke.newName(),wc={"&light":"."+kc,"&dark":"."+yc};function $o(n,e,t){return new Ke(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var zp=$o("."+qo,{"&":{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-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},wc),an="\uFFFF",Ko=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(oe.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=an}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let l=de.get(r),a=de.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:kh(r))||kh(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=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,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<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=s+o}}readNode(e){if(e.cmIgnore)return;let t=de.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.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+(Fp(e,i.node,i.offset)?t:0))}};function Fp(n,e,t){for(;;){if(!e||t<Tt(e))return!1;if(e==n)return!0;t=gn(e)+1,e=e.parentNode}}function kh(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}var Dr=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},_o=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=s||o?[]:Wp(e),a=new Ko(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=jp(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!yo(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||!yo(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=L.single(h,a)}}};function xc(n,e){let t,{newSel:i}=e,r=n.state.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=r.from,h=null;(s===8||H.android&&e.text.length<l-o)&&(a=r.to,h="end");let c=Vp(n.state.doc.sliceString(o,l,an),e.text,a-o,h);c&&(H.chrome&&s==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==an+an&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:Q.of(e.text.slice(c.from,c.toB).split(an))})}else i&&(!n.hasFocus&&n.state.facet(zr)||i.main.eq(r))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!r.empty&&i&&i.main.empty?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,r.to))}:(H.mac||H.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Q.of([" "])}):H.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
9
+ `&&n.lineWrapping&&(i&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Q.of([" "])}),t){if(H.ios&&n.inputState.flushIOSKey()||H.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&Oi(n.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&Oi(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Oi(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,a=()=>l||(l=Hp(n,t,i));return n.state.facet(Uh).some(h=>h(n,t.from,t.to,o,a))||n.dispatch(a()),!0}else if(i&&!i.main.eq(r)){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 Hp(n,e,t){let i,r=n.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+a))}else{let l=r.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),c,f=t&&oc(n,t.main.head);if(f){let g=e.insert.length-(e.to-e.from);c={from:f.from,to:f.to-g}}else c=n.state.doc.lineAt(s.head);let u=s.to-e.to,p=s.to-s.from;i=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:l,range:a||g.map(l)};let x=g.to-u,y=x-h.length;if(g.to-g.from!=p||n.state.sliceDoc(y,x)!=h||g.to>=c.from&&g.from<=c.to)return{range:g};let v=r.changes({from:y,to:x,insert:e.insert}),M=g.to-s.to;return{changes:v,range:a?L.range(Math.max(0,a.anchor+M),Math.max(0,a.head+M)):g.map(v)}})}else i={changes:l,selection:a&&r.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)),r.update(i,{userEvent:o,scrollIntoView:!0})}function Vp(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Wp(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Dr(t,i)),(r!=t||s!=i)&&e.push(new Dr(r,s))),e}function jp(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?L.single(t+e,i+e):null}var qp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},po=H.ie&&H.ie_version<=11,Go=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new wo,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.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(H.ie&&H.ie_version<=11||H.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()}),po&&(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),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{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(){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,r=this.selectionRange;if(i.state.facet(zr)?i.root.activeElement!=this.dom:!gr(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!i.state.selection.main.empty&&r.focusNode&&xr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=H.safari&&e.root.nodeType==11&&Bd(this.dom.ownerDocument)==this.dom&&$p(this.view)||wr(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=gr(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&zd(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,qp),po&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),po&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Oi(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){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,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!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:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&gr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new _o(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}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,r=xc(this.view,t);return this.view.state==i&&this.view.update([]),r}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=yh(t,e.previousSibling||e.target.previousSibling,-1),r=yh(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):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),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),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 r of this.scrollTargets)r.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 yh(n,e,t){for(;e;){let i=de.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function $p(n){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return xr(l.node,l.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}var z=class n{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);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(r=>t(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Nd(e.parent)||document,this.viewState=new Lr(e.state||oe.create(e)),e.scrollTo&&e.scrollTo.is(ar)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(sn).map(i=>new fn(i));for(let i of this.plugins)i.update(this);this.observer=new Go(this),this.inputState=new Bo(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ar(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}dispatch(...e){let t=e.length==1&&e[0]instanceof xe?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,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(mc))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=gc(s,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(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(oe.phrases)!=this.state.facet(oe.phrases))return this.setState(s);r=Cr.create(this,s,e),r.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:p}=u.state.selection;f=new cn(p.empty?p:L.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of u.effects)p.is(ar)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Or.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(on)!=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(r.startState.facet(dr)!=r.state.facet(dr)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let u of this.state.facet(Mo))try{u(r)}catch(p){He(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!xc(this,c)&&h.force&&Oi(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 Lr(e),this.plugins=e.facet(sn).map(i=>new fn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Ar(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(sn),i=e.state.facet(sn);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new fn(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-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,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Ih(i))s=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.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(p=>{try{return p.read(this)}catch(g){return He(this.state,g),wh}}),f=Cr.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));for(let p=0;p<h.length;p++)if(c[p]!=wh)try{let g=h[p];g.write&&g.write(c[p],this)}catch(g){He(this.state,g)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let g=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(g>1||g<-1){r=r+g,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Mo))l(t)}get themeClasses(){return qo+" "+(this.state.facet(jo)?yc:kc)+" "+this.state.facet(dr)}updateAttrs(){let e=xh(this,Xh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(zr)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),xh(this,rl,t);let i=this.observer.ignore(()=>{let r=Ao(this.contentDOM,this.contentAttrs,t),s=Ao(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(on);let e=this.state.facet(n.cspNonce);Ke.mount(this.root,this.styleModules.concat(zp).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;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.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 uo(this,e,sh(this,e,t,i))}moveByGroup(e,t){return uo(this,e,sh(this,e,t,i=>pp(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return dp(this,e,t,i)}moveVertically(e,t,i){return uo(this,e,mp(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(),ac(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 r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[ft.find(s,e-r.from,-1,t)];return tl(i,o.dir==ge.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(Jh)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Kp)return rc(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||nc(s.isolates,i=eh(this,e.from,e.to))))return s.order;i||(i=eh(this,e.from,e.to));let r=Zd(e.text,t,i);return this.bidiCache.push(new Or(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ph(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 ar.of(new cn(typeof e=="number"?L.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 ar.of(new cn(L.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return ye.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ye.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Ke.newName(),r=[dr.of(i),on.of($o(`.${i}`,e))];return t&&t.dark&&r.push(jo.of(!0)),r}static baseTheme(e){return Bt.lowest(on.of($o("."+qo,e,wc)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&de.get(i)||de.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}};z.styleModule=on;z.inputHandler=Uh;z.focusChangeEffect=Yh;z.perLineTextDirection=Jh;z.exceptionSink=Gh;z.updateListener=Mo;z.editable=zr;z.mouseSelectionStyle=_h;z.dragMovesSelection=Kh;z.clickAddsSelectionRange=$h;z.decorations=xn;z.atomicRanges=sl;z.bidiIsolatedRanges=Zh;z.scrollMargins=Qh;z.darkTheme=jo;z.cspNonce=I.define({combine:n=>n.length?n[0]:""});z.contentAttributes=rl;z.editorAttributes=Xh;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=X.define();var Kp=4096,wh={},Or=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ge.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function xh(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&Co(o,t)}return t}var _p=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Gp(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function pr(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var Up=Bt.default(z.domEventHandlers({keydown(n,e){return Cc(vc(e.state),n,e,"editor")}})),Fr=I.define({enables:Up}),vh=new WeakMap;function vc(n){let e=n.facet(Fr),t=vh.get(e);return t||vh.set(e,t=Jp(e.reduce((i,r)=>i.concat(r),[]))),t}function Sc(n,e,t){return Cc(vc(n.state),e,n,t)}var Rt=null,Yp=4e3;function Jp(n,e=_p){let t=Object.create(null),i=Object.create(null),r=(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")},s=(o,l,a,h,c)=>{var f,u;let p=t[o]||(t[o]=Object.create(null)),g=l.split(/ (?!$)/).map(v=>Gp(v,e));for(let v=1;v<g.length;v++){let M=g.slice(0,v).join(" ");r(M,!0),p[M]||(p[M]={preventDefault:!0,stopPropagation:!1,run:[O=>{let R=Rt={view:O,prefix:M,scope:o};return setTimeout(()=>{Rt==R&&(Rt=null)},Yp),!0}]})}let x=g.join(" ");r(x,!1);let y=p[x]||(p[x]={preventDefault:!1,stopPropagation:!1,run:((u=(f=p._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&y.run.push(a),h&&(y.preventDefault=!0),c&&(y.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)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}function Cc(n,e,t,i){let r=_a(e),s=$e(r,0),o=St(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;Rt&&Rt.view==t&&Rt.scope==i&&(l=Rt.prefix+" ",cc.indexOf(e.keyCode)<0&&(h=!0,Rt=null));let f=new Set,u=y=>{if(y){for(let v of y.run)if(!f.has(v)&&(f.add(v),v(t,e)))return y.stopPropagation&&(c=!0),!0;y.preventDefault&&(y.stopPropagation&&(c=!0),h=!0)}return!1},p=n[i],g,x;return p&&(u(p[l+pr(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&(g=At[e.keyCode])&&g!=r?(u(p[l+pr(g,e,!0)])||e.shiftKey&&(x=Ai[e.keyCode])!=r&&x!=g&&u(p[l+pr(x,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(p[l+pr(r,e,!0)])&&(a=!0),!a&&u(p._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),a}var Xp=!H.ios;var Sh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Xp&&(Sh[".cm-line"].caretColor="transparent !important",Sh[".cm-content"]={caretColor:"transparent !important"});function Ch(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function Zp(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:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}var Sn=class{constructor(e){let{regexp:t,decoration:i,decorate:r,boundary:s,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,r)this.addMatch=(l,a,h,c)=>r(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=s,this.maxLength=o}createDeco(e){let t=new at,i=t.add.bind(t);for(let{from:r,to:s}of Zp(e,this.maxLength))Ch(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(i=Math.min(l,i),r=Math.max(a,r))}),e.viewportChanged||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),l=Math.min(s.to,r);if(l>o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(s.from,a.from),f=Math.min(s.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],p,g=(x,y,v)=>u.push(v.range(x,y));if(a==h)for(this.regexp.lastIndex=c-a.from;(p=this.regexp.exec(a.text))&&p.index<f-a.from;)this.addMatch(p,e,p.index+a.from,g);else Ch(e.state.doc,this.regexp,c,f,(x,y)=>this.addMatch(y,e,x,g));t=t.update({filterFrom:c,filterTo:f,filter:(x,y)=>x<c||y>f,add:u})}}return t}},Uo=/x/.unicode!=null?"gu":"g",Qp=new RegExp(`[\0-\b
10
+ -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Uo),em={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"},mo=null;function tm(){var n;if(mo==null&&typeof document!="undefined"&&document.body){let e=document.body.style;mo=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return mo||!1}var yr=I.define({combine(n){let e=ze(n,{render:null,specialChars:Qp,addSpecialChars:null});return(e.replaceTabs=!tm())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Uo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Uo)),e}});function Ac(n={}){return[yr.of(n),im()]}var Ah=null;function im(){return Ah||(Ah=ye.fromClass(class{constructor(n){this.view=n,this.decorations=J.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(yr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Sn({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=$e(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=Pt(o.text,l,i-o.from);return J.replace({widget:new Jo((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=J.replace({widget:new Yo(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(yr);n.startState.facet(yr)!=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}))}var nm="\u2022";function rm(n){return n>=32?nm:n==10?"\u2424":String.fromCharCode(9216+n)}var Yo=class extends tt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=rm(this.code),i=e.state.phrase("Control character")+" "+(em[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}},Jo=class extends tt{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 Tc(){return om}var sm=J.line({class:"cm-activeLine"}),om=ye.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 r=n.lineBlockAt(i.head);r.from>e&&(t.push(sm.range(r.from)),e=r.from)}return J.set(t)}},{decorations:n=>n.decorations});var rn="-10000px",Er=class{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r),this.tooltipViews=this.tooltips.map(i)}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<s.length;a++){let h=s[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(a.dom.remove(),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function lm(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var go=I.define({combine:n=>{var e,t,i;return{position:H.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||lm}}}),Th=new WeakMap,Mc=ye.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(go);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.manager=new Er(n,Cn,t=>this.createTooltip(t)),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(go);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.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 r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=rn,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(n=t.destroy)===null||n===void 0||n.call(t);this.parent&&this.container.remove(),(e=this.intersectionObserver)===null||e===void 0||e.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:r}=this.manager.tooltipViews[0];if(H.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(this.view.scaleX!=1||this.view.scaleY!=1)i=!0;else if(r.style.top==rn&&r.style.left=="0px"){let s=r.getBoundingClientRect();i=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(i||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(e=r.width/this.parent.offsetWidth,t=r.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((r,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(go).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:r,scaleY:s}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=n.pos[l],u=n.size[l];if(!f||f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1){c.style.top=rn;continue}let p=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,x=u.right-u.left,y=(e=Th.get(h))!==null&&e!==void 0?e:u.bottom-u.top,v=h.offset||hm,M=this.view.textDirection==ge.LTR,O=u.width>i.right-i.left?M?i.left:i.right-u.width:M?Math.min(f.left-(p?14:0)+v.x,i.right-x):Math.max(i.left,f.left-x+(p?14:0)-v.x),R=this.above[l];!a.strictSide&&(R?f.top-(u.bottom-u.top)-v.y<i.top:f.bottom+(u.bottom-u.top)+v.y>i.bottom)&&R==i.bottom-f.bottom>f.top-i.top&&(R=this.above[l]=!R);let F=(R?f.top-i.top:i.bottom-f.bottom)-g;if(F<y&&h.resize!==!1){if(F<this.view.defaultLineHeight){c.style.top=rn;continue}Th.set(h,y),c.style.height=(y=F)/s+"px"}else c.style.height&&(c.style.height="");let q=R?f.top-y-g-v.y:f.bottom+g+v.y,w=O+x;if(h.overlap!==!0)for(let D of o)D.left<w&&D.right>O&&D.top<q+y&&D.bottom>q&&(q=R?D.top-y-2-g:D.bottom+g+2);if(this.position=="absolute"?(c.style.top=(q-n.parent.top)/s+"px",c.style.left=(O-n.parent.left)/r+"px"):(c.style.top=q/s+"px",c.style.left=O/r+"px"),p){let D=f.left+(M?v.x:-v.x)-(O+14-7);p.style.left=D/r+"px"}h.overlap!==!0&&o.push({left:O,top:q,right:w,bottom:q+y}),c.classList.toggle("cm-tooltip-above",R),c.classList.toggle("cm-tooltip-below",!R),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=rn}},{eventObservers:{scroll(){this.maybeMeasure()}}}),am=z.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"}}}),hm={x:0,y:0},Cn=I.define({enables:[Mc,am]}),Br=I.define(),Pr=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Er(e,Br,t=>this.createHostedView(t))}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}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 r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)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")}},cm=Cn.compute([Br],n=>{let e=n.facet(Br).filter(t=>t);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:Pr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Xo=class{constructor(e,t,i,r,s){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=s,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)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let r,s=1;if(i instanceof bn)r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let l=e.coordsAtPos(r);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),h=a&&a.dir==ge.RTL?-1:1;s=t.x<l.left?-h:h}let o=this.source(e,r,s);if(o!=null&&o.then){let l=this.pending={pos:r};o.then(a=>{this.pending==l&&(this.pending=null,a&&e.dispatch({effects:this.setHover.of(a)}))},a=>He(e.state,a,"hover tooltip"))}else o&&e.dispatch({effects:this.setHover.of(o)})}get tooltip(){let e=this.view.plugin(Mc),t=e?e.manager.tooltips.findIndex(i=>i.create==Pr.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t;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:i,tooltip:r}=this;if(i&&r&&!fm(r.dom,e)||this.pending){let{pos:s}=i||this.pending,o=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!um(this.view,s,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},mr=4;function fm(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-mr&&e.clientX<=t.right+mr&&e.clientY>=t.top-mr&&e.clientY<=t.bottom+mr}function um(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=n.posAtCoords({x:i,y:r},!1);return a>=e&&a<=t}function Lc(n,e={}){let t=X.define(),i=me.define({create(){return null},update(r,s){if(r&&(e.hideOnChange&&(s.docChanged||s.selection)||e.hideOn&&e.hideOn(s,r)))return null;if(r&&s.docChanged){let o=s.changes.mapPos(r.pos,-1,Ce.TrackDel);if(o==null)return null;let l=Object.assign(Object.create(null),r);l.pos=o,r.end!=null&&(l.end=s.changes.mapPos(r.end)),r=l}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(dm)&&(r=null);return r},provide:r=>Br.from(r)});return[i,ye.define(r=>new Xo(r,n,i,t,e.hoverTime||300)),cm]}var dm=X.define();var Mh=I.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 ni(n,e){let t=n.plugin(Dc),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var Dc=ye.fromClass(class{constructor(n){this.input=n.state.facet(ii),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Mh);this.top=new Li(n,!0,e.topContainer),this.bottom=new Li(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(Mh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Li(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Li(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(ii);if(t!=this.input){let i=t.filter(a=>a),r=[],s=[],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)),r.push(c),(c.top?s:o).push(c)}this.specs=i,this.panels=r,this.top.sync(s),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=>z.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Li=class{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=Lh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Lh(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 Lh(n){let e=n.nextSibling;return n.remove(),e}var ii=I.define({enables:Dc}),Ge=class extends Qe{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Ge.prototype.elementClass="";Ge.prototype.toDOM=void 0;Ge.prototype.mapMode=Ce.TrackBefore;Ge.prototype.startSide=Ge.prototype.endSide=-1;Ge.prototype.point=!0;var bo=I.define(),pm={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},dn=I.define();function ol(n){return[Oc(),dn.of(Object.assign(Object.assign({},pm),n))]}var Zo=I.define({combine:n=>n.some(e=>e)});function Oc(n){let e=[mm];return n&&n.fixed===!1&&e.push(Zo.of(!0)),e}var mm=ye.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(dn).map(e=>new Rr(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(Zo),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+"px"),this.view.state.facet(Zo)!=!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=ie.iter(this.view.state.facet(bo),this.view.viewport.from),i=[],r=this.gutters.map(s=>new el(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==et.Text&&o){Qo(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==et.Text){Qo(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(dn),t=n.state.facet(dn),i=n.docChanged||n.heightChanged||n.viewportChanged||!ie.eq(n.startState.facet(bo),n.state.facet(bo),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Rr(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==ge.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function Dh(n){return Array.isArray(n)?n:[n]}function Qo(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var el=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ie.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Ir(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Qo(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}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()}}},Rr=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=Dh(t.markers(e)),t.initialSpacer&&(this.spacer=new Ir(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=Dh(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!ie.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()}},Ir=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),gm(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function gm(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var bm=I.define(),Di=I.define({combine(n){return ze(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return i}})}}),pn=class extends Ge{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function ko(n,e){return n.state.facet(Di).formatNumber(e,n.state)}var km=dn.compute([Di],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(bm)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new pn(ko(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Di)!=e.state.facet(Di),initialSpacer(e){return new pn(ko(e,Oh(e.state.doc.lines)))},updateSpacer(e,t){let i=ko(t.view,Oh(t.view.state.doc.lines));return i==e.number?e:new pn(i)},domEventHandlers:n.facet(Di).domEventHandlers}));function Ec(n={}){return[Di.of(n),Oc(),km]}function Oh(n){let e=9;for(;e<n;)e=e*10+9;return e}var Eh=new Map;function ym(n){let e=Eh.get(n);return e||Eh.set(n,e=J.mark({attributes:n===" "?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":n.replace(/ /g,"\xB7")}})),e}function Bc(n){return ye.define(e=>({decorations:n.createDeco(e),update(t){this.decorations=n.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}var wm=Bc(new Sn({regexp:/\t| +/g,decoration:n=>ym(n[0]),boundary:/\S/}));function Pc(){return wm}var xm=Bc(new Sn({regexp:/\s+$/g,decoration:J.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function Rc(){return xm}var vm=0,An=class{constructor(e,t){this.from=e,this.to=t}},Z=class{constructor(e={}){this.id=vm++,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=Ee.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};Z.closedBy=new Z({deserialize:n=>n.split(" ")});Z.openedBy=new Z({deserialize:n=>n.split(" ")});Z.group=new Z({deserialize:n=>n.split(" ")});Z.contextHash=new Z({perNode:!0});Z.lookAhead=new Z({perNode:!0});Z.mounted=new Z({perNode:!0});var Bi=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[Z.mounted.id]}},Sm=Object.create(null),Ee=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Sm,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}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(Z.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 r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(Z.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};Ee.none=new Ee("",Object.create(null),0,8);var Wr=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);o&&(r||(r=Object.assign({},i.props)),r[o[0].id]=o[1])}t.push(r?new Ee(i.name,r,i.id,i.flags):i)}return new n(t)}},Hr=new WeakMap,Ic=new WeakMap,ve;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(ve||(ve={}));var pe=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Bi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Ln(this.topNode,e)}cursorAt(e,t=0,i=0){let r=Hr.get(this)||this.topNode,s=new Ln(r);return s.moveTo(e,t),Hr.set(this,s._tree),s}get topNode(){return new dt(this,0,0,null)}resolve(e,t=0){let i=Tn(Hr.get(this)||this.topNode,e,t,!1);return Hr.set(this,i),i}resolveInner(e,t=0){let i=Tn(Ic.get(this)||this.topNode,e,t,!0);return Ic.set(this,i),i}resolveStack(e,t=0){return Cm(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&ve.IncludeAnonymous)>0;for(let a=this.cursor(o|ve.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!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:dl(Ee.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Ee.none,t,i,r)))}static build(e){return Am(e)}};pe.empty=new pe(Ee.none,[],[],0);var ll=class n{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 n(this.buffer,this.index)}},Ht=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Ee.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Fc(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let h=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,h)}return new n(s,o,this.set)}};function Fc(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Tn(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof dt&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:ve.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof dt&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var jr=class{cursor(e=0){return new Ln(this,e)}getChild(e,t=null,i=null){let r=Nc(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Nc(this,e,t,i)}resolve(e,t=0){return Tn(this,e,t,!1)}resolveInner(e,t=0){return Tn(this,e,t,!0)}matchContext(e){return al(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},dt=class n extends jr{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from;if(Fc(r,i,f,f+c.length)){if(c instanceof Ht){if(s&ve.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,r);if(u>-1)return new Mn(new hl(o,c,e,f),null,u)}else if(s&ve.IncludeAnonymous||!c.type.isAnonymous||ul(c)){let u;if(!(s&ve.IgnoreMounts)&&(u=Bi.get(c))&&!u.overlay)return new n(u.tree,f,e,o);let p=new n(c,f,e,o);return s&ve.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(s&ve.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 r;if(!(i&ve.IgnoreOverlays)&&(r=Bi.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:l}of r.overlay)if((t>0?o<=s:o<s)&&(t<0?l>=s:l>s))return new n(r.tree,r.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 Nc(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function al(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}var hl=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Mn=class n extends jr{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:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}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&ve.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}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 n(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 n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new pe(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Hc(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof dt&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new cl(r,t)}var cl=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Hc(this.heads)}};function Cm(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof dt?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=Bi.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new dt(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Tn(l,e,t,!1))}}return r?Hc(r):i}var Ln=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof dt)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:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof dt?(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:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}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&ve.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ve.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ve.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 r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}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:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&ve.IncludeAnonymous||l instanceof Ht||!l.type.isAnonymous||ul(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<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new Mn(this.buffer,t,this.stack[r]);return this.bufferNode=new Mn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return al(this.node,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return al(this.node,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function ul(n){return n.children.some(e=>e instanceof Ht||!e.type.isAnonymous||ul(e))}function Am(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new ll(t,t.length):t,a=i.types,h=0,c=0;function f(F,q,w,D,b,Y){let{id:$,start:U,end:K,size:k}=l,T=c;for(;k<0;)if(l.next(),k==-1){let j=s[$];w.push(j),D.push(U-F);return}else if(k==-3){h=$;return}else if(k==-4){c=$;return}else throw new RangeError(`Unrecognized record size: ${k}`);let A=a[$],V,ae,we=U-F;if(K-U<=r&&(ae=y(l.pos-q,b))){let j=new Uint16Array(ae.size-ae.skip),W=l.pos-ae.size,G=j.length;for(;l.pos>W;)G=v(ae.start,j,G);V=new Ht(j,K-ae.start,i),we=ae.start-F}else{let j=l.pos-k;l.next();let W=[],G=[],he=$>=o?$:-1,Lt=0,te=K;for(;l.pos>j;)he>=0&&l.id==he&&l.size>=0?(l.end<=te-r&&(g(W,G,U,Lt,l.end,te,he,T),Lt=W.length,te=l.end),l.next()):Y>2500?u(U,j,W,G):f(U,j,W,G,he,Y+1);if(he>=0&&Lt>0&&Lt<W.length&&g(W,G,U,Lt,U,te,he,T),W.reverse(),G.reverse(),he>-1&&Lt>0){let Te=p(A);V=dl(A,W,G,0,W.length,0,K-U,Te,Te)}else V=x(A,W,G,K-U,T-K)}w.push(V),D.push(we)}function u(F,q,w,D){let b=[],Y=0,$=-1;for(;l.pos>q;){let{id:U,start:K,end:k,size:T}=l;if(T>4)l.next();else{if($>-1&&K<$)break;$<0&&($=k-r),b.push(U,K,k),Y++,l.next()}}if(Y){let U=new Uint16Array(Y*4),K=b[b.length-2];for(let k=b.length-3,T=0;k>=0;k-=3)U[T++]=b[k],U[T++]=b[k+1]-K,U[T++]=b[k+2]-K,U[T++]=T;w.push(new Ht(U,b[2]-K,i)),D.push(K-F)}}function p(F){return(q,w,D)=>{let b=0,Y=q.length-1,$,U;if(Y>=0&&($=q[Y])instanceof pe){if(!Y&&$.type==F&&$.length==D)return $;(U=$.prop(Z.lookAhead))&&(b=w[Y]+$.length+U)}return x(F,q,w,D,b)}}function g(F,q,w,D,b,Y,$,U){let K=[],k=[];for(;F.length>D;)K.push(F.pop()),k.push(q.pop()+w-b);F.push(x(i.types[$],K,k,Y-b,U-Y)),q.push(b-w)}function x(F,q,w,D,b=0,Y){if(h){let $=[Z.contextHash,h];Y=Y?[$].concat(Y):[$]}if(b>25){let $=[Z.lookAhead,b];Y=Y?[$].concat(Y):[$]}return new pe(F,q,w,D,Y)}function y(F,q){let w=l.fork(),D=0,b=0,Y=0,$=w.end-r,U={size:0,start:0,skip:0};e:for(let K=w.pos-F;w.pos>K;){let k=w.size;if(w.id==q&&k>=0){U.size=D,U.start=b,U.skip=Y,Y+=4,D+=4,w.next();continue}let T=w.pos-k;if(k<0||T<K||w.start<$)break;let A=w.id>=o?4:0,V=w.start;for(w.next();w.pos>T;){if(w.size<0)if(w.size==-3)A+=4;else break e;else w.id>=o&&(A+=4);w.next()}b=V,D+=k,Y+=A}return(q<0||D==F)&&(U.size=D,U.start=b,U.skip=Y),U.size>4?U:void 0}function v(F,q,w){let{id:D,start:b,end:Y,size:$}=l;if(l.next(),$>=0&&D<o){let U=w;if($>4){let K=l.pos-($-4);for(;l.pos>K;)w=v(F,q,w)}q[--w]=U,q[--w]=Y-F,q[--w]=b-F,q[--w]=D}else $==-3?h=D:$==-4&&(c=D);return w}let M=[],O=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,M,O,-1,0);let R=(e=n.length)!==null&&e!==void 0?e:M.length?O[0]+M[0].length:0;return new pe(a[n.topID],M.reverse(),O.reverse(),R)}var zc=new WeakMap;function Vr(n,e){if(!n.isAnonymous||e instanceof Ht||e.type!=n)return 1;let t=zc.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof pe)){t=1;break}t+=Vr(n,i)}zc.set(e,t)}return t}function dl(n,e,t,i,r,s,o,l,a){let h=0;for(let g=i;g<r;g++)h+=Vr(n,e[g]);let c=Math.ceil(h*1.5/8),f=[],u=[];function p(g,x,y,v,M){for(let O=y;O<v;){let R=O,F=x[O],q=Vr(n,g[O]);for(O++;O<v;O++){let w=Vr(n,g[O]);if(q+w>=c)break;q+=w}if(O==R+1){if(q>c){let w=g[R];p(w.children,w.positions,0,w.children.length,x[R]+M);continue}f.push(g[R])}else{let w=x[O-1]+g[O-1].length-F;f.push(dl(n,g,x,R,O,F,w,null,a))}u.push(F+M-s)}}return p(e,t,i,r,0),(l||a)(f,u,o)}var ri=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?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 r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let p=Math.max(u.from,a)-h,g=Math.min(u.to,f)-h;u=p>=g?null:new n(p,g,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}},Dn=class{startParse(e,t,i){return typeof e=="string"&&(e=new fl(e)),i=i?i.length?i.map(r=>new An(r.from,r.to)):[new An(0,0)]:[new An(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},fl=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var Sb=new Z({perNode:!0});var Tm=0,Pe=class n{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=Tm++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new n([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new _r;return t=>t.modified.indexOf(e)>-1?t:_r.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}},Mm=0,_r=class n{constructor(){this.instances=[],this.id=Mm++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Lm(t,l.modified));if(i)return i;let r=[],s=new Pe(r,e,t);for(let l of t)l.instances.push(s);let o=Dm(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function Lm(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function Dm(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function jc(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Pi(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return qc.add(e)}var qc=new Z,Pi=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Pi.empty=new Pi([],2,null);function bl(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Om(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function $c(n,e,t,i=0,r=n.length){let s=new ml(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var ml=class{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,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(o)));let h=r,c=Em(e)||Pi.empty,f=Om(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(Z.mounted);if(u&&u.overlay){let p=e.node.enter(u.overlay[0].from+l,1),g=this.highlighters.filter(y=>!y.scope||y.scope(u.tree.type)),x=e.firstChild();for(let y=0,v=l;;y++){let M=y<u.overlay.length?u.overlay[y]:null,O=M?M.from+l:a,R=Math.max(t,v),F=Math.min(i,O);if(R<F&&x)for(;e.from<F&&(this.highlightRange(e,R,F,r,s),this.startSpan(Math.min(F,e.to),h),!(e.to>=O||!e.nextSibling())););if(!M||O>i)break;v=M.to+l,v>t&&(this.highlightRange(p.cursor(),Math.max(t,M.from+l),Math.min(i,v),"",g),this.startSpan(Math.min(i,v),h))}x&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function Em(n){let e=n.type.prop(qc);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var E=Pe.define,qr=E(),Vt=E(),Vc=E(Vt),Wc=E(Vt),Wt=E(),$r=E(Wt),pl=E(Wt),gt=E(),si=E(gt),pt=E(),mt=E(),gl=E(),On=E(gl),Kr=E(),P={comment:qr,lineComment:E(qr),blockComment:E(qr),docComment:E(qr),name:Vt,variableName:E(Vt),typeName:Vc,tagName:E(Vc),propertyName:Wc,attributeName:E(Wc),className:E(Vt),labelName:E(Vt),namespace:E(Vt),macroName:E(Vt),literal:Wt,string:$r,docString:E($r),character:E($r),attributeValue:E($r),number:pl,integer:E(pl),float:E(pl),bool:E(Wt),regexp:E(Wt),escape:E(Wt),color:E(Wt),url:E(Wt),keyword:pt,self:E(pt),null:E(pt),atom:E(pt),unit:E(pt),modifier:E(pt),operatorKeyword:E(pt),controlKeyword:E(pt),definitionKeyword:E(pt),moduleKeyword:E(pt),operator:mt,derefOperator:E(mt),arithmeticOperator:E(mt),logicOperator:E(mt),bitwiseOperator:E(mt),compareOperator:E(mt),updateOperator:E(mt),definitionOperator:E(mt),typeOperator:E(mt),controlOperator:E(mt),punctuation:gl,separator:E(gl),bracket:On,angleBracket:E(On),squareBracket:E(On),paren:E(On),brace:E(On),content:gt,heading:si,heading1:E(si),heading2:E(si),heading3:E(si),heading4:E(si),heading5:E(si),heading6:E(si),contentSeparator:E(gt),list:E(gt),quote:E(gt),emphasis:E(gt),strong:E(gt),link:E(gt),monospace:E(gt),strikethrough:E(gt),inserted:E(),deleted:E(),changed:E(),invalid:E(),meta:Kr,documentMeta:E(Kr),annotation:E(Kr),processingInstruction:E(Kr),definition:Pe.defineModifier(),constant:Pe.defineModifier(),function:Pe.defineModifier(),standard:Pe.defineModifier(),local:Pe.defineModifier(),special:Pe.defineModifier()},Tb=bl([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var kl,Ri=new Z;function Bm(n){return I.define({combine:n?e=>e.concat(n):void 0})}var Pm=new Z,We=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,oe.prototype.hasOwnProperty("tree")||Object.defineProperty(oe.prototype,"tree",{get(){return Be(this)}}),this.parser=t,this.extension=[Ii.of(this),oe.languageData.of((s,o,l)=>{let a=Kc(s,o,l),h=a.type.prop(Ri);if(!h)return[];let c=s.facet(h),f=a.type.prop(Pm);if(f){let u=a.resolve(o-a.from,l);for(let p of f)if(p.test(u,s)){let g=s.facet(p.facet);return p.type=="replace"?g:g.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return Kc(e,t,i).type.prop(Ri)==this.data}findRegions(e){let t=e.facet(Ii);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Ri)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(Z.mounted);if(l){if(l.tree.prop(Ri)==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+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof pe&&r(h,s.positions[a]+o)}};return r(Be(e),0),i}get allowsNesting(){return!0}};We.setState=X.define();function Kc(n,e,t){let i=n.facet(Ii),r=Be(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,ve.ExcludeBuffers))s.type.isTop&&(r=s);return r}function Be(n){let e=n.field(We.state,!1);return e?e.tree:pe.empty}var vl=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},En=null,Bn=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],pe.empty,0,i,[],null)}startParse(){return this.parser.startParse(new vl(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=pe.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(ri.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=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(ri.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=En;En=this;try{return e()}finally{En=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=_c(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,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=ri.applyChanges(i,a),r=pe.empty,s=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);c<f&&l.push({from:c,to:f})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=_c(this.fragments,r,s),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 Dn{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=En;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new pe(Ee.none,[],[],o-s)},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 En}};function _c(n,e,t){return ri.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Pn=class n{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 n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Bn.create(e.facet(Ii).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};We.state=me.define({create:Pn.init,update(n,e){for(let t of e.effects)if(t.is(We.setState))return t.value;return e.startState.facet(Ii)!=e.state.facet(Ii)?Pn.init(e.state):n.apply(e)}});var Xc=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(Xc=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var yl=typeof navigator!="undefined"&&(!((kl=navigator.scheduling)===null||kl===void 0)&&kl.isInputPending)?()=>navigator.scheduling.isInputPending():null,Rm=ye.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(We.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(We.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Xc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(We.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!yl?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>yl&&yl()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:We.setState.of(new Pn(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>He(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()}}}),Ii=I.define({combine(n){return n.length?n[0]:null},enables:n=>[We.state,Rm,z.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Ni=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var Zc=I.define(),qt=I.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 jt(n){let e=n.facet(qt);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Hi(n,e){let t="",i=n.tabSize,r=n.facet(qt)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function Yr(n,e){n instanceof oe&&(n=new oi(n));for(let i of n.state.facet(Zc)){let r=i(n,e);if(r!==void 0)return r}let t=Be(n.state);return t.length>=e?Nm(n,t,e):null}var oi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=jt(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Pt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Im=new Z;function Nm(n,e,t){let i=e.resolveStack(t),r=i.node.enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o!=i.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Qc(i,n,t)}function Qc(n,e,t){for(let i=n;i;i=i.next){let r=Fm(i.node);if(r)return r(Sl.create(e,t,i))}return 0}function zm(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Fm(n){let e=n.type.prop(Im);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(Z.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>jm(o,!0,1,void 0,s&&!zm(o)?r.from:void 0)}return n.parent==null?Hm:null}function Hm(){return 0}var Sl=class n extends oi{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 n(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(Vm(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Qc(this.context.next,this.base,this.pos)}};function Vm(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Wm(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.from<o?t:null;l=a.to}}function jm(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Wm(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var qm=200;function ef(){return oe.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,r=t.lineAt(i);if(i>r.from+qm)return n;let s=t.sliceString(r.from,i);if(!e.some(h=>h.test(s)))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=Yr(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],p=Hi(o,f);u!=p&&a.push({from:c.from,to:c.from+u.length,insert:p})}return a.length?[n,{changes:a,sequential:!0}]:n})}var zi=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=Ke.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof We?l=>l.prop(Ri)==o.data:o?l=>l==o:void 0,this.style=bl(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ke(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},Cl=I.define(),tf=I.define({combine(n){return n.length?[n[0]]:null}});function wl(n){let e=n.facet(Cl);return e.length?e:n.facet(tf)}function Jr(n,e){let t=[$m],i;return n instanceof zi&&(n.module&&t.push(z.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(tf.of(n)):i?t.push(Cl.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(i=="dark")?[n]:[])):t.push(Cl.of(n)),t}var Al=class{constructor(e){this.markCache=Object.create(null),this.tree=Be(e.state),this.decorations=this.buildDeco(e,wl(e.state))}update(e){let t=Be(e.state),i=wl(e.state),r=i!=wl(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i))}buildDeco(e,t){if(!t||!this.tree.length)return J.none;let i=new at;for(let{from:r,to:s}of e.visibleRanges)$c(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=J.mark({class:a})))},r,s);return i.finish()}},$m=Bt.high(ye.fromClass(Al,{decorations:n=>n.decorations})),nf=zi.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),Km=z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),rf=1e4,sf="()[]{}",of=I.define({combine(n){return ze(n,{afterCursor:!0,brackets:sf,maxScanDistance:rf,renderMatch:Um})}}),_m=J.mark({class:"cm-matchingBracket"}),Gm=J.mark({class:"cm-nonmatchingBracket"});function Um(n){let e=[],t=n.matched?_m:Gm;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}var Ym=me.define({create(){return J.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(of);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=rt(e.state,r.head,-1,i)||r.head>0&&rt(e.state,r.head-1,1,i)||i.afterCursor&&(rt(e.state,r.head,1,i)||r.head<e.state.doc.length&&rt(e.state,r.head+1,-1,i));s&&(t=t.concat(i.renderMatch(s,e.state)))}return J.set(t,!0)},provide:n=>z.decorations.from(n)}),Jm=[Ym,Km];function lf(n={}){return[of.of(n),Jm]}var Xm=new Z;function Tl(n,e,t){let i=n.prop(e<0?Z.openedBy:Z.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function Ml(n){let e=n.type.prop(Xm);return e?e(n.node):n}function rt(n,e,t,i={}){let r=i.maxScanDistance||rf,s=i.brackets||sf,o=Be(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=Tl(a.type,t,s);if(h&&a.from<a.to){let c=Ml(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return Zm(n,e,t,a,c,h,s)}}return Qm(n,e,t,o,l.type,r,s)}function Zm(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.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&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=Ml(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(Tl(c.type,t,o))h++;else if(Tl(c.type,-t,o)){if(h==0){let f=Ml(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function Qm(n,e,t,i,r,s,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)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<=s;){let p=c.value;t<0&&(u+=p.length);let g=e+u*t;for(let x=t>0?0:p.length-1,y=t>0?p.length:-1;x!=y;x+=t){let v=o.indexOf(p[x]);if(!(v<0||i.resolveInner(g+x,1).type!=r))if(v%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:g+x,to:g+x+1},matched:v>>1==a>>1};f--}}t>0&&(u+=p.length)}return c.done?{start:h,matched:!1}:null}function Gc(n,e,t,i=0,r=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let s=r;for(let o=i;o<e;o++)n.charCodeAt(o)==9?s+=t-s%t:s++;return s}var Gr=class{constructor(e,t,i,r){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Gc(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Gc(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let r=o=>i?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return r(s)==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}};function eg(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||tg,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||Ol}}function tg(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}var Uc=new WeakMap,Fi=class n extends We{constructor(e){let t=Bm(e.languageData),i=eg(e),r,s=new class extends Dn{createParse(o,l,a){return new Ll(r,o,l,a)}};super(t,s,[Zc.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=sg(t),r=this,this.streamParser=i,this.stateAfter=new Z({perNode:!0}),this.tokenTable=e.tokenTable?new Ur(i.tokenTable):rg}static define(e){return new n(e)}getIndent(e,t){let i=Be(e.state),r=i.resolve(t);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let s,{overrideIndentation:o}=e.options;o&&(s=Uc.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let l=Dl(this,i,0,r.from,s!=null?s:t),a,h;if(l?(h=l.state,a=l.pos+1):(h=this.streamParser.startState(e.unit),a=0),t-a>1e4)return null;for(;a<t;){let f=e.state.doc.lineAt(a),u=Math.min(t,f.to);if(f.length){let p=o?o(f.from):-1,g=new Gr(f.text,e.state.tabSize,e.unit,p<0?void 0:p);for(;g.pos<u-f.from;)hf(this.streamParser.token,g,h)}else this.streamParser.blankLine(h,e.unit);if(u==t)break;a=f.to+1}let c=e.lineAt(t);return o&&s==null&&Uc.set(e.state,c.from),this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],e)}get allowsNesting(){return!1}};function Dl(n,e,t,i,r){let s=t>=i&&t+e.length<=r&&e.prop(n.stateAfter);if(s)return{state:n.streamParser.copyState(s),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof pe&&a<r&&Dl(n,l,a,i,r);if(h)return h}return null}function af(n,e,t,i,r){if(r&&t<=0&&i>=e.length)return e;!r&&e.type==n.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],l=e.children[s],a;if(o<i&&l instanceof pe){if(!(a=af(n,l,t-o,i-o,r)))break;return r?new pe(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function ig(n,e,t,i){for(let r of e){let s=r.from+(r.openStart?25:0),o=r.to-(r.openEnd?25:0),l=s<=t&&o>t&&Dl(n,r.tree,0-r.offset,t,o),a;if(l&&(a=af(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:a}}return{state:n.streamParser.startState(i?jt(i):4),tree:pe.empty}}var Ll=class{constructor(e,t,i,r){this.lang=e,this.input=t,this.fragments=i,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let s=Bn.get(),o=r[0].from,{state:l,tree:a}=ig(e,i,o,s==null?void 0:s.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(jt(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=Bn.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+2048);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
11
11
  `&&(t="");else{let i=t.indexOf(`
12
- `);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=i||(t=t.slice(0,s-(i-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(i>0?r>s:r>=s)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,r,s){if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let o=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-o}return this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),r=0,{streamParser:s}=this.lang,o=new $r(t,e?e.state.tabSize:4,e?Wt(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=nf(s.token,o,this.state);if(l&&(r=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,4,r)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=pe.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Xm,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new pe(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new pe(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function nf(n,e,t){e.start=e.pos;for(let i=0;i<10;i++){let r=n(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var Cl=Object.create(null),Bn=[Ee.none],Xm=new Fr(Bn),qc=[],$c=Object.create(null),rf=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"]])rf[n]=sf(Cl,e);var Kr=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),rf)}resolve(e){return e?this.table[e]||(this.table[e]=sf(this.extra,e)):0}},Zm=new Kr(Cl);function ml(n,e){qc.indexOf(n)>-1||(qc.push(n),console.warn(e))}function sf(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||P[h];c?typeof c=="function"?a.length?a=a.map(c):ml(h,`Modifier ${h} used at start of tag`):a.length?ml(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:ml(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=$c[r];if(s)return s.id;let o=$c[r]=Ee.define({id:Bn.length,name:i,props:[Nc({[i]:t})]});return Bn.push(o),o.id}function Qm(n){let e=Ee.define({id:Bn.length,name:"Document",props:[Pi.add(()=>n)],top:!0});return Bn.push(e),e}var eg=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=El(n.state,t.from);return i.line?tg(n):i.block?ng(n):!1};function Ol(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var tg=Ol(og,0);var ig=Ol(df,0);var ng=Ol((n,e)=>df(n,e,sg(e)),0);function El(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var Pn=50;function rg(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-Pn,i),o=n.sliceDoc(r,r+Pn),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-i<=2*Pn?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+Pn),f=n.sliceDoc(r-Pn,r));let u=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-t.length;return c.slice(u,u+e.length)==e&&f.slice(g,g+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-p-t.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function sg(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function df(n,e,t=e.selection.ranges){let i=t.map(s=>El(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>rg(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function og(n,e,t=e.selection.ranges){let i=[],r=-1;for(let{from:s,to:o}of t){let l=i.length,a=1e9,h=El(e,s).line;if(h){for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,p=u==f.length,g=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:g,token:h,indent:u,empty:p,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];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++,s.push({from:h,to:c})}return{changes:s}}return null}var Tl=Ne.define(),lg=Ne.define(),ag=I.define(),pf=I.define({combine(n){return ze(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),mf=me.define({create(){return oi.empty},update(n,e){let t=e.state.facet(pf),i=e.annotation(Tl);if(i){let a=rt.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=Yr(c,c.length,t.minDepth,a):c=yf(c,e.startState.selection),new oi(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(lg);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(xe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=rt.fromTransaction(e),o=e.annotation(xe.time),l=e.annotation(xe.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="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 oi(n.done.map(rt.fromJSON),n.undone.map(rt.fromJSON))}});function gf(n={}){return[mf,pf.of(n),z.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?bf:e.inputType=="historyRedo"?Ml:null;return i?(e.preventDefault(),i(t)):!1}})]}function Jr(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(mf,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var bf=Jr(0,!1),Ml=Jr(1,!1),hg=Jr(0,!0),cg=Jr(1,!0);var rt=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(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(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&De.fromJSON(e.changes),[],e.mapped&&vt.fromJSON(e.mapped),e.startSelection&&L.fromJSON(e.startSelection),e.selectionsAfter.map(L.fromJSON))}static fromTransaction(e,t){let i=Ue;for(let r of e.startState.facet(ag)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ue)}static selection(e){return new n(void 0,Ue,void 0,void 0,e)}};function Yr(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function fg(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function ug(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function kf(n,e){return n.length?e.length?n.concat(e):n:e}var Ue=[],dg=200;function yf(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-dg));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Yr(n,n.length-1,1e9,t.setSelAfter(i)))}else return[rt.selection([e])]}function pg(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 Al(n,e){if(!n.length)return n;let t=n.length,i=Ue;for(;t;){let r=mg(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[rt.selection(i)]:Ue}function mg(n,e,t){let i=kf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Ue,t);if(!n.changes)return rt.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new rt(r,X.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var gg=/^(input\.type|delete)($|\.)/,oi=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||gg.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,fg(l.changes,e.changes))||i=="input.type.compose")?o=Yr(o,o.length-1,r.minDepth,new rt(e.changes.compose(l.changes),kf(e.effects,l.effects),l.mapped,l.startSelection,Ue)):o=Yr(o,o.length,r.minDepth,e),new n(o,Ue,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ue;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&ug(s[s.length-1],e)?this:new n(yf(this.done,e),this.undone,t,i)}addMapping(e){return new n(Al(this.done,e),Al(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||t.selection;if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Tl.of({side:e,rest:pg(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Ue:r.slice(0,r.length-1);return s.mapped&&(l=Al(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Tl.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};oi.empty=new oi(Ue,Ue);var wf=[{key:"Mod-z",run:bf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ml,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ml,preventDefault:!0},{key:"Mod-u",run:hg,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:cg,preventDefault:!0}];function Hi(n,e){return L.create(n.ranges.map(e),n.mainIndex)}function gt(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function st({state:n,dispatch:e},t){let i=Hi(n.selection,t);return i.eq(n.selection)?!1:(e(gt(n,i)),!0)}function Xr(n,e){return L.cursor(e?n.to:n.from)}function xf(n,e){return st(n,t=>t.empty?n.moveByChar(t,e):Xr(t,e))}function Le(n){return n.textDirectionAt(n.state.selection.main.head)==ge.LTR}var vf=n=>xf(n,!Le(n)),Sf=n=>xf(n,Le(n));function Cf(n,e){return st(n,t=>t.empty?n.moveByGroup(t,e):Xr(t,e))}var bg=n=>Cf(n,!Le(n)),kg=n=>Cf(n,Le(n));var Ib=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function yg(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 Zr(n,e,t){let i=Be(n).resolveInner(e.head),r=t?Z.closedBy:Z.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;yg(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?nt(n,i.from,1):nt(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,L.cursor(l,t?-1:1)}var wg=n=>st(n,e=>Zr(n.state,e,!Le(n))),xg=n=>st(n,e=>Zr(n.state,e,Le(n)));function Af(n,e){return st(n,t=>{if(!t.empty)return Xr(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Tf=n=>Af(n,!1),Mf=n=>Af(n,!0);function Lf(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(z.scrollMargins)){let o=s(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function Df(n,e){let t=Lf(n),{state:i}=n,r=Hi(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):Xr(o,e));if(r.eq(i.selection))return!1;let s;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.bottom<h&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(gt(i,r),{effects:s}),!0}var of=n=>Df(n,!1),Ll=n=>Df(n,!0);function qt(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=L.cursor(i.from+s))}return r}var vg=n=>st(n,e=>qt(n,e,!0)),Sg=n=>st(n,e=>qt(n,e,!1)),Cg=n=>st(n,e=>qt(n,e,!Le(n))),Ag=n=>st(n,e=>qt(n,e,Le(n))),Tg=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).from,1)),Mg=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).to,-1));function Lg(n,e,t){let i=!1,r=Hi(n.selection,s=>{let o=nt(n,s.head,-1)||nt(n,s.head,1)||s.head>0&&nt(n,s.head-1,1)||s.head<n.doc.length&&nt(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?L.range(s.anchor,l):L.cursor(l)});return i?(e(gt(n,r)),!0):!1}var Dg=({state:n,dispatch:e})=>Lg(n,e,!1);function Ye(n,e){let t=Hi(n.state.selection,i=>{let r=e(i);return L.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(gt(n.state,t)),!0)}function Of(n,e){return Ye(n,t=>n.moveByChar(t,e))}var Ef=n=>Of(n,!Le(n)),Bf=n=>Of(n,Le(n));function Pf(n,e){return Ye(n,t=>n.moveByGroup(t,e))}var Og=n=>Pf(n,!Le(n)),Eg=n=>Pf(n,Le(n));var Bg=n=>Ye(n,e=>Zr(n.state,e,!Le(n))),Pg=n=>Ye(n,e=>Zr(n.state,e,Le(n)));function Rf(n,e){return Ye(n,t=>n.moveVertically(t,e))}var If=n=>Rf(n,!1),Nf=n=>Rf(n,!0);function zf(n,e){return Ye(n,t=>n.moveVertically(t,e,Lf(n).height))}var lf=n=>zf(n,!1),af=n=>zf(n,!0),Rg=n=>Ye(n,e=>qt(n,e,!0)),Ig=n=>Ye(n,e=>qt(n,e,!1)),Ng=n=>Ye(n,e=>qt(n,e,!Le(n))),zg=n=>Ye(n,e=>qt(n,e,Le(n))),Fg=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).from)),Hg=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).to)),hf=({state:n,dispatch:e})=>(e(gt(n,{anchor:0})),!0),cf=({state:n,dispatch:e})=>(e(gt(n,{anchor:n.doc.length})),!0),ff=({state:n,dispatch:e})=>(e(gt(n,{anchor:n.selection.main.anchor,head:0})),!0),uf=({state:n,dispatch:e})=>(e(gt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Vg=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Wg=({state:n,dispatch:e})=>{let t=Qr(n).map(({from:i,to:r})=>L.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:L.create(t),userEvent:"select"})),!0},jg=({state:n,dispatch:e})=>{let t=Hi(n.selection,i=>{var r;let s=Be(n).resolveStack(i.from,1);for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&(!((r=l.parent)===null||r===void 0)&&r.parent))return L.range(l.to,l.from)}return i});return e(gt(n,t)),!0},qg=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=L.create([t.main]):t.main.empty||(i=L.create([L.cursor(t.main.head)])),i?(e(gt(n,i)),!0):!1};function Rn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=Ur(n,a,!1)):a>o&&(t="delete.forward",a=Ur(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Ur(n,o,!1),l=Ur(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:L.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Ur(n,e,t){if(n instanceof z)for(let i of n.state.facet(z.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var Ff=(n,e)=>Rn(n,t=>{let i=t.from,{state:r}=n,s=r.doc.lineAt(i),o,l;if(!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(o=s.text.slice(0,i-s.from))){if(o[o.length-1]==" ")return i-1;let a=Bt(o,r.tabSize),h=a%Wt(r)||Wt(r);for(let c=0;c<h&&o[o.length-1-c]==" ";c++)i--;l=i}else l=be(s.text,i-s.from,e,e)+s.from,l==i&&s.number!=(e?r.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=be(s.text,l-s.from,!1,!1)+s.from);return l}),Dl=n=>Ff(n,!1),Hf=n=>Ff(n,!0),Vf=(n,e)=>Rn(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=be(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),Wf=n=>Vf(n,!1),$g=n=>Vf(n,!0),Kg=n=>Rn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var _g=n=>Rn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Gg=n=>Rn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var Ug=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Q.of(["",""])},range:L.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 r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:be(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:be(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:L.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Qr(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function jf(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Qr(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(L.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(L.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:L.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Jg=({state:n,dispatch:e})=>jf(n,e,!1),Xg=({state:n,dispatch:e})=>jf(n,e,!0);function qf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of Qr(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Zg=({state:n,dispatch:e})=>qf(n,e,!1),Qg=({state:n,dispatch:e})=>qf(n,e,!0),e0=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Qr(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Hi(e.selection,r=>n.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function t0(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Be(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(Z.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var i0=$f(!1),n0=$f(!0);function $f(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&t0(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new si(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=_r(h,s);for(c==null&&(c=Bt(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",Fi(e,c)];return a&&f.push(Fi(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Q.of(f)},range:L.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Bl(n,e){let t=-1;return n.changeByRange(i=>{let r=[];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,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:L.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var r0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new si(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=Bl(n,(s,o,l)=>{let a=_r(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Fi(n,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},s0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Bl(n,(t,i)=>{i.push({from:t.from,insert:n.facet(jt)})}),{userEvent:"input.indent"})),!0),o0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Bl(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Bt(r,n.tabSize),o=0,l=Fi(n,Math.max(0,s-Wt(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0);var l0=[{key:"Ctrl-b",run:vf,shift:Ef,preventDefault:!0},{key:"Ctrl-f",run:Sf,shift:Bf},{key:"Ctrl-p",run:Tf,shift:If},{key:"Ctrl-n",run:Mf,shift:Nf},{key:"Ctrl-a",run:Tg,shift:Fg},{key:"Ctrl-e",run:Mg,shift:Hg},{key:"Ctrl-d",run:Hf},{key:"Ctrl-h",run:Dl},{key:"Ctrl-k",run:Kg},{key:"Ctrl-Alt-h",run:Wf},{key:"Ctrl-o",run:Ug},{key:"Ctrl-t",run:Yg},{key:"Ctrl-v",run:Ll}],a0=[{key:"ArrowLeft",run:vf,shift:Ef,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:bg,shift:Og,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Cg,shift:Ng,preventDefault:!0},{key:"ArrowRight",run:Sf,shift:Bf,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:kg,shift:Eg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Ag,shift:zg,preventDefault:!0},{key:"ArrowUp",run:Tf,shift:If,preventDefault:!0},{mac:"Cmd-ArrowUp",run:hf,shift:ff},{mac:"Ctrl-ArrowUp",run:of,shift:lf},{key:"ArrowDown",run:Mf,shift:Nf,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cf,shift:uf},{mac:"Ctrl-ArrowDown",run:Ll,shift:af},{key:"PageUp",run:of,shift:lf},{key:"PageDown",run:Ll,shift:af},{key:"Home",run:Sg,shift:Ig,preventDefault:!0},{key:"Mod-Home",run:hf,shift:ff},{key:"End",run:vg,shift:Rg,preventDefault:!0},{key:"Mod-End",run:cf,shift:uf},{key:"Enter",run:i0},{key:"Mod-a",run:Vg},{key:"Backspace",run:Dl,shift:Dl},{key:"Delete",run:Hf},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Wf},{key:"Mod-Delete",mac:"Alt-Delete",run:$g},{mac:"Mod-Backspace",run:_g},{mac:"Mod-Delete",run:Gg}].concat(l0.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Kf=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:wg,shift:Bg},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:xg,shift:Pg},{key:"Alt-ArrowUp",run:Jg},{key:"Shift-Alt-ArrowUp",run:Zg},{key:"Alt-ArrowDown",run:Xg},{key:"Shift-Alt-ArrowDown",run:Qg},{key:"Escape",run:qg},{key:"Mod-Enter",run:n0},{key:"Alt-l",mac:"Ctrl-l",run:Wg},{key:"Mod-i",run:jg,preventDefault:!0},{key:"Mod-[",run:o0},{key:"Mod-]",run:s0},{key:"Mod-Alt-\\",run:r0},{key:"Shift-Mod-k",run:e0},{key:"Shift-Mod-\\",run:Dg},{key:"Mod-/",run:eg},{key:"Alt-A",run:ig}].concat(a0);function ne(){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 r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e<arguments.length;e++)_f(n,arguments[e]);return n}function _f(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)_f(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}var Gf=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n,li=class{constructor(e,t,i=0,r=e.length,s,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,r),this.bufferStart=i,this.normalize=s?l=>s(Gf(l)):Gf,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 $e(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=ir(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=St(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let l=r.charCodeAt(s),a=this.match(l,o);if(s==r.length-1){if(a)return this.value=a,this;break}o==i&&s<t.length&&t.charCodeAt(s)==l&&o++}}}match(e,t){let i=null;for(let r=0;r<this.matches.length;r+=2){let s=this.matches[r],o=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:t+1}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}};typeof Symbol!="undefined"&&(li.prototype[Symbol.iterator]=function(){return this});var Jf={from:-1,to:-1,match:/.*/.exec("")},Hl="gm"+(/x/.unicode==null?"":"u"),is=class{constructor(e,t,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=Jf,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new rs(e,t,i,r,s);this.re=new RegExp(t,Hl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=ss(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=ss(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Pl=new WeakMap,ns=class n{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=Pl.get(e);if(!r||r.from>=i||r.to<=t){let l=new n(t,e.sliceString(t,i));return Pl.set(e,l),l}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to<i&&(s+=e.sliceString(r.to,i)),Pl.set(e,new n(o,s)),new n(t,s.slice(t-o,i-o))}},rs=class{constructor(e,t,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=Jf,this.matchPos=ss(e,r),this.re=new RegExp(t,Hl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=ns.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=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,r,t)))return this.value={from:i,to:r,match:t},this.matchPos=ss(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ns.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(is.prototype[Symbol.iterator]=rs.prototype[Symbol.iterator]=function(){return this});function h0(n){try{return new RegExp(n,Hl),!0}catch(e){return!1}}function ss(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function Rl(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=ne("input",{class:"cm-textfield",name:"line",value:e}),i=ne("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:os.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},ne("label",n.state.phrase("Go to line"),": ",t)," ",ne("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,h,c,f]=s,u=c?+c.slice(1):0,p=h?+h:l.number;if(h&&f){let y=p/100;a&&(y=y*(a=="-"?-1:1)+l.number/o.doc.lines),p=Math.round(o.doc.lines*y)}else h&&a&&(p=p*(a=="-"?-1:1)+l.number);let g=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),x=L.cursor(g.from+Math.max(0,Math.min(u,g.length)));n.dispatch({effects:[os.of(!1),z.scrollIntoView(x.from,{y:"center"})],selection:x}),n.focus()}return{dom:i}}var os=X.define(),Uf=me.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(os)&&(n=t.value);return n},provide:n=>ti.from(n,e=>e?Rl:null)}),c0=n=>{let e=ii(n,Rl);if(!e){let t=[os.of(!0)];n.state.field(Uf,!1)==null&&t.push(X.appendConfig.of([Uf,f0])),n.dispatch({effects:t}),e=ii(n,Rl)}return e&&e.dom.querySelector("input").select(),!0},f0=z.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});var u0=({state:n,dispatch:e})=>{let{selection:t}=n,i=L.create(t.ranges.map(r=>n.wordAt(r.head)||L.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function d0(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new li(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new li(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(s){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}var p0=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return u0({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=d0(n,i);return r?(e(n.update({selection:n.selection.addRange(L.range(r.from,r.to),!1),effects:z.scrollIntoView(r.to)})),!0):!1},ji=I.define({combine(n){return ze(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Fl(e),scrollToMatch:e=>z.scrollIntoView(e)})}});var ls=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||h0(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"?`
13
- `: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 Nl(this):new Il(this)}getCursor(e,t=0,i){let r=e.doc?e:oe.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Wi(this,r,t,i):Vi(this,r,t,i)}},as=class{constructor(e){this.spec=e}};function Vi(n,e,t,i){return new li(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?m0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function m0(n,e){return(t,i,r,s)=>((s>t||s+r.length<i)&&(s=Math.max(0,t-2),r=n.sliceString(s,Math.min(n.length,i+2))),(e(hs(r,t-s))!=ue.Word||e(cs(r,t-s))!=ue.Word)&&(e(cs(r,i-s))!=ue.Word||e(hs(r,i-s))!=ue.Word))}var Il=class extends as{constructor(e){super(e)}nextMatch(e,t,i){let r=Vi(this.spec,e,i,e.doc.length).nextOverlapping();return r.done&&(r=Vi(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=i;;){let s=Math.max(t,r-1e4-this.spec.unquoted.length),o=Vi(this.spec,e,s,r),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==t)return null;r-=1e4}}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)}matchAll(e,t){let i=Vi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Vi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}};function Wi(n,e,t,i){return new is(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?g0(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function hs(n,e){return n.slice(be(n,e,!1),e)}function cs(n,e){return n.slice(e,be(n,e))}function g0(n){return(e,t,i)=>!i[0].length||(n(hs(i.input,i.index))!=ue.Word||n(cs(i.input,i.index))!=ue.Word)&&(n(cs(i.input,i.index+i[0].length))!=ue.Word||n(hs(i.input,i.index+i[0].length))!=ue.Word)}var Nl=class extends as{nextMatch(e,t,i){let r=Wi(this.spec,e,i,e.doc.length).next();return r.done&&(r=Wi(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=Wi(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==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<e.match.length?e.match[i]:t))}matchAll(e,t){let i=Wi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Wi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}},Nn=X.define(),Vl=X.define(),$t=me.define({create(n){return new In(zl(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Nn)?n=new In(t.value.create(),n.panel):t.is(Vl)&&(n=new In(n.query,t.value?Wl:null));return n},provide:n=>ti.from(n,e=>e.panel)});var In=class{constructor(e,t){this.query=e,this.panel=t}},b0=J.mark({class:"cm-searchMatch"}),k0=J.mark({class:"cm-searchMatch cm-searchMatch-selected"}),y0=ye.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field($t))}update(n){let e=n.state.field($t);(e!=n.startState.field($t)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return J.none;let{view:t}=this,i=new lt;for(let r=0,s=t.visibleRanges,o=s.length;r<o;r++){let{from:l,to:a}=s[r];for(;r<o-1&&a>s[r+1].from-2*250;)a=s[++r].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?k0:b0)})}return i.finish()}},{decorations:n=>n.decorations});function zn(n){return e=>{let t=e.state.field($t,!1);return t&&t.query.spec.valid?n(e,t):Qf(e)}}var fs=zn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=L.single(i.from,i.to),s=n.state.facet(ji);return n.dispatch({selection:r,effects:[jl(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),Zf(n),!0}),us=zn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=L.single(r.from,r.to),o=n.state.facet(ji);return n.dispatch({selection:s,effects:[jl(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),Zf(n),!0}),w0=zn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:L.create(t.map(i=>L.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),x0=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let l=new li(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(L.range(l.value.from,l.value.to))}return e(n.update({selection:L.create(s,o),userEvent:"select.search.matches"})),!0},Yf=zn((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=[],l,a,h=[];if(s.from==i&&s.to==r&&(a=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(t,s.from,s.to),h.push(z.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),s){let c=o.length==0||o[0].from>=s.to?0:s.to-s.from-a.length;l=L.single(s.from-c,s.to-c),h.push(jl(n,s)),h.push(t.facet(ji).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),v0=zn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:z.announce.of(i),userEvent:"input.replace.all"}),!0});function Wl(n){return n.state.facet(ji).createPanel(n)}function zl(n,e){var t,i,r,s,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(ji);return new ls({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:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Xf(n){let e=ii(n,Wl);return e&&e.dom.querySelector("[main-field]")}function Zf(n){let e=Xf(n);e&&e==n.root.activeElement&&e.select()}var Qf=n=>{let e=n.state.field($t,!1);if(e&&e.panel){let t=Xf(n);if(t&&t!=n.root.activeElement){let i=zl(n.state,e.query.spec);i.valid&&n.dispatch({effects:Nn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Vl.of(!0),e?Nn.of(zl(n.state,e.query.spec)):X.appendConfig.of(C0)]});return!0},eu=n=>{let e=n.state.field($t,!1);if(!e||!e.panel)return!1;let t=ii(n,Wl);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Vl.of(!1)}),!0},tu=[{key:"Mod-f",run:Qf,scope:"editor search-panel"},{key:"F3",run:fs,shift:us,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:fs,shift:us,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:eu,scope:"editor search-panel"},{key:"Mod-Shift-l",run:x0},{key:"Alt-g",run:c0},{key:"Mod-d",run:p0,preventDefault:!0}],Fl=class{constructor(e){this.view=e;let t=this.query=e.state.field($t).query.spec;this.commit=this.commit.bind(this),this.searchField=ne("input",{value:t.search,placeholder:je(e,"Find"),"aria-label":je(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ne("input",{value:t.replace,placeholder:je(e,"Replace"),"aria-label":je(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ne("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ne("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ne("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return ne("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=ne("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>fs(e),[je(e,"next")]),i("prev",()=>us(e),[je(e,"previous")]),i("select",()=>w0(e),[je(e,"all")]),ne("label",null,[this.caseField,je(e,"match case")]),ne("label",null,[this.reField,je(e,"regexp")]),ne("label",null,[this.wordField,je(e,"by word")]),...e.state.readOnly?[]:[ne("br"),this.replaceField,i("replace",()=>Yf(e),[je(e,"replace")]),i("replaceAll",()=>v0(e),[je(e,"replace all")])],ne("button",{name:"close",onclick:()=>eu(e),"aria-label":je(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new ls({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:Nn.of(e)}))}keydown(e){bc(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?us:fs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Yf(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Nn)&&!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(ji).top}};function je(n,e){return n.state.phrase(e)}var es=30,ts=/[\s\.,:;?!]/;function jl(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-es),o=Math.min(r,t+es),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<es;a++)if(!ts.test(l[a+1])&&ts.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-es;a--)if(!ts.test(l[a-1])&&ts.test(l[a])){l=l.slice(0,a);break}}return z.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}var S0=z.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"}}),C0=[$t,Et.low(y0),S0];var ql=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},ai=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=e,s=i.facet(hi).markerFilter;s&&(r=s(r));let o=J.set(r.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?J.widget({widget:new $l(l),diagnostic:l}).range(l.from):J.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new n(o,t,qi(o))}};function qi(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new ql(r,s,o.diagnostic),!1}),i}function nu(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(bs))||n.changes.touchesRange(t.from,t.to))}function ru(n,e){return n.field(Je,!1)?e:e.concat(X.appendConfig.of(uu))}function A0(n,e){return{effects:ru(n,[bs.of(e)])}}var bs=X.define(),_l=X.define(),su=X.define(),Je=me.define({create(){return new ai(J.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=qi(t,n.selected.diagnostic,r)||qi(t,null,r)}n=new ai(t,n.panel,i)}for(let t of e.effects)t.is(bs)?n=ai.init(t.value,n.panel,e.state):t.is(_l)?n=new ai(n.diagnostics,t.value?gs.open:null,n.selected):t.is(su)&&(n=new ai(n.diagnostics,n.panel,t.value));return n},provide:n=>[ti.from(n,e=>e.panel),z.decorations.from(n,e=>e.diagnostics)]});var T0=J.mark({class:"cm-lintRange cm-lintRange-active"});function M0(n,e,t){let{diagnostics:i}=n.state.field(Je),r=[],s=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)&&(e<h||t<0))&&(r.push(c.diagnostic),s=Math.min(a,s),o=Math.max(h,o))});let l=n.state.facet(hi).tooltipFilter;return l&&(r=l(r)),r.length?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:ou(n,r)}}}:null}function ou(n,e){return ne("ul",{class:"cm-tooltip-lint"},e.map(t=>hu(n,t,!1)))}var Gl=n=>{let e=n.state.field(Je,!1);(!e||!e.panel)&&n.dispatch({effects:ru(n.state,[_l.of(!0)])});let t=ii(n,gs.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Fn=n=>{let e=n.state.field(Je,!1);return!e||!e.panel?!1:(n.dispatch({effects:_l.of(!1)}),!0)};var L0=ye.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(hi);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(hi);Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let r=i.reduce((s,o)=>s.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(A0(this.view.state,r))},i=>{He(this.view.state,i)})}}update(n){let e=n.state.facet(hi);(n.docChanged||e!=n.startState.facet(hi)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),hi=I.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},ze(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function lu(n,e={}){return[hi.of({source:n,config:e}),L0,uu]}function au(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function hu(n,e,t){var i;let r=t?au(e.actions):[];return ne("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ne("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let p=qi(n.state.field(Je).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:h}=s,c=r[o]?h.indexOf(r[o]):-1,f=c<0?h:[h.slice(0,c),ne("u",h.slice(c,c+1)),h.slice(c+1)];return ne("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&ne("div",{class:"cm-diagnosticSource"},e.source))}var $l=class extends et{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ne("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},ms=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=hu(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},gs=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)Fn(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=au(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=qi(this.view.state.field(Je).diagnostics,s);a&&s.actions[l].apply(e,a.from,a.to)}}else return;r.preventDefault()},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=ne("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=ne("div",{class:"cm-panel-lint"},this.list,ne("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Fn(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Je).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Je),i=0,r=!1,s=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new ms(this.view,a.diagnostic),this.items.splice(i,0,c),r=!0):(c=this.items[h],h>i&&(this.items.splice(i,h-i),r=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),s=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new ms(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&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(Je),i=qi(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:su.of(i)})}static open(e){return new n(e)}};function ps(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function ds(n){return ps(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var D0=z.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:ds("#d11")},".cm-lintRange-warning":{backgroundImage:ds("orange")},".cm-lintRange-info":{backgroundImage:ds("#999")},".cm-lintRange-hint":{backgroundImage:ds("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function iu(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}var Kl=class extends Ge{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((t,i)=>iu(t)<iu(i.severity)?i.severity:t,"hint")}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=e.state.facet(ks).tooltipFilter;return r&&(i=r(i)),i.length&&(t.onmouseover=()=>E0(e,t,i)),t}};function O0(n,e){let t=i=>{let r=e.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientX<r.right+10&&i.clientY>r.top-10&&i.clientY<r.bottom+10)){for(let s=i.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),n.state.field(fu)&&n.dispatch({effects:Ul.of(null)})}};window.addEventListener("mousemove",t)}function E0(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:Ul.of({pos:o.from,above:!1,create(){return{dom:ou(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,O0(n,e)}let{hoverTime:r}=n.state.facet(ks),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function B0(n,e){let t=Object.create(null);for(let r of e){let s=n.lineAt(r.from);(t[s.from]||(t[s.from]=[])).push(r)}let i=[];for(let r in t)i.push(new Kl(t[r]).range(+r));return ie.of(i,!0)}var P0=el({class:"cm-gutter-lint",markers:n=>n.state.field(cu)}),cu=me.define({create(){return ie.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet(ks).markerFilter;for(let i of e.effects)if(i.is(bs)){let r=i.value;t&&(r=t(r||[])),n=B0(e.state.doc,r.slice(0))}return n}}),Ul=X.define(),fu=me.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=nu(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(Ul)?i.value:t,n)},provide:n=>vn.from(n)}),R0=z.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:ps('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:ps('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:ps('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),uu=[Je,z.decorations.compute([Je],n=>{let{selected:e,panel:t}=n.field(Je);return!e||!t||e.from==e.to?J.none:J.set([T0.range(e.from,e.to)])}),vc(M0,{hideOn:nu}),D0],ks=I.define({combine(n){return ze(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function du(n={}){return[ks.of(n),cu,P0,R0,fu]}var ys={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ci=X.define({map(n,e){let t=e.mapPos(n,-1,Ce.TrackAfter);return t==null?void 0:t}}),Jl=new class extends Ze{};Jl.startSide=1;Jl.endSide=-1;var gu=me.define({create(){return ie.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(ci)&&(n=n.update({add:[Jl.range(t.value,t.value+1)]}));return n}});function bu(){return[F0,gu]}var Yl="()[]{}<>";function I0(n){for(let e=0;e<Yl.length;e+=2)if(Yl.charCodeAt(e)==n)return Yl.charAt(e+1);return ir(n<128?n:n+1)}function N0(n,e){return n.languageDataAt("closeBrackets",e)[0]||ys}var z0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),F0=z.inputHandler.of((n,e,t,i)=>{if((z0?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&St($e(i,0))==1||e!=r.from||t!=r.to)return!1;let s=H0(n.state,i);return s?(n.dispatch(s),!0):!1});function H0(n,e){let t=N0(n,n.selection.main.head),i=t.brackets||ys.brackets;for(let r of i){let s=I0($e(r,0));if(e==r)return s==r?j0(n,r,i.indexOf(r+r+r)>-1,t):V0(n,r,s,t.before||ys.before);if(e==s&&ku(n,n.selection.main.from))return W0(n,r,s)}return null}function ku(n,e){let t=!1;return n.field(gu).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Xl(n,e){let t=n.sliceString(e,e+2);return t.slice(0,St($e(t,0)))}function V0(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:ci.of(o.to+e.length),range:L.range(o.anchor+e.length,o.head+e.length)};let l=Xl(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:ci.of(o.head+e.length),range:L.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function W0(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&Xl(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:L.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function j0(n,e,t,i){let r=i.stringPrefixes||ys.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:ci.of(l.to+e.length),range:L.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Xl(n.doc,a),c;if(h==e){if(pu(n,a))return{changes:{insert:e+e,from:a},effects:ci.of(a+e.length),range:L.cursor(a+e.length)};if(ku(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:L.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=mu(n,a-2*e.length,r))>-1&&pu(n,c))return{changes:{insert:e+e+e+e,from:a},effects:ci.of(a+e.length),range:L.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=ue.Word&&mu(n,a,r)>-1&&!q0(n,a,e,r))return{changes:{insert:e+e,from:a},effects:ci.of(a+e.length),range:L.cursor(a+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function pu(n,e){let t=Be(n).resolveInner(e+1);return t.parent&&t.from==e}function q0(n,e,t,i){let r=Be(n).resolveInner(e,-1),s=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=r.firstChild;for(;c&&c.from==r.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=r.to==e&&r.parent;if(!h)break;r=h}return!1}function mu(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ue.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=ue.Word)return s}return-1}var S={permittedHtmlTags:["b","bdi","bdo","del","i","ins","u","font","big","small","sub","sup","h1","h2","h3","h4","h5","h6","cite","code","em","s","strike","strong","tt","var","div","center","blockquote","q","ol","ul","dl","table","caption","pre","ruby","rb","rp","rt","rtc","p","span","abbr","dfn","kbd","samp","data","time","mark","br","wbr","hr","li","dt","dd","td","th","tr","noinclude","includeonly","onlyinclude","img","meta","link"],implicitlyClosedHtmlTags:["br","hr","wbr","img","meta","link"],tags:{apostrophes:"mw-apostrophes",apostrophesBold:"mw-apostrophes-bold",apostrophesItalic:"mw-apostrophes-italic",comment:"mw-comment",doubleUnderscore:"mw-double-underscore",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",hr:"mw-hr",htmlTagAttribute:"mw-htmltag-attribute",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",sectionHeader:"mw-section-header",sectionHeader1:"mw-section-1",sectionHeader2:"mw-section-2",sectionHeader3:"mw-section-3",sectionHeader4:"mw-section-4",sectionHeader5:"mw-section-5",sectionHeader6:"mw-section-6",signature:"mw-signature",tableBracket:"mw-table-bracket",tableDefinition:"mw-table-definition",tableDelimiter:"mw-table-delimiter",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableName:"mw-templatevariable-name",section:"mw-section",em:"mw-em",error:"mw-error",extGround:"mw-ext-ground",ext2Ground:"mw-ext2-ground",ext2LinkGround:"mw-ext2-link-ground",ext3Ground:"mw-ext3-ground",ext3LinkGround:"mw-ext3-link-ground",extLinkGround:"mw-ext-link-ground",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",htmlEntity:"mw-html-entity",link:"mw-link",linkGround:"mw-link-ground",linkPageName:"mw-link-pagename",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateExtGround:"mw-template-ext-ground",templateExt2Ground:"mw-template-ext2-ground",templateExt2LinkGround:"mw-template-ext2-link-ground",templateExt3Ground:"mw-template-ext3-ground",templateExt3LinkGround:"mw-template-ext3-link-ground",templateExtLinkGround:"mw-template-ext-link-ground",templateGround:"mw-template-ground",templateLinkGround:"mw-template-link-ground",templateVariableDelimiter:"mw-templatevariable-delimiter",template2ExtGround:"mw-template2-ext-ground",template2Ext2Ground:"mw-template2-ext2-ground",template2Ext3Ground:"mw-template2-ext3-ground",templatet2Ext2LinkGround:"mw-template2-ext2-link-ground",template2Ext3LinkGround:"mw-template2-ext3-link-ground",template2ExtLinkGround:"mw-template2-ext-link-ground",template2Ground:"mw-template2-ground",template2LinkGround:"mw-template2-link-ground",template3ExtGround:"mw-template3-ext-ground",template3Ext2Ground:"mw-template3-ext2-ground",template3Ext3Ground:"mw-template3-ext3-ground",template3ExtLinkGround:"mw-template3-ext-link-ground",template3Ext2LinkGround:"mw-template3-ext2-link-ground",template3Ext3LinkGround:"mw-template3-ext3-link-ground",template3Ground:"mw-template3-ground",template3LinkGround:"mw-template3-link-ground"},get tokenTable(){let n={};for(let e of Object.values(this.tags))n[e]=Pe.define();return n}};var Hn={};cd(Hn,{css:()=>Du,javascript:()=>Ou,json:()=>Eu,lua:()=>Ru});function ws(n){n={...G0,...n};var e=n.inline,t=n.tokenHooks,i=n.documentTypes||{},r=n.mediaTypes||{},s=n.mediaFeatures||{},o=n.mediaValueKeywords||{},l=n.propertyKeywords||{},a=n.nonStandardPropertyKeywords||{},h=n.fontProperties||{},c=n.counterDescriptors||{},f=n.colorKeywords||{},u=n.valueKeywords||{},p=n.allowNested,g=n.lineComment,x=n.supportsAtComponent===!0,y=n.highlightNonStandardPropertyKeywords!==!1,v,M;function O(k,T){return v=T,k}function R(k,T){var A=k.next();if(t[A]){var V=t[A](k,T);if(V!==!1)return V}if(A=="@")return k.eatWhile(/[\w\\\-]/),O("def",k.current());if(A=="="||(A=="~"||A=="|")&&k.eat("="))return O(null,"compare");if(A=='"'||A=="'")return T.tokenize=F(A),T.tokenize(k,T);if(A=="#")return k.eatWhile(/[\w\\\-]/),O("atom","hash");if(A=="!")return k.match(/^\s*\w*/),O("keyword","important");if(/\d/.test(A)||A=="."&&k.eat(/\d/))return k.eatWhile(/[\w.%]/),O("number","unit");if(A==="-"){if(/[\d.]/.test(k.peek()))return k.eatWhile(/[\w.%]/),O("number","unit");if(k.match(/^-[\w\\\-]*/))return k.eatWhile(/[\w\\\-]/),k.match(/^\s*:/,!1)?O("def","variable-definition"):O("variableName","variable");if(k.match(/^\w+-/))return O("meta","meta")}else return/[,+>*\/]/.test(A)?O(null,"select-op"):A=="."&&k.match(/^-?[_a-z][_a-z0-9-]*/i)?O("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(A)?O(null,A):k.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(k.current())&&(T.tokenize=q),O("variableName.function","variable")):/[\w\\\-]/.test(A)?(k.eatWhile(/[\w\\\-]/),O("property","word")):O(null,null)}function F(k){return function(T,A){for(var V=!1,ae;(ae=T.next())!=null;){if(ae==k&&!V){k==")"&&T.backUp(1);break}V=!V&&ae=="\\"}return(ae==k||!V&&k!=")")&&(A.tokenize=null),O("string","string")}}function q(k,T){return k.next(),k.match(/^\s*[\"\')]/,!1)?T.tokenize=null:T.tokenize=F(")"),O(null,"(")}function w(k,T,A){this.type=k,this.indent=T,this.prev=A}function D(k,T,A,V){return k.context=new w(A,T.indentation()+(V===!1?0:T.indentUnit),k.context),A}function b(k){return k.context.prev&&(k.context=k.context.prev),k.context.type}function Y(k,T,A){return K[A.context.type](k,T,A)}function $(k,T,A,V){for(var ae=V||1;ae>0;ae--)A.context=A.context.prev;return Y(k,T,A)}function U(k){var T=k.current().toLowerCase();u.hasOwnProperty(T)?M="atom":f.hasOwnProperty(T)?M="keyword":M="variable"}var K={};return K.top=function(k,T,A){if(k=="{")return D(A,T,"block");if(k=="}"&&A.context.prev)return b(A);if(x&&/@component/i.test(k))return D(A,T,"atComponentBlock");if(/^@(-moz-)?document$/i.test(k))return D(A,T,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(k))return D(A,T,"atBlock");if(/^@(font-face|counter-style)/i.test(k))return A.stateArg=k,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(k))return"keyframes";if(k&&k.charAt(0)=="@")return D(A,T,"at");if(k=="hash")M="builtin";else if(k=="word")M="tag";else{if(k=="variable-definition")return"maybeprop";if(k=="interpolation")return D(A,T,"interpolation");if(k==":")return"pseudo";if(p&&k=="(")return D(A,T,"parens")}return A.context.type},K.block=function(k,T,A){if(k=="word"){var V=T.current().toLowerCase();return l.hasOwnProperty(V)?(M="property","maybeprop"):a.hasOwnProperty(V)?(M=y?"string.special":"property","maybeprop"):p?(M=T.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(M="error","maybeprop")}else return k=="meta"?"block":!p&&(k=="hash"||k=="qualifier")?(M="error","block"):K.top(k,T,A)},K.maybeprop=function(k,T,A){return k==":"?D(A,T,"prop"):Y(k,T,A)},K.prop=function(k,T,A){if(k==";")return b(A);if(k=="{"&&p)return D(A,T,"propBlock");if(k=="}"||k=="{")return $(k,T,A);if(k=="(")return D(A,T,"parens");if(k=="hash"&&!/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(T.current()))M="error";else if(k=="word")U(T);else if(k=="interpolation")return D(A,T,"interpolation");return"prop"},K.propBlock=function(k,T,A){return k=="}"?b(A):k=="word"?(M="property","maybeprop"):A.context.type},K.parens=function(k,T,A){return k=="{"||k=="}"?$(k,T,A):k==")"?b(A):k=="("?D(A,T,"parens"):k=="interpolation"?D(A,T,"interpolation"):(k=="word"&&U(T),"parens")},K.pseudo=function(k,T,A){return k=="meta"?"pseudo":k=="word"?(M="variableName.constant",A.context.type):Y(k,T,A)},K.documentTypes=function(k,T,A){return k=="word"&&i.hasOwnProperty(T.current())?(M="tag",A.context.type):K.atBlock(k,T,A)},K.atBlock=function(k,T,A){if(k=="(")return D(A,T,"atBlock_parens");if(k=="}"||k==";")return $(k,T,A);if(k=="{")return b(A)&&D(A,T,p?"block":"top");if(k=="interpolation")return D(A,T,"interpolation");if(k=="word"){var V=T.current().toLowerCase();V=="only"||V=="not"||V=="and"||V=="or"?M="keyword":r.hasOwnProperty(V)?M="attribute":s.hasOwnProperty(V)?M="property":o.hasOwnProperty(V)?M="keyword":l.hasOwnProperty(V)?M="property":a.hasOwnProperty(V)?M=y?"string.special":"property":u.hasOwnProperty(V)?M="atom":f.hasOwnProperty(V)?M="keyword":M="error"}return A.context.type},K.atComponentBlock=function(k,T,A){return k=="}"?$(k,T,A):k=="{"?b(A)&&D(A,T,p?"block":"top",!1):(k=="word"&&(M="error"),A.context.type)},K.atBlock_parens=function(k,T,A){return k==")"?b(A):k=="{"||k=="}"?$(k,T,A,2):K.atBlock(k,T,A)},K.restricted_atBlock_before=function(k,T,A){return k=="{"?D(A,T,"restricted_atBlock"):k=="word"&&A.stateArg=="@counter-style"?(M="variable","restricted_atBlock_before"):Y(k,T,A)},K.restricted_atBlock=function(k,T,A){return k=="}"?(A.stateArg=null,b(A)):k=="word"?(A.stateArg=="@font-face"&&!h.hasOwnProperty(T.current().toLowerCase())||A.stateArg=="@counter-style"&&!c.hasOwnProperty(T.current().toLowerCase())?M="error":M="property","maybeprop"):"restricted_atBlock"},K.keyframes=function(k,T,A){return k=="word"?(M="variable","keyframes"):k=="{"?D(A,T,"top"):Y(k,T,A)},K.at=function(k,T,A){return k==";"?b(A):k=="{"||k=="}"?$(k,T,A):(k=="word"?M="tag":k=="hash"&&(M="builtin"),"at")},K.interpolation=function(k,T,A){return k=="}"?b(A):k=="{"||k==";"?$(k,T,A):(k=="word"?M="variable":k!="variable"&&k!="("&&k!=")"&&(M="error"),"interpolation")},{name:n.name,startState:function(){return{tokenize:null,state:e?"block":"top",stateArg:null,context:new w(e?"block":"top",0,null)}},token:function(k,T){if(!T.tokenize&&k.eatSpace())return null;var A=(T.tokenize||R)(k,T);return A&&typeof A=="object"&&(v=A[1],A=A[0]),M=A,v!="comment"&&(T.state=K[T.state](v,k,T)),M},indent:function(k,T,A){var V=k.context,ae=T&&T.charAt(0),we=V.indent;return V.type=="prop"&&(ae=="}"||ae==")")&&(V=V.prev),V.prev&&(ae=="}"&&(V.type=="block"||V.type=="top"||V.type=="interpolation"||V.type=="restricted_atBlock")?(V=V.prev,we=V.indent):(ae==")"&&(V.type=="parens"||V.type=="atBlock_parens")||ae=="{"&&(V.type=="at"||V.type=="atBlock"))&&(we=Math.max(0,V.indent-A.unit))),we},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:g,block:{open:"/*",close:"*/"}},autocomplete:_0}}}function bt(n){for(var e={},t=0;t<n.length;++t)e[n[t].toLowerCase()]=!0;return e}var yu=["domain","regexp","url","url-prefix"],wu=bt(yu),xu=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],xs=bt(xu),vu=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover","prefers-color-scheme","dynamic-range","video-dynamic-range"],vs=bt(vu),Su=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],Zl=bt(Su),Cu=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","all","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","binding","bleed","block-size","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-content","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","inset","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-height-step","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotate","rotation","rotation-point","row-gap","ruby-align","ruby-overhang","ruby-position","ruby-span","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-orientation","text-outline","text-overflow","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],Ss=bt(Cu),Au=["accent-color","aspect-ratio","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","content-visibility","margin-block","margin-block-end","margin-block-start","margin-inline","margin-inline-end","margin-inline-start","overflow-anchor","overscroll-behavior","padding-block","padding-block-end","padding-block-start","padding-inline","padding-inline-end","padding-inline-start","scroll-snap-stop","scrollbar-3d-light-color","scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-track-color","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","shape-inside","zoom"],Cs=bt(Au),$0=["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],As=bt($0),K0=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],Tu=bt(K0),Mu=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],Ts=bt(Mu),Lu=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","blur","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","brightness","bullets","button","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","conic-gradient","contain","content","contents","content-box","context-menu","continuous","contrast","copy","counter","counters","cover","crop","cross","crosshair","cubic-bezier","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","drop-shadow","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","grayscale","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","hue-rotate","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","manipulation","match","matrix","matrix3d","media-play-button","media-slider","media-sliderthumb","media-volume-slider","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiple_mask_images","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturate","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","sepia","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],Ms=bt(Lu),_0=yu.concat(xu).concat(vu).concat(Su).concat(Cu).concat(Au).concat(Mu).concat(Lu);var G0={documentTypes:wu,mediaTypes:xs,mediaFeatures:vs,mediaValueKeywords:Zl,propertyKeywords:Ss,nonStandardPropertyKeywords:Cs,fontProperties:As,counterDescriptors:Tu,colorKeywords:Ts,valueKeywords:Ms,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=Kt,Kt(n,e)):!1}}},Du=ws({name:"css"});function Kt(n,e){for(var t=!1,i;(i=n.next())!=null;){if(t&&i=="/"){e.tokenize=null;break}t=i=="*"}return["comment","comment"]}var ik=ws({name:"scss",mediaTypes:xs,mediaFeatures:vs,mediaValueKeywords:Zl,propertyKeywords:Ss,nonStandardPropertyKeywords:Cs,colorKeywords:Ts,valueKeywords:Ms,fontProperties:As,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=Kt,Kt(n,e)):["operator","operator"]},":":function(n){return n.match(/^\s*\{/,!1)?[null,null]:!1},$:function(n){return n.match(/^[\w-]+/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName.special","variable"]},"#":function(n){return n.eat("{")?[null,"interpolation"]:!1}}}),nk=ws({name:"less",mediaTypes:xs,mediaFeatures:vs,mediaValueKeywords:Zl,propertyKeywords:Ss,nonStandardPropertyKeywords:Cs,colorKeywords:Ts,valueKeywords:Ms,fontProperties:As,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=Kt,Kt(n,e)):["operator","operator"]},"@":function(n){return n.eat("{")?[null,"interpolation"]:n.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)?!1:(n.eatWhile(/[\w\\\-]/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName","variable"])},"&":function(){return["atom","atom"]}}}),rk=ws({name:"gss",documentTypes:wu,mediaTypes:xs,mediaFeatures:vs,propertyKeywords:Ss,nonStandardPropertyKeywords:Cs,fontProperties:As,counterDescriptors:Tu,colorKeywords:Ts,valueKeywords:Ms,supportsAtComponent:!0,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=Kt,Kt(n,e)):!1}}});function Ls(n){var e=n.statementIndent,t=n.jsonld,i=n.json||t,r=n.typescript,s=n.wordCharacters||/[\w$\xa1-\uffff]/,o=function(){function d(Re){return{type:Re,style:"keyword"}}var m=d("keyword a"),C=d("keyword b"),B=d("keyword c"),N=d("keyword d"),ee=d("operator"),se={type:"atom",style:"atom"};return{if:d("if"),while:m,with:m,else:C,do:C,try:C,finally:C,return:N,break:N,continue:N,new:d("new"),delete:B,void:B,throw:B,debugger:d("debugger"),var:d("var"),const:d("var"),let:d("var"),function:d("function"),catch:d("catch"),for:d("for"),switch:d("switch"),case:d("case"),default:d("default"),in:ee,typeof:ee,instanceof:ee,true:se,false:se,null:se,undefined:se,NaN:se,Infinity:se,this:d("this"),class:d("class"),super:d("atom"),yield:B,export:d("export"),import:d("import"),extends:B,await:B}}(),l=/[+\-*&%=<>!?|~^@]/,a=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function h(d){for(var m=!1,C,B=!1;(C=d.next())!=null;){if(!m){if(C=="/"&&!B)return;C=="["?B=!0:B&&C=="]"&&(B=!1)}m=!m&&C=="\\"}}var c,f;function u(d,m,C){return c=d,f=C,m}function p(d,m){var C=d.next();if(C=='"'||C=="'")return m.tokenize=g(C),m.tokenize(d,m);if(C=="."&&d.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return u("number","number");if(C=="."&&d.match(".."))return u("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(C))return u(C);if(C=="="&&d.eat(">"))return u("=>","operator");if(C=="0"&&d.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return u("number","number");if(/\d/.test(C))return d.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),u("number","number");if(C=="/")return d.eat("*")?(m.tokenize=x,x(d,m)):d.eat("/")?(d.skipToEnd(),u("comment","comment")):ad(d,m,1)?(h(d),d.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(d.eat("="),u("operator","operator",d.current()));if(C=="`")return m.tokenize=y,y(d,m);if(C=="#"&&d.peek()=="!")return d.skipToEnd(),u("meta","meta");if(C=="#"&&d.eatWhile(s))return u("variable","property");if(C=="<"&&d.match("!--")||C=="-"&&d.match("->")&&!/\S/.test(d.string.slice(0,d.start)))return d.skipToEnd(),u("comment","comment");if(l.test(C))return(C!=">"||!m.lexical||m.lexical.type!=">")&&(d.eat("=")?(C=="!"||C=="=")&&d.eat("="):/[<>*+\-|&?]/.test(C)&&(d.eat(C),C==">"&&d.eat(C))),C=="?"&&d.eat(".")?u("."):u("operator","operator",d.current());if(s.test(C)){d.eatWhile(s);var B=d.current();if(m.lastType!="."){if(o.propertyIsEnumerable(B)){var N=o[B];return u(N.type,N.style,B)}if(B=="async"&&d.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",B)}return u("variable","variable",B)}}function g(d){return function(m,C){var B=!1,N;if(t&&m.peek()=="@"&&m.match(a))return C.tokenize=p,u("jsonld-keyword","meta");for(;(N=m.next())!=null&&!(N==d&&!B);)B=!B&&N=="\\";return B||(C.tokenize=p),u("string","string")}}function x(d,m){for(var C=!1,B;B=d.next();){if(B=="/"&&C){m.tokenize=p;break}C=B=="*"}return u("comment","comment")}function y(d,m){for(var C=!1,B;(B=d.next())!=null;){if(!C&&(B=="`"||B=="$"&&d.eat("{"))){m.tokenize=p;break}C=!C&&B=="\\"}return u("quasi","string.special",d.current())}var v="([{}])";function M(d,m){m.fatArrowAt&&(m.fatArrowAt=null);var C=d.string.indexOf("=>",d.start);if(!(C<0)){if(r){var B=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(d.string.slice(d.start,C));B&&(C=B.index)}for(var N=0,ee=!1,se=C-1;se>=0;--se){var Re=d.string.charAt(se),qe=v.indexOf(Re);if(qe>=0&&qe<3){if(!N){++se;break}if(--N==0){Re=="("&&(ee=!0);break}}else if(qe>=3&&qe<6)++N;else if(s.test(Re))ee=!0;else if(/["'\/`]/.test(Re))for(;;--se){if(se==0)return;var Yi=d.string.charAt(se-1);if(Yi==Re&&d.string.charAt(se-2)!="\\"){se--;break}}else if(ee&&!N){++se;break}}ee&&!N&&(m.fatArrowAt=se)}}var O={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function R(d,m,C,B,N,ee){this.indented=d,this.column=m,this.type=C,this.prev=N,this.info=ee,B!=null&&(this.align=B)}function F(d,m){for(var C=d.localVars;C;C=C.next)if(C.name==m)return!0;for(var B=d.context;B;B=B.prev)for(var C=B.vars;C;C=C.next)if(C.name==m)return!0}function q(d,m,C,B,N){var ee=d.cc;for(w.state=d,w.stream=N,w.marked=null,w.cc=ee,w.style=m,d.lexical.hasOwnProperty("align")||(d.lexical.align=!0);;){var se=ee.length?ee.pop():i?te:he;if(se(C,B)){for(;ee.length&&ee[ee.length-1].lex;)ee.pop()();return w.marked?w.marked:C=="variable"&&F(d,B)?"variableName.local":m}}}var w={state:null,column:null,marked:null,cc:null};function D(){for(var d=arguments.length-1;d>=0;d--)w.cc.push(arguments[d])}function b(){return D.apply(null,arguments),!0}function Y(d,m){for(var C=m;C;C=C.next)if(C.name==d)return!0;return!1}function $(d){var m=w.state;if(w.marked="def",m.context){if(m.lexical.info=="var"&&m.context&&m.context.block){var C=U(d,m.context);if(C!=null){m.context=C;return}}else if(!Y(d,m.localVars)){m.localVars=new T(d,m.localVars);return}}n.globalVars&&!Y(d,m.globalVars)&&(m.globalVars=new T(d,m.globalVars))}function U(d,m){if(m)if(m.block){var C=U(d,m.prev);return C?C==m.prev?m:new k(C,m.vars,!0):null}else return Y(d,m.vars)?m:new k(m.prev,new T(d,m.vars),!1);else return null}function K(d){return d=="public"||d=="private"||d=="protected"||d=="abstract"||d=="readonly"}function k(d,m,C){this.prev=d,this.vars=m,this.block=C}function T(d,m){this.name=d,this.next=m}var A=new T("this",new T("arguments",null));function V(){w.state.context=new k(w.state.context,w.state.localVars,!1),w.state.localVars=A}function ae(){w.state.context=new k(w.state.context,w.state.localVars,!0),w.state.localVars=null}V.lex=ae.lex=!0;function we(){w.state.localVars=w.state.context.vars,w.state.context=w.state.context.prev}we.lex=!0;function j(d,m){var C=function(){var B=w.state,N=B.indented;if(B.lexical.type=="stat")N=B.lexical.indented;else for(var ee=B.lexical;ee&&ee.type==")"&&ee.align;ee=ee.prev)N=ee.indented;B.lexical=new R(N,w.stream.column(),d,null,B.lexical,m)};return C.lex=!0,C}function W(){var d=w.state;d.lexical.prev&&(d.lexical.type==")"&&(d.indented=d.lexical.indented),d.lexical=d.lexical.prev)}W.lex=!0;function _(d){function m(C){return C==d?b():d==";"||C=="}"||C==")"||C=="]"?D():b(m)}return m}function he(d,m){return d=="var"?b(j("vardef",m),zs,_(";"),W):d=="keyword a"?b(j("form"),Ps,he,W):d=="keyword b"?b(j("form"),he,W):d=="keyword d"?w.stream.match(/^\s*$/,!1)?b():b(j("stat"),di,_(";"),W):d=="debugger"?b(_(";")):d=="{"?b(j("}"),ae,jn,W,we):d==";"?b():d=="if"?(w.state.lexical.info=="else"&&w.state.cc[w.state.cc.length-1]==W&&w.state.cc.pop()(),b(j("form"),Ps,he,W,la)):d=="function"?b(Dt):d=="for"?b(j("form"),ae,aa,he,we,W):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form",d=="class"?d:m),ca,W)):d=="variable"?r&&m=="declare"?(w.marked="keyword",b(he)):r&&(m=="module"||m=="enum"||m=="type")&&w.stream.match(/^\s*\w/,!1)?(w.marked="keyword",m=="enum"?b(da):m=="type"?b(ha,_("operator"),re,_(";")):b(j("form"),Xe,_("{"),j("}"),jn,W,W)):r&&m=="namespace"?(w.marked="keyword",b(j("form"),te,he,W)):r&&m=="abstract"?(w.marked="keyword",b(he)):b(j("stat"),qu):d=="switch"?b(j("form"),Ps,_("{"),j("}","switch"),ae,jn,W,W,we):d=="case"?b(te,_(":")):d=="default"?b(_(":")):d=="catch"?b(j("form"),V,Mt,he,W,we):d=="export"?b(j("stat"),id,W):d=="import"?b(j("stat"),nd,W):d=="async"?b(he):m=="@"?b(te,he):D(j("stat"),te,_(";"),W)}function Mt(d){if(d=="(")return b(Yt,_(")"))}function te(d,m){return ia(d,m,!1)}function Te(d,m){return ia(d,m,!0)}function Ps(d){return d!="("?D():b(j(")"),di,_(")"),W)}function ia(d,m,C){if(w.state.fatArrowAt==w.stream.start){var B=C?ra:na;if(d=="(")return b(V,j(")"),Se(Yt,")"),W,_("=>"),B,we);if(d=="variable")return D(V,Xe,_("=>"),B,we)}var N=C?pi:Gt;return O.hasOwnProperty(d)?b(N):d=="function"?b(Dt,N):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form"),td,W)):d=="keyword c"||d=="async"?b(C?Te:te):d=="("?b(j(")"),di,_(")"),W,N):d=="operator"||d=="spread"?b(C?Te:te):d=="["?b(j("]"),sd,W,N):d=="{"?Gi(Wn,"}",null,N):d=="quasi"?D(Vn,N):d=="new"?b(Vu(C)):b()}function di(d){return d.match(/[;\}\)\],]/)?D():D(te)}function Gt(d,m){return d==","?b(di):pi(d,m,!1)}function pi(d,m,C){var B=C==!1?Gt:pi,N=C==!1?te:Te;if(d=="=>")return b(V,C?ra:na,we);if(d=="operator")return/\+\+|--/.test(m)||r&&m=="!"?b(B):r&&m=="<"&&w.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?b(j(">"),Se(re,">"),W,B):m=="?"?b(te,_(":"),N):b(N);if(d=="quasi")return D(Vn,B);if(d!=";"){if(d=="(")return Gi(Te,")","call",B);if(d==".")return b($u,B);if(d=="[")return b(j("]"),di,_("]"),W,B);if(r&&m=="as")return w.marked="keyword",b(re,B);if(d=="regexp")return w.state.lastType=w.marked="operator",w.stream.backUp(w.stream.pos-w.stream.start-1),b(N)}}function Vn(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Vn):b(di,Hu)}function Hu(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Vn)}function na(d){return M(w.stream,w.state),D(d=="{"?he:te)}function ra(d){return M(w.stream,w.state),D(d=="{"?he:Te)}function Vu(d){return function(m){return m=="."?b(d?ju:Wu):m=="variable"&&r?b(Ju,d?pi:Gt):D(d?Te:te)}}function Wu(d,m){if(m=="target")return w.marked="keyword",b(Gt)}function ju(d,m){if(m=="target")return w.marked="keyword",b(pi)}function qu(d){return d==":"?b(W,he):D(Gt,_(";"),W)}function $u(d){if(d=="variable")return w.marked="property",b()}function Wn(d,m){if(d=="async")return w.marked="property",b(Wn);if(d=="variable"||w.style=="keyword"){if(w.marked="property",m=="get"||m=="set")return b(Ku);var C;return r&&w.state.fatArrowAt==w.stream.start&&(C=w.stream.match(/^\s*:\s*/,!1))&&(w.state.fatArrowAt=w.stream.pos+C[0].length),b(Ut)}else{if(d=="number"||d=="string")return w.marked=t?"property":w.style+" property",b(Ut);if(d=="jsonld-keyword")return b(Ut);if(r&&K(m))return w.marked="keyword",b(Wn);if(d=="[")return b(te,mi,_("]"),Ut);if(d=="spread")return b(Te,Ut);if(m=="*")return w.marked="keyword",b(Wn);if(d==":")return D(Ut)}}function Ku(d){return d!="variable"?D(Ut):(w.marked="property",b(Dt))}function Ut(d){if(d==":")return b(Te);if(d=="(")return D(Dt)}function Se(d,m,C){function B(N,ee){if(C?C.indexOf(N)>-1:N==","){var se=w.state.lexical;return se.info=="call"&&(se.pos=(se.pos||0)+1),b(function(Re,qe){return Re==m||qe==m?D():D(d)},B)}return N==m||ee==m?b():C&&C.indexOf(";")>-1?D(d):b(_(m))}return function(N,ee){return N==m||ee==m?b():D(d,B)}}function Gi(d,m,C){for(var B=3;B<arguments.length;B++)w.cc.push(arguments[B]);return b(j(m,C),Se(d,m),W)}function jn(d){return d=="}"?b():D(he,jn)}function mi(d,m){if(r){if(d==":")return b(re);if(m=="?")return b(mi)}}function _u(d,m){if(r&&(d==":"||m=="in"))return b(re)}function sa(d){if(r&&d==":")return w.stream.match(/^\s*\w+\s+is\b/,!1)?b(te,Gu,re):b(re)}function Gu(d,m){if(m=="is")return w.marked="keyword",b()}function re(d,m){if(m=="keyof"||m=="typeof"||m=="infer"||m=="readonly")return w.marked="keyword",b(m=="typeof"?Te:re);if(d=="variable"||m=="void")return w.marked="type",b(yt);if(m=="|"||m=="&")return b(re);if(d=="string"||d=="number"||d=="atom")return b(yt);if(d=="[")return b(j("]"),Se(re,"]",","),W,yt);if(d=="{")return b(j("}"),Rs,W,yt);if(d=="(")return b(Se(Ns,")"),Uu,yt);if(d=="<")return b(Se(re,">"),re);if(d=="quasi")return D(Is,yt)}function Uu(d){if(d=="=>")return b(re)}function Rs(d){return d.match(/[\}\)\]]/)?b():d==","||d==";"?b(Rs):D(Ui,Rs)}function Ui(d,m){if(d=="variable"||w.style=="keyword")return w.marked="property",b(Ui);if(m=="?"||d=="number"||d=="string")return b(Ui);if(d==":")return b(re);if(d=="[")return b(_("variable"),_u,_("]"),Ui);if(d=="(")return D(bi,Ui);if(!d.match(/[;\}\)\],]/))return b()}function Is(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Is):b(re,Yu)}function Yu(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Is)}function Ns(d,m){return d=="variable"&&w.stream.match(/^\s*[?:]/,!1)||m=="?"?b(Ns):d==":"?b(re):d=="spread"?b(Ns):D(re)}function yt(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,yt);if(m=="|"||d=="."||m=="&")return b(re);if(d=="[")return b(re,_("]"),yt);if(m=="extends"||m=="implements")return w.marked="keyword",b(re);if(m=="?")return b(re,_(":"),re)}function Ju(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,yt)}function qn(){return D(re,Xu)}function Xu(d,m){if(m=="=")return b(re)}function zs(d,m){return m=="enum"?(w.marked="keyword",b(da)):D(Xe,mi,Lt,Qu)}function Xe(d,m){if(r&&K(m))return w.marked="keyword",b(Xe);if(d=="variable")return $(m),b();if(d=="spread")return b(Xe);if(d=="[")return Gi(Zu,"]");if(d=="{")return Gi(oa,"}")}function oa(d,m){return d=="variable"&&!w.stream.match(/^\s*:/,!1)?($(m),b(Lt)):(d=="variable"&&(w.marked="property"),d=="spread"?b(Xe):d=="}"?D():d=="["?b(te,_("]"),_(":"),oa):b(_(":"),Xe,Lt))}function Zu(){return D(Xe,Lt)}function Lt(d,m){if(m=="=")return b(Te)}function Qu(d){if(d==",")return b(zs)}function la(d,m){if(d=="keyword b"&&m=="else")return b(j("form","else"),he,W)}function aa(d,m){if(m=="await")return b(aa);if(d=="(")return b(j(")"),ed,W)}function ed(d){return d=="var"?b(zs,gi):d=="variable"?b(gi):D(gi)}function gi(d,m){return d==")"?b():d==";"?b(gi):m=="in"||m=="of"?(w.marked="keyword",b(te,gi)):D(te,gi)}function Dt(d,m){if(m=="*")return w.marked="keyword",b(Dt);if(d=="variable")return $(m),b(Dt);if(d=="(")return b(V,j(")"),Se(Yt,")"),W,sa,he,we);if(r&&m=="<")return b(j(">"),Se(qn,">"),W,Dt)}function bi(d,m){if(m=="*")return w.marked="keyword",b(bi);if(d=="variable")return $(m),b(bi);if(d=="(")return b(V,j(")"),Se(Yt,")"),W,sa,we);if(r&&m=="<")return b(j(">"),Se(qn,">"),W,bi)}function ha(d,m){if(d=="keyword"||d=="variable")return w.marked="type",b(ha);if(m=="<")return b(j(">"),Se(qn,">"),W)}function Yt(d,m){return m=="@"&&b(te,Yt),d=="spread"?b(Yt):r&&K(m)?(w.marked="keyword",b(Yt)):r&&d=="this"?b(mi,Lt):D(Xe,mi,Lt)}function td(d,m){return d=="variable"?ca(d,m):$n(d,m)}function ca(d,m){if(d=="variable")return $(m),b($n)}function $n(d,m){if(m=="<")return b(j(">"),Se(qn,">"),W,$n);if(m=="extends"||m=="implements"||r&&d==",")return m=="implements"&&(w.marked="keyword"),b(r?re:te,$n);if(d=="{")return b(j("}"),wt,W)}function wt(d,m){if(d=="async"||d=="variable"&&(m=="static"||m=="get"||m=="set"||r&&K(m))&&w.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1))return w.marked="keyword",b(wt);if(d=="variable"||w.style=="keyword")return w.marked="property",b(Kn,wt);if(d=="number"||d=="string")return b(Kn,wt);if(d=="[")return b(te,mi,_("]"),Kn,wt);if(m=="*")return w.marked="keyword",b(wt);if(r&&d=="(")return D(bi,wt);if(d==";"||d==",")return b(wt);if(d=="}")return b();if(m=="@")return b(te,wt)}function Kn(d,m){if(m=="!"||m=="?")return b(Kn);if(d==":")return b(re,Lt);if(m=="=")return b(Te);var C=w.state.lexical.prev,B=C&&C.info=="interface";return D(B?bi:Dt)}function id(d,m){return m=="*"?(w.marked="keyword",b(Fs,_(";"))):m=="default"?(w.marked="keyword",b(te,_(";"))):d=="{"?b(Se(fa,"}"),Fs,_(";")):D(he)}function fa(d,m){if(m=="as")return w.marked="keyword",b(_("variable"));if(d=="variable")return D(Te,fa)}function nd(d){return d=="string"?b():d=="("?D(te):d=="."?D(Gt):D(_n,ua,Fs)}function _n(d,m){return d=="{"?Gi(_n,"}"):(d=="variable"&&$(m),m=="*"&&(w.marked="keyword"),b(rd))}function ua(d){if(d==",")return b(_n,ua)}function rd(d,m){if(m=="as")return w.marked="keyword",b(_n)}function Fs(d,m){if(m=="from")return w.marked="keyword",b(te)}function sd(d){return d=="]"?b():D(Se(Te,"]"))}function da(){return D(j("form"),Xe,_("{"),j("}"),Se(od,"}"),W,W)}function od(){return D(Xe,Lt)}function ld(d,m){return d.lastType=="operator"||d.lastType==","||l.test(m.charAt(0))||/[,.]/.test(m.charAt(0))}function ad(d,m,C){return m.tokenize==p&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(m.lastType)||m.lastType=="quasi"&&/\{\s*$/.test(d.string.slice(0,d.pos-(C||0)))}return{name:n.name,startState:function(d){var m={tokenize:p,lastType:"sof",cc:[],lexical:new R(-d,0,"block",!1),localVars:n.localVars,context:n.localVars&&new k(null,null,!1),indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(m.globalVars=n.globalVars),m},token:function(d,m){if(d.sol()&&(m.lexical.hasOwnProperty("align")||(m.lexical.align=!1),m.indented=d.indentation(),M(d,m)),m.tokenize!=x&&d.eatSpace())return null;var C=m.tokenize(d,m);return c=="comment"?C:(m.lastType=c=="operator"&&(f=="++"||f=="--")?"incdec":c,q(m,C,c,f,d))},indent:function(d,m,C){if(d.tokenize==x||d.tokenize==y)return null;if(d.tokenize!=p)return 0;var B=m&&m.charAt(0),N=d.lexical,ee;if(!/^\s*else\b/.test(m))for(var se=d.cc.length-1;se>=0;--se){var Re=d.cc[se];if(Re==W)N=N.prev;else if(Re!=la&&Re!=we)break}for(;(N.type=="stat"||N.type=="form")&&(B=="}"||(ee=d.cc[d.cc.length-1])&&(ee==Gt||ee==pi)&&!/^[,\.=+\-*:?[\(]/.test(m));)N=N.prev;e&&N.type==")"&&N.prev.type=="stat"&&(N=N.prev);var qe=N.type,Yi=B==qe;return qe=="vardef"?N.indented+(d.lastType=="operator"||d.lastType==","?N.info.length+1:0):qe=="form"&&B=="{"?N.indented:qe=="form"?N.indented+C.unit:qe=="stat"?N.indented+(ld(d,m)?e||C.unit:0):N.info=="switch"&&!Yi&&n.doubleIndentSwitch!=!1?N.indented+(/^(?:case|default)\b/.test(m)?C.unit:2*C.unit):N.align?N.column+(Yi?0:1):N.indented+(Yi?0:C.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:i?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}var Ou=Ls({name:"javascript"}),Eu=Ls({name:"json",json:!0}),ok=Ls({name:"json",jsonld:!0}),lk=Ls({name:"typescript",typescript:!0});function U0(n){return new RegExp("^(?:"+n.join("|")+")","i")}function Ds(n){return new RegExp("^(?:"+n.join("|")+")$","i")}var Y0=Ds(["_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall","coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield","debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback","close","flush","lines","read","seek","setvbuf","write","io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write","math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh","os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname","package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall","string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper","table.concat","table.insert","table.maxn","table.remove","table.sort"]),J0=Ds(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),X0=Ds(["function","if","repeat","do","\\(","{"]),Z0=Ds(["end","until","\\)","}"]),Q0=U0(["end","until","\\)","}","else","elseif"]);function Bu(n){for(var e=0;n.eat("=");)++e;return n.eat("["),e}function Ql(n,e){var t=n.next();return t=="-"&&n.eat("-")?n.eat("[")&&n.eat("[")?(e.cur=Pu(Bu(n),"comment"))(n,e):(n.skipToEnd(),"comment"):t=='"'||t=="'"?(e.cur=eb(t))(n,e):t=="["&&/[\[=]/.test(n.peek())?(e.cur=Pu(Bu(n),"string"))(n,e):/\d/.test(t)?(n.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(t)?(n.eatWhile(/[\w\\\-_.]/),"variable"):null}function Pu(n,e){return function(t,i){for(var r=null,s;(s=t.next())!=null;)if(r==null)s=="]"&&(r=0);else if(s=="=")++r;else if(s=="]"&&r==n){i.cur=Ql;break}else r=null;return e}}function eb(n){return function(e,t){for(var i=!1,r;(r=e.next())!=null&&!(r==n&&!i);)i=!i&&r=="\\";return i||(t.cur=Ql),"string"}}var Ru={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:Ql}},token:function(n,e){if(n.eatSpace())return null;var t=e.cur(n,e),i=n.current();return t=="variable"&&(J0.test(i)?t="keyword":Y0.test(i)&&(t="builtin")),t!="comment"&&t!="string"&&(X0.test(i)?++e.indentDepth:Z0.test(i)&&--e.indentDepth),t},indent:function(n,e,t){var i=Q0.test(e);return n.basecol+t.unit*(n.indentDepth-(i?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}};var Iu=n=>{let e={};for(let[t,i]of Object.entries(n))Object.assign(e,{[t]:Array.isArray(i)?[...i]:i});return e},Nu=document.createElement("span"),tb=n=>(Nu.innerHTML=n,[...Nu.textContent].length===1),Os=class{constructor(e){this.config=e,this.urlProtocols=new RegExp(`^(?:${e.urlProtocols})`,"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.oldTokens=[],this.tokenTable={...S.tokenTable},this.permittedHtmlTags=new Set([...S.permittedHtmlTags,...e.permittedHtmlTags||[]]),this.implicitlyClosedHtmlTags=new Set([...S.implicitlyClosedHtmlTags,...e.implicitlyClosedHtmlTags||[]]);for(let t of Object.keys(e.tags))this.addTag(t)}get fileRegex(){let e=Object.entries(this.config.nsid).filter(([,t])=>t===6).map(([t])=>t).join("|");return new RegExp(`^\\s*(?:${e})\\s*:\\s*`,"iu")}addTag(e,t){var i,r;(i=this.tokenTable)[r=`mw-tag-${e}`]||(i[r]=Pe.define(t))}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}${e==="templateName"?" cm-mw-pagename":""}`}))}eatHtmlEntity(e,t){let i=e.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&tb(`&${i[0]}`)?S.tags.htmlEntity:t}makeStyle(e,t,i){return this.makeLocalStyle(`${e} ${this.isBold?S.tags.strong:""} ${this.isItalic?S.tags.em:""}`,t,i)}makeLocalStyle(e,t,i){let r="";switch(t.nTemplate){case 0:break;case 1:r+="-template";break;case 2:r+="-template2";break;default:r+="-template3";break}switch(t.nExt){case 0:break;case 1:r+="-ext";break;case 2:r+="-ext2";break;default:r+="-ext3";break}return t.nLink>0&&(r+="-link"),i&&t[i]--,(r&&`mw${r}-ground `)+e}inBlock(e,t,i=!0){return(r,s)=>(r.skipTo(t)?(i&&r.match(t),s.tokenize=s.stack.pop()):r.skipToEnd(),this.makeLocalStyle(e,s))}eatEnd(e){return(t,i)=>(t.skipToEnd(),i.tokenize=i.stack.pop(),this.makeLocalStyle(e,i))}inChar(e,t){return(i,r)=>i.eat(e)?(r.tokenize=r.stack.pop(),this.makeLocalStyle(t,r)):(i.skipTo(e)||i.skipToEnd(),this.makeLocalStyle(S.tags.error,r))}inSectionHeader(e){return(t,i)=>t.match(/^[^&<[{~']+/u)?(t.eol()?(t.backUp(e),i.tokenize=this.eatEnd(S.tags.sectionHeader)):t.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(t.backUp(e),i.tokenize=this.inBlock(S.tags.sectionHeader,"<!--",!1)),this.makeLocalStyle(S.tags.section,i)):this.eatWikiText(S.tags.section)(t,i)}inVariable(e,t){return e.match(/^[^{}|]+/u)?this.makeLocalStyle(S.tags.templateVariableName,t):e.eat("|")?(t.tokenize=this.inVariableDefault(!0),this.makeLocalStyle(S.tags.templateVariableDelimiter,t)):e.match("}}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,t)):e.match("{{{")?(t.stack.push(t.tokenize),this.makeLocalStyle(S.tags.templateVariableBracket,t)):(e.next(),this.makeLocalStyle(S.tags.templateVariableName,t))}inVariableDefault(e){let t=S.tags[e?"templateVariable":"comment"];return(i,r)=>i.match(/^[^{}[<&~|]+/u)?this.makeStyle(t,r):i.match("}}}")?(r.tokenize=r.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,r)):i.eat("|")?(r.tokenize=this.inVariableDefault(!1),this.makeLocalStyle(S.tags.templateVariableDelimiter,r)):this.eatWikiText(t)(i,r)}inParserFunctionName(e,t){return e.match(/^[^:}{~|<>[\]]+/u)?this.makeLocalStyle(S.tags.parserFunctionName,t):e.eat(":")?(t.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(S.tags.parserFunctionDelimiter,t)):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.error)(e,t)}inParserFunctionArguments(e,t){return e.match(/^[^|}{[<&~]+/u)?this.makeLocalStyle(S.tags.parserFunction,t):e.eat("|")?this.makeLocalStyle(S.tags.parserFunctionDelimiter,t):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.parserFunction)(e,t)}inTemplatePageName(e){return(t,i)=>t.match(/^\s*\|\s*/u)?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match(/^\s*\}\}/u)?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):t.match(/^\s*<!--.*?-->/u)?this.makeLocalStyle(S.tags.comment,i):e&&t.sol()?(i.nTemplate--,i.tokenize=i.stack.pop(),""):t.match(/^\s*[^\s|&~{}<>[\]]+/u)?(i.tokenize=this.inTemplatePageName(!0),this.makeLocalStyle(S.tags.templateName,i)):t.match(/^(?:[<>[\]}]|\{(?!\{))/u)?this.makeLocalStyle(S.tags.error,i):t.eatSpace()?this.makeLocalStyle(S.tags.templateName,i):this.eatWikiText(S.tags.templateName)(t,i)}inTemplateArgument(e){return(t,i)=>e&&t.eatWhile(/[^=|}{[<&~]/u)?t.eat("=")?(i.tokenize=this.inTemplateArgument(!1),this.makeLocalStyle(S.tags.templateArgumentName,i)):this.makeLocalStyle(S.tags.template,i):t.eatWhile(/[^|}{[<&~]/u)?this.makeLocalStyle(S.tags.template,i):t.eat("|")?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match("}}")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):this.eatWikiText(S.tags.template)(t,i)}eatExternalLinkProtocol(e){return(t,i)=>{for(let r=0;r<e;r++)t.next();return t.eol()?(i.nLink--,i.tokenize=i.stack.pop()):i.tokenize=this.inExternalLink.bind(this),this.makeLocalStyle(S.tags.extLinkProtocol,i)}}inExternalLink(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.match(/^\s*\]/u)?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.eatSpace()?(t.tokenize=this.inExternalLinkText.bind(this),this.makeLocalStyle("",t)):e.match(/^[^\s\]{&~']+/u)?(e.peek()==="'"&&(e.match("''",!1)?t.tokenize=this.inExternalLinkText.bind(this):e.next()),this.makeLocalStyle(S.tags.extLink,t)):this.eatWikiText(S.tags.extLink)(e,t)}inExternalLinkText(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.eat("]")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.match(/^[^'\]{&~<]+/u)?this.makeStyle(S.tags.extLinkText,t):this.eatWikiText(S.tags.extLinkText)(e,t)}inLink(e){return(t,i)=>{if(t.sol())return i.nLink--,i.tokenize=i.stack.pop(),"";if(t.match(/^\s*#\s*/u))return i.tokenize=this.inLinkToSection(e),this.makeStyle(S.tags.link,i);if(t.match(/^\s*\|\s*/u))return i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i);if(t.match(/^\s*\]\]/u))return i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink");if(t.match(/^(?:[<>[\]}]|\{(?!\{))/u))return this.makeStyle(S.tags.error,i);let r=`${S.tags.linkPageName} ${S.tags.pageName}`;return t.match(/^[^#|[\]&~{}<>]+/u)?this.makeStyle(r,i):this.eatWikiText(r)(t,i)}}inLinkToSection(e){return(t,i)=>t.sol()?(i.nLink--,i.tokenize=i.stack.pop(),""):t.match(/^[^|\]&~{}]+/u)?this.makeStyle(S.tags.linkToSection,i):t.eat("|")?(i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i)):t.match("]]")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink")):this.eatWikiText(S.tags.linkToSection)(t,i)}inLinkText(e){let t,i;return(r,s)=>{let o=`${S.tags.linkText} ${t?S.tags.strong:""} ${i?S.tags.em:""}`;if(r.match("]]"))return s.lbrack&&r.peek()==="]"?(r.backUp(1),s.lbrack=!1,this.makeStyle(o,s)):(s.tokenize=s.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,s,"nLink"));if(e&&r.eat("|"))return this.makeLocalStyle(S.tags.linkDelimiter,s);if(r.match("'''"))return t=!t,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);if(r.match("''"))return i=!i,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);let l=r.match(e?/^(?:[^'\]{&~<|[]|\[(?!\[))+/u:/^[^'\]{&~<]+/u);return l&&l[0].includes("[")&&(s.lbrack=!0),l?this.makeStyle(o,s):this.eatWikiText(o)(r,s)}}eatTagName(e,t,i){return(r,s)=>{let o="";for(let l=0;l<e;l++)o+=r.next();return r.eatSpace(),o=o.toLowerCase(),i?(s.tokenize=t?this.inChar(">",S.tags.htmlTagBracket):this.inHtmlTagAttribute(o),this.makeLocalStyle(S.tags.htmlTagName,s)):(s.tokenize=t?this.inChar(">",S.tags.extTagBracket):this.inExtTagAttribute(o),this.makeLocalStyle(S.tags.extTagName,s))}}inHtmlTagAttribute(e){return(t,i)=>t.match(/^[^>/<{]+/u)?this.makeLocalStyle(S.tags.htmlTagAttribute,i):t.match(/^\/?>/u)?(this.implicitlyClosedHtmlTags.has(e)||i.inHtmlTag.push(e),i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.htmlTagBracket,i)):this.eatWikiText(S.tags.htmlTagAttribute)(t,i)}eatNowiki(){return e=>e.match(/^[^&]+/u)?"":(e.next(),this.eatHtmlEntity(e,""))}inExtTagAttribute(e){return(t,i)=>t.match(/^[^>/]+/u)?this.makeLocalStyle(S.tags.extTagAttribute,i):t.eat(">")?(i.extName=e,e==="nowiki"||e==="pre"?(i.extMode={startState:()=>({}),token:this.eatNowiki()},i.extState={}):e in this.config.tagModes&&(i.extMode=this[this.config.tagModes[e]],i.extState=i.extMode.startState(0)),i.tokenize=this.eatExtTagArea(e),this.makeLocalStyle(S.tags.extTagBracket,i)):t.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.extTagBracket,i)):this.eatWikiText(S.tags.extTagAttribute)(t,i)}eatExtTagArea(e){return(t,i)=>{let r=t.pos,s=new RegExp(`</${e}\\s*(?:>|$)`,"iu"),o=s.exec(r?t.string.slice(r):t.string),l=!1;if(o){if(o.index===0)return i.tokenize=this.eatExtCloseTag(e),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(t,i);let a=o.index+r;l=t.string,t.string=l.slice(0,a)}return i.stack.push(i.tokenize),i.tokenize=this.inExtTokens(l),i.tokenize(t,i)}}eatExtCloseTag(e){return(t,i)=>(t.next(),t.next(),i.tokenize=this.eatTagName(e.length,!0,!1),this.makeLocalStyle(S.tags.extTagBracket,i))}inExtTokens(e){return(t,i)=>{let r;return i.extMode===!1?(r=S.tags.extTag,t.skipToEnd()):r=`mw-tag-${i.extName} ${i.extMode.token(t,i.extState)}`,t.eol()&&(e!==!1&&(t.string=e),i.tokenize=i.stack.pop()),r}}eatStartTable(e,t){return e.match(/^(?:\{\||\{{3}\s*!\s*\}\})\s*/u),t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,t)}inTableDefinition(e,t){return e.sol()?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):this.eatWikiText(S.tags.tableDefinition)(e,t)}inTableCaption(e,t){return e.sol()&&e.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1)?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):e.match(/^\s*(?:\||\{\{\s*!\s*\}\}){2}/u,!1)?(t.tokenize=this.inTableRow(!1,!1),""):this.eatWikiText(S.tags.tableCaption)(e,t)}inTable(e,t){if(e.sol()){if(e.eatSpace(),e.match(/^(?:\||\{\{\s*!\s*\}\})/u))return e.match(/^-+\s*/u)?(t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("+")?(e.eatSpace(),t.tokenize=this.inTableCaption.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.tableBracket,t)):(e.eatSpace(),t.tokenize=this.inTableRow(!0,!1),this.makeLocalStyle(S.tags.tableDelimiter,t));if(e.eat("!"))return e.eatSpace(),t.tokenize=this.inTableRow(!0,!0),this.makeLocalStyle(S.tags.tableDelimiter,t)}return this.eatWikiText("")(e,t)}inTableRow(e,t){return(i,r)=>{if(i.sol()){if(i.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1))return r.tokenize=this.inTable.bind(this),this.inTable(i,r)}else{if(i.match(/^[^'|{[<&~!]+/u))return this.makeStyle(t?S.tags.strong:"",r);if(i.match(/^(?:\||\{\{\s*!\s*\}\}){2}/u)||t&&i.match("!!")||e&&i.match(/^(?:\||\{\{\s*!\s*\}\})/u))return this.isBold=!1,this.isItalic=!1,e&&(r.tokenize=this.inTableRow(!1,t)),this.makeLocalStyle(S.tags.tableDelimiter,r)}return this.eatWikiText(t?S.tags.strong:"")(i,r)}}eatFreeExternalLinkProtocol(e,t){return e.match(this.urlProtocols),t.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,t)}inFreeExternalLink(e,t){if(!e.eol()){let i=e.match(/^[^\s{[\]<>~).,;:!?'"]*/u);if(t.lpar||(t.lpar=i[0].includes("(")),e.peek()==="~"){if(e.match(/^~{1,2}(?!~)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="{"){if(e.match(/^\{(?!\{)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="'"){if(e.match(/^'(?!')/u))return this.makeStyle(S.tags.freeExtLink,t)}else{if(t.lpar&&e.peek()===")")return e.next(),this.makeStyle(S.tags.freeExtLink,t);if(e.match(/^[).,;:!?]+(?=[^\s{[\]<>~).,;:!?'"]|~~?(?!~)|\{(?!\{)|'(?!'))/u))return this.makeStyle(S.tags.freeExtLink,t)}}return t.lpar=!1,t.tokenize=t.stack.pop(),this.makeStyle(S.tags.freeExtLink,t)}eatWikiText(e){return(t,i)=>{let r;if(t.sol()){if(t.match("//"))return this.makeStyle(e,i);if(t.match(this.urlProtocols))return i.stack.push(i.tokenize),i.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,i);switch(r=t.next(),r){case"-":if(t.match(/^-{3,}/u))return S.tags.hr;break;case"=":{let o=t.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->.*\S).*)?)$/u);if(o)return t.backUp(o[2].length),i.stack.push(i.tokenize),i.tokenize=this.inSectionHeader(o[3].length),this.makeLocalStyle(`${S.tags.sectionHeader} ${S.tags[`sectionHeader${o[1].length+1}`]}`,i);break}case"*":case"#":case";":return t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case":":return t.match(/^:*(?:\{\||\{{3}\s*!\s*\}\})/u,!1)&&(i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this)),t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case" ":{let o=t.match(/^\s*(:+\s*)?(?=\{\||\{{3}\s*!\s*\}\})/u);if(o){if(o[1])return i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this),this.makeLocalStyle(S.tags.list,i);t.eat("{")}else return S.tags.skipFormatting}case"{":if(t.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return i.stack.push(i.tokenize),i.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,i);break;default:}}else r=t.next();switch(r){case"&":return this.makeStyle(this.eatHtmlEntity(t,e),i);case"'":if(t.match(/^'*(?='{5})/u)||t.match(/^'''(?!')/u,!1))break;if(t.match("''"))return this.firstSingleLetterWord||t.match("''",!1)||this.prepareItalicForCorrection(t),this.isBold=!this.isBold,this.makeLocalStyle(S.tags.apostrophesBold,i);if(t.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(S.tags.apostrophesItalic,i);break;case"[":if(t.eat("[")){if(t.eatSpace(),/[^\]|[]/u.test(t.peek()||""))return i.nLink++,i.stack.push(i.tokenize),i.lbrack=!1,i.tokenize=this.inLink(!!t.match(this.fileRegex,!1)),this.makeLocalStyle(S.tags.linkBracket,i)}else{let o=t.match(this.urlProtocols,!1);if(o)return i.nLink++,i.stack.push(i.tokenize),i.tokenize=this.eatExternalLinkProtocol(o[0].length),this.makeLocalStyle(S.tags.extLinkBracket,i)}break;case"{":if(t.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))/u))return t.eatSpace(),i.stack.push(i.tokenize),i.tokenize=this.inVariable.bind(this),this.makeLocalStyle(S.tags.templateVariableBracket,i);if(t.match(/^\{(?!\{(?!\{))\s*/u)){if(t.peek()==="#")return i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i);let o=t.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/u,!1);return o&&(o[2]===":"||o[4]===void 0||o[3]==="}}")&&(o[1].toLowerCase()in this.config.functionSynonyms[0]||o[1]in this.config.functionSynonyms[1])?(i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i)):(i.nTemplate++,i.stack.push(i.tokenize),i.tokenize=this.inTemplatePageName(!1),this.makeLocalStyle(S.tags.templateBracket,i))}break;case"<":{if(t.match("!--"))return i.stack.push(i.tokenize),i.tokenize=this.inBlock(S.tags.comment,"-->"),this.makeLocalStyle(S.tags.comment,i);let o=!!t.eat("/"),l=t.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+/u);if(l){let a=l[0].toLowerCase();if(a in this.config.tags)return o?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!1),this.makeLocalStyle(S.tags.extTagBracket,i));if(this.permittedHtmlTags.has(a))return o&&a!==i.inHtmlTag.pop()?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):o&&this.implicitlyClosedHtmlTags.has(a)?this.makeLocalStyle(S.tags.error,i):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!0),this.makeLocalStyle(S.tags.htmlTagBracket,i));t.backUp(a.length)}break}case"~":if(t.match(/^~{2,4}/u))return S.tags.signature;break;case"_":{let o=1;for(;t.eat("_");)o++;if(o>2)return t.eol()||t.backUp(2),this.makeStyle(e,i);if(o===2){let l=t.match(/^\w+?__/u);if(l)return`__${l[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${l[0]}`in this.config.doubleUnderscore[1]?S.tags.doubleUnderscore:(t.eol()||t.backUp(2),this.makeStyle(e,i))}break}default:if(/\s/u.test(r||"")&&(t.eatSpace(),t.match(this.urlProtocols,!1)&&!t.match("//")))return i.stack.push(i.tokenize),i.tokenize=this.eatFreeExternalLinkProtocol.bind(this),this.makeStyle(e,i);break}return t.match(/^[^\s_>}[\]<{'|&:~=]+/u),this.makeStyle(e,i)}}prepareItalicForCorrection(e){let t=e.pos,i=e.string.slice(0,t-3),r=i.slice(-1),s=i.slice(-2,-1);if(r===" "){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=t}else if(s===" ")this.firstSingleLetterWord=t;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=t}this.wasBold=this.isBold,this.wasItalic=this.isItalic}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0,lpar:!1,lbrack:!1}),copyState:e=>{let t=Iu(e);return e.extMode&&e.extMode.copyState&&(t.extState=e.extMode.copyState(e.extState)),t},token:(e,t)=>{let i,r=null,s,o,l=[],a=[];if(this.oldTokens.length>0)return s=this.oldTokens.shift(),e.pos=s.pos,s.style;e.sol()&&(this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);do if(i=t.tokenize(e,t),o=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,o)o!==r&&(r=o,l.length>0&&(a.push(...l),l=[])),l.push({pos:e.pos,style:i,state:(t.extMode&&t.extMode.copyState||Iu)(t)});else return this.oldStyle=i,i;while(!e.eol());if(this.isBold&&this.isItalic)if(this.isItalic=this.wasItalic,this.isBold=this.wasBold,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,a.length>0)a[a.length-1].pos++,this.oldTokens=a;else return e.pos=l[0].pos-2,this.oldStyle||"";else this.oldTokens=[...a,...l];return s=this.oldTokens.shift(),e.pos=s.pos,s.style},blankLine:e=>{e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},tokenTable:this.tokenTable,languageData:{closeBrackets:{brackets:["(","[","{",'"']}}}}get"text/mediawiki"(){return this.mediawiki}};for(let[n,e]of Object.entries(Hn))Object.defineProperty(Os.prototype,n,{get(){return e}});var ea=n=>{let e=new Os(n),t=e.mediawiki,i=zi.define(t),r=Gr(Ni.define(e.getTagStyles()));return new Ii(i,r)},zu=n=>ea({...n,tags:{...n.tags,script:!0,style:!0},tagModes:{...n.tagModes,script:"javascript",style:"css"},permittedHtmlTags:["html","base","title","menu","a","area","audio","map","track","video","embed","iframe","object","picture","source","canvas","col","colgroup","tbody","tfoot","thead","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","slot","template","dir","frame","frameset","marquee","param","xmp"],implicitlyClosedHtmlTags:["area","base","col","embed","frame","input","param","source","track"]});var ta={plain:()=>[],mediawiki:ea,html:zu};for(let[n,e]of Object.entries(Hn))ta[n]=()=>new Ii(zi.define(e));var Es={},ib={highlightSpecialChars:[yc,{}],highlightActiveLine:[wc,{}],highlightWhitespace:[Mc,{}],highlightTrailingWhitespace:[Lc,{}],bracketMatching:[ef,{mediawiki:{brackets:"[]{}"}}],closeBrackets:[bu,{}]},Bs=(n,e)=>new Promise(t=>{if(e in window){t();return}let i=document.createElement("script");i.src=`https://testingcf.jsdelivr.net/${n}`,i.onload=()=>{t()},document.head.append(i)}),fi,$i,_t,Ki,_i,fe,kt,ui,Fu=class{constructor(e,t="plain",i){xt(this,fi,void 0);xt(this,$i,void 0);xt(this,_t,void 0);xt(this,Ki,void 0);xt(this,_i,void 0);xt(this,fe,void 0);xt(this,kt,void 0);xt(this,ui,!0);ot(this,fi,e),ot(this,kt,t),ot(this,$i,new Ct),ot(this,_t,new Ct),ot(this,Ki,new Ct),ot(this,_i,new Ct);let r,s=[G(this,$i).of(ta[t](i)),G(this,_t).of([]),G(this,Ki).of([]),G(this,_i).of(jt.of(" ")),Gr(Jc),z.contentAttributes.of({accesskey:e.accessKey,dir:e.dir,lang:e.lang}),oe.readOnly.of(e.readOnly),Ac(),z.lineWrapping,gf(),Uc(),Ir.of([...Kf,...wf,...tu]),z.updateListener.of(({state:{doc:p},docChanged:g})=>{g&&(clearTimeout(r),r=window.setTimeout(()=>{e.value=p.toString()},400))})];ot(this,fe,new z({extensions:s,doc:e.value}));let{offsetHeight:o,selectionStart:l,selectionEnd:a,scrollTop:h}=e,{fontSize:c,lineHeight:f}=getComputedStyle(e),u=document.activeElement===e;e.parentNode.insertBefore(G(this,fe).dom,e),G(this,fe).dom.style.minHeight="2em",G(this,fe).dom.style.height=`${o}px`,G(this,fe).dom.style.fontSize=c,G(this,fe).scrollDOM.style.lineHeight=f,G(this,fe).requestMeasure(),G(this,fe).dispatch({selection:{anchor:l,head:a}}),e.style.display="none",u&&G(this,fe).focus(),requestAnimationFrame(()=>{G(this,fe).scrollDOM.scrollTop=h})}get textarea(){return G(this,fi)}get view(){return G(this,fe)}get lang(){return G(this,kt)}get visible(){return G(this,ui)}setLanguage(e="plain",t){G(this,fe).dispatch({effects:[G(this,$i).reconfigure(ta[e](t)),G(this,_t).reconfigure(Es[e]||[])]}),ot(this,kt,e),(Es[e]?Gl:Fn)(G(this,fe))}lint(e){let t=e?[lu(i=>e(i.state.doc)),du()]:[];e?Es[G(this,kt)]=t:delete Es[G(this,kt)],G(this,fe).dispatch({effects:[G(this,_t).reconfigure(t)]}),(e?Gl:Fn)(G(this,fe))}update(){let e=G(this,_t).get(G(this,fe).state);if(e.length>0){let t=G(this,fe).plugin(e[0][1]);t.set=!0,t.force()}}prefer(e){G(this,fe).dispatch({effects:[G(this,Ki).reconfigure(e.map(t=>{let[i,r]=ib[t];return i(r[G(this,kt)])}))]})}setIndent(e){G(this,fe).dispatch({effects:[G(this,_i).reconfigure(jt.of(e))]})}async getLinter(e){var t,i;switch(G(this,kt)){case"mediawiki":{await Bs("combine/npm/wikiparser-node@1.3.1-b/extensions/dist/base.min.js,npm/wikiparser-node@1.3.1-b/extensions/dist/lint.min.js","wikiparse");let s=new wikiparse.Linter(e==null?void 0:e.include);return o=>s.codemirror(o.toString())}case"javascript":{await Bs("npm/eslint-linter-browserify","eslint");let r=new eslint.Linter,s={env:{browser:!0,es2018:!0},parserOptions:{ecmaVersion:9,sourceType:"module"},rules:{},...e};for(let[o,{meta:l}]of r.getRules())l!=null&&l.docs.recommended&&((i=(t=s.rules)[o])!=null||(t[o]=2));return o=>r.verify(o.toString(),s).map(({message:l,severity:a,line:h,column:c,endLine:f,endColumn:u})=>{let p=o.line(h).from+c-1;return{message:l,severity:a===1?"warning":"error",from:p,to:f===void 0?p+1:o.line(f).from+u-1}})}case"css":{await Bs("gh/openstyles/stylelint-bundle/dist/stylelint-bundle.min.js","stylelint");let r={rules:{"annotation-no-unknown":!0,"at-rule-no-unknown":!0,"block-no-empty":!0,"color-no-invalid-hex":!0,"comment-no-empty":!0,"custom-property-no-missing-var-function":!0,"declaration-block-no-duplicate-custom-properties":!0,"declaration-block-no-duplicate-properties":[!0,{ignore:["consecutive-duplicates-with-different-syntaxes"]}],"declaration-block-no-shorthand-property-overrides":!0,"font-family-no-duplicate-names":!0,"font-family-no-missing-generic-family-keyword":!0,"function-calc-no-unspaced-operator":!0,"function-linear-gradient-no-nonstandard-direction":!0,"function-no-unknown":!0,"keyframe-block-no-duplicate-selectors":!0,"keyframe-declaration-no-important":!0,"media-feature-name-no-unknown":!0,"media-query-no-invalid":!0,"named-grid-areas-no-invalid":!0,"no-descending-specificity":!0,"no-duplicate-at-import-rules":!0,"no-duplicate-selectors":!0,"no-empty-source":!0,"no-invalid-double-slash-comments":!0,"no-invalid-position-at-import-rule":!0,"no-irregular-whitespace":!0,"property-no-unknown":!0,"selector-anb-no-unmatchable":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":[!0,{ignore:["custom-elements"]}],"string-no-newline":!0,"unit-no-unknown":!0,...e==null?void 0:e.rules}};return async s=>{let{results:o}=await stylelint.lint({code:s.toString(),config:r});return o.flatMap(({warnings:l})=>l).map(({text:l,severity:a,line:h,column:c,endLine:f,endColumn:u})=>({message:l,severity:a,from:s.line(h).from+c-1,to:f===void 0?s.line(h).to:s.line(f).from+u-1}))}}case"lua":return await Bs("npm/luaparse","luaparse"),r=>{try{luaparse.parse(r.toString())}catch(s){if(s instanceof luaparse.SyntaxError)return[{message:s.message,severity:"error",from:s.index,to:s.index}]}return[]};default:return}}toggle(e=!G(this,ui)){e&&!G(this,ui)&&G(this,fe).dispatch({changes:{from:0,to:G(this,fe).state.doc.length,insert:G(this,fi).value}}),ot(this,ui,e),G(this,fe).dom.style.setProperty("display",e?"":"none","important"),G(this,fi).style.display=e?"none":""}};fi=new WeakMap,$i=new WeakMap,_t=new WeakMap,Ki=new WeakMap,_i=new WeakMap,fe=new WeakMap,kt=new WeakMap,ui=new WeakMap;export{Fu as CodeMirror6};
12
+ `);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=i||(t=t.slice(0,s-(i-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(i>0?r>s:r>=s)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,r,s){if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let o=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-o}return this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),r=0,{streamParser:s}=this.lang,o=new Gr(t,e?e.state.tabSize:4,e?jt(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=hf(s.token,o,this.state);if(l&&(r=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,4,r)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=pe.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:ng,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new pe(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new pe(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function hf(n,e,t){e.start=e.pos;for(let i=0;i<10;i++){let r=n(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var Ol=Object.create(null),Rn=[Ee.none],ng=new Wr(Rn),Yc=[],Jc=Object.create(null),cf=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"]])cf[n]=ff(Ol,e);var Ur=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),cf)}resolve(e){return e?this.table[e]||(this.table[e]=ff(this.extra,e)):0}},rg=new Ur(Ol);function xl(n,e){Yc.indexOf(n)>-1||(Yc.push(n),console.warn(e))}function ff(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||P[h];c?typeof c=="function"?a.length?a=a.map(c):xl(h,`Modifier ${h} used at start of tag`):a.length?xl(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:xl(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=Jc[r];if(s)return s.id;let o=Jc[r]=Ee.define({id:Rn.length,name:i,props:[jc({[i]:t})]});return Rn.push(o),o.id}function sg(n){let e=Ee.define({id:Rn.length,name:"Document",props:[Ri.add(()=>n)],top:!0});return Rn.push(e),e}var og=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=zl(n.state,t.from);return i.line?lg(n):i.block?hg(n):!1};function Nl(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var lg=Nl(ug,0);var ag=Nl(yf,0);var hg=Nl((n,e)=>yf(n,e,fg(e)),0);function zl(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var In=50;function cg(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-In,i),o=n.sliceDoc(r,r+In),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-i<=2*In?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+In),f=n.sliceDoc(r-In,r));let u=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-t.length;return c.slice(u,u+e.length)==e&&f.slice(g,g+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-p-t.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function fg(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function yf(n,e,t=e.selection.ranges){let i=t.map(s=>zl(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>cg(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function ug(n,e,t=e.selection.ranges){let i=[],r=-1;for(let{from:s,to:o}of t){let l=i.length,a=1e9,h=zl(e,s).line;if(h){for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,p=u==f.length,g=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:g,token:h,indent:u,empty:p,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];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++,s.push({from:h,to:c})}return{changes:s}}return null}var Bl=Ne.define(),dg=Ne.define(),pg=I.define(),wf=I.define({combine(n){return ze(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),xf=me.define({create(){return li.empty},update(n,e){let t=e.state.facet(wf),i=e.annotation(Bl);if(i){let a=st.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=Zr(c,c.length,t.minDepth,a):c=Af(c,e.startState.selection),new li(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(dg);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(xe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=st.fromTransaction(e),o=e.annotation(xe.time),l=e.annotation(xe.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="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 li(n.done.map(st.fromJSON),n.undone.map(st.fromJSON))}});function vf(n={}){return[xf,wf.of(n),z.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Sf:e.inputType=="historyRedo"?Pl:null;return i?(e.preventDefault(),i(t)):!1}})]}function Qr(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(xf,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var Sf=Qr(0,!1),Pl=Qr(1,!1),mg=Qr(0,!0),gg=Qr(1,!0);var st=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(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(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&De.fromJSON(e.changes),[],e.mapped&&vt.fromJSON(e.mapped),e.startSelection&&L.fromJSON(e.startSelection),e.selectionsAfter.map(L.fromJSON))}static fromTransaction(e,t){let i=Ue;for(let r of e.startState.facet(pg)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ue)}static selection(e){return new n(void 0,Ue,void 0,void 0,e)}};function Zr(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function bg(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function kg(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Cf(n,e){return n.length?e.length?n.concat(e):n:e}var Ue=[],yg=200;function Af(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-yg));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Zr(n,n.length-1,1e9,t.setSelAfter(i)))}else return[st.selection([e])]}function wg(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 El(n,e){if(!n.length)return n;let t=n.length,i=Ue;for(;t;){let r=xg(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[st.selection(i)]:Ue}function xg(n,e,t){let i=Cf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Ue,t);if(!n.changes)return st.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new st(r,X.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var vg=/^(input\.type|delete)($|\.)/,li=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||vg.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,bg(l.changes,e.changes))||i=="input.type.compose")?o=Zr(o,o.length-1,r.minDepth,new st(e.changes.compose(l.changes),Cf(e.effects,l.effects),l.mapped,l.startSelection,Ue)):o=Zr(o,o.length,r.minDepth,e),new n(o,Ue,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ue;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&kg(s[s.length-1],e)?this:new n(Af(this.done,e),this.undone,t,i)}addMapping(e){return new n(El(this.done,e),El(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||t.selection;if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Bl.of({side:e,rest:wg(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Ue:r.slice(0,r.length-1);return s.mapped&&(l=El(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Bl.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};li.empty=new li(Ue,Ue);var Tf=[{key:"Mod-z",run:Sf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Pl,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Pl,preventDefault:!0},{key:"Mod-u",run:mg,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:gg,preventDefault:!0}];function Vi(n,e){return L.create(n.ranges.map(e),n.mainIndex)}function bt(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function ot({state:n,dispatch:e},t){let i=Vi(n.selection,t);return i.eq(n.selection)?!1:(e(bt(n,i)),!0)}function es(n,e){return L.cursor(e?n.to:n.from)}function Mf(n,e){return ot(n,t=>t.empty?n.moveByChar(t,e):es(t,e))}function Le(n){return n.textDirectionAt(n.state.selection.main.head)==ge.LTR}var Lf=n=>Mf(n,!Le(n)),Df=n=>Mf(n,Le(n));function Of(n,e){return ot(n,t=>t.empty?n.moveByGroup(t,e):es(t,e))}var Sg=n=>Of(n,!Le(n)),Cg=n=>Of(n,Le(n));var Wb=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Ag(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 ts(n,e,t){let i=Be(n).resolveInner(e.head),r=t?Z.closedBy:Z.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;Ag(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?rt(n,i.from,1):rt(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,L.cursor(l,t?-1:1)}var Tg=n=>ot(n,e=>ts(n.state,e,!Le(n))),Mg=n=>ot(n,e=>ts(n.state,e,Le(n)));function Ef(n,e){return ot(n,t=>{if(!t.empty)return es(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Bf=n=>Ef(n,!1),Pf=n=>Ef(n,!0);function Rf(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(z.scrollMargins)){let o=s(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function If(n,e){let t=Rf(n),{state:i}=n,r=Vi(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):es(o,e));if(r.eq(i.selection))return!1;let s;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.bottom<h&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(bt(i,r),{effects:s}),!0}var uf=n=>If(n,!1),Rl=n=>If(n,!0);function $t(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=L.cursor(i.from+s))}return r}var Lg=n=>ot(n,e=>$t(n,e,!0)),Dg=n=>ot(n,e=>$t(n,e,!1)),Og=n=>ot(n,e=>$t(n,e,!Le(n))),Eg=n=>ot(n,e=>$t(n,e,Le(n))),Bg=n=>ot(n,e=>L.cursor(n.lineBlockAt(e.head).from,1)),Pg=n=>ot(n,e=>L.cursor(n.lineBlockAt(e.head).to,-1));function Rg(n,e,t){let i=!1,r=Vi(n.selection,s=>{let o=rt(n,s.head,-1)||rt(n,s.head,1)||s.head>0&&rt(n,s.head-1,1)||s.head<n.doc.length&&rt(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?L.range(s.anchor,l):L.cursor(l)});return i?(e(bt(n,r)),!0):!1}var Ig=({state:n,dispatch:e})=>Rg(n,e,!1);function Ye(n,e){let t=Vi(n.state.selection,i=>{let r=e(i);return L.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(bt(n.state,t)),!0)}function Nf(n,e){return Ye(n,t=>n.moveByChar(t,e))}var zf=n=>Nf(n,!Le(n)),Ff=n=>Nf(n,Le(n));function Hf(n,e){return Ye(n,t=>n.moveByGroup(t,e))}var Ng=n=>Hf(n,!Le(n)),zg=n=>Hf(n,Le(n));var Fg=n=>Ye(n,e=>ts(n.state,e,!Le(n))),Hg=n=>Ye(n,e=>ts(n.state,e,Le(n)));function Vf(n,e){return Ye(n,t=>n.moveVertically(t,e))}var Wf=n=>Vf(n,!1),jf=n=>Vf(n,!0);function qf(n,e){return Ye(n,t=>n.moveVertically(t,e,Rf(n).height))}var df=n=>qf(n,!1),pf=n=>qf(n,!0),Vg=n=>Ye(n,e=>$t(n,e,!0)),Wg=n=>Ye(n,e=>$t(n,e,!1)),jg=n=>Ye(n,e=>$t(n,e,!Le(n))),qg=n=>Ye(n,e=>$t(n,e,Le(n))),$g=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).from)),Kg=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).to)),mf=({state:n,dispatch:e})=>(e(bt(n,{anchor:0})),!0),gf=({state:n,dispatch:e})=>(e(bt(n,{anchor:n.doc.length})),!0),bf=({state:n,dispatch:e})=>(e(bt(n,{anchor:n.selection.main.anchor,head:0})),!0),kf=({state:n,dispatch:e})=>(e(bt(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),Gg=({state:n,dispatch:e})=>{let t=is(n).map(({from:i,to:r})=>L.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:L.create(t),userEvent:"select"})),!0},Ug=({state:n,dispatch:e})=>{let t=Vi(n.selection,i=>{var r;let s=Be(n).resolveStack(i.from,1);for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&(!((r=l.parent)===null||r===void 0)&&r.parent))return L.range(l.to,l.from)}return i});return e(bt(n,t)),!0},Yg=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=L.create([t.main]):t.main.empty||(i=L.create([L.cursor(t.main.head)])),i?(e(bt(n,i)),!0):!1};function Nn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=Xr(n,a,!1)):a>o&&(t="delete.forward",a=Xr(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Xr(n,o,!1),l=Xr(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:L.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Xr(n,e,t){if(n instanceof z)for(let i of n.state.facet(z.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var $f=(n,e)=>Nn(n,t=>{let i=t.from,{state:r}=n,s=r.doc.lineAt(i),o,l;if(!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(o=s.text.slice(0,i-s.from))){if(o[o.length-1]==" ")return i-1;let a=Pt(o,r.tabSize),h=a%jt(r)||jt(r);for(let c=0;c<h&&o[o.length-1-c]==" ";c++)i--;l=i}else l=be(s.text,i-s.from,e,e)+s.from,l==i&&s.number!=(e?r.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=be(s.text,l-s.from,!1,!1)+s.from);return l}),Il=n=>$f(n,!1),Kf=n=>$f(n,!0),_f=(n,e)=>Nn(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=be(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),Gf=n=>_f(n,!1),Jg=n=>_f(n,!0),Xg=n=>Nn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var Zg=n=>Nn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Qg=n=>Nn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var e0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Q.of(["",""])},range:L.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},t0=({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 r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:be(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:be(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:L.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function is(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Uf(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of is(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(L.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(L.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:L.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var i0=({state:n,dispatch:e})=>Uf(n,e,!1),n0=({state:n,dispatch:e})=>Uf(n,e,!0);function Yf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of is(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var r0=({state:n,dispatch:e})=>Yf(n,e,!1),s0=({state:n,dispatch:e})=>Yf(n,e,!0),o0=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(is(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Vi(e.selection,r=>n.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function l0(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Be(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(Z.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var a0=Jf(!1),h0=Jf(!0);function Jf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&l0(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new oi(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=Yr(h,s);for(c==null&&(c=Pt(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",Hi(e,c)];return a&&f.push(Hi(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Q.of(f)},range:L.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Fl(n,e){let t=-1;return n.changeByRange(i=>{let r=[];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,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:L.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var c0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new oi(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=Fl(n,(s,o,l)=>{let a=Yr(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Hi(n,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},f0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Fl(n,(t,i)=>{i.push({from:t.from,insert:n.facet(qt)})}),{userEvent:"input.indent"})),!0),u0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Fl(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Pt(r,n.tabSize),o=0,l=Hi(n,Math.max(0,s-jt(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0);var d0=[{key:"Ctrl-b",run:Lf,shift:zf,preventDefault:!0},{key:"Ctrl-f",run:Df,shift:Ff},{key:"Ctrl-p",run:Bf,shift:Wf},{key:"Ctrl-n",run:Pf,shift:jf},{key:"Ctrl-a",run:Bg,shift:$g},{key:"Ctrl-e",run:Pg,shift:Kg},{key:"Ctrl-d",run:Kf},{key:"Ctrl-h",run:Il},{key:"Ctrl-k",run:Xg},{key:"Ctrl-Alt-h",run:Gf},{key:"Ctrl-o",run:e0},{key:"Ctrl-t",run:t0},{key:"Ctrl-v",run:Rl}],p0=[{key:"ArrowLeft",run:Lf,shift:zf,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Sg,shift:Ng,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Og,shift:jg,preventDefault:!0},{key:"ArrowRight",run:Df,shift:Ff,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Cg,shift:zg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Eg,shift:qg,preventDefault:!0},{key:"ArrowUp",run:Bf,shift:Wf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:mf,shift:bf},{mac:"Ctrl-ArrowUp",run:uf,shift:df},{key:"ArrowDown",run:Pf,shift:jf,preventDefault:!0},{mac:"Cmd-ArrowDown",run:gf,shift:kf},{mac:"Ctrl-ArrowDown",run:Rl,shift:pf},{key:"PageUp",run:uf,shift:df},{key:"PageDown",run:Rl,shift:pf},{key:"Home",run:Dg,shift:Wg,preventDefault:!0},{key:"Mod-Home",run:mf,shift:bf},{key:"End",run:Lg,shift:Vg,preventDefault:!0},{key:"Mod-End",run:gf,shift:kf},{key:"Enter",run:a0},{key:"Mod-a",run:_g},{key:"Backspace",run:Il,shift:Il},{key:"Delete",run:Kf},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Gf},{key:"Mod-Delete",mac:"Alt-Delete",run:Jg},{mac:"Mod-Backspace",run:Zg},{mac:"Mod-Delete",run:Qg}].concat(d0.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Xf=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Tg,shift:Fg},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Mg,shift:Hg},{key:"Alt-ArrowUp",run:i0},{key:"Shift-Alt-ArrowUp",run:r0},{key:"Alt-ArrowDown",run:n0},{key:"Shift-Alt-ArrowDown",run:s0},{key:"Escape",run:Yg},{key:"Mod-Enter",run:h0},{key:"Alt-l",mac:"Ctrl-l",run:Gg},{key:"Mod-i",run:Ug,preventDefault:!0},{key:"Mod-[",run:u0},{key:"Mod-]",run:f0},{key:"Mod-Alt-\\",run:c0},{key:"Shift-Mod-k",run:o0},{key:"Shift-Mod-\\",run:Ig},{key:"Mod-/",run:og},{key:"Alt-A",run:ag}].concat(p0);function ne(){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 r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e<arguments.length;e++)Zf(n,arguments[e]);return n}function Zf(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Zf(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}var Qf=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n,ai=class{constructor(e,t,i=0,r=e.length,s,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,r),this.bufferStart=i,this.normalize=s?l=>s(Qf(l)):Qf,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 $e(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=sr(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=St(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let l=r.charCodeAt(s),a=this.match(l,o);if(s==r.length-1){if(a)return this.value=a,this;break}o==i&&s<t.length&&t.charCodeAt(s)==l&&o++}}}match(e,t){let i=null;for(let r=0;r<this.matches.length;r+=2){let s=this.matches[r],o=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:t+1}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}};typeof Symbol!="undefined"&&(ai.prototype[Symbol.iterator]=function(){return this});var iu={from:-1,to:-1,match:/.*/.exec("")},Kl="gm"+(/x/.unicode==null?"":"u"),ss=class{constructor(e,t,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=iu,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new ls(e,t,i,r,s);this.re=new RegExp(t,Kl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=as(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=as(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Hl=new WeakMap,os=class n{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=Hl.get(e);if(!r||r.from>=i||r.to<=t){let l=new n(t,e.sliceString(t,i));return Hl.set(e,l),l}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to<i&&(s+=e.sliceString(r.to,i)),Hl.set(e,new n(o,s)),new n(t,s.slice(t-o,i-o))}},ls=class{constructor(e,t,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=iu,this.matchPos=as(e,r),this.re=new RegExp(t,Kl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=os.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=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,r,t)))return this.value={from:i,to:r,match:t},this.matchPos=as(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=os.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(ss.prototype[Symbol.iterator]=ls.prototype[Symbol.iterator]=function(){return this});function m0(n){try{return new RegExp(n,Kl),!0}catch(e){return!1}}function as(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function Vl(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=ne("input",{class:"cm-textfield",name:"line",value:e}),i=ne("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:hs.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},ne("label",n.state.phrase("Go to line"),": ",t)," ",ne("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,h,c,f]=s,u=c?+c.slice(1):0,p=h?+h:l.number;if(h&&f){let y=p/100;a&&(y=y*(a=="-"?-1:1)+l.number/o.doc.lines),p=Math.round(o.doc.lines*y)}else h&&a&&(p=p*(a=="-"?-1:1)+l.number);let g=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),x=L.cursor(g.from+Math.max(0,Math.min(u,g.length)));n.dispatch({effects:[hs.of(!1),z.scrollIntoView(x.from,{y:"center"})],selection:x}),n.focus()}return{dom:i}}var hs=X.define(),eu=me.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(hs)&&(n=t.value);return n},provide:n=>ii.from(n,e=>e?Vl:null)}),g0=n=>{let e=ni(n,Vl);if(!e){let t=[hs.of(!0)];n.state.field(eu,!1)==null&&t.push(X.appendConfig.of([eu,b0])),n.dispatch({effects:t}),e=ni(n,Vl)}return e&&e.dom.querySelector("input").select(),!0},b0=z.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});var k0=({state:n,dispatch:e})=>{let{selection:t}=n,i=L.create(t.ranges.map(r=>n.wordAt(r.head)||L.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function y0(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new ai(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new ai(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(s){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}var w0=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return k0({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=y0(n,i);return r?(e(n.update({selection:n.selection.addRange(L.range(r.from,r.to),!1),effects:z.scrollIntoView(r.to)})),!0):!1},qi=I.define({combine(n){return ze(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new $l(e),scrollToMatch:e=>z.scrollIntoView(e)})}});var cs=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||m0(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"?`
13
+ `: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 jl(this):new Wl(this)}getCursor(e,t=0,i){let r=e.doc?e:oe.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?ji(this,r,t,i):Wi(this,r,t,i)}},fs=class{constructor(e){this.spec=e}};function Wi(n,e,t,i){return new ai(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?x0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function x0(n,e){return(t,i,r,s)=>((s>t||s+r.length<i)&&(s=Math.max(0,t-2),r=n.sliceString(s,Math.min(n.length,i+2))),(e(us(r,t-s))!=ue.Word||e(ds(r,t-s))!=ue.Word)&&(e(ds(r,i-s))!=ue.Word||e(us(r,i-s))!=ue.Word))}var Wl=class extends fs{constructor(e){super(e)}nextMatch(e,t,i){let r=Wi(this.spec,e,i,e.doc.length).nextOverlapping();return r.done&&(r=Wi(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=i;;){let s=Math.max(t,r-1e4-this.spec.unquoted.length),o=Wi(this.spec,e,s,r),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==t)return null;r-=1e4}}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)}matchAll(e,t){let i=Wi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Wi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}};function ji(n,e,t,i){return new ss(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?v0(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function us(n,e){return n.slice(be(n,e,!1),e)}function ds(n,e){return n.slice(e,be(n,e))}function v0(n){return(e,t,i)=>!i[0].length||(n(us(i.input,i.index))!=ue.Word||n(ds(i.input,i.index))!=ue.Word)&&(n(ds(i.input,i.index+i[0].length))!=ue.Word||n(us(i.input,i.index+i[0].length))!=ue.Word)}var jl=class extends fs{nextMatch(e,t,i){let r=ji(this.spec,e,i,e.doc.length).next();return r.done&&(r=ji(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=ji(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==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<e.match.length?e.match[i]:t))}matchAll(e,t){let i=ji(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=ji(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}},Fn=X.define(),_l=X.define(),Kt=me.define({create(n){return new zn(ql(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Fn)?n=new zn(t.value.create(),n.panel):t.is(_l)&&(n=new zn(n.query,t.value?Gl:null));return n},provide:n=>ii.from(n,e=>e.panel)});var zn=class{constructor(e,t){this.query=e,this.panel=t}},S0=J.mark({class:"cm-searchMatch"}),C0=J.mark({class:"cm-searchMatch cm-searchMatch-selected"}),A0=ye.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Kt))}update(n){let e=n.state.field(Kt);(e!=n.startState.field(Kt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return J.none;let{view:t}=this,i=new at;for(let r=0,s=t.visibleRanges,o=s.length;r<o;r++){let{from:l,to:a}=s[r];for(;r<o-1&&a>s[r+1].from-2*250;)a=s[++r].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?C0:S0)})}return i.finish()}},{decorations:n=>n.decorations});function Hn(n){return e=>{let t=e.state.field(Kt,!1);return t&&t.query.spec.valid?n(e,t):su(e)}}var ps=Hn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=L.single(i.from,i.to),s=n.state.facet(qi);return n.dispatch({selection:r,effects:[Ul(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),ru(n),!0}),ms=Hn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=L.single(r.from,r.to),o=n.state.facet(qi);return n.dispatch({selection:s,effects:[Ul(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),ru(n),!0}),T0=Hn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:L.create(t.map(i=>L.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),M0=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let l=new ai(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(L.range(l.value.from,l.value.to))}return e(n.update({selection:L.create(s,o),userEvent:"select.search.matches"})),!0},tu=Hn((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=[],l,a,h=[];if(s.from==i&&s.to==r&&(a=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(t,s.from,s.to),h.push(z.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),s){let c=o.length==0||o[0].from>=s.to?0:s.to-s.from-a.length;l=L.single(s.from-c,s.to-c),h.push(Ul(n,s)),h.push(t.facet(qi).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),L0=Hn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:z.announce.of(i),userEvent:"input.replace.all"}),!0});function Gl(n){return n.state.facet(qi).createPanel(n)}function ql(n,e){var t,i,r,s,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(qi);return new cs({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:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function nu(n){let e=ni(n,Gl);return e&&e.dom.querySelector("[main-field]")}function ru(n){let e=nu(n);e&&e==n.root.activeElement&&e.select()}var su=n=>{let e=n.state.field(Kt,!1);if(e&&e.panel){let t=nu(n);if(t&&t!=n.root.activeElement){let i=ql(n.state,e.query.spec);i.valid&&n.dispatch({effects:Fn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[_l.of(!0),e?Fn.of(ql(n.state,e.query.spec)):X.appendConfig.of(O0)]});return!0},ou=n=>{let e=n.state.field(Kt,!1);if(!e||!e.panel)return!1;let t=ni(n,Gl);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:_l.of(!1)}),!0},lu=[{key:"Mod-f",run:su,scope:"editor search-panel"},{key:"F3",run:ps,shift:ms,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ps,shift:ms,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ou,scope:"editor search-panel"},{key:"Mod-Shift-l",run:M0},{key:"Alt-g",run:g0},{key:"Mod-d",run:w0,preventDefault:!0}],$l=class{constructor(e){this.view=e;let t=this.query=e.state.field(Kt).query.spec;this.commit=this.commit.bind(this),this.searchField=ne("input",{value:t.search,placeholder:je(e,"Find"),"aria-label":je(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ne("input",{value:t.replace,placeholder:je(e,"Replace"),"aria-label":je(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ne("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ne("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ne("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return ne("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=ne("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>ps(e),[je(e,"next")]),i("prev",()=>ms(e),[je(e,"previous")]),i("select",()=>T0(e),[je(e,"all")]),ne("label",null,[this.caseField,je(e,"match case")]),ne("label",null,[this.reField,je(e,"regexp")]),ne("label",null,[this.wordField,je(e,"by word")]),...e.state.readOnly?[]:[ne("br"),this.replaceField,i("replace",()=>tu(e),[je(e,"replace")]),i("replaceAll",()=>L0(e),[je(e,"replace all")])],ne("button",{name:"close",onclick:()=>ou(e),"aria-label":je(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new cs({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:Fn.of(e)}))}keydown(e){Sc(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ms:ps)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),tu(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Fn)&&!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(qi).top}};function je(n,e){return n.state.phrase(e)}var ns=30,rs=/[\s\.,:;?!]/;function Ul(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-ns),o=Math.min(r,t+ns),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<ns;a++)if(!rs.test(l[a+1])&&rs.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-ns;a--)if(!rs.test(l[a-1])&&rs.test(l[a])){l=l.slice(0,a);break}}return z.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}var D0=z.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"}}),O0=[Kt,Bt.low(A0),D0];var Yl=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},hi=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=e,s=i.facet(ci).markerFilter;s&&(r=s(r));let o=J.set(r.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?J.widget({widget:new Jl(l),diagnostic:l}).range(l.from):J.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new n(o,t,$i(o))}};function $i(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new Yl(r,s,o.diagnostic),!1}),i}function hu(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(ws))||n.changes.touchesRange(t.from,t.to))}function cu(n,e){return n.field(Je,!1)?e:e.concat(X.appendConfig.of(ku))}function E0(n,e){return{effects:cu(n,[ws.of(e)])}}var ws=X.define(),Zl=X.define(),fu=X.define(),Je=me.define({create(){return new hi(J.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=$i(t,n.selected.diagnostic,r)||$i(t,null,r)}n=new hi(t,n.panel,i)}for(let t of e.effects)t.is(ws)?n=hi.init(t.value,n.panel,e.state):t.is(Zl)?n=new hi(n.diagnostics,t.value?ys.open:null,n.selected):t.is(fu)&&(n=new hi(n.diagnostics,n.panel,t.value));return n},provide:n=>[ii.from(n,e=>e.panel),z.decorations.from(n,e=>e.diagnostics)]});var B0=J.mark({class:"cm-lintRange cm-lintRange-active"});function P0(n,e,t){let{diagnostics:i}=n.state.field(Je),r=[],s=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)&&(e<h||t<0))&&(r.push(c.diagnostic),s=Math.min(a,s),o=Math.max(h,o))});let l=n.state.facet(ci).tooltipFilter;return l&&(r=l(r)),r.length?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:uu(n,r)}}}:null}function uu(n,e){return ne("ul",{class:"cm-tooltip-lint"},e.map(t=>mu(n,t,!1)))}var Ql=n=>{let e=n.state.field(Je,!1);(!e||!e.panel)&&n.dispatch({effects:cu(n.state,[Zl.of(!0)])});let t=ni(n,ys.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Vn=n=>{let e=n.state.field(Je,!1);return!e||!e.panel?!1:(n.dispatch({effects:Zl.of(!1)}),!0)};var R0=ye.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(ci);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(ci);Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let r=i.reduce((s,o)=>s.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(E0(this.view.state,r))},i=>{He(this.view.state,i)})}}update(n){let e=n.state.facet(ci);(n.docChanged||e!=n.startState.facet(ci)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),ci=I.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},ze(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function du(n,e={}){return[ci.of({source:n,config:e}),R0,ku]}function pu(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function mu(n,e,t){var i;let r=t?pu(e.actions):[];return ne("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ne("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let p=$i(n.state.field(Je).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:h}=s,c=r[o]?h.indexOf(r[o]):-1,f=c<0?h:[h.slice(0,c),ne("u",h.slice(c,c+1)),h.slice(c+1)];return ne("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&ne("div",{class:"cm-diagnosticSource"},e.source))}var Jl=class extends tt{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ne("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},ks=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=mu(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},ys=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)Vn(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=pu(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=$i(this.view.state.field(Je).diagnostics,s);a&&s.actions[l].apply(e,a.from,a.to)}}else return;r.preventDefault()},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=ne("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=ne("div",{class:"cm-panel-lint"},this.list,ne("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Vn(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Je).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Je),i=0,r=!1,s=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new ks(this.view,a.diagnostic),this.items.splice(i,0,c),r=!0):(c=this.items[h],h>i&&(this.items.splice(i,h-i),r=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),s=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new ks(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&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(Je),i=$i(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:fu.of(i)})}static open(e){return new n(e)}};function bs(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function gs(n){return bs(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var I0=z.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:gs("#d11")},".cm-lintRange-warning":{backgroundImage:gs("orange")},".cm-lintRange-info":{backgroundImage:gs("#999")},".cm-lintRange-hint":{backgroundImage:gs("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function au(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}var Xl=class extends Ge{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((t,i)=>au(t)<au(i.severity)?i.severity:t,"hint")}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=e.state.facet(xs).tooltipFilter;return r&&(i=r(i)),i.length&&(t.onmouseover=()=>z0(e,t,i)),t}};function N0(n,e){let t=i=>{let r=e.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientX<r.right+10&&i.clientY>r.top-10&&i.clientY<r.bottom+10)){for(let s=i.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),n.state.field(bu)&&n.dispatch({effects:ea.of(null)})}};window.addEventListener("mousemove",t)}function z0(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:ea.of({pos:o.from,above:!1,create(){return{dom:uu(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,N0(n,e)}let{hoverTime:r}=n.state.facet(xs),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function F0(n,e){let t=Object.create(null);for(let r of e){let s=n.lineAt(r.from);(t[s.from]||(t[s.from]=[])).push(r)}let i=[];for(let r in t)i.push(new Xl(t[r]).range(+r));return ie.of(i,!0)}var H0=ol({class:"cm-gutter-lint",markers:n=>n.state.field(gu)}),gu=me.define({create(){return ie.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet(xs).markerFilter;for(let i of e.effects)if(i.is(ws)){let r=i.value;t&&(r=t(r||[])),n=F0(e.state.doc,r.slice(0))}return n}}),ea=X.define(),bu=me.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=hu(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(ea)?i.value:t,n)},provide:n=>Cn.from(n)}),V0=z.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:bs('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:bs('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:bs('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),ku=[Je,z.decorations.compute([Je],n=>{let{selected:e,panel:t}=n.field(Je);return!e||!t||e.from==e.to?J.none:J.set([B0.range(e.from,e.to)])}),Lc(P0,{hideOn:hu}),I0],xs=I.define({combine(n){return ze(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function yu(n={}){return[xs.of(n),gu,H0,V0,bu]}var vs={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},fi=X.define({map(n,e){let t=e.mapPos(n,-1,Ce.TrackAfter);return t==null?void 0:t}}),ia=new class extends Qe{};ia.startSide=1;ia.endSide=-1;var vu=me.define({create(){return ie.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(fi)&&(n=n.update({add:[ia.range(t.value,t.value+1)]}));return n}});function Su(){return[$0,vu]}var ta="()[]{}<>";function W0(n){for(let e=0;e<ta.length;e+=2)if(ta.charCodeAt(e)==n)return ta.charAt(e+1);return sr(n<128?n:n+1)}function j0(n,e){return n.languageDataAt("closeBrackets",e)[0]||vs}var q0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),$0=z.inputHandler.of((n,e,t,i)=>{if((q0?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&St($e(i,0))==1||e!=r.from||t!=r.to)return!1;let s=K0(n.state,i);return s?(n.dispatch(s),!0):!1});function K0(n,e){let t=j0(n,n.selection.main.head),i=t.brackets||vs.brackets;for(let r of i){let s=W0($e(r,0));if(e==r)return s==r?U0(n,r,i.indexOf(r+r+r)>-1,t):_0(n,r,s,t.before||vs.before);if(e==s&&Cu(n,n.selection.main.from))return G0(n,r,s)}return null}function Cu(n,e){let t=!1;return n.field(vu).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function na(n,e){let t=n.sliceString(e,e+2);return t.slice(0,St($e(t,0)))}function _0(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:fi.of(o.to+e.length),range:L.range(o.anchor+e.length,o.head+e.length)};let l=na(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:fi.of(o.head+e.length),range:L.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function G0(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&na(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:L.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function U0(n,e,t,i){let r=i.stringPrefixes||vs.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:fi.of(l.to+e.length),range:L.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=na(n.doc,a),c;if(h==e){if(wu(n,a))return{changes:{insert:e+e,from:a},effects:fi.of(a+e.length),range:L.cursor(a+e.length)};if(Cu(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:L.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=xu(n,a-2*e.length,r))>-1&&wu(n,c))return{changes:{insert:e+e+e+e,from:a},effects:fi.of(a+e.length),range:L.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=ue.Word&&xu(n,a,r)>-1&&!Y0(n,a,e,r))return{changes:{insert:e+e,from:a},effects:fi.of(a+e.length),range:L.cursor(a+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function wu(n,e){let t=Be(n).resolveInner(e+1);return t.parent&&t.from==e}function Y0(n,e,t,i){let r=Be(n).resolveInner(e,-1),s=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=r.firstChild;for(;c&&c.from==r.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=r.to==e&&r.parent;if(!h)break;r=h}return!1}function xu(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ue.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=ue.Word)return s}return-1}var S={permittedHtmlTags:["b","bdi","bdo","del","i","ins","u","font","big","small","sub","sup","h1","h2","h3","h4","h5","h6","cite","code","em","s","strike","strong","tt","var","div","center","blockquote","q","ol","ul","dl","table","caption","pre","ruby","rb","rp","rt","rtc","p","span","abbr","dfn","kbd","samp","data","time","mark","br","wbr","hr","li","dt","dd","td","th","tr","noinclude","includeonly","onlyinclude","img","meta","link"],implicitlyClosedHtmlTags:["br","hr","wbr","img","meta","link"],tags:{apostrophes:"mw-apostrophes",apostrophesBold:"mw-apostrophes-bold",apostrophesItalic:"mw-apostrophes-italic",comment:"mw-comment",doubleUnderscore:"mw-double-underscore",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",hr:"mw-hr",htmlTagAttribute:"mw-htmltag-attribute",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",sectionHeader:"mw-section-header",sectionHeader1:"mw-section-1",sectionHeader2:"mw-section-2",sectionHeader3:"mw-section-3",sectionHeader4:"mw-section-4",sectionHeader5:"mw-section-5",sectionHeader6:"mw-section-6",signature:"mw-signature",tableBracket:"mw-table-bracket",tableDefinition:"mw-table-definition",tableDelimiter:"mw-table-delimiter",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableName:"mw-templatevariable-name",section:"mw-section",em:"mw-em",error:"mw-error",extGround:"mw-ext-ground",ext2Ground:"mw-ext2-ground",ext2LinkGround:"mw-ext2-link-ground",ext3Ground:"mw-ext3-ground",ext3LinkGround:"mw-ext3-link-ground",extLinkGround:"mw-ext-link-ground",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",htmlEntity:"mw-html-entity",link:"mw-link",linkGround:"mw-link-ground",linkPageName:"mw-link-pagename",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateExtGround:"mw-template-ext-ground",templateExt2Ground:"mw-template-ext2-ground",templateExt2LinkGround:"mw-template-ext2-link-ground",templateExt3Ground:"mw-template-ext3-ground",templateExt3LinkGround:"mw-template-ext3-link-ground",templateExtLinkGround:"mw-template-ext-link-ground",templateGround:"mw-template-ground",templateLinkGround:"mw-template-link-ground",templateVariableDelimiter:"mw-templatevariable-delimiter",template2ExtGround:"mw-template2-ext-ground",template2Ext2Ground:"mw-template2-ext2-ground",template2Ext3Ground:"mw-template2-ext3-ground",templatet2Ext2LinkGround:"mw-template2-ext2-link-ground",template2Ext3LinkGround:"mw-template2-ext3-link-ground",template2ExtLinkGround:"mw-template2-ext-link-ground",template2Ground:"mw-template2-ground",template2LinkGround:"mw-template2-link-ground",template3ExtGround:"mw-template3-ext-ground",template3Ext2Ground:"mw-template3-ext2-ground",template3Ext3Ground:"mw-template3-ext3-ground",template3ExtLinkGround:"mw-template3-ext-link-ground",template3Ext2LinkGround:"mw-template3-ext2-link-ground",template3Ext3LinkGround:"mw-template3-ext3-link-ground",template3Ground:"mw-template3-ground",template3LinkGround:"mw-template3-link-ground"},get tokenTable(){let n={};for(let e of Object.values(this.tags))n[e]=Pe.define();return n}};var Wn={};gd(Wn,{css:()=>Iu,javascript:()=>Nu,json:()=>zu,lua:()=>Vu});function Ss(n){n={...Q0,...n};var e=n.inline,t=n.tokenHooks,i=n.documentTypes||{},r=n.mediaTypes||{},s=n.mediaFeatures||{},o=n.mediaValueKeywords||{},l=n.propertyKeywords||{},a=n.nonStandardPropertyKeywords||{},h=n.fontProperties||{},c=n.counterDescriptors||{},f=n.colorKeywords||{},u=n.valueKeywords||{},p=n.allowNested,g=n.lineComment,x=n.supportsAtComponent===!0,y=n.highlightNonStandardPropertyKeywords!==!1,v,M;function O(k,T){return v=T,k}function R(k,T){var A=k.next();if(t[A]){var V=t[A](k,T);if(V!==!1)return V}if(A=="@")return k.eatWhile(/[\w\\\-]/),O("def",k.current());if(A=="="||(A=="~"||A=="|")&&k.eat("="))return O(null,"compare");if(A=='"'||A=="'")return T.tokenize=F(A),T.tokenize(k,T);if(A=="#")return k.eatWhile(/[\w\\\-]/),O("atom","hash");if(A=="!")return k.match(/^\s*\w*/),O("keyword","important");if(/\d/.test(A)||A=="."&&k.eat(/\d/))return k.eatWhile(/[\w.%]/),O("number","unit");if(A==="-"){if(/[\d.]/.test(k.peek()))return k.eatWhile(/[\w.%]/),O("number","unit");if(k.match(/^-[\w\\\-]*/))return k.eatWhile(/[\w\\\-]/),k.match(/^\s*:/,!1)?O("def","variable-definition"):O("variableName","variable");if(k.match(/^\w+-/))return O("meta","meta")}else return/[,+>*\/]/.test(A)?O(null,"select-op"):A=="."&&k.match(/^-?[_a-z][_a-z0-9-]*/i)?O("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(A)?O(null,A):k.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(k.current())&&(T.tokenize=q),O("variableName.function","variable")):/[\w\\\-]/.test(A)?(k.eatWhile(/[\w\\\-]/),O("property","word")):O(null,null)}function F(k){return function(T,A){for(var V=!1,ae;(ae=T.next())!=null;){if(ae==k&&!V){k==")"&&T.backUp(1);break}V=!V&&ae=="\\"}return(ae==k||!V&&k!=")")&&(A.tokenize=null),O("string","string")}}function q(k,T){return k.next(),k.match(/^\s*[\"\')]/,!1)?T.tokenize=null:T.tokenize=F(")"),O(null,"(")}function w(k,T,A){this.type=k,this.indent=T,this.prev=A}function D(k,T,A,V){return k.context=new w(A,T.indentation()+(V===!1?0:T.indentUnit),k.context),A}function b(k){return k.context.prev&&(k.context=k.context.prev),k.context.type}function Y(k,T,A){return K[A.context.type](k,T,A)}function $(k,T,A,V){for(var ae=V||1;ae>0;ae--)A.context=A.context.prev;return Y(k,T,A)}function U(k){var T=k.current().toLowerCase();u.hasOwnProperty(T)?M="atom":f.hasOwnProperty(T)?M="keyword":M="variable"}var K={};return K.top=function(k,T,A){if(k=="{")return D(A,T,"block");if(k=="}"&&A.context.prev)return b(A);if(x&&/@component/i.test(k))return D(A,T,"atComponentBlock");if(/^@(-moz-)?document$/i.test(k))return D(A,T,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(k))return D(A,T,"atBlock");if(/^@(font-face|counter-style)/i.test(k))return A.stateArg=k,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(k))return"keyframes";if(k&&k.charAt(0)=="@")return D(A,T,"at");if(k=="hash")M="builtin";else if(k=="word")M="tag";else{if(k=="variable-definition")return"maybeprop";if(k=="interpolation")return D(A,T,"interpolation");if(k==":")return"pseudo";if(p&&k=="(")return D(A,T,"parens")}return A.context.type},K.block=function(k,T,A){if(k=="word"){var V=T.current().toLowerCase();return l.hasOwnProperty(V)?(M="property","maybeprop"):a.hasOwnProperty(V)?(M=y?"string.special":"property","maybeprop"):p?(M=T.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(M="error","maybeprop")}else return k=="meta"?"block":!p&&(k=="hash"||k=="qualifier")?(M="error","block"):K.top(k,T,A)},K.maybeprop=function(k,T,A){return k==":"?D(A,T,"prop"):Y(k,T,A)},K.prop=function(k,T,A){if(k==";")return b(A);if(k=="{"&&p)return D(A,T,"propBlock");if(k=="}"||k=="{")return $(k,T,A);if(k=="(")return D(A,T,"parens");if(k=="hash"&&!/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(T.current()))M="error";else if(k=="word")U(T);else if(k=="interpolation")return D(A,T,"interpolation");return"prop"},K.propBlock=function(k,T,A){return k=="}"?b(A):k=="word"?(M="property","maybeprop"):A.context.type},K.parens=function(k,T,A){return k=="{"||k=="}"?$(k,T,A):k==")"?b(A):k=="("?D(A,T,"parens"):k=="interpolation"?D(A,T,"interpolation"):(k=="word"&&U(T),"parens")},K.pseudo=function(k,T,A){return k=="meta"?"pseudo":k=="word"?(M="variableName.constant",A.context.type):Y(k,T,A)},K.documentTypes=function(k,T,A){return k=="word"&&i.hasOwnProperty(T.current())?(M="tag",A.context.type):K.atBlock(k,T,A)},K.atBlock=function(k,T,A){if(k=="(")return D(A,T,"atBlock_parens");if(k=="}"||k==";")return $(k,T,A);if(k=="{")return b(A)&&D(A,T,p?"block":"top");if(k=="interpolation")return D(A,T,"interpolation");if(k=="word"){var V=T.current().toLowerCase();V=="only"||V=="not"||V=="and"||V=="or"?M="keyword":r.hasOwnProperty(V)?M="attribute":s.hasOwnProperty(V)?M="property":o.hasOwnProperty(V)?M="keyword":l.hasOwnProperty(V)?M="property":a.hasOwnProperty(V)?M=y?"string.special":"property":u.hasOwnProperty(V)?M="atom":f.hasOwnProperty(V)?M="keyword":M="error"}return A.context.type},K.atComponentBlock=function(k,T,A){return k=="}"?$(k,T,A):k=="{"?b(A)&&D(A,T,p?"block":"top",!1):(k=="word"&&(M="error"),A.context.type)},K.atBlock_parens=function(k,T,A){return k==")"?b(A):k=="{"||k=="}"?$(k,T,A,2):K.atBlock(k,T,A)},K.restricted_atBlock_before=function(k,T,A){return k=="{"?D(A,T,"restricted_atBlock"):k=="word"&&A.stateArg=="@counter-style"?(M="variable","restricted_atBlock_before"):Y(k,T,A)},K.restricted_atBlock=function(k,T,A){return k=="}"?(A.stateArg=null,b(A)):k=="word"?(A.stateArg=="@font-face"&&!h.hasOwnProperty(T.current().toLowerCase())||A.stateArg=="@counter-style"&&!c.hasOwnProperty(T.current().toLowerCase())?M="error":M="property","maybeprop"):"restricted_atBlock"},K.keyframes=function(k,T,A){return k=="word"?(M="variable","keyframes"):k=="{"?D(A,T,"top"):Y(k,T,A)},K.at=function(k,T,A){return k==";"?b(A):k=="{"||k=="}"?$(k,T,A):(k=="word"?M="tag":k=="hash"&&(M="builtin"),"at")},K.interpolation=function(k,T,A){return k=="}"?b(A):k=="{"||k==";"?$(k,T,A):(k=="word"?M="variable":k!="variable"&&k!="("&&k!=")"&&(M="error"),"interpolation")},{name:n.name,startState:function(){return{tokenize:null,state:e?"block":"top",stateArg:null,context:new w(e?"block":"top",0,null)}},token:function(k,T){if(!T.tokenize&&k.eatSpace())return null;var A=(T.tokenize||R)(k,T);return A&&typeof A=="object"&&(v=A[1],A=A[0]),M=A,v!="comment"&&(T.state=K[T.state](v,k,T)),M},indent:function(k,T,A){var V=k.context,ae=T&&T.charAt(0),we=V.indent;return V.type=="prop"&&(ae=="}"||ae==")")&&(V=V.prev),V.prev&&(ae=="}"&&(V.type=="block"||V.type=="top"||V.type=="interpolation"||V.type=="restricted_atBlock")?(V=V.prev,we=V.indent):(ae==")"&&(V.type=="parens"||V.type=="atBlock_parens")||ae=="{"&&(V.type=="at"||V.type=="atBlock"))&&(we=Math.max(0,V.indent-A.unit))),we},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:g,block:{open:"/*",close:"*/"}},autocomplete:Z0}}}function kt(n){for(var e={},t=0;t<n.length;++t)e[n[t].toLowerCase()]=!0;return e}var Au=["domain","regexp","url","url-prefix"],Tu=kt(Au),Mu=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],Cs=kt(Mu),Lu=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover","prefers-color-scheme","dynamic-range","video-dynamic-range"],As=kt(Lu),Du=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],ra=kt(Du),Ou=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","all","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","binding","bleed","block-size","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-content","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","inset","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-height-step","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotate","rotation","rotation-point","row-gap","ruby-align","ruby-overhang","ruby-position","ruby-span","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-orientation","text-outline","text-overflow","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],Ts=kt(Ou),Eu=["accent-color","aspect-ratio","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","content-visibility","margin-block","margin-block-end","margin-block-start","margin-inline","margin-inline-end","margin-inline-start","overflow-anchor","overscroll-behavior","padding-block","padding-block-end","padding-block-start","padding-inline","padding-inline-end","padding-inline-start","scroll-snap-stop","scrollbar-3d-light-color","scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-track-color","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","shape-inside","zoom"],Ms=kt(Eu),J0=["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],Ls=kt(J0),X0=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],Bu=kt(X0),Pu=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],Ds=kt(Pu),Ru=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","blur","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","brightness","bullets","button","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","conic-gradient","contain","content","contents","content-box","context-menu","continuous","contrast","copy","counter","counters","cover","crop","cross","crosshair","cubic-bezier","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","drop-shadow","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","grayscale","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","hue-rotate","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","manipulation","match","matrix","matrix3d","media-play-button","media-slider","media-sliderthumb","media-volume-slider","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiple_mask_images","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturate","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","sepia","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],Os=kt(Ru),Z0=Au.concat(Mu).concat(Lu).concat(Du).concat(Ou).concat(Eu).concat(Pu).concat(Ru);var Q0={documentTypes:Tu,mediaTypes:Cs,mediaFeatures:As,mediaValueKeywords:ra,propertyKeywords:Ts,nonStandardPropertyKeywords:Ms,fontProperties:Ls,counterDescriptors:Bu,colorKeywords:Ds,valueKeywords:Os,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=_t,_t(n,e)):!1}}},Iu=Ss({name:"css"});function _t(n,e){for(var t=!1,i;(i=n.next())!=null;){if(t&&i=="/"){e.tokenize=null;break}t=i=="*"}return["comment","comment"]}var ak=Ss({name:"scss",mediaTypes:Cs,mediaFeatures:As,mediaValueKeywords:ra,propertyKeywords:Ts,nonStandardPropertyKeywords:Ms,colorKeywords:Ds,valueKeywords:Os,fontProperties:Ls,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=_t,_t(n,e)):["operator","operator"]},":":function(n){return n.match(/^\s*\{/,!1)?[null,null]:!1},$:function(n){return n.match(/^[\w-]+/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName.special","variable"]},"#":function(n){return n.eat("{")?[null,"interpolation"]:!1}}}),hk=Ss({name:"less",mediaTypes:Cs,mediaFeatures:As,mediaValueKeywords:ra,propertyKeywords:Ts,nonStandardPropertyKeywords:Ms,colorKeywords:Ds,valueKeywords:Os,fontProperties:Ls,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=_t,_t(n,e)):["operator","operator"]},"@":function(n){return n.eat("{")?[null,"interpolation"]:n.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)?!1:(n.eatWhile(/[\w\\\-]/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName","variable"])},"&":function(){return["atom","atom"]}}}),ck=Ss({name:"gss",documentTypes:Tu,mediaTypes:Cs,mediaFeatures:As,propertyKeywords:Ts,nonStandardPropertyKeywords:Ms,fontProperties:Ls,counterDescriptors:Bu,colorKeywords:Ds,valueKeywords:Os,supportsAtComponent:!0,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=_t,_t(n,e)):!1}}});function Es(n){var e=n.statementIndent,t=n.jsonld,i=n.json||t,r=n.typescript,s=n.wordCharacters||/[\w$\xa1-\uffff]/,o=function(){function d(Re){return{type:Re,style:"keyword"}}var m=d("keyword a"),C=d("keyword b"),B=d("keyword c"),N=d("keyword d"),ee=d("operator"),se={type:"atom",style:"atom"};return{if:d("if"),while:m,with:m,else:C,do:C,try:C,finally:C,return:N,break:N,continue:N,new:d("new"),delete:B,void:B,throw:B,debugger:d("debugger"),var:d("var"),const:d("var"),let:d("var"),function:d("function"),catch:d("catch"),for:d("for"),switch:d("switch"),case:d("case"),default:d("default"),in:ee,typeof:ee,instanceof:ee,true:se,false:se,null:se,undefined:se,NaN:se,Infinity:se,this:d("this"),class:d("class"),super:d("atom"),yield:B,export:d("export"),import:d("import"),extends:B,await:B}}(),l=/[+\-*&%=<>!?|~^@]/,a=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function h(d){for(var m=!1,C,B=!1;(C=d.next())!=null;){if(!m){if(C=="/"&&!B)return;C=="["?B=!0:B&&C=="]"&&(B=!1)}m=!m&&C=="\\"}}var c,f;function u(d,m,C){return c=d,f=C,m}function p(d,m){var C=d.next();if(C=='"'||C=="'")return m.tokenize=g(C),m.tokenize(d,m);if(C=="."&&d.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return u("number","number");if(C=="."&&d.match(".."))return u("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(C))return u(C);if(C=="="&&d.eat(">"))return u("=>","operator");if(C=="0"&&d.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return u("number","number");if(/\d/.test(C))return d.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),u("number","number");if(C=="/")return d.eat("*")?(m.tokenize=x,x(d,m)):d.eat("/")?(d.skipToEnd(),u("comment","comment")):pd(d,m,1)?(h(d),d.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(d.eat("="),u("operator","operator",d.current()));if(C=="`")return m.tokenize=y,y(d,m);if(C=="#"&&d.peek()=="!")return d.skipToEnd(),u("meta","meta");if(C=="#"&&d.eatWhile(s))return u("variable","property");if(C=="<"&&d.match("!--")||C=="-"&&d.match("->")&&!/\S/.test(d.string.slice(0,d.start)))return d.skipToEnd(),u("comment","comment");if(l.test(C))return(C!=">"||!m.lexical||m.lexical.type!=">")&&(d.eat("=")?(C=="!"||C=="=")&&d.eat("="):/[<>*+\-|&?]/.test(C)&&(d.eat(C),C==">"&&d.eat(C))),C=="?"&&d.eat(".")?u("."):u("operator","operator",d.current());if(s.test(C)){d.eatWhile(s);var B=d.current();if(m.lastType!="."){if(o.propertyIsEnumerable(B)){var N=o[B];return u(N.type,N.style,B)}if(B=="async"&&d.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",B)}return u("variable","variable",B)}}function g(d){return function(m,C){var B=!1,N;if(t&&m.peek()=="@"&&m.match(a))return C.tokenize=p,u("jsonld-keyword","meta");for(;(N=m.next())!=null&&!(N==d&&!B);)B=!B&&N=="\\";return B||(C.tokenize=p),u("string","string")}}function x(d,m){for(var C=!1,B;B=d.next();){if(B=="/"&&C){m.tokenize=p;break}C=B=="*"}return u("comment","comment")}function y(d,m){for(var C=!1,B;(B=d.next())!=null;){if(!C&&(B=="`"||B=="$"&&d.eat("{"))){m.tokenize=p;break}C=!C&&B=="\\"}return u("quasi","string.special",d.current())}var v="([{}])";function M(d,m){m.fatArrowAt&&(m.fatArrowAt=null);var C=d.string.indexOf("=>",d.start);if(!(C<0)){if(r){var B=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(d.string.slice(d.start,C));B&&(C=B.index)}for(var N=0,ee=!1,se=C-1;se>=0;--se){var Re=d.string.charAt(se),qe=v.indexOf(Re);if(qe>=0&&qe<3){if(!N){++se;break}if(--N==0){Re=="("&&(ee=!0);break}}else if(qe>=3&&qe<6)++N;else if(s.test(Re))ee=!0;else if(/["'\/`]/.test(Re))for(;;--se){if(se==0)return;var Xi=d.string.charAt(se-1);if(Xi==Re&&d.string.charAt(se-2)!="\\"){se--;break}}else if(ee&&!N){++se;break}}ee&&!N&&(m.fatArrowAt=se)}}var O={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function R(d,m,C,B,N,ee){this.indented=d,this.column=m,this.type=C,this.prev=N,this.info=ee,B!=null&&(this.align=B)}function F(d,m){for(var C=d.localVars;C;C=C.next)if(C.name==m)return!0;for(var B=d.context;B;B=B.prev)for(var C=B.vars;C;C=C.next)if(C.name==m)return!0}function q(d,m,C,B,N){var ee=d.cc;for(w.state=d,w.stream=N,w.marked=null,w.cc=ee,w.style=m,d.lexical.hasOwnProperty("align")||(d.lexical.align=!0);;){var se=ee.length?ee.pop():i?te:he;if(se(C,B)){for(;ee.length&&ee[ee.length-1].lex;)ee.pop()();return w.marked?w.marked:C=="variable"&&F(d,B)?"variableName.local":m}}}var w={state:null,column:null,marked:null,cc:null};function D(){for(var d=arguments.length-1;d>=0;d--)w.cc.push(arguments[d])}function b(){return D.apply(null,arguments),!0}function Y(d,m){for(var C=m;C;C=C.next)if(C.name==d)return!0;return!1}function $(d){var m=w.state;if(w.marked="def",m.context){if(m.lexical.info=="var"&&m.context&&m.context.block){var C=U(d,m.context);if(C!=null){m.context=C;return}}else if(!Y(d,m.localVars)){m.localVars=new T(d,m.localVars);return}}n.globalVars&&!Y(d,m.globalVars)&&(m.globalVars=new T(d,m.globalVars))}function U(d,m){if(m)if(m.block){var C=U(d,m.prev);return C?C==m.prev?m:new k(C,m.vars,!0):null}else return Y(d,m.vars)?m:new k(m.prev,new T(d,m.vars),!1);else return null}function K(d){return d=="public"||d=="private"||d=="protected"||d=="abstract"||d=="readonly"}function k(d,m,C){this.prev=d,this.vars=m,this.block=C}function T(d,m){this.name=d,this.next=m}var A=new T("this",new T("arguments",null));function V(){w.state.context=new k(w.state.context,w.state.localVars,!1),w.state.localVars=A}function ae(){w.state.context=new k(w.state.context,w.state.localVars,!0),w.state.localVars=null}V.lex=ae.lex=!0;function we(){w.state.localVars=w.state.context.vars,w.state.context=w.state.context.prev}we.lex=!0;function j(d,m){var C=function(){var B=w.state,N=B.indented;if(B.lexical.type=="stat")N=B.lexical.indented;else for(var ee=B.lexical;ee&&ee.type==")"&&ee.align;ee=ee.prev)N=ee.indented;B.lexical=new R(N,w.stream.column(),d,null,B.lexical,m)};return C.lex=!0,C}function W(){var d=w.state;d.lexical.prev&&(d.lexical.type==")"&&(d.indented=d.lexical.indented),d.lexical=d.lexical.prev)}W.lex=!0;function G(d){function m(C){return C==d?b():d==";"||C=="}"||C==")"||C=="]"?D():b(m)}return m}function he(d,m){return d=="var"?b(j("vardef",m),js,G(";"),W):d=="keyword a"?b(j("form"),Fs,he,W):d=="keyword b"?b(j("form"),he,W):d=="keyword d"?w.stream.match(/^\s*$/,!1)?b():b(j("stat"),di,G(";"),W):d=="debugger"?b(G(";")):d=="{"?b(j("}"),ae,Kn,W,we):d==";"?b():d=="if"?(w.state.lexical.info=="else"&&w.state.cc[w.state.cc.length-1]==W&&w.state.cc.pop()(),b(j("form"),Fs,he,W,pa)):d=="function"?b(Ot):d=="for"?b(j("form"),ae,ma,he,we,W):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form",d=="class"?d:m),ba,W)):d=="variable"?r&&m=="declare"?(w.marked="keyword",b(he)):r&&(m=="module"||m=="enum"||m=="type")&&w.stream.match(/^\s*\w/,!1)?(w.marked="keyword",m=="enum"?b(wa):m=="type"?b(ga,G("operator"),re,G(";")):b(j("form"),Xe,G("{"),j("}"),Kn,W,W)):r&&m=="namespace"?(w.marked="keyword",b(j("form"),te,he,W)):r&&m=="abstract"?(w.marked="keyword",b(he)):b(j("stat"),Yu):d=="switch"?b(j("form"),Fs,G("{"),j("}","switch"),ae,Kn,W,W,we):d=="case"?b(te,G(":")):d=="default"?b(G(":")):d=="catch"?b(j("form"),V,Lt,he,W,we):d=="export"?b(j("stat"),ad,W):d=="import"?b(j("stat"),hd,W):d=="async"?b(he):m=="@"?b(te,he):D(j("stat"),te,G(";"),W)}function Lt(d){if(d=="(")return b(Jt,G(")"))}function te(d,m){return ha(d,m,!1)}function Te(d,m){return ha(d,m,!0)}function Fs(d){return d!="("?D():b(j(")"),di,G(")"),W)}function ha(d,m,C){if(w.state.fatArrowAt==w.stream.start){var B=C?fa:ca;if(d=="(")return b(V,j(")"),Se(Jt,")"),W,G("=>"),B,we);if(d=="variable")return D(V,Xe,G("=>"),B,we)}var N=C?pi:Ut;return O.hasOwnProperty(d)?b(N):d=="function"?b(Ot,N):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form"),ld,W)):d=="keyword c"||d=="async"?b(C?Te:te):d=="("?b(j(")"),di,G(")"),W,N):d=="operator"||d=="spread"?b(C?Te:te):d=="["?b(j("]"),fd,W,N):d=="{"?Yi($n,"}",null,N):d=="quasi"?D(qn,N):d=="new"?b(_u(C)):b()}function di(d){return d.match(/[;\}\)\],]/)?D():D(te)}function Ut(d,m){return d==","?b(di):pi(d,m,!1)}function pi(d,m,C){var B=C==!1?Ut:pi,N=C==!1?te:Te;if(d=="=>")return b(V,C?fa:ca,we);if(d=="operator")return/\+\+|--/.test(m)||r&&m=="!"?b(B):r&&m=="<"&&w.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?b(j(">"),Se(re,">"),W,B):m=="?"?b(te,G(":"),N):b(N);if(d=="quasi")return D(qn,B);if(d!=";"){if(d=="(")return Yi(Te,")","call",B);if(d==".")return b(Ju,B);if(d=="[")return b(j("]"),di,G("]"),W,B);if(r&&m=="as")return w.marked="keyword",b(re,B);if(d=="regexp")return w.state.lastType=w.marked="operator",w.stream.backUp(w.stream.pos-w.stream.start-1),b(N)}}function qn(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(qn):b(di,Ku)}function Ku(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(qn)}function ca(d){return M(w.stream,w.state),D(d=="{"?he:te)}function fa(d){return M(w.stream,w.state),D(d=="{"?he:Te)}function _u(d){return function(m){return m=="."?b(d?Uu:Gu):m=="variable"&&r?b(id,d?pi:Ut):D(d?Te:te)}}function Gu(d,m){if(m=="target")return w.marked="keyword",b(Ut)}function Uu(d,m){if(m=="target")return w.marked="keyword",b(pi)}function Yu(d){return d==":"?b(W,he):D(Ut,G(";"),W)}function Ju(d){if(d=="variable")return w.marked="property",b()}function $n(d,m){if(d=="async")return w.marked="property",b($n);if(d=="variable"||w.style=="keyword"){if(w.marked="property",m=="get"||m=="set")return b(Xu);var C;return r&&w.state.fatArrowAt==w.stream.start&&(C=w.stream.match(/^\s*:\s*/,!1))&&(w.state.fatArrowAt=w.stream.pos+C[0].length),b(Yt)}else{if(d=="number"||d=="string")return w.marked=t?"property":w.style+" property",b(Yt);if(d=="jsonld-keyword")return b(Yt);if(r&&K(m))return w.marked="keyword",b($n);if(d=="[")return b(te,mi,G("]"),Yt);if(d=="spread")return b(Te,Yt);if(m=="*")return w.marked="keyword",b($n);if(d==":")return D(Yt)}}function Xu(d){return d!="variable"?D(Yt):(w.marked="property",b(Ot))}function Yt(d){if(d==":")return b(Te);if(d=="(")return D(Ot)}function Se(d,m,C){function B(N,ee){if(C?C.indexOf(N)>-1:N==","){var se=w.state.lexical;return se.info=="call"&&(se.pos=(se.pos||0)+1),b(function(Re,qe){return Re==m||qe==m?D():D(d)},B)}return N==m||ee==m?b():C&&C.indexOf(";")>-1?D(d):b(G(m))}return function(N,ee){return N==m||ee==m?b():D(d,B)}}function Yi(d,m,C){for(var B=3;B<arguments.length;B++)w.cc.push(arguments[B]);return b(j(m,C),Se(d,m),W)}function Kn(d){return d=="}"?b():D(he,Kn)}function mi(d,m){if(r){if(d==":")return b(re);if(m=="?")return b(mi)}}function Zu(d,m){if(r&&(d==":"||m=="in"))return b(re)}function ua(d){if(r&&d==":")return w.stream.match(/^\s*\w+\s+is\b/,!1)?b(te,Qu,re):b(re)}function Qu(d,m){if(m=="is")return w.marked="keyword",b()}function re(d,m){if(m=="keyof"||m=="typeof"||m=="infer"||m=="readonly")return w.marked="keyword",b(m=="typeof"?Te:re);if(d=="variable"||m=="void")return w.marked="type",b(wt);if(m=="|"||m=="&")return b(re);if(d=="string"||d=="number"||d=="atom")return b(wt);if(d=="[")return b(j("]"),Se(re,"]",","),W,wt);if(d=="{")return b(j("}"),Hs,W,wt);if(d=="(")return b(Se(Ws,")"),ed,wt);if(d=="<")return b(Se(re,">"),re);if(d=="quasi")return D(Vs,wt)}function ed(d){if(d=="=>")return b(re)}function Hs(d){return d.match(/[\}\)\]]/)?b():d==","||d==";"?b(Hs):D(Ji,Hs)}function Ji(d,m){if(d=="variable"||w.style=="keyword")return w.marked="property",b(Ji);if(m=="?"||d=="number"||d=="string")return b(Ji);if(d==":")return b(re);if(d=="[")return b(G("variable"),Zu,G("]"),Ji);if(d=="(")return D(bi,Ji);if(!d.match(/[;\}\)\],]/))return b()}function Vs(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Vs):b(re,td)}function td(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Vs)}function Ws(d,m){return d=="variable"&&w.stream.match(/^\s*[?:]/,!1)||m=="?"?b(Ws):d==":"?b(re):d=="spread"?b(Ws):D(re)}function wt(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,wt);if(m=="|"||d=="."||m=="&")return b(re);if(d=="[")return b(re,G("]"),wt);if(m=="extends"||m=="implements")return w.marked="keyword",b(re);if(m=="?")return b(re,G(":"),re)}function id(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,wt)}function _n(){return D(re,nd)}function nd(d,m){if(m=="=")return b(re)}function js(d,m){return m=="enum"?(w.marked="keyword",b(wa)):D(Xe,mi,Dt,sd)}function Xe(d,m){if(r&&K(m))return w.marked="keyword",b(Xe);if(d=="variable")return $(m),b();if(d=="spread")return b(Xe);if(d=="[")return Yi(rd,"]");if(d=="{")return Yi(da,"}")}function da(d,m){return d=="variable"&&!w.stream.match(/^\s*:/,!1)?($(m),b(Dt)):(d=="variable"&&(w.marked="property"),d=="spread"?b(Xe):d=="}"?D():d=="["?b(te,G("]"),G(":"),da):b(G(":"),Xe,Dt))}function rd(){return D(Xe,Dt)}function Dt(d,m){if(m=="=")return b(Te)}function sd(d){if(d==",")return b(js)}function pa(d,m){if(d=="keyword b"&&m=="else")return b(j("form","else"),he,W)}function ma(d,m){if(m=="await")return b(ma);if(d=="(")return b(j(")"),od,W)}function od(d){return d=="var"?b(js,gi):d=="variable"?b(gi):D(gi)}function gi(d,m){return d==")"?b():d==";"?b(gi):m=="in"||m=="of"?(w.marked="keyword",b(te,gi)):D(te,gi)}function Ot(d,m){if(m=="*")return w.marked="keyword",b(Ot);if(d=="variable")return $(m),b(Ot);if(d=="(")return b(V,j(")"),Se(Jt,")"),W,ua,he,we);if(r&&m=="<")return b(j(">"),Se(_n,">"),W,Ot)}function bi(d,m){if(m=="*")return w.marked="keyword",b(bi);if(d=="variable")return $(m),b(bi);if(d=="(")return b(V,j(")"),Se(Jt,")"),W,ua,we);if(r&&m=="<")return b(j(">"),Se(_n,">"),W,bi)}function ga(d,m){if(d=="keyword"||d=="variable")return w.marked="type",b(ga);if(m=="<")return b(j(">"),Se(_n,">"),W)}function Jt(d,m){return m=="@"&&b(te,Jt),d=="spread"?b(Jt):r&&K(m)?(w.marked="keyword",b(Jt)):r&&d=="this"?b(mi,Dt):D(Xe,mi,Dt)}function ld(d,m){return d=="variable"?ba(d,m):Gn(d,m)}function ba(d,m){if(d=="variable")return $(m),b(Gn)}function Gn(d,m){if(m=="<")return b(j(">"),Se(_n,">"),W,Gn);if(m=="extends"||m=="implements"||r&&d==",")return m=="implements"&&(w.marked="keyword"),b(r?re:te,Gn);if(d=="{")return b(j("}"),xt,W)}function xt(d,m){if(d=="async"||d=="variable"&&(m=="static"||m=="get"||m=="set"||r&&K(m))&&w.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1))return w.marked="keyword",b(xt);if(d=="variable"||w.style=="keyword")return w.marked="property",b(Un,xt);if(d=="number"||d=="string")return b(Un,xt);if(d=="[")return b(te,mi,G("]"),Un,xt);if(m=="*")return w.marked="keyword",b(xt);if(r&&d=="(")return D(bi,xt);if(d==";"||d==",")return b(xt);if(d=="}")return b();if(m=="@")return b(te,xt)}function Un(d,m){if(m=="!"||m=="?")return b(Un);if(d==":")return b(re,Dt);if(m=="=")return b(Te);var C=w.state.lexical.prev,B=C&&C.info=="interface";return D(B?bi:Ot)}function ad(d,m){return m=="*"?(w.marked="keyword",b(qs,G(";"))):m=="default"?(w.marked="keyword",b(te,G(";"))):d=="{"?b(Se(ka,"}"),qs,G(";")):D(he)}function ka(d,m){if(m=="as")return w.marked="keyword",b(G("variable"));if(d=="variable")return D(Te,ka)}function hd(d){return d=="string"?b():d=="("?D(te):d=="."?D(Ut):D(Yn,ya,qs)}function Yn(d,m){return d=="{"?Yi(Yn,"}"):(d=="variable"&&$(m),m=="*"&&(w.marked="keyword"),b(cd))}function ya(d){if(d==",")return b(Yn,ya)}function cd(d,m){if(m=="as")return w.marked="keyword",b(Yn)}function qs(d,m){if(m=="from")return w.marked="keyword",b(te)}function fd(d){return d=="]"?b():D(Se(Te,"]"))}function wa(){return D(j("form"),Xe,G("{"),j("}"),Se(ud,"}"),W,W)}function ud(){return D(Xe,Dt)}function dd(d,m){return d.lastType=="operator"||d.lastType==","||l.test(m.charAt(0))||/[,.]/.test(m.charAt(0))}function pd(d,m,C){return m.tokenize==p&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(m.lastType)||m.lastType=="quasi"&&/\{\s*$/.test(d.string.slice(0,d.pos-(C||0)))}return{name:n.name,startState:function(d){var m={tokenize:p,lastType:"sof",cc:[],lexical:new R(-d,0,"block",!1),localVars:n.localVars,context:n.localVars&&new k(null,null,!1),indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(m.globalVars=n.globalVars),m},token:function(d,m){if(d.sol()&&(m.lexical.hasOwnProperty("align")||(m.lexical.align=!1),m.indented=d.indentation(),M(d,m)),m.tokenize!=x&&d.eatSpace())return null;var C=m.tokenize(d,m);return c=="comment"?C:(m.lastType=c=="operator"&&(f=="++"||f=="--")?"incdec":c,q(m,C,c,f,d))},indent:function(d,m,C){if(d.tokenize==x||d.tokenize==y)return null;if(d.tokenize!=p)return 0;var B=m&&m.charAt(0),N=d.lexical,ee;if(!/^\s*else\b/.test(m))for(var se=d.cc.length-1;se>=0;--se){var Re=d.cc[se];if(Re==W)N=N.prev;else if(Re!=pa&&Re!=we)break}for(;(N.type=="stat"||N.type=="form")&&(B=="}"||(ee=d.cc[d.cc.length-1])&&(ee==Ut||ee==pi)&&!/^[,\.=+\-*:?[\(]/.test(m));)N=N.prev;e&&N.type==")"&&N.prev.type=="stat"&&(N=N.prev);var qe=N.type,Xi=B==qe;return qe=="vardef"?N.indented+(d.lastType=="operator"||d.lastType==","?N.info.length+1:0):qe=="form"&&B=="{"?N.indented:qe=="form"?N.indented+C.unit:qe=="stat"?N.indented+(dd(d,m)?e||C.unit:0):N.info=="switch"&&!Xi&&n.doubleIndentSwitch!=!1?N.indented+(/^(?:case|default)\b/.test(m)?C.unit:2*C.unit):N.align?N.column+(Xi?0:1):N.indented+(Xi?0:C.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:i?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}var Nu=Es({name:"javascript"}),zu=Es({name:"json",json:!0}),uk=Es({name:"json",jsonld:!0}),dk=Es({name:"typescript",typescript:!0});function eb(n){return new RegExp("^(?:"+n.join("|")+")","i")}function Bs(n){return new RegExp("^(?:"+n.join("|")+")$","i")}var tb=Bs(["_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall","coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield","debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback","close","flush","lines","read","seek","setvbuf","write","io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write","math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh","os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname","package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall","string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper","table.concat","table.insert","table.maxn","table.remove","table.sort"]),ib=Bs(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),nb=Bs(["function","if","repeat","do","\\(","{"]),rb=Bs(["end","until","\\)","}"]),sb=eb(["end","until","\\)","}","else","elseif"]);function Fu(n){for(var e=0;n.eat("=");)++e;return n.eat("["),e}function sa(n,e){var t=n.next();return t=="-"&&n.eat("-")?n.eat("[")&&n.eat("[")?(e.cur=Hu(Fu(n),"comment"))(n,e):(n.skipToEnd(),"comment"):t=='"'||t=="'"?(e.cur=ob(t))(n,e):t=="["&&/[\[=]/.test(n.peek())?(e.cur=Hu(Fu(n),"string"))(n,e):/\d/.test(t)?(n.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(t)?(n.eatWhile(/[\w\\\-_.]/),"variable"):null}function Hu(n,e){return function(t,i){for(var r=null,s;(s=t.next())!=null;)if(r==null)s=="]"&&(r=0);else if(s=="=")++r;else if(s=="]"&&r==n){i.cur=sa;break}else r=null;return e}}function ob(n){return function(e,t){for(var i=!1,r;(r=e.next())!=null&&!(r==n&&!i);)i=!i&&r=="\\";return i||(t.cur=sa),"string"}}var Vu={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:sa}},token:function(n,e){if(n.eatSpace())return null;var t=e.cur(n,e),i=n.current();return t=="variable"&&(ib.test(i)?t="keyword":tb.test(i)&&(t="builtin")),t!="comment"&&t!="string"&&(nb.test(i)?++e.indentDepth:rb.test(i)&&--e.indentDepth),t},indent:function(n,e,t){var i=sb.test(e);return n.basecol+t.unit*(n.indentDepth-(i?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}};var Wu=n=>{let e={};for(let[t,i]of Object.entries(n))Object.assign(e,{[t]:Array.isArray(i)?[...i]:i});return e},ju=document.createElement("span"),lb=n=>(ju.innerHTML=n,[...ju.textContent].length===1),Ps=class{constructor(e){this.config=e,this.urlProtocols=new RegExp(`^(?:${e.urlProtocols})`,"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.oldTokens=[],this.tokenTable={...S.tokenTable},this.permittedHtmlTags=new Set([...S.permittedHtmlTags,...e.permittedHtmlTags||[]]),this.implicitlyClosedHtmlTags=new Set([...S.implicitlyClosedHtmlTags,...e.implicitlyClosedHtmlTags||[]]);for(let t of Object.keys(e.tags))this.addTag(t)}get fileRegex(){let e=Object.entries(this.config.nsid).filter(([,t])=>t===6).map(([t])=>t).join("|");return new RegExp(`^\\s*(?:${e})\\s*:\\s*`,"iu")}addTag(e,t){var i,r;(i=this.tokenTable)[r=`mw-tag-${e}`]||(i[r]=Pe.define(t))}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}${e==="templateName"?" cm-mw-pagename":""}`}))}eatHtmlEntity(e,t){let i=e.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&lb(`&${i[0]}`)?S.tags.htmlEntity:t}makeStyle(e,t,i){return this.makeLocalStyle(`${e} ${this.isBold?S.tags.strong:""} ${this.isItalic?S.tags.em:""}`,t,i)}makeLocalStyle(e,t,i){let r="";switch(t.nTemplate){case 0:break;case 1:r+="-template";break;case 2:r+="-template2";break;default:r+="-template3";break}switch(t.nExt){case 0:break;case 1:r+="-ext";break;case 2:r+="-ext2";break;default:r+="-ext3";break}return t.nLink>0&&(r+="-link"),i&&t[i]--,(r&&`mw${r}-ground `)+e}inBlock(e,t,i=!0){return(r,s)=>(r.skipTo(t)?(i&&r.match(t),s.tokenize=s.stack.pop()):r.skipToEnd(),this.makeLocalStyle(e,s))}eatEnd(e){return(t,i)=>(t.skipToEnd(),i.tokenize=i.stack.pop(),this.makeLocalStyle(e,i))}inChar(e,t){return(i,r)=>i.eat(e)?(r.tokenize=r.stack.pop(),this.makeLocalStyle(t,r)):(i.skipTo(e)||i.skipToEnd(),this.makeLocalStyle(S.tags.error,r))}inSectionHeader(e){return(t,i)=>t.match(/^[^&<[{~']+/u)?(t.eol()?(t.backUp(e),i.tokenize=this.eatEnd(S.tags.sectionHeader)):t.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(t.backUp(e),i.tokenize=this.inBlock(S.tags.sectionHeader,"<!--",!1)),this.makeLocalStyle(S.tags.section,i)):this.eatWikiText(S.tags.section)(t,i)}inVariable(e,t){return e.match(/^[^{}|]+/u)?this.makeLocalStyle(S.tags.templateVariableName,t):e.eat("|")?(t.tokenize=this.inVariableDefault(!0),this.makeLocalStyle(S.tags.templateVariableDelimiter,t)):e.match("}}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,t)):e.match("{{{")?(t.stack.push(t.tokenize),this.makeLocalStyle(S.tags.templateVariableBracket,t)):(e.next(),this.makeLocalStyle(S.tags.templateVariableName,t))}inVariableDefault(e){let t=S.tags[e?"templateVariable":"comment"];return(i,r)=>i.match(/^[^{}[<&~|]+/u)?this.makeStyle(t,r):i.match("}}}")?(r.tokenize=r.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,r)):i.eat("|")?(r.tokenize=this.inVariableDefault(!1),this.makeLocalStyle(S.tags.templateVariableDelimiter,r)):this.eatWikiText(t)(i,r)}inParserFunctionName(e,t){return e.match(/^[^:}{~|<>[\]]+/u)?this.makeLocalStyle(S.tags.parserFunctionName,t):e.eat(":")?(t.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(S.tags.parserFunctionDelimiter,t)):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.error)(e,t)}inParserFunctionArguments(e,t){return e.match(/^[^|}{[<&~]+/u)?this.makeLocalStyle(S.tags.parserFunction,t):e.eat("|")?this.makeLocalStyle(S.tags.parserFunctionDelimiter,t):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.parserFunction)(e,t)}inTemplatePageName(e){return(t,i)=>t.match(/^\s*\|\s*/u)?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match(/^\s*\}\}/u)?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):t.match(/^\s*<!--.*?-->/u)?this.makeLocalStyle(S.tags.comment,i):e&&t.sol()?(i.nTemplate--,i.tokenize=i.stack.pop(),""):t.match(/^\s*[^\s|&~{}<>[\]]+/u)?(i.tokenize=this.inTemplatePageName(!0),this.makeLocalStyle(S.tags.templateName,i)):t.match(/^(?:[<>[\]}]|\{(?!\{))/u)?this.makeLocalStyle(S.tags.error,i):t.eatSpace()?this.makeLocalStyle(S.tags.templateName,i):this.eatWikiText(S.tags.templateName)(t,i)}inTemplateArgument(e){return(t,i)=>e&&t.eatWhile(/[^=|}{[<&~]/u)?t.eat("=")?(i.tokenize=this.inTemplateArgument(!1),this.makeLocalStyle(S.tags.templateArgumentName,i)):this.makeLocalStyle(S.tags.template,i):t.eatWhile(/[^|}{[<&~]/u)?this.makeLocalStyle(S.tags.template,i):t.eat("|")?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match("}}")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):this.eatWikiText(S.tags.template)(t,i)}eatExternalLinkProtocol(e){return(t,i)=>{for(let r=0;r<e;r++)t.next();return t.eol()?(i.nLink--,i.tokenize=i.stack.pop()):i.tokenize=this.inExternalLink.bind(this),this.makeLocalStyle(S.tags.extLinkProtocol,i)}}inExternalLink(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.match(/^\s*\]/u)?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.eatSpace()?(t.tokenize=this.inExternalLinkText.bind(this),this.makeLocalStyle("",t)):e.match(/^[^\s\]{&~']+/u)?(e.peek()==="'"&&(e.match("''",!1)?t.tokenize=this.inExternalLinkText.bind(this):e.next()),this.makeLocalStyle(S.tags.extLink,t)):this.eatWikiText(S.tags.extLink)(e,t)}inExternalLinkText(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.eat("]")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.match(/^[^'\]{&~<]+/u)?this.makeStyle(S.tags.extLinkText,t):this.eatWikiText(S.tags.extLinkText)(e,t)}inLink(e){return(t,i)=>{if(t.sol())return i.nLink--,i.tokenize=i.stack.pop(),"";if(t.match(/^\s*#\s*/u))return i.tokenize=this.inLinkToSection(e),this.makeStyle(S.tags.link,i);if(t.match(/^\s*\|\s*/u))return i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i);if(t.match(/^\s*\]\]/u))return i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink");if(t.match(/^(?:[<>[\]}]|\{(?!\{))/u))return this.makeStyle(S.tags.error,i);let r=`${S.tags.linkPageName} ${S.tags.pageName}`;return t.match(/^[^#|[\]&~{}<>]+/u)?this.makeStyle(r,i):this.eatWikiText(r)(t,i)}}inLinkToSection(e){return(t,i)=>t.sol()?(i.nLink--,i.tokenize=i.stack.pop(),""):t.match(/^[^|\]&~{}]+/u)?this.makeStyle(S.tags.linkToSection,i):t.eat("|")?(i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i)):t.match("]]")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink")):this.eatWikiText(S.tags.linkToSection)(t,i)}inLinkText(e){let t,i;return(r,s)=>{let o=`${S.tags.linkText} ${t?S.tags.strong:""} ${i?S.tags.em:""}`;if(r.match("]]"))return s.lbrack&&r.peek()==="]"?(r.backUp(1),s.lbrack=!1,this.makeStyle(o,s)):(s.tokenize=s.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,s,"nLink"));if(e&&r.eat("|"))return this.makeLocalStyle(S.tags.linkDelimiter,s);if(r.match("'''"))return t=!t,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);if(r.match("''"))return i=!i,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);let l=r.match(e?/^(?:[^'\]{&~<|[]|\[(?!\[))+/u:/^[^'\]{&~<]+/u);return l&&l[0].includes("[")&&(s.lbrack=!0),l?this.makeStyle(o,s):this.eatWikiText(o)(r,s)}}eatTagName(e,t,i){return(r,s)=>{let o="";for(let l=0;l<e;l++)o+=r.next();return r.eatSpace(),o=o.toLowerCase(),i?(s.tokenize=t?this.inChar(">",S.tags.htmlTagBracket):this.inHtmlTagAttribute(o),this.makeLocalStyle(S.tags.htmlTagName,s)):(s.tokenize=t?this.inChar(">",S.tags.extTagBracket):this.inExtTagAttribute(o),this.makeLocalStyle(S.tags.extTagName,s))}}inHtmlTagAttribute(e){return(t,i)=>t.match(/^[^>/<{]+/u)?this.makeLocalStyle(S.tags.htmlTagAttribute,i):t.match(/^\/?>/u)?(this.implicitlyClosedHtmlTags.has(e)||i.inHtmlTag.push(e),i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.htmlTagBracket,i)):this.eatWikiText(S.tags.htmlTagAttribute)(t,i)}eatNowiki(){return e=>e.match(/^[^&]+/u)?"":(e.next(),this.eatHtmlEntity(e,""))}inExtTagAttribute(e){return(t,i)=>t.match(/^[^>/]+/u)?this.makeLocalStyle(S.tags.extTagAttribute,i):t.eat(">")?(i.extName=e,e==="nowiki"||e==="pre"?(i.extMode={startState:()=>({}),token:this.eatNowiki()},i.extState={}):e in this.config.tagModes&&(i.extMode=this[this.config.tagModes[e]],i.extState=i.extMode.startState(0)),i.tokenize=this.eatExtTagArea(e),this.makeLocalStyle(S.tags.extTagBracket,i)):t.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.extTagBracket,i)):this.eatWikiText(S.tags.extTagAttribute)(t,i)}eatExtTagArea(e){return(t,i)=>{let r=t.pos,s=new RegExp(`</${e}\\s*(?:>|$)`,"iu"),o=s.exec(r?t.string.slice(r):t.string),l=!1;if(o){if(o.index===0)return i.tokenize=this.eatExtCloseTag(e),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(t,i);let a=o.index+r;l=t.string,t.string=l.slice(0,a)}return i.stack.push(i.tokenize),i.tokenize=this.inExtTokens(l),i.tokenize(t,i)}}eatExtCloseTag(e){return(t,i)=>(t.next(),t.next(),i.tokenize=this.eatTagName(e.length,!0,!1),this.makeLocalStyle(S.tags.extTagBracket,i))}inExtTokens(e){return(t,i)=>{let r;return i.extMode===!1?(r=S.tags.extTag,t.skipToEnd()):r=`mw-tag-${i.extName} ${i.extMode.token(t,i.extState)}`,t.eol()&&(e!==!1&&(t.string=e),i.tokenize=i.stack.pop()),r}}eatStartTable(e,t){return e.match(/^(?:\{\||\{{3}\s*!\s*\}\})\s*/u),t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,t)}inTableDefinition(e,t){return e.sol()?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):this.eatWikiText(S.tags.tableDefinition)(e,t)}inTableCaption(e,t){return e.sol()&&e.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1)?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):e.match(/^\s*(?:\||\{\{\s*!\s*\}\}){2}/u,!1)?(t.tokenize=this.inTableRow(!1,!1),""):this.eatWikiText(S.tags.tableCaption)(e,t)}inTable(e,t){if(e.sol()){if(e.eatSpace(),e.match(/^(?:\||\{\{\s*!\s*\}\})/u))return e.match(/^-+\s*/u)?(t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("+")?(e.eatSpace(),t.tokenize=this.inTableCaption.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.tableBracket,t)):(e.eatSpace(),t.tokenize=this.inTableRow(!0,!1),this.makeLocalStyle(S.tags.tableDelimiter,t));if(e.eat("!"))return e.eatSpace(),t.tokenize=this.inTableRow(!0,!0),this.makeLocalStyle(S.tags.tableDelimiter,t)}return this.eatWikiText("")(e,t)}inTableRow(e,t){return(i,r)=>{if(i.sol()){if(i.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1))return r.tokenize=this.inTable.bind(this),this.inTable(i,r)}else{if(i.match(/^[^'|{[<&~!]+/u))return this.makeStyle(t?S.tags.strong:"",r);if(i.match(/^(?:\||\{\{\s*!\s*\}\}){2}/u)||t&&i.match("!!")||e&&i.match(/^(?:\||\{\{\s*!\s*\}\})/u))return this.isBold=!1,this.isItalic=!1,e&&(r.tokenize=this.inTableRow(!1,t)),this.makeLocalStyle(S.tags.tableDelimiter,r)}return this.eatWikiText(t?S.tags.strong:"")(i,r)}}eatFreeExternalLinkProtocol(e,t){return e.match(this.urlProtocols),t.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,t)}inFreeExternalLink(e,t){if(!e.eol()){let i=e.match(/^[^\s{[\]<>~).,;:!?'"]*/u);if(t.lpar||(t.lpar=i[0].includes("(")),e.peek()==="~"){if(e.match(/^~{1,2}(?!~)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="{"){if(e.match(/^\{(?!\{)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="'"){if(e.match(/^'(?!')/u))return this.makeStyle(S.tags.freeExtLink,t)}else{if(t.lpar&&e.peek()===")")return e.next(),this.makeStyle(S.tags.freeExtLink,t);if(e.match(/^[).,;:!?]+(?=[^\s{[\]<>~).,;:!?'"]|~~?(?!~)|\{(?!\{)|'(?!'))/u))return this.makeStyle(S.tags.freeExtLink,t)}}return t.lpar=!1,t.tokenize=t.stack.pop(),this.makeStyle(S.tags.freeExtLink,t)}eatWikiText(e){return(t,i)=>{let r;if(t.sol()){if(t.match("//"))return this.makeStyle(e,i);if(t.match(this.urlProtocols))return i.stack.push(i.tokenize),i.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,i);switch(r=t.next(),r){case"-":if(t.match(/^-{3,}/u))return S.tags.hr;break;case"=":{let o=t.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->.*\S).*)?)$/u);if(o)return t.backUp(o[2].length),i.stack.push(i.tokenize),i.tokenize=this.inSectionHeader(o[3].length),this.makeLocalStyle(`${S.tags.sectionHeader} ${S.tags[`sectionHeader${o[1].length+1}`]}`,i);break}case"*":case"#":case";":return t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case":":return t.match(/^:*(?:\{\||\{{3}\s*!\s*\}\})/u,!1)&&(i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this)),t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case" ":{let o=t.match(/^\s*(:+\s*)?(?=\{\||\{{3}\s*!\s*\}\})/u);if(o){if(o[1])return i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this),this.makeLocalStyle(S.tags.list,i);t.eat("{")}else return S.tags.skipFormatting}case"{":if(t.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return i.stack.push(i.tokenize),i.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,i);break;default:}}else r=t.next();switch(r){case"&":return this.makeStyle(this.eatHtmlEntity(t,e),i);case"'":if(t.match(/^'*(?='{5})/u)||t.match(/^'''(?!')/u,!1))break;if(t.match("''"))return this.firstSingleLetterWord||t.match("''",!1)||this.prepareItalicForCorrection(t),this.isBold=!this.isBold,this.makeLocalStyle(S.tags.apostrophesBold,i);if(t.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(S.tags.apostrophesItalic,i);break;case"[":if(t.eat("[")){if(t.eatSpace(),/[^\]|[]/u.test(t.peek()||""))return i.nLink++,i.stack.push(i.tokenize),i.lbrack=!1,i.tokenize=this.inLink(!!t.match(this.fileRegex,!1)),this.makeLocalStyle(S.tags.linkBracket,i)}else{let o=t.match(this.urlProtocols,!1);if(o)return i.nLink++,i.stack.push(i.tokenize),i.tokenize=this.eatExternalLinkProtocol(o[0].length),this.makeLocalStyle(S.tags.extLinkBracket,i)}break;case"{":if(t.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))/u))return t.eatSpace(),i.stack.push(i.tokenize),i.tokenize=this.inVariable.bind(this),this.makeLocalStyle(S.tags.templateVariableBracket,i);if(t.match(/^\{(?!\{(?!\{))\s*/u)){if(t.peek()==="#")return i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i);let o=t.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/u,!1);return o&&(o[2]===":"||o[4]===void 0||o[3]==="}}")&&(o[1].toLowerCase()in this.config.functionSynonyms[0]||o[1]in this.config.functionSynonyms[1])?(i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i)):(i.nTemplate++,i.stack.push(i.tokenize),i.tokenize=this.inTemplatePageName(!1),this.makeLocalStyle(S.tags.templateBracket,i))}break;case"<":{if(t.match("!--"))return i.stack.push(i.tokenize),i.tokenize=this.inBlock(S.tags.comment,"-->"),this.makeLocalStyle(S.tags.comment,i);let o=!!t.eat("/"),l=t.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+/u);if(l){let a=l[0].toLowerCase();if(a in this.config.tags)return o?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!1),this.makeLocalStyle(S.tags.extTagBracket,i));if(this.permittedHtmlTags.has(a))return o&&a!==i.inHtmlTag.pop()?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):o&&this.implicitlyClosedHtmlTags.has(a)?this.makeLocalStyle(S.tags.error,i):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!0),this.makeLocalStyle(S.tags.htmlTagBracket,i));t.backUp(a.length)}break}case"~":if(t.match(/^~{2,4}/u))return S.tags.signature;break;case"_":{let o=1;for(;t.eat("_");)o++;if(o>2)return t.eol()||t.backUp(2),this.makeStyle(e,i);if(o===2){let l=t.match(/^\w+?__/u);if(l)return`__${l[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${l[0]}`in this.config.doubleUnderscore[1]?S.tags.doubleUnderscore:(t.eol()||t.backUp(2),this.makeStyle(e,i))}break}default:if(/\s/u.test(r||"")&&(t.eatSpace(),t.match(this.urlProtocols,!1)&&!t.match("//")))return i.stack.push(i.tokenize),i.tokenize=this.eatFreeExternalLinkProtocol.bind(this),this.makeStyle(e,i);break}return t.match(/^[^\s_>}[\]<{'|&:~=]+/u),this.makeStyle(e,i)}}prepareItalicForCorrection(e){let t=e.pos,i=e.string.slice(0,t-3),r=i.slice(-1),s=i.slice(-2,-1);if(r===" "){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=t}else if(s===" ")this.firstSingleLetterWord=t;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=t}this.wasBold=this.isBold,this.wasItalic=this.isItalic}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0,lpar:!1,lbrack:!1}),copyState:e=>{let t=Wu(e);return e.extMode&&e.extMode.copyState&&(t.extState=e.extMode.copyState(e.extState)),t},token:(e,t)=>{let i,r=null,s,o,l=[],a=[];if(this.oldTokens.length>0)return s=this.oldTokens.shift(),e.pos=s.pos,s.style;e.sol()&&(this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);do if(i=t.tokenize(e,t),o=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,o)o!==r&&(r=o,l.length>0&&(a.push(...l),l=[])),l.push({pos:e.pos,style:i,state:(t.extMode&&t.extMode.copyState||Wu)(t)});else return this.oldStyle=i,i;while(!e.eol());if(this.isBold&&this.isItalic)if(this.isItalic=this.wasItalic,this.isBold=this.wasBold,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,a.length>0)a[a.length-1].pos++,this.oldTokens=a;else return e.pos=l[0].pos-2,this.oldStyle||"";else this.oldTokens=[...a,...l];return s=this.oldTokens.shift(),e.pos=s.pos,s.style},blankLine:e=>{e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},tokenTable:this.tokenTable,languageData:{closeBrackets:{brackets:["(","[","{",'"']}}}}get"text/mediawiki"(){return this.mediawiki}};for(let[n,e]of Object.entries(Wn))Object.defineProperty(Ps.prototype,n,{get(){return e}});var oa=n=>{let e=new Ps(n),t=e.mediawiki,i=Fi.define(t),r=Jr(zi.define(e.getTagStyles()));return new Ni(i,r)},qu=n=>oa({...n,tags:{...n.tags,script:!0,style:!0},tagModes:{...n.tagModes,script:"javascript",style:"css"},permittedHtmlTags:["html","base","title","menu","a","area","audio","map","track","video","embed","iframe","object","picture","source","canvas","col","colgroup","tbody","tfoot","thead","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","slot","template","dir","frame","frameset","marquee","param","xmp"],implicitlyClosedHtmlTags:["area","base","col","embed","frame","input","param","source","track"]});var la={plain:()=>[],mediawiki:oa,html:qu};for(let[n,e]of Object.entries(Wn))la[n]=()=>new Ni(Fi.define(e));var Rs={},ab={highlightSpecialChars:[Ac,{}],highlightActiveLine:[Tc,{}],highlightWhitespace:[Pc,{}],highlightTrailingWhitespace:[Rc,{}],bracketMatching:[lf,{mediawiki:{brackets:"[]{}"}}],closeBrackets:[Su,{}]},Is=(n,e)=>new Promise(t=>{if(e in window){t();return}let i=document.createElement("script");i.src=`https://testingcf.jsdelivr.net/${n}`,i.onload=()=>{t()},document.head.append(i)}),Ns=(n,e,t)=>n.line(e).from+t-1,Mt,Ki,Gt,_i,Gi,fe,yt,ui,jn,aa,Ui,zs,$u=class{constructor(e,t="plain",i){Ze(this,jn);Ze(this,Ui);Ze(this,Mt,void 0);Ze(this,Ki,void 0);Ze(this,Gt,void 0);Ze(this,_i,void 0);Ze(this,Gi,void 0);Ze(this,fe,void 0);Ze(this,yt,void 0);Ze(this,ui,!0);lt(this,Mt,e),lt(this,yt,t),lt(this,Ki,new Ct),lt(this,Gt,new Ct),lt(this,_i,new Ct),lt(this,Gi,new Ct);let r,s=[_(this,Ki).of(la[t](i)),_(this,Gt).of([]),_(this,_i).of([]),_(this,Gi).of(qt.of(" ")),Jr(nf),z.contentAttributes.of({accesskey:e.accessKey,dir:e.dir,lang:e.lang}),oe.readOnly.of(e.readOnly),Ec(),z.lineWrapping,vf(),ef(),Fr.of([...Xf,...Tf,...lu]),z.updateListener.of(({state:{doc:u},docChanged:p})=>{p&&(clearTimeout(r),r=window.setTimeout(()=>{e.value=u.toString()},400))})];lt(this,fe,new z({extensions:s,doc:e.value}));let{selectionStart:o,selectionEnd:l,scrollTop:a}=e,{fontSize:h,lineHeight:c}=getComputedStyle(e),f=document.activeElement===e;e.parentNode.insertBefore(_(this,fe).dom,e),ki(this,Ui,zs).call(this),ki(this,jn,aa).call(this),_(this,fe).dom.style.fontSize=h,_(this,fe).scrollDOM.style.lineHeight=c,_(this,fe).requestMeasure(),_(this,fe).dispatch({selection:{anchor:o,head:l}}),e.style.display="none",f&&_(this,fe).focus(),requestAnimationFrame(()=>{_(this,fe).scrollDOM.scrollTop=a})}get textarea(){return _(this,Mt)}get view(){return _(this,fe)}get lang(){return _(this,yt)}get visible(){return _(this,ui)}setLanguage(e="plain",t){_(this,fe).dispatch({effects:[_(this,Ki).reconfigure(la[e](t)),_(this,Gt).reconfigure(Rs[e]||[])]}),lt(this,yt,e),(Rs[e]?Ql:Vn)(_(this,fe))}lint(e){let t=e?[du(i=>e(i.state.doc)),yu()]:[];e?(Rs[_(this,yt)]=t,ki(this,Ui,zs).call(this,!0)):(delete Rs[_(this,yt)],ki(this,Ui,zs).call(this)),_(this,fe).dispatch({effects:[_(this,Gt).reconfigure(t)]}),(e?Ql:Vn)(_(this,fe))}update(){let e=_(this,Gt).get(_(this,fe).state);if(e.length>0){let t=_(this,fe).plugin(e[0][1]);t.set=!0,t.force()}}prefer(e){_(this,fe).dispatch({effects:[_(this,_i).reconfigure(e.map(t=>{let[i,r]=ab[t];return i(r[_(this,yt)])}))]})}setIndent(e){_(this,fe).dispatch({effects:[_(this,Gi).reconfigure(qt.of(e))]})}async getLinter(e){var t,i,r;switch(_(this,yt)){case"mediawiki":{let s="npm/wikiparser-node@1.3.4-b/extensions/dist",o=`combine/${s}/base.min.js,${s}/lint.min.js`;await Is(o,"wikiparse");let l=new wikiparse.Linter(e==null?void 0:e.include);return a=>l.codemirror(a.toString())}case"javascript":{await Is("npm/eslint-linter-browserify","eslint");let s=new eslint.Linter,o={env:{browser:!0,es2018:!0},parserOptions:{ecmaVersion:9,sourceType:"module"},rules:{},...e};for(let[l,{meta:a}]of s.getRules())(t=a==null?void 0:a.docs)!=null&&t.recommended&&((r=(i=o.rules)[l])!=null||(i[l]=2));return l=>s.verify(l.toString(),o).map(({message:a,severity:h,line:c,column:f,endLine:u,endColumn:p})=>{let g=Ns(l,c,f);return{message:a,severity:h===1?"warning":"error",from:g,to:u===void 0?g+1:Ns(l,u,p)}})}case"css":{await Is("gh/openstyles/stylelint-bundle/dist/stylelint-bundle.min.js","stylelint");let s={rules:{"annotation-no-unknown":!0,"at-rule-no-unknown":!0,"block-no-empty":!0,"color-no-invalid-hex":!0,"comment-no-empty":!0,"custom-property-no-missing-var-function":!0,"declaration-block-no-duplicate-custom-properties":!0,"declaration-block-no-duplicate-properties":[!0,{ignore:["consecutive-duplicates-with-different-syntaxes"]}],"declaration-block-no-shorthand-property-overrides":!0,"font-family-no-duplicate-names":!0,"font-family-no-missing-generic-family-keyword":!0,"function-calc-no-unspaced-operator":!0,"function-linear-gradient-no-nonstandard-direction":!0,"function-no-unknown":!0,"keyframe-block-no-duplicate-selectors":!0,"keyframe-declaration-no-important":!0,"media-feature-name-no-unknown":!0,"media-query-no-invalid":!0,"named-grid-areas-no-invalid":!0,"no-descending-specificity":!0,"no-duplicate-at-import-rules":!0,"no-duplicate-selectors":!0,"no-empty-source":!0,"no-invalid-double-slash-comments":!0,"no-invalid-position-at-import-rule":!0,"no-irregular-whitespace":!0,"property-no-unknown":!0,"selector-anb-no-unmatchable":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":[!0,{ignore:["custom-elements"]}],"string-no-newline":!0,"unit-no-unknown":!0,...e==null?void 0:e.rules}};return async o=>{let{results:l}=await stylelint.lint({code:o.toString(),config:s});return l.flatMap(({warnings:a})=>a).map(({text:a,severity:h,line:c,column:f,endLine:u,endColumn:p})=>({message:a,severity:h,from:Ns(o,c,f),to:u===void 0?o.line(c).to:Ns(o,u,p)}))}}case"lua":return await Is("npm/luaparse","luaparse"),s=>{try{luaparse.parse(s.toString())}catch(o){if(o instanceof luaparse.SyntaxError)return[{message:o.message,severity:"error",from:o.index,to:o.index}]}return[]};default:return}}setContent(e){_(this,fe).dispatch({changes:{from:0,to:_(this,fe).state.doc.length,insert:e}})}toggle(e=!_(this,ui)){e&&!_(this,ui)&&(this.setContent(_(this,Mt).value),ki(this,jn,aa).call(this)),lt(this,ui,e),_(this,fe).dom.style.setProperty("display",e?"":"none","important"),_(this,Mt).style.display=e?"none":""}};Mt=new WeakMap,Ki=new WeakMap,Gt=new WeakMap,_i=new WeakMap,Gi=new WeakMap,fe=new WeakMap,yt=new WeakMap,ui=new WeakMap,jn=new WeakSet,aa=function(){let{offsetHeight:e}=_(this,Mt);_(this,fe).dom.style.height=e?`${e}px`:_(this,Mt).style.height},Ui=new WeakSet,zs=function(e){_(this,fe).dom.style.minHeight=e?"calc(100px + 2em)":"2em"};export{$u as CodeMirror6};
14
14
  /**
15
15
  * @author MusikAnimal and others
16
16
  * @license GPL-2.0-or-later