-`){[e,t]=$i(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let O=this.children[s],a=o+O.length;o>e&&s&&(r+=n),e<a&&t>o&&(r+=O.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i))return 0;let n=0,[r,s,o,O]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==O)return n;let a=this.children[r],h=e.children[s];if(a!=h)return n+a.scanIdentical(h,t);n+=a.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new We(d,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,O=[],a=0,h=-1,l=[];function c(d){let p;if(d.lines>s&&d instanceof i)for(let m of d.children)c(m);else d.lines>o&&(a>o||!a)?(f(),O.push(d)):d instanceof We&&a&&(p=l[l.length-1])instanceof We&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,l[l.length-1]=new We(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&f(),a+=d.lines,h+=d.length+1,l.push(d))}function f(){a!=0&&(O.push(l.length==1?l[0]:i.from(l,h)),h=-1,a=l.length=0)}for(let d of e)c(d);return f(),O.length==1?O[0]:new i(O,t)}};Y.empty=new We([""],0);function Ed(i){let e=-1;for(let t of i)e+=t.length+1;return e}function _n(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s<i.length&&r<=n;s++){let O=i[s],a=r+O.length;a>=t&&(a>n&&(O=O.slice(0,n-r)),r<t&&(O=O.slice(t-r)),o?(e[e.length-1]+=O,o=!1):e.push(O)),r=a+1}return e}function va(i,e,t){return _n(i,[""],e,t)}var Nt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof We?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,O=r instanceof We?r.text.length:r.children.length;if(o==(t>0?O:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
-`,this;e--}else if(r instanceof We){let a=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof We?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},jn=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Nt(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},En=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},Nt.prototype[Symbol.iterator]=jn.prototype[Symbol.iterator]=En.prototype[Symbol.iterator]=function(){return this});var ls=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function $i(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}var di="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(i=>i?parseInt(i,36):1);for(let i=1;i<di.length;i++)di[i]+=di[i-1];function Md(i){for(let e=1;e<di.length;e+=2)if(di[e]>i)return di[e-1]<=i;return!1}function za(i){return i>=127462&&i<=127487}var Ra=8205;function le(i,e,t=!0,n=!0){return(t?Ca:Gd)(i,e,n)}function Ca(i,e,t){if(e==i.length)return e;e&&Ya(i.charCodeAt(e))&&Ua(i.charCodeAt(e-1))&&e--;let n=pi(i,e);for(e+=Mi(n);e<i.length;){let r=pi(i,e);if(n==Ra||r==Ra||t&&Md(r))e+=Mi(r),n=r;else if(za(r)){let s=0,o=e-2;for(;o>=0&&za(pi(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Gd(i,e,t){for(;e>0;){let n=Ca(i,e-2,t);if(n<e)return n;e--}return 0}function Ya(i){return i>=56320&&i<57344}function Ua(i){return i>=55296&&i<56320}function pi(i,e){let t=i.charCodeAt(e);if(!Ua(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Ya(n)?(t-55296<<10)+(n-56320)+65536:t}function Mi(i){return i<65536?1:2}var hs=/\r\n?|\n/,ae=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(ae||(ae={})),dt=class i{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,s),r+=s):r+=o,n+=s}}iterChangedRanges(e,t=!1){cs(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new i(e)}composeDesc(e){return this.empty?e:e.empty?this:Aa(this,e)}mapDesc(e,t=!1){return e.empty?this:fs(this,e,t)}mapPos(e,t=-1,n=ae.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let O=this.sections[o++],a=this.sections[o++],h=r+O;if(a<0){if(h>e)return s+(e-r);s+=O}else{if(n!=ae.Simple&&h>=e&&(n==ae.TrackDel&&r<e&&h>e||n==ae.TrackBefore&&r<e||n==ae.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!O)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let s=this.sections[n++],o=this.sections[n++],O=r+s;if(o>=0&&r<=t&&O>=e)return r<e&&O>t?"cover":!0;r=O}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new i(e)}static create(e){return new i(e)}},me=class i extends dt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return cs(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return fs(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],O=t[r+1];if(O>=0){t[r]=O,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(Y.empty);n.push(o?e.slice(s,s+o):Y.empty)}s+=o}return new i(t,n)}compose(e){return this.empty?e:e.empty?this:Aa(this,e,!0)}map(e,t=!1){return e.empty?this:fs(this,e,t,!0)}iterChanges(e,t=!1){cs(this,e,t)}get desc(){return dt.create(this.sections)}filter(e){let t=[],n=[],r=[],s=new Bt(this);e:for(let o=0,O=0;;){let a=o==e.length?1e9:e[o++];for(;O<a||O==a&&s.len==0;){if(s.done)break e;let l=Math.min(s.len,a-O);ce(r,l,-1);let c=s.ins==-1?-1:s.off==0?s.ins:0;ce(t,l,c),c>0&&xt(n,t,s.text),s.forward(l),O+=l}let h=e[o++];for(;O<h;){if(s.done)break e;let l=Math.min(s.len,h-O);ce(t,l,-1),ce(r,l,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(l),O+=l}}return{changes:new i(t,n),filtered:dt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,O=null;function a(l=!1){if(!l&&!r.length)return;o<t&&ce(r,t-o,-1);let c=new i(r,s);O=O?O.compose(c.map(O)):c,r=[],s=[],o=0}function h(l){if(Array.isArray(l))for(let c of l)h(c);else if(l instanceof i){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),O=O?O.compose(l.map(O)):l}else{let{from:c,to:f=c,insert:d}=l;if(c>f||c<0||f>t)throw new RangeError(`Invalid change range ${c} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?Y.of(d.split(n||hs)):d:Y.empty,m=p.length;if(c==f&&m==0)return;c<o&&a(),c>o&&ce(r,c-o,-1),ce(r,f-c,m),xt(s,r,p),o=f}}return h(e),a(!O),O}static empty(e){return new i(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,O)=>O&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<r;)n.push(Y.empty);n[r]=Y.of(s.slice(1)),t.push(s[0],n[r].length)}}}return new i(t,n)}static createSet(e,t){return new i(e,t)}};function ce(i,e,t,n=!1){if(e==0&&t<=0)return;let r=i.length-2;r>=0&&t<=0&&t==i[r+1]?i[r]+=e:e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function xt(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(t);else{for(;i.length<n;)i.push(Y.empty);i.push(t)}}function cs(i,e,t){let n=i.inserted;for(let r=0,s=0,o=0;o<i.sections.length;){let O=i.sections[o++],a=i.sections[o++];if(a<0)r+=O,s+=O;else{let h=r,l=s,c=Y.empty;for(;h+=O,l+=a,a&&n&&(c=c.append(n[o-2>>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)O=i.sections[o++],a=i.sections[o++];e(r,h,s,l,c),r=h,s=l}}}function fs(i,e,t,n=!1){let r=[],s=n?[]:null,o=new Bt(i),O=new Bt(e);for(let a=-1;;)if(o.ins==-1&&O.ins==-1){let h=Math.min(o.len,O.len);ce(r,h,-1),o.forward(h),O.forward(h)}else if(O.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(O.len<o.len||O.len==o.len&&!t))){let h=O.len;for(ce(r,O.ins,-1);h;){let l=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=l&&(ce(r,0,o.ins),s&&xt(s,r,o.text),a=o.i),o.forward(l),h-=l}O.next()}else if(o.ins>=0){let h=0,l=o.len;for(;l;)if(O.ins==-1){let c=Math.min(l,O.len);h+=c,l-=c,O.forward(c)}else if(O.ins==0&&O.len<l)l-=O.len,O.next();else break;ce(r,h,a<o.i?o.ins:0),s&&a<o.i&&xt(s,r,o.text),a=o.i,o.forward(o.len-l)}else{if(o.done&&O.done)return s?me.createSet(r,s):dt.create(r);throw new Error("Mismatched change set lengths")}}function Aa(i,e,t=!1){let n=[],r=t?[]:null,s=new Bt(i),o=new Bt(e);for(let O=!1;;){if(s.done&&o.done)return r?me.createSet(n,r):dt.create(n);if(s.ins==0)ce(n,s.len,0,O),s.next();else if(o.len==0&&!o.done)ce(n,0,o.ins,O),r&&xt(r,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=n.length;if(s.ins==-1){let l=o.ins==-1?-1:o.off?0:o.ins;ce(n,a,l,O),r&&l&&xt(r,n,o.text)}else o.ins==-1?(ce(n,s.off?0:s.len,a,O),r&&xt(r,n,s.textBit(a))):(ce(n,s.off?0:s.len,o.off?0:o.ins,O),r&&!o.off&&xt(r,n,o.text));O=(s.ins>a||o.ins>=0&&o.len>a)&&(O||n.length>h),s.forward2(a),o.forward(a)}}}}var Bt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Y.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Y.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},fi=class i{constructor(e,t,n){this.from=e,this.to=t,this.flags=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 bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new i(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return y.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return y.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return y.range(e.anchor,e.head)}static create(e,t,n){return new i(e,t,n)}},y=class i{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:i.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new i([this.main],0)}addRange(e,t=!0){return i.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,i.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new i(e.ranges.map(t=>fi.fromJSON(t)),e.main)}static single(e,t=e){return new i([i.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=n:s.from<n)return i.normalized(e.slice(),t);n=s.to}return new i(e,t)}static cursor(e,t=0,n,r){return fi.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r){let s=(n??16777215)<<6|(r==null?7:Math.min(6,r));return t<e?fi.create(t,e,48|s):fi.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let O=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?i.range(a,O):i.range(O,a))}}return new i(e,t)}};function _a(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Ps=0,z=class i{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Ps++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new i(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:bs),!!e.static,e.enables)}of(e){return new mi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new mi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new mi(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function bs(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}var mi=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Ps++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,O=this.type==2,a=!1,h=!1,l=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?h=!0:((t=e[c.id])!==null&&t!==void 0?t:1)&1||l.push(e[c.id]);return{create(c){return c.values[o]=n(c),1},update(c,f){if(a&&f.docChanged||h&&(f.docChanged||f.selection)||us(c,l)){let d=n(c);if(O?!Xa(d,c.values[o],r):!r(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,f)=>{let d,p=f.config.address[s];if(p!=null){let m=Ln(f,p);if(this.dependencies.every(g=>g instanceof z?f.facet(g)===c.facet(g):g instanceof ge?f.field(g,!1)==c.field(g,!1):!0)||(O?Xa(d=n(c),m,r):r(d=n(c),m)))return c.values[o]=m,0}else d=n(c);return c.values[o]=d,1}}}};function Xa(i,e,t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!t(i[n],e[n]))return!1;return!0}function us(i,e){let t=!1;for(let n of e)Ei(i,n)&1&&(t=!0);return t}function Ld(i,e,t){let n=t.map(a=>i[a.id]),r=t.map(a=>a.type),s=n.filter(a=>!(a&1)),o=i[e.id]>>1;function O(a){let h=[];for(let l=0;l<n.length;l++){let c=Ln(a,n[l]);if(r[l]==2)for(let f of c)h.push(f);else h.push(c)}return e.combine(h)}return{create(a){for(let h of n)Ei(a,h);return a.values[o]=O(a),1},update(a,h){if(!us(a,s))return 0;let l=O(a);return e.compare(l,a.values[o])?0:(a.values[o]=l,1)},reconfigure(a,h){let l=us(a,n),c=h.config.facets[e.id],f=h.facet(e);if(c&&!l&&bs(t,c))return a.values[o]=f,0;let d=O(a);return e.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}var Wa=z.define({static:!0}),ge=class i{constructor(e,t,n,r,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new i(Ps++,e.create,e.update,e.compare||((n,r)=>n===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Wa).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,Wa.of({field:this,create:e})]}get extension(){return this}},Dt={lowest:4,low:3,default:2,high:1,highest:0};function ji(i){return e=>new Mn(e,i)}var nt={highest:ji(Dt.highest),high:ji(Dt.high),default:ji(Dt.default),low:ji(Dt.low),lowest:ji(Dt.lowest)},Mn=class{constructor(e,t){this.inner=e,this.prec=t}},pt=class i{of(e){return new Gi(this,e)}reconfigure(e){return i.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Gi=class{constructor(e,t){this.compartment=e,this.inner=t}},Gn=class i{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let f of Dd(e,t,o))f instanceof ge?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let O=Object.create(null),a=[],h=[];for(let f of r)O[f.id]=h.length<<1,h.push(d=>f.slot(d));let l=n?.config.facets;for(let f in s){let d=s[f],p=d[0].facet,m=l&&l[f]||[];if(d.every(g=>g.type==0))if(O[p.id]=a.length<<1|1,bs(m,d))a.push(n.facet(p));else{let g=p.combine(d.map($=>$.value));a.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of d)g.type==0?(O[g.id]=a.length<<1|1,a.push(g.value)):(O[g.id]=h.length<<1,h.push($=>g.dynamicSlot($)));O[p.id]=h.length<<1,h.push(g=>Ld(g,p,d))}}let c=h.map(f=>f(O));return new i(e,o,c,O,a,s)}};function Dd(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,O){let a=r.get(o);if(a!=null){if(a<=O)return;let h=n[a].indexOf(o);h>-1&&n[a].splice(h,1),o instanceof Gi&&t.delete(o.compartment)}if(r.set(o,O),Array.isArray(o))for(let h of o)s(h,O);else if(o instanceof Gi){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,O)}else if(o instanceof Mn)s(o.inner,o.prec);else if(o instanceof ge)n[O].push(o),o.provides&&s(o.provides,O);else if(o instanceof mi)n[O].push(o),o.facet.extensions&&s(o.facet.extensions,Dt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,O)}}return s(i,Dt.default),n.reduce((o,O)=>o.concat(O))}function Ei(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function Ln(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}var ja=z.define(),ds=z.define({combine:i=>i.some(e=>e),static:!0}),Ea=z.define({combine:i=>i.length?i[0]:void 0,static:!0}),Ma=z.define(),Ga=z.define(),La=z.define(),Da=z.define({combine:i=>i.length?i[0]:!1}),ke=class{constructor(e,t){this.type=e,this.value=t}static define(){return new ps}},ps=class{of(e){return new ke(this,e)}},ms=class{constructor(e){this.map=e}of(e){return new D(this,e)}},D=class i{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new i(this.type,t)}is(e){return this.type==e}static define(e={}){return new ms(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}};D.reconfigure=D.define();D.appendConfig=D.define();var ne=class i{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&_a(n,t.newLength),s.some(O=>O.type==i.time)||(this.annotations=s.concat(i.time.of(Date.now())))}static create(e,t,n,r,s,o){return new i(e,t,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(i.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};ne.time=ke.define();ne.userEvent=ke.define();ne.addToHistory=ke.define();ne.remote=ke.define();function Id(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n<i.length&&(r==e.length||e[r]>=i[n]))s=i[n++],o=i[n++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Ia(i,e,t){var n;let r,s,o;return t?(r=e.changes,s=me.empty(e.changes.length),o=i.changes.compose(e.changes)):(r=e.changes.map(i.changes),s=i.changes.mapDesc(e.changes,!0),o=i.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(n=i.selection)===null||n===void 0?void 0:n.map(r),effects:D.mapEffects(i.effects,r).concat(D.mapEffects(e.effects,s)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function gs(i,e,t){let n=e.selection,r=gi(e.annotations);return e.userEvent&&(r=r.concat(ne.userEvent.of(e.userEvent))),{changes:e.changes instanceof me?e.changes:me.of(e.changes||[],t,i.facet(Ea)),selection:n&&(n instanceof y?n:y.single(n.anchor,n.head)),effects:gi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Na(i,e,t){let n=gs(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;n=Ia(n,gs(i,e[s],o?n.changes.newLength:i.doc.length),o)}let r=ne.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Bd(t?Nd(r):r)}function Nd(i){let e=i.startState,t=!0;for(let r of e.facet(Ma)){let s=r(i);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:Id(t,s))}if(t!==!0){let r,s;if(t===!1)s=i.changes.invertedDesc,r=me.empty(e.doc.length);else{let o=i.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}i=ne.create(e,r,i.selection&&i.selection.map(s),D.mapEffects(i.effects,s),i.annotations,i.scrollIntoView)}let n=e.facet(Ga);for(let r=n.length-1;r>=0;r--){let s=n[r](i);s instanceof ne?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ne?i=s[0]:i=Na(e,gi(s),!1)}return i}function Bd(i){let e=i.startState,t=e.facet(La),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=Ia(n,gs(e,s,i.changes.newLength),!0))}return n==i?i:ne.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}var Fd=[];function gi(i){return i==null?Fd:Array.isArray(i)?i:[i]}var _e=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(_e||(_e={})),Hd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,$s;try{$s=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Kd(i){if($s)return $s.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||Hd.test(t)))return!0}return!1}function Jd(i){return e=>{if(!/\S/.test(e))return _e.Space;if(Kd(e))return _e.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return _e.Word;return _e.Other}}var I=class i{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let O=0;O<this.config.dynamicSlots.length;O++)Ei(this,O<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Ei(this,n),Ln(this,n)}update(...e){return Na(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:r}=t;for(let O of e.effects)O.is(pt.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(O.value.compartment,O.value.extension)):O.is(D.reconfigure)?(t=null,n=O.value):O.is(D.appendConfig)&&(t=null,n=gi(n).concat(O.value));let s;t?s=e.startState.values.slice():(t=Gn.resolve(n,r,this),s=new i(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(ds)?e.newSelection:e.newSelection.asSingle();new i(t,e.newDoc,o,s,(O,a)=>a.update(O,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=gi(n.effects);for(let O=1;O<t.ranges.length;O++){let a=e(t.ranges[O]),h=this.changes(a.changes),l=h.map(r);for(let f=0;f<O;f++)s[f]=s[f].map(l);let c=r.mapDesc(h,!0);s.push(a.range.map(c)),r=r.compose(l),o=D.mapEffects(o,l).concat(D.mapEffects(gi(a.effects),c))}return{changes:r,selection:y.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof me?e:me.of(e,this.doc.length,this.facet(i.lineSeparator))}toText(e){return Y.of(e.split(this.facet(i.lineSeparator)||hs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ei(this,t),Ln(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof ge&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let o=n[s],O=e[s];r.push(o.init(a=>o.spec.fromJSON(O,a)))}}return i.create({doc:e.doc,selection:y.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Gn.resolve(e.extensions||[],new Map),n=e.doc instanceof Y?e.doc:Y.of((e.doc||"").split(t.staticFacet(i.lineSeparator)||hs)),r=e.selection?e.selection instanceof y?e.selection:y.single(e.selection.anchor,e.selection.head):y.single(0);return _a(r,n.length),t.staticFacet(ds)||(r=r.asSingle()),new i(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(i.tabSize)}get lineBreak(){return this.facet(i.lineSeparator)||`
-`}get readOnly(){return this.facet(Da)}phrase(e,...t){for(let n of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(ja))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return Jd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,O=e-n;for(;o>0;){let a=le(t,o,!1);if(s(t.slice(a,o))!=_e.Word)break;o=a}for(;O<r;){let a=le(t,O);if(s(t.slice(O,a))!=_e.Word)break;O=a}return o==O?null:y.range(o+n,O+n)}};I.allowMultipleSelections=ds;I.tabSize=z.define({combine:i=>i.length?i[0]:4});I.lineSeparator=Ea;I.readOnly=Da;I.phrases=z.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});I.languageData=ja;I.changeFilter=Ma;I.transactionFilter=Ga;I.transactionExtender=La;pt.reconfigure=D.define();function kt(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],O=n[s];if(O===void 0)n[s]=o;else if(!(O===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](O,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var Be=class{eq(e){return this==e}range(e,t=e){return Li.create(e,t,this)}};Be.prototype.startSide=Be.prototype.endSide=0;Be.prototype.point=!1;Be.prototype.mapMode=ae.TrackDel;var Li=class i{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new i(e,t,n)}};function Qs(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var ys=class i{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,O=s.length;;){if(o==O)return o;let a=o+O>>1,h=s[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:O;h>=0?O=a:o=a+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],r=[],s=[],o=-1,O=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],l=this.from[a]+e,c=this.to[a]+e,f,d;if(l==c){let p=t.mapPos(l,h.startSide,h.mapMode);if(p==null||(f=d=p,h.startSide!=h.endSide&&(d=t.mapPos(l,h.endSide),d<f)))continue}else if(f=t.mapPos(l,h.startSide),d=t.mapPos(c,h.endSide),f>d||f==d&&h.startSide>0&&h.endSide<=0)continue;(d-f||h.endSide-h.startSide)<0||(o<0&&(o=f),h.point&&(O=Math.max(O,d-f)),n.push(h),r.push(f-o),s.push(d-o))}return{mapped:n.length?new i(r,s,n,O):null,pos:o}}},F=class i{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new i(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(Qs)),this.isEmpty)return t.length?i.of(t):this;let O=new Dn(this,null,-1).goto(0),a=0,h=[],l=new Ft;for(;O.value||a<t.length;)if(a<t.length&&(O.from-t[a].from||O.startSide-t[a].value.startSide)>=0){let c=t[a++];l.addInner(c.from,c.to,c.value)||h.push(c)}else O.rangeIndex==1&&O.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(O.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(O.chunkIndex)||s<this.chunkPos[O.chunkIndex])&&l.addChunk(this.chunkPos[O.chunkIndex],this.chunk[O.chunkIndex])?O.nextChunk():((!o||r>O.to||s<O.from||o(O.from,O.to,O.value))&&(l.addInner(O.from,O.to,O.value)||h.push(Li.create(O.from,O.to,O.value))),O.next());return l.finishInner(this.nextLayer.isEmpty&&!h.length?i.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let o=0;o<this.chunk.length;o++){let O=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(O,O+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),n.push(e.mapPos(O));else if(h===!0){let{mapped:l,pos:c}=a.map(O,e);l&&(r=Math.max(r,l.maxPoint),t.push(l),n.push(c))}}let s=this.nextLayer.map(e);return t.length==0?s:new i(n,t,s||i.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Di.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Di.from(e).goto(t)}static compare(e,t,n,r,s=-1){let o=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),O=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),a=Za(o,O,n),h=new It(o,a,s),l=new It(O,a,s);n.iterGaps((c,f,d)=>Va(h,c,l,f,d,r)),n.empty&&n.length==0&&Va(h,0,l,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=999999999);let s=e.filter(l=>!l.isEmpty&&t.indexOf(l)<0),o=t.filter(l=>!l.isEmpty&&e.indexOf(l)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let O=Za(s,o),a=new It(s,O,0).goto(n),h=new It(o,O,0).goto(n);for(;;){if(a.to!=h.to||!Ss(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,n,r,s=-1){let o=new It(e,null,s).goto(t),O=t,a=o.openStart;for(;;){let h=Math.min(o.to,n);if(o.point){let l=o.activeForPoint(o.to),c=o.pointFrom<t?l.length+1:o.point.startSide<0?l.length:Math.min(l.length,a);r.point(O,h,o.point,l,c,o.pointRank),a=Math.min(o.openEnd(h),l.length)}else h>O&&(r.span(O,h,o.active,a),a=o.openEnd(h));if(o.to>n)return a+(o.point&&o.to>n?1:0);O=o.to,o.next()}}static of(e,t=!1){let n=new Ft;for(let r of e instanceof Li?[e]:t?ep(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return i.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=i.empty;r=r.nextLayer)t=new i(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};F.empty=new F([],[],null,-1);function ep(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if(Qs(e,n)>0)return i.slice().sort(Qs);e=n}return i}F.empty.nextLayer=F.empty;var Ft=class i{finishChunk(e){this.chunks.push(new ys(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new i)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(F.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=F.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Za(i,e,t){let n=new Map;for(let s of i)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let O=n.get(s.chunk[o]);O!=null&&(t?t.mapPos(O):O)==s.chunkPos[o]&&!t?.touchesRange(O,O+s.chunk[o].length)&&r.add(s.chunk[o])}return r}var Dn=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Di=class i{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new Dn(o,t,n,s));return r.length==1?r[0]:new i(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)as(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)as(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),as(this.heap,0)}}};function as(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1<i.length&&r.compare(i[n+1])>=0&&(r=i[n+1],n++),t.compare(r)<0)break;i[n]=t,i[e]=r,e=n}}var It=class{constructor(e,t,n){this.minPoint=n,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=Di.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Un(this.active,e),Un(this.activeTo,e),Un(this.activeRank,e),this.minActive=qa(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;An(this.active,t,n),An(this.activeTo,t,r),An(this.activeRank,t,s),e&&An(e,t,this.cursor.from),this.minActive=qa(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Un(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let r=n.length-1;r>=0&&n[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function Va(i,e,t,n,r,s){i.goto(e),t.goto(n);let o=n+r,O=n,a=n-e;for(;;){let h=i.to+a-t.to||i.endSide-t.endSide,l=h<0?i.to+a:t.to,c=Math.min(l,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Ss(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(O,c,i.point,t.point):c>O&&!Ss(i.active,t.active)&&s.compareRange(O,c,i.active,t.active),l>o)break;O=l,h<=0&&i.next(),h>=0&&t.next()}}function Ss(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!=e[t]&&!i[t].eq(e[t]))return!1;return!0}function Un(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function An(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function qa(i,e){let t=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||i[r].endSide-i[t].endSide)<0&&(t=r,n=e[r]);return t}function we(i,e,t=i.length){let n=0;for(let r=0;r<t;)i.charCodeAt(r)==9?(n+=e-n%e,r++):(n++,r=le(i,r));return n}function In(i,e,t,n){for(let r=0,s=0;;){if(s>=e)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?t-s%t:1,r=le(i,r)}return n===!0?-1:i.length}var xs="\u037C",Ba=typeof Symbol>"u"?"__"+xs:Symbol.for(xs),ks=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Fa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},je=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,O,a,h){let l=[],c=/^@(\w+)\b/.exec(o[0]),f=c&&c[1]=="keyframes";if(c&&O==null)return a.push(o[0]+";");for(let d in O){let p=O[d];if(/&/.test(d))s(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(!c)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,l,f)}else p!=null&&l.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(l.length||f)&&a.push((n&&!c&&!h?o.map(n):o).join(", ")+" {"+l.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
-`)}static newName(){let e=Fa[Ba]||1;return Fa[Ba]=e+1,xs+e.toString(36)}static mount(e,t,n){let r=e[ks],s=n&&n.nonce;r?s&&r.setNonce(s):r=new ws(e,s),r.mount(Array.isArray(t)?t:[t],e)}},Ha=new Map,ws=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Ha.get(n);if(s)return e[ks]=s;this.sheet=new r.CSSStyleSheet,Ha.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[ks]=this}mount(e,t){let n=this.sheet,r=0,s=0;for(let o=0;o<e.length;o++){let O=e[o],a=this.modules.indexOf(O);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,O),n)for(let h=0;h<O.rules.length;h++)n.insertRule(O.rules[h],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=O.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
-`;this.styleTag.textContent=o;let O=t.head||t;this.styleTag.parentNode!=O&&O.insertBefore(this.styleTag,O.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var mt={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:"'"},Qi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},tp=typeof navigator<"u"&&/Mac/.test(navigator.platform),ip=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(re=0;re<10;re++)mt[48+re]=mt[96+re]=String(re);var re;for(re=1;re<=24;re++)mt[re+111]="F"+re;var re;for(re=65;re<=90;re++)mt[re]=String.fromCharCode(re+32),Qi[re]=String.fromCharCode(re);var re;for(Nn in mt)Qi.hasOwnProperty(Nn)||(Qi[Nn]=mt[Nn]);var Nn;function Ka(i){var e=tp&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||ip&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?Qi:mt)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function sn(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function Ws(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function np(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function nr(i,e){if(!e.anchorNode)return!1;try{return Ws(i,e.anchorNode)}catch{return!1}}function on(i){return i.nodeType==3?Jt(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Ki(i,e,t,n){return t?Ja(i,e,t,n,-1)||Ja(i,e,t,n,1):!1}function Kt(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function lr(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function Ja(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:gt(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=Kt(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?gt(i):0}else return!1}}function gt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function Pr(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function rp(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function ql(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function sp(i,e,t,n,r,s,o,O){let a=i.ownerDocument,h=a.defaultView||window;for(let l=i,c=!1;l&&!c;)if(l.nodeType==1){let f,d=l==a.body,p=1,m=1;if(d)f=rp(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(l).position)&&(c=!0),l.scrollHeight<=l.clientHeight&&l.scrollWidth<=l.clientWidth){l=l.assignedSlot||l.parentNode;continue}let Q=l.getBoundingClientRect();({scaleX:p,scaleY:m}=ql(l,Q)),f={left:Q.left,right:Q.left+l.clientWidth*p,top:Q.top,bottom:Q.top+l.clientHeight*m}}let g=0,$=0;if(r=="nearest")e.top<f.top?($=-(f.top-e.top+o),t>0&&e.bottom>f.bottom+$&&($=e.bottom-f.bottom+$+o)):e.bottom>f.bottom&&($=e.bottom-f.bottom+o,t<0&&e.top-$<f.top&&($=-(f.top+$-e.top+o)));else{let Q=e.bottom-e.top,b=f.bottom-f.top;$=(r=="center"&&Q<=b?e.top+Q/2-b/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-b+o)-f.top}if(n=="nearest"?e.left<f.left?(g=-(f.left-e.left+s),t>0&&e.right>f.right+g&&(g=e.right-f.right+g+s)):e.right>f.right&&(g=e.right-f.right+s,t<0&&e.left<f.left+g&&(g=-(f.left+g-e.left+s))):g=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==O?e.left-s:e.right-(f.right-f.left)+s)-f.left,g||$)if(d)h.scrollBy(g,$);else{let Q=0,b=0;if($){let k=l.scrollTop;l.scrollTop+=$/m,b=(l.scrollTop-k)*m}if(g){let k=l.scrollLeft;l.scrollLeft+=g/p,Q=(l.scrollLeft-k)*p}e={left:e.left-Q,top:e.top-b,right:e.right-Q,bottom:e.bottom-b},Q&&Math.abs(Q-g)<1&&(n="nearest"),b&&Math.abs(b-$)<1&&(r="nearest")}if(d)break;l=l.assignedSlot||l.parentNode}else if(l.nodeType==11)l=l.host;else break}function op(i){let e=i.ownerDocument,t,n;for(let r=i.parentNode;r&&!(r==e.body||t&&n);)if(r.nodeType==1)!n&&r.scrollHeight>r.clientHeight&&(n=r),!t&&r.scrollWidth>r.clientWidth&&(t=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:t,y:n}}var Zs=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?gt(t):0),n,Math.min(e.focusOffset,n?gt(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},yi=null;function Cl(i){if(i.setActive)return i.setActive();if(yi)return i.focus(yi);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(yi==null?{get preventScroll(){return yi={preventScroll:!0},!0}}:void 0),!yi){yi=!1;for(let t=0;t<e.length;){let n=e[t++],r=e[t++],s=e[t++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=s&&(n.scrollLeft=s)}}}var el;function Jt(i,e,t=e){let n=el||(el=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function bi(i,e,t,n){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,i.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,i.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Op(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function Yl(i){for(;i.attributes.length;)i.removeAttributeNode(i.attributes[0])}function ap(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,gt(t));;)if(n){if(t.nodeType!=1)return!1;let r=t.childNodes[n-1];r.contentEditable=="false"?n--:(t=r,n=gt(t))}else{if(t==i)return!0;n=Kt(t),t=t.parentNode}}function Ul(i){return i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function Al(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=gt(t)}else if(t.parentNode&&!lr(t))n=Kt(t),t=t.parentNode;else return null}}function _l(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!lr(t))n=Kt(t)+1,t=t.parentNode;else return null}}var $e=class i{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new i(e.parentNode,Kt(e),t)}static after(e,t){return new i(e.parentNode,Kt(e)+1,t)}},go=[],H=class i{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:n.firstChild)){let O=i.get(s);(!O||!O.parent&&O.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&s!=o.dom&&(t.written=!0),o.dom.parentNode==n)for(;s&&s!=o.dom;)s=tl(s);else n.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:n.firstChild,s&&t&&t.node==n&&(t.written=!0);s;)s=tl(s)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let r=gt(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!i.get(n);)n=n.nextSibling;if(!n)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==n)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let r=-1,s=-1,o=-1,O=-1;for(let a=0,h=n,l=n;a<this.children.length;a++){let c=this.children[a],f=h+c.length;if(h<e&&f>t)return c.domBoundsAround(e,t,h);if(f>=e&&r==-1&&(r=a,s=h),h>t&&c.dom.parentNode==this.dom){o=a,O=l;break}l=f,h=f+c.breakAfter}return{from:s,to:O<0?n+this.length:O,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=go){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&n.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...n);for(let r=0;r<n.length;r++)n[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new hr(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}};H.prototype.breakAfter=0;function tl(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}var hr=class{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function jl(i,e,t,n,r,s,o,O,a){let{children:h}=i,l=h.length?h[e]:null,c=s.length?s[s.length-1]:null,f=c?c.breakAfter:o;if(!(e==n&&l&&!o&&!f&&s.length<2&&l.merge(t,r,s.length?c:null,t==0,O,a))){if(n<h.length){let d=h[n];d&&(r<d.length||d.breakAfter&&c?.breakAfter)?(e==n&&(d=d.split(r),r=0),!f&&c&&d.merge(0,r,c,!0,0,a)?s[s.length-1]=d:((r||d.children.length&&!d.children[0].length)&&d.merge(0,r,null,!1,0,a),s.push(d))):d?.breakAfter&&(c?c.breakAfter=1:o=1),n++}for(l&&(l.breakAfter=o,t>0&&(!o&&s.length&&l.merge(t,l.length,s[0],!1,O,0)?l.breakAfter=s.shift().breakAfter:(t<l.length||l.children.length&&l.children[l.children.length-1].length==0)&&l.merge(t,l.length,null,!1,O,0),e++));e<n&&s.length;)if(h[n-1].become(s[s.length-1]))n--,s.pop(),a=s.length?0:O;else if(h[e].become(s[0]))e++,s.shift(),O=s.length?0:a;else break;!s.length&&e&&n<h.length&&!h[e-1].breakAfter&&h[n].merge(0,0,h[e-1],!1,O,a)&&e--,(e<n||s.length)&&i.replaceChildren(e,n,s)}}function El(i,e,t,n,r,s){let o=i.childCursor(),{i:O,off:a}=o.findPos(t,1),{i:h,off:l}=o.findPos(e,-1),c=e-t;for(let f of n)c+=f.length;i.length+=c,jl(i,h,l,O,a,n,0,r,s)}var Te=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Vs=typeof document<"u"?document:{documentElement:{style:{}}},qs=/Edge\/(\d+)/.exec(Te.userAgent),Ml=/MSIE \d/.test(Te.userAgent),Cs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Te.userAgent),br=!!(Ml||Cs||qs),il=!br&&/gecko\/(\d+)/i.test(Te.userAgent),Ts=!br&&/Chrome\/(\d+)/.exec(Te.userAgent),nl="webkitFontSmoothing"in Vs.documentElement.style,Gl=!br&&/Apple Computer/.test(Te.vendor),rl=Gl&&(/Mobile\/\w+/.test(Te.userAgent)||Te.maxTouchPoints>2),v={mac:rl||/Mac/.test(Te.platform),windows:/Win/.test(Te.platform),linux:/Linux|X11/.test(Te.platform),ie:br,ie_version:Ml?Vs.documentMode||6:Cs?+Cs[1]:qs?+qs[1]:0,gecko:il,gecko_version:il?+(/Firefox\/(\d+)/.exec(Te.userAgent)||[0,0])[1]:0,chrome:!!Ts,chrome_version:Ts?+Ts[1]:0,ios:rl,android:/Android\b/.test(Te.userAgent),webkit:nl,safari:Gl,webkit_version:nl?+(/\bAppleWebKit\/(\d+)/.exec(Te.userAgent)||[0,0])[1]:0,tabSize:Vs.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},lp=256,at=class i extends H{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof i)||this.length-(t-e)+n.length>lp||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new i(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new $e(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return hp(this.dom,e,t)}},zt=class i extends H{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let r of t)r.setParent(this)}setAttrs(e){if(Yl(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,r,s,o){return n&&(!(n instanceof i&&n.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(El(this,e,t,n?n.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],n=0,r=-1,s=0;for(let O of this.children){let a=n+O.length;a>e&&t.push(n<e?O.split(e-n):O),r<0&&n>=e&&(r=s),n=a,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new i(this.mark,t,o)}domAtPos(e){return Ll(this,e)}coordsAt(e,t){return Il(this,e,t)}};function hp(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;e==0&&t<0||e==n&&t>=0?v.chrome||v.gecko||(e?(r--,o=1):s<n&&(s++,o=-1)):t<0?r--:s<n&&s++;let O=Jt(i,r,s).getClientRects();if(!O.length)return null;let a=O[(o?o<0:t>=0)?0:O.length-1];return v.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(O,h=>h.width)||a),o?Pr(a,o<0):a||null}var cr=class i extends H{static create(e,t,n){return new i(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=i.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,r,s,o){return n&&(!(n instanceof i)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof i&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Y.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,r=this.posAtStart;return n?n.slice(r,r+this.length):Y.empty}domAtPos(e){return(this.length?e==0:this.side>0)?$e.before(this.dom):$e.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let O=o?r.length-1:0;s=r[O],!(e>0?O==0:O==r.length-1||s.top<s.bottom);O+=o?-1:1);return Pr(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},On=class i extends H{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof i&&e.side==this.side}split(){return new i(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?$e.before(this.dom):$e.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Y.empty}get isHidden(){return!0}};at.prototype.children=cr.prototype.children=On.prototype.children=go;function Ll(i,e){let t=i.dom,{children:n}=i,r=0;for(let s=0;r<n.length;r++){let o=n[r],O=s+o.length;if(!(O==s&&o.getSide()<=0)){if(e>s&&e<O&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=O}}for(let s=r;s>0;s--){let o=n[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s<n.length;s++){let o=n[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new $e(t,0)}function Dl(i,e,t){let n,{children:r}=i;t>0&&e instanceof zt&&r.length&&(n=r[r.length-1])instanceof zt&&n.mark.eq(e.mark)?Dl(n,e.children[0],t-1):(r.push(e),e.setParent(i)),i.length+=e.length}function Il(i,e,t){let n=null,r=-1,s=null,o=-1;function O(h,l){for(let c=0,f=0;c<h.children.length&&f<=l;c++){let d=h.children[c],p=f+d.length;p>=l&&(d.children.length?O(d,l-f):(!s||s.isHidden&&t>0)&&(p>l||f==p&&d.getSide()>0)?(s=d,o=l-f):(f<l||f==p&&d.getSide()<0&&!d.isHidden)&&(n=d,r=l-f)),f=p}}O(i,e);let a=(t<0?n:s)||n||s;return a?a.coordsAt(Math.max(0,a==n?r:o),t):cp(i)}function cp(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=on(e);return t[t.length-1]||null}function Ys(i,e){for(let t in i)t=="class"&&e.class?e.class+=" "+i.class:t=="style"&&e.style?e.style+=";"+i.style:e[t]=i[t];return e}var sl=Object.create(null);function fr(i,e,t){if(i==e)return!0;i||(i=sl),e||(e=sl);let n=Object.keys(i),r=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function Us(i,e,t){let n=!1;if(e)for(let r in e)t&&r in t||(n=!0,r=="style"?i.style.cssText="":i.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(n=!0,r=="style"?i.style.cssText=t[r]:i.setAttribute(r,t[r]));return n}function fp(i){let e=Object.create(null);for(let t=0;t<i.attributes.length;t++){let n=i.attributes[t];e[n.name]=n.value}return e}var Rt=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Qe=function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i}(Qe||(Qe={})),j=class extends Be{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new an(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Xt(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=Nl(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Xt(e,n,r,t,e.widget||null,!0)}static line(e){return new ln(e)}static set(e,t=!1){return F.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};j.none=F.empty;var an=class i extends j{constructor(e){let{start:t,end:n}=Nl(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof i&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&fr(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};an.prototype.point=!1;var ln=class i extends j{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&this.spec.class==e.spec.class&&fr(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};ln.prototype.mapMode=ae.TrackBefore;ln.prototype.point=!0;var Xt=class i extends j{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?ae.TrackBefore:ae.TrackAfter:ae.TrackDel}get type(){return this.startSide!=this.endSide?Qe.WidgetRange:this.startSide<=0?Qe.WidgetBefore:Qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof i&&up(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Xt.prototype.point=!0;function Nl(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function up(i,e){return i==e||!!(i&&e&&i.compare(e))}function As(i,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=i?t[r]=Math.max(t[r],e):t.push(i,e)}var he=class i extends H{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,r,s,o){if(n){if(!(n instanceof i))return!1;this.dom||n.transferDOM(this)}return r&&this.setDeco(n?n.attrs:null),El(this,e,t,n?n.children.slice():[],s,o),!0}split(e){let t=new i;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:r}=this.childPos(e);r&&(t.append(this.children[n].split(r),0),this.children[n].merge(r,this.children[n].length,null,!1,0,0),n++);for(let s=n;s<this.children.length;s++)t.append(this.children[s],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){fr(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Dl(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Ys(t,this.attrs||{})),n&&(this.attrs=Ys({class:n},this.attrs||{}))}domAtPos(e){return Ll(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Yl(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Us(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&H.get(r)instanceof zt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=H.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!v.ios||!this.children.some(s=>s instanceof at))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof at)||/[^ -~]/.test(n.text))return null;let r=on(n.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=Il(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:n.top+o,bottom:n.bottom-o,left:n.left,right:n.left}}}return n}become(e){return e instanceof i&&this.children.length==0&&e.children.length==0&&fr(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,r=0;n<e.children.length;n++){let s=e.children[n],o=r+s.length;if(o>=t){if(s instanceof i)return s;if(o>t)break}r=o+s.breakAfter}return null}},Ht=class i extends H{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,r,s,o){return n&&(!(n instanceof i)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?$e.before(this.dom):$e.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new i(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return go}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Y.empty}domBoundsAround(){return null}become(e){return e instanceof i&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof hn?null:Pr(this.dom.getBoundingClientRect(),this.length?e==0:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t==n?!1:e<0?t<0:n>0}},hn=class extends Rt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Ji=class i{constructor(e,t,n,r){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Ht&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new he),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Bn(new On(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Ht)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:O}=this.cursor.next(this.skip);if(this.skip=0,O)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Bn(new at(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}span(e,t,n,r){this.buildText(t-e,n,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,n,r,s,o){if(this.disallowBlockEffectsFor[o]&&n instanceof Xt){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let O=t-e;if(n instanceof Xt)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Ht(n.widget||Wt.block,O,n));else{let a=cr.create(n.widget||Wt.inline,O,O?0:n.startSide),h=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<t||n.startSide>0),l=!a.isEditable&&(e<t||s>r.length||n.startSide<=0),c=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),h&&(c.append(Bn(new On(1),r),s),s=r.length+Math.max(0,s-r.length)),c.append(Bn(a,r),s),this.atCursorPos=l,this.pendingBuffer=l?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);O&&(this.textOff+O<=this.text.length?this.textOff+=O:(this.skip+=O-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,n,r,s){let o=new i(e,t,n,s);return o.openEnd=F.spans(r,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function Bn(i,e){for(let t of e)i=new zt(t,[i],i.length);return i}var Wt=class extends Rt{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Wt.inline=new Wt("span");Wt.block=new Wt("div");var J=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(J||(J={})),ei=J.LTR,$o=J.RTL;function Bl(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}var dp=Bl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),pp=Bl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),_s=Object.create(null),rt=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);_s[e]=t,_s[t]=-e}function Fl(i){return i<=247?dp[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?pp[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}var mp=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,ot=class{get dir(){return this.level%2?$o:ei}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let s=-1;for(let o=0;o<e.length;o++){let O=e[o];if(O.from<=t&&O.to>=t){if(O.level==n)return o;(s<0||(r!=0?r<0?O.from<t:O.to>t:e[s].level>O.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Hl(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++){let n=i[t],r=e[t];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!Hl(n.inner,r.inner))return!1}return!0}var B=[];function gp(i,e,t,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:e,O=s<n.length?n[s].from:t,a=s?256:r;for(let h=o,l=a,c=a;h<O;h++){let f=Fl(i.charCodeAt(h));f==512?f=l:f==8&&c==4&&(f=16),B[h]=f==4?2:f,f&7&&(c=f),l=f}for(let h=o,l=a,c=a;h<O;h++){let f=B[h];if(f==128)h<O-1&&l==B[h+1]&&l&24?f=B[h]=l:B[h]=256;else if(f==64){let d=h+1;for(;d<O&&B[d]==64;)d++;let p=h&&l==8||d<t&&B[d]==8?c==1?1:8:256;for(let m=h;m<d;m++)B[m]=p;h=d-1}else f==8&&c==1&&(B[h]=1);l=f,f&7&&(c=f)}}}function $p(i,e,t,n,r){let s=r==1?2:1;for(let o=0,O=0,a=0;o<=n.length;o++){let h=o?n[o-1].to:e,l=o<n.length?n[o].from:t;for(let c=h,f,d,p;c<l;c++)if(d=_s[f=i.charCodeAt(c)])if(d<0){for(let m=O-3;m>=0;m-=3)if(rt[m+1]==-d){let g=rt[m+2],$=g&2?r:g&4?g&1?s:r:0;$&&(B[c]=B[rt[m]]=$),O=m;break}}else{if(rt.length==189)break;rt[O++]=c,rt[O++]=f,rt[O++]=a}else if((p=B[c])==2||p==1){let m=p==r;a=m?0:1;for(let g=O-3;g>=0;g-=3){let $=rt[g+2];if($&2)break;if(m)rt[g+2]|=2;else{if($&4)break;rt[g+2]|=4}}}}}function Qp(i,e,t,n){for(let r=0,s=n;r<=t.length;r++){let o=r?t[r-1].to:i,O=r<t.length?t[r].from:e;for(let a=o;a<O;){let h=B[a];if(h==256){let l=a+1;for(;;)if(l==O){if(r==t.length)break;l=t[r++].to,O=r<t.length?t[r].from:e}else if(B[l]==256)l++;else break;let c=s==1,f=(l<e?B[l]:n)==1,d=c==f?c?1:2:n;for(let p=l,m=r,g=m?t[m-1].to:i;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:i),B[--p]=d;a=l}else s=h,a++}}}function js(i,e,t,n,r,s,o){let O=n%2?2:1;if(n%2==r%2)for(let a=e,h=0;a<t;){let l=!0,c=!1;if(h==s.length||a<s[h].from){let m=B[a];m!=O&&(l=!1,c=m==16)}let f=!l&&O==1?[]:null,d=l?n:n+1,p=a;e:for(;;)if(h<s.length&&p==s[h].from){if(c)break e;let m=s[h];if(!l)for(let g=m.to,$=h+1;;){if(g==t)break e;if($<s.length&&s[$].from==g)g=s[$++].to;else{if(B[g]==O)break e;break}}if(h++,f)f.push(m);else{m.from>a&&o.push(new ot(a,m.from,d));let g=m.direction==ei!=!(d%2);Es(i,g?n+1:n,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(l?B[p]!=O:B[p]==O))break;p++}f?js(i,a,p,n+1,r,f,o):a<p&&o.push(new ot(a,p,d)),a=p}else for(let a=t,h=s.length;a>e;){let l=!0,c=!1;if(!h||a>s[h-1].to){let m=B[a-1];m!=O&&(l=!1,c=m==16)}let f=!l&&O==1?[]:null,d=l?n:n+1,p=a;e:for(;;)if(h&&p==s[h-1].to){if(c)break e;let m=s[--h];if(!l)for(let g=m.from,$=h;;){if(g==e)break e;if($&&s[$-1].to==g)g=s[--$].from;else{if(B[g-1]==O)break e;break}}if(f)f.push(m);else{m.to<a&&o.push(new ot(m.to,a,d));let g=m.direction==ei!=!(d%2);Es(i,g?n+1:n,r,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(l?B[p-1]!=O:B[p-1]==O))break;p--}f?js(i,p,a,n+1,r,f,o):p<a&&o.push(new ot(p,a,d)),a=p}}function Es(i,e,t,n,r,s,o){let O=e%2?2:1;gp(i,r,s,n,O),$p(i,r,s,n,O),Qp(r,s,n,O),js(i,r,s,e,t,n,o)}function yp(i,e,t){if(!i)return[new ot(0,0,e==$o?1:0)];if(e==ei&&!t.length&&!mp.test(i))return Kl(i.length);if(t.length)for(;i.length>B.length;)B[B.length]=256;let n=[],r=e==ei?0:1;return Es(i,r,r,t,0,i.length,n),n}function Kl(i){return[new ot(0,i,0)]}var Jl="";function Sp(i,e,t,n,r){var s;let o=n.head-i.from,O=ot.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),a=e[O],h=a.side(r,t);if(o==h){let f=O+=r?1:-1;if(f<0||f>=e.length)return null;a=e[O=f],o=a.side(!r,t),h=a.side(r,t)}let l=le(i.text,o,a.forward(r,t));(l<a.from||l>a.to)&&(l=h),Jl=i.text.slice(Math.min(o,l),Math.max(o,l));let c=O==(r?e.length-1:0)?null:e[O+(r?1:-1)];return c&&l==h&&c.level+(r?0:1)<a.level?y.cursor(c.side(!r,t)+i.from,c.forward(r,t)?1:-1,c.level):y.cursor(l+i.from,a.forward(r,t)?-1:1,a.level)}function Pp(i,e,t){for(let n=e;n<t;n++){let r=Fl(i.charCodeAt(n));if(r==1)return ei;if(r==2||r==4)return $o}return ei}var eh=z.define(),th=z.define(),ih=z.define(),nh=z.define(),Ms=z.define(),rh=z.define(),sh=z.define(),Qo=z.define(),yo=z.define(),oh=z.define({combine:i=>i.some(e=>e)}),Oh=z.define({combine:i=>i.some(e=>e)}),ah=z.define(),en=class i{constructor(e,t="nearest",n="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new i(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new i(y.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Fn=D.define({map:(i,e)=>i.map(e)}),lh=D.define();function Me(i,e,t){let n=i.facet(nh);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var wt=z.define({combine:i=>i.length?i[0]:!0}),bp=0,Ii=z.define(),Ge=class i{constructor(e,t,n,r,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.extension=s(this)}static define(e,t){let{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=t||{};return new i(bp++,e,n,r,O=>{let a=[Ii.of(O)];return o&&a.push(cn.of(h=>{let l=h.plugin(O);return l?o(l):j.none})),s&&a.push(s(O)),a})}static fromClass(e,t){return i.define(n=>new e(n),t)}},tn=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Me(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Me(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Me(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},hh=z.define(),So=z.define(),cn=z.define(),ch=z.define(),Po=z.define(),fh=z.define();function ol(i,e){let t=i.state.facet(fh);if(!t.length)return t;let n=t.map(s=>s instanceof Function?s(i):s),r=[];return F.spans(n,e.from,e.to,{point(){},span(s,o,O,a){let h=s-e.from,l=o-e.from,c=r;for(let f=O.length-1;f>=0;f--,a--){let d=O[f].spec.bidiIsolate,p;if(d==null&&(d=Pp(e.text,h,l)),a>0&&c.length&&(p=c[c.length-1]).to==h&&p.direction==d)p.to=l,c=p.inner;else{let m={from:h,to:l,direction:d,inner:[]};c.push(m),c=m.inner}}}}),r}var uh=z.define();function dh(i){let e=0,t=0,n=0,r=0;for(let s of i.state.facet(uh)){let o=s(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:n,bottom:r}}var Ni=z.define(),Ot=class i{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new i(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let r=0,s=0,o=0,O=0;;r++){let a=r==e.length?null:e[r],h=o-O,l=a?a.fromB:1e9;for(;s<t.length&&t[s]<l;){let c=t[s],f=t[s+1],d=Math.max(O,c),p=Math.min(l,f);if(d<=p&&new i(d+h,p+h,d,p).addToSet(n),f>l)break;s+=2}if(!a)return n;new i(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,O=a.toB}}},ur=class i{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=me.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,O,a)=>r.push(new Ot(s,o,O,a))),this.changedRanges=r}static create(e,t,n){return new i(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},dr=class extends H{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=j.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.setDOM(e.contentDOM),this.children=[new he],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ot(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:h,toA:l})=>l<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!Rp(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?kp(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:l}=this.hasComposition;n=new Ot(h,l,e.changes.mapPos(h,-1),e.changes.mapPos(l,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(v.ie||v.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,O=this.updateDeco(),a=vp(o,O,e.changes);return n=Ot.extendWithRanges(n,a),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=v.chrome||v.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Ht&&o.widget instanceof hn&&s.push(o.dom);r.updateGaps(s)}updateChildren(e,t,n){let r=n?n.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=r.length-1;;o--){let O=o>=0?r[o]:null;if(!O)break;let{fromA:a,toA:h,fromB:l,toB:c}=O,f,d,p,m;if(n&&n.range.fromB<c&&n.range.toB>l){let k=Ji.build(this.view.state.doc,l,n.range.fromB,this.decorations,this.dynamicDecorationMap),P=Ji.build(this.view.state.doc,n.range.toB,c,this.decorations,this.dynamicDecorationMap);d=k.breakAtStart,p=k.openStart,m=P.openEnd;let R=this.compositionView(n);P.breakAtStart?R.breakAfter=1:P.content.length&&R.merge(R.length,R.length,P.content[0],!1,P.openStart,0)&&(R.breakAfter=P.content[0].breakAfter,P.content.shift()),k.content.length&&R.merge(0,0,k.content[k.content.length-1],!0,0,k.openEnd)&&k.content.pop(),f=k.content.concat(R).concat(P.content)}else({content:f,breakAtStart:d,openStart:p,openEnd:m}=Ji.build(this.view.state.doc,l,c,this.decorations,this.dynamicDecorationMap));let{i:g,off:$}=s.findPos(h,1),{i:Q,off:b}=s.findPos(a,-1);jl(this,Q,b,g,$,f,d,p,m)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(lh)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new at(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new zt(r,[t],t.length);let n=new he;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let O=H.get(s);O&&O!=o&&(O.dom=null),o.setDOM(s)},n=this.childPos(e.range.fromB,1),r=this.children[n.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)n=r.childPos(n.off,1),r=r.children[n.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,r=n==this.dom,s=!r&&nr(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let O=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(O.anchor)),h=O.empty?a:this.moveToLine(this.domAtPos(O.head));if(v.gecko&&O.empty&&!this.hasComposition&&xp(a)){let c=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(c,a.node.childNodes[a.offset]||null)),a=h=new $e(c,0),o=!0}let l=this.view.observer.selectionRange;(o||!l.focusNode||(!Ki(a.node,a.offset,l.anchorNode,l.anchorOffset)||!Ki(h.node,h.offset,l.focusNode,l.focusOffset))&&!this.suppressWidgetCursorChange(l,O))&&(this.view.observer.ignore(()=>{v.android&&v.chrome&&this.dom.contains(l.focusNode)&&zp(l.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let c=sn(this.view.root);if(c)if(O.empty){if(v.gecko){let f=wp(a.node,a.offset);if(f&&f!=3){let d=(f==1?Al:_l)(a.node,a.offset);d&&(a=new $e(d.node,d.offset))}}c.collapse(a.node,a.offset),O.bidiLevel!=null&&c.caretBidiLevel!==void 0&&(c.caretBidiLevel=O.bidiLevel)}else if(c.extend){c.collapse(a.node,a.offset);try{c.extend(h.node,h.offset)}catch{}}else{let f=document.createRange();O.anchor>O.head&&([a,h]=[h,a]),f.setEnd(h.node,h.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new $e(l.anchorNode,l.anchorOffset),this.impreciseHead=h.precise?null:new $e(l.focusNode,l.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ki(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=sn(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=he.find(this,t.head);if(!o)return;let O=o.posAtStart;if(t.head==O||t.head==O+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let l=this.domAtPos(t.head+t.assoc);n.collapse(l.node,l.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&n.collapse(r,s)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let r=e.offset;!n&&r<t.childNodes.length;r++){let s=H.get(t.childNodes[r]);s instanceof he&&(n=s.domAtPos(0))}for(let r=e.offset-1;!n&&r>=0;r--){let s=H.get(t.childNodes[r]);s instanceof he&&(n=s.domAtPos(s.length))}return n?new $e(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=H.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let r=this.children[t];if(n<r.length||r instanceof he)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,r=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let O=this.children[o],a=s-O.breakAfter,h=a-O.length;if(a<e)break;if(h<=e&&(h<e||O.covers(-1))&&(a>e||O.covers(1))&&(!n||O instanceof he&&!(n instanceof he&&t>=0)))n=O,r=h;else if(n&&h==e&&a==e&&O instanceof Ht&&Math.abs(t)<2){if(O.deco.startSide<0)break;o&&(n=null)}s=h}return n?n.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),r=this.children[t];if(!(r instanceof he))return null;for(;r.children.length;){let{i:O,off:a}=r.childPos(n,1);for(;;O++){if(O==r.children.length)return null;if((r=r.children[O]).length)break}n=a}if(!(r instanceof at))return null;let s=le(r.text,n);if(s==n)return null;let o=Jt(r.dom,n,s).getClientRects();for(let O=0;O<o.length;O++){let a=o[O];if(O==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,O=-1,a=this.view.textDirection==J.LTR;for(let h=0,l=0;l<this.children.length;l++){let c=this.children[l],f=h+c.length;if(f>r)break;if(h>=n){let d=c.dom.getBoundingClientRect();if(t.push(d.height),o){let p=c.dom.lastChild,m=p?on(p):[];if(m.length){let g=m[m.length-1],$=a?g.right-d.left:d.right-g.left;$>O&&(O=$,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=f)}}}h=f+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?J.RTL:J.LTR}measureTextSize(){for(let s of this.children)if(s instanceof he){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,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.dom.appendChild(e);let s=on(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new hr(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>n){let O=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(j.replace({widget:new hn(O),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return j.set(e)}updateDeco(){let e=1,t=this.view.state.facet(cn).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(ch).map((s,o)=>{let O=typeof s=="function";return O&&(n=!0),O?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(F.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(ah))try{if(h(this.view,e.range,e))return!0}catch(l){Me(this.view.state,l,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=dh(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:O,offsetHeight:a}=this.view.scrollDOM;sp(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,O),-O),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==J.LTR)}};function xp(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function ph(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=Al(t.focusNode,t.focusOffset),r=_l(t.focusNode,t.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let O=H.get(r.node);if(!O||O instanceof at&&O.text!=r.node.nodeValue)s=r;else if(i.docView.lastCompositionAfterCursor){let a=H.get(n.node);!a||a instanceof at&&a.text!=n.node.nodeValue||(s=r)}}if(i.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function kp(i,e,t){let n=ph(i,t);if(!n)return null;let{node:r,from:s,to:o}=n,O=r.nodeValue;if(/[\n\r]/.test(O)||i.state.doc.sliceString(n.from,n.to)!=O)return null;let a=e.invertedDesc,h=new Ot(a.mapPos(s),a.mapPos(o),s,o),l=[];for(let c=r.parentNode;;c=c.parentNode){let f=H.get(c);if(f instanceof zt)l.push({node:c,deco:f.mark});else{if(f instanceof he||c.nodeName=="DIV"&&c.parentNode==i.contentDOM)return{range:h,text:r,marks:l,line:c};if(c!=i.contentDOM)l.push({node:c,deco:new an({inclusive:!0,attributes:fp(c),tagName:c.tagName.toLowerCase()})});else return null}}}function wp(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}var Tp=class{constructor(){this.changes=[]}compareRange(e,t){As(e,t,this.changes)}comparePoint(e,t){As(e,t,this.changes)}};function vp(i,e,t){let n=new Tp;return F.compare(i,e,t,n),n.changes}function zp(i,e){for(let t=i;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Rp(i,e){let t=!1;return e&&i.iterChangedRanges((n,r)=>{n<e.to&&r>e.from&&(t=!0)}),t}function Xp(i,e,t=1){let n=i.charCategorizer(e),r=i.doc.lineAt(e),s=e-r.from;if(r.length==0)return y.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,O=s;t<0?o=le(r.text,s,!1):O=le(r.text,s);let a=n(r.text.slice(o,O));for(;o>0;){let h=le(r.text,o,!1);if(n(r.text.slice(h,o))!=a)break;o=h}for(;O<r.length;){let h=le(r.text,O);if(n(r.text.slice(O,h))!=a)break;O=h}return y.range(o+r.from,O+r.from)}function Wp(i,e){return e.left>i?e.left-i:Math.max(0,i-e.right)}function Zp(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function vs(i,e){return i.top<e.bottom-1&&i.bottom>e.top+1}function Ol(i,e){return e<i.top?{top:e,left:i.left,right:i.right,bottom:i.bottom}:i}function al(i,e){return e>i.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function Gs(i,e,t){let n,r,s,o,O=!1,a,h,l,c;for(let p=i.firstChild;p;p=p.nextSibling){let m=on(p);for(let g=0;g<m.length;g++){let $=m[g];r&&vs(r,$)&&($=Ol(al($,r.bottom),r.top));let Q=Wp(e,$),b=Zp(t,$);if(Q==0&&b==0)return p.nodeType==3?ll(p,e,t):Gs(p,e,t);if(!n||o>b||o==b&&s>Q){n=p,r=$,s=Q,o=b;let k=b?t<$.top?-1:1:Q?e<$.left?-1:1:0;O=!k||(k>0?g<m.length-1:g>0)}Q==0?t>$.bottom&&(!l||l.bottom<$.bottom)?(a=p,l=$):t<$.top&&(!c||c.top>$.top)&&(h=p,c=$):l&&vs(l,$)?l=al(l,$.bottom):c&&vs(c,$)&&(c=Ol(c,$.top))}}if(l&&l.bottom>=t?(n=a,r=l):c&&c.top<=t&&(n=h,r=c),!n)return{node:i,offset:0};let f=Math.max(r.left,Math.min(r.right,e));if(n.nodeType==3)return ll(n,f,t);if(O&&n.contentEditable!="false")return Gs(n,f,t);let d=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(r.left+r.right)/2?1:0);return{node:i,offset:d}}function ll(i,e,t){let n=i.nodeValue.length,r=-1,s=1e9,o=0;for(let O=0;O<n;O++){let a=Jt(i,O,O+1).getClientRects();for(let h=0;h<a.length;h++){let l=a[h];if(l.top==l.bottom)continue;o||(o=e-l.left);let c=(l.top>t?l.top-t:t-l.bottom)-1;if(l.left-1<=e&&l.right+1>=e&&c<s){let f=e>=(l.left+l.right)/2,d=f;if((v.chrome||v.gecko)&&Jt(i,O).getBoundingClientRect().left==l.right&&(d=!f),c<=0)return{node:i,offset:O+(d?1:0)};r=O+(d?1:0),s=c}}}return{node:i,offset:r>-1?r:o>0?i.nodeValue.length:0}}function mh(i,e,t,n=-1){var r,s;let o=i.contentDOM.getBoundingClientRect(),O=o.top+i.viewState.paddingTop,a,{docHeight:h}=i.viewState,{x:l,y:c}=e,f=c-O;if(f<0)return 0;if(f>h)return i.state.doc.length;for(let k=i.viewState.heightOracle.textHeight/2,P=!1;a=i.elementAtHeight(f),a.type!=Qe.Text;)for(;f=n>0?a.bottom+k:a.top-k,!(f>=0&&f<=h);){if(P)return t?null:0;P=!0,n=-n}c=O+f;let d=a.from;if(d<i.viewport.from)return i.viewport.from==0?0:t?null:hl(i,o,a,l,c);if(d>i.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:hl(i,o,a,l,c);let p=i.dom.ownerDocument,m=i.root.elementFromPoint?i.root:p,g=m.elementFromPoint(l,c);g&&!i.contentDOM.contains(g)&&(g=null),g||(l=Math.max(o.left+1,Math.min(o.right-1,l)),g=m.elementFromPoint(l,c),g&&!i.contentDOM.contains(g)&&(g=null));let $,Q=-1;if(g&&((r=i.docView.nearest(g))===null||r===void 0?void 0:r.isEditable)!=!1){if(p.caretPositionFromPoint){let k=p.caretPositionFromPoint(l,c);k&&({offsetNode:$,offset:Q}=k)}else if(p.caretRangeFromPoint){let k=p.caretRangeFromPoint(l,c);k&&({startContainer:$,startOffset:Q}=k,(!i.contentDOM.contains($)||v.safari&&Vp($,Q,l)||v.chrome&&qp($,Q,l))&&($=void 0))}}if(!$||!i.docView.dom.contains($)){let k=he.find(i.docView,d);if(!k)return f>a.top+a.height/2?a.to:a.from;({node:$,offset:Q}=Gs(k.dom,l,c))}let b=i.docView.nearest($);if(!b)return null;if(b.isWidget&&((s=b.dom)===null||s===void 0?void 0:s.nodeType)==1){let k=b.dom.getBoundingClientRect();return e.y<k.top||e.y<=k.bottom&&e.x<=(k.left+k.right)/2?b.posAtStart:b.posAtEnd}else return b.localPosFromDOM($,Q)+b.posAtStart}function hl(i,e,t,n,r){let s=Math.round((n-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&t.height>i.defaultLineHeight*1.5){let O=i.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(i.defaultLineHeight-O)*.5)/O);s+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+In(o,s,i.state.tabSize)}function Vp(i,e,t){let n;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(let r=i.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Jt(i,n-1,n).getBoundingClientRect().left>t}function qp(i,e,t){if(e!=0)return!1;for(let r=i;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let n=i.nodeType==1?i.getBoundingClientRect():Jt(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Ls(i,e){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==Qe.Text))return n}return t}function Cp(i,e,t,n){let r=Ls(i,e.head),s=!n||r.type!=Qe.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),O=i.textDirectionAt(r.from),a=i.posAtCoords({x:t==(O==J.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return y.cursor(a,t?-1:1)}return y.cursor(t?r.to:r.from,t?-1:1)}function cl(i,e,t,n){let r=i.state.doc.lineAt(e.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let O=e,a=null;;){let h=Sp(r,s,o,O,t),l=Jl;if(!h){if(r.number==(t?i.state.doc.lines:1))return O;l=`
-`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),h=i.visualLineSide(r,!t)}if(a){if(!a(l))return O}else{if(!n)return h;a=n(l)}O=h}}function Yp(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==_e.Space&&(r=o),r==o}}function Up(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return y.cursor(r,e.assoc);let o=e.goalColumn,O,a=i.contentDOM.getBoundingClientRect(),h=i.coordsAtPos(r,e.assoc||-1),l=i.documentTop;if(h)o==null&&(o=h.left-a.left),O=s<0?h.top:h.bottom;else{let d=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(r-d.from))),O=(s<0?d.top:d.bottom)+l}let c=a.left+o,f=n??i.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=O+(f+d)*s,m=mh(i,{x:c,y:p},!1,s);if(p<a.top||p>a.bottom||(s<0?m<r:m>r)){let g=i.docView.coordsForChar(m),$=!g||p<g.top?-1:1;return y.cursor(m,$,void 0,o)}}}function rr(i,e,t){for(;;){let n=0;for(let r of i)r.between(e-1,e+1,(s,o,O)=>{if(e>s&&e<o){let a=n||t||(e-s<o-e?-1:1);e=a<0?s:o,n=a}});if(!n)return e}}function zs(i,e,t){let n=rr(i.state.facet(Po).map(r=>r(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:y.cursor(n,n<t.from?1:-1)}var Bi="\uFFFF",Ds=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(I.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Bi}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let O=H.get(r),a=H.get(o);(O&&a?O.breakAfter:(O?O.breakAfter:lr(r))||lr(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,O;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(O=r.exec(t))&&(s=O.index,o=O[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=s+o}}readNode(e){if(e.cmIgnore)return;let t=H.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Ap(e,n.node,n.offset)?t:0))}};function Ap(i,e,t){for(;;){if(!e||t<gt(e))return!1;if(e==i)return!0;t=Kt(e)+1,e=e.parentNode}}var pr=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Is=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let O=s||o?[]:Ep(e),a=new Ds(O,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Mp(O,this.bounds.from)}else{let O=e.observer.selectionRange,a=s&&s.node==O.focusNode&&s.offset==O.focusOffset||!Ws(e.contentDOM,O.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(O.focusNode,O.focusOffset),h=o&&o.node==O.anchorNode&&o.offset==O.anchorOffset||!Ws(e.contentDOM,O.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(O.anchorNode,O.anchorOffset),l=e.viewport;if((v.ios||v.chrome)&&e.state.selection.main.empty&&a!=h&&(l.from>0||l.to<e.state.doc.length)){let c=Math.min(a,h),f=Math.max(a,h),d=l.from-c,p=l.to-f;(d==0||d==1||c==0)&&(p==0||p==-1||f==e.state.doc.length)&&(a=0,h=e.state.doc.length)}this.newSel=y.single(h,a)}}};function gh(i,e){let t,{newSel:n}=e,r=i.state.selection.main,s=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:O}=e.bounds,a=r.from,h=null;(s===8||v.android&&e.text.length<O-o)&&(a=r.to,h="end");let l=jp(i.state.doc.sliceString(o,O,Bi),e.text,a-o,h);l&&(v.chrome&&s==13&&l.toB==l.from+2&&e.text.slice(l.from,l.toB)==Bi+Bi&&l.toB--,t={from:o+l.from,to:o+l.toA,insert:Y.of(e.text.slice(l.from,l.toB).split(Bi))})}else n&&(!i.hasFocus&&i.state.facet(wt)||n.main.eq(r))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!r.empty&&n&&n.main.empty?t={from:r.from,to:r.to,insert:i.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:i.state.doc.slice(r.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,r.to))}:(v.mac||v.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=y.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:Y.of([" "])}):v.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
- `&&i.lineWrapping&&(n&&(n=y.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:Y.of([" "])}),t)return bo(i,t,n,s);if(n&&!n.main.eq(r)){let o=!1,O="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),O=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:O}),!0}else return!1}function bo(i,e,t,n=-1){if(v.ios&&i.inputState.flushIOSKey(e))return!0;let r=i.state.selection.main;if(v.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&i.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&bi(i.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&bi(i.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&bi(i.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,O=()=>o||(o=_p(i,e,t));return i.state.facet(rh).some(a=>a(i,e.from,e.to,s,O))||i.dispatch(O()),!0}function _p(i,e,t){let n,r=i.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let O=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(i.state.toText(O+e.insert.sliceString(0,void 0,i.state.lineBreak)+a))}else{let O=r.changes(e),a=t&&t.main.to<=O.newLength?t.main:void 0;if(r.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=i.state.sliceDoc(e.from,e.to),l,c=t&&ph(i,t.main.head);if(c){let p=e.insert.length-(e.to-e.from);l={from:c.from,to:c.to-p}}else l=i.state.doc.lineAt(s.head);let f=s.to-e.to,d=s.to-s.from;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:O,range:a||p.map(O)};let m=p.to-f,g=m-h.length;if(p.to-p.from!=d||i.state.sliceDoc(g,m)!=h||p.to>=l.from&&p.from<=l.to)return{range:p};let $=r.changes({from:g,to:m,insert:e.insert}),Q=p.to-s.to;return{changes:$,range:a?y.range(Math.max(0,a.anchor+Q),Math.max(0,a.head+Q)):p.map($)}})}else n={changes:O,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,o+=".compose",i.inputState.compositionFirstChange&&(o+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:o,scrollIntoView:!0})}function jp(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s<r&&i.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&i.length==e.length)return null;let o=i.length,O=e.length;for(;o>0&&O>0&&i.charCodeAt(o-1)==e.charCodeAt(O-1);)o--,O--;if(n=="end"){let a=Math.max(0,s-Math.min(o,O));t-=o+a-s}if(o<s&&i.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,O=s+(O-o),o=s}else if(O<s){let a=t<=s&&t>=O?s-t:0;s-=a,o=s+(o-O),O=s}return{from:s,toA:o,toB:O}}function Ep(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new pr(t,n)),(r!=t||s!=n)&&e.push(new pr(r,s))),e}function Mp(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?y.single(t+e,n+e):null}var Ns=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,v.safari&&e.contentDOM.addEventListener("input",()=>null),v.gecko&&rm(e.contentDOM.ownerDocument)}handleEvent(e){!Fp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Gp(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,O=n[s];O&&o!=!O.handlers.length&&(r.removeEventListener(s,this.handleEvent),O=null),O||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Qh.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),v.android&&v.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return v.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=$h.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||Lp.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,bi(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:v.safari&&!v.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function fl(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){Me(t.state,r)}}}function Gp(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(fl(n.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(fl(n.value,o))}}for(let n in Fe)t(n).handlers.push(Fe[n]);for(let n in Le)t(n).observers.push(Le[n]);return e}var $h=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Lp="dthko",Qh=[16,17,18,20,91,92,224,225],Hn=6;function Kn(i){return Math.max(0,i)*.7+8}function Dp(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}var Bs=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=op(e.contentDOM),this.atoms=e.state.facet(Po).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(I.allowMultipleSelections)&&Ip(e,t),this.dragging=Bp(e,t)&&Ph(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Dp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,s=0,o=this.view.win.innerWidth,O=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:O}=this.scrollParents.y.getBoundingClientRect());let a=dh(this.view);e.clientX-a.left<=r+Hn?t=-Kn(r-e.clientX):e.clientX+a.right>=o-Hn&&(t=Kn(e.clientX-o)),e.clientY-a.top<=s+Hn?n=-Kn(s-e.clientY):e.clientY+a.bottom>=O-Hn&&(n=Kn(e.clientY-O)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let r=e.ranges[n],s=null;if(r.empty){let o=rr(this.atoms,r.from,0);o!=r.from&&(s=y.cursor(o,-1))}else{let o=rr(this.atoms,r.from,-1),O=rr(this.atoms,r.to,1);(o!=r.from||O!=r.to)&&(s=y.range(r.from==r.anchor?o:O,r.from==r.head?o:O))}s&&(t||(t=e.ranges.slice()),t[n]=s)}return t?y.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Ip(i,e){let t=i.state.facet(eh);return t.length?t[0](e):v.mac?e.metaKey:e.ctrlKey}function Np(i,e){let t=i.state.facet(th);return t.length?t[0](e):v.mac?!e.altKey:!e.ctrlKey}function Bp(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=sn(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Fp(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=H.get(t))&&n.ignoreEvent(e))return!1;return!0}var Fe=Object.create(null),Le=Object.create(null),yh=v.ie&&v.ie_version<15||v.ios&&v.webkit_version<604;function Hp(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),Sh(i,t.value)},50)}function xr(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function Sh(i,e){e=xr(i.state,Qo,e);let{state:t}=i,n,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Fs!=null&&t.selection.ranges.every(a=>a.empty)&&Fs==s.toString()){let a=-1;n=t.changeByRange(h=>{let l=t.doc.lineAt(h.from);if(l.from==a)return{range:h};a=l.from;let c=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:l.from,insert:c},range:y.cursor(h.from+c.length)}})}else o?n=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:y.cursor(a.from+h.length)}}):n=t.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Le.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Fe.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);Le.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};Le.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Fe.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(ih))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=em(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new Bs(i,e,t,n)),n&&i.observer.ignore(()=>{Cl(i.contentDOM);let s=i.root.activeElement;s&&!s.contains(i.contentDOM)&&s.blur()});let r=i.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function ul(i,e,t,n){if(n==1)return y.cursor(e,t);if(n==2)return Xp(i.state,e,t);{let r=he.find(i.docView,e),s=i.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,O=r?r.posAtEnd:s.to;return O<i.state.doc.length&&O==s.to&&O++,y.range(o,O)}}var dl=(i,e,t)=>e>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function Kp(i,e,t,n){let r=he.find(i.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&dl(t,n,o))return-1;let O=r.coordsAt(s,1);return O&&dl(t,n,O)?1:o&&o.bottom>=n?-1:1}function pl(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Kp(i,t,e.clientX,e.clientY)}}var Jp=v.ie&&v.ie_version<=11,ml=null,gl=0,$l=0;function Ph(i){if(!Jp)return i.detail;let e=ml,t=$l;return ml=i,$l=Date.now(),gl=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(gl+1)%3:1}function em(i,e){let t=pl(i,e),n=Ph(e),r=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,O){let a=pl(i,s),h,l=ul(i,a.pos,a.bias,n);if(t.pos!=a.pos&&!o){let c=ul(i,t.pos,t.bias,n),f=Math.min(c.from,l.from),d=Math.max(c.to,l.to);l=f<l.from?y.range(f,d):y.range(d,f)}return o?r.replaceRange(r.main.extend(l.from,l.to)):O&&n==1&&r.ranges.length>1&&(h=tm(r,a.pos))?h:O?r.addRange(l):y.create([l])}}}function tm(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:r}=i.ranges[t];if(n<=e&&r>=e)return y.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}Fe.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let r=i.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=y.range(s,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",xr(i.state,yo,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Fe.dragend=i=>(i.inputState.draggedContent=null,!1);function Ql(i,e,t,n){if(t=xr(i.state,Qo,t),!t)return;let r=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=i.inputState,o=n&&s&&Np(i,e)?{from:s.from,to:s.to}:null,O={from:r,insert:t},a=i.state.changes(o?[o,O]:O);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}Fe.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),r=0,s=()=>{++r==t.length&&Ql(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let O=new FileReader;O.onerror=s,O.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(O.result)||(n[o]=O.result),s()},O.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return Ql(i,e,n,!0),!0}return!1};Fe.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=yh?null:e.clipboardData;return t?(Sh(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Hp(i),!1)};function im(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function nm(i){let e=[],t=[],n=!1;for(let r of i.selection.ranges)r.empty||(e.push(i.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:xr(i,yo,e.join(i.lineBreak)),ranges:t,linewise:n}}var Fs=null;Fe.copy=Fe.cut=(i,e)=>{let{text:t,ranges:n,linewise:r}=nm(i.state);if(!t&&!r)return!1;Fs=r?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=yh?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(im(i,t),!1)};var bh=ke.define();function xh(i,e){let t=[];for(let n of i.facet(sh)){let r=n(i,e);r&&t.push(r)}return t?i.update({effects:t,annotations:bh.of(!0)}):null}function kh(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=xh(i.state,e);t?i.dispatch(t):i.update([])}},10)}Le.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),kh(i)};Le.blur=i=>{i.observer.clearSelectionRange(),kh(i)};Le.compositionstart=Le.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};Le.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,v.chrome&&v.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};Le.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};Fe.beforeinput=(i,e)=>{var t,n;if(e.inputType=="insertReplacementText"&&i.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let O=o[0],a=i.posAtDOM(O.startContainer,O.startOffset),h=i.posAtDOM(O.endContainer,O.endOffset);return bo(i,{from:a,to:h,insert:i.state.toText(s)},null),!0}}let r;if(v.chrome&&v.android&&(r=$h.find(s=>s.inputType==e.inputType))&&(i.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return v.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),v.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>Le.compositionend(i,e),20),!1};var yl=new Set;function rm(i){yl.has(i)||(yl.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}var Sl=["pre-wrap","normal","pre-line","break-spaces"],xi=!1;function Pl(){xi=!1}var Hs=class{constructor(e){this.lineWrapping=e,this.doc=Y.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Sl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,s,o){let O=Sl.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=O;if(this.lineWrapping=O,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let l=o[h];l<0?h++:this.heightSamples[Math.floor(l*10)]=!0}}return a}},Ks=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},st=class i{constructor(e,t,n,r,s){this.from=e,this.length=t,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Xt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new i(this.from,this.length+e.length,this.top,this.height+e.height,t)}},K=function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i}(K||(K={})),sr=.001,Ze=class i{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>sr&&(xi=!0),this.height=e)}replace(e,t,n){return i.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,o=n.doc;for(let O=r.length-1;O>=0;O--){let{fromA:a,toA:h,fromB:l,toB:c}=r[O],f=s.lineAt(a,K.ByPosNoHeight,n.setDoc(t),0,0),d=f.to>=h?f:s.lineAt(h,K.ByPosNoHeight,n,0,0);for(c+=d.to-h,h=d.to;O>0&&f.from<=r[O-1].toA;)a=r[O-1].fromA,l=r[O-1].fromB,O--,a<f.from&&(f=s.lineAt(a,K.ByPosNoHeight,n,0,0));l+=f.from-a,a=f.from;let p=eo.build(n.setDoc(o),e,l,c);s=mr(s,s.replace(a,h,p))}return s.updateHeight(n,0)}static empty(){return new Ee(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,r=0,s=0;for(;;)if(t==n)if(r>s*2){let O=e[t-1];O.break?e.splice(--t,1,O.left,null,O.right):e.splice(--t,1,O.left,O.right),n+=1+O.break,r-=O.size}else if(s>r*2){let O=e[n];O.break?e.splice(n,1,O.left,null,O.right):e.splice(n,1,O.left,O.right),n+=2+O.break,s-=O.size}else break;else if(r<s){let O=e[t++];O&&(r+=O.size)}else{let O=e[--n];O&&(s+=O.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new Js(i.of(e.slice(0,t)),o,i.of(e.slice(n)))}};function mr(i,e){return i==e?i:(i.constructor!=e.constructor&&(xi=!0),e)}Ze.prototype.size=1;var gr=class extends Ze{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,r){return new st(r,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,r,s){return this.blockAt(0,n,r,s)}forEachLine(e,t,n,r,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,n,r,s))}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},Ee=class i extends gr{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,r){return new st(r,this.length,n,this.height,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof i||r instanceof vt&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof vt?r=new i(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ze.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setHeight(r.heights[r.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},vt=class i extends Ze{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,o,O=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(O=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:O}}blockAt(e,t,n,r){let{firstLine:s,lastLine:o,perLine:O,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),l=t.doc.lineAt(h),c=O+l.length*a,f=Math.max(n,e-c/2);return new st(l.from,l.length,f,c,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-n)/O))),{from:l,length:c}=t.doc.line(s+h);return new st(l,c,n+O*h,O,0)}}lineAt(e,t,n,r,s){if(t==K.ByHeight)return this.blockAt(e,n,r,s);if(t==K.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new st(d,p-d,0,0,0)}let{firstLine:o,perLine:O,perChar:a}=this.heightMetrics(n,s),h=n.doc.lineAt(e),l=O+h.length*a,c=h.number-o,f=r+O*c+a*(h.from-s-c);return new st(h.from,h.length,Math.max(r,Math.min(f,r+this.height-l)),l,0)}forEachLine(e,t,n,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:O,perLine:a,perChar:h}=this.heightMetrics(n,s);for(let l=e,c=r;l<=t;){let f=n.doc.lineAt(l);if(l==e){let p=f.number-O;c+=a*p+h*(e-s-p)}let d=a+h*f.length;o(new st(f.from,f.length,c,d,0)),c+=d,l=f.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let s=n[n.length-1];s instanceof i?n[n.length-1]=new i(s.length+r):n.push(null,new i(r-1))}if(e>0){let s=n[0];s instanceof i?n[0]=new i(e+s.length):n.unshift(new i(e-1),null)}return Ze.of(n)}decomposeLeft(e,t){t.push(new i(e-1),null)}decomposeRight(e,t){t.push(null,new i(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],O=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new i(r.from-t-1).updateHeight(e,t));O<=s&&r.more;){let l=e.doc.lineAt(O).length;o.length&&o.push(null);let c=r.heights[r.index++];a==-1?a=c:Math.abs(c-a)>=sr&&(a=-2);let f=new Ee(l,c);f.outdated=!1,o.push(f),O+=l+1}O<=s&&o.push(null,new i(s-O).updateHeight(e,O));let h=Ze.of(o);return(a<0||Math.abs(h.height-this.height)>=sr||Math.abs(a-this.heightMetrics(e,t).perLine)>=sr)&&(xi=!0),mr(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Js=class extends Ze{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,n,r,s){let o=r+this.left.height,O=s+this.left.length+this.break,a=t==K.ByHeight?e<o:e<O,h=a?this.left.lineAt(e,t,n,r,s):this.right.lineAt(e,t,n,o,O);if(this.break||(a?h.to<O:h.from>O))return h;let l=t==K.ByPosNoHeight?K.ByPosNoHeight:K.ByPos;return a?h.join(this.right.lineAt(O,l,n,o,O)):this.left.lineAt(O,l,n,r,s).join(h)}forEachLine(e,t,n,r,s,o){let O=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,s,o),t>=a&&this.right.forEachLine(e,t,n,O,a,o);else{let h=this.lineAt(a,K.ByPos,n,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,n,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,n,O,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let O of n)s.push(O);if(e>0&&bl(s,o-1),t<this.length){let O=s.length;this.decomposeRight(t,s),bl(s,O)}return Ze.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ze.of(this.break?[e,null,t]:[e,t]):(this.left=mr(this.left,e),this.right=mr(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:s,right:o}=this,O=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=O+o.length&&r.more?a=o=o.updateHeight(e,O,n,r):o.updateHeight(e,O,n),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function bl(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof vt&&(n=i[e+1])instanceof vt&&i.splice(e-1,3,new vt(t.length+1+n.length))}var sm=5,eo=class i{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Ee?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Ee(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new gr(o,r,n)):(o||s||r>=sm)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ee(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new vt(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ee)return e;let t=new Ee(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ee)&&!this.isCovered?this.nodes.push(new Ee(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let r of this.nodes)r instanceof Ee&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(e,t,n,r){let s=new i(n,e);return F.spans(t,n,r,s,0),s.finish(n)}};function om(i,e,t){let n=new to;return F.compare(i,e,t,n,0),n.changes}var to=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&As(e,t,this.changes,5)}};function Om(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,r=n.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),O=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=i.parentNode;h&&h!=n.body;)if(h.nodeType==1){let l=h,c=window.getComputedStyle(l);if((l.scrollHeight>l.clientHeight||l.scrollWidth>l.clientWidth)&&c.overflow!="visible"){let f=l.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),O=Math.max(O,f.top),a=Math.min(h==i.parentNode?r.innerHeight:a,f.bottom)}h=c.position=="absolute"||c.position=="fixed"?l.offsetParent:l.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:O-(t.top+e),bottom:Math.max(O,a)-(t.top+e)}}function am(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var nn=class{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],s=t[n];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return j.replace({widget:new io(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},io=class extends Rt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},$r=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=xl,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=J.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(So).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Hs(t),this.stateDeco=e.facet(cn).filter(n=>typeof n!="function"),this.heightMap=Ze.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle.setDoc(e.doc),[new Ot(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=j.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Si(s,o))}}return this.viewports=e.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?xl:new no(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Fi(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(cn).filter(l=>typeof l!="function");let r=e.changedRanges,s=Ot.extendWithRanges(r,om(n,this.stateDeco,e?e.changes:me.empty(this.state.doc.length))),o=this.heightMap.height,O=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Pl(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||xi)&&(e.flags|=2),O?(this.scrollAnchorPos=e.changes.mapPos(O.from,-1),this.scrollAnchorHeight=O.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Oh)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?J.RTL:J.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),O=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=O.height;this.contentDOMHeight=O.height,this.mustMeasureContent=!1;let h=0,l=0;if(O.width&&O.height){let{scaleX:k,scaleY:P}=ql(t,O);(k>.005&&Math.abs(this.scaleX-k)>.005||P>.005&&Math.abs(this.scaleY-P)>.005)&&(this.scaleX=k,this.scaleY=P,h|=8,o=a=!0)}let c=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=f)&&(this.paddingTop=c,this.paddingBottom=f,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Ul(e.scrollDOM);let p=(this.printing?am:Om)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let $=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if($!=this.inView&&(this.inView=$,$&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let Q=O.width;if((this.contentDOMWidth!=Q||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=O.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let k=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(k)&&(o=!0),o||r.lineWrapping&&Math.abs(Q-this.contentDOMWidth)>r.charWidth){let{lineHeight:P,charWidth:R,textHeight:T}=e.docView.measureTextSize();o=P>0&&r.refresh(s,P,R,T,Q/R,k),o&&(e.docView.minWidth=0,h|=8)}m>0&&g>0?l=Math.max(m,g):m<0&&g<0&&(l=Math.min(m,g)),Pl();for(let P of this.viewports){let R=P.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(P);this.heightMap=(o?Ze.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle,[new Ot(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Ks(P.from,R))}xi&&(h|=2)}let b=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),h|=this.updateForViewport()),(h&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:O}=this,a=new Si(r.lineAt(o-n*1e3,K.ByHeight,s,0,0).from,r.lineAt(O+(1-n)*1e3,K.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let l=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=r.lineAt(h,K.ByPos,s,0,0),f;t.y=="center"?f=(c.top+c.bottom)/2-l/2:t.y=="start"||t.y=="nearest"&&h<a.from?f=c.top:f=c.bottom-l,a=new Si(r.lineAt(f-1e3/2,K.ByHeight,s,0,0).from,r.lineAt(f+l+1e3/2,K.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Si(this.heightMap.lineAt(n,K.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,K.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,K.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,K.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:O}=this;return(e==0||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=O+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s<O+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new nn(t.mapPos(r.from),t.mapPos(r.to),r.size));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=J.LTR&&!n)return[];let O=[],a=(l,c,f,d)=>{if(c-l<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let $ of m)if($>l&&$<c){a(l,$-10,f,d),a($+10,c,f,d);return}let g=hm(e,$=>$.from>=f.from&&$.to<=f.to&&Math.abs($.from-l)<s&&Math.abs($.to-c)<s&&!m.some(Q=>$.from<Q&&$.to>Q));if(!g){if(c<f.to&&t&&n&&t.visibleRanges.some($=>$.from<=c&&$.to>=c)){let $=t.moveToLineBoundary(y.cursor(c),!1,!0).head;$>l&&(c=$)}g=new nn(l,c,this.gapSize(f,l,c,d))}O.push(g)},h=l=>{if(l.length<o||l.type!=Qe.Text)return;let c=lm(l.from,l.to,this.stateDeco);if(c.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(n){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,$;if(f!=null){let Q=er(c,f),b=((this.visibleBottom-this.visibleTop)/2+m)/l.height;g=Q-b,$=Q+b}else g=(this.visibleTop-l.top-m)/l.height,$=(this.visibleBottom-l.top+m)/l.height;d=Jn(c,g),p=Jn(c,$)}else{let m=c.total*this.heightOracle.charWidth,g=r*this.heightOracle.charWidth,$,Q;if(f!=null){let b=er(c,f),k=((this.pixelViewport.right-this.pixelViewport.left)/2+g)/m;$=b-k,Q=b+k}else $=(this.pixelViewport.left-g)/m,Q=(this.pixelViewport.right+g)/m;d=Jn(c,$),p=Jn(c,Q)}d>l.from&&a(l.from,d,l,c),p<l.to&&a(p,l.to,l,c)};for(let l of this.viewportLines)Array.isArray(l.type)?l.type.forEach(h):h(l);return O}gapSize(e,t,n,r){let s=er(r,n)-er(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){nn.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=j.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];F.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Fi(this.heightMap.lineAt(e,K.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Fi(this.heightMap.lineAt(this.scaler.fromDOM(e),K.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Fi(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Si=class{constructor(e,t){this.from=e,this.to=t}};function lm(i,e,t){let n=[],r=i,s=0;return F.spans(t,i,e,{span(){},point(o,O){o>r&&(n.push({from:r,to:o}),s+=o-r),r=O}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function Jn({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let r=0;;r++){let{from:s,to:o}=e[r],O=o-s;if(n<=O)return s+n;n-=O}}function er(i,e){let t=0;for(let{from:n,to:r}of i.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/i.total}function hm(i,e){for(let t of i)if(e(t))return t}var xl={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}},no=class i{constructor(e,t,n){let r=0,s=0,o=0;this.viewports=n.map(({from:O,to:a})=>{let h=t.lineAt(O,K.ByPos,e,0,0).top,l=t.lineAt(a,K.ByPos,e,0,0).bottom;return r+=l-h,{from:O,to:a,top:h,bottom:l,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let O of this.viewports)O.domTop=o+(O.top-s)*this.scale,o=O.domBottom=O.domTop+(O.bottom-O.top),s=O.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,r=s.domBottom}}eq(e){return e instanceof i?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}};function Fi(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new st(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(r=>Fi(r,e)):i._content)}var tr=z.define({combine:i=>i.join(" ")}),ro=z.define({combine:i=>i.indexOf(!0)>-1}),so=je.newName(),wh=je.newName(),Th=je.newName(),vh={"&light":"."+wh,"&dark":"."+Th};function oo(i,e,t){return new je(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):i+" "+n}})}var cm=oo("."+so,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},vh),fm={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Rs=v.ie&&v.ie_version<=11,Oo=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Zs,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(v.ie&&v.ie_version<=11||v.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(v.chrome&&v.chrome_version<126)&&(this.editContext=new ao(e),e.state.facet(wt)&&(e.contentDOM.editContext=this.editContext.editContext)),Rs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(wt)?n.root.activeElement!=this.dom:!nr(n.dom,r))return;let s=r.anchorNode&&n.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(v.ie&&v.ie_version<=11||v.android&&v.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Ki(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=sn(e.root);if(!t)return!1;let n=v.safari&&e.root.nodeType==11&&np(this.dom.ownerDocument)==this.dom&&um(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=nr(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&ap(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,fm),Rs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Rs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&bi(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&nr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Is(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=gh(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=kl(t,e.previousSibling||e.target.previousSibling,-1),r=kl(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(wt)!=e.state.facet(wt)&&(e.view.contentDOM.editContext=e.state.facet(wt)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function kl(i,e,t){for(;e;){let n=H.get(e);if(n&&n.parent==i)return n;let r=e.parentNode;e=r!=i.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function wl(i,e){let t=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return Ki(o.node,o.offset,r,s)&&([t,n,r,s]=[r,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}}function um(i,e){if(e.getComposedRanges){let r=e.getComposedRanges(i.root)[0];if(r)return wl(i,r)}let t=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?wl(i,t):null}var ao=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let{anchor:r}=e.state.selection.main,s={from:this.toEditorPos(n.updateRangeStart),to:this.toEditorPos(n.updateRangeEnd),insert:Y.of(n.text.split(`
-`))};s.from==this.from&&r<this.from?s.from=r:s.to==this.to&&r>this.to&&(s.to=r),!(s.from==s.to&&!s.insert.length)&&(this.pendingContextChange=s,e.state.readOnly||bo(e,s,y.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=n=>{let r=[],s=null;for(let o=this.toEditorPos(n.rangeStart),O=this.toEditorPos(n.rangeEnd);o<O;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,O=s.underlineThickness;if(o!="None"&&O!="None"){let a=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${O=="Thin"?1:2}px`;r.push(j.mark({attributes:{style:a}}).range(this.toEditorPos(s.rangeStart),this.toEditorPos(s.rangeEnd)))}}e.dispatch({effects:lh.of(j.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let r=sn(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,O,a,h)=>{if(n)return;let l=h.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(h)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=l,this.to+=l;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},w=class i{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Op(e.parent)||document,this.viewState=new $r(e.state||I.create(e)),e.scrollTo&&e.scrollTo.is(Fn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ii).map(r=>new tn(r));for(let r of this.plugins)r.update(this);this.observer=new Oo(this),this.inputState=new Ns(this),this.inputState.ensureHandlers(this.plugins),this.docView=new dr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof ne?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,r,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,O=0,a=null;e.some(f=>f.annotation(bh))?(this.inputState.notifiedFocused=o,O=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=xh(s,o),a||(O=1));let h=this.observer.delayedAndroidKey,l=null;if(h?(this.observer.clearDelayedAndroidKey(),l=this.observer.readChange(),(l&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(l=null)):this.observer.clear(),s.facet(I.phrases)!=this.state.facet(I.phrases))return this.setState(s);r=ur.create(this,s,e),r.flags|=O;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(c&&(c=c.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection;c=new en(d.empty?d:y.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(Fn)&&(c=d.value.clip(this.state))}this.viewState.update(r,c),this.bidiCache=Qr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(Ni)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(tr)!=r.state.facet(tr)&&(this.viewState.mustMeasureContent=!0),(t||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Ms))try{f(r)}catch(d){Me(this.state,d,"update listener")}(a||l)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),l&&!gh(this,l)&&h.force&&bi(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new $r(e),this.plugins=e.facet(Ii).map(n=>new tn(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new dr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ii),n=e.state.facet(Ii);if(t!=n){let r=[];for(let s of n){let o=t.indexOf(s);if(o<0)r.push(new tn(s));else{let O=this.plugins[o];O.mustUpdate=e,r.push(O)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Me(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let O=0;;O++){if(o<0)if(Ul(n))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(O>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let l=h.map(d=>{try{return d.read(this)}catch(p){return Me(this.state,p),Tl}}),c=ur.create(this,this.state,[]),f=!1;c.flags|=a,t?t.flags|=a:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),f=this.docView.update(c),f&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(l[d]!=Tl)try{let p=h[d];p.write&&p.write(l[d],this)}catch(p){Me(this.state,p)}if(f&&this.docView.updateSelection(!0),!c.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 p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(p>1||p<-1){r=r+p,n.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let O of this.state.facet(Ms))O(t)}get themeClasses(){return so+" "+(this.state.facet(ro)?Th:wh)+" "+this.state.facet(tr)}updateAttrs(){let e=vl(this,hh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(wt)?"true":"false",class:"cm-content",style:`${v.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),vl(this,So,t);let n=this.observer.ignore(()=>{let r=Us(this.contentDOM,this.contentAttrs,t),s=Us(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(i.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Ni);let e=this.state.facet(i.cspNonce);je.mount(this.root,this.styleModules.concat(cm).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return zs(this,e,cl(this,e,t,n))}moveByGroup(e,t){return zs(this,e,cl(this,e,t,n=>Yp(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return y.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return Cp(this,e,t,n)}moveVertically(e,t,n){return zs(this,e,Up(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),mh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[ot.find(s,e-r.from,-1,t)];return Pr(n,o.dir==J.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(oh)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>dm)return Kl(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Hl(s.isolates,n=ol(this,e))))return s.order;n||(n=ol(this,e));let r=yp(e.text,t,n);return this.bidiCache.push(new Qr(e.from,e.to,t,n,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||v.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Cl(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Fn.of(new en(typeof e=="number"?y.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Fn.of(new en(y.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ge.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ge.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=je.newName(),r=[tr.of(n),Ni.of(oo(`.${n}`,e))];return t&&t.dark&&r.push(ro.of(!0)),r}static baseTheme(e){return nt.lowest(Ni.of(oo("."+so,e,vh)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&H.get(n)||H.get(e);return((t=r?.rootView)===null||t===void 0?void 0:t.view)||null}};w.styleModule=Ni;w.inputHandler=rh;w.clipboardInputFilter=Qo;w.clipboardOutputFilter=yo;w.scrollHandler=ah;w.focusChangeEffect=sh;w.perLineTextDirection=oh;w.exceptionSink=nh;w.updateListener=Ms;w.editable=wt;w.mouseSelectionStyle=ih;w.dragMovesSelection=th;w.clickAddsSelectionRange=eh;w.decorations=cn;w.outerDecorations=ch;w.atomicRanges=Po;w.bidiIsolatedRanges=fh;w.scrollMargins=uh;w.darkTheme=ro;w.cspNonce=z.define({combine:i=>i.length?i[0]:""});w.contentAttributes=So;w.editorAttributes=hh;w.lineWrapping=w.contentAttributes.of({class:"cm-lineWrapping"});w.announce=D.define();var dm=4096,Tl={},Qr=class i{constructor(e,t,n,r,s,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:J.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&n.push(new i(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}};function vl(i,e,t){for(let n=i.state.facet(e),r=n.length-1;r>=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&Ys(o,t)}return t}var pm=v.mac?"mac":v.windows?"win":v.linux?"linux":"key";function mm(i,e){let t=i.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,O;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))O=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?O=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),O&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function ir(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}var gm=nt.default(w.domEventHandlers({keydown(i,e){return Sm($m(e.state),i,e,"editor")}})),lt=z.define({enables:gm}),zl=new WeakMap;function $m(i){let e=i.facet(lt),t=zl.get(e);return t||zl.set(e,t=ym(e.reduce((n,r)=>n.concat(r),[]))),t}var Tt=null,Qm=4e3;function ym(i,e=pm){let t=Object.create(null),n=Object.create(null),r=(o,O)=>{let a=n[o];if(a==null)n[o]=O;else if(a!=O)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,O,a,h,l)=>{var c,f;let d=t[o]||(t[o]=Object.create(null)),p=O.split(/ (?!$)/).map($=>mm($,e));for(let $=1;$<p.length;$++){let Q=p.slice(0,$).join(" ");r(Q,!0),d[Q]||(d[Q]={preventDefault:!0,stopPropagation:!1,run:[b=>{let k=Tt={view:b,prefix:Q,scope:o};return setTimeout(()=>{Tt==k&&(Tt=null)},Qm),!0}]})}let m=p.join(" ");r(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(c=d._any)===null||c===void 0?void 0:c.run)===null||f===void 0?void 0:f.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),l&&(g.stopPropagation=!0)};for(let o of i){let O=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of O){let l=t[h]||(t[h]=Object.create(null));l._any||(l._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let f in l)l[f].run.push(d=>c(d,lo))}let a=o[e]||o.key;if(a)for(let h of O)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}var lo=null;function Sm(i,e,t,n){lo=e;let r=Ka(e),s=pi(r,0),o=Mi(s)==r.length&&r!=" ",O="",a=!1,h=!1,l=!1;Tt&&Tt.view==t&&Tt.scope==n&&(O=Tt.prefix+" ",Qh.indexOf(e.keyCode)<0&&(h=!0,Tt=null));let c=new Set,f=g=>{if(g){for(let $ of g.run)if(!c.has($)&&(c.add($),$(t)))return g.stopPropagation&&(l=!0),!0;g.preventDefault&&(g.stopPropagation&&(l=!0),h=!0)}return!1},d=i[n],p,m;return d&&(f(d[O+ir(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(v.windows&&e.ctrlKey&&e.altKey)&&(p=mt[e.keyCode])&&p!=r?(f(d[O+ir(p,e,!0)])||e.shiftKey&&(m=Qi[e.keyCode])!=r&&m!=p&&f(d[O+ir(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[O+ir(r,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),h&&(a=!0),a&&l&&e.stopPropagation(),lo=null,a}var fn=class i{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=zh(e);return[new i(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return Pm(e,t,n)}};function zh(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==J.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function Rl(i,e,t,n){let r=i.coordsAtPos(e,t*2);if(!r)return n;let s=i.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,O=i.posAtCoords({x:s.left+1,y:o}),a=i.posAtCoords({x:s.right-1,y:o});return O==null||a==null?n:{from:Math.max(n.from,Math.min(O,a)),to:Math.min(n.to,Math.max(O,a))}}function Pm(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),r=Math.min(t.to,i.viewport.to),s=i.textDirection==J.LTR,o=i.contentDOM,O=o.getBoundingClientRect(),a=zh(i),h=o.querySelector(".cm-line"),l=h&&window.getComputedStyle(h),c=O.left+(l?parseInt(l.paddingLeft)+Math.min(0,parseInt(l.textIndent)):0),f=O.right-(l?parseInt(l.paddingRight):0),d=Ls(i,n),p=Ls(i,r),m=d.type==Qe.Text?d:null,g=p.type==Qe.Text?p:null;if(m&&(i.lineWrapping||d.widgetLineBreaks)&&(m=Rl(i,n,1,m)),g&&(i.lineWrapping||p.widgetLineBreaks)&&(g=Rl(i,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return Q(b(t.from,t.to,m));{let P=m?b(t.from,null,m):k(d,!1),R=g?b(null,t.to,g):k(p,!0),T=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&P.bottom+i.defaultLineHeight/2<R.top?T.push($(c,P.bottom,f,R.top)):P.bottom<R.top&&i.elementAtHeight((P.bottom+R.top)/2).type==Qe.Text&&(P.bottom=R.top=(P.bottom+R.top)/2),Q(P).concat(T).concat(Q(R))}function $(P,R,T,E){return new fn(e,P-a.left,R-a.top-.01,T-P,E-R+.01)}function Q({top:P,bottom:R,horizontal:T}){let E=[];for(let U=0;U<T.length;U+=2)E.push($(T[U],P,T[U+1],R));return E}function b(P,R,T){let E=1e9,U=-1e9,A=[];function C(M,te,be,xe,Xe){let Ue=i.coordsAtPos(M,M==T.to?-2:2),se=i.coordsAtPos(be,be==T.from?2:-2);!Ue||!se||(E=Math.min(Ue.top,se.top,E),U=Math.max(Ue.bottom,se.bottom,U),Xe==J.LTR?A.push(s&&te?c:Ue.left,s&&xe?f:se.right):A.push(!s&&xe?c:se.left,!s&&te?f:Ue.right))}let V=P??T.from,N=R??T.to;for(let M of i.visibleRanges)if(M.to>V&&M.from<N)for(let te=Math.max(M.from,V),be=Math.min(M.to,N);;){let xe=i.state.doc.lineAt(te);for(let Xe of i.bidiSpans(xe)){let Ue=Xe.from+xe.from,se=Xe.to+xe.from;if(Ue>=be)break;se>te&&C(Math.max(Ue,te),P==null&&Ue<=V,Math.min(se,be),R==null&&se>=N,Xe.dir)}if(te=xe.to+1,te>=be)break}return A.length==0&&C(V,P==null,N,R==null,i.textDirection),{top:E,bottom:U,horizontal:A}}function k(P,R){let T=O.top+(R?P.top:P.bottom);return{top:T,bottom:T,horizontal:[]}}}function bm(i,e){return i.constructor==e.constructor&&i.eq(e)}var ho=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(or)!=e.state.facet(or)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(or);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!bm(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},or=z.define();function Rh(i){return[Ge.define(e=>new ho(e,i)),or.of(i)]}var Xh=!v.ios,un=z.define({combine(i){return kt(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Wh(i={}){return[un.of(i),xm,km,wm,Oh.of(!0)]}function Zh(i){return i.startState.facet(un)!=i.state.facet(un)}var xm=Rh({above:!0,markers(i){let{state:e}=i,t=e.facet(un),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||Xh:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",O=r.empty?r:y.cursor(r.head,r.head>r.anchor?-1:1);for(let a of fn.forRange(i,o,O))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Zh(i);return t&&Xl(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){Xl(e.state,i)},class:"cm-cursorLayer"});function Xl(i,e){e.style.animationDuration=i.facet(un).cursorBlinkRate+"ms"}var km=Rh({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:fn.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Zh(i)},class:"cm-selectionLayer"}),co={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Xh&&(co[".cm-line"].caretColor=co[".cm-content"].caretColor="transparent !important");var wm=nt.highest(w.theme(co)),Vh=D.define({map(i,e){return i==null?null:e.mapPos(i)}}),Hi=ge.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(Vh)?n.value:t,i)}}),Tm=Ge.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(Hi);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(Hi)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(Hi),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(Hi)!=i&&this.view.dispatch({effects:Vh.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function qh(){return[Hi,Tm]}var XP=/x/.unicode!=null?"gu":"g";function xo(){return zm}var vm=j.line({class:"cm-activeLine"}),zm=Ge.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let r=i.lineBlockAt(n.head);r.from>e&&(t.push(vm.range(r.from)),e=r.from)}return j.set(t)}},{decorations:i=>i.decorations});var fo=2e3;function Rm(i,e,t){let n=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>fo||t.off>fo||e.col<0||t.col<0){let o=Math.min(e.off,t.off),O=Math.max(e.off,t.off);for(let a=n;a<=r;a++){let h=i.doc.line(a);h.length<=O&&s.push(y.range(h.from+o,h.to+O))}}else{let o=Math.min(e.col,t.col),O=Math.max(e.col,t.col);for(let a=n;a<=r;a++){let h=i.doc.line(a),l=In(h.text,o,i.tabSize,!0);if(l<0)s.push(y.cursor(h.to));else{let c=In(h.text,O,i.tabSize);s.push(y.range(h.from+l,h.from+c))}}}return s}function Xm(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function Wl(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),r=t-n.from,s=r>fo?-1:r==n.length?Xm(i,e.clientX):we(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:s,off:r}}function Wm(i,e){let t=Wl(i,e),n=i.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(r.changes)}},get(r,s,o){let O=Wl(i,r);if(!O)return n;let a=Rm(i.state,t,O);return a.length?o?y.create(a.concat(n.ranges)):y.create(a):n}}:null}function Ch(i){let e=i?.eventFilter||(t=>t.altKey&&t.button==0);return w.mouseSelectionStyle.of((t,n)=>e(n)?Wm(t,n):null)}var WP=w.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var He=class extends Be{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};He.prototype.elementClass="";He.prototype.toDOM=void 0;He.prototype.mapMode=ae.TrackBefore;He.prototype.startSide=He.prototype.endSide=-1;He.prototype.point=!0;var Or=z.define(),Zm=z.define();var ar=z.define();var uo=z.define({combine:i=>i.some(e=>e)});function Vm(i){let e=[qm];return i&&i.fixed===!1&&e.push(uo.of(!0)),e}var qm=Ge.fromClass(class{constructor(i){this.view=i,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(ar).map(e=>new yr(i,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!i.state.facet(uo),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}i.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(uo)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&this.dom.remove();let t=F.iter(this.view.state.facet(Or),this.view.viewport.from),n=[],r=this.gutters.map(s=>new mo(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let O of s.type)if(O.type==Qe.Text&&o){po(t,n,O.from);for(let a of r)a.line(this.view,O,n);o=!1}else if(O.widget)for(let a of r)a.widget(this.view,O)}else if(s.type==Qe.Text){po(t,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();i&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(i){let e=i.startState.facet(ar),t=i.state.facet(ar),n=i.docChanged||i.heightChanged||i.viewportChanged||!F.eq(i.startState.facet(Or),i.state.facet(Or),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(i)&&(n=!0);else{n=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new yr(this.view,s)):(this.gutters[o].update(i),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove()}},{provide:i=>w.scrollMargins.of(e=>{let t=e.plugin(i);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==J.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function Zl(i){return Array.isArray(i)?i:[i]}function po(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}var mo=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=F.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let O=new Sr(e,o,s,n);r.elements.push(O),r.dom.appendChild(O.dom)}else r.elements[this.i].update(e,o,s,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];po(this.cursor,r,t.from),n.length&&(r=r.concat(n));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let s of e.state.facet(Zm)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},yr=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let O=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,O,r)&&r.preventDefault()});this.markers=Zl(t.markers(e)),t.initialSpacer&&(this.spacer=new Sr(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Zl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let n=e.view.viewport;return!F.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Sr=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),Cm(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let O=o,a=s<t.length?t[s++]:null,h=!1;if(a){let l=a.elementClass;l&&(n+=" "+l);for(let c=o;c<this.markers.length;c++)if(this.markers[c].compare(a)){O=c,h=!0;break}}else O=this.markers.length;for(;o<O;){let l=this.markers[o++];if(l.toDOM){l.destroy(r);let c=r.nextSibling;r.remove(),r=c}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Cm(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}var Ym=z.define(),Um=z.define(),Pi=z.define({combine(i){return kt(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let r in t){let s=n[r],o=t[r];n[r]=s?(O,a,h)=>s(O,a,h)||o(O,a,h):o}return n}})}}),rn=class extends He{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Xs(i,e){return i.state.facet(Pi).formatNumber(e,i.state)}var Am=ar.compute([Pi],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Ym)},lineMarker(e,t,n){return n.some(r=>r.toDOM)?null:new rn(Xs(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Um)){let s=r(e,t,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Pi)!=e.state.facet(Pi),initialSpacer(e){return new rn(Xs(e,Vl(e.state.doc.lines)))},updateSpacer(e,t){let n=Xs(t.view,Vl(t.view.state.doc.lines));return n==e.number?e:new rn(n)},domEventHandlers:i.facet(Pi).domEventHandlers}));function Yh(i={}){return[Pi.of(i),Vm(),Am]}function Vl(i){let e=9;for(;e<i;)e=e*10+9;return e}var _m=new class extends He{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},jm=Or.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.head).from;r>t&&(t=r,e.push(_m.range(r)))}return F.of(e)});function ko(){return jm}async function Uh(i){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(i);return}let e=document.createElement("textarea");e.style="position: absolute; left: -1000px; top: -1000px;",e.value=i,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}var Em=0,ve=class{constructor(e,t){this.from=e,this.to=t}},Z=class{constructor(e={}){this.id=Em++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ie.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Z.closedBy=new Z({deserialize:i=>i.split(" ")});Z.openedBy=new Z({deserialize:i=>i.split(" ")});Z.group=new Z({deserialize:i=>i.split(" ")});Z.isolate=new Z({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});Z.contextHash=new Z({perNode:!0});Z.lookAhead=new Z({perNode:!0});Z.mounted=new Z({perNode:!0});var ti=class{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[Z.mounted.id]}},Mm=Object.create(null),ie=class i{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Mm,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new i(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(Z.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(Z.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}};ie.none=new ie("",Object.create(null),0,8);var $t=class i{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let s of e){let o=s(n);o&&(r||(r=Object.assign({},n.props)),r[o[0].id]=o[1])}t.push(r?new ie(n.name,r,n.id,n.flags):n)}return new i(t)}},kr=new WeakMap,Ah=new WeakMap,L;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(L||(L={}));var q=class i{constructor(e,t,n,r,s){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,O]of s)this.props[typeof o=="number"?o:o.id]=O}}toString(){let e=ti.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let r=n.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ki(this.topNode,e)}cursorAt(e,t=0,n=0){let r=kr.get(this)||this.topNode,s=new ki(r);return s.moveTo(e,t),kr.set(this,s._tree),s}get topNode(){return new ze(this,0,0,null)}resolve(e,t=0){let n=dn(kr.get(this)||this.topNode,e,t,!1);return kr.set(this,n),n}resolveInner(e,t=0){let n=dn(Ah.get(this)||this.topNode,e,t,!0);return Ah.set(this,n),n}resolveStack(e,t=0){return Gm(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:s=this.length}=e,o=e.mode||0,O=(o&L.IncludeAnonymous)>0;for(let a=this.cursor(o|L.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!O&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(O||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Co(ie.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new i(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new i(ie.none,t,n,r)))}static build(e){return Lm(e)}};q.empty=new q(ie.none,[],[],0);var wo=class i{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new i(this.buffer,this.index)}},Zt=class i{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return ie.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,n,r,s){let{buffer:o}=this,O=-1;for(let a=e;a!=t&&!(Dh(s,r,o[a+1],o[a+2])&&(O=a,n>0));a=o[a+3]);return O}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let O=e,a=0;O<t;){s[a++]=r[O++],s[a++]=r[O++]-n;let h=s[a++]=r[O++]-n;s[a++]=r[O++]-e,o=Math.max(o,h)}return new i(s,o,this.set)}};function Dh(i,e,t,n){switch(i){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function dn(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let o=!n&&i instanceof ze&&i.index<0?null:i.parent;if(!o)return i;i=o}let s=n?0:L.IgnoreOverlays;if(n)for(let o=i,O=o.parent;O;o=O,O=o.parent)o instanceof ze&&o.index<0&&((r=O.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(i=O);for(;;){let o=i.enter(e,t,s);if(!o)return i;i=o}}var Tr=class{cursor(e=0){return new ki(this,e)}getChild(e,t=null,n=null){let r=_h(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return _h(this,e,t,n)}resolve(e,t=0){return dn(this,e,t,!1)}resolveInner(e,t=0){return dn(this,e,t,!0)}matchContext(e){return To(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(n=t,t=r.prevSibling):t=r}return n}get node(){return this}get next(){return this.parent}},ze=class i extends Tr{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,s=0){for(let o=this;;){for(let{children:O,positions:a}=o._tree,h=t>0?O.length:-1;e!=h;e+=t){let l=O[e],c=a[e]+o.from;if(Dh(r,n,c,c+l.length)){if(l instanceof Zt){if(s&L.ExcludeBuffers)continue;let f=l.findChild(0,l.buffer.length,t,n-c,r);if(f>-1)return new ii(new vo(o,l,e,c),null,f)}else if(s&L.IncludeAnonymous||!l.type.isAnonymous||qo(l)){let f;if(!(s&L.IgnoreMounts)&&(f=ti.get(l))&&!f.overlay)return new i(f.tree,c,e,o);let d=new i(l,c,e,o);return s&L.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?l.children.length-1:0,t,n,r)}}}if(s&L.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let r;if(!(n&L.IgnoreOverlays)&&(r=ti.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:O}of r.overlay)if((t>0?o<=s:o<s)&&(t<0?O>=s:O>s))return new i(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function _h(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function To(i,e,t=e.length-1){for(let n=i.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var vo=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},ii=class i extends Tr{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new i(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&L.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new i(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new i(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new i(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new q(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Ih(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;s<i.length;s++){let o=i[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let n=t instanceof ze&&t.index<0?null:t.parent,r=i.slice();return n?r[e]=n:r.splice(e,1),new zo(r,t)}var zo=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Ih(this.heads)}};function Gm(i,e,t){let n=i.resolveInner(e,t),r=null;for(let s=n instanceof ze?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[n])).push(o.resolve(e,t)),s=o}else{let o=ti.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let O=new ze(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(dn(O,e,t,!1))}}return r?Ih(r):n}var ki=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ze)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof ze?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&L.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&L.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&L.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let O=n._tree.children[s];if(this.mode&L.IncludeAnonymous||O instanceof Zt||!O.type.isAnonymous||qo(O))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r<this.stack.length;r++)t=new ii(this.buffer,t,this.stack[r]);return this.bufferNode=new ii(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return To(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return To(this.node,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function qo(i){return i.children.some(e=>e instanceof Zt||!e.type.isAnonymous||qo(e))}function Lm(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=n.types.length}=i,O=Array.isArray(t)?new wo(t,t.length):t,a=n.types,h=0,l=0;function c(P,R,T,E,U,A){let{id:C,start:V,end:N,size:M}=O,te=l;for(;M<0;)if(O.next(),M==-1){let se=s[C];T.push(se),E.push(V-P);return}else if(M==-3){h=C;return}else if(M==-4){l=C;return}else throw new RangeError(`Unrecognized record size: ${M}`);let be=a[C],xe,Xe,Ue=V-P;if(N-V<=r&&(Xe=g(O.pos-R,U))){let se=new Uint16Array(Xe.size-Xe.skip),Ae=O.pos-Xe.size,it=se.length;for(;O.pos>Ae;)it=$(Xe.start,se,it);xe=new Zt(se,N-Xe.start,n),Ue=Xe.start-P}else{let se=O.pos-M;O.next();let Ae=[],it=[],Lt=C>=o?C:-1,ci=0,Yn=N;for(;O.pos>se;)Lt>=0&&O.id==Lt&&O.size>=0?(O.end<=Yn-r&&(p(Ae,it,V,ci,O.end,Yn,Lt,te),ci=Ae.length,Yn=O.end),O.next()):A>2500?f(V,se,Ae,it):c(V,se,Ae,it,Lt,A+1);if(Lt>=0&&ci>0&&ci<Ae.length&&p(Ae,it,V,ci,V,Yn,Lt,te),Ae.reverse(),it.reverse(),Lt>-1&&ci>0){let Ta=d(be);xe=Co(be,Ae,it,0,Ae.length,0,N-V,Ta,Ta)}else xe=m(be,Ae,it,N-V,te-N)}T.push(xe),E.push(Ue)}function f(P,R,T,E){let U=[],A=0,C=-1;for(;O.pos>R;){let{id:V,start:N,end:M,size:te}=O;if(te>4)O.next();else{if(C>-1&&N<C)break;C<0&&(C=M-r),U.push(V,N,M),A++,O.next()}}if(A){let V=new Uint16Array(A*4),N=U[U.length-2];for(let M=U.length-3,te=0;M>=0;M-=3)V[te++]=U[M],V[te++]=U[M+1]-N,V[te++]=U[M+2]-N,V[te++]=te;T.push(new Zt(V,U[2]-N,n)),E.push(N-P)}}function d(P){return(R,T,E)=>{let U=0,A=R.length-1,C,V;if(A>=0&&(C=R[A])instanceof q){if(!A&&C.type==P&&C.length==E)return C;(V=C.prop(Z.lookAhead))&&(U=T[A]+C.length+V)}return m(P,R,T,E,U)}}function p(P,R,T,E,U,A,C,V){let N=[],M=[];for(;P.length>E;)N.push(P.pop()),M.push(R.pop()+T-U);P.push(m(n.types[C],N,M,A-U,V-A)),R.push(U-T)}function m(P,R,T,E,U=0,A){if(h){let C=[Z.contextHash,h];A=A?[C].concat(A):[C]}if(U>25){let C=[Z.lookAhead,U];A=A?[C].concat(A):[C]}return new q(P,R,T,E,A)}function g(P,R){let T=O.fork(),E=0,U=0,A=0,C=T.end-r,V={size:0,start:0,skip:0};e:for(let N=T.pos-P;T.pos>N;){let M=T.size;if(T.id==R&&M>=0){V.size=E,V.start=U,V.skip=A,A+=4,E+=4,T.next();continue}let te=T.pos-M;if(M<0||te<N||T.start<C)break;let be=T.id>=o?4:0,xe=T.start;for(T.next();T.pos>te;){if(T.size<0)if(T.size==-3)be+=4;else break e;else T.id>=o&&(be+=4);T.next()}U=xe,E+=M,A+=be}return(R<0||E==P)&&(V.size=E,V.start=U,V.skip=A),V.size>4?V:void 0}function $(P,R,T){let{id:E,start:U,end:A,size:C}=O;if(O.next(),C>=0&&E<o){let V=T;if(C>4){let N=O.pos-(C-4);for(;O.pos>N;)T=$(P,R,T)}R[--T]=V,R[--T]=A-P,R[--T]=U-P,R[--T]=E}else C==-3?h=E:C==-4&&(l=E);return T}let Q=[],b=[];for(;O.pos>0;)c(i.start||0,i.bufferStart||0,Q,b,-1,0);let k=(e=i.length)!==null&&e!==void 0?e:Q.length?b[0]+Q[0].length:0;return new q(a[i.topID],Q.reverse(),b.reverse(),k)}var jh=new WeakMap;function wr(i,e){if(!i.isAnonymous||e instanceof Zt||e.type!=i)return 1;let t=jh.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof q)){t=1;break}t+=wr(i,n)}jh.set(e,t)}return t}function Co(i,e,t,n,r,s,o,O,a){let h=0;for(let p=n;p<r;p++)h+=wr(i,e[p]);let l=Math.ceil(h*1.5/8),c=[],f=[];function d(p,m,g,$,Q){for(let b=g;b<$;){let k=b,P=m[b],R=wr(i,p[b]);for(b++;b<$;b++){let T=wr(i,p[b]);if(R+T>=l)break;R+=T}if(b==k+1){if(R>l){let T=p[k];d(T.children,T.positions,0,T.children.length,m[k]+Q);continue}c.push(p[k])}else{let T=m[b-1]+p[b-1].length-P;c.push(Co(i,p,m,k,b,P,T,null,a))}f.push(P+Q-s)}}return d(e,t,n,r,0),(O||a)(c,f,o)}var wi=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof ii?this.setBuffer(e.context.buffer,e.index,t):e instanceof ze&&this.map.set(e.tree,t)}get(e){return e instanceof ii?this.getBuffer(e.context.buffer,e.index):e instanceof ze?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},Qt=class i{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new i(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let O=0,a=0,h=0;;O++){let l=O<t.length?t[O]:null,c=l?l.fromA:1e9;if(c-a>=n)for(;o&&o.from<c;){let f=o;if(a>=f.from||c<=f.to||h){let d=Math.max(f.from,a)-h,p=Math.min(f.to,c)-h;f=d>=p?null:new i(d,p,f.tree,f.offset+h,O>0,!!l)}if(f&&r.push(f),o.to>c)break;o=s<e.length?e[s++]:null}if(!l)break;a=l.toA,h=l.toA-l.toB}return r}},yt=class{startParse(e,t,n){return typeof e=="string"&&(e=new Ro(e)),n=n?n.length?n.map(r=>new ve(r.from,r.to)):[new ve(0,0)]:[new ve(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}},Ro=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function Ti(i){return(e,t,n,r)=>new Zo(e,i,t,n,r)}var vr=class{constructor(e,t,n,r,s){this.parser=e,this.parse=t,this.overlay=n,this.target=r,this.from=s}};function Eh(i){if(!i.length||i.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(i))}var Xo=class{constructor(e,t,n,r,s,o,O){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=s,this.target=o,this.prev=O,this.depth=0,this.ranges=[]}},Wo=new Z({perNode:!0}),Zo=class{constructor(e,t,n,r,s){this.nest=t,this.input=n,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new q(n.type,n.children,n.positions,n.length,n.propValues.concat([[Wo,this.stoppedAt]]))),n}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[Z.mounted.id]=new ti(t,e.overlay,e.parser),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Vo(this.fragments),t=null,n=null,r=new ki(new ze(this.baseTree,this.ranges[0].from,0,null),L.IncludeAnonymous|L.IgnoreMounts);e:for(let s,o;;){let O=!0,a;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)O=!1;else if(e.hasNode(r)){if(t){let h=t.mounts.find(l=>l.frag.from<=r.from&&l.frag.to>=r.to&&l.mount.overlay);if(h)for(let l of h.mount.overlay){let c=l.from+h.pos,f=l.to+h.pos;c>=r.from&&f<=r.to&&!t.ranges.some(d=>d.from<f&&d.to>c)&&t.ranges.push({from:c,to:f})}}O=!1}else if(n&&(o=Dm(n.ranges,r.from,r.to)))O=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.from<r.to||!s.overlay)){r.tree||Im(r);let h=e.findMounts(r.from,s.parser);if(typeof s.overlay=="function")t=new Xo(s.parser,s.overlay,h,this.inner.length,r.from,r.tree,t);else{let l=Gh(this.ranges,s.overlay||(r.from<r.to?[new ve(r.from,r.to)]:[]));l.length&&Eh(l),(l.length||!s.overlay)&&this.inner.push(new vr(s.parser,l.length?s.parser.startParse(this.input,Lh(h,l),l):s.parser.startParse(""),s.overlay?s.overlay.map(c=>new ve(c.from-r.from,c.to-r.from)):null,r.tree,l.length?l[0].from:r.from)),s.overlay?l.length&&(n={ranges:l,depth:0,prev:n}):O=!1}}else t&&(a=t.predicate(r))&&(a===!0&&(a=new ve(r.from,r.to)),a.from<a.to&&t.ranges.push(a));if(O&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let h=Gh(this.ranges,t.ranges);h.length&&(Eh(h),this.inner.splice(t.index,0,new vr(t.parser,t.parser.startParse(this.input,Lh(t.mounts,h),h),t.ranges.map(l=>new ve(l.from-t.start,l.to-t.start)),t.target,h[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function Dm(i,e,t){for(let n of i){if(n.from>=t)break;if(n.to>e)return n.from<=e&&n.to>=t?2:1}return 0}function Mh(i,e,t,n,r,s){if(e<t){let o=i.buffer[e+1];n.push(i.slice(e,t,o)),r.push(o-s)}}function Im(i){let{node:e}=i,t=[],n=e.context.buffer;do t.push(i.index),i.parent();while(!i.tree);let r=i.tree,s=r.children.indexOf(n),o=r.children[s],O=o.buffer,a=[s];function h(l,c,f,d,p,m){let g=t[m],$=[],Q=[];Mh(o,l,g,$,Q,d);let b=O[g+1],k=O[g+2];a.push($.length);let P=m?h(g+4,O[g+3],o.set.types[O[g]],b,k-b,m-1):e.toTree();return $.push(P),Q.push(b-d),Mh(o,O[g+3],c,$,Q,d),new q(f,$,Q,p)}r.children[s]=h(0,O.length,ie.none,0,o.length,t.length-1);for(let l of a){let c=i.tree.children[l],f=i.tree.positions[l];i.yield(new ze(c,f+i.from,l,i._tree))}}var zr=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(L.IncludeAnonymous|L.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)t.to>=e&&t.enter(n,1,L.IgnoreOverlays|L.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof q)t=t.children[0];else break}return!1}},Vo=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let n=this.curFrag=e[0];this.curTo=(t=n.tree.prop(Wo))!==null&&t!==void 0?t:n.to,this.inner=new zr(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Wo))!==null&&e!==void 0?e:t.to,this.inner=new zr(t.tree,-t.offset)}}findMounts(e,t){var n;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(n=s.tree)===null||n===void 0?void 0:n.prop(Z.mounted);if(o&&o.parser==t)for(let O=this.fragI;O<this.fragments.length;O++){let a=this.fragments[O];if(a.from>=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}};function Gh(i,e){let t=null,n=e;for(let r=1,s=0;r<i.length;r++){let o=i[r-1].to,O=i[r].from;for(;s<n.length;s++){let a=n[s];if(a.from>=O)break;a.to<=o||(t||(n=t=e.slice()),a.from<o?(t[s]=new ve(a.from,o),a.to>O&&t.splice(s+1,0,new ve(O,a.to))):a.to>O?t[s--]=new ve(O,a.to):t.splice(s--,1))}}return n}function Nm(i,e,t,n){let r=0,s=0,o=!1,O=!1,a=-1e9,h=[];for(;;){let l=r==i.length?1e9:o?i[r].to:i[r].from,c=s==e.length?1e9:O?e[s].to:e[s].from;if(o!=O){let f=Math.max(a,t),d=Math.min(l,c,n);f<d&&h.push(new ve(f,d))}if(a=Math.min(l,c),a==1e9)break;l==a&&(o?(o=!1,r++):o=!0),c==a&&(O?(O=!1,s++):O=!0)}return h}function Lh(i,e){let t=[];for(let{pos:n,mount:r,frag:s}of i){let o=n+(r.overlay?r.overlay[0].from:0),O=o+r.tree.length,a=Math.max(s.from,o),h=Math.min(s.to,O);if(r.overlay){let l=r.overlay.map(f=>new ve(f.from+n,f.to+n)),c=Nm(e,l,a,h);for(let f=0,d=a;;f++){let p=f==c.length,m=p?h:c[f].from;if(m>d&&t.push(new Qt(d,m,r.tree,-o,s.from>=d||s.openStart,s.to<=m||s.openEnd)),p)break;d=c[f].to}}else t.push(new Qt(a,h,r.tree,-o,s.from>=o||s.openStart,s.to<=O||s.openEnd))}return t}var Bm=0,Ve=class i{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Bm++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof i&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new i(n,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Zr(e);return n=>n.modified.indexOf(t)>-1?n:Zr.get(n.base||n,n.modified.concat(t).sort((r,s)=>r.id-s.id))}},Fm=0,Zr=class i{constructor(e){this.name=e,this.instances=[],this.id=Fm++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(O=>O.base==e&&Hm(t,O.modified));if(n)return n;let r=[],s=new Ve(e.name,r,e,t);for(let O of t)O.instances.push(s);let o=Km(t);for(let O of e.set)if(!O.modified.length)for(let a of o)r.push(i.get(O,a));return s}};function Hm(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function Km(i){let e=[[]];for(let t=0;t<i.length;t++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].concat(i[t]));return e.sort((t,n)=>n.length-t.length)}function oe(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,O=r;for(let c=0;;){if(O=="..."&&c>0&&c+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(O);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),c+=f[0].length,c==r.length)break;let d=r[c++];if(c==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);O=r.slice(c)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let l=new vi(n,o,a>0?s.slice(0,a):null);e[h]=l.sort(e[h])}}return Fh.add(e)}var Fh=new Z,vi=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};vi.empty=new vi([],2,null);function _o(i,e){let t=Object.create(null);for(let s of i)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:n,all:r=null}=e||{};return{style:s=>{let o=r;for(let O of s)for(let a of O.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function Jm(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function Hh(i,e,t,n=0,r=i.length){let s=new Uo(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}var Uo=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,s){let{type:o,from:O,to:a}=e;if(O>=n||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=r,l=eg(e)||vi.empty,c=Jm(s,l.tags);if(c&&(h&&(h+=" "),h+=c,l.mode==1&&(r+=(r?" ":"")+c)),this.startSpan(Math.max(t,O),h),l.opaque)return;let f=e.tree&&e.tree.prop(Z.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+O,1),p=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),m=e.firstChild();for(let g=0,$=O;;g++){let Q=g<f.overlay.length?f.overlay[g]:null,b=Q?Q.from+O:a,k=Math.max(t,$),P=Math.min(n,b);if(k<P&&m)for(;e.from<P&&(this.highlightRange(e,k,P,r,s),this.startSpan(Math.min(P,e.to),h),!(e.to>=b||!e.nextSibling())););if(!Q||b>n)break;$=Q.to+O,$>t&&(this.highlightRange(d.cursor(),Math.max(t,Q.from+O),Math.min(n,$),"",p),this.startSpan(Math.min(n,$),h))}m&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}};function eg(i){let e=i.type.prop(Fh);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var x=Ve.define,Rr=x(),Vt=x(),Nh=x(Vt),Bh=x(Vt),qt=x(),Xr=x(qt),Yo=x(qt),ft=x(),ni=x(ft),ht=x(),ct=x(),Ao=x(),pn=x(Ao),Wr=x(),u={comment:Rr,lineComment:x(Rr),blockComment:x(Rr),docComment:x(Rr),name:Vt,variableName:x(Vt),typeName:Nh,tagName:x(Nh),propertyName:Bh,attributeName:x(Bh),className:x(Vt),labelName:x(Vt),namespace:x(Vt),macroName:x(Vt),literal:qt,string:Xr,docString:x(Xr),character:x(Xr),attributeValue:x(Xr),number:Yo,integer:x(Yo),float:x(Yo),bool:x(qt),regexp:x(qt),escape:x(qt),color:x(qt),url:x(qt),keyword:ht,self:x(ht),null:x(ht),atom:x(ht),unit:x(ht),modifier:x(ht),operatorKeyword:x(ht),controlKeyword:x(ht),definitionKeyword:x(ht),moduleKeyword:x(ht),operator:ct,derefOperator:x(ct),arithmeticOperator:x(ct),logicOperator:x(ct),bitwiseOperator:x(ct),compareOperator:x(ct),updateOperator:x(ct),definitionOperator:x(ct),typeOperator:x(ct),controlOperator:x(ct),punctuation:Ao,separator:x(Ao),bracket:pn,angleBracket:x(pn),squareBracket:x(pn),paren:x(pn),brace:x(pn),content:ft,heading:ni,heading1:x(ni),heading2:x(ni),heading3:x(ni),heading4:x(ni),heading5:x(ni),heading6:x(ni),contentSeparator:x(ft),list:x(ft),quote:x(ft),emphasis:x(ft),strong:x(ft),link:x(ft),monospace:x(ft),strikethrough:x(ft),inserted:x(),deleted:x(),changed:x(),invalid:x(),meta:Wr,documentMeta:x(Wr),annotation:x(Wr),processingInstruction:x(Wr),definition:Ve.defineModifier("definition"),constant:Ve.defineModifier("constant"),function:Ve.defineModifier("function"),standard:Ve.defineModifier("standard"),local:Ve.defineModifier("local"),special:Ve.defineModifier("special")};for(let i in u){let e=u[i];e instanceof Ve&&(e.name=i)}var jP=_o([{tag:u.link,class:"tok-link"},{tag:u.heading,class:"tok-heading"},{tag:u.emphasis,class:"tok-emphasis"},{tag:u.strong,class:"tok-strong"},{tag:u.keyword,class:"tok-keyword"},{tag:u.atom,class:"tok-atom"},{tag:u.bool,class:"tok-bool"},{tag:u.url,class:"tok-url"},{tag:u.labelName,class:"tok-labelName"},{tag:u.inserted,class:"tok-inserted"},{tag:u.deleted,class:"tok-deleted"},{tag:u.literal,class:"tok-literal"},{tag:u.string,class:"tok-string"},{tag:u.number,class:"tok-number"},{tag:[u.regexp,u.escape,u.special(u.string)],class:"tok-string2"},{tag:u.variableName,class:"tok-variableName"},{tag:u.local(u.variableName),class:"tok-variableName tok-local"},{tag:u.definition(u.variableName),class:"tok-variableName tok-definition"},{tag:u.special(u.variableName),class:"tok-variableName2"},{tag:u.definition(u.propertyName),class:"tok-propertyName tok-definition"},{tag:u.typeName,class:"tok-typeName"},{tag:u.namespace,class:"tok-namespace"},{tag:u.className,class:"tok-className"},{tag:u.macroName,class:"tok-macroName"},{tag:u.propertyName,class:"tok-propertyName"},{tag:u.operator,class:"tok-operator"},{tag:u.comment,class:"tok-comment"},{tag:u.meta,class:"tok-meta"},{tag:u.invalid,class:"tok-invalid"},{tag:u.punctuation,class:"tok-punctuation"}]);var jo,St=new Z;function Ri(i){return z.define({combine:i?e=>e.concat(i):void 0})}var Yr=new Z,fe=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,I.prototype.hasOwnProperty("tree")||Object.defineProperty(I.prototype,"tree",{get(){return G(this)}}),this.parser=t,this.extension=[zi.of(this),I.languageData.of((s,o,O)=>{let a=Kh(s,o,O),h=a.type.prop(St);if(!h)return[];let l=s.facet(h),c=a.type.prop(Yr);if(c){let f=a.resolve(o-a.from,O);for(let d of c)if(d.test(f,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(l)}}return l})].concat(n)}isActiveAt(e,t,n=-1){return Kh(e,t,n).type.prop(St)==this.data}findRegions(e){let t=e.facet(zi);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(St)==this.data){n.push({from:o,to:o+s.length});return}let O=s.prop(Z.mounted);if(O){if(O.tree.prop(St)==this.data){if(O.overlay)for(let a of O.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+s.length});return}else if(O.overlay){let a=n.length;if(r(O.tree,O.overlay[0].from+o),n.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof q&&r(h,s.positions[a]+o)}};return r(G(e),0),n}get allowsNesting(){return!0}};fe.setState=D.define();function Kh(i,e,t){let n=i.facet(zi),r=G(i).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(e,t,L.ExcludeBuffers))s.type.isTop&&(r=s);return r}var ue=class i extends fe{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=Ri(e.languageData);return new i(t,e.parser.configure({props:[St.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new i(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function G(i){let e=i.field(fe.state,!1);return e?e.tree:q.empty}var Lo=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},mn=null,ri=class i{constructor(e,t,n=[],r,s,o,O,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=O,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new i(e,t,[],q.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Lo(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=q.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Qt.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Qt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=mn;mn=this;try{return e()}finally{mn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Jh(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:O}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,l,c,f)=>a.push({fromA:h,toA:l,fromB:c,toB:f})),n=Qt.applyChanges(n,a),r=q.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){O=[];for(let h of this.skipped){let l=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);l<c&&O.push({from:l,to:c})}}}return new i(this.parser,t,n,r,s,o,O,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:r,to:s}=this.skipped[n];r<e.to&&s>e.from&&(this.fragments=Jh(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends yt{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=mn;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new q(ie.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return mn}};function Jh(i,e,t){return Qt.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}var gn=class i{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new i(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=ri.create(e.facet(zi).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new i(n)}};fe.state=ge.define({create:gn.init,update(i,e){for(let t of e.effects)if(t.is(fe.setState))return t.value;return e.startState.facet(zi)!=e.state.facet(zi)?gn.init(e.state):i.apply(e)}});var rc=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(rc=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Eo=typeof navigator<"u"&&(!((jo=navigator.scheduling)===null||jo===void 0)&&jo.isInputPending)?()=>navigator.scheduling.isInputPending():null,tg=Ge.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(fe.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(fe.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=rc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(fe.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Eo?Math.max(25,e.timeRemaining()-5):1e9),O=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>Eo&&Eo()||Date.now()>o,r+(O?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:fe.setState.of(new gn(s.context))})),this.chunkBudget>0&&!(a&&!O)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Me(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),zi=z.define({combine(i){return i.length?i[0]:null},enables:i=>[fe.state,tg,w.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]}),Oe=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},$n=class i{constructor(e,t,n,r,s,o=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:n}=e;if(!t){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(n)}return new i(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,t,n)}static matchFilename(e,t){for(let r of e)if(r.filename&&r.filename.test(t))return r;let n=/\.([^.]+)$/.exec(t);if(n){for(let r of e)if(r.extensions.indexOf(n[1])>-1)return r}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let r of e)if(r.alias.some(s=>s==t))return r;if(n)for(let r of e)for(let s of r.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return r}return null}},sc=z.define(),Yt=z.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Ct(i){let e=i.facet(Yt);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function yn(i,e){let t="",n=i.tabSize,r=i.facet(Yt)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s<e;s++)t+=r;return t}function Ko(i,e){i instanceof I&&(i=new si(i));for(let n of i.state.facet(sc)){let r=n(i,e);if(r!==void 0)return r}let t=G(i.state);return t.length>=e?ig(i,t,e):null}var si=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ct(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return we(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},ye=new Z;function ig(i,e,t){let n=e.resolveStack(t),r=n.node.enterUnfinishedNodesBefore(t);if(r!=n.node){let s=[];for(let o=r;o!=n.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return oc(n,i,t)}function oc(i,e,t){for(let n=i;n;n=n.next){let r=rg(n.node);if(r)return r(Do.create(e,t,n))}return 0}function ng(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function rg(i){let e=i.type.prop(ye);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(Z.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>Oc(o,!0,1,void 0,s&&!ng(o)?r.from:void 0)}return i.parent==null?sg:null}function sg(){return 0}var Do=class i extends si{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new i(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(og(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return oc(this.context.next,this.base,this.pos)}};function og(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function Og(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let O=t.to;;){let a=e.childAfter(O);if(!a||a==n)return null;if(!a.type.isSkipped)return a.from<o?t:null;O=a.to}}function Ur({closing:i,align:e=!0,units:t=1}){return n=>Oc(n,e,t,i)}function Oc(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,O=n&&s.slice(o,o+n.length)==n||r==i.pos+o,a=e?Og(i):null;return a?O?i.column(a.from):i.column(a.to):i.baseIndent+(O?0:i.unit*t)}var ac=i=>i.baseIndent;function qe({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}var lc=z.define(),Se=new Z;function Ut(i){let e=i.firstChild,t=i.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?i.to:t.from}:null}var Pt=class i{constructor(e,t){this.specs=e;let n;function r(O){let a=je.newName();return(n||(n=Object.create(null)))["."+a]=O,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof fe?O=>O.prop(St)==o.data:o?O=>O==o:void 0,this.style=_o(e.map(O=>({tag:O.tag,class:O.class||r(Object.assign({},O,{tag:null}))})),{all:s}).style,this.module=n?new je(n):null,this.themeType=t.themeType}static define(e,t){return new i(e,t||{})}},Io=z.define(),hc=z.define({combine(i){return i.length?[i[0]]:null}});function Mo(i){let e=i.facet(Io);return e.length?e:i.facet(hc)}function Jo(i,e){let t=[ag],n;return i instanceof Pt&&(i.module&&t.push(w.styleModule.of(i.module)),n=i.themeType),e?.fallback?t.push(hc.of(i)):n?t.push(Io.computeN([w.darkTheme],r=>r.facet(w.darkTheme)==(n=="dark")?[i]:[])):t.push(Io.of(i)),t}var No=class{constructor(e){this.markCache=Object.create(null),this.tree=G(e.state),this.decorations=this.buildDeco(e,Mo(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=G(e.state),n=Mo(e.state),r=n!=Mo(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return j.none;let n=new Ft;for(let{from:r,to:s}of e.visibleRanges)Hh(this.tree,t,(o,O,a)=>{n.add(o,O,this.markCache[a]||(this.markCache[a]=j.mark({class:a})))},r,s);return n.finish()}},ag=nt.high(Ge.fromClass(No,{decorations:i=>i.decorations})),FP=Pt.define([{tag:u.meta,color:"#404740"},{tag:u.link,textDecoration:"underline"},{tag:u.heading,textDecoration:"underline",fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strong,fontWeight:"bold"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.keyword,color:"#708"},{tag:[u.atom,u.bool,u.url,u.contentSeparator,u.labelName],color:"#219"},{tag:[u.literal,u.inserted],color:"#164"},{tag:[u.string,u.deleted],color:"#a11"},{tag:[u.regexp,u.escape,u.special(u.string)],color:"#e40"},{tag:u.definition(u.variableName),color:"#00f"},{tag:u.local(u.variableName),color:"#30a"},{tag:[u.typeName,u.namespace],color:"#085"},{tag:u.className,color:"#167"},{tag:[u.special(u.variableName),u.macroName],color:"#256"},{tag:u.definition(u.propertyName),color:"#00c"},{tag:u.comment,color:"#940"},{tag:u.invalid,color:"#f00"}]),lg=w.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),cc=1e4,fc="()[]{}",uc=z.define({combine(i){return kt(i,{afterCursor:!0,brackets:fc,maxScanDistance:cc,renderMatch:fg})}}),hg=j.mark({class:"cm-matchingBracket"}),cg=j.mark({class:"cm-nonmatchingBracket"});function fg(i){let e=[],t=i.matched?hg:cg;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}var ug=ge.define({create(){return j.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(uc);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=Ke(e.state,r.head,-1,n)||r.head>0&&Ke(e.state,r.head-1,1,n)||n.afterCursor&&(Ke(e.state,r.head,1,n)||r.head<e.state.doc.length&&Ke(e.state,r.head+1,-1,n));s&&(t=t.concat(n.renderMatch(s,e.state)))}return j.set(t,!0)},provide:i=>w.decorations.from(i)}),dg=[ug,lg];function dc(i={}){return[uc.of(i),dg]}var Sn=new Z;function Bo(i,e,t){let n=i.prop(e<0?Z.openedBy:Z.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function Fo(i){let e=i.type.prop(Sn);return e?e(i.node):i}function Ke(i,e,t,n={}){let r=n.maxScanDistance||cc,s=n.brackets||fc,o=G(i),O=o.resolveInner(e,t);for(let a=O;a;a=a.parent){let h=Bo(a.type,t,s);if(h&&a.from<a.to){let l=Fo(a);if(l&&(t>0?e>=l.from&&e<l.to:e>l.from&&e<=l.to))return pg(i,e,t,a,l,h,s)}}return mg(i,e,t,o,O.type,r,s)}function pg(i,e,t,n,r,s,o){let O=n.parent,a={from:r.from,to:r.to},h=0,l=O?.cursor();if(l&&(t<0?l.childBefore(n.from):l.childAfter(n.to)))do if(t<0?l.to<=n.from:l.from>=n.to){if(h==0&&s.indexOf(l.type.name)>-1&&l.from<l.to){let c=Fo(l);return{start:a,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(Bo(l.type,t,o))h++;else if(Bo(l.type,-t,o)){if(h==0){let c=Fo(l);return{start:a,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(t<0?l.prevSibling():l.nextSibling());return{start:a,matched:!1}}function mg(i,e,t,n,r,s,o){let O=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(O);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},l=i.doc.iterRange(e,t>0?i.doc.length:0),c=0;for(let f=0;!l.next().done&&f<=s;){let d=l.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let $=o.indexOf(d[m]);if(!($<0||n.resolveInner(p+m,1).type!=r))if($%2==0==t>0)c++;else{if(c==1)return{start:h,end:{from:p+m,to:p+m+1},matched:$>>1==a>>1};c--}}t>0&&(f+=d.length)}return l.done?{start:h,matched:!1}:null}function ec(i,e,t,n=0,r=0){e==null&&(e=i.search(/[^\s\u00a0]/),e==-1&&(e=i.length));let s=r;for(let o=n;o<e;o++)i.charCodeAt(o)==9?s+=t-s%t:s++;return s}var Vr=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ec(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:ec(this.string,null,this.tabSize)}match(e,t,n){if(typeof e=="string"){let r=o=>n?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return r(s)==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}};function gg(i){return{name:i.name||"",token:i.token,blankLine:i.blankLine||(()=>{}),startState:i.startState||(()=>!0),copyState:i.copyState||$g,indent:i.indent||(()=>null),languageData:i.languageData||{},tokenTable:i.tokenTable||tO}}function $g(i){if(typeof i!="object")return i;let e={};for(let t in i){let n=i[t];e[t]=n instanceof Array?n.slice():n}return e}var tc=new WeakMap,qr=class i extends fe{constructor(e){let t=Ri(e.languageData),n=gg(e),r,s=new class extends yt{createParse(o,O,a){return new Ho(r,o,O,a)}};super(t,s,[sc.of((o,O)=>this.getIndent(o,O))],e.name),this.topNode=Pg(t),r=this,this.streamParser=n,this.stateAfter=new Z({perNode:!0}),this.tokenTable=e.tokenTable?new Cr(n.tokenTable):Sg}static define(e){return new i(e)}getIndent(e,t){let n=G(e.state),r=n.resolve(t);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let s,{overrideIndentation:o}=e.options;o&&(s=tc.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let O=eO(this,n,0,r.from,s??t),a,h;if(O?(h=O.state,a=O.pos+1):(h=this.streamParser.startState(e.unit),a=0),t-a>1e4)return null;for(;a<t;){let c=e.state.doc.lineAt(a),f=Math.min(t,c.to);if(c.length){let d=o?o(c.from):-1,p=new Vr(c.text,e.state.tabSize,e.unit,d<0?void 0:d);for(;p.pos<f-c.from;)mc(this.streamParser.token,p,h)}else this.streamParser.blankLine(h,e.unit);if(f==t)break;a=c.to+1}let l=e.lineAt(t);return o&&s==null&&tc.set(e.state,l.from),this.streamParser.indent(h,/^\s*(.*)/.exec(l.text)[1],e)}get allowsNesting(){return!1}};function eO(i,e,t,n,r){let s=t>=n&&t+e.length<=r&&e.prop(i.stateAfter);if(s)return{state:i.streamParser.copyState(s),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let O=e.children[o],a=t+e.positions[o],h=O instanceof q&&a<r&&eO(i,O,a,n,r);if(h)return h}return null}function pc(i,e,t,n,r){if(r&&t<=0&&n>=e.length)return e;!r&&e.type==i.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],O=e.children[s],a;if(o<n&&O instanceof q){if(!(a=pc(i,O,t-o,n-o,r)))break;return r?new q(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function Qg(i,e,t,n){for(let r of e){let s=r.from+(r.openStart?25:0),o=r.to-(r.openEnd?25:0),O=s<=t&&o>t&&eO(i,r.tree,0-r.offset,t,o),a;if(O&&(a=pc(i,r.tree,t+r.offset,O.pos+r.offset,!1)))return{state:O.state,tree:a}}return{state:i.streamParser.startState(n?Ct(n):4),tree:q.empty}}var Ho=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let s=ri.get(),o=r[0].from,{state:O,tree:a}=Qg(e,n,o,s?.state);this.state=O,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(Ct(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=ri.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+2048);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
+`){[e,t]=$i(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let O=this.children[s],a=o+O.length;o>e&&s&&(r+=n),e<a&&t>o&&(r+=O.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i))return 0;let n=0,[r,s,o,O]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==O)return n;let a=this.children[r],h=e.children[s];if(a!=h)return n+a.scanIdentical(h,t);n+=a.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new Xe(d,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,O=[],a=0,h=-1,l=[];function c(d){let p;if(d.lines>s&&d instanceof i)for(let m of d.children)c(m);else d.lines>o&&(a>o||!a)?(f(),O.push(d)):d instanceof Xe&&a&&(p=l[l.length-1])instanceof Xe&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,l[l.length-1]=new Xe(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&f(),a+=d.lines,h+=d.length+1,l.push(d))}function f(){a!=0&&(O.push(l.length==1?l[0]:i.from(l,h)),h=-1,a=l.length=0)}for(let d of e)c(d);return f(),O.length==1?O[0]:new i(O,t)}};Y.empty=new Xe([""],0);function Md(i){let e=-1;for(let t of i)e+=t.length+1;return e}function _n(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s<i.length&&r<=n;s++){let O=i[s],a=r+O.length;a>=t&&(a>n&&(O=O.slice(0,n-r)),r<t&&(O=O.slice(t-r)),o?(e[e.length-1]+=O,o=!1):e.push(O)),r=a+1}return e}function va(i,e,t){return _n(i,[""],e,t)}var Bt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Xe?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,O=r instanceof Xe?r.text.length:r.children.length;if(o==(t>0?O:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
+`,this;e--}else if(r instanceof Xe){let a=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof Xe?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},jn=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Bt(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},En=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},Bt.prototype[Symbol.iterator]=jn.prototype[Symbol.iterator]=En.prototype[Symbol.iterator]=function(){return this});var ls=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function $i(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}var di="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(i=>i?parseInt(i,36):1);for(let i=1;i<di.length;i++)di[i]+=di[i-1];function Gd(i){for(let e=1;e<di.length;e+=2)if(di[e]>i)return di[e-1]<=i;return!1}function za(i){return i>=127462&&i<=127487}var Wa=8205;function le(i,e,t=!0,n=!0){return(t?Ca:Ld)(i,e,n)}function Ca(i,e,t){if(e==i.length)return e;e&&Ya(i.charCodeAt(e))&&Ua(i.charCodeAt(e-1))&&e--;let n=pi(i,e);for(e+=Mi(n);e<i.length;){let r=pi(i,e);if(n==Wa||r==Wa||t&&Gd(r))e+=Mi(r),n=r;else if(za(r)){let s=0,o=e-2;for(;o>=0&&za(pi(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Ld(i,e,t){for(;e>0;){let n=Ca(i,e-2,t);if(n<e)return n;e--}return 0}function Ya(i){return i>=56320&&i<57344}function Ua(i){return i>=55296&&i<56320}function pi(i,e){let t=i.charCodeAt(e);if(!Ua(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Ya(n)?(t-55296<<10)+(n-56320)+65536:t}function Mi(i){return i<65536?1:2}var hs=/\r\n?|\n/,ae=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(ae||(ae={})),pt=class i{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,s),r+=s):r+=o,n+=s}}iterChangedRanges(e,t=!1){cs(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new i(e)}composeDesc(e){return this.empty?e:e.empty?this:Aa(this,e)}mapDesc(e,t=!1){return e.empty?this:fs(this,e,t)}mapPos(e,t=-1,n=ae.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let O=this.sections[o++],a=this.sections[o++],h=r+O;if(a<0){if(h>e)return s+(e-r);s+=O}else{if(n!=ae.Simple&&h>=e&&(n==ae.TrackDel&&r<e&&h>e||n==ae.TrackBefore&&r<e||n==ae.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!O)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let s=this.sections[n++],o=this.sections[n++],O=r+s;if(o>=0&&r<=t&&O>=e)return r<e&&O>t?"cover":!0;r=O}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new i(e)}static create(e){return new i(e)}},me=class i extends pt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return cs(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return fs(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],O=t[r+1];if(O>=0){t[r]=O,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(Y.empty);n.push(o?e.slice(s,s+o):Y.empty)}s+=o}return new i(t,n)}compose(e){return this.empty?e:e.empty?this:Aa(this,e,!0)}map(e,t=!1){return e.empty?this:fs(this,e,t,!0)}iterChanges(e,t=!1){cs(this,e,t)}get desc(){return pt.create(this.sections)}filter(e){let t=[],n=[],r=[],s=new Nt(this);e:for(let o=0,O=0;;){let a=o==e.length?1e9:e[o++];for(;O<a||O==a&&s.len==0;){if(s.done)break e;let l=Math.min(s.len,a-O);ce(r,l,-1);let c=s.ins==-1?-1:s.off==0?s.ins:0;ce(t,l,c),c>0&&kt(n,t,s.text),s.forward(l),O+=l}let h=e[o++];for(;O<h;){if(s.done)break e;let l=Math.min(s.len,h-O);ce(t,l,-1),ce(r,l,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(l),O+=l}}return{changes:new i(t,n),filtered:pt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,O=null;function a(l=!1){if(!l&&!r.length)return;o<t&&ce(r,t-o,-1);let c=new i(r,s);O=O?O.compose(c.map(O)):c,r=[],s=[],o=0}function h(l){if(Array.isArray(l))for(let c of l)h(c);else if(l instanceof i){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),O=O?O.compose(l.map(O)):l}else{let{from:c,to:f=c,insert:d}=l;if(c>f||c<0||f>t)throw new RangeError(`Invalid change range ${c} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?Y.of(d.split(n||hs)):d:Y.empty,m=p.length;if(c==f&&m==0)return;c<o&&a(),c>o&&ce(r,c-o,-1),ce(r,f-c,m),kt(s,r,p),o=f}}return h(e),a(!O),O}static empty(e){return new i(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,O)=>O&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<r;)n.push(Y.empty);n[r]=Y.of(s.slice(1)),t.push(s[0],n[r].length)}}}return new i(t,n)}static createSet(e,t){return new i(e,t)}};function ce(i,e,t,n=!1){if(e==0&&t<=0)return;let r=i.length-2;r>=0&&t<=0&&t==i[r+1]?i[r]+=e:e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function kt(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(t);else{for(;i.length<n;)i.push(Y.empty);i.push(t)}}function cs(i,e,t){let n=i.inserted;for(let r=0,s=0,o=0;o<i.sections.length;){let O=i.sections[o++],a=i.sections[o++];if(a<0)r+=O,s+=O;else{let h=r,l=s,c=Y.empty;for(;h+=O,l+=a,a&&n&&(c=c.append(n[o-2>>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)O=i.sections[o++],a=i.sections[o++];e(r,h,s,l,c),r=h,s=l}}}function fs(i,e,t,n=!1){let r=[],s=n?[]:null,o=new Nt(i),O=new Nt(e);for(let a=-1;;)if(o.ins==-1&&O.ins==-1){let h=Math.min(o.len,O.len);ce(r,h,-1),o.forward(h),O.forward(h)}else if(O.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(O.len<o.len||O.len==o.len&&!t))){let h=O.len;for(ce(r,O.ins,-1);h;){let l=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=l&&(ce(r,0,o.ins),s&&kt(s,r,o.text),a=o.i),o.forward(l),h-=l}O.next()}else if(o.ins>=0){let h=0,l=o.len;for(;l;)if(O.ins==-1){let c=Math.min(l,O.len);h+=c,l-=c,O.forward(c)}else if(O.ins==0&&O.len<l)l-=O.len,O.next();else break;ce(r,h,a<o.i?o.ins:0),s&&a<o.i&&kt(s,r,o.text),a=o.i,o.forward(o.len-l)}else{if(o.done&&O.done)return s?me.createSet(r,s):pt.create(r);throw new Error("Mismatched change set lengths")}}function Aa(i,e,t=!1){let n=[],r=t?[]:null,s=new Nt(i),o=new Nt(e);for(let O=!1;;){if(s.done&&o.done)return r?me.createSet(n,r):pt.create(n);if(s.ins==0)ce(n,s.len,0,O),s.next();else if(o.len==0&&!o.done)ce(n,0,o.ins,O),r&&kt(r,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=n.length;if(s.ins==-1){let l=o.ins==-1?-1:o.off?0:o.ins;ce(n,a,l,O),r&&l&&kt(r,n,o.text)}else o.ins==-1?(ce(n,s.off?0:s.len,a,O),r&&kt(r,n,s.textBit(a))):(ce(n,s.off?0:s.len,o.off?0:o.ins,O),r&&!o.off&&kt(r,n,o.text));O=(s.ins>a||o.ins>=0&&o.len>a)&&(O||n.length>h),s.forward2(a),o.forward(a)}}}}var Nt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Y.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Y.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},fi=class i{constructor(e,t,n){this.from=e,this.to=t,this.flags=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 bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new i(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return S.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return S.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return S.range(e.anchor,e.head)}static create(e,t,n){return new i(e,t,n)}},S=class i{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:i.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new i([this.main],0)}addRange(e,t=!0){return i.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,i.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new i(e.ranges.map(t=>fi.fromJSON(t)),e.main)}static single(e,t=e){return new i([i.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=n:s.from<n)return i.normalized(e.slice(),t);n=s.to}return new i(e,t)}static cursor(e,t=0,n,r){return fi.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r){let s=(n??16777215)<<6|(r==null?7:Math.min(6,r));return t<e?fi.create(t,e,48|s):fi.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let O=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?i.range(a,O):i.range(O,a))}}return new i(e,t)}};function _a(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Ps=0,W=class i{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Ps++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new i(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:bs),!!e.static,e.enables)}of(e){return new mi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new mi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new mi(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function bs(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}var mi=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Ps++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,O=this.type==2,a=!1,h=!1,l=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?h=!0:((t=e[c.id])!==null&&t!==void 0?t:1)&1||l.push(e[c.id]);return{create(c){return c.values[o]=n(c),1},update(c,f){if(a&&f.docChanged||h&&(f.docChanged||f.selection)||us(c,l)){let d=n(c);if(O?!Ra(d,c.values[o],r):!r(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,f)=>{let d,p=f.config.address[s];if(p!=null){let m=Ln(f,p);if(this.dependencies.every(g=>g instanceof W?f.facet(g)===c.facet(g):g instanceof ge?f.field(g,!1)==c.field(g,!1):!0)||(O?Ra(d=n(c),m,r):r(d=n(c),m)))return c.values[o]=m,0}else d=n(c);return c.values[o]=d,1}}}};function Ra(i,e,t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!t(i[n],e[n]))return!1;return!0}function us(i,e){let t=!1;for(let n of e)Ei(i,n)&1&&(t=!0);return t}function Dd(i,e,t){let n=t.map(a=>i[a.id]),r=t.map(a=>a.type),s=n.filter(a=>!(a&1)),o=i[e.id]>>1;function O(a){let h=[];for(let l=0;l<n.length;l++){let c=Ln(a,n[l]);if(r[l]==2)for(let f of c)h.push(f);else h.push(c)}return e.combine(h)}return{create(a){for(let h of n)Ei(a,h);return a.values[o]=O(a),1},update(a,h){if(!us(a,s))return 0;let l=O(a);return e.compare(l,a.values[o])?0:(a.values[o]=l,1)},reconfigure(a,h){let l=us(a,n),c=h.config.facets[e.id],f=h.facet(e);if(c&&!l&&bs(t,c))return a.values[o]=f,0;let d=O(a);return e.compare(d,f)?(a.values[o]=f,0):(a.values[o]=d,1)}}}var Xa=W.define({static:!0}),ge=class i{constructor(e,t,n,r,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new i(Ps++,e.create,e.update,e.compare||((n,r)=>n===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Xa).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,Xa.of({field:this,create:e})]}get extension(){return this}},Dt={lowest:4,low:3,default:2,high:1,highest:0};function ji(i){return e=>new Mn(e,i)}var nt={highest:ji(Dt.highest),high:ji(Dt.high),default:ji(Dt.default),low:ji(Dt.low),lowest:ji(Dt.lowest)},Mn=class{constructor(e,t){this.inner=e,this.prec=t}},mt=class i{of(e){return new Gi(this,e)}reconfigure(e){return i.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Gi=class{constructor(e,t){this.compartment=e,this.inner=t}},Gn=class i{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let f of Id(e,t,o))f instanceof ge?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let O=Object.create(null),a=[],h=[];for(let f of r)O[f.id]=h.length<<1,h.push(d=>f.slot(d));let l=n?.config.facets;for(let f in s){let d=s[f],p=d[0].facet,m=l&&l[f]||[];if(d.every(g=>g.type==0))if(O[p.id]=a.length<<1|1,bs(m,d))a.push(n.facet(p));else{let g=p.combine(d.map($=>$.value));a.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of d)g.type==0?(O[g.id]=a.length<<1|1,a.push(g.value)):(O[g.id]=h.length<<1,h.push($=>g.dynamicSlot($)));O[p.id]=h.length<<1,h.push(g=>Dd(g,p,d))}}let c=h.map(f=>f(O));return new i(e,o,c,O,a,s)}};function Id(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,O){let a=r.get(o);if(a!=null){if(a<=O)return;let h=n[a].indexOf(o);h>-1&&n[a].splice(h,1),o instanceof Gi&&t.delete(o.compartment)}if(r.set(o,O),Array.isArray(o))for(let h of o)s(h,O);else if(o instanceof Gi){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,O)}else if(o instanceof Mn)s(o.inner,o.prec);else if(o instanceof ge)n[O].push(o),o.provides&&s(o.provides,O);else if(o instanceof mi)n[O].push(o),o.facet.extensions&&s(o.facet.extensions,Dt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,O)}}return s(i,Dt.default),n.reduce((o,O)=>o.concat(O))}function Ei(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function Ln(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}var ja=W.define(),ds=W.define({combine:i=>i.some(e=>e),static:!0}),Ea=W.define({combine:i=>i.length?i[0]:void 0,static:!0}),Ma=W.define(),Ga=W.define(),La=W.define(),Da=W.define({combine:i=>i.length?i[0]:!1}),ke=class{constructor(e,t){this.type=e,this.value=t}static define(){return new ps}},ps=class{of(e){return new ke(this,e)}},ms=class{constructor(e){this.map=e}of(e){return new D(this,e)}},D=class i{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new i(this.type,t)}is(e){return this.type==e}static define(e={}){return new ms(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}};D.reconfigure=D.define();D.appendConfig=D.define();var ne=class i{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&_a(n,t.newLength),s.some(O=>O.type==i.time)||(this.annotations=s.concat(i.time.of(Date.now())))}static create(e,t,n,r,s,o){return new i(e,t,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(i.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};ne.time=ke.define();ne.userEvent=ke.define();ne.addToHistory=ke.define();ne.remote=ke.define();function Bd(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n<i.length&&(r==e.length||e[r]>=i[n]))s=i[n++],o=i[n++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Ia(i,e,t){var n;let r,s,o;return t?(r=e.changes,s=me.empty(e.changes.length),o=i.changes.compose(e.changes)):(r=e.changes.map(i.changes),s=i.changes.mapDesc(e.changes,!0),o=i.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(n=i.selection)===null||n===void 0?void 0:n.map(r),effects:D.mapEffects(i.effects,r).concat(D.mapEffects(e.effects,s)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function gs(i,e,t){let n=e.selection,r=gi(e.annotations);return e.userEvent&&(r=r.concat(ne.userEvent.of(e.userEvent))),{changes:e.changes instanceof me?e.changes:me.of(e.changes||[],t,i.facet(Ea)),selection:n&&(n instanceof S?n:S.single(n.anchor,n.head)),effects:gi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Ba(i,e,t){let n=gs(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;n=Ia(n,gs(i,e[s],o?n.changes.newLength:i.doc.length),o)}let r=ne.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Fd(t?Nd(r):r)}function Nd(i){let e=i.startState,t=!0;for(let r of e.facet(Ma)){let s=r(i);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:Bd(t,s))}if(t!==!0){let r,s;if(t===!1)s=i.changes.invertedDesc,r=me.empty(e.doc.length);else{let o=i.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}i=ne.create(e,r,i.selection&&i.selection.map(s),D.mapEffects(i.effects,s),i.annotations,i.scrollIntoView)}let n=e.facet(Ga);for(let r=n.length-1;r>=0;r--){let s=n[r](i);s instanceof ne?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ne?i=s[0]:i=Ba(e,gi(s),!1)}return i}function Fd(i){let e=i.startState,t=e.facet(La),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=Ia(n,gs(e,s,i.changes.newLength),!0))}return n==i?i:ne.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}var Hd=[];function gi(i){return i==null?Hd:Array.isArray(i)?i:[i]}var _e=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(_e||(_e={})),Kd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,$s;try{$s=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Jd(i){if($s)return $s.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||Kd.test(t)))return!0}return!1}function ep(i){return e=>{if(!/\S/.test(e))return _e.Space;if(Jd(e))return _e.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return _e.Word;return _e.Other}}var I=class i{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let O=0;O<this.config.dynamicSlots.length;O++)Ei(this,O<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Ei(this,n),Ln(this,n)}update(...e){return Ba(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:r}=t;for(let O of e.effects)O.is(mt.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(O.value.compartment,O.value.extension)):O.is(D.reconfigure)?(t=null,n=O.value):O.is(D.appendConfig)&&(t=null,n=gi(n).concat(O.value));let s;t?s=e.startState.values.slice():(t=Gn.resolve(n,r,this),s=new i(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(ds)?e.newSelection:e.newSelection.asSingle();new i(t,e.newDoc,o,s,(O,a)=>a.update(O,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:S.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=gi(n.effects);for(let O=1;O<t.ranges.length;O++){let a=e(t.ranges[O]),h=this.changes(a.changes),l=h.map(r);for(let f=0;f<O;f++)s[f]=s[f].map(l);let c=r.mapDesc(h,!0);s.push(a.range.map(c)),r=r.compose(l),o=D.mapEffects(o,l).concat(D.mapEffects(gi(a.effects),c))}return{changes:r,selection:S.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof me?e:me.of(e,this.doc.length,this.facet(i.lineSeparator))}toText(e){return Y.of(e.split(this.facet(i.lineSeparator)||hs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ei(this,t),Ln(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof ge&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let o=n[s],O=e[s];r.push(o.init(a=>o.spec.fromJSON(O,a)))}}return i.create({doc:e.doc,selection:S.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Gn.resolve(e.extensions||[],new Map),n=e.doc instanceof Y?e.doc:Y.of((e.doc||"").split(t.staticFacet(i.lineSeparator)||hs)),r=e.selection?e.selection instanceof S?e.selection:S.single(e.selection.anchor,e.selection.head):S.single(0);return _a(r,n.length),t.staticFacet(ds)||(r=r.asSingle()),new i(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(i.tabSize)}get lineBreak(){return this.facet(i.lineSeparator)||`
+`}get readOnly(){return this.facet(Da)}phrase(e,...t){for(let n of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(ja))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return ep(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,O=e-n;for(;o>0;){let a=le(t,o,!1);if(s(t.slice(a,o))!=_e.Word)break;o=a}for(;O<r;){let a=le(t,O);if(s(t.slice(O,a))!=_e.Word)break;O=a}return o==O?null:S.range(o+n,O+n)}};I.allowMultipleSelections=ds;I.tabSize=W.define({combine:i=>i.length?i[0]:4});I.lineSeparator=Ea;I.readOnly=Da;I.phrases=W.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});I.languageData=ja;I.changeFilter=Ma;I.transactionFilter=Ga;I.transactionExtender=La;mt.reconfigure=D.define();function wt(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],O=n[s];if(O===void 0)n[s]=o;else if(!(O===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](O,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var Ne=class{eq(e){return this==e}range(e,t=e){return Li.create(e,t,this)}};Ne.prototype.startSide=Ne.prototype.endSide=0;Ne.prototype.point=!1;Ne.prototype.mapMode=ae.TrackDel;var Li=class i{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new i(e,t,n)}};function Qs(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var Ss=class i{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,O=s.length;;){if(o==O)return o;let a=o+O>>1,h=s[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:O;h>=0?O=a:o=a+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],r=[],s=[],o=-1,O=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],l=this.from[a]+e,c=this.to[a]+e,f,d;if(l==c){let p=t.mapPos(l,h.startSide,h.mapMode);if(p==null||(f=d=p,h.startSide!=h.endSide&&(d=t.mapPos(l,h.endSide),d<f)))continue}else if(f=t.mapPos(l,h.startSide),d=t.mapPos(c,h.endSide),f>d||f==d&&h.startSide>0&&h.endSide<=0)continue;(d-f||h.endSide-h.startSide)<0||(o<0&&(o=f),h.point&&(O=Math.max(O,d-f)),n.push(h),r.push(f-o),s.push(d-o))}return{mapped:n.length?new i(r,s,n,O):null,pos:o}}},F=class i{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new i(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(Qs)),this.isEmpty)return t.length?i.of(t):this;let O=new Dn(this,null,-1).goto(0),a=0,h=[],l=new Ft;for(;O.value||a<t.length;)if(a<t.length&&(O.from-t[a].from||O.startSide-t[a].value.startSide)>=0){let c=t[a++];l.addInner(c.from,c.to,c.value)||h.push(c)}else O.rangeIndex==1&&O.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(O.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(O.chunkIndex)||s<this.chunkPos[O.chunkIndex])&&l.addChunk(this.chunkPos[O.chunkIndex],this.chunk[O.chunkIndex])?O.nextChunk():((!o||r>O.to||s<O.from||o(O.from,O.to,O.value))&&(l.addInner(O.from,O.to,O.value)||h.push(Li.create(O.from,O.to,O.value))),O.next());return l.finishInner(this.nextLayer.isEmpty&&!h.length?i.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let o=0;o<this.chunk.length;o++){let O=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(O,O+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),n.push(e.mapPos(O));else if(h===!0){let{mapped:l,pos:c}=a.map(O,e);l&&(r=Math.max(r,l.maxPoint),t.push(l),n.push(c))}}let s=this.nextLayer.map(e);return t.length==0?s:new i(n,t,s||i.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Di.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Di.from(e).goto(t)}static compare(e,t,n,r,s=-1){let o=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),O=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),a=Za(o,O,n),h=new It(o,a,s),l=new It(O,a,s);n.iterGaps((c,f,d)=>qa(h,c,l,f,d,r)),n.empty&&n.length==0&&qa(h,0,l,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=999999999);let s=e.filter(l=>!l.isEmpty&&t.indexOf(l)<0),o=t.filter(l=>!l.isEmpty&&e.indexOf(l)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let O=Za(s,o),a=new It(s,O,0).goto(n),h=new It(o,O,0).goto(n);for(;;){if(a.to!=h.to||!ys(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,n,r,s=-1){let o=new It(e,null,s).goto(t),O=t,a=o.openStart;for(;;){let h=Math.min(o.to,n);if(o.point){let l=o.activeForPoint(o.to),c=o.pointFrom<t?l.length+1:o.point.startSide<0?l.length:Math.min(l.length,a);r.point(O,h,o.point,l,c,o.pointRank),a=Math.min(o.openEnd(h),l.length)}else h>O&&(r.span(O,h,o.active,a),a=o.openEnd(h));if(o.to>n)return a+(o.point&&o.to>n?1:0);O=o.to,o.next()}}static of(e,t=!1){let n=new Ft;for(let r of e instanceof Li?[e]:t?tp(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return i.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=i.empty;r=r.nextLayer)t=new i(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};F.empty=new F([],[],null,-1);function tp(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if(Qs(e,n)>0)return i.slice().sort(Qs);e=n}return i}F.empty.nextLayer=F.empty;var Ft=class i{finishChunk(e){this.chunks.push(new Ss(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new i)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(F.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=F.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Za(i,e,t){let n=new Map;for(let s of i)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let O=n.get(s.chunk[o]);O!=null&&(t?t.mapPos(O):O)==s.chunkPos[o]&&!t?.touchesRange(O,O+s.chunk[o].length)&&r.add(s.chunk[o])}return r}var Dn=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Di=class i{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new Dn(o,t,n,s));return r.length==1?r[0]:new i(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)as(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)as(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),as(this.heap,0)}}};function as(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1<i.length&&r.compare(i[n+1])>=0&&(r=i[n+1],n++),t.compare(r)<0)break;i[n]=t,i[e]=r,e=n}}var It=class{constructor(e,t,n){this.minPoint=n,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=Di.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Un(this.active,e),Un(this.activeTo,e),Un(this.activeRank,e),this.minActive=Va(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;An(this.active,t,n),An(this.activeTo,t,r),An(this.activeRank,t,s),e&&An(e,t,this.cursor.from),this.minActive=Va(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Un(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let r=n.length-1;r>=0&&n[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function qa(i,e,t,n,r,s){i.goto(e),t.goto(n);let o=n+r,O=n,a=n-e;for(;;){let h=i.to+a-t.to||i.endSide-t.endSide,l=h<0?i.to+a:t.to,c=Math.min(l,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&ys(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(O,c,i.point,t.point):c>O&&!ys(i.active,t.active)&&s.compareRange(O,c,i.active,t.active),l>o)break;O=l,h<=0&&i.next(),h>=0&&t.next()}}function ys(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!=e[t]&&!i[t].eq(e[t]))return!1;return!0}function Un(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function An(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function Va(i,e){let t=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||i[r].endSide-i[t].endSide)<0&&(t=r,n=e[r]);return t}function we(i,e,t=i.length){let n=0;for(let r=0;r<t;)i.charCodeAt(r)==9?(n+=e-n%e,r++):(n++,r=le(i,r));return n}function In(i,e,t,n){for(let r=0,s=0;;){if(s>=e)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?t-s%t:1,r=le(i,r)}return n===!0?-1:i.length}var xs="\u037C",Na=typeof Symbol>"u"?"__"+xs:Symbol.for(xs),ks=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Fa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},je=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,O,a,h){let l=[],c=/^@(\w+)\b/.exec(o[0]),f=c&&c[1]=="keyframes";if(c&&O==null)return a.push(o[0]+";");for(let d in O){let p=O[d];if(/&/.test(d))s(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(!c)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,l,f)}else p!=null&&l.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(l.length||f)&&a.push((n&&!c&&!h?o.map(n):o).join(", ")+" {"+l.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
+`)}static newName(){let e=Fa[Na]||1;return Fa[Na]=e+1,xs+e.toString(36)}static mount(e,t,n){let r=e[ks],s=n&&n.nonce;r?s&&r.setNonce(s):r=new ws(e,s),r.mount(Array.isArray(t)?t:[t],e)}},Ha=new Map,ws=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Ha.get(n);if(s)return e[ks]=s;this.sheet=new r.CSSStyleSheet,Ha.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[ks]=this}mount(e,t){let n=this.sheet,r=0,s=0;for(let o=0;o<e.length;o++){let O=e[o],a=this.modules.indexOf(O);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,O),n)for(let h=0;h<O.rules.length;h++)n.insertRule(O.rules[h],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=O.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
+`;this.styleTag.textContent=o;let O=t.head||t;this.styleTag.parentNode!=O&&O.insertBefore(this.styleTag,O.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var gt={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:"'"},Qi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ip=typeof navigator<"u"&&/Mac/.test(navigator.platform),np=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(re=0;re<10;re++)gt[48+re]=gt[96+re]=String(re);var re;for(re=1;re<=24;re++)gt[re+111]="F"+re;var re;for(re=65;re<=90;re++)gt[re]=String.fromCharCode(re+32),Qi[re]=String.fromCharCode(re);var re;for(Bn in gt)Qi.hasOwnProperty(Bn)||(Qi[Bn]=gt[Bn]);var Bn;function Ka(i){var e=ip&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||np&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?Qi:gt)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function sn(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function Xs(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function nr(i,e){if(!e.anchorNode)return!1;try{return Xs(i,e.anchorNode)}catch{return!1}}function on(i){return i.nodeType==3?Jt(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Ki(i,e,t,n){return t?Ja(i,e,t,n,-1)||Ja(i,e,t,n,1):!1}function Kt(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function lr(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function Ja(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:at(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=Kt(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?at(i):0}else return!1}}function at(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function Pr(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function rp(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function Vl(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function sp(i,e,t,n,r,s,o,O){let a=i.ownerDocument,h=a.defaultView||window;for(let l=i,c=!1;l&&!c;)if(l.nodeType==1){let f,d=l==a.body,p=1,m=1;if(d)f=rp(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(l).position)&&(c=!0),l.scrollHeight<=l.clientHeight&&l.scrollWidth<=l.clientWidth){l=l.assignedSlot||l.parentNode;continue}let Q=l.getBoundingClientRect();({scaleX:p,scaleY:m}=Vl(l,Q)),f={left:Q.left,right:Q.left+l.clientWidth*p,top:Q.top,bottom:Q.top+l.clientHeight*m}}let g=0,$=0;if(r=="nearest")e.top<f.top?($=-(f.top-e.top+o),t>0&&e.bottom>f.bottom+$&&($=e.bottom-f.bottom+$+o)):e.bottom>f.bottom&&($=e.bottom-f.bottom+o,t<0&&e.top-$<f.top&&($=-(f.top+$-e.top+o)));else{let Q=e.bottom-e.top,b=f.bottom-f.top;$=(r=="center"&&Q<=b?e.top+Q/2-b/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-b+o)-f.top}if(n=="nearest"?e.left<f.left?(g=-(f.left-e.left+s),t>0&&e.right>f.right+g&&(g=e.right-f.right+g+s)):e.right>f.right&&(g=e.right-f.right+s,t<0&&e.left<f.left+g&&(g=-(f.left+g-e.left+s))):g=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==O?e.left-s:e.right-(f.right-f.left)+s)-f.left,g||$)if(d)h.scrollBy(g,$);else{let Q=0,b=0;if($){let k=l.scrollTop;l.scrollTop+=$/m,b=(l.scrollTop-k)*m}if(g){let k=l.scrollLeft;l.scrollLeft+=g/p,Q=(l.scrollLeft-k)*p}e={left:e.left-Q,top:e.top-b,right:e.right-Q,bottom:e.bottom-b},Q&&Math.abs(Q-g)<1&&(n="nearest"),b&&Math.abs(b-$)<1&&(r="nearest")}if(d)break;l=l.assignedSlot||l.parentNode}else if(l.nodeType==11)l=l.host;else break}function op(i){let e=i.ownerDocument,t,n;for(let r=i.parentNode;r&&!(r==e.body||t&&n);)if(r.nodeType==1)!n&&r.scrollHeight>r.clientHeight&&(n=r),!t&&r.scrollWidth>r.clientWidth&&(t=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:t,y:n}}var Zs=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?at(t):0),n,Math.min(e.focusOffset,n?at(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},Si=null;function Cl(i){if(i.setActive)return i.setActive();if(Si)return i.focus(Si);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Si==null?{get preventScroll(){return Si={preventScroll:!0},!0}}:void 0),!Si){Si=!1;for(let t=0;t<e.length;){let n=e[t++],r=e[t++],s=e[t++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=s&&(n.scrollLeft=s)}}}var el;function Jt(i,e,t=e){let n=el||(el=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function bi(i,e,t,n){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,i.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,i.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Op(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function Yl(i){for(;i.attributes.length;)i.removeAttributeNode(i.attributes[0])}function ap(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,at(t));;)if(n){if(t.nodeType!=1)return!1;let r=t.childNodes[n-1];r.contentEditable=="false"?n--:(t=r,n=at(t))}else{if(t==i)return!0;n=Kt(t),t=t.parentNode}}function Ul(i){return i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function Al(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=at(t)}else if(t.parentNode&&!lr(t))n=Kt(t),t=t.parentNode;else return null}}function _l(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!lr(t))n=Kt(t)+1,t=t.parentNode;else return null}}var $e=class i{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new i(e.parentNode,Kt(e),t)}static after(e,t){return new i(e.parentNode,Kt(e)+1,t)}},go=[],H=class i{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:n.firstChild)){let O=i.get(s);(!O||!O.parent&&O.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&s!=o.dom&&(t.written=!0),o.dom.parentNode==n)for(;s&&s!=o.dom;)s=tl(s);else n.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:n.firstChild,s&&t&&t.node==n&&(t.written=!0);s;)s=tl(s)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let r=at(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!i.get(n);)n=n.nextSibling;if(!n)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==n)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let r=-1,s=-1,o=-1,O=-1;for(let a=0,h=n,l=n;a<this.children.length;a++){let c=this.children[a],f=h+c.length;if(h<e&&f>t)return c.domBoundsAround(e,t,h);if(f>=e&&r==-1&&(r=a,s=h),h>t&&c.dom.parentNode==this.dom){o=a,O=l;break}l=f,h=f+c.breakAfter}return{from:s,to:O<0?n+this.length:O,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=go){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&n.indexOf(s)<0&&s.destroy()}n.length<250?this.children.splice(e,t-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(t));for(let r=0;r<n.length;r++)n[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new hr(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}};H.prototype.breakAfter=0;function tl(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}var hr=class{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function jl(i,e,t,n,r,s,o,O,a){let{children:h}=i,l=h.length?h[e]:null,c=s.length?s[s.length-1]:null,f=c?c.breakAfter:o;if(!(e==n&&l&&!o&&!f&&s.length<2&&l.merge(t,r,s.length?c:null,t==0,O,a))){if(n<h.length){let d=h[n];d&&(r<d.length||d.breakAfter&&c?.breakAfter)?(e==n&&(d=d.split(r),r=0),!f&&c&&d.merge(0,r,c,!0,0,a)?s[s.length-1]=d:((r||d.children.length&&!d.children[0].length)&&d.merge(0,r,null,!1,0,a),s.push(d))):d?.breakAfter&&(c?c.breakAfter=1:o=1),n++}for(l&&(l.breakAfter=o,t>0&&(!o&&s.length&&l.merge(t,l.length,s[0],!1,O,0)?l.breakAfter=s.shift().breakAfter:(t<l.length||l.children.length&&l.children[l.children.length-1].length==0)&&l.merge(t,l.length,null,!1,O,0),e++));e<n&&s.length;)if(h[n-1].become(s[s.length-1]))n--,s.pop(),a=s.length?0:O;else if(h[e].become(s[0]))e++,s.shift(),O=s.length?0:a;else break;!s.length&&e&&n<h.length&&!h[e-1].breakAfter&&h[n].merge(0,0,h[e-1],!1,O,a)&&e--,(e<n||s.length)&&i.replaceChildren(e,n,s)}}function El(i,e,t,n,r,s){let o=i.childCursor(),{i:O,off:a}=o.findPos(t,1),{i:h,off:l}=o.findPos(e,-1),c=e-t;for(let f of n)c+=f.length;i.length+=c,jl(i,h,l,O,a,n,0,r,s)}var Te=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},qs=typeof document<"u"?document:{documentElement:{style:{}}},Vs=/Edge\/(\d+)/.exec(Te.userAgent),Ml=/MSIE \d/.test(Te.userAgent),Cs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Te.userAgent),br=!!(Ml||Cs||Vs),il=!br&&/gecko\/(\d+)/i.test(Te.userAgent),Ts=!br&&/Chrome\/(\d+)/.exec(Te.userAgent),nl="webkitFontSmoothing"in qs.documentElement.style,Gl=!br&&/Apple Computer/.test(Te.vendor),rl=Gl&&(/Mobile\/\w+/.test(Te.userAgent)||Te.maxTouchPoints>2),z={mac:rl||/Mac/.test(Te.platform),windows:/Win/.test(Te.platform),linux:/Linux|X11/.test(Te.platform),ie:br,ie_version:Ml?qs.documentMode||6:Cs?+Cs[1]:Vs?+Vs[1]:0,gecko:il,gecko_version:il?+(/Firefox\/(\d+)/.exec(Te.userAgent)||[0,0])[1]:0,chrome:!!Ts,chrome_version:Ts?+Ts[1]:0,ios:rl,android:/Android\b/.test(Te.userAgent),webkit:nl,safari:Gl,webkit_version:nl?+(/\bAppleWebKit\/(\d+)/.exec(Te.userAgent)||[0,0])[1]:0,tabSize:qs.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},lp=256,lt=class i extends H{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof i)||this.length-(t-e)+n.length>lp||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new i(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new $e(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return hp(this.dom,e,t)}},Wt=class i extends H{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let r of t)r.setParent(this)}setAttrs(e){if(Yl(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,r,s,o){return n&&(!(n instanceof i&&n.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(El(this,e,t,n?n.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],n=0,r=-1,s=0;for(let O of this.children){let a=n+O.length;a>e&&t.push(n<e?O.split(e-n):O),r<0&&n>=e&&(r=s),n=a,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new i(this.mark,t,o)}domAtPos(e){return Ll(this,e)}coordsAt(e,t){return Il(this,e,t)}};function hp(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;e==0&&t<0||e==n&&t>=0?z.chrome||z.gecko||(e?(r--,o=1):s<n&&(s++,o=-1)):t<0?r--:s<n&&s++;let O=Jt(i,r,s).getClientRects();if(!O.length)return null;let a=O[(o?o<0:t>=0)?0:O.length-1];return z.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(O,h=>h.width)||a),o?Pr(a,o<0):a||null}var cr=class i extends H{static create(e,t,n){return new i(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=i.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,r,s,o){return n&&(!(n instanceof i)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof i&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Y.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,r=this.posAtStart;return n?n.slice(r,r+this.length):Y.empty}domAtPos(e){return(this.length?e==0:this.side>0)?$e.before(this.dom):$e.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let O=o?r.length-1:0;s=r[O],!(e>0?O==0:O==r.length-1||s.top<s.bottom);O+=o?-1:1);return Pr(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},On=class i extends H{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof i&&e.side==this.side}split(){return new i(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?$e.before(this.dom):$e.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Y.empty}get isHidden(){return!0}};lt.prototype.children=cr.prototype.children=On.prototype.children=go;function Ll(i,e){let t=i.dom,{children:n}=i,r=0;for(let s=0;r<n.length;r++){let o=n[r],O=s+o.length;if(!(O==s&&o.getSide()<=0)){if(e>s&&e<O&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=O}}for(let s=r;s>0;s--){let o=n[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s<n.length;s++){let o=n[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new $e(t,0)}function Dl(i,e,t){let n,{children:r}=i;t>0&&e instanceof Wt&&r.length&&(n=r[r.length-1])instanceof Wt&&n.mark.eq(e.mark)?Dl(n,e.children[0],t-1):(r.push(e),e.setParent(i)),i.length+=e.length}function Il(i,e,t){let n=null,r=-1,s=null,o=-1;function O(h,l){for(let c=0,f=0;c<h.children.length&&f<=l;c++){let d=h.children[c],p=f+d.length;p>=l&&(d.children.length?O(d,l-f):(!s||s.isHidden&&t>0)&&(p>l||f==p&&d.getSide()>0)?(s=d,o=l-f):(f<l||f==p&&d.getSide()<0&&!d.isHidden)&&(n=d,r=l-f)),f=p}}O(i,e);let a=(t<0?n:s)||n||s;return a?a.coordsAt(Math.max(0,a==n?r:o),t):cp(i)}function cp(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=on(e);return t[t.length-1]||null}function Ys(i,e){for(let t in i)t=="class"&&e.class?e.class+=" "+i.class:t=="style"&&e.style?e.style+=";"+i.style:e[t]=i[t];return e}var sl=Object.create(null);function fr(i,e,t){if(i==e)return!0;i||(i=sl),e||(e=sl);let n=Object.keys(i),r=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function Us(i,e,t){let n=!1;if(e)for(let r in e)t&&r in t||(n=!0,r=="style"?i.style.cssText="":i.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(n=!0,r=="style"?i.style.cssText=t[r]:i.setAttribute(r,t[r]));return n}function fp(i){let e=Object.create(null);for(let t=0;t<i.attributes.length;t++){let n=i.attributes[t];e[n.name]=n.value}return e}var Rt=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Qe=function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i}(Qe||(Qe={})),j=class extends Ne{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new an(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Xt(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=Bl(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Xt(e,n,r,t,e.widget||null,!0)}static line(e){return new ln(e)}static set(e,t=!1){return F.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};j.none=F.empty;var an=class i extends j{constructor(e){let{start:t,end:n}=Bl(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof i&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&fr(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};an.prototype.point=!1;var ln=class i extends j{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&this.spec.class==e.spec.class&&fr(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};ln.prototype.mapMode=ae.TrackBefore;ln.prototype.point=!0;var Xt=class i extends j{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?ae.TrackBefore:ae.TrackAfter:ae.TrackDel}get type(){return this.startSide!=this.endSide?Qe.WidgetRange:this.startSide<=0?Qe.WidgetBefore:Qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof i&&up(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Xt.prototype.point=!0;function Bl(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function up(i,e){return i==e||!!(i&&e&&i.compare(e))}function As(i,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=i?t[r]=Math.max(t[r],e):t.push(i,e)}var he=class i extends H{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,r,s,o){if(n){if(!(n instanceof i))return!1;this.dom||n.transferDOM(this)}return r&&this.setDeco(n?n.attrs:null),El(this,e,t,n?n.children.slice():[],s,o),!0}split(e){let t=new i;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:r}=this.childPos(e);r&&(t.append(this.children[n].split(r),0),this.children[n].merge(r,this.children[n].length,null,!1,0,0),n++);for(let s=n;s<this.children.length;s++)t.append(this.children[s],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){fr(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Dl(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Ys(t,this.attrs||{})),n&&(this.attrs=Ys({class:n},this.attrs||{}))}domAtPos(e){return Ll(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Yl(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Us(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&H.get(r)instanceof Wt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=H.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!z.ios||!this.children.some(s=>s instanceof lt))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof lt)||/[^ -~]/.test(n.text))return null;let r=on(n.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=Il(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:n.top+o,bottom:n.bottom-o,left:n.left,right:n.left}}}return n}become(e){return e instanceof i&&this.children.length==0&&e.children.length==0&&fr(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,r=0;n<e.children.length;n++){let s=e.children[n],o=r+s.length;if(o>=t){if(s instanceof i)return s;if(o>t)break}r=o+s.breakAfter}return null}},Ht=class i extends H{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,r,s,o){return n&&(!(n instanceof i)||!this.widget.compare(n.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?$e.before(this.dom):$e.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new i(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return go}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Y.empty}domBoundsAround(){return null}become(e){return e instanceof i&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof hn?null:Pr(this.dom.getBoundingClientRect(),this.length?e==0:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t==n?!1:e<0?t<0:n>0}},hn=class extends Rt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},Ji=class i{constructor(e,t,n,r){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Ht&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new he),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Nn(new On(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Ht)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:O}=this.cursor.next(this.skip);if(this.skip=0,O)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Nn(new lt(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}span(e,t,n,r){this.buildText(t-e,n,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,n,r,s,o){if(this.disallowBlockEffectsFor[o]&&n instanceof Xt){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let O=t-e;if(n instanceof Xt)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Ht(n.widget||Zt.block,O,n));else{let a=cr.create(n.widget||Zt.inline,O,O?0:n.startSide),h=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<t||n.startSide>0),l=!a.isEditable&&(e<t||s>r.length||n.startSide<=0),c=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),h&&(c.append(Nn(new On(1),r),s),s=r.length+Math.max(0,s-r.length)),c.append(Nn(a,r),s),this.atCursorPos=l,this.pendingBuffer=l?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);O&&(this.textOff+O<=this.text.length?this.textOff+=O:(this.skip+=O-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,n,r,s){let o=new i(e,t,n,s);return o.openEnd=F.spans(r,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function Nn(i,e){for(let t of e)i=new Wt(t,[i],i.length);return i}var Zt=class extends Rt{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Zt.inline=new Zt("span");Zt.block=new Zt("div");var J=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(J||(J={})),ei=J.LTR,$o=J.RTL;function Nl(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}var dp=Nl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),pp=Nl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),_s=Object.create(null),rt=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);_s[e]=t,_s[t]=-e}function Fl(i){return i<=247?dp[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?pp[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}var mp=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,ot=class{get dir(){return this.level%2?$o:ei}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let s=-1;for(let o=0;o<e.length;o++){let O=e[o];if(O.from<=t&&O.to>=t){if(O.level==n)return o;(s<0||(r!=0?r<0?O.from<t:O.to>t:e[s].level>O.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Hl(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++){let n=i[t],r=e[t];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!Hl(n.inner,r.inner))return!1}return!0}var N=[];function gp(i,e,t,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:e,O=s<n.length?n[s].from:t,a=s?256:r;for(let h=o,l=a,c=a;h<O;h++){let f=Fl(i.charCodeAt(h));f==512?f=l:f==8&&c==4&&(f=16),N[h]=f==4?2:f,f&7&&(c=f),l=f}for(let h=o,l=a,c=a;h<O;h++){let f=N[h];if(f==128)h<O-1&&l==N[h+1]&&l&24?f=N[h]=l:N[h]=256;else if(f==64){let d=h+1;for(;d<O&&N[d]==64;)d++;let p=h&&l==8||d<t&&N[d]==8?c==1?1:8:256;for(let m=h;m<d;m++)N[m]=p;h=d-1}else f==8&&c==1&&(N[h]=1);l=f,f&7&&(c=f)}}}function $p(i,e,t,n,r){let s=r==1?2:1;for(let o=0,O=0,a=0;o<=n.length;o++){let h=o?n[o-1].to:e,l=o<n.length?n[o].from:t;for(let c=h,f,d,p;c<l;c++)if(d=_s[f=i.charCodeAt(c)])if(d<0){for(let m=O-3;m>=0;m-=3)if(rt[m+1]==-d){let g=rt[m+2],$=g&2?r:g&4?g&1?s:r:0;$&&(N[c]=N[rt[m]]=$),O=m;break}}else{if(rt.length==189)break;rt[O++]=c,rt[O++]=f,rt[O++]=a}else if((p=N[c])==2||p==1){let m=p==r;a=m?0:1;for(let g=O-3;g>=0;g-=3){let $=rt[g+2];if($&2)break;if(m)rt[g+2]|=2;else{if($&4)break;rt[g+2]|=4}}}}}function Qp(i,e,t,n){for(let r=0,s=n;r<=t.length;r++){let o=r?t[r-1].to:i,O=r<t.length?t[r].from:e;for(let a=o;a<O;){let h=N[a];if(h==256){let l=a+1;for(;;)if(l==O){if(r==t.length)break;l=t[r++].to,O=r<t.length?t[r].from:e}else if(N[l]==256)l++;else break;let c=s==1,f=(l<e?N[l]:n)==1,d=c==f?c?1:2:n;for(let p=l,m=r,g=m?t[m-1].to:i;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:i),N[--p]=d;a=l}else s=h,a++}}}function js(i,e,t,n,r,s,o){let O=n%2?2:1;if(n%2==r%2)for(let a=e,h=0;a<t;){let l=!0,c=!1;if(h==s.length||a<s[h].from){let m=N[a];m!=O&&(l=!1,c=m==16)}let f=!l&&O==1?[]:null,d=l?n:n+1,p=a;e:for(;;)if(h<s.length&&p==s[h].from){if(c)break e;let m=s[h];if(!l)for(let g=m.to,$=h+1;;){if(g==t)break e;if($<s.length&&s[$].from==g)g=s[$++].to;else{if(N[g]==O)break e;break}}if(h++,f)f.push(m);else{m.from>a&&o.push(new ot(a,m.from,d));let g=m.direction==ei!=!(d%2);Es(i,g?n+1:n,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(l?N[p]!=O:N[p]==O))break;p++}f?js(i,a,p,n+1,r,f,o):a<p&&o.push(new ot(a,p,d)),a=p}else for(let a=t,h=s.length;a>e;){let l=!0,c=!1;if(!h||a>s[h-1].to){let m=N[a-1];m!=O&&(l=!1,c=m==16)}let f=!l&&O==1?[]:null,d=l?n:n+1,p=a;e:for(;;)if(h&&p==s[h-1].to){if(c)break e;let m=s[--h];if(!l)for(let g=m.from,$=h;;){if(g==e)break e;if($&&s[$-1].to==g)g=s[--$].from;else{if(N[g-1]==O)break e;break}}if(f)f.push(m);else{m.to<a&&o.push(new ot(m.to,a,d));let g=m.direction==ei!=!(d%2);Es(i,g?n+1:n,r,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(l?N[p-1]!=O:N[p-1]==O))break;p--}f?js(i,p,a,n+1,r,f,o):p<a&&o.push(new ot(p,a,d)),a=p}}function Es(i,e,t,n,r,s,o){let O=e%2?2:1;gp(i,r,s,n,O),$p(i,r,s,n,O),Qp(r,s,n,O),js(i,r,s,e,t,n,o)}function Sp(i,e,t){if(!i)return[new ot(0,0,e==$o?1:0)];if(e==ei&&!t.length&&!mp.test(i))return Kl(i.length);if(t.length)for(;i.length>N.length;)N[N.length]=256;let n=[],r=e==ei?0:1;return Es(i,r,r,t,0,i.length,n),n}function Kl(i){return[new ot(0,i,0)]}var Jl="";function yp(i,e,t,n,r){var s;let o=n.head-i.from,O=ot.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),a=e[O],h=a.side(r,t);if(o==h){let f=O+=r?1:-1;if(f<0||f>=e.length)return null;a=e[O=f],o=a.side(!r,t),h=a.side(r,t)}let l=le(i.text,o,a.forward(r,t));(l<a.from||l>a.to)&&(l=h),Jl=i.text.slice(Math.min(o,l),Math.max(o,l));let c=O==(r?e.length-1:0)?null:e[O+(r?1:-1)];return c&&l==h&&c.level+(r?0:1)<a.level?S.cursor(c.side(!r,t)+i.from,c.forward(r,t)?1:-1,c.level):S.cursor(l+i.from,a.forward(r,t)?-1:1,a.level)}function Pp(i,e,t){for(let n=e;n<t;n++){let r=Fl(i.charCodeAt(n));if(r==1)return ei;if(r==2||r==4)return $o}return ei}var eh=W.define(),th=W.define(),ih=W.define(),nh=W.define(),Ms=W.define(),rh=W.define(),sh=W.define(),Qo=W.define(),So=W.define(),oh=W.define({combine:i=>i.some(e=>e)}),Oh=W.define({combine:i=>i.some(e=>e)}),ah=W.define(),en=class i{constructor(e,t="nearest",n="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new i(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new i(S.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Fn=D.define({map:(i,e)=>i.map(e)}),lh=D.define();function Me(i,e,t){let n=i.facet(nh);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var Tt=W.define({combine:i=>i.length?i[0]:!0}),bp=0,Ii=W.define(),Ge=class i{constructor(e,t,n,r,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.extension=s(this)}static define(e,t){let{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=t||{};return new i(bp++,e,n,r,O=>{let a=[Ii.of(O)];return o&&a.push(cn.of(h=>{let l=h.plugin(O);return l?o(l):j.none})),s&&a.push(s(O)),a})}static fromClass(e,t){return i.define(n=>new e(n),t)}},tn=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Me(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Me(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Me(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},hh=W.define(),yo=W.define(),cn=W.define(),ch=W.define(),Po=W.define(),fh=W.define();function ol(i,e){let t=i.state.facet(fh);if(!t.length)return t;let n=t.map(s=>s instanceof Function?s(i):s),r=[];return F.spans(n,e.from,e.to,{point(){},span(s,o,O,a){let h=s-e.from,l=o-e.from,c=r;for(let f=O.length-1;f>=0;f--,a--){let d=O[f].spec.bidiIsolate,p;if(d==null&&(d=Pp(e.text,h,l)),a>0&&c.length&&(p=c[c.length-1]).to==h&&p.direction==d)p.to=l,c=p.inner;else{let m={from:h,to:l,direction:d,inner:[]};c.push(m),c=m.inner}}}}),r}var uh=W.define();function dh(i){let e=0,t=0,n=0,r=0;for(let s of i.state.facet(uh)){let o=s(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:n,bottom:r}}var Bi=W.define(),Ot=class i{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new i(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let r=0,s=0,o=0,O=0;;r++){let a=r==e.length?null:e[r],h=o-O,l=a?a.fromB:1e9;for(;s<t.length&&t[s]<l;){let c=t[s],f=t[s+1],d=Math.max(O,c),p=Math.min(l,f);if(d<=p&&new i(d+h,p+h,d,p).addToSet(n),f>l)break;s+=2}if(!a)return n;new i(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,O=a.toB}}},ur=class i{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=me.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,O,a)=>r.push(new Ot(s,o,O,a))),this.changedRanges=r}static create(e,t,n){return new i(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},dr=class extends H{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=j.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.setDOM(e.contentDOM),this.children=[new he],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ot(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:h,toA:l})=>l<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!Wp(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?kp(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:l}=this.hasComposition;n=new Ot(h,l,e.changes.mapPos(h,-1),e.changes.mapPos(l,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(z.ie||z.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,O=this.updateDeco(),a=vp(o,O,e.changes);return n=Ot.extendWithRanges(n,a),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=z.chrome||z.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Ht&&o.widget instanceof hn&&s.push(o.dom);r.updateGaps(s)}updateChildren(e,t,n){let r=n?n.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=r.length-1;;o--){let O=o>=0?r[o]:null;if(!O)break;let{fromA:a,toA:h,fromB:l,toB:c}=O,f,d,p,m;if(n&&n.range.fromB<c&&n.range.toB>l){let k=Ji.build(this.view.state.doc,l,n.range.fromB,this.decorations,this.dynamicDecorationMap),y=Ji.build(this.view.state.doc,n.range.toB,c,this.decorations,this.dynamicDecorationMap);d=k.breakAtStart,p=k.openStart,m=y.openEnd;let w=this.compositionView(n);y.breakAtStart?w.breakAfter=1:y.content.length&&w.merge(w.length,w.length,y.content[0],!1,y.openStart,0)&&(w.breakAfter=y.content[0].breakAfter,y.content.shift()),k.content.length&&w.merge(0,0,k.content[k.content.length-1],!0,0,k.openEnd)&&k.content.pop(),f=k.content.concat(w).concat(y.content)}else({content:f,breakAtStart:d,openStart:p,openEnd:m}=Ji.build(this.view.state.doc,l,c,this.decorations,this.dynamicDecorationMap));let{i:g,off:$}=s.findPos(h,1),{i:Q,off:b}=s.findPos(a,-1);jl(this,Q,b,g,$,f,d,p,m)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(lh)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new lt(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Wt(r,[t],t.length);let n=new he;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let O=H.get(s);O&&O!=o&&(O.dom=null),o.setDOM(s)},n=this.childPos(e.range.fromB,1),r=this.children[n.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)n=r.childPos(n.off,1),r=r.children[n.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,r=n==this.dom,s=!r&&nr(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let O=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(O.anchor)),h=O.empty?a:this.moveToLine(this.domAtPos(O.head));if(z.gecko&&O.empty&&!this.hasComposition&&xp(a)){let c=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(c,a.node.childNodes[a.offset]||null)),a=h=new $e(c,0),o=!0}let l=this.view.observer.selectionRange;(o||!l.focusNode||(!Ki(a.node,a.offset,l.anchorNode,l.anchorOffset)||!Ki(h.node,h.offset,l.focusNode,l.focusOffset))&&!this.suppressWidgetCursorChange(l,O))&&(this.view.observer.ignore(()=>{z.android&&z.chrome&&this.dom.contains(l.focusNode)&&zp(l.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let c=sn(this.view.root);if(c)if(O.empty){if(z.gecko){let f=wp(a.node,a.offset);if(f&&f!=3){let d=(f==1?Al:_l)(a.node,a.offset);d&&(a=new $e(d.node,d.offset))}}c.collapse(a.node,a.offset),O.bidiLevel!=null&&c.caretBidiLevel!==void 0&&(c.caretBidiLevel=O.bidiLevel)}else if(c.extend){c.collapse(a.node,a.offset);try{c.extend(h.node,h.offset)}catch{}}else{let f=document.createRange();O.anchor>O.head&&([a,h]=[h,a]),f.setEnd(h.node,h.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new $e(l.anchorNode,l.anchorOffset),this.impreciseHead=h.precise?null:new $e(l.focusNode,l.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ki(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=sn(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=he.find(this,t.head);if(!o)return;let O=o.posAtStart;if(t.head==O||t.head==O+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let l=this.domAtPos(t.head+t.assoc);n.collapse(l.node,l.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&n.collapse(r,s)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let r=e.offset;!n&&r<t.childNodes.length;r++){let s=H.get(t.childNodes[r]);s instanceof he&&(n=s.domAtPos(0))}for(let r=e.offset-1;!n&&r>=0;r--){let s=H.get(t.childNodes[r]);s instanceof he&&(n=s.domAtPos(s.length))}return n?new $e(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=H.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let r=this.children[t];if(n<r.length||r instanceof he)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,r=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let O=this.children[o],a=s-O.breakAfter,h=a-O.length;if(a<e)break;if(h<=e&&(h<e||O.covers(-1))&&(a>e||O.covers(1))&&(!n||O instanceof he&&!(n instanceof he&&t>=0)))n=O,r=h;else if(n&&h==e&&a==e&&O instanceof Ht&&Math.abs(t)<2){if(O.deco.startSide<0)break;o&&(n=null)}s=h}return n?n.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),r=this.children[t];if(!(r instanceof he))return null;for(;r.children.length;){let{i:O,off:a}=r.childPos(n,1);for(;;O++){if(O==r.children.length)return null;if((r=r.children[O]).length)break}n=a}if(!(r instanceof lt))return null;let s=le(r.text,n);if(s==n)return null;let o=Jt(r.dom,n,s).getClientRects();for(let O=0;O<o.length;O++){let a=o[O];if(O==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,O=-1,a=this.view.textDirection==J.LTR;for(let h=0,l=0;l<this.children.length;l++){let c=this.children[l],f=h+c.length;if(f>r)break;if(h>=n){let d=c.dom.getBoundingClientRect();if(t.push(d.height),o){let p=c.dom.lastChild,m=p?on(p):[];if(m.length){let g=m[m.length-1],$=a?g.right-d.left:d.right-g.left;$>O&&(O=$,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=f)}}}h=f+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?J.RTL:J.LTR}measureTextSize(){for(let s of this.children)if(s instanceof he){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,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.dom.appendChild(e);let s=on(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new hr(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>n){let O=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(j.replace({widget:new hn(O),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return j.set(e)}updateDeco(){let e=1,t=this.view.state.facet(cn).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(ch).map((s,o)=>{let O=typeof s=="function";return O&&(n=!0),O?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(F.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(ah))try{if(h(this.view,e.range,e))return!0}catch(l){Me(this.view.state,l,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=dh(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:O,offsetHeight:a}=this.view.scrollDOM;sp(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,O),-O),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==J.LTR)}};function xp(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function ph(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=Al(t.focusNode,t.focusOffset),r=_l(t.focusNode,t.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let O=H.get(r.node);if(!O||O instanceof lt&&O.text!=r.node.nodeValue)s=r;else if(i.docView.lastCompositionAfterCursor){let a=H.get(n.node);!a||a instanceof lt&&a.text!=n.node.nodeValue||(s=r)}}if(i.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function kp(i,e,t){let n=ph(i,t);if(!n)return null;let{node:r,from:s,to:o}=n,O=r.nodeValue;if(/[\n\r]/.test(O)||i.state.doc.sliceString(n.from,n.to)!=O)return null;let a=e.invertedDesc,h=new Ot(a.mapPos(s),a.mapPos(o),s,o),l=[];for(let c=r.parentNode;;c=c.parentNode){let f=H.get(c);if(f instanceof Wt)l.push({node:c,deco:f.mark});else{if(f instanceof he||c.nodeName=="DIV"&&c.parentNode==i.contentDOM)return{range:h,text:r,marks:l,line:c};if(c!=i.contentDOM)l.push({node:c,deco:new an({inclusive:!0,attributes:fp(c),tagName:c.tagName.toLowerCase()})});else return null}}}function wp(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}var Tp=class{constructor(){this.changes=[]}compareRange(e,t){As(e,t,this.changes)}comparePoint(e,t){As(e,t,this.changes)}};function vp(i,e,t){let n=new Tp;return F.compare(i,e,t,n),n.changes}function zp(i,e){for(let t=i;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Wp(i,e){let t=!1;return e&&i.iterChangedRanges((n,r)=>{n<e.to&&r>e.from&&(t=!0)}),t}function Rp(i,e,t=1){let n=i.charCategorizer(e),r=i.doc.lineAt(e),s=e-r.from;if(r.length==0)return S.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,O=s;t<0?o=le(r.text,s,!1):O=le(r.text,s);let a=n(r.text.slice(o,O));for(;o>0;){let h=le(r.text,o,!1);if(n(r.text.slice(h,o))!=a)break;o=h}for(;O<r.length;){let h=le(r.text,O);if(n(r.text.slice(O,h))!=a)break;O=h}return S.range(o+r.from,O+r.from)}function Xp(i,e){return e.left>i?e.left-i:Math.max(0,i-e.right)}function Zp(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function vs(i,e){return i.top<e.bottom-1&&i.bottom>e.top+1}function Ol(i,e){return e<i.top?{top:e,left:i.left,right:i.right,bottom:i.bottom}:i}function al(i,e){return e>i.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function Gs(i,e,t){let n,r,s,o,O=!1,a,h,l,c;for(let p=i.firstChild;p;p=p.nextSibling){let m=on(p);for(let g=0;g<m.length;g++){let $=m[g];r&&vs(r,$)&&($=Ol(al($,r.bottom),r.top));let Q=Xp(e,$),b=Zp(t,$);if(Q==0&&b==0)return p.nodeType==3?ll(p,e,t):Gs(p,e,t);if(!n||o>b||o==b&&s>Q){n=p,r=$,s=Q,o=b;let k=b?t<$.top?-1:1:Q?e<$.left?-1:1:0;O=!k||(k>0?g<m.length-1:g>0)}Q==0?t>$.bottom&&(!l||l.bottom<$.bottom)?(a=p,l=$):t<$.top&&(!c||c.top>$.top)&&(h=p,c=$):l&&vs(l,$)?l=al(l,$.bottom):c&&vs(c,$)&&(c=Ol(c,$.top))}}if(l&&l.bottom>=t?(n=a,r=l):c&&c.top<=t&&(n=h,r=c),!n)return{node:i,offset:0};let f=Math.max(r.left,Math.min(r.right,e));if(n.nodeType==3)return ll(n,f,t);if(O&&n.contentEditable!="false")return Gs(n,f,t);let d=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(r.left+r.right)/2?1:0);return{node:i,offset:d}}function ll(i,e,t){let n=i.nodeValue.length,r=-1,s=1e9,o=0;for(let O=0;O<n;O++){let a=Jt(i,O,O+1).getClientRects();for(let h=0;h<a.length;h++){let l=a[h];if(l.top==l.bottom)continue;o||(o=e-l.left);let c=(l.top>t?l.top-t:t-l.bottom)-1;if(l.left-1<=e&&l.right+1>=e&&c<s){let f=e>=(l.left+l.right)/2,d=f;if((z.chrome||z.gecko)&&Jt(i,O).getBoundingClientRect().left==l.right&&(d=!f),c<=0)return{node:i,offset:O+(d?1:0)};r=O+(d?1:0),s=c}}}return{node:i,offset:r>-1?r:o>0?i.nodeValue.length:0}}function mh(i,e,t,n=-1){var r,s;let o=i.contentDOM.getBoundingClientRect(),O=o.top+i.viewState.paddingTop,a,{docHeight:h}=i.viewState,{x:l,y:c}=e,f=c-O;if(f<0)return 0;if(f>h)return i.state.doc.length;for(let k=i.viewState.heightOracle.textHeight/2,y=!1;a=i.elementAtHeight(f),a.type!=Qe.Text;)for(;f=n>0?a.bottom+k:a.top-k,!(f>=0&&f<=h);){if(y)return t?null:0;y=!0,n=-n}c=O+f;let d=a.from;if(d<i.viewport.from)return i.viewport.from==0?0:t?null:hl(i,o,a,l,c);if(d>i.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:hl(i,o,a,l,c);let p=i.dom.ownerDocument,m=i.root.elementFromPoint?i.root:p,g=m.elementFromPoint(l,c);g&&!i.contentDOM.contains(g)&&(g=null),g||(l=Math.max(o.left+1,Math.min(o.right-1,l)),g=m.elementFromPoint(l,c),g&&!i.contentDOM.contains(g)&&(g=null));let $,Q=-1;if(g&&((r=i.docView.nearest(g))===null||r===void 0?void 0:r.isEditable)!=!1){if(p.caretPositionFromPoint){let k=p.caretPositionFromPoint(l,c);k&&({offsetNode:$,offset:Q}=k)}else if(p.caretRangeFromPoint){let k=p.caretRangeFromPoint(l,c);k&&({startContainer:$,startOffset:Q}=k,(!i.contentDOM.contains($)||z.safari&&qp($,Q,l)||z.chrome&&Vp($,Q,l))&&($=void 0))}$&&(Q=Math.min(at($),Q))}if(!$||!i.docView.dom.contains($)){let k=he.find(i.docView,d);if(!k)return f>a.top+a.height/2?a.to:a.from;({node:$,offset:Q}=Gs(k.dom,l,c))}let b=i.docView.nearest($);if(!b)return null;if(b.isWidget&&((s=b.dom)===null||s===void 0?void 0:s.nodeType)==1){let k=b.dom.getBoundingClientRect();return e.y<k.top||e.y<=k.bottom&&e.x<=(k.left+k.right)/2?b.posAtStart:b.posAtEnd}else return b.localPosFromDOM($,Q)+b.posAtStart}function hl(i,e,t,n,r){let s=Math.round((n-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&t.height>i.defaultLineHeight*1.5){let O=i.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(i.defaultLineHeight-O)*.5)/O);s+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+In(o,s,i.state.tabSize)}function qp(i,e,t){let n;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(let r=i.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Jt(i,n-1,n).getBoundingClientRect().left>t}function Vp(i,e,t){if(e!=0)return!1;for(let r=i;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let n=i.nodeType==1?i.getBoundingClientRect():Jt(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Ls(i,e){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==Qe.Text))return n}return t}function Cp(i,e,t,n){let r=Ls(i,e.head),s=!n||r.type!=Qe.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),O=i.textDirectionAt(r.from),a=i.posAtCoords({x:t==(O==J.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return S.cursor(a,t?-1:1)}return S.cursor(t?r.to:r.from,t?-1:1)}function cl(i,e,t,n){let r=i.state.doc.lineAt(e.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let O=e,a=null;;){let h=yp(r,s,o,O,t),l=Jl;if(!h){if(r.number==(t?i.state.doc.lines:1))return O;l=`
+`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),h=i.visualLineSide(r,!t)}if(a){if(!a(l))return O}else{if(!n)return h;a=n(l)}O=h}}function Yp(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==_e.Space&&(r=o),r==o}}function Up(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return S.cursor(r,e.assoc);let o=e.goalColumn,O,a=i.contentDOM.getBoundingClientRect(),h=i.coordsAtPos(r,e.assoc||-1),l=i.documentTop;if(h)o==null&&(o=h.left-a.left),O=s<0?h.top:h.bottom;else{let d=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(r-d.from))),O=(s<0?d.top:d.bottom)+l}let c=a.left+o,f=n??i.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=O+(f+d)*s,m=mh(i,{x:c,y:p},!1,s);if(p<a.top||p>a.bottom||(s<0?m<r:m>r)){let g=i.docView.coordsForChar(m),$=!g||p<g.top?-1:1;return S.cursor(m,$,void 0,o)}}}function rr(i,e,t){for(;;){let n=0;for(let r of i)r.between(e-1,e+1,(s,o,O)=>{if(e>s&&e<o){let a=n||t||(e-s<o-e?-1:1);e=a<0?s:o,n=a}});if(!n)return e}}function zs(i,e,t){let n=rr(i.state.facet(Po).map(r=>r(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:S.cursor(n,n<t.from?1:-1)}var Ni="\uFFFF",Ds=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(I.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ni}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let O=H.get(r),a=H.get(o);(O&&a?O.breakAfter:(O?O.breakAfter:lr(r))||lr(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,O;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(O=r.exec(t))&&(s=O.index,o=O[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=s+o}}readNode(e){if(e.cmIgnore)return;let t=H.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Ap(e,n.node,n.offset)?t:0))}};function Ap(i,e,t){for(;;){if(!e||t<at(e))return!1;if(e==i)return!0;t=Kt(e)+1,e=e.parentNode}}var pr=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Is=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let O=s||o?[]:Ep(e),a=new Ds(O,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Mp(O,this.bounds.from)}else{let O=e.observer.selectionRange,a=s&&s.node==O.focusNode&&s.offset==O.focusOffset||!Xs(e.contentDOM,O.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(O.focusNode,O.focusOffset),h=o&&o.node==O.anchorNode&&o.offset==O.anchorOffset||!Xs(e.contentDOM,O.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(O.anchorNode,O.anchorOffset),l=e.viewport;if((z.ios||z.chrome)&&e.state.selection.main.empty&&a!=h&&(l.from>0||l.to<e.state.doc.length)){let c=Math.min(a,h),f=Math.max(a,h),d=l.from-c,p=l.to-f;(d==0||d==1||c==0)&&(p==0||p==-1||f==e.state.doc.length)&&(a=0,h=e.state.doc.length)}this.newSel=S.single(h,a)}}};function gh(i,e){let t,{newSel:n}=e,r=i.state.selection.main,s=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:O}=e.bounds,a=r.from,h=null;(s===8||z.android&&e.text.length<O-o)&&(a=r.to,h="end");let l=jp(i.state.doc.sliceString(o,O,Ni),e.text,a-o,h);l&&(z.chrome&&s==13&&l.toB==l.from+2&&e.text.slice(l.from,l.toB)==Ni+Ni&&l.toB--,t={from:o+l.from,to:o+l.toA,insert:Y.of(e.text.slice(l.from,l.toB).split(Ni))})}else n&&(!i.hasFocus&&i.state.facet(Tt)||n.main.eq(r))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!r.empty&&n&&n.main.empty?t={from:r.from,to:r.to,insert:i.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:i.state.doc.slice(r.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,r.to))}:(z.mac||z.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=S.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:Y.of([" "])}):z.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
+ `&&i.lineWrapping&&(n&&(n=S.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:Y.of([" "])}),t)return bo(i,t,n,s);if(n&&!n.main.eq(r)){let o=!1,O="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),O=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:O}),!0}else return!1}function bo(i,e,t,n=-1){if(z.ios&&i.inputState.flushIOSKey(e))return!0;let r=i.state.selection.main;if(z.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&i.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&bi(i.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&bi(i.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&bi(i.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,O=()=>o||(o=_p(i,e,t));return i.state.facet(rh).some(a=>a(i,e.from,e.to,s,O))||i.dispatch(O()),!0}function _p(i,e,t){let n,r=i.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let O=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(i.state.toText(O+e.insert.sliceString(0,void 0,i.state.lineBreak)+a))}else{let O=r.changes(e),a=t&&t.main.to<=O.newLength?t.main:void 0;if(r.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=i.state.sliceDoc(e.from,e.to),l,c=t&&ph(i,t.main.head);if(c){let p=e.insert.length-(e.to-e.from);l={from:c.from,to:c.to-p}}else l=i.state.doc.lineAt(s.head);let f=s.to-e.to,d=s.to-s.from;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:O,range:a||p.map(O)};let m=p.to-f,g=m-h.length;if(p.to-p.from!=d||i.state.sliceDoc(g,m)!=h||p.to>=l.from&&p.from<=l.to)return{range:p};let $=r.changes({from:g,to:m,insert:e.insert}),Q=p.to-s.to;return{changes:$,range:a?S.range(Math.max(0,a.anchor+Q),Math.max(0,a.head+Q)):p.map($)}})}else n={changes:O,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,o+=".compose",i.inputState.compositionFirstChange&&(o+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:o,scrollIntoView:!0})}function jp(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s<r&&i.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&i.length==e.length)return null;let o=i.length,O=e.length;for(;o>0&&O>0&&i.charCodeAt(o-1)==e.charCodeAt(O-1);)o--,O--;if(n=="end"){let a=Math.max(0,s-Math.min(o,O));t-=o+a-s}if(o<s&&i.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,O=s+(O-o),o=s}else if(O<s){let a=t<=s&&t>=O?s-t:0;s-=a,o=s+(o-O),O=s}return{from:s,toA:o,toB:O}}function Ep(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new pr(t,n)),(r!=t||s!=n)&&e.push(new pr(r,s))),e}function Mp(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?S.single(t+e,n+e):null}var Bs=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,z.safari&&e.contentDOM.addEventListener("input",()=>null),z.gecko&&rm(e.contentDOM.ownerDocument)}handleEvent(e){!Fp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Gp(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,O=n[s];O&&o!=!O.handlers.length&&(r.removeEventListener(s,this.handleEvent),O=null),O||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Qh.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),z.android&&z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=$h.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||Lp.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,bi(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:z.safari&&!z.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function fl(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){Me(t.state,r)}}}function Gp(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(fl(n.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(fl(n.value,o))}}for(let n in Fe)t(n).handlers.push(Fe[n]);for(let n in Le)t(n).observers.push(Le[n]);return e}var $h=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Lp="dthko",Qh=[16,17,18,20,91,92,224,225],Hn=6;function Kn(i){return Math.max(0,i)*.7+8}function Dp(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}var Ns=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=op(e.contentDOM),this.atoms=e.state.facet(Po).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(I.allowMultipleSelections)&&Ip(e,t),this.dragging=Np(e,t)&&Ph(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Dp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,s=0,o=this.view.win.innerWidth,O=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:O}=this.scrollParents.y.getBoundingClientRect());let a=dh(this.view);e.clientX-a.left<=r+Hn?t=-Kn(r-e.clientX):e.clientX+a.right>=o-Hn&&(t=Kn(e.clientX-o)),e.clientY-a.top<=s+Hn?n=-Kn(s-e.clientY):e.clientY+a.bottom>=O-Hn&&(n=Kn(e.clientY-O)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let r=e.ranges[n],s=null;if(r.empty){let o=rr(this.atoms,r.from,0);o!=r.from&&(s=S.cursor(o,-1))}else{let o=rr(this.atoms,r.from,-1),O=rr(this.atoms,r.to,1);(o!=r.from||O!=r.to)&&(s=S.range(r.from==r.anchor?o:O,r.from==r.head?o:O))}s&&(t||(t=e.ranges.slice()),t[n]=s)}return t?S.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Ip(i,e){let t=i.state.facet(eh);return t.length?t[0](e):z.mac?e.metaKey:e.ctrlKey}function Bp(i,e){let t=i.state.facet(th);return t.length?t[0](e):z.mac?!e.altKey:!e.ctrlKey}function Np(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=sn(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Fp(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=H.get(t))&&n.ignoreEvent(e))return!1;return!0}var Fe=Object.create(null),Le=Object.create(null),Sh=z.ie&&z.ie_version<15||z.ios&&z.webkit_version<604;function Hp(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),yh(i,t.value)},50)}function xr(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function yh(i,e){e=xr(i.state,Qo,e);let{state:t}=i,n,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Fs!=null&&t.selection.ranges.every(a=>a.empty)&&Fs==s.toString()){let a=-1;n=t.changeByRange(h=>{let l=t.doc.lineAt(h.from);if(l.from==a)return{range:h};a=l.from;let c=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:l.from,insert:c},range:S.cursor(h.from+c.length)}})}else o?n=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:S.cursor(a.from+h.length)}}):n=t.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Le.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Fe.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);Le.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};Le.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Fe.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(ih))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=em(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new Ns(i,e,t,n)),n&&i.observer.ignore(()=>{Cl(i.contentDOM);let s=i.root.activeElement;s&&!s.contains(i.contentDOM)&&s.blur()});let r=i.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function ul(i,e,t,n){if(n==1)return S.cursor(e,t);if(n==2)return Rp(i.state,e,t);{let r=he.find(i.docView,e),s=i.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,O=r?r.posAtEnd:s.to;return O<i.state.doc.length&&O==s.to&&O++,S.range(o,O)}}var dl=(i,e,t)=>e>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function Kp(i,e,t,n){let r=he.find(i.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&dl(t,n,o))return-1;let O=r.coordsAt(s,1);return O&&dl(t,n,O)?1:o&&o.bottom>=n?-1:1}function pl(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Kp(i,t,e.clientX,e.clientY)}}var Jp=z.ie&&z.ie_version<=11,ml=null,gl=0,$l=0;function Ph(i){if(!Jp)return i.detail;let e=ml,t=$l;return ml=i,$l=Date.now(),gl=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(gl+1)%3:1}function em(i,e){let t=pl(i,e),n=Ph(e),r=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,O){let a=pl(i,s),h,l=ul(i,a.pos,a.bias,n);if(t.pos!=a.pos&&!o){let c=ul(i,t.pos,t.bias,n),f=Math.min(c.from,l.from),d=Math.max(c.to,l.to);l=f<l.from?S.range(f,d):S.range(d,f)}return o?r.replaceRange(r.main.extend(l.from,l.to)):O&&n==1&&r.ranges.length>1&&(h=tm(r,a.pos))?h:O?r.addRange(l):S.create([l])}}}function tm(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:r}=i.ranges[t];if(n<=e&&r>=e)return S.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}Fe.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let r=i.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=S.range(s,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",xr(i.state,So,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Fe.dragend=i=>(i.inputState.draggedContent=null,!1);function Ql(i,e,t,n){if(t=xr(i.state,Qo,t),!t)return;let r=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=i.inputState,o=n&&s&&Bp(i,e)?{from:s.from,to:s.to}:null,O={from:r,insert:t},a=i.state.changes(o?[o,O]:O);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}Fe.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),r=0,s=()=>{++r==t.length&&Ql(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let O=new FileReader;O.onerror=s,O.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(O.result)||(n[o]=O.result),s()},O.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return Ql(i,e,n,!0),!0}return!1};Fe.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=Sh?null:e.clipboardData;return t?(yh(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Hp(i),!1)};function im(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function nm(i){let e=[],t=[],n=!1;for(let r of i.selection.ranges)r.empty||(e.push(i.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:xr(i,So,e.join(i.lineBreak)),ranges:t,linewise:n}}var Fs=null;Fe.copy=Fe.cut=(i,e)=>{let{text:t,ranges:n,linewise:r}=nm(i.state);if(!t&&!r)return!1;Fs=r?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=Sh?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(im(i,t),!1)};var bh=ke.define();function xh(i,e){let t=[];for(let n of i.facet(sh)){let r=n(i,e);r&&t.push(r)}return t?i.update({effects:t,annotations:bh.of(!0)}):null}function kh(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=xh(i.state,e);t?i.dispatch(t):i.update([])}},10)}Le.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),kh(i)};Le.blur=i=>{i.observer.clearSelectionRange(),kh(i)};Le.compositionstart=Le.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};Le.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,z.chrome&&z.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};Le.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};Fe.beforeinput=(i,e)=>{var t,n;if(e.inputType=="insertReplacementText"&&i.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let O=o[0],a=i.posAtDOM(O.startContainer,O.startOffset),h=i.posAtDOM(O.endContainer,O.endOffset);return bo(i,{from:a,to:h,insert:i.state.toText(s)},null),!0}}let r;if(z.chrome&&z.android&&(r=$h.find(s=>s.inputType==e.inputType))&&(i.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return z.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),z.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>Le.compositionend(i,e),20),!1};var Sl=new Set;function rm(i){Sl.has(i)||(Sl.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}var yl=["pre-wrap","normal","pre-line","break-spaces"],xi=!1;function Pl(){xi=!1}var Hs=class{constructor(e){this.lineWrapping=e,this.doc=Y.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return yl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,s,o){let O=yl.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=O;if(this.lineWrapping=O,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let l=o[h];l<0?h++:this.heightSamples[Math.floor(l*10)]=!0}}return a}},Ks=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},st=class i{constructor(e,t,n,r,s){this.from=e,this.length=t,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Xt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new i(this.from,this.length+e.length,this.top,this.height+e.height,t)}},K=function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i}(K||(K={})),sr=.001,Ze=class i{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>sr&&(xi=!0),this.height=e)}replace(e,t,n){return i.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,o=n.doc;for(let O=r.length-1;O>=0;O--){let{fromA:a,toA:h,fromB:l,toB:c}=r[O],f=s.lineAt(a,K.ByPosNoHeight,n.setDoc(t),0,0),d=f.to>=h?f:s.lineAt(h,K.ByPosNoHeight,n,0,0);for(c+=d.to-h,h=d.to;O>0&&f.from<=r[O-1].toA;)a=r[O-1].fromA,l=r[O-1].fromB,O--,a<f.from&&(f=s.lineAt(a,K.ByPosNoHeight,n,0,0));l+=f.from-a,a=f.from;let p=eo.build(n.setDoc(o),e,l,c);s=mr(s,s.replace(a,h,p))}return s.updateHeight(n,0)}static empty(){return new Ee(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,r=0,s=0;for(;;)if(t==n)if(r>s*2){let O=e[t-1];O.break?e.splice(--t,1,O.left,null,O.right):e.splice(--t,1,O.left,O.right),n+=1+O.break,r-=O.size}else if(s>r*2){let O=e[n];O.break?e.splice(n,1,O.left,null,O.right):e.splice(n,1,O.left,O.right),n+=2+O.break,s-=O.size}else break;else if(r<s){let O=e[t++];O&&(r+=O.size)}else{let O=e[--n];O&&(s+=O.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new Js(i.of(e.slice(0,t)),o,i.of(e.slice(n)))}};function mr(i,e){return i==e?i:(i.constructor!=e.constructor&&(xi=!0),e)}Ze.prototype.size=1;var gr=class extends Ze{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,r){return new st(r,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,r,s){return this.blockAt(0,n,r,s)}forEachLine(e,t,n,r,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,n,r,s))}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},Ee=class i extends gr{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,r){return new st(r,this.length,n,this.height,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof i||r instanceof zt&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof zt?r=new i(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ze.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setHeight(r.heights[r.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},zt=class i extends Ze{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,o,O=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(O=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:O}}blockAt(e,t,n,r){let{firstLine:s,lastLine:o,perLine:O,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),l=t.doc.lineAt(h),c=O+l.length*a,f=Math.max(n,e-c/2);return new st(l.from,l.length,f,c,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-n)/O))),{from:l,length:c}=t.doc.line(s+h);return new st(l,c,n+O*h,O,0)}}lineAt(e,t,n,r,s){if(t==K.ByHeight)return this.blockAt(e,n,r,s);if(t==K.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new st(d,p-d,0,0,0)}let{firstLine:o,perLine:O,perChar:a}=this.heightMetrics(n,s),h=n.doc.lineAt(e),l=O+h.length*a,c=h.number-o,f=r+O*c+a*(h.from-s-c);return new st(h.from,h.length,Math.max(r,Math.min(f,r+this.height-l)),l,0)}forEachLine(e,t,n,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:O,perLine:a,perChar:h}=this.heightMetrics(n,s);for(let l=e,c=r;l<=t;){let f=n.doc.lineAt(l);if(l==e){let p=f.number-O;c+=a*p+h*(e-s-p)}let d=a+h*f.length;o(new st(f.from,f.length,c,d,0)),c+=d,l=f.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let s=n[n.length-1];s instanceof i?n[n.length-1]=new i(s.length+r):n.push(null,new i(r-1))}if(e>0){let s=n[0];s instanceof i?n[0]=new i(e+s.length):n.unshift(new i(e-1),null)}return Ze.of(n)}decomposeLeft(e,t){t.push(new i(e-1),null)}decomposeRight(e,t){t.push(null,new i(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],O=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new i(r.from-t-1).updateHeight(e,t));O<=s&&r.more;){let l=e.doc.lineAt(O).length;o.length&&o.push(null);let c=r.heights[r.index++];a==-1?a=c:Math.abs(c-a)>=sr&&(a=-2);let f=new Ee(l,c);f.outdated=!1,o.push(f),O+=l+1}O<=s&&o.push(null,new i(s-O).updateHeight(e,O));let h=Ze.of(o);return(a<0||Math.abs(h.height-this.height)>=sr||Math.abs(a-this.heightMetrics(e,t).perLine)>=sr)&&(xi=!0),mr(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Js=class extends Ze{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,n,r,s){let o=r+this.left.height,O=s+this.left.length+this.break,a=t==K.ByHeight?e<o:e<O,h=a?this.left.lineAt(e,t,n,r,s):this.right.lineAt(e,t,n,o,O);if(this.break||(a?h.to<O:h.from>O))return h;let l=t==K.ByPosNoHeight?K.ByPosNoHeight:K.ByPos;return a?h.join(this.right.lineAt(O,l,n,o,O)):this.left.lineAt(O,l,n,r,s).join(h)}forEachLine(e,t,n,r,s,o){let O=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,s,o),t>=a&&this.right.forEachLine(e,t,n,O,a,o);else{let h=this.lineAt(a,K.ByPos,n,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,n,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,n,O,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let O of n)s.push(O);if(e>0&&bl(s,o-1),t<this.length){let O=s.length;this.decomposeRight(t,s),bl(s,O)}return Ze.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ze.of(this.break?[e,null,t]:[e,t]):(this.left=mr(this.left,e),this.right=mr(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:s,right:o}=this,O=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=O+o.length&&r.more?a=o=o.updateHeight(e,O,n,r):o.updateHeight(e,O,n),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function bl(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof zt&&(n=i[e+1])instanceof zt&&i.splice(e-1,3,new zt(t.length+1+n.length))}var sm=5,eo=class i{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Ee?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Ee(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new gr(o,r,n)):(o||s||r>=sm)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ee(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new zt(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ee)return e;let t=new Ee(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ee)&&!this.isCovered?this.nodes.push(new Ee(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let r of this.nodes)r instanceof Ee&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(e,t,n,r){let s=new i(n,e);return F.spans(t,n,r,s,0),s.finish(n)}};function om(i,e,t){let n=new to;return F.compare(i,e,t,n,0),n.changes}var to=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&As(e,t,this.changes,5)}};function Om(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,r=n.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),O=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=i.parentNode;h&&h!=n.body;)if(h.nodeType==1){let l=h,c=window.getComputedStyle(l);if((l.scrollHeight>l.clientHeight||l.scrollWidth>l.clientWidth)&&c.overflow!="visible"){let f=l.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),O=Math.max(O,f.top),a=Math.min(h==i.parentNode?r.innerHeight:a,f.bottom)}h=c.position=="absolute"||c.position=="fixed"?l.offsetParent:l.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:O-(t.top+e),bottom:Math.max(O,a)-(t.top+e)}}function am(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var nn=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],s=t[n];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return j.replace({widget:new io(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},io=class extends Rt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},$r=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=xl,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=J.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(yo).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Hs(t),this.stateDeco=e.facet(cn).filter(n=>typeof n!="function"),this.heightMap=Ze.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle.setDoc(e.doc),[new Ot(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=j.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new yi(s,o))}}return this.viewports=e.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?xl:new no(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Fi(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(cn).filter(l=>typeof l!="function");let r=e.changedRanges,s=Ot.extendWithRanges(r,om(n,this.stateDeco,e?e.changes:me.empty(this.state.doc.length))),o=this.heightMap.height,O=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Pl(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||xi)&&(e.flags|=2),O?(this.scrollAnchorPos=e.changes.mapPos(O.from,-1),this.scrollAnchorHeight=O.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Oh)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?J.RTL:J.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),O=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=O.height;this.contentDOMHeight=O.height,this.mustMeasureContent=!1;let h=0,l=0;if(O.width&&O.height){let{scaleX:k,scaleY:y}=Vl(t,O);(k>.005&&Math.abs(this.scaleX-k)>.005||y>.005&&Math.abs(this.scaleY-y)>.005)&&(this.scaleX=k,this.scaleY=y,h|=8,o=a=!0)}let c=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=f)&&(this.paddingTop=c,this.paddingBottom=f,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Ul(e.scrollDOM);let p=(this.printing?am:Om)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let $=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if($!=this.inView&&(this.inView=$,$&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let Q=O.width;if((this.contentDOMWidth!=Q||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=O.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let k=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(k)&&(o=!0),o||r.lineWrapping&&Math.abs(Q-this.contentDOMWidth)>r.charWidth){let{lineHeight:y,charWidth:w,textHeight:T}=e.docView.measureTextSize();o=y>0&&r.refresh(s,y,w,T,Q/w,k),o&&(e.docView.minWidth=0,h|=8)}m>0&&g>0?l=Math.max(m,g):m<0&&g<0&&(l=Math.min(m,g)),Pl();for(let y of this.viewports){let w=y.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(y);this.heightMap=(o?Ze.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle,[new Ot(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Ks(y.from,w))}xi&&(h|=2)}let b=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),h|=this.updateForViewport()),(h&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:O}=this,a=new yi(r.lineAt(o-n*1e3,K.ByHeight,s,0,0).from,r.lineAt(O+(1-n)*1e3,K.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let l=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=r.lineAt(h,K.ByPos,s,0,0),f;t.y=="center"?f=(c.top+c.bottom)/2-l/2:t.y=="start"||t.y=="nearest"&&h<a.from?f=c.top:f=c.bottom-l,a=new yi(r.lineAt(f-1e3/2,K.ByHeight,s,0,0).from,r.lineAt(f+l+1e3/2,K.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new yi(this.heightMap.lineAt(n,K.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,K.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,K.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,K.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:O}=this;return(e==0||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=O+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s<O+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new nn(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=J.LTR&&!n)return[];let O=[],a=(l,c,f,d)=>{if(c-l<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let $ of m)if($>l&&$<c){a(l,$-10,f,d),a($+10,c,f,d);return}let g=hm(e,$=>$.from>=f.from&&$.to<=f.to&&Math.abs($.from-l)<s&&Math.abs($.to-c)<s&&!m.some(Q=>$.from<Q&&$.to>Q));if(!g){if(c<f.to&&t&&n&&t.visibleRanges.some(b=>b.from<=c&&b.to>=c)){let b=t.moveToLineBoundary(S.cursor(c),!1,!0).head;b>l&&(c=b)}let $=this.gapSize(f,l,c,d),Q=n||$<2e6?$:2e6;g=new nn(l,c,$,Q)}O.push(g)},h=l=>{if(l.length<o||l.type!=Qe.Text)return;let c=lm(l.from,l.to,this.stateDeco);if(c.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(n){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,$;if(f!=null){let Q=er(c,f),b=((this.visibleBottom-this.visibleTop)/2+m)/l.height;g=Q-b,$=Q+b}else g=(this.visibleTop-l.top-m)/l.height,$=(this.visibleBottom-l.top+m)/l.height;d=Jn(c,g),p=Jn(c,$)}else{let m=c.total*this.heightOracle.charWidth,g=r*this.heightOracle.charWidth,$=0;if(m>2e6)for(let w of e)w.from>=l.from&&w.from<l.to&&w.size!=w.displaySize&&w.from*this.heightOracle.charWidth+$<this.pixelViewport.left&&($=w.size-w.displaySize);let Q=this.pixelViewport.left+$,b=this.pixelViewport.right+$,k,y;if(f!=null){let w=er(c,f),T=((b-Q)/2+g)/m;k=w-T,y=w+T}else k=(Q-g)/m,y=(b+g)/m;d=Jn(c,k),p=Jn(c,y)}d>l.from&&a(l.from,d,l,c),p<l.to&&a(p,l.to,l,c)};for(let l of this.viewportLines)Array.isArray(l.type)?l.type.forEach(h):h(l);return O}gapSize(e,t,n,r){let s=er(r,n)-er(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){nn.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=j.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];F.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Fi(this.heightMap.lineAt(e,K.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Fi(this.heightMap.lineAt(this.scaler.fromDOM(e),K.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Fi(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},yi=class{constructor(e,t){this.from=e,this.to=t}};function lm(i,e,t){let n=[],r=i,s=0;return F.spans(t,i,e,{span(){},point(o,O){o>r&&(n.push({from:r,to:o}),s+=o-r),r=O}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function Jn({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let r=0;;r++){let{from:s,to:o}=e[r],O=o-s;if(n<=O)return s+n;n-=O}}function er(i,e){let t=0;for(let{from:n,to:r}of i.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/i.total}function hm(i,e){for(let t of i)if(e(t))return t}var xl={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}},no=class i{constructor(e,t,n){let r=0,s=0,o=0;this.viewports=n.map(({from:O,to:a})=>{let h=t.lineAt(O,K.ByPos,e,0,0).top,l=t.lineAt(a,K.ByPos,e,0,0).bottom;return r+=l-h,{from:O,to:a,top:h,bottom:l,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let O of this.viewports)O.domTop=o+(O.top-s)*this.scale,o=O.domBottom=O.domTop+(O.bottom-O.top),s=O.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,r=s.domBottom}}eq(e){return e instanceof i?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}};function Fi(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new st(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(r=>Fi(r,e)):i._content)}var tr=W.define({combine:i=>i.join(" ")}),ro=W.define({combine:i=>i.indexOf(!0)>-1}),so=je.newName(),wh=je.newName(),Th=je.newName(),vh={"&light":"."+wh,"&dark":"."+Th};function oo(i,e,t){return new je(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):i+" "+n}})}var cm=oo("."+so,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<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"}},vh),fm={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ws=z.ie&&z.ie_version<=11,Oo=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Zs,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(z.ie&&z.ie_version<=11||z.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(z.chrome&&z.chrome_version<126)&&(this.editContext=new ao(e),e.state.facet(Tt)&&(e.contentDOM.editContext=this.editContext.editContext)),Ws&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Tt)?n.root.activeElement!=this.dom:!nr(this.dom,r))return;let s=r.anchorNode&&n.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(z.ie&&z.ie_version<=11||z.android&&z.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Ki(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=sn(e.root);if(!t)return!1;let n=z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&um(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=nr(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&ap(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,fm),Ws&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ws&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&bi(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&nr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Is(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=gh(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=kl(t,e.previousSibling||e.target.previousSibling,-1),r=kl(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Tt)!=e.state.facet(Tt)&&(e.view.contentDOM.editContext=e.state.facet(Tt)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function kl(i,e,t){for(;e;){let n=H.get(e);if(n&&n.parent==i)return n;let r=e.parentNode;e=r!=i.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function wl(i,e){let t=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return Ki(o.node,o.offset,r,s)&&([t,n,r,s]=[r,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}}function um(i,e){if(e.getComposedRanges){let r=e.getComposedRanges(i.root)[0];if(r)return wl(i,r)}let t=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?wl(i,t):null}var ao=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let{anchor:r}=e.state.selection.main,s={from:this.toEditorPos(n.updateRangeStart),to:this.toEditorPos(n.updateRangeEnd),insert:Y.of(n.text.split(`
+`))};s.from==this.from&&r<this.from?s.from=r:s.to==this.to&&r>this.to&&(s.to=r),!(s.from==s.to&&!s.insert.length)&&(this.pendingContextChange=s,e.state.readOnly||bo(e,s,S.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=n=>{let r=[],s=null;for(let o=this.toEditorPos(n.rangeStart),O=this.toEditorPos(n.rangeEnd);o<O;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,O=s.underlineThickness;if(o!="None"&&O!="None"){let a=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${O=="Thin"?1:2}px`;r.push(j.mark({attributes:{style:a}}).range(this.toEditorPos(s.rangeStart),this.toEditorPos(s.rangeEnd)))}}e.dispatch({effects:lh.of(j.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let r=sn(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,O,a,h)=>{if(n)return;let l=h.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(h)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=l,this.to+=l;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},v=class i{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Op(e.parent)||document,this.viewState=new $r(e.state||I.create(e)),e.scrollTo&&e.scrollTo.is(Fn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ii).map(r=>new tn(r));for(let r of this.plugins)r.update(this);this.observer=new Oo(this),this.inputState=new Bs(this),this.inputState.ensureHandlers(this.plugins),this.docView=new dr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof ne?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,r,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,O=0,a=null;e.some(f=>f.annotation(bh))?(this.inputState.notifiedFocused=o,O=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=xh(s,o),a||(O=1));let h=this.observer.delayedAndroidKey,l=null;if(h?(this.observer.clearDelayedAndroidKey(),l=this.observer.readChange(),(l&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(l=null)):this.observer.clear(),s.facet(I.phrases)!=this.state.facet(I.phrases))return this.setState(s);r=ur.create(this,s,e),r.flags|=O;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(c&&(c=c.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection;c=new en(d.empty?d:S.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(Fn)&&(c=d.value.clip(this.state))}this.viewState.update(r,c),this.bidiCache=Qr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(Bi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(tr)!=r.state.facet(tr)&&(this.viewState.mustMeasureContent=!0),(t||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let f of this.state.facet(Ms))try{f(r)}catch(d){Me(this.state,d,"update listener")}(a||l)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),l&&!gh(this,l)&&h.force&&bi(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new $r(e),this.plugins=e.facet(Ii).map(n=>new tn(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new dr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ii),n=e.state.facet(Ii);if(t!=n){let r=[];for(let s of n){let o=t.indexOf(s);if(o<0)r.push(new tn(s));else{let O=this.plugins[o];O.mustUpdate=e,r.push(O)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Me(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let O=0;;O++){if(o<0)if(Ul(n))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(O>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let l=h.map(d=>{try{return d.read(this)}catch(p){return Me(this.state,p),Tl}}),c=ur.create(this,this.state,[]),f=!1;c.flags|=a,t?t.flags|=a:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),f=this.docView.update(c),f&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(l[d]!=Tl)try{let p=h[d];p.write&&p.write(l[d],this)}catch(p){Me(this.state,p)}if(f&&this.docView.updateSelection(!0),!c.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 p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(p>1||p<-1){r=r+p,n.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let O of this.state.facet(Ms))O(t)}get themeClasses(){return so+" "+(this.state.facet(ro)?Th:wh)+" "+this.state.facet(tr)}updateAttrs(){let e=vl(this,hh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Tt)?"true":"false",class:"cm-content",style:`${z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),vl(this,yo,t);let n=this.observer.ignore(()=>{let r=Us(this.contentDOM,this.contentAttrs,t),s=Us(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(i.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Bi);let e=this.state.facet(i.cspNonce);je.mount(this.root,this.styleModules.concat(cm).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return zs(this,e,cl(this,e,t,n))}moveByGroup(e,t){return zs(this,e,cl(this,e,t,n=>Yp(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return S.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return Cp(this,e,t,n)}moveVertically(e,t,n){return zs(this,e,Up(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),mh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[ot.find(s,e-r.from,-1,t)];return Pr(n,o.dir==J.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(oh)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>dm)return Kl(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Hl(s.isolates,n=ol(this,e))))return s.order;n||(n=ol(this,e));let r=Sp(e.text,t,n);return this.bidiCache.push(new Qr(e.from,e.to,t,n,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||z.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Cl(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Fn.of(new en(typeof e=="number"?S.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Fn.of(new en(S.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ge.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ge.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=je.newName(),r=[tr.of(n),Bi.of(oo(`.${n}`,e))];return t&&t.dark&&r.push(ro.of(!0)),r}static baseTheme(e){return nt.lowest(Bi.of(oo("."+so,e,vh)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&H.get(n)||H.get(e);return((t=r?.rootView)===null||t===void 0?void 0:t.view)||null}};v.styleModule=Bi;v.inputHandler=rh;v.clipboardInputFilter=Qo;v.clipboardOutputFilter=So;v.scrollHandler=ah;v.focusChangeEffect=sh;v.perLineTextDirection=oh;v.exceptionSink=nh;v.updateListener=Ms;v.editable=Tt;v.mouseSelectionStyle=ih;v.dragMovesSelection=th;v.clickAddsSelectionRange=eh;v.decorations=cn;v.outerDecorations=ch;v.atomicRanges=Po;v.bidiIsolatedRanges=fh;v.scrollMargins=uh;v.darkTheme=ro;v.cspNonce=W.define({combine:i=>i.length?i[0]:""});v.contentAttributes=yo;v.editorAttributes=hh;v.lineWrapping=v.contentAttributes.of({class:"cm-lineWrapping"});v.announce=D.define();var dm=4096,Tl={},Qr=class i{constructor(e,t,n,r,s,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:J.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&n.push(new i(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}};function vl(i,e,t){for(let n=i.state.facet(e),r=n.length-1;r>=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&Ys(o,t)}return t}var pm=z.mac?"mac":z.windows?"win":z.linux?"linux":"key";function mm(i,e){let t=i.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,O;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))O=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?O=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),O&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function ir(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}var gm=nt.default(v.domEventHandlers({keydown(i,e){return ym($m(e.state),i,e,"editor")}})),ht=W.define({enables:gm}),zl=new WeakMap;function $m(i){let e=i.facet(ht),t=zl.get(e);return t||zl.set(e,t=Sm(e.reduce((n,r)=>n.concat(r),[]))),t}var vt=null,Qm=4e3;function Sm(i,e=pm){let t=Object.create(null),n=Object.create(null),r=(o,O)=>{let a=n[o];if(a==null)n[o]=O;else if(a!=O)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,O,a,h,l)=>{var c,f;let d=t[o]||(t[o]=Object.create(null)),p=O.split(/ (?!$)/).map($=>mm($,e));for(let $=1;$<p.length;$++){let Q=p.slice(0,$).join(" ");r(Q,!0),d[Q]||(d[Q]={preventDefault:!0,stopPropagation:!1,run:[b=>{let k=vt={view:b,prefix:Q,scope:o};return setTimeout(()=>{vt==k&&(vt=null)},Qm),!0}]})}let m=p.join(" ");r(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((f=(c=d._any)===null||c===void 0?void 0:c.run)===null||f===void 0?void 0:f.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),l&&(g.stopPropagation=!0)};for(let o of i){let O=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of O){let l=t[h]||(t[h]=Object.create(null));l._any||(l._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let f in l)l[f].run.push(d=>c(d,lo))}let a=o[e]||o.key;if(a)for(let h of O)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}var lo=null;function ym(i,e,t,n){lo=e;let r=Ka(e),s=pi(r,0),o=Mi(s)==r.length&&r!=" ",O="",a=!1,h=!1,l=!1;vt&&vt.view==t&&vt.scope==n&&(O=vt.prefix+" ",Qh.indexOf(e.keyCode)<0&&(h=!0,vt=null));let c=new Set,f=g=>{if(g){for(let $ of g.run)if(!c.has($)&&(c.add($),$(t)))return g.stopPropagation&&(l=!0),!0;g.preventDefault&&(g.stopPropagation&&(l=!0),h=!0)}return!1},d=i[n],p,m;return d&&(f(d[O+ir(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(z.windows&&e.ctrlKey&&e.altKey)&&(p=gt[e.keyCode])&&p!=r?(f(d[O+ir(p,e,!0)])||e.shiftKey&&(m=Qi[e.keyCode])!=r&&m!=p&&f(d[O+ir(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(d[O+ir(r,e,!0)])&&(a=!0),!a&&f(d._any)&&(a=!0)),h&&(a=!0),a&&l&&e.stopPropagation(),lo=null,a}var fn=class i{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=zh(e);return[new i(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return Pm(e,t,n)}};function zh(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==J.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function Wl(i,e,t,n){let r=i.coordsAtPos(e,t*2);if(!r)return n;let s=i.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,O=i.posAtCoords({x:s.left+1,y:o}),a=i.posAtCoords({x:s.right-1,y:o});return O==null||a==null?n:{from:Math.max(n.from,Math.min(O,a)),to:Math.min(n.to,Math.max(O,a))}}function Pm(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),r=Math.min(t.to,i.viewport.to),s=i.textDirection==J.LTR,o=i.contentDOM,O=o.getBoundingClientRect(),a=zh(i),h=o.querySelector(".cm-line"),l=h&&window.getComputedStyle(h),c=O.left+(l?parseInt(l.paddingLeft)+Math.min(0,parseInt(l.textIndent)):0),f=O.right-(l?parseInt(l.paddingRight):0),d=Ls(i,n),p=Ls(i,r),m=d.type==Qe.Text?d:null,g=p.type==Qe.Text?p:null;if(m&&(i.lineWrapping||d.widgetLineBreaks)&&(m=Wl(i,n,1,m)),g&&(i.lineWrapping||p.widgetLineBreaks)&&(g=Wl(i,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return Q(b(t.from,t.to,m));{let y=m?b(t.from,null,m):k(d,!1),w=g?b(null,t.to,g):k(p,!0),T=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&y.bottom+i.defaultLineHeight/2<w.top?T.push($(c,y.bottom,f,w.top)):y.bottom<w.top&&i.elementAtHeight((y.bottom+w.top)/2).type==Qe.Text&&(y.bottom=w.top=(y.bottom+w.top)/2),Q(y).concat(T).concat(Q(w))}function $(y,w,T,E){return new fn(e,y-a.left,w-a.top-.01,T-y,E-w+.01)}function Q({top:y,bottom:w,horizontal:T}){let E=[];for(let U=0;U<T.length;U+=2)E.push($(T[U],y,T[U+1],w));return E}function b(y,w,T){let E=1e9,U=-1e9,A=[];function C(M,te,be,xe,Re){let Ue=i.coordsAtPos(M,M==T.to?-2:2),se=i.coordsAtPos(be,be==T.from?2:-2);!Ue||!se||(E=Math.min(Ue.top,se.top,E),U=Math.max(Ue.bottom,se.bottom,U),Re==J.LTR?A.push(s&&te?c:Ue.left,s&&xe?f:se.right):A.push(!s&&xe?c:se.left,!s&&te?f:Ue.right))}let q=y??T.from,B=w??T.to;for(let M of i.visibleRanges)if(M.to>q&&M.from<B)for(let te=Math.max(M.from,q),be=Math.min(M.to,B);;){let xe=i.state.doc.lineAt(te);for(let Re of i.bidiSpans(xe)){let Ue=Re.from+xe.from,se=Re.to+xe.from;if(Ue>=be)break;se>te&&C(Math.max(Ue,te),y==null&&Ue<=q,Math.min(se,be),w==null&&se>=B,Re.dir)}if(te=xe.to+1,te>=be)break}return A.length==0&&C(q,y==null,B,w==null,i.textDirection),{top:E,bottom:U,horizontal:A}}function k(y,w){let T=O.top+(w?y.top:y.bottom);return{top:T,bottom:T,horizontal:[]}}}function bm(i,e){return i.constructor==e.constructor&&i.eq(e)}var ho=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(or)!=e.state.facet(or)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(or);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!bm(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},or=W.define();function Wh(i){return[Ge.define(e=>new ho(e,i)),or.of(i)]}var Rh=!z.ios,un=W.define({combine(i){return wt(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Xh(i={}){return[un.of(i),xm,km,wm,Oh.of(!0)]}function Zh(i){return i.startState.facet(un)!=i.state.facet(un)}var xm=Wh({above:!0,markers(i){let{state:e}=i,t=e.facet(un),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||Rh:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",O=r.empty?r:S.cursor(r.head,r.head>r.anchor?-1:1);for(let a of fn.forRange(i,o,O))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Zh(i);return t&&Rl(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){Rl(e.state,i)},class:"cm-cursorLayer"});function Rl(i,e){e.style.animationDuration=i.facet(un).cursorBlinkRate+"ms"}var km=Wh({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:fn.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Zh(i)},class:"cm-selectionLayer"}),co={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Rh&&(co[".cm-line"].caretColor=co[".cm-content"].caretColor="transparent !important");var wm=nt.highest(v.theme(co)),qh=D.define({map(i,e){return i==null?null:e.mapPos(i)}}),Hi=ge.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(qh)?n.value:t,i)}}),Tm=Ge.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(Hi);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(Hi)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(Hi),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(Hi)!=i&&this.view.dispatch({effects:qh.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Vh(){return[Hi,Tm]}var RP=/x/.unicode!=null?"gu":"g";function xo(){return zm}var vm=j.line({class:"cm-activeLine"}),zm=Ge.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let r=i.lineBlockAt(n.head);r.from>e&&(t.push(vm.range(r.from)),e=r.from)}return j.set(t)}},{decorations:i=>i.decorations});var fo=2e3;function Wm(i,e,t){let n=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>fo||t.off>fo||e.col<0||t.col<0){let o=Math.min(e.off,t.off),O=Math.max(e.off,t.off);for(let a=n;a<=r;a++){let h=i.doc.line(a);h.length<=O&&s.push(S.range(h.from+o,h.to+O))}}else{let o=Math.min(e.col,t.col),O=Math.max(e.col,t.col);for(let a=n;a<=r;a++){let h=i.doc.line(a),l=In(h.text,o,i.tabSize,!0);if(l<0)s.push(S.cursor(h.to));else{let c=In(h.text,O,i.tabSize);s.push(S.range(h.from+l,h.from+c))}}}return s}function Rm(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function Xl(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),r=t-n.from,s=r>fo?-1:r==n.length?Rm(i,e.clientX):we(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:s,off:r}}function Xm(i,e){let t=Xl(i,e),n=i.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(r.changes)}},get(r,s,o){let O=Xl(i,r);if(!O)return n;let a=Wm(i.state,t,O);return a.length?o?S.create(a.concat(n.ranges)):S.create(a):n}}:null}function Ch(i){let e=i?.eventFilter||(t=>t.altKey&&t.button==0);return v.mouseSelectionStyle.of((t,n)=>e(n)?Xm(t,n):null)}var XP=v.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var He=class extends Ne{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};He.prototype.elementClass="";He.prototype.toDOM=void 0;He.prototype.mapMode=ae.TrackBefore;He.prototype.startSide=He.prototype.endSide=-1;He.prototype.point=!0;var Or=W.define(),Zm=W.define();var ar=W.define();var uo=W.define({combine:i=>i.some(e=>e)});function qm(i){let e=[Vm];return i&&i.fixed===!1&&e.push(uo.of(!0)),e}var Vm=Ge.fromClass(class{constructor(i){this.view=i,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(ar).map(e=>new Sr(i,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!i.state.facet(uo),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}i.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(uo)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&this.dom.remove();let t=F.iter(this.view.state.facet(Or),this.view.viewport.from),n=[],r=this.gutters.map(s=>new mo(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let O of s.type)if(O.type==Qe.Text&&o){po(t,n,O.from);for(let a of r)a.line(this.view,O,n);o=!1}else if(O.widget)for(let a of r)a.widget(this.view,O)}else if(s.type==Qe.Text){po(t,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();i&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(i){let e=i.startState.facet(ar),t=i.state.facet(ar),n=i.docChanged||i.heightChanged||i.viewportChanged||!F.eq(i.startState.facet(Or),i.state.facet(Or),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(i)&&(n=!0);else{n=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Sr(this.view,s)):(this.gutters[o].update(i),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove()}},{provide:i=>v.scrollMargins.of(e=>{let t=e.plugin(i);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==J.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function Zl(i){return Array.isArray(i)?i:[i]}function po(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}var mo=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=F.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let O=new yr(e,o,s,n);r.elements.push(O),r.dom.appendChild(O.dom)}else r.elements[this.i].update(e,o,s,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];po(this.cursor,r,t.from),n.length&&(r=r.concat(n));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let s of e.state.facet(Zm)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Sr=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let O=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,O,r)&&r.preventDefault()});this.markers=Zl(t.markers(e)),t.initialSpacer&&(this.spacer=new yr(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Zl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let n=e.view.viewport;return!F.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},yr=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),Cm(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let O=o,a=s<t.length?t[s++]:null,h=!1;if(a){let l=a.elementClass;l&&(n+=" "+l);for(let c=o;c<this.markers.length;c++)if(this.markers[c].compare(a)){O=c,h=!0;break}}else O=this.markers.length;for(;o<O;){let l=this.markers[o++];if(l.toDOM){l.destroy(r);let c=r.nextSibling;r.remove(),r=c}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Cm(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}var Ym=W.define(),Um=W.define(),Pi=W.define({combine(i){return wt(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let r in t){let s=n[r],o=t[r];n[r]=s?(O,a,h)=>s(O,a,h)||o(O,a,h):o}return n}})}}),rn=class extends He{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Rs(i,e){return i.state.facet(Pi).formatNumber(e,i.state)}var Am=ar.compute([Pi],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Ym)},lineMarker(e,t,n){return n.some(r=>r.toDOM)?null:new rn(Rs(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Um)){let s=r(e,t,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Pi)!=e.state.facet(Pi),initialSpacer(e){return new rn(Rs(e,ql(e.state.doc.lines)))},updateSpacer(e,t){let n=Rs(t.view,ql(t.view.state.doc.lines));return n==e.number?e:new rn(n)},domEventHandlers:i.facet(Pi).domEventHandlers}));function Yh(i={}){return[Pi.of(i),qm(),Am]}function ql(i){let e=9;for(;e<i;)e=e*10+9;return e}var _m=new class extends He{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},jm=Or.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.head).from;r>t&&(t=r,e.push(_m.range(r)))}return F.of(e)});function ko(){return jm}async function Uh(i){if(window.isSecureContext&&navigator.clipboard){await navigator.clipboard.writeText(i);return}let e=document.createElement("textarea");e.setAttribute("style","position: absolute; left: -1000px; top: -1000px;"),e.value=i,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}var Em=0,ve=class{constructor(e,t){this.from=e,this.to=t}},Z=class{constructor(e={}){this.id=Em++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ie.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Z.closedBy=new Z({deserialize:i=>i.split(" ")});Z.openedBy=new Z({deserialize:i=>i.split(" ")});Z.group=new Z({deserialize:i=>i.split(" ")});Z.isolate=new Z({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});Z.contextHash=new Z({perNode:!0});Z.lookAhead=new Z({perNode:!0});Z.mounted=new Z({perNode:!0});var ti=class{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[Z.mounted.id]}},Mm=Object.create(null),ie=class i{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Mm,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new i(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(Z.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(Z.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}};ie.none=new ie("",Object.create(null),0,8);var $t=class i{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let s of e){let o=s(n);o&&(r||(r=Object.assign({},n.props)),r[o[0].id]=o[1])}t.push(r?new ie(n.name,r,n.id,n.flags):n)}return new i(t)}},kr=new WeakMap,Ah=new WeakMap,L;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(L||(L={}));var V=class i{constructor(e,t,n,r,s){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,O]of s)this.props[typeof o=="number"?o:o.id]=O}}toString(){let e=ti.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let r=n.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ki(this.topNode,e)}cursorAt(e,t=0,n=0){let r=kr.get(this)||this.topNode,s=new ki(r);return s.moveTo(e,t),kr.set(this,s._tree),s}get topNode(){return new ze(this,0,0,null)}resolve(e,t=0){let n=dn(kr.get(this)||this.topNode,e,t,!1);return kr.set(this,n),n}resolveInner(e,t=0){let n=dn(Ah.get(this)||this.topNode,e,t,!0);return Ah.set(this,n),n}resolveStack(e,t=0){return Gm(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:s=this.length}=e,o=e.mode||0,O=(o&L.IncludeAnonymous)>0;for(let a=this.cursor(o|L.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!O&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(O||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Co(ie.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new i(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new i(ie.none,t,n,r)))}static build(e){return Lm(e)}};V.empty=new V(ie.none,[],[],0);var wo=class i{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new i(this.buffer,this.index)}},qt=class i{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return ie.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,n,r,s){let{buffer:o}=this,O=-1;for(let a=e;a!=t&&!(Dh(s,r,o[a+1],o[a+2])&&(O=a,n>0));a=o[a+3]);return O}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let O=e,a=0;O<t;){s[a++]=r[O++],s[a++]=r[O++]-n;let h=s[a++]=r[O++]-n;s[a++]=r[O++]-e,o=Math.max(o,h)}return new i(s,o,this.set)}};function Dh(i,e,t,n){switch(i){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function dn(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let o=!n&&i instanceof ze&&i.index<0?null:i.parent;if(!o)return i;i=o}let s=n?0:L.IgnoreOverlays;if(n)for(let o=i,O=o.parent;O;o=O,O=o.parent)o instanceof ze&&o.index<0&&((r=O.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(i=O);for(;;){let o=i.enter(e,t,s);if(!o)return i;i=o}}var Tr=class{cursor(e=0){return new ki(this,e)}getChild(e,t=null,n=null){let r=_h(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return _h(this,e,t,n)}resolve(e,t=0){return dn(this,e,t,!1)}resolveInner(e,t=0){return dn(this,e,t,!0)}matchContext(e){return To(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(n=t,t=r.prevSibling):t=r}return n}get node(){return this}get next(){return this.parent}},ze=class i extends Tr{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,s=0){for(let o=this;;){for(let{children:O,positions:a}=o._tree,h=t>0?O.length:-1;e!=h;e+=t){let l=O[e],c=a[e]+o.from;if(Dh(r,n,c,c+l.length)){if(l instanceof qt){if(s&L.ExcludeBuffers)continue;let f=l.findChild(0,l.buffer.length,t,n-c,r);if(f>-1)return new ii(new vo(o,l,e,c),null,f)}else if(s&L.IncludeAnonymous||!l.type.isAnonymous||Vo(l)){let f;if(!(s&L.IgnoreMounts)&&(f=ti.get(l))&&!f.overlay)return new i(f.tree,c,e,o);let d=new i(l,c,e,o);return s&L.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?l.children.length-1:0,t,n,r)}}}if(s&L.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let r;if(!(n&L.IgnoreOverlays)&&(r=ti.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:O}of r.overlay)if((t>0?o<=s:o<s)&&(t<0?O>=s:O>s))return new i(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function _h(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function To(i,e,t=e.length-1){for(let n=i.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var vo=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},ii=class i extends Tr{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new i(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&L.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new i(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new i(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new i(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new V(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Ih(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;s<i.length;s++){let o=i[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let n=t instanceof ze&&t.index<0?null:t.parent,r=i.slice();return n?r[e]=n:r.splice(e,1),new zo(r,t)}var zo=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Ih(this.heads)}};function Gm(i,e,t){let n=i.resolveInner(e,t),r=null;for(let s=n instanceof ze?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[n])).push(o.resolve(e,t)),s=o}else{let o=ti.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let O=new ze(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(dn(O,e,t,!1))}}return r?Ih(r):n}var ki=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ze)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof ze?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&L.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&L.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&L.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let O=n._tree.children[s];if(this.mode&L.IncludeAnonymous||O instanceof qt||!O.type.isAnonymous||Vo(O))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r<this.stack.length;r++)t=new ii(this.buffer,t,this.stack[r]);return this.bufferNode=new ii(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return To(this.node,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return To(this.node,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function Vo(i){return i.children.some(e=>e instanceof qt||!e.type.isAnonymous||Vo(e))}function Lm(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=n.types.length}=i,O=Array.isArray(t)?new wo(t,t.length):t,a=n.types,h=0,l=0;function c(y,w,T,E,U,A){let{id:C,start:q,end:B,size:M}=O,te=l;for(;M<0;)if(O.next(),M==-1){let se=s[C];T.push(se),E.push(q-y);return}else if(M==-3){h=C;return}else if(M==-4){l=C;return}else throw new RangeError(`Unrecognized record size: ${M}`);let be=a[C],xe,Re,Ue=q-y;if(B-q<=r&&(Re=g(O.pos-w,U))){let se=new Uint16Array(Re.size-Re.skip),Ae=O.pos-Re.size,it=se.length;for(;O.pos>Ae;)it=$(Re.start,se,it);xe=new qt(se,B-Re.start,n),Ue=Re.start-y}else{let se=O.pos-M;O.next();let Ae=[],it=[],Lt=C>=o?C:-1,ci=0,Yn=B;for(;O.pos>se;)Lt>=0&&O.id==Lt&&O.size>=0?(O.end<=Yn-r&&(p(Ae,it,q,ci,O.end,Yn,Lt,te),ci=Ae.length,Yn=O.end),O.next()):A>2500?f(q,se,Ae,it):c(q,se,Ae,it,Lt,A+1);if(Lt>=0&&ci>0&&ci<Ae.length&&p(Ae,it,q,ci,q,Yn,Lt,te),Ae.reverse(),it.reverse(),Lt>-1&&ci>0){let Ta=d(be);xe=Co(be,Ae,it,0,Ae.length,0,B-q,Ta,Ta)}else xe=m(be,Ae,it,B-q,te-B)}T.push(xe),E.push(Ue)}function f(y,w,T,E){let U=[],A=0,C=-1;for(;O.pos>w;){let{id:q,start:B,end:M,size:te}=O;if(te>4)O.next();else{if(C>-1&&B<C)break;C<0&&(C=M-r),U.push(q,B,M),A++,O.next()}}if(A){let q=new Uint16Array(A*4),B=U[U.length-2];for(let M=U.length-3,te=0;M>=0;M-=3)q[te++]=U[M],q[te++]=U[M+1]-B,q[te++]=U[M+2]-B,q[te++]=te;T.push(new qt(q,U[2]-B,n)),E.push(B-y)}}function d(y){return(w,T,E)=>{let U=0,A=w.length-1,C,q;if(A>=0&&(C=w[A])instanceof V){if(!A&&C.type==y&&C.length==E)return C;(q=C.prop(Z.lookAhead))&&(U=T[A]+C.length+q)}return m(y,w,T,E,U)}}function p(y,w,T,E,U,A,C,q){let B=[],M=[];for(;y.length>E;)B.push(y.pop()),M.push(w.pop()+T-U);y.push(m(n.types[C],B,M,A-U,q-A)),w.push(U-T)}function m(y,w,T,E,U=0,A){if(h){let C=[Z.contextHash,h];A=A?[C].concat(A):[C]}if(U>25){let C=[Z.lookAhead,U];A=A?[C].concat(A):[C]}return new V(y,w,T,E,A)}function g(y,w){let T=O.fork(),E=0,U=0,A=0,C=T.end-r,q={size:0,start:0,skip:0};e:for(let B=T.pos-y;T.pos>B;){let M=T.size;if(T.id==w&&M>=0){q.size=E,q.start=U,q.skip=A,A+=4,E+=4,T.next();continue}let te=T.pos-M;if(M<0||te<B||T.start<C)break;let be=T.id>=o?4:0,xe=T.start;for(T.next();T.pos>te;){if(T.size<0)if(T.size==-3)be+=4;else break e;else T.id>=o&&(be+=4);T.next()}U=xe,E+=M,A+=be}return(w<0||E==y)&&(q.size=E,q.start=U,q.skip=A),q.size>4?q:void 0}function $(y,w,T){let{id:E,start:U,end:A,size:C}=O;if(O.next(),C>=0&&E<o){let q=T;if(C>4){let B=O.pos-(C-4);for(;O.pos>B;)T=$(y,w,T)}w[--T]=q,w[--T]=A-y,w[--T]=U-y,w[--T]=E}else C==-3?h=E:C==-4&&(l=E);return T}let Q=[],b=[];for(;O.pos>0;)c(i.start||0,i.bufferStart||0,Q,b,-1,0);let k=(e=i.length)!==null&&e!==void 0?e:Q.length?b[0]+Q[0].length:0;return new V(a[i.topID],Q.reverse(),b.reverse(),k)}var jh=new WeakMap;function wr(i,e){if(!i.isAnonymous||e instanceof qt||e.type!=i)return 1;let t=jh.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof V)){t=1;break}t+=wr(i,n)}jh.set(e,t)}return t}function Co(i,e,t,n,r,s,o,O,a){let h=0;for(let p=n;p<r;p++)h+=wr(i,e[p]);let l=Math.ceil(h*1.5/8),c=[],f=[];function d(p,m,g,$,Q){for(let b=g;b<$;){let k=b,y=m[b],w=wr(i,p[b]);for(b++;b<$;b++){let T=wr(i,p[b]);if(w+T>=l)break;w+=T}if(b==k+1){if(w>l){let T=p[k];d(T.children,T.positions,0,T.children.length,m[k]+Q);continue}c.push(p[k])}else{let T=m[b-1]+p[b-1].length-y;c.push(Co(i,p,m,k,b,y,T,null,a))}f.push(y+Q-s)}}return d(e,t,n,r,0),(O||a)(c,f,o)}var wi=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof ii?this.setBuffer(e.context.buffer,e.index,t):e instanceof ze&&this.map.set(e.tree,t)}get(e){return e instanceof ii?this.getBuffer(e.context.buffer,e.index):e instanceof ze?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},Qt=class i{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new i(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let O=0,a=0,h=0;;O++){let l=O<t.length?t[O]:null,c=l?l.fromA:1e9;if(c-a>=n)for(;o&&o.from<c;){let f=o;if(a>=f.from||c<=f.to||h){let d=Math.max(f.from,a)-h,p=Math.min(f.to,c)-h;f=d>=p?null:new i(d,p,f.tree,f.offset+h,O>0,!!l)}if(f&&r.push(f),o.to>c)break;o=s<e.length?e[s++]:null}if(!l)break;a=l.toA,h=l.toA-l.toB}return r}},St=class{startParse(e,t,n){return typeof e=="string"&&(e=new Wo(e)),n=n?n.length?n.map(r=>new ve(r.from,r.to)):[new ve(0,0)]:[new ve(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}},Wo=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function Ti(i){return(e,t,n,r)=>new Zo(e,i,t,n,r)}var vr=class{constructor(e,t,n,r,s){this.parser=e,this.parse=t,this.overlay=n,this.target=r,this.from=s}};function Eh(i){if(!i.length||i.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(i))}var Ro=class{constructor(e,t,n,r,s,o,O){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=s,this.target=o,this.prev=O,this.depth=0,this.ranges=[]}},Xo=new Z({perNode:!0}),Zo=class{constructor(e,t,n,r,s){this.nest=t,this.input=n,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new V(n.type,n.children,n.positions,n.length,n.propValues.concat([[Xo,this.stoppedAt]]))),n}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[Z.mounted.id]=new ti(t,e.overlay,e.parser),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new qo(this.fragments),t=null,n=null,r=new ki(new ze(this.baseTree,this.ranges[0].from,0,null),L.IncludeAnonymous|L.IgnoreMounts);e:for(let s,o;;){let O=!0,a;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)O=!1;else if(e.hasNode(r)){if(t){let h=t.mounts.find(l=>l.frag.from<=r.from&&l.frag.to>=r.to&&l.mount.overlay);if(h)for(let l of h.mount.overlay){let c=l.from+h.pos,f=l.to+h.pos;c>=r.from&&f<=r.to&&!t.ranges.some(d=>d.from<f&&d.to>c)&&t.ranges.push({from:c,to:f})}}O=!1}else if(n&&(o=Dm(n.ranges,r.from,r.to)))O=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.from<r.to||!s.overlay)){r.tree||Im(r);let h=e.findMounts(r.from,s.parser);if(typeof s.overlay=="function")t=new Ro(s.parser,s.overlay,h,this.inner.length,r.from,r.tree,t);else{let l=Gh(this.ranges,s.overlay||(r.from<r.to?[new ve(r.from,r.to)]:[]));l.length&&Eh(l),(l.length||!s.overlay)&&this.inner.push(new vr(s.parser,l.length?s.parser.startParse(this.input,Lh(h,l),l):s.parser.startParse(""),s.overlay?s.overlay.map(c=>new ve(c.from-r.from,c.to-r.from)):null,r.tree,l.length?l[0].from:r.from)),s.overlay?l.length&&(n={ranges:l,depth:0,prev:n}):O=!1}}else t&&(a=t.predicate(r))&&(a===!0&&(a=new ve(r.from,r.to)),a.from<a.to&&t.ranges.push(a));if(O&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let h=Gh(this.ranges,t.ranges);h.length&&(Eh(h),this.inner.splice(t.index,0,new vr(t.parser,t.parser.startParse(this.input,Lh(t.mounts,h),h),t.ranges.map(l=>new ve(l.from-t.start,l.to-t.start)),t.target,h[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function Dm(i,e,t){for(let n of i){if(n.from>=t)break;if(n.to>e)return n.from<=e&&n.to>=t?2:1}return 0}function Mh(i,e,t,n,r,s){if(e<t){let o=i.buffer[e+1];n.push(i.slice(e,t,o)),r.push(o-s)}}function Im(i){let{node:e}=i,t=[],n=e.context.buffer;do t.push(i.index),i.parent();while(!i.tree);let r=i.tree,s=r.children.indexOf(n),o=r.children[s],O=o.buffer,a=[s];function h(l,c,f,d,p,m){let g=t[m],$=[],Q=[];Mh(o,l,g,$,Q,d);let b=O[g+1],k=O[g+2];a.push($.length);let y=m?h(g+4,O[g+3],o.set.types[O[g]],b,k-b,m-1):e.toTree();return $.push(y),Q.push(b-d),Mh(o,O[g+3],c,$,Q,d),new V(f,$,Q,p)}r.children[s]=h(0,O.length,ie.none,0,o.length,t.length-1);for(let l of a){let c=i.tree.children[l],f=i.tree.positions[l];i.yield(new ze(c,f+i.from,l,i._tree))}}var zr=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(L.IncludeAnonymous|L.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)t.to>=e&&t.enter(n,1,L.IgnoreOverlays|L.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof V)t=t.children[0];else break}return!1}},qo=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let n=this.curFrag=e[0];this.curTo=(t=n.tree.prop(Xo))!==null&&t!==void 0?t:n.to,this.inner=new zr(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Xo))!==null&&e!==void 0?e:t.to,this.inner=new zr(t.tree,-t.offset)}}findMounts(e,t){var n;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(n=s.tree)===null||n===void 0?void 0:n.prop(Z.mounted);if(o&&o.parser==t)for(let O=this.fragI;O<this.fragments.length;O++){let a=this.fragments[O];if(a.from>=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}};function Gh(i,e){let t=null,n=e;for(let r=1,s=0;r<i.length;r++){let o=i[r-1].to,O=i[r].from;for(;s<n.length;s++){let a=n[s];if(a.from>=O)break;a.to<=o||(t||(n=t=e.slice()),a.from<o?(t[s]=new ve(a.from,o),a.to>O&&t.splice(s+1,0,new ve(O,a.to))):a.to>O?t[s--]=new ve(O,a.to):t.splice(s--,1))}}return n}function Bm(i,e,t,n){let r=0,s=0,o=!1,O=!1,a=-1e9,h=[];for(;;){let l=r==i.length?1e9:o?i[r].to:i[r].from,c=s==e.length?1e9:O?e[s].to:e[s].from;if(o!=O){let f=Math.max(a,t),d=Math.min(l,c,n);f<d&&h.push(new ve(f,d))}if(a=Math.min(l,c),a==1e9)break;l==a&&(o?(o=!1,r++):o=!0),c==a&&(O?(O=!1,s++):O=!0)}return h}function Lh(i,e){let t=[];for(let{pos:n,mount:r,frag:s}of i){let o=n+(r.overlay?r.overlay[0].from:0),O=o+r.tree.length,a=Math.max(s.from,o),h=Math.min(s.to,O);if(r.overlay){let l=r.overlay.map(f=>new ve(f.from+n,f.to+n)),c=Bm(e,l,a,h);for(let f=0,d=a;;f++){let p=f==c.length,m=p?h:c[f].from;if(m>d&&t.push(new Qt(d,m,r.tree,-o,s.from>=d||s.openStart,s.to<=m||s.openEnd)),p)break;d=c[f].to}}else t.push(new Qt(a,h,r.tree,-o,s.from>=o||s.openStart,s.to<=O||s.openEnd))}return t}var Nm=0,qe=class i{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Nm++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof i&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new i(n,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Zr(e);return n=>n.modified.indexOf(t)>-1?n:Zr.get(n.base||n,n.modified.concat(t).sort((r,s)=>r.id-s.id))}},Fm=0,Zr=class i{constructor(e){this.name=e,this.instances=[],this.id=Fm++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(O=>O.base==e&&Hm(t,O.modified));if(n)return n;let r=[],s=new qe(e.name,r,e,t);for(let O of t)O.instances.push(s);let o=Km(t);for(let O of e.set)if(!O.modified.length)for(let a of o)r.push(i.get(O,a));return s}};function Hm(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function Km(i){let e=[[]];for(let t=0;t<i.length;t++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].concat(i[t]));return e.sort((t,n)=>n.length-t.length)}function oe(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,O=r;for(let c=0;;){if(O=="..."&&c>0&&c+3==r.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(O);if(!f)throw new RangeError("Invalid path: "+r);if(s.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),c+=f[0].length,c==r.length)break;let d=r[c++];if(c==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);O=r.slice(c)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let l=new vi(n,o,a>0?s.slice(0,a):null);e[h]=l.sort(e[h])}}return Fh.add(e)}var Fh=new Z,vi=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};vi.empty=new vi([],2,null);function _o(i,e){let t=Object.create(null);for(let s of i)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:n,all:r=null}=e||{};return{style:s=>{let o=r;for(let O of s)for(let a of O.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function Jm(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function Hh(i,e,t,n=0,r=i.length){let s=new Uo(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}var Uo=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,s){let{type:o,from:O,to:a}=e;if(O>=n||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=r,l=eg(e)||vi.empty,c=Jm(s,l.tags);if(c&&(h&&(h+=" "),h+=c,l.mode==1&&(r+=(r?" ":"")+c)),this.startSpan(Math.max(t,O),h),l.opaque)return;let f=e.tree&&e.tree.prop(Z.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+O,1),p=this.highlighters.filter(g=>!g.scope||g.scope(f.tree.type)),m=e.firstChild();for(let g=0,$=O;;g++){let Q=g<f.overlay.length?f.overlay[g]:null,b=Q?Q.from+O:a,k=Math.max(t,$),y=Math.min(n,b);if(k<y&&m)for(;e.from<y&&(this.highlightRange(e,k,y,r,s),this.startSpan(Math.min(y,e.to),h),!(e.to>=b||!e.nextSibling())););if(!Q||b>n)break;$=Q.to+O,$>t&&(this.highlightRange(d.cursor(),Math.max(t,Q.from+O),Math.min(n,$),"",p),this.startSpan(Math.min(n,$),h))}m&&e.parent()}else if(e.firstChild()){f&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}};function eg(i){let e=i.type.prop(Fh);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var x=qe.define,Wr=x(),Vt=x(),Bh=x(Vt),Nh=x(Vt),Ct=x(),Rr=x(Ct),Yo=x(Ct),ut=x(),ni=x(ut),ct=x(),ft=x(),Ao=x(),pn=x(Ao),Xr=x(),u={comment:Wr,lineComment:x(Wr),blockComment:x(Wr),docComment:x(Wr),name:Vt,variableName:x(Vt),typeName:Bh,tagName:x(Bh),propertyName:Nh,attributeName:x(Nh),className:x(Vt),labelName:x(Vt),namespace:x(Vt),macroName:x(Vt),literal:Ct,string:Rr,docString:x(Rr),character:x(Rr),attributeValue:x(Rr),number:Yo,integer:x(Yo),float:x(Yo),bool:x(Ct),regexp:x(Ct),escape:x(Ct),color:x(Ct),url:x(Ct),keyword:ct,self:x(ct),null:x(ct),atom:x(ct),unit:x(ct),modifier:x(ct),operatorKeyword:x(ct),controlKeyword:x(ct),definitionKeyword:x(ct),moduleKeyword:x(ct),operator:ft,derefOperator:x(ft),arithmeticOperator:x(ft),logicOperator:x(ft),bitwiseOperator:x(ft),compareOperator:x(ft),updateOperator:x(ft),definitionOperator:x(ft),typeOperator:x(ft),controlOperator:x(ft),punctuation:Ao,separator:x(Ao),bracket:pn,angleBracket:x(pn),squareBracket:x(pn),paren:x(pn),brace:x(pn),content:ut,heading:ni,heading1:x(ni),heading2:x(ni),heading3:x(ni),heading4:x(ni),heading5:x(ni),heading6:x(ni),contentSeparator:x(ut),list:x(ut),quote:x(ut),emphasis:x(ut),strong:x(ut),link:x(ut),monospace:x(ut),strikethrough:x(ut),inserted:x(),deleted:x(),changed:x(),invalid:x(),meta:Xr,documentMeta:x(Xr),annotation:x(Xr),processingInstruction:x(Xr),definition:qe.defineModifier("definition"),constant:qe.defineModifier("constant"),function:qe.defineModifier("function"),standard:qe.defineModifier("standard"),local:qe.defineModifier("local"),special:qe.defineModifier("special")};for(let i in u){let e=u[i];e instanceof qe&&(e.name=i)}var jP=_o([{tag:u.link,class:"tok-link"},{tag:u.heading,class:"tok-heading"},{tag:u.emphasis,class:"tok-emphasis"},{tag:u.strong,class:"tok-strong"},{tag:u.keyword,class:"tok-keyword"},{tag:u.atom,class:"tok-atom"},{tag:u.bool,class:"tok-bool"},{tag:u.url,class:"tok-url"},{tag:u.labelName,class:"tok-labelName"},{tag:u.inserted,class:"tok-inserted"},{tag:u.deleted,class:"tok-deleted"},{tag:u.literal,class:"tok-literal"},{tag:u.string,class:"tok-string"},{tag:u.number,class:"tok-number"},{tag:[u.regexp,u.escape,u.special(u.string)],class:"tok-string2"},{tag:u.variableName,class:"tok-variableName"},{tag:u.local(u.variableName),class:"tok-variableName tok-local"},{tag:u.definition(u.variableName),class:"tok-variableName tok-definition"},{tag:u.special(u.variableName),class:"tok-variableName2"},{tag:u.definition(u.propertyName),class:"tok-propertyName tok-definition"},{tag:u.typeName,class:"tok-typeName"},{tag:u.namespace,class:"tok-namespace"},{tag:u.className,class:"tok-className"},{tag:u.macroName,class:"tok-macroName"},{tag:u.propertyName,class:"tok-propertyName"},{tag:u.operator,class:"tok-operator"},{tag:u.comment,class:"tok-comment"},{tag:u.meta,class:"tok-meta"},{tag:u.invalid,class:"tok-invalid"},{tag:u.punctuation,class:"tok-punctuation"}]);var jo,yt=new Z;function Wi(i){return W.define({combine:i?e=>e.concat(i):void 0})}var Yr=new Z,fe=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,I.prototype.hasOwnProperty("tree")||Object.defineProperty(I.prototype,"tree",{get(){return G(this)}}),this.parser=t,this.extension=[zi.of(this),I.languageData.of((s,o,O)=>{let a=Kh(s,o,O),h=a.type.prop(yt);if(!h)return[];let l=s.facet(h),c=a.type.prop(Yr);if(c){let f=a.resolve(o-a.from,O);for(let d of c)if(d.test(f,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(l)}}return l})].concat(n)}isActiveAt(e,t,n=-1){return Kh(e,t,n).type.prop(yt)==this.data}findRegions(e){let t=e.facet(zi);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(yt)==this.data){n.push({from:o,to:o+s.length});return}let O=s.prop(Z.mounted);if(O){if(O.tree.prop(yt)==this.data){if(O.overlay)for(let a of O.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+s.length});return}else if(O.overlay){let a=n.length;if(r(O.tree,O.overlay[0].from+o),n.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof V&&r(h,s.positions[a]+o)}};return r(G(e),0),n}get allowsNesting(){return!0}};fe.setState=D.define();function Kh(i,e,t){let n=i.facet(zi),r=G(i).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(e,t,L.ExcludeBuffers))s.type.isTop&&(r=s);return r}var ue=class i extends fe{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=Wi(e.languageData);return new i(t,e.parser.configure({props:[yt.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new i(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function G(i){let e=i.field(fe.state,!1);return e?e.tree:V.empty}var Lo=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},mn=null,ri=class i{constructor(e,t,n=[],r,s,o,O,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=O,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new i(e,t,[],V.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Lo(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=V.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Qt.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Qt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=mn;mn=this;try{return e()}finally{mn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Jh(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:O}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,l,c,f)=>a.push({fromA:h,toA:l,fromB:c,toB:f})),n=Qt.applyChanges(n,a),r=V.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){O=[];for(let h of this.skipped){let l=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);l<c&&O.push({from:l,to:c})}}}return new i(this.parser,t,n,r,s,o,O,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:r,to:s}=this.skipped[n];r<e.to&&s>e.from&&(this.fragments=Jh(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends St{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=mn;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new V(ie.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return mn}};function Jh(i,e,t){return Qt.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}var gn=class i{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new i(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=ri.create(e.facet(zi).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new i(n)}};fe.state=ge.define({create:gn.init,update(i,e){for(let t of e.effects)if(t.is(fe.setState))return t.value;return e.startState.facet(zi)!=e.state.facet(zi)?gn.init(e.state):i.apply(e)}});var rc=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(rc=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Eo=typeof navigator<"u"&&(!((jo=navigator.scheduling)===null||jo===void 0)&&jo.isInputPending)?()=>navigator.scheduling.isInputPending():null,tg=Ge.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(fe.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(fe.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=rc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(fe.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Eo?Math.max(25,e.timeRemaining()-5):1e9),O=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>Eo&&Eo()||Date.now()>o,r+(O?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:fe.setState.of(new gn(s.context))})),this.chunkBudget>0&&!(a&&!O)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Me(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),zi=W.define({combine(i){return i.length?i[0]:null},enables:i=>[fe.state,tg,v.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]}),Oe=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},$n=class i{constructor(e,t,n,r,s,o=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:n}=e;if(!t){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(n)}return new i(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,t,n)}static matchFilename(e,t){for(let r of e)if(r.filename&&r.filename.test(t))return r;let n=/\.([^.]+)$/.exec(t);if(n){for(let r of e)if(r.extensions.indexOf(n[1])>-1)return r}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let r of e)if(r.alias.some(s=>s==t))return r;if(n)for(let r of e)for(let s of r.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return r}return null}},sc=W.define(),Ut=W.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Yt(i){let e=i.facet(Ut);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Sn(i,e){let t="",n=i.tabSize,r=i.facet(Ut)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s<e;s++)t+=r;return t}function Ko(i,e){i instanceof I&&(i=new si(i));for(let n of i.state.facet(sc)){let r=n(i,e);if(r!==void 0)return r}let t=G(i.state);return t.length>=e?ig(i,t,e):null}var si=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Yt(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return we(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Se=new Z;function ig(i,e,t){let n=e.resolveStack(t),r=n.node.enterUnfinishedNodesBefore(t);if(r!=n.node){let s=[];for(let o=r;o!=n.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return oc(n,i,t)}function oc(i,e,t){for(let n=i;n;n=n.next){let r=rg(n.node);if(r)return r(Do.create(e,t,n))}return 0}function ng(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function rg(i){let e=i.type.prop(Se);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(Z.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>Oc(o,!0,1,void 0,s&&!ng(o)?r.from:void 0)}return i.parent==null?sg:null}function sg(){return 0}var Do=class i extends si{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new i(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(og(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return oc(this.context.next,this.base,this.pos)}};function og(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function Og(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let O=t.to;;){let a=e.childAfter(O);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+h}}O=a.to}}function Ur({closing:i,align:e=!0,units:t=1}){return n=>Oc(n,e,t,i)}function Oc(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,O=n&&s.slice(o,o+n.length)==n||r==i.pos+o,a=e?Og(i):null;return a?O?i.column(a.from):i.column(a.to):i.baseIndent+(O?0:i.unit*t)}var ac=i=>i.baseIndent;function Ve({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}var lc=W.define(),ye=new Z;function At(i){let e=i.firstChild,t=i.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?i.to:t.from}:null}var Pt=class i{constructor(e,t){this.specs=e;let n;function r(O){let a=je.newName();return(n||(n=Object.create(null)))["."+a]=O,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof fe?O=>O.prop(yt)==o.data:o?O=>O==o:void 0,this.style=_o(e.map(O=>({tag:O.tag,class:O.class||r(Object.assign({},O,{tag:null}))})),{all:s}).style,this.module=n?new je(n):null,this.themeType=t.themeType}static define(e,t){return new i(e,t||{})}},Io=W.define(),hc=W.define({combine(i){return i.length?[i[0]]:null}});function Mo(i){let e=i.facet(Io);return e.length?e:i.facet(hc)}function Jo(i,e){let t=[ag],n;return i instanceof Pt&&(i.module&&t.push(v.styleModule.of(i.module)),n=i.themeType),e?.fallback?t.push(hc.of(i)):n?t.push(Io.computeN([v.darkTheme],r=>r.facet(v.darkTheme)==(n=="dark")?[i]:[])):t.push(Io.of(i)),t}var Bo=class{constructor(e){this.markCache=Object.create(null),this.tree=G(e.state),this.decorations=this.buildDeco(e,Mo(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=G(e.state),n=Mo(e.state),r=n!=Mo(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return j.none;let n=new Ft;for(let{from:r,to:s}of e.visibleRanges)Hh(this.tree,t,(o,O,a)=>{n.add(o,O,this.markCache[a]||(this.markCache[a]=j.mark({class:a})))},r,s);return n.finish()}},ag=nt.high(Ge.fromClass(Bo,{decorations:i=>i.decorations})),FP=Pt.define([{tag:u.meta,color:"#404740"},{tag:u.link,textDecoration:"underline"},{tag:u.heading,textDecoration:"underline",fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strong,fontWeight:"bold"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.keyword,color:"#708"},{tag:[u.atom,u.bool,u.url,u.contentSeparator,u.labelName],color:"#219"},{tag:[u.literal,u.inserted],color:"#164"},{tag:[u.string,u.deleted],color:"#a11"},{tag:[u.regexp,u.escape,u.special(u.string)],color:"#e40"},{tag:u.definition(u.variableName),color:"#00f"},{tag:u.local(u.variableName),color:"#30a"},{tag:[u.typeName,u.namespace],color:"#085"},{tag:u.className,color:"#167"},{tag:[u.special(u.variableName),u.macroName],color:"#256"},{tag:u.definition(u.propertyName),color:"#00c"},{tag:u.comment,color:"#940"},{tag:u.invalid,color:"#f00"}]),lg=v.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),cc=1e4,fc="()[]{}",uc=W.define({combine(i){return wt(i,{afterCursor:!0,brackets:fc,maxScanDistance:cc,renderMatch:fg})}}),hg=j.mark({class:"cm-matchingBracket"}),cg=j.mark({class:"cm-nonmatchingBracket"});function fg(i){let e=[],t=i.matched?hg:cg;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}var ug=ge.define({create(){return j.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(uc);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=Ke(e.state,r.head,-1,n)||r.head>0&&Ke(e.state,r.head-1,1,n)||n.afterCursor&&(Ke(e.state,r.head,1,n)||r.head<e.state.doc.length&&Ke(e.state,r.head+1,-1,n));s&&(t=t.concat(n.renderMatch(s,e.state)))}return j.set(t,!0)},provide:i=>v.decorations.from(i)}),dg=[ug,lg];function dc(i={}){return[uc.of(i),dg]}var yn=new Z;function No(i,e,t){let n=i.prop(e<0?Z.openedBy:Z.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function Fo(i){let e=i.type.prop(yn);return e?e(i.node):i}function Ke(i,e,t,n={}){let r=n.maxScanDistance||cc,s=n.brackets||fc,o=G(i),O=o.resolveInner(e,t);for(let a=O;a;a=a.parent){let h=No(a.type,t,s);if(h&&a.from<a.to){let l=Fo(a);if(l&&(t>0?e>=l.from&&e<l.to:e>l.from&&e<=l.to))return pg(i,e,t,a,l,h,s)}}return mg(i,e,t,o,O.type,r,s)}function pg(i,e,t,n,r,s,o){let O=n.parent,a={from:r.from,to:r.to},h=0,l=O?.cursor();if(l&&(t<0?l.childBefore(n.from):l.childAfter(n.to)))do if(t<0?l.to<=n.from:l.from>=n.to){if(h==0&&s.indexOf(l.type.name)>-1&&l.from<l.to){let c=Fo(l);return{start:a,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(No(l.type,t,o))h++;else if(No(l.type,-t,o)){if(h==0){let c=Fo(l);return{start:a,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(t<0?l.prevSibling():l.nextSibling());return{start:a,matched:!1}}function mg(i,e,t,n,r,s,o){let O=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(O);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},l=i.doc.iterRange(e,t>0?i.doc.length:0),c=0;for(let f=0;!l.next().done&&f<=s;){let d=l.value;t<0&&(f+=d.length);let p=e+f*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let $=o.indexOf(d[m]);if(!($<0||n.resolveInner(p+m,1).type!=r))if($%2==0==t>0)c++;else{if(c==1)return{start:h,end:{from:p+m,to:p+m+1},matched:$>>1==a>>1};c--}}t>0&&(f+=d.length)}return l.done?{start:h,matched:!1}:null}function ec(i,e,t,n=0,r=0){e==null&&(e=i.search(/[^\s\u00a0]/),e==-1&&(e=i.length));let s=r;for(let o=n;o<e;o++)i.charCodeAt(o)==9?s+=t-s%t:s++;return s}var qr=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ec(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:ec(this.string,null,this.tabSize)}match(e,t,n){if(typeof e=="string"){let r=o=>n?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return r(s)==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}};function gg(i){return{name:i.name||"",token:i.token,blankLine:i.blankLine||(()=>{}),startState:i.startState||(()=>!0),copyState:i.copyState||$g,indent:i.indent||(()=>null),languageData:i.languageData||{},tokenTable:i.tokenTable||tO}}function $g(i){if(typeof i!="object")return i;let e={};for(let t in i){let n=i[t];e[t]=n instanceof Array?n.slice():n}return e}var tc=new WeakMap,Vr=class i extends fe{constructor(e){let t=Wi(e.languageData),n=gg(e),r,s=new class extends St{createParse(o,O,a){return new Ho(r,o,O,a)}};super(t,s,[sc.of((o,O)=>this.getIndent(o,O))],e.name),this.topNode=Pg(t),r=this,this.streamParser=n,this.stateAfter=new Z({perNode:!0}),this.tokenTable=e.tokenTable?new Cr(n.tokenTable):yg}static define(e){return new i(e)}getIndent(e,t){let n=G(e.state),r=n.resolve(t);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let s,{overrideIndentation:o}=e.options;o&&(s=tc.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let O=eO(this,n,0,r.from,s??t),a,h;if(O?(h=O.state,a=O.pos+1):(h=this.streamParser.startState(e.unit),a=0),t-a>1e4)return null;for(;a<t;){let c=e.state.doc.lineAt(a),f=Math.min(t,c.to);if(c.length){let d=o?o(c.from):-1,p=new qr(c.text,e.state.tabSize,e.unit,d<0?void 0:d);for(;p.pos<f-c.from;)mc(this.streamParser.token,p,h)}else this.streamParser.blankLine(h,e.unit);if(f==t)break;a=c.to+1}let l=e.lineAt(t);return o&&s==null&&tc.set(e.state,l.from),this.streamParser.indent(h,/^\s*(.*)/.exec(l.text)[1],e)}get allowsNesting(){return!1}};function eO(i,e,t,n,r){let s=t>=n&&t+e.length<=r&&e.prop(i.stateAfter);if(s)return{state:i.streamParser.copyState(s),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let O=e.children[o],a=t+e.positions[o],h=O instanceof V&&a<r&&eO(i,O,a,n,r);if(h)return h}return null}function pc(i,e,t,n,r){if(r&&t<=0&&n>=e.length)return e;!r&&e.type==i.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],O=e.children[s],a;if(o<n&&O instanceof V){if(!(a=pc(i,O,t-o,n-o,r)))break;return r?new V(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function Qg(i,e,t,n){for(let r of e){let s=r.from+(r.openStart?25:0),o=r.to-(r.openEnd?25:0),O=s<=t&&o>t&&eO(i,r.tree,0-r.offset,t,o),a;if(O&&(a=pc(i,r.tree,t+r.offset,O.pos+r.offset,!1)))return{state:O.state,tree:a}}return{state:i.streamParser.startState(n?Yt(n):4),tree:V.empty}}var Ho=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let s=ri.get(),o=r[0].from,{state:O,tree:a}=Qg(e,n,o,s?.state);this.state=O,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(Yt(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=ri.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+2048);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`