@rr0/ufoathome 0.87.0 → 0.89.0
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-embed-scene/rr0-scene.mjs +2 -2
- package/dist-embed-sighting/rr0-sighting.mjs +3 -3
- package/dist-embed-sighting-editor/SightingEditorMessages_es-CpHb-hWv.js +1 -0
- package/dist-embed-sighting-editor/SightingEditorMessages_fr-DJOAwb2f.js +1 -0
- package/dist-embed-sighting-editor/SightingEditorMessages_it-Bv7GHyda.js +1 -0
- package/dist-embed-sighting-editor/SightingFileEditor-Dd7giSWi.js +11 -0
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +69 -49
- package/package.json +7 -1
- package/dist-embed-sighting-editor/SightingEditorMessages_es-Sx_R4Jc9.js +0 -1
- package/dist-embed-sighting-editor/SightingEditorMessages_fr-D46kxBx_.js +0 -1
- package/dist-embed-sighting-editor/SightingEditorMessages_it-I2dx1jsT.js +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Vc from"./sightingSchema-D7VMkxdw.js";let Es=[],Ul=[];(()=>{let s="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,e=0;t<s.length;t++)(t%2?Ul:Es).push(e=e+s[t])})();function zc(s){if(s<768)return!1;for(let t=0,e=Es.length;;){let i=t+e>>1;if(s<Es[i])e=i;else if(s>=Ul[i])t=i+1;else return!0;if(t==e)return!1}}function ro(s){return s>=127462&&s<=127487}const oo=8205;function $c(s,t,e=!0,i=!0){return(e?Gl:qc)(s,t,i)}function Gl(s,t,e){if(t==s.length)return t;t&&Yl(s.charCodeAt(t))&&Ql(s.charCodeAt(t-1))&&t--;let i=os(s,t);for(t+=lo(i);t<s.length;){let n=os(s,t);if(i==oo||n==oo||e&&zc(n))t+=lo(n),i=n;else if(ro(n)){let r=0,o=t-2;for(;o>=0&&ro(os(s,o));)r++,o-=2;if(r%2==0)break;t+=2}else break}return t}function qc(s,t,e){for(;t>1;){let i=Gl(s,t-2,e);if(i<t)return i;t--}return 0}function os(s,t){let e=s.charCodeAt(t);if(!Ql(e)||t+1==s.length)return e;let i=s.charCodeAt(t+1);return Yl(i)?(e-55296<<10)+(i-56320)+65536:e}function Yl(s){return s>=56320&&s<57344}function Ql(s){return s>=55296&&s<56320}function lo(s){return s<65536?1:2}class W{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=Je(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),Ut.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Je(this,t,e);let i=[];return this.decompose(t,e,i,0),Ut.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new di(this),r=new di(t);for(let o=e,l=e;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(t=1){return new di(this,t)}iterRange(t,e=this.length){return new Xl(this,t,e)}iterLines(t,e){let i;if(t==null)i=this.iter();else{e==null&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new _l(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?W.empty:t.length<=32?new Q(t):Ut.from(Q.split(t,[]))}}class Q extends W{constructor(t,e=jc(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((e?i:l)>=t)return new Kc(n,l,i,o);n=l+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new Q(ao(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(n&1){let o=i.pop(),l=hn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new Q(l,o.length+r.length));else{let a=l.length>>1;i.push(new Q(l.slice(0,a)),new Q(l.slice(a)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof Q))return super.replace(t,e,i);[t,e]=Je(this,t,e);let n=hn(this.text,hn(i.text,ao(this.text,0,t)),e),r=this.length+i.length-(e-t);return n.length<=32?new Q(n,r):Ut.from(Q.split(n,[]),r)}sliceString(t,e=this.length,i=`
|
|
2
|
+
`){[t,e]=Je(this,t,e);let n="";for(let r=0,o=0;r<=e&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>t&&o&&(n+=i),t<a&&e>r&&(n+=l.slice(Math.max(0,t-r),e-r)),r=a+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,i.length==32&&(e.push(new Q(i,n)),i=[],n=-1);return n>-1&&e.push(new Q(i,n)),e}}class Ut extends W{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,e,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((e?a:l)>=t)return o.lineInner(t,e,i,n);n=l+1,i=a+1}}decompose(t,e,i,n){for(let r=0,o=0;o<=e&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(t<=a&&e>=o){let h=n&((o<=t?1:0)|(a>=e?2:0));o>=t&&a<=e&&!h?i.push(l):l.decompose(t-o,e-o,i,h)}o=a+1}}replace(t,e,i){if([t,e]=Je(this,t,e),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(t>=r&&e<=l){let a=o.replace(t-r,e-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[n]=a,new Ut(c,this.length-(e-t)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i=`
|
|
3
|
+
`){[t,e]=Je(this,t,e);let n="";for(let r=0,o=0;r<this.children.length&&o<=e;r++){let l=this.children[r],a=o+l.length;o>t&&r&&(n+=i),t<a&&e>o&&(n+=l.sliceString(t-o,e-o,i)),o=a+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Ut))return 0;let i=0,[n,r,o,l]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,r+=e){if(n==o||r==l)return i;let a=this.children[n],h=t.children[r];if(a!=h)return i+a.scanIdentical(h,e);i+=a.length+1}}static from(t,e=t.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of t)i+=d.lines;if(i<32){let d=[];for(let p of t)p.flatten(d);return new Q(d,e)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof Ut)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof Q&&a&&(p=c[c.length-1])instanceof Q&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new Q(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>n&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Ut.from(c,h)),h=-1,a=c.length=0)}for(let d of t)f(d);return u(),l.length==1?l[0]:new Ut(l,e)}}W.empty=new Q([""],0);function jc(s){let t=-1;for(let e of s)t+=e.length+1;return t}function hn(s,t,e=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let l=s[r],a=n+l.length;a>=e&&(a>i&&(l=l.slice(0,i-n)),n<e&&(l=l.slice(e-n)),o?(t[t.length-1]+=l,o=!1):t.push(l)),n=a+1}return t}function ao(s,t,e){return hn(s,[""],t,e)}class di{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof Q?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof Q?n.text.length:n.children.length;if(o==(e>0?l:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
|
|
4
|
+
`,this;t--}else if(n instanceof Q){let a=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,a.length>Math.max(0,t))return this.value=t==0?a:e>0?a.slice(t):a.slice(0,a.length-t),this;t-=a.length}else{let a=n.children[o+(e<0?-1:0)];t>a.length?(t-=a.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(e>0?1:(a instanceof Q?a.text.length:a.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Xl{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new di(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class _l{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(W.prototype[Symbol.iterator]=function(){return this.iter()},di.prototype[Symbol.iterator]=Xl.prototype[Symbol.iterator]=_l.prototype[Symbol.iterator]=function(){return this});class Kc{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function Je(s,t,e){return t=Math.max(0,Math.min(s.length,t)),[t,Math.max(t,Math.min(s.length,e))]}function lt(s,t,e=!0,i=!0){return $c(s,t,e,i)}function Uc(s){return s>=56320&&s<57344}function Gc(s){return s>=55296&&s<56320}function St(s,t){let e=s.charCodeAt(t);if(!Gc(e)||t+1==s.length)return e;let i=s.charCodeAt(t+1);return Uc(i)?(e-55296<<10)+(i-56320)+65536:e}function Jl(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function ie(s){return s<65536?1:2}const Is=/\r\n?|\n/;var ft=(function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s})(ft||(ft={}));class Zt{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let r=this.sections[e++],o=this.sections[e++];o<0?(t(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(t,e=!1){Ns(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new Zt(t)}composeDesc(t){return this.empty?t:t.empty?this:Zl(this,t)}mapDesc(t,e=!1){return t.empty?this:Hs(this,t,e)}mapPos(t,e=-1,i=ft.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=n+l;if(a<0){if(h>t)return r+(t-n);r+=l}else{if(i!=ft.Simple&&h>=t&&(i==ft.TrackDel&&n<t&&h>t||i==ft.TrackBefore&&n<t||i==ft.TrackAfter&&h>t))return null;if(h>t||h==t&&e<0&&!l)return t==n||e<0?r:r+a;r+=a}n=h}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return r}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=e&&l>=t)return n<t&&l>e?"cover":!0;n=l}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Zt(t)}static create(t){return new Zt(t)}}class _ extends Zt{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return Ns(this,(e,i,n,r,o)=>t=t.replace(n,n+(i-e),o),!1),t}mapDesc(t,e=!1){return Hs(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,r=0;n<e.length;n+=2){let o=e[n],l=e[n+1];if(l>=0){e[n]=l,e[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(W.empty);i.push(o?t.slice(r,r+o):W.empty)}r+=o}return new _(e,i)}compose(t){return this.empty?t:t.empty?this:Zl(this,t,!0)}map(t,e=!1){return t.empty?this:Hs(this,t,e,!0)}iterChanges(t,e=!1){Ns(this,t,e)}get desc(){return Zt.create(this.sections)}filter(t){let e=[],i=[],n=[],r=new ki(this);t:for(let o=0,l=0;;){let a=o==t.length?1e9:t[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break t;let c=Math.min(r.len,a-l);ot(n,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;ot(e,c,f),f>0&&me(i,e,r.text),r.forward(c),l+=c}let h=t[o++];for(;l<h;){if(r.done)break t;let c=Math.min(r.len,h-l);ot(e,c,-1),ot(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new _(e,i),filtered:Zt.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):n==0?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!n.length)return;o<e&&ot(n,e-o,-1);let f=new _(n,r);l=l?l.compose(f.map(l)):f,n=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof _){if(c.length!=e)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${e})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>e)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${e})`);let p=d?typeof d=="string"?W.of(d.split(i||Is)):d:W.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&ot(n,f-o,-1),ot(n,u-f,m),me(r,n,p),o=u}}return h(t),a(!l),l}static empty(t){return new _(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="number")e.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)e.push(r[0],0);else{for(;i.length<n;)i.push(W.empty);i[n]=W.of(r.slice(1)),e.push(r[0],i[n].length)}}}return new _(e,i)}static createSet(t,e){return new _(t,e)}}function ot(s,t,e,i=!1){if(t==0&&e<=0)return;let n=s.length-2;n>=0&&e<=0&&e==s[n+1]?s[n]+=t:n>=0&&t==0&&s[n]==0?s[n+1]+=e:i?(s[n]+=t,s[n+1]+=e):s.push(t,e)}function me(s,t,e){if(e.length==0)return;let i=t.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(e);else{for(;s.length<i;)s.push(W.empty);s.push(e)}}function Ns(s,t,e){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],a=s.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,c=r,f=W.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(e||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];t(n,h,r,c,f),n=h,r=c}}}function Hs(s,t,e,i=!1){let n=[],r=i?[]:null,o=new ki(s),l=new ki(t);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);ot(n,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&&!e))){let h=l.len;for(ot(n,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(ot(n,0,o.ins),r&&me(r,n,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;ot(n,h,a<o.i?o.ins:0),r&&a<o.i&&me(r,n,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?_.createSet(n,r):Zt.create(n);throw new Error("Mismatched change set lengths")}}}function Zl(s,t,e=!1){let i=[],n=e?[]:null,r=new ki(s),o=new ki(t);for(let l=!1;;){if(r.done&&o.done)return n?_.createSet(i,n):Zt.create(i);if(r.ins==0)ot(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)ot(i,0,o.ins,l),n&&me(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;ot(i,a,c,l),n&&c&&me(n,i,o.text)}else o.ins==-1?(ot(i,r.off?0:r.len,a,l),n&&me(n,i,r.textBit(a))):(ot(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&me(n,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class ki{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[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:t}=this.set,e=this.i-2>>1;return e>=t.length?W.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?W.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class de{constructor(t,e,i,n){this.from=t,this.to=e,this.flags=i,this.goalColumn=n}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new de(i,n,this.flags,this.goalColumn)}extend(t,e=t,i=0){if(t<=this.anchor&&e>=this.anchor)return x.range(t,e,void 0,void 0,i);let n=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return x.range(this.anchor,n,void 0,void 0,i)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return x.range(t.anchor,t.head)}static create(t,e,i,n){return new de(t,e,i,n)}}class x{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:x.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new x([this.main],0)}addRange(t,e=!0){return x.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,x.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new x(t.ranges.map(e=>de.fromJSON(e)),t.main)}static single(t,e=t){return new x([x.range(t,e)],0)}static create(t,e=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let r=t[n];if(r.empty?r.from<=i:r.from<i)return x.normalized(t.slice(),e);i=r.to}return new x(t,e)}static cursor(t,e=0,i,n){return de.create(t,t,(e==0?0:e<0?8:16)|(i==null?7:Math.min(6,i)),n)}static range(t,e,i,n,r){let o=n==null?7:Math.min(6,n);return!r&&t!=e&&(r=e<t?1:-1),r&&(o|=r<0?8:16),e<t?de.create(e,t,o|32,i):de.create(t,e,o,i)}static undirectionalRange(t,e){return de.create(t,e,64,void 0)}static normalized(t,e=0){let i=t[e];t.sort((n,r)=>n.from-r.from),e=t.indexOf(i);for(let n=1;n<t.length;n++){let r=t[n],o=t[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);n<=e&&e--,t.splice(--n,2,r.anchor>r.head?x.range(a,l):x.range(l,a))}}return new x(t,e)}}function ta(s,t){for(let e of s.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}let Ar=0;class M{constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=Ar++,this.default=t([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(t={}){return new M(t.combine||(e=>e),t.compareInput||((e,i)=>e===i),t.compare||(t.combine?(e,i)=>e===i:Mr),!!t.static,t.enables)}of(t){return new cn([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new cn(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new cn(t,this,2,e)}from(t,e){return e||(e=i=>i),this.compute([t],i=>e(i.field(t)))}}function Mr(s,t){return s==t||s.length==t.length&&s.every((e,i)=>e===t[i])}class cn{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=Ar++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,r=this.id,o=t[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((e=t[f.id])!==null&&e!==void 0?e:1)&1)==0&&c.push(t[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Ws(f,c)){let d=i(f);if(l?!ho(d,f.values[o],n):!n(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let m=xn(u,p);if(this.dependencies.every(g=>g instanceof M?u.facet(g)===f.facet(g):g instanceof mt?u.field(g,!1)==f.field(g,!1):!0)||(l?ho(d=i(f),m,n):n(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}get extension(){return this}}function ho(s,t,e){if(s.length!=t.length)return!1;for(let i=0;i<s.length;i++)if(!e(s[i],t[i]))return!1;return!0}function Ws(s,t){let e=!1;for(let i of t)pi(s,i)&1&&(e=!0);return e}function Yc(s,t,e){let i=e.map(a=>s[a.id]),n=e.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[t.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=xn(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return t.combine(h)}return{create(a){for(let h of i)pi(a,h);return a.values[o]=l(a),1},update(a,h){if(!Ws(a,r))return 0;let c=l(a);return t.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Ws(a,i),f=h.config.facets[t.id],u=h.facet(t);if(f&&!c&&Mr(e,f))return a.values[o]=u,0;let d=l(a);return t.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Vi=M.define({static:!0});class mt{constructor(t,e,i,n,r){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(t){let e=new mt(Ar++,t.create,t.update,t.compare||((i,n)=>i===n),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(Vi).find(i=>i.field==this);return(e?.create||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:i=>(i.values[e]=this.create(i),1),update:(i,n)=>{let r=i.values[e],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[e]=o,1)},reconfigure:(i,n)=>{let r=i.facet(Vi),o=n.facet(Vi),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[e]=l.create(i),1):n.config.address[this.id]!=null?(i.values[e]=n.field(this),0):(i.values[e]=this.create(i),1)}}}init(t){return[this,Vi.of({field:this,create:t})]}get extension(){return this}}const Te={lowest:4,low:3,default:2,high:1,highest:0};function oi(s){return t=>new ea(t,s)}const si={highest:oi(Te.highest),high:oi(Te.high),default:oi(Te.default),low:oi(Te.low),lowest:oi(Te.lowest)};class ea{constructor(t,e){this.inner=t,this.prec=e}get extension(){return this}}class $n{of(t){return new Fs(this,t)}reconfigure(t){return $n.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Fs{constructor(t,e){this.compartment=t,this.inner=e}get extension(){return this}}class bn{constructor(t,e,i,n,r,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return e==null?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],r=Object.create(null),o=new Map;for(let u of Qc(t,e,o))u instanceof mt?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Mr(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>Yc(g,p,d))}}let f=h.map(u=>u(l));return new bn(t,o,f,l,a,r)}}function Qc(s,t,e){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Fs&&e.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Fs){if(e.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=t.get(o.compartment)||o.inner;e.set(o.compartment,h),r(h,l)}else if(o instanceof ea)r(o.inner,o.prec);else if(o instanceof mt)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof cn)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Te.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(s,Te.default),i.reduce((o,l)=>o.concat(l))}function pi(s,t){if(t&1)return 2;let e=t>>1,i=s.status[e];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[e]=4;let n=s.computeSlot(s,s.config.dynamicSlots[e]);return s.status[e]=2|n}function xn(s,t){return t&1?s.config.staticValues[t>>1]:s.values[t>>1]}const ia=M.define(),Vs=M.define({combine:s=>s.some(t=>t),static:!0}),na=M.define({combine:s=>s.length?s[0]:void 0,static:!0}),sa=M.define(),ra=M.define(),oa=M.define(),la=M.define({combine:s=>s.length?s[0]:!1});class ae{constructor(t,e){this.type=t,this.value=e}static define(){return new Xc}}class Xc{of(t){return new ae(this,t)}}class _c{constructor(t){this.map=t}of(t){return new I(this,t)}}class I{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return e===void 0?void 0:e==this.value?this:new I(this.type,e)}is(t){return this.type==t}static define(t={}){return new _c(t.map||(e=>e))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let r=n.map(e);r&&i.push(r)}return i}}I.reconfigure=I.define();I.appendConfig=I.define();class J{constructor(t,e,i,n,r,o){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&ta(i,e.newLength),r.some(l=>l.type==J.time)||(this.annotations=r.concat(J.time.of(Date.now())))}static create(t,e,i,n,r,o){return new J(t,e,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(J.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&e[t.length]=="."))}}J.time=ae.define();J.userEvent=ae.define();J.addToHistory=ae.define();J.remote=ae.define();function Jc(s,t){let e=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==t.length||t[n]>=s[i]))r=s[i++],o=s[i++];else if(n<t.length)r=t[n++],o=t[n++];else return e;!e.length||e[e.length-1]<r?e.push(r,o):e[e.length-1]<o&&(e[e.length-1]=o)}}function aa(s,t,e){var i;let n,r,o;return e?(n=t.changes,r=_.empty(t.changes.length),o=s.changes.compose(t.changes)):(n=t.changes.map(s.changes),r=s.changes.mapDesc(t.changes,!0),o=s.changes.compose(n)),{changes:o,selection:t.selection?t.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:I.mapEffects(s.effects,n).concat(I.mapEffects(t.effects,r)),annotations:s.annotations.length?s.annotations.concat(t.annotations):t.annotations,scrollIntoView:s.scrollIntoView||t.scrollIntoView}}function zs(s,t,e){let i=t.selection,n=Ue(t.annotations);return t.userEvent&&(n=n.concat(J.userEvent.of(t.userEvent))),{changes:t.changes instanceof _?t.changes:_.of(t.changes||[],e,s.facet(na)),selection:i&&(i instanceof x?i:x.single(i.anchor,i.head)),effects:Ue(t.effects),annotations:n,scrollIntoView:!!t.scrollIntoView}}function ha(s,t,e){let i=zs(s,t.length?t[0]:{},s.doc.length);t.length&&t[0].filter===!1&&(e=!1);for(let r=1;r<t.length;r++){t[r].filter===!1&&(e=!1);let o=!!t[r].sequential;i=aa(i,zs(s,t[r],o?i.changes.newLength:s.doc.length),o)}let n=J.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return tf(e?Zc(n):n)}function Zc(s){let t=s.startState,e=!0;for(let n of t.facet(sa)){let r=n(s);if(r===!1){e=!1;break}Array.isArray(r)&&(e=e===!0?r:Jc(e,r))}if(e!==!0){let n,r;if(e===!1)r=s.changes.invertedDesc,n=_.empty(t.doc.length);else{let o=s.changes.filter(e);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=J.create(t,n,s.selection&&s.selection.map(r),I.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=t.facet(ra);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof J?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof J?s=r[0]:s=ha(t,Ue(r),!1)}return s}function tf(s){let t=s.startState,e=t.facet(oa),i=s;for(let n=e.length-1;n>=0;n--){let r=e[n](s);r&&Object.keys(r).length&&(i=aa(i,zs(t,r,s.changes.newLength),!0))}return i==s?s:J.create(t,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const ef=[];function Ue(s){return s==null?ef:Array.isArray(s)?s:[s]}var Tt=(function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s})(Tt||(Tt={}));const nf=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let $s;try{$s=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function sf(s){if($s)return $s.test(s);for(let t=0;t<s.length;t++){let e=s[t];if(/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||nf.test(e)))return!0}return!1}function rf(s){return t=>{if(!/\S/.test(t))return Tt.Space;if(sf(t))return Tt.Word;for(let e=0;e<s.length;e++)if(t.indexOf(s[e])>-1)return Tt.Word;return Tt.Other}}class V{constructor(t,e,i,n,r,o){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)pi(this,l<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(i==null){if(e)throw new RangeError("Field is not present in this state");return}return pi(this,i),xn(this,i)}update(...t){return ha(this,t,!0)}applyTransaction(t){let e=this.config,{base:i,compartments:n}=e;for(let l of t.effects)l.is($n.reconfigure)?(e&&(n=new Map,e.compartments.forEach((a,h)=>n.set(h,a)),e=null),n.set(l.value.compartment,l.value.extension)):l.is(I.reconfigure)?(e=null,i=l.value):l.is(I.appendConfig)&&(e=null,i=Ue(i).concat(l.value));let r;e?r=t.startState.values.slice():(e=bn.resolve(i,n,this),r=new V(e,this.doc,this.selection,e.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=t.startState.facet(Vs)?t.newSelection:t.newSelection.asSingle();new V(e,t.newDoc,o,r,(l,a)=>a.update(l,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:x.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),r=[i.range],o=Ue(i.effects);for(let l=1;l<e.ranges.length;l++){let a=t(e.ranges[l]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=n.mapDesc(h,!0);r.push(a.range.map(f)),n=n.compose(c),o=I.mapEffects(o,c).concat(I.mapEffects(Ue(a.effects),f))}return{changes:n,selection:x.create(r,e.mainIndex),effects:o}}changes(t=[]){return t instanceof _?t:_.of(t,this.doc.length,this.facet(V.lineSeparator))}toText(t){return W.of(t.split(this.facet(V.lineSeparator)||Is))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return e==null?t.default:(pi(this,e),xn(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof mt&&this.config.address[n.id]!=null&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(t,r)){let o=i[r],l=t[r];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return V.create({doc:t.doc,selection:x.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=bn.resolve(t.extensions||[],new Map),i=t.doc instanceof W?t.doc:W.of((t.doc||"").split(e.staticFacet(V.lineSeparator)||Is)),n=t.selection?t.selection instanceof x?t.selection:x.single(t.selection.anchor,t.selection.head):x.single(0);return ta(n,i.length),e.staticFacet(Vs)||(n=n.asSingle()),new V(e,i,n,e.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(V.tabSize)}get lineBreak(){return this.facet(V.lineSeparator)||`
|
|
5
|
+
`}get readOnly(){return this.facet(la)}phrase(t,...e){for(let i of this.facet(V.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let r=+(n||1);return!r||r>e.length?i:e[r-1]})),t}languageDataAt(t,e,i=-1){let n=[];for(let r of this.facet(ia))for(let o of r(this,e,i))Object.prototype.hasOwnProperty.call(o,t)&&n.push(o[t]);return n}charCategorizer(t){let e=this.languageDataAt("wordChars",t);return rf(e.length?e[0]:"")}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),r=this.charCategorizer(t),o=t-i,l=t-i;for(;o>0;){let a=lt(e,o,!1);if(r(e.slice(a,o))!=Tt.Word)break;o=a}for(;l<n;){let a=lt(e,l);if(r(e.slice(l,a))!=Tt.Word)break;l=a}return o==l?null:x.range(o+i,l+i)}}V.allowMultipleSelections=Vs;V.tabSize=M.define({combine:s=>s.length?s[0]:4});V.lineSeparator=na;V.readOnly=la;V.phrases=M.define({compare(s,t){let e=Object.keys(s),i=Object.keys(t);return e.length==i.length&&e.every(n=>s[n]==t[n])}});V.languageData=ia;V.changeFilter=sa;V.transactionFilter=ra;V.transactionExtender=oa;$n.reconfigure=I.define();function he(s,t,e={}){let i={};for(let n of s)for(let r of Object.keys(n)){let o=n[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(e,r))i[r]=e[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let n in t)i[n]===void 0&&(i[n]=t[n]);return i}class ye{eq(t){return this==t}range(t,e=t){return qs.create(t,e,this)}}ye.prototype.startSide=ye.prototype.endSide=0;ye.prototype.point=!1;ye.prototype.mapMode=ft.TrackDel;function Or(s,t){return s==t||s.constructor==t.constructor&&s.eq(t)}let qs=class ca{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new ca(t,e,i)}};function js(s,t){return s.from-t.from||s.value.startSide-t.value.startSide}class Tr{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return Ve(this.to)}findIndex(t,e,i,n=0){let r=i?this.to:this.from;for(let o=n,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-t||(i?this.value[a].endSide:this.value[a].startSide)-e;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(t,e,i,n){for(let r=this.findIndex(e,-1e9,!0),o=this.findIndex(i,1e9,!1,r);r<o;r++)if(n(this.from[r]+t,this.to[r]+t,this.value[r])===!1)return!1}map(t,e,i,n,r){let o=[],l=[],a=[],h=-1,c=-1;t:for(let f=0;f<this.value.length;f++){let u=this.value[f],d=this.from[f]+t,p=this.to[f]+t,m,g;if(d==p){let y=e.mapPos(d,u.startSide,u.mapMode);if(y==null||(m=g=y,u.startSide!=u.endSide&&(g=e.mapPos(d,u.endSide),g<m)))continue}else if(m=e.mapPos(d,u.startSide),g=e.mapPos(p,u.endSide),m>g||m==g&&u.startSide>0&&u.endSide<=0)continue;if(!((g-m||u.endSide-u.startSide)<0))if(h<0&&(h=m),u.point&&(c=Math.max(c,g-m)),(m-i||u.startSide-n)>=0)o.push(u),l.push(m-h),a.push(g-h),i=g,n=u.endSide;else{if(m==g)for(let y=o.length;y>0;y--){if((m-(a[y-1]+h)||u.startSide-o[y-1].endSide)>=0){o.splice(y,0,u),l.splice(y,0,m-h),a.splice(y,0,g-h);continue t}if((m-(l[y-1]+h)||u.endSide-o[y-1].startSide)>0)break}r(m,g,u)}}return{mapped:o.length?new Tr(l,a,o,c):null,pos:h}}}class R{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new R(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=t,o=t.filter;if(e.length==0&&!o)return this;if(i&&(e=e.slice().sort(js)),this.isEmpty)return e.length?R.of(e):this;let l=new fa(this,null,-1).goto(0),a=0,h=[],c=new se;for(;l.value||a<e.length;)if(a<e.length&&(l.from-e[a].from||l.startSide-e[a].value.startSide)>=0){let f=e[a++];c.addInner(f.from,f.to,f.value,!1)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==e.length||this.chunkEnd(l.chunkIndex)<e[a].from)&&(!o||n>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||n>l.to||r<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value,!1)||h.push(qs.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?R.empty:this.nextLayer.update({add:h,filter:o,filterFrom:n,filterTo:r}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1,r,o=(a,h,c)=>{r||(r=new se),r.addRange(a,h,c,!1)};for(let a=0;a<this.chunk.length;a++){let h=this.chunkPos[a],c=this.chunk[a],f=t.touchesRange(h,h+c.length);if(f===!1)n=Math.max(n,c.maxPoint),e.push(c),i.push(t.mapPos(h));else if(f===!0){let[u,d]=e.length?[Ve(i)+Ve(e).length,Ve(Ve(e).value).endSide]:[-1,-1],{mapped:p,pos:m}=c.map(h,t,u,d,o);p&&(n=Math.max(n,p.maxPoint),e.push(p),i.push(m))}}let l=this.nextLayer.map(t);return r&&(l=r.finishInner(l)),e.length==0?l:new R(i,e,l||R.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],o=this.chunk[n];if(e>=r&&t<=r+o.length&&o.between(r,t-r,e-r,i)===!1)return}this.nextLayer.between(t,e,i)}}iter(t=0){return vi.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return vi.from(t).goto(e)}static compare(t,e,i,n,r=-1){let o=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=co(o,l,i),h=new li(o,a,r),c=new li(l,a,r);i.iterGaps((f,u,d)=>fo(h,f,c,u,d,n)),i.empty&&i.length==0&&fo(h,0,c,0,0,n)}static eq(t,e,i=0,n){n==null&&(n=999999999);let r=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0),o=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=co(r,o),a=new li(r,l,0).goto(i),h=new li(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Ks(a.active,h.active)||a.point&&(!h.point||!Or(a.point,h.point)))return!1;if(a.to>n)return!0;a.next(),h.next()}}static spans(t,e,i,n,r=-1){let o=new li(t,null,r).goto(e),l=e,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<e?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);n.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(n.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(t,e=!1){let i=new se;for(let n of t instanceof qs?[t]:e?of(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return R.empty;let e=Ve(t);for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=R.empty;n=n.nextLayer)e=new R(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}R.empty=new R([],[],null,-1);function Ve(s){return s[s.length-1]}function of(s){if(s.length>1)for(let t=s[0],e=1;e<s.length;e++){let i=s[e];if(js(t,i)>0)return s.slice().sort(js);t=i}return s}R.empty.nextLayer=R.empty;class se{finishChunk(t){this.chunks.push(new Tr(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,t&&(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(t,e,i){this.addRange(t,e,i,!0)}addRange(t,e,i,n){this.addInner(t,e,i,n)||(this.nextLayer||(this.nextLayer=new se)).addRange(t,e,i,n)}addInner(t,e,i,n){let r=t-this.lastTo||i.startSide-this.last.endSide;if(n&&r<=0&&(t-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=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(R.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let e=R.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function co(s,t,e){let i=new Map;for(let r of s)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&i.set(r.chunk[o],r.chunkPos[o]);let n=new Set;for(let r of t)for(let o=0;o<r.chunk.length;o++){let l=i.get(r.chunk[o]);l!=null&&(e?e.mapPos(l):l)==r.chunkPos[o]&&!e?.touchesRange(l,l+r.chunk[o].length)&&n.add(r.chunk[o])}return n}class fa{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<t||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==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=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class vi{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let r=0;r<t.length;r++)for(let o=t[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new fa(o,e,i,r));return n.length==1?n[0]:new vi(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let i=this.heap.length>>1;i>=0;i--)ls(this.heap,i);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let i=this.heap.length>>1;i>=0;i--)ls(this.heap,i);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),ls(this.heap,0)}}}function ls(s,t){for(let e=s[t];;){let i=(t<<1)+1;if(i>=s.length)break;let n=s[i];if(i+1<s.length&&n.compare(s[i+1])>=0&&(n=s[i+1],i++),e.compare(n)<0)break;s[i]=e,s[t]=n,t=i}}class li{constructor(t,e,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=vi.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){zi(this.active,t),zi(this.activeTo,t),zi(this.activeRank,t),this.minActive=uo(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:r}=this.cursor;for(;e<this.activeRank.length&&(r-this.activeRank[e]||n-this.activeTo[e])>0;)e++;$i(this.active,e,i),$i(this.activeTo,e,n),$i(this.activeRank,e,r),t&&$i(t,e,this.cursor.from),this.minActive=uo(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&zi(i,n)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.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 n=i.length-1;n>=0&&i[n]<t;n--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function fo(s,t,e,i,n,r){s.goto(t),e.goto(i);let o=i+n,l=i,a=i-t,h=!!r.boundChange;for(let c=!1;;){let f=s.to+a-e.to,u=f||s.endSide-e.endSide,d=u<0?s.to+a:e.to,p=Math.min(d,o);if(s.point||e.point?(s.point&&e.point&&Or(s.point,e.point)&&Ks(s.activeForPoint(s.to),e.activeForPoint(e.to))||r.comparePoint(l,p,s.point,e.point),c=!1):(c&&r.boundChange(l),p>l&&!Ks(s.active,e.active)&&r.compareRange(l,p,s.active,e.active),h&&p<o&&(f||s.openEnd(d)!=e.openEnd(d))&&(c=!0)),d>o)break;l=d,u<=0&&s.next(),u>=0&&e.next()}}function Ks(s,t){if(s.length!=t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!=t[e]&&!Or(s[e],t[e]))return!1;return!0}function zi(s,t){for(let e=t,i=s.length-1;e<i;e++)s[e]=s[e+1];s.pop()}function $i(s,t,e){for(let i=s.length-1;i>=t;i--)s[i+1]=s[i];s[t]=e}function uo(s,t){let e=-1,i=1e9;for(let n=0;n<t.length;n++)(t[n]-i||s[n].endSide-s[e].endSide)<0&&(e=n,i=t[n]);return e}function Li(s,t,e=s.length){let i=0;for(let n=0;n<e&&n<s.length;)s.charCodeAt(n)==9?(i+=t-i%t,n++):(i++,n=lt(s,n));return i}function lf(s,t,e,i){for(let n=0,r=0;;){if(r>=t)return n;if(n==s.length)break;r+=s.charCodeAt(n)==9?e-r%e:1,n=lt(s,n)}return s.length}const Us="ͼ",po=typeof Symbol>"u"?"__"+Us:Symbol.for(Us),Gs=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),mo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class be{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(n(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in t)r(n(o),t[o],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
+
`)}static newName(){let t=mo[po]||1;return mo[po]=t+1,Us+t.toString(36)}static mount(t,e,i){let n=t[Gs],r=i&&i.nonce;n?r&&n.setNonce(r):n=new af(t,r),n.mount(Array.isArray(e)?e:[e],t)}}let go=new Map;class af{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let r=go.get(i);if(r)return t[Gs]=r;this.sheet=new n.CSSStyleSheet,go.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[Gs]=this}mount(t,e){let i=this.sheet,n=0,r=0;for(let o=0;o<t.length;o++){let l=t[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),i)for(let h=0;h<l.rules.length;h++)i.insertRule(l.rules[h],n++)}else{for(;r<a;)n+=this.modules[r++].rules.length;n+=l.rules.length,r++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
|
|
7
|
+
`;this.styleTag.textContent=o;let l=e.head||e;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var xe={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:"'"},Si={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},hf=typeof navigator<"u"&&/Mac/.test(navigator.platform),cf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var it=0;it<10;it++)xe[48+it]=xe[96+it]=String(it);for(var it=1;it<=24;it++)xe[it+111]="F"+it;for(var it=65;it<=90;it++)xe[it]=String.fromCharCode(it+32),Si[it]=String.fromCharCode(it);for(var as in xe)Si.hasOwnProperty(as)||(Si[as]=xe[as]);function ff(s){var t=hf&&s.metaKey&&s.shiftKey&&!s.ctrlKey&&!s.altKey||cf&&s.shiftKey&&s.key&&s.key.length==1||s.key=="Unidentified",e=!t&&s.key||(s.shiftKey?Si:xe)[s.keyCode]||s.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}function Gt(){var s=arguments[0];typeof s=="string"&&(s=document.createElement(s));var t=1,e=arguments[1];if(e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)){for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var n=e[i];typeof n=="string"?s.setAttribute(i,n):n!=null&&(s[i]=n)}t++}for(;t<arguments.length;t++)ua(s,arguments[t]);return s}function ua(s,t){if(typeof t=="string")s.appendChild(document.createTextNode(t));else if(t!=null)if(t.nodeType!=null)s.appendChild(t);else if(Array.isArray(t))for(var e=0;e<t.length;e++)ua(s,t[e]);else throw new RangeError("Unsupported child node: "+t)}let ct=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ys=typeof document<"u"?document:{documentElement:{style:{}}};const Qs=/Edge\/(\d+)/.exec(ct.userAgent),da=/MSIE \d/.test(ct.userAgent),Xs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ct.userAgent),qn=!!(da||Xs||Qs),yo=!qn&&/gecko\/(\d+)/i.test(ct.userAgent),hs=!qn&&/Chrome\/(\d+)/.exec(ct.userAgent),bo="webkitFontSmoothing"in Ys.documentElement.style,_s=!qn&&/Apple Computer/.test(ct.vendor),xo=_s&&(/Mobile\/\w+/.test(ct.userAgent)||ct.maxTouchPoints>2);var A={mac:xo||/Mac/.test(ct.platform),windows:/Win/.test(ct.platform),linux:/Linux|X11/.test(ct.platform),ie:qn,ie_version:da?Ys.documentMode||6:Xs?+Xs[1]:Qs?+Qs[1]:0,gecko:yo,gecko_version:yo?+(/Firefox\/(\d+)/.exec(ct.userAgent)||[0,0])[1]:0,chrome:!!hs,chrome_version:hs?+hs[1]:0,ios:xo,android:/Android\b/.test(ct.userAgent),webkit:bo,webkit_version:bo?+(/\bAppleWebKit\/(\d+)/.exec(ct.userAgent)||[0,0])[1]:0,safari:_s,safari_version:_s?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ct.userAgent)||[0,0])[1]:0,tabSize:Ys.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Dr(s,t){for(let e in s)e=="class"&&t.class?t.class+=" "+s.class:e=="style"&&t.style?t.style+=";"+s.style:t[e]=s[e];return t}const wn=Object.create(null);function Br(s,t,e){if(s==t)return!0;s||(s=wn),t||(t=wn);let i=Object.keys(s),n=Object.keys(t);if(i.length-0!=n.length-0)return!1;for(let r of i)if(r!=e&&(n.indexOf(r)==-1||s[r]!==t[r]))return!1;return!0}function uf(s,t){for(let e=s.attributes.length-1;e>=0;e--){let i=s.attributes[e].name;t[i]==null&&s.removeAttribute(i)}for(let e in t){let i=t[e];e=="style"?s.style.cssText=i:s.getAttribute(e)!=i&&s.setAttribute(e,i)}}function wo(s,t,e){let i=!1;if(t)for(let n in t)e&&n in e||(i=!0,n=="style"?s.style.cssText="":s.removeAttribute(n));if(e)for(let n in e)t&&t[n]==e[n]||(i=!0,n=="style"?s.style.cssText=e[n]:s.setAttribute(n,e[n]));return i}function df(s){let t=Object.create(null);for(let e=0;e<s.attributes.length;e++){let i=s.attributes[e];t[i.name]=i.value}return t}class ce{eq(t){return!1}updateDOM(t,e,i){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var nt=(function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s})(nt||(nt={}));class H extends ye{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new Ei(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Ie(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,n;if(t.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:o}=pa(t,e);i=(r?e?-3e8:-1:5e8)-1,n=(o?e?2e8:1:-6e8)+1}return new Ie(t,i,n,e,t.widget||null,!0)}static line(t){return new Ii(t)}static set(t,e=!1){return R.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}H.none=R.empty;class Ei extends H{constructor(t){let{start:e,end:i}=pa(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?Dr(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||wn}eq(t){return this==t||t instanceof Ei&&this.tagName==t.tagName&&Br(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Ei.prototype.point=!1;class Ii extends H{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Ii&&this.spec.class==t.spec.class&&Br(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}Ii.prototype.mapMode=ft.TrackBefore;Ii.prototype.point=!0;class Ie extends H{constructor(t,e,i,n,r,o){super(e,i,r,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?ft.TrackBefore:ft.TrackAfter:ft.TrackDel}get type(){return this.startSide!=this.endSide?nt.WidgetRange:this.startSide<=0?nt.WidgetBefore:nt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Ie&&pf(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}Ie.prototype.point=!0;function pa(s,t=!1){let{inclusiveStart:e,inclusiveEnd:i}=s;return e==null&&(e=s.inclusive),i==null&&(i=s.inclusive),{start:e??t,end:i??t}}function pf(s,t){return s==t||!!(s&&t&&s.compare(t))}function Ge(s,t,e,i=0){let n=e.length-1;n>=0&&e[n]+i>=s?e[n]=Math.max(e[n],t):e.push(s,t)}class Ci extends ye{constructor(t,e,i){super(),this.tagName=t,this.attributes=e,this.rank=i}eq(t){return t==this||t instanceof Ci&&this.tagName==t.tagName&&Br(this.attributes,t.attributes)}static create(t){return new Ci(t.tagName,t.attributes||wn,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(t,e=!1){return R.of(t,e)}}Ci.prototype.startSide=Ci.prototype.endSide=-1;function Ai(s){let t;return s.nodeType==11?t=s.getSelection?s:s.ownerDocument:t=s,t.getSelection()}function Js(s,t){return t?s==t||s.contains(t.nodeType!=1?t.parentNode:t):!1}function mi(s,t){if(!t.anchorNode)return!1;try{return Js(s,t.anchorNode)}catch{return!1}}function fn(s){return s.nodeType==3?Mi(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function gi(s,t,e,i){return e?ko(s,t,e,i,-1)||ko(s,t,e,i,1):!1}function we(s){for(var t=0;;t++)if(s=s.previousSibling,!s)return t}function kn(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName)}function ko(s,t,e,i,n){for(;;){if(s==e&&t==i)return!0;if(t==(n<0?0:oe(s))){if(s.nodeName=="DIV")return!1;let r=s.parentNode;if(!r||r.nodeType!=1)return!1;t=we(s)+(n<0?0:1),s=r}else if(s.nodeType==1){if(s=s.childNodes[t+(n<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;t=n<0?oe(s):0}else return!1}}function oe(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function vn(s,t){let{left:e,right:i}=s;if(e==i)return s;let n=t?e:i;return{left:n,right:n,top:s.top,bottom:s.bottom}}function mf(s){let t=s.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function ma(s,t){let e=t.width/s.offsetWidth,i=t.height/s.offsetHeight;return(e>.995&&e<1.005||!isFinite(e)||Math.abs(t.width-s.offsetWidth)<1)&&(e=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-s.offsetHeight)<1)&&(i=1),{scaleX:e,scaleY:i}}function gf(s,t,e,i,n,r,o,l){let a=s.ownerDocument,h=a.defaultView||window;for(let c=s,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,p=1,m=1;if(d)u=mf(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 w=c.getBoundingClientRect();({scaleX:p,scaleY:m}=ma(c,w)),u={left:w.left,right:w.left+c.clientWidth*p,top:w.top,bottom:w.top+c.clientHeight*m}}let g=0,y=0;if(n=="nearest")t.top<u.top+o?(y=t.top-(u.top+o),e>0&&t.bottom>u.bottom+y&&(y=t.bottom-u.bottom+o)):t.bottom>u.bottom-o&&(y=t.bottom-u.bottom+o,e<0&&t.top-y<u.top&&(y=t.top-(u.top+o)));else{let w=t.bottom-t.top,b=u.bottom-u.top;y=(n=="center"&&w<=b?t.top+w/2-b/2:n=="start"||n=="center"&&e<0?t.top-o:t.bottom-b+o)-u.top}if(i=="nearest"?t.left<u.left+r?(g=t.left-(u.left+r),e>0&&t.right>u.right+g&&(g=t.right-u.right+r)):t.right>u.right-r&&(g=t.right-u.right+r,e<0&&t.left<u.left+g&&(g=t.left-(u.left+r))):g=(i=="center"?t.left+(t.right-t.left)/2-(u.right-u.left)/2:i=="start"==l?t.left-r:t.right-(u.right-u.left)+r)-u.left,g||y)if(d)h.scrollBy(g,y);else{let w=0,b=0;if(y){let O=c.scrollTop;c.scrollTop+=y/m,b=(c.scrollTop-O)*m}if(g){let O=c.scrollLeft;c.scrollLeft+=g/p,w=(c.scrollLeft-O)*p}t={left:t.left-w,top:t.top-b,right:t.right-w,bottom:t.bottom-b},w&&Math.abs(w-g)<1&&(i="nearest"),b&&Math.abs(b-y)<1&&(n="nearest")}if(d)break;(t.top<u.top||t.bottom>u.bottom||t.left<u.left||t.right>u.right)&&(t={left:Math.max(t.left,u.left),right:Math.min(t.right,u.right),top:Math.max(t.top,u.top),bottom:Math.min(t.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function ga(s,t=!0){let e=s.ownerDocument,i=null,n=null;for(let r=s.parentNode;r&&!(r==e.body||(!t||i)&&n);)if(r.nodeType==1)!n&&r.scrollHeight>r.clientHeight&&(n=r),t&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:n}}class yf{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?oe(e):0),i,Math.min(t.focusOffset,i?oe(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}function ya(s){let t=[];for(let e=s;e;e=e.nodeType==11?e.host:e.parentNode)e.nodeType==1&&t.push({node:e,left:e.scrollLeft,top:e.scrollTop});return t}function ba(s,t=!0){for(let{node:e,left:i,top:n}of s)t&&e.scrollTop!=n&&(e.scrollTop=n),e.scrollLeft!=i&&(e.scrollLeft=i)}let Oe=null;A.safari&&A.safari_version>=26&&(Oe=!1);function xa(s){if(s.setActive)return s.setActive();if(Oe)return s.focus(Oe);let t=ya(s);s.focus(Oe==null?{get preventScroll(){return Oe={preventScroll:!0},!0}}:void 0),Oe||(Oe=!1,ba(t))}let vo;function Mi(s,t,e=t){let i=vo||(vo=document.createRange());return i.setEnd(s,e),i.setStart(s,t),i}function Ye(s,t,e,i){let n={key:t,code:t,keyCode:e,which:e,cancelable:!0};i&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=i);let r=new KeyboardEvent("keydown",n);r.synthetic=!0,s.dispatchEvent(r);let o=new KeyboardEvent("keyup",n);return o.synthetic=!0,s.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function bf(s){for(;s;){if(s&&(s.nodeType==9||s.nodeType==11&&s.host))return s;s=s.assignedSlot||s.parentNode}return null}function xf(s,t){let e=t.focusNode,i=t.focusOffset;if(!e||t.anchorNode!=e||t.anchorOffset!=i)return!1;for(i=Math.min(i,oe(e));;)if(i){if(e.nodeType!=1)return!1;let n=e.childNodes[i-1];n.contentEditable=="false"?i--:(e=n,i=oe(e))}else{if(e==s)return!0;i=we(e),e=e.parentNode}}function wa(s){return s instanceof Window?s.pageYOffset>Math.max(0,s.document.documentElement.scrollHeight-s.innerHeight-4):s.scrollTop>Math.max(1,s.scrollHeight-s.clientHeight-4)}function ka(s,t){for(let e=s,i=t;;){if(e.nodeType==3&&i>0)return{node:e,offset:i};if(e.nodeType==1&&i>0){if(e.contentEditable=="false")return null;e=e.childNodes[i-1],i=oe(e)}else if(e.parentNode&&!kn(e))i=we(e),e=e.parentNode;else return null}}function va(s,t){for(let e=s,i=t;;){if(e.nodeType==3&&i<e.nodeValue.length)return{node:e,offset:i};if(e.nodeType==1&&i<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[i],i=0}else if(e.parentNode&&!kn(e))i=we(e)+1,e=e.parentNode;else return null}}class It{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new It(t.parentNode,we(t),e)}static after(t,e){return new It(t.parentNode,we(t)+1,e)}}var j=(function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s})(j||(j={}));const Ne=j.LTR,Pr=j.RTL;function Sa(s){let t=[];for(let e=0;e<s.length;e++)t.push(1<<+s[e]);return t}const wf=Sa("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),kf=Sa("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Zs=Object.create(null),$t=[];for(let s of["()","[]","{}"]){let t=s.charCodeAt(0),e=s.charCodeAt(1);Zs[t]=e,Zs[e]=-t}function Ca(s){return s<=247?wf[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?kf[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1}const vf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Qt{get dir(){return this.level%2?Pr:Ne}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let r=-1;for(let o=0;o<t.length;o++){let l=t[o];if(l.from<=e&&l.to>=e){if(l.level==i)return o;(r<0||(n!=0?n<0?l.from<e:l.to>e:t[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function Aa(s,t){if(s.length!=t.length)return!1;for(let e=0;e<s.length;e++){let i=s[e],n=t[e];if(i.from!=n.from||i.to!=n.to||i.direction!=n.direction||!Aa(i.inner,n.inner))return!1}return!0}const q=[];function Sf(s,t,e,i,n){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:t,l=r<i.length?i[r].from:e,a=r?256:n;for(let h=o,c=a,f=a;h<l;h++){let u=Ca(s.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),q[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=q[h];if(u==128)h<l-1&&c==q[h+1]&&c&24?u=q[h]=c:q[h]=256;else if(u==64){let d=h+1;for(;d<l&&q[d]==64;)d++;let p=h&&c==8||d<e&&q[d]==8?f==1?1:8:256;for(let m=h;m<d;m++)q[m]=p;h=d-1}else u==8&&f==1&&(q[h]=1);c=u,u&7&&(f=u)}}}function Cf(s,t,e,i,n){let r=n==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:t,c=o<i.length?i[o].from:e;for(let f=h,u,d,p;f<c;f++)if(d=Zs[u=s.charCodeAt(f)])if(d<0){for(let m=l-3;m>=0;m-=3)if($t[m+1]==-d){let g=$t[m+2],y=g&2?n:g&4?g&1?r:n:0;y&&(q[f]=q[$t[m]]=y),l=m;break}}else{if($t.length==189)break;$t[l++]=f,$t[l++]=u,$t[l++]=a}else if((p=q[f])==2||p==1){let m=p==n;a=m?0:1;for(let g=l-3;g>=0;g-=3){let y=$t[g+2];if(y&2)break;if(m)$t[g+2]|=2;else{if(y&4)break;$t[g+2]|=4}}}}}function Af(s,t,e,i){for(let n=0,r=i;n<=e.length;n++){let o=n?e[n-1].to:s,l=n<e.length?e[n].from:t;for(let a=o;a<l;){let h=q[a];if(h==256){let c=a+1;for(;;)if(c==l){if(n==e.length)break;c=e[n++].to,l=n<e.length?e[n].from:t}else if(q[c]==256)c++;else break;let f=r==1,u=(c<t?q[c]:i)==1,d=f==u?f?1:2:i;for(let p=c,m=n,g=m?e[m-1].to:s;p>a;)p==g&&(p=e[--m].from,g=m?e[m-1].to:s),q[--p]=d;a=c}else r=h,a++}}}function tr(s,t,e,i,n,r,o){let l=i%2?2:1;if(i%2==n%2)for(let a=t,h=0;a<e;){let c=!0,f=!1;if(h==r.length||a<r[h].from){let m=q[a];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;t:for(;;)if(h<r.length&&p==r[h].from){if(f)break t;let m=r[h];if(!c)for(let g=m.to,y=h+1;;){if(g==e)break t;if(y<r.length&&r[y].from==g)g=r[y++].to;else{if(q[g]==l)break t;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new Qt(a,m.from,d));let g=m.direction==Ne!=!(d%2);er(s,g?i+1:i,n,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==e||(c?q[p]!=l:q[p]==l))break;p++}u?tr(s,a,p,i+1,n,u,o):a<p&&o.push(new Qt(a,p,d)),a=p}else for(let a=e,h=r.length;a>t;){let c=!0,f=!1;if(!h||a>r[h-1].to){let m=q[a-1];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;t:for(;;)if(h&&p==r[h-1].to){if(f)break t;let m=r[--h];if(!c)for(let g=m.from,y=h;;){if(g==t)break t;if(y&&r[y-1].to==g)g=r[--y].from;else{if(q[g-1]==l)break t;break}}if(u)u.push(m);else{m.to<a&&o.push(new Qt(m.to,a,d));let g=m.direction==Ne!=!(d%2);er(s,g?i+1:i,n,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==t||(c?q[p-1]!=l:q[p-1]==l))break;p--}u?tr(s,p,a,i+1,n,u,o):p<a&&o.push(new Qt(p,a,d)),a=p}}function er(s,t,e,i,n,r,o){let l=t%2?2:1;Sf(s,n,r,i,l),Cf(s,n,r,i,l),Af(n,r,i,l),tr(s,n,r,t,e,i,o)}function Mf(s,t,e){if(!s)return[new Qt(0,0,t==Pr?1:0)];if(t==Ne&&!e.length&&!vf.test(s))return Ma(s.length);if(e.length)for(;s.length>q.length;)q[q.length]=256;let i=[],n=t==Ne?0:1;return er(s,n,n,e,0,s.length,i),i}function Ma(s){return[new Qt(0,s,0)]}let Oa="";function Of(s,t,e,i,n){var r;let o=i.head-s.from,l=Qt.find(t,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=t[l],h=a.side(n,e);if(o==h){let u=l+=n?1:-1;if(u<0||u>=t.length)return null;a=t[l=u],o=a.side(!n,e),h=a.side(n,e)}let c=lt(s.text,o,a.forward(n,e));(c<a.from||c>a.to)&&(c=h),Oa=s.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(n?t.length-1:0)?null:t[l+(n?1:-1)];return f&&c==h&&f.level+(n?0:1)<a.level?x.cursor(f.side(!n,e)+s.from,f.forward(n,e)?1:-1,f.level):x.cursor(c+s.from,a.forward(n,e)?-1:1,a.level)}function Tf(s,t,e){for(let i=t;i<e;i++){let n=Ca(s.charCodeAt(i));if(n==1)return Ne;if(n==2||n==4)return Pr}return Ne}const Ta=M.define(),Da=M.define(),Ba=M.define(),Pa=M.define(),ir=M.define(),Ra=M.define(),La=M.define(),Rr=M.define(),Lr=M.define(),Ea=M.define({combine:s=>s.some(t=>t)}),Ia=M.define({combine:s=>s.some(t=>t)}),Na=M.define();class Qe{constructor(t,e,i,n,r,o=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=o}map(t){return t.empty?this:new Qe(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new Qe(x.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const qi=I.define({map:(s,t)=>s.map(t)}),Ha=I.define();function ut(s,t,e){let i=s.facet(Pa);i.length?i[0](t):window.onerror&&window.onerror(String(t),e,void 0,void 0,t)||(e?console.error(e+":",t):console.error(t))}const ne=M.define({combine:s=>s.length?s[0]:!0});let Df=0;const $e=M.define({combine(s){return s.filter((t,e)=>{for(let i=0;i<e;i++)if(s[i].plugin==t.plugin)return!1;return!0})}});class st{constructor(t,e,i,n,r){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat($e.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat($e.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:r,decorations:o}=e||{};return new st(Df++,t,i,n,l=>{let a=[];return o&&a.push(jn.of(h=>{let c=h.plugin(l);return c?o(c):H.none})),r&&a.push(r(l)),a})}static fromClass(t,e){return st.define((i,n)=>new t(i,n),e)}}class cs{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(i){if(ut(e.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){ut(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(i){ut(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Wa=M.define(),Er=M.define(),jn=M.define(),Fa=M.define(),Ir=M.define(),Ni=M.define(),Va=M.define();function So(s,t){let e=s.state.facet(Va);if(!e.length)return e;let i=e.map(r=>r instanceof Function?r(s):r),n=[];return R.spans(i,t.from,t.to,{point(){},span(r,o,l,a){let h=r-t.from,c=o-t.from,f=n;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=Tf(t.text,h,c)),a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let m={from:h,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),n}const za=M.define();function Nr(s){let t=0,e=0,i=0,n=0;for(let r of s.state.facet(za)){let o=r(s);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(e=Math.max(e,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:t,right:e,top:i,bottom:n}}const fi=M.define();class Dt{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Dt(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(e.length==0)return t;let i=[];for(let n=0,r=0,o=0;;){let l=n<t.length?t[n].fromB:1e9,a=r<e.length?e[r]:1e9,h=Math.min(l,a);if(h==1e9)break;let c=h+o,f=h,u=c;for(;;)if(r<e.length&&e[r]<=f){let d=e[r+1];r+=2,f=Math.max(f,d);for(let p=n;p<t.length&&t[p].fromB<=f;p++)o=t[p].toA-t[p].toB;u=Math.max(u,d+o)}else if(n<t.length&&t[n].fromB<=f){let d=t[n++];f=Math.max(f,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new Dt(c,u,h,f))}return i}}class Sn{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=_.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,o,l,a)=>n.push(new Dt(r,o,l,a))),this.changedRanges=n}static create(t,e,i){return new Sn(t,e,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Bf=[];class Y{constructor(t,e,i=0){this.dom=t,this.length=e,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Bf}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&uf(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let i=e;for(let n of this.children){if(n==t)return i;i+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e,i){return null}domPosFor(t,e){let i=we(this.dom),n=this.length?t>0:e>0;return new It(this.parent.dom,i+(n?1:0),t==0||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof Un)return t;return null}static get(t){return t.cmTile}}class Kn extends Y{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(this.flags&2)return;super.sync(t);let e=this.dom,i=null,n,r=t?.node==e?t:null,o=0;for(let l of this.children){if(l.sync(t),o+=l.length+l.breakAfter,n=i?i.nextSibling:e.firstChild,r&&n!=l.dom&&(r.written=!0),l.dom.parentNode==e)for(;n&&n!=l.dom;)n=Co(n);else e.insertBefore(l.dom,n);i=l.dom}for(n=i?i.nextSibling:e.firstChild,r&&n&&(r.written=!0);n;)n=Co(n);this.length=o}}function Co(s){let t=s.nextSibling;return s.parentNode.removeChild(s),t}class Un extends Kn{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=Y.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],i=this,n=0,r=0;;)if(n==i.children.length){if(!e.length)return;i=i.parent,i.breakAfter&&r++,n=e.pop()}else{let o=i.children[n++];if(o instanceof re)e.push(n),i=o,n=0;else{let l=r+o.length,a=t(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(t,e){let i,n=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(t>=a&&t<=h){if(l.isWidget()&&e>=-1&&e<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<t||t==h&&(e<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,n=t-a),(h>t||t==a&&(e>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=t-a)}}),!i&&!r)throw new Error("No tile at position "+t);return i&&e<0||!r?{tile:i,offset:n}:{tile:r,offset:o}}}class re extends Kn{constructor(t,e){super(t),this.wrapper=e}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,e){let i=new re(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class Ze extends Kn{constructor(t,e){super(t),this.attrs=e}isLine(){return!0}static start(t,e,i){let n=new Ze(e||document.createElement("div"),t);return(!e||!i)&&(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(t,e,i){let n=null,r=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u<c.children.length&&d<=f;u++){let p=c.children[u],m=d+p.length;m>=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(e>0&&!(o.flags&32)||i&&Rf(o,p)))&&(m>f||p.flags&32&&e<=1)?(o=p,l=f-d):(d<f||p.flags&16&&!p.isHidden&&e>=-1)&&(n=p,r=f-d)),d=m}}a(this,t);let h=(e<0?n:o)||n||o;return h?{tile:h,offset:h==n?r:l}:null}coordsIn(t,e,i){let n=this.resolveInline(t,e,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),e,i):Pf(this)}domIn(t,e){let i=this.resolveInline(t,e);if(i){let{tile:n,offset:r}=i;if(this.dom.contains(n.dom))return n.isText()?new It(n.dom,Math.min(n.dom.nodeValue.length,r)):n.domPosFor(r,n.flags&16?1:n.flags&32?-1:e);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new It(a.dom,0);a==i.tile&&(l=!0)}}return new It(this.dom,0)}}function Pf(s){let t=s.dom.lastChild;if(!t)return s.dom.getBoundingClientRect();let e=fn(t);return e[e.length-1]||null}function Rf(s,t){let e=s.coordsIn(0,1),i=t.coordsIn(0,1);return e&&i&&i.top<e.bottom}class yt extends Kn{constructor(t,e){super(t),this.mark=e}get domAttrs(){return this.mark.attrs}static of(t,e){let i=new yt(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class Be extends Y{constructor(t,e){super(t,e.length),this.text=e}sync(t){this.flags&2||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,e,i){let n=this.dom.nodeValue.length;t>n&&(t=n);let r=t,o=t,l=0;t==0&&e<0||t==n&&e>=0?A.chrome||A.gecko||(t?(r--,l=1):o<n&&(o++,l=-1)):e<0?r--:o<n&&o++;let a=Mi(this.dom,r,o).getClientRects();if(!a.length)return null;let h=a[(l?l<0:e>=0)?0:a.length-1];return A.safari&&!l&&h.width==0&&(h=Array.prototype.find.call(a,c=>c.width)||h),i==null?h:vn(h,(l?l>0:e<0)==i)}static of(t,e){let i=new Be(e||document.createTextNode(t),t);return e||(i.flags|=2),i}}class He extends Y{constructor(t,e,i,n){super(t,e,n),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,e){return this.coordsInWidget(t,e,!1)}coordsInWidget(t,e,i){let n=this.widget.coordsAt(this.dom,t,e);if(n)return n;if(i)return vn(this.dom.getBoundingClientRect(),this.length?t==0:e<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:t>0;for(let a=l?r.length-1:0;o=r[a],!(t>0?a==0:a==r.length-1||o.top<o.bottom);a+=l?-1:1);return vn(o,!l)}}get overrideDOMText(){if(!this.length)return W.empty;let{root:t}=this;if(!t)return W.empty;let e=this.posAtStart;return t.view.state.doc.slice(e,e+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,e,i,n,r){return r||(r=t.toDOM(e),t.editable||(r.contentEditable="false")),new He(r,i,t,n)}}class Cn extends Y{constructor(t){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),super(e,0,t)}get isHidden(){return!0}get overrideDOMText(){return W.empty}coordsIn(t,e,i){let n=this.dom.getBoundingClientRect();return i==null?n:vn(n,e>0==i)}}class Lf{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,e,i){let{tile:n,index:r,beforeBreak:o,parents:l}=this;for(;t||e>0;)if(n.isComposite())if(o){if(!t)break;i&&i.break(),t--,o=!1}else if(r==n.children.length){if(!t&&!l.length)break;i&&i.leave(n),o=!!n.breakAfter,{tile:n,index:r}=l.pop(),r++}else{let a=n.children[r],h=a.breakAfter;(e>0?a.length<=t:a.length<t)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,r++,t-=a.length):(l.push({tile:n,index:r}),n=a,r=0,i&&a.isComposite()&&i.enter(a))}else{let a=n.length;if(r<a&&t){let h=Math.min(t,a-r);i&&i.skip(n,r,r+h),t-=h,r+=h}if(r==a)o=!!n.breakAfter,{tile:n,index:r}=l.pop(),r++;else if(!t)break}return this.tile=n,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Ef{constructor(t,e,i,n){this.from=t,this.to=e,this.wrapper=i,this.rank=n}}class If{constructor(t,e,i){this.cache=t,this.root=e,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(t,e,i,n){var r;this.flushBuffer();let o=this.ensureMarks(e,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+t.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new Be(l.dom,l.text+t);a.parent=o}else o.append(n||Be.of(t,(r=this.cache.find(Be))===null||r===void 0?void 0:r.dom));this.pos+=t.length,this.afterWidget=null}addComposition(t,e){let i=this.curLine;i.dom!=e.line.dom&&(i.setDOM(this.cache.reused.has(e.line)?fs(e.line.dom):e.line.dom),this.cache.reused.set(e.line,2));let n=i;for(let l=e.marks.length-1;l>=0;l--){let a=e.marks[l],h=n.lastChild;if(h instanceof yt&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(fs(a.dom)),n=h;else{if(this.cache.reused.get(a)){let f=Y.get(a.dom);f&&f.setDOM(fs(a.dom))}let c=yt.of(a.mark,a.dom);n.append(c),n=c}this.cache.reused.set(a,2)}let r=Y.get(t.text);r&&this.cache.reused.set(r,2);let o=new Be(t.text,t.text.nodeValue);o.flags|=8,this.pos=t.range.toB,n.append(o)}addInlineWidget(t,e,i){let n=this.afterWidget&&t.flags&48&&(this.afterWidget.flags&48)==(t.flags&48);n||this.flushBuffer();let r=this.ensureMarks(e,i);!n&&!(t.flags&16)&&r.append(this.getBuffer(1)),r.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,i){this.flushBuffer(),this.ensureMarks(e,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){let e=this.afterWidget||this.lastBlock;e.length+=t,this.pos+=t}addLineStart(t,e){var i;t||(t=$a);let n=Ze.start(t,e||((i=this.cache.find(Ze))===null||i===void 0?void 0:i.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var i;let n=this.curLine;for(let r=t.length-1;r>=0;r--){let o=t[r],l;if(e>0&&(l=n.lastChild)&&l instanceof yt&&l.mark.eq(o))n=l,e--;else{let a=yt.of(o,(i=this.cache.find(yt,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);n.append(a),n=a,e=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;(!t||!Ao(this.curLine,!1)||t.dom.nodeName!="BR"&&t.isWidget()&&!(A.ios&&Ao(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(us,0,32)||new He(us.toDOM(),0,us,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to<this.pos&&this.wrappers.splice(t,1);for(let t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){let e=t.rank*102+t.value.rank,i=new Ef(t.from,t.to,t.value,e),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-i.rank||this.wrappers[n-1].to-i.to)<0;)n--;this.wrappers.splice(n,0,i)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let i of this.wrappers){let n=e.lastChild;if(i.from<this.pos&&n instanceof re&&n.wrapper.eq(i.wrapper))e=n;else{let r=re.of(i.wrapper,(t=this.cache.find(re,o=>o.wrapper.eq(i.wrapper)))===null||t===void 0?void 0:t.dom);e.append(r),e=r}}return e}blockPosCovered(){let t=this.lastBlock;return t!=null&&!t.breakAfter&&(!t.isWidget()||(t.flags&160)>0)}getBuffer(t){let e=2|(t<0?16:32),i=this.cache.find(Cn,void 0,1);return i&&(i.flags=e),i||new Cn(e)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Nf{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:n,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=n;let l=this.textOff=Math.min(t,n.length);return r?null:n.slice(0,l)}let e=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,e);return this.textOff=e,i}}const An=[He,Ze,Be,yt,Cn,re,Un];for(let s=0;s<An.length;s++)An[s].bucket=s;class Hf{constructor(t){this.view=t,this.buckets=An.map(()=>[]),this.index=An.map(()=>0),this.reused=new Map}add(t){let e=t.constructor.bucket,i=this.buckets[e];i.length<6?i.push(t):i[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,i=2){let n=t.bucket,r=this.buckets[n],o=this.index[n];for(let l=0;l<r.length;l++){let a=(l+o)%r.length,h=r[a];if((!e||e(h))&&!this.reused.has(h))return r.splice(a,1),a<o&&this.index[n]--,this.reused.set(h,i),h}return null}findWidget(t,e,i){let n=this.buckets[0];if(n.length)for(let r=0,o=0;;r++){if(r==n.length){if(o)return null;o=1,r=0}let l=n[r];if(!this.reused.has(l)&&(o==0?l.widget.compare(t):l.widget.constructor==t.constructor&&t.updateDOM(l.dom,this.view,l.widget)))return n.splice(r,1),r<this.index[0]&&this.index[0]--,l.widget==t&&l.length==e&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new He(l.dom,e,t,l.flags&-498|i))}}reuse(t){return this.reused.set(t,1),t}maybeReuse(t,e=2){if(!this.reused.has(t))return this.reused.set(t,e),t.dom}clear(){for(let t=0;t<this.buckets.length;t++)this.buckets[t].length=this.index[t]=0}}class Wf{constructor(t,e,i,n,r){this.view=t,this.decorations=n,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new Hf(t),this.text=new Nf(t.state.doc),this.builder=new If(this.cache,new Un(t,t.contentDOM),R.iter(i)),this.cache.reused.set(e,2),this.old=new Lf(e),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(t,e){let i=e&&this.getCompositionContext(e.text);for(let n=0,r=0,o=0;;){let l=o<t.length?t[o++]:null,a=l?l.fromA:this.old.root.length;if(a>n){let h=a-n;this.preserve(h,!o,!l),n=a,r+=h}if(!l)break;e&&l.fromA<=e.range.fromA&&l.toA>=e.range.toA?(this.forward(l.fromA,e.range.fromA,e.range.fromA<e.range.toA?1:-1),this.emit(r,e.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(e,i),this.text.skip(e.range.toB-e.range.fromB),this.forward(e.range.fromA,l.toA),this.emit(e.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(r,l.toB)),r=l.toB,n=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,i){let n=zf(this.old),r=this.openMarks;this.old.advance(t,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?He.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,n,r),r=n.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,n,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),n,r)),r=n.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Cn)this.cache.add(o);else if(o instanceof yt)this.builder.ensureLine(null),this.builder.addMark(o,n,r),this.cache.reused.set(o,1),r=n.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof yt&&n.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?n.length&&(n.length=r=0):o instanceof yt&&(n.shift(),r=Math.min(r,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let i=null,n=this.builder,r=-1,o=R.spans(this.decorations,t,e,{point:(l,a,h,c,f,u)=>{if(h instanceof Ie){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=c.length,f>c.length)n.continueWidget(a-l);else{let d=h.widget||(h.block?ti.block:ti.inline),p=Ff(h),m=this.cache.findWidget(d,a-l,p)||He.of(d,this.view,a-l,p);h.block?(h.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(m)):(n.ensureLine(i),n.addInlineWidget(m,c,f))}i=null}else i=Vf(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;f<a;){let u=this.text.next(Math.min(512,a-f));u==null?(n.addLineStartIfNotCovered(i),n.addBreak(),f++):(n.ensureLine(i),n.addText(u,h,f==l?c:h.length),f+=u.length),i=null}r=h.length}});r>-1&&(this.openWidget=o>r),this.openWidget||n.addLineStartIfNotCovered(i),this.openMarks=o}forward(t,e,i=1){e-t<=10?this.old.advance(e-t,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(t){let e=[],i=null;for(let n=t.parentNode;;n=n.parentNode){let r=Y.get(n);if(n==this.view.contentDOM)break;r instanceof yt?e.push(r):r?.isLine()?i=r:r instanceof re||(n.nodeName=="DIV"&&!i&&n!=this.view.contentDOM?i=new Ze(n,$a):i||e.push(yt.of(new Ei({tagName:n.nodeName.toLowerCase(),attributes:df(n)}),n)))}return{line:i,marks:e}}}function Ao(s,t){let e=i=>{for(let n of i.children)if((t?n.isText():n.length)||e(n))return!0;return!1};return e(s)}function Ff(s){let t=s.isReplace?(s.startSide<0?64:0)|(s.endSide>0?128:0):s.startSide>0?32:16;return s.block&&(t|=256),t}const $a={class:"cm-line"};function Vf(s,t){let e=t.spec.attributes,i=t.spec.class;return!e&&!i||(s||(s={class:"cm-line"}),e&&Dr(e,s),i&&(s.class+=" "+i)),s}function zf(s){let t=[];for(let e=s.parents.length;e>1;e--){let i=e==s.parents.length?s.tile:s.parents[e].tile;i instanceof yt&&t.push(i.mark)}return t}function fs(s){let t=Y.get(s);return t&&t.setDOM(s.cloneNode()),s}class ti extends ce{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}ti.inline=new ti("span");ti.block=new ti("div");const us=new class extends ce{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Mo{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=H.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Un(t,t.contentDOM),this.updateInner([new Dt(0,0,0,t.state.doc.length)],null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:f})=>f<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((e=this.domChanged)===null||e===void 0)&&e.newSel?n=this.domChanged.newSel.head:!Xf(t.changes,this.hasComposition)&&!t.selectionSet&&(n=t.state.selection.main.head));let r=n>-1?qf(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;i=new Dt(c,f,t.changes.mapPos(c,-1),t.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(A.ie||A.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=Uf(o,this.decorations,t.changes);a.length&&(i=Dt.extendWithRanges(i,a));let h=Yf(l,this.blockWrappers,t.changes);return h.length&&(i=Dt.extendWithRanges(i,h)),r&&!i.some(c=>c.fromA<=r.range.fromA&&c.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(e||t.length){let o=this.tile,l=new Wf(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);e&&Y.get(e.text)&&l.cache.reused.set(Y.get(e.text),2),this.tile=l.run(t,e),nr(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=A.chrome||A.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof ds&&n.push(r.dom);i.updateGaps(n)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let i of e.effects)i.is(Ha)&&(this.editContextFormatting=i.value)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,n=this.view.root.activeElement,r=n==i,o=!r&&!(this.view.state.facet(ne)||i.tabIndex>-1)&&mi(i,this.view.observer.selectionRange)&&!(n&&i.contains(n));if(!(r||e||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),A.gecko&&a.empty&&!this.hasComposition&&$f(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new It(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!gi(h.node,h.offset,f.anchorNode,f.anchorOffset)||!gi(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{A.android&&A.chrome&&i.contains(f.focusNode)&&Qf(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Ai(this.view.root);if(u)if(a.empty){if(A.gecko){let d=jf(h.node,h.offset);if(d&&d!=3){let p=(d==1?ka:va)(h.node,h.offset);p&&(h=new It(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new It(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new It(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&gi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Ai(t.root),{anchorNode:n,anchorOffset:r}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let o=this.lineAt(e.head,e.assoc);if(!o)return;let l=o.posAtStart;if(e.head==l||e.head==l+o.length)return;let a=this.coordsAt(e.head,-1),h=this.coordsAt(e.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(e.head+e.assoc,e.assoc);i.collapse(c.node,c.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let f=t.observer.selectionRange;t.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=e.from&&i.collapse(n,r)}posFromDOM(t,e){let i=this.tile.nearest(t);if(!i)return this.tile.dom.compareDocumentPosition(t)&2?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let r;if(t==i.dom)r=i.dom.childNodes[e];else{let o=oe(t)==0?0:e==0?-1:1;for(;;){let l=t.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(t==l.firstChild?o=-1:o=1),t=l}o<0?r=t:r=t.nextSibling}if(r==i.dom.firstChild)return n;for(;r&&!Y.get(r);)r=r.nextSibling;if(!r)return n+i.length;for(let o=0,l=n;;o++){let a=i.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return i.isText()?t==i.dom?n+e:n+(e?i.length:0):n}domAtPos(t,e){let{tile:i,offset:n}=this.tile.resolveBlock(t,e);return i.isWidget()?i.domPosFor(n,e):i.domIn(n,e)}inlineDOMNearPos(t,e){let i,n=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=t)return!0;h.flags&16&&(r=!0)}else{let f=c+h.length;if(c<=t&&(i=h,n=t-c,r=f<t),f>=t&&!o&&(o=h,l=t-c,a=c>t),c>t&&o)return!0}}),!i&&!o?this.domAtPos(t,e):(r&&o?i=null:a&&i&&(o=null),i&&e<0||!o?i.domIn(n,e):o.domIn(l,e))}coordsAt(t,e,i){let{tile:n,offset:r}=this.tile.resolveBlock(t,e);return n.isWidget()?n.widget instanceof ds?null:n.coordsInWidget(r,e,!0):n.coordsIn(r,e,i)}lineAt(t,e){let{tile:i}=this.tile.resolveBlock(t,e);return i.isLine()?i:null}coordsForChar(t){let{tile:e,offset:i}=this.tile.resolveBlock(t,1);if(!e.isLine())return null;function n(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=n(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&o<r.length){let l=lt(r.text,o);if(l==o)return null;let a=Mi(r.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(h==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return n(e,i)}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==j.LTR,h=0,c=(f,u,d)=>{for(let p=0;p<f.children.length&&!(u>n);p++){let m=f.children[p],g=u+m.length,y=m.dom.getBoundingClientRect(),{height:w}=y;if(d&&!p&&(h+=y.top-d.top),m instanceof re)g>i&&c(m,u,y);else if(u>=i&&(h>0&&e.push(-h),e.push(w+h),h=0,o)){let b=m.dom.lastChild,O=b?fn(b):[];if(O.length){let k=O[O.length-1],v=a?k.right-y.left:y.right-k.left;v>l&&(l=v,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==f.children.length-1&&(h+=d.bottom-y.bottom),u=g+m.breakAfter}};return c(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return getComputedStyle(e.dom).direction=="rtl"?j.RTL:j.LTR}measureTextSize(){let t=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=fn(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(t)return t;let e=document.createElement("div"),i,n,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.tile.dom.appendChild(e);let o=fn(e.firstChild)[0];i=e.getBoundingClientRect().height,n=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,e.remove()}),{lineHeight:i,charWidth:n,textHeight:r}}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let r=n==e.viewports.length?null:e.viewports[n],o=r?r.from-1:this.view.state.doc.length;if(o>i){let l=(e.lineBlockAt(o).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(H.replace({widget:new ds(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return H.set(t)}updateDeco(){let t=1,e=this.view.state.facet(jn).map(r=>(this.dynamicDecorationMap[t++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(Ir).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(R.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(Fa).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(t){if(t.isSnapshot){let h=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=h.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let h of this.view.state.facet(Na))try{if(h(this.view,t.range,t))return!0}catch(c){ut(this.view.state,c,"scroll handler")}let{range:e}=t,i=this.coordsAt(e.head,e.assoc||(e.head>e.anchor?-1:1)),n;if(!i)return;!e.empty&&(n=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=Nr(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(gf(this.view.scrollDOM,o,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,l),-l),Math.max(Math.min(t.yMargin,a),-a),this.view.textDirection==j.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(e.head,1);if(h){let c=ya(h.dom);h.dom.scrollIntoView({block:"nearest"}),ba(c,!1)}}}lineHasWidget(t){let e=i=>i.isWidget()||i.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){nr(this.tile)}}function nr(s,t){let e=t?.get(s);if(e!=1){e==null&&s.destroy();for(let i of s.children)nr(i,t)}}function $f(s){return s.node.nodeType==1&&s.node.firstChild&&(s.offset==0||s.node.childNodes[s.offset-1].contentEditable=="false")&&(s.offset==s.node.childNodes.length||s.node.childNodes[s.offset].contentEditable=="false")}function qa(s,t){let e=s.observer.selectionRange;if(!e.focusNode)return null;let i=ka(e.focusNode,e.focusOffset),n=va(e.focusNode,e.focusOffset),r=i||n;if(n&&i&&n.node!=i.node){let l=Y.get(n.node);if(!l||l.isText()&&l.text!=n.node.nodeValue)r=n;else if(s.docView.lastCompositionAfterCursor){let a=Y.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(r=n)}}if(s.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=t-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function qf(s,t,e){let i=qa(s,e);if(!i)return null;let{node:n,from:r,to:o}=i,l=n.nodeValue;if(/[\n\r]/.test(l)||s.state.doc.sliceString(i.from,i.to)!=l)return null;let a=t.invertedDesc;return{range:new Dt(a.mapPos(r),a.mapPos(o),r,o),text:n}}function jf(s,t){return s.nodeType!=1?0:(t&&s.childNodes[t-1].contentEditable=="false"?1:0)|(t<s.childNodes.length&&s.childNodes[t].contentEditable=="false"?2:0)}let Kf=class{constructor(){this.changes=[]}compareRange(t,e){Ge(t,e,this.changes)}comparePoint(t,e){Ge(t,e,this.changes)}boundChange(t){Ge(t,t,this.changes)}};function Uf(s,t,e){let i=new Kf;return R.compare(s,t,e,i),i.changes}class Gf{constructor(){this.changes=[]}compareRange(t,e){Ge(t,e,this.changes)}comparePoint(){}boundChange(t){Ge(t,t,this.changes)}}function Yf(s,t,e){let i=new Gf;return R.compare(s,t,e,i),i.changes}function Qf(s,t){for(let e=s;e&&e!=t;e=e.assignedSlot||e.parentNode)if(e.nodeType==1&&e.contentEditable=="false")return!0;return!1}function Xf(s,t){let e=!1;return t&&s.iterChangedRanges((i,n)=>{i<t.to&&n>t.from&&(e=!0)}),e}class ds extends ce{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function _f(s,t,e=1){let i=s.charCategorizer(t),n=s.doc.lineAt(t),r=t-n.from;if(n.length==0)return x.cursor(t);r==0?e=1:r==n.length&&(e=-1);let o=r,l=r;e<0?o=lt(n.text,r,!1):l=lt(n.text,r);let a=i(n.text.slice(o,l));for(;o>0;){let h=lt(n.text,o,!1);if(i(n.text.slice(h,o))!=a)break;o=h}for(;l<n.length;){let h=lt(n.text,l);if(i(n.text.slice(l,h))!=a)break;l=h}return x.undirectionalRange(o+n.from,l+n.from)}function Jf(s,t,e,i,n){let r=Math.round((i-t.left)*s.defaultCharacterWidth);if(s.lineWrapping&&e.height>s.defaultLineHeight*1.5){let l=s.viewState.heightOracle.textHeight,a=Math.floor((n-e.top-(s.defaultLineHeight-l)*.5)/l);r+=a*s.viewState.heightOracle.lineLength}let o=s.state.sliceDoc(e.from,e.to);return e.from+lf(o,r,s.state.tabSize)}function sr(s,t,e){let i=s.lineBlockAt(t);if(Array.isArray(i.type)){let n;for(let r of i.type){if(r.from>t)break;if(!(r.to<t)){if(r.from<t&&r.to>t)return r;(!n||r.type==nt.Text&&(n.type!=r.type||(e<0?r.from<t:r.to>t)))&&(n=r)}}return n||i}return i}function Zf(s,t,e,i){let n=sr(s,t.head,t.assoc||-1),r=!i||n.type!=nt.Text||!(s.lineWrapping||n.widgetLineBreaks)?null:s.coordsAtPos(t.assoc<0&&t.head>n.from?t.head-1:t.head);if(r){let o=s.dom.getBoundingClientRect(),l=s.textDirectionAt(n.from),a=s.posAtCoords({x:e==(l==j.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return x.cursor(a,e?-1:1)}return x.cursor(e?n.to:n.from,e?-1:1)}function Oo(s,t,e,i){let n=s.state.doc.lineAt(t.head),r=s.bidiSpans(n),o=s.textDirectionAt(n.from);for(let l=t,a=null;;){let h=Of(n,r,o,l,e),c=Oa;if(!h){if(n.number==(e?s.state.doc.lines:1))return l;c=`
|
|
8
|
+
`,n=s.state.doc.line(n.number+(e?1:-1)),r=s.bidiSpans(n),h=s.visualLineSide(n,!e)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function tu(s,t,e){let i=s.state.charCategorizer(t),n=i(e);return r=>{let o=i(r);return n==Tt.Space&&(n=o),n==o}}function eu(s,t,e,i){let n=t.head,r=e?1:-1;if(n==(e?s.state.doc.length:0))return x.cursor(n,t.assoc);let o=t.goalColumn,l,a=s.contentDOM.getBoundingClientRect(),h=s.coordsAtPos(n,t.assoc||((t.empty?e:t.head==t.from)?1:-1)),c=s.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=s.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,s.defaultCharacterWidth*(n-p.from))),l=(r<0?p.top:p.bottom)+c}let f=a.left+o,u=s.viewState.heightOracle.textHeight>>1,d=i??u;for(let p=0;;p+=u){let m=l+(d+p)*r,g=rr(s,{x:f,y:m},!1,r);if(e?m>a.bottom:m<a.top)return x.cursor(g.pos,g.assoc);let y=s.coordsAtPos(g.pos,g.assoc),w=y?(y.top+y.bottom)/2:0;if(!y||(e?w>l:w<l))return x.cursor(g.pos,g.assoc,void 0,o)}}function yi(s,t,e){for(;;){let i=0;for(let n of s)n.between(t-1,t+1,(r,o,l)=>{if(t>r&&t<o){let a=i||e||(t-r<o-t?-1:1);t=a<0?r:o,i=a}});if(!i)return t}}function ja(s,t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],r=null;if(n.empty){let o=yi(s,n.from,0);o!=n.from&&(r=x.cursor(o,-1))}else{let o=yi(s,n.from,-1),l=yi(s,n.to,1);(o!=n.from||l!=n.to)&&(n.undirectional?r=x.undirectionalRange(n.from,n.to):r=x.range(n.from==n.anchor?o:l,n.from==n.head?o:l))}r&&(e||(e=t.ranges.slice()),e[i]=r)}return e?x.create(e,t.mainIndex):t}function ps(s,t,e){let i=yi(s.state.facet(Ni).map(n=>n(s)),e.from,t.head>e.from?-1:1);return i==e.from?e:x.cursor(i,i<e.from?1:-1)}class Yt{constructor(t,e){this.pos=t,this.assoc=e}}function rr(s,t,e,i){let n=s.contentDOM.getBoundingClientRect(),r=n.top+s.viewState.paddingTop,{x:o,y:l}=t,a=l-r,h;for(;;){if(a<0)return new Yt(0,1);if(a>s.viewState.docHeight)return new Yt(s.state.doc.length,-1);if(h=s.elementAtHeight(a),i==null)break;if(h.type==nt.Text){if(i<0?h.to<s.viewport.from:h.from>s.viewport.to)break;let u=s.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+r:u.bottom>=a+r))break}let f=s.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+f:h.top-f}if(s.viewport.from>=h.to||s.viewport.to<=h.from){if(e)return null;if(h.type==nt.Text){let f=Jf(s,n,h,o,l);return new Yt(f,f==h.from?1:-1)}}if(h.type!=nt.Text)return a<(h.top+h.bottom)/2?new Yt(h.from,1):new Yt(h.to,-1);let c=s.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=s.docView.lineAt(h.from,-2)),new iu(s,o,l,s.textDirectionAt(h.from)).scanTile(c,h.from)}class iu{constructor(t,e,i,n){this.view=t,this.x=e,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to<t)&&(this.line=this.view.state.doc.lineAt(t),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(t,e){let{line:i,spans:n}=this.bidiSpansAt(t);return n[Qt.find(n,t-i.from,-1,e)].level==this.baseDir}dirAt(t,e){let{line:i,spans:n}=this.bidiSpansAt(t);return n[Qt.find(n,t-i.from,-1,e)].dir}bidiIn(t,e){let{spans:i,line:n}=this.bidiSpansAt(t);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<e)}scan(t,e,i=!1){let n=0,r=t.length-1,o=new Set,l=this.bidiIn(t[0],t[r]),a,h,c=-1,f=1e9,u;t:for(;n<r;){let p=r-n,m=n+r>>1;e:if(o.has(m)){for(let w=1;w<p;w++){let b=m+w;if(b>=r&&(b-=p),!o.has(b)){m=b;break e}}break t}o.add(m);let g=e(m),y=0;if(g)for(let w=0;w<g.length;w++){let b=g[w];if(!(b.width==0&&g.length>1))if(b.bottom<this.y)(!a||a.bottom<b.bottom)&&(a=b),y=1;else if(b.top>this.y)(!h||h.top>b.top)&&(h=b),y=-1;else{let O=b.left>this.x?this.x-b.left:b.right<this.x?this.x-b.right:0,k=Math.abs(O);k<f&&(c=m,f=k,u=b),O&&(y=O<0==(this.baseDir==j.LTR)?-1:1)}}y==-1&&(!l||this.baseDirAt(t[m],1))?r=m:y==1&&(!l||this.baseDirAt(t[m+1],-1))&&(n=m+1)}if(!u){if(!h&&!a)return{i:0,after:!1};let p=a&&(!h||this.y-a.bottom<h.top-this.y)?a:h;return this.y=(p.top+p.bottom)/2,this.scan(t,e,!0)}if(f&&!i){let{top:p,bottom:m}=u;if(a&&a.bottom>(p+p+m)/3)return this.y=a.bottom-1,this.scan(t,e,!0);if(h&&h.top<(p+m+m)/3)return this.y=h.top+1,this.scan(t,e,!0)}let d=(l?this.dirAt(t[c],1):this.baseDir)==j.LTR;return{i:c,after:this.x>(u.left+u.right)/2==d}}scanText(t,e){let i=[];for(let r=0;r<t.length;r=lt(t.text,r))i.push(e+r);i.push(e+t.length);let n=this.scan(i,r=>{let o=i[r]-e,l=i[r+1]-e;return Mi(t.dom,o,l).getClientRects()});return n.after?new Yt(i[n.i+1],-1):new Yt(i[n.i],1)}scanTile(t,e){if(!t.length)return new Yt(e,1);if(t.children.length==1){let l=t.children[0];if(l.isText())return this.scanText(l,e);if(l.isComposite())return this.scanTile(l,e)}let i=[e];for(let l=0,a=e;l<t.children.length;l++)i.push(a+=t.children[l].length);let n=this.scan(i,l=>{let a=t.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Mi(a.dom,0,a.length)).getClientRects()}),r=t.children[n.i],o=i[n.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):n.after?new Yt(i[n.i+1],-1):new Yt(o,1)}}const ze="";class nu{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(V.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=ze}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let r=this.text.length;this.readNode(n);let o=Y.get(n),l=n.nextSibling;if(l==e){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=Y.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:kn(n))||kn(l)&&(n.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!ru(l,e)&&this.lineBreak(),n=l}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(e))&&(r=l.index,o=l[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==t&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(t){let e=Y.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(su(t,i.node,i.offset)?e:0))}}function su(s,t,e){for(;;){if(!t||e<oe(t))return!1;if(t==s)return!0;e=we(t)+1,t=t.parentNode}}function ru(s,t){let e;for(;!(s==t||!s);s=s.nextSibling){let i=Y.get(s);if(!i?.isWidget())return!1;i&&(e||(e=[])).push(i)}if(e)for(let i of e){let n=i.overrideDOMText;if(n?.length)return!1}return!0}class To{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class ou{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:r,impreciseAnchor:o}=t.docView,l=t.state.selection;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=Ka(t.docView.tile,e,i,0))){let a=r||o?[]:au(t),h=new nu(a,t);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=hu(a,this.bounds.from)}else{let a=t.observer.selectionRange,h=r&&r.node==a.focusNode&&r.offset==a.focusOffset||!Js(t.contentDOM,a.focusNode)?l.main.head:t.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Js(t.contentDOM,a.anchorNode)?l.main.anchor:t.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=t.viewport;if((A.ios||A.chrome)&&h!=c&&Math.min(h,c)<=l.main.from&&Math.max(h,c)>=l.main.to&&(f.from>0||f.to<t.state.doc.length)){let u=Math.min(h,c),d=Math.max(h,c),p=f.from-u,m=f.to-d;(p==0||p==1||u==0)&&(m==0||m==-1||d==t.state.doc.length)&&(h=0,c=t.state.doc.length)}if(t.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(x.range(c,h));else if(t.lineWrapping&&c==h&&!(l.main.empty&&l.main.head==h)&&t.inputState.lastTouchTime>Date.now()-100){let u=t.coordsAtPos(h,-1),d=0;u&&(d=t.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=x.create([x.cursor(h,d)])}else this.newSel=x.single(c,h)}}}function Ka(s,t,e,i){if(s.isComposite()){let n=-1,r=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<s.children.length;a++){let f=s.children[a],u=h+f.length;if(h<t&&u>e)return Ka(f,t,e,h);if(u>=t&&n==-1&&(n=a,r=h),h>e&&f.dom.parentNode==s.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:r,to:l<0?i+s.length:l,startDOM:(n?s.children[n-1].dom.nextSibling:null)||s.dom.firstChild,endDOM:o<s.children.length&&o>=0?s.children[o].dom:null}}else return s.isText()?{from:i,to:i+s.length,startDOM:s.dom,endDOM:s.dom.nextSibling}:null}function Ua(s,t){let e,{newSel:i}=t,{state:n}=s,r=n.selection.main,o=s.inputState.lastKeyTime>Date.now()-100?s.inputState.lastKeyCode:-1;if(t.bounds){let{from:l,to:a}=t.bounds,h=r.from,c=null;(o===8||A.android&&t.text.length<a-l)&&(h=r.to,c="end");let f=n.doc.sliceString(l,a,ze),u,d;!r.empty&&r.from>=l&&r.to<=a&&(t.typeOver||f!=t.text)&&f.slice(0,r.from-l)==t.text.slice(0,r.from-l)&&f.slice(r.to-l)==t.text.slice(u=t.text.length-(f.length-(r.to-l)))?e={from:r.from,to:r.to,insert:W.of(t.text.slice(r.from-l,u).split(ze))}:(d=Ga(f,t.text,h-l,c))&&(A.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==ze+ze&&d.toB--,e={from:l+d.from,to:l+d.toA,insert:W.of(t.text.slice(d.from,d.toB).split(ze))})}else i&&(!s.hasFocus&&n.facet(ne)||Mn(i,r))&&(i=null);if(!e&&!i)return!1;if((A.mac||A.android)&&e&&e.from==e.to&&e.from==r.head-1&&/^\. ?$/.test(e.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&e.insert.length==2&&(i=x.single(i.main.anchor-1,i.main.head-1)),e={from:e.from,to:e.to,insert:W.of([e.insert.toString().replace("."," ")])}):n.doc.lineAt(r.from).to<r.to&&s.docView.lineHasWidget(r.to)&&s.inputState.insertingTextAt>Date.now()-50?e={from:r.from,to:r.to,insert:n.toText(s.inputState.insertingText)}:A.chrome&&e&&e.from==e.to&&e.from==r.head&&e.insert.toString()==`
|
|
9
|
+
`&&s.lineWrapping&&(i&&(i=x.single(i.main.anchor-1,i.main.head-1)),e={from:r.from,to:r.to,insert:W.of([" "])}),e)return Hr(s,e,i,o);if(i&&!Mn(i,r)){let l=!1,a="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(l=!0),a=s.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=ja(n.facet(Ni).map(h=>h(s)),i))),s.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function Hr(s,t,e,i=-1){if(A.ios&&s.inputState.flushIOSKey(t))return!0;let n=s.state.selection.main;if(A.android&&(t.to==n.to&&(t.from==n.from||t.from==n.from-1&&s.state.sliceDoc(t.from,n.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&Ye(s.contentDOM,"Enter",13)||(t.from==n.from-1&&t.to==n.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from&&t.to>n.head)&&Ye(s.contentDOM,"Backspace",8)||t.from==n.from&&t.to==n.to+1&&t.insert.length==0&&Ye(s.contentDOM,"Delete",46)))return!0;let r=t.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let o,l=()=>o||(o=lu(s,t,e));return s.state.facet(Ra).some(a=>a(s,t.from,t.to,r,l))||s.dispatch(l()),!0}function lu(s,t,e){let i,n=s.state,r=n.selection.main,o=-1;if(t.from==t.to&&t.from<r.from||t.from>r.to){let a=t.from<r.from?-1:1,h=a<0?r.from:r.to,c=yi(n.facet(Ni).map(f=>f(s)),h,a);t.from==c&&(o=c)}if(o>-1)i={changes:t,selection:x.cursor(t.from+t.insert.length,-1)};else if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&s.inputState.composing<0){let a=r.from<t.from?n.sliceDoc(r.from,t.from):"",h=r.to>t.to?n.sliceDoc(t.to,r.to):"";i=n.replaceSelection(s.state.toText(a+t.insert.sliceString(0,void 0,s.state.lineBreak)+h))}else{let a=n.changes(t),h=e&&e.main.to<=a.newLength?e.main:void 0;if(n.selection.ranges.length>1&&(s.inputState.composing>=0||s.inputState.compositionPendingChange)&&t.to<=r.to+10&&t.to>=r.to-10){let c=s.state.sliceDoc(t.from,t.to),f,u=e&&qa(s,e.main.head);if(u){let p=t.insert.length-(t.to-t.from);f={from:u.from,to:u.to-p}}else f=s.state.doc.lineAt(r.head);let d=r.to-t.to;i=n.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let m=p.to-d,g=m-c.length;if(s.state.sliceDoc(g,m)!=c||m>=f.from&&g<=f.to)return{range:p};let y=n.changes({from:g,to:m,insert:t.insert}),w=p.to-r.to;return{changes:y,range:h?x.range(Math.max(0,h.anchor+w),Math.max(0,h.head+w)):p.map(y)}})}else i={changes:a,selection:h&&n.selection.replaceRange(h)}}let l="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,l+=".compose",s.inputState.compositionFirstChange&&(l+=".start",s.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:l,scrollIntoView:!0})}function Ga(s,t,e,i){let n=Math.min(s.length,t.length),r=0;for(;r<n&&s.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==n&&s.length==t.length)return null;let o=s.length,l=t.length;for(;o>0&&l>0&&s.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));e-=o+a-r}if(o<r&&s.length<t.length){let a=e<=r&&e>=o?r-e:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=e<=r&&e>=l?r-e:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function au(s){let t=[];if(s.root.activeElement!=s.contentDOM)return t;let{anchorNode:e,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return e&&(t.push(new To(e,i)),(n!=e||r!=i)&&t.push(new To(n,r))),t}function hu(s,t){if(s.length==0)return null;let e=s[0].pos,i=s.length==2?s[1].pos:e;return e>-1&&i>-1?x.single(e+t,i+t):null}function Mn(s,t){return t.head==s.main.head&&t.anchor==s.main.anchor}class cu{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,A.safari&&t.contentDOM.addEventListener("input",()=>null),A.gecko&&Mu(t.contentDOM.ownerDocument)}handleEvent(t){!xu(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let n of i.observers)n(this.view,e);for(let n of i.handlers){if(e.defaultPrevented)break;if(n(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=uu(t),i=this.handlers,n=this.view.contentDOM;for(let r in e)if(r!="scroll"){let o=!e[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(n.removeEventListener(r,this.handleEvent),l=null),l||n.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!e[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&Qa.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),A.android&&A.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;if(A.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&(Ya.some(e=>e.keyCode==t.keyCode)&&!t.ctrlKey||du.indexOf(t.key)>-1&&t.ctrlKey)){let e={ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey,shiftKey:t.shiftKey};return e.shiftKey&&A.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&fu(this.view.win)&&(e.shiftKey=!1),this.pendingIOSKey={key:t.key,keyCode:t.keyCode,mods:e},setTimeout(()=>this.flushIOSKey(),50),!0}return t.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(t){let e=this.pendingIOSKey;return!e||this.view.observer.pendingRecords().length||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,Ye(this.view.contentDOM,e.key,e.keyCode,e.mods))}ignoreDuringComposition(t){return!/^key/.test(t.type)||t.synthetic?!1:this.composing>0?!0:A.safari&&!A.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function fu(s){return s.visualViewport?s.visualViewport.height*s.visualViewport.scale/s.document.documentElement.clientHeight<.85:!1}function Do(s,t){return(e,i)=>{try{return t.call(s,i,e)}catch(n){ut(e.state,n)}}}function uu(s){let t=Object.create(null);function e(i){return t[i]||(t[i]={observers:[],handlers:[]})}for(let i of s){let n=i.spec,r=n&&n.plugin.domEventHandlers,o=n&&n.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&e(l).handlers.push(Do(i.value,a))}if(o)for(let l in o){let a=o[l];a&&e(l).observers.push(Do(i.value,a))}}for(let i in Ht)e(i).handlers.push(Ht[i]);for(let i in pt)e(i).observers.push(pt[i]);return t}const Ya=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],du="dthko",Qa=[16,17,18,20,91,92,224,225],ji=6;function Ki(s){return Math.max(0,s)*.7+8}function pu(s,t){return Math.max(Math.abs(s.clientX-t.clientX),Math.abs(s.clientY-t.clientY))}class mu{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=ga(t.contentDOM),this.atoms=t.state.facet(Ni).map(o=>o(t));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(V.allowMultipleSelections)&&gu(t,e),this.dragging=bu(t,e)&&Ja(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&pu(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,i=0,n=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Nr(this.view);t.clientX-a.left<=n+ji?e=-Ki(n-t.clientX):t.clientX+a.right>=o-ji&&(e=Ki(t.clientX-o)),t.clientY-a.top<=r+ji?i=-Ki(r-t.clientY):t.clientY+a.bottom>=l-ji&&(i=Ki(t.clientY-l)),this.setScrollSpeed(e,i)}up(t){this.dragging==null&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=ja(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function gu(s,t){let e=s.state.facet(Ta);return e.length?e[0](t):A.mac?t.metaKey:t.ctrlKey}function yu(s,t){let e=s.state.facet(Da);return e.length?e[0](t):A.mac?!t.altKey:!t.ctrlKey}function bu(s,t){let{main:e}=s.state.selection;if(e.empty)return!1;let i=Ai(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r<n.length;r++){let o=n[r];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function xu(s,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,i;e!=s.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(i=Y.get(e))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(t))return!1;return!0}const Ht=Object.create(null),pt=Object.create(null),Xa=A.ie&&A.ie_version<15||A.ios&&A.webkit_version<604;function wu(s){let t=s.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{s.focus(),e.remove(),_a(s,e.value)},50)}function Gn(s,t,e){for(let i of s.facet(t))e=i(e,s);return e}function _a(s,t){t=Gn(s.state,Rr,t);let{state:e}=s,i,n=1,r=e.toText(t),o=r.lines==e.selection.ranges.length;if(or!=null&&e.selection.ranges.every(a=>a.empty)&&or==r.toString()){let a=-1;i=e.changeByRange(h=>{let c=e.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=e.toText((o?r.line(n++).text:t)+e.lineBreak);return{changes:{from:c.from,insert:f},range:x.cursor(h.from+f.length)}})}else o?i=e.changeByRange(a=>{let h=r.line(n++);return{changes:{from:a.from,to:a.to,insert:h.text},range:x.cursor(a.from+h.length)}}):i=e.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}pt.scroll=s=>{let t=s.inputState;t.lastScrollTop=s.scrollDOM.scrollTop,t.lastScrollLeft=s.scrollDOM.scrollLeft,A.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())};pt.wheel=pt.mousewheel=s=>{s.inputState.lastWheelEvent=Date.now()};Ht.keydown=(s,t)=>(s.inputState.setSelectionOrigin("select"),t.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1);pt.touchstart=(s,t)=>{let e=s.inputState,i=t.targetTouches[0];e.touchActive=!0,e.lastTouchTime=Date.now(),i&&(e.lastTouchX=i.clientX,e.lastTouchY=i.clientY),e.setSelectionOrigin("select.pointer")};pt.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};pt.touchend=(s,t)=>{s.inputState.touchActive=!1};Ht.mousedown=(s,t)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let e=null;for(let i of s.state.facet(Ba))if(e=i(s,t),e)break;if(!e&&t.button==0&&(e=vu(s,t)),e){let i=!s.hasFocus;s.inputState.startMouseSelection(new mu(s,t,e,i)),i&&s.observer.ignore(()=>{xa(s.contentDOM);let r=s.root.activeElement;r&&!r.contains(s.contentDOM)&&r.blur()});let n=s.inputState.mouseSelection;if(n)return n.start(t),n.dragging===!1}else s.inputState.setSelectionOrigin("select.pointer");return!1};function Bo(s,t,e,i){if(i==1)return x.cursor(t,e);if(i==2)return _f(s.state,t,e);{let n=s.docView.lineAt(t,e),r=s.state.doc.lineAt(n?n.posAtEnd:t),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return l<s.state.doc.length&&l==r.to&&l++,x.undirectionalRange(o,l)}}const ku=A.ie&&A.ie_version<=11;let Po=null,Ro=0,Lo=0;function Ja(s){if(!ku)return s.detail;let t=Po,e=Lo;return Po=s,Lo=Date.now(),Ro=!t||e>Date.now()-400&&Math.abs(t.clientX-s.clientX)<2&&Math.abs(t.clientY-s.clientY)<2?(Ro+1)%3:1}function vu(s,t){let e=s.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=Ja(t),n=s.state.selection;return{update(r){r.docChanged&&(e.pos=r.changes.mapPos(e.pos),n=n.map(r.changes))},get(r,o,l){let a=s.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,c=Bo(s,a.pos,a.assoc,i);if(e.pos!=a.pos&&!o){let f=Bo(s,e.pos,e.assoc,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u<c.from?x.range(u,d,c.assoc):x.range(d,u,c.assoc)}return o?n.replaceRange(n.main.extend(c.from,c.to,c.assoc)):l&&i==1&&n.ranges.length>1&&(h=Su(n,a.pos))?h:l?n.addRange(c):x.create([c])}}}function Su(s,t){for(let e=0;e<s.ranges.length;e++){let{from:i,to:n}=s.ranges[e];if(i<=t&&n>=t)return x.create(s.ranges.slice(0,e).concat(s.ranges.slice(e+1)),s.mainIndex==e?0:s.mainIndex-(s.mainIndex>e?1:0))}return null}Ht.dragstart=(s,t)=>{let{selection:{main:e}}=s.state;if(t.target.draggable){let n=s.docView.tile.nearest(t.target);if(n&&n.isWidget()){let r=n.posAtStart,o=r+n.length;(r>=e.to||o<=e.from)&&(e=x.undirectionalRange(r,o))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=e,t.dataTransfer&&(t.dataTransfer.setData("Text",Gn(s.state,Lr,s.state.sliceDoc(e.from,e.to))),t.dataTransfer.effectAllowed="copyMove"),!1};Ht.dragend=s=>(s.inputState.draggedContent=null,!1);function Eo(s,t,e,i){if(e=Gn(s.state,Rr,e),!e)return;let n=s.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:r}=s.inputState,o=i&&r&&yu(s,t)?{from:r.from,to:r.to}:null,l={from:n,insert:e},a=s.state.changes(o?[o,l]:l);s.focus(),s.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),s.inputState.draggedContent=null}Ht.drop=(s,t)=>{if(!t.dataTransfer)return!1;if(s.state.readOnly)return!0;let e=t.dataTransfer.files;if(e&&e.length){let i=Array(e.length),n=0,r=()=>{++n==e.length&&Eo(s,t,i.filter(o=>o!=null).join(s.state.lineBreak),!1)};for(let o=0;o<e.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(e[o])}return!0}else{let i=t.dataTransfer.getData("Text");if(i)return Eo(s,t,i,!0),!0}return!1};Ht.paste=(s,t)=>{if(s.state.readOnly)return!0;s.observer.flush();let e=Xa?null:t.clipboardData;return e?(_a(s,e.getData("text/plain")||e.getData("text/uri-list")),!0):(wu(s),!1)};function Cu(s,t){let e=s.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function Au(s){let t=[],e=[],i=!1;for(let n of s.selection.ranges)n.empty||(t.push(s.sliceDoc(n.from,n.to)),e.push(n));if(!t.length){let n=-1;for(let{from:r}of s.selection.ranges){let o=s.doc.lineAt(r);o.number>n&&(t.push(o.text),e.push({from:o.from,to:Math.min(s.doc.length,o.to+1)})),n=o.number}i=!0}return{text:Gn(s,Lr,t.join(s.lineBreak)),ranges:e,linewise:i}}let or=null;Ht.copy=Ht.cut=(s,t)=>{if(!mi(s.contentDOM,s.observer.selectionRange))return!1;let{text:e,ranges:i,linewise:n}=Au(s.state);if(!e&&!n)return!1;or=n?e:null,t.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Xa?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",e),!0):(Cu(s,e),!1)};const Za=ae.define();function th(s,t){let e=[];for(let i of s.facet(La)){let n=i(s,t);n&&e.push(n)}return e.length?s.update({effects:e,annotations:Za.of(!0)}):null}function eh(s){setTimeout(()=>{let t=s.hasFocus;if(t!=s.inputState.notifiedFocused){let e=th(s.state,t);e?s.dispatch(e):s.update([])}},10)}pt.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),eh(s)};pt.blur=s=>{s.observer.clearSelectionRange(),eh(s)};pt.compositionstart=pt.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))};pt.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,A.chrome&&A.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))};pt.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};Ht.beforeinput=(s,t)=>{var e,i;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(s.inputState.insertingText=t.data,s.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&s.observer.editContext){let r=(e=t.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain"),o=t.getTargetRanges();if(r&&o.length){let l=o[0],a=s.posAtDOM(l.startContainer,l.startOffset),h=s.posAtDOM(l.endContainer,l.endOffset);return Hr(s,{from:a,to:h,insert:s.state.toText(r)},null),!0}}let n;if(A.chrome&&A.android&&(n=Ya.find(r=>r.inputType==t.inputType))&&(s.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return A.ios&&t.inputType=="deleteContentForward"&&s.observer.flushSoon(),A.safari&&t.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>pt.compositionend(s,t),20),!1};const Io=new Set;function Mu(s){Io.has(s)||(Io.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}const No=["pre-wrap","normal","pre-line","break-spaces"];let ei=!1;function Ho(){ei=!1}class Ou{constructor(t){this.lineWrapping=t,this.doc=W.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return No.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(e=!0,this.heightSamples[Math.floor(n*10)]=!0)}return e}refresh(t,e,i,n,r,o){let l=No.indexOf(t)>-1,a=Math.abs(e-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=r,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}}class Tu{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Et{constructor(t,e,i,n,r){this.from=t,this.length=e,this.top=i,this.height=n,this._content=r}get type(){return typeof this._content=="number"?nt.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 Ie?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Et(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var U=(function(s){return s[s.ByPos=0]="ByPos",s[s.ByHeight=1]="ByHeight",s[s.ByPosNoHeight=2]="ByPosNoHeight",s})(U||(U={}));const un=.001;class dt{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>un&&(ei=!0),this.height=t)}replace(t,e,i){return dt.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let r=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=n[l],u=r.lineAt(a,U.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=h?u:r.lineAt(h,U.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=n[l-1].toA;)a=n[l-1].fromA,c=n[l-1].fromB,l--,a<u.from&&(u=r.lineAt(a,U.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let p=Wr.build(i.setDoc(o),t,c,f);r=On(r,r.replace(a,h,p))}return r.updateHeight(i,0)}static empty(){return new vt(0,0,0)}static of(t){if(t.length==1)return t[0];let e=0,i=t.length,n=0,r=0;for(;;)if(e==i)if(n>r*2){let l=t[e-1];l.break?t.splice(--e,1,l.left,null,l.right):t.splice(--e,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(r>n*2){let l=t[i];l.break?t.splice(i,1,l.left,null,l.right):t.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(n<r){let l=t[e++];l&&(n+=l.size)}else{let l=t[--i];l&&(r+=l.size)}let o=0;return t[e-1]==null?(o=1,e--):t[e]==null&&(o=1,i++),new Bu(dt.of(t.slice(0,e)),o,dt.of(t.slice(i)))}}function On(s,t){return s==t?s:(s.constructor!=t.constructor&&(ei=!0),t)}dt.prototype.size=1;const Du=H.replace({});class ih extends dt{constructor(t,e,i){super(t,e),this.deco=i,this.spaceAbove=0}mainBlock(t,e){return new Et(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,i,n){return this.spaceAbove&&t<i+this.spaceAbove?new Et(n,0,i,this.spaceAbove,Du):this.mainBlock(i,n)}lineAt(t,e,i,n,r){let o=this.mainBlock(n,r);return this.spaceAbove?this.blockAt(0,i,n,r).join(o):o}forEachLine(t,e,i,n,r,o){t<=r+this.length&&e>=r&&o(this.lineAt(0,U.ByPos,i,n,r))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class vt extends ih{constructor(t,e,i){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,e){return new Et(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,i){let n=i[0];return i.length==1&&(n instanceof vt||n instanceof et&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof et?n=new vt(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):dt.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class et extends dt{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,n=t.doc.lineAt(e+this.length).number,r=n-i+1,o,l=0;if(t.lineWrapping){let a=Math.min(this.height,t.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(t,e,i,n){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(e,n);if(e.lineWrapping){let h=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),c=e.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,t-f/2);return new Et(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-r,Math.floor((t-i)/l))),{from:c,length:f}=e.doc.line(r+h);return new Et(c,f,i+l*h,l,0)}}lineAt(t,e,i,n,r){if(e==U.ByHeight)return this.blockAt(t,i,n,r);if(e==U.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(t);return new Et(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),h=i.doc.lineAt(t),c=l+h.length*a,f=h.number-o,u=n+l*f+a*(h.from-r-f);return new Et(h.from,h.length,Math.max(n,Math.min(u,n+this.height-c)),c,0)}forEachLine(t,e,i,n,r,o){t=Math.max(t,r),e=Math.min(e,r+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,r);for(let c=t,f=n;c<=e;){let u=i.doc.lineAt(c);if(c==t){let p=u.number-l;f+=a*p+h*(t-r-p)}let d=a+h*u.length;o(new Et(u.from,u.length,f,d,0)),f+=d,c=u.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let r=i[i.length-1];r instanceof et?i[i.length-1]=new et(r.length+n):i.push(null,new et(n-1))}if(t>0){let r=i[0];r instanceof et?i[0]=new et(t+r.length):i.unshift(new et(t-1),null)}return dt.of(i)}decomposeLeft(t,e){e.push(new et(t-1),null)}decomposeRight(t,e){e.push(null,new et(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let r=e+this.length;if(n&&n.from<=e+this.length&&n.more){let o=[],l=Math.max(e,n.from),a=-1;for(n.from>e&&o.push(new et(n.from-e-1).updateHeight(t,e));l<=r&&n.more;){let c=t.doc.lineAt(l).length;o.length&&o.push(null);let f=n.heights[n.index++],u=0;f<0&&(u=-f,f=n.heights[n.index++]),a==-1?a=f:Math.abs(f-a)>=un&&(a=-2);let d=new vt(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=r&&o.push(null,new et(r-l).updateHeight(t,l));let h=dt.of(o);return(a<0||Math.abs(h.height-this.height)>=un||Math.abs(a-this.heightMetrics(t,e).perLine)>=un)&&(ei=!0),On(this,h)}else(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Bu extends dt{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return this.flags&1}blockAt(t,e,i,n){let r=i+this.left.height;return t<r?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,r,n+this.left.length+this.break)}lineAt(t,e,i,n,r){let o=n+this.left.height,l=r+this.left.length+this.break,a=e==U.ByHeight?t<o:t<l,h=a?this.left.lineAt(t,e,i,n,r):this.right.lineAt(t,e,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=e==U.ByPosNoHeight?U.ByPosNoHeight:U.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,n,r).join(h)}forEachLine(t,e,i,n,r,o){let l=n+this.left.height,a=r+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,i,n,r,o),e>=a&&this.right.forEachLine(t,e,i,l,a,o);else{let h=this.lineAt(a,U.ByPos,i,n,r);t<h.from&&this.left.forEachLine(t,h.from-1,i,n,r,o),h.to>=t&&h.from<=e&&o(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,l,a,o)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];t>0&&this.decomposeLeft(t,r);let o=r.length;for(let l of i)r.push(l);if(t>0&&Wo(r,o-1),e<this.length){let l=r.length;this.decomposeRight(e,r),Wo(r,l)}return dt.of(r)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?dt.of(this.break?[t,null,e]:[t,e]):(this.left=On(this.left,t),this.right=On(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:o}=this,l=e+r.length+this.break,a=null;return n&&n.from<=e+r.length&&n.more?a=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(t,l,i,n):o.updateHeight(t,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Wo(s,t){let e,i;s[t]==null&&(e=s[t-1])instanceof et&&(i=s[t+1])instanceof et&&s.splice(t-1,3,new et(e.length+1+i.length))}const Pu=5;class Wr{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let i=Math.min(e,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof vt?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new vt(i-this.pos,-1,0)),this.writtenTo=i,e>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new ih(o,n,i)):(o||r||n>=Pu)&&this.addLineDeco(n,r,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new vt(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let i=new et(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof vt)return t;let e=new vt(0,-1,0);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof vt)&&!this.isCovered?this.nodes.push(new vt(0,-1,0)):(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=t;for(let n of this.nodes)n instanceof vt&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let r=new Wr(i,t);return R.spans(e,i,n,r,0),r.finish(i)}}function Ru(s,t,e){let i=new Lu;return R.compare(s,t,e,i,0),i.changes}class Lu{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Ge(t,e,this.changes,5)}}function Eu(s,t){let e=s.getBoundingClientRect(),i=s.ownerDocument,n=i.defaultView||window,r=Math.max(0,e.left),o=Math.min(n.innerWidth,e.right),l=Math.max(0,e.top),a=Math.min(n.innerHeight,e.bottom);for(let h=s.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();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==s.parentNode?n.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-e.left,right:Math.max(r,o)-e.left,top:l-(e.top+t),bottom:Math.max(l,a)-(e.top+t)}}function Iu(s){let t=s.getBoundingClientRect(),e=s.ownerDocument.defaultView||window;return t.left<e.innerWidth&&t.right>0&&t.top<e.innerHeight&&t.bottom>0}function Nu(s,t){let e=s.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}class ms{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(t,e){return H.replace({widget:new Hu(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class Hu extends ce{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class Fo{constructor(t,e){this.view=t,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.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Vo,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=j.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=e.facet(Er).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Ou(i),this.stateDeco=zo(e),this.heightMap=dt.empty().applyChanges(this.stateDeco,W.empty,this.heightOracle.setDoc(e.doc),[new Dt(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=H.set(this.lineGaps.map(n=>n.draw(this,!1))),this.scrollParent=t.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:r,to:o})=>n>=r&&n<=o)){let{from:r,to:o}=this.lineBlockAt(n);t.push(new Ui(r,o))}}return this.viewports=t.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?Vo:new Fr(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(ui(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=zo(this.state);let n=t.changedRanges,r=Dt.extendWithRanges(n,Ru(i,this.stateDeco,t?t.changes:_.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ho(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||ei)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(h||!t.changes.empty||t.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Ia)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?j.RTL:j.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",l=e.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:k,scaleY:v}=ma(e,l);(k>.005&&Math.abs(this.scaleX-k)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=k,this.scaleY=v,h|=16,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|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=16);let d=ga(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=wa(this.scrollParent||t.win);let m=(this.printing?Nu:Eu)(e,this.paddingTop),g=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(a=!0)),!this.inView&&!this.scrollTarget&&!Iu(t.dom))return 0;let b=l.width;if((this.contentDOMWidth!=b||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,h|=16),a){let k=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(k)&&(o=!0),o||n.lineWrapping&&Math.abs(b-this.contentDOMWidth)>n.charWidth){let{lineHeight:v,charWidth:S,textHeight:P}=t.docView.measureTextSize();o=v>0&&n.refresh(r,v,S,P,Math.max(5,b/S),k),o&&(t.docView.minWidth=0,h|=16)}g>0&&y>0?c=Math.max(g,y):g<0&&y<0&&(c=Math.min(g,y)),Ho();for(let v of this.viewports){let S=v.from==this.viewport.from?k:t.docView.measureVisibleLineHeights(v);this.heightMap=(o?dt.empty().applyChanges(this.stateDeco,W.empty,this.heightOracle,[new Dt(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Tu(v.from,S))}ei&&(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&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Ui(n.lineAt(o-i*1e3,U.ByHeight,r,0,0).from,n.lineAt(l+(1-i)*1e3,U.ByHeight,r,0,0).to);if(e){let{head:h}=e.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=n.lineAt(h,U.ByPos,r,0,0),u;e.y=="center"?u=(f.top+f.bottom)/2-c/2:e.y=="start"||e.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new Ui(n.lineAt(u-1e3/2,U.ByHeight,r,0,0).from,n.lineAt(u+c+1e3/2,U.ByHeight,r,0,0).to)}}return a}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Ui(this.heightMap.lineAt(i,U.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,U.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,U.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,U.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(t==0||n<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&r<l+2*1e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new ms(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,o=n<<1;if(this.defaultTextDirection!=j.LTR&&!i)return[];let l=[],a=(c,f,u,d)=>{if(f-c<r)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let y of m)if(y>c&&y<f){a(c,y-10,u,d),a(y+10,f,u,d);return}let g=Fu(t,y=>y.from>=u.from&&y.to<=u.to&&Math.abs(y.from-c)<r&&Math.abs(y.to-f)<r&&!m.some(w=>y.from<w&&y.to>w));if(!g){if(f<u.to&&e&&i&&e.visibleRanges.some(b=>b.from<=f&&b.to>=f)){let b=e.moveToLineBoundary(x.cursor(f),!1,!0).head;b>c&&(f=b)}let y=this.gapSize(u,c,f,d),w=i||y<2e6?y:2e6;g=new ms(c,f,y,w)}l.push(g)},h=c=>{if(c.length<o||c.type!=nt.Text)return;let f=Wu(c.from,c.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let m=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,y;if(u!=null){let w=Yi(f,u),b=((this.visibleBottom-this.visibleTop)/2+m)/c.height;g=w-b,y=w+b}else g=(this.visibleTop-c.top-m)/c.height,y=(this.visibleBottom-c.top+m)/c.height;d=Gi(f,g),p=Gi(f,y)}else{let m=f.total*this.heightOracle.charWidth,g=n*this.heightOracle.charWidth,y=0;if(m>2e6)for(let v of t)v.from>=c.from&&v.from<c.to&&v.size!=v.displaySize&&v.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=v.size-v.displaySize);let w=this.pixelViewport.left+y,b=this.pixelViewport.right+y,O,k;if(u!=null){let v=Yi(f,u),S=((b-w)/2+g)/m;O=v-S,k=v+S}else O=(w-g)/m,k=(b+g)/m;d=Gi(f,O),p=Gi(f,k)}d>c.from&&a(c.from,d,c,f),p<c.to&&a(p,c.to,c,f)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(h):h(c);return l}gapSize(t,e,i,n){let r=Yi(n,i)-Yi(n,e);return this.heightOracle.lineWrapping?t.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(t){ms.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=H.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];R.spans(e,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let r=0;r<i.length&&!(n&8);r++){let o=this.visibleRanges[r],l=i[r];(o.from!=l.from||o.to!=l.to)&&(n|=4,t&&t.mapPos(o.from,-1)==l.from&&t.mapPos(o.to,1)==l.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||ui(this.heightMap.lineAt(t,U.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||ui(this.heightMap.lineAt(this.scaler.fromDOM(t),U.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return ui(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ui{constructor(t,e){this.from=t,this.to=e}}function Wu(s,t,e){let i=[],n=s,r=0;return R.spans(e,s,t,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),r+=o-n),n=l}},20),n<t&&(i.push({from:n,to:t}),r+=t-n),{total:r,ranges:i}}function Gi({total:s,ranges:t},e){if(e<=0)return t[0].from;if(e>=1)return t[t.length-1].to;let i=Math.floor(s*e);for(let n=0;;n++){let{from:r,to:o}=t[n],l=o-r;if(i<=l)return r+i;i-=l}}function Yi(s,t){let e=0;for(let{from:i,to:n}of s.ranges){if(t<=n){e+=t-i;break}e+=n-i}return e/s.total}function Fu(s,t){for(let e of s)if(t(e))return e}const Vo={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}};function zo(s){let t=s.facet(jn).filter(i=>typeof i!="function"),e=s.facet(Ir).filter(i=>typeof i!="function");return e.length&&t.push(R.join(e)),t}class Fr{constructor(t,e,i){let n=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=e.lineAt(l,U.ByPos,t,0,0).top,c=e.lineAt(a,U.ByPos,t,0,0).bottom;return n+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(e.height-n);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.top)return n+(t-i)*this.scale;if(t<=r.bottom)return r.domTop+(t-r.top);i=r.bottom,n=r.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.domTop)return i+(t-n)/this.scale;if(t<=r.domBottom)return r.top+(t-r.domTop);i=r.bottom,n=r.domBottom}}eq(t){return t instanceof Fr?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to):!1}}function ui(s,t){if(t.scale==1)return s;let e=t.toDOM(s.top),i=t.toDOM(s.bottom);return new Et(s.from,s.length,e,i-e,Array.isArray(s._content)?s._content.map(n=>ui(n,t)):s._content)}const Qi=M.define({combine:s=>s.join(" ")}),lr=M.define({combine:s=>s.indexOf(!0)>-1}),ar=be.newName(),nh=be.newName(),sh=be.newName(),rh={"&light":"."+nh,"&dark":"."+sh};function hr(s,t,e){return new be(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return s;if(!e||!e[n])throw new RangeError(`Unsupported selector: ${n}`);return e[n]}):s+" "+i}})}const Vu=hr("."+ar,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",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:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".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",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".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"}},rh),zu={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},gs=A.ie&&A.ie_version<=11;class $u{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new yf,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);(A.ie&&A.ie_version<=11||A.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&A.android&&t.constructor.EDIT_CONTEXT!==!1&&!(A.chrome&&A.chrome_version<126)&&(this.editContext=new ju(t),t.state.facet(ne)&&(t.contentDOM.editContext=this.editContext.editContext)),gs&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(ne)?i.root.activeElement!=this.dom:!mi(this.dom,n))return;let r=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(A.ie&&A.ie_version<=11||A.android&&A.chrome)&&!i.state.selection.main.empty&&n.focusNode&&gi(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Ai(t.root);if(!e)return!1;let i=A.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&qu(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=mi(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&xf(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(i.nodeType==1)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=e)i.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,zu),gs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),gs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let n=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Ye(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,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 t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let r of t){let o=this.readMutation(r);o&&(o.typeOver&&(n=!0),e==-1?{from:e,to:i}=o:(e=Math.min(o.from,e),i=Math.max(o.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&mi(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new ou(this.view,t,e,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Ua(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!Mn(this.view.state.selection,e.newSel.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty(t.type=="attributes"),t.type=="childList"){let i=$o(e,t.previousSibling||t.target.previousSibling,-1),n=$o(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(ne)!=t.state.facet(ne)&&(t.view.contentDOM.editContext=t.state.facet(ne)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function $o(s,t,e){for(;t;){let i=Y.get(t);if(i&&i.parent==s)return i;let n=t.parentNode;t=n!=s.dom?n:e>0?t.nextSibling:t.previousSibling}return null}function qo(s,t){let e=t.startContainer,i=t.startOffset,n=t.endContainer,r=t.endOffset,o=s.docView.domAtPos(s.state.selection.main.anchor,1);return gi(o.node,o.offset,n,r)&&([e,i,n,r]=[n,r,e,i]),{anchorNode:e,anchorOffset:i,focusNode:n,focusOffset:r}}function qu(s,t){if(t.getComposedRanges){let n=t.getComposedRanges(s.root)[0];if(n)return qo(s,n)}let e=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),e=n.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",i,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",i,!0),e?qo(s,e):null}class ju{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let n=t.state.selection.main,{anchor:r,head:o}=n,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let c=Ga(t.state.sliceDoc(l,a),i.text,(h?n.from:n.to)-l,h?"end":null);if(!c){let u=x.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Mn(u,n)||t.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:W.of(i.text.slice(c.from,c.toB).split(`
|
|
10
|
+
`))};if((A.mac||A.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:W.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!t.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);Hr(t,f,x.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),f.from<f.to&&!f.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=t.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,n.push(r)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;n.push(H.mark({attributes:{style:c}}).range(a,h))}}}t.dispatch({effects:Ha.of(H.set(n))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let n=Ai(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let c=h.length-(o-r);if(n&&o>=n.to)if(n.from==r&&n.to==o&&n.insert.eq(h)){n=this.pendingContextChange=null,e+=c,this.to+=c;return}else n=null,this.revertPending(t.state);if(r+=e,o+=e,o<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=c}e+=c}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class T{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var 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),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(n=>n.forEach(r=>i(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=t.root||bf(t.parent)||document,this.viewState=new Fo(this,t.state||V.create(t)),t.scrollTo&&t.scrollTo.is(qi)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet($e).map(n=>new cs(n));for(let n of this.plugins)n.update(this);this.observer=new $u(this),this.inputState=new cu(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Mo(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let e=t.length==1&&t[0]instanceof J?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,n,r=this.state;for(let u of t){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;t.some(u=>u.annotation(Za))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=th(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(V.phrases)!=this.state.facet(V.phrases))return this.setState(r);n=Sn.create(this,r,t),n.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of t){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:m}=this.state.facet(T.cursorScrollMargin);f=new Qe(d.empty?d:x.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of u.effects)d.is(qi)&&(f=d.value.clip(this.state))}this.viewState.update(n,f),this.bidiCache=Tn.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),e=this.docView.update(n),this.state.facet(fi)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(Qi)!=n.state.facet(Qi)&&(this.viewState.mustMeasureContent=!0),(e||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!n.empty)for(let u of this.state.facet(ir))try{u(n)}catch(d){ut(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Ua(this,c)&&h.force&&Ye(this.contentDOM,h.key,h.keyCode)})}setState(t){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=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Fo(this,t),this.plugins=t.facet($e).map(i=>new cs(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Mo(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet($e),i=t.state.facet($e);if(e!=i){let n=[];for(let r of i){let o=e.indexOf(r);if(o<0)n.push(new cs(r));else{let l=this.plugins[o];l.mustUpdate=t,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=t&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(i){ut(this.state,i,"doc view update listener")}}}measure(t=!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,t&&this.observer.forceFlush();let e=null,i=this.viewState.scrollParent,n=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(n-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if(wa(i||this.win))r=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(n);r=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];h&4||([this.measureRequests,c]=[c,this.measureRequests]);let f=c.map(p=>{try{return p.read(this)}catch(m){return ut(this.state,m),jo}}),u=Sn.create(this,this.state,[]),d=!1;u.flags|=h,e?e.flags|=h:e=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(f[p]!=jo)try{let m=c[p];m.write&&m.write(f[p],this)}catch(m){ut(this.state,m)}if(d&&this.docView.updateSelection(!0),!u.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 m=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)/this.viewState.scaleY-o/l;if((m>1||m<-1)&&!(A.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){n=n+m,i?r<0?i.scrollTop=i.scrollHeight:i.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let a of this.state.facet(ir))a(e)}get themeClasses(){return ar+" "+(this.state.facet(lr)?sh:nh)+" "+this.state.facet(Qi)}updateAttrs(){let t=Ko(this,Wa,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ne)?"true":"false",class:"cm-content",style:`${A.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Ko(this,Er,e);let i=this.observer.ignore(()=>{let n=wo(this.contentDOM,this.contentAttrs,e),r=wo(this.dom,this.editorAttrs,t);return n||r});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let n of i.effects)if(n.is(T.announce)){e&&(this.announceDOM.textContent=""),e=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(fi);let t=this.state.facet(T.cspNonce);be.mount(this.root,this.styleModules.concat(Vu).reverse(),t?{nonce:t}: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(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(i=>i.plugin==t)||null),e&&e.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(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return ps(this,t,Oo(this,t,e,i))}moveByGroup(t,e){return ps(this,t,Oo(this,t,e,i=>tu(this,t.head,i)))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),r=i[e?i.length-1:0];return x.cursor(r.side(e,n)+t.from,r.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return Zf(this,t,e,i)}moveVertically(t,e,i){return ps(this,t,eu(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=rr(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),rr(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.state.doc.lineAt(t),n=this.bidiSpans(i),r=n[Qt.find(n,t-i.from,-1,e)];return this.docView.coordsAt(t,e,r.dir==j.RTL)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Ea)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Ku)return Ma(t.length);let e=this.textDirectionAt(t.from),i;for(let r of this.bidiCache)if(r.from==t.from&&r.dir==e&&(r.fresh||Aa(r.isolates,i=So(this,t))))return r.order;i||(i=So(this,t));let n=Mf(t.text,e,i);return this.bidiCache.push(new Tn(t.from,t.to,e,i,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||A.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{xa(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.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(t,e={}){var i,n,r,o;return qi.of(new Qe(typeof t=="number"?x.cursor(t):t,(i=e.y)!==null&&i!==void 0?i:"nearest",(n=e.x)!==null&&n!==void 0?n:"nearest",(r=e.yMargin)!==null&&r!==void 0?r:5,(o=e.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return qi.of(new Qe(x.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return st.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return st.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=be.newName(),n=[Qi.of(i),fi.of(hr(`.${i}`,t))];return e&&e.dark&&n.push(lr.of(!0)),n}static baseTheme(t){return si.lowest(fi.of(hr("."+ar,t,rh)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&Y.get(i)||Y.get(t);return((e=n?.root)===null||e===void 0?void 0:e.view)||null}}T.styleModule=fi;T.inputHandler=Ra;T.clipboardInputFilter=Rr;T.clipboardOutputFilter=Lr;T.scrollHandler=Na;T.focusChangeEffect=La;T.perLineTextDirection=Ea;T.exceptionSink=Pa;T.updateListener=ir;T.editable=ne;T.mouseSelectionStyle=Ba;T.dragMovesSelection=Da;T.clickAddsSelectionRange=Ta;T.decorations=jn;T.blockWrappers=Fa;T.outerDecorations=Ir;T.atomicRanges=Ni;T.bidiIsolatedRanges=Va;T.cursorScrollMargin=M.define({combine:s=>{let t=5,e=5;for(let i of s)typeof i=="number"?t=e=i:{x:t,y:e}=i;return{x:t,y:e}}});T.scrollMargins=za;T.darkTheme=lr;T.cspNonce=M.define({combine:s=>s.length?s[0]:""});T.contentAttributes=Er;T.editorAttributes=Wa;T.lineWrapping=T.contentAttributes.of({class:"cm-lineWrapping"});T.announce=I.define();const Ku=4096,jo={};class Tn{constructor(t,e,i,n,r,o){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=r,this.order=o}static update(t,e){if(e.empty&&!t.some(r=>r.fresh))return t;let i=[],n=t.length?t[t.length-1].dir:j.LTR;for(let r=Math.max(0,t.length-10);r<t.length;r++){let o=t[r];o.dir==n&&!e.touchesRange(o.from,o.to)&&i.push(new Tn(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Ko(s,t,e){for(let i=s.state.facet(t),n=i.length-1;n>=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&Dr(o,e)}return e}const Uu=A.mac?"mac":A.windows?"win":A.linux?"linux":"key";function Gu(s,t){const e=s.split(/-(?!$)/);let i=e[e.length-1];i=="Space"&&(i=" ");let n,r,o,l;for(let a=0;a<e.length-1;++a){const h=e[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))t=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return n&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Xi(s,t,e){return t.altKey&&(s="Alt-"+s),t.ctrlKey&&(s="Ctrl-"+s),t.metaKey&&(s="Meta-"+s),e!==!1&&t.shiftKey&&(s="Shift-"+s),s}const Yu=si.default(T.domEventHandlers({keydown(s,t){return Ju(Qu(t.state),s,t,"editor")}})),Vr=M.define({enables:Yu}),Uo=new WeakMap;function Qu(s){let t=s.facet(Vr),e=Uo.get(t);return e||Uo.set(t,e=_u(t.reduce((i,n)=>i.concat(n),[]))),e}let pe=null;const Xu=4e3;function _u(s,t=Uu){let e=Object.create(null),i=Object.create(null),n=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,c)=>{var f,u;let d=e[o]||(e[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>Gu(y,t));for(let y=1;y<p.length;y++){let w=p.slice(0,y).join(" ");n(w,!0),d[w]||(d[w]={preventDefault:!0,stopPropagation:!1,run:[b=>{let O=pe={view:b,prefix:w,scope:o};return setTimeout(()=>{pe==O&&(pe=null)},Xu),!0}]})}let m=p.join(" ");n(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let o of s){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=e[h]||(e[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,cr))}let a=o[t]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return e}let cr=null;function Ju(s,t,e,i){cr=t;let n=ff(t),r=St(n,0),o=ie(r)==n.length&&n!=" ",l="",a=!1,h=!1,c=!1;pe&&pe.view==e&&pe.scope==i&&(l=pe.prefix+" ",Qa.indexOf(t.keyCode)<0&&(h=!0,pe=null));let f=new Set,u=g=>{if(g){for(let y of g.run)if(!f.has(y)&&(f.add(y),y(e)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),h=!0)}return!1},d=s[i],p,m;return d&&(u(d[l+Xi(n,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(A.windows&&t.ctrlKey&&t.altKey)&&!(A.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=xe[t.keyCode])&&p!=n?(u(d[l+Xi(p,t,!0)])||t.shiftKey&&(m=Si[t.keyCode])!=n&&m!=p&&u(d[l+Xi(m,t,!1)]))&&(a=!0):o&&t.shiftKey&&u(d[l+Xi(n,t,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&t.stopPropagation(),cr=null,a}class Re{constructor(t,e,i,n,r){this.className=t,this.left=e,this.top=i,this.width=n,this.height=r}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let n=t.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let r=oh(t);return[new Re(e,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}else return Zu(t,e,i)}}function oh(s){let t=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==j.LTR?t.left:t.right-s.scrollDOM.clientWidth*s.scaleX)-s.scrollDOM.scrollLeft*s.scaleX,top:t.top-s.scrollDOM.scrollTop*s.scaleY}}function Go(s,t,e,i){let n=s.coordsAtPos(t,e*2);if(!n)return i;let r=s.dom.getBoundingClientRect(),o=(n.top+n.bottom)/2,l=s.posAtCoords({x:r.left+1,y:o}),a=s.posAtCoords({x:r.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function Zu(s,t,e){if(e.to<=s.viewport.from||e.from>=s.viewport.to)return[];let i=Math.max(e.from,s.viewport.from),n=Math.min(e.to,s.viewport.to),r=s.textDirection==j.LTR,o=s.contentDOM,l=o.getBoundingClientRect(),a=oh(s),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),d=sr(s,i,1),p=sr(s,n,-1),m=d.type==nt.Text?d:null,g=p.type==nt.Text?p:null;if(m&&(s.lineWrapping||d.widgetLineBreaks)&&(m=Go(s,i,1,m)),g&&(s.lineWrapping||p.widgetLineBreaks)&&(g=Go(s,n,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return w(b(e.from,e.to,m));{let k=m?b(e.from,null,m):O(d,!1),v=g?b(null,e.to,g):O(p,!0),S=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&k.bottom+s.defaultLineHeight/2<v.top?S.push(y(f,k.bottom,u,v.top)):k.bottom<v.top&&s.elementAtHeight((k.bottom+v.top)/2).type==nt.Text&&(k.bottom=v.top=(k.bottom+v.top)/2),w(k).concat(S).concat(w(v))}function y(k,v,S,P){return new Re(t,k-a.left,v-a.top,Math.max(0,S-k),P-v)}function w({top:k,bottom:v,horizontal:S}){let P=[];for(let N=0;N<S.length;N+=2)P.push(y(S[N],k,S[N+1],v));return P}function b(k,v,S){let P=1e9,N=-1e9,$=[];function E(F,K,ht,wt,Vt){let tt=s.coordsAtPos(F,F==S.to?-2:2),At=s.coordsAtPos(ht,ht==S.from?2:-2);!tt||!At||(P=Math.min(tt.top,At.top,P),N=Math.max(tt.bottom,At.bottom,N),Vt==j.LTR?$.push(r&&K?f:tt.left,r&&wt?u:At.right):$.push(!r&&wt?f:At.left,!r&&K?u:tt.right))}let B=k??S.from,z=v??S.to;for(let F of s.visibleRanges)if(F.to>B&&F.from<z)for(let K=Math.max(F.from,B),ht=Math.min(F.to,z);;){let wt=s.state.doc.lineAt(K);for(let Vt of s.bidiSpans(wt)){let tt=Vt.from+wt.from,At=Vt.to+wt.from;if(tt>=ht)break;At>K&&E(Math.max(tt,K),k==null&&tt<=B,Math.min(At,ht),v==null&&At>=z,Vt.dir)}if(K=wt.to+1,K>=ht)break}return $.length==0&&E(B,k==null,z,v==null,s.textDirection),{top:P,bottom:N,horizontal:$}}function O(k,v){let S=l.top+(v?k.top:k.bottom);return{top:S,bottom:S,horizontal:[]}}}function td(s,t){return s.constructor==t.constructor&&s.eq(t)}class ed{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(dn)!=t.state.facet(dn)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(dn);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;(t!=this.scaleX||e!=this.scaleY)&&(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((e,i)=>!td(e,this.drawn[i]))){let e=this.dom.firstChild,i=0;for(let n of t)n.update&&e&&n.constructor&&this.drawn[i].constructor&&n.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(n.draw(),e);for(;e;){let n=e.nextSibling;e.remove(),e=n}this.drawn=t,A.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const dn=M.define();function lh(s){return[st.define(t=>new ed(t,s)),dn.of(s)]}const ii=M.define({combine(s){return he(s,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function id(s={}){return[ii.of(s),nd,sd,od,Ia.of(!0)]}function ah(s){return s.startState.facet(ii)!=s.state.facet(ii)}const nd=lh({above:!0,markers(s){let{state:t}=s,e=t.facet(ii),i=[];for(let n of t.selection.ranges){let r=n==t.selection.main;if(n.empty||e.drawRangeCursor&&!(r&&A.ios&&e.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=n.empty?n:x.cursor(n.head,n.assoc);for(let a of Re.forRange(s,o,l))i.push(a)}}return i},update(s,t){s.transactions.some(i=>i.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let e=ah(s);return e&&Yo(s.state,t),s.docChanged||s.selectionSet||e},mount(s,t){Yo(t.state,s)},class:"cm-cursorLayer"});function Yo(s,t){t.style.animationDuration=s.facet(ii).cursorBlinkRate+"ms"}const sd=lh({above:!1,markers(s){let t=[],{main:e,ranges:i}=s.state.selection;for(let n of i)if(!n.empty)for(let r of Re.forRange(s,"cm-selectionBackground",n))t.push(r);if(A.ios&&!e.empty&&s.state.facet(ii).iosSelectionHandles){for(let n of Re.forRange(s,"cm-selectionHandle cm-selectionHandle-start",x.cursor(e.from,1)))t.push(n);for(let n of Re.forRange(s,"cm-selectionHandle cm-selectionHandle-end",x.cursor(e.to,1)))t.push(n)}return t},update(s,t){return s.docChanged||s.selectionSet||s.viewportChanged||ah(s)},class:"cm-selectionLayer"}),rd=A.gecko&&A.gecko_version==153?"#ffffff01":"transparent",od=si.highest(T.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${rd} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Qo(s,t,e,i,n){t.lastIndex=0;for(let r=s.iterRange(e,i),o=e,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=t.exec(r.value);)n(o+l.index,l)}function ld(s,t){let e=s.visibleRanges;if(e.length==1&&e[0].from==s.viewport.from&&e[0].to==s.viewport.to)return e;let i=[];for(let{from:n,to:r}of e)n=Math.max(s.state.doc.lineAt(n).from,n-t),r=Math.min(s.state.doc.lineAt(r).to,r+t),i.length&&i[i.length-1].to>=n?i[i.length-1].to=r:i.push({from:n,to:r});return i}class ad{constructor(t){const{regexp:e,decoration:i,decorate:n,boundary:r,maxLength:o=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(l,a,h,c)=>n(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(t){let e=new se,i=e.add.bind(e);for(let{from:n,to:r}of ld(t,this.maxLength))Qo(t.state.doc,this.regexp,n,r,(o,l)=>this.addMatch(l,t,o,i));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges((r,o,l,a)=>{a>=t.view.viewport.from&&l<=t.view.viewport.to&&(i=Math.min(l,i),n=Math.max(a,n))}),t.viewportMoved||n-i>1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let r of t.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,n);if(l>=o){let a=t.state.doc.lineAt(o),h=a.to<l?t.state.doc.lineAt(l):a,c=Math.max(r.from,a.from),f=Math.min(r.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=[],d,p=(m,g,y)=>u.push(y.range(m,g));if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.index<f-a.from;)this.addMatch(d,t,d.index+a.from,p);else Qo(t.state.doc,this.regexp,c,f,(m,g)=>this.addMatch(g,t,m,p));e=e.update({filterFrom:c,filterTo:f,filter:(m,g)=>m<c||g>f,add:u})}}return e}}const fr=/x/.unicode!=null?"gu":"g",hd=new RegExp(`[\0-\b
|
|
11
|
+
--\u2028\u2029\uFEFF-]`,fr),cd={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let ys=null;function fd(){var s;if(ys==null&&typeof document<"u"&&document.body){let t=document.body.style;ys=((s=t.tabSize)!==null&&s!==void 0?s:t.MozTabSize)!=null}return ys||!1}const pn=M.define({combine(s){let t=he(s,{render:null,specialChars:hd,addSpecialChars:null});return(t.replaceTabs=!fd())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,fr)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,fr)),t}});function ud(s={}){return[pn.of(s),dd()]}let Xo=null;function dd(){return Xo||(Xo=st.fromClass(class{constructor(s){this.view=s,this.decorations=H.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(s.state.facet(pn)),this.decorations=this.decorator.createDeco(s)}makeDecorator(s){return new ad({regexp:s.specialChars,decoration:(t,e,i)=>{let{doc:n}=e.state,r=St(t[0],0);if(r==9){let o=n.lineAt(i),l=e.state.tabSize,a=Li(o.text,l,i-o.from);return H.replace({widget:new yd((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=H.replace({widget:new gd(s,r)}))},boundary:s.replaceTabs?void 0:/[^]/})}update(s){let t=s.state.facet(pn);s.startState.facet(pn)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(s.view)):this.decorations=this.decorator.updateDeco(s,this.decorations)}},{decorations:s=>s.decorations}))}const pd="•";function md(s){return s>=32?pd:s==10?"":String.fromCharCode(9216+s)}class gd extends ce{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=md(this.code),i=t.state.phrase("Control character")+" "+(cd[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let r=document.createElement("span");return r.textContent=e,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class yd extends ce{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const _i="-10000px";class hh{constructor(t,e,i,n){this.facet=e,this.createTooltipView=i,this.removeTooltipView=n,this.input=t.state.facet(e),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(t,e){var i;let n=t.state.facet(this.facet),r=n.filter(a=>a);if(n===this.input){for(let a of this.tooltipViews)a.update&&a.update(t);return!1}let o=[],l=e?[]:null;for(let a=0;a<r.length;a++){let h=r[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,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=e[c]),f.update&&f.update(t)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return e&&(l.forEach((a,h)=>e[h]=a),e.length=l.length),this.input=n,this.tooltips=r,this.tooltipViews=o,!0}}function bd(s){let t=s.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const bs=M.define({combine:s=>{var t,e,i;return{position:A.ios?"absolute":((t=s.find(n=>n.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=s.find(n=>n.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((i=s.find(n=>n.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||bd}}}),_o=new WeakMap,zr=st.fromClass(class{constructor(s){this.view=s,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=s.state.facet(bs);this.position=t.position,this.parent=t.parent,this.classes=s.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new hh(s,Yn,(e,i)=>this.createTooltip(e,i),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),s.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 s of this.manager.tooltipViews)this.intersectionObserver.observe(s.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(s){s.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(s,this.above);t&&this.observeIntersection();let e=t||s.geometryChanged,i=s.state.facet(bs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;e=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(s,t){let e=s.create(this.view),i=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),s.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",e.dom.appendChild(n)}return e.dom.style.position=this.position,e.dom.style.top=_i,e.dom.style.left="0px",this.container.insertBefore(e.dom,i),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var s,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(s=i.destroy)===null||s===void 0||s.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let s=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(A.safari){let o=r.getBoundingClientRect();e=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else e=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(e||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(s=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:s,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),n=Nr(this.view);return{visible:{left:i.left+n.left,top:i.top+n.top,right:i.right-n.right,bottom:i.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(bs).tooltipSpace(this.view),scaleX:s,scaleY:t,makeAbsolute:e}}writeMeasure(s){var t;if(s.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:i,scaleX:n,scaleY:r}=s,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=s.pos[l],u=s.size[l];if(!f||a.clip!==!1&&(f.bottom<=Math.max(e.top,i.top)||f.top>=Math.min(e.bottom,i.bottom)||f.right<Math.max(e.left,i.left)-.1||f.left>Math.min(e.right,i.right)+.1)){c.style.top=_i;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=u.right-u.left,g=(t=_o.get(h))!==null&&t!==void 0?t:u.bottom-u.top,y=h.offset||wd,w=this.view.textDirection==j.LTR,b=u.width>i.right-i.left?w?i.left:i.right-u.width:w?Math.max(i.left,Math.min(f.left-(d?14:0)+y.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-y.x),i.right-m),O=this.above[l];!a.strictSide&&(O?f.top-g-p-y.y<i.top:f.bottom+g+p+y.y>i.bottom)&&O==i.bottom-f.bottom>f.top-i.top&&(O=this.above[l]=!O);let k=(O?f.top-i.top:i.bottom-f.bottom)-p;if(k<g&&h.resize!==!1){if(k<this.view.defaultLineHeight){c.style.top=_i;continue}_o.set(h,g),c.style.height=(g=k)/r+"px"}else c.style.height&&(c.style.height="");let v=O?f.top-g-p-y.y:f.bottom+p+y.y,S=b+m;if(h.overlap!==!0)for(let P of o)P.left<S&&P.right>b&&P.top<v+g&&P.bottom>v&&(v=O?P.top-g-2-p:P.bottom+p+2);if(this.position=="absolute"?(c.style.top=(v-s.parent.top)/r+"px",Jo(c,(b-s.parent.left)/n)):(c.style.top=v/r+"px",Jo(c,b/n)),d){let P=f.left+(w?y.x:-y.x)-(b+14-7);d.style.left=P/n+"px"}h.overlap!==!0&&o.push({left:b,top:v,right:S,bottom:v+g}),c.classList.toggle("cm-tooltip-above",O),c.classList.toggle("cm-tooltip-below",!O),h.positioned&&h.positioned(s.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 s of this.manager.tooltipViews)s.dom.style.top=_i}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Jo(s,t){let e=parseInt(s.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(s.style.left=t+"px")}const xd=T.baseTheme({".cm-tooltip":{zIndex:500,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:"14px",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"}}}),wd={x:0,y:0},Yn=M.define({enables:[zr,xd]}),Dn=M.define({combine:s=>s.reduce((t,e)=>t.concat(e),[])});class Qn{static create(t){return new Qn(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new hh(t,Dn,(e,i)=>this.createHostedView(e,i),e=>e.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)(t=e.destroy)===null||t===void 0||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(n!==void 0){if(e===void 0)e=n;else if(e!==n)return}}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const kd=Yn.compute([Dn],s=>{let t=s.facet(Dn);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var i;return(i=e.end)!==null&&i!==void 0?i:e.pos})),create:Qn.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),ch=M.define();class vd{constructor(t,e,i,n,r,o){this.view=t,this.source=e,this.field=i,this.locked=n,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(t){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.tile.nearest(e.target);if(!i)return;let n,r=1;if(i.isWidget())n=i.posAtStart;else{if(n=t.posAtCoords(e),n==null)return;let o=t.coordsAtPos(n);if(!o||e.y<o.top||e.y>o.bottom||e.x<o.left-t.defaultCharacterWidth||e.x>o.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(n)).find(h=>h.from<=n&&h.to>=n),a=l&&l.dir==j.RTL?-1:1;r=e.x<o.left?-a:a}this.activateHover(t,n,r)}activateHover(t,e,i,n){let r=this.source(t,e,i),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];n&&this.locked.set(a,n),t.dispatch({effects:this.setHover.of(a)})}};if(r&&"then"in r){let l=this.pending={pos:e};r.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>ut(t.state,a,"hover tooltip"))}else o(r)}get tooltip(){let t=this.view.plugin(zr),e=t?t.manager.tooltips.findIndex(i=>i.create==Qn.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:r}=this;if(n.length&&!this.locked.has(n)&&r&&!Sd(r.dom,t)||this.pending){let{pos:o}=n[0]||this.pending,l=(i=(e=n[0])===null||e===void 0?void 0:e.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!Cd(this.view,o,l,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length&&!this.locked.has(e)){let{tooltip:i}=this;i&&i.dom.contains(t.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e);let{active:n}=this;n.length&&!this.locked.has(n)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Ji=4;function Sd(s,t){let{left:e,right:i,top:n,bottom:r}=s.getBoundingClientRect(),o;if(o=s.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();n=Math.min(l.top,n),r=Math.max(l.bottom,r)}return t.clientX>=e-Ji&&t.clientX<=i+Ji&&t.clientY>=n-Ji&&t.clientY<=r+Ji}function Cd(s,t,e,i,n,r){let o=s.scrollDOM.getBoundingClientRect(),l=s.documentTop+s.documentPadding.top+s.contentHeight;if(o.left>i||o.right<i||o.top>n||Math.min(o.bottom,l)<n)return!1;let a=s.posAtCoords({x:i,y:n},!1);return a>=t&&a<=e}function Ad(s,t={}){let e=I.define(),i=new WeakMap,n=mt.define({create(){return[]},update(o,l){let a=i.get(o);if(o.length&&(t.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:t.hideOn&&(o=o.filter(h=>!t.hideOn(l,h)))),l.docChanged&&o.length){let h=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,ft.TrackDel);if(f!=null){let u=Object.assign(Object.create(null),c);u.pos=f,u.end!=null&&(u.end=l.changes.mapPos(u.end)),h.push(u)}}o=h}for(let h of l.effects)h.is(e)&&(o=h.value,a=void 0),(h.is(Od)&&!h.value||h.value==n)&&(o=[]);return o.length&&a&&i.set(o,a),o},provide:o=>Dn.from(o)});const r=st.define(o=>new vd(o,s,n,i,e,t.hoverTime||300));return{active:n,extension:[n,r,ch.of(r),kd]}}function Md(s,t,e,i={}){var n;let r=s.state.facet(ch).map(o=>s.plugin(o)).filter(o=>!!o);if(i.tooltip&&i.tooltip.active){let o=r.find(l=>l.field==i.tooltip.active);o&&(r=[o])}for(let o of r)o.activateHover(s,t,e,(n=i.until)!==null&&n!==void 0?n:(()=>!1))}function fh(s,t){let e=s.plugin(zr);if(!e)return null;let i=e.manager.tooltips.indexOf(t);return i<0?null:e.manager.tooltipViews[i]}const Od=I.define(),Zo=M.define({combine(s){let t,e;for(let i of s)t=t||i.topContainer,e=e||i.bottomContainer;return{topContainer:t,bottomContainer:e}}});function Td(s,t){let e=s.plugin(uh),i=e?e.specs.indexOf(t):-1;return i>-1?e.panels[i]:null}const uh=st.fromClass(class{constructor(s){this.input=s.state.facet(ur),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(e=>e(s));let t=s.state.facet(Zo);this.top=new Zi(s,!0,t.topContainer),this.bottom=new Zi(s,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(s){let t=s.state.facet(Zo);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Zi(s.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Zi(s.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let e=s.state.facet(ur);if(e!=this.input){let i=e.filter(a=>a),n=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(s.view),l.push(c)):(c=this.panels[h],c.update&&c.update(s)),n.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=n,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(s)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:s=>T.scrollMargins.of(t=>{let e=t.plugin(s);return e&&{top:e.top.scrollMargin(),bottom:e.bottom.scrollMargin()}})});class Zi{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,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";let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=tl(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=tl(t)}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 t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function tl(s){let t=s.nextSibling;return s.remove(),t}const ur=M.define({enables:uh});class le extends ye{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}le.prototype.elementClass="";le.prototype.toDOM=void 0;le.prototype.mapMode=ft.TrackBefore;le.prototype.startSide=le.prototype.endSide=-1;le.prototype.point=!0;const xs=M.define(),Dd=M.define(),Bd={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>R.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},bi=M.define();function dh(s){return[ph(),bi.of({...Bd,...s})]}const el=M.define({combine:s=>s.some(t=>t)});function ph(s){return[Pd]}const Pd=st.fromClass(class{constructor(s){this.view=s,this.domAfter=null,this.prevViewport=s.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=s.state.facet(bi).map(t=>new nl(s,t)),this.fixed=!s.state.facet(el);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),s.scrollDOM.insertBefore(this.dom,s.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(s){if(this.updateGutters(s)){let t=this.prevViewport,e=s.view.viewport,i=Math.min(t.to,e.to)-Math.max(t.from,e.from);this.syncGutters(i<(e.to-e.from)*.8)}if(s.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(el)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=s.view.viewport}syncGutters(s){let t=this.dom.nextSibling;s&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let e=R.iter(this.view.state.facet(xs),this.view.viewport.from),i=[],n=this.gutters.map(r=>new Rd(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==nt.Text&&o){dr(e,i,l.from);for(let a of n)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of n)a.widget(this.view,l)}else if(r.type==nt.Text){dr(e,i,r.from);for(let o of n)o.line(this.view,r,i)}else if(r.widget)for(let o of n)o.widget(this.view,r);for(let r of n)r.finish();s&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(s){let t=s.startState.facet(bi),e=s.state.facet(bi),i=s.docChanged||s.heightChanged||s.viewportChanged||!R.eq(s.startState.facet(xs),s.state.facet(xs),s.view.viewport.from,s.view.viewport.to);if(t==e)for(let n of this.gutters)n.update(s)&&(i=!0);else{i=!0;let n=[];for(let r of e){let o=t.indexOf(r);o<0?n.push(new nl(this.view,r)):(this.gutters[o].update(s),n.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),n.indexOf(r)<0&&r.destroy();for(let r of n)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=n}return i}destroy(){for(let s of this.gutters)s.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:s=>T.scrollMargins.of(t=>{let e=t.plugin(s);if(!e||e.gutters.length==0||!e.fixed)return null;let i=e.dom.offsetWidth*t.scaleX,n=e.domAfter?e.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==j.LTR?{left:i,right:n}:{right:i,left:n}})});function il(s){return Array.isArray(s)?s:[s]}function dr(s,t,e){for(;s.value&&s.from<=e;)s.from==e&&t.push(s.value),s.next()}class Rd{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=R.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,r=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==n.elements.length){let l=new mh(t,o,r,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(t,o,r,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];dr(this.cursor,n,e.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(t,e,n);r&&n.unshift(r);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let r of t.state.facet(Dd)){let o=r(t,e.widget,e);o&&(n||(n=[])).push(o)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class nl{constructor(t,e){this.view=t,this.config=e,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 e.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=n.clientY;let l=t.lineBlockAtHeight(o-t.documentTop);e.domEventHandlers[i](t,l,n)&&n.preventDefault()});this.markers=il(e.markers(t)),e.initialSpacer&&(this.spacer=new mh(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=il(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],t);n!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[n])}let i=t.view.viewport;return!R.eq(this.markers,e,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class mh{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Ld(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<e.length?e[r++]: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(n);let f=n.nextSibling;n.remove(),n=f}}if(!a)break;a.toDOM&&(h?n=n.nextSibling:this.dom.insertBefore(a.toDOM(t),n)),h&&o++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}function Ld(s,t){if(s.length!=t.length)return!1;for(let e=0;e<s.length;e++)if(!s[e].compare(t[e]))return!1;return!0}const Ed=M.define(),Id=M.define(),qe=M.define({combine(s){return he(s,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let n in e){let r=i[n],o=e[n];i[n]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return i}})}});class ws extends le{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function ks(s,t){return s.state.facet(qe).formatNumber(t,s.state)}const Nd=bi.compute([qe],s=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Ed)},lineMarker(t,e,i){return i.some(n=>n.toDOM)?null:new ws(ks(t,t.state.doc.lineAt(e.from).number))},widgetMarker:(t,e,i)=>{for(let n of t.state.facet(Id)){let r=n(t,e,i);if(r)return r}return null},lineMarkerChange:t=>t.startState.facet(qe)!=t.state.facet(qe),initialSpacer(t){return new ws(ks(t,sl(t.state.doc.lines)))},updateSpacer(t,e){let i=ks(e.view,sl(e.view.state.doc.lines));return i==t.number?t:new ws(i)},domEventHandlers:s.facet(qe).domEventHandlers,side:"before"}));function Hd(s={}){return[qe.of(s),ph(),Nd]}function sl(s){let t=9;for(;t<s;)t=t*10+9;return t}const gh=1024;let Wd=0;class vs{constructor(t,e){this.from=t,this.to=e}}class L{constructor(t={}){this.id=Wd++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=xt.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}}L.closedBy=new L({deserialize:s=>s.split(" ")});L.openedBy=new L({deserialize:s=>s.split(" ")});L.group=new L({deserialize:s=>s.split(" ")});L.isolate=new L({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});L.contextHash=new L({perNode:!0});L.lookAhead=new L({perNode:!0});L.mounted=new L({perNode:!0});class xi{constructor(t,e,i,n=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=n}static get(t){return t&&t.props&&t.props[L.mounted.id]}}const Fd=Object.create(null);class xt{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):Fd,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),n=new xt(t.name||"",e,t.id,i);if(t.props){for(let r of t.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}}return n}prop(t){return this.props[t.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(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(L.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return i=>{for(let n=i.prop(L.group),r=-1;r<(n?n.length:0);r++){let o=e[r<0?i.name:n[r]];if(o)return o}}}}xt.none=new xt("",Object.create(null),0,8);class $r{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let r of t){let o=r(i);if(o){n||(n=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in n&&(l=a.combine(n[a.id],l)),n[a.id]=l}}e.push(n?new xt(i.name,n,i.id,i.flags):i)}return new $r(e)}}const tn=new WeakMap,rl=new WeakMap;var G;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(G||(G={}));class X{constructor(t,e,i,n,r){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=xi.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let n=i.toString();n&&(e&&(e+=","),e+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new mr(this.topNode,t)}cursorAt(t,e=0,i=0){let n=tn.get(this)||this.topNode,r=new mr(n);return r.moveTo(t,e),tn.set(this,r._tree),r}get topNode(){return new Rt(this,0,0,null)}resolve(t,e=0){let i=Oi(tn.get(this)||this.topNode,t,e,!1);return tn.set(this,i),i}resolveInner(t,e=0){let i=Oi(rl.get(this)||this.topNode,t,e,!0);return rl.set(this,i),i}resolveStack(t,e=0){return $d(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:r=this.length}=t,o=t.mode||0,l=(o&G.IncludeAnonymous)>0;for(let a=this.cursor(o|G.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=n&&(!l&&a.type.isAnonymous||e(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(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:Kr(xt.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,n)=>new X(this.type,e,i,n,this.propValues),t.makeTree||((e,i,n)=>new X(xt.none,e,i,n)))}static build(t){return qd(t)}}X.empty=new X(xt.none,[],[],0);class qr{constructor(t,e){this.buffer=t,this.index=e}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 qr(this.buffer,this.index)}}class ke{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return xt.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),t+=4,i==t)return r;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return r+"("+o.join(",")+")"}findChild(t,e,i,n,r){let{buffer:o}=this,l=-1;for(let a=t;a!=e&&!(yh(r,n,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(t,e,i){let n=this.buffer,r=new Uint16Array(e-t),o=0;for(let l=t,a=0;l<e;){r[a++]=n[l++],r[a++]=n[l++]-i;let h=r[a++]=n[l++]-i;r[a++]=n[l++]-t,o=Math.max(o,h)}return new ke(r,o,this.set)}}function yh(s,t,e,i){switch(s){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function Oi(s,t,e,i){for(var n;s.from==s.to||(e<1?s.from>=t:s.from>t)||(e>-1?s.to<=t:s.to<t);){let o=!i&&s instanceof Rt&&s.index<0?null:s.parent;if(!o)return s;s=o}let r=i?0:G.IgnoreOverlays;if(i)for(let o=s,l=o.parent;l;o=l,l=o.parent)o instanceof Rt&&o.index<0&&((n=l.enter(t,e,r))===null||n===void 0?void 0:n.from)!=o.from&&(s=l);for(;;){let o=s.enter(t,e,r);if(!o)return s;s=o}}class bh{cursor(t=0){return new mr(this,t)}getChild(t,e=null,i=null){let n=ol(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return ol(this,t,e,i)}resolve(t,e=0){return Oi(this,t,e,!1)}resolveInner(t,e=0){return Oi(this,t,e,!0)}matchContext(t){return pr(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let n=e.lastChild;if(!n||n.to!=e.to)break;n.type.isError&&n.from==n.to?(i=e,e=n.prevSibling):e=n}return i}get node(){return this}get next(){return this.parent}}class Rt extends bh{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=e>0?l.length:-1;t!=h;t+=e){let c=l[t],f=a[t]+o.from,u;if(!(!(r&G.EnterBracketed&&c instanceof X&&(u=xi.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!yh(n,i,f,f+c.length))){if(c instanceof ke){if(r&G.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,e,i-f,n);if(d>-1)return new ge(new Vd(o,c,t,f),null,d)}else if(r&G.IncludeAnonymous||!c.type.isAnonymous||jr(c)){let d;if(!(r&G.IgnoreMounts)&&(d=xi.get(c))&&!d.overlay)return new Rt(d.tree,f,t,o);let p=new Rt(c,f,t,o);return r&G.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(e<0?c.children.length-1:0,e,i,n,r)}}}if(r&G.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<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(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let n;if(!(i&G.IgnoreOverlays)&&(n=xi.get(this._tree))&&n.overlay){let r=t-this.from,o=i&G.EnterBracketed&&n.bracketed;for(let{from:l,to:a}of n.overlay)if((e>0||o?l<=r:l<r)&&(e<0||o?a>=r:a>r))return new Rt(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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 ol(s,t,e,i){let n=s.cursor(),r=[];if(!n.firstChild())return r;if(e!=null){for(let o=!1;!o;)if(o=n.type.is(e),!n.nextSibling())return r}for(;;){if(i!=null&&n.type.is(i))return r;if(n.type.is(t)&&r.push(n.node),!n.nextSibling())return i==null?r:[]}}function pr(s,t,e=t.length-1){for(let i=s;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}class Vd{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class ge extends bh{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(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return r<0?null:new ge(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&G.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new ge(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new ge(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new ge(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let o=i.buffer[this.index+1];t.push(i.slice(n,r,o)),e.push(0)}return new X(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function xh(s){if(!s.length)return null;let t=0,e=s[0];for(let r=1;r<s.length;r++){let o=s[r];(o.from>e.from||o.to<e.to)&&(e=o,t=r)}let i=e instanceof Rt&&e.index<0?null:e.parent,n=s.slice();return i?n[t]=i:n.splice(t,1),new zd(n,e)}class zd{constructor(t,e){this.heads=t,this.node=e}get next(){return xh(this.heads)}}function $d(s,t,e){let i=s.resolveInner(t,e),n=null;for(let r=i instanceof Rt?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(n||(n=[i])).push(o.resolve(t,e)),r=o}else{let o=xi.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let l=new Rt(o.tree,o.overlay[0].from+r.from,-1,r);(n||(n=[i])).push(Oi(l,t,e,!1))}}return n?xh(n):i}class mr{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~G.EnterBracketed,t instanceof Rt)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return t?t instanceof Rt?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&G.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&G.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&G.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(e.findChild(n,this.index,-1,0,4))}else{let n=e.buffer[this.index+3];if(n<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(n.buffer.buffer[r+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let r=e+t,o=t<0?-1:i._tree.children.length;r!=o;r+=t){let l=i._tree.children[r];if(this.mode&G.IncludeAnonymous||l instanceof ke||!l.type.isAnonymous||jr(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,r=this.stack.length;r>=0;){for(let o=t;o;o=o._parent)if(o.index==n){if(n==this.index)return o;e=o,i=r+1;break t}n=this.stack[--r]}for(let n=i;n<this.stack.length;n++)e=new ge(this.buffer,e,this.stack[n]);return this.bufferNode=new ge(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return pr(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return pr(this._tree,t,n);let o=i[e.buffer[this.stack[r]]];if(!o.isAnonymous){if(t[n]&&t[n]!=o.name)return!1;n--}}return!0}}function jr(s){return s.children.some(t=>t instanceof ke||!t.type.isAnonymous||jr(t))}function qd(s){var t;let{buffer:e,nodeSet:i,maxBufferLength:n=gh,reused:r=[],minRepeatType:o=i.types.length}=s,l=Array.isArray(e)?new qr(e,e.length):e,a=i.types,h=0,c=0;function f(k,v,S,P,N,$){let{id:E,start:B,end:z,size:F}=l,K=c,ht=h;if(F<0)if(l.next(),F==-1){let te=r[E];S.push(te),P.push(B-k);return}else if(F==-3){h=E;return}else if(F==-4){c=E;return}else throw new RangeError(`Unrecognized record size: ${F}`);let wt=a[E],Vt,tt,At=B-k;if(z-B<=n&&(tt=g(l.pos-v,N))){let te=new Uint16Array(tt.size-tt.skip),Mt=l.pos-tt.size,zt=te.length;for(;l.pos>Mt;)zt=y(tt.start,te,zt);Vt=new ke(te,z-tt.start,i),At=tt.start-k}else{let te=l.pos-F;l.next();let Mt=[],zt=[],Ae=E>=o?E:-1,Fe=0,Fi=z;for(;l.pos>te;)Ae>=0&&l.id==Ae&&l.size>=0?(l.end<=Fi-n&&(p(Mt,zt,B,Fe,l.end,Fi,Ae,K,ht),Fe=Mt.length,Fi=l.end),l.next()):$>2500?u(B,te,Mt,zt):f(B,te,Mt,zt,Ae,$+1);if(Ae>=0&&Fe>0&&Fe<Mt.length&&p(Mt,zt,B,Fe,B,Fi,Ae,K,ht),Mt.reverse(),zt.reverse(),Ae>-1&&Fe>0){let so=d(wt,ht);Vt=Kr(wt,Mt,zt,0,Mt.length,0,z-B,so,so)}else Vt=m(wt,Mt,zt,z-B,K-z,ht)}S.push(Vt),P.push(At)}function u(k,v,S,P){let N=[],$=0,E=-1;for(;l.pos>v;){let{id:B,start:z,end:F,size:K}=l;if(K>4)l.next();else{if(E>-1&&z<E)break;E<0&&(E=F-n),N.push(B,z,F),$++,l.next()}}if($){let B=new Uint16Array($*4),z=N[N.length-2];for(let F=N.length-3,K=0;F>=0;F-=3)B[K++]=N[F],B[K++]=N[F+1]-z,B[K++]=N[F+2]-z,B[K++]=K;S.push(new ke(B,N[2]-z,i)),P.push(z-k)}}function d(k,v){return(S,P,N)=>{let $=0,E=S.length-1,B,z;if(E>=0&&(B=S[E])instanceof X){if(!E&&B.type==k&&B.length==N)return B;(z=B.prop(L.lookAhead))&&($=P[E]+B.length+z)}return m(k,S,P,N,$,v)}}function p(k,v,S,P,N,$,E,B,z){let F=[],K=[];for(;k.length>P;)F.push(k.pop()),K.push(v.pop()+S-N);k.push(m(i.types[E],F,K,$-N,B-$,z)),v.push(N-S)}function m(k,v,S,P,N,$,E){if($){let B=[L.contextHash,$];E=E?[B].concat(E):[B]}if(N>25){let B=[L.lookAhead,N];E=E?[B].concat(E):[B]}return new X(k,v,S,P,E)}function g(k,v){let S=l.fork(),P=0,N=0,$=0,E=S.end-n,B={size:0,start:0,skip:0};t:for(let z=S.pos-k;S.pos>z;){let F=S.size;if(S.id==v&&F>=0){B.size=P,B.start=N,B.skip=$,$+=4,P+=4,S.next();continue}let K=S.pos-F;if(F<0||K<z||S.start<E)break;let ht=S.id>=o?4:0,wt=S.start;for(S.next();S.pos>K;){if(S.size<0)if(S.size==-3||S.size==-4)ht+=4;else break t;else S.id>=o&&(ht+=4);S.next()}N=wt,P+=F,$+=ht}return(v<0||P==k)&&(B.size=P,B.start=N,B.skip=$),B.size>4?B:void 0}function y(k,v,S){let{id:P,start:N,end:$,size:E}=l;if(l.next(),E>=0&&P<o){let B=S;if(E>4){let z=l.pos-(E-4);for(;l.pos>z;)S=y(k,v,S)}v[--S]=B,v[--S]=$-k,v[--S]=N-k,v[--S]=P}else E==-3?h=P:E==-4&&(c=P);return S}let w=[],b=[];for(;l.pos>0;)f(s.start||0,s.bufferStart||0,w,b,-1,0);let O=(t=s.length)!==null&&t!==void 0?t:w.length?b[0]+w[0].length:0;return new X(a[s.topID],w.reverse(),b.reverse(),O)}const ll=new WeakMap;function mn(s,t){if(!s.isAnonymous||t instanceof ke||t.type!=s)return 1;let e=ll.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=s||!(i instanceof X)){e=1;break}e+=mn(s,i)}ll.set(t,e)}return e}function Kr(s,t,e,i,n,r,o,l,a){let h=0;for(let p=i;p<n;p++)h+=mn(s,t[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,m,g,y,w){for(let b=g;b<y;){let O=b,k=m[b],v=mn(s,p[b]);for(b++;b<y;b++){let S=mn(s,p[b]);if(v+S>=c)break;v+=S}if(b==O+1){if(v>c){let S=p[O];d(S.children,S.positions,0,S.children.length,m[O]+w);continue}f.push(p[O])}else{let S=m[b-1]+p[b-1].length-k;f.push(Kr(s,p,m,O,b,k,S,null,a))}u.push(k+w-r)}}return d(t,e,i,n,0),(l||a)(f,u,o)}class Le{constructor(t,e,i,n,r=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let n=[new Le(0,t.length,t,0,!1,i)];for(let r of e)r.to>t.length&&n.push(r);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],r=1,o=t.length?t[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<e.length?e[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 d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new Le(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&n.push(u),o.to>f)break;o=r<t.length?t[r++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return n}}class wh{startParse(t,e,i){return typeof t=="string"&&(t=new jd(t)),i=i?i.length?i.map(n=>new vs(n.from,n.to)):[new vs(0,0)]:[new vs(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let r=n.advance();if(r)return r}}}class jd{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new L({perNode:!0});let Kd=0;class Ot{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=Kd++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof Ot&&(e=t),e?.base)throw new Error("Can not derive from a modified tag");let n=new Ot(i,[],null,[]);if(n.set.push(n),e)for(let r of e.set)n.set.push(r);return n}static defineModifier(t){let e=new Bn(t);return i=>i.modified.indexOf(e)>-1?i:Bn.get(i.base||i,i.modified.concat(e).sort((n,r)=>n.id-r.id))}}let Ud=0;class Bn{constructor(t){this.name=t,this.instances=[],this.id=Ud++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&Gd(e,l.modified));if(i)return i;let n=[],r=new Ot(t.name,n,t,e);for(let l of e)l.instances.push(r);let o=Yd(e);for(let l of t.set)if(!l.modified.length)for(let a of o)n.push(Bn.get(l,a));return r}}function Gd(s,t){return s.length==t.length&&s.every((e,i)=>e==t[i])}function Yd(s){let t=[[]];for(let e=0;e<s.length;e++)for(let i=0,n=t.length;i<n;i++)t.push(t[i].concat(s[e]));return t.sort((e,i)=>i.length-e.length)}function kh(s){let t=Object.create(null);for(let e in s){let i=s[e];Array.isArray(i)||(i=[i]);for(let n of e.split(" "))if(n){let r=[],o=2,l=n;for(let f=0;;){if(l=="..."&&f>0&&f+3==n.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+n);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==n.length)break;let d=n[f++];if(f==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(f)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+n);let c=new Ti(i,o,a>0?r.slice(0,a):null);t[h]=c.sort(t[h])}}return vh.add(t)}const vh=new L({combine(s,t){let e,i,n;for(;s||t;){if(!s||t&&s.depth>=t.depth?(n=t,t=t.next):(n=s,s=s.next),e&&e.mode==n.mode&&!n.context&&!e.context)continue;let r=new Ti(n.tags,n.mode,n.context);e?e.next=r:i=r,e=r}return i}});class Ti{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}Ti.empty=new Ti([],2,null);function Sh(s,t){let e=Object.create(null);for(let r of s)if(!Array.isArray(r.tag))e[r.tag.id]=r.class;else for(let o of r.tag)e[o.id]=r.class;let{scope:i,all:n=null}=t||{};return{style:r=>{let o=n;for(let l of r)for(let a of l.set){let h=e[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Qd(s,t){let e=null;for(let i of s){let n=i.style(t);n&&(e=e?e+" "+n:n)}return e}function Xd(s,t,e,i=0,n=s.length){let r=new _d(i,Array.isArray(t)?t:[t],e);r.highlightRange(s.cursor(),i,n,"",r.highlighters),r.flush(n)}class _d{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,r){let{type:o,from:l,to:a}=t;if(l>=i||a<=e)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=n,c=Jd(t)||Ti.empty,f=Qd(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(e,l),h),c.opaque)return;let u=t.tree&&t.tree.prop(L.mounted);if(u&&u.overlay){let d=t.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=t.firstChild();for(let g=0,y=l;;g++){let w=g<u.overlay.length?u.overlay[g]:null,b=w?w.from+l:a,O=Math.max(e,y),k=Math.min(i,b);if(O<k&&m)for(;t.from<k&&(this.highlightRange(t,O,k,n,r),this.startSpan(Math.min(k,t.to),h),!(t.to>=b||!t.nextSibling())););if(!w||b>i)break;y=w.to+l,y>e&&(this.highlightRange(d.cursor(),Math.max(e,w.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}m&&t.parent()}else if(t.firstChild()){u&&(n="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,r),this.startSpan(Math.min(i,t.to),h)}while(t.nextSibling());t.parent()}}}function Jd(s){let t=s.type.prop(vh);for(;t&&t.context&&!s.matchContext(t.context);)t=t.next;return t||null}const C=Ot.define,en=C(),fe=C(),al=C(fe),hl=C(fe),ue=C(),nn=C(ue),Ss=C(ue),Kt=C(),Me=C(Kt),qt=C(),jt=C(),gr=C(),ai=C(gr),sn=C(),D={comment:en,lineComment:C(en),blockComment:C(en),docComment:C(en),name:fe,variableName:C(fe),typeName:al,tagName:C(al),propertyName:hl,attributeName:C(hl),className:C(fe),labelName:C(fe),namespace:C(fe),macroName:C(fe),literal:ue,string:nn,docString:C(nn),character:C(nn),attributeValue:C(nn),number:Ss,integer:C(Ss),float:C(Ss),bool:C(ue),regexp:C(ue),escape:C(ue),color:C(ue),url:C(ue),keyword:qt,self:C(qt),null:C(qt),atom:C(qt),unit:C(qt),modifier:C(qt),operatorKeyword:C(qt),controlKeyword:C(qt),definitionKeyword:C(qt),moduleKeyword:C(qt),operator:jt,derefOperator:C(jt),arithmeticOperator:C(jt),logicOperator:C(jt),bitwiseOperator:C(jt),compareOperator:C(jt),updateOperator:C(jt),definitionOperator:C(jt),typeOperator:C(jt),controlOperator:C(jt),punctuation:gr,separator:C(gr),bracket:ai,angleBracket:C(ai),squareBracket:C(ai),paren:C(ai),brace:C(ai),content:Kt,heading:Me,heading1:C(Me),heading2:C(Me),heading3:C(Me),heading4:C(Me),heading5:C(Me),heading6:C(Me),contentSeparator:C(Kt),list:C(Kt),quote:C(Kt),emphasis:C(Kt),strong:C(Kt),link:C(Kt),monospace:C(Kt),strikethrough:C(Kt),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:sn,documentMeta:C(sn),annotation:C(sn),processingInstruction:C(sn),definition:Ot.defineModifier("definition"),constant:Ot.defineModifier("constant"),function:Ot.defineModifier("function"),standard:Ot.defineModifier("standard"),local:Ot.defineModifier("local"),special:Ot.defineModifier("special")};for(let s in D){let t=D[s];t instanceof Ot&&(t.name=s)}Sh([{tag:D.link,class:"tok-link"},{tag:D.heading,class:"tok-heading"},{tag:D.emphasis,class:"tok-emphasis"},{tag:D.strong,class:"tok-strong"},{tag:D.keyword,class:"tok-keyword"},{tag:D.atom,class:"tok-atom"},{tag:D.bool,class:"tok-bool"},{tag:D.url,class:"tok-url"},{tag:D.labelName,class:"tok-labelName"},{tag:D.inserted,class:"tok-inserted"},{tag:D.deleted,class:"tok-deleted"},{tag:D.literal,class:"tok-literal"},{tag:D.string,class:"tok-string"},{tag:D.number,class:"tok-number"},{tag:[D.regexp,D.escape,D.special(D.string)],class:"tok-string2"},{tag:D.variableName,class:"tok-variableName"},{tag:D.local(D.variableName),class:"tok-variableName tok-local"},{tag:D.definition(D.variableName),class:"tok-variableName tok-definition"},{tag:D.special(D.variableName),class:"tok-variableName2"},{tag:D.definition(D.propertyName),class:"tok-propertyName tok-definition"},{tag:D.typeName,class:"tok-typeName"},{tag:D.namespace,class:"tok-namespace"},{tag:D.className,class:"tok-className"},{tag:D.macroName,class:"tok-macroName"},{tag:D.propertyName,class:"tok-propertyName"},{tag:D.operator,class:"tok-operator"},{tag:D.comment,class:"tok-comment"},{tag:D.meta,class:"tok-meta"},{tag:D.invalid,class:"tok-invalid"},{tag:D.punctuation,class:"tok-punctuation"}]);var Cs;const je=new L;function Zd(s){return M.define({combine:s?t=>t.concat(s):void 0})}const tp=new L;class Nt{constructor(t,e,i=[],n=""){this.data=t,this.name=n,V.prototype.hasOwnProperty("tree")||Object.defineProperty(V.prototype,"tree",{get(){return rt(this)}}),this.parser=e,this.extension=[ve.of(this),V.languageData.of((r,o,l)=>{let a=cl(r,o,l),h=a.type.prop(je);if(!h)return[];let c=r.facet(h),f=a.type.prop(tp);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(t,e,i=-1){return cl(t,e,i).type.prop(je)==this.data}findRegions(t){let e=t.facet(ve);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(r,o)=>{if(r.prop(je)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(L.mounted);if(l){if(l.tree.prop(je)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof X&&n(h,r.positions[a]+o)}};return n(rt(t),0),i}get allowsNesting(){return!0}}Nt.setState=I.define();function cl(s,t,e){let i=s.facet(ve),n=rt(s).topNode;if(!i||i.allowsNesting)for(let r=n;r;r=r.enter(t,e,G.ExcludeBuffers|G.EnterBracketed))r.type.isTop&&(n=r);return n}class Pn extends Nt{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Zd(t.languageData);return new Pn(e,t.parser.configure({props:[je.add(i=>i.isTop?e:void 0)]}),t.name)}configure(t,e){return new Pn(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function rt(s){let t=s.field(Nt.state,!1);return t?t.tree:X.empty}class ep{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let hi=null;class Rn{constructor(t,e,i=[],n,r,o,l,a){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Rn(t,e,[],X.empty,0,i,[],null)}startParse(){return this.parser.startParse(new ep(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=X.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let n=Date.now()+t;t=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(Le.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Le.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=hi;hi=this;try{return t()}finally{hi=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=fl(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let a=[];if(t.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=Le.applyChanges(i,a),n=X.empty,r=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=t.mapPos(h.from,1),f=t.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new Rn(this.parser,e,i,n,r,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:r}=this.skipped[i];n<t.to&&r>t.from&&(this.fragments=fl(this.fragments,n,r),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends wh{createParse(e,i,n){let r=n[0].from,o=n[n.length-1].to;return{parsedPos:r,advance(){let a=hi;if(a){for(let h of n)a.tempSkipped.push(h);t&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,t]):t)}return this.parsedPos=o,new X(xt.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return hi}}function fl(s,t,e){return Le.applyChanges(s,[{fromA:t,toA:e,fromB:t,toB:e}])}class ni{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new ni(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Rn.create(t.facet(ve).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new ni(i)}}Nt.state=mt.define({create:ni.init,update(s,t){for(let e of t.effects)if(e.is(Nt.setState))return e.value;return t.startState.facet(ve)!=t.state.facet(ve)?ni.init(t.state):s.apply(t)}});let Ch=s=>{let t=setTimeout(()=>s(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Ch=s=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(s,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const As=typeof navigator<"u"&&(!((Cs=navigator.scheduling)===null||Cs===void 0)&&Cs.isInputPending)?()=>navigator.scheduling.isInputPending():null,ip=st.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Nt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Nt.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=Ch(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(Nt.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!As?Math.max(25,t.timeRemaining()-5):1e9),l=r.context.treeLen<n&&i.doc.length>n+1e3,a=r.context.work(()=>As&&As()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Nt.setState.of(new ni(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>ut(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ve=M.define({combine(s){return s.length?s[0]:null},enables:s=>[Nt.state,ip,T.contentAttributes.compute([s],t=>{let e=t.facet(s);return e&&e.name?{"data-language":e.name}:{}})]});class np{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const sp=M.define(),Ur=M.define({combine:s=>{if(!s.length)return" ";let t=s[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(s[0]));return t}});function Ln(s){let t=s.facet(Ur);return t.charCodeAt(0)==9?s.tabSize*t.length:t.length}function Di(s,t){let e="",i=s.tabSize,n=s.facet(Ur)[0];if(n==" "){for(;t>=i;)e+=" ",t-=i;n=" "}for(let r=0;r<t;r++)e+=n;return e}function Gr(s,t){s instanceof V&&(s=new Xn(s));for(let i of s.state.facet(sp)){let n=i(s,t);if(n!==void 0)return n}let e=rt(s.state);return e.length>=t?rp(s,e,t):null}class Xn{constructor(t,e={}){this.state=t,this.options=e,this.unit=Ln(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return n!=null&&n>=i.from&&n<=i.to?r&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.countColumn(i,t-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return Li(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let o=r(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ah=new L;function rp(s,t,e){let i=t.resolveStack(e),n=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(n!=i.node){let r=[];for(let o=n;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return Mh(i,s,e)}function Mh(s,t,e){for(let i=s;i;i=i.next){let n=lp(i.node);if(n)return n(Yr.create(t,e,i))}return 0}function op(s){return s.pos==s.options.simulateBreak&&s.options.simulateDoubleBreak}function lp(s){let t=s.type.prop(Ah);if(t)return t;let e=s.firstChild,i;if(e&&(i=e.type.prop(L.closedBy))){let n=s.lastChild,r=n&&i.indexOf(n.name)>-1;return o=>fp(o,!0,1,void 0,r&&!op(o)?n.from:void 0)}return s.parent==null?ap:null}function ap(){return 0}class Yr extends Xn{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new Yr(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(hp(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Mh(this.context.next,this.base,this.pos)}}function hp(s,t){for(let e=t;e;e=e.parent)if(s==e)return!0;return!1}function cp(s){let t=s.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let n=s.options.simulateBreak,r=s.state.doc.lineAt(e.from),o=n==null||n<=r.from?r.to:Math.min(r.to,n);for(let l=e.to;;){let a=t.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(e.to-r.from))[0].length;return{from:e.from,to:e.to+h}}l=a.to}}function fp(s,t,e,i,n){let r=s.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||n==s.pos+o,a=cp(s);return a?l?s.column(a.from):s.column(a.to):s.baseIndent+(l?0:s.unit*e)}function ul({except:s,units:t=1}={}){return e=>{let i=s&&s.test(e.textAfter);return e.baseIndent+(i?0:t*e.unit)}}const up=200;function dp(){return V.transactionFilter.of(s=>{if(!s.docChanged||!s.isUserEvent("input.type")&&!s.isUserEvent("input.complete"))return s;let t=s.startState.languageDataAt("indentOnInput",s.startState.selection.main.head);if(!t.length)return s;let e=s.newDoc,{head:i}=s.newSelection.main,n=e.lineAt(i);if(i>n.from+up)return s;let r=e.sliceString(n.from,i);if(!t.some(h=>h.test(r)))return s;let{state:o}=s,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=Gr(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=Di(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[s,{changes:a,sequential:!0}]:s})}const pp=M.define(),Oh=new L;function mp(s){let t=s.firstChild,e=s.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?s.to:e.from}:null}function gp(s,t,e){let i=rt(s);if(i.length<e)return null;let n=i.resolveStack(e,1),r=null;for(let o=n;o;o=o.next){let l=o.node;if(l.to<=e||l.from>e)continue;if(r&&l.from<t)break;let a=l.type.prop(Oh);if(a&&(l.to<i.length-50||i.length==s.doc.length||!yp(l))){let h=a(l,s);h&&h.from<=e&&h.from>=t&&h.to>e&&(r=h)}}return r}function yp(s){let t=s.lastChild;return t&&t.to==s.to&&t.type.isError}function En(s,t,e){for(let i of s.facet(pp)){let n=i(s,t,e);if(n)return n}return gp(s,t,e)}function Th(s,t){let e=t.mapPos(s.from,1),i=t.mapPos(s.to,-1);return e>=i?void 0:{from:e,to:i}}const _n=I.define({map:Th}),Hi=I.define({map:Th});function Dh(s){let t=[];for(let{head:e}of s.state.selection.ranges)t.some(i=>i.from<=e&&i.to>=e)||t.push(s.lineBlockAt(e));return t}const We=mt.define({create(){return H.none},update(s,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((i,n)=>s=dl(s,i,n)),s=s.map(t.changes);let e=[];for(let i of t.effects)i.is(_n)&&!bp(s,i.value.from,i.value.to)?e.push(i.value):i.is(Hi)&&(s=s.update({filter:(n,r)=>i.value.from!=n||i.value.to!=r,filterFrom:i.value.from,filterTo:i.value.to}));if(e.length){let{preparePlaceholder:i}=t.state.facet(Rh),n=e.map(r=>(i?H.replace({widget:new Ap(i(t.state,r))}):pl).range(r.from,r.to));s=s.update({add:n})}return t.selection&&(s=dl(s,t.selection.main.head)),s},provide:s=>T.decorations.from(s),toJSON(s,t){let e=[];return s.between(0,t.doc.length,(i,n)=>{e.push(i,n)}),e},fromJSON(s){if(!Array.isArray(s)||s.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let e=0;e<s.length;){let i=s[e++],n=s[e++];if(typeof i!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");t.push(pl.range(i,n))}return H.set(t,!0)}});function dl(s,t,e=t){let i=!1;return s.between(t,e,(n,r)=>{n<e&&r>t&&(i=!0)}),i?s.update({filterFrom:t,filterTo:e,filter:(n,r)=>n>=e||r<=t}):s}function In(s,t,e){var i;let n=null;return(i=s.field(We,!1))===null||i===void 0||i.between(t,e,(r,o)=>{(!n||n.from>r)&&(n={from:r,to:o})}),n}function bp(s,t,e){let i=!1;return s.between(t,t,(n,r)=>{n==t&&r==e&&(i=!0)}),i}function Bh(s,t){return s.field(We,!1)?t:t.concat(I.appendConfig.of(Lh()))}const xp=s=>{for(let t of Dh(s)){let e=En(s.state,t.from,t.to);if(e)return s.dispatch({effects:Bh(s.state,[_n.of(e),Ph(s,e)])}),!0}return!1},wp=s=>{if(!s.state.field(We,!1))return!1;let t=[];for(let e of Dh(s)){let i=In(s.state,e.from,e.to);i&&t.push(Hi.of(i),Ph(s,i,!1))}return t.length&&s.dispatch({effects:t}),t.length>0};function Ph(s,t,e=!0){let i=s.state.doc.lineAt(t.from).number,n=s.state.doc.lineAt(t.to).number;return T.announce.of(`${s.state.phrase(e?"Folded lines":"Unfolded lines")} ${i} ${s.state.phrase("to")} ${n}.`)}const kp=s=>{let{state:t}=s,e=[];for(let i=0;i<t.doc.length;){let n=s.lineBlockAt(i),r=En(t,n.from,n.to);r&&e.push(_n.of(r)),i=(r?s.lineBlockAt(r.to):n).to+1}return e.length&&s.dispatch({effects:Bh(s.state,e)}),!!e.length},vp=s=>{let t=s.state.field(We,!1);if(!t||!t.size)return!1;let e=[];return t.between(0,s.state.doc.length,(i,n)=>{e.push(Hi.of({from:i,to:n}))}),s.dispatch({effects:e}),!0},Sp=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:xp},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:wp},{key:"Ctrl-Alt-[",run:kp},{key:"Ctrl-Alt-]",run:vp}],Cp={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Rh=M.define({combine(s){return he(s,Cp)}});function Lh(s){return[We,Tp]}function Eh(s,t){let{state:e}=s,i=e.facet(Rh),n=o=>{let l=s.lineBlockAt(s.posAtDOM(o.target)),a=In(s.state,l.from,l.to);a&&s.dispatch({effects:Hi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(s,n,t);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",e.phrase("folded code")),r.title=e.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=n,r}const pl=H.replace({widget:new class extends ce{toDOM(s){return Eh(s,null)}}});class Ap extends ce{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Eh(t,this.value)}}const Mp={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Ms extends le{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function Op(s={}){let t={...Mp,...s},e=new Ms(t,!0),i=new Ms(t,!1),n=st.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(ve)!=o.state.facet(ve)||o.startState.field(We,!1)!=o.state.field(We,!1)||rt(o.startState)!=rt(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new se;for(let a of o.viewportLineBlocks){let h=In(o.state,a.from,a.to)?i:En(o.state,a.from,a.to)?e:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=t;return[n,dh({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(n))===null||l===void 0?void 0:l.markers)||R.empty},initialSpacer(){return new Ms(t,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=In(o.state,l.from,l.to);if(h)return o.dispatch({effects:Hi.of(h)}),!0;let c=En(o.state,l.from,l.to);return c?(o.dispatch({effects:_n.of(c)}),!0):!1}}}),Lh()]}const Tp=T.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Jn{constructor(t,e){this.specs=t;let i;function n(l){let a=be.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof e.all=="string"?e.all:e.all?n(e.all):void 0,o=e.scope;this.scope=o instanceof Nt?l=>l.prop(je)==o.data:o?l=>l==o:void 0,this.style=Sh(t.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new be(i):null,this.themeType=e.themeType}static define(t,e){return new Jn(t,e||{})}}const yr=M.define(),Ih=M.define({combine(s){return s.length?[s[0]]:null}});function Os(s){let t=s.facet(yr);return t.length?t:s.facet(Ih)}function Dp(s,t){let e=[Pp],i;return s instanceof Jn&&(s.module&&e.push(T.styleModule.of(s.module)),i=s.themeType),t?.fallback?e.push(Ih.of(s)):i?e.push(yr.computeN([T.darkTheme],n=>n.facet(T.darkTheme)==(i=="dark")?[s]:[])):e.push(yr.of(s)),e}class Bp{constructor(t){this.markCache=Object.create(null),this.tree=rt(t.state),this.decorations=this.buildDeco(t,Os(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=rt(t.state),i=Os(t.state),n=i!=Os(t.startState),{viewport:r}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!n&&e.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return H.none;let i=new se;for(let{from:n,to:r}of t.visibleRanges)Xd(this.tree,e,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=H.mark({class:a})))},n,r);return i.finish()}}const Pp=si.high(st.fromClass(Bp,{decorations:s=>s.decorations})),Rp=T.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Nh=1e4,Hh="()[]{}",Wh=M.define({combine(s){return he(s,{afterCursor:!0,brackets:Hh,maxScanDistance:Nh,renderMatch:Ip})}}),Lp=H.mark({class:"cm-matchingBracket"}),Ep=H.mark({class:"cm-nonmatchingBracket"});function Ip(s){let t=[],e=s.matched?Lp:Ep;return t.push(e.range(s.start.from,s.start.to)),s.end&&t.push(e.range(s.end.from,s.end.to)),t}function ml(s){let t=[],e=s.facet(Wh);for(let i of s.selection.ranges){if(!i.empty)continue;let n=Xt(s,i.head,-1,e)||i.head>0&&Xt(s,i.head-1,1,e)||e.afterCursor&&(Xt(s,i.head,1,e)||i.head<s.doc.length&&Xt(s,i.head+1,-1,e));n&&(t=t.concat(e.renderMatch(n,s)))}return H.set(t,!0)}const Np=st.fromClass(class{constructor(s){this.paused=!1,this.decorations=ml(s.state)}update(s){(s.docChanged||s.selectionSet||this.paused)&&(s.view.composing?(this.decorations=this.decorations.map(s.changes),this.paused=!0):(this.decorations=ml(s.state),this.paused=!1))}},{decorations:s=>s.decorations}),Hp=[Np,Rp];function Wp(s={}){return[Wh.of(s),Hp]}const Fp=new L;function br(s,t,e){let i=s.prop(t<0?L.openedBy:L.closedBy);if(i)return i;if(s.name.length==1){let n=e.indexOf(s.name);if(n>-1&&n%2==(t<0?1:0))return[e[n+t]]}return null}function xr(s){let t=s.type.prop(Fp);return t?t(s.node):s}function Xt(s,t,e,i={}){let n=i.maxScanDistance||Nh,r=i.brackets||Hh,o=rt(s),l=o.resolveInner(t,e);for(let a=l;a;a=a.parent){let h=br(a.type,e,r);if(h&&a.from<a.to){let c=xr(a);if(c&&(e>0?t>=c.from&&t<c.to:t>c.from&&t<=c.to))return Vp(s,t,e,a,c,h,r)}}return zp(s,t,e,o,l.type,n,r)}function Vp(s,t,e,i,n,r,o){let l=i.parent,a={from:n.from,to:n.to},h=0,c=l?.cursor();if(c&&(e<0?c.childBefore(i.from):c.childAfter(i.to)))do if(e<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from<c.to){let f=xr(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(br(c.type,e,o))h++;else if(br(c.type,-e,o)){if(h==0){let f=xr(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(e<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function zp(s,t,e,i,n,r,o){if(e<0?!t:t==s.doc.length)return null;let l=e<0?s.sliceDoc(t-1,t):s.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=e>0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},c=s.doc.iterRange(t,e>0?s.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;e<0&&(u+=d.length);let p=t+u*e;for(let m=e>0?0:d.length-1,g=e>0?d.length:-1;m!=g;m+=e){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=n))if(y%2==0==e>0)f++;else{if(f==1)return{start:h,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};f--}}e>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}const $p=Object.create(null),gl=[xt.none],yl=[],bl=Object.create(null),qp=Object.create(null);for(let[s,t]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"]])qp[s]=jp($p,t);function Ts(s,t){yl.indexOf(s)>-1||(yl.push(s),console.warn(t))}function jp(s,t){let e=[];for(let l of t.split(" ")){let a=[];for(let h of l.split(".")){let c=s[h]||D[h];c?typeof c=="function"?a.length?a=a.map(c):Ts(h,`Modifier ${h} used at start of tag`):a.length?Ts(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:Ts(h,`Unknown highlighting tag ${h}`)}for(let h of a)e.push(h)}if(!e.length)return 0;let i=t.replace(/ /g,"_"),n=i+" "+e.map(l=>l.id),r=bl[n];if(r)return r.id;let o=bl[n]=xt.define({id:gl.length,name:i,props:[kh({[i]:e})]});return gl.push(o),o.id}j.RTL,j.LTR;const Kp=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.from),i=Xr(s.state,e.from);return i.line?Up(s):i.block?Yp(s):!1};function Qr(s,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=s(t,e);return n?(i(e.update(n)),!0):!1}}const Up=Qr(_p,0),Gp=Qr(Fh,0),Yp=Qr((s,t)=>Fh(s,t,Xp(t)),0);function Xr(s,t){let e=s.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}const ci=50;function Qp(s,{open:t,close:e},i,n){let r=s.sliceDoc(i-ci,i),o=s.sliceDoc(n,n+ci),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-t.length,h)==t&&o.slice(a,a+e.length)==e)return{open:{pos:i-l,margin:l&&1},close:{pos:n+a,margin:a&&1}};let c,f;n-i<=2*ci?c=f=s.sliceDoc(i,n):(c=s.sliceDoc(i,i+ci),f=s.sliceDoc(n-ci,n));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-e.length;return c.slice(u,u+t.length)==t&&f.slice(p,p+e.length)==e?{open:{pos:i+u+t.length,margin:/\s/.test(c.charAt(u+t.length))?1:0},close:{pos:n-d-e.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function Xp(s){let t=[];for(let e of s.selection.ranges){let i=s.doc.lineAt(e.from),n=e.to<=i.to?i:s.doc.lineAt(e.to);n.from>i.from&&n.from==e.to&&(n=e.to==i.to+1?i:s.doc.lineAt(e.to-1));let r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=n.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return t}function Fh(s,t,e=t.selection.ranges){let i=e.map(r=>Xr(t,r.from).block);if(!i.every(r=>r))return null;let n=e.map((r,o)=>Qp(t,i[o],r.from,r.to));if(s!=2&&!n.every(r=>r))return{changes:t.changes(e.map((r,o)=>n[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(s!=1&&n.some(r=>r)){let r=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let a=i[o],{open:h,close:c}=l;r.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:r}}return null}function _p(s,t,e=t.selection.ranges){let i=[],n=-1;t:for(let{from:r,to:o}of e){let l=i.length,a=1e9,h;for(let c=r;c<=o;){let f=t.doc.lineAt(c);if(h==null&&(h=Xr(t,f.from).line,!h))continue t;if(f.from>n&&(r==o||o>f.from)){n=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:h,indent:u,empty:d,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(s!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=t.changes(r);return{changes:o,selection:t.selection.map(o,1)}}else if(s!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}const wr=ae.define(),Jp=ae.define(),Zp=M.define(),Vh=M.define({combine(s){return he(s,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}}),zh=mt.define({create(){return _t.empty},update(s,t){let e=t.state.facet(Vh),i=t.annotation(wr);if(i){let a=bt.fromTransaction(t,i.selection),h=i.side,c=h==0?s.undone:s.done;return a?c=Nn(c,c.length,e.minDepth,a):c=jh(c,t.startState.selection),new _t(h==0?i.rest:c,h==0?c:i.rest)}let n=t.annotation(Jp);if((n=="full"||n=="before")&&(s=s.isolate()),t.annotation(J.addToHistory)===!1)return t.changes.empty?s:s.addMapping(t.changes.desc);let r=bt.fromTransaction(t),o=t.annotation(J.time),l=t.annotation(J.userEvent);return r?s=s.addChanges(r,o,l,e,t):t.selection&&(s=s.addSelection(t.startState.selection,o,l,e.newGroupDelay)),(n=="full"||n=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(t=>t.toJSON()),undone:s.undone.map(t=>t.toJSON())}},fromJSON(s){return new _t(s.done.map(bt.fromJSON),s.undone.map(bt.fromJSON))}});function tm(s={}){return[zh,Vh.of(s),T.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?$h:t.inputType=="historyRedo"?kr:null;return i?(t.preventDefault(),i(e)):!1}})]}function Zn(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let n=e.field(zh,!1);if(!n)return!1;let r=n.pop(s,e,t);return r?(i(r),!0):!1}}const $h=Zn(0,!1),kr=Zn(1,!1),em=Zn(0,!0),im=Zn(1,!0);class bt{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new bt(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(t){return new bt(t.changes&&_.fromJSON(t.changes),[],t.mapped&&Zt.fromJSON(t.mapped),t.startSelection&&x.fromJSON(t.startSelection),t.selectionsAfter.map(x.fromJSON))}static fromTransaction(t,e){let i=Bt;for(let n of t.startState.facet(Zp)){let r=n(t);r.length&&(i=i.concat(r))}return!i.length&&t.changes.empty?null:new bt(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,Bt)}static selection(t){return new bt(void 0,Bt,void 0,void 0,t)}}function Nn(s,t,e,i){let n=t+1>e+20?t-e-1:0,r=s.slice(n,t);return r.push(i),r}function nm(s,t){let e=[],i=!1;return s.iterChangedRanges((n,r)=>e.push(n,r)),t.iterChangedRanges((n,r,o,l)=>{for(let a=0;a<e.length;){let h=e[a++],c=e[a++];l>=h&&o<=c&&(i=!0)}}),i}function sm(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function qh(s,t){return s.length?t.length?s.concat(t):s:t}const Bt=[],rm=200;function jh(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-rm));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),Nn(s,s.length-1,1e9,e.setSelAfter(i)))}else return[bt.selection([t])]}function om(s){let t=s[s.length-1],e=s.slice();return e[s.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function Ds(s,t){if(!s.length)return s;let e=s.length,i=Bt;for(;e;){let n=lm(s[e-1],t,i);if(n.changes&&!n.changes.empty||n.effects.length){let r=s.slice(0,e);return r[e-1]=n,r}else t=n.mapped,e--,i=n.selectionsAfter}return i.length?[bt.selection(i)]:Bt}function lm(s,t,e){let i=qh(s.selectionsAfter.length?s.selectionsAfter.map(l=>l.map(t)):Bt,e);if(!s.changes)return bt.selection(i);let n=s.changes.map(t),r=t.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(r):r;return new bt(n,I.mapEffects(s.effects,t),o,s.startSelection.map(r),i)}const am=/^(input\.type|delete)($|\.)/;class _t{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new _t(this.done,this.undone):this}addChanges(t,e,i,n,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&t.changes&&(!i||am.test(i))&&(!l.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,nm(l.changes,t.changes))||i=="input.type.compose")?o=Nn(o,o.length-1,n.minDepth,new bt(t.changes.compose(l.changes),qh(I.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,Bt)):o=Nn(o,o.length,n.minDepth,t),new _t(o,Bt,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Bt;return r.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&sm(r[r.length-1],t)?this:new _t(jh(this.done,t),this.undone,e,i)}addMapping(t){return new _t(Ds(this.done,t),Ds(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=t==0?this.done:this.undone;if(n.length==0)return null;let r=n[n.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):e.selection);if(i&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:wr.of({side:t,rest:om(n),selection:o}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=n.length==1?Bt:n.slice(0,n.length-1);return r.mapped&&(l=Ds(l,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:wr.of({side:t,rest:l,selection:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}_t.empty=new _t(Bt,Bt);const hm=[{key:"Mod-z",run:$h,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:kr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:kr,preventDefault:!0},{key:"Mod-u",run:em,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:im,preventDefault:!0}];function ri(s,t){return x.create(s.ranges.map(t),s.mainIndex)}function Wt(s,t){return s.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Ft({state:s,dispatch:t},e){let i=ri(s.selection,e);return i.eq(s.selection,!0)?!1:(t(Wt(s,i)),!0)}function ts(s,t){return x.cursor(t?s.to:s.from)}function Kh(s,t){return Ft(s,e=>e.empty?s.moveByChar(e,t):ts(e,t))}function at(s){return s.textDirectionAt(s.state.selection.main.head)==j.LTR}const Uh=s=>Kh(s,!at(s)),Gh=s=>Kh(s,at(s));function Yh(s,t){return Ft(s,e=>e.empty?s.moveByGroup(e,t):ts(e,t))}const cm=s=>Yh(s,!at(s)),fm=s=>Yh(s,at(s));function um(s,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(t.from,t.to)))||t.firstChild}function es(s,t,e){let i=rt(s).resolveInner(t.head),n=e?L.closedBy:L.openedBy;for(let a=t.head;;){let h=e?i.childAfter(a):i.childBefore(a);if(!h)break;um(s,h,n)?i=h:a=e?h.to:h.from}let r=i.type.prop(n),o,l;return r&&(o=e?Xt(s,i.from,1):Xt(s,i.to,-1))&&o.matched?l=e?o.end.to:o.end.from:l=e?i.to:i.from,x.cursor(l,e?-1:1)}const dm=s=>Ft(s,t=>es(s.state,t,!at(s))),pm=s=>Ft(s,t=>es(s.state,t,at(s)));function Qh(s,t){return Ft(s,e=>{if(!e.empty)return ts(e,t);let i=s.moveVertically(e,t);return i.head!=e.head?i:s.moveToLineBoundary(e,t)})}const Xh=s=>Qh(s,!1),_h=s=>Qh(s,!0);function Jh(s){let t=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,e=0,i=0,n;if(t){for(let r of s.state.facet(T.scrollMargins)){let o=r(s);o?.top&&(e=Math.max(o?.top,e)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=s.scrollDOM.clientHeight-e-i}else n=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(s.defaultLineHeight,n-5)}}function Zh(s,t){let e=Jh(s),{state:i}=s,n=ri(i.selection,o=>o.empty?s.moveVertically(o,t,e.height):ts(o,t));if(n.eq(i.selection))return!1;let r;if(e.selfScroll){let o=s.coordsAtPos(i.selection.main.head),l=s.scrollDOM.getBoundingClientRect(),a=l.top+e.marginTop,h=l.bottom-e.marginBottom;o&&o.top>a&&o.bottom<h&&(r=T.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-a}))}return s.dispatch(Wt(i,n),{effects:r}),!0}const xl=s=>Zh(s,!1),vr=s=>Zh(s,!0);function Ce(s,t,e){let i=s.lineBlockAt(t.head),n=s.moveToLineBoundary(t,e);if(n.head==t.head&&n.head!=(e?i.to:i.from)&&(n=s.moveToLineBoundary(t,e,!1)),!e&&n.head==i.from&&i.length){let r=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&t.head!=i.from+r&&(n=x.cursor(i.from+r))}return n}const mm=s=>Ft(s,t=>Ce(s,t,!0)),gm=s=>Ft(s,t=>Ce(s,t,!1)),ym=s=>Ft(s,t=>Ce(s,t,!at(s))),bm=s=>Ft(s,t=>Ce(s,t,at(s))),xm=s=>Ft(s,t=>x.cursor(s.lineBlockAt(t.head).from,1)),wm=s=>Ft(s,t=>x.cursor(s.lineBlockAt(t.head).to,-1));function km(s,t,e){let i=!1,n=ri(s.selection,r=>{let o=Xt(s,r.head,-1)||Xt(s,r.head,1)||r.head>0&&Xt(s,r.head-1,1)||r.head<s.doc.length&&Xt(s,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return x.cursor(l)});return i?(t(Wt(s,n)),!0):!1}const vm=({state:s,dispatch:t})=>km(s,t);function Lt(s,t,e){let i=ri(s.state.selection,n=>{n.undirectional&&n.head>=n.anchor!=t&&(n=x.range(n.head,n.anchor));let r=e(n);return x.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(s.state.selection)?!1:(s.dispatch(Wt(s.state,i)),!0)}function tc(s,t){return Lt(s,t,e=>s.moveByChar(e,t))}const ec=s=>tc(s,!at(s)),ic=s=>tc(s,at(s));function nc(s,t){return Lt(s,t,e=>s.moveByGroup(e,t))}const Sm=s=>nc(s,!at(s)),Cm=s=>nc(s,at(s)),Am=s=>{let t=!at(s);return Lt(s,t,e=>es(s.state,e,t))},Mm=s=>{let t=at(s);return Lt(s,t,e=>es(s.state,e,t))};function sc(s,t){return Lt(s,t,e=>s.moveVertically(e,t))}const rc=s=>sc(s,!1),oc=s=>sc(s,!0);function lc(s,t){return Lt(s,t,e=>s.moveVertically(e,t,Jh(s).height))}const wl=s=>lc(s,!1),kl=s=>lc(s,!0),Om=s=>Lt(s,!0,t=>Ce(s,t,!0)),Tm=s=>Lt(s,!1,t=>Ce(s,t,!1)),Dm=s=>{let t=!at(s);return Lt(s,t,e=>Ce(s,e,t))},Bm=s=>{let t=at(s);return Lt(s,t,e=>Ce(s,e,t))},Pm=s=>Lt(s,!1,t=>x.cursor(s.lineBlockAt(t.head).from)),Rm=s=>Lt(s,!0,t=>x.cursor(s.lineBlockAt(t.head).to)),vl=({state:s,dispatch:t})=>(t(Wt(s,{anchor:0})),!0),Sl=({state:s,dispatch:t})=>(t(Wt(s,{anchor:s.doc.length})),!0),Cl=({state:s,dispatch:t})=>(t(Wt(s,{anchor:s.selection.main.anchor,head:0})),!0),Al=({state:s,dispatch:t})=>(t(Wt(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),Lm=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),Em=({state:s,dispatch:t})=>{let e=is(s).map(({from:i,to:n})=>x.undirectionalRange(i,Math.min(n+1,s.doc.length)));return t(s.update({selection:x.create(e),userEvent:"select"})),!0},Im=({state:s,dispatch:t})=>{let e=ri(s.selection,i=>{let n=rt(s),r=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;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)&&o.next)return x.undirectionalRange(l.from,l.to)}return i});return e.eq(s.selection)?!1:(t(Wt(s,e)),!0)};function ac(s,t){let{state:e}=s,i=e.selection,n=e.selection.ranges.slice();for(let r of e.selection.ranges){let o=e.doc.lineAt(r.head);if(t?o.to<s.state.doc.length:o.from>0)for(let l=r;;){let a=s.moveVertically(l,t);if(a.head<o.from||a.head>o.to){n.some(h=>h.head==a.head)||n.push(a);break}else{if(a.head==l.head)break;l=a}}}return n.length==i.ranges.length?!1:(s.dispatch(Wt(e,x.create(n,n.length-1))),!0)}const Nm=s=>ac(s,!1),Hm=s=>ac(s,!0),Wm=({state:s,dispatch:t})=>{let e=s.selection,i=null;return e.ranges.length>1?i=x.create([e.main]):e.main.empty||(i=x.create([x.cursor(e.main.head)])),i?(t(Wt(s,i)),!0):!1};function Wi(s,t){if(s.state.readOnly)return!1;let e="delete.selection",{state:i}=s,n=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=t(r);a<o?(e="delete.backward",a=rn(s,a,!1)):a>o&&(e="delete.forward",a=rn(s,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=rn(s,o,!1),l=rn(s,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:x.cursor(o,o<r.head?-1:1)}});return n.changes.empty?!1:(s.dispatch(i.update(n,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?T.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function rn(s,t,e){if(s instanceof T)for(let i of s.state.facet(T.atomicRanges).map(n=>n(s)))i.between(t,t,(n,r)=>{n<t&&r>t&&(t=e?r:n)});return t}const hc=(s,t,e)=>Wi(s,i=>{let n=i.from,{state:r}=s,o=r.doc.lineAt(n),l,a;if(e&&!t&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,n-o.from))){if(l[l.length-1]==" ")return n-1;let h=Li(l,r.tabSize),c=h%Ln(r)||Ln(r);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)n--;a=n}else a=lt(o.text,n-o.from,t,t)+o.from,a==n&&o.number!=(t?r.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,n-o.from))&&(a=lt(o.text,a-o.from,!1,!1)+o.from);return a}),Sr=s=>hc(s,!1,!0),cc=s=>hc(s,!0,!1),fc=(s,t)=>Wi(s,e=>{let i=e.head,{state:n}=s,r=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(t?r.to:r.from)){i==e.head&&r.number!=(t?n.doc.lines:1)&&(i+=t?1:-1);break}let a=lt(r.text,i-r.from,t)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=e.head)&&(l=c),i=a}return i}),uc=s=>fc(s,!1),Fm=s=>fc(s,!0),Vm=s=>Wi(s,t=>{let e=s.lineBlockAt(t.head).to;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),zm=s=>Wi(s,t=>{let e=s.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),$m=s=>Wi(s,t=>{let e=s.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(s.state.doc.length,t.head+1)}),qm=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:W.of(["",""])},range:x.cursor(i.from)}));return t(s.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},jm=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let n=i.from,r=s.doc.lineAt(n),o=n==r.from?n-1:lt(r.text,n-r.from,!1)+r.from,l=n==r.to?n+1:lt(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:s.doc.slice(n,l).append(s.doc.slice(o,n))},range:x.cursor(l)}});return e.changes.empty?!1:(t(s.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function is(s){let t=[],e=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.from),r=s.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=s.doc.lineAt(i.to-1)),e>=n.number){let o=t[t.length-1];o.to=r.to,o.ranges.push(i)}else t.push({from:n.from,to:r.to,ranges:[i]});e=r.number+1}return t}function dc(s,t,e){if(s.readOnly)return!1;let i=[],n=[];for(let r of is(s)){if(e?r.to==s.doc.length:r.from==0)continue;let o=s.doc.lineAt(e?r.to+1:r.from-1),l=o.length+1;if(e){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+s.lineBreak});for(let a of r.ranges)n.push(x.range(Math.min(s.doc.length,a.anchor+l),Math.min(s.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:s.lineBreak+o.text});for(let a of r.ranges)n.push(x.range(a.anchor-l,a.head-l))}}return i.length?(t(s.update({changes:i,scrollIntoView:!0,selection:x.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Km=({state:s,dispatch:t})=>dc(s,t,!1),Um=({state:s,dispatch:t})=>dc(s,t,!0);function pc(s,t,e){if(s.readOnly)return!1;let i=[];for(let r of is(s))e?i.push({from:r.from,insert:s.doc.slice(r.from,r.to)+s.lineBreak}):i.push({from:r.to,insert:s.lineBreak+s.doc.slice(r.from,r.to)});let n=s.changes(i);return t(s.update({changes:n,selection:s.selection.map(n,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Gm=({state:s,dispatch:t})=>pc(s,t,!1),Ym=({state:s,dispatch:t})=>pc(s,t,!0),Qm=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(is(t).map(({from:n,to:r})=>(n>0?n--:r<t.doc.length&&r++,{from:n,to:r}))),i=ri(t.selection,n=>{let r;if(s.lineWrapping){let o=s.lineBlockAt(n.head),l=s.coordsAtPos(n.head,n.assoc||1);l&&(r=o.bottom+s.documentTop-l.bottom+s.defaultLineHeight/2)}return s.moveVertically(n,!0,r)}).map(e);return s.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Xm(s,t){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=rt(s).resolveInner(t),i=e.childBefore(t),n=e.childAfter(t),r;return i&&n&&i.to<=t&&n.from>=t&&(r=i.type.prop(L.closedBy))&&r.indexOf(n.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(n.from).from&&!/\S/.test(s.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const Ml=mc(!1),_m=mc(!0);function mc(s){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{let{from:r,to:o}=n,l=t.doc.lineAt(r),a=!s&&r==o&&Xm(t,r);s&&(r=o=(o<=l.to?l:t.doc.lineAt(o)).to);let h=new Xn(t,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Gr(h,r);for(c==null&&(c=Li(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",Di(t,c)];return a&&f.push(Di(t,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:W.of(f)},range:x.cursor(r+1+f[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function _r(s,t){let e=-1;return s.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=s.doc.lineAt(o);l.number>e&&(i.empty||i.to>l.from)&&(t(l,n,i),e=l.number),o=l.to+1}let r=s.changes(n);return{changes:n,range:x.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Jm=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=Object.create(null),i=new Xn(s,{overrideIndentation:r=>{let o=e[r];return o??-1}}),n=_r(s,(r,o,l)=>{let a=Gr(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=Di(s,a);(h!=c||l.from<r.from+h.length)&&(e[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:c}))});return n.changes.empty||t(s.update(n,{userEvent:"indent"})),!0},gc=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(_r(s,(e,i)=>{i.push({from:e.from,insert:s.facet(Ur)})}),{userEvent:"input.indent"})),!0),yc=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(_r(s,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=Li(n,s.tabSize),o=0,l=Di(s,Math.max(0,r-Ln(s)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Zm=s=>(s.setTabFocusMode(),!0),tg=[{key:"Ctrl-b",run:Uh,shift:ec,preventDefault:!0},{key:"Ctrl-f",run:Gh,shift:ic},{key:"Ctrl-p",run:Xh,shift:rc},{key:"Ctrl-n",run:_h,shift:oc},{key:"Ctrl-a",run:xm,shift:Pm},{key:"Ctrl-e",run:wm,shift:Rm},{key:"Ctrl-d",run:cc},{key:"Ctrl-h",run:Sr},{key:"Ctrl-k",run:Vm},{key:"Ctrl-Alt-h",run:uc},{key:"Ctrl-o",run:qm},{key:"Ctrl-t",run:jm},{key:"Ctrl-v",run:vr}],eg=[{key:"ArrowLeft",run:Uh,shift:ec,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:cm,shift:Sm,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:ym,shift:Dm,preventDefault:!0},{key:"ArrowRight",run:Gh,shift:ic,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:fm,shift:Cm,preventDefault:!0},{mac:"Cmd-ArrowRight",run:bm,shift:Bm,preventDefault:!0},{key:"ArrowUp",run:Xh,shift:rc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:vl,shift:Cl},{mac:"Ctrl-ArrowUp",run:xl,shift:wl},{key:"ArrowDown",run:_h,shift:oc,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Sl,shift:Al},{mac:"Ctrl-ArrowDown",run:vr,shift:kl},{key:"PageUp",run:xl,shift:wl},{key:"PageDown",run:vr,shift:kl},{key:"Home",run:gm,shift:Tm,preventDefault:!0},{key:"Mod-Home",run:vl,shift:Cl},{key:"End",run:mm,shift:Om,preventDefault:!0},{key:"Mod-End",run:Sl,shift:Al},{key:"Enter",run:Ml,shift:Ml},{key:"Mod-a",run:Lm},{key:"Backspace",run:Sr,shift:Sr,preventDefault:!0},{key:"Delete",run:cc,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:uc,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Fm,preventDefault:!0},{mac:"Mod-Backspace",run:zm,preventDefault:!0},{mac:"Mod-Delete",run:$m,preventDefault:!0}].concat(tg.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),ig=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:dm,shift:Am},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:pm,shift:Mm},{key:"Alt-ArrowUp",run:Km},{key:"Shift-Alt-ArrowUp",run:Gm},{key:"Alt-ArrowDown",run:Um},{key:"Shift-Alt-ArrowDown",run:Ym},{key:"Mod-Alt-ArrowUp",run:Nm},{key:"Mod-Alt-ArrowDown",run:Hm},{key:"Escape",run:Wm},{key:"Mod-Enter",run:_m},{key:"Alt-l",mac:"Ctrl-l",run:Em},{key:"Mod-i",run:Im,preventDefault:!0},{key:"Mod-[",run:yc},{key:"Mod-]",run:gc},{key:"Mod-Alt-\\",run:Jm},{key:"Shift-Mod-k",run:Qm},{key:"Shift-Mod-\\",run:vm},{key:"Mod-/",run:Kp},{key:"Alt-A",mac:"Ctrl-A",run:Gp},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Zm}].concat(eg),ng={key:"Tab",run:gc,shift:yc};class bc{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=rt(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),r=n.search(xc(t,!1));return r<0?null:{from:i+r,to:this.pos,text:n.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(t,e,i){t=="abort"&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Ol(s){let t=Object.keys(s).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function sg(s){let t=Object.create(null),e=Object.create(null);for(let{label:n}of s){t[n[0]]=!0;for(let r=1;r<n.length;r++)e[n[r]]=!0}let i=Ol(t)+Ol(e)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function rg(s){let t=s.map(n=>typeof n=="string"?{label:n}:n),[e,i]=t.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:sg(t);return n=>{let r=n.matchBefore(i);return r||n.explicit?{from:r?r.from:n.pos,options:t,validFor:e}:null}}class Tl{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function Ee(s){return s.selection.main.from}function xc(s,t){var e;let{source:i}=s,n=t&&i[0]!="^",r=i[i.length-1]!="$";return!n&&!r?s:new RegExp(`${n?"^":""}(?:${i})${r?"$":""}`,(e=s.flags)!==null&&e!==void 0?e:s.ignoreCase?"i":"")}const wc=ae.define();function og(s,t,e,i){let{main:n}=s.selection,r=e-n.from,o=i-n.from;return{...s.changeByRange(l=>{if(l!=n&&e!=i&&s.sliceDoc(l.from+r,l.from+o)!=s.sliceDoc(e,i))return{range:l};let a=s.toText(t);return{changes:{from:l.from+r,to:i==n.from?l.to:l.from+o,insert:a},range:x.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Dl=new WeakMap;function lg(s){if(!Array.isArray(s))return s;let t=Dl.get(s);return t||Dl.set(s,t=rg(s)),t}const Hn=I.define(),Bi=I.define();class ag{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=St(t,e),n=ie(i);this.chars.push(i);let r=t.slice(e,e+n),o=r.toUpperCase();this.folded.push(St(o==r?r.toLowerCase():o,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:r,byWord:o}=this;if(e.length==1){let w=St(t,0),b=ie(w),O=b==t.length?0:-100;if(w!=e[0])if(w==i[0])O+=-200;else return null;return this.ret(O,[0,b])}let l=t.indexOf(this.pattern);if(l==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,h=0;if(l<0){for(let w=0,b=Math.min(t.length,200);w<b&&h<a;){let O=St(t,w);(O==e[h]||O==i[h])&&(n[h++]=w),w+=ie(O)}if(h<a)return null}let c=0,f=0,u=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let w=0,b=Math.min(t.length,200),O=0;w<b&&f<a;){let k=St(t,w);l<0&&(c<a&&k==e[c]&&(r[c++]=w),d<a&&(k==e[d]||k==i[d]?(d==0&&(p=w),m=w+1,d++):d=0));let v,S=k<255?k>=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(v=Jl(k))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!w||S==1&&g||O==0&&S!=0)&&(e[f]==k||i[f]==k&&(u=!0)?o[f++]=w:o.length&&(y=!1)),O=S,w+=ie(k)}return f==a&&o[0]==0&&y?this.result(-100+(u?-200:0),o,t):d==a&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==a?this.ret(-900-t.length,[p,m]):f==a?this.result(-100+(u?-200:0)+-700+(y?0:-1100),o,t):e.length==2?null:this.result((n[0]?-700:0)+-200+-1100,n,t)}result(t,e,i){let n=[],r=0;for(let o of e){let l=o+(this.astral?ie(St(i,o)):1);r&&n[r-1]==o?n[r-1]=l:(n[r++]=o,n[r++]=l)}return this.ret(t-i.length,n)}}class hg{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const Z=M.define({combine(s){return he(s,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:cg,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>Bl(t(i),e(i)),optionClass:(t,e)=>i=>Bl(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})}});function Bl(s,t){return s?t?s+" "+t:s:t}function cg(s,t,e,i,n,r){let o=s.textDirection==j.RTL,l=o,a=!1,h="top",c,f,u=t.left-n.left,d=n.right-t.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))c=Math.max(n.top,Math.min(e.top,n.bottom-m))-t.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?t.right:n.right-t.left)-30);let w=n.bottom-t.bottom;w>=m||w>t.top?c=e.bottom-t.top:(h="bottom",c=t.bottom-e.top)}let g=(t.bottom-t.top)/r.offsetHeight,y=(t.right-t.left)/r.offsetWidth;return{style:`${h}: ${c/g}px; max-width: ${f/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const Jr=I.define();function fg(s){let t=s.addToOptions.slice();return s.icons&&t.push({render(e){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),e.type&&i.classList.add(...e.type.split(/\s+/g).map(n=>"cm-completionIcon-"+n)),i.setAttribute("aria-hidden","true"),i},position:20}),t.push({render(e,i,n,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=e.displayLabel||e.label,a=0;for(let h=0;h<r.length;){let c=r[h++],f=r[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(e){if(!e.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=e.detail,i},position:80}),t.sort((e,i)=>e.position-i.position).map(e=>e.render)}function Bs(s,t,e){if(s<=e)return{from:0,to:s};if(t<0&&(t=0),t<=s>>1){let n=Math.floor(t/e);return{from:n*e,to:(n+1)*e}}let i=Math.ceil((s-t)/e);return{from:s-i*e,to:s-(i-1)*e}}class ug{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:r,selected:o}=n.open,l=t.state.facet(Z);this.optionContent=fg(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Bs(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=t.state.field(e).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(t,h[+f[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(t.dispatch({effects:Jr.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=t.state.field(this.stateField,!1);h&&h.tooltip&&t.state.facet(Z).closeOnBlur&&a.relatedTarget!=t.contentDOM&&t.dispatch({effects:Bi.of(null)})}),this.showOptions(r,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:r,selected:o,disabled:l}=i.open;(!n.open||n.open.options!=r)&&(this.range=Bs(r.length,o,t.state.facet(Z).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((e=n.open)===null||e===void 0?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of e.split(" "))i&&this.dom.classList.add(i);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Bs(e.options.length,e.selected,this.view.state.facet(Z).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:r}=n;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(n);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(l,n)}).catch(l=>ut(this.view.state,l,"completion info")):(this.addInfoPane(o,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),t.nodeType!=null)i.appendChild(t),this.infoDestroy=null;else{let{dom:n,destroy:r}=t;i.appendChild(n),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)i.nodeName!="LI"||!i.id?n--:n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return e&&pg(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return n.top>Math.min(r.bottom,e.bottom)-10||n.bottom<Math.max(r.top,e.top)+10?null:this.view.state.facet(Z).positionInfo(this.view,e,n,i,r,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",o=>{o.target==n&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=t[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof h!="string"&&h.header)n.appendChild(h.header(h));else{let d=n.appendChild(document.createElement("completion-section"));d.textContent=u}}const c=n.appendChild(document.createElement("li"));c.id=e+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function dg(s,t){return e=>new ug(e,s,t)}function pg(s,t){let e=s.getBoundingClientRect(),i=t.getBoundingClientRect(),n=e.height/s.offsetHeight;i.top<e.top?s.scrollTop-=(e.top-i.top)/n:i.bottom>e.bottom&&(s.scrollTop+=(i.bottom-e.bottom)/n)}function Pl(s){return(s.boost||0)*100+(s.apply?10:0)+(s.info?5:0)+(s.type?1:0)}function mg(s,t){let e=[],i=null,n=null,r=c=>{e.push(c);let{section:f}=c.completion;if(f){i||(i=[]);let u=typeof f=="string"?f:f.name;i.some(d=>d.name==u)||i.push(typeof f=="string"?{name:u}:f)}},o=t.facet(Z);for(let c of s)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)r(new Tl(u,c.source,f?f(u):[],1e9-e.length));else{let u=t.sliceDoc(c.from,c.to),d,p=o.filterStrict?new hg(u):new ag(u);for(let m of c.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,y=d.score+(m.boost||0);if(r(new Tl(m,c.source,g,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:w}=m.section;n||(n=Object.create(null)),n[w]=Math.max(y,n[w]||-1e9)}}}}if(i){let c=Object.create(null),f=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?n[p.name]-n[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(u))f-=1e5,c[d.name]=f;for(let d of e){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let c of e.sort((f,u)=>u.score-f.score||h(f.completion,u.completion))){let f=c.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?l.push(c):Pl(c.completion)>Pl(a)&&(l[l.length-1]=c),a=c.completion}return l}class Ke{constructor(t,e,i,n,r,o){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=r,this.disabled=o}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new Ke(this.options,Rl(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,r,o){if(n&&!o&&t.some(h=>h.isPending))return n.setDisabled();let l=mg(t,e);if(!l.length)return n&&t.some(h=>h.isPending)?n.setDisabled():null;let a=e.facet(Z).selectOnOpen?0:-1;if(n&&n.selected!=a&&n.selected!=-1){let h=n.options[n.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==h){a=c;break}}return new Ke(l,Rl(i,a),{pos:t.reduce((h,c)=>c.hasResult()?Math.min(h,c.from):h,1e8),create:kg,above:r.aboveCursor},n?n.timestamp:Date.now(),a,!1)}map(t){return new Ke(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ke(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Wn{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new Wn(xg,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:e}=t,i=e.facet(Z),r=(i.override||e.languageDataAt("autocomplete",Ee(e)).map(lg)).map(a=>(this.active.find(c=>c.source==a)||new Pt(a,this.active.some(c=>c.state!=0)?1:0)).update(t,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=t.effects.some(a=>a.is(Zr));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||r.some(a=>a.hasResult()&&t.changes.touchesRange(a.from,a.to))||!gg(r,this.active)||l?o=Ke.build(r,e,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new Pt(a.source,0):a));for(let a of t.effects)a.is(Jr)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new Wn(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?yg:bg}}function gg(s,t){if(s==t)return!0;for(let e=0,i=0;;){for(;e<s.length&&!s[e].hasResult();)e++;for(;i<t.length&&!t[i].hasResult();)i++;let n=e==s.length,r=i==t.length;if(n||r)return n==r;if(s[e++].result!=t[i++].result)return!1}}const yg={"aria-autocomplete":"list"},bg={};function Rl(s,t){let e={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":s};return t>-1&&(e["aria-activedescendant"]=s+"-"+t),e}const xg=[];function kc(s,t){if(s.isUserEvent("input.complete")){let i=s.annotation(wc);if(i&&t.activateOnCompletion(i))return 12}let e=s.isUserEvent("input.type");return e&&t.activateOnTyping?5:e?1:s.isUserEvent("delete.backward")?2:s.selection?8:s.docChanged?16:0}class Pt{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(t,e){let i=kc(t,e),n=this;(i&8||i&16&&this.touches(t))&&(n=new Pt(n.source,0)),i&4&&n.state==0&&(n=new Pt(this.source,1)),n=n.updateFor(t,i);for(let r of t.effects)if(r.is(Hn))n=new Pt(n.source,1,r.value);else if(r.is(Bi))n=new Pt(n.source,0);else if(r.is(Zr))for(let o of r.value)o.source==n.source&&(n=o);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Ee(t.state))}}class Xe extends Pt{constructor(t,e,i,n,r,o){super(t,3,e),this.limit=i,this.result=n,this.from=r,this.to=o}hasResult(){return!0}updateFor(t,e){var i;if(!(e&3))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let r=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),l=Ee(t.state);if(l>o||!n||e&2&&(Ee(t.startState)==this.from||l<this.limit))return new Pt(this.source,e&4?1:0);let a=t.changes.mapPos(this.limit);return wg(n.validFor,t.state,r,o)?new Xe(this.source,this.explicit,a,n,r,o):n.update&&(n=n.update(n,r,o,new bc(t.state,l,!1)))?new Xe(this.source,this.explicit,a,n,n.from,(i=n.to)!==null&&i!==void 0?i:Ee(t.state)):new Pt(this.source,1,this.explicit)}map(t){if(t.empty)return this;let e=this.result.map?this.result.map(this.result,t):this.result;return e?new Xe(this.source,this.explicit,t.mapPos(this.limit),e,t.mapPos(this.from),t.mapPos(this.to,1)):new Pt(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function wg(s,t,e,i){if(!s)return!1;let n=t.sliceDoc(e,i);return typeof s=="function"?s(n,e,i,t):xc(s,!0).test(n)}const Zr=I.define({map(s,t){return s.map(e=>e.map(t))}}),gt=mt.define({create(){return Wn.start()},update(s,t){return s.update(t)},provide:s=>[Yn.from(s,t=>t.tooltip),T.contentAttributes.from(s,t=>t.attrs)]});function to(s,t){const e=t.completion.apply||t.completion.label;let i=s.state.field(gt).active.find(n=>n.source==t.source);return i instanceof Xe?(typeof e=="string"?s.dispatch({...og(s.state,e,i.from,i.to),annotations:wc.of(t.completion)}):e(s,t.completion,i.from,i.to),!0):!1}const kg=dg(gt,to);function on(s,t="option"){return e=>{let i=e.state.field(gt,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<e.state.facet(Z).interactionDelay)return!1;let n=1,r;t=="page"&&(r=fh(e,i.open.tooltip))&&(n=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+n*(s?1:-1):s?0:o-1;return l<0?l=t=="page"?0:o-1:l>=o&&(l=t=="page"?o-1:0),e.dispatch({effects:Jr.of(l)}),!0}}const vg=s=>{let t=s.state.field(gt,!1);return s.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<s.state.facet(Z).interactionDelay?!1:to(s,t.open.options[t.open.selected])},Ps=s=>s.state.field(gt,!1)?(s.dispatch({effects:Hn.of(!0)}),!0):!1,Sg=s=>{let t=s.state.field(gt,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(s.dispatch({effects:Bi.of(null)}),!0)};class Cg{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ag=50,Mg=1e3,Og=st.fromClass(class{constructor(s){this.view=s,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of s.state.field(gt).active)t.isPending&&this.startQuery(t)}update(s){let t=s.state.field(gt),e=s.state.facet(Z);if(!s.selectionSet&&!s.docChanged&&s.startState.field(gt)==t)return;let i=s.transactions.some(r=>{let o=kc(r,e);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&s.docChanged||o.updates.length+s.transactions.length>Ag&&Date.now()-o.time>Mg){for(let l of o.context.abortListeners)try{l()}catch(a){ut(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...s.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),s.transactions.some(r=>r.effects.some(o=>o.is(Hn)))&&(this.pendingStart=!0);let n=this.pendingStart?50:e.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),n):-1,this.composing!=0)for(let r of s.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:s}=this.view,t=s.field(gt);for(let e of t.active)e.isPending&&!this.running.some(i=>i.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Z).updateSyncTime))}startQuery(s){let{state:t}=this.view,e=Ee(t),i=new bc(t,e,s.explicit,this.view),n=new Cg(s,i);this.running.push(n),Promise.resolve(s.source(i)).then(r=>{n.context.aborted||(n.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Bi.of(null)}),ut(this.view.state,r)})}scheduleAccept(){this.running.every(s=>s.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Z).updateSyncTime))}accept(){var s;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],e=this.view.state.facet(Z),i=this.view.state.field(gt);for(let n=0;n<this.running.length;n++){let r=this.running[n];if(r.done===void 0)continue;if(this.running.splice(n--,1),r.done){let l=Ee(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),h=new Xe(r.active.source,r.active.explicit,a,r.done,r.done.from,(s=r.done.to)!==null&&s!==void 0?s:l);for(let c of r.updates)h=h.update(c,e);if(h.hasResult()){t.push(h);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new Pt(r.active.source,0);for(let a of r.updates)l=l.update(a,e);l.isPending||t.push(l)}else this.startQuery(o)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Zr.of(t)})}},{eventHandlers:{blur(s){let t=this.view.state.field(gt,!1);if(t&&t.tooltip&&this.view.state.facet(Z).closeOnBlur){let e=t.open&&fh(this.view,t.open.tooltip);(!e||!e.dom.contains(s.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Bi.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Hn.of(!1)}),20),this.composing=0}}}),Tg=typeof navigator=="object"&&/Win/.test(navigator.platform),Dg=si.highest(T.domEventHandlers({keydown(s,t){let e=t.state.field(gt,!1);if(!e||!e.open||e.open.disabled||e.open.selected<0||s.key.length>1||s.ctrlKey&&!(Tg&&s.altKey)||s.metaKey)return!1;let i=e.open.options[e.open.selected],n=e.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||n.result.commitCharacters;return r&&r.indexOf(s.key)>-1&&to(t,i),!1}})),Bg=T.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Pi={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Pe=I.define({map(s,t){let e=t.mapPos(s,-1,ft.TrackAfter);return e??void 0}}),eo=new class extends ye{};eo.startSide=1;eo.endSide=-1;const vc=mt.define({create(){return R.empty},update(s,t){if(s=s.map(t.changes),t.selection){let e=t.state.doc.lineAt(t.selection.main.head);s=s.update({filter:i=>i>=e.from&&i<=e.to})}for(let e of t.effects)e.is(Pe)&&(s=s.update({add:[eo.range(e.value,e.value+1)]}));return s}});function Pg(){return[Lg,vc]}const Rs="()[]{}<>«»»«[]{}";function Sc(s){for(let t=0;t<Rs.length;t+=2)if(Rs.charCodeAt(t)==s)return Rs.charAt(t+1);return Jl(s<128?s:s+1)}function Cc(s,t){return s.languageDataAt("closeBrackets",t)[0]||Pi}const Rg=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Lg=T.inputHandler.of((s,t,e,i)=>{if((Rg?s.composing:s.compositionStarted)||s.state.readOnly)return!1;let n=s.state.selection.main;if(i.length>2||i.length==2&&ie(St(i,0))==1||t!=n.from||e!=n.to)return!1;let r=Ng(s.state,i);return r?(s.dispatch(r),!0):!1}),Eg=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let i=Cc(s,s.selection.main.head).brackets||Pi.brackets,n=null,r=s.changeByRange(o=>{if(o.empty){let l=Hg(s.doc,o.head);for(let a of i)if(a==l&&ns(s.doc,o.head)==Sc(St(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:x.cursor(o.head-a.length)}}return{range:n=o}});return n||t(s.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},Ig=[{key:"Backspace",run:Eg}];function Ng(s,t){let e=Cc(s,s.selection.main.head),i=e.brackets||Pi.brackets;for(let n of i){let r=Sc(St(n,0));if(t==n)return r==n?Vg(s,n,i.indexOf(n+n+n)>-1,e):Wg(s,n,r,e.before||Pi.before);if(t==r&&Ac(s,s.selection.main.from))return Fg(s,n,r)}return null}function Ac(s,t){let e=!1;return s.field(vc).between(0,s.doc.length,i=>{i==t&&(e=!0)}),e}function ns(s,t){let e=s.sliceString(t,t+2);return e.slice(0,ie(St(e,0)))}function Hg(s,t){let e=s.sliceString(t-2,t);return ie(St(e,0))==e.length?e:e.slice(1)}function Wg(s,t,e,i){let n=null,r=s.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:e,from:o.to}],effects:Pe.of(o.to+t.length),range:x.range(o.anchor+t.length,o.head+t.length)};let l=ns(s.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:t+e,from:o.head},effects:Pe.of(o.head+t.length),range:x.cursor(o.head+t.length)}:{range:n=o}});return n?null:s.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Fg(s,t,e){let i=null,n=s.changeByRange(r=>r.empty&&ns(s.doc,r.head)==e?{changes:{from:r.head,to:r.head+e.length,insert:e},range:x.cursor(r.head+e.length)}:i={range:r});return i?null:s.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function Vg(s,t,e,i){let n=i.stringPrefixes||Pi.stringPrefixes,r=null,o=s.changeByRange(l=>{if(!l.empty)return{changes:[{insert:t,from:l.from},{insert:t,from:l.to}],effects:Pe.of(l.to+t.length),range:x.range(l.anchor+t.length,l.head+t.length)};let a=l.head,h=ns(s.doc,a),c;if(h==t){if(Ll(s,a))return{changes:{insert:t+t,from:a},effects:Pe.of(a+t.length),range:x.cursor(a+t.length)};if(Ac(s,a)){let u=e&&s.sliceDoc(a,a+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+u.length,insert:u},range:x.cursor(a+u.length)}}}else{if(e&&s.sliceDoc(a-2*t.length,a)==t+t&&(c=El(s,a-2*t.length,n))>-1&&Ll(s,c))return{changes:{insert:t+t+t+t,from:a},effects:Pe.of(a+t.length),range:x.cursor(a+t.length)};if(s.charCategorizer(a)(h)!=Tt.Word&&El(s,a,n)>-1&&!zg(s,a,t,n))return{changes:{insert:t+t,from:a},effects:Pe.of(a+t.length),range:x.cursor(a+t.length)}}return{range:r=l}});return r?null:s.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Ll(s,t){let e=rt(s).resolveInner(t+1);return e.parent&&e.from==t}function zg(s,t,e,i){let n=rt(s).resolveInner(t,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=s.sliceDoc(n.from,Math.min(n.to,n.from+e.length+r)),a=l.indexOf(e);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=n.firstChild;for(;c&&c.from==n.from&&c.to-c.from>e.length+a;){if(s.sliceDoc(c.to-e.length,c.to)==e)return!1;c=c.firstChild}return!0}let h=n.to==t&&n.parent;if(!h)break;n=h}return!1}function El(s,t,e){let i=s.charCategorizer(t);if(i(s.sliceDoc(t-1,t))!=Tt.Word)return t;for(let n of e){let r=t-n.length;if(s.sliceDoc(r,t)==n&&i(s.sliceDoc(r-1,r))!=Tt.Word)return r}return-1}function $g(s={}){return[Dg,gt,Z.of(s),Og,qg,Bg]}const Mc=[{key:"Ctrl-Space",run:Ps},{mac:"Alt-`",run:Ps},{mac:"Alt-i",run:Ps},{key:"Escape",run:Sg},{key:"ArrowDown",run:on(!0)},{key:"ArrowUp",run:on(!1)},{key:"PageDown",run:on(!0,"page")},{key:"PageUp",run:on(!1,"page")},{key:"Enter",run:vg}],qg=si.highest(Vr.computeN([Z],s=>s.facet(Z).defaultKeymap?[Mc]:[]));var Il={};class Fn{constructor(t,e,i,n,r,o,l,a,h,c=0,f){this.p=t,this.stack=e,this.state=i,this.reducePos=n,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let n=t.parser.context;return new Fn(t,[],e,i,i,0,[],0,n?new Nl(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,n=t&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=r.dynamicPrecedence(n);if(l&&(this.score+=l),i==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(n,this.reducePos);return}let a=this.stack.length-(i-1)*3-(t&262144?6:0),h=a?this.stack[a-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&h==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-h;c>=2e3&&!(!((e=this.p.parser.nodeSet.types[n])===null||e===void 0)&&e.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=c));let f=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-f;if(n<r.minRepeatTerm||t&131072){let d=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,h,d,u+4,!0)}if(t&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=r.getGoto(d,n,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(n,h)}storeNode(t,e,i,n=4,r=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(e==i)return;if(this.buffer[o-2]>=e){this.buffer[o-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(t,e,i,n);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,n>4&&(n-=4)}this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=n}}shift(t,e,i,n){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let r=t,{parser:o}=this.p;this.pos=n;let l=o.stateFlag(r,1);!l&&(n>i||e<=o.maxNode)&&(this.reducePos=n),this.pushState(r,l?i:Math.min(i,this.reducePos)),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,n,4)}else this.pos=n,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,n,4)}apply(t,e,i,n){t&65536?this.reduce(t):this.shift(t,e,i,n)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let n=this.pos;this.reducePos=this.pos=n+t.length,this.pushState(e,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),n=t.bufferBase+e;for(;t&&n==t.bufferBase;)t=t.parent;return new Fn(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new jg(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if((i&65536)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let n=[];for(let r=0,o;r<e.length;r+=2)(o=e[r+1])!=this.state&&this.p.parser.hasAction(o,t)&&n.push(e[r],o);if(this.stack.length<120)for(let r=0;n.length<8&&r<e.length;r+=2){let o=e[r+1];n.some((l,a)=>a&1&&l==o)||n.push(e[r],o)}e=n}let i=[];for(let n=0;n<e.length&&i.length<4;n+=2){let r=e[n+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(e[n],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let i=e>>19,n=e&65535,r=this.stack.length-i*3;if(r<0||t.getGoto(this.stack[r],n,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;e=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(n,r)=>{if(!e.includes(n))return e.push(n),t.allActions(n,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&t.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new Nl(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Nl{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class jg{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=n}}class Vn{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new Vn(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Vn(this.stack,this.pos,this.index)}}function ln(s,t=Uint16Array){if(typeof s!="string")return s;let e=null;for(let i=0,n=0;i<s.length;){let r=0;for(;;){let o=s.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}e?e[n++]=r:e=new t(r)}return e}class gn{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Hl=new gn;class Kg{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Hl,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,n=this.rangeIndex,r=this.pos+t;for(;r<i.from;){if(!n)return null;let o=this.ranges[--n];r-=i.from-o.to,i=o}for(;e<0?r>i.to:r>=i.to;){if(n==this.ranges.length-1)return null;let o=this.ranges[++n];r+=o.from-i.to,i=o}return r}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,n;if(e>=0&&e<this.chunk.length)i=this.pos+t,n=this.chunk.charCodeAt(e);else{let r=this.resolveOffset(t,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),n=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),n}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=Hl,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let n of this.ranges){if(n.from>=e)break;n.to>t&&(i+=this.input.read(Math.max(n.from,t),Math.min(n.to,e)))}return i}}class _e{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Ug(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}_e.prototype.contextual=_e.prototype.fallback=_e.prototype.extend=!1;_e.prototype.fallback=_e.prototype.extend=!1;function Ug(s,t,e,i,n,r){let o=0,l=1<<i,{dialect:a}=e.p.parser;t:for(;(l&s[o])!=0;){let h=s[o+1];for(let d=o+3;d<h;d+=2)if((s[d+1]&l)>0){let p=s[d];if(a.allows(p)&&(t.token.value==-1||t.token.value==p||Gg(p,t.token.value,n,r))){t.acceptToken(p);break}}let c=t.next,f=0,u=s[o+2];if(t.next<0&&u>f&&s[h+u*3-3]==65535){o=s[h+u*3-1];continue t}for(;f<u;){let d=f+u>>1,p=h+d+(d<<1),m=s[p],g=s[p+1]||65536;if(c<m)u=d;else if(c>=g)f=d+1;else{o=s[p+2],t.advance();continue t}}break}}function Wl(s,t,e){for(let i=t,n;(n=s[i])!=65535;i++)if(n==e)return i-t;return-1}function Gg(s,t,e,i){let n=Wl(e,i,t);return n<0||Wl(e,i,s)<n}const kt=typeof process<"u"&&Il&&/\bparse\b/.test(Il.LOG);let Ls=null;function Fl(s,t,e){let i=s.cursor(G.IncludeAnonymous);for(i.moveTo(t);;)if(!(e<0?i.childBefore(t):i.childAfter(t)))for(;;){if((e<0?i.to<t:i.from>t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(s.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:s.length}}class Yg{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?Fl(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?Fl(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],n=this.index[e];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[n],o=this.start[e]+i.positions[n];if(o>t)return this.nextStart=o,null;if(r instanceof X){if(o==t){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(L.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[e]++,o+r.length>=Math.max(this.safeFrom,t)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+r.length}}}class Qg{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new gn)}getActions(t){let e=0,i=null,{parser:n}=t.p,{tokenizers:r}=n,o=n.stateSlot(t.state,3),l=t.curContext?t.curContext.hash:0,a=0;for(let h=0;h<r.length;h++){if((1<<h&o)==0)continue;let c=r[h],f=this.tokens[h];if(!(i&&!c.fallback)&&((c.contextual||f.start!=t.pos||f.mask!=o||f.context!=l)&&(this.updateCachedToken(f,c,t),f.mask=o,f.context=l),f.lookAhead>f.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=e;if(f.extended>-1&&(e=this.addActions(t,f.extended,f.end,e)),e=this.addActions(t,f.value,f.end,e),!c.extend&&(i=f,e>u))break}}for(;this.actions.length>e;)this.actions.pop();return a&&t.setLookAhead(a),!i&&t.pos==this.stream.end&&(i=new gn,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new gn,{pos:i,p:n}=t;return e.start=i,e.end=Math.min(i+1,n.stream.end),e.value=i==n.stream.end?n.parser.eofTerm:0,e}updateCachedToken(t,e,i){let n=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(n,t),i),t.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==t.value){let l=r.specializers[o](this.stream.read(t.start,t.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?t.value=l>>1:t.extended=l>>1;break}}}else t.value=0,t.end=this.stream.clipPos(n+1)}putAction(t,e,i,n){for(let r=0;r<n;r+=3)if(this.actions[r]==t)return n;return this.actions[n++]=t,this.actions[n++]=e,this.actions[n++]=i,n}addActions(t,e,i,n){let{state:r}=t,{parser:o}=t.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(r,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=ee(l,h+2);else{n==0&&l[h+1]==2&&(n=this.putAction(ee(l,h+2),e,i,n));break}l[h]==e&&(n=this.putAction(ee(l,h+1),e,i,n))}return n}}class Xg{constructor(t,e,i,n){this.parser=t,this.input=e,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Kg(e,n),this.tokens=new Qg(t,this.stream),this.topTerm=t.top[1];let{from:r}=n[0];this.stacks=[Fn.start(this,t.top[0],r)],this.fragments=i.length&&this.stream.end-r>t.bufferLength*4?new Yg(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],n,r;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<t.length;o++){let l=t[o];for(;;){if(this.tokens.mainToken=null,l.pos>e)i.push(l);else{if(this.advanceStack(l,i,t))continue;{n||(n=[],r=[]),n.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=n&&Jg(n);if(o)return kt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw kt&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&n){let o=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,r,i);if(o)return kt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let h=i[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue t}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let n=t.pos,{parser:r}=this,o=kt?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let h=t.curContext&&t.curContext.tracker.strict,c=h?t.curContext.hash:0;for(let f=this.fragments.nodeAt(n);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(t.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(L.contextHash)||0)==c))return t.useNode(f,u),kt&&console.log(o+this.stackID(t)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof X)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof X&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(t.state,4);if(l>0)return t.reduce(l),kt&&console.log(o+this.stackID(t)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let a=this.tokens.getActions(t);for(let h=0;h<a.length;){let c=a[h++],f=a[h++],u=a[h++],d=h==a.length||!i,p=d?t:t.split(),m=this.tokens.mainToken;if(p.apply(c,f,m?m.start:p.pos,u),kt&&console.log(o+this.stackID(p)+` (via ${(c&65536)==0?"shift":`reduce of ${r.getName(c&65535)}`} for ${r.getName(f)} @ ${n}${p==t?"":", split"})`),d)return!0;p.pos>n?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return Vl(t,e),!0}}runRecovery(t,e,i){let n=null,r=!1;for(let o=0;o<t.length;o++){let l=t[o],a=e[o<<1],h=e[(o<<1)+1],c=kt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),kt&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=c;for(let d=0;d<10&&f.forceReduce()&&(kt&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)kt&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))kt&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),kt&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Vl(l,i)):(!n||n.score<f.score)&&(n=f)}return n}stackToTree(t){return t.close(),X.build({buffer:Vn.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(Ls||(Ls=new WeakMap)).get(t);return e||Ls.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function Vl(s,t){for(let e=0;e<t.length;e++){let i=t[e];if(i.pos==s.pos&&i.sameState(s)){t[e].score<s.score&&(t[e]=s);return}}t.push(s)}class _g{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||this.disabled[t]==0}}class zn extends wh{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let l=0;l<t.repeatNodeCount;l++)e.push("");let i=Object.keys(t.topRules).map(l=>t.topRules[l][1]),n=[];for(let l=0;l<e.length;l++)n.push([]);function r(l,a,h){n[l].push([a,a.deserialize(String(h))])}if(t.nodeProps)for(let l of t.nodeProps){let a=l[0];typeof a=="string"&&(a=L[a]);for(let h=1;h<l.length;){let c=l[h++];if(c>=0)r(c,a,l[h++]);else{let f=l[h+-c];for(let u=-c;u>0;u--)r(l[h++],a,f);h++}}}this.nodeSet=new $r(e.map((l,a)=>xt.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:n[a],top:i.indexOf(a)>-1,error:a==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(a)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=gh;let o=ln(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(zl),this.states=ln(t.states,Uint32Array),this.data=ln(t.stateData),this.goto=ln(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(l=>typeof l=="number"?new _e(o,l):l),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let n=new Xg(this,t,e,i);for(let r of this.wrappers)n=r(n,t,e,i);return n}getGoto(t,e,i=!1){let n=this.goto;if(e>=n[0])return-1;for(let r=n[e+1];;){let o=n[r++],l=o&1,a=n[r++];if(l&&i)return a;for(let h=r+(o>>1);r<h;r++)if(n[r]==t)return a;if(l)return-1}}hasAction(t,e){let i=this.data;for(let n=0;n<2;n++)for(let r=this.stateSlot(t,n?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=ee(i,r+2)];else{if(i[r+1]==2)return ee(i,r+2);break}if(o==e||o==0)return ee(i,r+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,i=>i==e?!0:null)}allActions(t,e){let i=this.stateSlot(t,4),n=i?e(i):void 0;for(let r=this.stateSlot(t,1);n==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=ee(this.data,r+2);else break;n=e(ee(this.data,r+1))}return n}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=ee(this.data,i+2);else break;if((this.data[i+2]&1)==0){let n=this.data[i+1];e.some((r,o)=>o&1&&r==n)||e.push(this.data[i],n)}}return e}configure(t){let e=Object.assign(Object.create(zn.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let n=t.tokenizers.find(r=>r.from==i);return n?n.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,n)=>{let r=t.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return e.specializers[n]=zl(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let r of t.split(" ")){let o=e.indexOf(r);o>=0&&(i[o]=!0)}let n=null;for(let r=0;r<e.length;r++)if(!i[r])for(let o=this.dialects[e[r]],l;(l=this.data[o++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[l]=1;return new _g(t,i,n)}static deserialize(t){return new zn(t)}}function ee(s,t){return s[t]|s[t+1]<<16}function Jg(s){let t=null;for(let e of s){let i=e.p.stoppedAt;(e.pos==e.p.stream.end||i!=null&&e.pos>i)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function zl(s){if(s.external){let t=s.extend?1:0;return(e,i)=>s.external(e,i)<<1|t}return s.get}const Zg=kh({String:D.string,Number:D.number,"True False":D.bool,PropertyName:D.propertyName,Null:D.null,", :":D.separator,"[ ]":D.squareBracket,"{ }":D.brace}),t0=zn.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[Zg],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),e0=()=>s=>{try{JSON.parse(s.state.doc.toString())}catch(t){if(!(t instanceof SyntaxError))throw t;const e=i0(t,s.state.doc);return[{from:e,message:t.message,severity:"error",to:e}]}return[]};function i0(s,t){let e;return(e=s.message.match(/at position (\d+)/))?Math.min(+e[1],t.length):(e=s.message.match(/at line (\d+) column (\d+)/))?Math.min(t.line(+e[1]).from+ +e[2]-1,t.length):0}const Oc=Pn.define({name:"json",parser:t0.configure({props:[Ah.add({Object:ul({except:/^\s*\}/}),Array:ul({except:/^\s*\]/})}),Oh.add({"Object Array":mp})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function n0(){return new np(Oc)}class $l{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class De{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=i.facet(Jt).markerFilter;n&&(t=n(t,i));let r=t.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new se,l=[],a=0,h=i.doc.iter(),c=0,f=i.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!l.length)break;let m,g;if(l.length)m=a,g=l.reduce((b,O)=>Math.min(b,O.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;g=p.to,l.push(p),d++}for(;d<r.length;){let b=r[d];if(b.from==m&&(b.to>b.from||b.to==m))l.push(b),d++,g=Math.min(b.to,g);else{g=Math.min(b.from,g);break}}g=Math.min(g,f);let y=!1;if(l.some(b=>b.from==m&&(b.to==g||g==f))&&(y=m==g,!y&&g-m<10)){let b=m-(c+h.value.length);b>0&&(h.next(b),c=m);for(let O=m;;){if(O>=g){y=!0;break}if(!h.lineBreak&&c+h.value.length>O)break;O=c+h.value.length,c+=h.value.length,h.next()}}let w=Ec(l);if(y)o.add(m,m,H.widget({widget:new d0(w),diagnostics:l.slice()}));else{let b=l.reduce((O,k)=>k.markClass?O+" "+k.markClass:O,"");o.add(m,g,H.mark({class:"cm-lintRange cm-lintRange-"+w+b,diagnostics:l.slice(),inclusiveEnd:l.some(O=>O.to>g)}))}if(a=g,a==f)break;for(let b=0;b<l.length;b++)l[b].to<=a&&l.splice(b--,1)}let u=o.finish();return new De(u,e,Se(u))}}function Se(s,t=null,e=0){let i=null;return s.between(e,1e9,(n,r,{spec:o})=>{if(!(t&&o.diagnostics.indexOf(t)<0))if(!i)i=new $l(n,r,t||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new $l(i.from,r,i.diagnostic)}}),i}function Tc(s,t){let e=t.pos,i=t.end||e,n=s.state.facet(Jt).hideOn(s,e,i);if(n!=null)return n;let r=s.startState.doc.lineAt(t.pos);return!!(s.effects.some(o=>o.is(ss))||s.changes.touchesRange(r.from,Math.max(r.to,i)))}function Dc(s,t){return s.field(Ct,!1)?t:t.concat(I.appendConfig.of(Wc))}function s0(s,t){return{effects:Dc(s,[ss.of(t)])}}const ss=I.define(),io=I.define(),Bc=I.define(),Ct=mt.define({create(){return new De(H.none,null,null)},update(s,t){if(t.docChanged&&s.diagnostics.size){let e=s.diagnostics.map(t.changes),i=null,n=s.panel;if(s.selected){let r=t.changes.mapPos(s.selected.from,1);i=Se(e,s.selected.diagnostic,r)||Se(e,null,r)}!e.size&&n&&t.state.facet(Jt).autoPanel&&(n=null),s=new De(e,n,i)}for(let e of t.effects)if(e.is(ss)){let i=t.state.facet(Jt).autoPanel?e.value.length?Ri.open:null:s.panel;s=De.init(e.value,i,t.state)}else e.is(io)?s=new De(s.diagnostics,e.value?Ri.open:null,s.selected):e.is(Bc)&&(s=new De(s.diagnostics,s.panel,e.value));return s},provide:s=>[ur.from(s,t=>t.panel),T.decorations.from(s,t=>t.diagnostics)]}),r0=H.mark({class:"cm-lintRange cm-lintRange-active"});function o0(s,t,e){let{diagnostics:i}=s.state.field(Ct),n,r=-1,o=-1;i.between(t-(e<0?1:0),t+(e>0?1:0),(a,h,{spec:c})=>{if(t>=a&&t<=h&&(a==h||(t>a||e>0)&&(t<h||e<0)))return n=c.diagnostics,r=a,o=h,!1});let l=s.state.facet(Jt).tooltipFilter;return n&&l&&(n=l(n,s.state)),n?{pos:r,end:o,above:!0,create(){return{dom:Pc(s,n)}}}:null}function Pc(s,t){return Gt("ul",{class:"cm-tooltip-lint"},t.map(e=>Lc(s,e,!1)))}const l0=s=>{let t=s.state.field(Ct,!1);(!t||!t.panel)&&s.dispatch({effects:Dc(s.state,[io.of(!0)])});let e=Td(s,Ri.open);return e&&e.dom.querySelector(".cm-panel-lint ul").focus(),!0},ql=s=>{let t=s.state.field(Ct,!1);return!t||!t.panel?!1:(s.dispatch({effects:io.of(!1)}),!0)},a0=s=>{let t=s.state.field(Ct,!1);if(!t)return!1;let e=s.state.selection.main,i=Se(t.diagnostics,null,e.to+1);return!i&&(i=Se(t.diagnostics,null,0),!i||i.from==e.from&&i.to==e.to)?!1:(s.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),Md(s,i.from,1,{tooltip:Hc,until:n=>n.docChanged||n.newSelection.main.head<i.from||n.newSelection.main.head>i.to}),!0)},h0=[{key:"Mod-Shift-m",run:l0,preventDefault:!0},{key:"F8",run:a0}],c0=st.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:t}=s.state.facet(Jt);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let s=Date.now();if(s<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-s);else{this.set=!1;let{state:t}=this.view,{sources:e}=t.facet(Jt);e.length&&f0(e.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==t.doc&&this.view.dispatch(s0(this.view.state,i.reduce((n,r)=>n.concat(r))))},i=>{ut(this.view.state,i)})}}update(s){let t=s.state.facet(Jt);(s.docChanged||t!=s.startState.facet(Jt)||t.needsRefresh&&t.needsRefresh(s))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function f0(s,t,e){let i=[],n=-1;for(let r of s)r.then(o=>{i.push(o),clearTimeout(n),i.length==s.length?t(i):n=setTimeout(()=>t(i),200)},e)}const Jt=M.define({combine(s){return{sources:s.map(t=>t.source).filter(t=>t!=null),...he(s.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:jl,tooltipFilter:jl,needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e,hideOn:(t,e)=>t?e?(i,n,r)=>t(i,n,r)||e(i,n,r):t:e,autoPanel:(t,e)=>t||e})}}});function jl(s,t){return s?t?(e,i)=>t(s(e,i),i):s:t}function u0(s,t={}){return[Jt.of({source:s,config:t}),c0,Wc]}function Rc(s){let t=[];if(s)t:for(let{name:e}of s){for(let i=0;i<e.length;i++){let n=e[i];if(/[a-zA-Z]/.test(n)&&!t.some(r=>r.toLowerCase()==n.toLowerCase())){t.push(n);continue t}}t.push("")}return t}function Lc(s,t,e){var i;let n=e?Rc(t.actions):[];return Gt("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Gt("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(s):t.message),(i=t.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Se(s.state.field(Ct).diagnostics,t);p&&r.apply(s,p.from,p.to)},{name:h}=r,c=n[o]?h.indexOf(n[o]):-1,f=c<0?h:[h.slice(0,c),Gt("u",h.slice(c,c+1)),h.slice(c+1)],u=r.markClass?" "+r.markClass:"";return Gt("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[o]})"`}.`},f)}),t.source&&Gt("div",{class:"cm-diagnosticSource"},t.source))}class d0 extends ce{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Gt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Kl{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Lc(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ri{constructor(t){this.view=t,this.items=[];let e=n=>{if(!(n.ctrlKey||n.altKey||n.metaKey)){if(n.keyCode==27)ql(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Rc(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==n.keyCode){let a=Se(this.view.state.field(Ct).diagnostics,r);a&&r.actions[l].apply(t,a.from,a.to)}}else return;n.preventDefault()}},i=n=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(n.target)&&this.moveSelection(r)};this.list=Gt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e,onclick:i}),this.dom=Gt("div",{class:"cm-panel-lint"},this.list,Gt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>ql(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(Ct).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(Ct),i=0,n=!1,r=null,o=new Set;for(t.between(0,this.view.state.doc.length,(l,a,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new Kl(this.view,c),this.items.splice(i,0,u),n=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),n=!0)),e&&u.diagnostic==e.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new Kl(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/h:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let t=this.list.firstChild;function e(){let i=t;t=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=this.view.state.field(Ct),i=Se(e.diagnostics,this.items[t].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Bc.of(i)})}static open(t){return new Ri(t)}}function yn(s,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(s)}</svg>')`}function an(s){return yn(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${s}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const p0=T.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:an("#f11")},".cm-lintRange-warning":{backgroundImage:an("orange")},".cm-lintRange-info":{backgroundImage:an("#999")},".cm-lintRange-hint":{backgroundImage:an("#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}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function m0(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function Ec(s){let t="hint",e=1;for(let i of s){let n=m0(i.severity);n>e&&(e=n,t=i.severity)}return t}class Ic extends le{constructor(t){super(),this.diagnostics=t,this.severity=Ec(t)}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=t.state.facet(rs).tooltipFilter;return n&&(i=n(i,t.state)),i.length&&(e.onmouseover=()=>y0(t,e,i)),e}}function g0(s,t){let e=i=>{let n=t.getBoundingClientRect();if(!(i.clientX>n.left-10&&i.clientX<n.right+10&&i.clientY>n.top-10&&i.clientY<n.bottom+10)){for(let r=i.target;r;r=r.parentNode)if(r.nodeType==1&&r.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",e),s.state.field(Nc)&&s.dispatch({effects:no.of(null)})}};window.addEventListener("mousemove",e)}function y0(s,t,e){function i(){let o=s.elementAtHeight(t.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:no.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Pc(s,e),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,g0(s,t)}let{hoverTime:n}=s.state.facet(rs),r=setTimeout(i,n);t.onmouseout=()=>{clearTimeout(r),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,n)}}function b0(s,t){let e=Object.create(null);for(let n of t){let r=s.lineAt(n.from);(e[r.from]||(e[r.from]=[])).push(n)}let i=[];for(let n in e)i.push(new Ic(e[n]).range(+n));return R.of(i,!0)}const x0=dh({class:"cm-gutter-lint",markers:s=>s.state.field(Cr),widgetMarker:(s,t,e)=>{let i=[];return s.state.field(Cr).between(e.from,e.to,(n,r,o)=>{n>e.from&&n<e.to&&i.push(...o.diagnostics)}),i.length?new Ic(i):null}}),Cr=mt.define({create(){return R.empty},update(s,t){s=s.map(t.changes);let e=t.state.facet(rs).markerFilter;for(let i of t.effects)if(i.is(ss)){let n=i.value;e&&(n=e(n||[],t.state)),s=b0(t.state.doc,n.slice(0))}return s}}),no=I.define(),Nc=mt.define({create(){return null},update(s,t){return s&&t.docChanged&&(s=Tc(t,s)?null:{...s,pos:t.changes.mapPos(s.pos)}),t.effects.reduce((e,i)=>i.is(no)?i.value:e,s)},provide:s=>Yn.from(s)}),w0=T.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:yn('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:yn('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:yn('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Hc=Ad(o0,{hideOn:Tc}),Wc=[Ct,T.decorations.compute([Ct],s=>{let{selected:t,panel:e}=s.field(Ct);return!t||!e||t.from==t.to?H.none:H.set([r0.range(t.from,t.to)])}),Hc,p0],rs=M.define({combine(s){return he(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function k0(s={}){return[rs.of(s),Cr,x0,w0,Nc]}class wi{constructor(t=[]){this.at=t}static FIELDS=Vc;fieldsAt(t){let e=wi.FIELDS;for(const i of t)e=e?.[i]?.fields;return e}pathTo(t,e){const i=[];for(let n=t;n;n=n.parent)if(n.name==="Property"){const r=n.getChild("PropertyName");r&&i.unshift(e.slice(r.from,r.to).replace(/^"|"$/g,""))}return[...this.at,...i]}keyCompletions(t){return Object.entries(t).map(([e,i])=>({label:`"${e}"`,apply:`"${e}": `,type:i.type==="enum"?"enum":i.type==="object"||i.type==="array"?"class":"property",detail:i.type==="enum"?i.values?.join(" | "):i.type,...i.doc===void 0?{}:{info:i.doc}}))}valueCompletions(t){return(t.values??[]).map(e=>({label:`"${e}"`,apply:`"${e}"`,type:"enum"}))}get source(){return t=>{const e=t.state.doc.toString(),i=rt(t.state).resolveInner(t.pos,-1),n=e.slice(0,t.pos);if(i.name==="PropertyName")return this.keys(this.pathTo(i.parent?.parent??null,e),i.from,i.to);if(i.name==="String"&&i.parent?.name==="Property")return this.values(this.fieldAt(this.pathTo(i.parent,e)),i.from,i.to);if(/:\s*$/.test(n)){const o=i.name==="Property"?i:this.propertyBefore(i,t.pos);return this.values(o?this.fieldAt(this.pathTo(o,e)):void 0,t.pos)}if(!t.explicit&&!/[{,[]\s*$/.test(n))return null;const r=i.name==="Object"?i:i.parent?.name==="Object"?i.parent:i;return this.keys(this.pathTo(r,e),t.pos)}}keys(t,e,i){const n=this.fieldsAt(t);return n===void 0?null:{from:e,...i===void 0?{}:{to:i},options:this.keyCompletions(n),validFor:wi.WORD}}values(t,e,i){return t?.values===void 0?null:{from:e,...i===void 0?{}:{to:i},options:this.valueCompletions(t),validFor:wi.WORD}}static WORD=/^"?[\w-]*"?$/;fieldAt(t){return this.fieldsAt(t.slice(0,-1))?.[t[t.length-1]]}propertyBefore(t,e){let i;for(let n=t.firstChild;n;n=n.nextSibling)n.name==="Property"&&n.from<e&&(i=n);return i}}class Fc{static COLOURS=Jn.define([{tag:D.propertyName,color:"var(--file-key)"},{tag:[D.string,D.attributeValue],color:"var(--file-string)"},{tag:[D.number,D.bool,D.null],color:"var(--file-literal)"},{tag:D.invalid,color:"var(--rr0-alert)"}]);view;changing=!1;constructor(t,e,i,n){const r=[...Ig,...ig,...hm,...Sp,...Mc,...h0,ng];this.view=new T({parent:t,doc:e,extensions:[Hd(),Op(),ud(),tm(),id(),dp(),Wp(),Pg(),$g(),Vr.of(r),V.tabSize.of(2),Dp(Fc.COLOURS,{fallback:!0}),n0(),Oc.data.of({autocomplete:new wi().source}),k0(),u0(e0()),T.contentAttributes.of({"aria-label":n}),T.theme({"&":{maxHeight:"28rem",fontSize:"0.82em",border:"1px solid color-mix(in srgb, currentColor 25%, transparent)",borderRadius:"4px"},"&.cm-focused":{outline:"2px solid color-mix(in srgb, currentColor 45%, transparent)"},".cm-scroller":{overflow:"auto",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},".cm-tooltip":{backgroundColor:"Canvas",color:"CanvasText",border:"1px solid color-mix(in srgb, CanvasText 30%, transparent)"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:"Highlight",color:"HighlightText"},".cm-gutters":{backgroundColor:"transparent",color:"color-mix(in srgb, currentColor 55%, transparent)",border:"none"}}),T.updateListener.of(o=>{o.docChanged&&!this.changing&&i(o.state.doc.toString())})]})}get text(){return this.view.state.doc.toString()}set text(t){const e=this.view.state.doc.toString();if(t!==e){this.changing=!0;try{const i=Math.min(this.view.state.selection.main.head,t.length);this.view.dispatch({changes:{from:0,to:e.length,insert:t},selection:{anchor:i}})}finally{this.changing=!1}}}get focused(){return this.view.hasFocus}destroy(){this.view.destroy()}}export{Fc as SightingFileEditor};
|