1(()=>{let t,e,i=[],s=[];function n(t){return t>=127462&&t<=127487}function r(t,e,r){if(e==t.length)return e;e&&l(t.charCodeAt(e))&&h(t.charCodeAt(e-1))&&e--;let c=o(t,e);for(e+=a(c);e<t.length;){let l=o(t,e);if(8205==c||8205==l||r&&function(t){if(t<768)return!1;for(let e=0,n=i.length;;){let r=e+n>>1;if(t<i[r])n=r;else{if(!(t>=s[r]))return!0;e=r+1}if(e==n)return!1}}(l))e+=a(l),c=l;else if(n(l)){let i=0,s=e-2;for(;s>=0&&n(o(t,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function o(t,e){let i=t.charCodeAt(e);if(!h(i)||e+1==t.length)return i;let s=t.charCodeAt(e+1);return l(s)?(i-55296<<10)+(s-56320)+65536:i}function l(t){return t>=56320&&t<57344}function h(t){return t>=55296&&t<56320}function a(t){return t<65536?1:2}(()=>{let t="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(t=>t?parseInt(t,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?s:i).push(n+=t[e])})();class c{lineAt(t){if(t<0||t>this.length)throw RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=v(this,t,e);let s=[];return this.decompose(0,t,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(e,this.length,s,1),u.from(s,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=v(this,t,e);let i=[];return this.decompose(t,e,i,0),u.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),s=new p(this),n=new p(t);for(let t=e,r=e;;){if(s.next(t),n.next(t),t=0,s.lineBreak!=n.lineBreak||s.done!=n.done||s.value!=n.value)return!1;if(r+=s.value.length,s.done||r>=i)return!0}}iter(t=1){return new p(this,t)}iterRange(t,e=this.length){return new g(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let s=this.line(t).from;i=this.iterRange(s,Math.max(s,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new m(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new f(t):u.from(f.split(t,[])):c.empty}}class f extends c{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,s){for(let n=0;;n++){let r=this.text[n],o=s+r.length;if((e?i:o)>=t)return new w(s,o,i,r);s=o+1,i++}}decompose(t,e,i,s){var n;let r=t<=0&&e>=this.length?this:new f((n=this.text,d(n,[""],t,e)),Math.min(e,this.length)-Math.max(0,t));if(1&s){let t=i.pop(),e=d(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new f(e,t.length+r.length));else{let t=e.length>>1;i.push(new f(e.slice(0,t)),new f(e.slice(t)))}}else i.push(r)}replace(t,e,i){var s;if(!(i instanceof f))return super.replace(t,e,i);[t,e]=v(this,t,e);let n=d(this.text,d(i.text,(s=this.text,d(s,[""],0,t))),e),r=this.length+i.length-(e-t);return n.length<=32?new f(n,r):u.from(f.split(n,[]),r)}sliceString(t,e=this.length,i="\n"){[t,e]=v(this,t,e);let s="";for(let n=0,r=0;n<=e&&r<this.text.length;r++){let o=this.text[r],l=n+o.length;n>t&&r&&(s+=i),t<l&&e>n&&(s+=o.slice(Math.max(0,t-n),e-n)),n=l+1}return s}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],s=-1;for(let n of t)i.push(n),s+=n.length+1,32==i.length&&(e.push(new f(i,s)),i=[],s=-1);return s>-1&&e.push(new f(i,s)),e}}class u extends c{constructor(t,e){for(let i of(super(),this.children=t,this.length=e,this.lines=0,t))this.lines+=i.lines}lineInner(t,e,i,s){for(let n=0;;n++){let r=this.children[n],o=s+r.length,l=i+r.lines-1;if((e?l:o)>=t)return r.lineInner(t,e,i,s);s=o+1,i=l+1}}decompose(t,e,i,s){for(let n=0,r=0;r<=e&&n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(t<=l&&e>=r){let n=s&(r<=t|2*(l>=e));r>=t&&l<=e&&!n?i.push(o):o.decompose(t-r,e-r,i,n)}r=l+1}}replace(t,e,i){if([t,e]=v(this,t,e),i.lines<this.lines)for(let s=0,n=0;s<this.children.length;s++){let r=this.children[s],o=n+r.length;if(t>=n&&e<=o){let l=r.replace(t-n,e-n,i),h=this.lines-r.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let n=this.children.slice();return n[s]=l,new u(n,this.length-(e-t)+i.length)}return super.replace(n,o,l)}n=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=v(this,t,e);let s="";for(let n=0,r=0;n<this.children.length&&r<=e;n++){let o=this.children[n],l=r+o.length;r>t&&n&&(s+=i),t<l&&e>r&&(s+=o.sliceString(t-r,e-r,i)),r=l+1}return s}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof u))return 0;let i=0,[s,n,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;s+=e,n+=e){if(s==r||n==o)return i;let l=this.children[s],h=t.children[n];if(l!=h)return i+l.scanIdentical(h,e);i+=l.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new f(i,e)}let s=Math.max(32,i>>5),n=s<<1,r=s>>1,o=[],l=0,h=-1,a=[];function c(){0!=l&&(o.push(1==a.length?a[0]:u.from(a,h)),h=-1,l=a.length=0)}for(let e of t)!function t(e){let i;if(e.lines>n&&e instanceof u)for(let i of e.children)t(i);else e.lines>r&&(l>r||!l)?(c(),o.push(e)):e instanceof f&&l&&(i=a[a.length-1])instanceof f&&e.lines+i.lines<=32?(l+=e.lines,h+=e.length+1,a[a.length-1]=new f(i.text.concat(e.text),i.length+1+e.length)):(l+e.lines>s&&c(),l+=e.lines,h+=e.length+1,a.push(e))}(e);return c(),1==o.length?o[0]:new u(o,e)}}function d(t,e,i=0,s=1e9){for(let n=0,r=0,o=!0;r<t.length&&n<=s;r++){let l=t[r],h=n+l.length;h>=i&&(h>s&&(l=l.slice(0,s-n)),n<i&&(l=l.slice(i-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=h+1}return e}c.empty=new f([""],0);class p{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof f?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],n=this.offsets[i],r=n>>1,o=s instanceof f?s.text.length:s.children.length;if(r==(e>0?o:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&n)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(s instanceof f){let n=s.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,n.length>Math.max(0,t))return this.value=0==t?n:e>0?n.slice(t):n.slice(0,n.length-t),this;t-=n.length}else{let n=s.children[r+(e<0?-1:0)];t>n.length?(t-=n.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(n),this.offsets.push(e>0?1:(n instanceof f?n.text.length:n.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class g{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new p(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:s}=this.cursor.next(t);return this.pos+=(s.length+t)*e,this.value=s.length<=i?s:e<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class m{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:s}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=function(){return this.iter()},p.prototype[Symbol.iterator]=g.prototype[Symbol.iterator]=m.prototype[Symbol.iterator]=function(){return this});class w{constructor(t,e,i,s){this.from=t,this.to=e,this.number=i,this.text=s}get length(){return this.to-this.from}}function v(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function b(t,e,i=!0,s=!0){return function(t,e,i=!0,s=!0){return(i?r:function(t,e,i){for(;e>0;){let s=r(t,e-2,i);if(s<e)return s;e--}return 0})(t,e,s)}(t,e,i,s)}let y=/\r\n?|\n/;var k,x,S=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(S||(S={}));class C{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,s=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?(t(i,s,n),s+=n):s+=r,i+=n}}iterChangedRanges(t,e=!1){M(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],s=this.sections[e++];s<0?t.push(i,s):t.push(s,i)}return new C(t)}composeDesc(t){return this.empty?t:t.empty?this:D(this,t)}mapDesc(t,e=!1){return t.empty?this:T(this,t,e)}mapPos(t,e=-1,i=S.Simple){let s=0,n=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],l=this.sections[r++],h=s+o;if(l<0){if(h>t)return n+(t-s);n+=o}else{if(i!=S.Simple&&h>=t&&(i==S.TrackDel&&s<t&&h>t||i==S.TrackBefore&&s<t||i==S.TrackAfter&&h>t))return null;if(h>t||h==t&&e<0&&!o)return t==s||e<0?n:n+l;n+=l}s=h}if(t>s)throw RangeError(`Position ${t} is out of range for changeset of length ${s}`);return n}touchesRange(t,e=t){for(let i=0,s=0;i<this.sections.length&&s<=e;){let n=this.sections[i++],r=this.sections[i++],o=s+n;if(r>=0&&s<=e&&o>=t)return!(s<t)||!(o>e)||"cover";s=o}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],s=this.sections[e++];t+=(t?" ":"")+i+(s>=0?":"+s:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw RangeError("Invalid JSON representation of ChangeDesc");return new C(t)}static create(t){return new C(t)}}class A extends C{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw RangeError("Applying change set to a document with the wrong length");return M(this,(e,i,s,n,r)=>t=t.replace(s,s+(i-e),r),!1),t}mapDesc(t,e=!1){return T(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,n=0;s<e.length;s+=2){let r=e[s],o=e[s+1];if(o>=0){e[s]=o,e[s+1]=r;let l=s>>1;for(;i.length<l;)i.push(c.empty);i.push(r?t.slice(n,n+r):c.empty)}n+=r}return new A(e,i)}compose(t){return this.empty?t:t.empty?this:D(this,t,!0)}map(t,e=!1){return t.empty?this:T(this,t,e,!0)}iterChanges(t,e=!1){M(this,t,e)}get desc(){return C.create(this.sections)}filter(t){let e=[],i=[],s=[],n=new E(this);t:for(let r=0,o=0;;){let l=r==t.length?1e9:t[r++];for(;o<l||o==l&&0==n.len;){if(n.done)break t;let t=Math.min(n.len,l-o);P(s,t,-1);let r=-1==n.ins?-1:0==n.off?n.ins:0;P(e,t,r),r>0&&O(i,e,n.text),n.forward(t),o+=t}let h=t[r++];for(;o<h;){if(n.done)break t;let t=Math.min(n.len,h-o);P(e,t,-1),P(s,t,-1==n.ins?-1:0==n.off?n.ins:0),n.forward(t),o+=t}}return{changes:new A(e,i),filtered:C.create(s)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],s=this.sections[e+1];s<0?t.push(i):0==s?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let s=[],n=[],r=0,o=null;function l(t=!1){if(!t&&!s.length)return;r<e&&P(s,e-r,-1);let i=new A(s,n);o=o?o.compose(i.map(o)):i,s=[],n=[],r=0}return!function t(h){if(Array.isArray(h))for(let e of h)t(e);else if(h instanceof A){if(h.length!=e)throw RangeError(`Mismatched change set length (got ${h.length}, expected ${e})`);l(),o=o?o.compose(h.map(o)):h}else{let{from:t,to:o=t,insert:a}=h;if(t>o||t<0||o>e)throw RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let f=a?"string"==typeof a?c.of(a.split(i||y)):a:c.empty,u=f.length;if(t==o&&0==u)return;t<r&&l(),t>r&&P(s,t-r,-1),P(s,o-t,u),O(n,s,f),r=o}}(t),l(!o),o}static empty(t){return new A(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let n=t[s];if("number"==typeof n)e.push(n,-1);else if(!Array.isArray(n)||"number"!=typeof n[0]||n.some((t,e)=>e&&"string"!=typeof t))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==n.length)e.push(n[0],0);else{for(;i.length<s;)i.push(c.empty);i[s]=c.of(n.slice(1)),e.push(n[0],i[s].length)}}return new A(e,i)}static createSet(t,e){return new A(t,e)}}function P(t,e,i,s=!1){if(0==e&&i<=0)return;let n=t.length-2;n>=0&&i<=0&&i==t[n+1]?t[n]+=e:n>=0&&0==e&&0==t[n]?t[n+1]+=i:s?(t[n]+=e,t[n+1]+=i):t.push(e,i)}function O(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(c.empty);t.push(i)}}function M(t,e,i){let s=t.inserted;for(let n=0,r=0,o=0;o<t.sections.length;){let l=t.sections[o++],h=t.sections[o++];if(h<0)n+=l,r+=l;else{let a=n,f=r,u=c.empty;for(;a+=l,f+=h,h&&s&&(u=u.append(s[o-2>>1])),!i&&o!=t.sections.length&&!(t.sections[o+1]<0);)l=t.sections[o++],h=t.sections[o++];e(n,a,r,f,u),n=a,r=f}}}function T(t,e,i,s=!1){let n=[],r=s?[]:null,o=new E(t),l=new E(e);for(let t=-1;;)if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");else if(-1==o.ins&&-1==l.ins){let t=Math.min(o.len,l.len);P(n,t,-1),o.forward(t),l.forward(t)}else if(l.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!i))){let e=l.len;for(P(n,l.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(P(n,0,o.ins),r&&O(r,n,o.text),t=o.i),o.forward(i),e-=i}l.next()}else if(o.ins>=0){let e=0,i=o.len;for(;i;)if(-1==l.ins){let t=Math.min(i,l.len);e+=t,i-=t,l.forward(t)}else if(0==l.ins&&l.len<i)i-=l.len,l.next();else break;P(n,e,t<o.i?o.ins:0),r&&t<o.i&&O(r,n,o.text),t=o.i,o.forward(o.len-i)}else if(o.done&&l.done)return r?A.createSet(n,r):C.create(n);else throw Error("Mismatched change set lengths")}function D(t,e,i=!1){let s=[],n=i?[]:null,r=new E(t),o=new E(e);for(let t=!1;;)if(r.done&&o.done)return n?A.createSet(s,n):C.create(s);else if(0==r.ins)P(s,r.len,0,t),r.next();else if(0!=o.len||o.done)if(r.done||o.done)throw Error("Mismatched change set lengths");else{let e=Math.min(r.len2,o.len),i=s.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;P(s,e,i,t),n&&i&&O(n,s,o.text)}else -1==o.ins?(P(s,r.off?0:r.len,e,t),n&&O(n,s,r.textBit(e))):(P(s,r.off?0:r.len,o.off?0:o.ins,t),n&&!o.off&&O(n,s,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||s.length>i),r.forward2(e),o.forward(e)}else P(s,0,o.ins,t),n&&O(n,s,o.text),o.next()}class E{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return -2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?c.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?c.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class B{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 0xffffff==t?void 0:t}map(t,e=-1){let i,s;return this.empty?i=s=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),s=t.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new B(i,s,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return R.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return R.range(this.anchor,i)}eq(t,e=!1){return this.anchor==t.anchor&&this.head==t.head&&(!e||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid JSON representation for SelectionRange");return R.range(t.anchor,t.head)}static create(t,e,i){return new B(t,e,i)}}class R{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:R.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new R([this.main],0)}addRange(t,e=!0){return R.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,R.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new R(t.ranges.map(t=>B.fromJSON(t)),t.main)}static single(t,e=t){return new R([R.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw RangeError("A selection needs at least one range");for(let i=0,s=0;s<t.length;s++){let n=t[s];if(n.empty?n.from<=i:n.from<i)return R.normalized(t.slice(),e);i=n.to}return new R(t,e)}static cursor(t,e=0,i,s){return B.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=s?s:0xffffff)<<6)}static range(t,e,i,s){let n=(null!=i?i:0xffffff)<<6|(null==s?7:Math.min(6,s));return e<t?B.create(e,t,48|n):B.create(t,e,8*(e>t)|n)}static normalized(t,e=0){let i=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(i);for(let i=1;i<t.length;i++){let s=t[i],n=t[i-1];if(s.empty?s.from<=n.to:s.from<n.to){let r=n.from,o=Math.max(s.to,n.to);i<=e&&e--,t.splice(--i,2,s.anchor>s.head?R.range(o,r):R.range(r,o))}}return new R(t,e)}}function N(t,e){for(let i of t.ranges)if(i.to>e)throw RangeError("Selection points outside of document")}let L=0;class I{constructor(t,e,i,s,n){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=s,this.id=L++,this.default=t([]),this.extensions="function"==typeof n?n(this):n}get reader(){return this}static define(t={}){return new I(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(!t.combine?V:(t,e)=>t===e),!!t.static,t.enables)}of(t){return new H([],this,0,t)}compute(t,e){if(this.isStatic)throw Error("Can't compute a static facet");return new H(t,this,1,e)}computeN(t,e){if(this.isStatic)throw Error("Can't compute a static facet");return new H(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],i=>e(i.field(t)))}}function V(t,e){return t==e||t.length==e.length&&t.every((t,i)=>t===e[i])}class H{constructor(t,e,i,s){this.dependencies=t,this.facet=e,this.type=i,this.value=s,this.id=L++}dynamicSlot(t){var e;let i=this.value,s=this.facet.compareInput,n=this.id,r=t[n]>>1,o=2==this.type,l=!1,h=!1,a=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?h=!0:((null!=(e=t[i.id])?e:1)&1)==0&&a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(l&&e.docChanged||h&&(e.docChanged||e.selection)||z(t,a)){let e=i(t);if(o?!W(e,t.values[r],s):!s(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let l,h=e.config.address[n];if(null!=h){let n=Q(e,h);if(this.dependencies.every(i=>i instanceof I?e.facet(i)===t.facet(i):!(i instanceof q)||e.field(i,!1)==t.field(i,!1))||(o?W(l=i(t),n,s):s(l=i(t),n)))return t.values[r]=n,0}else l=i(t);return t.values[r]=l,1}}}}function W(t,e,i){if(t.length!=e.length)return!1;for(let s=0;s<t.length;s++)if(!i(t[s],e[s]))return!1;return!0}function z(t,e){let i=!1;for(let s of e)1&G(t,s)&&(i=!0);return i}let F=I.define({static:!0});class q{constructor(t,e,i,s,n){this.id=t,this.createF=e,this.updateF=i,this.compareF=s,this.spec=n,this.provides=void 0}static define(t){let e=new q(L++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(F).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let s=t.values[e],n=this.updateF(s,i);return this.compareF(s,n)?0:(t.values[e]=n,1)},reconfigure:(t,i)=>{let s=t.facet(F),n=i.facet(F),r;return(r=s.find(t=>t.field==this))&&r!=n.find(t=>t.field==this)?(t.values[e]=r.create(t),1):null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,F.of({field:this,create:t})]}get extension(){return this}}let _={lowest:4,low:3,default:2,high:1,highest:0};function j(t){return e=>new Y(e,t)}let U={highest:j(_.highest),high:j(_.high),default:j(_.default),low:j(_.low),lowest:j(_.lowest)};class Y{constructor(t,e){this.inner=t,this.prec=e}}class X{of(t){return new $(this,t)}reconfigure(t){return X.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class ${constructor(t,e){this.compartment=t,this.inner=e}}class K{constructor(t,e,i,s,n,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=s,this.staticValues=n,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){var s,n,r;let o,l,h=[],a=Object.create(null),c=new Map;for(let i of(s=t,n=e,r=c,o=[[],[],[],[],[]],l=new Map,!function t(e,i){let s=l.get(e);if(null!=s){if(s<=i)return;let t=o[s].indexOf(e);t>-1&&o[s].splice(t,1),e instanceof $&&r.delete(e.compartment)}if(l.set(e,i),Array.isArray(e))for(let s of e)t(s,i);else if(e instanceof $){if(r.has(e.compartment))throw RangeError("Duplicate use of compartment in extensions");let s=n.get(e.compartment)||e.inner;r.set(e.compartment,s),t(s,i)}else if(e instanceof Y)t(e.inner,e.prec);else if(e instanceof q)o[i].push(e),e.provides&&t(e.provides,i);else if(e instanceof H)o[i].push(e),e.facet.extensions&&t(e.facet.extensions,_.default);else{let s=e.extension;if(!s)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);t(s,i)}}(s,_.default),o.reduce((t,e)=>t.concat(e))))i instanceof q?h.push(i):(a[i.facet.id]||(a[i.facet.id]=[])).push(i);let f=Object.create(null),u=[],d=[];for(let t of h)f[t.id]=d.length<<1,d.push(e=>t.slot(e));let p=null==i?void 0:i.config.facets;for(let t in a){let e=a[t],s=e[0].facet,n=p&&p[t]||[];if(e.every(t=>0==t.type))if(f[s.id]=u.length<<1|1,V(n,e))u.push(i.facet(s));else{let t=s.combine(e.map(t=>t.value));u.push(i&&s.compare(t,i.facet(s))?i.facet(s):t)}else{for(let t of e)0==t.type?(f[t.id]=u.length<<1|1,u.push(t.value)):(f[t.id]=d.length<<1,d.push(e=>t.dynamicSlot(e)));f[s.id]=d.length<<1,d.push(t=>(function(t,e,i){let s=i.map(e=>t[e.id]),n=i.map(t=>t.type),r=s.filter(t=>!(1&t)),o=t[e.id]>>1;function l(t){let i=[];for(let e=0;e<s.length;e++){let r=Q(t,s[e]);if(2==n[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of s)G(t,e);return t.values[o]=l(t),1},update(t,i){if(!z(t,r))return 0;let s=l(t);return e.compare(s,t.values[o])?0:(t.values[o]=s,1)},reconfigure(t,n){let r=z(t,s),h=n.config.facets[e.id],a=n.facet(e);if(h&&!r&&V(i,h))return t.values[o]=a,0;let c=l(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}})(t,s,e))}}return new K(t,c,d.map(t=>t(f)),f,u,a)}}function G(t,e){if(1&e)return 2;let i=e>>1,s=t.status[i];if(4==s)throw Error("Cyclic dependency between fields and/or facets");if(2&s)return s;t.status[i]=4;let n=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|n}function Q(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}let J=I.define(),Z=I.define({combine:t=>t.some(t=>t),static:!0}),tt=I.define({combine:t=>t.length?t[0]:void 0,static:!0}),te=I.define(),ti=I.define(),ts=I.define(),tn=I.define({combine:t=>!!t.length&&t[0]});class tr{constructor(t,e){this.type=t,this.value=e}static define(){return new to}}class to{of(t){return new tr(this,t)}}class tl{constructor(t){this.map=t}of(t){return new th(this,t)}}class th{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new th(this.type,e)}is(t){return this.type==t}static define(t={}){return new tl(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let s of t){let t=s.map(e);t&&i.push(t)}return i}}th.reconfigure=th.define(),th.appendConfig=th.define();class ta{constructor(t,e,i,s,n,r){this.startState=t,this.changes=e,this.selection=i,this.effects=s,this.annotations=n,this.scrollIntoView=r,this._doc=null,this._state=null,i&&N(i,e.newLength),n.some(t=>t.type==ta.time)||(this.annotations=n.concat(ta.time.of(Date.now())))}static create(t,e,i,s,n,r){return new ta(t,e,i,s,n,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(ta.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function tc(t,e,i){var s;let n,r,o;return i?(n=e.changes,r=A.empty(e.changes.length),o=t.changes.compose(e.changes)):(n=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):null==(s=t.selection)?void 0:s.map(n),effects:th.mapEffects(t.effects,n).concat(th.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function tf(t,e,i){let s=e.selection,n=td(e.annotations);return e.userEvent&&(n=n.concat(ta.userEvent.of(e.userEvent))),{changes:e.changes instanceof A?e.changes:A.of(e.changes||[],i,t.facet(tt)),selection:s&&(s instanceof R?s:R.single(s.anchor,s.head)),effects:td(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}ta.time=tr.define(),ta.userEvent=tr.define(),ta.addToHistory=tr.define(),ta.remote=tr.define();let tu=[];function td(t){return null==t?tu:Array.isArray(t)?t:[t]}var tp=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(tp||(tp={}));let tg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{t=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}class tm{constructor(t,e,i,s,n,r){this.config=t,this.doc=e,this.selection=i,this.values=s,this.status=t.statusTemplate.slice(),this.computeSlot=n,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)G(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null==i){if(e)throw RangeError("Field is not present in this state");return}return G(this,i),Q(this,i)}update(...t){return function t(e,i,s){let n=tf(e,i.length?i[0]:{},e.doc.length);i.length&&!1===i[0].filter&&(s=!1);for(let t=1;t<i.length;t++){!1===i[t].filter&&(s=!1);let r=!!i[t].sequential;n=tc(n,tf(e,i[t],r?n.changes.newLength:e.doc.length),r)}let r=ta.create(e,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(ts),s=t;for(let n=i.length-1;n>=0;n--){let r=i[n](t);r&&Object.keys(r).length&&(s=tc(s,tf(e,r,t.changes.newLength),!0))}return s==t?t:ta.create(e,t.changes,t.selection,s.effects,s.annotations,s.scrollIntoView)}(s?function(e){let i=e.startState,s=!0;for(let t of i.facet(te)){let i=t(e);if(!1===i){s=!1;break}Array.isArray(i)&&(s=!0===s?i:function(t,e){let i=[];for(let s=0,n=0;;){let r,o;if(s<t.length&&(n==e.length||e[n]>=t[s]))r=t[s++],o=t[s++];else{if(!(n<e.length))return i;r=e[n++],o=e[n++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}(s,i))}if(!0!==s){let t,n;if(!1===s)n=e.changes.invertedDesc,t=A.empty(i.doc.length);else{let i=e.changes.filter(s);t=i.changes,n=i.filtered.mapDesc(i.changes).invertedDesc}e=ta.create(i,t,e.selection&&e.selection.map(n),th.mapEffects(e.effects,n),e.annotations,e.scrollIntoView)}let n=i.facet(ti);for(let s=n.length-1;s>=0;s--){let r=n[s](e);e=r instanceof ta?r:Array.isArray(r)&&1==r.length&&r[0]instanceof ta?r[0]:t(i,td(r),!1)}return e}(r):r)}(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:s,compartments:n}=i;for(let e of t.effects)e.is(X.reconfigure)?(i&&(n=new Map,i.compartments.forEach((t,e)=>n.set(e,t)),i=null),n.set(e.value.compartment,e.value.extension)):e.is(th.reconfigure)?(i=null,s=e.value):e.is(th.appendConfig)&&(i=null,s=td(s).concat(e.value));e=i?t.startState.values.slice():new tm(i=K.resolve(s,n,this),this.doc,this.selection,i.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values;let r=t.startState.facet(Z)?t.newSelection:t.newSelection.asSingle();new tm(i,t.newDoc,r,e,(e,i)=>i.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:R.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),s=this.changes(i.changes),n=[i.range],r=td(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),l=this.changes(o.changes),h=l.map(s);for(let t=0;t<i;t++)n[t]=n[t].map(h);let a=s.mapDesc(l,!0);n.push(o.range.map(a)),s=s.compose(h),r=th.mapEffects(r,h).concat(th.mapEffects(td(o.effects),a))}return{changes:s,selection:R.create(n,e.mainIndex),effects:r}}changes(t=[]){return t instanceof A?t:A.of(t,this.doc.length,this.facet(tm.lineSeparator))}toText(t){return c.of(t.split(this.facet(tm.lineSeparator)||y))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(G(this,e),Q(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let s=t[i];s instanceof q&&null!=this.config.address[s.id]&&(e[i]=s.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let n=i[e],r=t[e];s.push(n.init(t=>n.spec.fromJSON(r,t)))}}return tm.create({doc:t.doc,selection:R.fromJSON(t.selection),extensions:e.extensions?s.concat([e.extensions]):s})}static create(t={}){let e=K.resolve(t.extensions||[],new Map),i=t.doc instanceof c?t.doc:c.of((t.doc||"").split(e.staticFacet(tm.lineSeparator)||y)),s=t.selection?t.selection instanceof R?t.selection:R.single(t.selection.anchor,t.selection.head):R.single(0);return N(s,i.length),e.staticFacet(Z)||(s=s.asSingle()),new tm(e,i,s,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(tm.tabSize)}get lineBreak(){return this.facet(tm.lineSeparator)||"\n"}get readOnly(){return this.facet(tn)}phrase(t,...e){for(let e of this.facet(tm.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,i)=>{if("$"==i)return"$";let s=+(i||1);return!s||s>e.length?t:e[s-1]})),t}languageDataAt(t,e,i=-1){let s=[];for(let n of this.facet(J))for(let r of n(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&s.push(r[t]);return s}charCategorizer(e){var i;return i=this.languageDataAt("wordChars",e).join(""),e=>{if(!/\S/.test(e))return tp.Space;if(function(e){if(t)return t.test(e);for(let t=0;t<e.length;t++){let i=e[t];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||tg.test(i)))return!0}return!1}(e))return tp.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return tp.Word;return tp.Other}}wordAt(t){let{text:e,from:i,length:s}=this.doc.lineAt(t),n=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=b(e,r,!1);if(n(e.slice(t,r))!=tp.Word)break;r=t}for(;o<s;){let t=b(e,o);if(n(e.slice(o,t))!=tp.Word)break;o=t}return r==o?null:R.range(r+i,o+i)}}function tw(t,e,i={}){let s={};for(let e of t)for(let t of Object.keys(e)){let n=e[t],r=s[t];if(void 0===r)s[t]=n;else if(r===n||void 0===n);else if(Object.hasOwnProperty.call(i,t))s[t]=i[t](r,n);else throw Error("Config merge conflict for field "+t)}for(let t in e)void 0===s[t]&&(s[t]=e[t]);return s}tm.allowMultipleSelections=Z,tm.tabSize=I.define({combine:t=>t.length?t[0]:4}),tm.lineSeparator=tt,tm.readOnly=tn,tm.phrases=I.define({compare(t,e){let i=Object.keys(t),s=Object.keys(e);return i.length==s.length&&i.every(i=>t[i]==e[i])}}),tm.languageData=J,tm.changeFilter=te,tm.transactionFilter=ti,tm.transactionExtender=ts,X.reconfigure=th.define();class tv{eq(t){return this==t}range(t,e=t){return tb.create(t,e,this)}}tv.prototype.startSide=tv.prototype.endSide=0,tv.prototype.point=!1,tv.prototype.mapMode=S.TrackDel;class tb{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new tb(t,e,i)}}function ty(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class tk{constructor(t,e,i,s){this.from=t,this.to=e,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,s=0){let n=i?this.to:this.from;for(let r=s,o=n.length;;){if(r==o)return r;let s=r+o>>1,l=n[s]-t||(i?this.value[s].endSide:this.value[s].startSide)-e;if(s==r)return l>=0?r:o;l>=0?o=s:r=s+1}}between(t,e,i,s){for(let n=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,n);n<r;n++)if(!1===s(this.from[n]+t,this.to[n]+t,this.value[n]))return!1}map(t,e){let i=[],s=[],n=[],r=-1,o=-1;for(let l=0;l<this.value.length;l++){let h=this.value[l],a=this.from[l]+t,c=this.to[l]+t,f,u;if(a==c){let t=e.mapPos(a,h.startSide,h.mapMode);if(null==t||(f=u=t,h.startSide!=h.endSide&&(u=e.mapPos(a,h.endSide))<f))continue}else if((f=e.mapPos(a,h.startSide))>(u=e.mapPos(c,h.endSide))||f==u&&h.startSide>0&&h.endSide<=0)continue;0>(u-f||h.endSide-h.startSide)||(r<0&&(r=f),h.point&&(o=Math.max(o,u-f)),i.push(h),s.push(f-r),n.push(u-r))}return{mapped:i.length?new tk(s,n,i,o):null,pos:r}}}class tx{constructor(t,e,i,s){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=s}static create(t,e,i,s){return new tx(t,e,i,s)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:s=0,filterTo:n=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(ty)),this.isEmpty)return e.length?tx.of(e):this;let o=new tA(this,null,-1).goto(0),l=0,h=[],a=new tS;for(;o.value||l<e.length;)if(l<e.length&&(o.from-e[l].from||o.startSide-e[l].value.startSide)>=0){let t=e[l++];a.addInner(t.from,t.to,t.value)||h.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==e.length||this.chunkEnd(o.chunkIndex)<e[l].from)&&(!r||s>this.chunkEnd(o.chunkIndex)||n<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||s>o.to||n<o.from||r(o.from,o.to,o.value))&&!a.addInner(o.from,o.to,o.value)&&h.push(tb.create(o.from,o.to,o.value)),o.next());return a.finishInner(this.nextLayer.isEmpty&&!h.length?tx.empty:this.nextLayer.update({add:h,filter:r,filterFrom:s,filterTo:n}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],s=-1;for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],o=this.chunk[n],l=t.touchesRange(r,r+o.length);if(!1===l)s=Math.max(s,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===l){let{mapped:n,pos:l}=o.map(r,t);n&&(s=Math.max(s,n.maxPoint),e.push(n),i.push(l))}}let n=this.nextLayer.map(t);return 0==e.length?n:new tx(i,e,n||tx.empty,s)}between(t,e,i){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let n=this.chunkPos[s],r=this.chunk[s];if(e>=n&&t<=n+r.length&&!1===r.between(n,t-n,e-n,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return tP.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return tP.from(t).goto(e)}static compare(t,e,i,s,n=-1){let r=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=n),o=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=n),l=tC(r,o,i),h=new tM(r,l,n),a=new tM(o,l,n);i.iterGaps((t,e,i)=>tT(h,t,a,e,i,s)),i.empty&&0==i.length&&tT(h,0,a,0,0,s)}static eq(t,e,i=0,s){null==s&&(s=0x3b9ac9ff);let n=t.filter(t=>!t.isEmpty&&0>e.indexOf(t)),r=e.filter(e=>!e.isEmpty&&0>t.indexOf(e));if(n.length!=r.length)return!1;if(!n.length)return!0;let o=tC(n,r),l=new tM(n,o,0).goto(i),h=new tM(r,o,0).goto(i);for(;;){if(l.to!=h.to||!tD(l.active,h.active)||l.point&&(!h.point||!l.point.eq(h.point)))return!1;if(l.to>s)return!0;l.next(),h.next()}}static spans(t,e,i,s,n=-1){let r=new tM(t,null,n).goto(e),o=e,l=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),n=r.pointFrom<e?i.length+1:r.point.startSide<0?i.length:Math.min(i.length,l);s.point(o,t,r.point,i,n,r.pointRank),l=Math.min(r.openEnd(t),i.length)}else t>o&&(s.span(o,t,r.active,l),l=r.openEnd(t));if(r.to>i)return l+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new tS;for(let s of t instanceof tb?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let s=t[i];if(ty(e,s)>0)return t.slice().sort(ty);e=s}return t}(t):t)i.add(s.from,s.to,s.value);return i.finish()}static join(t){if(!t.length)return tx.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let s=t[i];s!=tx.empty;s=s.nextLayer)e=new tx(s.chunkPos,s.chunk,e,Math.max(s.maxPoint,e.maxPoint));return e}}tx.empty=new tx([],[],null,-1),tx.empty.nextLayer=tx.empty;class tS{finishChunk(t){this.chunks.push(new tk(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new tS)).add(t,e,i)}addInner(t,e,i){let s=t-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&0>(t-this.lastFrom||i.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(s<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if(0>(t-this.lastTo||e.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(tx.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=tx.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function tC(t,e,i){let s=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&s.set(e.chunk[t],e.chunkPos[t]);let n=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=s.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||n.add(t.chunk[e])}return n}class tA{constructor(t,e,i,s=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(t,e){0>(this.to-t||this.endSide-e)&&this.gotoInner(t,e,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class tP{constructor(t){this.heap=t}static from(t,e=null,i=-1){let s=[];for(let n=0;n<t.length;n++)for(let r=t[n];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&s.push(new tA(r,e,i,n));return 1==s.length?s[0]:new tP(s)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)tO(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)tO(this.heap,t);0>(this.to-t||this.value.endSide-e)&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),tO(this.heap,0)}}}function tO(t,e){for(let i=t[e];;){let s=(e<<1)+1;if(s>=t.length)break;let n=t[s];if(s+1<t.length&&n.compare(t[s+1])>=0&&(n=t[s+1],s++),0>i.compare(n))break;t[s]=i,t[e]=n,e=s}}class tM{constructor(t,e,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=tP.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e);)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){tE(this.active,t),tE(this.activeTo,t),tE(this.activeRank,t),this.minActive=tR(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:s,rank:n}=this.cursor;for(;e<this.activeRank.length&&(n-this.activeRank[e]||s-this.activeTo[e])>0;)e++;tB(this.active,e,i),tB(this.activeTo,e,s),tB(this.activeRank,e,n),t&&tB(t,e,this.cursor.from),this.minActive=tR(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&0>(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)){if(this.activeTo[s]>t){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&tE(i,s)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let t=this.cursor.value;if(t.point)if(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}else this.addActive(i),this.cursor.next()}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function tT(t,e,i,s,n,r){t.goto(e),i.goto(s);let o=s+n,l=s,h=s-e;for(;;){let e=t.to+h-i.to,s=e||t.endSide-i.endSide,n=s<0?t.to+h:i.to,a=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&tD(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(l,a,t.point,i.point):a>l&&!tD(t.active,i.active)&&r.compareRange(l,a,t.active,i.active),n>o)break;(e||t.openEnd!=i.openEnd)&&r.boundChange&&r.boundChange(n),l=n,s<=0&&t.next(),s>=0&&i.next()}}function tD(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function tE(t,e){for(let i=e,s=t.length-1;i<s;i++)t[i]=t[i+1];t.pop()}function tB(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function tR(t,e){let i=-1,s=1e9;for(let n=0;n<e.length;n++)0>(e[n]-s||t[n].endSide-t[i].endSide)&&(i=n,s=e[n]);return i}function tN(t,e,i=t.length){let s=0;for(let n=0;n<i&&n<t.length;)9==t.charCodeAt(n)?(s+=e-s%e,n++):(s++,n=b(t,n));return s}let tL="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),tI="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),tV="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class tH{constructor(t,e){this.rules=[];let{finish:i}=e||{};function s(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}for(let e in t)!function t(e,n,r,o){let l=[],h=/^@(\w+)\b/.exec(e[0]),a=h&&"keyframes"==h[1];if(h&&null==n)return r.push(e[0]+";");for(let i in n){let o=n[i];if(/&/.test(i))t(i.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((t,e)=>t.concat(e)),o,r);else if(o&&"object"==typeof o){if(!h)throw RangeError("The value of a property ("+i+") should be a primitive value.");t(s(i),o,l,a)}else null!=o&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+o+";")}(l.length||a)&&r.push((i&&!h&&!o?e.map(i):e).join(", ")+" {"+l.join(" ")+"}")}(s(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=tV[tL]||1;return tV[tL]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let s=t[tI],n=i&&i.nonce;s?n&&s.setNonce(n):s=new tz(t,n),s.mount(Array.isArray(e)?e:[e],t)}}let tW=new Map;class tz{constructor(t,e){let i=t.ownerDocument||t,s=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&s.CSSStyleSheet){let e=tW.get(i);if(e)return t[tI]=e;this.sheet=new s.CSSStyleSheet,tW.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[tI]=this}mount(t,e){let i=this.sheet,s=0,n=0;for(let e=0;e<t.length;e++){let r=t[e],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),i)for(let t=0;t<r.rules.length;t++)i.insertRule(r.rules[t],s++)}else{for(;n<o;)s+=this.modules[n++].rules.length;s+=r.rules.length,n++}}if(i)0>e.adoptedStyleSheets.indexOf(this.sheet)&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t;let i=e.head||e;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}for(var tF={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:"'"},tq={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},t_="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),tj="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),tU=0;tU<10;tU++)tF[48+tU]=tF[96+tU]=String(tU);for(var tU=1;tU<=24;tU++)tF[tU+111]="F"+tU;for(var tU=65;tU<=90;tU++)tF[tU]=String.fromCharCode(tU+32),tq[tU]=String.fromCharCode(tU);for(var tY in tF)tq.hasOwnProperty(tY)||(tq[tY]=tF[tY]);function tX(t){return(11==t.nodeType?t.getSelection?t:t.ownerDocument:t).getSelection()}function t$(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function tK(t,e){if(!e.anchorNode)return!1;try{return t$(t,e.anchorNode)}catch(t){return!1}}function tG(t){return 3==t.nodeType?t6(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function tQ(t,e,i,s){return!!i&&(t0(t,e,i,s,-1)||t0(t,e,i,s,1))}function tJ(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function tZ(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function t0(t,e,i,s,n){for(;;){if(t==i&&e==s)return!0;if(e==(n<0?0:t1(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=tJ(t)+(n<0?0:1),t=i}else{if(1!=t.nodeType||1==(t=t.childNodes[e+(n<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=n<0?t1(t):0}}}function t1(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function t2(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function t3(t,e){let i=e.width/t.offsetWidth,s=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(e.width-t.offsetWidth))&&(i=1),(s>.995&&s<1.005||!isFinite(s)||1>Math.abs(e.height-t.offsetHeight))&&(s=1),{scaleX:i,scaleY:s}}class t4{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?t1(e):0),i,Math.min(t.focusOffset,i?t1(i):0))}set(t,e,i,s){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=s}}let t5=null;function t8(t){if(t.setActive)return t.setActive();if(t5)return t.focus(t5);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==t5?{get preventScroll(){return t5={preventScroll:!0},!0}}:void 0),!t5){t5=!1;for(let t=0;t<e.length;){let i=e[t++],s=e[t++],n=e[t++];i.scrollTop!=s&&(i.scrollTop=s),i.scrollLeft!=n&&(i.scrollLeft=n)}}}function t6(t,i,s=i){let n=e||(e=document.createRange());return n.setEnd(t,s),n.setStart(t,i),n}function t9(t,e,i,s){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0};s&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=s);let r=new KeyboardEvent("keydown",n);r.synthetic=!0,t.dispatchEvent(r);let o=new KeyboardEvent("keyup",n);return o.synthetic=!0,t.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function t7(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function et(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function ee(t,e){for(let i=t,s=e;;)if(3==i.nodeType&&s>0)return{node:i,offset:s};else if(1==i.nodeType&&s>0){if("false"==i.contentEditable)return null;s=t1(i=i.childNodes[s-1])}else{if(!i.parentNode||tZ(i))return null;s=tJ(i),i=i.parentNode}}function ei(t,e){for(let i=t,s=e;;)if(3==i.nodeType&&s<i.nodeValue.length)return{node:i,offset:s};else if(1==i.nodeType&&s<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[s],s=0}else{if(!i.parentNode||tZ(i))return null;s=tJ(i)+1,i=i.parentNode}}class es{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new es(t.parentNode,tJ(t),e)}static after(t,e){return new es(t.parentNode,tJ(t)+1,e)}}let en=[];class er{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(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i=this.dom,s=null,n;for(let r of this.children){if(7&r.flags){if(!r.dom&&(n=s?s.nextSibling:i.firstChild)){let t=er.get(n);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(n)}r.sync(t,e),r.flags&=-8}if(n=s?s.nextSibling:i.firstChild,e&&!e.written&&e.node==i&&n!=r.dom&&(e.written=!0),r.dom.parentNode==i)for(;n&&n!=r.dom;)n=eo(n);else i.insertBefore(r.dom,n);s=r.dom}for((n=s?s.nextSibling:i.firstChild)&&e&&e.node==i&&(e.written=!0);n;)n=eo(n)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let s=0==t1(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==s&&e.firstChild!=e.lastChild&&(s=t==e.firstChild?-1:1),t=e}i=s<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!er.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let s=this.children[t];if(s.dom==i)return e;e+=s.length+s.breakAfter}}domBoundsAround(t,e,i=0){let s=-1,n=-1,r=-1,o=-1;for(let l=0,h=i,a=i;l<this.children.length;l++){let i=this.children[l],c=h+i.length;if(h<t&&c>e)return i.domBoundsAround(t,e,h);if(c>=t&&-1==s&&(s=l,n=h),h>e&&i.dom.parentNode==this.dom){r=l,o=a;break}a=c,h=c+i.breakAfter}return{from:n,to:o<0?i+this.length:o,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=en){this.markDirty();for(let s=t;s<e;s++){let t=this.children[s];t.parent==this&&0>i.indexOf(t)&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new el(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,s,n,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!((this.flags|t.flags)&8)}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function eo(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}er.prototype.breakAfter=0;class el{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function eh(t,e,i,s,n,r,o,l,h){let{children:a}=t,c=a.length?a[e]:null,f=r.length?r[r.length-1]:null,u=f?f.breakAfter:o;if(!(e==s&&c&&!o&&!u&&r.length<2&&c.merge(i,n,r.length?f:null,0==i,l,h))){if(s<a.length){let t=a[s];t&&(n<t.length||t.breakAfter&&(null==f?void 0:f.breakAfter))?(e==s&&(t=t.split(n),n=0),!u&&f&&t.merge(0,n,f,!0,0,h)?r[r.length-1]=t:((n||t.children.length&&!t.children[0].length)&&t.merge(0,n,null,!1,0,h),r.push(t))):(null==t?void 0:t.breakAfter)&&(f?f.breakAfter=1:o=1),s++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));e<s&&r.length;)if(a[s-1].become(r[r.length-1]))s--,r.pop(),h=r.length?0:l;else if(a[e].become(r[0]))e++,r.shift(),l=r.length?0:h;else break;!r.length&&e&&s<a.length&&!a[e-1].breakAfter&&a[s].merge(0,0,a[e-1],!1,l,h)&&e--,(e<s||r.length)&&t.replaceChildren(e,s,r)}}function ea(t,e,i,s,n,r){let o=t.childCursor(),{i:l,off:h}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),f=e-i;for(let t of s)f+=t.length;t.length+=f,eh(t,a,c,l,h,s,0,n,r)}let ec="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},ef="undefined"!=typeof document?document:{documentElement:{style:{}}},eu=/Edge\/(\d+)/.exec(ec.userAgent),ed=/MSIE \d/.test(ec.userAgent),ep=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ec.userAgent),eg=!!(ed||ep||eu),em=!eg&&/gecko\/(\d+)/i.test(ec.userAgent),ew=!eg&&/Chrome\/(\d+)/.exec(ec.userAgent),ev="webkitFontSmoothing"in ef.documentElement.style,eb=!eg&&/Apple Computer/.test(ec.vendor),ey=eb&&(/Mobile\/\w+/.test(ec.userAgent)||ec.maxTouchPoints>2);var ek={mac:ey||/Mac/.test(ec.platform),windows:/Win/.test(ec.platform),linux:/Linux|X11/.test(ec.platform),ie:eg,ie_version:ed?ef.documentMode||6:ep?+ep[1]:eu?+eu[1]:0,gecko:em,gecko_version:em?+(/Firefox\/(\d+)/.exec(ec.userAgent)||[0,0])[1]:0,chrome:!!ew,chrome_version:ew?+ew[1]:0,ios:ey,android:/Android\b/.test(ec.userAgent),webkit:ev,safari:eb,webkit_version:ev?+(/\bAppleWebKit\/(\d+)/.exec(ec.userAgent)||[0,0])[1]:0,tabSize:null!=ef.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class ex extends er{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags)&&(!i||i instanceof ex&&!(this.length-(e-t)+i.length>256)&&!(8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new ex(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new es(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let s=t.nodeValue.length;e>s&&(e=s);let n=e,r=e,o=0;0==e&&i<0||e==s&&i>=0?!(ek.chrome||ek.gecko)&&(e?(n--,o=1):r<s&&(r++,o=-1)):i<0?n--:r<s&&r++;let l=t6(t,n,r).getClientRects();if(!l.length)return null;let h=l[(o?o<0:i>=0)?0:l.length-1];return ek.safari&&!o&&0==h.width&&(h=Array.prototype.find.call(l,t=>t.width)||h),o?t2(h,o<0):h||null}(this.dom,t,e)}}class eS extends er{constructor(t,e=[],i=0){for(let s of(super(),this.mark=t,this.children=e,this.length=i,e))s.setParent(this)}setAttrs(t){if(t7(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!((this.flags|t.flags)&8)}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,s,n,r){return(!i||!!(i instanceof eS&&i.mark.eq(this.mark))&&(!t||!(n<=0))&&(!(e<this.length)||!(r<=0)))&&(ea(this,t,e,i?i.children.slice():[],n-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,s=-1,n=0;for(let r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),s<0&&i>=t&&(s=n),i=o,n++}let r=this.length-t;return this.length=t,s>-1&&(this.children.length=s,this.markDirty()),new eS(this.mark,e,r)}domAtPos(t){return eP(this,t)}coordsAt(t,e){return eO(this,t,e)}}class eC extends er{static create(t,e,i){return new eC(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=eC.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,s,n,r){return(!i||i instanceof eC&&!!this.widget.compare(i.widget)&&(!(t>0)||!(n<=0))&&(!(e<this.length)||!(r<=0)))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof eC&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return c.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):c.empty}domAtPos(t){return(this.length?0==t:this.side>0)?es.before(this.dom):es.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let s=this.dom.getClientRects(),n=null;if(!s.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?s.length-1:0;n=s[e],t>0?0!=e:e!=s.length-1&&!(n.top<n.bottom);e+=r?-1:1);return t2(n,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class eA extends er{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof eA&&t.side==this.side}split(){return new eA(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?es.before(this.dom):es.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return c.empty}get isHidden(){return!0}}function eP(t,e){let i=t.dom,{children:s}=t,n=0;for(let t=0;n<s.length;n++){let r=s[n],o=t+r.length;if(!(o==t&&0>=r.getSide())){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=n;t>0;t--){let e=s[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=n;t<s.length;t++){let e=s[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new es(i,0)}function eO(t,e,i){let s=null,n=-1,r=null,o=-1;!function t(e,l){for(let h=0,a=0;h<e.children.length&&a<=l;h++){let c=e.children[h],f=a+c.length;f>=l&&(c.children.length?t(c,l-a):(!r||r.isHidden&&(i>0||function(t,e){let i=t.coordsAt(0,1),s=e.coordsAt(0,1);return i&&s&&s.top<i.bottom}(r,c)))&&(f>l||a==f&&c.getSide()>0)?(r=c,o=l-a):(a<l||a==f&&0>c.getSide()&&!c.isHidden)&&(s=c,n=l-a)),a=f}}(t,e);let l=(i<0?s:r)||s||r;return l?l.coordsAt(Math.max(0,l==s?n:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=tG(e);return i[i.length-1]||null}(t)}function eM(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}ex.prototype.children=eC.prototype.children=eA.prototype.children=en;let eT=Object.create(null);function eD(t,e,i){if(t==e)return!0;t||(t=eT),e||(e=eT);let s=Object.keys(t),n=Object.keys(e);if(s.length-(i&&s.indexOf(i)>-1?1:0)!=n.length-(i&&n.indexOf(i)>-1?1:0))return!1;for(let r of s)if(r!=i&&(-1==n.indexOf(r)||t[r]!==e[r]))return!1;return!0}function eE(t,e,i){let s=!1;if(e)for(let n in e)i&&n in i||(s=!0,"style"==n?t.style.cssText="":t.removeAttribute(n));if(i)for(let n in i)e&&e[n]==i[n]||(s=!0,"style"==n?t.style.cssText=i[n]:t.setAttribute(n,i[n]));return s}class eB{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var eR=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(eR||(eR={}));class eN extends tv{constructor(t,e,i,s){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(t){return new eL(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new eV(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,s;if(t.isBlockGap)i=-5e8,s=4e8;else{let{start:n,end:r}=eH(t,e);i=(n?e?-3e8:-1:5e8)-1,s=(r?e?2e8:1:-6e8)+1}return new eV(t,i,s,e,t.widget||null,!0)}static line(t){return new eI(t)}static set(t,e=!1){return tx.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}eN.none=tx.empty;class eL extends eN{constructor(t){let{start:e,end:i}=eH(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof eL&&this.tagName==t.tagName&&(this.class||(null==(e=this.attrs)?void 0:e.class))==(t.class||(null==(i=t.attrs)?void 0:i.class))&&eD(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw RangeError("Mark decorations may not be empty");return super.range(t,e)}}eL.prototype.point=!1;class eI extends eN{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof eI&&this.spec.class==t.spec.class&&eD(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}eI.prototype.mapMode=S.TrackBefore,eI.prototype.point=!0;class eV extends eN{constructor(t,e,i,s,n,r){super(e,i,n,t),this.block=s,this.isReplace=r,this.mapMode=s?e<=0?S.TrackBefore:S.TrackAfter:S.TrackDel}get type(){return this.startSide!=this.endSide?eR.WidgetRange:this.startSide<=0?eR.WidgetBefore:eR.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){var e,i;return t instanceof eV&&(e=this.widget,e==(i=t.widget)||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function eH(t,e=!1){let{inclusiveStart:i,inclusiveEnd:s}=t;return null==i&&(i=t.inclusive),null==s&&(s=t.inclusive),{start:null!=i?i:e,end:null!=s?s:e}}function eW(t,e,i,s=0){let n=i.length-1;n>=0&&i[n]+s>=t?i[n]=Math.max(i[n],e):i.push(t,e)}eV.prototype.point=!0;class ez extends er{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,s,n,r){if(i){if(!(i instanceof ez))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),ea(this,t,e,i?i.children.slice():[],n,r),!0}split(t){let e=new ez;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:i,off:s}=this.childPos(t);s&&(e.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){eD(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){!function t(e,i,s){let n,{children:r}=e;s>0&&i instanceof eS&&r.length&&(n=r[r.length-1])instanceof eS&&n.mark.eq(i.mark)?t(n,i.children[0],s-1):(r.push(i),i.setParent(e)),e.length+=i.length}(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=eM(e,this.attrs||{})),i&&(this.attrs=eM({class:i},this.attrs||{}))}domAtPos(t){return eP(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(t7(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),void 0!==this.prevAttrs&&(eE(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let s=this.dom.lastChild;for(;s&&er.get(s)instanceof eS;)s=s.lastChild;if(!s||!this.length||"BR"!=s.nodeName&&(null==(i=er.get(s))?void 0:i.isEditable)==!1&&(!ek.ios||!this.children.some(t=>t instanceof ex))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t=0,e;for(let i of this.children){if(!(i instanceof ex)||/[^ -~]/.test(i.text))return null;let s=tG(i.dom);if(1!=s.length)return null;t+=s[0].width,e=s[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(t,e){let i=eO(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(2>Math.abs(e-t.lineHeight)&&t.textHeight<e){let s=(e-t.textHeight)/2;return{top:i.top+s,bottom:i.bottom-s,left:i.left,right:i.left}}}return i}become(t){return t instanceof ez&&0==this.children.length&&0==t.children.length&&eD(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let i=0,s=0;i<t.children.length;i++){let n=t.children[i],r=s+n.length;if(r>=e){if(n instanceof ez)return n;if(r>e)break}s=r+n.breakAfter}return null}}class eF extends er{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,s,n,r){return(!i||i instanceof eF&&!!this.widget.compare(i.widget)&&(!(t>0)||!(n<=0))&&(!(e<this.length)||!(r<=0)))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?es.before(this.dom):es.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new eF(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return en}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):c.empty}domBoundsAround(){return null}become(t){return t instanceof eF&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);return i||(this.widget instanceof eq?null:t2(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class eq extends eB{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class e_{constructor(t,e,i,s){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof eF&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new ez),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ej(new eA(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof eF||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:s}=this.cursor.next(this.skip);if(this.skip=0,s)throw Error("Ran out of text content when drawing inline views");if(i){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,t--;continue}this.text=e,this.textOff=0}let s=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(ej(new ex(this.text.slice(this.textOff,this.textOff+s)),e),i),this.atCursorPos=!0,this.textOff+=s,t-=s,i=0}}span(t,e,i,s){this.buildText(e-t,i,s),this.pos=e,this.openStart<0&&(this.openStart=s)}point(t,e,i,s,n,r){if(this.disallowBlockEffectsFor[r]&&i instanceof eV){if(i.block)throw RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=e-t;if(i instanceof eV)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new eF(i.widget||eU.block,o,i));else{let r=eC.create(i.widget||eU.inline,o,o?0:i.startSide),l=this.atCursorPos&&!r.isEditable&&n<=s.length&&(t<e||i.startSide>0),h=!r.isEditable&&(t<e||n>s.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||l||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(s),l&&(a.append(ej(new eA(1),s),n),n=s.length+Math.max(0,n-s.length)),a.append(ej(r,s),n),this.atCursorPos=h,this.pendingBuffer=h?t<e||n>s.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);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=e),this.openStart<0&&(this.openStart=n)}static build(t,e,i,s,n){let r=new e_(t,e,i,n);return r.openEnd=tx.spans(s,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function ej(t,e){for(let i of e)t=new eS(i,[t],t.length);return t}class eU extends eB{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}eU.inline=new eU("span"),eU.block=new eU("div");var eY=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(eY||(eY={}));let eX=eY.LTR,e$=eY.RTL;function eK(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<t[i]);return e}let eG=eK("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),eQ=eK("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),eJ=Object.create(null),eZ=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);eJ[e]=i,eJ[i]=-e}function e0(t){return t<=247?eG[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?eQ[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}let e1=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class e2{get dir(){return this.level%2?e$:eX}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,s){let n=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(n<0||(0!=s?s<0?o.from<e:o.to>e:t[n].level>o.level))&&(n=r)}}if(n<0)throw RangeError("Index out of range");return n}}let e3=[];function e4(t){return[new e2(0,t,0)]}let e5="",e8=I.define(),e6=I.define(),e9=I.define(),e7=I.define(),it=I.define(),ie=I.define(),ii=I.define(),is=I.define(),ir=I.define(),io=I.define({combine:t=>t.some(t=>t)}),il=I.define({combine:t=>t.some(t=>t)}),ih=I.define();class ia{constructor(t,e="nearest",i="nearest",s=5,n=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=s,this.xMargin=n,this.isSnapshot=r}map(t){return t.empty?this:new ia(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new ia(R.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}let ic=th.define({map:(t,e)=>t.map(e)}),iu=th.define();function id(t,e,i){let s=t.facet(e7);s.length?s[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}let ip=I.define({combine:t=>!t.length||t[0]}),ig=0,im=I.define({combine:t=>t.filter((e,i)=>{for(let s=0;s<i;s++)if(t[s].plugin==e.plugin)return!1;return!0})});class iw{constructor(t,e,i,s,n){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=s,this.baseExtensions=n(this),this.extension=this.baseExtensions.concat(im.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(im.of({plugin:this,arg:t}))}static define(t,e){let{eventHandlers:i,eventObservers:s,provide:n,decorations:r}=e||{};return new iw(ig++,t,i,s,t=>{let e=[];return r&&e.push(ik.of(e=>{let i=e.plugin(t);return i?r(i):eN.none})),n&&e.push(n(t)),e})}static fromClass(t,e){return iw.define((e,i)=>new t(e,i),e)}}class iv{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(id(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){id(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null==(e=this.value)?void 0:e.destroy)try{this.value.destroy()}catch(e){id(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}let ib=I.define(),iy=I.define(),ik=I.define(),ix=I.define(),iS=I.define(),iC=I.define();function iA(t,e){let i=t.state.facet(iC);if(!i.length)return i;let s=i.map(e=>e instanceof Function?e(t):e),n=[];return tx.spans(s,e.from,e.to,{point(){},span(t,i,s,r){let o=t-e.from,l=i-e.from,h=n;for(let t=s.length-1;t>=0;t--,r--){let i=s[t].spec.bidiIsolate,n;if(null==i&&(i=function(t,e,i){for(let s=e;s<i;s++){let e=e0(t.charCodeAt(s));if(1==e)break;if(2==e||4==e)return e$}return eX}(e.text,o,l)),r>0&&h.length&&(n=h[h.length-1]).to==o&&n.direction==i)n.to=l,h=n.inner;else{let t={from:o,to:l,direction:i,inner:[]};h.push(t),h=t.inner}}}}),n}let iP=I.define();function iO(t){let e=0,i=0,s=0,n=0;for(let r of t.state.facet(iP)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(s=Math.max(s,o.top)),null!=o.bottom&&(n=Math.max(n,o.bottom)))}return{left:e,right:i,top:s,bottom:n}}let iM=I.define();class iT{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new iT(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let s=t[e-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let s=0,n=0,r=0,o=0;;s++){let l=s==t.length?null:t[s],h=r-o,a=l?l.fromB:1e9;for(;n<e.length&&e[n]<a;){let t=e[n],s=e[n+1],r=Math.max(o,t),l=Math.min(a,s);if(r<=l&&new iT(r+h,l+h,r,l).addToSet(i),s>a)break;n+=2}if(!l)return i;new iT(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),r=l.toA,o=l.toB}}}class iD{constructor(t,e,i){for(let s of(this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=A.empty(this.startState.doc.length),i))this.changes=this.changes.compose(s.changes);let s=[];this.changes.iterChangedRanges((t,e,i,n)=>s.push(new iT(t,e,i,n))),this.changedRanges=s}static create(t,e,i){return new iD(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class iE extends er{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=eN.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(t.contentDOM),this.children=[new ez],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new iT(0,0,0,t.state.doc.length)],0,null)}update(t){var e,i,s,n,r,o;let l,h,a=t.changedRanges;this.minWidth>0&&a.length&&(a.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let c=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null==(e=this.domChanged)?void 0:e.newSel)?c=this.domChanged.newSel.head:(i=t.changes,s=this.hasComposition,l=!1,s&&i.iterChangedRanges((t,e)=>{t<s.to&&e>s.from&&(l=!0)}),l||t.selectionSet||(c=t.state.selection.main.head)));let f=c>-1?function(t,e,i){let s=iB(t,i);if(!s)return null;let{node:n,from:r,to:o}=s,l=n.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(s.from,s.to)!=l)return null;let h=e.invertedDesc,a=new iT(h.mapPos(r),h.mapPos(o),r,o),c=[];for(let e=n.parentNode;;e=e.parentNode){let i=er.get(e);if(i instanceof eS)c.push({node:e,deco:i.mark});else{if(i instanceof ez||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:n,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new eL({inclusive:!0,attributes:function(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let s=t.attributes[i];e[s.name]=s.value}return e}(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,c):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:i}=this.hasComposition;a=new iT(e,i,t.changes.mapPos(e,-1),t.changes.mapPos(i,1)).addToSet(a.slice())}this.hasComposition=f?{from:f.range.fromB,to:f.range.toB}:null,(ek.ie||ek.chrome)&&!f&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let u=(n=this.decorations,r=this.updateDeco(),o=t.changes,h=new iR,tx.compare(n,r,o,h),h.changes);return a=iT.extendWithRanges(a,u),(!!(7&this.flags)||0!=a.length)&&(this.updateInner(a,t.startState.doc.length,f),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:s}=this.view;s.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=ek.chrome||ek.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||s.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof eF&&t.widget instanceof eq&&n.push(t.dom);s.updateGaps(n)}updateChildren(t,e,i){let s=i?i.range.addToSet(t.slice()):t,n=this.childCursor(e);for(let t=s.length-1;;t--){let e=t>=0?s[t]:null;if(!e)break;let{fromA:r,toA:o,fromB:l,toB:h}=e,a,c,f,u;if(i&&i.range.fromB<h&&i.range.toB>l){let t=e_.build(this.view.state.doc,l,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=e_.build(this.view.state.doc,i.range.toB,h,this.decorations,this.dynamicDecorationMap);c=t.breakAtStart,f=t.openStart,u=e.openEnd;let s=this.compositionView(i);e.breakAtStart?s.breakAfter=1:e.content.length&&s.merge(s.length,s.length,e.content[0],!1,e.openStart,0)&&(s.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&s.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),a=t.content.concat(s).concat(e.content)}else({content:a,breakAtStart:c,openStart:f,openEnd:u}=e_.build(this.view.state.doc,l,h,this.decorations,this.dynamicDecorationMap));let{i:d,off:p}=n.findPos(o,1),{i:g,off:m}=n.findPos(r,-1);eh(this,g,m,d,p,a,c,f,u)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){for(let e of(this.editContextFormatting=this.editContextFormatting.map(t.changes),t.transactions))for(let t of e.effects)t.is(iu)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new ex(t.text.nodeValue);for(let{deco:i}of(e.flags|=8,t.marks))e=new eS(i,[e],e.length);let i=new ez;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|!!e.children.some(t=>7&t.flags),this.markedForComposition.add(e);let i=er.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),s=this.children[i.i];e(t.line,s);for(let n=t.marks.length-1;n>=-1;n--)i=s.childPos(i.off,1),s=s.children[i.i],e(n>=0?t.marks[n].node:t.text,s)}updateSelection(t=!1,e=!1){var i;(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let s=this.view.root.activeElement,n=s==this.dom,r=!n&&!(this.view.state.facet(ip)||this.dom.tabIndex>-1)&&tK(this.dom,this.view.observer.selectionRange)&&!(s&&this.dom.contains(s));if(!(n||e||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(l.anchor)),a=l.empty?h:this.moveToLine(this.domAtPos(l.head));if(ek.gecko&&l.empty&&!this.hasComposition&&1==(i=h).node.nodeType&&i.node.firstChild&&(0==i.offset||"false"==i.node.childNodes[i.offset-1].contentEditable)&&(i.offset==i.node.childNodes.length||"false"==i.node.childNodes[i.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null)),h=a=new es(t,0),o=!0}let c=this.view.observer.selectionRange;!o&&c.focusNode&&(tQ(h.node,h.offset,c.anchorNode,c.anchorOffset)&&tQ(a.node,a.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,l))||(this.view.observer.ignore(()=>{ek.android&&ek.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=tX(this.view.root);if(t)if(l.empty){if(ek.gecko){var e,i;let t=(e=h.node,i=h.offset,1!=e.nodeType?0:(i&&"false"==e.childNodes[i-1].contentEditable?1:0)|2*(i<e.childNodes.length&&"false"==e.childNodes[i].contentEditable));if(t&&3!=t){let e=(1==t?ee:ei)(h.node,h.offset);e&&(h=new es(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=l.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=l.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(a.node,a.offset)}catch(t){}}else{let e=document.createRange();l.anchor>l.head&&([h,a]=[a,h]),e.setEnd(a.node,a.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,a)),this.impreciseAnchor=h.precise?null:new es(c.anchorNode,c.anchorOffset),this.impreciseHead=a.precise?null:new es(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&tQ(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=tX(t.root),{anchorNode:s,anchorOffset:n}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let r=ez.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let l=this.coordsAt(e.head,-1),h=this.coordsAt(e.head,1);if(!l||!h||l.bottom>h.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(s,n)}moveToLine(t){let e=this.dom,i;if(t.node!=e)return t;for(let s=t.offset;!i&&s<e.childNodes.length;s++){let t=er.get(e.childNodes[s]);t instanceof ez&&(i=t.domAtPos(0))}for(let s=t.offset-1;!i&&s>=0;s--){let t=er.get(e.childNodes[s]);t instanceof ez&&(i=t.domAtPos(t.length))}return i?new es(i.node,i.offset,!0):t}nearest(t){for(let e=t;e;){let t=er.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof ez)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,s=0;for(let n=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],l=n-o.breakAfter,h=l-o.length;if(l<t)break;if(h<=t&&(h<t||o.covers(-1))&&(l>t||o.covers(1))&&(!i||o instanceof ez&&!(i instanceof ez&&e>=0)))i=o,s=h;else if(i&&h==t&&l==t&&o instanceof eF&&2>Math.abs(e))if(o.deco.startSide<0)break;else r&&(i=null);n=h}return i?i.coordsAt(t-s,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),s=this.children[e];if(!(s instanceof ez))return null;for(;s.children.length;){let{i:t,off:e}=s.childPos(i,1);for(;;t++){if(t==s.children.length)return null;if((s=s.children[t]).length)break}i=e}if(!(s instanceof ex))return null;let n=b(s.text,i);if(n==i)return null;let r=t6(s.dom,i,n).getClientRects();for(let t=0;t<r.length;t++){let e=r[t];if(t==r.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:s}=t,n=this.view.contentDOM.clientWidth,r=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==eY.LTR;for(let t=0,h=0;h<this.children.length;h++){let a=this.children[h],c=t+a.length;if(c>s)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,s=e?tG(e):[];if(s.length){let e=s[s.length-1],r=l?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=n,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?eY.RTL:eY.LTR}measureTextSize(){for(let t of this.children)if(t instanceof ez){let e=t.measureTextSize();if(e)return e}let t=document.createElement("div"),e,i,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let n=tG(t.firstChild)[0];e=t.getBoundingClientRect().height,i=n?n.width/27:7,s=n?n.height:e,t.remove()}),{lineHeight:e,charWidth:i,textHeight:s}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new el(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,s=0;;s++){let n=s==e.viewports.length?null:e.viewports[s],r=n?n.from-1:this.length;if(r>i){let s=(e.lineBlockAt(r).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(eN.replace({widget:new eq(s),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!n)break;i=n.to+1}return eN.set(t)}updateDeco(){let t=1,e=this.view.state.facet(ik).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,s=this.view.state.facet(ix).map((t,e)=>{let s="function"==typeof t;return s&&(i=!0),s?t(this.view):t});for(s.length&&(this.dynamicDecorationMap[t++]=i,e.push(tx.join(s))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=e.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let e of this.view.state.facet(ih))try{if(e(this.view,t.range,t))return!0}catch(t){id(this.view.state,t,"scroll handler")}let{range:e}=t,i=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1),s;if(!i)return;!e.empty&&(s=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let n=iO(this.view),r={left:i.left-n.left,top:i.top-n.top,right:i.right+n.right,bottom:i.bottom+n.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(t,e,i,s,n,r,o,l){let h=t.ownerDocument,a=h.defaultView||window;for(let c=t,f=!1;c&&!f;)if(1==c.nodeType){let t,u=c==h.body,d=1,p=1;if(u)t=function(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:p}=t3(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*p}}let g=0,m=0;if("nearest"==n)e.top<t.top?(m=e.top-(t.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=e.top-(t.top+o)));else{let s=e.bottom-e.top,r=t.bottom-t.top;m=("center"==n&&s<=r?e.top+s/2-r/2:"start"==n||"center"==n&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==s?e.left<t.left?(g=e.left-(t.left+r),i>0&&e.right>t.right+g&&(g=e.right-t.right+r)):e.right>t.right&&(g=e.right-t.right+r,i<0&&e.left<t.left+g&&(g=e.left-(t.left+r))):g=("center"==s?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==s==l?e.left-r:e.right-(t.right-t.left)+r)-t.left,g||m)if(u)a.scrollBy(g,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/p,i=(c.scrollTop-t)*p}if(g){let e=c.scrollLeft;c.scrollLeft+=g/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&1>Math.abs(t-g)&&(s="nearest"),i&&1>Math.abs(i-m)&&(n="nearest")}if(u)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,r,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==eY.LTR)}}function iB(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let s=ee(i.focusNode,i.focusOffset),n=ei(i.focusNode,i.focusOffset),r=s||n;if(n&&s&&n.node!=s.node){let e=er.get(n.node);if(!e||e instanceof ex&&e.text!=n.node.nodeValue)r=n;else if(t.docView.lastCompositionAfterCursor){let t=er.get(s.node);!t||t instanceof ex&&t.text!=s.node.nodeValue||(r=n)}}if(t.docView.lastCompositionAfterCursor=r!=s,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}let iR=class{constructor(){this.changes=[]}compareRange(t,e){eW(t,e,this.changes)}comparePoint(t,e){eW(t,e,this.changes)}boundChange(t){eW(t,t,this.changes)}};function iN(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function iL(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function iI(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function iV(t,e,i){let s=t.nodeValue.length,n=-1,r=1e9,o=0;for(let l=0;l<s;l++){let s=t6(t,l,l+1).getClientRects();for(let h=0;h<s.length;h++){let a=s[h];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,s=i;if((ek.chrome||ek.gecko)&&t6(t,l).getBoundingClientRect().left==a.right&&(s=!i),c<=0)return{node:t,offset:l+ +!!s};n=l+ +!!s,r=c}}}return{node:t,offset:n>-1?n:o>0?t.nodeValue.length:0}}function iH(t,e,i,s=-1){var n,r;let o=t.contentDOM.getBoundingClientRect(),l=o.top+t.viewState.paddingTop,h,{docHeight:a}=t.viewState,{x:c,y:f}=e,u=f-l;if(u<0)return 0;if(u>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,n=!1;(h=t.elementAtHeight(u)).type!=eR.Text;)for(;!((u=s>0?h.bottom+e:h.top-e)>=0)||!(u<=a);){if(n)return i?null:0;n=!0,s=-s}f=l+u;let d=h.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:iW(t,o,h,c,f);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:iW(t,o,h,c,f);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(c,f);m&&!t.contentDOM.contains(m)&&(m=null),!m&&(c=Math.max(o.left+1,Math.min(o.right-1,c)),(m=g.elementFromPoint(c,f))&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&(null==(n=t.docView.nearest(m))?void 0:n.isEditable)!=!1){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,f);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,f);e&&({startContainer:w,startOffset:v}=e,(!t.contentDOM.contains(w)||ek.safari&&function(t,e,i){let s,n=t;if(3!=t.nodeType||e!=(s=t.nodeValue.length))return!1;for(;;){let t=n.nextSibling;if(t){if("BR"==t.nodeName)break;return!1}{let t=n.parentNode;if(!t||"DIV"==t.nodeName)break;n=t}}return t6(t,s-1,s).getBoundingClientRect().right>i}(w,v,c)||ek.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}return i-(1==t.nodeType?t.getBoundingClientRect():t6(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(w,v,c))&&(w=void 0))}w&&(v=Math.min(t1(w),v))}if(!w||!t.docView.dom.contains(w)){let e=ez.find(t.docView,d);if(!e)return u>h.top+h.height/2?h.to:h.from;({node:w,offset:v}=function t(e,i,s){let n,r,o,l,h,a,c,f,u=!1;for(let g=e.firstChild;g;g=g.nextSibling){let e=tG(g);for(let m=0;m<e.length;m++){var d,p;let w=e[m];a&&iN(a,w)&&(w=iL(iI(w,a.bottom),a.top));let v=(d=w).left>i?d.left-i:Math.max(0,i-d.right),b=(p=w).top>s?p.top-s:Math.max(0,s-p.bottom);if(0==v&&0==b)return 3==g.nodeType?iV(g,i,s):t(g,i,s);(!h||f>b||f==b&&c>v)&&(h=g,a=w,c=v,f=b,u=!v||(i<w.left?m>0:m<e.length-1)),0==v?s>w.bottom&&(!o||o.bottom<w.bottom)?(n=g,o=w):s<w.top&&(!l||l.top>w.top)&&(r=g,l=w):o&&iN(o,w)?o=iI(o,w.bottom):l&&iN(l,w)&&(l=iL(l,w.top))}}if(o&&o.bottom>=s?(h=n,a=o):l&&l.top<=s&&(h=r,a=l),!h)return{node:e,offset:0};let g=Math.max(a.left,Math.min(a.right,i));if(3==h.nodeType)return iV(h,g,s);if(u&&"false"!=h.contentEditable)return t(h,g,s);let m=Array.prototype.indexOf.call(e.childNodes,h)+ +(i>=(a.left+a.right)/2);return{node:e,offset:m}}(e.dom,c,f))}let b=t.docView.nearest(w);if(!b)return null;if(!b.isWidget||(null==(r=b.dom)?void 0:r.nodeType)!=1)return b.localPosFromDOM(w,v)+b.posAtStart;{let t=b.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?b.posAtStart:b.posAtEnd}}function iW(t,e,i,s,n){let r=Math.round((s-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((n-i.top-(t.defaultLineHeight-e)*.5)/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,s){for(let s=0,n=0;;){if(n>=e)return s;if(s==t.length)break;n+=9==t.charCodeAt(s)?i-n%i:1,s=b(t,s)}return t.length}(o,r,t.state.tabSize)}function iz(t,e,i){let s=t.lineBlockAt(e);if(Array.isArray(s.type)){let t;for(let n of s.type){if(n.from>e)break;if(!(n.to<e)){if(n.from<e&&n.to>e)return n;(!t||n.type==eR.Text&&(t.type!=n.type||(i<0?n.from<e:n.to>e)))&&(t=n)}}return t||s}return s}function iF(t,e,i,s){let n=t.state.doc.lineAt(e.head),r=t.bidiSpans(n),o=t.textDirectionAt(n.from);for(let l=e,h=null;;){let e=function(t,e,i,s,n){var r;let o=s.head-t.from,l=e2.find(e,o,null!=(r=s.bidiLevel)?r:-1,s.assoc),h=e[l],a=h.side(n,i);if(o==a){let t=l+=n?1:-1;if(t<0||t>=e.length)return null;o=(h=e[l=t]).side(!n,i),a=h.side(n,i)}let c=b(t.text,o,h.forward(n,i));(c<h.from||c>h.to)&&(c=a),e5=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return f&&c==a&&f.level+ +!n<h.level?R.cursor(f.side(!n,i)+t.from,f.forward(n,i)?1:-1,f.level):R.cursor(c+t.from,h.forward(n,i)?-1:1,h.level)}(n,r,o,l,i),a=e5;if(!e){if(n.number==(i?t.state.doc.lines:1))return l;a="\n",n=t.state.doc.line(n.number+(i?1:-1)),r=t.bidiSpans(n),e=t.visualLineSide(n,!i)}if(h){if(!h(a))return l}else{if(!s)return e;h=s(a)}l=e}}function iq(t,e,i){for(;;){let s=0;for(let n of t)n.between(e-1,e+1,(t,n,r)=>{if(e>t&&e<n){let r=s||i||(e-t<n-e?-1:1);e=r<0?t:n,s=r}});if(!s)return e}}function i_(t,e,i){let s=iq(t.state.facet(iS).map(e=>e(t)),i.from,e.head>i.from?-1:1);return s==i.from?i:R.cursor(s,s<i.from?1:-1)}class ij{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(tm.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+="￿"}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s);let t=this.text.length;this.readNode(s);let n=s.nextSibling;if(n==e)break;let r=er.get(s),o=er.get(n);(r&&o?r.breakAfter:(r?r.breakAfter:tZ(s))||tZ(n)&&("BR"!=s.nodeName||s.cmIgnore)&&this.text.length>t)&&this.lineBreak(),s=n}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let n=-1,r=1,o;if(this.lineSeparator?(n=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(o=s.exec(e))&&(n=o.index,r=o[0].length),this.append(e.slice(i,n<0?e.length:n)),n<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=n+r}}readNode(t){if(t.cmIgnore)return;let e=er.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(!function(t,e,i){for(;;){if(!e||i<t1(e))return!1;if(e==t)return!0;i=tJ(e)+1,e=e.parentNode}}(t,i.node,i.offset)?0:e))}}class iU{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class iY{constructor(t,e,i,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:n,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=n||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=t.observer.selectionRange;return i&&(e.push(new iU(i,s)),(n!=i||r!=s)&&e.push(new iU(n,r))),e}(t),i=new ij(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,s=2==t.length?t[1].pos:i;return i>-1&&s>-1?R.single(i+e,s+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=n&&n.node==e.focusNode&&n.offset==e.focusOffset||!t$(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),s=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!t$(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if((ek.ios||ek.chrome)&&t.state.selection.main.empty&&i!=s&&(o.from>0||o.to<t.state.doc.length)){let e=Math.min(i,s),n=Math.max(i,s),r=o.from-e,l=o.to-n;(0==r||1==r||0==e)&&(0==l||-1==l||n==t.state.doc.length)&&(i=0,s=t.state.doc.length)}this.newSel=R.single(s,i)}}}function iX(t,e){let i,{newSel:s}=e,n=t.state.selection.main,r=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:o}=e.bounds,l=n.from,h=null;(8===r||ek.android&&e.text.length<o-s)&&(l=n.to,h="end");let a=function(t,e,i,s){let n=Math.min(t.length,e.length),r=0;for(;r<n&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==n&&t.length==e.length)return null;let o=t.length,l=e.length;for(;o>0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if("end"==s){let t=Math.max(0,r-Math.min(o,l));i-=o+t-r}if(o<r&&t.length<e.length){let t=i<=r&&i>=o?r-i:0;r-=t,l=r+(l-o),o=r}else if(l<r){let t=i<=r&&i>=l?r-i:0;r-=t,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}(t.state.doc.sliceString(s,o,"￿"),e.text,l-s,h);a&&(ek.chrome&&13==r&&a.toB==a.from+2&&"￿￿"==e.text.slice(a.from,a.toB)&&a.toB--,i={from:s+a.from,to:s+a.toA,insert:c.of(e.text.slice(a.from,a.toB).split("￿"))})}else s&&(!t.hasFocus&&t.state.facet(ip)||s.main.eq(n))&&(s=null);if(!i&&!s)return!1;if(!i&&e.typeOver&&!n.empty&&s&&s.main.empty?i={from:n.from,to:n.to,insert:t.state.doc.slice(n.from,n.to)}:(ek.mac||ek.android)&&i&&i.from==i.to&&i.from==n.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=R.single(s.main.anchor-1,s.main.head-1)),i={from:i.from,to:i.to,insert:c.of([i.insert.toString().replace("."," ")])}):i&&i.from>=n.from&&i.to<=n.to&&(i.from!=n.from||i.to!=n.to)&&n.to-n.from-(i.to-i.from)<=4?i={from:n.from,to:n.to,insert:t.state.doc.slice(n.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,n.to))}:ek.chrome&&i&&i.from==i.to&&i.from==n.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=R.single(s.main.anchor-1,s.main.head-1)),i={from:n.from,to:n.to,insert:c.of([" "])}),i)return i$(t,i,s,r);if(!s||s.main.eq(n))return!1;{let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:s,scrollIntoView:e,userEvent:i}),!0}}function i$(t,e,i,s=-1){let n;if(ek.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(ek.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&" "==t.state.sliceDoc(e.from,r.from))&&1==e.insert.length&&2==e.insert.lines&&t9(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&0==e.insert.length||8==s&&e.insert.length<e.to-e.from&&e.to>r.head)&&t9(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&0==e.insert.length&&t9(t.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let l=()=>n||(n=function(t,e,i){let s,n=t.state,r=n.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.from<e.from?n.sliceDoc(r.from,e.from):"",o=r.to>e.to?n.sliceDoc(e.to,r.to):"";s=n.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=n.changes(e),l=i&&i.main.to<=o.newLength?i.main:void 0;if(n.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let h=t.state.sliceDoc(e.from,e.to),a,c=i&&iB(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);a={from:c.from,to:c.to-t}}else a=t.state.doc.lineAt(r.head);let f=r.to-e.to,u=r.to-r.from;s=n.changeByRange(i=>{if(i.from==r.from&&i.to==r.to)return{changes:o,range:l||i.map(o)};let s=i.to-f,c=s-h.length;if(i.to-i.from!=u||t.state.sliceDoc(c,s)!=h||i.to>=a.from&&i.from<=a.to)return{range:i};let d=n.changes({from:c,to:s,insert:e.insert}),p=i.to-r.to;return{changes:d,range:l?R.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):i.map(d)}})}else s={changes:o,selection:l&&n.selection.replaceRange(l)}}let o="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1)),n.update(s,{userEvent:o,scrollIntoView:!0})}(t,e,i));return t.state.facet(ie).some(i=>i(t,e.from,e.to,o,l))||t.dispatch(l()),!0}class iK{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,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=t.hasFocus,ek.safari&&t.contentDOM.addEventListener("input",()=>null),ek.gecko&&function(t){sc.has(t)||(sc.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){!(!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i=e.target,s;i!=t.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(s=er.get(i))&&s.ignoreEvent(e))return!1;return!0}(this.view,t)||this.ignoreDuringComposition(t))&&("keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,s=t&&t.plugin.domEventHandlers,n=t&&t.plugin.domEventObservers;if(s)for(let t in s){let n=s[t];n&&i(t).handlers.push(iG(e.value,n))}if(n)for(let t in n){let s=n[t];s&&i(t).observers.push(iG(e.value,s))}}for(let t in i2)i(t).handlers.push(i2[t]);for(let t in i3)i(t).observers.push(i3[t]);return e}(t),i=this.handlers,s=this.view.contentDOM;for(let t in e)if("scroll"!=t){let n=!e[t].handlers.length,r=i[t];r&&!r.handlers.length!=n&&(s.removeEventListener(t,this.handleEvent),r=null),r||s.addEventListener(t,this.handleEvent,{passive:n})}for(let t in i)"scroll"==t||e[t]||s.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){let e;return this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),!!(9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=t.keyCode&&0>iZ.indexOf(t.keyCode)&&(this.tabFocusMode=-1),ek.android&&ek.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))?(this.view.observer.delayAndroidKey(t.key,t.keyCode),!0):ek.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=iQ.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||iJ.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=t.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(t){let e=this.pendingIOSKey;return!(!e||"Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,t9(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(ek.safari&&!ek.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function iG(t,e){return(i,s)=>{try{return e.call(t,s,i)}catch(t){id(i.state,t)}}}let iQ=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],iJ="dthko",iZ=[16,17,18,20,91,92,224,225];function i0(t){return .7*Math.max(0,t)+8}class i1{constructor(t,e,i,s){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e=t.ownerDocument,i,s;for(let n=t.parentNode;n;)if(n==e.body||i&&s)break;else if(1==n.nodeType)!s&&n.scrollHeight>n.clientHeight&&(s=n),!i&&n.scrollWidth>n.clientWidth&&(i=n),n=n.assignedSlot||n.parentNode;else if(11==n.nodeType)n=n.host;else break;return{x:i,y:s}}(t.contentDOM),this.atoms=t.state.facet(iS).map(e=>e(t));let n=t.contentDOM.ownerDocument;n.addEventListener("mousemove",this.move=this.move.bind(this)),n.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(tm.allowMultipleSelections)&&function(t,e){let i=t.state.facet(e8);return i.length?i[0](e):ek.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let s=tX(t.root);if(!s||0==s.rangeCount)return!0;let n=s.getRangeAt(0).getClientRects();for(let t=0;t<n.length;t++){let i=n[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)&&1==sn(e)&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>(e=this.startEvent,Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))))return;this.select(this.lastEvent=t);let i=0,s=0,n=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let h=iO(this.view);t.clientX-h.left<=n+6?i=-i0(n-t.clientX):t.clientX+h.right>=o-6&&(i=i0(t.clientX-o)),t.clientY-h.top<=r+6?s=-i0(r-t.clientY):t.clientY+h.bottom>=l-6&&(s=i0(t.clientY-l)),this.setScrollSpeed(i,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let s=t.ranges[i],n=null;if(s.empty){let t=iq(this.atoms,s.from,0);t!=s.from&&(n=R.cursor(t,-1))}else{let t=iq(this.atoms,s.from,-1),e=iq(this.atoms,s.to,1);(t!=s.from||e!=s.to)&&(n=R.range(s.from==s.anchor?t:e,s.from==s.head?t:e))}n&&(e||(e=t.ranges.slice()),e[i]=n)}return e?R.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(e.state.selection,!1===this.dragging))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}let i2=Object.create(null),i3=Object.create(null),i4=ek.ie&&ek.ie_version<15||ek.ios&&ek.webkit_version<604;function i5(t,e,i){for(let s of t.facet(e))i=s(i,t);return i}function i8(t,e){e=i5(t.state,is,e);let{state:i}=t,s,n=1,r=i.toText(e),o=r.lines==i.selection.ranges.length;if(null!=so&&i.selection.ranges.every(t=>t.empty)&&so==r.toString()){let t=-1;s=i.changeByRange(s=>{let l=i.doc.lineAt(s.from);if(l.from==t)return{range:s};t=l.from;let h=i.toText((o?r.line(n++).text:e)+i.lineBreak);return{changes:{from:l.from,insert:h},range:R.cursor(s.from+h.length)}})}else s=o?i.changeByRange(t=>{let e=r.line(n++);return{changes:{from:t.from,to:t.to,insert:e.text},range:R.cursor(t.from+e.length)}}):i.replaceSelection(r);t.dispatch(s,{userEvent:"input.paste",scrollIntoView:!0})}function i6(t,e,i,s){if(1==s)return R.cursor(e,i);{if(2==s)return function(t,e,i=1){let s=t.charCategorizer(e),n=t.doc.lineAt(e),r=e-n.from;if(0==n.length)return R.cursor(e);0==r?i=1:r==n.length&&(i=-1);let o=r,l=r;i<0?o=b(n.text,r,!1):l=b(n.text,r);let h=s(n.text.slice(o,l));for(;o>0;){let t=b(n.text,o,!1);if(s(n.text.slice(t,o))!=h)break;o=t}for(;l<n.length;){let t=b(n.text,l);if(s(n.text.slice(l,t))!=h)break;l=t}return R.range(o+n.from,l+n.from)}(t.state,e,i);let n=ez.find(t.docView,e),r=t.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return l<t.state.doc.length&&l==r.to&&l++,R.range(o,l)}}i3.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},i2.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),i3.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},i3.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},i2.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let s of t.state.facet(e9))if(i=s(t,e))break;if(i||0!=e.button||(i=function(t,e){let i=i7(t,e),s=sn(e),n=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),n=n.map(t.changes))},get(e,r,o){let l=i7(t,e),h,a=i6(t,l.pos,l.bias,s);if(i.pos!=l.pos&&!r){let e=i6(t,i.pos,i.bias,s),n=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=n<a.from?R.range(n,r):R.range(r,n)}return r?n.replaceRange(n.main.extend(a.from,a.to)):o&&1==s&&n.ranges.length>1&&(h=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:s,to:n}=t.ranges[i];if(s<=e&&n>=e)return R.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i))}return null}(n,l.pos))?h:o?n.addRange(a):R.create([a])}}}(t,e)),i){let s=!t.hasFocus;t.inputState.startMouseSelection(new i1(t,e,i,s)),s&&t.observer.ignore(()=>{t8(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let n=t.inputState.mouseSelection;if(n)return n.start(e),!1===n.dragging}return!1};let i9=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function i7(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:function(t,e,i,s){let n=ez.find(t.docView,e);if(!n)return 1;let r=e-n.posAtStart;if(0==r)return 1;if(r==n.length)return -1;let o=n.coordsAt(r,-1);if(o&&i9(i,s,o))return -1;let l=n.coordsAt(r,1);return l&&i9(i,s,l)?1:o&&o.bottom>=s?-1:1}(t,i,e.clientX,e.clientY)}}let st=ek.ie&&ek.ie_version<=11,se=null,si=0,ss=0;function sn(t){if(!st)return t.detail;let e=se,i=ss;return se=t,ss=Date.now(),si=!e||i>Date.now()-400&&2>Math.abs(e.clientX-t.clientX)&&2>Math.abs(e.clientY-t.clientY)?(si+1)%3:1}function sr(t,e,i,s){let n;if(!(i=i5(t.state,is,i)))return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,l=s&&o&&((n=t.state.facet(e6)).length?n[0](e):ek.mac?!e.altKey:!e.ctrlKey)?{from:o.from,to:o.to}:null,h={from:r,insert:i},a=t.state.changes(l?[l,h]:h);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:l?"move.drop":"input.drop"}),t.inputState.draggedContent=null}i2.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let s=t.docView.nearest(e.target);if(s&&s.isWidget){let t=s.posAtStart,e=t+s.length;(t>=i.to||e<=i.from)&&(i=R.range(t,e))}}let{inputState:s}=t;return s.mouseSelection&&(s.mouseSelection.dragging=!0),s.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",i5(t.state,ir,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},i2.dragend=t=>(t.inputState.draggedContent=null,!1),i2.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let s=Array(i.length),n=0,r=()=>{++n==i.length&&sr(t,e,s.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(s[t]=e.result),r()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return sr(t,e,i,!0),!0}return!1},i2.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=i4?null:e.clipboardData;return i?(i8(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(!function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),i8(t,i.value)},50)}(t),!1)};let so=null;i2.copy=i2.cut=(t,e)=>{let{text:i,ranges:s,linewise:n}=function(t){let e=[],i=[],s=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),i.push(s));if(!e.length){let n=-1;for(let{from:s}of t.selection.ranges){let r=t.doc.lineAt(s);r.number>n&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),n=r.number}s=!0}return{text:i5(t,ir,e.join(t.lineBreak)),ranges:i,linewise:s}}(t.state);if(!i&&!n)return!1;so=n?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:s,scrollIntoView:!0,userEvent:"delete.cut"});let r=i4?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(!function(t,e){let i=t.dom.parentNode;if(!i)return;let s=i.appendChild(document.createElement("textarea"));s.style.cssText="position: fixed; left: -10000px; top: 10px",s.value=e,s.focus(),s.selectionEnd=e.length,s.selectionStart=0,setTimeout(()=>{s.remove(),t.focus()},50)}(t,i),!1)};let sl=tr.define();function sh(t,e){let i=[];for(let s of t.facet(ii)){let n=s(t,e);n&&i.push(n)}return i.length?t.update({effects:i,annotations:sl.of(!0)}):null}function sa(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=sh(t.state,e);i?t.dispatch(i):t.update([])}},10)}i3.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),sa(t)},i3.blur=t=>{t.observer.clearSelectionRange(),sa(t)},i3.compositionstart=i3.compositionupdate=t=>{!t.observer.editContext&&(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},i3.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,ek.chrome&&ek.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},i3.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},i2.beforeinput=(t,e)=>{var i,s;let n;if("insertReplacementText"==e.inputType&&t.observer.editContext){let s=null==(i=e.dataTransfer)?void 0:i.getData("text/plain"),n=e.getTargetRanges();if(s&&n.length){let e=n[0],i=t.posAtDOM(e.startContainer,e.startOffset),r=t.posAtDOM(e.endContainer,e.endOffset);return i$(t,{from:i,to:r,insert:t.state.toText(s)},null),!0}}if(ek.chrome&&ek.android&&(n=iQ.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null==(s=window.visualViewport)?void 0:s.height)||0;setTimeout(()=>{var i;((null==(i=window.visualViewport)?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return ek.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),ek.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>i3.compositionend(t,e),20),!1};let sc=new Set,sf=["pre-wrap","normal","pre-line","break-spaces"],su=!1;class sd{constructor(t){this.lineWrapping=t,this.doc=c.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return sf.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let s=t[i];s<0?i++:this.heightSamples[Math.floor(10*s)]||(e=!0,this.heightSamples[Math.floor(10*s)]=!0)}return e}refresh(t,e,i,s,n,r){let o=sf.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=s,this.lineLength=n,l){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}}class sp{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class sg{constructor(t,e,i,s,n){this.from=t,this.length=e,this.top=i,this.height=s,this._content=n}get type(){return"number"==typeof this._content?eR.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 eV?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new sg(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var sm=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(sm||(sm={}));class sw{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=2*!!t|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>.001&&(su=!0),this.height=t)}replace(t,e,i){return sw.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let n=this,r=i.doc;for(let o=s.length-1;o>=0;o--){let{fromA:l,toA:h,fromB:a,toB:c}=s[o],f=n.lineAt(l,sm.ByPosNoHeight,i.setDoc(e),0,0),u=f.to>=h?f:n.lineAt(h,sm.ByPosNoHeight,i,0,0);for(c+=u.to-h,h=u.to;o>0&&f.from<=s[o-1].toA;)l=s[o-1].fromA,a=s[o-1].fromB,o--,l<f.from&&(f=n.lineAt(l,sm.ByPosNoHeight,i,0,0));a+=f.from-l,l=f.from;let d=sC.build(i.setDoc(r),t,a,c);n=sv(n,n.replace(l,h,d))}return n.updateHeight(i,0)}static empty(){return new sy(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,s=0,n=0;for(;;)if(e==i)if(s>2*n){let n=t[e-1];n.break?t.splice(--e,1,n.left,null,n.right):t.splice(--e,1,n.left,n.right),i+=1+n.break,s-=n.size}else if(n>2*s){let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,n-=e.size}else break;else if(s<n){let i=t[e++];i&&(s+=i.size)}else{let e=t[--i];e&&(n+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new sx(sw.of(t.slice(0,e)),r,sw.of(t.slice(i)))}}function sv(t,e){return t==e?t:(t.constructor!=e.constructor&&(su=!0),e)}sw.prototype.size=1;class sb extends sw{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,s){return new sg(s,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,s,n){return this.blockAt(0,i,s,n)}forEachLine(t,e,i,s,n,r){t<=n+this.length&&e>=n&&r(this.blockAt(0,i,s,n))}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more&&this.setHeight(s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class sy extends sb{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,s){return new sg(s,this.length,i,this.height,this.breaks)}replace(t,e,i){let s=i[0];return 1==i.length&&(s instanceof sy||s instanceof sk&&4&s.flags)&&10>Math.abs(this.length-s.length)?(s instanceof sk?s=new sy(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):sw.of(i)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more?this.setHeight(s.heights[s.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class sk extends sw{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,n=s-i+1,r,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*n);r=e/n,this.length>n+1&&(o=(this.height-e)/(this.length-n-1))}else r=this.height/n;return{firstLine:i,lastLine:s,perLine:r,perChar:o}}blockAt(t,e,i,s){let{firstLine:n,lastLine:r,perLine:o,perChar:l}=this.heightMetrics(e,s);if(e.lineWrapping){let n=s+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),r=e.doc.lineAt(n),h=o+r.length*l,a=Math.max(i,t-h/2);return new sg(r.from,r.length,a,h,0)}{let s=Math.max(0,Math.min(r-n,Math.floor((t-i)/o))),{from:l,length:h}=e.doc.line(n+s);return new sg(l,h,i+o*s,o,0)}}lineAt(t,e,i,s,n){if(e==sm.ByHeight)return this.blockAt(t,i,s,n);if(e==sm.ByPosNoHeight){let{from:e,to:s}=i.doc.lineAt(t);return new sg(e,s-e,0,0,0)}let{firstLine:r,perLine:o,perChar:l}=this.heightMetrics(i,n),h=i.doc.lineAt(t),a=o+h.length*l,c=h.number-r,f=s+o*c+l*(h.from-n-c);return new sg(h.from,h.length,Math.max(s,Math.min(f,s+this.height-a)),a,0)}forEachLine(t,e,i,s,n,r){t=Math.max(t,n),e=Math.min(e,n+this.length);let{firstLine:o,perLine:l,perChar:h}=this.heightMetrics(i,n);for(let a=t,c=s;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=l*i+h*(t-n-i)}let s=l+h*e.length;r(new sg(e.from,e.length,c,s,0)),c+=s,a=e.to+1}}replace(t,e,i){let s=this.length-e;if(s>0){let t=i[i.length-1];t instanceof sk?i[i.length-1]=new sk(t.length+s):i.push(null,new sk(s-1))}if(t>0){let e=i[0];e instanceof sk?i[0]=new sk(t+e.length):i.unshift(new sk(t-1),null)}return sw.of(i)}decomposeLeft(t,e){e.push(new sk(t-1),null)}decomposeRight(t,e){e.push(null,new sk(this.length-t-1))}updateHeight(t,e=0,i=!1,s){let n=e+this.length;if(s&&s.from<=e+this.length&&s.more){let i=[],r=Math.max(e,s.from),o=-1;for(s.from>e&&i.push(new sk(s.from-e-1).updateHeight(t,e));r<=n&&s.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let n=s.heights[s.index++];-1==o?o=n:Math.abs(n-o)>=.001&&(o=-2);let l=new sy(e,n);l.outdated=!1,i.push(l),r+=e+1}r<=n&&i.push(null,new sk(n-r).updateHeight(t,r));let l=sw.of(i);return(o<0||Math.abs(l.height-this.height)>=.001||Math.abs(o-this.heightMetrics(t,e).perLine)>=.001)&&(su=!0),sv(this,l)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class sx extends sw{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,s){let n=i+this.left.height;return t<n?this.left.blockAt(t,e,i,s):this.right.blockAt(t,e,n,s+this.left.length+this.break)}lineAt(t,e,i,s,n){let r=s+this.left.height,o=n+this.left.length+this.break,l=e==sm.ByHeight?t<r:t<o,h=l?this.left.lineAt(t,e,i,s,n):this.right.lineAt(t,e,i,r,o);if(this.break||(l?h.to<o:h.from>o))return h;let a=e==sm.ByPosNoHeight?sm.ByPosNoHeight:sm.ByPos;return l?h.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,s,n).join(h)}forEachLine(t,e,i,s,n,r){let o=s+this.left.height,l=n+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,s,n,r),e>=l&&this.right.forEachLine(t,e,i,o,l,r);else{let h=this.lineAt(l,sm.ByPos,i,s,n);t<h.from&&this.left.forEachLine(t,h.from-1,i,s,n,r),h.to>=t&&h.from<=e&&r(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,o,l,r)}}replace(t,e,i){let s=this.left.length+this.break;if(e<s)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-s,e-s,i));let n=[];t>0&&this.decomposeLeft(t,n);let r=n.length;for(let t of i)n.push(t);if(t>0&&sS(n,r-1),e<this.length){let t=n.length;this.decomposeRight(e,n),sS(n,t)}return sw.of(n)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&t>=++i&&e.push(null),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,s=i+this.break;if(t>=s)return this.right.decomposeRight(t-s,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<s&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?sw.of(this.break?[t,null,e]:[t,e]):(this.left=sv(this.left,t),this.right=sv(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,s){let{left:n,right:r}=this,o=e+n.length+this.break,l=null;return(s&&s.from<=e+n.length&&s.more?l=n=n.updateHeight(t,e,i,s):n.updateHeight(t,e,i),s&&s.from<=o+r.length&&s.more?l=r=r.updateHeight(t,o,i,s):r.updateHeight(t,o,i),l)?this.balanced(n,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function sS(t,e){let i,s;null==t[e]&&(i=t[e-1])instanceof sk&&(s=t[e+1])instanceof sk&&t.splice(e-1,3,new sk(i.length+1+s.length))}class sC{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof sy?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new sy(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0,n=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new sb(r,s,i)):(r||n||s>=5)&&this.addLineDeco(s,n,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new sy(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new sk(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof sy)return t;let e=new sy(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,t),s.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof sy||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new sy(0,-1));let i=t;for(let t of this.nodes)t instanceof sy&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,s){let n=new sC(i,t);return tx.spans(e,i,s,n,0),n.finish(i)}}class sA{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,s){(t<e||i&&i.heightRelevant||s&&s.heightRelevant)&&eW(t,e,this.changes,5)}}class sP{constructor(t,e,i,s){this.from=t,this.to=e,this.size=i,this.displaySize=s}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let s=t[i],n=e[i];if(s.from!=n.from||s.to!=n.to||s.size!=n.size)return!1}return!0}draw(t,e){return eN.replace({widget:new sO(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class sO extends eB{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class sM{constructor(t){this.state=t,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=sB,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=eY.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(iy).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new sd(e),this.stateDeco=t.facet(ik).filter(t=>"function"!=typeof t),this.heightMap=sw.empty().applyChanges(this.stateDeco,c.empty,this.heightOracle.setDoc(t.doc),[new iT(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=eN.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let s=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>s>=t&&s<=e)){let{from:e,to:i}=this.lineBlockAt(s);t.push(new sT(e,i))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?sB:new sR(this.heightOracle,this.heightMap,this.viewports),2*!t.eq(this.scaler)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(sN(t,this.scaler))})}update(t,e=null){var i,s;let n;this.state=t.state;let r=this.stateDeco;this.stateDeco=this.state.facet(ik).filter(t=>"function"!=typeof t);let o=t.changedRanges,l=iT.extendWithRanges(o,(i=this.stateDeco,s=t?t.changes:A.empty(this.state.doc.length),n=new sA,tx.compare(r,i,s,n,0),n.changes)),h=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);su=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),l),(this.heightMap.height!=h||su)&&(t.flags|=2),a?(this.scrollAnchorPos=t.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=h);let c=l.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<c.from||e.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,e));let f=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,t.flags|=this.updateForViewport(),(f||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(il)&&(this.mustEnforceCursorAssoc=!0)}measure(t){var e;let i,s,n=t.contentDOM,r=window.getComputedStyle(n),o=this.heightOracle,l=r.whiteSpace;this.defaultTextDirection="rtl"==r.direction?eY.RTL:eY.LTR;let h=this.heightOracle.mustRefreshForWrapping(l),a=n.getBoundingClientRect(),f=h||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let u=0,d=0;if(a.width&&a.height){let{scaleX:t,scaleY:e}=t3(n,a);(t>.005&&Math.abs(this.scaleX-t)>.005||e>.005&&Math.abs(this.scaleY-e)>.005)&&(this.scaleX=t,this.scaleY=e,u|=16,h=f=!0)}let p=(parseInt(r.paddingTop)||0)*this.scaleY,g=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=g)&&(this.paddingTop=p,this.paddingBottom=g,u|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(o.lineWrapping&&(f=!0),this.editorWidth=t.scrollDOM.clientWidth,u|=16);let m=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=m&&(this.scrollAnchorHeight=-1,this.scrollTop=m),this.scrolledToBottom=et(t.scrollDOM);let w=(this.printing?function(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}:function(t,e){let i=t.getBoundingClientRect(),s=t.ownerDocument,n=s.defaultView||window,r=Math.max(0,i.left),o=Math.min(n.innerWidth,i.right),l=Math.max(0,i.top),h=Math.min(n.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=s.body;)if(1==e.nodeType){let i=e,s=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=s.overflow){let s=i.getBoundingClientRect();r=Math.max(r,s.left),o=Math.min(o,s.right),l=Math.max(l,s.top),h=Math.min(e==t.parentNode?n.innerHeight:h,s.bottom)}e="absolute"==s.position||"fixed"==s.position?i.offsetParent:i.parentNode}else if(11==e.nodeType)e=e.host;else break;return{left:r-i.left,right:Math.max(r,o)-i.left,top:l-(i.top+e),bottom:Math.max(l,h)-(i.top+e)}})(n,this.paddingTop),v=w.top-this.pixelViewport.top,b=w.bottom-this.pixelViewport.bottom;this.pixelViewport=w;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(f=!0)),!this.inView&&!this.scrollTarget&&(i=(e=t.dom).getBoundingClientRect(),s=e.ownerDocument.defaultView||window,!(i.left<s.innerWidth)||!(i.right>0)||!(i.top<s.innerHeight)||!(i.bottom>0)))return 0;let k=a.width;if((this.contentDOMWidth!=k||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=t.scrollDOM.clientHeight,u|=16),f){let e=t.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(e)&&(h=!0),h||o.lineWrapping&&Math.abs(k-this.contentDOMWidth)>o.charWidth){let{lineHeight:i,charWidth:s,textHeight:n}=t.docView.measureTextSize();(h=i>0&&o.refresh(l,i,s,n,k/s,e))&&(t.docView.minWidth=0,u|=16)}for(let i of(v>0&&b>0?d=Math.max(v,b):v<0&&b<0&&(d=Math.min(v,b)),su=!1,this.viewports)){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(h?sw.empty().applyChanges(this.stateDeco,c.empty,this.heightOracle,[new iT(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(o,0,h,new sp(i.from,s))}su&&(u|=2)}let x=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return x&&(2&u&&(u|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),u|=this.updateForViewport()),(2&u||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(h?[]:this.lineGaps,t)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),s=this.heightMap,n=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,l=new sT(s.lineAt(r-1e3*i,sm.ByHeight,n,0,0).from,s.lineAt(o+(1-i)*1e3,sm.ByHeight,n,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=s.lineAt(t,sm.ByPos,n,0,0),o;o="center"==e.y?(r.top+r.bottom)/2-i/2:"start"==e.y||"nearest"==e.y&&t<l.from?r.top:r.bottom-i,l=new sT(s.lineAt(o-500,sm.ByHeight,n,0,0).from,s.lineAt(o+i+500,sm.ByHeight,n,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),s=e.mapPos(t.to,1);return new sT(this.heightMap.lineAt(i,sm.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,sm.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(t,sm.ByPos,this.heightOracle,0,0),{bottom:n}=this.heightMap.lineAt(e,sm.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||s<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||n>=o+Math.max(10,Math.min(i,250)))&&s>r-2e3&&n<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let s of t)e.touchesRange(s.from,s.to)||i.push(new sP(e.mapPos(s.from),e.mapPos(s.to),s.size,s.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,n=s>>1,r=s<<1;if(this.defaultTextDirection!=eY.LTR&&!i)return[];let o=[],l=(s,r,h,a)=>{if(r-s<n)return;let c=this.state.selection.main,f=[c.from];for(let t of(c.empty||f.push(c.to),f))if(t>s&&t<r){l(s,t-10,h,a),l(t+10,r,h,a);return}let u=function(t,e){for(let i of t)if(e(i))return i}(t,t=>t.from>=h.from&&t.to<=h.to&&Math.abs(t.from-s)<n&&Math.abs(t.to-r)<n&&!f.some(e=>t.from<e&&t.to>e));if(!u){if(r<h.to&&e&&i&&e.visibleRanges.some(t=>t.from<=r&&t.to>=r)){let t=e.moveToLineBoundary(R.cursor(r),!1,!0).head;t>s&&(r=t)}let t=this.gapSize(h,s,r,a),n=i||t<2e6?t:2e6;u=new sP(s,r,t,n)}o.push(u)},h=e=>{var n,o,h;let a,c,f,u,d;if(e.length<r||e.type!=eR.Text)return;let p=(n=e.from,o=e.to,h=this.stateDeco,f=[],u=n,d=0,tx.spans(h,n,o,{span(){},point(t,e){t>u&&(f.push({from:u,to:t}),d+=t-u),u=e}},20),u<o&&(f.push({from:u,to:o}),d+=o-u),{total:d,ranges:f});if(p.total<r)return;let g=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,n=s/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=g){let s=sE(p,g),r=((this.visibleBottom-this.visibleTop)/2+n)/e.height;t=s-r,i=s+r}else t=(this.visibleTop-e.top-n)/e.height,i=(this.visibleBottom-e.top+n)/e.height;a=sD(p,t),c=sD(p,i)}else{let i,n,r=p.total*this.heightOracle.charWidth,o=s*this.heightOracle.charWidth,l=0;if(r>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=i.size-i.displaySize);let h=this.pixelViewport.left+l,f=this.pixelViewport.right+l;if(null!=g){let t=sE(p,g),e=((f-h)/2+o)/r;i=t-e,n=t+e}else i=(h-o)/r,n=(f+o)/r;a=sD(p,i),c=sD(p,n)}a>e.from&&l(e.from,a,e,p),c<e.to&&l(c,e.to,e,p)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(h):h(t);return o}gapSize(t,e,i,s){let n=sE(s,i)-sE(s,e);return this.heightOracle.lineWrapping?t.height*n:s.total*this.heightOracle.charWidth*n}updateLineGaps(t){sP.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=eN.set(t.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];tx.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let e=0;e<i.length&&!(8&s);e++){let n=this.visibleRanges[e],r=i[e];(n.from!=r.from||n.to!=r.to)&&(s|=4,t&&t.mapPos(n.from,-1)==r.from&&t.mapPos(n.to,1)==r.to||(s|=8))}return this.visibleRanges=i,s}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||sN(this.heightMap.lineAt(t,sm.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||sN(this.heightMap.lineAt(this.scaler.fromDOM(t),sm.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return sN(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class sT{constructor(t,e){this.from=t,this.to=e}}function sD({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let s=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:n}=e[t],r=n-i;if(s<=r)return i+s;s-=r}}function sE(t,e){let i=0;for(let{from:s,to:n}of t.ranges){if(e<=n){i+=e-s;break}i+=n-s}return i/t.total}let sB={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class sR{constructor(t,e,i){let s=0,n=0,r=0;for(let o of(this.viewports=i.map(({from:i,to:n})=>{let r=e.lineAt(i,sm.ByPos,t,0,0).top,o=e.lineAt(n,sm.ByPos,t,0,0).bottom;return s+=o-r,{from:i,to:n,top:r,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(e.height-s),this.viewports))o.domTop=r+(o.top-n)*this.scale,r=o.domBottom=o.domTop+(o.bottom-o.top),n=o.bottom}toDOM(t){for(let e=0,i=0,s=0;;e++){let n=e<this.viewports.length?this.viewports[e]:null;if(!n||t<n.top)return s+(t-i)*this.scale;if(t<=n.bottom)return n.domTop+(t-n.top);i=n.bottom,s=n.domBottom}}fromDOM(t){for(let e=0,i=0,s=0;;e++){let n=e<this.viewports.length?this.viewports[e]:null;if(!n||t<n.domTop)return i+(t-s)/this.scale;if(t<=n.domBottom)return n.top+(t-n.domTop);i=n.bottom,s=n.domBottom}}eq(t){return t instanceof sR&&this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to)}}function sN(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),s=e.toDOM(t.bottom);return new sg(t.from,t.length,i,s-i,Array.isArray(t._content)?t._content.map(t=>sN(t,e)):t._content)}let sL=I.define({combine:t=>t.join(" ")}),sI=I.define({combine:t=>t.indexOf(!0)>-1}),sV=tH.newName(),sH=tH.newName(),sW=tH.newName(),sz={"&light":"."+sH,"&dark":"."+sW};function sF(t,e,i){return new tH(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}let sq=sF("."+sV,{"&":{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:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{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"}},sz),s_={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},sj=ek.ie&&ek.ie_version<=11;class sU{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new t4,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(ek.ie&&ek.ie_version<=11||ek.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&ek.android&&!1!==t.constructor.EDIT_CONTEXT&&!(ek.chrome&&ek.chrome_version<126)&&(this.editContext=new s$(t),t.state.facet(ip)&&(t.contentDOM.editContext=this.editContext.editContext)),sj&&(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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null==(t=this.view.docView)?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(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(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){for(let e of(this.gapIntersection.disconnect(),t))this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(ip)?i.root.activeElement!=this.dom:!tK(this.dom,s))return;let n=s.anchorNode&&i.docView.nearest(s.anchorNode);if(n&&n.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(ek.ie&&ek.ie_version<=11||ek.android&&ek.chrome)&&!i.state.selection.main.empty&&s.focusNode&&tQ(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=tX(t.root);if(!e)return!1;let i=ek.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return sX(t,i)}let i=null;function s(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",s,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",s,!0),i?sX(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let s=tK(this.dom,i);return s&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,s=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=s)return!1;for(s=Math.min(s,t1(i));;)if(s){if(1!=i.nodeType)return!1;let t=i.childNodes[s-1];"false"==t.contentEditable?s--:s=t1(i=t)}else{if(i==t)return!0;s=tJ(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),s&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else if(11==i.nodeType)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,s_),sj&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),sj&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;this.delayedAndroidKey||(this.flushingAndroidKey=this.view.win.requestAnimationFrame(()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&t9(this.dom,t.key,t.keyCode))})),this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null==(i=this.delayedAndroidKey)?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,s=!1;for(let n of t){let t=this.readMutation(n);t&&(t.typeOver&&(s=!0),-1==e?{from:e,to:i}=t:(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:s}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),s=this.selectionChanged&&tK(this.dom,this.selectionRange);if(t<0&&!s)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let n=new iY(this.view,t,e,i);return this.view.docView.domChanged={newSel:n.newSel?n.newSel.main:null},n}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,s=iX(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),s}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=sY(e,t.previousSibling||t.target.previousSibling,-1),s=sY(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(ip)!=t.state.facet(ip)&&(t.view.contentDOM.editContext=t.state.facet(ip)?this.editContext.editContext:null))}destroy(){var t,e,i;for(let s of(this.stop(),null==(t=this.intersection)||t.disconnect(),null==(e=this.gapIntersection)||e.disconnect(),null==(i=this.resizeScroll)||i.disconnect(),this.scrollTargets))s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function sY(t,e,i){for(;e;){let s=er.get(e);if(s&&s.parent==t)return s;let n=e.parentNode;e=n!=t.dom?n:i>0?e.nextSibling:e.previousSibling}return null}function sX(t,e){let i=e.startContainer,s=e.startOffset,n=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return tQ(o.node,o.offset,n,r)&&([i,s,n,r]=[n,r,i,s]),{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}}class s${constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});for(let i in this.handlers.textupdate=e=>{let i=t.state.selection.main,{anchor:s,head:n}=i,r=this.toEditorPos(e.updateRangeStart),o=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:r,drifted:!1});let l={from:r,to:o,insert:c.of(e.text.split("\n"))};if(l.from==this.from&&s<this.from?l.from=s:l.to==this.to&&s>this.to&&(l.to=s),l.from==l.to&&!l.insert.length){let s=R.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd));s.main.eq(i)||t.dispatch({selection:s,userEvent:"select"});return}if((ek.mac||ek.android)&&l.from==n-1&&/^\. ?$/.test(e.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(l={from:r,to:o,insert:c.of([e.text.replace("."," ")])}),this.pendingContextChange=l,!t.state.readOnly){let i=this.to-this.from+(l.to-l.from+l.insert.length);i$(t,l,R.single(this.toEditorPos(e.selectionStart,i),this.toEditorPos(e.selectionEnd,i)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=i=>{let s=[],n=null;for(let e=this.toEditorPos(i.rangeStart),r=this.toEditorPos(i.rangeEnd);e<r;e++){let i=t.coordsForChar(e);n=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||n||new DOMRect,s.push(n)}e.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,s=t.underlineThickness;if("None"!=e&&"None"!=s){let n=this.toEditorPos(t.rangeStart),r=this.toEditorPos(t.rangeEnd);if(n<r){let t=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==s?1:2}px`;i.push(eN.mark({attributes:{style:t}}).range(n,r))}}}t.dispatch({effects:iu.of(eN.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}},this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=tX(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,s=this.pendingContextChange;return t.changes.iterChanges((n,r,o,l,h)=>{if(i)return;let a=h.length-(r-n);if(s&&r>=s.to)if(s.from==n&&s.to==r&&s.insert.eq(h)){s=this.pendingContextChange=null,e+=a,this.to+=a;return}else s=null,this.revertPending(t.state);if(n+=e,(r+=e)<=this.from)this.from+=a,this.to+=a;else if(n<this.to){if(n<this.from||r>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(n),this.toContextPos(r),h.toString()),this.to+=a}e+=a}),s&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),s=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class sK{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;for(let e of(this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach(t=>i(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new sM(t.state||tm.create(t)),t.scrollTo&&t.scrollTo.is(ic)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(im).map(t=>new iv(t)),this.plugins))e.update(this);this.observer=new sU(this),this.inputState=new iK(this),this.inputState.ensureHandlers(this.plugins),this.docView=new iE(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null==(e=document.fonts)?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof ta?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,s,n=this.state;for(let e of t){if(e.startState!=n)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=e.state}if(this.destroyed){this.viewState.state=n;return}let r=this.hasFocus,o=0,l=null;t.some(t=>t.annotation(sl))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,(l=sh(n,r))||(o=1));let h=this.observer.delayedAndroidKey,a=null;if(h?(this.observer.clearDelayedAndroidKey(),((a=this.observer.readChange())&&!this.state.doc.eq(n.doc)||!this.state.selection.eq(n.selection))&&(a=null)):this.observer.clear(),n.facet(tm.phrases)!=this.state.facet(tm.phrases))return this.setState(n);s=iD.create(this,n,t),s.flags|=o;let c=this.viewState.scrollTarget;try{for(let e of(this.updateState=2,t)){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new ia(t.empty?t:R.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(ic)&&(c=t.value.clip(this.state))}this.viewState.update(s,c),this.bidiCache=sJ.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(iM)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(sL)!=s.state.facet(sL)&&(this.viewState.mustMeasureContent=!0),(e||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!s.empty)for(let t of this.state.facet(it))try{t(s)}catch(t){id(this.state,t,"update listener")}(l||a)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),a&&!iX(this,a)&&h.force&&t9(this.contentDOM,h.key,h.keyCode)})}setState(t){if(0!=this.updateState)throw Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);for(let e of(this.viewState=new sM(t),this.plugins=t.facet(im).map(t=>new iv(t)),this.pluginMap.clear(),this.plugins))e.update(this);this.docView.destroy(),this.docView=new iE(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(im),i=t.state.facet(im);if(e!=i){let s=[];for(let n of i){let i=e.indexOf(n);if(i<0)s.push(new iv(n));else{let e=this.plugins[i];e.mustUpdate=t,s.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){id(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,s=i.scrollTop*this.scaleY,{scrollAnchorPos:n,scrollAnchorHeight:r}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(et(i))n=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(s);n=t.from,r=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&o||([this.measureRequests,l]=[l,this.measureRequests]);let h=l.map(t=>{try{return t.read(this)}catch(t){return id(this.state,t),sQ}}),a=iD.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,!a.empty&&(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),(c=this.docView.update(a))&&this.docViewUpdate());for(let t=0;t<l.length;t++)if(h[t]!=sQ)try{let e=l[t];e.write&&e.write(h[t],this)}catch(t){id(this.state,t)}if(c&&this.docView.updateSelection(!0),!a.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}else{let t=(n<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(n).top)-r;if(t>1||t<-1){i.scrollTop=(s+=t)/this.scaleY,r=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(it))t(e)}get themeClasses(){return sV+" "+(this.state.facet(sI)?sW:sH)+" "+this.state.facet(sL)}updateAttrs(){let t=sZ(this,ib,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ip)?"true":"false",class:"cm-content",style:`${ek.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),sZ(this,iy,e);let i=this.observer.ignore(()=>{let i=eE(this.contentDOM,this.contentAttrs,e),s=eE(this.dom,this.editorAttrs,t);return i||s});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)t.is(sK.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(iM);let t=this.state.facet(sK.cspNonce);tH.mount(this.root,this.styleModules.concat(sq).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if((this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t)&&!(this.measureRequests.indexOf(t)>-1)){if(null!=t.key){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return i_(this,t,iF(this,t,e,i))}moveByGroup(t,e){return i_(this,t,iF(this,t,e,e=>{var i;let s,n;return i=t.head,n=(s=this.state.charCategorizer(i))(e),t=>{let e=s(t);return n==tp.Space&&(n=e),n==e}}))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),n=i[e?i.length-1:0];return R.cursor(n.side(e,s)+t.from,n.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,s){let n=iz(t,e.head,e.assoc||-1),r=s&&n.type==eR.Text&&(t.lineWrapping||n.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),s=t.textDirectionAt(n.from),o=t.posAtCoords({x:i==(s==eY.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return R.cursor(o,i?-1:1)}return R.cursor(i?n.to:n.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return i_(this,t,function(t,e,i,s){let n=e.head,r=i?1:-1;if(n==(i?t.state.doc.length:0))return R.cursor(n,e.assoc);let o=e.goalColumn,l,h=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(n,e.assoc||-1),c=t.documentTop;if(a)null==o&&(o=a.left-h.left),l=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(n);null==o&&(o=Math.min(h.right-h.left,t.defaultCharacterWidth*(n-e.from))),l=(r<0?e.top:e.bottom)+c}let f=h.left+o,u=null!=s?s:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=l+(u+e)*r,s=iH(t,{x:f,y:i},!1,r);if(i<h.top||i>h.bottom||(r<0?s<n:s>n)){let e=t.docView.coordsForChar(s),n=!e||i<e.top?-1:1;return R.cursor(s,n,void 0,o)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),iH(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(t),n=this.bidiSpans(s);return t2(i,n[e2.find(n,t-s.from,-1,e)].dir==eY.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(io)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>sG)return e4(t.length);let e=this.textDirectionAt(t.from),i;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==e&&(s.fresh||function t(e,i){if(e.length!=i.length)return!1;for(let s=0;s<e.length;s++){let n=e[s],r=i[s];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!t(n.inner,r.inner))return!1}return!0}(s.isolates,i=iA(this,t))))return s.order;i||(i=iA(this,t));let s=function(t,e,i){if(!t)return[new e2(0,0,+(e==e$))];if(e==eX&&!i.length&&!e1.test(t))return e4(t.length);if(i.length)for(;t.length>e3.length;)e3[e3.length]=256;let s=[],n=+(e!=eX);return function t(e,i,s,n,r,o,l){let h=i%2?2:1;!function(t,e,i,s,n){for(let r=0;r<=s.length;r++){let o=r?s[r-1].to:e,l=r<s.length?s[r].from:i,h=r?256:n;for(let e=o,i=h,s=h;e<l;e++){let n=e0(t.charCodeAt(e));512==n?n=i:8==n&&4==s&&(n=16),e3[e]=4==n?2:n,7&n&&(s=n),i=n}for(let t=o,e=h,s=h;t<l;t++){let n=e3[t];if(128==n)t<l-1&&e==e3[t+1]&&24&e?n=e3[t]=e:e3[t]=256;else if(64==n){let n=t+1;for(;n<l&&64==e3[n];)n++;let r=t&&8==e||n<i&&8==e3[n]?1==s?1:8:256;for(let e=t;e<n;e++)e3[e]=r;t=n-1}else 8==n&&1==s&&(e3[t]=1);e=n,7&n&&(s=n)}}}(e,r,o,n,h),function(t,e,i,s,n){let r=1==n?2:1;for(let o=0,l=0,h=0;o<=s.length;o++){let a=o?s[o-1].to:e,c=o<s.length?s[o].from:i;for(let e=a,i,s,o;e<c;e++)if(s=eJ[i=t.charCodeAt(e)])if(s<0){for(let t=l-3;t>=0;t-=3)if(eZ[t+1]==-s){let i=eZ[t+2],s=2&i?n:4&i?1&i?r:n:0;s&&(e3[e]=e3[eZ[t]]=s),l=t;break}}else if(189==eZ.length)break;else eZ[l++]=e,eZ[l++]=i,eZ[l++]=h;else if(2==(o=e3[e])||1==o){let t=o==n;h=+!t;for(let e=l-3;e>=0;e-=3){let i=eZ[e+2];if(2&i)break;if(t)eZ[e+2]|=2;else{if(4&i)break;eZ[e+2]|=4}}}}}(e,r,o,n,h),function(t,e,i,s){for(let n=0,r=s;n<=i.length;n++){let o=n?i[n-1].to:t,l=n<i.length?i[n].from:e;for(let h=o;h<l;){let o=e3[h];if(256==o){let o=h+1;for(;;)if(o==l){if(n==i.length)break;o=i[n++].to,l=n<i.length?i[n].from:e}else if(256==e3[o])o++;else break;let a=1==r,c=a==((o<e?e3[o]:s)==1)?a?1:2:s;for(let e=o,s=n,r=s?i[s-1].to:t;e>h;)e==r&&(e=i[--s].from,r=s?i[s-1].to:t),e3[--e]=c;h=o}else r=o,h++}}}(r,o,n,h),function e(i,s,n,r,o,l,h){let a=r%2?2:1;if(r%2==o%2)for(let c=s,f=0;c<n;){let s=!0,u=!1;if(f==l.length||c<l[f].from){let t=e3[c];t!=a&&(s=!1,u=16==t)}let d=s||1!=a?null:[],p=s?r:r+1,g=c;e:for(;;)if(f<l.length&&g==l[f].from){if(u)break;let e=l[f];if(!s)for(let t=e.to,i=f+1;;){if(t==n)break e;if(i<l.length&&l[i].from==t)t=l[i++].to;else if(e3[t]==a)break e;else break}f++,d?d.push(e):(e.from>c&&h.push(new e2(c,e.from,p)),t(i,e.direction==eX!=!(p%2)?r+1:r,o,e.inner,e.from,e.to,h),c=e.to),g=e.to}else if(g==n||(s?e3[g]!=a:e3[g]==a))break;else g++;d?e(i,c,g,r+1,o,d,h):c<g&&h.push(new e2(c,g,p)),c=g}else for(let c=n,f=l.length;c>s;){let n=!0,u=!1;if(!f||c>l[f-1].to){let t=e3[c-1];t!=a&&(n=!1,u=16==t)}let d=n||1!=a?null:[],p=n?r:r+1,g=c;e:for(;;)if(f&&g==l[f-1].to){if(u)break;let e=l[--f];if(!n)for(let t=e.from,i=f;;){if(t==s)break e;if(i&&l[i-1].to==t)t=l[--i].from;else if(e3[t-1]==a)break e;else break}d?d.push(e):(e.to<c&&h.push(new e2(e.to,c,p)),t(i,e.direction==eX!=!(p%2)?r+1:r,o,e.inner,e.from,e.to,h),c=e.from),g=e.from}else if(g==s||(n?e3[g-1]!=a:e3[g-1]==a))break;else g--;d?e(i,g,c,r+1,o,d,h):g<c&&h.push(new e2(g,c,p)),c=g}}(e,r,o,i,s,n,l)}(t,n,n,i,0,t.length,s),s}(t.text,e,i);return this.bidiCache.push(new sJ(t.from,t.to,e,i,!0,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ek.safari&&(null==(t=this.inputState)?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{t8(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return ic.of(new ia("number"==typeof t?R.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return ic.of(new ia(R.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return iw.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return iw.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=tH.newName(),s=[sL.of(i),iM.of(sF(`.${i}`,t))];return e&&e.dark&&s.push(sI.of(!0)),s}static baseTheme(t){return U.lowest(iM.of(sF("."+sV,t,sz)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&er.get(i)||er.get(t);return(null==(e=null==s?void 0:s.rootView)?void 0:e.view)||null}}sK.styleModule=iM,sK.inputHandler=ie,sK.clipboardInputFilter=is,sK.clipboardOutputFilter=ir,sK.scrollHandler=ih,sK.focusChangeEffect=ii,sK.perLineTextDirection=io,sK.exceptionSink=e7,sK.updateListener=it,sK.editable=ip,sK.mouseSelectionStyle=e9,sK.dragMovesSelection=e6,sK.clickAddsSelectionRange=e8,sK.decorations=ik,sK.outerDecorations=ix,sK.atomicRanges=iS,sK.bidiIsolatedRanges=iC,sK.scrollMargins=iP,sK.darkTheme=sI,sK.cspNonce=I.define({combine:t=>t.length?t[0]:""}),sK.contentAttributes=iy,sK.editorAttributes=ib,sK.lineWrapping=sK.contentAttributes.of({class:"cm-lineWrapping"}),sK.announce=th.define();let sG=4096,sQ={};class sJ{constructor(t,e,i,s,n,r){this.from=t,this.to=e,this.dir=i,this.isolates=s,this.fresh=n,this.order=r}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],s=t.length?t[t.length-1].dir:eY.LTR;for(let n=Math.max(0,t.length-10);n<t.length;n++){let r=t[n];r.dir!=s||e.touchesRange(r.from,r.to)||i.push(new sJ(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function sZ(t,e,i){for(let s=t.state.facet(e),n=s.length-1;n>=0;n--){let e=s[n],r="function"==typeof e?e(t):e;r&&eM(r,i)}return i}let s0=ek.mac?"mac":ek.windows?"win":ek.linux?"linux":"key";function s1(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}let s2=U.default(sK.domEventHandlers({keydown:(t,e)=>(function(t,e,i,s){var n;s8=e;let r=("Esc"==(n=!(t_&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||tj&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?tq:tF)[e.keyCode]||e.key||"Unidentified")&&(n="Escape"),"Del"==n&&(n="Delete"),"Left"==n&&(n="ArrowLeft"),"Up"==n&&(n="ArrowUp"),"Right"==n&&(n="ArrowRight"),"Down"==n&&(n="ArrowDown"),n),o=(65536>function(t,e){let i=t.charCodeAt(0);if(!(i>=55296&&i<56320)||1==t.length)return i;let s=t.charCodeAt(e+1);return s>=56320&&s<57344?(i-55296<<10)+(s-56320)+65536:i}(r,0)?1:2)==r.length&&" "!=r,l="",h=!1,a=!1,c=!1;s5&&s5.view==i&&s5.scope==s&&(l=s5.prefix+" ",0>iZ.indexOf(e.keyCode)&&(a=!0,s5=null));let f=new Set,u=t=>{if(t){for(let e of t.run)if(!f.has(e)&&(f.add(e),e(i)))return t.stopPropagation&&(c=!0),!0;t.preventDefault&&(t.stopPropagation&&(c=!0),a=!0)}return!1},d=t[s],p,g;return d&&(u(d[l+s1(r,e,!o)])?h=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ek.windows&&e.ctrlKey&&e.altKey)&&(p=tF[e.keyCode])&&p!=r?u(d[l+s1(p,e,!0)])?h=!0:e.shiftKey&&(g=tq[e.keyCode])!=r&&g!=p&&u(d[l+s1(g,e,!1)])&&(h=!0):o&&e.shiftKey&&u(d[l+s1(r,e,!0)])&&(h=!0),!h&&u(d._any)&&(h=!0)),a&&(h=!0),h&&c&&e.stopPropagation(),s8=null,h})(function(t){let e=t.facet(s3),i=s4.get(e);return i||s4.set(e,i=function(t,e=s0){let i=Object.create(null),s=Object.create(null),n=(t,e)=>{let i=s[t];if(null==i)s[t]=e;else if(i!=e)throw Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},r=(t,s,r,o,l)=>{var h,a;let c=i[t]||(i[t]=Object.create(null)),f=s.split(/ (?!$)/).map(t=>(function(t,e){let i,s,n,r,o=t.split(/-(?!$)/),l=o[o.length-1];"Space"==l&&(l=" ");for(let t=0;t<o.length-1;++t){let l=o[t];if(/^(cmd|meta|m)$/i.test(l))r=!0;else if(/^a(lt)?$/i.test(l))i=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))n=!0;else if(/^mod$/i.test(l))"mac"==e?r=!0:s=!0;else throw Error("Unrecognized modifier name: "+l)}return i&&(l="Alt-"+l),s&&(l="Ctrl-"+l),r&&(l="Meta-"+l),n&&(l="Shift-"+l),l})(t,e));for(let e=1;e<f.length;e++){let i=f.slice(0,e).join(" ");n(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let s=s5={view:e,prefix:i,scope:t};return setTimeout(()=>{s5==s&&(s5=null)},4e3),!0}]})}let u=f.join(" ");n(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(null==(a=null==(h=c._any)?void 0:h.run)?void 0:a.slice())||[]});r&&d.run.push(r),o&&(d.preventDefault=!0),l&&(d.stopPropagation=!0)};for(let s of t){let t=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:n}=s;for(let e in t)t[e].run.push(t=>n(t,s8))}let n=s[e]||s.key;if(n)for(let e of t)r(e,n,s.run,s.preventDefault,s.stopPropagation),s.shift&&r(e,"Shift-"+n,s.shift,s.preventDefault,s.stopPropagation)}return i}(e.reduce((t,e)=>t.concat(e),[]))),i}(e.state),t,e,"editor")})),s3=I.define({enables:s2}),s4=new WeakMap,s5=null,s8=null;I.define();I.define({combine:t=>tw(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}),U.highest(sK.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));let s6=th.define({map:(t,e)=>null==t?null:e.mapPos(t)});q.define({create:()=>null,update:(t,e)=>(null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((t,e)=>e.is(s6)?e.value:t,t))});let s9=null!=/x/.unicode?"gu":"g",s7=RegExp("[\0-\b\n-\x1f-Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]",s9),nt=null;I.define({combine(t){let e=tw(t,{render:null,specialChars:s7,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==nt&&"undefined"!=typeof document&&document.body){let e=document.body.style;nt=(null!=(t=e.tabSize)?t:e.MozTabSize)!=null}return nt||!1}())&&(e.specialChars=RegExp("	|"+e.specialChars.source,s9)),e.addSpecialChars&&(e.specialChars=RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,s9)),e}});let ne="-10000px";class ni{constructor(t,e,i,s){this.facet=e,this.createTooltipView=i,this.removeTooltipView=s,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let n=null;this.tooltipViews=this.tooltips.map(t=>n=i(t,n))}update(t,e){var i;let s=t.state.facet(this.facet),n=s.filter(t=>t);if(s===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let r=[],o=e?[]:null;for(let i=0;i<n.length;i++){let s=n[i],l=-1;if(s){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==s.create&&(l=t)}if(l<0)r[i]=this.createTooltipView(s,i?r[i-1]:null),o&&(o[i]=!!s.above);else{let s=r[i]=this.tooltipViews[l];o&&(o[i]=e[l]),s.update&&s.update(t)}}}for(let t of this.tooltipViews)0>r.indexOf(t)&&(this.removeTooltipView(t),null==(i=t.destroy)||i.call(t));return e&&(o.forEach((t,i)=>e[i]=t),e.length=o.length),this.input=s,this.tooltips=n,this.tooltipViews=r,!0}}function ns(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}let nn=I.define({combine:t=>{var e,i,s;return{position:ek.ios?"absolute":(null==(e=t.find(t=>t.position))?void 0:e.position)||"fixed",parent:(null==(i=t.find(t=>t.parent))?void 0:i.parent)||null,tooltipSpace:(null==(s=t.find(t=>t.tooltipSpace))?void 0:s.tooltipSpace)||ns}}}),nr=new WeakMap,no=iw.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(nn);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new ni(t,nc,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver)for(let t of(this.intersectionObserver.disconnect(),this.manager.tooltipViews))this.intersectionObserver.observe(t.dom)}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,s=t.state.facet(nn);if(s.position!=this.position&&!this.madeAbsolute){for(let t of(this.position=s.position,this.manager.tooltipViews))t.dom.style.position=this.position;i=!0}if(s.parent!=this.parent){for(let t of(this.parent&&this.container.remove(),this.parent=s.parent,this.createContainer(),this.manager.tooltipViews))this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t,e){let i=t.create(this.view),s=e?e.dom:null;if(i.dom.classList.add("cm-tooltip"),t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",i.dom.appendChild(t)}return i.dom.style.position=this.position,i.dom.style.top=ne,i.dom.style.left="0px",this.container.insertBefore(i.dom,s),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var t,e,i;for(let e of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))e.dom.remove(),null==(t=e.destroy)||t.call(e);this.parent&&this.container.remove(),null==(e=this.resizeObserver)||e.disconnect(),null==(i=this.intersectionObserver)||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(ek.gecko)i=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==ne&&"0px"==t.style.left){let e=t.getBoundingClientRect();i=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(i||"absolute"==this.position)if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(t=i.width/this.parent.offsetWidth,e=i.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let s=this.view.scrollDOM.getBoundingClientRect(),n=iO(this.view);return{visible:{left:s.left+n.left,top:s.top+n.top,right:s.right-n.right,bottom:s.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(nn).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i}}writeMeasure(t){var e;if(t.makeAbsolute)for(let t of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))t.dom.style.position="absolute";let{visible:i,space:s,scaleX:n,scaleY:r}=t,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let h=this.manager.tooltips[l],a=this.manager.tooltipViews[l],{dom:c}=a,f=t.pos[l],u=t.size[l];if(!f||!1!==h.clip&&(f.bottom<=Math.max(i.top,s.top)||f.top>=Math.min(i.bottom,s.bottom)||f.right<Math.max(i.left,s.left)-.1||f.left>Math.min(i.right,s.right)+.1)){c.style.top=ne;continue}let d=h.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=7*!!d,g=u.right-u.left,m=null!=(e=nr.get(a))?e:u.bottom-u.top,w=a.offset||na,v=this.view.textDirection==eY.LTR,b=u.width>s.right-s.left?v?s.left:s.right-u.width:v?Math.max(s.left,Math.min(f.left-14*!!d+w.x,s.right-g)):Math.min(Math.max(s.left,f.left-g+14*!!d-w.x),s.right-g),y=this.above[l];!h.strictSide&&(y?f.top-m-p-w.y<s.top:f.bottom+m+p+w.y>s.bottom)&&y==s.bottom-f.bottom>f.top-s.top&&(y=this.above[l]=!y);let k=(y?f.top-s.top:s.bottom-f.bottom)-p;if(k<m&&!1!==a.resize){if(k<this.view.defaultLineHeight){c.style.top=ne;continue}nr.set(a,m),c.style.height=(m=k)/r+"px"}else c.style.height&&(c.style.height="");let x=y?f.top-m-p-w.y:f.bottom+p+w.y,S=b+g;if(!0!==a.overlap)for(let t of o)t.left<S&&t.right>b&&t.top<x+m&&t.bottom>x&&(x=y?t.top-m-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(x-t.parent.top)/r+"px",nl(c,(b-t.parent.left)/n)):(c.style.top=x/r+"px",nl(c,b/n)),d){let t=f.left+(v?w.x:-w.x)-(b+14-7);d.style.left=t/n+"px"}!0!==a.overlap&&o.push({left:b,top:x,right:S,bottom:x+m}),c.classList.toggle("cm-tooltip-above",y),c.classList.toggle("cm-tooltip-below",!y),a.positioned&&a.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView)&&(this.inView=this.view.inView,!this.inView))for(let t of this.manager.tooltipViews)t.dom.style.top=ne}},{eventObservers:{scroll(){this.maybeMeasure()}}});function nl(t,e){let i=parseInt(t.style.left,10);(isNaN(i)||Math.abs(e-i)>1)&&(t.style.left=e+"px")}let nh=sK.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),na={x:0,y:0},nc=I.define({enables:[no,nh]}),nf=I.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});th.define();let nu=I.define({combine(t){let e,i;for(let s of t)e=e||s.topContainer,i=i||s.bottomContainer;return{topContainer:e,bottomContainer:i}}}),nd=iw.fromClass(class{constructor(t){this.input=t.state.facet(nm),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet(nu);for(let i of(this.top=new np(t,!0,e.topContainer),this.bottom=new np(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top)),this.panels))i.dom.classList.add("cm-panel"),i.mount&&i.mount()}update(t){let e=t.state.facet(nu);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new np(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new np(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(nm);if(i!=this.input){let e=i.filter(t=>t),s=[],n=[],r=[],o=[];for(let i of e){let e=this.specs.indexOf(i),l;e<0?(l=i(t.view),o.push(l)):(l=this.panels[e]).update&&l.update(t),s.push(l),(l.top?n:r).push(l)}for(let t of(this.specs=e,this.panels=s,this.top.sync(n),this.bottom.sync(r),o))t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>sK.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class np{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&0>t.indexOf(e)&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=ng(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=ng(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function ng(t){let e=t.nextSibling;return t.remove(),e}let nm=I.define({enables:nd});q.define({create:()=>[],update(t,e){for(let i of e.effects)i.is(nw)?t=[i.value].concat(t):i.is(nv)&&(t=t.filter(t=>t!=i.value));return t},provide:t=>nm.computeN([t],e=>e.field(t))});let nw=th.define(),nv=th.define();class nb extends tv{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}nb.prototype.elementClass="",nb.prototype.toDOM=void 0,nb.prototype.mapMode=S.TrackBefore,nb.prototype.startSide=nb.prototype.endSide=-1,nb.prototype.point=!0;let ny=I.define(),nk=I.define(),nx={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>tx.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},nS=I.define(),nC=I.define({combine:t=>t.some(t=>t)});function nA(t){let e=[nP];return t&&!1===t.fixed&&e.push(nC.of(!0)),e}let nP=iw.fromClass(class{constructor(t){for(let e of(this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(nS).map(e=>new nD(t,e)),this.fixed=!t.state.facet(nC),this.gutters))"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,s=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(s<(i.to-i.from)*.8)}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(nC)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=tx.iter(this.view.state.facet(ny),this.view.viewport.from),s=[],n=this.gutters.map(t=>new nT(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(s.length&&(s=[]),Array.isArray(t.type)){let e=!0;for(let r of t.type)if(r.type==eR.Text&&e){for(let t of(nM(i,s,r.from),n))t.line(this.view,r,s);e=!1}else if(r.widget)for(let t of n)t.widget(this.view,r)}else if(t.type==eR.Text)for(let e of(nM(i,s,t.from),n))e.line(this.view,t,s);else if(t.widget)for(let e of n)e.widget(this.view,t);for(let t of n)t.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(nS),i=t.state.facet(nS),s=t.docChanged||t.heightChanged||t.viewportChanged||!tx.eq(t.startState.facet(ny),t.state.facet(ny),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(s=!0);else{s=!0;let n=[];for(let s of i){let i=e.indexOf(s);i<0?n.push(new nD(this.view,s)):(this.gutters[i].update(t),n.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),0>n.indexOf(t)&&t.destroy();for(let t of n)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=n}return s}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>sK.scrollMargins.of(e=>{let i=e.plugin(t);if(!i||0==i.gutters.length||!i.fixed)return null;let s=i.dom.offsetWidth*e.scaleX,n=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==eY.LTR?{left:s,right:n}:{right:s,left:n}})});function nO(t){return Array.isArray(t)?t:[t]}function nM(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class nT{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=tx.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:s}=this,n=(e.top-this.height)/t.scaleY,r=e.height/t.scaleY;if(this.i==s.elements.length){let e=new nE(t,r,n,i);s.elements.push(e),s.dom.appendChild(e.dom)}else s.elements[this.i].update(t,r,n,i);this.height=e.bottom,this.i++}line(t,e,i){let s=[];nM(this.cursor,s,e.from),i.length&&(s=s.concat(i));let n=this.gutter.config.lineMarker(t,e,s);n&&s.unshift(n);let r=this.gutter;(0!=s.length||r.config.renderEmptyElements)&&this.addElement(t,e,s)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),s=i?[i]:null;for(let i of t.state.facet(nk)){let n=i(t,e.widget,e);n&&(s||(s=[])).push(n)}s&&this.addElement(t,e,s)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class nD{constructor(t,e){for(let i in this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),e.domEventHandlers)this.dom.addEventListener(i,s=>{let n=s.target,r;if(n!=this.dom&&this.dom.contains(n)){for(;n.parentNode!=this.dom;)n=n.parentNode;let t=n.getBoundingClientRect();r=(t.top+t.bottom)/2}else r=s.clientY;let o=t.lineBlockAtHeight(r-t.documentTop);e.domEventHandlers[i](t,o,s)&&s.preventDefault()});this.markers=nO(e.markers(t)),e.initialSpacer&&(this.spacer=new nE(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=nO(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!tx.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class nE{constructor(t,e,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,s)}update(t,e,i,s){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),!function(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,s)&&this.setMarkers(t,s)}setMarkers(t,e){let i="cm-gutterElement",s=this.dom.firstChild;for(let n=0,r=0;;){let o=r,l=n<e.length?e[n++]:null,h=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=r;t<this.markers.length;t++)if(this.markers[t].compare(l)){o=t,h=!0;break}}else o=this.markers.length;for(;r<o;){let t=this.markers[r++];if(t.toDOM){t.destroy(s);let e=s.nextSibling;s.remove(),s=e}}if(!l)break;l.toDOM&&(h?s=s.nextSibling:this.dom.insertBefore(l.toDOM(t),s)),h&&r++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}let nB=I.define(),nR=I.define(),nN=I.define({combine:t=>tw(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let s=i[t],n=e[t];i[t]=s?(t,e,i)=>s(t,e,i)||n(t,e,i):n}return i}})});class nL extends nb{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function nI(t,e){return t.state.facet(nN).formatNumber(e,t.state)}let nV=nS.compute([nN],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(nB),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new nL(nI(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,i)=>{for(let s of t.state.facet(nR)){let n=s(t,e,i);if(n)return n}return null},lineMarkerChange:t=>t.startState.facet(nN)!=t.state.facet(nN),initialSpacer:t=>new nL(nI(t,nW(t.state.doc.lines))),updateSpacer(t,e){let i=nI(e.view,nW(e.view.state.doc.lines));return i==t.number?t:new nL(i)},domEventHandlers:t.facet(nN).domEventHandlers,side:"before"}));function nH(t={}){return[nN.of(t),nA(),nV]}function nW(t){let e=9;for(;e<t;)e=10*e+9;return e}let nz=0;class nF{constructor(t,e){this.from=t,this.to=e}}class nq{constructor(t={}){this.id=nz++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=nU.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}nq.closedBy=new nq({deserialize:t=>t.split(" ")}),nq.openedBy=new nq({deserialize:t=>t.split(" ")}),nq.group=new nq({deserialize:t=>t.split(" ")}),nq.isolate=new nq({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw RangeError("Invalid value for isolate: "+t);return t||"auto"}}),nq.contextHash=new nq({perNode:!0}),nq.lookAhead=new nq({perNode:!0}),nq.mounted=new nq({perNode:!0});class n_{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[nq.mounted.id]}}let nj=Object.create(null);class nU{constructor(t,e,i,s=0){this.name=t,this.props=e,this.id=i,this.flags=s}static define(t){let e=t.props&&t.props.length?Object.create(null):nj,i=!!t.top|2*!!t.skipped|4*!!t.error|8*(null==t.name),s=new nU(t.name||"",e,t.id,i);if(t.props){for(let i of t.props)if(Array.isArray(i)||(i=i(s)),i){if(i[0].perNode)throw RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}}return s}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(nq.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let s of i.split(" "))e[s]=t[i];return t=>{for(let i=t.prop(nq.group),s=-1;s<(i?i.length:0);s++){let n=e[s<0?t.name:i[s]];if(n)return n}}}}nU.none=new nU("",Object.create(null),0,8);class nY{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let s=null;for(let e of t){let t=e(i);t&&(s||(s=Object.assign({},i.props)),s[t[0].id]=t[1])}e.push(s?new nU(i.name,s,i.id,i.flags):i)}return new nY(e)}}let nX=new WeakMap,n$=new WeakMap;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(k||(k={}));class nK{constructor(t,e,i,s,n){if(this.type=t,this.children=e,this.positions=i,this.length=s,this.props=null,n&&n.length)for(let[t,e]of(this.props=Object.create(null),n))this.props["number"==typeof t?t:t.id]=e}toString(){let t=n_.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new n9(this.topNode,t)}cursorAt(t,e=0,i=0){let s=new n9(nX.get(this)||this.topNode);return s.moveTo(t,e),nX.set(this,s._tree),s}get topNode(){return new n1(this,0,0,null)}resolve(t,e=0){let i=nZ(nX.get(this)||this.topNode,t,e,!1);return nX.set(this,i),i}resolveInner(t,e=0){let i=nZ(n$.get(this)||this.topNode,t,e,!0);return n$.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let s=t.resolveInner(e,i),n=null;for(let t=s instanceof n1?s:s.context.parent;t;t=t.parent)if(t.index<0){let r=t.parent;(n||(n=[s])).push(r.resolve(e,i)),t=r}else{let r=n_.get(t.tree);if(r&&r.overlay&&r.overlay[0].from<=e&&r.overlay[r.overlay.length-1].to>=e){let o=new n1(r.tree,r.overlay[0].from+t.from,-1,t);(n||(n=[s])).push(nZ(o,e,i,!1))}}return n?n8(n):s}(this,t,e)}iterate(t){let{enter:e,leave:i,from:s=0,to:n=this.length}=t,r=t.mode||0,o=(r&k.IncludeAnonymous)>0;for(let t=this.cursor(r|k.IncludeAnonymous);;){let r=!1;if(t.from<=n&&t.to>=s&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:ri(nU.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,i)=>new nK(this.type,t,e,i,this.propValues),t.makeTree||((t,e,i)=>new nK(nU.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:n=1024,reused:r=[],minRepeatType:o=s.types.length}=t,l=Array.isArray(i)?new nG(i,i.length):i,h=s.types,a=0,c=0;function f(t,e,i,n,r,o,l,h,a){let c=[],f=[];for(;t.length>n;)c.push(t.pop()),f.push(e.pop()+i-r);t.push(u(s.types[l],c,f,o-r,h-o,a)),e.push(r-i)}function u(t,e,i,s,n,r,o){if(r){let t=[nq.contextHash,r];o=o?[t].concat(o):[t]}if(n>25){let t=[nq.lookAhead,n];o=o?[t].concat(o):[t]}return new nK(t,e,i,s,o)}let d=[],p=[];for(;l.pos>0;)!function t(e,i,d,p,g,m){let{id:w,start:v,end:b,size:y}=l,k=c,x=a;for(;y<0;){if(l.next(),-1==y){let t=r[w];d.push(t),p.push(v-e);return}if(-3==y){a=w;return}if(-4==y){c=w;return}else throw RangeError(`Unrecognized record size: ${y}`)}let S=h[w],C,A,P=v-e;if(b-v<=n&&(A=function(t,e){let i=l.fork(),s=0,r=0,h=0,a=i.end-n,c={size:0,start:0,skip:0};i:for(let n=i.pos-t;i.pos>n;){let t=i.size;if(i.id==e&&t>=0){c.size=s,c.start=r,c.skip=h,h+=4,s+=4,i.next();continue}let l=i.pos-t;if(t<0||l<n||i.start<a)break;let f=4*(i.id>=o),u=i.start;for(i.next();i.pos>l;){if(i.size<0)if(-3==i.size)f+=4;else break i;else i.id>=o&&(f+=4);i.next()}r=u,s+=t,h+=f}return(e<0||s==t)&&(c.size=s,c.start=r,c.skip=h),c.size>4?c:void 0}(l.pos-i,g))){let t=new Uint16Array(A.size-A.skip),i=l.pos-A.size,n=t.length;for(;l.pos>i;)n=function t(e,i,s){let{id:n,start:r,end:h,size:f}=l;if(l.next(),f>=0&&n<o){let o=s;if(f>4){let n=l.pos-(f-4);for(;l.pos>n;)s=t(e,i,s)}i[--s]=o,i[--s]=h-e,i[--s]=r-e,i[--s]=n}else -3==f?a=n:-4==f&&(c=n);return s}(A.start,t,n);C=new nQ(t,b-A.start,s),P=A.start-e}else{let e=l.pos-y;l.next();let i=[],r=[],h=w>=o?w:-1,a=0,c=b;for(;l.pos>e;)h>=0&&l.id==h&&l.size>=0?(l.end<=c-n&&(f(i,r,v,a,l.end,c,h,k,x),a=i.length,c=l.end),l.next()):m>2500?function(t,e,i,r){let o=[],h=0,a=-1;for(;l.pos>e;){let{id:t,start:e,end:i,size:s}=l;if(s>4)l.next();else if(a>-1&&e<a)break;else a<0&&(a=i-n),o.push(t,e,i),h++,l.next()}if(h){let e=new Uint16Array(4*h),n=o[o.length-2];for(let t=o.length-3,i=0;t>=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-n,e[i++]=o[t+2]-n,e[i++]=i;i.push(new nQ(e,o[2]-n,s)),r.push(n-t)}}(v,e,i,r):t(v,e,i,r,h,m+1);if(h>=0&&a>0&&a<i.length&&f(i,r,v,a,v,c,h,k,x),i.reverse(),r.reverse(),h>-1&&a>0){let t=function(t,e){return(i,s,n)=>{let r=0,o=i.length-1,l,h;if(o>=0&&(l=i[o])instanceof nK){if(!o&&l.type==t&&l.length==n)return l;(h=l.prop(nq.lookAhead))&&(r=s[o]+l.length+h)}return u(t,i,s,n,r,e)}}(S,x);C=ri(S,i,r,0,i.length,0,b-v,t,t)}else C=u(S,i,r,b-v,k-b,x)}d.push(C),p.push(P)}(t.start||0,t.bufferStart||0,d,p,-1,0);let g=null!=(e=t.length)?e:d.length?p[0]+d[0].length:0;return new nK(h[t.topID],d.reverse(),p.reverse(),g)}(t)}}nK.empty=new nK(nU.none,[],[],0);class nG{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new nG(this.buffer,this.index)}}class nQ{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return nU.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],s=this.set.types[e],n=s.name;if(/\W/.test(n)&&!s.isError&&(n=JSON.stringify(n)),i==(t+=4))return n;let r=[];for(;t<i;)r.push(this.childString(t)),t=this.buffer[t+3];return n+"("+r.join(",")+")"}findChild(t,e,i,s,n){let{buffer:r}=this,o=-1;for(let l=t;l!=e&&(!nJ(n,s,r[l+1],r[l+2])||(o=l,!(i>0)));l=r[l+3]);return o}slice(t,e,i){let s=this.buffer,n=new Uint16Array(e-t),r=0;for(let o=t,l=0;o<e;){n[l++]=s[o++],n[l++]=s[o++]-i;let e=n[l++]=s[o++]-i;n[l++]=s[o++]-t,r=Math.max(r,e)}return new nQ(n,r,this.set)}}function nJ(t,e,i,s){switch(t){case -2:return i<e;case -1:return s>=e&&i<e;case 0:return i<e&&s>e;case 1:return i<=e&&s>e;case 2:return s>e;case 4:return!0}}function nZ(t,e,i,s){for(var n;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!s&&t instanceof n1&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=s?0:k.IgnoreOverlays;if(s)for(let s=t,o=s.parent;o;o=(s=o).parent)s instanceof n1&&s.index<0&&(null==(n=o.enter(e,i,r))?void 0:n.from)!=s.from&&(t=o);for(;;){let s=t.enter(e,i,r);if(!s)return t;t=s}}class n0{cursor(t=0){return new n9(this,t)}getChild(t,e=null,i=null){let s=n2(this,t,e,i);return s.length?s[0]:null}getChildren(t,e=null,i=null){return n2(this,t,e,i)}resolve(t,e=0){return nZ(this,t,e,!1)}resolveInner(t,e=0){return nZ(this,t,e,!0)}matchContext(t){return n3(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class n1 extends n0{constructor(t,e,i,s){super(),this._tree=t,this.from=e,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,s,n=0){for(let r=this;;){for(let{children:o,positions:l}=r._tree,h=e>0?o.length:-1;t!=h;t+=e){let h=o[t],a=l[t]+r.from;if(nJ(s,i,a,a+h.length)){if(h instanceof nQ){if(n&k.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,e,i-a,s);if(o>-1)return new n5(new n4(r,h,t,a),null,o)}else if(n&k.IncludeAnonymous||!h.type.isAnonymous||n7(h)){let o;if(!(n&k.IgnoreMounts)&&(o=n_.get(h))&&!o.overlay)return new n1(o.tree,a,t,r);let l=new n1(h,a,t,r);return n&k.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?h.children.length-1:0,e,i,s)}}}if(n&k.IncludeAnonymous||!r.type.isAnonymous||(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,!(r=r._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let s;if(!(i&k.IgnoreOverlays)&&(s=n_.get(this._tree))&&s.overlay){let i=t-this.from;for(let{from:t,to:n}of s.overlay)if((e>0?t<=i:t<i)&&(e<0?n>=i:n>i))return new n1(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function n2(t,e,i,s){let n=t.cursor(),r=[];if(!n.firstChild())return r;if(null!=i){for(let t=!1;!t;)if(t=n.type.is(i),!n.nextSibling())return r}for(;;){if(null!=s&&n.type.is(s))return r;if(n.type.is(e)&&r.push(n.node),!n.nextSibling())return null==s?r:[]}}function n3(t,e,i=e.length-1){for(let s=t;i>=0;s=s.parent){if(!s)return!1;if(!s.type.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}class n4{constructor(t,e,i,s){this.parent=t,this.buffer=e,this.index=i,this.start=s}}class n5 extends n0{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.context.start,i);return n<0?null:new n5(this.context,this,n)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&k.ExcludeBuffers)return null;let{buffer:s}=this.context,n=s.findChild(this.index+4,s.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return n<0?null:new n5(this.context,this,n)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new n5(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new n5(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,s=this.index+4,n=i.buffer[this.index+3];if(n>s){let r=i.buffer[this.index+1];t.push(i.slice(s,n,r)),e.push(0)}return new nK(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function n8(t){if(!t.length)return null;let e=0,i=t[0];for(let s=1;s<t.length;s++){let n=t[s];(n.from>i.from||n.to<i.to)&&(i=n,e=s)}let s=i instanceof n1&&i.index<0?null:i.parent,n=t.slice();return s?n[e]=s:n.splice(e,1),new n6(n,i)}class n6{constructor(t,e){this.heads=t,this.node=e}get next(){return n8(this.heads)}}class n9{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof n1)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:s}=this.buffer;return this.type=e||s.set.types[s.buffer[t]],this.from=i+s.buffer[t+1],this.to=i+s.buffer[t+2],!0}yield(t){return!!t&&(t instanceof n1?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:s}=this.buffer,n=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.buffer.start,i);return!(n<0)&&(this.stack.push(this.index),this.yieldBuf(n))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&k.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&k.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&k.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:s}=this;if(s){if(t>0){if(this.index<s.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(s.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=s)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let s=e+t,n=t<0?-1:i._tree.children.length;s!=n;s+=t){let t=i._tree.children[s];if(this.mode&k.IncludeAnonymous||t instanceof nQ||!t.type.isAnonymous||n7(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)i:for(let s=this.index,n=this.stack.length;n>=0;){for(let r=t;r;r=r._parent)if(r.index==s){if(s==this.index)return r;e=r,i=n+1;break i}s=this.stack[--n]}for(let t=i;t<this.stack.length;t++)e=new n5(this.buffer,e,this.stack[t]);return this.bufferNode=new n5(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let s=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&e&&e(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(t){if(!this.buffer)return n3(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let s=t.length-1,n=this.stack.length-1;s>=0;n--){if(n<0)return n3(this._tree,t,s);let r=i[e.buffer[this.stack[n]]];if(!r.isAnonymous){if(t[s]&&t[s]!=r.name)return!1;s--}}return!0}}function n7(t){return t.children.some(t=>t instanceof nQ||!t.type.isAnonymous||n7(t))}let rt=new WeakMap;function re(t,e){if(!t.isAnonymous||e instanceof nQ||e.type!=t)return 1;let i=rt.get(e);if(null==i){for(let s of(i=1,e.children)){if(s.type!=t||!(s instanceof nK)){i=1;break}i+=re(t,s)}rt.set(e,i)}return i}function ri(t,e,i,s,n,r,o,l,h){let a=0;for(let i=s;i<n;i++)a+=re(t,e[i]);let c=Math.ceil(1.5*a/8),f=[],u=[];return!function e(i,s,n,o,l){for(let a=n;a<o;){let n=a,d=s[a],p=re(t,i[a]);for(a++;a<o;a++){let e=re(t,i[a]);if(p+e>=c)break;p+=e}if(a==n+1){if(p>c){let t=i[n];e(t.children,t.positions,0,t.children.length,s[n]+l);continue}f.push(i[n])}else{let e=s[a-1]+i[a-1].length-d;f.push(ri(t,i,s,n,a,d,e,null,h))}u.push(d+l-r)}}(e,i,s,n,0),(l||h)(f,u,o)}class rs{constructor(t,e,i,s,n=!1,r=!1){this.from=t,this.to=e,this.tree=i,this.offset=s,this.open=!!n|2*!!r}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let s=[new rs(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&s.push(i);return s}static applyChanges(t,e,i=128){if(!e.length)return t;let s=[],n=1,r=t.length?t[0]:null;for(let o=0,l=0,h=0;;o++){let a=o<e.length?e[o]:null,c=a?a.fromA:1e9;if(c-l>=i)for(;r&&r.from<c;){let e=r;if(l>=e.from||c<=e.to||h){let t=Math.max(e.from,l)-h,i=Math.min(e.to,c)-h;e=t>=i?null:new rs(t,i,e.tree,e.offset+h,o>0,!!a)}if(e&&s.push(e),r.to>c)break;r=n<t.length?t[n++]:null}if(!a)break;l=a.toA,h=a.toA-a.toB}return s}}class rn{startParse(t,e,i){return"string"==typeof t&&(t=new rr(t)),i=i?i.length?i.map(t=>new nF(t.from,t.to)):[new nF(0,0)]:[new nF(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let s=this.startParse(t,e,i);for(;;){let t=s.advance();if(t)return t}}}class rr{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new nq({perNode:!0});let ro=0;class rl{constructor(t,e,i,s){this.name=t,this.set=e,this.base=i,this.modified=s,this.id=ro++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){if(t instanceof rl&&(e=t),null==e?void 0:e.base)throw Error("Can not derive from a modified tag");let i=new rl("string"==typeof t?t:"?",[],null,[]);if(i.set.push(i),e)for(let t of e.set)i.set.push(t);return i}static defineModifier(t){let e=new ra(t);return t=>t.modified.indexOf(e)>-1?t:ra.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let rh=0;class ra{constructor(t){this.name=t,this.instances=[],this.id=rh++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(i=>{var s,n;return i.base==t&&(s=e,n=i.modified,s.length==n.length&&s.every((t,e)=>t==n[e]))});if(i)return i;let s=[],n=new rl(t.name,s,t,e);for(let t of e)t.instances.push(n);let r=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let s=0,n=e.length;s<n;s++)e.push(e[s].concat(t[i]));return e.sort((t,e)=>e.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of r)s.push(ra.get(e,t));return n}}function rc(t){let e=Object.create(null);for(let i in t){let s=t[i];for(let t of(Array.isArray(s)||(s=[s]),i.split(" ")))if(t){let i=[],n=2,r=t;for(let e=0;;){if("..."==r&&e>0&&e+3==t.length){n=1;break}let s=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!s)throw RangeError("Invalid path: "+t);if(i.push("*"==s[0]?"":'"'==s[0][0]?JSON.parse(s[0]):s[0]),(e+=s[0].length)==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){n=0;break}if("/"!=o)throw RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,l=i[o];if(!l)throw RangeError("Invalid path: "+t);let h=new ru(s,n,o>0?i.slice(0,o):null);e[l]=h.sort(e[l])}}return rf.add(e)}let rf=new nq;class ru{constructor(t,e,i,s){this.tags=t,this.mode=e,this.context=i,this.next=s}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function rd(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:s,all:n=null}=e||{};return{style:t=>{let e=n;for(let s of t)for(let t of s.set){let s=i[t.id];if(s){e=e?e+" "+s:s;break}}return e},scope:s}}ru.empty=new ru([],2,null);class rp{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,s,n){let{type:r,from:o,to:l}=t;if(o>=i||l<=e)return;r.isTop&&(n=this.highlighters.filter(t=>!t.scope||t.scope(r)));let h=s,a=function(t){let e=t.type.prop(rf);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||ru.empty,c=function(t,e){let i=null;for(let s of t){let t=s.style(e);t&&(i=i?i+" "+t:t)}return i}(n,a.tags);if(c&&(h&&(h+=" "),h+=c,1==a.mode&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(e,o),h),a.opaque)return;let f=t.tree&&t.tree.prop(nq.mounted);if(f&&f.overlay){let r=t.node.enter(f.overlay[0].from+o,1),a=this.highlighters.filter(t=>!t.scope||t.scope(f.tree.type)),c=t.firstChild();for(let u=0,d=o;;u++){let p=u<f.overlay.length?f.overlay[u]:null,g=p?p.from+o:l,m=Math.max(e,d),w=Math.min(i,g);if(m<w&&c)for(;t.from<w&&(this.highlightRange(t,m,w,s,n),this.startSpan(Math.min(w,t.to),h),!(t.to>=g)&&t.nextSibling()););if(!p||g>i)break;(d=p.to+o)>e&&(this.highlightRange(r.cursor(),Math.max(e,p.from+o),Math.min(i,d),"",a),this.startSpan(Math.min(i,d),h))}c&&t.parent()}else if(t.firstChild()){f&&(s="");do{if(t.to<=e)continue;if(t.from>=i)break;this.highlightRange(t,e,i,s,n),this.startSpan(Math.min(i,t.to),h)}while(t.nextSibling())t.parent()}}}let rg=rl.define,rm=rg(),rw=rg(),rv=rg(rw),rb=rg(rw),ry=rg(),rk=rg(ry),rx=rg(ry),rS=rg(),rC=rg(rS),rA=rg(),rP=rg(),rO=rg(),rM=rg(rO),rT=rg(),rD={comment:rm,lineComment:rg(rm),blockComment:rg(rm),docComment:rg(rm),name:rw,variableName:rg(rw),typeName:rv,tagName:rg(rv),propertyName:rb,attributeName:rg(rb),className:rg(rw),labelName:rg(rw),namespace:rg(rw),macroName:rg(rw),literal:ry,string:rk,docString:rg(rk),character:rg(rk),attributeValue:rg(rk),number:rx,integer:rg(rx),float:rg(rx),bool:rg(ry),regexp:rg(ry),escape:rg(ry),color:rg(ry),url:rg(ry),keyword:rA,self:rg(rA),null:rg(rA),atom:rg(rA),unit:rg(rA),modifier:rg(rA),operatorKeyword:rg(rA),controlKeyword:rg(rA),definitionKeyword:rg(rA),moduleKeyword:rg(rA),operator:rP,derefOperator:rg(rP),arithmeticOperator:rg(rP),logicOperator:rg(rP),bitwiseOperator:rg(rP),compareOperator:rg(rP),updateOperator:rg(rP),definitionOperator:rg(rP),typeOperator:rg(rP),controlOperator:rg(rP),punctuation:rO,separator:rg(rO),bracket:rM,angleBracket:rg(rM),squareBracket:rg(rM),paren:rg(rM),brace:rg(rM),content:rS,heading:rC,heading1:rg(rC),heading2:rg(rC),heading3:rg(rC),heading4:rg(rC),heading5:rg(rC),heading6:rg(rC),contentSeparator:rg(rS),list:rg(rS),quote:rg(rS),emphasis:rg(rS),strong:rg(rS),link:rg(rS),monospace:rg(rS),strikethrough:rg(rS),inserted:rg(),deleted:rg(),changed:rg(),invalid:rg(),meta:rT,documentMeta:rg(rT),annotation:rg(rT),processingInstruction:rg(rT),definition:rl.defineModifier("definition"),constant:rl.defineModifier("constant"),function:rl.defineModifier("function"),standard:rl.defineModifier("standard"),local:rl.defineModifier("local"),special:rl.defineModifier("special")};for(let t in rD){let e=rD[t];e instanceof rl&&(e.name=t)}rd([{tag:rD.link,class:"tok-link"},{tag:rD.heading,class:"tok-heading"},{tag:rD.emphasis,class:"tok-emphasis"},{tag:rD.strong,class:"tok-strong"},{tag:rD.keyword,class:"tok-keyword"},{tag:rD.atom,class:"tok-atom"},{tag:rD.bool,class:"tok-bool"},{tag:rD.url,class:"tok-url"},{tag:rD.labelName,class:"tok-labelName"},{tag:rD.inserted,class:"tok-inserted"},{tag:rD.deleted,class:"tok-deleted"},{tag:rD.literal,class:"tok-literal"},{tag:rD.string,class:"tok-string"},{tag:rD.number,class:"tok-number"},{tag:[rD.regexp,rD.escape,rD.special(rD.string)],class:"tok-string2"},{tag:rD.variableName,class:"tok-variableName"},{tag:rD.local(rD.variableName),class:"tok-variableName tok-local"},{tag:rD.definition(rD.variableName),class:"tok-variableName tok-definition"},{tag:rD.special(rD.variableName),class:"tok-variableName2"},{tag:rD.definition(rD.propertyName),class:"tok-propertyName tok-definition"},{tag:rD.typeName,class:"tok-typeName"},{tag:rD.namespace,class:"tok-namespace"},{tag:rD.className,class:"tok-className"},{tag:rD.macroName,class:"tok-macroName"},{tag:rD.propertyName,class:"tok-propertyName"},{tag:rD.operator,class:"tok-operator"},{tag:rD.comment,class:"tok-comment"},{tag:rD.meta,class:"tok-meta"},{tag:rD.invalid,class:"tok-invalid"},{tag:rD.punctuation,class:"tok-punctuation"}]);let rE=new nq,rB=new nq;class rR{constructor(t,e,i=[],s=""){this.data=t,this.name=s,tm.prototype.hasOwnProperty("tree")||Object.defineProperty(tm.prototype,"tree",{get(){return rI(this)}}),this.parser=e,this.extension=[rU.of(this),tm.languageData.of((t,e,i)=>{let s=rN(t,e,i),n=s.type.prop(rE);if(!n)return[];let r=t.facet(n),o=s.type.prop(rB);if(o){let n=s.resolve(e-s.from,i);for(let e of o)if(e.test(n,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r})].concat(i)}isActiveAt(t,e,i=-1){return rN(t,e,i).type.prop(rE)==this.data}findRegions(t){let e=t.facet(rU);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],s=(t,e)=>{if(t.prop(rE)==this.data)return void i.push({from:e,to:e+t.length});let n=t.prop(nq.mounted);if(n){if(n.tree.prop(rE)==this.data){if(n.overlay)for(let t of n.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}else if(n.overlay){let t=i.length;if(s(n.tree,n.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let n=t.children[i];n instanceof nK&&s(n,t.positions[i]+e)}};return s(rI(t),0),i}get allowsNesting(){return!0}}function rN(t,e,i){let s=t.facet(rU),n=rI(t).topNode;if(!s||s.allowsNesting)for(let t=n;t;t=t.enter(e,i,k.ExcludeBuffers))t.type.isTop&&(n=t);return n}rR.setState=th.define();class rL extends rR{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){var e;let i=(e=t.languageData,I.define({combine:e?t=>t.concat(e):void 0}));return new rL(i,t.parser.configure({props:[rE.add(t=>t.isTop?i:void 0)]}),t.name)}configure(t,e){return new rL(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function rI(t){let e=t.field(rR.state,!1);return e?e.tree:nK.empty}class rV{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let rH=null;class rW{constructor(t,e,i=[],s,n,r,o,l){this.parser=t,this.state=e,this.fragments=i,this.tree=s,this.treeLen=n,this.viewport=r,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new rW(t,e,[],nK.empty,0,i,[],null)}startParse(){return this.parser.startParse(new rV(this.state.doc),this.fragments)}work(t,e){return(null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=nK.empty&&this.isDone(null!=e?e:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s){if(this.fragments=this.withoutTempSkipped(rs.addTree(s,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(i=this.parse.stoppedAt)?i:this.state.doc.length,this.tree=s,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(rs.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=rH;rH=this;try{return t()}finally{rH=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=rz(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:n,viewport:r,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,i,s,n)=>e.push({fromA:t,toA:i,fromB:s,toB:n})),i=rs.applyChanges(i,e),s=nK.empty,n=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length)for(let e of(o=[],this.skipped)){let i=t.mapPos(e.from,1),s=t.mapPos(e.to,-1);i<s&&o.push({from:i,to:s})}}return new rW(this.parser,e,i,s,n,r,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:s}=this.skipped[e];i<t.to&&s>t.from&&(this.fragments=rz(this.fragments,i,s),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends rn{createParse(e,i,s){let n=s[0].from,r=s[s.length-1].to;return{parsedPos:n,advance(){let e=rH;if(e){for(let t of s)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=r,new nK(nU.none,[],[],r-n)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return rH}}function rz(t,e,i){return rs.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class rF{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new rF(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=rW.create(t.facet(rU).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new rF(i)}}rR.state=q.define({create:rF.init,update(t,e){for(let t of e.effects)if(t.is(rR.setState))return t.value;return e.startState.facet(rU)!=e.state.facet(rU)?rF.init(e.state):t.apply(e)}});let rq=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(rq=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});let r_="undefined"!=typeof navigator&&(null==(x=navigator.scheduling)?void 0:x.isInputPending)?()=>navigator.scheduling.isInputPending():null,rj=iw.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(rR.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(rR.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=rq(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,n=i.field(rR.state);if(n.tree==n.context.tree&&n.context.isDone(s+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!r_?Math.max(25,t.timeRemaining()-5):1e9),o=n.context.treeLen<s&&i.doc.length>s+1e3,l=n.context.work(()=>r_&&r_()||Date.now()>r,s+1e5*!o);this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(n.context.takeTree(),this.view.dispatch({effects:rR.setState.of(new rF(n.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(n.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>id(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),rU=I.define({combine:t=>t.length?t[0]:null,enables:t=>[rR.state,rj,sK.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]}),rY=I.define(),rX=I.define({combine:t=>{if(!t.length)return"  ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function r$(t){let e=t.facet(rX);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function rK(t,e){let i="",s=t.tabSize,n=t.facet(rX)[0];if("	"==n){for(;e>=s;)i+="	",e-=s;n=" "}for(let t=0;t<e;t++)i+=n;return i}function rG(t,e){for(let i of(t instanceof tm&&(t=new rQ(t)),t.state.facet(rY))){let s=i(t,e);if(void 0!==s)return s}let i=rI(t.state);return i.length>=e?function(t,e,i){let s=e.resolveStack(i),n=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(n!=s.node){let t=[];for(let e=n;e&&!(e.from<s.node.from||e.to>s.node.to||e.from==s.node.from&&e.type==s.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)s={node:t[e],next:s}}return rZ(s,t,i)}(t,i,e):null}class rQ{constructor(t,e={}){this.state=t,this.options=e,this.unit=r$(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:n}=this.options;if(null!=s&&s>=i.from&&s<=i.to)if(n&&s==t)return{text:"",from:t};else if(e<0?s<t:s<=t)return{text:i.text.slice(s-i.from),from:s};else return{text:i.text.slice(0,s-i.from),from:i.from};return i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(t,e);return i.slice(t-s,Math.min(i.length,t+100-s))}column(t,e=1){let{text:i,from:s}=this.lineAt(t,e),n=this.countColumn(i,t-s),r=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return r>-1&&(n+=r-this.countColumn(i,i.search(/\S|$/))),n}countColumn(t,e=t.length){return tN(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:s}=this.lineAt(t,e),n=this.options.overrideIndentation;if(n){let t=n(s);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let rJ=new nq;function rZ(t,e,i){for(let s=t;s;s=s.next){let t=function(t){let e=t.type.prop(rJ);if(e)return e;let i=t.firstChild,s;if(i&&(s=i.type.prop(nq.closedBy))){let e=t.lastChild,i=e&&s.indexOf(e.name)>-1;return t=>(function(t,e,i,s,n){let r=t.textAfter,o=r.match(/^\s*/)[0].length,l=s&&r.slice(o,o+s.length)==s||n==t.pos+o,h=e?function(t){let e=t.node,i=e.childAfter(e.from),s=e.lastChild;if(!i)return null;let n=t.options.simulateBreak,r=t.state.doc.lineAt(i.from),o=null==n||n<=r.from?r.to:Math.min(r.to,n);for(let t=i.to;;){let n=e.childAfter(t);if(!n||n==s)return null;if(!n.type.isSkipped){if(n.from>=o)return null;let t=/^ */.exec(r.text.slice(i.to-r.from))[0].length;return{from:i.from,to:i.to+t}}t=n.to}}(t):null;return h?l?t.column(h.from):t.column(h.to):t.baseIndent+(l?0:+t.unit)})(t,!0,1,void 0,i&&!(t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak)?e.from:void 0)}return null==t.parent?r0:null}(s.node);if(t)return t(r1.create(e,i,s))}return 0}function r0(){return 0}class r1 extends rQ{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new r1(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(function(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return rZ(this.context.next,this.base,this.pos)}}let r2=I.define(),r3=new nq;function r4(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}function r5(t,e,i){for(let s of t.facet(r2)){let n=s(t,e,i);if(n)return n}return function(t,e,i){let s=rI(t);if(s.length<i)return null;let n=s.resolveStack(i,1),r=null;for(let o=n;o;o=o.next){let n=o.node;if(n.to<=i||n.from>i)continue;if(r&&n.from<e)break;let l=n.type.prop(r3);if(l&&(n.to<s.length-50||s.length==t.doc.length||!function(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}(n))){let s=l(n,t);s&&s.from<=i&&s.from>=e&&s.to>i&&(r=s)}}return r}(t,e,i)}function r8(t,e){let i=e.mapPos(t.from,1),s=e.mapPos(t.to,-1);return i>=s?void 0:{from:i,to:s}}let r6=th.define({map:r8}),r9=th.define({map:r8});function r7(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some(t=>t.from<=i&&t.to>=i)||e.push(t.lineBlockAt(i));return e}let ot=q.define({create:()=>eN.none,update(t,e){for(let i of(e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,i)=>t=oe(t,e,i)),t=t.map(e.changes),e.effects))if(i.is(r6)&&!function(t,e,i){let s=!1;return t.between(e,e,(t,n)=>{t==e&&n==i&&(s=!0)}),s}(t,i.value.from,i.value.to)){let{preparePlaceholder:s}=e.state.facet(ol),n=s?eN.replace({widget:new of(s(e.state,i.value))}):oc;t=t.update({add:[n.range(i.value.from,i.value.to)]})}else i.is(r9)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));return e.selection&&(t=oe(t,e.selection.main.head)),t},provide:t=>sK.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,(t,e)=>{i.push(t,e)}),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let s=t[i++],n=t[i++];if("number"!=typeof s||"number"!=typeof n)throw RangeError("Invalid JSON for fold state");e.push(oc.range(s,n))}return eN.set(e,!0)}});function oe(t,e,i=e){let s=!1;return t.between(e,i,(t,n)=>{t<i&&n>e&&(s=!0)}),s?t.update({filterFrom:e,filterTo:i,filter:(t,s)=>t>=i||s<=e}):t}function oi(t,e,i){var s;let n=null;return null==(s=t.field(ot,!1))||s.between(e,i,(t,e)=>{(!n||n.from>t)&&(n={from:t,to:e})}),n}function os(t,e){return t.field(ot,!1)?e:e.concat(th.appendConfig.of(oh()))}function on(t,e,i=!0){let s=t.state.doc.lineAt(e.from).number,n=t.state.doc.lineAt(e.to).number;return sK.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${s} ${t.state.phrase("to")} ${n}.`)}let or=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of r7(t)){let i=r5(t.state,e.from,e.to);if(i)return t.dispatch({effects:os(t.state,[r6.of(i),on(t,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(ot,!1))return!1;let e=[];for(let i of r7(t)){let s=oi(t.state,i.from,i.to);s&&e.push(r9.of(s),on(t,s,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,i=[];for(let s=0;s<e.doc.length;){let n=t.lineBlockAt(s),r=r5(e,n.from,n.to);r&&i.push(r6.of(r)),s=(r?t.lineBlockAt(r.to):n).to+1}return i.length&&t.dispatch({effects:os(t.state,i)}),!!i.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(ot,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,(t,e)=>{i.push(r9.of({from:t,to:e}))}),t.dispatch({effects:i}),!0}}],oo={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},ol=I.define({combine:t=>tw(t,oo)});function oh(t){let e=[ot,op];return t&&e.push(ol.of(t)),e}function oa(t,e){let{state:i}=t,s=i.facet(ol),n=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),s=oi(t.state,i.from,i.to);s&&t.dispatch({effects:r9.of(s)}),e.preventDefault()};if(s.placeholderDOM)return s.placeholderDOM(t,n,e);let r=document.createElement("span");return r.textContent=s.placeholderText,r.setAttribute("aria-label",i.phrase("folded code")),r.title=i.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=n,r}let oc=eN.replace({widget:new class extends eB{toDOM(t){return oa(t,null)}}});class of extends eB{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return oa(t,this.value)}}let ou={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class od extends nb{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}let op=sK.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class og{constructor(t,e){let i;function s(t){let e=tH.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;let n="string"==typeof e.all?e.all:e.all?s(e.all):void 0,r=e.scope;this.scope=r instanceof rR?t=>t.prop(rE)==r.data:r?t=>t==r:void 0,this.style=rd(t.map(t=>({tag:t.tag,class:t.class||s(Object.assign({},t,{tag:null}))})),{all:n}).style,this.module=i?new tH(i):null,this.themeType=e.themeType}static define(t,e){return new og(t,e||{})}}let om=I.define(),ow=I.define({combine:t=>t.length?[t[0]]:null});function ov(t){let e=t.facet(om);return e.length?e:t.facet(ow)}let ob=U.high(iw.fromClass(class{constructor(t){this.markCache=Object.create(null),this.tree=rI(t.state),this.decorations=this.buildDeco(t,ov(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=rI(t.state),i=ov(t.state),s=i!=ov(t.startState),{viewport:n}=t.view,r=t.changes.mapPos(this.decoratedTo,1);e.length<n.to&&!s&&e.type==this.tree.type&&r>=n.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=r):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=n.to)}buildDeco(t,e){if(!e||!this.tree.length)return eN.none;let i=new tS;for(let{from:s,to:n}of t.visibleRanges)!function(t,e,i,s=0,n=t.length){let r=new rp(s,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),s,n,"",r.highlighters),r.flush(n)}(this.tree,e,(t,e,s)=>{i.add(t,e,this.markCache[s]||(this.markCache[s]=eN.mark({class:s})))},s,n);return i.finish()}},{decorations:t=>t.decorations}));rD.meta,rD.link,rD.heading,rD.emphasis,rD.strong,rD.strikethrough,rD.keyword,rD.atom,rD.bool,rD.url,rD.contentSeparator,rD.labelName,rD.literal,rD.inserted,rD.string,rD.deleted,rD.regexp,rD.escape,rD.special(rD.string),rD.definition(rD.variableName),rD.local(rD.variableName),rD.typeName,rD.namespace,rD.className,rD.special(rD.variableName),rD.macroName,rD.definition(rD.propertyName),rD.comment,rD.invalid,sK.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}});let oy="()[]{}",ok=I.define({combine:t=>tw(t,{afterCursor:!0,brackets:oy,maxScanDistance:1e4,renderMatch:oC})}),ox=eN.mark({class:"cm-matchingBracket"}),oS=eN.mark({class:"cm-nonmatchingBracket"});function oC(t){let e=[],i=t.matched?ox:oS;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}q.define({create:()=>eN.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],s=e.state.facet(ok);for(let t of e.state.selection.ranges){if(!t.empty)continue;let n=oM(e.state,t.head,-1,s)||t.head>0&&oM(e.state,t.head-1,1,s)||s.afterCursor&&(oM(e.state,t.head,1,s)||t.head<e.state.doc.length&&oM(e.state,t.head+1,-1,s));n&&(i=i.concat(s.renderMatch(n,e.state)))}return eN.set(i,!0)},provide:t=>sK.decorations.from(t)});let oA=new nq;function oP(t,e,i){let s=t.prop(e<0?nq.openedBy:nq.closedBy);if(s)return s;if(1==t.name.length){let s=i.indexOf(t.name);if(s>-1&&s%2==+(e<0))return[i[s+e]]}return null}function oO(t){let e=t.type.prop(oA);return e?e(t.node):t}function oM(t,e,i,s={}){let n=s.maxScanDistance||1e4,r=s.brackets||oy,o=rI(t),l=o.resolveInner(e,i);for(let t=l;t;t=t.parent){let s=oP(t.type,i,r);if(s&&t.from<t.to){let n=oO(t);if(n&&(i>0?e>=n.from&&e<n.to:e>n.from&&e<=n.to))return function(t,e,i,s,n,r,o){let l=s.parent,h={from:n.from,to:n.to},a=0,c=null==l?void 0:l.cursor();if(c&&(i<0?c.childBefore(s.from):c.childAfter(s.to)))do if(i<0?c.to<=s.from:c.from>=s.to){if(0==a&&r.indexOf(c.type.name)>-1&&c.from<c.to){let t=oO(c);return{start:h,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}else if(oP(c.type,i,o))a++;else if(oP(c.type,-i,o)){if(0==a){let t=oO(c);return{start:h,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}a--}}while(i<0?c.prevSibling():c.nextSibling())return{start:h,matched:!1}}(0,0,i,t,n,s,r)}}return function(t,e,i,s,n,r,o){let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),h=o.indexOf(l);if(h<0||h%2==0!=i>0)return null;let a={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),f=0;for(let t=0;!c.next().done&&t<=r;){let r=c.value;i<0&&(t+=r.length);let l=e+t*i;for(let t=i>0?0:r.length-1,e=i>0?r.length:-1;t!=e;t+=i){let e=o.indexOf(r[t]);if(!(e<0)&&s.resolveInner(l+t,1).type==n)if(e%2==0==i>0)f++;else{if(1==f)return{start:a,end:{from:l+t,to:l+t+1},matched:e>>1==h>>1};f--}}i>0&&(t+=r.length)}return c.done?{start:a,matched:!1}:null}(t,e,i,o,l.type,n,r)}let oT=Object.create(null),oD=[nU.none],oE=[],oB=Object.create(null),oR=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])oR[t]=function(t,e){let i=[];for(let s of e.split(" ")){let e=[];for(let i of s.split(".")){let s=t[i]||rD[i];s?"function"==typeof s?e.length?e=e.map(s):oN(i,`Modifier ${i} used at start of tag`):e.length?oN(i,`Tag ${i} used as modifier`):e=Array.isArray(s)?s:[s]:oN(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let s=e.replace(/ /g,"_"),n=s+" "+i.map(t=>t.id),r=oB[n];if(r)return r.id;let o=oB[n]=nU.define({id:oD.length,name:s,props:[rc({[s]:i})]});return oD.push(o),o.id}(oT,e);function oN(t,e){oE.indexOf(t)>-1||(oE.push(t),console.warn(e))}function oL(t){return t.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(t)}function oI(t){for(let e=t.iter();!e.next().done;)if(oL(e.value))return!0;return!1}let oV=I.define({combine:t=>t.some(t=>t)});function oH(t,e,i){let s=new tS,n=t.visibleRanges;for(let{from:r,to:o}of(i||(n=function(t,e){let i=e.iter(),s=0,n=[],r=null;for(let{from:e,to:o}of t)if(!r||!(r.to>e)||!((e=r.to)>=o))for(s+i.value.length<e&&(i.next(e-(s+i.value.length)),s=e);;){let t=s,e=s+i.value.length;if(!i.lineBreak&&oL(i.value)&&(r&&r.to>t-10?r.to=Math.min(o,e):n.push(r={from:t,to:Math.min(o,e)})),e>=o)break;s=e,i.next()}return n}(n,t.state.doc)),n))e.iterate({enter:t=>{let e=t.type.prop(nq.isolate);e&&s.add(t.from,t.to,oW[e])},from:r,to:o});return s.finish()}iw.fromClass(class{constructor(t){this.always=t.state.facet(oV)||t.textDirection!=eY.LTR||t.state.facet(sK.perLineTextDirection),this.hasRTL=!this.always&&oI(t.state.doc),this.tree=rI(t.state),this.decorations=this.always||this.hasRTL?oH(t,this.tree,this.always):eN.none}update(t){var e;let i,s=t.state.facet(oV)||t.view.textDirection!=eY.LTR||t.state.facet(sK.perLineTextDirection);if(s||this.hasRTL||(e=t.changes,i=!1,e.iterChanges((t,e,s,n,r)=>{!i&&oI(r)&&(i=!0)}),!i)||(this.hasRTL=!0),!s&&!this.hasRTL)return;let n=rI(t.state);(s!=this.always||n!=this.tree||t.docChanged||t.viewportChanged)&&(this.tree=n,this.always=s,this.decorations=oH(t.view,n,s))}},{provide:t=>{function e(e){var i,s;return null!=(s=null==(i=e.plugin(t))?void 0:i.decorations)?s:eN.none}return[sK.outerDecorations.of(e),U.lowest(sK.bidiIsolatedRanges.of(e))]}});let oW={rtl:eN.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:eY.RTL}),ltr:eN.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:eY.LTR}),auto:eN.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};function oz(t,e){return({state:i,dispatch:s})=>{if(i.readOnly)return!1;let n=t(e,i);return!!n&&(s(i.update(n)),!0)}}let oF=oz(function(t,e,i=e.selection.ranges){let s=[],n=-1;for(let{from:t,to:r}of i){let i=s.length,o=1e9,l=oj(e,t).line;if(l){for(let i=t;i<=r;){let h=e.doc.lineAt(i);if(h.from>n&&(t==r||r>h.from)){n=h.from;let t=/^\s*/.exec(h.text)[0].length,e=t==h.length,i=h.text.slice(t,t+l.length)==l?t:-1;t<h.text.length&&t<o&&(o=t),s.push({line:h,comment:i,token:l,indent:t,empty:e,single:!1})}i=h.to+1}if(o<1e9)for(let t=i;t<s.length;t++)s[t].indent<s[t].line.text.length&&(s[t].indent=o);s.length==i+1&&(s[i].single=!0)}}if(2!=t&&s.some(t=>t.comment<0&&(!t.empty||t.single))){let t=[];for(let{line:e,token:i,indent:n,empty:r,single:o}of s)(o||!r)&&t.push({from:e.from+n,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&s.some(t=>t.comment>=0)){let t=[];for(let{line:e,comment:i,token:n}of s)if(i>=0){let s=e.from+i,r=s+n.length;" "==e.text[r-e.from]&&r++,t.push({from:s,to:r})}return{changes:t}}return null},0),oq=oz(oU,0),o_=oz((t,e)=>oU(t,e,function(t){let e=[];for(let i of t.selection.ranges){let s=t.doc.lineAt(i.from),n=i.to<=s.to?s:t.doc.lineAt(i.to);n.from>s.from&&n.from==i.to&&(n=i.to==s.to+1?s:t.doc.lineAt(i.to-1));let r=e.length-1;r>=0&&e[r].to>s.from?e[r].to=n.to:e.push({from:s.from+/^\s*/.exec(s.text)[0].length,to:n.to})}return e}(e)),0);function oj(t,e){let i=t.languageDataAt("commentTokens",e,1);return i.length?i[0]:{}}function oU(t,e,i=e.selection.ranges){let s=i.map(t=>oj(e,t.from).block);if(!s.every(t=>t))return null;let n=i.map((t,i)=>(function(t,{open:e,close:i},s,n){let r,o,l=t.sliceDoc(s-50,s),h=t.sliceDoc(n,n+50),a=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(h)[0].length,f=l.length-a;if(l.slice(f-e.length,f)==e&&h.slice(c,c+i.length)==i)return{open:{pos:s-a,margin:a&&1},close:{pos:n+c,margin:c&&1}};n-s<=100?r=o=t.sliceDoc(s,n):(r=t.sliceDoc(s,s+50),o=t.sliceDoc(n-50,n));let u=/^\s*/.exec(r)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-i.length;return r.slice(u,u+e.length)==e&&o.slice(p,p+i.length)==i?{open:{pos:s+u+e.length,margin:+!!/\s/.test(r.charAt(u+e.length))},close:{pos:n-d-i.length,margin:+!!/\s/.test(o.charAt(p-1))}}:null})(e,s[i],t.from,t.to));if(2!=t&&!n.every(t=>t))return{changes:e.changes(i.map((t,e)=>n[e]?[]:[{from:t.from,insert:s[e].open+" "},{from:t.to,insert:" "+s[e].close}]))};if(1!=t&&n.some(t=>t)){let t=[];for(let e=0,i;e<n.length;e++)if(i=n[e]){let n=s[e],{open:r,close:o}=i;t.push({from:r.pos-n.open.length,to:r.pos+r.margin},{from:o.pos-o.margin,to:o.pos+n.close.length})}return{changes:t}}return null}let oY=tr.define(),oX=tr.define(),o$=I.define(),oK=I.define({combine:t=>tw(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,s)=>t(i,s)||e(i,s)})}),oG=q.define({create:()=>o4.empty,update(t,e){let i=e.state.facet(oK),s=e.annotation(oY);if(s){let n=oQ.fromTransaction(e,s.selection),r=s.side,o=0==r?t.undone:t.done;return o=n?oJ(o,o.length,i.minDepth,n):o1(o,e.startState.selection),new o4(0==r?s.rest:o,0==r?o:s.rest)}let n=e.annotation(oX);if(("full"==n||"before"==n)&&(t=t.isolate()),!1===e.annotation(ta.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let r=oQ.fromTransaction(e),o=e.annotation(ta.time),l=e.annotation(ta.userEvent);return r?t=t.addChanges(r,o,l,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,i.newGroupDelay)),("full"==n||"after"==n)&&(t=t.isolate()),t},toJSON:t=>({done:t.done.map(t=>t.toJSON()),undone:t.undone.map(t=>t.toJSON())}),fromJSON:t=>new o4(t.done.map(oQ.fromJSON),t.undone.map(oQ.fromJSON))});class oQ{constructor(t,e,i,s,n){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=s,this.selectionsAfter=n}setSelAfter(t){return new oQ(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null==(t=this.changes)?void 0:t.toJSON(),mapped:null==(e=this.mapped)?void 0:e.toJSON(),startSelection:null==(i=this.startSelection)?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(t=>t.toJSON())}}static fromJSON(t){return new oQ(t.changes&&A.fromJSON(t.changes),[],t.mapped&&C.fromJSON(t.mapped),t.startSelection&&R.fromJSON(t.startSelection),t.selectionsAfter.map(R.fromJSON))}static fromTransaction(t,e){let i=o0;for(let e of t.startState.facet(o$)){let s=e(t);s.length&&(i=i.concat(s))}return!i.length&&t.changes.empty?null:new oQ(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,o0)}static selection(t){return new oQ(void 0,o0,void 0,void 0,t)}}function oJ(t,e,i,s){let n=t.slice(e+1>i+20?e-i-1:0,e);return n.push(s),n}function oZ(t,e){return t.length?e.length?t.concat(e):t:e}let o0=[];function o1(t,e){if(!t.length)return[oQ.selection([e])];{let i=t[t.length-1],s=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-200));return s.length&&s[s.length-1].eq(e)?t:(s.push(e),oJ(t,t.length-1,1e9,i.setSelAfter(s)))}}function o2(t,e){if(!t.length)return t;let i=t.length,s=o0;for(;i;){let n=function(t,e,i){let s=oZ(t.selectionsAfter.length?t.selectionsAfter.map(t=>t.map(e)):o0,i);if(!t.changes)return oQ.selection(s);let n=t.changes.map(e),r=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(r):r;return new oQ(n,th.mapEffects(t.effects,e),o,t.startSelection.map(r),s)}(t[i-1],e,s);if(n.changes&&!n.changes.empty||n.effects.length){let e=t.slice(0,i);return e[i-1]=n,e}e=n.mapped,i--,s=n.selectionsAfter}return s.length?[oQ.selection(s)]:o0}let o3=/^(input\.type|delete)($|\.)/;class o4{constructor(t,e,i=0,s){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new o4(this.done,this.undone):this}addChanges(t,e,i,s,n){var r,o;let l,h,a=this.done,c=a[a.length-1];return new o4(a=c&&c.changes&&!c.changes.empty&&t.changes&&(!i||o3.test(i))&&(!c.selectionsAfter.length&&e-this.prevTime<s.newGroupDelay&&s.joinToEvent(n,(r=c.changes,o=t.changes,l=[],h=!1,r.iterChangedRanges((t,e)=>l.push(t,e)),o.iterChangedRanges((t,e,i,s)=>{for(let t=0;t<l.length;){let e=l[t++],n=l[t++];s>=e&&i<=n&&(h=!0)}}),h))||"input.type.compose"==i)?oJ(a,a.length-1,s.minDepth,new oQ(t.changes.compose(c.changes),oZ(th.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,o0)):oJ(a,a.length,s.minDepth,t),o0,e,i)}addSelection(t,e,i,s){var n;let r=this.done.length?this.done[this.done.length-1].selectionsAfter:o0;return r.length>0&&e-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(n=r[r.length-1],n.ranges.length==t.ranges.length&&0===n.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length)?this:new o4(o1(this.done,t),this.undone,e,i)}addMapping(t){return new o4(o2(this.done,t),o2(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let s=0==t?this.done:this.undone;if(0==s.length)return null;let n=s[s.length-1],r=n.selectionsAfter[0]||e.selection;if(i&&n.selectionsAfter.length){let i,o;return e.update({selection:n.selectionsAfter[n.selectionsAfter.length-1],annotations:oY.of({side:t,rest:(i=s[s.length-1],(o=s.slice())[s.length-1]=i.setSelAfter(i.selectionsAfter.slice(0,i.selectionsAfter.length-1)),o),selection:r}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0})}{if(!n.changes)return null;let i=1==s.length?o0:s.slice(0,s.length-1);return n.mapped&&(i=o2(i,n.mapped)),e.update({changes:n.changes,selection:n.startSelection,effects:n.effects,annotations:oY.of({side:t,rest:i,selection:r}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}}}function o5(t,e){return R.create(t.ranges.map(e),t.mainIndex)}function o8(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function o6({state:t,dispatch:e},i){let s=o5(t.selection,i);return!s.eq(t.selection,!0)&&(e(o8(t,s)),!0)}function o9(t,e){return R.cursor(e?t.to:t.from)}function o7(t,e){return o6(t,i=>i.empty?t.moveByChar(i,e):o9(i,e))}function lt(t){return t.textDirectionAt(t.state.selection.main.head)==eY.LTR}o4.empty=new o4(o0,o0);let le=t=>o7(t,!lt(t)),li=t=>o7(t,lt(t));function ls(t,e){return o6(t,i=>i.empty?t.moveByGroup(i,e):o9(i,e))}function ln(t,e,i){let s,n,r=rI(t).resolveInner(e.head),o=i?nq.closedBy:nq.openedBy;for(let s=e.head;;){let e=i?r.childAfter(s):r.childBefore(s);if(!e)break;!function(t,e,i){if(e.type.prop(i))return!0;let s=e.to-e.from;return s&&(s>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}(t,e,o)?s=i?e.to:e.from:r=e}return n=r.type.prop(o)&&(s=i?oM(t,r.from,1):oM(t,r.to,-1))&&s.matched?i?s.end.to:s.end.from:i?r.to:r.from,R.cursor(n,i?-1:1)}function lr(t,e){return o6(t,i=>{if(!i.empty)return o9(i,e);let s=t.moveVertically(i,e);return s.head!=i.head?s:t.moveToLineBoundary(i,e)})}"undefined"!=typeof Intl&&Intl.Segmenter;let lo=t=>lr(t,!1),ll=t=>lr(t,!0);function lh(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,i=0,s=0,n;if(e){for(let e of t.state.facet(sK.scrollMargins)){let n=e(t);(null==n?void 0:n.top)&&(i=Math.max(null==n?void 0:n.top,i)),(null==n?void 0:n.bottom)&&(s=Math.max(null==n?void 0:n.bottom,s))}n=t.scrollDOM.clientHeight-i-s}else n=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:i,marginBottom:s,selfScroll:e,height:Math.max(t.defaultLineHeight,n-5)}}function la(t,e){let i,s=lh(t),{state:n}=t,r=o5(n.selection,i=>i.empty?t.moveVertically(i,e,s.height):o9(i,e));if(r.eq(n.selection))return!1;if(s.selfScroll){let e=t.coordsAtPos(n.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),l=o.top+s.marginTop,h=o.bottom-s.marginBottom;e&&e.top>l&&e.bottom<h&&(i=sK.scrollIntoView(r.main.head,{y:"start",yMargin:e.top-l}))}return t.dispatch(o8(n,r),{effects:i}),!0}let lc=t=>la(t,!1),lf=t=>la(t,!0);function lu(t,e,i){let s=t.lineBlockAt(e.head),n=t.moveToLineBoundary(e,i);if(n.head==e.head&&n.head!=(i?s.to:s.from)&&(n=t.moveToLineBoundary(e,i,!1)),!i&&n.head==s.from&&s.length){let i=/^\s*/.exec(t.state.sliceDoc(s.from,Math.min(s.from+100,s.to)))[0].length;i&&e.head!=s.from+i&&(n=R.cursor(s.from+i))}return n}function ld(t,e){let i=o5(t.state.selection,t=>{let i=e(t);return R.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return!i.eq(t.state.selection)&&(t.dispatch(o8(t.state,i)),!0)}function lp(t,e){return ld(t,i=>t.moveByChar(i,e))}let lg=t=>lp(t,!lt(t)),lm=t=>lp(t,lt(t));function lw(t,e){return ld(t,i=>t.moveByGroup(i,e))}function lv(t,e){return ld(t,i=>t.moveVertically(i,e))}let lb=t=>lv(t,!1),ly=t=>lv(t,!0);function lk(t,e){return ld(t,i=>t.moveVertically(i,e,lh(t).height))}let lx=t=>lk(t,!1),lS=t=>lk(t,!0),lC=({state:t,dispatch:e})=>(e(o8(t,{anchor:0})),!0),lA=({state:t,dispatch:e})=>(e(o8(t,{anchor:t.doc.length})),!0),lP=({state:t,dispatch:e})=>(e(o8(t,{anchor:t.selection.main.anchor,head:0})),!0),lO=({state:t,dispatch:e})=>(e(o8(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function lM(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:s}=t,n=s.changeByRange(s=>{let{from:n,to:r}=s;if(n==r){let o=e(s);o<n?(i="delete.backward",o=lT(t,o,!1)):o>n&&(i="delete.forward",o=lT(t,o,!0)),n=Math.min(n,o),r=Math.max(r,o)}else n=lT(t,n,!1),r=lT(t,r,!0);return n==r?{range:s}:{changes:{from:n,to:r},range:R.cursor(n,n<s.head?-1:1)}});return!n.changes.empty&&(t.dispatch(s.update(n,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?sK.announce.of(s.phrase("Selection deleted")):void 0})),!0)}function lT(t,e,i){if(t instanceof sK)for(let s of t.state.facet(sK.atomicRanges).map(e=>e(t)))s.between(e,e,(t,s)=>{t<e&&s>e&&(e=i?s:t)});return e}let lD=(t,e,i)=>lM(t,s=>{let n=s.from,{state:r}=t,o=r.doc.lineAt(n),l,h;if(i&&!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,n-o.from))){if("	"==l[l.length-1])return n-1;let t=tN(l,r.tabSize)%r$(r)||r$(r);for(let e=0;e<t&&" "==l[l.length-1-e];e++)n--;h=n}else(h=b(o.text,n-o.from,e,e)+o.from)==n&&o.number!=(e?r.doc.lines:1)?h+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(h-o.from,n-o.from))&&(h=b(o.text,h-o.from,!1,!1)+o.from);return h}),lE=t=>lD(t,!1,!0),lB=t=>lD(t,!0,!1),lR=(t,e)=>lM(t,i=>{let s=i.head,{state:n}=t,r=n.doc.lineAt(s),o=n.charCategorizer(s);for(let t=null;;){if(s==(e?r.to:r.from)){s==i.head&&r.number!=(e?n.doc.lines:1)&&(s+=e?1:-1);break}let l=b(r.text,s-r.from,e)+r.from,h=r.text.slice(Math.min(s,l)-r.from,Math.max(s,l)-r.from),a=o(h);if(null!=t&&a!=t)break;(" "!=h||s!=i.head)&&(t=a),s=l}return s}),lN=t=>lR(t,!1);function lL(t){let e=[],i=-1;for(let s of t.selection.ranges){let n=t.doc.lineAt(s.from),r=t.doc.lineAt(s.to);if(s.empty||s.to!=r.from||(r=t.doc.lineAt(s.to-1)),i>=n.number){let t=e[e.length-1];t.to=r.to,t.ranges.push(s)}else e.push({from:n.from,to:r.to,ranges:[s]});i=r.number+1}return e}function lI(t,e,i){if(t.readOnly)return!1;let s=[],n=[];for(let e of lL(t)){if(i?e.to==t.doc.length:0==e.from)continue;let r=t.doc.lineAt(i?e.to+1:e.from-1),o=r.length+1;if(i)for(let i of(s.push({from:e.to,to:r.to},{from:e.from,insert:r.text+t.lineBreak}),e.ranges))n.push(R.range(Math.min(t.doc.length,i.anchor+o),Math.min(t.doc.length,i.head+o)));else for(let i of(s.push({from:r.from,to:e.from},{from:e.to,insert:t.lineBreak+r.text}),e.ranges))n.push(R.range(i.anchor-o,i.head-o))}return!!s.length&&(e(t.update({changes:s,scrollIntoView:!0,selection:R.create(n,t.selection.mainIndex),userEvent:"move.line"})),!0)}function lV(t,e,i){if(t.readOnly)return!1;let s=[];for(let e of lL(t))i?s.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):s.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:s,scrollIntoView:!0,userEvent:"input.copyline"})),!0}let lH=lz(!1),lW=lz(!0);function lz(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let s=e.changeByRange(i=>{let{from:s,to:n}=i,r=e.doc.lineAt(s),o=!t&&s==n&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i=rI(t).resolveInner(e),s=i.childBefore(e),n=i.childAfter(e),r;return s&&n&&s.to<=e&&n.from>=e&&(r=s.type.prop(nq.closedBy))&&r.indexOf(n.name)>-1&&t.doc.lineAt(s.to).from==t.doc.lineAt(n.from).from&&!/\S/.test(t.sliceDoc(s.to,n.from))?{from:s.to,to:n.from}:null}(e,s);t&&(s=n=(n<=r.to?r:e.doc.lineAt(n)).to);let l=new rQ(e,{simulateBreak:s,simulateDoubleBreak:!!o}),h=rG(l,s);for(null==h&&(h=tN(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));n<r.to&&/\s/.test(r.text[n-r.from]);)n++;o?{from:s,to:n}=o:s>r.from&&s<r.from+100&&!/\S/.test(r.text.slice(0,s))&&(s=r.from);let a=["",rK(e,h)];return o&&a.push(rK(e,l.lineIndent(r.from,-1))),{changes:{from:s,to:n,insert:c.of(a)},range:R.cursor(s+1+a[1].length)}});return i(e.update(s,{scrollIntoView:!0,userEvent:"input"})),!0}}function lF(t,e){let i=-1;return t.changeByRange(s=>{let n=[];for(let r=s.from;r<=s.to;){let o=t.doc.lineAt(r);o.number>i&&(s.empty||s.to>o.from)&&(e(o,n,s),i=o.number),r=o.to+1}let r=t.changes(n);return{changes:n,range:R.range(r.mapPos(s.anchor,1),r.mapPos(s.head,1))}})}let lq=[{key:"Ctrl-b",run:le,shift:lg,preventDefault:!0},{key:"Ctrl-f",run:li,shift:lm},{key:"Ctrl-p",run:lo,shift:lb},{key:"Ctrl-n",run:ll,shift:ly},{key:"Ctrl-a",run:t=>o6(t,e=>R.cursor(t.lineBlockAt(e.head).from,1)),shift:t=>ld(t,e=>R.cursor(t.lineBlockAt(e.head).from))},{key:"Ctrl-e",run:t=>o6(t,e=>R.cursor(t.lineBlockAt(e.head).to,-1)),shift:t=>ld(t,e=>R.cursor(t.lineBlockAt(e.head).to))},{key:"Ctrl-d",run:lB},{key:"Ctrl-h",run:lE},{key:"Ctrl-k",run:t=>lM(t,e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})},{key:"Ctrl-Alt-h",run:lN},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:c.of(["",""])},range:R.cursor(t.from)}));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,s=t.doc.lineAt(i),n=i==s.from?i-1:b(s.text,i-s.from,!1)+s.from,r=i==s.to?i+1:b(s.text,i-s.from,!0)+s.from;return{changes:{from:n,to:r,insert:t.doc.slice(i,r).append(t.doc.slice(n,i))},range:R.cursor(r)}});return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:lf}],l_=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>o6(t,e=>ln(t.state,e,!lt(t))),shift:t=>ld(t,e=>ln(t.state,e,!lt(t)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>o6(t,e=>ln(t.state,e,lt(t))),shift:t=>ld(t,e=>ln(t.state,e,lt(t)))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>lI(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>lV(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>lI(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>lV(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,s=null;return i.ranges.length>1?s=R.create([i.main]):i.main.empty||(s=R.create([R.cursor(i.main.head)])),!!s&&(e(o8(t,s)),!0)}},{key:"Mod-Enter",run:lW},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=lL(t).map(({from:e,to:i})=>R.range(e,Math.min(i+1,t.doc.length)));return e(t.update({selection:R.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=o5(t.selection,e=>{let i=rI(t),s=i.resolveStack(e.from,1);if(e.empty){let t=i.resolveStack(e.from,-1);t.node.from>=s.node.from&&t.node.to<=s.node.to&&(s=t)}for(let t=s;t;t=t.next){let{node:i}=t;if((i.from<e.from&&i.to>=e.to||i.to>e.to&&i.from<=e.from)&&t.next)return R.range(i.to,i.from)}return e});return!i.eq(t.selection)&&(e(o8(t,i)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(lF(t,(e,i)=>{let s=/^\s*/.exec(e.text)[0];if(!s)return;let n=tN(s,t.tabSize),r=0,o=rK(t,Math.max(0,n-r$(t)));for(;r<s.length&&r<o.length&&s.charCodeAt(r)==o.charCodeAt(r);)r++;i.push({from:e.from+r,to:e.from+s.length,insert:o.slice(r)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(lF(t,(e,i)=>{i.push({from:e.from,insert:t.facet(rX)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),s=new rQ(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),n=lF(t,(e,n,r)=>{let o=rG(s,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],h=rK(t,o);(l!=h||r.from<e.from+l.length)&&(i[e.from]=o,n.push({from:e.from,to:e.from+l.length,insert:h}))});return n.changes.empty||e(t.update(n,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(lL(e).map(({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i}))),s=o5(e.selection,e=>{let i;if(t.lineWrapping){let s=t.lineBlockAt(e.head),n=t.coordsAtPos(e.head,e.assoc||1);n&&(i=s.bottom+t.documentTop-n.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,i)}).map(i);return t.dispatch({changes:i,selection:s,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>(function(t,e,i){let s=!1,n=o5(t.selection,e=>{let n=oM(t,e.head,-1)||oM(t,e.head,1)||e.head>0&&oM(t,e.head-1,1)||e.head<t.doc.length&&oM(t,e.head+1,-1);if(!n||!n.end)return e;s=!0;let r=n.start.from==e.head?n.end.to:n.end.from;return i?R.range(e.anchor,r):R.cursor(r)});return!!s&&(e(o8(t,n)),!0)})(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),s=oj(t.state,i.from);return s.line?oF(t):!!s.block&&o_(t)}},{key:"Alt-A",run:oq},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:le,shift:lg,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>ls(t,!lt(t)),shift:t=>lw(t,!lt(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>o6(t,e=>lu(t,e,!lt(t))),shift:t=>ld(t,e=>lu(t,e,!lt(t))),preventDefault:!0},{key:"ArrowRight",run:li,shift:lm,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>ls(t,lt(t)),shift:t=>lw(t,lt(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>o6(t,e=>lu(t,e,lt(t))),shift:t=>ld(t,e=>lu(t,e,lt(t))),preventDefault:!0},{key:"ArrowUp",run:lo,shift:lb,preventDefault:!0},{mac:"Cmd-ArrowUp",run:lC,shift:lP},{mac:"Ctrl-ArrowUp",run:lc,shift:lx},{key:"ArrowDown",run:ll,shift:ly,preventDefault:!0},{mac:"Cmd-ArrowDown",run:lA,shift:lO},{mac:"Ctrl-ArrowDown",run:lf,shift:lS},{key:"PageUp",run:lc,shift:lx},{key:"PageDown",run:lf,shift:lS},{key:"Home",run:t=>o6(t,e=>lu(t,e,!1)),shift:t=>ld(t,e=>lu(t,e,!1)),preventDefault:!0},{key:"Mod-Home",run:lC,shift:lP},{key:"End",run:t=>o6(t,e=>lu(t,e,!0)),shift:t=>ld(t,e=>lu(t,e,!0)),preventDefault:!0},{key:"Mod-End",run:lA,shift:lO},{key:"Enter",run:lH,shift:lH},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:lE,shift:lE},{key:"Delete",run:lB},{key:"Mod-Backspace",mac:"Alt-Backspace",run:lN},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>lR(t,!0)},{mac:"Mod-Backspace",run:t=>lM(t,e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)})},{mac:"Mod-Delete",run:t=>lM(t,e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)})}].concat(lq.map(t=>({mac:t.key,run:t.run,shift:t.shift}))));class lj{constructor(t,e,i,s,n,r,o,l,h,a=0,c){this.p=t,this.stack=e,this.state=i,this.reducePos=s,this.pos=n,this.score=r,this.buffer=o,this.bufferBase=l,this.curContext=h,this.lookAhead=a,this.parent=c}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let s=t.parser.context;return new lj(t,[],e,i,i,0,[],0,s?new lU(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,s=65535&t,{parser:n}=this.p,r=this.reducePos<this.pos-25;r&&this.setLookAhead(this.pos);let o=n.dynamicPrecedence(s);if(o&&(this.score+=o),0==i){this.pushState(n.getGoto(this.state,s,!0),this.reducePos),s<n.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,r?8:4,!0),this.reduceContext(s,this.reducePos);return}let l=this.stack.length-(i-1)*3-(262144&t?6:0),h=l?this.stack[l-2]:this.p.ranges[0].from,a=this.reducePos-h;a>=2e3&&!(null==(e=this.p.parser.nodeSet.types[s])?void 0:e.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=a):this.p.lastBigReductionSize<a&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=a));let c=l?this.stack[l-1]:0,f=this.bufferBase+this.buffer.length-c;if(s<n.minRepeatTerm||131072&t){let t=n.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,h,t,f+4,!0)}if(262144&t)this.state=this.stack[l];else{let t=this.stack[l-3];this.state=n.getGoto(t,s,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(s,h)}storeNode(t,e,i,s=4,n=!1){if(0==t&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let t=this,s=this.buffer.length;if(0==s&&t.parent&&(s=t.bufferBase-t.parent.bufferBase,t=t.parent),s>0&&0==t.buffer[s-4]&&t.buffer[s-1]>-1){if(e==i)return;if(t.buffer[s-2]>=e){t.buffer[s-2]=i;return}}}if(n&&this.pos!=i){let n=this.buffer.length;if(n>0&&0!=this.buffer[n-4]){let t=!1;for(let e=n;e>0&&this.buffer[e-2]>i;e-=4)if(this.buffer[e-1]>=0){t=!0;break}if(t)for(;n>0&&this.buffer[n-2]>i;)this.buffer[n]=this.buffer[n-4],this.buffer[n+1]=this.buffer[n-3],this.buffer[n+2]=this.buffer[n-2],this.buffer[n+3]=this.buffer[n-1],n-=4,s>4&&(s-=4)}this.buffer[n]=t,this.buffer[n+1]=e,this.buffer[n+2]=i,this.buffer[n+3]=s}else this.buffer.push(t,e,i,s)}shift(t,e,i,s){if(131072&t)this.pushState(65535&t,this.pos);else if((262144&t)==0){let{parser:n}=this.p;(s>this.pos||e<=n.maxNode)&&(this.pos=s,n.stateFlag(t,1)||(this.reducePos=s)),this.pushState(t,i),this.shiftContext(e,i),e<=n.maxNode&&this.buffer.push(e,i,s,4)}else this.pos=s,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,s,4)}apply(t,e,i,s){65536&t?this.reduce(t):this.shift(t,e,i,s)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(e,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),s=t.bufferBase+e;for(;t&&s==t.bufferBase;)t=t.parent;return new lj(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new lY(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(0==i)return!1;if((65536&i)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let s=0,n;s<e.length;s+=2)(n=e[s+1])!=this.state&&this.p.parser.hasAction(n,t)&&i.push(e[s],n);if(this.stack.length<120)for(let t=0;i.length<8&&t<e.length;t+=2){let s=e[t+1];i.some((t,e)=>1&e&&t==s)||i.push(e[t],s)}e=i}let i=[];for(let t=0;t<e.length&&i.length<4;t+=2){let s=e[t+1];if(s==this.state)continue;let n=this.split();n.pushState(s,this.pos),n.storeNode(0,n.pos,n.pos,4,!0),n.shiftContext(e[t],this.pos),n.reducePos=this.pos,n.score-=200,i.push(n)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((65536&e)==0)return!1;if(!t.validAction(this.state,e)){let i=e>>19,s=65535&e,n=this.stack.length-3*i;if(n<0||0>t.getGoto(this.stack[n],s,!1)){let t=this.findForcedReduction();if(null==t)return!1;e=t}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(s,n)=>{if(!e.includes(s))return e.push(s),t.allActions(s,e=>{if(393216&e);else if(65536&e){let i=(e>>19)-n;if(i>1){let s=65535&e,n=this.stack.length-3*i;if(n>=0&&t.getGoto(this.stack[n],s,!1)>=0)return i<<19|65536|s}}else{let t=i(e,n+1);if(null!=t)return t}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:t}=this.p;return 65535==t.data[t.stateSlot(this.state,1)]&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||-3!=this.buffer[t])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||-4!=this.buffer[t])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new lU(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){t>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=t)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class lU{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class lY{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t>>19;0==e?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(e-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],65535&t,!0);this.state=i}}class lX{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,0==this.index&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new lX(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;null!=t&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new lX(this.stack,this.pos,this.index)}}function l$(t,e=Uint16Array){if("string"!=typeof t)return t;let i=null;for(let s=0,n=0;s<t.length;){let r=0;for(;;){let e=t.charCodeAt(s++),i=!1;if(126==e){r=65535;break}e>=92&&e--,e>=34&&e--;let n=e-32;if(n>=46&&(n-=46,i=!0),r+=n,i)break;r*=46}i?i[n++]=r:i=new e(r)}return i}class lK{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}let lG=new lK;class lQ{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=lG,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,s=this.rangeIndex,n=this.pos+t;for(;n<i.from;){if(!s)return null;let t=this.ranges[--s];n-=i.from-t.to,i=t}for(;e<0?n>i.to:n>=i.to;){if(s==this.ranges.length-1)return null;let t=this.ranges[++s];n+=t.from-i.to,i=t}return n}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,s;if(e>=0&&e<this.chunk.length)i=this.pos+t,s=this.chunk.charCodeAt(e);else{let e=this.resolveOffset(t,1);if(null==e)return -1;if((i=e)>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let t=this.rangeIndex,e=this.range;for(;e.to<=i;)e=this.ranges[++t];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>e.to&&(this.chunk2=this.chunk2.slice(0,e.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(null==i||i<this.token.start)throw RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=lG,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let s of this.ranges){if(s.from>=e)break;s.to>t&&(i+=this.input.read(Math.max(s.from,t),Math.min(s.to,e)))}return i}}class lJ{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;lZ(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}function lZ(t,e,i,s,n,r){let o=0,l=1<<s,{dialect:h}=i.p.parser;i:for(;(l&t[o])!=0;){let i=t[o+1];for(let s=o+3;s<i;s+=2)if((t[s+1]&l)>0){let i=t[s];if(h.allows(i)&&(-1==e.token.value||e.token.value==i||function(t,e,i,s){let n=l0(i,s,e);return n<0||l0(i,s,t)<n}(i,e.token.value,n,r))){e.acceptToken(i);break}}let s=e.next,a=0,c=t[o+2];if(e.next<0&&c>a&&65535==t[i+3*c-3]){o=t[i+3*c-1];continue}for(;a<c;){let n=a+c>>1,r=i+n+(n<<1),l=t[r],h=t[r+1]||65536;if(s<l)c=n;else if(s>=h)a=n+1;else{o=t[r+2],e.advance();continue i}}break}}function l0(t,e,i){for(let s=e,n;65535!=(n=t[s]);s++)if(n==i)return s-e;return -1}lJ.prototype.contextual=lJ.prototype.fallback=lJ.prototype.extend=!1,(class{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data="string"==typeof t?l$(t):t}token(t,e){let i=t.pos,s=0;for(;;){let i=t.next<0,n=t.resolveOffset(1,1);if(lZ(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(null==this.elseToken)return;if(!i&&s++,null==n)break;t.reset(n,t.token)}s&&(t.reset(i,t.token),t.acceptToken(this.elseToken,s))}}).prototype.contextual=lJ.prototype.fallback=lJ.prototype.extend=!1;let l1=null;function l2(t,e,i){let s=t.cursor(k.IncludeAnonymous);for(s.moveTo(e);;)if(!(i<0?s.childBefore(e):s.childAfter(e)))for(;;){if((i<0?s.to<e:s.from>e)&&!s.type.isError)return i<0?Math.max(0,Math.min(s.to-1,e-25)):Math.min(t.length,Math.max(s.from+1,e+25));if(i<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return i<0?0:t.length}}class l3{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?l2(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?l2(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],s=this.index[e];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=i.children[s],r=this.start[e]+i.positions[s];if(r>t)return this.nextStart=r,null;if(n instanceof nK){if(r==t){if(r<this.safeFrom)return null;let t=r+n.length;if(t<=this.safeTo){let e=n.prop(nq.lookAhead);if(!e||t+e<this.fragment.to)return n}}this.index[e]++,r+n.length>=Math.max(this.safeFrom,t)&&(this.trees.push(n),this.start.push(r),this.index.push(0))}else this.index[e]++,this.nextStart=r+n.length}}}class l4{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(t=>new lK)}getActions(t){let e=0,i=null,{parser:s}=t.p,{tokenizers:n}=s,r=s.stateSlot(t.state,3),o=t.curContext?t.curContext.hash:0,l=0;for(let s=0;s<n.length;s++){if((1<<s&r)==0)continue;let h=n[s],a=this.tokens[s];if((!i||h.fallback)&&((h.contextual||a.start!=t.pos||a.mask!=r||a.context!=o)&&(this.updateCachedToken(a,h,t),a.mask=r,a.context=o),a.lookAhead>a.end+25&&(l=Math.max(a.lookAhead,l)),0!=a.value)){let s=e;if(a.extended>-1&&(e=this.addActions(t,a.extended,a.end,e)),e=this.addActions(t,a.value,a.end,e),!h.extend&&(i=a,e>s))break}}for(;this.actions.length>e;)this.actions.pop();return l&&t.setLookAhead(l),i||t.pos!=this.stream.end||((i=new lK).value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new lK,{pos:i,p:s}=t;return e.start=i,e.end=Math.min(i+1,s.stream.end),e.value=i==s.stream.end?s.parser.eofTerm:0,e}updateCachedToken(t,e,i){let s=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(s,t),i),t.value>-1){let{parser:e}=i.p;for(let s=0;s<e.specialized.length;s++)if(e.specialized[s]==t.value){let n=e.specializers[s](this.stream.read(t.start,t.end),i);if(n>=0&&i.p.parser.dialect.allows(n>>1)){(1&n)==0?t.value=n>>1:t.extended=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,e,i,s){for(let e=0;e<s;e+=3)if(this.actions[e]==t)return s;return this.actions[s++]=t,this.actions[s++]=e,this.actions[s++]=i,s}addActions(t,e,i,s){let{state:n}=t,{parser:r}=t.p,{data:o}=r;for(let t=0;t<2;t++)for(let l=r.stateSlot(n,t?2:1);;l+=3){if(65535==o[l])if(1==o[l+1])l=l7(o,l+2);else{0==s&&2==o[l+1]&&(s=this.putAction(l7(o,l+2),e,i,s));break}o[l]==e&&(s=this.putAction(l7(o,l+1),e,i,s))}return s}}class l5{constructor(t,e,i,s){this.parser=t,this.input=e,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new lQ(e,s),this.tokens=new l4(t,this.stream),this.topTerm=t.top[1];let{from:n}=s[0];this.stacks=[lj.start(this,t.top[0],n)],this.fragments=i.length&&this.stream.end-n>4*t.bufferLength?new l3(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t,e,i=this.stacks,s=this.minStackPos,n=this.stacks=[];if(this.bigReductionCount>300&&1==i.length){let[t]=i;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<i.length;r++){let o=i[r];for(;;){if(this.tokens.mainToken=null,o.pos>s)n.push(o);else{if(this.advanceStack(o,n,i))continue;t||(t=[],e=[]),t.push(o);let s=this.tokens.getMainToken(o);e.push(s.value,s.end)}break}}if(!n.length){let e=t&&function(t){let e=null;for(let i of t){let t=i.p.stoppedAt;(i.pos==i.p.stream.end||null!=t&&i.pos>t)&&i.p.parser.stateFlag(i.state,2)&&(!e||e.score<i.score)&&(e=i)}return e}(t);if(e)return this.stackToTree(e);if(this.parser.strict)throw SyntaxError("No parse at "+s);this.recovering||(this.recovering=5)}if(this.recovering&&t){let i=null!=this.stoppedAt&&t[0].pos>this.stoppedAt?t[0]:this.runRecovery(t,e,n);if(i)return this.stackToTree(i.forceAll())}if(this.recovering){let t=1==this.recovering?1:3*this.recovering;if(n.length>t)for(n.sort((t,e)=>e.score-t.score);n.length>t;)n.pop();n.some(t=>t.reducePos>s)&&this.recovering--}else if(n.length>1){s:for(let t=0;t<n.length-1;t++){let e=n[t];for(let i=t+1;i<n.length;i++){let s=n[i];if(e.sameState(s)||e.buffer.length>500&&s.buffer.length>500)if((e.score-s.score||e.buffer.length-s.buffer.length)>0)n.splice(i--,1);else{n.splice(t--,1);continue s}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let t=1;t<n.length;t++)n[t].pos<this.minStackPos&&(this.minStackPos=n[t].pos);return null}stopAt(t){if(null!=this.stoppedAt&&this.stoppedAt<t)throw RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let s=t.pos,{parser:n}=this;if(null!=this.stoppedAt&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let e=t.curContext&&t.curContext.tracker.strict,i=e?t.curContext.hash:0;for(let r=this.fragments.nodeAt(s);r;){let s=this.parser.nodeSet.types[r.type.id]==r.type?n.getGoto(t.state,r.type.id):-1;if(s>-1&&r.length&&(!e||(r.prop(nq.contextHash)||0)==i))return t.useNode(r,s),!0;if(!(r instanceof nK)||0==r.children.length||r.positions[0]>0)break;let o=r.children[0];if(o instanceof nK&&0==r.positions[0])r=o;else break}}let r=n.stateSlot(t.state,4);if(r>0)return t.reduce(r),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let o=this.tokens.getActions(t);for(let n=0;n<o.length;){let r=o[n++],l=o[n++],h=o[n++],a=n==o.length||!i,c=a?t:t.split(),f=this.tokens.mainToken;if(c.apply(r,l,f?f.start:c.pos,h),a)return!0;c.pos>s?e.push(c):i.push(c)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return l8(t,e),!0}}runRecovery(t,e,i){let s=null,n=!1;for(let r=0;r<t.length;r++){let o=t[r],l=e[r<<1],h=e[(r<<1)+1];if(o.deadEnd&&(n||(n=!0,o.restart(),this.advanceFully(o,i))))continue;let a=o.split();for(let t=0;a.forceReduce()&&t<10&&!this.advanceFully(a,i);t++);for(let t of o.recoverByInsert(l))this.advanceFully(t,i);this.stream.end>o.pos?(h==o.pos&&(h++,l=0),o.recoverByDelete(l,h),l8(o,i)):(!s||s.score<o.score)&&(s=o)}return s}stackToTree(t){return t.close(),nK.build({buffer:lX.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(l1||(l1=new WeakMap)).get(t);return e||l1.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function l8(t,e){for(let i=0;i<e.length;i++){let s=e[i];if(s.pos==t.pos&&s.sameState(t)){e[i].score<t.score&&(e[i]=t);return}}e.push(t)}class l6{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||0==this.disabled[t]}}class l9 extends rn{constructor(t){if(super(),this.wrappers=[],14!=t.version)throw RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let i=0;i<t.repeatNodeCount;i++)e.push("");let i=Object.keys(t.topRules).map(e=>t.topRules[e][1]),s=[];for(let t=0;t<e.length;t++)s.push([]);function n(t,e,i){s[t].push([e,e.deserialize(String(i))])}if(t.nodeProps)for(let e of t.nodeProps){let t=e[0];"string"==typeof t&&(t=nq[t]);for(let i=1;i<e.length;){let s=e[i++];if(s>=0)n(s,t,e[i++]);else{let r=e[i+-s];for(let o=-s;o>0;o--)n(e[i++],t,r);i++}}}this.nodeSet=new nY(e.map((e,n)=>nU.define({name:n>=this.minRepeatTerm?void 0:e,id:n,props:s[n],top:i.indexOf(n)>-1,error:0==n,skipped:t.skippedNodes&&t.skippedNodes.indexOf(n)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=1024;let r=l$(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let t=0;t<this.specializerSpecs.length;t++)this.specialized[t]=this.specializerSpecs[t].term;this.specializers=this.specializerSpecs.map(ht),this.states=l$(t.states,Uint32Array),this.data=l$(t.stateData),this.goto=l$(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(t=>"number"==typeof t?new lJ(r,t):t),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let s=new l5(this,t,e,i);for(let n of this.wrappers)s=n(s,t,e,i);return s}getGoto(t,e,i=!1){let s=this.goto;if(e>=s[0])return -1;for(let n=s[e+1];;){let e=s[n++],r=1&e,o=s[n++];if(r&&i)return o;for(let i=n+(e>>1);n<i;n++)if(s[n]==t)return o;if(r)return -1}}hasAction(t,e){let i=this.data;for(let s=0;s<2;s++)for(let n=this.stateSlot(t,s?2:1),r;;n+=3){if(65535==(r=i[n]))if(1==i[n+1])r=i[n=l7(i,n+2)];else if(2==i[n+1])return l7(i,n+2);else break;if(r==e||0==r)return l7(i,n+1)}return 0}stateSlot(t,e){return this.states[6*t+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,t=>t==e||null)}allActions(t,e){let i=this.stateSlot(t,4),s=i?e(i):void 0;for(let i=this.stateSlot(t,1);null==s;i+=3){if(65535==this.data[i])if(1==this.data[i+1])i=l7(this.data,i+2);else break;s=e(l7(this.data,i+1))}return s}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(65535==this.data[i])if(1==this.data[i+1])i=l7(this.data,i+2);else break;if((1&this.data[i+2])==0){let t=this.data[i+1];e.some((e,i)=>1&i&&e==t)||e.push(this.data[i],t)}}return e}configure(t){let e=Object.assign(Object.create(l9.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(e=>{let i=t.tokenizers.find(t=>t.from==e);return i?i.to:e})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,s)=>{let n=t.specializers.find(t=>t.from==i.external);if(!n)return i;let r=Object.assign(Object.assign({},i),{external:n.to});return e.specializers[s]=ht(r),r})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),null!=t.strict&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),null!=t.bufferLength&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return null==e?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let s of t.split(" ")){let t=e.indexOf(s);t>=0&&(i[t]=!0)}let s=null;for(let t=0;t<e.length;t++)if(!i[t])for(let i=this.dialects[e[t]],n;65535!=(n=this.data[i++]);)(s||(s=new Uint8Array(this.maxTerm+1)))[n]=1;return new l6(t,i,s)}static deserialize(t){return new l9(t)}}function l7(t,e){return t[e]|t[e+1]<<16}function ht(t){if(t.external){let e=+!!t.extend;return(i,s)=>t.external(i,s)<<1|e}return t.get}let he=rc({KeywordControl:rD.controlKeyword,SupportFunction:rD.function(rD.keyword),KeywordOther:rD.keyword,EntityNameType:rD.typeName,ReasoningPhrase:rD.meta,Comment:rD.lineComment,OpenParen:rD.paren,CloseParen:rD.paren,OpenBrace:rD.brace,CloseBrace:rD.brace,OpenBracket:rD.squareBracket,CloseBracket:rD.squareBracket}),hi=l9.deserialize({version:14,states:"$UOQOPOOOOOO'#Cp'#CpOOOO'#Cn'#CnQQOPOOOQOPO'#CjOQOPO'#CkOQOPO'#ClOQOPO'#CmOQOPO'#CpOQOPO'#CpOQOPO'#CpOOOO-E6l-E6lO{OPO,59UO!SOPO,59VO!ZOPO,59WO!bOPO,59XO!iOPO,59[O!pOPO,59[O!wOPO,59[OOOO1G.p1G.pOOOO1G.q1G.qOOOO1G.r1G.rOOOO1G.s1G.sOOOO1G.v1G.v",stateData:"#^~OQPORPOSPOTPOUPOVPOWWOYXO[YOeSOgTOhUOiVO~OfcO~PQOfdO~PQOfeO~PQOffO~PQOXgO~PQOZgO~PQO]gO~PQOVUQRSTWXYZ[]W~",goto:"#OePPPPPPPPPPPPPPffffxP!lqPORSTUVWXY[]^_`abQRO`ZR[]^_`abQ[SQ]TQ^UQ_VQ`WQaXRbYqQORSTUVWXY[]^_`ab",nodeNames:"⚠ Program KeywordControl SupportFunction KeywordOther EntityNameType ReasoningPhrase Comment OpenParen CloseParen OpenBrace CloseBrace OpenBracket CloseBracket DefinitionBlock Proof NowBlock HerebyBlock",maxTerm:25,propSources:[he],skippedNodes:[0],repeatNodeCount:1,tokenData:"! j~Rmvw!|xy#Ryz#W![!]#]!}#O#z#P#Q$P#T#U$U#U#V(O#V#W)l#W#X3U#X#Y5W#Y#Z8]#Z#[8{#[#]9_#]#^:l#`#a>_#a#b>k#b#c?W#c#d@f#d#eAk#e#fCO#f#gC[#g#hGv#h#iKZ#i#jMX#j#kMq#k#lN|#o#p! `#q#r! e~#ROQ~~#WOW~~#]OX~~#`P![!]#c~#hSV~OY#cZ;'S#c;'S;=`#t<%lO#c~#wP;=`<%l#c~$PO[~~$UO]~~$XR#b#c$b#g#h%Y#h#i'r~$eQ#W#X$k#h#i$p~$pOS~~$sP#c#d$v~$yP#b#c$|~%PP#m#n%S~%VP#a#b$k~%_QS~#g#h%e#m#n'S~%hQ#c#d%n#i#j&v~%qP#V#W%t~%wP#]#^%z~%}P#T#U&Q~&TP#h#i&W~&ZP#]#^&^~&aP#j#k&d~&gP#]#^&j~&mP#h#i&p~&sP#m#n$k~&yP#a#b&|~'PP#X#Y$k~'VP#a#b'Y~']P#a#b'`~'cP#X#Y'f~'iP#h#i'l~'oP#f#g&p~'uP#h#i'x~'{P#f#g$k~(RQ#X#Y(X#m#n(}~([Rpq$k#Z#[(e#]#^(q~(hP#]#^(k~(nP#b#c$k~(tP#b#c(w~(zP#Z#[!|~)SUU~OY(}Z!](}!^#Q(}#R;'S(};'S;=`)f<%lO(}~)iP;=`<%l(}~)oR#T#U)x#`#a+P#c#d+|~){Q#b#c*R#g#h*q~*UP#V#W*X~*[P#X#Y*_~*bP#`#a*e~*hP#X#Y*k~*nP#W#X$k~*tP#X#Y*w~*|PT~#g#h$k~+SP#i#j+V~+YP#g#h+]~+`P#h#i+c~+fP#X#Y+i~+lP#f#g+o~+tPS~#g#h+w~+|OR~~,PS#[#],]#a#b,{#b#c.W#f#g2l~,`P#X#Y,c~,fP#f#g,i~,lP#X#Y,o~,rP#b#c,u~,xP#V#W&|~-OQ#a#b-U#d#e-b~-XP#i#j-[~-_P#h#i%z~-eP#T#U-h~-kP#h#i-n~-qP#]#^-t~-wP#U#V-z~-}P#]#^.Q~.TP#`#a&d~.ZR#b#c.d#g#h/l#h#i1j~.gP#X#Y.j~.mP#V#W.p~.sP#h#i.v~.yP#X#Y.|~/PP#W#X/S~/VP#b#c/Y~/]P#X#Y/`~/cP#g#h/f~/iP#g#h$k~/oQ#]#^/u#h#i0n~/xQ#W#X0O#g#h0U~0RP#X#Y'x~0XP#h#i0[~0_P#X#Y0b~0eP#b#c0h~0kP#V#W&p~0qP#f#g0t~0wP#i#j0z~0}P#V#W1Q~1TP#h#i1W~1ZP#c#d1^~1aP#f#g1d~1gP#g#h+w~1mP#f#g1p~1sP#T#U1v~1yP#W#X1|~2PP#]#^2S~2VP#V#W2Y~2]P#h#i2`~2cP#]#^2f~2iP#c#d(k~2oP#f#g2r~2uP#X#Y2x~2{P#V#W3O~3RP#h#i/S~3XP#X#Y3[~3_P#Y#Z3b~3gRS~#Y#Z3p#]#^4S#d#e5Q~3sP#i#j3v~3yP#b#c3|~4PP#V#W$k~4VP#b#c4Y~4]P#]#^4`~4cP#h#i4f~4iP#]#^4l~4oP#c#d4r~4uP#b#c4x~4}Pe~#g#h+w~5TP#f#g*e~5ZR#b#c5d#e#f6O#l#m6}~5gQ#W#X5m#j#k5r~5rOf~~5uP#]#^5x~5{P#f#g2f~6RP#i#j6U~6XP#T#U6[~6_P#`#a6b~6eQ#]#^6k#g#h$k~6nP#h#i6q~6tP#]#^6w~6zP#X#Y1d~7QRpq!|#]#^7Z#d#e7g~7^P#g#h7a~7dP#h#i,i~7jP#T#U7m~7pP#b#c7s~7vP#g#h7y~7|P#]#^8P~8SP#c#d8V~8YP#b#c1d~8`R#c#d8i#f#g8o#i#j3v~8lP#f#g!|~8rP#c#d8u~8xP#a#b(}~9OP#]#^9R~9UP#j#k9X~9[P#X#Y(k~9bQ#X#Y9h#c#d:Y~9kQ#b#c,u#f#g9q~9tP#X#Y9w~9zP#U#V9}~:QP#m#n:T~:YOi~~:]P#`#a:`~:cP#W#X:f~:iP#g#h!|~:oV#W#X;U#Y#Z;n#a#b;w#b#c<a#f#g=c#g#h>X#h#i$k~;XP#X#Y;[~;_P#a#b;b~;eP#d#e;h~;kP#c#d7a~;qQpq$k#Y#Z!|~;zP#d#e;}~<QP#`#a<T~<WP#]#^<Z~<^P#X#Y:f~<dP#j#k<g~<jP#c#d<m~<pP#`#a<s~<vP#i#j<y~<|P#h#i=P~=SP#]#^=V~=YP#j#k=]~=`P#X#Y/S~=fP#f#g=i~=lP#X#Y=o~=rP#Y#Z=u~=xP#`#a={~>OP#X#Y>R~>UP#l#m&W~>[Ppq$k~>bP#X#Y>e~>hP#h#i$k~>nQ#X#Y>t#c#d?Q~>wP#T#U>z~>}P#b#c/f~?TP#W#X&|~?ZP#c#d?^~?aQ#h#i?g#k#l@a~?lPQ~#T#U?o~?rP#h#i?u~?xP#]#^?{~@OP#c#d@R~@UP#b#c@X~@^PR~#g#h+w~@fOh~~@iS#Y#Z$k#f#g!|#h#i@u#j#k0O~@xP#[#]@{~AOP#X#YAR~AUP#f#gAX~A[P#k#lA_~AbP#]#^Ae~AhP#g#h&|~AnQ#X#Y'x#f#gAt~AwQ#X#Y*k#c#dA}~BQR#^#_BZ#c#dBg#j#kBr~B^P#X#YBa~BdP#V#W&Q~BjP#Y#ZBm~BrOg~~BuP#]#^Bx~B{P#W#X*e~CRP#i#jCU~CXP#T#U$k~C_P#X#YCb~CeU#V#WCw#W#XDg#Y#Z=u#Z#[EP#e#fFb#g#hGd~CzP#c#dC}~DQP#b#cDT~DWP#g#hDZ~D^P#]#^Da~DdP#W#X0O~DjP#X#YDm~DpP#Y#ZDs~DvP#]#^Dy~D|P#b#c&|~ESP#]#^EV~EYP#g#hE]~E`P#h#iEc~EfP#f#gEi~ElP#T#UEo~ErP#h#iEu~ExP#]#^E{~FOP#c#dFR~FUP#b#cFX~F[Qpq+w#g#h+w~FeP#i#jFh~FkP#]#^Fn~FqP#f#gFt~FwP#X#YFz~F}P#a#bGQ~GTP#X#YGW~GZP#b#cG^~GaP#h#i1d~GgP#X#YGj~GmP#f#gGp~GsP#j#k&|~GyT#V#WHY#]#^Hr#h#iIn#i#jJS#m#nKQ~H]P#[#]H`~HcP#X#YHf~HiP#a#bHl~HoP#X#Y@X~HuP#Z#[Hx~H{P#b#cIO~IRP#T#UIU~IXP#h#iI[~I_P#i#jIb~IeP#f#gIh~IkP#X#Y+w~IsPQ~#f#gIv~IyP#i#jI|~JPP#V#W>e~JVQ#V#WJ]#d#eJc~J`P#[#]$k~JfP#d#eJi~JlP#c#dJo~JrP#g#hJu~JxP#X#YJ{~KQOT~~KTQ#a#b'Y#b#c$p~K^R#T#UKg#[#]Km#f#gLo~KjP#_#`&|~KpR#T#U>e#X#YKy#i#j/f~K|R#b#c$k#c#dLV#g#hLi~LYP#f#gL]~L`P#X#YLc~LfP#a#b@X~LlP#]#^/f~LrP#T#ULu~LxP#b#cL{~MOP#g#hMR~MUP#]#^&Q~M[P#b#cM_~MbP#]#^Me~MhP#e#fMk~MnP#i#j=]~MtP#c#dMw~MzP#V#WM}~NQP#T#UNT~NWP#U#VNZ~N^P#i#jNa~NdP#`#aNg~NjP#T#UNm~NpP#f#gNs~NvQ#]#^6w#m#n+w~! PP#[#]! S~! VP#X#Y! Y~! ]P#f#g&|~! eOY~~! jOZ~",tokenizers:[0],topRules:{Program:[0,1]},tokenPrec:92}),hs=[...l_,...or,{key:"Enter",run:lH}],hn=og.define([{tag:rD.controlKeyword,class:"control-keyword"},{tag:rD.function(rD.keyword),class:"function-keyword"},{tag:rD.keyword,class:"general-keyword"},{tag:rD.typeName,class:"type-name"},{tag:rD.meta,class:"meta-info"},{tag:rD.lineComment,class:"line-comment"},{tag:rD.paren,class:"paren"},{tag:rD.brace,class:"brace"},{tag:rD.squareBracket,class:"square-bracket"}]),hr=hi.configure({props:[he,r3.add({DefinitionBlock:r4,Proof:r4,NowBlock:r4,HerebyBlock:r4})]}),ho=rL.define({parser:hr}),hl=rJ.add({Proof:t=>t.lineIndent(t.node.from)+t.unit,DefinitionBlock:t=>t.lineIndent(t.node.from)+t.unit,NowBlock:t=>t.lineIndent(t.node.from)+t.unit,HerebyBlock:t=>t.lineIndent(t.node.from)+t.unit}),hh=ho.configure({props:[hl]}),ha=new X,hc=window.editors=window.editors||{},hf=window.lineNumberConfigs=window.lineNumberConfigs||{},hu=window.editorOrder=window.editorOrder||[],hd=th.define(),hp=q.define({create:()=>eN.none,update(t,e){for(let i of(t=t.map(e.changes),e.effects))i.is(hd)&&(t=t.update({add:i.value}));return t},provide:t=>sK.decorations.from(t)});function hg(t,e){t.querySelectorAll(".editor-container, .copy-button, .edit-button, .reset-button, .compile-button").forEach(t=>{t.style.display=e?"none":""});let i=t.querySelector(".hide-button"),s=t.querySelector(".show-button");i&&s&&(i.style.display=e?"none":"inline",s.style.display=e?"inline":"none")}document.addEventListener("DOMContentLoaded",function(){window.mizarInitialized=!0;let t=document.querySelectorAll(".mizarWrapper");if(0===t.length)return void console.warn("No Mizar blocks found.");t.forEach(t=>{let e=t.id.replace("mizarBlock","");t.querySelector(".editor-container").firstChild||function(t,e){let i,s,n=t.querySelector(".editor-container");n.id=`editorContainer${e}`;let r=n.getAttribute("data-content"),o=document.createElement("div");o.innerHTML=r;let l=o.textContent||o.innerText||"",h=new X;hf[e]=h;let a=new sK({state:tm.create({doc:l,extensions:[h.of(nH({formatNumber:t=>`${t+function(t){let e=1;for(let i of hu){if(i===t)break;e+=hc[i].state.doc.lines}return e}(e)-1}`})),ha.of(sK.editable.of(!1)),(i=[ob],hn instanceof og&&(hn.module&&i.push(sK.styleModule.of(hn.module)),s=hn.themeType),s?i.push(om.computeN([sK.darkTheme],t=>t.facet(sK.darkTheme)==("dark"==s)?[hn]:[])):i.push(om.of(hn)),i),oh(),function(t={}){var e;let i={...ou,...t},s=new od(i,!0),n=new od(i,!1),r=iw.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(rU)!=t.state.facet(rU)||t.startState.field(ot,!1)!=t.state.field(ot,!1)||rI(t.startState)!=rI(t.state)||i.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new tS;for(let i of t.viewportLineBlocks){let r=oi(t.state,i.from,i.to)?n:r5(t.state,i.from,i.to)?s:null;r&&e.add(i.from,i.from,r)}return e.finish()}}),{domEventHandlers:o}=i;return[r,(e={class:"cm-foldGutter",markers(t){var e;return(null==(e=t.plugin(r))?void 0:e.markers)||tx.empty},initialSpacer:()=>new od(i,!1),domEventHandlers:{...o,click:(t,e,i)=>{if(o.click&&o.click(t,e,i))return!0;let s=oi(t.state,e.from,e.to);if(s)return t.dispatch({effects:r9.of(s)}),!0;let n=r5(t.state,e.from,e.to);return!!n&&(t.dispatch({effects:r6.of(n)}),!0)}}},[nA(),nS.of({...nx,...e})]),oh()]}(),s3.of(hs),iw.fromClass(class{constructor(t){this.decorations=this.buildDecorations(t)}update(t){(t.docChanged||t.viewportChanged)&&(this.decorations=this.buildDecorations(t.view))}buildDecorations(t){let e=new tS,i=[],s=["bracket-color-0","bracket-color-1","bracket-color-2","bracket-color-3","bracket-color-4"];return rI(t.state).iterate({enter:({type:t,from:n,to:r})=>{if(t.is("OpenParen")||t.is("OpenBrace")||t.is("OpenBracket")){i.push({type:t,from:n,to:r});let o=i.length%s.length;e.add(n,r,eN.mark({class:s[o]}))}else if((t.is("CloseParen")||t.is("CloseBrace")||t.is("CloseBracket"))&&i.pop()){let t=(i.length+1)%s.length;e.add(n,r,eN.mark({class:s[t]}))}}}),e.finish()}},{decorations:t=>t.decorations}),sK.updateListener.of(t=>{t.docChanged&&function(){let t=1;for(let e of hu){let i=hc[e],s=t,n=nH({formatNumber:t=>`${t+s-1}`});i.dispatch({effects:hf[e].reconfigure(n)}),t+=i.state.doc.lines}}()}),hw,hp,hh]}),parent:n});window.editors[e]=a,hu.push(e);let c=t.querySelector("button[id^='editButton']"),f=t.querySelector("button[id^='compileButton']"),u=t.querySelector("button[id^='resetButton']"),d=t.querySelector("button[id^='graphButton']");c.addEventListener("click",()=>{a.dispatch({effects:ha.reconfigure(sK.editable.of(!0))}),c.style.display="none",f.style.display="inline",u.style.display="inline"}),f.addEventListener("click",()=>{if(t.isRequestInProgress)return;t.isRequestInProgress=!0;let i=document.createElement("div");i.className="loading-spinner",i.innerHTML="Loading...",f.parentNode.insertBefore(i,f.nextSibling),hb(t,hm,e).finally(()=>{i.remove(),t.isRequestInProgress=!1})}),u.addEventListener("click",async()=>{let t=n.getAttribute("data-content"),e=document.createElement("div");e.innerHTML=t;let i=e.textContent||e.innerText||"";a.dispatch({changes:{from:0,to:a.state.doc.length,insert:i}}),a.dispatch({effects:ha.reconfigure(sK.editable.of(!1))}),c.style.display="inline",f.style.display="none",u.style.display="none",a.dispatch({effects:hm.of(null)}),a.dispatch({effects:hd.of([])});try{let t,e=await fetch(DOKU_BASE+"lib/exe/ajax.php?call=clear_temp_files",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"}}),i=await e.text();try{t=JSON.parse(i)}catch(t){throw Error("Server returned a non-JSON response: "+i)}t.success?console.log(t.message):console.error("Failed to clear temporary files:",t.message)}catch(t){console.error("Error clearing temporary files:",t)}}),d.addEventListener("click",()=>{if(t.isRequestInProgress)return;t.isRequestInProgress=!0;let i=document.createElement("div");i.className="loading-spinner",i.textContent="Visualizing...",d.parentNode.insertBefore(i,d.nextSibling),hy(t,e).finally(()=>{i.remove(),t.isRequestInProgress=!1})})}(t,e)}),document.querySelectorAll(".hide-button").forEach(t=>{t.addEventListener("click",()=>{let e=t.closest(".mizarWrapper");e&&hg(e,!0)})}),document.querySelectorAll(".show-button").forEach(t=>{t.addEventListener("click",()=>{let e=t.closest(".mizarWrapper");e&&hg(e,!1)})});let e=document.getElementById("hideAllButton"),i=document.getElementById("showAllButton"),s=document.getElementById("resetAllButton");function n(t){document.querySelectorAll(".mizarWrapper").forEach(e=>{hg(e,t)})}e&&i&&(e.addEventListener("click",t=>{n(!0),e.style.display="none",i.style.display="",t.target.blur()}),i.addEventListener("click",t=>{n(!1),i.style.display="none",e.style.display="",t.target.blur()})),s&&s.addEventListener("click",t=>{document.querySelectorAll(".mizarWrapper").forEach(t=>{let e=t.querySelector("button[id^='resetButton']");e&&e.click()}),t.target.blur()})},{once:!0});let hm=th.define(),hw=q.define({create:()=>null,update(t,e){for(let i of e.effects)i.is(hm)&&(t=i.value);return t},provide:t=>nm.from(t,t=>{var e;return t?(e=t,t=>{let i=document.createElement("div");return i.innerHTML=e,i.className="cm-error-panel",{dom:i}}):null})});function hv(t){let e=1;for(let i of hu){let s=hc[i],n=s.state.doc.lines;if(t>=e&&t<e+n)return{editor:s,localLine:t-e+1};e+=n}return null}async function hb(t,e,i){t.eventSource&&t.eventSource.close();let s="content="+encodeURIComponent(hk(t));try{if(!(await fetch(DOKU_BASE+"lib/exe/ajax.php?call=view_compile",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s})).ok)throw Error("Network response was not ok");t.eventSource=new EventSource(DOKU_BASE+"lib/exe/ajax.php?call=view_sse&"+s),t.eventSource.onmessage=function(t){let s=hc[i],n=s.state.field(hw)||"";n+=t.data+"<br>",s.dispatch({effects:e.of(n)}),n.includes("❌")?s.dom.querySelector(".cm-error-panel").style.backgroundColor="#fcc":s.dom.querySelector(".cm-error-panel").style.backgroundColor="#ccffcc"},t.eventSource.addEventListener("compileErrors",function(t){try{let s=JSON.parse(t.data),n=hc[i].state.field(hw)||"",r={};for(let t in s.forEach(function(t){let{line:e,column:i,message:s}=t,o=`<a href="#" class="error-link" data-line="${e}" data-column="${i}">[Ln ${e}, Col ${i}]</a>`;n+=`\u{274C} ${s} ${o}<br>`;let l=hv(e);if(l){let{editor:t,localLine:n}=l,o=t.state.doc.line(n),h=o.from+(i-1),a=h+1;if(h>=o.from&&a<=o.to){let n=eN.mark({class:"error-underline",attributes:{title:`${s} (Ln ${e}, Col ${i})`}}).range(h,a),o=Object.keys(hc).find(e=>hc[e]===t);r[o]||(r[o]=[]),r[o].push(n)}}}),r){let e=hc[t],i=r[t];i.length>0&&e.dispatch({effects:hd.of(i.sort((t,e)=>t.from-e.from))})}hc[i].dispatch({effects:[e.of(n)]}),n.includes("❌")?hc[i].dom.querySelector(".cm-error-panel").style.backgroundColor="#fcc":hc[i].dom.querySelector(".cm-error-panel").style.backgroundColor="#ccffcc",hc[i].dom.querySelector(".cm-error-panel").querySelectorAll(".error-link").forEach(t=>{t.addEventListener("click",function(e){e.preventDefault();let i=parseInt(t.getAttribute("data-line"),10),s=hv(i);if(s){let{editor:t,localLine:e}=s,i=t.state.doc.line(e);t.dispatch({scrollIntoView:{from:i.from,to:i.to}})}})})}catch(e){console.error("Failed to parse error data:",e),console.error("Event data:",t.data)}}),t.eventSource.onerror=()=>{t.eventSource.close(),t.isRequestInProgress=!1,function(t){let e=t.querySelector("[id^='compileButton']"),i=t.querySelector("[id^='resetButton']");e.style.display="none",i.style.display="inline-block",t.isRequestInProgress=!1}(t)}}catch(e){console.error("Fetch error: ",e),t.isRequestInProgress=!1}}async function hy(t,e){let i="content="+encodeURIComponent(hk(t));try{let s=await fetch(DOKU_BASE+"lib/exe/ajax.php?call=view_graph",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i});if(!s.ok)throw Error("network error");let n=await s.json(),r=t.querySelector(`#outputmizarBlock${e}`);n.success?(r.innerHTML=`<div class="graph-wrapper">
2          <button class="close-graph" title="Close">\u{2716}</button>
3          ${n.data.svg}
4        </div>`,r.style.display="block",r.querySelector(".close-graph").addEventListener("click",()=>{r.innerHTML="",r.style.display="none"})):(r.innerHTML=`<pre class="err">${n.data.err}</pre>`,r.style.display="block")}catch(t){console.error(t),alert("Graph generation failed: "+t.message)}}function hk(t){let e="",i=Array.from(document.querySelectorAll(".mizarWrapper")).indexOf(t);for(let t=0;t<=i;t++){let i=hc[hu[t]];i&&i.state&&(e+=i.state.doc.toString()+"\n")}return e.trim()}window.createMizarFile=async function(t){let e=function(){let t="";for(let e of hu){let i=hc[e];i&&i.state&&(t+=i.state.doc.toString()+"\n")}return t}();if(!e)return void console.error("Error: Combined content is empty.");t.endsWith(".miz")||(t+=".miz");try{let i=await fetch(DOKU_BASE+"lib/exe/ajax.php?call=create_combined_file",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"content="+encodeURIComponent(e)+"&filename="+encodeURIComponent(t)});if(!i.ok)return void console.error("Failed to create file: Network response was not ok");let s=await i.json();if(s.success){console.log("File created successfully:",t);let e=new Blob([s.data.content],{type:"application/octet-stream"}),i=URL.createObjectURL(e),n=window.open("","_blank");n.document.write("<pre>"+s.data.content.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")+"</pre>"),n.document.title=t;let r=n.document.createElement("a");r.href=i,r.download=t,r.textContent="⬇️ Click here to download the file",r.style.display="block",r.style.marginTop="10px",n.document.body.appendChild(r),n.addEventListener("unload",()=>{URL.revokeObjectURL(i)})}else console.error("Failed to create file:",s.message)}catch(t){console.error("Error creating file:",t)}},document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".copy-button").forEach(t=>{t.addEventListener("click",t=>{let e=t.currentTarget,i=e.dataset.mizarid,s=i.replace("mizarBlock","");if(!hc[s])return void console.error("エディタが見つかりません: ",i);let n=hc[s].state.doc.toString();navigator.clipboard.writeText(n).then(()=>{e.textContent="Copied!",e.disabled=!0,setTimeout(()=>{e.textContent="Copy",e.disabled=!1},2e3)}).catch(t=>{console.error("コピーに失敗しました: ",t)})})})})})();
5//# sourceMappingURL=script.js.map
6