@bhsd/codemirror-mediawiki 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.min.js +1 -1
  2. package/package.json +1 -1
package/dist/main.min.js CHANGED
@@ -1 +1 @@
1
- var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{a:()=>Uu});var i={};t.r(i),t.d(i,{css:()=>Rl,javascript:()=>dl});class n{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=d(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),s.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=d(this,t,e);let i=[];return this.decompose(t,e,i,0),s.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new l(this),r=new l(t);for(let t=e,s=e;;){if(n.next(t),r.next(t),t=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(s+=n.value.length,n.done||s>=i)return!0}}iter(t=1){return new l(this,t)}iterRange(t,e=this.length){return new h(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new r(t):s.from(r.split(t,[])):n.empty}}class r extends n{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,n){for(let r=0;;r++){let s=this.text[r],o=n+s.length;if((e?i:o)>=t)return new u(n,o,i,s);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new r(a(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new r(e,t.length+s.length));else{let t=e.length>>1;i.push(new r(e.slice(0,t)),new r(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof r))return super.replace(t,e,i);[t,e]=d(this,t,e);let n=o(this.text,o(i.text,a(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new r(n,l):s.from(r.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let r=0,s=0;r<=e&&s<this.text.length;s++){let o=this.text[s],a=r+o.length;r>t&&s&&(n+=i),t<a&&e>r&&(n+=o.slice(Math.max(0,t-r),e-r)),r=a+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new r(i,n)),i=[],n=-1);return n>-1&&e.push(new r(i,n)),e}}class s extends n{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let r=0;;r++){let s=this.children[r],o=n+s.length,a=i+s.lines-1;if((e?a:o)>=t)return s.lineInner(t,e,i,n);n=o+1,i=a+1}}decompose(t,e,i,n){for(let r=0,s=0;s<=e&&r<this.children.length;r++){let o=this.children[r],a=s+o.length;if(t<=a&&e>=s){let r=n&((s<=t?1:0)|(a>=e?2:0));s>=t&&a<=e&&!r?i.push(o):o.decompose(t-s,e-s,i,r)}s=a+1}}replace(t,e,i){if([t,e]=d(this,t,e),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],a=r+o.length;if(t>=r&&e<=a){let l=o.replace(t-r,e-r,i),h=this.lines-o.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let r=this.children.slice();return r[n]=l,new s(r,this.length-(e-t)+i.length)}return super.replace(r,a,l)}r=a+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let r=0,s=0;r<this.children.length&&s<=e;r++){let o=this.children[r],a=s+o.length;s>t&&r&&(n+=i),t<a&&e>s&&(n+=o.sliceString(t-s,e-s,i)),s=a+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof s))return 0;let i=0,[n,r,o,a]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,r+=e){if(n==o||r==a)return i;let s=this.children[n],l=t.children[r];if(s!=l)return i+s.scanIdentical(l,e);i+=s.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 r(i,e)}let n=Math.max(32,i>>5),o=n<<1,a=n>>1,l=[],h=0,c=-1,u=[];function d(t){let e;if(t.lines>o&&t instanceof s)for(let e of t.children)d(e);else t.lines>a&&(h>a||!h)?(f(),l.push(t)):t instanceof r&&h&&(e=u[u.length-1])instanceof r&&t.lines+e.lines<=32?(h+=t.lines,c+=t.length+1,u[u.length-1]=new r(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&f(),h+=t.lines,c+=t.length+1,u.push(t))}function f(){0!=h&&(l.push(1==u.length?u[0]:s.from(u,c)),c=-1,h=u.length=0)}for(let e of t)d(e);return f(),1==l.length?l[0]:new s(l,e)}}function o(t,e,i=0,n=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=n;s++){let a=t[s],l=r+a.length;l>=i&&(l>n&&(a=a.slice(0,n-r)),r<i&&(a=a.slice(i-r)),o?(e[e.length-1]+=a,o=!1):e.push(a)),r=l+1}return e}function a(t,e,i){return o(t,[""],e,i)}n.empty=new r([""],0);class l{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 r?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,a=n instanceof r?n.text.length:n.children.length;if(o==(e>0?a: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&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof r){let r=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,r.length>Math.max(0,t))return this.value=0==t?r:e>0?r.slice(t):r.slice(0,r.length-t),this;t-=r.length}else{let s=n.children[o+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof r?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class h{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new l(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class c{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=h.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function d(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let f="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 t=1;t<f.length;t++)f[t]+=f[t-1];function p(t){for(let e=1;e<f.length;e+=2)if(f[e]>t)return f[e-1]<=t;return!1}function m(t){return t>=127462&&t<=127487}const g=8205;function w(t,e,i=!0,n=!0){return(i?v:b)(t,e,n)}function v(t,e,i){if(e==t.length)return e;e&&k(t.charCodeAt(e))&&y(t.charCodeAt(e-1))&&e--;let n=x(t,e);for(e+=A(n);e<t.length;){let r=x(t,e);if(n==g||r==g||i&&p(r))e+=A(r),n=r;else{if(!m(r))break;{let i=0,n=e-2;for(;n>=0&&m(x(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function b(t,e,i){for(;e>0;){let n=v(t,e-2,i);if(n<e)return n;e--}return 0}function k(t){return t>=56320&&t<57344}function y(t){return t>=55296&&t<56320}function x(t,e){let i=t.charCodeAt(e);if(!y(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return k(n)?n-56320+(i-55296<<10)+65536:i}function S(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function A(t){return t<65536?1:2}const M=/\r\n?|\n/;var C=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(C||(C={}));class T{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,n=0;e<this.sections.length;){let r=this.sections[e++],s=this.sections[e++];s<0?(t(i,n,r),n+=r):n+=s,i+=r}}iterChangedRanges(t,e=!1){E(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new T(t)}composeDesc(t){return this.empty?t:t.empty?this:P(this,t)}mapDesc(t,e=!1){return t.empty?this:B(this,t,e)}mapPos(t,e=-1,i=C.Simple){let n=0,r=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],a=this.sections[s++],l=n+o;if(a<0){if(l>t)return r+(t-n);r+=o}else{if(i!=C.Simple&&l>=t&&(i==C.TrackDel&&n<t&&l>t||i==C.TrackBefore&&n<t||i==C.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?r:r+a;r+=a}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return r}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let r=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&r>=t)return!(n<t&&r>e)||"cover";n=r}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new T(t)}static create(t){return new T(t)}}class D extends T{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return E(this,((e,i,n,r,s)=>t=t.replace(n,n+(i-e),s)),!1),t}mapDesc(t,e=!1){return B(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let r=0,s=0;r<e.length;r+=2){let o=e[r],a=e[r+1];if(a>=0){e[r]=a,e[r+1]=o;let l=r>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(s,s+o):n.empty)}s+=o}return new D(e,i)}compose(t){return this.empty?t:t.empty?this:P(this,t,!0)}map(t,e=!1){return t.empty?this:B(this,t,e,!0)}iterChanges(t,e=!1){E(this,t,e)}get desc(){return T.create(this.sections)}filter(t){let e=[],i=[],n=[],r=new N(this);t:for(let s=0,o=0;;){let a=s==t.length?1e9:t[s++];for(;o<a||o==a&&0==r.len;){if(r.done)break t;let t=Math.min(r.len,a-o);O(n,t,-1);let s=-1==r.ins?-1:0==r.off?r.ins:0;O(e,t,s),s>0&&L(i,e,r.text),r.forward(t),o+=t}let l=t[s++];for(;o<l;){if(r.done)break t;let t=Math.min(r.len,l-o);O(e,t,-1),O(n,t,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(t),o+=t}}return{changes:new D(e,i),filtered:T.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let r=[],s=[],o=0,a=null;function l(t=!1){if(!t&&!r.length)return;o<e&&O(r,e-o,-1);let i=new D(r,s);a=a?a.compose(i.map(a)):i,r=[],s=[],o=0}return function t(h){if(Array.isArray(h))for(let e of h)t(e);else if(h instanceof D){if(h.length!=e)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${e})`);l(),a=a?a.compose(h.map(a)):h}else{let{from:t,to:a=t,insert:c}=h;if(t>a||t<0||a>e)throw new RangeError(`Invalid change range ${t} to ${a} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||M)):c:n.empty,d=u.length;if(t==a&&0==d)return;t<o&&l(),t>o&&O(r,t-o,-1),O(r,a-t,d),L(s,r,u),o=a}}(t),l(!a),a}static empty(t){return new D(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let r=0;r<t.length;r++){let s=t[r];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<r;)i.push(n.empty);i[r]=n.of(s.slice(1)),e.push(s[0],i[r].length)}}}return new D(e,i)}static createSet(t,e){return new D(t,e)}}function O(t,e,i,n=!1){if(0==e&&i<=0)return;let r=t.length-2;r>=0&&i<=0&&i==t[r+1]?t[r]+=e:0==e&&0==t[r]?t[r+1]+=i:n?(t[r]+=e,t[r+1]+=i):t.push(e,i)}function L(t,e,i){if(0==i.length)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<r;)t.push(n.empty);t.push(i)}}function E(t,e,i){let r=t.inserted;for(let s=0,o=0,a=0;a<t.sections.length;){let l=t.sections[a++],h=t.sections[a++];if(h<0)s+=l,o+=l;else{let c=s,u=o,d=n.empty;for(;c+=l,u+=h,h&&r&&(d=d.append(r[a-2>>1])),!(i||a==t.sections.length||t.sections[a+1]<0);)l=t.sections[a++],h=t.sections[a++];e(s,c,o,u,d),s=c,o=u}}}function B(t,e,i,n=!1){let r=[],s=n?[]:null,o=new N(t),a=new N(e);for(let t=-1;;)if(-1==o.ins&&-1==a.ins){let t=Math.min(o.len,a.len);O(r,t,-1),o.forward(t),a.forward(t)}else if(a.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(a.len<o.len||a.len==o.len&&!i))){let e=a.len;for(O(r,a.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(O(r,0,o.ins),s&&L(s,r,o.text),t=o.i),o.forward(i),e-=i}a.next()}else{if(!(o.ins>=0)){if(o.done&&a.done)return s?D.createSet(r,s):T.create(r);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==a.ins){let t=Math.min(i,a.len);e+=t,i-=t,a.forward(t)}else{if(!(0==a.ins&&a.len<i))break;i-=a.len,a.next()}O(r,e,t<o.i?o.ins:0),s&&t<o.i&&L(s,r,o.text),t=o.i,o.forward(o.len-i)}}}function P(t,e,i=!1){let n=[],r=i?[]:null,s=new N(t),o=new N(e);for(let t=!1;;){if(s.done&&o.done)return r?D.createSet(n,r):T.create(n);if(0==s.ins)O(n,s.len,0,t),s.next();else if(0!=o.len||o.done){if(s.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(s.len2,o.len),i=n.length;if(-1==s.ins){let i=-1==o.ins?-1:o.off?0:o.ins;O(n,e,i,t),r&&i&&L(r,n,o.text)}else-1==o.ins?(O(n,s.off?0:s.len,e,t),r&&L(r,n,s.textBit(e))):(O(n,s.off?0:s.len,o.off?0:o.ins,t),r&&!o.off&&L(r,n,o.text));t=(s.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),s.forward2(e),o.forward(e)}}else O(n,0,o.ins,t),r&&L(r,n,o.text),o.next()}}class N{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?n.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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 R{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 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new R(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return z.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return z.range(this.anchor,i)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return z.range(t.anchor,t.head)}static create(t,e,i){return new R(t,e,i)}}class z{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:z.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let e=0;e<this.ranges.length;e++)if(!this.ranges[e].eq(t.ranges[e]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new z([this.main],0)}addRange(t,e=!0){return z.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,z.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 new RangeError("Invalid JSON representation for EditorSelection");return new z(t.ranges.map((t=>R.fromJSON(t))),t.main)}static single(t,e=t){return new z([z.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let r=t[n];if(r.empty?r.from<=i:r.from<i)return z.normalized(t.slice(),e);i=r.to}return new z(t,e)}static cursor(t,e=0,i,n){return R.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let r=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?R.create(e,t,48|r):R.create(t,e,(e>t?8:0)|r)}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 n=t[i],r=t[i-1];if(n.empty?n.from<=r.to:n.from<r.to){let s=r.from,o=Math.max(n.to,r.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?z.range(o,s):z.range(s,o))}}return new z(t,e)}}function I(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=V++,this.default=t([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:W),!!t.static,t.enables)}of(t){return new F([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function W(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class F{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=V++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,r=this.id,s=t[r]>>1,o=2==this.type,a=!1,l=!1,h=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?l=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&h.push(t[i.id]);return{create:t=>(t.values[s]=i(t),1),update(t,e){if(a&&e.docChanged||l&&(e.docChanged||e.selection)||_(t,h)){let e=i(t);if(o?!q(e,t.values[s],n):!n(e,t.values[s]))return t.values[s]=e,1}return 0},reconfigure:(t,e)=>{let a,l=e.config.address[r];if(null!=l){let r=tt(e,l);if(this.dependencies.every((i=>i instanceof H?e.facet(i)===t.facet(i):!(i instanceof $)||e.field(i,!1)==t.field(i,!1)))||(o?q(a=i(t),r,n):n(a=i(t),r)))return t.values[s]=r,0}else a=i(t);return t.values[s]=a,1}}}}function q(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function _(t,e){let i=!1;for(let n of e)1&Q(t,n)&&(i=!0);return i}function j(t,e,i){let n=i.map((e=>t[e.id])),r=i.map((t=>t.type)),s=n.filter((t=>!(1&t))),o=t[e.id]>>1;function a(t){let i=[];for(let e=0;e<n.length;e++){let s=tt(t,n[e]);if(2==r[e])for(let t of s)i.push(t);else i.push(s)}return e.combine(i)}return{create(t){for(let e of n)Q(t,e);return t.values[o]=a(t),1},update(t,i){if(!_(t,s))return 0;let n=a(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,r){let s=_(t,n),l=r.config.facets[e.id],h=r.facet(e);if(l&&!s&&W(i,l))return t.values[o]=h,0;let c=a(t);return e.compare(c,h)?(t.values[o]=h,0):(t.values[o]=c,1)}}}const K=H.define({static:!0});class ${constructor(t,e,i,n,r){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(t){let e=new $(V++,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(K).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 n=t.values[e],r=this.updateF(n,i);return this.compareF(n,r)?0:(t.values[e]=r,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,K.of({field:this,create:t})]}get extension(){return this}}function G(t){return e=>new Y(e,t)}const U={highest:G(0),high:G(1),default:G(2),low:G(3),lowest:G(4)};class Y{constructor(t,e){this.inner=t,this.prec=e}}class J{of(t){return new X(this,t)}reconfigure(t){return J.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class X{constructor(t,e){this.compartment=t,this.inner=e}}class Z{constructor(t,e,i,n,r,s){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=s,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){let n=[],r=Object.create(null),s=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],r=new Map;return function t(s,o){let a=r.get(s);if(null!=a){if(a<=o)return;let t=n[a].indexOf(s);t>-1&&n[a].splice(t,1),s instanceof X&&i.delete(s.compartment)}if(r.set(s,o),Array.isArray(s))for(let e of s)t(e,o);else if(s instanceof X){if(i.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(s.compartment)||s.inner;i.set(s.compartment,n),t(n,o)}else if(s instanceof Y)t(s.inner,s.prec);else if(s instanceof $)n[o].push(s),s.provides&&t(s.provides,o);else if(s instanceof F)n[o].push(s),s.facet.extensions&&t(s.facet.extensions,2);else{let e=s.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);t(e,o)}}(t,2),n.reduce(((t,e)=>t.concat(e)))}(t,e,s))i instanceof $?n.push(i):(r[i.facet.id]||(r[i.facet.id]=[])).push(i);let o=Object.create(null),a=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let h=null==i?void 0:i.config.facets;for(let t in r){let e=r[t],n=e[0].facet,s=h&&h[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=a.length<<1|1,W(s,e))a.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));a.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=a.length<<1|1,a.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>j(t,n,e)))}}let c=l.map((t=>t(o)));return new Z(t,s,c,o,a,r)}}function Q(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let r=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|r}function tt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const et=H.define(),it=H.define({combine:t=>t.some((t=>t)),static:!0}),nt=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),rt=H.define(),st=H.define(),ot=H.define(),at=H.define({combine:t=>!!t.length&&t[0]});class lt{constructor(t,e){this.type=t,this.value=e}static define(){return new ht}}class ht{of(t){return new lt(this,t)}}class ct{constructor(t){this.map=t}of(t){return new ut(this,t)}}class ut{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 ut(this.type,e)}is(t){return this.type==t}static define(t={}){return new ct(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}ut.reconfigure=ut.define(),ut.appendConfig=ut.define();class dt{constructor(t,e,i,n,r,s){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&I(i,e.newLength),r.some((t=>t.type==dt.time))||(this.annotations=r.concat(dt.time.of(Date.now())))}static create(t,e,i,n,r,s){return new dt(t,e,i,n,r,s)}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(dt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function ft(t,e){let i=[];for(let n=0,r=0;;){let s,o;if(n<t.length&&(r==e.length||e[r]>=t[n]))s=t[n++],o=t[n++];else{if(!(r<e.length))return i;s=e[r++],o=e[r++]}!i.length||i[i.length-1]<s?i.push(s,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function pt(t,e,i){var n;let r,s,o;return i?(r=e.changes,s=D.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):null===(n=t.selection)||void 0===n?void 0:n.map(r),effects:ut.mapEffects(t.effects,r).concat(ut.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function mt(t,e,i){let n=e.selection,r=vt(e.annotations);return e.userEvent&&(r=r.concat(dt.userEvent.of(e.userEvent))),{changes:e.changes instanceof D?e.changes:D.of(e.changes||[],i,t.facet(nt)),selection:n&&(n instanceof z?n:z.single(n.anchor,n.head)),effects:vt(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function gt(t,e,i){let n=mt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let r=1;r<e.length;r++){!1===e[r].filter&&(i=!1);let s=!!e[r].sequential;n=pt(n,mt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let r=dt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(ot),n=t;for(let r=i.length-1;r>=0;r--){let s=i[r](t);s&&Object.keys(s).length&&(n=pt(n,mt(e,s,t.changes.newLength),!0))}return n==t?t:dt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(rt)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:ft(i,e))}if(!0!==i){let n,r;if(!1===i)r=t.changes.invertedDesc,n=D.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,r=e.filtered.mapDesc(e.changes).invertedDesc}t=dt.create(e,n,t.selection&&t.selection.map(r),ut.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let n=e.facet(st);for(let i=n.length-1;i>=0;i--){let r=n[i](t);t=r instanceof dt?r:Array.isArray(r)&&1==r.length&&r[0]instanceof dt?r[0]:gt(e,vt(r),!1)}return t}(r):r)}dt.time=lt.define(),dt.userEvent=lt.define(),dt.addToHistory=lt.define(),dt.remote=lt.define();const wt=[];function vt(t){return null==t?wt:Array.isArray(t)?t:[t]}var bt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(bt||(bt={}));const kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let yt;try{yt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}class xt{constructor(t,e,i,n,r,s){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Q(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Q(this,i),tt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return gt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:r}=i;for(let e of t.effects)e.is(J.reconfigure)?(i&&(r=new Map,i.compartments.forEach(((t,e)=>r.set(e,t))),i=null),r.set(e.value.compartment,e.value.extension)):e.is(ut.reconfigure)?(i=null,n=e.value):e.is(ut.appendConfig)&&(i=null,n=vt(n).concat(e.value));i?e=t.startState.values.slice():(i=Z.resolve(n,r,this),e=new xt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values);let s=t.startState.facet(it)?t.newSelection:t.newSelection.asSingle();new xt(i,t.newDoc,s,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:z.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),r=[i.range],s=vt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),a=this.changes(o.changes),l=a.map(n);for(let t=0;t<i;t++)r[t]=r[t].map(l);let h=n.mapDesc(a,!0);r.push(o.range.map(h)),n=n.compose(l),s=ut.mapEffects(s,l).concat(ut.mapEffects(vt(o.effects),h))}return{changes:n,selection:z.create(r,e.mainIndex),effects:s}}changes(t=[]){return t instanceof D?t:D.of(t,this.doc.length,this.facet(xt.lineSeparator))}toText(t){return n.of(t.split(this.facet(xt.lineSeparator)||M))}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:(Q(this,e),tt(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof $&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let r=i[e],s=t[e];n.push(r.init((t=>r.spec.fromJSON(s,t))))}return xt.create({doc:t.doc,selection:z.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Z.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(xt.lineSeparator)||M)),r=t.selection?t.selection instanceof z?t.selection:z.single(t.selection.anchor,t.selection.head):z.single(0);return I(r,i.length),e.staticFacet(it)||(r=r.asSingle()),new xt(e,i,r,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(xt.tabSize)}get lineBreak(){return this.facet(xt.lineSeparator)||"\n"}get readOnly(){return this.facet(at)}phrase(t,...e){for(let e of this.facet(xt.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 n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let r of this.facet(et))for(let s of r(this,e,i))Object.prototype.hasOwnProperty.call(s,t)&&n.push(s[t]);return n}charCategorizer(t){return e=this.languageDataAt("wordChars",t).join(""),t=>{if(!/\S/.test(t))return bt.Space;if(function(t){if(yt)return yt.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||kt.test(i)))return!0}return!1}(t))return bt.Word;for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>-1)return bt.Word;return bt.Other};var e}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),r=this.charCategorizer(t),s=t-i,o=t-i;for(;s>0;){let t=w(e,s,!1);if(r(e.slice(t,s))!=bt.Word)break;s=t}for(;o<n;){let t=w(e,o);if(r(e.slice(o,t))!=bt.Word)break;o=t}return s==o?null:z.range(s+i,o+i)}}function St(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let r=e[t],s=n[t];if(void 0===s)n[t]=r;else if(s===r||void 0===r);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](s,r)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}xt.allowMultipleSelections=it,xt.tabSize=H.define({combine:t=>t.length?t[0]:4}),xt.lineSeparator=nt,xt.readOnly=at,xt.phrases=H.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),xt.languageData=et,xt.changeFilter=rt,xt.transactionFilter=st,xt.transactionExtender=ot,J.reconfigure=ut.define();class At{eq(t){return this==t}range(t,e=t){return Mt.create(t,e,this)}}At.prototype.startSide=At.prototype.endSide=0,At.prototype.point=!1,At.prototype.mapMode=C.TrackDel;class Mt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Mt(t,e,i)}}function Ct(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Tt{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let r=i?this.to:this.from;for(let s=n,o=r.length;;){if(s==o)return s;let n=s+o>>1,a=r[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==s)return a>=0?s:o;a>=0?o=n:s=n+1}}between(t,e,i,n){for(let r=this.findIndex(e,-1e9,!0),s=this.findIndex(i,1e9,!1,r);r<s;r++)if(!1===n(this.from[r]+t,this.to[r]+t,this.value[r]))return!1}map(t,e){let i=[],n=[],r=[],s=-1,o=-1;for(let a=0;a<this.value.length;a++){let l,h,c=this.value[a],u=this.from[a]+t,d=this.to[a]+t;if(u==d){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=h=t,c.startSide!=c.endSide&&(h=e.mapPos(u,c.endSide),h<l))continue}else if(l=e.mapPos(u,c.startSide),h=e.mapPos(d,c.endSide),l>h||l==h&&c.startSide>0&&c.endSide<=0)continue;(h-l||c.endSide-c.startSide)<0||(s<0&&(s=l),c.point&&(o=Math.max(o,h-l)),i.push(c),n.push(l-s),r.push(h-s))}return{mapped:i.length?new Tt(n,r,i,o):null,pos:s}}}class Dt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Dt(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=t,s=t.filter;if(0==e.length&&!s)return this;if(i&&(e=e.slice().sort(Ct)),this.isEmpty)return e.length?Dt.of(e):this;let o=new Et(this,null,-1).goto(0),a=0,l=[],h=new Ot;for(;o.value||a<e.length;)if(a<e.length&&(o.from-e[a].from||o.startSide-e[a].value.startSide)>=0){let t=e[a++];h.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(a==e.length||this.chunkEnd(o.chunkIndex)<e[a].from)&&(!s||n>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||n>o.to||r<o.from||s(o.from,o.to,o.value))&&(h.addInner(o.from,o.to,o.value)||l.push(Mt.create(o.from,o.to,o.value))),o.next());return h.finishInner(this.nextLayer.isEmpty&&!l.length?Dt.empty:this.nextLayer.update({add:l,filter:s,filterFrom:n,filterTo:r}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],a=t.touchesRange(s,s+o.length);if(!1===a)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===a){let{mapped:r,pos:a}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(a))}}let r=this.nextLayer.map(t);return 0==e.length?r:new Dt(i,e,r||Dt.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],s=this.chunk[n];if(e>=r&&t<=r+s.length&&!1===s.between(r,t-r,e-r,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Bt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Bt.from(t).goto(e)}static compare(t,e,i,n,r=-1){let s=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r)),a=Lt(s,o,i),l=new Nt(s,a,r),h=new Nt(o,a,r);i.iterGaps(((t,e,i)=>Rt(l,t,h,e,i,n))),i.empty&&0==i.length&&Rt(l,0,h,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let r=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),s=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=Lt(r,s),a=new Nt(r,o,0).goto(i),l=new Nt(s,o,0).goto(i);for(;;){if(a.to!=l.to||!zt(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>n)return!0;a.next(),l.next()}}static spans(t,e,i,n,r=-1){let s=new Nt(t,null,r).goto(e),o=e,a=s.openStart;for(;;){let t=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),r=s.pointFrom<e?i.length+1:Math.min(i.length,a);n.point(o,t,s.point,i,r,s.pointRank),a=Math.min(s.openEnd(t),i.length)}else t>o&&(n.span(o,t,s.active,a),a=s.openEnd(t));if(s.to>i)return a+(s.point&&s.to>i?1:0);o=s.to,s.next()}}static of(t,e=!1){let i=new Ot;for(let n of t instanceof Mt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Ct(e,n)>0)return t.slice().sort(Ct);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Dt.empty=new Dt([],[],null,-1),Dt.empty.nextLayer=Dt.empty;class Ot{finishChunk(t){this.chunks.push(new Tt(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 Ot)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Dt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Dt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Lt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let r=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let s=n.get(t.chunk[e]);null==s||(i?i.mapPos(s):s)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(s,s+t.chunk[e].length))||r.add(t.chunk[e])}return r}class Et{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let 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 n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{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 Bt{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let r=0;r<t.length;r++)for(let s=t[r];!s.isEmpty;s=s.nextLayer)s.maxPoint>=i&&n.push(new Et(s,e,i,r));return 1==n.length?n[0]:new Bt(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Pt(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--)Pt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&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(),Pt(this.heap,0)}}}function Pt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let r=t[n];if(n+1<t.length&&r.compare(t[n+1])>=0&&(r=t[n+1],n++),i.compare(r)<0)break;t[n]=i,t[e]=r,e=n}}class Nt{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=Bt.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){It(this.active,t),It(this.activeTo,t),It(this.activeRank,t),this.minActive=Ht(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:r}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=r;)e++;Vt(this.active,e,i),Vt(this.activeTo,e,n),Vt(this.activeRank,e,r),t&&Vt(t,e,this.cursor.from),this.minActive=Ht(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&It(i,n)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){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}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}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 Rt(t,e,i,n,r,s){t.goto(e),i.goto(n);let o=n+r,a=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,r=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&zt(t.activeForPoint(t.to),i.activeForPoint(i.to))||s.comparePoint(a,r,t.point,i.point):r>a&&!zt(t.active,i.active)&&s.compareRange(a,r,t.active,i.active),n>o)break;a=n,e<=0&&t.next(),e>=0&&i.next()}}function zt(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 It(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Vt(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function Ht(t,e){let i=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||t[r].endSide-t[i].endSide)<0&&(i=r,n=e[r]);return i}function Wt(t,e,i=t.length){let n=0;for(let r=0;r<i;)9==t.charCodeAt(r)?(n+=e-n%e,r++):(n++,r=w(t,r));return n}const Ft="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),qt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),_t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class jt{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function r(t,e,s,o){let a=[],l=/^@(\w+)\b/.exec(t[0]),h=l&&"keyframes"==l[1];if(l&&null==e)return s.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))r(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,s);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");r(n(i),o,a,h)}else null!=o&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(a.length||h)&&s.push((!i||l||o?t:t.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let e in t)r(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=_t[Ft]||1;return _t[Ft]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[qt],r=i&&i.nonce;n?r&&n.setNonce(r):n=new $t(t,r),n.mount(Array.isArray(e)?e:[e])}}let Kt=new Map;class $t{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=Kt.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[qt]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],Kt.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[qt]=this}mount(t){let e=this.sheet,i=0,n=0;for(let r=0;r<t.length;r++){let s=t[r],o=this.modules.indexOf(s);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,s),e)for(let t=0;t<s.rules.length;t++)e.insertRule(s.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=s.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}for(var Gt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ut={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Yt="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Jt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Xt=0;Xt<10;Xt++)Gt[48+Xt]=Gt[96+Xt]=String(Xt);for(Xt=1;Xt<=24;Xt++)Gt[Xt+111]="F"+Xt;for(Xt=65;Xt<=90;Xt++)Gt[Xt]=String.fromCharCode(Xt+32),Ut[Xt]=String.fromCharCode(Xt);for(var Zt in Gt)Ut.hasOwnProperty(Zt)||(Ut[Zt]=Gt[Zt]);function Qt(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function te(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function ee(t,e){if(!e.anchorNode)return!1;try{return te(t,e.anchorNode)}catch(t){return!1}}function ie(t){return 3==t.nodeType?pe(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function ne(t,e,i,n){return!!i&&(se(t,e,i,n,-1)||se(t,e,i,n,1))}function re(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function se(t,e,i,n,r){for(;;){if(t==i&&e==n)return!0;if(e==(r<0?0:oe(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=re(t)+(r<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(r<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=r<0?oe(t):0}}}function oe(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function ae(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function le(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function he(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class ce{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?oe(e):0),i,Math.min(t.focusOffset,i?oe(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let ue,de=null;function fe(t){if(t.setActive)return t.setActive();if(de)return t.focus(de);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==de?{get preventScroll(){return de={preventScroll:!0},!0}}:void 0),!de){de=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],r=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=r&&(i.scrollLeft=r)}}}function pe(t,e,i=e){let n=ue||(ue=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function me(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},r=new KeyboardEvent("keydown",n);r.synthetic=!0,t.dispatchEvent(r);let s=new KeyboardEvent("keyup",n);return s.synthetic=!0,t.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function ge(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function we(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}class ve{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new ve(t.parentNode,re(t),e)}static after(t,e){return new ve(t.parentNode,re(t)+1,e)}}const be=[];class ke{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 new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,r=null;for(let s of this.children){if(7&s.flags){if(!s.dom&&(i=r?r.nextSibling:n.firstChild)){let t=ke.get(i);(!t||!t.parent&&t.canReuseDOM(s))&&s.reuseDOM(i)}s.sync(t,e),s.flags&=-8}if(i=r?r.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=s.dom&&(e.written=!0),s.dom.parentNode==n)for(;i&&i!=s.dom;)i=ye(i);else n.insertBefore(s.dom,i);r=s.dom}for(i=r?r.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=ye(i)}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 n=0==oe(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!ke.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,r=-1,s=-1,o=-1;for(let a=0,l=i,h=i;a<this.children.length;a++){let i=this.children[a],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=a,r=l),l>e&&i.dom.parentNode==this.dom){s=a,o=h;break}h=c,l=c+i.breakAfter}return{from:r,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].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=be){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}this.children.splice(t,e-t,...i);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 xe(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,n,r,s){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function ye(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ke.prototype.breakAfter=0;class xe{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 Se(t,e,i,n,r,s,o,a,l){let{children:h}=t,c=h.length?h[e]:null,u=s.length?s[s.length-1]:null,d=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!d&&s.length<2&&c.merge(i,r,s.length?u:null,0==i,a,l))){if(n<h.length){let t=h[n];t&&(r<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(r),r=0),!d&&u&&t.merge(0,r,u,!0,0,l)?s[s.length-1]=t:((r||t.children.length&&!t.children[0].length)&&t.merge(0,r,null,!1,0,l),s.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&s.length&&c.merge(i,c.length,s[0],!1,a,0)?c.breakAfter=s.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,a,0),e++));e<n&&s.length;)if(h[n-1].become(s[s.length-1]))n--,s.pop(),l=s.length?0:a;else{if(!h[e].become(s[0]))break;e++,s.shift(),a=s.length?0:l}!s.length&&e&&n<h.length&&!h[e-1].breakAfter&&h[n].merge(0,0,h[e-1],!1,a,l)&&e--,(e<n||s.length)&&t.replaceChildren(e,n,s)}}function Ae(t,e,i,n,r,s){let o=t.childCursor(),{i:a,off:l}=o.findPos(i,1),{i:h,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,Se(t,h,c,a,l,n,0,r,s)}let Me="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Ce="undefined"!=typeof document?document:{documentElement:{style:{}}};const Te=/Edge\/(\d+)/.exec(Me.userAgent),De=/MSIE \d/.test(Me.userAgent),Oe=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Me.userAgent),Le=!!(De||Oe||Te),Ee=!Le&&/gecko\/(\d+)/i.test(Me.userAgent),Be=!Le&&/Chrome\/(\d+)/.exec(Me.userAgent),Pe="webkitFontSmoothing"in Ce.documentElement.style,Ne=!Le&&/Apple Computer/.test(Me.vendor),Re=Ne&&(/Mobile\/\w+/.test(Me.userAgent)||Me.maxTouchPoints>2);var ze={mac:Re||/Mac/.test(Me.platform),windows:/Win/.test(Me.platform),linux:/Linux|X11/.test(Me.platform),ie:Le,ie_version:De?Ce.documentMode||6:Oe?+Oe[1]:Te?+Te[1]:0,gecko:Ee,gecko_version:Ee?+(/Firefox\/(\d+)/.exec(Me.userAgent)||[0,0])[1]:0,chrome:!!Be,chrome_version:Be?+Be[1]:0,ios:Re,android:/Android\b/.test(Me.userAgent),webkit:Pe,safari:Ne,webkit_version:Pe?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=Ce.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Ie extends ke{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 Ie)||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 Ie(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 ve(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 n=t.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;0==e&&i<0||e==n&&i>=0?ze.chrome||ze.gecko||(e?(r--,o=1):s<n&&(s++,o=-1)):i<0?r--:s<n&&s++;let a=pe(t,r,s).getClientRects();if(!a.length)return null;let l=a[(o?o<0:i>=0)?0:a.length-1];return ze.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(a,(t=>t.width))||l),o?ae(l,o<0):l||null}(this.dom,t,e)}}class Ve extends ke{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(ge(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)&&!(8&(this.flags|t.flags))}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,n,r,s){return!(i&&(!(i instanceof Ve&&i.mark.eq(this.mark))||t&&r<=0||e<this.length&&s<=0)||(Ae(this,t,e,i?i.children.slice():[],r-1,s-1),this.markDirty(),0))}split(t){let e=[],i=0,n=-1,r=0;for(let s of this.children){let o=i+s.length;o>t&&e.push(i<t?s.split(t-i):s),n<0&&i>=t&&(n=r),i=o,r++}let s=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Ve(this.mark,e,s)}domAtPos(t){return Fe(this,t)}coordsAt(t,e){return _e(this,t,e)}}class He extends ke{static create(t,e,i){return new He(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=He.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.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,r,s){return!(i&&(!(i instanceof He&&this.widget.compare(i.widget))||t>0&&r<=0||e<this.length&&s<=0)||(this.length=t+(i?i.length:0)+(this.length-e),0))}become(t){return t instanceof He&&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 n.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,r=this.posAtStart;return i?i.slice(r,r+this.length):n.empty}domAtPos(t){return(this.length?0==t:this.side>0)?ve.before(this.dom):ve.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 n=this.dom.getClientRects(),r=null;if(!n.length)return null;let s=this.side?this.side<0:t>0;for(let e=s?n.length-1:0;r=n[e],!(t>0?0==e:e==n.length-1||r.top<r.bottom);e+=s?-1:1);return ae(r,!s)}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 We extends ke{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof We&&t.side==this.side}split(){return new We(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?ve.before(this.dom):ve.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return n.empty}get isHidden(){return!0}}function Fe(t,e){let i=t.dom,{children:n}=t,r=0;for(let t=0;r<n.length;r++){let s=n[r],o=t+s.length;if(!(o==t&&s.getSide()<=0)){if(e>t&&e<o&&s.dom.parentNode==i)return s.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=r;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=r;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new ve(i,0)}function qe(t,e,i){let n,{children:r}=t;i>0&&e instanceof Ve&&r.length&&(n=r[r.length-1])instanceof Ve&&n.mark.eq(e.mark)?qe(n,e.children[0],i-1):(r.push(e),e.setParent(t)),t.length+=e.length}function _e(t,e,i){let n=null,r=-1,s=null,o=-1;!function t(e,a){for(let l=0,h=0;l<e.children.length&&h<=a;l++){let c=e.children[l],u=h+c.length;u>=a&&(c.children.length?t(c,a-h):(!s||s.isHidden&&i>0)&&(u>a||h==u&&c.getSide()>0)?(s=c,o=a-h):(h<a||h==u&&c.getSide()<0&&!c.isHidden)&&(n=c,r=a-h)),h=u}}(t,e);let a=(i<0?n:s)||n||s;return a?a.coordsAt(Math.max(0,a==n?r:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=ie(e);return i[i.length-1]||null}(t)}function je(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}Ie.prototype.children=He.prototype.children=We.prototype.children=be;const Ke=Object.create(null);function $e(t,e,i){if(t==e)return!0;t||(t=Ke),e||(e=Ke);let n=Object.keys(t),r=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=r.length-(i&&r.indexOf(i)>-1?1:0))return!1;for(let s of n)if(s!=i&&(-1==r.indexOf(s)||t[s]!==e[s]))return!1;return!0}function Ge(t,e,i){let n=!1;if(e)for(let r in e)i&&r in i||(n=!0,"style"==r?t.style.cssText="":t.removeAttribute(r));if(i)for(let r in i)e&&e[r]==i[r]||(n=!0,"style"==r?t.style.cssText=i[r]:t.setAttribute(r,i[r]));return n}function Ue(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class Ye extends ke{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,r,s){if(i){if(!(i instanceof Ye))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Ae(this,t,e,i?i.children.slice():[],r,s),!0}split(t){let e=new Ye;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,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){$e(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){qe(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=je(e,this.attrs||{})),i&&(this.attrs=je({class:i},this.attrs||{}))}domAtPos(t){return Fe(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(ge(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&&(Ge(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&ke.get(n)instanceof Ve;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=ke.get(n))||void 0===i?void 0:i.isEditable)||ze.ios&&this.children.some((t=>t instanceof Ie))))){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,e=0;for(let i of this.children){if(!(i instanceof Ie)||/[^ -~]/.test(i.text))return null;let n=ie(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=_e(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let r=t.children[i],s=n+r.length;if(s>=e){if(r instanceof Ye)return r;if(s>e)break}n=s+r.breakAfter}return null}}class Je extends ke{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,r,s){return!(i&&(!(i instanceof Je&&this.widget.compare(i.widget))||t>0&&r<=0||e<this.length&&s<=0)||(this.length=t+(i?i.length:0)+(this.length-e),0))}domAtPos(t){return 0==t?ve.before(this.dom):ve.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Je(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return be}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.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):n.empty}domBoundsAround(){return null}become(t){return t instanceof Je&&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){return this.widget.coordsAt(this.dom,t,e)}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 Xe{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}destroy(t){}}var Ze=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Ze||(Ze={}));class Qe extends At{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new ti(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 ii(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:r,end:s}=ni(t,n);e=(r?n?-3e8:-1:5e8)-1,i=1+(s?n?2e8:1:-6e8)}return new ii(t,e,i,n,t.widget||null,!0)}static line(t){return new ei(t)}static set(t,e=!1){return Dt.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Qe.none=Dt.empty;class ti extends Qe{constructor(t){let{start:e,end:i}=ni(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 ti&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&$e(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}ti.prototype.point=!1;class ei extends Qe{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof ei&&this.spec.class==t.spec.class&&$e(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}ei.prototype.mapMode=C.TrackBefore,ei.prototype.point=!0;class ii extends Qe{constructor(t,e,i,n,r,s){super(e,i,r,t),this.block=n,this.isReplace=s,this.mapMode=n?e<=0?C.TrackBefore:C.TrackAfter:C.TrackDel}get type(){return this.startSide!=this.endSide?Ze.WidgetRange:this.startSide<=0?Ze.WidgetBefore:Ze.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof ii&&((e=this.widget)==(i=t.widget)||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function ni(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function ri(t,e,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=t?i[r]=Math.max(i[r],e):i.push(t,e)}ii.prototype.point=!0;class si{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,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 Je&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ye),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(oi(new We(-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 Je||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new 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 n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(oi(new Ie(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,r,s){if(this.disallowBlockEffectsFor[s]&&i instanceof ii){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=e-t;if(i instanceof ii)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Je(i.widget||new ai("div"),o,i));else{let s=He.create(i.widget||new ai("span"),o,o?0:i.startSide),a=this.atCursorPos&&!s.isEditable&&r<=n.length&&(t<e||i.startSide>0),l=!s.isEditable&&(t<e||r>n.length||i.startSide<=0),h=this.getLine();2!=this.pendingBuffer||a||s.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),a&&(h.append(oi(new We(1),n),r),r=n.length+Math.max(0,r-n.length)),h.append(oi(s,n),r),this.atCursorPos=l,this.pendingBuffer=l?t<e||r>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.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=r)}static build(t,e,i,n,r){let s=new si(t,e,i,r);return s.openEnd=Dt.spans(n,e,i,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}}function oi(t,e){for(let i of e)t=new Ve(i,[t],t.length);return t}class ai extends Xe{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}}const li=H.define(),hi=H.define(),ci=H.define(),ui=H.define(),di=H.define(),fi=H.define(),pi=H.define(),mi=H.define({combine:t=>t.some((t=>t))}),gi=H.define({combine:t=>t.some((t=>t))});class wi{constructor(t,e="nearest",i="nearest",n=5,r=5,s=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=s}map(t){return t.empty?this:new wi(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 wi(z.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const vi=ut.define({map:(t,e)=>t.map(e)});function bi(t,e,i){let n=t.facet(ui);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const ki=H.define({combine:t=>!t.length||t[0]});let yi=0;const xi=H.define();class Si{constructor(t,e,i,n,r){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=r(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:r,decorations:s}=e||{};return new Si(yi++,t,i,n,(t=>{let e=[xi.of(t)];return s&&e.push(Ti.of((e=>{let i=e.plugin(t);return i?s(i):Qe.none}))),r&&e.push(r(t)),e}))}static fromClass(t,e){return Si.define((e=>new t(e)),e)}}class Ai{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(bi(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.create(t)}catch(e){bi(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){bi(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Mi=H.define(),Ci=H.define(),Ti=H.define(),Di=H.define(),Oi=H.define();function Li(t,e,i){let n=t.state.facet(Oi);if(!n.length)return n;let r=n.map((e=>e instanceof Function?e(t):e)),s=[];return Dt.spans(r,e,i,{point(){},span(t,e,i,n){let r=s;for(let s=i.length-1;s>=0;s--,n--){let o,a=i[s].spec.bidiIsolate;if(null!=a)if(n>0&&r.length&&(o=r[r.length-1]).to==t&&o.direction==a)o.to=e,r=o.inner;else{let i={from:t,to:e,direction:a,inner:[]};r.push(i),r=i.inner}}}}),s}const Ei=H.define();function Bi(t){let e=0,i=0,n=0,r=0;for(let s of t.state.facet(Ei)){let o=s(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:e,right:i,top:n,bottom:r}}const Pi=H.define();class Ni{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Ni(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,r=0,s=0,o=0;;n++){let a=n==t.length?null:t[n],l=s-o,h=a?a.fromB:1e9;for(;r<e.length&&e[r]<h;){let t=e[r],n=e[r+1],s=Math.max(o,t),a=Math.min(h,n);if(s<=a&&new Ni(s+l,a+l,s,a).addToSet(i),n>h)break;r+=2}if(!a)return i;new Ni(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),s=a.toA,o=a.toB}}}class Ri{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=D.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,r)=>n.push(new Ni(t,e,i,r)))),this.changedRanges=n}static create(t,e,i){return new Ri(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&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}}var zi=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(zi||(zi={}));const Ii=zi.LTR,Vi=zi.RTL;function Hi(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Wi=Hi("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Fi=Hi("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),qi=Object.create(null),_i=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);qi[e]=i,qi[i]=-e}const ji=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ki{get dir(){return this.level%2?Vi:Ii}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}static find(t,e,i,n){let r=-1;for(let s=0;s<t.length;s++){let o=t[s];if(o.from<=e&&o.to>=e){if(o.level==i)return s;(r<0||(0!=n?n<0?o.from<e:o.to>e:t[r].level>o.level))&&(r=s)}}if(r<0)throw new RangeError("Index out of range");return r}}function $i(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!$i(n.inner,r.inner))return!1}return!0}const Gi=[];function Ui(t,e,i,n,r,s,o){let a=n%2?2:1;if(n%2==r%2)for(let l=e,h=0;l<i;){let e=!0,c=!1;if(h==s.length||l<s[h].from){let t=Gi[l];t!=a&&(e=!1,c=16==t)}let u=e||1!=a?null:[],d=e?n:n+1,f=l;t:for(;;)if(h<s.length&&f==s[h].from){if(c)break t;let p=s[h];if(!e)for(let t=p.to,e=h+1;;){if(t==i)break t;if(!(e<s.length&&s[e].from==t)){if(Gi[t]==a)break t;break}t=s[e++].to}h++,u?u.push(p):(p.from>l&&o.push(new Ki(l,p.from,d)),Yi(t,p.direction==Ii!=!(d%2)?n+1:n,r,p.inner,p.from,p.to,o),l=p.to),f=p.to}else{if(f==i||(e?Gi[f]!=a:Gi[f]==a))break;f++}u?Ui(t,l,f,n+1,r,u,o):l<f&&o.push(new Ki(l,f,d)),l=f}else for(let l=i,h=s.length;l>e;){let i=!0,c=!1;if(!h||l>s[h-1].to){let t=Gi[l-1];t!=a&&(i=!1,c=16==t)}let u=i||1!=a?null:[],d=i?n:n+1,f=l;t:for(;;)if(h&&f==s[h-1].to){if(c)break t;let p=s[--h];if(!i)for(let t=p.from,i=h;;){if(t==e)break t;if(!i||s[i-1].to!=t){if(Gi[t-1]==a)break t;break}t=s[--i].from}u?u.push(p):(p.to<l&&o.push(new Ki(p.to,l,d)),Yi(t,p.direction==Ii!=!(d%2)?n+1:n,r,p.inner,p.from,p.to,o),l=p.from),f=p.from}else{if(f==e||(i?Gi[f-1]!=a:Gi[f-1]==a))break;f--}u?Ui(t,f,l,n+1,r,u,o):f<l&&o.push(new Ki(f,l,d)),l=f}}function Yi(t,e,i,n,r,s,o){let a=e%2?2:1;!function(t,e,i,n,r){for(let o=0;o<=n.length;o++){let a=o?n[o-1].to:e,l=o<n.length?n[o].from:i,h=o?256:r;for(let e=a,i=h,n=h;e<l;e++){let r=(s=t.charCodeAt(e))<=247?Wi[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?Fi[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1;512==r?r=i:8==r&&4==n&&(r=16),Gi[e]=4==r?2:r,7&r&&(n=r),i=r}for(let t=a,e=h,n=h;t<l;t++){let r=Gi[t];if(128==r)t<l-1&&e==Gi[t+1]&&24&e?r=Gi[t]=e:Gi[t]=256;else if(64==r){let r=t+1;for(;r<l&&64==Gi[r];)r++;let s=t&&8==e||r<i&&8==Gi[r]?1==n?1:8:256;for(let e=t;e<r;e++)Gi[e]=s;t=r-1}else 8==r&&1==n&&(Gi[t]=1);e=r,7&r&&(n=r)}}var s}(t,r,s,n,a),function(t,e,i,n,r){let s=1==r?2:1;for(let o=0,a=0,l=0;o<=n.length;o++){let h=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=h;o<c;o++)if(i=qi[e=t.charCodeAt(o)])if(i<0){for(let t=a-3;t>=0;t-=3)if(_i[t+1]==-i){let e=_i[t+2],i=2&e?r:4&e?1&e?s:r:0;i&&(Gi[o]=Gi[_i[t]]=i),a=t;break}}else{if(189==_i.length)break;_i[a++]=o,_i[a++]=e,_i[a++]=l}else if(2==(n=Gi[o])||1==n){let t=n==r;l=t?0:1;for(let e=a-3;e>=0;e-=3){let i=_i[e+2];if(2&i)break;if(t)_i[e+2]|=2;else{if(4&i)break;_i[e+2]|=4}}}}}(t,r,s,n,a),function(t,e,i,n){for(let r=0,s=n;r<=i.length;r++){let o=r?i[r-1].to:t,a=r<i.length?i[r].from:e;for(let l=o;l<a;){let o=Gi[l];if(256==o){let o=l+1;for(;;)if(o==a){if(r==i.length)break;o=i[r++].to,a=r<i.length?i[r].from:e}else{if(256!=Gi[o])break;o++}let h=1==s,c=h==(1==(o<e?Gi[o]:n))?h?1:2:n;for(let e=o,n=r,s=n?i[n-1].to:t;e>l;)e==s&&(e=i[--n].from,s=n?i[n-1].to:t),Gi[--e]=c;l=o}else s=o,l++}}}(r,s,n,a),Ui(t,r,s,e,i,n,o)}function Ji(t){return[new Ki(0,t,0)]}let Xi="";function Zi(t,e,i,n,r){var s;let o=n.head-t.from,a=-1;if(0==o){if(!r||!t.length)return null;e[0].level!=i&&(o=e[0].side(!1,i),a=0)}else if(o==t.length){if(r)return null;let t=e[e.length-1];t.level!=i&&(o=t.side(!0,i),a=e.length-1)}a<0&&(a=Ki.find(e,o,null!==(s=n.bidiLevel)&&void 0!==s?s:-1,n.assoc));let l=e[a];o==l.side(r,i)&&(l=e[a+=r?1:-1],o=l.side(!r,i));let h=r==(l.dir==i),c=w(t.text,o,h);if(Xi=t.text.slice(Math.min(o,c),Math.max(o,c)),c>l.from&&c<l.to)return z.cursor(c+t.from,h?-1:1,l.level);let u=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return u||l.level==i?u&&u.level<l.level?z.cursor(u.side(!r,i)+t.from,r?1:-1,u.level):z.cursor(c+t.from,r?-1:1,l.level):z.cursor(r?t.to:t.from,r?-1:1,i)}class Qi extends ke{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Ye],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ni(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.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);let n=-1;this.view.inputState.composing>=0&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;return e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)})),i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let r=n>-1?function(t,e,i){let n=en(t,i);if(!n)return null;let{node:r,from:s,to:o}=n,a=r.nodeValue;if(/[\n\r]/.test(a))return null;if(t.state.doc.sliceString(n.from,n.to)!=a)return null;let l=e.invertedDesc,h=new Ni(l.mapPos(s),l.mapPos(o),s,o),c=[];for(let e=r.parentNode;;e=e.parentNode){let i=ke.get(e);if(i instanceof Ve)c.push({node:e,deco:i.mark});else{if(i instanceof Ye||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:h,text:r,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new ti({inclusive:!0,attributes:Ue(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Ni(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(ze.ie||ze.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let s=function(t,e,i){let n=new rn;return Dt.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=Ni.extendWithRanges(i,s),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,r),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=ze.chrome||ze.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof Je&&t.widget instanceof tn&&r.push(t.dom);n.updateGaps(r)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,r=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let s,o,a,l,{fromA:h,toA:c,fromB:u,toB:d}=e;if(i&&i.range.fromB<d&&i.range.toB>u){let t=si.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=si.build(this.view.state.doc,i.range.toB,d,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,a=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),s=t.content.concat(n).concat(e.content)}else({content:s,breakAtStart:o,openStart:a,openEnd:l}=si.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=r.findPos(c,1),{i:m,off:g}=r.findPos(h,-1);Se(this,m,g,f,p,s,o,a,l)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new Ie(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new Ve(i,[e],e.length);let i=new Ye;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=ke.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let r=t.marks.length-1;r>=-1;r--)i=n.childPos(i.off,1),n=n.children[i.i],e(r>=0?t.marks[r].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,r=!n&&ee(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||r))return;let s=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(o.anchor)),l=o.empty?a:this.moveToLine(this.domAtPos(o.head));if(ze.gecko&&o.empty&&!this.hasComposition&&1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore((()=>a.node.insertBefore(t,a.node.childNodes[a.offset]||null))),a=l=new ve(t,0),s=!0}var h;let c=this.view.observer.selectionRange;!s&&c.focusNode&&ne(a.node,a.offset,c.anchorNode,c.anchorOffset)&&ne(l.node,l.offset,c.focusNode,c.focusOffset)||(this.view.observer.ignore((()=>{ze.android&&ze.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=Qt(this.view.root);if(t)if(o.empty){if(ze.gecko){let t=(e=a.node,n=a.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=nn(a.node,a.offset,1==t?1:-1);e&&(a=new ve(e.node,e.offset))}}t.collapse(a.node,a.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(a.node,a.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([a,l]=[l,a]),e.setEnd(l.node,l.offset),e.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(e)}var e,n;r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new ve(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new ve(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Qt(t.root),{anchorNode:n,anchorOffset:r}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let s=Ye.find(this,e.head);if(!s)return;let o=s.posAtStart;if(e.head==o||e.head==o+s.length)return;let a=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!a||!l||a.bottom>l.top)return;let h=this.domAtPos(e.head+e.assoc);i.collapse(h.node,h.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(n,r)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=ke.get(i.childNodes[n]);t instanceof Ye&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=ke.get(i.childNodes[n]);t instanceof Ye&&(e=t.domAtPos(t.length))}return e?new ve(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=ke.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 new 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 Ye)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let r=this.length,s=this.children.length-1;s>=0;s--){let o=this.children[s],a=r-o.breakAfter,l=a-o.length;if(a<t)break;l<=t&&(l<t||o.covers(-1))&&(a>t||o.covers(1))&&(!i||o instanceof Ye&&!(i instanceof Ye&&e>=0))&&(i=o,n=l),r=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Ye))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof Ie))return null;let r=w(n.text,i);if(r==i)return null;let s=pe(n.dom,i,r).getClientRects();for(let t=0;t<s.length;t++){let e=s[t];if(t==s.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==zi.LTR;for(let t=0,l=0;l<this.children.length;l++){let h=this.children[l],c=t+h.length;if(c>n)break;if(t>=i){let i=h.dom.getBoundingClientRect();if(e.push(i.height),s){let e=h.dom.lastChild,n=e?ie(e):[];if(n.length){let e=n[n.length-1],s=a?e.right-i.left:i.right-e.left;s>o&&(o=s,this.minWidth=r,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?zi.RTL:zi.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Ye){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let r=ie(n.firstChild)[0];t=n.getBoundingClientRect().height,e=r?r.width/27:7,i=r?r.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new xe(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let r=n==e.viewports.length?null:e.viewports[n],s=r?r.from-1:this.length;if(s>i){let n=(e.lineBlockAt(s).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Qe.replace({widget:new tn(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!r)break;i=r.to+1}return Qe.set(t)}updateDeco(){let t=this.view.state.facet(Ti).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let r=Bi(this.view),s={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:o,offsetHeight:a}=this.view.scrollDOM;!function(t,e,i,n,r,s,o,a){let l=t.ownerDocument,h=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,d=c==l.body,f=1,p=1;if(d)t=le(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:f,scaleY:p}=he(c,e)),t={left:e.left,right:e.left+c.clientWidth*f,top:e.top,bottom:e.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==r)e.top<t.top?(g=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+g&&(g=e.bottom-t.bottom+g+o)):e.bottom>t.bottom&&(g=e.bottom-t.bottom+o,i<0&&e.top-g<t.top&&(g=-(t.top+g-e.top+o)));else{let n=e.bottom-e.top,s=t.bottom-t.top;g=("center"==r&&n<=s?e.top+n/2-s/2:"start"==r||"center"==r&&i<0?e.top-o:e.bottom-s+o)-t.top}if("nearest"==n?e.left<t.left?(m=-(t.left-e.left+s),i>0&&e.right>t.right+m&&(m=e.right-t.right+m+s)):e.right>t.right&&(m=e.right-t.right+s,i<0&&e.left<t.left+m&&(m=-(t.left+m-e.left+s))):m=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==a?e.left-s:e.right-(t.right-t.left)+s)-t.left,m||g)if(d)h.scrollBy(m,g);else{let t=0,i=0;if(g){let t=c.scrollTop;c.scrollTop+=g/p,i=(c.scrollTop-t)*p}if(m){let e=c.scrollLeft;c.scrollLeft+=m/f,t=(c.scrollLeft-e)*f}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-m)<1&&(n="nearest"),i&&Math.abs(i-g)<1&&(r="nearest")}if(d)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,s,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,a),-a),this.view.textDirection==zi.LTR)}}class tn extends Xe{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function en(t,e){let i=t.observer.selectionRange,n=i.focusNode&&nn(i.focusNode,i.focusOffset,0);if(!n)return null;let r=e-n.offset;return{from:r,to:r+n.node.nodeValue.length,node:n.node}}function nn(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return{node:i,offset:n};if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=oe(i)}if(i>=0)for(let n=t,r=e;;){if(3==n.nodeType)return{node:n,offset:r};if(!(1==n.nodeType&&r<n.childNodes.length&&i>=0))break;n=n.childNodes[r],r=0}return null}let rn=class{constructor(){this.changes=[]}compareRange(t,e){ri(t,e,this.changes)}comparePoint(t,e){ri(t,e,this.changes)}};function sn(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function on(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function an(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function ln(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function hn(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function cn(t,e,i){let n,r,s,o,a,l,h,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=ie(d);for(let f=0;f<t.length;f++){let p=t[f];r&&an(r,p)&&(p=ln(hn(p,r.bottom),r.top));let m=sn(e,p),g=on(i,p);if(0==m&&0==g)return 3==d.nodeType?un(d,e,i):cn(d,e,i);if(!n||o>g||o==g&&s>m){n=d,r=p,s=m,o=g;let a=g?i<p.top?-1:1:m?e<p.left?-1:1:0;u=!a||(a>0?f<t.length-1:f>0)}0==m?i>p.bottom&&(!h||h.bottom<p.bottom)?(a=d,h=p):i<p.top&&(!c||c.top>p.top)&&(l=d,c=p):h&&an(h,p)?h=hn(h,p.bottom):c&&an(c,p)&&(c=ln(c,p.top))}}if(h&&h.bottom>=i?(n=a,r=h):c&&c.top<=i&&(n=l,r=c),!n)return{node:t,offset:0};let d=Math.max(r.left,Math.min(r.right,e));return 3==n.nodeType?un(n,d,i):u&&"false"!=n.contentEditable?cn(n,d,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(r.left+r.right)/2?1:0)}}function un(t,e,i){let n=t.nodeValue.length,r=-1,s=1e9,o=0;for(let a=0;a<n;a++){let n=pe(t,a,a+1).getClientRects();for(let l=0;l<n.length;l++){let h=n[l];if(h.top==h.bottom)continue;o||(o=e-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<s){let i=e>=(h.left+h.right)/2,n=i;if((ze.chrome||ze.gecko)&&pe(t,a).getBoundingClientRect().left==h.right&&(n=!i),c<=0)return{node:t,offset:a+(n?1:0)};r=a+(n?1:0),s=c}}}return{node:t,offset:r>-1?r:o>0?t.nodeValue.length:0}}function dn(t,e,i,n=-1){var r,s;let o,a=t.contentDOM.getBoundingClientRect(),l=a.top+t.viewState.paddingTop,{docHeight:h}=t.viewState,{x:c,y:u}=e,d=u-l;if(d<0)return 0;if(d>h)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,r=!1;o=t.elementAtHeight(d),o.type!=Ze.Text;)for(;d=n>0?o.bottom+e:o.top-e,!(d>=0&&d<=h);){if(r)return i?null:0;r=!0,n=-n}u=l+d;let f=o.from;if(f<t.viewport.from)return 0==t.viewport.from?0:i?null:fn(t,a,o,c,u);if(f>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:fn(t,a,o,c,u);let p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(c,u);g&&!t.contentDOM.contains(g)&&(g=null),g||(c=Math.max(a.left+1,Math.min(a.right-1,c)),g=m.elementFromPoint(c,u),g&&!t.contentDOM.contains(g)&&(g=null));let w,v=-1;if(g&&0!=(null===(r=t.docView.nearest(g))||void 0===r?void 0:r.isEditable))if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||ze.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return pe(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||ze.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():pe(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=Ye.find(t.docView,f);if(!e)return d>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=cn(e.dom,c,u))}let b=t.docView.nearest(w);if(!b)return null;if(b.isWidget&&1==(null===(s=b.dom)||void 0===s?void 0:s.nodeType)){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}return b.localPosFromDOM(w,v)+b.posAtStart}function fn(t,e,i,n,r){let s=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;s+=Math.floor((r-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,r=0;;){if(r>=e)return n;if(n==t.length)break;r+=9==t.charCodeAt(n)?i-r%i:1,n=w(t,n)}return t.length}(o,s,t.state.tabSize)}function pn(t,e,i,n){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let a=e,l=null;;){let e=Zi(r,s,o,a,i),h=Xi;if(!e){if(r.number==(i?t.state.doc.lines:1))return a;h="\n",r=t.state.doc.line(r.number+(i?1:-1)),s=t.bidiSpans(r),e=z.cursor(i?r.from:r.to)}if(l){if(!l(h))return a}else{if(!n)return e;l=n(h)}a=e}}function mn(t,e,i){for(;;){let n=0;for(let r of t)r.between(e-1,e+1,((t,r,s)=>{if(e>t&&e<r){let s=n||i||(e-t<r-e?-1:1);e=s<0?t:r,n=s}}));if(!n)return e}}function gn(t,e,i){let n=mn(t.state.facet(Di).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:z.cursor(n,n<i.from?1:-1)}class wn{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.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,ze.safari&&t.contentDOM.addEventListener("input",(()=>null)),ze.gecko&&function(t){jn.has(t)||(jn.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,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=ke.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(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=bn(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let r=!e[t].handlers.length,s=i[t];s&&r!=!s.handlers.length&&(n.removeEventListener(t,this.handleEvent),s=null),s||n.addEventListener(t,this.handleEvent,{passive:r})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=t.keyCode&&xn.indexOf(t.keyCode)<0&&(this.view.inputState.lastEscPress=0),ze.android&&ze.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!ze.ios||t.synthetic||t.altKey||t.metaKey||!((e=kn.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||yn.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(){let t=this.pendingIOSKey;return!!t&&(this.pendingIOSKey=void 0,me(this.view.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(ze.safari&&!ze.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.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 vn(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){bi(i.state,t)}}}function bn(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;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let r=t.domEventHandlers[n];r&&i(n).handlers.push(vn(e.value,r))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let r=t.domEventObservers[n];r&&i(n).observers.push(vn(e.value,r))}}for(let t in Mn)i(t).handlers.push(Mn[t]);for(let t in Cn)i(t).observers.push(Cn[t]);return e}const kn=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],yn="dthko",xn=[16,17,18,20,91,92,224,225];function Sn(t){return.7*Math.max(0,t)+8}class An{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(Di).map((e=>e(t)));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(xt.allowMultipleSelections)&&function(t,e){let i=t.state.facet(li);return i.length?i[0](e):ze.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Qt(t.root);if(!n||0==n.rangeCount)return!0;let r=n.getRangeAt(0).getClientRects();for(let t=0;t<r.length;t++){let i=r[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!=Vn(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let r=0,s=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},a=Bi(this.view);t.clientX-a.left<=o.left+6?r=-Sn(o.left-t.clientX):t.clientX+a.right>=o.right-6&&(r=Sn(t.clientX-o.right)),t.clientY-a.top<=o.top+6?s=-Sn(o.top-t.clientY):t.clientY+a.bottom>=o.bottom-6&&(s=Sn(t.clientY-o.bottom)),this.setScrollSpeed(r,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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],r=null;if(n.empty){let t=mn(this.atoms,n.from,0);t!=n.from&&(r=z.cursor(t,-1))}else{let t=mn(this.atoms,n.from,-1),e=mn(this.atoms,n.to,1);t==n.from&&e==n.to||(r=z.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}r&&(e||(e=t.ranges.slice()),e[i]=r)}return e?z.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)||i.main.assoc!=e.state.selection.main.assoc&&!1===this.dragging)&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const Mn=Object.create(null),Cn=Object.create(null),Tn=ze.ie&&ze.ie_version<15||ze.ios&&ze.webkit_version<604;function Dn(t,e){let i,{state:n}=t,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(null!=Wn&&n.selection.ranges.every((t=>t.empty))&&Wn==s.toString()){let t=-1;i=n.changeByRange((i=>{let a=n.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let l=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:a.from,insert:l},range:z.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=s.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:z.cursor(t.from+e.length)}})):n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function On(t,e,i,n){if(1==n)return z.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return z.cursor(e);0==s?i=1:s==r.length&&(i=-1);let o=s,a=s;i<0?o=w(r.text,s,!1):a=w(r.text,s);let l=n(r.text.slice(o,a));for(;o>0;){let t=w(r.text,o,!1);if(n(r.text.slice(t,o))!=l)break;o=t}for(;a<r.length;){let t=w(r.text,a);if(n(r.text.slice(a,t))!=l)break;a=t}return z.range(o+r.from,a+r.from)}(t.state,e,i);{let i=Ye.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),r=i?i.posAtStart:n.from,s=i?i.posAtEnd:n.to;return s<t.state.doc.length&&s==n.to&&s++,z.range(r,s)}}Cn.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Mn.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),Cn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Cn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Mn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(ci))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Pn(t,e),n=Vn(e),r=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),r=r.map(t.changes))},get(e,s,o){let a,l=Pn(t,e),h=On(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!s){let e=On(t,i.pos,i.bias,n),r=Math.min(e.from,h.from),s=Math.max(e.to,h.to);h=r<h.from?z.range(r,s):z.range(s,r)}return s?r.replaceRange(r.main.extend(h.from,h.to)):o&&1==n&&r.ranges.length>1&&(a=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:r}=t.ranges[i];if(n<=e&&r>=e)return z.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(r,l.pos))?a:o?r.addRange(h):z.create([h])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new An(t,e,i,n)),n&&t.observer.ignore((()=>fe(t.contentDOM)));let r=t.inputState.mouseSelection;if(r)return r.start(e),!1===r.dragging}return!1};let Ln=(t,e)=>t>=e.top&&t<=e.bottom,En=(t,e,i)=>Ln(e,i)&&t>=i.left&&t<=i.right;function Bn(t,e,i,n){let r=Ye.find(t.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(0==s)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&En(i,n,o))return-1;let a=r.coordsAt(s,1);return a&&En(i,n,a)?1:o&&Ln(n,o)?-1:1}function Pn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Bn(t,i,e.clientX,e.clientY)}}const Nn=ze.ie&&ze.ie_version<=11;let Rn=null,zn=0,In=0;function Vn(t){if(!Nn)return t.detail;let e=Rn,i=In;return Rn=t,In=Date.now(),zn=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(zn+1)%3:1}function Hn(t,e,i,n){if(!i)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=n&&s&&function(t,e){let i=t.state.facet(hi);return i.length?i[0](e):ze.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:s.from,to:s.to}:null,a={from:r,insert:i},l=t.state.changes(o?[o,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mn.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=z.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},Mn.dragend=t=>(t.inputState.draggedContent=null,!1),Mn.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),r=0,s=()=>{++r==i.length&&Hn(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=s,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),s()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Hn(t,e,i,!0),!0}return!1},Mn.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Tn?null:e.clipboardData;return i?(Dn(t,i.getData("text/plain")||i.getData("text/uri-text")),!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(),Dn(t,i.value)}),50)}(t),!1)};let Wn=null;Mn.copy=Mn.cut=(t,e)=>{let{text:i,ranges:n,linewise:r}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let r=-1;for(let{from:n}of t.selection.ranges){let s=t.doc.lineAt(n);s.number>r&&(e.push(s.text),i.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),r=s.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!r)return!1;Wn=r?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=Tn?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),!1)};const Fn=lt.define();function qn(t,e){let i=[];for(let n of t.facet(pi)){let r=n(t,e);r&&i.push(r)}return i?t.update({effects:i,annotations:Fn.of(!0)}):null}function _n(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=qn(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Cn.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),_n(t)},Cn.blur=t=>{t.observer.clearSelectionRange(),_n(t)},Cn.compositionstart=Cn.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},Cn.compositionend=t=>{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,ze.chrome&&ze.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},Cn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mn.beforeinput=(t,e)=>{var i;let n;if(ze.chrome&&ze.android&&(n=kn.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return!1};const jn=new Set,Kn=["pre-wrap","normal","pre-line","break-spaces"];class $n{constructor(t){this.lineWrapping=t,this.doc=n.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}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 Kn.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,r,s){let o=Kn.indexOf(t)>-1,a=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=r,a){this.heightSamples={};for(let t=0;t<s.length;t++){let e=s[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return a}}class Gn{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Un{constructor(t,e,i,n,r){this.from=t,this.length=e,this.top=i,this.height=n,this._content=r}get type(){return"number"==typeof this._content?Ze.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 ii?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 Un(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Yn=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Yn||(Yn={}));const Jn=.001;class Xn{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=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>Jn&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Xn.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let r=this,s=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:a,toA:l,fromB:h,toB:c}=n[o],u=r.lineAt(a,Yn.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=l?u:r.lineAt(l,Yn.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&u.from<=n[o-1].toA;)a=n[o-1].fromA,h=n[o-1].fromB,o--,a<u.from&&(u=r.lineAt(a,Yn.ByPosNoHeight,i,0,0));h+=u.from-a,a=u.from;let f=nr.build(i.setDoc(s),t,h,c);r=r.replace(a,l,f)}return r.updateHeight(i,0)}static empty(){return new Qn(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,r=0;for(;;)if(e==i)if(n>2*r){let r=t[e-1];r.break?t.splice(--e,1,r.left,null,r.right):t.splice(--e,1,r.left,r.right),i+=1+r.break,n-=r.size}else{if(!(r>2*n))break;{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,r-=e.size}}else if(n<r){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(r+=e.size)}let s=0;return null==t[e-1]?(s=1,e--):null==t[e]&&(s=1,i++),new er(Xn.of(t.slice(0,e)),s,Xn.of(t.slice(i)))}}Xn.prototype.size=1;class Zn extends Xn{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Un(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,r){return this.blockAt(0,i,n,r)}forEachLine(t,e,i,n,r,s){t<=r+this.length&&e>=r&&s(this.blockAt(0,i,n,r))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Qn extends Zn{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Un(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Qn||n instanceof tr&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof tr?n=new Qn(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Xn.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,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 tr extends Xn{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,r=t.doc.lineAt(e+this.length).number,s=r-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*s);i=e/s,this.length>s+1&&(o=(this.height-e)/(this.length-s-1))}else i=this.height/s;return{firstLine:n,lastLine:r,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:r,lastLine:s,perLine:o,perChar:a}=this.heightMetrics(e,n);if(e.lineWrapping){let r=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),s=e.doc.lineAt(r),l=o+s.length*a,h=Math.max(i,t-l/2);return new Un(s.from,s.length,h,l,0)}{let n=Math.max(0,Math.min(s-r,Math.floor((t-i)/o))),{from:a,length:l}=e.doc.line(r+n);return new Un(a,l,i+o*n,o,0)}}lineAt(t,e,i,n,r){if(e==Yn.ByHeight)return this.blockAt(t,i,n,r);if(e==Yn.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Un(e,n-e,0,0,0)}let{firstLine:s,perLine:o,perChar:a}=this.heightMetrics(i,r),l=i.doc.lineAt(t),h=o+l.length*a,c=l.number-s,u=n+o*c+a*(l.from-r-c);return new Un(l.from,l.length,Math.max(n,Math.min(u,n+this.height-h)),h,0)}forEachLine(t,e,i,n,r,s){t=Math.max(t,r),e=Math.min(e,r+this.length);let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(i,r);for(let h=t,c=n;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-o;c+=a*i+l*(t-r-i)}let n=a+l*e.length;s(new Un(e.from,e.length,c,n,0)),c+=n,h=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof tr?i[i.length-1]=new tr(t.length+n):i.push(null,new tr(n-1))}if(t>0){let e=i[0];e instanceof tr?i[0]=new tr(t+e.length):i.unshift(new tr(t-1),null)}return Xn.of(i)}decomposeLeft(t,e){e.push(new tr(t-1),null)}decomposeRight(t,e){e.push(null,new tr(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let r=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],s=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new tr(n.from-e-1).updateHeight(t,e));s<=r&&n.more;){let e=t.doc.lineAt(s).length;i.length&&i.push(null);let r=n.heights[n.index++];-1==o?o=r:Math.abs(r-o)>=Jn&&(o=-2);let a=new Qn(e,r);a.outdated=!1,i.push(a),s+=e+1}s<=r&&i.push(null,new tr(r-s).updateHeight(t,s));let a=Xn.of(i);return(o<0||Math.abs(a.height-this.height)>=Jn||Math.abs(o-this.heightMetrics(t,e).perLine)>=Jn)&&(t.heightChanged=!0),a}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class er extends Xn{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,n){let r=i+this.left.height;return t<r?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,r,n+this.left.length+this.break)}lineAt(t,e,i,n,r){let s=n+this.left.height,o=r+this.left.length+this.break,a=e==Yn.ByHeight?t<s:t<o,l=a?this.left.lineAt(t,e,i,n,r):this.right.lineAt(t,e,i,s,o);if(this.break||(a?l.to<o:l.from>o))return l;let h=e==Yn.ByPosNoHeight?Yn.ByPosNoHeight:Yn.ByPos;return a?l.join(this.right.lineAt(o,h,i,s,o)):this.left.lineAt(o,h,i,n,r).join(l)}forEachLine(t,e,i,n,r,s){let o=n+this.left.height,a=r+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,i,n,r,s),e>=a&&this.right.forEachLine(t,e,i,o,a,s);else{let l=this.lineAt(a,Yn.ByPos,i,n,r);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,r,s),l.to>=t&&l.from<=e&&s(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,a,s)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];t>0&&this.decomposeLeft(t,r);let s=r.length;for(let t of i)r.push(t);if(t>0&&ir(r,s-1),e<this.length){let t=r.length;this.decomposeRight(e,r),ir(r,t)}return Xn.of(r)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?Xn.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:s}=this,o=e+r.length+this.break,a=null;return n&&n.from<=e+r.length&&n.more?a=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?a=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),a?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function ir(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof tr&&(n=t[e+1])instanceof tr&&t.splice(e-1,3,new tr(i.length+1+n.length))}class nr{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 Qn?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Qn(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 n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let s=e-t;i.block?this.addBlock(new Zn(s,n,i)):(s||r||n>=5)&&this.addLineDeco(n,r,s)}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 Qn(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new tr(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 Qn)return t;let e=new Qn(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 n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Qn||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Qn(0,-1));let i=t;for(let t of this.nodes)t instanceof Qn&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let r=new nr(i,t);return Dt.spans(e,i,n,r,0),r.finish(i)}}class rr{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&ri(t,e,this.changes,5)}}function sr(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,r=n.defaultView||window,s=Math.max(0,i.left),o=Math.min(r.innerWidth,i.right),a=Math.max(0,i.top),l=Math.min(r.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();s=Math.max(s,n.left),o=Math.min(o,n.right),a=Math.max(a,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:s-i.left,right:Math.max(s,o)-i.left,top:a-(i.top+e),bottom:Math.max(a,l)-(i.top+e)}}function or(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ar{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(t,e){return Qe.replace({widget:new lr(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class lr extends Xe{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 hr{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=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=pr,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=zi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Ci).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new $n(e),this.stateDeco=t.facet(Ti).filter((t=>"function"!=typeof t)),this.heightMap=Xn.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle.setDoc(t.doc),[new Ni(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Qe.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 n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new cr(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?pr:new mr(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:gr(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Ti).filter((t=>"function"!=typeof t));let n=t.changedRanges,r=Ni.extendWithRanges(n,function(t,e,i){let n=new rr;return Dt.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:D.empty(this.state.doc.length))),s=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=s&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),l&&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(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(gi)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?zi.RTL:zi.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let h=0,c=0;if(a.width&&a.height){let{scaleX:t,scaleY:i}=he(e,a);this.scaleX==t&&this.scaleY==i||(this.scaleX=t,this.scaleY=i,h|=8,o=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==d||(this.paddingTop=u,this.paddingBottom=d,h|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=8);let f=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=we(t.scrollDOM);let p=(this.printing?or:sr)(e,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let v=a.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=a.width,this.editorHeight=t.scrollDOM.clientHeight,h|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(e)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:i,charWidth:n,textHeight:a}=t.docView.measureTextSize();o=i>0&&r.refresh(s,i,n,a,v/n,e),o&&(t.docView.minWidth=0,h|=8)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),r.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Xn.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle,[new Ni(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Gn(i.from,s))}r.heightChanged&&(h|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&h||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,a=new cr(n.lineAt(s-1e3*i,Yn.ByHeight,r,0,0).from,n.lineAt(o+1e3*(1-i),Yn.ByHeight,r,0,0).to);if(e){let{head:t}=e.range;if(t<a.from||t>a.to){let i,s=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,Yn.ByPos,r,0,0);i="center"==e.y?(o.top+o.bottom)/2-s/2:"start"==e.y||"nearest"==e.y&&t<a.from?o.top:o.bottom-s,a=new cr(n.lineAt(i-500,Yn.ByHeight,r,0,0).from,n.lineAt(i+s+500,Yn.ByHeight,r,0,0).to)}}return a}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new cr(this.heightMap.lineAt(i,Yn.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Yn.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Yn.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,Yn.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==t||n<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&n>s-2e3&&r<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new ar(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,s=n<<1;if(this.defaultTextDirection!=zi.LTR&&!i)return[];let o=[],a=(n,s,l,h)=>{if(s-n<r)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<s)return a(n,t-10,l,h),void a(t+10,s,l,h);let d=function(t,e){for(let i of t)if(e(i))return i}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<r&&Math.abs(t.to-s)<r&&!u.some((e=>t.from<e&&t.to>e))));if(!d){if(s<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=s&&t.to>=s))){let t=e.moveToLineBoundary(z.cursor(s),!1,!0).head;t>n&&(s=t)}d=new ar(n,s,this.gapSize(l,n,s,h))}o.push(d)};for(let t of this.viewportLines){if(t.length<s)continue;let e=ur(t.from,t.to,this.stateDeco);if(e.total<s)continue;let r,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,s,a=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=fr(e,l),r=((this.visibleBottom-this.visibleTop)/2+a)/t.height;i=n-r,s=n+r}else i=(this.visibleTop-t.top-a)/t.height,s=(this.visibleBottom-t.top+a)/t.height;r=dr(e,i),o=dr(e,s)}else{let t,i,s=e.total*this.heightOracle.charWidth,a=n*this.heightOracle.charWidth;if(null!=l){let n=fr(e,l),r=((this.pixelViewport.right-this.pixelViewport.left)/2+a)/s;t=n-r,i=n+r}else t=(this.pixelViewport.left-a)/s,i=(this.pixelViewport.right+a)/s;r=dr(e,t),o=dr(e,i)}r>t.from&&a(t.from,r,t,e),o<t.to&&a(o,t.to,t,e)}return o}gapSize(t,e,i,n){let r=fr(n,i)-fr(n,e);return this.heightOracle.lineWrapping?t.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(t){ar.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Qe.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Dt.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||gr(this.heightMap.lineAt(t,Yn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return gr(this.heightMap.lineAt(this.scaler.fromDOM(t),Yn.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 gr(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 cr{constructor(t,e){this.from=t,this.to=e}}function ur(t,e,i){let n=[],r=t,s=0;return Dt.spans(i,t,e,{span(){},point(t,e){t>r&&(n.push({from:r,to:t}),s+=t-r),r=e}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function dr({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:r}=e[t],s=r-i;if(n<=s)return i+n;n-=s}}function fr(t,e){let i=0;for(let{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}const pr={toDOM:t=>t,fromDOM:t=>t,scale:1};class mr{constructor(t,e,i){let n=0,r=0,s=0;this.viewports=i.map((({from:i,to:r})=>{let s=e.lineAt(i,Yn.ByPos,t,0,0).top,o=e.lineAt(r,Yn.ByPos,t,0,0).bottom;return n+=o-s,{from:i,to:r,top:s,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=s+(t.top-r)*this.scale,s=t.domBottom=t.domTop+(t.bottom-t.top),r=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.top)return n+(t-i)*this.scale;if(t<=r.bottom)return r.domTop+(t-r.top);i=r.bottom,n=r.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.domTop)return i+(t-n)/this.scale;if(t<=r.domBottom)return r.top+(t-r.domTop);i=r.bottom,n=r.domBottom}}}function gr(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Un(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>gr(t,e))):t._content)}const wr=H.define({combine:t=>t.join(" ")}),vr=H.define({combine:t=>t.indexOf(!0)>-1}),br=jt.newName(),kr=jt.newName(),yr=jt.newName(),xr={"&light":"."+kr,"&dark":"."+yr};function Sr(t,e,i){return new jt(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const Ar=Sr("."+br,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},xr),Mr="￿";class Cr{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(xt.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Mr}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let r=n.nextSibling;if(r==e)break;let s=ke.get(n),o=ke.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:Dr(n))||Dr(r)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=r}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r,s=-1,o=1;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(r=n.exec(e))&&(s=r.index,o=r[0].length),this.append(e.slice(i,s<0?e.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=s+o}}readNode(t){if(t.cmIgnore)return;let e=ke.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+(Tr(t,i.node,i.offset)?e:0))}}function Tr(t,e,i){for(;;){if(!e||i<oe(e))return!1;if(e==t)return!0;i=re(e)+1,e=e.parentNode}}function Dr(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Or{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Lr{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:r,impreciseAnchor:s}=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=r||s?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}=t.observer.selectionRange;return i&&(e.push(new Or(i,n)),r==i&&s==n||e.push(new Or(r,s))),e}(t),i=new Cr(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,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?z.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=r&&r.node==e.focusNode&&r.offset==e.focusOffset||!te(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!te(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=z.single(n,i)}}}function Er(t,e){let i,{newSel:r}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:r,to:a}=e.bounds,l=s.from,h=null;(8===o||ze.android&&e.text.length<a-r)&&(l=s.to,h="end");let c=function(t,e,i,n){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,a=e.length;for(;o>0&&a>0&&t.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;return"end"==n&&(i-=o+Math.max(0,s-Math.min(o,a))-s),o<s&&t.length<e.length?(s-=i<=s&&i>=o?s-i:0,a=s+(a-o),o=s):a<s&&(s-=i<=s&&i>=a?s-i:0,o=s+(o-a),a=s),{from:s,toA:o,toB:a}}(t.state.doc.sliceString(r,a,Mr),e.text,l-r,h);c&&(ze.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==Mr+Mr&&c.toB--,i={from:r+c.from,to:r+c.toA,insert:n.of(e.text.slice(c.from,c.toB).split(Mr))})}else r&&(!t.hasFocus&&t.state.facet(ki)||r.main.eq(s))&&(r=null);if(!i&&!r)return!1;if(!i&&e.typeOver&&!s.empty&&r&&r.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(ze.mac||ze.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(r&&2==i.insert.length&&(r=z.single(r.main.anchor-1,r.main.head-1)),i={from:s.from,to:s.to,insert:n.of([" "])}):ze.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(r&&(r=z.single(r.main.anchor-1,r.main.head-1)),i={from:s.from,to:s.to,insert:n.of([" "])}),i){if(ze.ios&&t.inputState.flushIOSKey())return!0;if(ze.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&me(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from&&i.to>s.head)&&me(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&me(t.contentDOM,"Delete",46)))return!0;let e,n=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>e||(e=function(t,e,i){let n,r=t.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=s.from<e.from?r.sliceDoc(s.from,e.from):"",o=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=r.changes(e),a=i&&i.main.to<=o.newLength?i.main:void 0;if(r.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let l,h=t.state.sliceDoc(e.from,e.to),c=i&&en(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);l={from:c.from,to:c.to-t}}else l=t.state.doc.lineAt(s.head);let u=s.to-e.to,d=s.to-s.from;n=r.changeByRange((i=>{if(i.from==s.from&&i.to==s.to)return{changes:o,range:a||i.map(o)};let n=i.to-u,c=n-h.length;if(i.to-i.from!=d||t.state.sliceDoc(c,n)!=h||i.to>=l.from&&i.from<=l.to)return{range:i};let f=r.changes({from:c,to:n,insert:e.insert}),p=i.to-s.to;return{changes:f,range:a?z.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(f)}}))}else n={changes:o,selection:a&&r.selection.replaceRange(a)}}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)),r.update(n,{userEvent:o,scrollIntoView:!0})}(t,i,r));return t.state.facet(fi).some((e=>e(t,i.from,i.to,n,a)))||t.dispatch(a()),!0}if(r&&!r.main.eq(s)){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:r,scrollIntoView:e,userEvent:i}),!0}return!1}const Br={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Pr=ze.ie&&ze.ie_version<=11;class Nr{constructor(t){this.view=t,this.active=!1,this.selectionRange=new ce,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(ze.ie&&ze.ie_version<=11||ze.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()})),Pr&&(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),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?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.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(ki)?i.root.activeElement!=this.dom:!ee(i.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);r&&r.ignoreEvent(t)?e||(this.selectionChanged=!1):(ze.ie&&ze.ie_version<=11||ze.android&&ze.chrome)&&!i.state.selection.main.empty&&n.focusNode&&ne(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=ze.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,a=t.docView.domAtPos(t.state.selection.main.anchor);return ne(a.node,a.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}(this.view)||Qt(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=ee(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,oe(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=oe(i))}else{if(i==t)return!0;n=re(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(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)break;i=i.host}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,Br),Pr&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Pr&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&me(this.dom,t.key,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let r of t){let t=this.readMutation(r);t&&(t.typeOver&&(n=!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:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&ee(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Lr(this.view,t,e,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Er(this.view,e);return this.view.state==i&&this.view.update([]),n}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=Rr(e,t.previousSibling||t.target.previousSibling,-1),n=Rr(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):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),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),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Rr(t,e,i){for(;e;){let n=ke.get(e);if(n&&n.parent==t)return n;let r=e.parentNode;e=r!=t.dom?r:i>0?e.nextSibling:e.previousSibling}return null}class zr{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(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 hr(t.state||xt.create(t)),t.scrollTo&&t.scrollTo.is(vi)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(xi).map((t=>new Ai(t)));for(let t of this.plugins)t.update(this);this.observer=new Nr(this),this.inputState=new wn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Qi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}dispatch(...t){let e=1==t.length&&t[0]instanceof dt?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 new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,r=this.state;for(let e of t){if(e.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=e.state}if(this.destroyed)return void(this.viewState.state=r);let s=this.hasFocus,o=0,a=null;t.some((t=>t.annotation(Fn)))?(this.inputState.notifiedFocused=s,o=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=qn(r,s),a||(o=1));let l=this.observer.delayedAndroidKey,h=null;if(l?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(xt.phrases)!=this.state.facet(xt.phrases))return this.setState(r);e=Ri.create(this,r,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new wi(t.empty?t:z.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(vi)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=Hr.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Pi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(wr)!=e.state.facet(wr)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(di))try{t(e)}catch(t){bi(this.state,t,"update listener")}(a||h)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!Er(this,h)&&l.force&&me(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new hr(t),this.plugins=t.facet(xi).map((t=>new Ai(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Qi(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(xi),i=t.state.facet(xi);if(e!=i){let n=[];for(let r of i){let i=e.indexOf(r);if(i<0)n.push(new Ai(r));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,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)}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(s<0)if(we(i))r=-1,s=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);r=t.from,s=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 a=[];4&o||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map((t=>{try{return t.read(this)}catch(t){return bi(this.state,t),Vr}})),h=Ri.create(this,this.state,[]),c=!1;h.flags|=o,e?e.flags|=o:e=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),c=this.docView.update(h));for(let t=0;t<a.length;t++)if(l[t]!=Vr)try{let e=a[t];e.write&&e.write(l[t],this)}catch(t){bi(this.state,t)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}{let t=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-s;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(di))t(e)}get themeClasses(){return br+" "+(this.state.facet(vr)?yr:kr)+" "+this.state.facet(wr)}updateAttrs(){let t=Wr(this,Mi,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ki)?"true":"false",class:"cm-content",style:`${ze.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Wr(this,Ci,e);let i=this.observer.ignore((()=>{let i=Ge(this.contentDOM,this.contentAttrs,e),n=Ge(this.dom,this.editorAttrs,t);return i||n}));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(zr.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(Pi);let t=this.state.facet(zr.cspNonce);jt.mount(this.root,this.styleModules.concat(Ar).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw new 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){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==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 gn(this,t,pn(this,t,e,i))}moveByGroup(t,e){return gn(this,t,pn(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return t=>{let e=n(t);return r==bt.Space&&(r=e),r==e}}(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let r=function(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==Ze.Text))return t;return i}(t,e.head),s=n&&r.type==Ze.Text&&(t.lineWrapping||r.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(r.from),o=t.posAtCoords({x:i==(n==zi.LTR)?e.right-1:e.left+1,y:(s.top+s.bottom)/2});if(null!=o)return z.cursor(o,i?-1:1)}return z.cursor(i?r.to:r.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return gn(this,t,function(t,e,i,n){let r=e.head,s=i?1:-1;if(r==(i?t.state.doc.length:0))return z.cursor(r,e.assoc);let o,a=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(r,e.assoc||-1),c=t.documentTop;if(h)null==a&&(a=h.left-l.left),o=s<0?h.top:h.bottom;else{let e=t.viewState.lineBlockAt(r);null==a&&(a=Math.min(l.right-l.left,t.defaultCharacterWidth*(r-e.from))),o=(s<0?e.top:e.bottom)+c}let u=l.left+a,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=o+(d+e)*s,n=dn(t,{x:u,y:i},!1,s);if(i<l.top||i>l.bottom||(s<0?n<r:n>r)){let e=t.docView.coordsForChar(n),r=!e||i<e.top?-1:1;return z.cursor(n,r,void 0,a)}}}(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(),dn(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 n=this.state.doc.lineAt(t),r=this.bidiSpans(n);return ae(i,r[Ki.find(r,t-n.from,-1,e)].dir==zi.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(mi)||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>Ir)return Ji(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||$i(n.isolates,e=Li(this,t.from,t.to))))return n.order;e||(e=Li(this,t.from,t.to));let n=function(t,e,i){if(!t)return[new Ki(0,0,e==Vi?1:0)];if(e==Ii&&!i.length&&!ji.test(t))return Ji(t.length);if(i.length)for(;t.length>Gi.length;)Gi[Gi.length]=256;let n=[],r=e==Ii?0:1;return Yi(t,r,r,i,0,t.length,n),n}(t.text,i,e);return this.bidiCache.push(new Hr(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ze.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{fe(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.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 vi.of(new wi("number"==typeof t?z.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 vi.of(new wi(z.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return Si.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return Si.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=jt.newName(),n=[wr.of(i),Pi.of(Sr(`.${i}`,t))];return e&&e.dark&&n.push(vr.of(!0)),n}static baseTheme(t){return U.lowest(Pi.of(Sr("."+br,t,xr)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&ke.get(i)||ke.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}zr.styleModule=Pi,zr.inputHandler=fi,zr.focusChangeEffect=pi,zr.perLineTextDirection=mi,zr.exceptionSink=ui,zr.updateListener=di,zr.editable=ki,zr.mouseSelectionStyle=ci,zr.dragMovesSelection=hi,zr.clickAddsSelectionRange=li,zr.decorations=Ti,zr.atomicRanges=Di,zr.bidiIsolatedRanges=Oi,zr.scrollMargins=Ei,zr.darkTheme=vr,zr.cspNonce=H.define({combine:t=>t.length?t[0]:""}),zr.contentAttributes=Ci,zr.editorAttributes=Mi,zr.lineWrapping=zr.contentAttributes.of({class:"cm-lineWrapping"}),zr.announce=ut.define();const Ir=4096,Vr={};class Hr{constructor(t,e,i,n,r,s){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=r,this.order=s}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:zi.LTR;for(let r=Math.max(0,t.length-10);r<t.length;r++){let s=t[r];s.dir!=n||e.touchesRange(s.from,s.to)||i.push(new Hr(e.mapPos(s.from,1),e.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return i}}function Wr(t,e,i){for(let n=t.state.facet(e),r=n.length-1;r>=0;r--){let e=n[r],s="function"==typeof e?e(t):e;s&&je(s,i)}return i}const Fr=ze.mac?"mac":ze.windows?"win":ze.linux?"linux":"key";function qr(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}const _r=U.default(zr.domEventHandlers({keydown:(t,e)=>Yr($r(e.state),t,e,"editor")})),jr=H.define({enables:_r}),Kr=new WeakMap;function $r(t){let e=t.facet(jr),i=Kr.get(e);return i||Kr.set(e,i=function(t,e=Fr){let i=Object.create(null),n=Object.create(null),r=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},s=(t,n,s,o,a)=>{var l,h;let c=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let n,r,s,o,a=i[i.length-1];"Space"==a&&(a=" ");for(let t=0;t<i.length-1;++t){const a=i[t];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==e?o=!0:r=!0}}return n&&(a="Alt-"+a),r&&(a="Ctrl-"+a),o&&(a="Meta-"+a),s&&(a="Shift-"+a),a}(t,e)));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");r(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=Gr={view:e,prefix:i,scope:t};return setTimeout((()=>{Gr==n&&(Gr=null)}),Ur),!0}]})}let d=u.join(" ");r(d,!1);let f=c[d]||(c[d]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(l=c._any)||void 0===l?void 0:l.run)||void 0===h?void 0:h.slice())||[]});s&&f.run.push(s),o&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let e in t)t[e].run.push(n.any)}let r=n[e]||n.key;if(r)for(let e of t)s(e,r,n.run,n.preventDefault,n.stopPropagation),n.shift&&s(e,"Shift-"+r,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let Gr=null;const Ur=4e3;function Yr(t,e,i,n){let r=function(t){var e=!(Yt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Jt&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Ut:Gt)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),s=A(x(r,0))==r.length&&" "!=r,o="",a=!1,l=!1,h=!1;Gr&&Gr.view==i&&Gr.scope==n&&(o=Gr.prefix+" ",xn.indexOf(e.keyCode)<0&&(l=!0,Gr=null));let c,u,d=new Set,f=t=>{if(t){for(let n of t.run)if(!d.has(n)&&(d.add(n),n(i,e)))return t.stopPropagation&&(h=!0),!0;t.preventDefault&&(t.stopPropagation&&(h=!0),l=!0)}return!1},p=t[n];return p&&(f(p[o+qr(r,e,!s)])?a=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ze.windows&&e.ctrlKey&&e.altKey)&&(c=Gt[e.keyCode])&&c!=r?(f(p[o+qr(c,e,!0)])||e.shiftKey&&(u=Ut[e.keyCode])!=r&&u!=c&&f(p[o+qr(u,e,!1)]))&&(a=!0):s&&e.shiftKey&&f(p[o+qr(r,e,!0)])&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&h&&e.stopPropagation(),a}const Jr={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};function Xr(t,e,i,n,r){e.lastIndex=0;for(let s,o=t.iterRange(i,n),a=i;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;s=e.exec(o.value);)r(a+s.index,s)}!ze.ios&&(Jr[".cm-line"].caretColor="transparent !important",Jr[".cm-content"]={caretColor:"transparent !important"});class Zr{constructor(t){const{regexp:e,decoration:i,decorate:n,boundary:r,maxLength:s=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(t,e,i,r)=>n(r,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,n,r)=>{let s=i(t,e,n);s&&r(n,n+t[0].length,s)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,n,r)=>r(n,n+t[0].length,i)}this.boundary=r,this.maxLength=s}createDeco(t){let e=new Ot,i=e.add.bind(e);for(let{from:e,to:n}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let n=[];for(let{from:r,to:s}of i)r=Math.max(t.state.doc.lineAt(r).from,r-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}(t,this.maxLength))Xr(t.state.doc,this.regexp,e,n,((e,n)=>this.addMatch(n,t,e,i)));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges(((e,r,s,o)=>{o>t.view.viewport.from&&s<t.view.viewport.to&&(i=Math.min(s,i),n=Math.max(o,n))})),t.viewportChanged||n-i>1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let r of t.visibleRanges){let s=Math.max(r.from,i),o=Math.min(r.to,n);if(o>s){let i=t.state.doc.lineAt(s),n=i.to<o?t.state.doc.lineAt(o):i,a=Math.max(r.from,i.from),l=Math.min(r.to,n.to);if(this.boundary){for(;s>i.from;s--)if(this.boundary.test(i.text[s-1-i.from])){a=s;break}for(;o<n.to;o++)if(this.boundary.test(n.text[o-n.from])){l=o;break}}let h,c=[],u=(t,e,i)=>c.push(i.range(t,e));if(i==n)for(this.regexp.lastIndex=a-i.from;(h=this.regexp.exec(i.text))&&h.index<l-i.from;)this.addMatch(h,t,h.index+i.from,u);else Xr(t.state.doc,this.regexp,a,l,((e,i)=>this.addMatch(i,t,e,u)));e=e.update({filterFrom:a,filterTo:l,filter:(t,e)=>t<a||e>l,add:c})}}return e}}const Qr=null!=/x/.unicode?"gu":"g",ts=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",Qr),es={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let is=null;const ns=H.define({combine(t){let e=St(t,{render:null,specialChars:ts,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==is&&"undefined"!=typeof document&&document.body){let e=document.body.style;is=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return is||!1}())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,Qr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Qr)),e}});function rs(t={}){return[ns.of(t),ss||(ss=Si.fromClass(class{constructor(t){this.view=t,this.decorations=Qe.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(ns)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new Zr({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:r}=i.state,s=x(e[0],0);if(9==s){let t=r.lineAt(n),e=i.state.tabSize,s=Wt(t.text,e,n-t.from);return Qe.replace({widget:new as((e-s%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Qe.replace({widget:new os(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(ns);t.startState.facet(ns)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let ss=null;class os extends Xe{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=function(t){return t>=32?"•":10==t?"␤":String.fromCharCode(9216+t)}(this.code),i=t.state.phrase("Control character")+" "+(es[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let r=document.createElement("span");return r.textContent=e,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class as extends Xe{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const ls=Qe.line({class:"cm-activeLine"}),hs=Si.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let n of t.state.selection.ranges){let r=t.lineBlockAt(n.head);r.from>e&&(i.push(ls.range(r.from)),e=r.from)}return Qe.set(i)}},{decorations:t=>t.decorations}),cs="-10000px";class us{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter((t=>t)),this.tooltipViews=this.tooltips.map(i)}update(t,e){var i;let n=t.state.facet(this.facet),r=n.filter((t=>t));if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let s=[],o=e?[]:null;for(let i=0;i<r.length;i++){let n=r[i],a=-1;if(n){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==n.create&&(a=t)}if(a<0)s[i]=this.createTooltipView(n),o&&(o[i]=!!n.above);else{let n=s[i]=this.tooltipViews[a];o&&(o[i]=e[a]),n.update&&n.update(t)}}}for(let t of this.tooltipViews)s.indexOf(t)<0&&(t.dom.remove(),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(o.forEach(((t,i)=>e[i]=t)),e.length=o.length),this.input=n,this.tooltips=r,this.tooltipViews=s,!0}}function ds(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const fs=H.define({combine:t=>{var e,i,n;return{position:ze.ios?"absolute":(null===(e=t.find((t=>t.position)))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find((t=>t.parent)))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=t.find((t=>t.tooltipSpace)))||void 0===n?void 0:n.tooltipSpace)||ds}}}),ps=new WeakMap,ms=Si.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(fs);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.manager=new us(t,vs,(t=>this.createTooltip(t))),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){this.intersectionObserver.disconnect();for(let t of 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,n=t.state.facet(fs);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let t of 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){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=cs,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);this.parent&&this.container.remove(),null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect(),e=1,i=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(ze.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(1!=this.view.scaleX||1!=this.view.scaleY)n=!0;else if(t.style.top==cs&&"0px"==t.style.left){let e=t.getBoundingClientRect();n=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(n||"absolute"==this.position)if(this.parent){let t=this.parent.getBoundingClientRect();t.width&&t.height&&(e=t.width/this.parent.offsetWidth,i=t.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:i}=this.view.viewState);return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,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(fs).tooltipSpace(this.view),scaleX:e,scaleY:i,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{editor:i,space:n,scaleX:r,scaleY:s}=t,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],h=this.manager.tooltipViews[a],{dom:c}=h,u=t.pos[a],d=t.size[a];if(!u||u.bottom<=Math.max(i.top,n.top)||u.top>=Math.min(i.bottom,n.bottom)||u.right<Math.max(i.left,n.left)-.1||u.left>Math.min(i.right,n.right)+.1){c.style.top=cs;continue}let f=l.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(e=ps.get(h))&&void 0!==e?e:d.bottom-d.top,w=h.offset||ws,v=this.view.textDirection==zi.LTR,b=d.width>n.right-n.left?v?n.left:n.right-d.width:v?Math.min(u.left-(f?14:0)+w.x,n.right-m):Math.max(n.left,u.left-m+(f?14:0)-w.x),k=this.above[a];!l.strictSide&&(k?u.top-(d.bottom-d.top)-w.y<n.top:u.bottom+(d.bottom-d.top)+w.y>n.bottom)&&k==n.bottom-u.bottom>u.top-n.top&&(k=this.above[a]=!k);let y=(k?u.top-n.top:n.bottom-u.bottom)-p;if(y<g&&!1!==h.resize){if(y<this.view.defaultLineHeight){c.style.top=cs;continue}ps.set(h,g),c.style.height=(g=y)/s+"px"}else c.style.height&&(c.style.height="");let x=k?u.top-g-p-w.y:u.bottom+p+w.y,S=b+m;if(!0!==h.overlap)for(let t of o)t.left<S&&t.right>b&&t.top<x+g&&t.bottom>x&&(x=k?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(x-t.parent.top)/s+"px",c.style.left=(b-t.parent.left)/r+"px"):(c.style.top=x/s+"px",c.style.left=b/r+"px"),f){let t=u.left+(v?w.x:-w.x)-(b+14-7);f.style.left=t/r+"px"}!0!==h.overlap&&o.push({left:b,top:x,right:S,bottom:x+g}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),h.positioned&&h.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=cs}},{eventObservers:{scroll(){this.maybeMeasure()}}}),gs=zr.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"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"}}}),ws={x:0,y:0},vs=H.define({enables:[ms,gs]}),bs=H.define();class ks{static create(t){return new ks(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new us(t,bs,(t=>this.createHostedView(t)))}createHostedView(t){let e=t.create(this.view);return e.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(e.dom),this.mounted&&e.mount&&e.mount(this.view),e}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(void 0!==n)if(void 0===e)e=n;else if(e!==n)return}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const ys=vs.compute([bs],(t=>{let e=t.facet(bs).filter((t=>t));return 0===e.length?null:{pos:Math.min(...e.map((t=>t.pos))),end:Math.max(...e.map((t=>{var e;return null!==(e=t.end)&&void 0!==e?e:t.pos}))),create:ks.create,above:e[0].above,arrow:e.some((t=>t.arrow))}}));class xs{constructor(t,e,i,n,r){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((()=>this.startHover()),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.nearest(e.target);if(!i)return;let n,r=1;if(i instanceof He)n=i.posAtStart;else{if(n=t.posAtCoords(e),null==n)return;let i=t.coordsAtPos(n);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let s=t.bidiSpans(t.state.doc.lineAt(n)).find((t=>t.from<=n&&t.to>=n)),o=s&&s.dir==zi.RTL?-1:1;r=e.x<i.left?-o:o}let s=this.source(t,n,r);if(null==s?void 0:s.then){let e=this.pending={pos:n};s.then((i=>{this.pending==e&&(this.pending=null,i&&t.dispatch({effects:this.setHover.of(i)}))}),(e=>bi(t.state,e,"hover tooltip")))}else s&&t.dispatch({effects:this.setHover.of(s)})}get tooltip(){let t=this.view.plugin(ms),e=t?t.manager.tooltips.findIndex((t=>t.create==ks.create)):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:n}=this;if(i&&n&&!function(t,e){let i=t.getBoundingClientRect();return e.clientX>=i.left-Ss&&e.clientX<=i.right+Ss&&e.clientY>=i.top-Ss&&e.clientY<=i.bottom+Ss}(n.dom,t)||this.pending){let{pos:n}=i||this.pending,r=null!==(e=null==i?void 0:i.end)&&void 0!==e?e:n;(n==r?this.view.posAtCoords(this.lastMove)==n:function(t,e,i,n,r,s){let o=t.scrollDOM.getBoundingClientRect(),a=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>n||o.right<n||o.top>r||Math.min(o.bottom,a)<r)return!1;let l=t.posAtCoords({x:n,y:r},!1);return l>=e&&l<=i}(this.view,n,r,t.clientX,t.clientY))||(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Ss=4;function As(t,e={}){let i=ut.define(),n=$.define({create:()=>null,update(t,n){if(t&&(e.hideOnChange&&(n.docChanged||n.selection)||e.hideOn&&e.hideOn(n,t)))return null;if(t&&n.docChanged){let e=n.changes.mapPos(t.pos,-1,C.TrackDel);if(null==e)return null;let i=Object.assign(Object.create(null),t);i.pos=e,null!=t.end&&(i.end=n.changes.mapPos(t.end)),t=i}for(let e of n.effects)e.is(i)&&(t=e.value),e.is(Ms)&&(t=null);return t},provide:t=>bs.from(t)});return[n,Si.define((r=>new xs(r,t,n,i,e.hoverTime||300))),ys]}const Ms=ut.define(),Cs=H.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function Ts(t,e){let i=t.plugin(Ds),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const Ds=Si.fromClass(class{constructor(t){this.input=t.state.facet(Es),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(Cs);this.top=new Os(t,!0,e.topContainer),this.bottom=new Os(t,!1,e.bottomContainer),this.top.sync(this.panels.filter((t=>t.top))),this.bottom.sync(this.panels.filter((t=>!t.top)));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(Cs);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Os(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Os(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Es);if(i!=this.input){let e=i.filter((t=>t)),n=[],r=[],s=[],o=[];for(let i of e){let e,a=this.specs.indexOf(i);a<0?(e=i(t.view),o.push(e)):(e=this.panels[a],e.update&&e.update(t)),n.push(e),(e.top?r:s).push(e)}this.specs=e,this.panels=n,this.top.sync(r),this.bottom.sync(s);for(let t of 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=>zr.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class Os{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));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=Ls(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Ls(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 Ls(t){let e=t.nextSibling;return t.remove(),e}const Es=H.define({enables:Ds});class Bs extends At{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Bs.prototype.elementClass="",Bs.prototype.toDOM=void 0,Bs.prototype.mapMode=C.TrackBefore,Bs.prototype.startSide=Bs.prototype.endSide=-1,Bs.prototype.point=!0;const Ps=H.define(),Ns={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Dt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Rs=H.define();function zs(t){return[Vs(),Rs.of(Object.assign(Object.assign({},Ns),t))]}const Is=H.define({combine:t=>t.some((t=>t))});function Vs(t){let e=[Hs];return t&&!1===t.fixed&&e.push(Is.of(!0)),e}const Hs=Si.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Rs).map((e=>new _s(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(Is),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(Is)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=Dt.iter(this.view.state.facet(Ps),this.view.viewport.from),n=[],r=this.gutters.map((t=>new qs(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let s of t.type)if(s.type==Ze.Text&&e){Fs(i,n,s.from);for(let t of r)t.line(this.view,s,n);e=!1}else if(s.widget)for(let t of r)t.widget(this.view,s)}else if(t.type==Ze.Text){Fs(i,n,t.from);for(let e of r)e.line(this.view,t,n)}else if(t.widget)for(let e of r)e.widget(this.view,t);for(let t of r)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(Rs),i=t.state.facet(Rs),n=t.docChanged||t.heightChanged||t.viewportChanged||!Dt.eq(t.startState.facet(Ps),t.state.facet(Ps),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let r=[];for(let n of i){let i=e.indexOf(n);i<0?r.push(new _s(this.view,n)):(this.gutters[i].update(t),r.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),r.indexOf(t)<0&&t.destroy();for(let t of r)this.dom.appendChild(t.dom);this.gutters=r}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>zr.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==zi.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function Ws(t){return Array.isArray(t)?t:[t]}function Fs(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class qs{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=Dt.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,r=(e.top-this.height)/t.scaleY,s=e.height/t.scaleY;if(this.i==n.elements.length){let e=new js(t,s,r,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,s,r,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];Fs(this.cursor,n,e.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(t,e,n);r&&n.unshift(r);let s=this.gutter;(0!=n.length||s.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e);i&&this.addElement(t,e,[i])}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class _s{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(n=>{let r,s=n.target;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let t=s.getBoundingClientRect();r=(t.top+t.bottom)/2}else r=n.clientY;let o=t.lineBlockAtHeight(r-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=Ws(e.markers(t)),e.initialSpacer&&(this.spacer=new js(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=Ws(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!Dt.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 js{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),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,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,s=0;;){let o=s,a=r<e.length?e[r++]:null,l=!1;if(a){let t=a.elementClass;t&&(i+=" "+t);for(let t=s;t<this.markers.length;t++)if(this.markers[t].compare(a)){o=t,l=!0;break}}else o=this.markers.length;for(;s<o;){let t=this.markers[s++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!a)break;a.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(a.toDOM(t),n)),l&&s++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}const Ks=H.define(),$s=H.define({combine:t=>St(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],r=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||r(t,e,i):r}return i}})});class Gs extends Bs{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function Us(t,e){return t.state.facet($s).formatNumber(e,t.state)}const Ys=Rs.compute([$s],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(Ks),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new Gs(Us(t,t.state.doc.lineAt(e.from).number)),widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet($s)!=t.state.facet($s),initialSpacer:t=>new Gs(Us(t,Xs(t.state.doc.lines))),updateSpacer(t,e){let i=Us(e.view,Xs(e.view.state.doc.lines));return i==t.number?t:new Gs(i)},domEventHandlers:t.facet($s).domEventHandlers})));function Js(t={}){return[$s.of(t),Vs(),Ys]}function Xs(t){let e=9;for(;e<t;)e=10*e+9;return e}const Zs=1024;let Qs=0;class to{constructor(t,e){this.from=t,this.to=e}}class eo{constructor(t={}){this.id=Qs++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=ro.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}eo.closedBy=new eo({deserialize:t=>t.split(" ")}),eo.openedBy=new eo({deserialize:t=>t.split(" ")}),eo.group=new eo({deserialize:t=>t.split(" ")}),eo.contextHash=new eo({perNode:!0}),eo.lookAhead=new eo({perNode:!0}),eo.mounted=new eo({perNode:!0});class io{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[eo.mounted.id]}}const no=Object.create(null);class ro{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):no,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new ro(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}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(eo.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 n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(eo.group),n=-1;n<(i?i.length:0);n++){let r=e[n<0?t.name:i[n]];if(r)return r}}}}ro.none=new ro("",Object.create(null),0,8);class so{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);t&&(n||(n=Object.assign({},i.props)),n[t[0].id]=t[1])}e.push(n?new ro(i.name,n,i.id,i.flags):i)}return new so(e)}}const oo=new WeakMap,ao=new WeakMap;var lo;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(lo||(lo={}));class ho{constructor(t,e,i,n,r){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[t,e]of r)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=io.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 So(this.topNode,t)}cursorAt(t,e=0,i=0){let n=oo.get(this)||this.topNode,r=new So(n);return r.moveTo(t,e),oo.set(this,r._tree),r}get topNode(){return new go(this,0,0,null)}resolve(t,e=0){let i=po(oo.get(this)||this.topNode,t,e,!1);return oo.set(this,i),i}resolveInner(t,e=0){let i=po(ao.get(this)||this.topNode,t,e,!0);return ao.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),r=null;for(let t=n instanceof go?n:n.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(r||(r=[n])).push(s.resolve(e,i)),t=s}else{let s=io.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new go(s.tree,s.overlay[0].from+t.from,-1,t);(r||(r=[n])).push(po(o,e,i,!1))}}return r?yo(r):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:r=this.length}=t,s=t.mode||0,o=(s&lo.IncludeAnonymous)>0;for(let t=this.cursor(s|lo.IncludeAnonymous);;){let s=!1;if(t.from<=r&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;s=!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:To(ro.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new ho(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new ho(ro.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:r=Zs,reused:s=[],minRepeatType:o=n.types.length}=t,a=Array.isArray(i)?new co(i,i.length):i,l=n.types,h=0,c=0;function u(t,e,i,g,w,v){let{id:b,start:k,end:y,size:x}=a,S=c;for(;x<0;){if(a.next(),-1==x){let e=s[b];return i.push(e),void g.push(k-t)}if(-3==x)return void(h=b);if(-4==x)return void(c=b);throw new RangeError(`Unrecognized record size: ${x}`)}let A,M,C=l[b],T=k-t;if(y-k<=r&&(M=function(t,e){let i=a.fork(),n=0,s=0,l=0,h=i.end-r,c={size:0,start:0,skip:0};t:for(let r=i.pos-t;i.pos>r;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=l,l+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<r||i.start<h)break;let u=i.id>=o?4:0,d=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}s=d,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=l),c.size>4?c:void 0}(a.pos-e,w))){let e=new Uint16Array(M.size-M.skip),i=a.pos-M.size,r=e.length;for(;a.pos>i;)r=m(M.start,e,r);A=new uo(e,y-M.start,n),T=M.start-t}else{let t=a.pos-x;a.next();let e=[],i=[],n=b>=o?b:-1,s=0,l=y;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=l-r&&(f(e,i,k,s,a.end,l,n,S),s=e.length,l=a.end),a.next()):v>2500?d(k,t,e,i):u(k,t,e,i,n,v+1);if(n>=0&&s>0&&s<e.length&&f(e,i,k,s,k,l,n,S),e.reverse(),i.reverse(),n>-1&&s>0){let t=function(t){return(e,i,n)=>{let r,s,o=0,a=e.length-1;if(a>=0&&(r=e[a])instanceof ho){if(!a&&r.type==t&&r.length==n)return r;(s=r.prop(eo.lookAhead))&&(o=i[a]+r.length+s)}return p(t,e,i,n,o)}}(C);A=To(C,e,i,0,e.length,0,y-k,t,t)}else A=p(C,e,i,y-k,S-y)}i.push(A),g.push(T)}function d(t,e,i,s){let o=[],l=0,h=-1;for(;a.pos>e;){let{id:t,start:e,end:i,size:n}=a;if(n>4)a.next();else{if(h>-1&&e<h)break;h<0&&(h=i-r),o.push(t,e,i),l++,a.next()}}if(l){let e=new Uint16Array(4*l),r=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]-r,e[i++]=o[t+2]-r,e[i++]=i;i.push(new uo(e,o[2]-r,n)),s.push(r-t)}}function f(t,e,i,r,s,o,a,l){let h=[],c=[];for(;t.length>r;)h.push(t.pop()),c.push(e.pop()+i-s);t.push(p(n.types[a],h,c,o-s,l-o)),e.push(s-i)}function p(t,e,i,n,r=0,s){if(h){let t=[eo.contextHash,h];s=s?[t].concat(s):[t]}if(r>25){let t=[eo.lookAhead,r];s=s?[t].concat(s):[t]}return new ho(t,e,i,n,s)}function m(t,e,i){let{id:n,start:r,end:s,size:l}=a;if(a.next(),l>=0&&n<o){let o=i;if(l>4){let n=a.pos-(l-4);for(;a.pos>n;)i=m(t,e,i)}e[--i]=o,e[--i]=s-t,e[--i]=r-t,e[--i]=n}else-3==l?h=n:-4==l&&(c=n);return i}let g=[],w=[];for(;a.pos>0;)u(t.start||0,t.bufferStart||0,g,w,-1,0);let v=null!==(e=t.length)&&void 0!==e?e:g.length?w[0]+g[0].length:0;return new ho(l[t.topID],g.reverse(),w.reverse(),v)}(t)}}ho.empty=new ho(ro.none,[],[],0);class co{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 co(this.buffer,this.index)}}class uo{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ro.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),i==(t+=4))return r;let s=[];for(;t<i;)s.push(this.childString(t)),t=this.buffer[t+3];return r+"("+s.join(",")+")"}findChild(t,e,i,n,r){let{buffer:s}=this,o=-1;for(let a=t;a!=e&&!(fo(r,n,s[a+1],s[a+2])&&(o=a,i>0));a=s[a+3]);return o}slice(t,e,i){let n=this.buffer,r=new Uint16Array(e-t),s=0;for(let o=t,a=0;o<e;){r[a++]=n[o++],r[a++]=n[o++]-i;let e=r[a++]=n[o++]-i;r[a++]=n[o++]-t,s=Math.max(s,e)}return new uo(r,s,this.set)}}function fo(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function po(t,e,i,n){for(var r;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof go&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=n?0:lo.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof go&&n.index<0&&(null===(r=o.enter(e,i,s))||void 0===r?void 0:r.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,s);if(!n)return t;t=n}}class mo{cursor(t=0){return new So(this,t)}getChild(t,e=null,i=null){let n=wo(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return wo(this,t,e,i)}resolve(t,e=0){return po(this,t,e,!1)}resolveInner(t,e=0){return po(this,t,e,!0)}matchContext(t){return vo(this,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 go extends mo{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,r=0){for(let s=this;;){for(let{children:o,positions:a}=s._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],h=a[t]+s.from;if(fo(n,i,h,h+l.length))if(l instanceof uo){if(r&lo.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-h,n);if(o>-1)return new ko(new bo(s,l,t,h),null,o)}else if(r&lo.IncludeAnonymous||!l.type.isAnonymous||Ao(l)){let o;if(!(r&lo.IgnoreMounts)&&(o=io.get(l))&&!o.overlay)return new go(o.tree,h,t,s);let a=new go(l,h,t,s);return r&lo.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(r&lo.IncludeAnonymous||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,s=s._parent,!s)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 n;if(!(i&lo.IgnoreOverlays)&&(n=io.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:r}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?r>=i:r>i))return new go(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function wo(t,e,i,n){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(null!=i)for(;!r.type.is(i);)if(!r.nextSibling())return s;for(;;){if(null!=n&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return null==n?s:[]}}function vo(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class bo{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class ko extends mo{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return r<0?null:new ko(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&lo.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new ko(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new ko(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 ko(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let s=i.buffer[this.index+1];t.push(i.slice(n,r,s)),e.push(0)}return new ho(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function yo(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let r=t[n];(r.from>i.from||r.to<i.to)&&(i=r,e=n)}let n=i instanceof go&&i.index<0?null:i.parent,r=t.slice();return n?r[e]=n:r.splice(e,1),new xo(r,i)}class xo{constructor(t,e){this.heads=t,this.node=e}get next(){return yo(this.heads)}}class So{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 go)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:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof go?(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:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&lo.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&lo.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&lo.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:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,r=t<0?-1:i._tree.children.length;n!=r;n+=t){let t=i._tree.children[n];if(this.mode&lo.IncludeAnonymous||t instanceof uo||!t.type.isAnonymous||Ao(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)t:for(let n=this.index,r=this.stack.length;r>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,i=r+1;break t}n=this.stack[--r]}for(let t=i;t<this.stack.length;t++)e=new ko(this.buffer,e,this.stack[t]);return this.bufferNode=new ko(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return vo(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return vo(this.node,t,n);let s=i[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}}function Ao(t){return t.children.some((t=>t instanceof uo||!t.type.isAnonymous||Ao(t)))}const Mo=new WeakMap;function Co(t,e){if(!t.isAnonymous||e instanceof uo||e.type!=t)return 1;let i=Mo.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof ho)){i=1;break}i+=Co(t,n)}Mo.set(e,i)}return i}function To(t,e,i,n,r,s,o,a,l){let h=0;for(let i=n;i<r;i++)h+=Co(t,e[i]);let c=Math.ceil(1.5*h/8),u=[],d=[];return function e(i,n,r,o,a){for(let h=r;h<o;){let r=h,f=n[h],p=Co(t,i[h]);for(h++;h<o;h++){let e=Co(t,i[h]);if(p+e>=c)break;p+=e}if(h==r+1){if(p>c){let t=i[r];e(t.children,t.positions,0,t.children.length,n[r]+a);continue}u.push(i[r])}else{let e=n[h-1]+i[h-1].length-f;u.push(To(t,i,n,r,h,f,e,null,l))}d.push(f+a-s)}}(e,i,n,r,0),(a||l)(u,d,o)}class Do{constructor(t,e,i,n,r=!1,s=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(r?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new Do(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],r=1,s=t.length?t[0]:null;for(let o=0,a=0,l=0;;o++){let h=o<e.length?e[o]:null,c=h?h.fromA:1e9;if(c-a>=i)for(;s&&s.from<c;){let e=s;if(a>=e.from||c<=e.to||l){let t=Math.max(e.from,a)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new Do(t,i,e.tree,e.offset+l,o>0,!!h)}if(e&&n.push(e),s.to>c)break;s=r<t.length?t[r++]:null}if(!h)break;a=h.toA,l=h.toA-h.toB}return n}}class Oo{startParse(t,e,i){return"string"==typeof t&&(t=new Lo(t)),i=i?i.length?i.map((t=>new to(t.from,t.to))):[new to(0,0)]:[new to(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class Lo{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 eo({perNode:!0});let Eo=0;class Bo{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=Eo++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new Bo([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new No;return e=>e.modified.indexOf(t)>-1?e:No.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let Po=0;class No{constructor(){this.instances=[],this.id=Po++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,r=i.modified,n.length==r.length&&n.every(((t,e)=>t==r[e])));var n,r}));if(i)return i;let n=[],r=new Bo(n,t,e);for(let t of e)t.instances.push(r);let s=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].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 s)n.push(No.get(e,t));return r}}function Ro(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],r=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){r=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){r=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let o=i.length-1,a=i[o];if(!a)throw new RangeError("Invalid path: "+t);let l=new Io(n,r,o>0?i.slice(0,o):null);e[a]=l.sort(e[a])}}return zo.add(e)}const zo=new eo;class Io{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}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 Vo(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:n,all:r=null}=e||{};return{style:t=>{let e=r;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function Ho(t,e,i,n=0,r=t.length){let s=new Wo(n,Array.isArray(e)?e:[e],i);s.highlightRange(t.cursor(),n,r,"",s.highlighters),s.flush(r)}Io.empty=new Io([],2,null);class Wo{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,r){let{type:s,from:o,to:a}=t;if(o>=i||a<=e)return;s.isTop&&(r=this.highlighters.filter((t=>!t.scope||t.scope(s))));let l=n,h=function(t){let e=t.type.prop(zo);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||Io.empty,c=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(r,h.tags);if(c&&(l&&(l+=" "),l+=c,1==h.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(e,o),l),h.opaque)return;let u=t.tree&&t.tree.prop(eo.mounted);if(u&&u.overlay){let s=t.node.enter(u.overlay[0].from+o,1),h=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),c=t.firstChild();for(let d=0,f=o;;d++){let p=d<u.overlay.length?u.overlay[d]:null,m=p?p.from+o:a,g=Math.max(e,f),w=Math.min(i,m);if(g<w&&c)for(;t.from<w&&(this.highlightRange(t,g,w,n,r),this.startSpan(Math.min(w,t.to),l),!(t.to>=m)&&t.nextSibling()););if(!p||m>i)break;f=p.to+o,f>e&&(this.highlightRange(s.cursor(),Math.max(e,p.from+o),Math.min(i,f),"",h),this.startSpan(Math.min(i,f),l))}c&&t.parent()}else if(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,r),this.startSpan(Math.min(i,t.to),l)}}while(t.nextSibling());t.parent()}}}const Fo=Bo.define,qo=Fo(),_o=Fo(),jo=Fo(_o),Ko=Fo(_o),$o=Fo(),Go=Fo($o),Uo=Fo($o),Yo=Fo(),Jo=Fo(Yo),Xo=Fo(),Zo=Fo(),Qo=Fo(),ta=Fo(Qo),ea=Fo(),ia={comment:qo,lineComment:Fo(qo),blockComment:Fo(qo),docComment:Fo(qo),name:_o,variableName:Fo(_o),typeName:jo,tagName:Fo(jo),propertyName:Ko,attributeName:Fo(Ko),className:Fo(_o),labelName:Fo(_o),namespace:Fo(_o),macroName:Fo(_o),literal:$o,string:Go,docString:Fo(Go),character:Fo(Go),attributeValue:Fo(Go),number:Uo,integer:Fo(Uo),float:Fo(Uo),bool:Fo($o),regexp:Fo($o),escape:Fo($o),color:Fo($o),url:Fo($o),keyword:Xo,self:Fo(Xo),null:Fo(Xo),atom:Fo(Xo),unit:Fo(Xo),modifier:Fo(Xo),operatorKeyword:Fo(Xo),controlKeyword:Fo(Xo),definitionKeyword:Fo(Xo),moduleKeyword:Fo(Xo),operator:Zo,derefOperator:Fo(Zo),arithmeticOperator:Fo(Zo),logicOperator:Fo(Zo),bitwiseOperator:Fo(Zo),compareOperator:Fo(Zo),updateOperator:Fo(Zo),definitionOperator:Fo(Zo),typeOperator:Fo(Zo),controlOperator:Fo(Zo),punctuation:Qo,separator:Fo(Qo),bracket:ta,angleBracket:Fo(ta),squareBracket:Fo(ta),paren:Fo(ta),brace:Fo(ta),content:Yo,heading:Jo,heading1:Fo(Jo),heading2:Fo(Jo),heading3:Fo(Jo),heading4:Fo(Jo),heading5:Fo(Jo),heading6:Fo(Jo),contentSeparator:Fo(Yo),list:Fo(Yo),quote:Fo(Yo),emphasis:Fo(Yo),strong:Fo(Yo),link:Fo(Yo),monospace:Fo(Yo),strikethrough:Fo(Yo),inserted:Fo(),deleted:Fo(),changed:Fo(),invalid:Fo(),meta:ea,documentMeta:Fo(ea),annotation:Fo(ea),processingInstruction:Fo(ea),definition:Bo.defineModifier(),constant:Bo.defineModifier(),function:Bo.defineModifier(),standard:Bo.defineModifier(),local:Bo.defineModifier(),special:Bo.defineModifier()};var na;Vo([{tag:ia.link,class:"tok-link"},{tag:ia.heading,class:"tok-heading"},{tag:ia.emphasis,class:"tok-emphasis"},{tag:ia.strong,class:"tok-strong"},{tag:ia.keyword,class:"tok-keyword"},{tag:ia.atom,class:"tok-atom"},{tag:ia.bool,class:"tok-bool"},{tag:ia.url,class:"tok-url"},{tag:ia.labelName,class:"tok-labelName"},{tag:ia.inserted,class:"tok-inserted"},{tag:ia.deleted,class:"tok-deleted"},{tag:ia.literal,class:"tok-literal"},{tag:ia.string,class:"tok-string"},{tag:ia.number,class:"tok-number"},{tag:[ia.regexp,ia.escape,ia.special(ia.string)],class:"tok-string2"},{tag:ia.variableName,class:"tok-variableName"},{tag:ia.local(ia.variableName),class:"tok-variableName tok-local"},{tag:ia.definition(ia.variableName),class:"tok-variableName tok-definition"},{tag:ia.special(ia.variableName),class:"tok-variableName2"},{tag:ia.definition(ia.propertyName),class:"tok-propertyName tok-definition"},{tag:ia.typeName,class:"tok-typeName"},{tag:ia.namespace,class:"tok-namespace"},{tag:ia.className,class:"tok-className"},{tag:ia.macroName,class:"tok-macroName"},{tag:ia.propertyName,class:"tok-propertyName"},{tag:ia.operator,class:"tok-operator"},{tag:ia.comment,class:"tok-comment"},{tag:ia.meta,class:"tok-meta"},{tag:ia.invalid,class:"tok-invalid"},{tag:ia.punctuation,class:"tok-punctuation"}]);const ra=new eo;const sa=new eo;class oa{constructor(t,e,i=[],n=""){this.data=t,this.name=n,xt.prototype.hasOwnProperty("tree")||Object.defineProperty(xt.prototype,"tree",{get(){return la(this)}}),this.parser=e,this.extension=[wa.of(this),xt.languageData.of(((t,e,i)=>{let n=aa(t,e,i),r=n.type.prop(ra);if(!r)return[];let s=t.facet(r),o=n.type.prop(sa);if(o){let r=n.resolve(e-n.from,i);for(let e of o)if(e.test(r,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(s)}}return s}))].concat(i)}isActiveAt(t,e,i=-1){return aa(t,e,i).type.prop(ra)==this.data}findRegions(t){let e=t.facet(wa);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(ra)==this.data)return void i.push({from:e,to:e+t.length});let r=t.prop(eo.mounted);if(r){if(r.tree.prop(ra)==this.data){if(r.overlay)for(let t of r.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(r.overlay){let t=i.length;if(n(r.tree,r.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let r=t.children[i];r instanceof ho&&n(r,t.positions[i]+e)}};return n(la(t),0),i}get allowsNesting(){return!0}}function aa(t,e,i){let n=t.facet(wa),r=la(t).topNode;if(!n||n.allowsNesting)for(let t=r;t;t=t.enter(e,i,lo.ExcludeBuffers))t.type.isTop&&(r=t);return r}function la(t){let e=t.field(oa.state,!1);return e?e.tree:ho.empty}oa.setState=ut.define();class ha{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 ca=null;class ua{constructor(t,e,i=[],n,r,s,o,a){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new ua(t,e,[],ho.empty,0,i,[],null)}startParse(){return this.parser.startParse(new ha(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=ho.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 n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(Do.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,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(Do.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=ca;ca=this;try{return t()}finally{ca=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=da(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,r)=>e.push({fromA:t,toA:i,fromB:n,toB:r}))),i=Do.applyChanges(i,e),n=ho.empty,r=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&o.push({from:i,to:n})}}}return new ua(this.parser,e,i,n,r,s,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:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=da(this.fragments,i,n),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 Oo{createParse(e,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let e=ca;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new ho(ro.none,[],[],s-r)},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 ca}}function da(t,e,i){return Do.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class fa{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 fa(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=ua.create(t.facet(wa).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new fa(i)}}oa.state=$.define({create:fa.init,update(t,e){for(let t of e.effects)if(t.is(oa.setState))return t.value;return e.startState.facet(wa)!=e.state.facet(wa)?fa.init(e.state):t.apply(e)}});let pa=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(pa=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const ma="undefined"!=typeof navigator&&(null===(na=navigator.scheduling)||void 0===na?void 0:na.isInputPending)?()=>navigator.scheduling.isInputPending():null,ga=Si.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(oa.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(oa.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=pa(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(oa.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!ma?Math.max(25,t.timeRemaining()-5):1e9),o=r.context.treeLen<n&&i.doc.length>n+1e3,a=r.context.work((()=>ma&&ma()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:oa.setState.of(new fa(r.context))})),this.chunkBudget>0&&(!a||o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>bi(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()}}}),wa=H.define({combine:t=>t.length?t[0]:null,enables:t=>[oa.state,ga,zr.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});class va{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const ba=H.define(),ka=H.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 new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function ya(t){let e=t.facet(ka);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function xa(t,e){let i="",n=t.tabSize,r=t.facet(ka)[0];if("\t"==r){for(;e>=n;)i+="\t",e-=n;r=" "}for(let t=0;t<e;t++)i+=r;return i}function Sa(t,e){t instanceof xt&&(t=new Aa(t));for(let i of t.state.facet(ba)){let n=i(t,e);if(void 0!==n)return n}let i=la(t.state);return i.length>=e?function(t,e,i){let n=e.resolveStack(i),r=n.node.enterUnfinishedNodesBefore(i);if(r!=n.node){let t=[];for(let e=r;e!=n.node;e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Ca(n,t,i)}(t,i,e):null}class Aa{constructor(t,e={}){this.state=t,this.options=e,this.unit=ya(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return null!=n&&n>=i.from&&n<=i.to?r&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.countColumn(i,t-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return s>-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return Wt(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let t=r(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ma=new eo;function Ca(t,e,i){for(let n=t;n;n=n.next){let t=Ta(n.node);if(t)return t(Oa.create(e,i,n))}return 0}function Ta(t){let e=t.type.prop(Ma);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(eo.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>function(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==t.pos+o,l=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(i.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let t=i.to;;){let r=e.childAfter(t);if(!r||r==n)return null;if(!r.type.isSkipped)return r.from<o?i:null;t=r.to}}(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*i)}(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?Da:null}function Da(){return 0}class Oa extends Aa{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 Oa(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(La(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Ca(this.context.next,this.base,this.pos)}}function La(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}class Ea{constructor(t,e){let i;function n(t){let e=jt.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const r="string"==typeof e.all?e.all:e.all?n(e.all):void 0,s=e.scope;this.scope=s instanceof oa?t=>t.prop(ra)==s.data:s?t=>t==s:void 0,this.style=Vo(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:r}).style,this.module=i?new jt(i):null,this.themeType=e.themeType}static define(t,e){return new Ea(t,e||{})}}const Ba=H.define(),Pa=H.define({combine:t=>t.length?[t[0]]:null});function Na(t){let e=t.facet(Ba);return e.length?e:t.facet(Pa)}function Ra(t,e){let i,n=[Ia];return t instanceof Ea&&(t.module&&n.push(zr.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(Pa.of(t)):i?n.push(Ba.computeN([zr.darkTheme],(e=>e.facet(zr.darkTheme)==("dark"==i)?[t]:[]))):n.push(Ba.of(t)),n}class za{constructor(t){this.markCache=Object.create(null),this.tree=la(t.state),this.decorations=this.buildDeco(t,Na(t.state))}update(t){let e=la(t.state),i=Na(t.state),n=i!=Na(t.startState);e.length<t.view.viewport.to&&!n&&e.type==this.tree.type?this.decorations=this.decorations.map(t.changes):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i))}buildDeco(t,e){if(!e||!this.tree.length)return Qe.none;let i=new Ot;for(let{from:n,to:r}of t.visibleRanges)Ho(this.tree,e,((t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=Qe.mark({class:n})))}),n,r);return i.finish()}}const Ia=U.high(Si.fromClass(za,{decorations:t=>t.decorations})),Va=Ea.define([{tag:ia.meta,color:"#404740"},{tag:ia.link,textDecoration:"underline"},{tag:ia.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ia.emphasis,fontStyle:"italic"},{tag:ia.strong,fontWeight:"bold"},{tag:ia.strikethrough,textDecoration:"line-through"},{tag:ia.keyword,color:"#708"},{tag:[ia.atom,ia.bool,ia.url,ia.contentSeparator,ia.labelName],color:"#219"},{tag:[ia.literal,ia.inserted],color:"#164"},{tag:[ia.string,ia.deleted],color:"#a11"},{tag:[ia.regexp,ia.escape,ia.special(ia.string)],color:"#e40"},{tag:ia.definition(ia.variableName),color:"#00f"},{tag:ia.local(ia.variableName),color:"#30a"},{tag:[ia.typeName,ia.namespace],color:"#085"},{tag:ia.className,color:"#167"},{tag:[ia.special(ia.variableName),ia.macroName],color:"#256"},{tag:ia.definition(ia.propertyName),color:"#00c"},{tag:ia.comment,color:"#940"},{tag:ia.invalid,color:"#f00"}]),Ha=1e4,Wa="()[]{}",Fa=new eo;function qa(t,e,i){let n=t.prop(e<0?eo.openedBy:eo.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function _a(t){let e=t.type.prop(Fa);return e?e(t.node):t}function ja(t,e,i,n={}){let r=n.maxScanDistance||Ha,s=n.brackets||Wa,o=la(t),a=o.resolveInner(e,i);for(let t=a;t;t=t.parent){let n=qa(t.type,i,s);if(n&&t.from<t.to){let r=_a(t);if(r&&(i>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return Ka(0,0,i,t,r,n,s)}}return function(t,e,i,n,r,s,o){let a=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(a);if(l<0||l%2==0!=i>0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=s;){let s=c.value;i<0&&(t+=s.length);let a=e+t*i;for(let t=i>0?0:s.length-1,e=i>0?s.length:-1;t!=e;t+=i){let e=o.indexOf(s[t]);if(!(e<0||n.resolveInner(a+t,1).type!=r))if(e%2==0==i>0)u++;else{if(1==u)return{start:h,end:{from:a+t,to:a+t+1},matched:e>>1==l>>1};u--}}i>0&&(t+=s.length)}return c.done?{start:h,matched:!1}:null}(t,e,i,o,a.type,r,s)}function Ka(t,e,i,n,r,s,o){let a=n.parent,l={from:r.from,to:r.to},h=0,c=null==a?void 0:a.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do{if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&s.indexOf(c.type.name)>-1&&c.from<c.to){let t=_a(c);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(qa(c.type,i,o))h++;else if(qa(c.type,-i,o)){if(0==h){let t=_a(c);return{start:l,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}h--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}function $a(t,e,i,n=0,r=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=r;for(let r=n;r<e;r++)9==t.charCodeAt(r)?s+=i-s%i:s++;return s}class Ga{constructor(t,e,i,n){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,i=this.string.charAt(this.pos);if(e="string"==typeof t?i==t:i&&(t instanceof RegExp?t.test(i):t(i)),e)return++this.pos,i}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=$a(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!==(t=this.overrideIndent)&&void 0!==t?t:$a(this.string,null,this.tabSize)}match(t,e,i){if("string"==typeof t){let n=t=>i?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function Ua(t){if("object"!=typeof t)return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}const Ya=new WeakMap;class Ja extends oa{constructor(t){let e,i=(r=t.languageData,H.define({combine:r?t=>t.concat(r):void 0})),n={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||Ua,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||el};var r,s;super(i,new class extends Oo{createParse(t,i,n){return new Qa(e,t,i,n)}},[ba.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=ro.define({id:il.length,name:"Document",props:[ra.add((()=>t))],top:!0});return il.push(e),e}(i),e=this,this.streamParser=n,this.stateAfter=new eo({perNode:!0}),this.tokenTable=t.tokenTable?new al(n.tokenTable):ll}static define(t){return new Ja(t)}getIndent(t,e){let i,n=la(t.state),r=n.resolve(e);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let{overrideIndentation:s}=t.options;s&&(i=Ya.get(t.state),null!=i&&i<e-1e4&&(i=void 0));let o,a,l=Xa(this,n,0,r.from,null!=i?i:e);if(l?(a=l.state,o=l.pos+1):(a=this.streamParser.startState(t.unit),o=0),e-o>1e4)return null;for(;o<e;){let i=t.state.doc.lineAt(o),n=Math.min(e,i.to);if(i.length){let e=s?s(i.from):-1,r=new Ga(i.text,t.state.tabSize,t.unit,e<0?void 0:e);for(;r.pos<n-i.from;)tl(this.streamParser.token,r,a)}else this.streamParser.blankLine(a,t.unit);if(n==e)break;o=i.to+1}let h=t.lineAt(e);return s&&null==i&&Ya.set(t.state,h.from),this.streamParser.indent(a,/^\s*(.*)/.exec(h.text)[1],t)}get allowsNesting(){return!1}}function Xa(t,e,i,n,r){let s=i>=n&&i+e.length<=r&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:i+e.length};for(let s=e.children.length-1;s>=0;s--){let o=e.children[s],a=i+e.positions[s],l=o instanceof ho&&a<r&&Xa(t,o,a,n,r);if(l)return l}return null}function Za(t,e,i,n,r){if(r&&i<=0&&n>=e.length)return e;r||e.type!=t.topNode||(r=!0);for(let s=e.children.length-1;s>=0;s--){let o,a=e.positions[s],l=e.children[s];if(a<n&&l instanceof ho){if(!(o=Za(t,l,i-a,n-a,r)))break;return r?new ho(e.type,e.children.slice(0,s).concat(o),e.positions.slice(0,s+1),a+o.length):o}}return null}class Qa{constructor(t,e,i,n){this.lang=t,this.input=e,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let r=ua.get(),s=n[0].from,{state:o,tree:a}=function(t,e,i,n){for(let n of e){let e,r=n.from+(n.openStart?25:0),s=n.to-(n.openEnd?25:0),o=r<=i&&s>i&&Xa(t,n.tree,0-n.offset,i,s);if(o&&(e=Za(t,n.tree,i+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?ya(n):4),tree:ho.empty}}(t,i,s,null==r?void 0:r.state);this.state=o,this.parsedPos=this.chunkStart=s+a.length;for(let t=0;t<a.children.length;t++)this.chunks.push(a.children[t]),this.chunkPos.push(a.positions[t]);r&&this.parsedPos<r.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(ya(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let t=ua.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+2048);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=i)break;if(e=e.slice(0,n-(i-e.length)),t++,t==this.ranges.length)break;let r=this.ranges[t].from,s=this.lineAfter(r);e+=s,i=r+s.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,r=t+e;if(i>0?n>r:n>=r)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,n,r){if(this.ranges.length>1){e+=r=this.skipGapsTo(e,r,1);let t=this.chunk.length;i+=r=this.skipGapsTo(i,r,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,i,n),r}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:r}=this.lang,s=new Ga(e,t?t.state.tabSize:4,t?ya(t.state):2);if(s.eol())r.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=tl(r.token,s,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,4,n)),s.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=ho.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:nl,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new ho(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new ho(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function tl(t,e,i){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,i);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const el=Object.create(null),il=[ro.none],nl=new so(il),rl=[],sl=Object.create(null),ol=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"]])ol[t]=cl(el,e);class al{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),ol)}resolve(t){return t?this.table[t]||(this.table[t]=cl(this.extra,t)):0}}const ll=new al(el);function hl(t,e){rl.indexOf(t)>-1||(rl.push(t),console.warn(e))}function cl(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||ia[i];n?"function"==typeof n?e.length?e=e.map(n):hl(i,`Modifier ${i} used at start of tag`):e.length?hl(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:hl(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+i.map((t=>t.id)),s=sl[r];if(s)return s.id;let o=sl[r]=ro.define({id:il.length,name:n,props:[Ro({[n]:i})]});return il.push(o),o.id}function ul(t){var e,i,n=t.statementIndent,r=t.jsonld,s=t.json||r,o=t.typescript,a=t.wordCharacters||/[\w$\xa1-\uffff]/,l=function(){function t(t){return{type:t,style:"keyword"}}var e=t("keyword a"),i=t("keyword b"),n=t("keyword c"),r=t("keyword d"),s=t("operator"),o={type:"atom",style:"atom"};return{if:t("if"),while:e,with:e,else:i,do:i,try:i,finally:i,return:r,break:r,continue:r,new:t("new"),delete:n,void:n,throw:n,debugger:t("debugger"),var:t("var"),const:t("var"),let:t("var"),function:t("function"),catch:t("catch"),for:t("for"),switch:t("switch"),case:t("case"),default:t("default"),in:s,typeof:s,instanceof:s,true:o,false:o,null:o,undefined:o,NaN:o,Infinity:o,this:t("this"),class:t("class"),super:t("atom"),yield:n,export:t("export"),import:t("import"),extends:n,await:n}}(),h=/[+\-*&%=<>!?|~^@]/,c=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function u(t,n,r){return e=t,i=r,n}function d(t,e){var i,n=t.next();if('"'==n||"'"==n)return e.tokenize=(i=n,function(t,e){var n,s=!1;if(r&&"@"==t.peek()&&t.match(c))return e.tokenize=d,u("jsonld-keyword","meta");for(;null!=(n=t.next())&&(n!=i||s);)s=!s&&"\\"==n;return s||(e.tokenize=d),u("string","string")}),e.tokenize(t,e);if("."==n&&t.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return u("number","number");if("."==n&&t.match(".."))return u("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return u(n);if("="==n&&t.eat(">"))return u("=>","operator");if("0"==n&&t.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return u("number","number");if(/\d/.test(n))return t.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),u("number","number");if("/"==n)return t.eat("*")?(e.tokenize=f,f(t,e)):t.eat("/")?(t.skipToEnd(),u("comment","comment")):function(t,e,i){return e.tokenize==d&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(e.lastType)||"quasi"==e.lastType&&/\{\s*$/.test(t.string.slice(0,t.pos-1))}(t,e)?(function(t){for(var e,i=!1,n=!1;null!=(e=t.next());){if(!i){if("/"==e&&!n)return;"["==e?n=!0:n&&"]"==e&&(n=!1)}i=!i&&"\\"==e}}(t),t.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(t.eat("="),u("operator","operator",t.current()));if("`"==n)return e.tokenize=p,p(t,e);if("#"==n&&"!"==t.peek())return t.skipToEnd(),u("meta","meta");if("#"==n&&t.eatWhile(a))return u("variable","property");if("<"==n&&t.match("!--")||"-"==n&&t.match("->")&&!/\S/.test(t.string.slice(0,t.start)))return t.skipToEnd(),u("comment","comment");if(h.test(n))return">"==n&&e.lexical&&">"==e.lexical.type||(t.eat("=")?"!"!=n&&"="!=n||t.eat("="):/[<>*+\-|&?]/.test(n)&&(t.eat(n),">"==n&&t.eat(n))),"?"==n&&t.eat(".")?u("."):u("operator","operator",t.current());if(a.test(n)){t.eatWhile(a);var s=t.current();if("."!=e.lastType){if(l.propertyIsEnumerable(s)){var o=l[s];return u(o.type,o.style,s)}if("async"==s&&t.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",s)}return u("variable","variable",s)}}function f(t,e){for(var i,n=!1;i=t.next();){if("/"==i&&n){e.tokenize=d;break}n="*"==i}return u("comment","comment")}function p(t,e){for(var i,n=!1;null!=(i=t.next());){if(!n&&("`"==i||"$"==i&&t.eat("{"))){e.tokenize=d;break}n=!n&&"\\"==i}return u("quasi","string.special",t.current())}var m="([{}])";function g(t,e){e.fatArrowAt&&(e.fatArrowAt=null);var i=t.string.indexOf("=>",t.start);if(!(i<0)){if(o){var n=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(t.string.slice(t.start,i));n&&(i=n.index)}for(var r=0,s=!1,l=i-1;l>=0;--l){var h=t.string.charAt(l),c=m.indexOf(h);if(c>=0&&c<3){if(!r){++l;break}if(0==--r){"("==h&&(s=!0);break}}else if(c>=3&&c<6)++r;else if(a.test(h))s=!0;else if(/["'\/`]/.test(h))for(;;--l){if(0==l)return;if(t.string.charAt(l-1)==h&&"\\"!=t.string.charAt(l-2)){l--;break}}else if(s&&!r){++l;break}}s&&!r&&(e.fatArrowAt=l)}}var w={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function v(t,e,i,n,r,s){this.indented=t,this.column=e,this.type=i,this.prev=r,this.info=s,null!=n&&(this.align=n)}function b(t,e){for(var i=t.localVars;i;i=i.next)if(i.name==e)return!0;for(var n=t.context;n;n=n.prev)for(i=n.vars;i;i=i.next)if(i.name==e)return!0}var k={state:null,column:null,marked:null,cc:null};function y(){for(var t=arguments.length-1;t>=0;t--)k.cc.push(arguments[t])}function x(){return y.apply(null,arguments),!0}function S(t,e){for(var i=e;i;i=i.next)if(i.name==t)return!0;return!1}function A(e){var i=k.state;if(k.marked="def",i.context)if("var"==i.lexical.info&&i.context&&i.context.block){var n=M(e,i.context);if(null!=n)return void(i.context=n)}else if(!S(e,i.localVars))return void(i.localVars=new D(e,i.localVars));t.globalVars&&!S(e,i.globalVars)&&(i.globalVars=new D(e,i.globalVars))}function M(t,e){if(e){if(e.block){var i=M(t,e.prev);return i?i==e.prev?e:new T(i,e.vars,!0):null}return S(t,e.vars)?e:new T(e.prev,new D(t,e.vars),!1)}return null}function C(t){return"public"==t||"private"==t||"protected"==t||"abstract"==t||"readonly"==t}function T(t,e,i){this.prev=t,this.vars=e,this.block=i}function D(t,e){this.name=t,this.next=e}var O=new D("this",new D("arguments",null));function L(){k.state.context=new T(k.state.context,k.state.localVars,!1),k.state.localVars=O}function E(){k.state.context=new T(k.state.context,k.state.localVars,!0),k.state.localVars=null}function B(){k.state.localVars=k.state.context.vars,k.state.context=k.state.context.prev}function P(t,e){var i=function(){var i=k.state,n=i.indented;if("stat"==i.lexical.type)n=i.lexical.indented;else for(var r=i.lexical;r&&")"==r.type&&r.align;r=r.prev)n=r.indented;i.lexical=new v(n,k.stream.column(),t,null,i.lexical,e)};return i.lex=!0,i}function N(){var t=k.state;t.lexical.prev&&(")"==t.lexical.type&&(t.indented=t.lexical.indented),t.lexical=t.lexical.prev)}function R(t){return function e(i){return i==t?x():";"==t||"}"==i||")"==i||"]"==i?y():x(e)}}function z(t,e){return"var"==t?x(P("vardef",e),kt,R(";"),N):"keyword a"==t?x(P("form"),W,z,N):"keyword b"==t?x(P("form"),z,N):"keyword d"==t?k.stream.match(/^\s*$/,!1)?x():x(P("stat"),q,R(";"),N):"debugger"==t?x(R(";")):"{"==t?x(P("}"),E,rt,N,B):";"==t?x():"if"==t?("else"==k.state.lexical.info&&k.state.cc[k.state.cc.length-1]==N&&k.state.cc.pop()(),x(P("form"),W,z,N,Ct)):"function"==t?x(Lt):"for"==t?x(P("form"),E,Tt,z,B,N):"class"==t||o&&"interface"==e?(k.marked="keyword",x(P("form","class"==t?t:e),Rt,N)):"variable"==t?o&&"declare"==e?(k.marked="keyword",x(z)):o&&("module"==e||"enum"==e||"type"==e)&&k.stream.match(/^\s*\w/,!1)?(k.marked="keyword","enum"==e?x(Gt):"type"==e?x(Bt,R("operator"),ht,R(";")):x(P("form"),yt,R("{"),P("}"),rt,N,N)):o&&"namespace"==e?(k.marked="keyword",x(P("form"),V,z,N)):o&&"abstract"==e?(k.marked="keyword",x(z)):x(P("stat"),X):"switch"==t?x(P("form"),W,R("{"),P("}","switch"),E,rt,N,N,B):"case"==t?x(V,R(":")):"default"==t?x(R(":")):"catch"==t?x(P("form"),L,I,z,N,B):"export"==t?x(P("stat"),Ht,N):"import"==t?x(P("stat"),Ft,N):"async"==t?x(z):"@"==e?x(V,z):y(P("stat"),V,R(";"),N)}function I(t){if("("==t)return x(Pt,R(")"))}function V(t,e){return F(t,e,!1)}function H(t,e){return F(t,e,!0)}function W(t){return"("!=t?y():x(P(")"),q,R(")"),N)}function F(t,e,i){if(k.state.fatArrowAt==k.stream.start){var n=i?U:G;if("("==t)return x(L,P(")"),it(Pt,")"),N,R("=>"),n,B);if("variable"==t)return y(L,yt,R("=>"),n,B)}var r=i?j:_;return w.hasOwnProperty(t)?x(r):"function"==t?x(Lt,r):"class"==t||o&&"interface"==e?(k.marked="keyword",x(P("form"),Nt,N)):"keyword c"==t||"async"==t?x(i?H:V):"("==t?x(P(")"),q,R(")"),N,r):"operator"==t||"spread"==t?x(i?H:V):"["==t?x(P("]"),$t,N,r):"{"==t?nt(Q,"}",null,r):"quasi"==t?y(K,r):"new"==t?x(function(t){return function(e){return"."==e?x(t?J:Y):"variable"==e&&o?x(wt,t?j:_):y(t?H:V)}}(i)):x()}function q(t){return t.match(/[;\}\)\],]/)?y():y(V)}function _(t,e){return","==t?x(q):j(t,e,!1)}function j(t,e,i){var n=0==i?_:j,r=0==i?V:H;return"=>"==t?x(L,i?U:G,B):"operator"==t?/\+\+|--/.test(e)||o&&"!"==e?x(n):o&&"<"==e&&k.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?x(P(">"),it(ht,">"),N,n):"?"==e?x(V,R(":"),r):x(r):"quasi"==t?y(K,n):";"!=t?"("==t?nt(H,")","call",n):"."==t?x(Z,n):"["==t?x(P("]"),q,R("]"),N,n):o&&"as"==e?(k.marked="keyword",x(ht,n)):"regexp"==t?(k.state.lastType=k.marked="operator",k.stream.backUp(k.stream.pos-k.stream.start-1),x(r)):void 0:void 0}function K(t,e){return"quasi"!=t?y():"${"!=e.slice(e.length-2)?x(K):x(q,$)}function $(t){if("}"==t)return k.marked="string.special",k.state.tokenize=p,x(K)}function G(t){return g(k.stream,k.state),y("{"==t?z:V)}function U(t){return g(k.stream,k.state),y("{"==t?z:H)}function Y(t,e){if("target"==e)return k.marked="keyword",x(_)}function J(t,e){if("target"==e)return k.marked="keyword",x(j)}function X(t){return":"==t?x(N,z):y(_,R(";"),N)}function Z(t){if("variable"==t)return k.marked="property",x()}function Q(t,e){return"async"==t?(k.marked="property",x(Q)):"variable"==t||"keyword"==k.style?(k.marked="property","get"==e||"set"==e?x(tt):(o&&k.state.fatArrowAt==k.stream.start&&(i=k.stream.match(/^\s*:\s*/,!1))&&(k.state.fatArrowAt=k.stream.pos+i[0].length),x(et))):"number"==t||"string"==t?(k.marked=r?"property":k.style+" property",x(et)):"jsonld-keyword"==t?x(et):o&&C(e)?(k.marked="keyword",x(Q)):"["==t?x(V,st,R("]"),et):"spread"==t?x(H,et):"*"==e?(k.marked="keyword",x(Q)):":"==t?y(et):void 0;var i}function tt(t){return"variable"!=t?y(et):(k.marked="property",x(Lt))}function et(t){return":"==t?x(H):"("==t?y(Lt):void 0}function it(t,e,i){function n(r,s){if(i?i.indexOf(r)>-1:","==r){var o=k.state.lexical;return"call"==o.info&&(o.pos=(o.pos||0)+1),x((function(i,n){return i==e||n==e?y():y(t)}),n)}return r==e||s==e?x():i&&i.indexOf(";")>-1?y(t):x(R(e))}return function(i,r){return i==e||r==e?x():y(t,n)}}function nt(t,e,i){for(var n=3;n<arguments.length;n++)k.cc.push(arguments[n]);return x(P(e,i),it(t,e),N)}function rt(t){return"}"==t?x():y(z,rt)}function st(t,e){if(o){if(":"==t)return x(ht);if("?"==e)return x(st)}}function ot(t,e){if(o&&(":"==t||"in"==e))return x(ht)}function at(t){if(o&&":"==t)return k.stream.match(/^\s*\w+\s+is\b/,!1)?x(V,lt,ht):x(ht)}function lt(t,e){if("is"==e)return k.marked="keyword",x()}function ht(t,e){return"keyof"==e||"typeof"==e||"infer"==e||"readonly"==e?(k.marked="keyword",x("typeof"==e?H:ht)):"variable"==t||"void"==e?(k.marked="type",x(gt)):"|"==e||"&"==e?x(ht):"string"==t||"number"==t||"atom"==t?x(gt):"["==t?x(P("]"),it(ht,"]",","),N,gt):"{"==t?x(P("}"),ut,N,gt):"("==t?x(it(mt,")"),ct,gt):"<"==t?x(it(ht,">"),ht):"quasi"==t?y(ft,gt):void 0}function ct(t){if("=>"==t)return x(ht)}function ut(t){return t.match(/[\}\)\]]/)?x():","==t||";"==t?x(ut):y(dt,ut)}function dt(t,e){return"variable"==t||"keyword"==k.style?(k.marked="property",x(dt)):"?"==e||"number"==t||"string"==t?x(dt):":"==t?x(ht):"["==t?x(R("variable"),ot,R("]"),dt):"("==t?y(Et,dt):t.match(/[;\}\)\],]/)?void 0:x()}function ft(t,e){return"quasi"!=t?y():"${"!=e.slice(e.length-2)?x(ft):x(ht,pt)}function pt(t){if("}"==t)return k.marked="string.special",k.state.tokenize=p,x(ft)}function mt(t,e){return"variable"==t&&k.stream.match(/^\s*[?:]/,!1)||"?"==e?x(mt):":"==t?x(ht):"spread"==t?x(mt):y(ht)}function gt(t,e){return"<"==e?x(P(">"),it(ht,">"),N,gt):"|"==e||"."==t||"&"==e?x(ht):"["==t?x(ht,R("]"),gt):"extends"==e||"implements"==e?(k.marked="keyword",x(ht)):"?"==e?x(ht,R(":"),ht):void 0}function wt(t,e){if("<"==e)return x(P(">"),it(ht,">"),N,gt)}function vt(){return y(ht,bt)}function bt(t,e){if("="==e)return x(ht)}function kt(t,e){return"enum"==e?(k.marked="keyword",x(Gt)):y(yt,st,At,Mt)}function yt(t,e){return o&&C(e)?(k.marked="keyword",x(yt)):"variable"==t?(A(e),x()):"spread"==t?x(yt):"["==t?nt(St,"]"):"{"==t?nt(xt,"}"):void 0}function xt(t,e){return"variable"!=t||k.stream.match(/^\s*:/,!1)?("variable"==t&&(k.marked="property"),"spread"==t?x(yt):"}"==t?y():"["==t?x(V,R("]"),R(":"),xt):x(R(":"),yt,At)):(A(e),x(At))}function St(){return y(yt,At)}function At(t,e){if("="==e)return x(H)}function Mt(t){if(","==t)return x(kt)}function Ct(t,e){if("keyword b"==t&&"else"==e)return x(P("form","else"),z,N)}function Tt(t,e){return"await"==e?x(Tt):"("==t?x(P(")"),Dt,N):void 0}function Dt(t){return"var"==t?x(kt,Ot):"variable"==t?x(Ot):y(Ot)}function Ot(t,e){return")"==t?x():";"==t?x(Ot):"in"==e||"of"==e?(k.marked="keyword",x(V,Ot)):y(V,Ot)}function Lt(t,e){return"*"==e?(k.marked="keyword",x(Lt)):"variable"==t?(A(e),x(Lt)):"("==t?x(L,P(")"),it(Pt,")"),N,at,z,B):o&&"<"==e?x(P(">"),it(vt,">"),N,Lt):void 0}function Et(t,e){return"*"==e?(k.marked="keyword",x(Et)):"variable"==t?(A(e),x(Et)):"("==t?x(L,P(")"),it(Pt,")"),N,at,B):o&&"<"==e?x(P(">"),it(vt,">"),N,Et):void 0}function Bt(t,e){return"keyword"==t||"variable"==t?(k.marked="type",x(Bt)):"<"==e?x(P(">"),it(vt,">"),N):void 0}function Pt(t,e){return"@"==e&&x(V,Pt),"spread"==t?x(Pt):o&&C(e)?(k.marked="keyword",x(Pt)):o&&"this"==t?x(st,At):y(yt,st,At)}function Nt(t,e){return"variable"==t?Rt(t,e):zt(t,e)}function Rt(t,e){if("variable"==t)return A(e),x(zt)}function zt(t,e){return"<"==e?x(P(">"),it(vt,">"),N,zt):"extends"==e||"implements"==e||o&&","==t?("implements"==e&&(k.marked="keyword"),x(o?ht:V,zt)):"{"==t?x(P("}"),It,N):void 0}function It(t,e){return"async"==t||"variable"==t&&("static"==e||"get"==e||"set"==e||o&&C(e))&&k.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1)?(k.marked="keyword",x(It)):"variable"==t||"keyword"==k.style?(k.marked="property",x(Vt,It)):"number"==t||"string"==t?x(Vt,It):"["==t?x(V,st,R("]"),Vt,It):"*"==e?(k.marked="keyword",x(It)):o&&"("==t?y(Et,It):";"==t||","==t?x(It):"}"==t?x():"@"==e?x(V,It):void 0}function Vt(t,e){if("!"==e||"?"==e)return x(Vt);if(":"==t)return x(ht,At);if("="==e)return x(H);var i=k.state.lexical.prev;return y(i&&"interface"==i.info?Et:Lt)}function Ht(t,e){return"*"==e?(k.marked="keyword",x(Kt,R(";"))):"default"==e?(k.marked="keyword",x(V,R(";"))):"{"==t?x(it(Wt,"}"),Kt,R(";")):y(z)}function Wt(t,e){return"as"==e?(k.marked="keyword",x(R("variable"))):"variable"==t?y(H,Wt):void 0}function Ft(t){return"string"==t?x():"("==t?y(V):"."==t?y(_):y(qt,_t,Kt)}function qt(t,e){return"{"==t?nt(qt,"}"):("variable"==t&&A(e),"*"==e&&(k.marked="keyword"),x(jt))}function _t(t){if(","==t)return x(qt,_t)}function jt(t,e){if("as"==e)return k.marked="keyword",x(qt)}function Kt(t,e){if("from"==e)return k.marked="keyword",x(V)}function $t(t){return"]"==t?x():y(it(H,"]"))}function Gt(){return y(P("form"),yt,R("{"),P("}"),it(Ut,"}"),N,N)}function Ut(){return y(yt,At)}return L.lex=E.lex=!0,B.lex=!0,N.lex=!0,{name:t.name,startState:function(e){var i={tokenize:d,lastType:"sof",cc:[],lexical:new v(-e,0,"block",!1),localVars:t.localVars,context:t.localVars&&new T(null,null,!1),indented:0};return t.globalVars&&"object"==typeof t.globalVars&&(i.globalVars=t.globalVars),i},token:function(t,n){if(t.sol()&&(n.lexical.hasOwnProperty("align")||(n.lexical.align=!1),n.indented=t.indentation(),g(t,n)),n.tokenize!=f&&t.eatSpace())return null;var r=n.tokenize(t,n);return"comment"==e?r:(n.lastType="operator"!=e||"++"!=i&&"--"!=i?e:"incdec",function(t,e,i,n,r){var o=t.cc;for(k.state=t,k.stream=r,k.marked=null,k.cc=o,k.style=e,t.lexical.hasOwnProperty("align")||(t.lexical.align=!0);;)if((o.length?o.pop():s?V:z)(i,n)){for(;o.length&&o[o.length-1].lex;)o.pop()();return k.marked?k.marked:"variable"==i&&b(t,n)?"variableName.local":e}}(n,r,e,i,t))},indent:function(e,i,r){if(e.tokenize==f||e.tokenize==p)return null;if(e.tokenize!=d)return 0;var s,o=i&&i.charAt(0),a=e.lexical;if(!/^\s*else\b/.test(i))for(var l=e.cc.length-1;l>=0;--l){var c=e.cc[l];if(c==N)a=a.prev;else if(c!=Ct&&c!=B)break}for(;("stat"==a.type||"form"==a.type)&&("}"==o||(s=e.cc[e.cc.length-1])&&(s==_||s==j)&&!/^[,\.=+\-*:?[\(]/.test(i));)a=a.prev;n&&")"==a.type&&"stat"==a.prev.type&&(a=a.prev);var u=a.type,m=o==u;return"vardef"==u?a.indented+("operator"==e.lastType||","==e.lastType?a.info.length+1:0):"form"==u&&"{"==o?a.indented:"form"==u?a.indented+r.unit:"stat"==u?a.indented+(function(t,e){return"operator"==t.lastType||","==t.lastType||h.test(e.charAt(0))||/[,.]/.test(e.charAt(0))}(e,i)?n||r.unit:0):"switch"!=a.info||m||0==t.doubleIndentSwitch?a.align?a.column+(m?0:1):a.indented+(m?0:r.unit):a.indented+(/^(?:case|default)\b/.test(i)?r.unit:2*r.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:s?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}const dl=ul({name:"javascript"});function fl(t){var e,i,n=(t={...Nl,...t}).inline,r=t.tokenHooks,s=t.documentTypes||{},o=t.mediaTypes||{},a=t.mediaFeatures||{},l=t.mediaValueKeywords||{},h=t.propertyKeywords||{},c=t.nonStandardPropertyKeywords||{},u=t.fontProperties||{},d=t.counterDescriptors||{},f=t.colorKeywords||{},p=t.valueKeywords||{},m=t.allowNested,g=t.lineComment,w=!0===t.supportsAtComponent,v=!1!==t.highlightNonStandardPropertyKeywords;function b(t,i){return e=i,t}function k(t,e){var i=t.next();if(r[i]){var n=r[i](t,e);if(!1!==n)return n}return"@"==i?(t.eatWhile(/[\w\\\-]/),b("def",t.current())):"="==i||("~"==i||"|"==i)&&t.eat("=")?b(null,"compare"):'"'==i||"'"==i?(e.tokenize=y(i),e.tokenize(t,e)):"#"==i?(t.eatWhile(/[\w\\\-]/),b("atom","hash")):"!"==i?(t.match(/^\s*\w*/),b("keyword","important")):/\d/.test(i)||"."==i&&t.eat(/\d/)?(t.eatWhile(/[\w.%]/),b("number","unit")):"-"!==i?/[,+>*\/]/.test(i)?b(null,"select-op"):"."==i&&t.match(/^-?[_a-z][_a-z0-9-]*/i)?b("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(i)?b(null,i):t.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(t.current())&&(e.tokenize=x),b("variableName.function","variable")):/[\w\\\-]/.test(i)?(t.eatWhile(/[\w\\\-]/),b("property","word")):b(null,null):/[\d.]/.test(t.peek())?(t.eatWhile(/[\w.%]/),b("number","unit")):t.match(/^-[\w\\\-]*/)?(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?b("def","variable-definition"):b("variableName","variable")):t.match(/^\w+-/)?b("meta","meta"):void 0}function y(t){return function(e,i){for(var n,r=!1;null!=(n=e.next());){if(n==t&&!r){")"==t&&e.backUp(1);break}r=!r&&"\\"==n}return(n==t||!r&&")"!=t)&&(i.tokenize=null),b("string","string")}}function x(t,e){return t.next(),t.match(/^\s*[\"\')]/,!1)?e.tokenize=null:e.tokenize=y(")"),b(null,"(")}function S(t,e,i){this.type=t,this.indent=e,this.prev=i}function A(t,e,i,n){return t.context=new S(i,e.indentation()+(!1===n?0:e.indentUnit),t.context),i}function M(t){return t.context.prev&&(t.context=t.context.prev),t.context.type}function C(t,e,i){return O[i.context.type](t,e,i)}function T(t,e,i,n){for(var r=n||1;r>0;r--)i.context=i.context.prev;return C(t,e,i)}function D(t){var e=t.current().toLowerCase();i=p.hasOwnProperty(e)?"atom":f.hasOwnProperty(e)?"keyword":"variable"}var O={top:function(t,e,n){if("{"==t)return A(n,e,"block");if("}"==t&&n.context.prev)return M(n);if(w&&/@component/i.test(t))return A(n,e,"atComponentBlock");if(/^@(-moz-)?document$/i.test(t))return A(n,e,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(t))return A(n,e,"atBlock");if(/^@(font-face|counter-style)/i.test(t))return n.stateArg=t,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(t))return"keyframes";if(t&&"@"==t.charAt(0))return A(n,e,"at");if("hash"==t)i="builtin";else if("word"==t)i="tag";else{if("variable-definition"==t)return"maybeprop";if("interpolation"==t)return A(n,e,"interpolation");if(":"==t)return"pseudo";if(m&&"("==t)return A(n,e,"parens")}return n.context.type},block:function(t,e,n){if("word"==t){var r=e.current().toLowerCase();return h.hasOwnProperty(r)?(i="property","maybeprop"):c.hasOwnProperty(r)?(i=v?"string.special":"property","maybeprop"):m?(i=e.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(i="error","maybeprop")}return"meta"==t?"block":m||"hash"!=t&&"qualifier"!=t?O.top(t,e,n):(i="error","block")},maybeprop:function(t,e,i){return":"==t?A(i,e,"prop"):C(t,e,i)},prop:function(t,e,n){if(";"==t)return M(n);if("{"==t&&m)return A(n,e,"propBlock");if("}"==t||"{"==t)return T(t,e,n);if("("==t)return A(n,e,"parens");if("hash"!=t||/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(e.current())){if("word"==t)D(e);else if("interpolation"==t)return A(n,e,"interpolation")}else i="error";return"prop"},propBlock:function(t,e,n){return"}"==t?M(n):"word"==t?(i="property","maybeprop"):n.context.type},parens:function(t,e,i){return"{"==t||"}"==t?T(t,e,i):")"==t?M(i):"("==t?A(i,e,"parens"):"interpolation"==t?A(i,e,"interpolation"):("word"==t&&D(e),"parens")},pseudo:function(t,e,n){return"meta"==t?"pseudo":"word"==t?(i="variableName.constant",n.context.type):C(t,e,n)},documentTypes:function(t,e,n){return"word"==t&&s.hasOwnProperty(e.current())?(i="tag",n.context.type):O.atBlock(t,e,n)},atBlock:function(t,e,n){if("("==t)return A(n,e,"atBlock_parens");if("}"==t||";"==t)return T(t,e,n);if("{"==t)return M(n)&&A(n,e,m?"block":"top");if("interpolation"==t)return A(n,e,"interpolation");if("word"==t){var r=e.current().toLowerCase();i="only"==r||"not"==r||"and"==r||"or"==r?"keyword":o.hasOwnProperty(r)?"attribute":a.hasOwnProperty(r)?"property":l.hasOwnProperty(r)?"keyword":h.hasOwnProperty(r)?"property":c.hasOwnProperty(r)?v?"string.special":"property":p.hasOwnProperty(r)?"atom":f.hasOwnProperty(r)?"keyword":"error"}return n.context.type},atComponentBlock:function(t,e,n){return"}"==t?T(t,e,n):"{"==t?M(n)&&A(n,e,m?"block":"top",!1):("word"==t&&(i="error"),n.context.type)},atBlock_parens:function(t,e,i){return")"==t?M(i):"{"==t||"}"==t?T(t,e,i,2):O.atBlock(t,e,i)},restricted_atBlock_before:function(t,e,n){return"{"==t?A(n,e,"restricted_atBlock"):"word"==t&&"@counter-style"==n.stateArg?(i="variable","restricted_atBlock_before"):C(t,e,n)},restricted_atBlock:function(t,e,n){return"}"==t?(n.stateArg=null,M(n)):"word"==t?(i="@font-face"==n.stateArg&&!u.hasOwnProperty(e.current().toLowerCase())||"@counter-style"==n.stateArg&&!d.hasOwnProperty(e.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},keyframes:function(t,e,n){return"word"==t?(i="variable","keyframes"):"{"==t?A(n,e,"top"):C(t,e,n)},at:function(t,e,n){return";"==t?M(n):"{"==t||"}"==t?T(t,e,n):("word"==t?i="tag":"hash"==t&&(i="builtin"),"at")},interpolation:function(t,e,n){return"}"==t?M(n):"{"==t||";"==t?T(t,e,n):("word"==t?i="variable":"variable"!=t&&"("!=t&&")"!=t&&(i="error"),"interpolation")}};return{name:t.name,startState:function(){return{tokenize:null,state:n?"block":"top",stateArg:null,context:new S(n?"block":"top",0,null)}},token:function(t,n){if(!n.tokenize&&t.eatSpace())return null;var r=(n.tokenize||k)(t,n);return r&&"object"==typeof r&&(e=r[1],r=r[0]),i=r,"comment"!=e&&(n.state=O[n.state](e,t,n)),i},indent:function(t,e,i){var n=t.context,r=e&&e.charAt(0),s=n.indent;return"prop"!=n.type||"}"!=r&&")"!=r||(n=n.prev),n.prev&&("}"!=r||"block"!=n.type&&"top"!=n.type&&"interpolation"!=n.type&&"restricted_atBlock"!=n.type?(")"!=r||"parens"!=n.type&&"atBlock_parens"!=n.type)&&("{"!=r||"at"!=n.type&&"atBlock"!=n.type)||(s=Math.max(0,n.indent-i.unit)):s=(n=n.prev).indent),s},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:g,block:{open:"/*",close:"*/"}},autocomplete:Pl}}}function pl(t){for(var e={},i=0;i<t.length;++i)e[t[i].toLowerCase()]=!0;return e}ul({name:"json",json:!0}),ul({name:"json",jsonld:!0}),ul({name:"typescript",typescript:!0});var ml=["domain","regexp","url","url-prefix"],gl=pl(ml),wl=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],vl=pl(wl),bl=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover","prefers-color-scheme","dynamic-range","video-dynamic-range"],kl=pl(bl),yl=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],xl=pl(yl),Sl=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","all","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","binding","bleed","block-size","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-content","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","inset","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-height-step","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotate","rotation","rotation-point","row-gap","ruby-align","ruby-overhang","ruby-position","ruby-span","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-orientation","text-outline","text-overflow","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],Al=pl(Sl),Ml=["accent-color","aspect-ratio","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","content-visibility","margin-block","margin-block-end","margin-block-start","margin-inline","margin-inline-end","margin-inline-start","overflow-anchor","overscroll-behavior","padding-block","padding-block-end","padding-block-start","padding-inline","padding-inline-end","padding-inline-start","scroll-snap-stop","scrollbar-3d-light-color","scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-track-color","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","shape-inside","zoom"],Cl=pl(Ml),Tl=pl(["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"]),Dl=pl(["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"]),Ol=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],Ll=pl(Ol),El=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","blur","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","brightness","bullets","button","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","conic-gradient","contain","content","contents","content-box","context-menu","continuous","contrast","copy","counter","counters","cover","crop","cross","crosshair","cubic-bezier","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","drop-shadow","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","grayscale","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","hue-rotate","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","manipulation","match","matrix","matrix3d","media-play-button","media-slider","media-sliderthumb","media-volume-slider","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiple_mask_images","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturate","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","sepia","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],Bl=pl(El),Pl=ml.concat(wl).concat(bl).concat(yl).concat(Sl).concat(Ml).concat(Ol).concat(El);const Nl={documentTypes:gl,mediaTypes:vl,mediaFeatures:kl,mediaValueKeywords:xl,propertyKeywords:Al,nonStandardPropertyKeywords:Cl,fontProperties:Tl,counterDescriptors:Dl,colorKeywords:Ll,valueKeywords:Bl,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=zl,zl(t,e))}}},Rl=fl({name:"css"});function zl(t,e){for(var i,n=!1;null!=(i=t.next());){if(n&&"/"==i){e.tokenize=null;break}n="*"==i}return["comment","comment"]}fl({name:"scss",mediaTypes:vl,mediaFeatures:kl,mediaValueKeywords:xl,propertyKeywords:Al,nonStandardPropertyKeywords:Cl,colorKeywords:Ll,valueKeywords:Bl,fontProperties:Tl,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=zl,zl(t,e)):["operator","operator"]},":":function(t){return!!t.match(/^\s*\{/,!1)&&[null,null]},$:function(t){return t.match(/^[\w-]+/),t.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName.special","variable"]},"#":function(t){return!!t.eat("{")&&[null,"interpolation"]}}}),fl({name:"less",mediaTypes:vl,mediaFeatures:kl,mediaValueKeywords:xl,propertyKeywords:Al,nonStandardPropertyKeywords:Cl,colorKeywords:Ll,valueKeywords:Bl,fontProperties:Tl,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=zl,zl(t,e)):["operator","operator"]},"@":function(t){return t.eat("{")?[null,"interpolation"]:!t.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)&&(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName","variable"])},"&":function(){return["atom","atom"]}}}),fl({name:"gss",documentTypes:gl,mediaTypes:vl,mediaFeatures:kl,propertyKeywords:Al,nonStandardPropertyKeywords:Cl,fontProperties:Tl,counterDescriptors:Dl,colorKeywords:Ll,valueKeywords:Bl,supportsAtComponent:!0,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=zl,zl(t,e))}}});const Il=ia,Vl=new class{get permittedHtmlTags(){return{b:!0,bdi:!0,del:!0,i:!0,ins:!0,u:!0,font:!0,big:!0,small:!0,sub:!0,sup:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,cite:!0,code:!0,em:!0,s:!0,strike:!0,strong:!0,tt:!0,var:!0,div:!0,center:!0,blockquote:!0,q:!0,ol:!0,ul:!0,dl:!0,table:!0,caption:!0,pre:!0,ruby:!0,rb:!0,rp:!0,rt:!0,rtc:!0,p:!0,span:!0,abbr:!0,dfn:!0,kbd:!0,samp:!0,data:!0,time:!0,mark:!0,br:!0,wbr:!0,hr:!0,li:!0,dt:!0,dd:!0,td:!0,th:!0,tr:!0,noinclude:!0,includeonly:!0,onlyinclude:!0}}get implicitlyClosedHtmlTags(){return{br:!0,hr:!0,wbr:!0}}get tags(){return{apostrophes:"character",apostrophesBold:"strong",apostrophesItalic:"emphasis",comment:"comment",doubleUnderscore:"controlKeyword",extLink:"url",extLinkBracket:"modifier",extLinkProtocol:"namespace",extLinkText:"labelName",hr:"contentSeparator",htmlTagAttribute:"attributeName",htmlTagBracket:"angleBracket",htmlTagName:"tagName",extTagAttribute:"attributeName",extTagBracket:"angleBracket",extTagName:"tagName",indenting:"operatorKeyword",linkBracket:"squareBracket",linkDelimiter:"operator",linkText:"string",linkToSection:"className",list:"list",parserFunction:"unit",parserFunctionBracket:"paren",parserFunctionDelimiter:"punctuation",parserFunctionName:"keyword",sectionHeader:"heading",sectionHeader1:"heading1",sectionHeader2:"heading2",sectionHeader3:"heading3",sectionHeader4:"heading4",sectionHeader5:"heading5",sectionHeader6:"heading6",signature:"quote",tableBracket:"null",tableDefinition:"definitionOperator",tableDelimiter:"typeOperator",template:"attributeValue",templateArgumentName:"definitionKeyword",templateBracket:"bracket",templateDelimiter:"separator",templateName:"moduleKeyword",templateVariable:"atom",templateVariableBracket:"brace",templateVariableName:"variableName",section:"mw-section",em:"mw-em",error:"mw-error",extTag:"mw-exttag",extGround:"mw-ext-ground",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",link:"mw-link",linkGround:"mw-link-ground",linkPageName:"mw-link-pagename",mnemonic:"mw-mnemonic",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateGround:"mw-template-ground",templateExtGround:"mw-template-ext-ground",templateLinkGround:"mw-template-link-ground",templateVariableDelimiter:"mw-templatevariable-delimiter",template2ExtGround:"mw-template2-ext-ground",template2Ground:"mw-template2-ground",template3ExtGround:"mw-template3-ext-ground",template3Ground:"mw-template3-ground",pre:"mw-tag-pre",nowiki:"mw-tag-nowiki"}}get tokenTable(){return{[this.tags.section]:Bo.define(),[this.tags.em]:Bo.define(),[this.tags.error]:Bo.define(),[this.tags.extTag]:Bo.define(),[this.tags.extGround]:Bo.define(),[this.tags.freeExtLink]:Bo.define(),[this.tags.freeExtLinkProtocol]:Bo.define(),[this.tags.link]:Bo.define(),[this.tags.linkGround]:Bo.define(),[this.tags.linkPageName]:Bo.define(),[this.tags.mnemonic]:Bo.define(),[this.tags.pageName]:Bo.define(),[this.tags.skipFormatting]:Bo.define(),[this.tags.strong]:Bo.define(),[this.tags.tableCaption]:Bo.define(),[this.tags.templateGround]:Bo.define(),[this.tags.templateExtGround]:Bo.define(),[this.tags.templateLinkGround]:Bo.define(),[this.tags.templateVariableDelimiter]:Bo.define(),[this.tags.template2ExtGround]:Bo.define(),[this.tags.template2Ground]:Bo.define(),[this.tags.template3ExtGround]:Bo.define(),[this.tags.template3Ground]:Bo.define(),[this.tags.pre]:Bo.define(),[this.tags.nowiki]:Bo.define()}}getHighlightStyle(t){return Ea.define([{tag:Il[this.tags.apostrophes],class:"cm-mw-apostrophes"},{tag:Il[this.tags.apostrophesBold],class:"cm-mw-apostrophes-bold"},{tag:Il[this.tags.apostrophesItalic],class:"cm-mw-apostrophes-italic"},{tag:Il[this.tags.comment],class:"cm-mw-comment"},{tag:Il[this.tags.doubleUnderscore],class:"cm-mw-double-underscore"},{tag:Il[this.tags.extLink],class:"cm-mw-extlink"},{tag:Il[this.tags.extLinkBracket],class:"cm-mw-extlink-bracket"},{tag:Il[this.tags.extLinkProtocol],class:"cm-mw-extlink-protocol"},{tag:Il[this.tags.extLinkText],class:"cm-mw-extlink-text"},{tag:Il[this.tags.hr],class:"cm-mw-hr"},{tag:Il[this.tags.htmlTagAttribute],class:"cm-mw-htmltag-attribute"},{tag:Il[this.tags.htmlTagBracket],class:"cm-mw-htmltag-bracket"},{tag:Il[this.tags.htmlTagName],class:"cm-mw-htmltag-name"},{tag:Il[this.tags.extTagAttribute],class:"cm-mw-exttag-attribute"},{tag:Il[this.tags.extTagBracket],class:"cm-mw-exttag-bracket"},{tag:Il[this.tags.extTagName],class:"cm-mw-exttag-name"},{tag:Il[this.tags.indenting],class:"cm-mw-indenting"},{tag:Il[this.tags.linkBracket],class:"cm-mw-link-bracket"},{tag:Il[this.tags.linkDelimiter],class:"cm-mw-link-delimiter"},{tag:Il[this.tags.linkText],class:"cm-mw-link-text"},{tag:Il[this.tags.linkToSection],class:"cm-mw-link-tosection"},{tag:Il[this.tags.list],class:"cm-mw-list"},{tag:Il[this.tags.parserFunction],class:"cm-mw-parserfunction"},{tag:Il[this.tags.parserFunctionBracket],class:"cm-mw-parserfunction-bracket"},{tag:Il[this.tags.parserFunctionDelimiter],class:"cm-mw-parserfunction-delimiter"},{tag:Il[this.tags.parserFunctionName],class:"cm-mw-parserfunction-name"},{tag:Il[this.tags.sectionHeader],class:"cm-mw-section-header"},{tag:Il[this.tags.sectionHeader1],class:"cm-mw-section-1"},{tag:Il[this.tags.sectionHeader2],class:"cm-mw-section-2"},{tag:Il[this.tags.sectionHeader3],class:"cm-mw-section-3"},{tag:Il[this.tags.sectionHeader4],class:"cm-mw-section-4"},{tag:Il[this.tags.sectionHeader5],class:"cm-mw-section-5"},{tag:Il[this.tags.sectionHeader6],class:"cm-mw-section-6"},{tag:Il[this.tags.signature],class:"cm-mw-signature"},{tag:Il[this.tags.tableBracket],class:"cm-mw-table-bracket"},{tag:Il[this.tags.tableDefinition],class:"cm-mw-table-definition"},{tag:Il[this.tags.tableDelimiter],class:"cm-mw-table-delimiter"},{tag:Il[this.tags.template],class:"cm-mw-template"},{tag:Il[this.tags.templateArgumentName],class:"cm-mw-template-argument-name"},{tag:Il[this.tags.templateBracket],class:"cm-mw-template-bracket"},{tag:Il[this.tags.templateDelimiter],class:"cm-mw-template-delimiter"},{tag:Il[this.tags.templateName],class:"cm-mw-pagename cm-mw-template-name"},{tag:Il[this.tags.templateVariable],class:"cm-mw-templatevariable"},{tag:Il[this.tags.templateVariableBracket],class:"cm-mw-templatevariable-bracket"},{tag:Il[this.tags.templateVariableName],class:"cm-mw-templatevariable-name"},{tag:t.tokenTable[this.tags.section],class:"cm-mw-section"},{tag:t.tokenTable[this.tags.em],class:"cm-mw-em"},{tag:t.tokenTable[this.tags.error],class:"cm-mw-error"},{tag:t.tokenTable[this.tags.extTag],class:"cm-mw-exttag"},{tag:t.tokenTable[this.tags.extGround],class:"cm-mw-ext-ground"},{tag:t.tokenTable[this.tags.freeExtLink],class:"cm-mw-free-extlink"},{tag:t.tokenTable[this.tags.freeExtLinkProtocol],class:"cm-mw-free-extlink-protocol"},{tag:t.tokenTable[this.tags.linkGround],class:"cm-mw-link-ground"},{tag:t.tokenTable[this.tags.linkPageName],class:"cm-mw-link-pagename"},{tag:t.tokenTable[this.tags.mnemonic],class:"cm-mw-mnemonic"},{tag:t.tokenTable[this.tags.pageName],class:"cm-mw-pagename"},{tag:t.tokenTable[this.tags.skipFormatting],class:"cm-mw-skipformatting"},{tag:t.tokenTable[this.tags.strong],class:"cm-mw-strong"},{tag:t.tokenTable[this.tags.tableCaption],class:"cm-mw-table-caption"},{tag:t.tokenTable[this.tags.templateGround],class:"cm-mw-template-ground"},{tag:t.tokenTable[this.tags.templateExtGround],class:"cm-mw-template-ext-ground"},{tag:t.tokenTable[this.tags.templateLinkGround],class:"cm-mw-template-link-ground"},{tag:t.tokenTable[this.tags.templateVariableDelimiter],class:"cm-mw-templatevariable-delimiter"},{tag:t.tokenTable[this.tags.template2ExtGround],class:"cm-mw-template2-ext-ground"},{tag:t.tokenTable[this.tags.template2Ground],class:"cm-mw-template2-ground"},{tag:t.tokenTable[this.tags.template3ExtGround],class:"cm-mw-template3-ext-ground"},{tag:t.tokenTable[this.tags.template3Ground],class:"cm-mw-template3-ground"},{tag:t.tokenTable[this.tags.pre],class:"cm-mw-tag-pre"},{tag:t.tokenTable[this.tags.nowiki],class:"cm-mw-tag-nowiki"}])}},Hl=t=>{const e={};for(const[i,n]of Object.entries(t))Object.assign(e,{[i]:Array.isArray(n)?[...n]:n});return e};class Wl{constructor(t){this.config=t,this.urlProtocols=new RegExp(`^(?:${t.urlProtocols})`,"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.tokens=[],this.oldTokens=[]}eatMnemonic(t,e,i){let n;return n=t.eat("#")?t.eat("x")?t.eatWhile(/[a-f\d]/i)&&t.eat(";"):t.eatWhile(/\d/)&&t.eat(";"):t.eatWhile(/[\w.\-:]/)&&t.eat(";"),n?i+=` ${Vl.tags.mnemonic}`:e}makeStyle(t,e,i){return this.isBold&&(t+=` ${Vl.tags.strong}`),this.isItalic&&(t+=` ${Vl.tags.em}`),this.makeLocalStyle(t,e,i)}makeLocalStyle(t,e,i){let n="";switch(e.nTemplate){case 0:break;case 1:n+="-template";break;case 2:n+="-template2";break;default:n+="-template3"}switch(e.nExt){case 0:break;case 1:n+="-ext";break;case 2:n+="-ext2";break;default:n+="-ext3"}return e.nLink>0&&(n+="-link"),""!==n&&(t=`mw${n}-ground ${t}`),i&&e[i]--,t.trim()}eatBlock(t,e,i=!0){return(n,r)=>(n.skipTo(e)?(i&&n.match(e),r.tokenize=r.stack.pop()):n.skipToEnd(),this.makeLocalStyle(t,r))}eatEnd(t){return(e,i)=>(e.skipToEnd(),i.tokenize=i.stack.pop(),this.makeLocalStyle(t,i))}eatChar(t,e){return(i,n)=>(n.tokenize=n.stack.pop(),i.eat(t)?this.makeLocalStyle(e,n):this.makeLocalStyle(Vl.tags.error,n))}eatSectionHeader(t){return(e,i)=>e.match(/^[^&<[{~]+/)?(e.eol()?(e.backUp(t),i.tokenize=this.eatEnd(Vl.tags.sectionHeader)):e.match(/^<!--(?!.*?-->.*?=)/,!1)&&(e.backUp(t),i.tokenize=this.eatBlock(Vl.tags.sectionHeader,"\x3c!--",!1)),Vl.tags.section):this.eatWikiText(Vl.tags.section,"")(e,i)}inVariable(t,e){return t.match(/^[^{}|]+/)?this.makeLocalStyle(Vl.tags.templateVariableName,e):t.eat("|")?(e.tokenize=this.inVariableDefault.bind(this),this.makeLocalStyle(Vl.tags.templateVariableDelimiter,e)):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.templateVariableBracket,e)):t.match("{{{")?(e.stack.push(e.tokenize),this.makeLocalStyle(Vl.tags.templateVariableBracket,e)):(t.next(),this.makeLocalStyle(Vl.tags.templateVariableName,e))}inVariableDefault(t,e){return t.match(/^[^{}[<&~]+/)?this.makeLocalStyle(Vl.tags.templateVariable,e):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.templateVariableBracket,e)):this.eatWikiText(Vl.tags.templateVariable,"")(t,e)}inParserFunctionName(t,e){return t.match(/^[^:}{~]+/)?this.makeLocalStyle(Vl.tags.parserFunctionName,e):t.eat(":")?(e.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(Vl.tags.parserFunctionDelimiter,e)):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(Vl.tags.parserFunction,"")(t,e)}inParserFunctionArguments(t,e){return t.match(/^[^|}{[<&~]+/)?this.makeLocalStyle(Vl.tags.parserFunction,e):t.eat("|")?this.makeLocalStyle(Vl.tags.parserFunctionDelimiter,e):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(Vl.tags.parserFunction,"")(t,e)}eatTemplatePageName(t){return(e,i)=>e.match(/^\s*\|\s*/)?(i.tokenize=this.eatTemplateArgument(!0),this.makeLocalStyle(Vl.tags.templateDelimiter,i)):e.match(/^\s*\}\}/)?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.templateBracket,i,"nTemplate")):e.match(/^\s*<!--.*?-->/)?this.makeLocalStyle(Vl.tags.comment,i):t&&e.sol()?(i.nTemplate--,i.tokenize=i.stack.pop(),""):e.match(/^\s*[^\s|}<{&~]+/)?(i.tokenize=this.eatTemplatePageName(!0),this.makeLocalStyle(Vl.tags.templateName,i)):e.eatSpace()?(e.eol(),this.makeLocalStyle(Vl.tags.templateName,i)):this.eatWikiText(Vl.tags.templateName,`${Vl.tags.templateName}-mnemonic`)(e,i)}eatTemplateArgument(t){return(e,i)=>t&&e.eatWhile(/[^=|}{[<&~]/)?e.eat("=")?(i.tokenize=this.eatTemplateArgument(!1),this.makeLocalStyle(Vl.tags.templateArgumentName,i)):this.makeLocalStyle(Vl.tags.template,i):e.eatWhile(/[^|}{[<&~]/)?this.makeLocalStyle(Vl.tags.template,i):e.eat("|")?(i.tokenize=this.eatTemplateArgument(!0),this.makeLocalStyle(Vl.tags.templateDelimiter,i)):e.match("}}")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.templateBracket,i,"nTemplate")):this.eatWikiText(Vl.tags.template,"")(e,i)}eatExternalLinkProtocol(t){return(e,i)=>{for(;t>0;)t--,e.next();return e.eol()?(i.nLink--,i.tokenize=i.stack.pop()):i.tokenize=this.inExternalLink.bind(this),this.makeLocalStyle(Vl.tags.extLinkProtocol,i)}}inExternalLink(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.match(/^\s*\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.extLinkBracket,e,"nLink")):t.eatSpace()?(e.tokenize=this.inExternalLinkText.bind(this),this.makeStyle("",e)):t.match(/^[^\s\]{&~']+/)||t.eatSpace()?("'"===t.peek()&&(t.match("''",!1)?e.tokenize=this.inExternalLinkText.bind(this):t.next()),this.makeStyle(Vl.tags.extLink,e)):this.eatWikiText(Vl.tags.extLink,"")(t,e)}inExternalLinkText(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.eat("]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.extLinkBracket,e,"nLink")):t.match(/^[^'\]{&~<]+/)?this.makeStyle(Vl.tags.extLinkText,e):this.eatWikiText(Vl.tags.extLinkText,"")(t,e)}inLink(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.match(/^\s*#\s*/)?(e.tokenize=this.inLinkToSection.bind(this),this.makeLocalStyle(Vl.tags.link,e)):t.match(/^\s*\|\s*/)?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(Vl.tags.linkDelimiter,e)):t.match(/^\s*\]\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.linkBracket,e,"nLink")):t.match(/^\s*[^\s#|\]&~{]+/)||t.eatSpace()?this.makeStyle(`${Vl.tags.linkPageName} ${Vl.tags.pageName}`,e):this.eatWikiText(`${Vl.tags.linkPageName} ${Vl.tags.pageName}`,Vl.tags.pageName)(t,e)}inLinkToSection(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.match(/^[^|\]&~{}]+/)?this.makeLocalStyle(Vl.tags.linkToSection,e):t.eat("|")?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(Vl.tags.linkDelimiter,e)):t.match("]]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.linkBracket,e,"nLink")):this.eatWikiText(Vl.tags.linkToSection,"")(t,e)}eatLinkText(){let t,e;return(i,n)=>{let r;return i.match("]]")?(n.tokenize=n.stack.pop(),this.makeLocalStyle(Vl.tags.linkBracket,n,"nLink")):i.match("'''")?(t=!t,this.makeLocalStyle(`${Vl.tags.linkText} ${Vl.tags.apostrophes}`,n)):i.match("''")?(e=!e,this.makeLocalStyle(`${Vl.tags.linkText} ${Vl.tags.apostrophes}`,n)):(r=Vl.tags.linkText,t&&(r+=` ${Vl.tags.strong}`),e&&(r+=` ${Vl.tags.em}`),i.match(/^[^'\]{&~<]+/)?this.makeStyle(r,n):this.eatWikiText(r,"")(i,n))}}eatTagName(t,e,i){return(n,r)=>{let s="";for(;t>0;)t--,s+=n.next();return n.eatSpace(),i?(e&&!Vl.implicitlyClosedHtmlTags[s]?r.tokenize=this.eatChar(">",Vl.tags.htmlTagBracket):r.tokenize=this.eatHtmlTagAttribute(s),this.makeLocalStyle(Vl.tags.htmlTagName,r)):(r.tokenize=e?this.eatChar(">",Vl.tags.extTagBracket):this.eatExtTagAttribute(s),this.makeLocalStyle(Vl.tags.extTagName,r))}}eatHtmlTagAttribute(t){return(e,i)=>e.match(/^(?:"[^<">]*"|'[^<'>]*'|[^>/<{&~])+/)?this.makeLocalStyle(Vl.tags.htmlTagAttribute,i):e.eat(">")?(t in Vl.implicitlyClosedHtmlTags||i.inHtmlTag.push(t),i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.htmlTagBracket,i)):e.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.htmlTagBracket,i)):this.eatWikiText(Vl.tags.htmlTagAttribute,"")(e,i)}eatExtTagAttribute(t){return(e,i)=>e.match(/^(?:"[^">]*"|'[^'>]*'|[^>/<{&~])+/)?this.makeLocalStyle(Vl.tags.extTagAttribute,i):e.eat(">")?(i.extName=t,t in this.config.tagModes&&(i.extMode=this[this.config.tagModes[t]],i.extState=i.extMode.startState(0)),i.tokenize=this.eatExtTagArea(t),this.makeLocalStyle(Vl.tags.extTagBracket,i)):e.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.extTagBracket,i)):this.eatWikiText(Vl.tags.extTagAttribute,"")(e,i)}eatExtTagArea(t){return(e,i)=>{const n=e.pos,r=new RegExp(`</${t}\\s*>`,"i").exec(n?e.string.slice(n):e.string);let s,o=!1;if(r){if(0===r.index)return i.tokenize=this.eatExtCloseTag(t),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(e,i);s=r.index+n,o=e.string,e.string=o.slice(0,s)}return i.stack.push(i.tokenize),i.tokenize=this.eatExtTokens(o),i.tokenize(e,i)}}eatExtCloseTag(t){return(e,i)=>(e.next(),e.next(),i.tokenize=this.eatTagName(t.length,!0,!1),this.makeLocalStyle(Vl.tags.extTagBracket,i))}eatExtTokens(t){return(e,i)=>{let n;return!1===i.extMode?(n=Vl.tags.extTag,e.skipToEnd()):(n=Vl.tags[i.extName],n+=` ${i.extMode.token(e,i.extState)}`),e.eol()&&(!1!==t&&(e.string=t),i.tokenize=i.stack.pop()),this.makeLocalStyle(n,i)}}eatStartTable(t,e){return t.match("{|"),t.eatSpace(),e.tokenize=this.inTableDefinition.bind(this),Vl.tags.tableBracket}inTableDefinition(t,e){return t.sol()?(e.tokenize=this.inTable.bind(this),this.inTable(t,e)):this.eatWikiText(Vl.tags.tableDefinition,"")(t,e)}inTableCaption(t,e){return t.sol()&&t.match(/^\s*[|!]/,!1)?(e.tokenize=this.inTable.bind(this),this.inTable(t,e)):this.eatWikiText(Vl.tags.tableCaption,"")(t,e)}inTable(t,e){if(t.sol()){if(t.eatSpace(),t.eat("|"))return t.eat("-")?(t.eatSpace(),e.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(Vl.tags.tableDelimiter,e)):t.eat("+")?(t.eatSpace(),e.tokenize=this.inTableCaption.bind(this),this.makeLocalStyle(Vl.tags.tableDelimiter,e)):t.eat("}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.tableBracket,e)):(t.eatSpace(),e.tokenize=this.eatTableRow(!0,!1),this.makeLocalStyle(Vl.tags.tableDelimiter,e));if(t.eat("!"))return t.eatSpace(),e.tokenize=this.eatTableRow(!0,!0),this.makeLocalStyle(Vl.tags.tableDelimiter,e)}return this.eatWikiText("","")(t,e)}eatTableRow(t,e){return(i,n)=>{if(i.sol()){if(i.match(/^\s*[|!]/,!1))return n.tokenize=this.inTable.bind(this),this.inTable(i,n)}else{if(i.match(/^[^'|{[<&~!]+/))return this.makeStyle(e?Vl.tags.strong:"",n);if(i.match("||")||e&&i.match("!!")||t&&i.eat("|"))return this.isBold=!1,this.isItalic=!1,t&&(n.tokenize=this.eatTableRow(!1,e)),this.makeLocalStyle(Vl.tags.tableDelimiter,n)}const r=e?Vl.tags.strong:"";return this.eatWikiText(r,r)(i,n)}}eatFreeExternalLinkProtocol(t,e){return t.match(this.urlProtocols),e.tokenize=this.eatFreeExternalLink.bind(this),this.makeLocalStyle(Vl.tags.freeExtLinkProtocol,e)}eatFreeExternalLink(t,e){if(t.eol());else if(t.match(/^[^\s{[\]<>~).,']*/))if("~"===t.peek()){if(!t.match(/^~{3,}/,!1))return t.match(/^~*/),this.makeLocalStyle(Vl.tags.freeExtLink,e)}else if("{"===t.peek()){if(!t.match("{{",!1))return t.next(),this.makeLocalStyle(Vl.tags.freeExtLink,e)}else if("'"===t.peek()){if(!t.match("''",!1))return t.next(),this.makeLocalStyle(Vl.tags.freeExtLink,e)}else if(t.match(/^[).,]+(?=[^\s{[\]<>~).,])/))return this.makeLocalStyle(Vl.tags.freeExtLink,e);return e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.freeExtLink,e)}eatWikiText(t,e){return(i,n)=>{let r,s,o,a,l,h=!1;if(i.sol()){if(!i.match("//",!1)&&i.match(this.urlProtocols))return n.stack.push(n.tokenize),n.tokenize=this.eatFreeExternalLink.bind(this),this.makeLocalStyle(Vl.tags.freeExtLinkProtocol,n);switch(r=i.next(),r){case"-":if(i.match(/^-{3,}/))return Vl.tags.hr;break;case"=":if(s=i.match(/^(={0,5})(.+?(=\1\s*)(<!--(?!.*-->.*\S).*)?)$/),s)return i.backUp(s[2].length),n.stack.push(n.tokenize),n.tokenize=this.eatSectionHeader(s[3].length),`${Vl.tags.sectionHeader} ${Vl.tags[`sectionHeader${s[1].length+1}`]}`;break;case"*":case"#":return i.match(/^[*#]*:*/),Vl.tags.list;case":":return i.match(/^:*\{\|/,!1)&&(n.stack.push(n.tokenize),n.tokenize=this.eatStartTable.bind(this)),i.match(/^:*[*#]*/),Vl.tags.indenting;case" ":if(!i.match(/^\s*:*\{\|/,!1))return Vl.tags.skipFormatting;if(i.eatSpace(),i.match(/^:+/))return n.stack.push(n.tokenize),n.tokenize=this.eatStartTable.bind(this),Vl.tags.indenting;i.eat("{");case"{":if(i.match(/^(?:\||\{\{!\}\})/))return i.eatSpace(),n.stack.push(n.tokenize),n.tokenize=this.inTableDefinition.bind(this),Vl.tags.tableBracket}}else r=i.next();switch(r){case"&":return this.makeStyle(this.eatMnemonic(i,t,e),n);case"'":if(i.match(/^'*(?='{5})/)||i.match(/^'''(?!')/,!1))break;if(i.match("''"))return this.firstSingleLetterWord||i.match("''",!1)||this.prepareItalicForCorrection(i),this.isBold=!this.isBold,this.makeLocalStyle(Vl.tags.apostrophesBold,n);if(i.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(Vl.tags.apostrophesItalic,n);break;case"[":if(i.eat("[")){if(i.eatSpace(),/[^\]|[]/.test(i.peek()||""))return n.nLink++,n.stack.push(n.tokenize),n.tokenize=this.inLink.bind(this),this.makeLocalStyle(Vl.tags.linkBracket,n)}else if(o=i.match(this.urlProtocols),o)return n.nLink++,i.backUp(o[0].length),n.stack.push(n.tokenize),n.tokenize=this.eatExternalLinkProtocol(o[0].length),this.makeLocalStyle(Vl.tags.extLinkBracket,n);break;case"{":if(i.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))/))return i.eatSpace(),n.stack.push(n.tokenize),n.tokenize=this.inVariable.bind(this),this.makeLocalStyle(Vl.tags.templateVariableBracket,n);if(i.match(/^\{(?!\{(?!\{))\s*/))return"#"===i.peek()?(n.nExt++,n.stack.push(n.tokenize),n.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(Vl.tags.parserFunctionBracket,n)):(a=i.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/),!a||(i.backUp(a[0].length),":"!==a[2]&&void 0!==a[4]&&"}}"!==a[3]||!(a[1].toLowerCase()in this.config.functionSynonyms[0])&&!(a[1]in this.config.functionSynonyms[1]))?(n.nTemplate++,n.stack.push(n.tokenize),n.tokenize=this.eatTemplatePageName(!1),this.makeLocalStyle(Vl.tags.templateBracket,n)):(n.nExt++,n.stack.push(n.tokenize),n.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(Vl.tags.parserFunctionBracket,n)));break;case"<":if(h=Boolean(i.eat("/")),l=i.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+/),i.match("!--"))return c=this.eatBlock(Vl.tags.comment,"--\x3e"),n.stack.push(n.tokenize),n.tokenize=c,c(i,n);if(l){if(l=l[0].toLowerCase(),this.config.tags&&l in this.config.tags)return h?Vl.tags.error:(i.backUp(l.length),n.stack.push(n.tokenize),n.tokenize=this.eatTagName(l.length,h,!1),this.makeLocalStyle(Vl.tags.extTagBracket,n));if(l in Vl.permittedHtmlTags)return h&&l!==n.inHtmlTag.pop()?(i.pos++,Vl.tags.error):h&&l in Vl.implicitlyClosedHtmlTags?Vl.tags.error:(i.backUp(l.length),n.stack.push(n.tokenize),n.tokenize=this.eatTagName(l.length,h||l in Vl.implicitlyClosedHtmlTags,!0),this.makeLocalStyle(Vl.tags.htmlTagBracket,n));i.backUp(l.length)}break;case"~":if(i.match(/^~{2,4}/))return Vl.tags.signature;break;case"_":for(s=1;i.eat("_");)s++;if(s>2)return i.eol()||i.backUp(2),this.makeStyle(t,n);if(2===s&&(a=i.match(/^([^\s>}[\]<{'|&:~]+?)__/),a&&a[0]))return`__${a[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${a[0]}`in this.config.doubleUnderscore[1]?Vl.tags.doubleUnderscore:(i.eol()||i.backUp(2),this.makeStyle(t,n));break;default:if(/\s/.test(r||"")&&(i.eatSpace(),i.match(this.urlProtocols,!1)&&!i.match("//")))return n.stack.push(n.tokenize),n.tokenize=this.eatFreeExternalLinkProtocol.bind(this),this.makeStyle(t,n)}var c;return i.match(/^[^\s_>}[\]<{'|&:~=]+/),this.makeStyle(t,n)}}prepareItalicForCorrection(t){const e=t.pos,i=t.string.slice(0,e-3),n=i.slice(-1),r=i.slice(-2,-1);if(" "===n){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=e}else if(" "===r)this.firstSingleLetterWord=e;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=e}this.wasBold=this.isBold,this.wasItalic=this.isItalic}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText("",""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0}),copyState:t=>{const e=Hl(t);return t.extMode&&t.extMode.copyState&&(e.extState=t.extMode.copyState(t.extState)),e},token:(t,e)=>{let i,n,r,s=null,o=[];const a=[];if(this.oldTokens.length>0)return n=this.oldTokens.shift(),t.pos=n.pos,n.style;t.sol()&&(this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);do{if(i=e.tokenize(t,e),r=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,!r)return this.oldStyle=i,i;r!==s&&(s=r,o.length>0&&(a.push(...o),o=[])),o.push({pos:t.pos,style:i,state:(e.extMode&&e.extMode.copyState||Hl)(e)})}while(!t.eol());if(this.isBold&&this.isItalic){if(this.isItalic=this.wasItalic,this.isBold=this.wasBold,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,!(a.length>0))return t.pos=o[0].pos-2,this.oldStyle||"";a[a.length-1].pos++,this.oldTokens=a}else this.oldTokens=[...a,...o];return n=this.oldTokens.shift(),t.pos=n.pos,n.style},blankLine:t=>{t.extMode&&t.extMode.blankLine&&t.extMode.blankLine(t.extState,0)},tokenTable:Vl.tokenTable}}get"text/mediawiki"(){return this.mediawiki}eatNowiki(t){return e=>e.match(/^[^&]+/)?t:(e.next(),this.eatMnemonic(e,t,t))}get"mw-tag-pre"(){return{startState:()=>({}),token:this.eatNowiki(Vl.tags.pre)}}get"mw-tag-nowiki"(){return{startState:()=>({}),token:this.eatNowiki(Vl.tags.nowiki)}}}for(const[t,e]of Object.entries(i))Object.defineProperty(Wl.prototype,t,{get:()=>e});const Fl=t=>{const e=new Wl(t).mediawiki,i=Ja.define(e),n=Ra(Vl.getHighlightStyle(e));return new va(i,n)};function ql(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let r=t(e,i);return!!r&&(n(i.update(r)),!0)}}const _l=ql(Yl,0),jl=ql(Ul,0),Kl=ql(((t,e)=>Ul(t,e,function(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),r=i.to<=n.to?n:t.doc.lineAt(i.to),s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}(e))),0);function $l(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const Gl=50;function Ul(t,e,i=e.selection.ranges){let n=i.map((t=>$l(e,t.from).block));if(!n.every((t=>t)))return null;let r=i.map(((t,i)=>function(t,{open:e,close:i},n,r){let s,o,a=t.sliceDoc(n-Gl,n),l=t.sliceDoc(r,r+Gl),h=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(l)[0].length,u=a.length-h;if(a.slice(u-e.length,u)==e&&l.slice(c,c+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:r+c,margin:c&&1}};r-n<=2*Gl?s=o=t.sliceDoc(n,r):(s=t.sliceDoc(n,n+Gl),o=t.sliceDoc(r-Gl,r));let d=/^\s*/.exec(s)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return s.slice(d,d+e.length)==e&&o.slice(p,p+i.length)==i?{open:{pos:n+d+e.length,margin:/\s/.test(s.charAt(d+e.length))?1:0},close:{pos:r-f-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(e,n[i],t.from,t.to)));if(2!=t&&!r.every((t=>t)))return{changes:e.changes(i.map(((t,e)=>r[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}])))};if(1!=t&&r.some((t=>t))){let t=[];for(let e,i=0;i<r.length;i++)if(e=r[i]){let r=n[i],{open:s,close:o}=e;t.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:t}}return null}function Yl(t,e,i=e.selection.ranges){let n=[],r=-1;for(let{from:t,to:s}of i){let i=n.length,o=1e9,a=$l(e,t).line;if(a){for(let i=t;i<=s;){let l=e.doc.lineAt(i);if(l.from>r&&(t==s||s>l.from)){r=l.from;let t=/^\s*/.exec(l.text)[0].length,e=t==l.length,i=l.text.slice(t,t+a.length)==a?t:-1;t<l.text.length&&t<o&&(o=t),n.push({line:l,comment:i,token:a,indent:t,empty:e,single:!1})}i=l.to+1}if(o<1e9)for(let t=i;t<n.length;t++)n[t].indent<n[t].line.text.length&&(n[t].indent=o);n.length==i+1&&(n[i].single=!0)}}if(2!=t&&n.some((t=>t.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:i,indent:r,empty:s,single:o}of n)!o&&s||t.push({from:e.from+r,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&n.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:i,token:r}of n)if(i>=0){let n=e.from+i,s=n+r.length;" "==e.text[s-e.from]&&s++,t.push({from:n,to:s})}return{changes:t}}return null}const Jl=lt.define(),Xl=lt.define(),Zl=H.define(),Ql=H.define({combine:t=>St(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}),th=$.define({create:()=>wh.empty,update(t,e){let i=e.state.facet(Ql),n=e.annotation(Jl);if(n){let r=ah.fromTransaction(e,n.selection),s=n.side,o=0==s?t.undone:t.done;return o=r?lh(o,o.length,i.minDepth,r):dh(o,e.startState.selection),new wh(0==s?n.rest:o,0==s?o:n.rest)}let r=e.annotation(Xl);if("full"!=r&&"before"!=r||(t=t.isolate()),!1===e.annotation(dt.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let s=ah.fromTransaction(e),o=e.annotation(dt.time),a=e.annotation(dt.userEvent);return s?t=t.addChanges(s,o,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,i.newGroupDelay)),"full"!=r&&"after"!=r||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new wh(t.done.map(ah.fromJSON),t.undone.map(ah.fromJSON))});function eh(t={}){return[th,Ql.of(t),zr.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?nh:"historyRedo"==t.inputType?rh:null;return!!i&&(t.preventDefault(),i(e))}})]}function ih(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let r=i.field(th,!1);if(!r)return!1;let s=r.pop(t,i,e);return!!s&&(n(s),!0)}}const nh=ih(0,!1),rh=ih(1,!1),sh=ih(0,!0),oh=ih(1,!0);class ah{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new ah(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new ah(t.changes&&D.fromJSON(t.changes),[],t.mapped&&T.fromJSON(t.mapped),t.startSelection&&z.fromJSON(t.startSelection),t.selectionsAfter.map(z.fromJSON))}static fromTransaction(t,e){let i=ch;for(let e of t.startState.facet(Zl)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new ah(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,ch)}static selection(t){return new ah(void 0,ch,void 0,void 0,t)}}function lh(t,e,i,n){let r=e+1>i+20?e-i-1:0,s=t.slice(r,e);return s.push(n),s}function hh(t,e){return t.length?e.length?t.concat(e):t:e}const ch=[],uh=200;function dh(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-uh));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),lh(t,t.length-1,1e9,i.setSelAfter(n)))}return[ah.selection([e])]}function fh(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function ph(t,e){if(!t.length)return t;let i=t.length,n=ch;for(;i;){let r=mh(t[i-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,i);return e[i-1]=r,e}e=r.mapped,i--,n=r.selectionsAfter}return n.length?[ah.selection(n)]:ch}function mh(t,e,i){let n=hh(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):ch,i);if(!t.changes)return ah.selection(n);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new ah(r,ut.mapEffects(t.effects,e),o,t.startSelection.map(s),n)}const gh=/^(input\.type|delete)($|\.)/;class wh{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new wh(this.done,this.undone):this}addChanges(t,e,i,n,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&!o.changes.empty&&t.changes&&(!i||gh.test(i))&&(!o.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,function(t,e){let i=[],n=!1;return t.iterChangedRanges(((t,e)=>i.push(t,e))),e.iterChangedRanges(((t,e,r,s)=>{for(let t=0;t<i.length;){let e=i[t++],o=i[t++];s>=e&&r<=o&&(n=!0)}})),n}(o.changes,t.changes))||"input.type.compose"==i)?lh(s,s.length-1,n.minDepth,new ah(t.changes.compose(o.changes),hh(t.effects,o.effects),o.mapped,o.startSelection,ch)):lh(s,s.length,n.minDepth,t),new wh(s,ch,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ch;return r.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(s=r[r.length-1],o=t,s.ranges.length==o.ranges.length&&0===s.ranges.filter(((t,e)=>t.empty!=o.ranges[e].empty)).length)?this:new wh(dh(this.done,t),this.undone,e,i);var s,o}addMapping(t){return new wh(ph(this.done,t),ph(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let r=n[n.length-1],s=r.selectionsAfter[0]||e.selection;if(i&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Jl.of({side:t,rest:fh(n),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let i=1==n.length?ch:n.slice(0,n.length-1);return r.mapped&&(i=ph(i,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Jl.of({side:t,rest:i,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}wh.empty=new wh(ch,ch);const vh=[{key:"Mod-z",run:nh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:rh,preventDefault:!0},{linux:"Ctrl-Shift-z",run:rh,preventDefault:!0},{key:"Mod-u",run:sh,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:oh,preventDefault:!0}];function bh(t,e){return z.create(t.ranges.map(e),t.mainIndex)}function kh(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function yh({state:t,dispatch:e},i){let n=bh(t.selection,i);return!n.eq(t.selection)&&(e(kh(t,n)),!0)}function xh(t,e){return z.cursor(e?t.to:t.from)}function Sh(t,e){return yh(t,(i=>i.empty?t.moveByChar(i,e):xh(i,e)))}function Ah(t){return t.textDirectionAt(t.state.selection.main.head)==zi.LTR}const Mh=t=>Sh(t,!Ah(t)),Ch=t=>Sh(t,Ah(t));function Th(t,e){return yh(t,(i=>i.empty?t.moveByGroup(i,e):xh(i,e)))}function Dh(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Oh(t,e,i){let n,r,s=la(t).resolveInner(e.head),o=i?eo.closedBy:eo.openedBy;for(let n=e.head;;){let e=i?s.childAfter(n):s.childBefore(n);if(!e)break;Dh(t,e,o)?s=e:n=i?e.to:e.from}return r=s.type.prop(o)&&(n=i?ja(t,s.from,1):ja(t,s.to,-1))&&n.matched?i?n.end.to:n.end.from:i?s.to:s.from,z.cursor(r,i?-1:1)}function Lh(t,e){return yh(t,(i=>{if(!i.empty)return xh(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}"undefined"!=typeof Intl&&Intl.Segmenter;const Eh=t=>Lh(t,!1),Bh=t=>Lh(t,!0);function Ph(t){let e,i=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0;if(i){for(let e of t.state.facet(zr.scrollMargins)){let i=e(t);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(r=Math.max(null==i?void 0:i.bottom,r))}e=t.scrollDOM.clientHeight-n-r}else e=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:i,height:Math.max(t.defaultLineHeight,e-5)}}function Nh(t,e){let i,n=Ph(t),{state:r}=t,s=bh(r.selection,(i=>i.empty?t.moveVertically(i,e,n.height):xh(i,e)));if(s.eq(r.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(r.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),a=o.top+n.marginTop,l=o.bottom-n.marginBottom;e&&e.top>a&&e.bottom<l&&(i=zr.scrollIntoView(s.main.head,{y:"start",yMargin:e.top-a}))}return t.dispatch(kh(r,s),{effects:i}),!0}const Rh=t=>Nh(t,!1),zh=t=>Nh(t,!0);function Ih(t,e,i){let n=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,i);if(r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),!i&&r.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(r=z.cursor(n.from+i))}return r}function Vh(t,e){let i=bh(t.state.selection,(t=>{let i=e(t);return z.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(t.state.selection)&&(t.dispatch(kh(t.state,i)),!0)}function Hh(t,e){return Vh(t,(i=>t.moveByChar(i,e)))}const Wh=t=>Hh(t,!Ah(t)),Fh=t=>Hh(t,Ah(t));function qh(t,e){return Vh(t,(i=>t.moveByGroup(i,e)))}function _h(t,e){return Vh(t,(i=>t.moveVertically(i,e)))}const jh=t=>_h(t,!1),Kh=t=>_h(t,!0);function $h(t,e){return Vh(t,(i=>t.moveVertically(i,e,Ph(t).height)))}const Gh=t=>$h(t,!1),Uh=t=>$h(t,!0),Yh=({state:t,dispatch:e})=>(e(kh(t,{anchor:0})),!0),Jh=({state:t,dispatch:e})=>(e(kh(t,{anchor:t.doc.length})),!0),Xh=({state:t,dispatch:e})=>(e(kh(t,{anchor:t.selection.main.anchor,head:0})),!0),Zh=({state:t,dispatch:e})=>(e(kh(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function Qh(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,r=n.changeByRange((n=>{let{from:r,to:s}=n;if(r==s){let o=e(n);o<r?(i="delete.backward",o=tc(t,o,!1)):o>r&&(i="delete.forward",o=tc(t,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=tc(t,r,!1),s=tc(t,s,!0);return r==s?{range:n}:{changes:{from:r,to:s},range:z.cursor(r,r<n.head?-1:1)}}));return!r.changes.empty&&(t.dispatch(n.update(r,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?zr.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function tc(t,e,i){if(t instanceof zr)for(let n of t.state.facet(zr.atomicRanges).map((e=>e(t))))n.between(e,e,((t,n)=>{t<e&&n>e&&(e=i?n:t)}));return e}const ec=(t,e)=>Qh(t,(i=>{let n,r,s=i.from,{state:o}=t,a=o.doc.lineAt(s);if(!e&&s>a.from&&s<a.from+200&&!/[^ \t]/.test(n=a.text.slice(0,s-a.from))){if("\t"==n[n.length-1])return s-1;let t=Wt(n,o.tabSize)%ya(o)||ya(o);for(let e=0;e<t&&" "==n[n.length-1-e];e++)s--;r=s}else r=w(a.text,s-a.from,e,e)+a.from,r==s&&a.number!=(e?o.doc.lines:1)?r+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(a.text.slice(r-a.from,s-a.from))&&(r=w(a.text,r-a.from,!1,!1)+a.from);return r})),ic=t=>ec(t,!1),nc=t=>ec(t,!0),rc=(t,e)=>Qh(t,(i=>{let n=i.head,{state:r}=t,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let t=null;;){if(n==(e?s.to:s.from)){n==i.head&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let a=w(s.text,n-s.from,e)+s.from,l=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),h=o(l);if(null!=t&&h!=t)break;" "==l&&n==i.head||(t=h),n=a}return n})),sc=t=>rc(t,!1);function oc(t){let e=[],i=-1;for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=t.doc.lineAt(n.to);if(n.empty||n.to!=s.from||(s=t.doc.lineAt(n.to-1)),i>=r.number){let t=e[e.length-1];t.to=s.to,t.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});i=s.number+1}return e}function ac(t,e,i){if(t.readOnly)return!1;let n=[],r=[];for(let e of oc(t)){if(i?e.to==t.doc.length:0==e.from)continue;let s=t.doc.lineAt(i?e.to+1:e.from-1),o=s.length+1;if(i){n.push({from:e.to,to:s.to},{from:e.from,insert:s.text+t.lineBreak});for(let i of e.ranges)r.push(z.range(Math.min(t.doc.length,i.anchor+o),Math.min(t.doc.length,i.head+o)))}else{n.push({from:s.from,to:e.from},{from:e.to,insert:t.lineBreak+s.text});for(let t of e.ranges)r.push(z.range(t.anchor-o,t.head-o))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:z.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function lc(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of oc(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const hc=cc(!1);function cc(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let r=e.changeByRange((i=>{let{from:r,to:s}=i,o=e.doc.lineAt(r),a=!t&&r==s&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=la(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e);return r&&s&&r.to<=e&&s.from>=e&&(i=r.type.prop(eo.closedBy))&&i.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}(e,r);t&&(r=s=(s<=o.to?o:e.doc.lineAt(s)).to);let l=new Aa(e,{simulateBreak:r,simulateDoubleBreak:!!a}),h=Sa(l,r);for(null==h&&(h=Wt(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));s<o.to&&/\s/.test(o.text[s-o.from]);)s++;a?({from:r,to:s}=a):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);let c=["",xa(e,h)];return a&&c.push(xa(e,l.lineIndent(o.from,-1))),{changes:{from:r,to:s,insert:n.of(c)},range:z.cursor(r+1+c[1].length)}}));return i(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function uc(t,e){let i=-1;return t.changeByRange((n=>{let r=[];for(let s=n.from;s<=n.to;){let o=t.doc.lineAt(s);o.number>i&&(n.empty||n.to>o.from)&&(e(o,r,n),i=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:z.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const dc=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>yh(t,(e=>Oh(t.state,e,!Ah(t)))),shift:t=>Vh(t,(e=>Oh(t.state,e,!Ah(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>yh(t,(e=>Oh(t.state,e,Ah(t)))),shift:t=>Vh(t,(e=>Oh(t.state,e,Ah(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>ac(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>lc(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>ac(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>lc(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=z.create([i.main]):i.main.empty||(n=z.create([z.cursor(i.main.head)])),!!n&&(e(kh(t,n)),!0)}},{key:"Mod-Enter",run:cc(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=oc(t).map((({from:e,to:i})=>z.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:z.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=bh(t.selection,(e=>{var i;for(let n=la(t).resolveStack(e.from,1);n;n=n.next){let{node:t}=n;if((t.from<e.from&&t.to>=e.to||t.to>e.to&&t.from<=e.from)&&(null===(i=t.parent)||void 0===i?void 0:i.parent))return z.range(t.to,t.from)}return e}));return e(kh(t,i)),!0},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(uc(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=Wt(n,t.tabSize),s=0,o=xa(t,Math.max(0,r-ya(t)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;i.push({from:e.from+s,to:e.from+n.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(uc(t,((e,i)=>{i.push({from:e.from,insert:t.facet(ka)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new Aa(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),r=uc(t,((e,r,s)=>{let o=Sa(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let a=/^\s*/.exec(e.text)[0],l=xa(t,o);(a!=l||s.from<e.from+a.length)&&(i[e.from]=o,r.push({from:e.from,to:e.from+a.length,insert:l}))}));return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(oc(e).map((({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i})))),n=bh(e.selection,(e=>t.moveVertically(e,!0))).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(t,e,i){let n=!1,r=bh(t.selection,(e=>{let r=ja(t,e.head,-1)||ja(t,e.head,1)||e.head>0&&ja(t,e.head-1,1)||e.head<t.doc.length&&ja(t,e.head+1,-1);if(!r||!r.end)return e;n=!0;let s=r.start.from==e.head?r.end.to:r.end.from;return i?z.range(e.anchor,s):z.cursor(s)}));return!!n&&(e(kh(t,r)),!0)}(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=$l(t.state,i.from);return n.line?_l(t):!!n.block&&Kl(t)}},{key:"Alt-A",run:jl}].concat([{key:"ArrowLeft",run:Mh,shift:Wh,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Th(t,!Ah(t)),shift:t=>qh(t,!Ah(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>yh(t,(e=>Ih(t,e,!Ah(t)))),shift:t=>Vh(t,(e=>Ih(t,e,!Ah(t)))),preventDefault:!0},{key:"ArrowRight",run:Ch,shift:Fh,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Th(t,Ah(t)),shift:t=>qh(t,Ah(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>yh(t,(e=>Ih(t,e,Ah(t)))),shift:t=>Vh(t,(e=>Ih(t,e,Ah(t)))),preventDefault:!0},{key:"ArrowUp",run:Eh,shift:jh,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Yh,shift:Xh},{mac:"Ctrl-ArrowUp",run:Rh,shift:Gh},{key:"ArrowDown",run:Bh,shift:Kh,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Jh,shift:Zh},{mac:"Ctrl-ArrowDown",run:zh,shift:Uh},{key:"PageUp",run:Rh,shift:Gh},{key:"PageDown",run:zh,shift:Uh},{key:"Home",run:t=>yh(t,(e=>Ih(t,e,!1))),shift:t=>Vh(t,(e=>Ih(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:Yh,shift:Xh},{key:"End",run:t=>yh(t,(e=>Ih(t,e,!0))),shift:t=>Vh(t,(e=>Ih(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:Jh,shift:Zh},{key:"Enter",run:hc},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:ic,shift:ic},{key:"Delete",run:nc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:sc},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>rc(t,!0)},{mac:"Mod-Backspace",run:t=>Qh(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=>Qh(t,(e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}))}].concat([{key:"Ctrl-b",run:Mh,shift:Wh,preventDefault:!0},{key:"Ctrl-f",run:Ch,shift:Fh},{key:"Ctrl-p",run:Eh,shift:jh},{key:"Ctrl-n",run:Bh,shift:Kh},{key:"Ctrl-a",run:t=>yh(t,(e=>z.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>Vh(t,(e=>z.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>yh(t,(e=>z.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>Vh(t,(e=>z.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:nc},{key:"Ctrl-h",run:ic},{key:"Ctrl-k",run:t=>Qh(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:sc},{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:n.of(["",""])},range:z.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,n=t.doc.lineAt(i),r=i==n.from?i-1:w(n.text,i-n.from,!1)+n.from,s=i==n.to?i+1:w(n.text,i-n.from,!0)+n.from;return{changes:{from:r,to:s,insert:t.doc.slice(i,s).append(t.doc.slice(r,i))},range:z.cursor(s)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:zh}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));function fc(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var r=i[n];"string"==typeof r?t.setAttribute(n,r):null!=r&&(t[n]=r)}e++}for(;e<arguments.length;e++)pc(t,arguments[e]);return t}function pc(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var i=0;i<e.length;i++)pc(t,e[i])}}const mc="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class gc{constructor(t,e,i=0,n=t.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=r?t=>r(mc(t)):mc,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return x(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=S(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=A(t);let n=this.normalize(e);for(let t=0,r=i;;t++){let s=n.charCodeAt(t),o=this.match(s,r);if(t==n.length-1){if(o)return this.value=o,this;break}r==i&&t<e.length&&e.charCodeAt(t)==s&&r++}}}match(t,e){let i=null;for(let n=0;n<this.matches.length;n+=2){let r=this.matches[n],s=!1;this.query.charCodeAt(r)==t&&(r==this.query.length-1?i={from:this.matches[n+1],to:e+1}:(this.matches[n]++,s=!0)),s||(this.matches.splice(n,2),n-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?i={from:e,to:e+1}:this.matches.push(1,e)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"undefined"!=typeof Symbol&&(gc.prototype[Symbol.iterator]=function(){return this});const wc={from:-1,to:-1,match:/.*/.exec("")},vc="gm"+(null==/x/.unicode?"":"u");class bc{constructor(t,e,i,n=0,r=t.length){if(this.text=t,this.to=r,this.curLine="",this.done=!1,this.value=wc,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new xc(t,e,i,n,r);this.re=new RegExp(e,vc+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=t.iter();let s=t.lineAt(n);this.curLineStart=s.from,this.matchPos=Sc(t,n),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=Sc(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}const kc=new WeakMap;class yc{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=kc.get(t);if(!n||n.from>=i||n.to<=e){let n=new yc(e,t.sliceString(e,i));return kc.set(t,n),n}if(n.from==e&&n.to==i)return n;let{text:r,from:s}=n;return s>e&&(r=t.sliceString(e,s)+r,s=e),n.to<i&&(r+=t.sliceString(n.to,i)),kc.set(t,new yc(s,r)),new yc(e,r.slice(e-s,i-s))}}class xc{constructor(t,e,i,n,r){this.text=t,this.to=r,this.done=!1,this.value=wc,this.matchPos=Sc(t,n),this.re=new RegExp(e,vc+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=yc.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,match:e},this.matchPos=Sc(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=yc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Sc(t,e){if(e>=t.length)return e;let i,n=t.lineAt(e);for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}function Ac(t){let e=fc("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,r=n.doc.lineAt(n.selection.main.head),[,s,o,a,l]=i,h=a?+a.slice(1):0,c=o?+o:r.number;if(o&&l){let t=c/100;s&&(t=t*("-"==s?-1:1)+r.number/n.doc.lines),c=Math.round(n.doc.lines*t)}else o&&s&&(c=c*("-"==s?-1:1)+r.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,c))),d=z.cursor(u.from+Math.max(0,Math.min(h,u.length)));t.dispatch({effects:[Mc.of(!1),zr.scrollIntoView(d.from,{y:"center"})],selection:d}),t.focus()}return{dom:fc("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:Mc.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},fc("label",t.state.phrase("Go to line"),": ",e)," ",fc("button",{class:"cm-button",type:"submit"},t.state.phrase("go")))}}"undefined"!=typeof Symbol&&(bc.prototype[Symbol.iterator]=xc.prototype[Symbol.iterator]=function(){return this});const Mc=ut.define(),Cc=$.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(Mc)&&(t=i.value);return t},provide:t=>Es.from(t,(t=>t?Ac:null))}),Tc=zr.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Dc=H.define({combine:t=>St(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new nu(t),scrollToMatch:t=>zr.scrollIntoView(t)})});class Oc{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,vc),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new zc(this):new Bc(this)}getCursor(t,e=0,i){let n=t.doc?t:xt.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?Pc(this,n,e,i):Ec(this,n,e,i)}}class Lc{constructor(t){this.spec=t}}function Ec(t,e,i,n){return new gc(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?function(t,e){return(i,n,r,s)=>((s>i||s+r.length<n)&&(s=Math.max(0,i-2),r=t.sliceString(s,Math.min(t.length,n+2))),!(e(Nc(r,i-s))==bt.Word&&e(Rc(r,i-s))==bt.Word||e(Rc(r,n-s))==bt.Word&&e(Nc(r,n-s))==bt.Word))}(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}class Bc extends Lc{constructor(t){super(t)}nextMatch(t,e,i){let n=Ec(this.spec,t,i,t.doc.length).nextOverlapping();return n.done&&(n=Ec(this.spec,t,0,e).nextOverlapping()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let i=Math.max(e,n-1e4-this.spec.unquoted.length),r=Ec(this.spec,t,i,n),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(i==e)return null;n-=1e4}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=Ec(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let r=Ec(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function Pc(t,e,i,n){return new bc(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(r=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(r(Nc(i.input,i.index))!=bt.Word||r(Rc(i.input,i.index))!=bt.Word)&&(r(Rc(i.input,i.index+i[0].length))!=bt.Word||r(Nc(i.input,i.index+i[0].length))!=bt.Word)):void 0},i,n);var r}function Nc(t,e){return t.slice(w(t,e,!1),e)}function Rc(t,e){return t.slice(e,w(t,e))}class zc extends Lc{nextMatch(t,e,i){let n=Pc(this.spec,t,i,t.doc.length).next();return n.done&&(n=Pc(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let r=Math.max(e,i-1e4*n),s=Pc(this.spec,t,r,i),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==e||o.from>r+10))return o;if(r==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,((e,i)=>"$"==i?"$":"&"==i?t.match[0]:"0"!=i&&+i<t.match.length?t.match[i]:e)))}matchAll(t,e){let i=Pc(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let r=Pc(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}const Ic=ut.define(),Vc=ut.define(),Hc=$.define({create:t=>new Wc(Xc(t).create(),null),update(t,e){for(let i of e.effects)i.is(Ic)?t=new Wc(i.value.create(),t.panel):i.is(Vc)&&(t=new Wc(t.query,i.value?Jc:null));return t},provide:t=>Es.from(t,(t=>t.panel))});class Wc{constructor(t,e){this.query=t,this.panel=e}}const Fc=Qe.mark({class:"cm-searchMatch"}),qc=Qe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),_c=Si.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Hc))}update(t){let e=t.state.field(Hc);(e!=t.startState.field(Hc)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Qe.none;let{view:i}=this,n=new Ot;for(let e=0,r=i.visibleRanges,s=r.length;e<s;e++){let{from:o,to:a}=r[e];for(;e<s-1&&a>r[e+1].from-500;)a=r[++e].to;t.highlight(i.state,o,a,((t,e)=>{let r=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));n.add(t,e,r?qc:Fc)}))}return n.finish()}},{decorations:t=>t.decorations});function jc(t){return e=>{let i=e.state.field(Hc,!1);return i&&i.query.spec.valid?t(e,i):tu(e)}}const Kc=jc(((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let r=z.single(n.from,n.to),s=t.state.facet(Dc);return t.dispatch({selection:r,effects:[au(t,n),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),Qc(t),!0})),$c=jc(((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,r=e.prevMatch(i,n,n);if(!r)return!1;let s=z.single(r.from,r.to),o=t.state.facet(Dc);return t.dispatch({selection:s,effects:[au(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),Qc(t),!0})),Gc=jc(((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length||(t.dispatch({selection:z.create(i.map((t=>z.range(t.from,t.to)))),userEvent:"select.search.matches"}),0))})),Uc=jc(((t,{query:e})=>{let{state:i}=t,{from:n,to:r}=i.selection.main;if(i.readOnly)return!1;let s=e.nextMatch(i,n,n);if(!s)return!1;let o,a,l=[],h=[];if(s.from==n&&s.to==r&&(a=i.toText(e.getReplacement(s)),l.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(i,s.from,s.to),h.push(zr.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),s){let e=0==l.length||l[0].from>=s.to?0:s.to-s.from-a.length;o=z.single(s.from-e,s.to-e),h.push(au(t,s)),h.push(i.facet(Dc).scrollToMatch(o.main,t))}return t.dispatch({changes:l,selection:o,effects:h,userEvent:"input.replace"}),!0})),Yc=jc(((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map((t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}}));if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:zr.announce.of(n),userEvent:"input.replace.all"}),!0}));function Jc(t){return t.state.facet(Dc).createPanel(t)}function Xc(t,e){var i,n,r,s,o;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let h=t.facet(Dc);return new Oc({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:h.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==e?void 0:e.caseSensitive)&&void 0!==n?n:h.caseSensitive,literal:null!==(r=null==e?void 0:e.literal)&&void 0!==r?r:h.literal,regexp:null!==(s=null==e?void 0:e.regexp)&&void 0!==s?s:h.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:h.wholeWord})}function Zc(t){let e=Ts(t,Jc);return e&&e.dom.querySelector("[main-field]")}function Qc(t){let e=Zc(t);e&&e==t.root.activeElement&&e.select()}const tu=t=>{let e=t.state.field(Hc,!1);if(e&&e.panel){let i=Zc(t);if(i&&i!=t.root.activeElement){let n=Xc(t.state,e.query.spec);n.valid&&t.dispatch({effects:Ic.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[Vc.of(!0),e?Ic.of(Xc(t.state,e.query.spec)):ut.appendConfig.of(hu)]});return!0},eu=t=>{let e=t.state.field(Hc,!1);if(!e||!e.panel)return!1;let i=Ts(t,Jc);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Vc.of(!1)}),!0},iu=[{key:"Mod-f",run:tu,scope:"editor search-panel"},{key:"F3",run:Kc,shift:$c,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Kc,shift:$c,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:eu,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],o=0;for(let e=new gc(t.doc,t.sliceDoc(n,r));!e.next().done;){if(s.length>1e3)return!1;e.value.from==n&&(o=s.length),s.push(z.range(e.value.from,e.value.to))}return e(t.update({selection:z.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:t=>{let e=Ts(t,Ac);if(!e){let i=[Mc.of(!0)];null==t.state.field(Cc,!1)&&i.push(ut.appendConfig.of([Cc,Tc])),t.dispatch({effects:i}),e=Ts(t,Ac)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:i}=t,n=z.create(i.ranges.map((e=>t.wordAt(e.head)||z.cursor(e.head))),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)})({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=n)))return!1;let r=function(t,e){let{main:i,ranges:n}=t.selection,r=t.wordAt(i.head),s=r&&r.from==i.from&&r.to==i.to;for(let i=!1,r=new gc(t.doc,e,n[n.length-1].to);;){if(r.next(),!r.done){if(i&&n.some((t=>t.from==r.value.from)))continue;if(s){let e=t.wordAt(r.value.from);if(!e||e.from!=r.value.from||e.to!=r.value.to)continue}return r.value}if(i)return null;r=new gc(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(t,n);return!!r&&(e(t.update({selection:t.selection.addRange(z.range(r.from,r.to),!1),effects:zr.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class nu{constructor(t){this.view=t;let e=this.query=t.state.field(Hc).query.spec;function i(t,e,i){return fc("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=fc("input",{value:e.search,placeholder:ru(t,"Find"),"aria-label":ru(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=fc("input",{value:e.replace,placeholder:ru(t,"Replace"),"aria-label":ru(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=fc("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=fc("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=fc("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=fc("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>Kc(t)),[ru(t,"next")]),i("prev",(()=>$c(t)),[ru(t,"previous")]),i("select",(()=>Gc(t)),[ru(t,"all")]),fc("label",null,[this.caseField,ru(t,"match case")]),fc("label",null,[this.reField,ru(t,"regexp")]),fc("label",null,[this.wordField,ru(t,"by word")]),...t.state.readOnly?[]:[fc("br"),this.replaceField,i("replace",(()=>Uc(t)),[ru(t,"replace")]),i("replaceAll",(()=>Yc(t)),[ru(t,"replace all")])],fc("button",{name:"close",onclick:()=>eu(t),"aria-label":ru(t,"close"),type:"button"},["×"])])}commit(){let t=new Oc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Ic.of(t)}))}keydown(t){var e,i;i=t,Yr($r((e=this.view).state),i,e,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?$c:Kc)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),Uc(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(Ic)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Dc).top}}function ru(t,e){return t.state.phrase(e)}const su=30,ou=/[\s\.,:;?!]/;function au(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),r=t.state.doc.lineAt(i).to,s=Math.max(n.from,e-su),o=Math.min(r,i+su),a=t.state.sliceDoc(s,o);if(s!=n.from)for(let t=0;t<su;t++)if(!ou.test(a[t+1])&&ou.test(a[t])){a=a.slice(t);break}if(o!=r)for(let t=a.length-1;t>a.length-su;t--)if(!ou.test(a[t-1])&&ou.test(a[t])){a=a.slice(0,t);break}return zr.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const lu=zr.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),hu=[Hc,U.low(_c),lu];class cu{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class uu{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=t,r=i.facet(Mu).markerFilter;r&&(n=r(n));let s=Qe.set(n.map((t=>t.from==t.to||t.from==t.to-1&&i.doc.lineAt(t.from).to==t.from?Qe.widget({widget:new Du(t),diagnostic:t}).range(t.from):Qe.mark({attributes:{class:"cm-lintRange cm-lintRange-"+t.severity+(t.markClass?" "+t.markClass:"")},diagnostic:t}).range(t.from,t.to))),!0);return new uu(s,e,du(s))}}function du(t,e=null,i=0){let n=null;return t.between(i,1e9,((t,i,{spec:r})=>{if(!e||r.diagnostic==e)return n=new cu(t,i,r.diagnostic),!1})),n}function fu(t,e){let i=t.startState.doc.lineAt(e.pos);return!(!t.effects.some((t=>t.is(mu)))&&!t.changes.touchesRange(i.from,i.to))}function pu(t,e){return t.field(vu,!1)?e:e.concat(ut.appendConfig.of(qu))}const mu=ut.define(),gu=ut.define(),wu=ut.define(),vu=$.define({create:()=>new uu(Qe.none,null,null),update(t,e){if(e.docChanged){let i=t.diagnostics.map(e.changes),n=null;if(t.selected){let r=e.changes.mapPos(t.selected.from,1);n=du(i,t.selected.diagnostic,r)||du(i,null,r)}t=new uu(i,t.panel,n)}for(let i of e.effects)i.is(mu)?t=uu.init(i.value,t.panel,e.state):i.is(gu)?t=new uu(t.diagnostics,i.value?Lu.open:null,t.selected):i.is(wu)&&(t=new uu(t.diagnostics,t.panel,i.value));return t},provide:t=>[Es.from(t,(t=>t.panel)),zr.decorations.from(t,(t=>t.diagnostics))]}),bu=Qe.mark({class:"cm-lintRange cm-lintRange-active"});function ku(t,e,i){let{diagnostics:n}=t.state.field(vu),r=[],s=2e8,o=0;n.between(e-(i<0?1:0),e+(i>0?1:0),((t,n,{spec:a})=>{e>=t&&e<=n&&(t==n||(e>t||i>0)&&(e<n||i<0))&&(r.push(a.diagnostic),s=Math.min(t,s),o=Math.max(n,o))}));let a=t.state.facet(Mu).tooltipFilter;return a&&(r=a(r)),r.length?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create:()=>({dom:yu(t,r)})}:null}function yu(t,e){return fc("ul",{class:"cm-tooltip-lint"},e.map((e=>Tu(t,e,!1))))}const xu=t=>{let e=t.state.field(vu,!1);return!(!e||!e.panel||(t.dispatch({effects:gu.of(!1)}),0))},Su=[{key:"Mod-Shift-m",run:t=>{let e=t.state.field(vu,!1);e&&e.panel||t.dispatch({effects:pu(t.state,[gu.of(!0)])});let i=Ts(t,Lu.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(vu,!1);if(!e)return!1;let i=t.state.selection.main,n=e.diagnostics.iter(i.to+1);return!(!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==i.from&&n.to==i.to)||(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),0))}}],Au=Si.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(Mu);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:t}=this.view,{sources:e}=t.facet(Mu);Promise.all(e.map((t=>Promise.resolve(t(this.view))))).then((e=>{let i=e.reduce(((t,e)=>t.concat(e)));this.view.state.doc==t.doc&&this.view.dispatch(function(t,e){return{effects:pu(t,[mu.of(e)])}}(this.view.state,i))}),(t=>{bi(this.view.state,t)}))}}update(t){let e=t.state.facet(Mu);(t.docChanged||e!=t.startState.facet(Mu)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),Mu=H.define({combine:t=>Object.assign({sources:t.map((t=>t.source))},St(t.map((t=>t.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e}))});function Cu(t){let e=[];if(t)t:for(let{name:i}of t){for(let t=0;t<i.length;t++){let n=i[t];if(/[a-zA-Z]/.test(n)&&!e.some((t=>t.toLowerCase()==n.toLowerCase()))){e.push(n);continue t}}e.push("")}return e}function Tu(t,e,i){var n;let r=i?Cu(e.actions):[];return fc("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},fc("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),null===(n=e.actions)||void 0===n?void 0:n.map(((i,n)=>{let s=!1,o=n=>{if(n.preventDefault(),s)return;s=!0;let r=du(t.state.field(vu).diagnostics,e);r&&i.apply(t,r.from,r.to)},{name:a}=i,l=r[n]?a.indexOf(r[n]):-1,h=l<0?a:[a.slice(0,l),fc("u",a.slice(l,l+1)),a.slice(l+1)];return fc("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${a}${l<0?"":` (access key "${r[n]})"`}.`},h)})),e.source&&fc("div",{class:"cm-diagnosticSource"},e.source))}class Du extends Xe{constructor(t){super(),this.diagnostic=t}eq(t){return t.diagnostic==this.diagnostic}toDOM(){return fc("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Ou{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Tu(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Lu{constructor(t){this.view=t,this.items=[],this.list=fc("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e=>{if(27==e.keyCode)xu(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=Cu(i.actions);for(let r=0;r<n.length;r++)if(n[r].toUpperCase().charCodeAt(0)==e.keyCode){let e=du(this.view.state.field(vu).diagnostics,i);e&&i.actions[r].apply(t,e.from,e.to)}}}e.preventDefault()},onclick:t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)}}),this.dom=fc("div",{class:"cm-panel-lint"},this.list,fc("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>xu(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(vu).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(vu),i=0,n=!1,r=null;for(t.between(0,this.view.state.doc.length,((t,s,{spec:o})=>{let a,l=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==o.diagnostic){l=t;break}l<0?(a=new Ou(this.view,o.diagnostic),this.items.splice(i,0,a),n=!0):(a=this.items[l],l>i&&(this.items.splice(i,l-i),n=!0)),e&&a.diagnostic==e.diagnostic?a.dom.hasAttribute("aria-selected")||(a.dom.setAttribute("aria-selected","true"),r=a):a.dom.hasAttribute("aria-selected")&&a.dom.removeAttribute("aria-selected"),i++}));i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();0==this.items.length&&(this.items.push(new Ou(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let i=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/i:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=du(this.view.state.field(vu).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:wu.of(e)})}static open(t){return new Lu(t)}}function Eu(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Bu(t){return Eu(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Pu=zr.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Bu("#d11")},".cm-lintRange-warning":{backgroundImage:Bu("orange")},".cm-lintRange-info":{backgroundImage:Bu("#999")},".cm-lintRange-hint":{backgroundImage:Bu("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Nu(t){return"error"==t?4:"warning"==t?3:"info"==t?2:1}class Ru extends Bs{constructor(t){super(),this.diagnostics=t,this.severity=t.reduce(((t,e)=>Nu(t)<Nu(e.severity)?e.severity:t),"hint")}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=t.state.facet(_u).tooltipFilter;return n&&(i=n(i)),i.length&&(e.onmouseover=()=>function(t,e,i){function n(){let n=t.elementAtHeight(e.getBoundingClientRect().top+5-t.documentTop);t.coordsAtPos(n.from)&&t.dispatch({effects:Hu.of({pos:n.from,above:!1,create:()=>({dom:yu(t,i),getCoords:()=>e.getBoundingClientRect()})})}),e.onmouseout=e.onmousemove=null,function(t,e){let i=n=>{let r=e.getBoundingClientRect();if(!(n.clientX>r.left-10&&n.clientX<r.right+10&&n.clientY>r.top-10&&n.clientY<r.bottom+10)){for(let t=n.target;t;t=t.parentNode)if(1==t.nodeType&&t.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",i),t.state.field(Wu)&&t.dispatch({effects:Hu.of(null)})}};window.addEventListener("mousemove",i)}(t,e)}let{hoverTime:r}=t.state.facet(_u),s=setTimeout(n,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(n,r)}}(t,e,i)),e}}function zu(t,e){let i=Object.create(null);for(let n of e){let e=t.lineAt(n.from);(i[e.from]||(i[e.from]=[])).push(n)}let n=[];for(let t in i)n.push(new Ru(i[t]).range(+t));return Dt.of(n,!0)}const Iu=zs({class:"cm-gutter-lint",markers:t=>t.state.field(Vu)}),Vu=$.define({create:()=>Dt.empty,update(t,e){t=t.map(e.changes);let i=e.state.facet(_u).markerFilter;for(let n of e.effects)if(n.is(mu)){let r=n.value;i&&(r=i(r||[])),t=zu(e.state.doc,r.slice(0))}return t}}),Hu=ut.define(),Wu=$.define({create:()=>null,update:(t,e)=>(t&&e.docChanged&&(t=fu(e,t)?null:Object.assign(Object.assign({},t),{pos:e.changes.mapPos(t.pos)})),e.effects.reduce(((t,e)=>e.is(Hu)?e.value:t),t)),provide:t=>vs.from(t)}),Fu=zr.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Eu('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Eu('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Eu('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),qu=[vu,zr.decorations.compute([vu],(t=>{let{selected:e,panel:i}=t.field(vu);return e&&i&&e.from!=e.to?Qe.set([bu.range(e.from,e.to)]):Qe.none})),As(ku,{hideOn:fu}),Pu],_u=H.define({combine:t=>St(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})});function ju(t={}){return[_u.of(t),Vu,Iu,Fu,Wu]}const Ku=Ra(Va),$u={plain:()=>[],javascript:()=>new va(Ja.define(dl),Ku),css:()=>new va(Ja.define(Rl),Ku),mediawiki:Fl,html:t=>Fl({...t,tags:{...t.tags,script:!0,style:!0},tagModes:{...t.tagModes,script:"javascript",style:"css"}})},Gu={};class Uu{constructor(t,e="plain",i){this.textarea=t,this.language=new J,this.linter=new J,this.lintGutter=new J;const n=[this.language.of($u[e](i)),this.linter.of([]),this.lintGutter.of([]),zr.contentAttributes.of({accesskey:t.accessKey,dir:t.dir,lang:t.lang}),Js(),zr.lineWrapping,eh(),rs(),hs,xt.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,r=i.lineAt(n);if(n>r.from+200)return t;let s=i.sliceString(r.from,n);if(!e.some((t=>t.test(s))))return t;let{state:o}=t,a=-1,l=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==a)continue;a=e.from;let i=Sa(o,e.from);if(null==i)continue;let n=/^\s*/.exec(e.text)[0],r=xa(o,i);n!=r&&l.push({from:e.from,to:e.from+n.length,insert:r})}return l.length?[t,{changes:l,sequential:!0}]:t})),jr.of([...dc,...vh,...iu,...Su])];this.view=new zr({extensions:n,doc:t.value,parent:t.parentElement}),this.view.dom.style.height=`${t.offsetHeight}px`,this.view.requestMeasure(),t.style.display="none",t.form&&t.form.addEventListener("submit",(()=>{this.save()}))}setLanguage(t="plain",e){this.view.dispatch({effects:[this.language.reconfigure($u[t](e)),this.linter.reconfigure(t in Gu?Gu[t]:[]),this.lintGutter.reconfigure(t in Gu?ju():[])]})}lint(t){const e=this.language.get(this.view.state).language,i=e?e.name:"plain",n=t?function(t,e={}){return[Mu.of({source:t,config:e}),Au,qu]}(t):[];t?Gu[i]=n:delete Gu[i],this.view.dispatch({effects:[this.linter.reconfigure(n),this.lintGutter.reconfigure(t?ju():[])]})}save(){this.textarea.value=this.view.state.doc.toString()}}var Yu=e.a;export{Yu as CodeMirror6};
1
+ var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{a:()=>Uu});var i={};t.r(i),t.d(i,{css:()=>Rl,javascript:()=>dl});class n{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=d(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),s.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=d(this,t,e);let i=[];return this.decompose(t,e,i,0),s.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new l(this),r=new l(t);for(let t=e,s=e;;){if(n.next(t),r.next(t),t=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(s+=n.value.length,n.done||s>=i)return!0}}iter(t=1){return new l(this,t)}iterRange(t,e=this.length){return new h(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new r(t):s.from(r.split(t,[])):n.empty}}class r extends n{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,n){for(let r=0;;r++){let s=this.text[r],o=n+s.length;if((e?i:o)>=t)return new u(n,o,i,s);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new r(a(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new r(e,t.length+s.length));else{let t=e.length>>1;i.push(new r(e.slice(0,t)),new r(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof r))return super.replace(t,e,i);[t,e]=d(this,t,e);let n=o(this.text,o(i.text,a(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new r(n,l):s.from(r.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let r=0,s=0;r<=e&&s<this.text.length;s++){let o=this.text[s],a=r+o.length;r>t&&s&&(n+=i),t<a&&e>r&&(n+=o.slice(Math.max(0,t-r),e-r)),r=a+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new r(i,n)),i=[],n=-1);return n>-1&&e.push(new r(i,n)),e}}class s extends n{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let r=0;;r++){let s=this.children[r],o=n+s.length,a=i+s.lines-1;if((e?a:o)>=t)return s.lineInner(t,e,i,n);n=o+1,i=a+1}}decompose(t,e,i,n){for(let r=0,s=0;s<=e&&r<this.children.length;r++){let o=this.children[r],a=s+o.length;if(t<=a&&e>=s){let r=n&((s<=t?1:0)|(a>=e?2:0));s>=t&&a<=e&&!r?i.push(o):o.decompose(t-s,e-s,i,r)}s=a+1}}replace(t,e,i){if([t,e]=d(this,t,e),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],a=r+o.length;if(t>=r&&e<=a){let l=o.replace(t-r,e-r,i),h=this.lines-o.lines+l.lines;if(l.lines<h>>4&&l.lines>h>>6){let r=this.children.slice();return r[n]=l,new s(r,this.length-(e-t)+i.length)}return super.replace(r,a,l)}r=a+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let r=0,s=0;r<this.children.length&&s<=e;r++){let o=this.children[r],a=s+o.length;s>t&&r&&(n+=i),t<a&&e>s&&(n+=o.sliceString(t-s,e-s,i)),s=a+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof s))return 0;let i=0,[n,r,o,a]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,r+=e){if(n==o||r==a)return i;let s=this.children[n],l=t.children[r];if(s!=l)return i+s.scanIdentical(l,e);i+=s.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 r(i,e)}let n=Math.max(32,i>>5),o=n<<1,a=n>>1,l=[],h=0,c=-1,u=[];function d(t){let e;if(t.lines>o&&t instanceof s)for(let e of t.children)d(e);else t.lines>a&&(h>a||!h)?(f(),l.push(t)):t instanceof r&&h&&(e=u[u.length-1])instanceof r&&t.lines+e.lines<=32?(h+=t.lines,c+=t.length+1,u[u.length-1]=new r(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&f(),h+=t.lines,c+=t.length+1,u.push(t))}function f(){0!=h&&(l.push(1==u.length?u[0]:s.from(u,c)),c=-1,h=u.length=0)}for(let e of t)d(e);return f(),1==l.length?l[0]:new s(l,e)}}function o(t,e,i=0,n=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=n;s++){let a=t[s],l=r+a.length;l>=i&&(l>n&&(a=a.slice(0,n-r)),r<i&&(a=a.slice(i-r)),o?(e[e.length-1]+=a,o=!1):e.push(a)),r=l+1}return e}function a(t,e,i){return o(t,[""],e,i)}n.empty=new r([""],0);class l{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 r?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,a=n instanceof r?n.text.length:n.children.length;if(o==(e>0?a: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&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof r){let r=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,r.length>Math.max(0,t))return this.value=0==t?r:e>0?r.slice(t):r.slice(0,r.length-t),this;t-=r.length}else{let s=n.children[o+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof r?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class h{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new l(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class c{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=h.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function d(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let f="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 t=1;t<f.length;t++)f[t]+=f[t-1];function p(t){for(let e=1;e<f.length;e+=2)if(f[e]>t)return f[e-1]<=t;return!1}function m(t){return t>=127462&&t<=127487}const g=8205;function w(t,e,i=!0,n=!0){return(i?v:b)(t,e,n)}function v(t,e,i){if(e==t.length)return e;e&&k(t.charCodeAt(e))&&y(t.charCodeAt(e-1))&&e--;let n=x(t,e);for(e+=A(n);e<t.length;){let r=x(t,e);if(n==g||r==g||i&&p(r))e+=A(r),n=r;else{if(!m(r))break;{let i=0,n=e-2;for(;n>=0&&m(x(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function b(t,e,i){for(;e>0;){let n=v(t,e-2,i);if(n<e)return n;e--}return 0}function k(t){return t>=56320&&t<57344}function y(t){return t>=55296&&t<56320}function x(t,e){let i=t.charCodeAt(e);if(!y(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return k(n)?n-56320+(i-55296<<10)+65536:i}function S(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function A(t){return t<65536?1:2}const M=/\r\n?|\n/;var C=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(C||(C={}));class T{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,n=0;e<this.sections.length;){let r=this.sections[e++],s=this.sections[e++];s<0?(t(i,n,r),n+=r):n+=s,i+=r}}iterChangedRanges(t,e=!1){E(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new T(t)}composeDesc(t){return this.empty?t:t.empty?this:P(this,t)}mapDesc(t,e=!1){return t.empty?this:B(this,t,e)}mapPos(t,e=-1,i=C.Simple){let n=0,r=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],a=this.sections[s++],l=n+o;if(a<0){if(l>t)return r+(t-n);r+=o}else{if(i!=C.Simple&&l>=t&&(i==C.TrackDel&&n<t&&l>t||i==C.TrackBefore&&n<t||i==C.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?r:r+a;r+=a}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return r}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let r=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&r>=t)return!(n<t&&r>e)||"cover";n=r}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new T(t)}static create(t){return new T(t)}}class D extends T{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return E(this,((e,i,n,r,s)=>t=t.replace(n,n+(i-e),s)),!1),t}mapDesc(t,e=!1){return B(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let r=0,s=0;r<e.length;r+=2){let o=e[r],a=e[r+1];if(a>=0){e[r]=a,e[r+1]=o;let l=r>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(s,s+o):n.empty)}s+=o}return new D(e,i)}compose(t){return this.empty?t:t.empty?this:P(this,t,!0)}map(t,e=!1){return t.empty?this:B(this,t,e,!0)}iterChanges(t,e=!1){E(this,t,e)}get desc(){return T.create(this.sections)}filter(t){let e=[],i=[],n=[],r=new N(this);t:for(let s=0,o=0;;){let a=s==t.length?1e9:t[s++];for(;o<a||o==a&&0==r.len;){if(r.done)break t;let t=Math.min(r.len,a-o);O(n,t,-1);let s=-1==r.ins?-1:0==r.off?r.ins:0;O(e,t,s),s>0&&L(i,e,r.text),r.forward(t),o+=t}let l=t[s++];for(;o<l;){if(r.done)break t;let t=Math.min(r.len,l-o);O(e,t,-1),O(n,t,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(t),o+=t}}return{changes:new D(e,i),filtered:T.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let r=[],s=[],o=0,a=null;function l(t=!1){if(!t&&!r.length)return;o<e&&O(r,e-o,-1);let i=new D(r,s);a=a?a.compose(i.map(a)):i,r=[],s=[],o=0}return function t(h){if(Array.isArray(h))for(let e of h)t(e);else if(h instanceof D){if(h.length!=e)throw new RangeError(`Mismatched change set length (got ${h.length}, expected ${e})`);l(),a=a?a.compose(h.map(a)):h}else{let{from:t,to:a=t,insert:c}=h;if(t>a||t<0||a>e)throw new RangeError(`Invalid change range ${t} to ${a} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||M)):c:n.empty,d=u.length;if(t==a&&0==d)return;t<o&&l(),t>o&&O(r,t-o,-1),O(r,a-t,d),L(s,r,u),o=a}}(t),l(!a),a}static empty(t){return new D(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let r=0;r<t.length;r++){let s=t[r];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<r;)i.push(n.empty);i[r]=n.of(s.slice(1)),e.push(s[0],i[r].length)}}}return new D(e,i)}static createSet(t,e){return new D(t,e)}}function O(t,e,i,n=!1){if(0==e&&i<=0)return;let r=t.length-2;r>=0&&i<=0&&i==t[r+1]?t[r]+=e:0==e&&0==t[r]?t[r+1]+=i:n?(t[r]+=e,t[r+1]+=i):t.push(e,i)}function L(t,e,i){if(0==i.length)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<r;)t.push(n.empty);t.push(i)}}function E(t,e,i){let r=t.inserted;for(let s=0,o=0,a=0;a<t.sections.length;){let l=t.sections[a++],h=t.sections[a++];if(h<0)s+=l,o+=l;else{let c=s,u=o,d=n.empty;for(;c+=l,u+=h,h&&r&&(d=d.append(r[a-2>>1])),!(i||a==t.sections.length||t.sections[a+1]<0);)l=t.sections[a++],h=t.sections[a++];e(s,c,o,u,d),s=c,o=u}}}function B(t,e,i,n=!1){let r=[],s=n?[]:null,o=new N(t),a=new N(e);for(let t=-1;;)if(-1==o.ins&&-1==a.ins){let t=Math.min(o.len,a.len);O(r,t,-1),o.forward(t),a.forward(t)}else if(a.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(a.len<o.len||a.len==o.len&&!i))){let e=a.len;for(O(r,a.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(O(r,0,o.ins),s&&L(s,r,o.text),t=o.i),o.forward(i),e-=i}a.next()}else{if(!(o.ins>=0)){if(o.done&&a.done)return s?D.createSet(r,s):T.create(r);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==a.ins){let t=Math.min(i,a.len);e+=t,i-=t,a.forward(t)}else{if(!(0==a.ins&&a.len<i))break;i-=a.len,a.next()}O(r,e,t<o.i?o.ins:0),s&&t<o.i&&L(s,r,o.text),t=o.i,o.forward(o.len-i)}}}function P(t,e,i=!1){let n=[],r=i?[]:null,s=new N(t),o=new N(e);for(let t=!1;;){if(s.done&&o.done)return r?D.createSet(n,r):T.create(n);if(0==s.ins)O(n,s.len,0,t),s.next();else if(0!=o.len||o.done){if(s.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(s.len2,o.len),i=n.length;if(-1==s.ins){let i=-1==o.ins?-1:o.off?0:o.ins;O(n,e,i,t),r&&i&&L(r,n,o.text)}else-1==o.ins?(O(n,s.off?0:s.len,e,t),r&&L(r,n,s.textBit(e))):(O(n,s.off?0:s.len,o.off?0:o.ins,t),r&&!o.off&&L(r,n,o.text));t=(s.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),s.forward2(e),o.forward(e)}}else O(n,0,o.ins,t),r&&L(r,n,o.text),o.next()}}class N{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?n.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.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 R{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 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new R(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return z.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return z.range(this.anchor,i)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return z.range(t.anchor,t.head)}static create(t,e,i){return new R(t,e,i)}}class z{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:z.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let e=0;e<this.ranges.length;e++)if(!this.ranges[e].eq(t.ranges[e]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new z([this.main],0)}addRange(t,e=!0){return z.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,z.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 new RangeError("Invalid JSON representation for EditorSelection");return new z(t.ranges.map((t=>R.fromJSON(t))),t.main)}static single(t,e=t){return new z([z.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let r=t[n];if(r.empty?r.from<=i:r.from<i)return z.normalized(t.slice(),e);i=r.to}return new z(t,e)}static cursor(t,e=0,i,n){return R.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let r=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?R.create(e,t,48|r):R.create(t,e,(e>t?8:0)|r)}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 n=t[i],r=t[i-1];if(n.empty?n.from<=r.to:n.from<r.to){let s=r.from,o=Math.max(n.to,r.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?z.range(o,s):z.range(s,o))}}return new z(t,e)}}function I(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let V=0;class H{constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=V++,this.default=t([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:W),!!t.static,t.enables)}of(t){return new F([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new F(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function W(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class F{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=V++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,r=this.id,s=t[r]>>1,o=2==this.type,a=!1,l=!1,h=[];for(let i of this.dependencies)"doc"==i?a=!0:"selection"==i?l=!0:0==(1&(null!==(e=t[i.id])&&void 0!==e?e:1))&&h.push(t[i.id]);return{create:t=>(t.values[s]=i(t),1),update(t,e){if(a&&e.docChanged||l&&(e.docChanged||e.selection)||_(t,h)){let e=i(t);if(o?!q(e,t.values[s],n):!n(e,t.values[s]))return t.values[s]=e,1}return 0},reconfigure:(t,e)=>{let a,l=e.config.address[r];if(null!=l){let r=tt(e,l);if(this.dependencies.every((i=>i instanceof H?e.facet(i)===t.facet(i):!(i instanceof $)||e.field(i,!1)==t.field(i,!1)))||(o?q(a=i(t),r,n):n(a=i(t),r)))return t.values[s]=r,0}else a=i(t);return t.values[s]=a,1}}}}function q(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function _(t,e){let i=!1;for(let n of e)1&Q(t,n)&&(i=!0);return i}function j(t,e,i){let n=i.map((e=>t[e.id])),r=i.map((t=>t.type)),s=n.filter((t=>!(1&t))),o=t[e.id]>>1;function a(t){let i=[];for(let e=0;e<n.length;e++){let s=tt(t,n[e]);if(2==r[e])for(let t of s)i.push(t);else i.push(s)}return e.combine(i)}return{create(t){for(let e of n)Q(t,e);return t.values[o]=a(t),1},update(t,i){if(!_(t,s))return 0;let n=a(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,r){let s=_(t,n),l=r.config.facets[e.id],h=r.facet(e);if(l&&!s&&W(i,l))return t.values[o]=h,0;let c=a(t);return e.compare(c,h)?(t.values[o]=h,0):(t.values[o]=c,1)}}}const K=H.define({static:!0});class ${constructor(t,e,i,n,r){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(t){let e=new $(V++,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(K).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 n=t.values[e],r=this.updateF(n,i);return this.compareF(n,r)?0:(t.values[e]=r,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,K.of({field:this,create:t})]}get extension(){return this}}function G(t){return e=>new Y(e,t)}const U={highest:G(0),high:G(1),default:G(2),low:G(3),lowest:G(4)};class Y{constructor(t,e){this.inner=t,this.prec=e}}class J{of(t){return new X(this,t)}reconfigure(t){return J.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class X{constructor(t,e){this.compartment=t,this.inner=e}}class Z{constructor(t,e,i,n,r,s){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=s,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){let n=[],r=Object.create(null),s=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],r=new Map;return function t(s,o){let a=r.get(s);if(null!=a){if(a<=o)return;let t=n[a].indexOf(s);t>-1&&n[a].splice(t,1),s instanceof X&&i.delete(s.compartment)}if(r.set(s,o),Array.isArray(s))for(let e of s)t(e,o);else if(s instanceof X){if(i.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(s.compartment)||s.inner;i.set(s.compartment,n),t(n,o)}else if(s instanceof Y)t(s.inner,s.prec);else if(s instanceof $)n[o].push(s),s.provides&&t(s.provides,o);else if(s instanceof F)n[o].push(s),s.facet.extensions&&t(s.facet.extensions,2);else{let e=s.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);t(e,o)}}(t,2),n.reduce(((t,e)=>t.concat(e)))}(t,e,s))i instanceof $?n.push(i):(r[i.facet.id]||(r[i.facet.id]=[])).push(i);let o=Object.create(null),a=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let h=null==i?void 0:i.config.facets;for(let t in r){let e=r[t],n=e[0].facet,s=h&&h[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=a.length<<1|1,W(s,e))a.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));a.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=a.length<<1|1,a.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>j(t,n,e)))}}let c=l.map((t=>t(o)));return new Z(t,s,c,o,a,r)}}function Q(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let r=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|r}function tt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const et=H.define(),it=H.define({combine:t=>t.some((t=>t)),static:!0}),nt=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),rt=H.define(),st=H.define(),ot=H.define(),at=H.define({combine:t=>!!t.length&&t[0]});class lt{constructor(t,e){this.type=t,this.value=e}static define(){return new ht}}class ht{of(t){return new lt(this,t)}}class ct{constructor(t){this.map=t}of(t){return new ut(this,t)}}class ut{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 ut(this.type,e)}is(t){return this.type==t}static define(t={}){return new ct(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}ut.reconfigure=ut.define(),ut.appendConfig=ut.define();class dt{constructor(t,e,i,n,r,s){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&I(i,e.newLength),r.some((t=>t.type==dt.time))||(this.annotations=r.concat(dt.time.of(Date.now())))}static create(t,e,i,n,r,s){return new dt(t,e,i,n,r,s)}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(dt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function ft(t,e){let i=[];for(let n=0,r=0;;){let s,o;if(n<t.length&&(r==e.length||e[r]>=t[n]))s=t[n++],o=t[n++];else{if(!(r<e.length))return i;s=e[r++],o=e[r++]}!i.length||i[i.length-1]<s?i.push(s,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function pt(t,e,i){var n;let r,s,o;return i?(r=e.changes,s=D.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):null===(n=t.selection)||void 0===n?void 0:n.map(r),effects:ut.mapEffects(t.effects,r).concat(ut.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function mt(t,e,i){let n=e.selection,r=vt(e.annotations);return e.userEvent&&(r=r.concat(dt.userEvent.of(e.userEvent))),{changes:e.changes instanceof D?e.changes:D.of(e.changes||[],i,t.facet(nt)),selection:n&&(n instanceof z?n:z.single(n.anchor,n.head)),effects:vt(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function gt(t,e,i){let n=mt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let r=1;r<e.length;r++){!1===e[r].filter&&(i=!1);let s=!!e[r].sequential;n=pt(n,mt(t,e[r],s?n.changes.newLength:t.doc.length),s)}let r=dt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(ot),n=t;for(let r=i.length-1;r>=0;r--){let s=i[r](t);s&&Object.keys(s).length&&(n=pt(n,mt(e,s,t.changes.newLength),!0))}return n==t?t:dt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(rt)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:ft(i,e))}if(!0!==i){let n,r;if(!1===i)r=t.changes.invertedDesc,n=D.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,r=e.filtered.mapDesc(e.changes).invertedDesc}t=dt.create(e,n,t.selection&&t.selection.map(r),ut.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let n=e.facet(st);for(let i=n.length-1;i>=0;i--){let r=n[i](t);t=r instanceof dt?r:Array.isArray(r)&&1==r.length&&r[0]instanceof dt?r[0]:gt(e,vt(r),!1)}return t}(r):r)}dt.time=lt.define(),dt.userEvent=lt.define(),dt.addToHistory=lt.define(),dt.remote=lt.define();const wt=[];function vt(t){return null==t?wt:Array.isArray(t)?t:[t]}var bt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(bt||(bt={}));const kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let yt;try{yt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}class xt{constructor(t,e,i,n,r,s){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Q(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Q(this,i),tt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return gt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:r}=i;for(let e of t.effects)e.is(J.reconfigure)?(i&&(r=new Map,i.compartments.forEach(((t,e)=>r.set(e,t))),i=null),r.set(e.value.compartment,e.value.extension)):e.is(ut.reconfigure)?(i=null,n=e.value):e.is(ut.appendConfig)&&(i=null,n=vt(n).concat(e.value));i?e=t.startState.values.slice():(i=Z.resolve(n,r,this),e=new xt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values);let s=t.startState.facet(it)?t.newSelection:t.newSelection.asSingle();new xt(i,t.newDoc,s,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:z.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),r=[i.range],s=vt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),a=this.changes(o.changes),l=a.map(n);for(let t=0;t<i;t++)r[t]=r[t].map(l);let h=n.mapDesc(a,!0);r.push(o.range.map(h)),n=n.compose(l),s=ut.mapEffects(s,l).concat(ut.mapEffects(vt(o.effects),h))}return{changes:n,selection:z.create(r,e.mainIndex),effects:s}}changes(t=[]){return t instanceof D?t:D.of(t,this.doc.length,this.facet(xt.lineSeparator))}toText(t){return n.of(t.split(this.facet(xt.lineSeparator)||M))}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:(Q(this,e),tt(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof $&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let r=i[e],s=t[e];n.push(r.init((t=>r.spec.fromJSON(s,t))))}return xt.create({doc:t.doc,selection:z.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Z.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(xt.lineSeparator)||M)),r=t.selection?t.selection instanceof z?t.selection:z.single(t.selection.anchor,t.selection.head):z.single(0);return I(r,i.length),e.staticFacet(it)||(r=r.asSingle()),new xt(e,i,r,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(xt.tabSize)}get lineBreak(){return this.facet(xt.lineSeparator)||"\n"}get readOnly(){return this.facet(at)}phrase(t,...e){for(let e of this.facet(xt.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 n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let r of this.facet(et))for(let s of r(this,e,i))Object.prototype.hasOwnProperty.call(s,t)&&n.push(s[t]);return n}charCategorizer(t){return e=this.languageDataAt("wordChars",t).join(""),t=>{if(!/\S/.test(t))return bt.Space;if(function(t){if(yt)return yt.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>"€"&&(i.toUpperCase()!=i.toLowerCase()||kt.test(i)))return!0}return!1}(t))return bt.Word;for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>-1)return bt.Word;return bt.Other};var e}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),r=this.charCategorizer(t),s=t-i,o=t-i;for(;s>0;){let t=w(e,s,!1);if(r(e.slice(t,s))!=bt.Word)break;s=t}for(;o<n;){let t=w(e,o);if(r(e.slice(o,t))!=bt.Word)break;o=t}return s==o?null:z.range(s+i,o+i)}}function St(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let r=e[t],s=n[t];if(void 0===s)n[t]=r;else if(s===r||void 0===r);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](s,r)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}xt.allowMultipleSelections=it,xt.tabSize=H.define({combine:t=>t.length?t[0]:4}),xt.lineSeparator=nt,xt.readOnly=at,xt.phrases=H.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),xt.languageData=et,xt.changeFilter=rt,xt.transactionFilter=st,xt.transactionExtender=ot,J.reconfigure=ut.define();class At{eq(t){return this==t}range(t,e=t){return Mt.create(t,e,this)}}At.prototype.startSide=At.prototype.endSide=0,At.prototype.point=!1,At.prototype.mapMode=C.TrackDel;class Mt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Mt(t,e,i)}}function Ct(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Tt{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let r=i?this.to:this.from;for(let s=n,o=r.length;;){if(s==o)return s;let n=s+o>>1,a=r[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==s)return a>=0?s:o;a>=0?o=n:s=n+1}}between(t,e,i,n){for(let r=this.findIndex(e,-1e9,!0),s=this.findIndex(i,1e9,!1,r);r<s;r++)if(!1===n(this.from[r]+t,this.to[r]+t,this.value[r]))return!1}map(t,e){let i=[],n=[],r=[],s=-1,o=-1;for(let a=0;a<this.value.length;a++){let l,h,c=this.value[a],u=this.from[a]+t,d=this.to[a]+t;if(u==d){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=h=t,c.startSide!=c.endSide&&(h=e.mapPos(u,c.endSide),h<l))continue}else if(l=e.mapPos(u,c.startSide),h=e.mapPos(d,c.endSide),l>h||l==h&&c.startSide>0&&c.endSide<=0)continue;(h-l||c.endSide-c.startSide)<0||(s<0&&(s=l),c.point&&(o=Math.max(o,h-l)),i.push(c),n.push(l-s),r.push(h-s))}return{mapped:i.length?new Tt(n,r,i,o):null,pos:s}}}class Dt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Dt(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=t,s=t.filter;if(0==e.length&&!s)return this;if(i&&(e=e.slice().sort(Ct)),this.isEmpty)return e.length?Dt.of(e):this;let o=new Et(this,null,-1).goto(0),a=0,l=[],h=new Ot;for(;o.value||a<e.length;)if(a<e.length&&(o.from-e[a].from||o.startSide-e[a].value.startSide)>=0){let t=e[a++];h.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(a==e.length||this.chunkEnd(o.chunkIndex)<e[a].from)&&(!s||n>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||n>o.to||r<o.from||s(o.from,o.to,o.value))&&(h.addInner(o.from,o.to,o.value)||l.push(Mt.create(o.from,o.to,o.value))),o.next());return h.finishInner(this.nextLayer.isEmpty&&!l.length?Dt.empty:this.nextLayer.update({add:l,filter:s,filterFrom:n,filterTo:r}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],a=t.touchesRange(s,s+o.length);if(!1===a)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(s));else if(!0===a){let{mapped:r,pos:a}=o.map(s,t);r&&(n=Math.max(n,r.maxPoint),e.push(r),i.push(a))}}let r=this.nextLayer.map(t);return 0==e.length?r:new Dt(i,e,r||Dt.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],s=this.chunk[n];if(e>=r&&t<=r+s.length&&!1===s.between(r,t-r,e-r,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Bt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Bt.from(t).goto(e)}static compare(t,e,i,n,r=-1){let s=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r)),a=Lt(s,o,i),l=new Nt(s,a,r),h=new Nt(o,a,r);i.iterGaps(((t,e,i)=>Rt(l,t,h,e,i,n))),i.empty&&0==i.length&&Rt(l,0,h,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let r=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),s=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=Lt(r,s),a=new Nt(r,o,0).goto(i),l=new Nt(s,o,0).goto(i);for(;;){if(a.to!=l.to||!zt(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>n)return!0;a.next(),l.next()}}static spans(t,e,i,n,r=-1){let s=new Nt(t,null,r).goto(e),o=e,a=s.openStart;for(;;){let t=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),r=s.pointFrom<e?i.length+1:Math.min(i.length,a);n.point(o,t,s.point,i,r,s.pointRank),a=Math.min(s.openEnd(t),i.length)}else t>o&&(n.span(o,t,s.active,a),a=s.openEnd(t));if(s.to>i)return a+(s.point&&s.to>i?1:0);o=s.to,s.next()}}static of(t,e=!1){let i=new Ot;for(let n of t instanceof Mt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Ct(e,n)>0)return t.slice().sort(Ct);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Dt.empty=new Dt([],[],null,-1),Dt.empty.nextLayer=Dt.empty;class Ot{finishChunk(t){this.chunks.push(new Tt(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 Ot)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Dt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Dt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Lt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let r=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let s=n.get(t.chunk[e]);null==s||(i?i.mapPos(s):s)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(s,s+t.chunk[e].length))||r.add(t.chunk[e])}return r}class Et{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let 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 n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{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 Bt{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let r=0;r<t.length;r++)for(let s=t[r];!s.isEmpty;s=s.nextLayer)s.maxPoint>=i&&n.push(new Et(s,e,i,r));return 1==n.length?n[0]:new Bt(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Pt(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--)Pt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&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(),Pt(this.heap,0)}}}function Pt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let r=t[n];if(n+1<t.length&&r.compare(t[n+1])>=0&&(r=t[n+1],n++),i.compare(r)<0)break;t[n]=i,t[e]=r,e=n}}class Nt{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=Bt.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){It(this.active,t),It(this.activeTo,t),It(this.activeRank,t),this.minActive=Ht(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:r}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=r;)e++;Vt(this.active,e,i),Vt(this.activeTo,e,n),Vt(this.activeRank,e,r),t&&Vt(t,e,this.cursor.from),this.minActive=Ht(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&It(i,n)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){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}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}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 Rt(t,e,i,n,r,s){t.goto(e),i.goto(n);let o=n+r,a=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,r=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&zt(t.activeForPoint(t.to),i.activeForPoint(i.to))||s.comparePoint(a,r,t.point,i.point):r>a&&!zt(t.active,i.active)&&s.compareRange(a,r,t.active,i.active),n>o)break;a=n,e<=0&&t.next(),e>=0&&i.next()}}function zt(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 It(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Vt(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function Ht(t,e){let i=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||t[r].endSide-t[i].endSide)<0&&(i=r,n=e[r]);return i}function Wt(t,e,i=t.length){let n=0;for(let r=0;r<i;)9==t.charCodeAt(r)?(n+=e-n%e,r++):(n++,r=w(t,r));return n}const Ft="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),qt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),_t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class jt{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function r(t,e,s,o){let a=[],l=/^@(\w+)\b/.exec(t[0]),h=l&&"keyframes"==l[1];if(l&&null==e)return s.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))r(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,s);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");r(n(i),o,a,h)}else null!=o&&a.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(a.length||h)&&s.push((!i||l||o?t:t.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(let e in t)r(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=_t[Ft]||1;return _t[Ft]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[qt],r=i&&i.nonce;n?r&&n.setNonce(r):n=new $t(t,r),n.mount(Array.isArray(e)?e:[e])}}let Kt=new Map;class $t{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=Kt.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[qt]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],Kt.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[qt]=this}mount(t){let e=this.sheet,i=0,n=0;for(let r=0;r<t.length;r++){let s=t[r],o=this.modules.indexOf(s);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,s),e)for(let t=0;t<s.rules.length;t++)e.insertRule(s.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=s.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}for(var Gt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ut={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Yt="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Jt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Xt=0;Xt<10;Xt++)Gt[48+Xt]=Gt[96+Xt]=String(Xt);for(Xt=1;Xt<=24;Xt++)Gt[Xt+111]="F"+Xt;for(Xt=65;Xt<=90;Xt++)Gt[Xt]=String.fromCharCode(Xt+32),Ut[Xt]=String.fromCharCode(Xt);for(var Zt in Gt)Ut.hasOwnProperty(Zt)||(Ut[Zt]=Gt[Zt]);function Qt(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function te(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function ee(t,e){if(!e.anchorNode)return!1;try{return te(t,e.anchorNode)}catch(t){return!1}}function ie(t){return 3==t.nodeType?pe(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function ne(t,e,i,n){return!!i&&(se(t,e,i,n,-1)||se(t,e,i,n,1))}function re(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function se(t,e,i,n,r){for(;;){if(t==i&&e==n)return!0;if(e==(r<0?0:oe(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=re(t)+(r<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(r<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=r<0?oe(t):0}}}function oe(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function ae(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function le(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function he(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class ce{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?oe(e):0),i,Math.min(t.focusOffset,i?oe(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let ue,de=null;function fe(t){if(t.setActive)return t.setActive();if(de)return t.focus(de);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==de?{get preventScroll(){return de={preventScroll:!0},!0}}:void 0),!de){de=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],r=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=r&&(i.scrollLeft=r)}}}function pe(t,e,i=e){let n=ue||(ue=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function me(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},r=new KeyboardEvent("keydown",n);r.synthetic=!0,t.dispatchEvent(r);let s=new KeyboardEvent("keyup",n);return s.synthetic=!0,t.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function ge(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function we(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}class ve{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new ve(t.parentNode,re(t),e)}static after(t,e){return new ve(t.parentNode,re(t)+1,e)}}const be=[];class ke{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 new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,r=null;for(let s of this.children){if(7&s.flags){if(!s.dom&&(i=r?r.nextSibling:n.firstChild)){let t=ke.get(i);(!t||!t.parent&&t.canReuseDOM(s))&&s.reuseDOM(i)}s.sync(t,e),s.flags&=-8}if(i=r?r.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=s.dom&&(e.written=!0),s.dom.parentNode==n)for(;i&&i!=s.dom;)i=ye(i);else n.insertBefore(s.dom,i);r=s.dom}for(i=r?r.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=ye(i)}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 n=0==oe(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!ke.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,r=-1,s=-1,o=-1;for(let a=0,l=i,h=i;a<this.children.length;a++){let i=this.children[a],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=a,r=l),l>e&&i.dom.parentNode==this.dom){s=a,o=h;break}h=c,l=c+i.breakAfter}return{from:r,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].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=be){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}this.children.splice(t,e-t,...i);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 xe(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,n,r,s){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function ye(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ke.prototype.breakAfter=0;class xe{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 Se(t,e,i,n,r,s,o,a,l){let{children:h}=t,c=h.length?h[e]:null,u=s.length?s[s.length-1]:null,d=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!d&&s.length<2&&c.merge(i,r,s.length?u:null,0==i,a,l))){if(n<h.length){let t=h[n];t&&(r<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(r),r=0),!d&&u&&t.merge(0,r,u,!0,0,l)?s[s.length-1]=t:((r||t.children.length&&!t.children[0].length)&&t.merge(0,r,null,!1,0,l),s.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&s.length&&c.merge(i,c.length,s[0],!1,a,0)?c.breakAfter=s.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,a,0),e++));e<n&&s.length;)if(h[n-1].become(s[s.length-1]))n--,s.pop(),l=s.length?0:a;else{if(!h[e].become(s[0]))break;e++,s.shift(),a=s.length?0:l}!s.length&&e&&n<h.length&&!h[e-1].breakAfter&&h[n].merge(0,0,h[e-1],!1,a,l)&&e--,(e<n||s.length)&&t.replaceChildren(e,n,s)}}function Ae(t,e,i,n,r,s){let o=t.childCursor(),{i:a,off:l}=o.findPos(i,1),{i:h,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,Se(t,h,c,a,l,n,0,r,s)}let Me="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Ce="undefined"!=typeof document?document:{documentElement:{style:{}}};const Te=/Edge\/(\d+)/.exec(Me.userAgent),De=/MSIE \d/.test(Me.userAgent),Oe=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Me.userAgent),Le=!!(De||Oe||Te),Ee=!Le&&/gecko\/(\d+)/i.test(Me.userAgent),Be=!Le&&/Chrome\/(\d+)/.exec(Me.userAgent),Pe="webkitFontSmoothing"in Ce.documentElement.style,Ne=!Le&&/Apple Computer/.test(Me.vendor),Re=Ne&&(/Mobile\/\w+/.test(Me.userAgent)||Me.maxTouchPoints>2);var ze={mac:Re||/Mac/.test(Me.platform),windows:/Win/.test(Me.platform),linux:/Linux|X11/.test(Me.platform),ie:Le,ie_version:De?Ce.documentMode||6:Oe?+Oe[1]:Te?+Te[1]:0,gecko:Ee,gecko_version:Ee?+(/Firefox\/(\d+)/.exec(Me.userAgent)||[0,0])[1]:0,chrome:!!Be,chrome_version:Be?+Be[1]:0,ios:Re,android:/Android\b/.test(Me.userAgent),webkit:Pe,safari:Ne,webkit_version:Pe?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=Ce.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Ie extends ke{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 Ie)||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 Ie(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 ve(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 n=t.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;0==e&&i<0||e==n&&i>=0?ze.chrome||ze.gecko||(e?(r--,o=1):s<n&&(s++,o=-1)):i<0?r--:s<n&&s++;let a=pe(t,r,s).getClientRects();if(!a.length)return null;let l=a[(o?o<0:i>=0)?0:a.length-1];return ze.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(a,(t=>t.width))||l),o?ae(l,o<0):l||null}(this.dom,t,e)}}class Ve extends ke{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(ge(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)&&!(8&(this.flags|t.flags))}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,n,r,s){return!(i&&(!(i instanceof Ve&&i.mark.eq(this.mark))||t&&r<=0||e<this.length&&s<=0)||(Ae(this,t,e,i?i.children.slice():[],r-1,s-1),this.markDirty(),0))}split(t){let e=[],i=0,n=-1,r=0;for(let s of this.children){let o=i+s.length;o>t&&e.push(i<t?s.split(t-i):s),n<0&&i>=t&&(n=r),i=o,r++}let s=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Ve(this.mark,e,s)}domAtPos(t){return Fe(this,t)}coordsAt(t,e){return _e(this,t,e)}}class He extends ke{static create(t,e,i){return new He(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=He.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.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,r,s){return!(i&&(!(i instanceof He&&this.widget.compare(i.widget))||t>0&&r<=0||e<this.length&&s<=0)||(this.length=t+(i?i.length:0)+(this.length-e),0))}become(t){return t instanceof He&&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 n.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,r=this.posAtStart;return i?i.slice(r,r+this.length):n.empty}domAtPos(t){return(this.length?0==t:this.side>0)?ve.before(this.dom):ve.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 n=this.dom.getClientRects(),r=null;if(!n.length)return null;let s=this.side?this.side<0:t>0;for(let e=s?n.length-1:0;r=n[e],!(t>0?0==e:e==n.length-1||r.top<r.bottom);e+=s?-1:1);return ae(r,!s)}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 We extends ke{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof We&&t.side==this.side}split(){return new We(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?ve.before(this.dom):ve.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return n.empty}get isHidden(){return!0}}function Fe(t,e){let i=t.dom,{children:n}=t,r=0;for(let t=0;r<n.length;r++){let s=n[r],o=t+s.length;if(!(o==t&&s.getSide()<=0)){if(e>t&&e<o&&s.dom.parentNode==i)return s.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=r;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=r;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new ve(i,0)}function qe(t,e,i){let n,{children:r}=t;i>0&&e instanceof Ve&&r.length&&(n=r[r.length-1])instanceof Ve&&n.mark.eq(e.mark)?qe(n,e.children[0],i-1):(r.push(e),e.setParent(t)),t.length+=e.length}function _e(t,e,i){let n=null,r=-1,s=null,o=-1;!function t(e,a){for(let l=0,h=0;l<e.children.length&&h<=a;l++){let c=e.children[l],u=h+c.length;u>=a&&(c.children.length?t(c,a-h):(!s||s.isHidden&&i>0)&&(u>a||h==u&&c.getSide()>0)?(s=c,o=a-h):(h<a||h==u&&c.getSide()<0&&!c.isHidden)&&(n=c,r=a-h)),h=u}}(t,e);let a=(i<0?n:s)||n||s;return a?a.coordsAt(Math.max(0,a==n?r:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=ie(e);return i[i.length-1]||null}(t)}function je(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}Ie.prototype.children=He.prototype.children=We.prototype.children=be;const Ke=Object.create(null);function $e(t,e,i){if(t==e)return!0;t||(t=Ke),e||(e=Ke);let n=Object.keys(t),r=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=r.length-(i&&r.indexOf(i)>-1?1:0))return!1;for(let s of n)if(s!=i&&(-1==r.indexOf(s)||t[s]!==e[s]))return!1;return!0}function Ge(t,e,i){let n=!1;if(e)for(let r in e)i&&r in i||(n=!0,"style"==r?t.style.cssText="":t.removeAttribute(r));if(i)for(let r in i)e&&e[r]==i[r]||(n=!0,"style"==r?t.style.cssText=i[r]:t.setAttribute(r,i[r]));return n}function Ue(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class Ye extends ke{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,r,s){if(i){if(!(i instanceof Ye))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Ae(this,t,e,i?i.children.slice():[],r,s),!0}split(t){let e=new Ye;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,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){$e(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){qe(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=je(e,this.attrs||{})),i&&(this.attrs=je({class:i},this.attrs||{}))}domAtPos(t){return Fe(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(ge(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&&(Ge(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&ke.get(n)instanceof Ve;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=ke.get(n))||void 0===i?void 0:i.isEditable)||ze.ios&&this.children.some((t=>t instanceof Ie))))){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,e=0;for(let i of this.children){if(!(i instanceof Ie)||/[^ -~]/.test(i.text))return null;let n=ie(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=_e(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let r=t.children[i],s=n+r.length;if(s>=e){if(r instanceof Ye)return r;if(s>e)break}n=s+r.breakAfter}return null}}class Je extends ke{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,r,s){return!(i&&(!(i instanceof Je&&this.widget.compare(i.widget))||t>0&&r<=0||e<this.length&&s<=0)||(this.length=t+(i?i.length:0)+(this.length-e),0))}domAtPos(t){return 0==t?ve.before(this.dom):ve.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Je(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return be}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.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):n.empty}domBoundsAround(){return null}become(t){return t instanceof Je&&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){return this.widget.coordsAt(this.dom,t,e)}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 Xe{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}destroy(t){}}var Ze=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Ze||(Ze={}));class Qe extends At{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new ti(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 ii(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:r,end:s}=ni(t,n);e=(r?n?-3e8:-1:5e8)-1,i=1+(s?n?2e8:1:-6e8)}return new ii(t,e,i,n,t.widget||null,!0)}static line(t){return new ei(t)}static set(t,e=!1){return Dt.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Qe.none=Dt.empty;class ti extends Qe{constructor(t){let{start:e,end:i}=ni(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 ti&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&$e(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}ti.prototype.point=!1;class ei extends Qe{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof ei&&this.spec.class==t.spec.class&&$e(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}ei.prototype.mapMode=C.TrackBefore,ei.prototype.point=!0;class ii extends Qe{constructor(t,e,i,n,r,s){super(e,i,r,t),this.block=n,this.isReplace=s,this.mapMode=n?e<=0?C.TrackBefore:C.TrackAfter:C.TrackDel}get type(){return this.startSide!=this.endSide?Ze.WidgetRange:this.startSide<=0?Ze.WidgetBefore:Ze.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof ii&&((e=this.widget)==(i=t.widget)||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function ni(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function ri(t,e,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=t?i[r]=Math.max(i[r],e):i.push(t,e)}ii.prototype.point=!0;class si{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,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 Je&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ye),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(oi(new We(-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 Je||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new 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 n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(oi(new Ie(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,r,s){if(this.disallowBlockEffectsFor[s]&&i instanceof ii){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=e-t;if(i instanceof ii)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Je(i.widget||new ai("div"),o,i));else{let s=He.create(i.widget||new ai("span"),o,o?0:i.startSide),a=this.atCursorPos&&!s.isEditable&&r<=n.length&&(t<e||i.startSide>0),l=!s.isEditable&&(t<e||r>n.length||i.startSide<=0),h=this.getLine();2!=this.pendingBuffer||a||s.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),a&&(h.append(oi(new We(1),n),r),r=n.length+Math.max(0,r-n.length)),h.append(oi(s,n),r),this.atCursorPos=l,this.pendingBuffer=l?t<e||r>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.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=r)}static build(t,e,i,n,r){let s=new si(t,e,i,r);return s.openEnd=Dt.spans(n,e,i,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}}function oi(t,e){for(let i of e)t=new Ve(i,[t],t.length);return t}class ai extends Xe{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}}const li=H.define(),hi=H.define(),ci=H.define(),ui=H.define(),di=H.define(),fi=H.define(),pi=H.define(),mi=H.define({combine:t=>t.some((t=>t))}),gi=H.define({combine:t=>t.some((t=>t))});class wi{constructor(t,e="nearest",i="nearest",n=5,r=5,s=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=s}map(t){return t.empty?this:new wi(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 wi(z.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const vi=ut.define({map:(t,e)=>t.map(e)});function bi(t,e,i){let n=t.facet(ui);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const ki=H.define({combine:t=>!t.length||t[0]});let yi=0;const xi=H.define();class Si{constructor(t,e,i,n,r){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=r(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:r,decorations:s}=e||{};return new Si(yi++,t,i,n,(t=>{let e=[xi.of(t)];return s&&e.push(Ti.of((e=>{let i=e.plugin(t);return i?s(i):Qe.none}))),r&&e.push(r(t)),e}))}static fromClass(t,e){return Si.define((e=>new t(e)),e)}}class Ai{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(bi(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.create(t)}catch(e){bi(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){bi(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Mi=H.define(),Ci=H.define(),Ti=H.define(),Di=H.define(),Oi=H.define();function Li(t,e,i){let n=t.state.facet(Oi);if(!n.length)return n;let r=n.map((e=>e instanceof Function?e(t):e)),s=[];return Dt.spans(r,e,i,{point(){},span(t,e,i,n){let r=s;for(let s=i.length-1;s>=0;s--,n--){let o,a=i[s].spec.bidiIsolate;if(null!=a)if(n>0&&r.length&&(o=r[r.length-1]).to==t&&o.direction==a)o.to=e,r=o.inner;else{let i={from:t,to:e,direction:a,inner:[]};r.push(i),r=i.inner}}}}),s}const Ei=H.define();function Bi(t){let e=0,i=0,n=0,r=0;for(let s of t.state.facet(Ei)){let o=s(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:e,right:i,top:n,bottom:r}}const Pi=H.define();class Ni{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Ni(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,r=0,s=0,o=0;;n++){let a=n==t.length?null:t[n],l=s-o,h=a?a.fromB:1e9;for(;r<e.length&&e[r]<h;){let t=e[r],n=e[r+1],s=Math.max(o,t),a=Math.min(h,n);if(s<=a&&new Ni(s+l,a+l,s,a).addToSet(i),n>h)break;r+=2}if(!a)return i;new Ni(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),s=a.toA,o=a.toB}}}class Ri{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=D.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,r)=>n.push(new Ni(t,e,i,r)))),this.changedRanges=n}static create(t,e,i){return new Ri(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&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}}var zi=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(zi||(zi={}));const Ii=zi.LTR,Vi=zi.RTL;function Hi(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Wi=Hi("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Fi=Hi("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),qi=Object.create(null),_i=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);qi[e]=i,qi[i]=-e}const ji=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ki{get dir(){return this.level%2?Vi:Ii}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}static find(t,e,i,n){let r=-1;for(let s=0;s<t.length;s++){let o=t[s];if(o.from<=e&&o.to>=e){if(o.level==i)return s;(r<0||(0!=n?n<0?o.from<e:o.to>e:t[r].level>o.level))&&(r=s)}}if(r<0)throw new RangeError("Index out of range");return r}}function $i(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!$i(n.inner,r.inner))return!1}return!0}const Gi=[];function Ui(t,e,i,n,r,s,o){let a=n%2?2:1;if(n%2==r%2)for(let l=e,h=0;l<i;){let e=!0,c=!1;if(h==s.length||l<s[h].from){let t=Gi[l];t!=a&&(e=!1,c=16==t)}let u=e||1!=a?null:[],d=e?n:n+1,f=l;t:for(;;)if(h<s.length&&f==s[h].from){if(c)break t;let p=s[h];if(!e)for(let t=p.to,e=h+1;;){if(t==i)break t;if(!(e<s.length&&s[e].from==t)){if(Gi[t]==a)break t;break}t=s[e++].to}h++,u?u.push(p):(p.from>l&&o.push(new Ki(l,p.from,d)),Yi(t,p.direction==Ii!=!(d%2)?n+1:n,r,p.inner,p.from,p.to,o),l=p.to),f=p.to}else{if(f==i||(e?Gi[f]!=a:Gi[f]==a))break;f++}u?Ui(t,l,f,n+1,r,u,o):l<f&&o.push(new Ki(l,f,d)),l=f}else for(let l=i,h=s.length;l>e;){let i=!0,c=!1;if(!h||l>s[h-1].to){let t=Gi[l-1];t!=a&&(i=!1,c=16==t)}let u=i||1!=a?null:[],d=i?n:n+1,f=l;t:for(;;)if(h&&f==s[h-1].to){if(c)break t;let p=s[--h];if(!i)for(let t=p.from,i=h;;){if(t==e)break t;if(!i||s[i-1].to!=t){if(Gi[t-1]==a)break t;break}t=s[--i].from}u?u.push(p):(p.to<l&&o.push(new Ki(p.to,l,d)),Yi(t,p.direction==Ii!=!(d%2)?n+1:n,r,p.inner,p.from,p.to,o),l=p.from),f=p.from}else{if(f==e||(i?Gi[f-1]!=a:Gi[f-1]==a))break;f--}u?Ui(t,f,l,n+1,r,u,o):f<l&&o.push(new Ki(f,l,d)),l=f}}function Yi(t,e,i,n,r,s,o){let a=e%2?2:1;!function(t,e,i,n,r){for(let o=0;o<=n.length;o++){let a=o?n[o-1].to:e,l=o<n.length?n[o].from:i,h=o?256:r;for(let e=a,i=h,n=h;e<l;e++){let r=(s=t.charCodeAt(e))<=247?Wi[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?Fi[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1;512==r?r=i:8==r&&4==n&&(r=16),Gi[e]=4==r?2:r,7&r&&(n=r),i=r}for(let t=a,e=h,n=h;t<l;t++){let r=Gi[t];if(128==r)t<l-1&&e==Gi[t+1]&&24&e?r=Gi[t]=e:Gi[t]=256;else if(64==r){let r=t+1;for(;r<l&&64==Gi[r];)r++;let s=t&&8==e||r<i&&8==Gi[r]?1==n?1:8:256;for(let e=t;e<r;e++)Gi[e]=s;t=r-1}else 8==r&&1==n&&(Gi[t]=1);e=r,7&r&&(n=r)}}var s}(t,r,s,n,a),function(t,e,i,n,r){let s=1==r?2:1;for(let o=0,a=0,l=0;o<=n.length;o++){let h=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=h;o<c;o++)if(i=qi[e=t.charCodeAt(o)])if(i<0){for(let t=a-3;t>=0;t-=3)if(_i[t+1]==-i){let e=_i[t+2],i=2&e?r:4&e?1&e?s:r:0;i&&(Gi[o]=Gi[_i[t]]=i),a=t;break}}else{if(189==_i.length)break;_i[a++]=o,_i[a++]=e,_i[a++]=l}else if(2==(n=Gi[o])||1==n){let t=n==r;l=t?0:1;for(let e=a-3;e>=0;e-=3){let i=_i[e+2];if(2&i)break;if(t)_i[e+2]|=2;else{if(4&i)break;_i[e+2]|=4}}}}}(t,r,s,n,a),function(t,e,i,n){for(let r=0,s=n;r<=i.length;r++){let o=r?i[r-1].to:t,a=r<i.length?i[r].from:e;for(let l=o;l<a;){let o=Gi[l];if(256==o){let o=l+1;for(;;)if(o==a){if(r==i.length)break;o=i[r++].to,a=r<i.length?i[r].from:e}else{if(256!=Gi[o])break;o++}let h=1==s,c=h==(1==(o<e?Gi[o]:n))?h?1:2:n;for(let e=o,n=r,s=n?i[n-1].to:t;e>l;)e==s&&(e=i[--n].from,s=n?i[n-1].to:t),Gi[--e]=c;l=o}else s=o,l++}}}(r,s,n,a),Ui(t,r,s,e,i,n,o)}function Ji(t){return[new Ki(0,t,0)]}let Xi="";function Zi(t,e,i,n,r){var s;let o=n.head-t.from,a=-1;if(0==o){if(!r||!t.length)return null;e[0].level!=i&&(o=e[0].side(!1,i),a=0)}else if(o==t.length){if(r)return null;let t=e[e.length-1];t.level!=i&&(o=t.side(!0,i),a=e.length-1)}a<0&&(a=Ki.find(e,o,null!==(s=n.bidiLevel)&&void 0!==s?s:-1,n.assoc));let l=e[a];o==l.side(r,i)&&(l=e[a+=r?1:-1],o=l.side(!r,i));let h=r==(l.dir==i),c=w(t.text,o,h);if(Xi=t.text.slice(Math.min(o,c),Math.max(o,c)),c>l.from&&c<l.to)return z.cursor(c+t.from,h?-1:1,l.level);let u=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return u||l.level==i?u&&u.level<l.level?z.cursor(u.side(!r,i)+t.from,r?1:-1,u.level):z.cursor(c+t.from,r?-1:1,l.level):z.cursor(r?t.to:t.from,r?-1:1,i)}class Qi extends ke{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Ye],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ni(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.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);let n=-1;this.view.inputState.composing>=0&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;return e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)})),i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let r=n>-1?function(t,e,i){let n=en(t,i);if(!n)return null;let{node:r,from:s,to:o}=n,a=r.nodeValue;if(/[\n\r]/.test(a))return null;if(t.state.doc.sliceString(n.from,n.to)!=a)return null;let l=e.invertedDesc,h=new Ni(l.mapPos(s),l.mapPos(o),s,o),c=[];for(let e=r.parentNode;;e=e.parentNode){let i=ke.get(e);if(i instanceof Ve)c.push({node:e,deco:i.mark});else{if(i instanceof Ye||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:h,text:r,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new ti({inclusive:!0,attributes:Ue(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Ni(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(ze.ie||ze.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let s=function(t,e,i){let n=new rn;return Dt.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=Ni.extendWithRanges(i,s),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,r),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=ze.chrome||ze.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof Je&&t.widget instanceof tn&&r.push(t.dom);n.updateGaps(r)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,r=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let s,o,a,l,{fromA:h,toA:c,fromB:u,toB:d}=e;if(i&&i.range.fromB<d&&i.range.toB>u){let t=si.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=si.build(this.view.state.doc,i.range.toB,d,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,a=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),s=t.content.concat(n).concat(e.content)}else({content:s,breakAtStart:o,openStart:a,openEnd:l}=si.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=r.findPos(c,1),{i:m,off:g}=r.findPos(h,-1);Se(this,m,g,f,p,s,o,a,l)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new Ie(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new Ve(i,[e],e.length);let i=new Ye;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=ke.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let r=t.marks.length-1;r>=-1;r--)i=n.childPos(i.off,1),n=n.children[i.i],e(r>=0?t.marks[r].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,r=!n&&ee(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||r))return;let s=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(o.anchor)),l=o.empty?a:this.moveToLine(this.domAtPos(o.head));if(ze.gecko&&o.empty&&!this.hasComposition&&1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable)){let t=document.createTextNode("");this.view.observer.ignore((()=>a.node.insertBefore(t,a.node.childNodes[a.offset]||null))),a=l=new ve(t,0),s=!0}var h;let c=this.view.observer.selectionRange;!s&&c.focusNode&&ne(a.node,a.offset,c.anchorNode,c.anchorOffset)&&ne(l.node,l.offset,c.focusNode,c.focusOffset)||(this.view.observer.ignore((()=>{ze.android&&ze.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=Qt(this.view.root);if(t)if(o.empty){if(ze.gecko){let t=(e=a.node,n=a.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=nn(a.node,a.offset,1==t?1:-1);e&&(a=new ve(e.node,e.offset))}}t.collapse(a.node,a.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(a.node,a.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([a,l]=[l,a]),e.setEnd(l.node,l.offset),e.setStart(a.node,a.offset),t.removeAllRanges(),t.addRange(e)}var e,n;r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new ve(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new ve(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Qt(t.root),{anchorNode:n,anchorOffset:r}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let s=Ye.find(this,e.head);if(!s)return;let o=s.posAtStart;if(e.head==o||e.head==o+s.length)return;let a=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!a||!l||a.bottom>l.top)return;let h=this.domAtPos(e.head+e.assoc);i.collapse(h.node,h.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(n,r)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=ke.get(i.childNodes[n]);t instanceof Ye&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=ke.get(i.childNodes[n]);t instanceof Ye&&(e=t.domAtPos(t.length))}return e?new ve(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=ke.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 new 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 Ye)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let r=this.length,s=this.children.length-1;s>=0;s--){let o=this.children[s],a=r-o.breakAfter,l=a-o.length;if(a<t)break;l<=t&&(l<t||o.covers(-1))&&(a>t||o.covers(1))&&(!i||o instanceof Ye&&!(i instanceof Ye&&e>=0))&&(i=o,n=l),r=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Ye))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof Ie))return null;let r=w(n.text,i);if(r==i)return null;let s=pe(n.dom,i,r).getClientRects();for(let t=0;t<s.length;t++){let e=s[t];if(t==s.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,a=this.view.textDirection==zi.LTR;for(let t=0,l=0;l<this.children.length;l++){let h=this.children[l],c=t+h.length;if(c>n)break;if(t>=i){let i=h.dom.getBoundingClientRect();if(e.push(i.height),s){let e=h.dom.lastChild,n=e?ie(e):[];if(n.length){let e=n[n.length-1],s=a?e.right-i.left:i.right-e.left;s>o&&(o=s,this.minWidth=r,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?zi.RTL:zi.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Ye){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let r=ie(n.firstChild)[0];t=n.getBoundingClientRect().height,e=r?r.width/27:7,i=r?r.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new xe(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let r=n==e.viewports.length?null:e.viewports[n],s=r?r.from-1:this.length;if(s>i){let n=(e.lineBlockAt(s).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Qe.replace({widget:new tn(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!r)break;i=r.to+1}return Qe.set(t)}updateDeco(){let t=this.view.state.facet(Ti).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let r=Bi(this.view),s={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:o,offsetHeight:a}=this.view.scrollDOM;!function(t,e,i,n,r,s,o,a){let l=t.ownerDocument,h=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,d=c==l.body,f=1,p=1;if(d)t=le(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:f,scaleY:p}=he(c,e)),t={left:e.left,right:e.left+c.clientWidth*f,top:e.top,bottom:e.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==r)e.top<t.top?(g=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+g&&(g=e.bottom-t.bottom+g+o)):e.bottom>t.bottom&&(g=e.bottom-t.bottom+o,i<0&&e.top-g<t.top&&(g=-(t.top+g-e.top+o)));else{let n=e.bottom-e.top,s=t.bottom-t.top;g=("center"==r&&n<=s?e.top+n/2-s/2:"start"==r||"center"==r&&i<0?e.top-o:e.bottom-s+o)-t.top}if("nearest"==n?e.left<t.left?(m=-(t.left-e.left+s),i>0&&e.right>t.right+m&&(m=e.right-t.right+m+s)):e.right>t.right&&(m=e.right-t.right+s,i<0&&e.left<t.left+m&&(m=-(t.left+m-e.left+s))):m=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==a?e.left-s:e.right-(t.right-t.left)+s)-t.left,m||g)if(d)h.scrollBy(m,g);else{let t=0,i=0;if(g){let t=c.scrollTop;c.scrollTop+=g/p,i=(c.scrollTop-t)*p}if(m){let e=c.scrollLeft;c.scrollLeft+=m/f,t=(c.scrollLeft-e)*f}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-m)<1&&(n="nearest"),i&&Math.abs(i-g)<1&&(r="nearest")}if(d)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,s,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,a),-a),this.view.textDirection==zi.LTR)}}class tn extends Xe{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function en(t,e){let i=t.observer.selectionRange,n=i.focusNode&&nn(i.focusNode,i.focusOffset,0);if(!n)return null;let r=e-n.offset;return{from:r,to:r+n.node.nodeValue.length,node:n.node}}function nn(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return{node:i,offset:n};if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=oe(i)}if(i>=0)for(let n=t,r=e;;){if(3==n.nodeType)return{node:n,offset:r};if(!(1==n.nodeType&&r<n.childNodes.length&&i>=0))break;n=n.childNodes[r],r=0}return null}let rn=class{constructor(){this.changes=[]}compareRange(t,e){ri(t,e,this.changes)}comparePoint(t,e){ri(t,e,this.changes)}};function sn(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function on(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function an(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function ln(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function hn(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function cn(t,e,i){let n,r,s,o,a,l,h,c,u=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=ie(d);for(let f=0;f<t.length;f++){let p=t[f];r&&an(r,p)&&(p=ln(hn(p,r.bottom),r.top));let m=sn(e,p),g=on(i,p);if(0==m&&0==g)return 3==d.nodeType?un(d,e,i):cn(d,e,i);if(!n||o>g||o==g&&s>m){n=d,r=p,s=m,o=g;let a=g?i<p.top?-1:1:m?e<p.left?-1:1:0;u=!a||(a>0?f<t.length-1:f>0)}0==m?i>p.bottom&&(!h||h.bottom<p.bottom)?(a=d,h=p):i<p.top&&(!c||c.top>p.top)&&(l=d,c=p):h&&an(h,p)?h=hn(h,p.bottom):c&&an(c,p)&&(c=ln(c,p.top))}}if(h&&h.bottom>=i?(n=a,r=h):c&&c.top<=i&&(n=l,r=c),!n)return{node:t,offset:0};let d=Math.max(r.left,Math.min(r.right,e));return 3==n.nodeType?un(n,d,i):u&&"false"!=n.contentEditable?cn(n,d,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(r.left+r.right)/2?1:0)}}function un(t,e,i){let n=t.nodeValue.length,r=-1,s=1e9,o=0;for(let a=0;a<n;a++){let n=pe(t,a,a+1).getClientRects();for(let l=0;l<n.length;l++){let h=n[l];if(h.top==h.bottom)continue;o||(o=e-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<s){let i=e>=(h.left+h.right)/2,n=i;if((ze.chrome||ze.gecko)&&pe(t,a).getBoundingClientRect().left==h.right&&(n=!i),c<=0)return{node:t,offset:a+(n?1:0)};r=a+(n?1:0),s=c}}}return{node:t,offset:r>-1?r:o>0?t.nodeValue.length:0}}function dn(t,e,i,n=-1){var r,s;let o,a=t.contentDOM.getBoundingClientRect(),l=a.top+t.viewState.paddingTop,{docHeight:h}=t.viewState,{x:c,y:u}=e,d=u-l;if(d<0)return 0;if(d>h)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,r=!1;o=t.elementAtHeight(d),o.type!=Ze.Text;)for(;d=n>0?o.bottom+e:o.top-e,!(d>=0&&d<=h);){if(r)return i?null:0;r=!0,n=-n}u=l+d;let f=o.from;if(f<t.viewport.from)return 0==t.viewport.from?0:i?null:fn(t,a,o,c,u);if(f>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:fn(t,a,o,c,u);let p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(c,u);g&&!t.contentDOM.contains(g)&&(g=null),g||(c=Math.max(a.left+1,Math.min(a.right-1,c)),g=m.elementFromPoint(c,u),g&&!t.contentDOM.contains(g)&&(g=null));let w,v=-1;if(g&&0!=(null===(r=t.docView.nearest(g))||void 0===r?void 0:r.isEditable))if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||ze.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return pe(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||ze.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():pe(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect()).left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=Ye.find(t.docView,f);if(!e)return d>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=cn(e.dom,c,u))}let b=t.docView.nearest(w);if(!b)return null;if(b.isWidget&&1==(null===(s=b.dom)||void 0===s?void 0:s.nodeType)){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}return b.localPosFromDOM(w,v)+b.posAtStart}function fn(t,e,i,n,r){let s=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;s+=Math.floor((r-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,r=0;;){if(r>=e)return n;if(n==t.length)break;r+=9==t.charCodeAt(n)?i-r%i:1,n=w(t,n)}return t.length}(o,s,t.state.tabSize)}function pn(t,e,i,n){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let a=e,l=null;;){let e=Zi(r,s,o,a,i),h=Xi;if(!e){if(r.number==(i?t.state.doc.lines:1))return a;h="\n",r=t.state.doc.line(r.number+(i?1:-1)),s=t.bidiSpans(r),e=z.cursor(i?r.from:r.to)}if(l){if(!l(h))return a}else{if(!n)return e;l=n(h)}a=e}}function mn(t,e,i){for(;;){let n=0;for(let r of t)r.between(e-1,e+1,((t,r,s)=>{if(e>t&&e<r){let s=n||i||(e-t<r-e?-1:1);e=s<0?t:r,n=s}}));if(!n)return e}}function gn(t,e,i){let n=mn(t.state.facet(Di).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:z.cursor(n,n<i.from?1:-1)}class wn{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.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,ze.safari&&t.contentDOM.addEventListener("input",(()=>null)),ze.gecko&&function(t){jn.has(t)||(jn.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,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=ke.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(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=bn(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let r=!e[t].handlers.length,s=i[t];s&&r!=!s.handlers.length&&(n.removeEventListener(t,this.handleEvent),s=null),s||n.addEventListener(t,this.handleEvent,{passive:r})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=t.keyCode&&xn.indexOf(t.keyCode)<0&&(this.view.inputState.lastEscPress=0),ze.android&&ze.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!ze.ios||t.synthetic||t.altKey||t.metaKey||!((e=kn.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||yn.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(){let t=this.pendingIOSKey;return!!t&&(this.pendingIOSKey=void 0,me(this.view.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(ze.safari&&!ze.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.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 vn(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){bi(i.state,t)}}}function bn(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;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let r=t.domEventHandlers[n];r&&i(n).handlers.push(vn(e.value,r))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let r=t.domEventObservers[n];r&&i(n).observers.push(vn(e.value,r))}}for(let t in Mn)i(t).handlers.push(Mn[t]);for(let t in Cn)i(t).observers.push(Cn[t]);return e}const kn=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],yn="dthko",xn=[16,17,18,20,91,92,224,225];function Sn(t){return.7*Math.max(0,t)+8}class An{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(Di).map((e=>e(t)));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(xt.allowMultipleSelections)&&function(t,e){let i=t.state.facet(li);return i.length?i[0](e):ze.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Qt(t.root);if(!n||0==n.rangeCount)return!0;let r=n.getRangeAt(0).getClientRects();for(let t=0;t<r.length;t++){let i=r[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!=Vn(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let r=0,s=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},a=Bi(this.view);t.clientX-a.left<=o.left+6?r=-Sn(o.left-t.clientX):t.clientX+a.right>=o.right-6&&(r=Sn(t.clientX-o.right)),t.clientY-a.top<=o.top+6?s=-Sn(o.top-t.clientY):t.clientY+a.bottom>=o.bottom-6&&(s=Sn(t.clientY-o.bottom)),this.setScrollSpeed(r,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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],r=null;if(n.empty){let t=mn(this.atoms,n.from,0);t!=n.from&&(r=z.cursor(t,-1))}else{let t=mn(this.atoms,n.from,-1),e=mn(this.atoms,n.to,1);t==n.from&&e==n.to||(r=z.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}r&&(e||(e=t.ranges.slice()),e[i]=r)}return e?z.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)||i.main.assoc!=e.state.selection.main.assoc&&!1===this.dragging)&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const Mn=Object.create(null),Cn=Object.create(null),Tn=ze.ie&&ze.ie_version<15||ze.ios&&ze.webkit_version<604;function Dn(t,e){let i,{state:n}=t,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(null!=Wn&&n.selection.ranges.every((t=>t.empty))&&Wn==s.toString()){let t=-1;i=n.changeByRange((i=>{let a=n.doc.lineAt(i.from);if(a.from==t)return{range:i};t=a.from;let l=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:a.from,insert:l},range:z.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=s.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:z.cursor(t.from+e.length)}})):n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function On(t,e,i,n){if(1==n)return z.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return z.cursor(e);0==s?i=1:s==r.length&&(i=-1);let o=s,a=s;i<0?o=w(r.text,s,!1):a=w(r.text,s);let l=n(r.text.slice(o,a));for(;o>0;){let t=w(r.text,o,!1);if(n(r.text.slice(t,o))!=l)break;o=t}for(;a<r.length;){let t=w(r.text,a);if(n(r.text.slice(a,t))!=l)break;a=t}return z.range(o+r.from,a+r.from)}(t.state,e,i);{let i=Ye.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),r=i?i.posAtStart:n.from,s=i?i.posAtEnd:n.to;return s<t.state.doc.length&&s==n.to&&s++,z.range(r,s)}}Cn.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Mn.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),Cn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Cn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Mn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(ci))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Pn(t,e),n=Vn(e),r=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),r=r.map(t.changes))},get(e,s,o){let a,l=Pn(t,e),h=On(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!s){let e=On(t,i.pos,i.bias,n),r=Math.min(e.from,h.from),s=Math.max(e.to,h.to);h=r<h.from?z.range(r,s):z.range(s,r)}return s?r.replaceRange(r.main.extend(h.from,h.to)):o&&1==n&&r.ranges.length>1&&(a=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:r}=t.ranges[i];if(n<=e&&r>=e)return z.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(r,l.pos))?a:o?r.addRange(h):z.create([h])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new An(t,e,i,n)),n&&t.observer.ignore((()=>fe(t.contentDOM)));let r=t.inputState.mouseSelection;if(r)return r.start(e),!1===r.dragging}return!1};let Ln=(t,e)=>t>=e.top&&t<=e.bottom,En=(t,e,i)=>Ln(e,i)&&t>=i.left&&t<=i.right;function Bn(t,e,i,n){let r=Ye.find(t.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(0==s)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&En(i,n,o))return-1;let a=r.coordsAt(s,1);return a&&En(i,n,a)?1:o&&Ln(n,o)?-1:1}function Pn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Bn(t,i,e.clientX,e.clientY)}}const Nn=ze.ie&&ze.ie_version<=11;let Rn=null,zn=0,In=0;function Vn(t){if(!Nn)return t.detail;let e=Rn,i=In;return Rn=t,In=Date.now(),zn=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(zn+1)%3:1}function Hn(t,e,i,n){if(!i)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=n&&s&&function(t,e){let i=t.state.facet(hi);return i.length?i[0](e):ze.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:s.from,to:s.to}:null,a={from:r,insert:i},l=t.state.changes(o?[o,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mn.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=z.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},Mn.dragend=t=>(t.inputState.draggedContent=null,!1),Mn.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),r=0,s=()=>{++r==i.length&&Hn(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=s,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),s()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Hn(t,e,i,!0),!0}return!1},Mn.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Tn?null:e.clipboardData;return i?(Dn(t,i.getData("text/plain")||i.getData("text/uri-text")),!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(),Dn(t,i.value)}),50)}(t),!1)};let Wn=null;Mn.copy=Mn.cut=(t,e)=>{let{text:i,ranges:n,linewise:r}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let r=-1;for(let{from:n}of t.selection.ranges){let s=t.doc.lineAt(n);s.number>r&&(e.push(s.text),i.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),r=s.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!r)return!1;Wn=r?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=Tn?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),!1)};const Fn=lt.define();function qn(t,e){let i=[];for(let n of t.facet(pi)){let r=n(t,e);r&&i.push(r)}return i?t.update({effects:i,annotations:Fn.of(!0)}):null}function _n(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=qn(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Cn.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),_n(t)},Cn.blur=t=>{t.observer.clearSelectionRange(),_n(t)},Cn.compositionstart=Cn.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},Cn.compositionend=t=>{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,ze.chrome&&ze.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},Cn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mn.beforeinput=(t,e)=>{var i;let n;if(ze.chrome&&ze.android&&(n=kn.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return!1};const jn=new Set,Kn=["pre-wrap","normal","pre-line","break-spaces"];class $n{constructor(t){this.lineWrapping=t,this.doc=n.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}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 Kn.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,r,s){let o=Kn.indexOf(t)>-1,a=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=r,a){this.heightSamples={};for(let t=0;t<s.length;t++){let e=s[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return a}}class Gn{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Un{constructor(t,e,i,n,r){this.from=t,this.length=e,this.top=i,this.height=n,this._content=r}get type(){return"number"==typeof this._content?Ze.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 ii?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 Un(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Yn=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Yn||(Yn={}));const Jn=.001;class Xn{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=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>Jn&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Xn.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let r=this,s=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:a,toA:l,fromB:h,toB:c}=n[o],u=r.lineAt(a,Yn.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=l?u:r.lineAt(l,Yn.ByPosNoHeight,i,0,0);for(c+=d.to-l,l=d.to;o>0&&u.from<=n[o-1].toA;)a=n[o-1].fromA,h=n[o-1].fromB,o--,a<u.from&&(u=r.lineAt(a,Yn.ByPosNoHeight,i,0,0));h+=u.from-a,a=u.from;let f=nr.build(i.setDoc(s),t,h,c);r=r.replace(a,l,f)}return r.updateHeight(i,0)}static empty(){return new Qn(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,r=0;for(;;)if(e==i)if(n>2*r){let r=t[e-1];r.break?t.splice(--e,1,r.left,null,r.right):t.splice(--e,1,r.left,r.right),i+=1+r.break,n-=r.size}else{if(!(r>2*n))break;{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,r-=e.size}}else if(n<r){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(r+=e.size)}let s=0;return null==t[e-1]?(s=1,e--):null==t[e]&&(s=1,i++),new er(Xn.of(t.slice(0,e)),s,Xn.of(t.slice(i)))}}Xn.prototype.size=1;class Zn extends Xn{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Un(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,r){return this.blockAt(0,i,n,r)}forEachLine(t,e,i,n,r,s){t<=r+this.length&&e>=r&&s(this.blockAt(0,i,n,r))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Qn extends Zn{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Un(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Qn||n instanceof tr&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof tr?n=new Qn(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Xn.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,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 tr extends Xn{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,r=t.doc.lineAt(e+this.length).number,s=r-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*s);i=e/s,this.length>s+1&&(o=(this.height-e)/(this.length-s-1))}else i=this.height/s;return{firstLine:n,lastLine:r,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:r,lastLine:s,perLine:o,perChar:a}=this.heightMetrics(e,n);if(e.lineWrapping){let r=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),s=e.doc.lineAt(r),l=o+s.length*a,h=Math.max(i,t-l/2);return new Un(s.from,s.length,h,l,0)}{let n=Math.max(0,Math.min(s-r,Math.floor((t-i)/o))),{from:a,length:l}=e.doc.line(r+n);return new Un(a,l,i+o*n,o,0)}}lineAt(t,e,i,n,r){if(e==Yn.ByHeight)return this.blockAt(t,i,n,r);if(e==Yn.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Un(e,n-e,0,0,0)}let{firstLine:s,perLine:o,perChar:a}=this.heightMetrics(i,r),l=i.doc.lineAt(t),h=o+l.length*a,c=l.number-s,u=n+o*c+a*(l.from-r-c);return new Un(l.from,l.length,Math.max(n,Math.min(u,n+this.height-h)),h,0)}forEachLine(t,e,i,n,r,s){t=Math.max(t,r),e=Math.min(e,r+this.length);let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(i,r);for(let h=t,c=n;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-o;c+=a*i+l*(t-r-i)}let n=a+l*e.length;s(new Un(e.from,e.length,c,n,0)),c+=n,h=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof tr?i[i.length-1]=new tr(t.length+n):i.push(null,new tr(n-1))}if(t>0){let e=i[0];e instanceof tr?i[0]=new tr(t+e.length):i.unshift(new tr(t-1),null)}return Xn.of(i)}decomposeLeft(t,e){e.push(new tr(t-1),null)}decomposeRight(t,e){e.push(null,new tr(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let r=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],s=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new tr(n.from-e-1).updateHeight(t,e));s<=r&&n.more;){let e=t.doc.lineAt(s).length;i.length&&i.push(null);let r=n.heights[n.index++];-1==o?o=r:Math.abs(r-o)>=Jn&&(o=-2);let a=new Qn(e,r);a.outdated=!1,i.push(a),s+=e+1}s<=r&&i.push(null,new tr(r-s).updateHeight(t,s));let a=Xn.of(i);return(o<0||Math.abs(a.height-this.height)>=Jn||Math.abs(o-this.heightMetrics(t,e).perLine)>=Jn)&&(t.heightChanged=!0),a}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class er extends Xn{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,n){let r=i+this.left.height;return t<r?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,r,n+this.left.length+this.break)}lineAt(t,e,i,n,r){let s=n+this.left.height,o=r+this.left.length+this.break,a=e==Yn.ByHeight?t<s:t<o,l=a?this.left.lineAt(t,e,i,n,r):this.right.lineAt(t,e,i,s,o);if(this.break||(a?l.to<o:l.from>o))return l;let h=e==Yn.ByPosNoHeight?Yn.ByPosNoHeight:Yn.ByPos;return a?l.join(this.right.lineAt(o,h,i,s,o)):this.left.lineAt(o,h,i,n,r).join(l)}forEachLine(t,e,i,n,r,s){let o=n+this.left.height,a=r+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,i,n,r,s),e>=a&&this.right.forEachLine(t,e,i,o,a,s);else{let l=this.lineAt(a,Yn.ByPos,i,n,r);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,r,s),l.to>=t&&l.from<=e&&s(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,a,s)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];t>0&&this.decomposeLeft(t,r);let s=r.length;for(let t of i)r.push(t);if(t>0&&ir(r,s-1),e<this.length){let t=r.length;this.decomposeRight(e,r),ir(r,t)}return Xn.of(r)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?Xn.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:r,right:s}=this,o=e+r.length+this.break,a=null;return n&&n.from<=e+r.length&&n.more?a=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?a=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),a?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function ir(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof tr&&(n=t[e+1])instanceof tr&&t.splice(e-1,3,new tr(i.length+1+n.length))}class nr{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 Qn?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Qn(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 n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let s=e-t;i.block?this.addBlock(new Zn(s,n,i)):(s||r||n>=5)&&this.addLineDeco(n,r,s)}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 Qn(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new tr(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 Qn)return t;let e=new Qn(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 n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Qn||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Qn(0,-1));let i=t;for(let t of this.nodes)t instanceof Qn&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let r=new nr(i,t);return Dt.spans(e,i,n,r,0),r.finish(i)}}class rr{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&ri(t,e,this.changes,5)}}function sr(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,r=n.defaultView||window,s=Math.max(0,i.left),o=Math.min(r.innerWidth,i.right),a=Math.max(0,i.top),l=Math.min(r.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();s=Math.max(s,n.left),o=Math.min(o,n.right),a=Math.max(a,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:s-i.left,right:Math.max(s,o)-i.left,top:a-(i.top+e),bottom:Math.max(a,l)-(i.top+e)}}function or(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ar{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],r=e[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(t,e){return Qe.replace({widget:new lr(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class lr extends Xe{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 hr{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=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=pr,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=zi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Ci).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new $n(e),this.stateDeco=t.facet(Ti).filter((t=>"function"!=typeof t)),this.heightMap=Xn.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle.setDoc(t.doc),[new Ni(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Qe.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 n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new cr(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?pr:new mr(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:gr(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Ti).filter((t=>"function"!=typeof t));let n=t.changedRanges,r=Ni.extendWithRanges(n,function(t,e,i){let n=new rr;return Dt.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:D.empty(this.state.doc.length))),s=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=s&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),l&&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(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(gi)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?zi.RTL:zi.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let h=0,c=0;if(a.width&&a.height){let{scaleX:t,scaleY:i}=he(e,a);this.scaleX==t&&this.scaleY==i||(this.scaleX=t,this.scaleY=i,h|=8,o=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,d=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==d||(this.paddingTop=u,this.paddingBottom=d,h|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=8);let f=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=we(t.scrollDOM);let p=(this.printing?or:sr)(e,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let v=a.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=a.width,this.editorHeight=t.scrollDOM.clientHeight,h|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(e)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:i,charWidth:n,textHeight:a}=t.docView.measureTextSize();o=i>0&&r.refresh(s,i,n,a,v/n,e),o&&(t.docView.minWidth=0,h|=8)}m>0&&g>0?c=Math.max(m,g):m<0&&g<0&&(c=Math.min(m,g)),r.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Xn.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle,[new Ni(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Gn(i.from,s))}r.heightChanged&&(h|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&h||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,a=new cr(n.lineAt(s-1e3*i,Yn.ByHeight,r,0,0).from,n.lineAt(o+1e3*(1-i),Yn.ByHeight,r,0,0).to);if(e){let{head:t}=e.range;if(t<a.from||t>a.to){let i,s=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,Yn.ByPos,r,0,0);i="center"==e.y?(o.top+o.bottom)/2-s/2:"start"==e.y||"nearest"==e.y&&t<a.from?o.top:o.bottom-s,a=new cr(n.lineAt(i-500,Yn.ByHeight,r,0,0).from,n.lineAt(i+s+500,Yn.ByHeight,r,0,0).to)}}return a}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new cr(this.heightMap.lineAt(i,Yn.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Yn.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Yn.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,Yn.ByPos,this.heightOracle,0,0),{visibleTop:s,visibleBottom:o}=this;return(0==t||n<=s-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=o+Math.max(10,Math.min(i,250)))&&n>s-2e3&&r<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new ar(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,s=n<<1;if(this.defaultTextDirection!=zi.LTR&&!i)return[];let o=[],a=(n,s,l,h)=>{if(s-n<r)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<s)return a(n,t-10,l,h),void a(t+10,s,l,h);let d=function(t,e){for(let i of t)if(e(i))return i}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<r&&Math.abs(t.to-s)<r&&!u.some((e=>t.from<e&&t.to>e))));if(!d){if(s<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=s&&t.to>=s))){let t=e.moveToLineBoundary(z.cursor(s),!1,!0).head;t>n&&(s=t)}d=new ar(n,s,this.gapSize(l,n,s,h))}o.push(d)};for(let t of this.viewportLines){if(t.length<s)continue;let e=ur(t.from,t.to,this.stateDeco);if(e.total<s)continue;let r,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,s,a=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=fr(e,l),r=((this.visibleBottom-this.visibleTop)/2+a)/t.height;i=n-r,s=n+r}else i=(this.visibleTop-t.top-a)/t.height,s=(this.visibleBottom-t.top+a)/t.height;r=dr(e,i),o=dr(e,s)}else{let t,i,s=e.total*this.heightOracle.charWidth,a=n*this.heightOracle.charWidth;if(null!=l){let n=fr(e,l),r=((this.pixelViewport.right-this.pixelViewport.left)/2+a)/s;t=n-r,i=n+r}else t=(this.pixelViewport.left-a)/s,i=(this.pixelViewport.right+a)/s;r=dr(e,t),o=dr(e,i)}r>t.from&&a(t.from,r,t,e),o<t.to&&a(o,t.to,t,e)}return o}gapSize(t,e,i,n){let r=fr(n,i)-fr(n,e);return this.heightOracle.lineWrapping?t.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(t){ar.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Qe.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Dt.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||gr(this.heightMap.lineAt(t,Yn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return gr(this.heightMap.lineAt(this.scaler.fromDOM(t),Yn.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 gr(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 cr{constructor(t,e){this.from=t,this.to=e}}function ur(t,e,i){let n=[],r=t,s=0;return Dt.spans(i,t,e,{span(){},point(t,e){t>r&&(n.push({from:r,to:t}),s+=t-r),r=e}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function dr({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:r}=e[t],s=r-i;if(n<=s)return i+n;n-=s}}function fr(t,e){let i=0;for(let{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}const pr={toDOM:t=>t,fromDOM:t=>t,scale:1};class mr{constructor(t,e,i){let n=0,r=0,s=0;this.viewports=i.map((({from:i,to:r})=>{let s=e.lineAt(i,Yn.ByPos,t,0,0).top,o=e.lineAt(r,Yn.ByPos,t,0,0).bottom;return n+=o-s,{from:i,to:r,top:s,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=s+(t.top-r)*this.scale,s=t.domBottom=t.domTop+(t.bottom-t.top),r=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.top)return n+(t-i)*this.scale;if(t<=r.bottom)return r.domTop+(t-r.top);i=r.bottom,n=r.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.domTop)return i+(t-n)/this.scale;if(t<=r.domBottom)return r.top+(t-r.domTop);i=r.bottom,n=r.domBottom}}}function gr(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Un(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>gr(t,e))):t._content)}const wr=H.define({combine:t=>t.join(" ")}),vr=H.define({combine:t=>t.indexOf(!0)>-1}),br=jt.newName(),kr=jt.newName(),yr=jt.newName(),xr={"&light":"."+kr,"&dark":"."+yr};function Sr(t,e,i){return new jt(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const Ar=Sr("."+br,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},xr),Mr="￿";class Cr{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(xt.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Mr}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let r=n.nextSibling;if(r==e)break;let s=ke.get(n),o=ke.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:Dr(n))||Dr(r)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=r}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r,s=-1,o=1;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(r=n.exec(e))&&(s=r.index,o=r[0].length),this.append(e.slice(i,s<0?e.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=s+o}}readNode(t){if(t.cmIgnore)return;let e=ke.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+(Tr(t,i.node,i.offset)?e:0))}}function Tr(t,e,i){for(;;){if(!e||i<oe(e))return!1;if(e==t)return!0;i=re(e)+1,e=e.parentNode}}function Dr(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Or{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Lr{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:r,impreciseAnchor:s}=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=r||s?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}=t.observer.selectionRange;return i&&(e.push(new Or(i,n)),r==i&&s==n||e.push(new Or(r,s))),e}(t),i=new Cr(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,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?z.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=r&&r.node==e.focusNode&&r.offset==e.focusOffset||!te(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!te(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=z.single(n,i)}}}function Er(t,e){let i,{newSel:r}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:r,to:a}=e.bounds,l=s.from,h=null;(8===o||ze.android&&e.text.length<a-r)&&(l=s.to,h="end");let c=function(t,e,i,n){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,a=e.length;for(;o>0&&a>0&&t.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;return"end"==n&&(i-=o+Math.max(0,s-Math.min(o,a))-s),o<s&&t.length<e.length?(s-=i<=s&&i>=o?s-i:0,a=s+(a-o),o=s):a<s&&(s-=i<=s&&i>=a?s-i:0,o=s+(o-a),a=s),{from:s,toA:o,toB:a}}(t.state.doc.sliceString(r,a,Mr),e.text,l-r,h);c&&(ze.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==Mr+Mr&&c.toB--,i={from:r+c.from,to:r+c.toA,insert:n.of(e.text.slice(c.from,c.toB).split(Mr))})}else r&&(!t.hasFocus&&t.state.facet(ki)||r.main.eq(s))&&(r=null);if(!i&&!r)return!1;if(!i&&e.typeOver&&!s.empty&&r&&r.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(ze.mac||ze.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(r&&2==i.insert.length&&(r=z.single(r.main.anchor-1,r.main.head-1)),i={from:s.from,to:s.to,insert:n.of([" "])}):ze.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(r&&(r=z.single(r.main.anchor-1,r.main.head-1)),i={from:s.from,to:s.to,insert:n.of([" "])}),i){if(ze.ios&&t.inputState.flushIOSKey())return!0;if(ze.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&me(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from&&i.to>s.head)&&me(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&me(t.contentDOM,"Delete",46)))return!0;let e,n=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a=()=>e||(e=function(t,e,i){let n,r=t.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=s.from<e.from?r.sliceDoc(s.from,e.from):"",o=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=r.changes(e),a=i&&i.main.to<=o.newLength?i.main:void 0;if(r.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let l,h=t.state.sliceDoc(e.from,e.to),c=i&&en(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);l={from:c.from,to:c.to-t}}else l=t.state.doc.lineAt(s.head);let u=s.to-e.to,d=s.to-s.from;n=r.changeByRange((i=>{if(i.from==s.from&&i.to==s.to)return{changes:o,range:a||i.map(o)};let n=i.to-u,c=n-h.length;if(i.to-i.from!=d||t.state.sliceDoc(c,n)!=h||i.to>=l.from&&i.from<=l.to)return{range:i};let f=r.changes({from:c,to:n,insert:e.insert}),p=i.to-s.to;return{changes:f,range:a?z.range(Math.max(0,a.anchor+p),Math.max(0,a.head+p)):i.map(f)}}))}else n={changes:o,selection:a&&r.selection.replaceRange(a)}}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)),r.update(n,{userEvent:o,scrollIntoView:!0})}(t,i,r));return t.state.facet(fi).some((e=>e(t,i.from,i.to,n,a)))||t.dispatch(a()),!0}if(r&&!r.main.eq(s)){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:r,scrollIntoView:e,userEvent:i}),!0}return!1}const Br={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Pr=ze.ie&&ze.ie_version<=11;class Nr{constructor(t){this.view=t,this.active=!1,this.selectionRange=new ce,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(ze.ie&&ze.ie_version<=11||ze.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()})),Pr&&(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),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?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.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(ki)?i.root.activeElement!=this.dom:!ee(i.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);r&&r.ignoreEvent(t)?e||(this.selectionChanged=!1):(ze.ie&&ze.ie_version<=11||ze.android&&ze.chrome)&&!i.state.selection.main.empty&&n.focusNode&&ne(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=ze.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,a=t.docView.domAtPos(t.state.selection.main.anchor);return ne(a.node,a.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}(this.view)||Qt(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=ee(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,oe(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=oe(i))}else{if(i==t)return!0;n=re(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(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)break;i=i.host}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,Br),Pr&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Pr&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;t&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&me(this.dom,t.key,t.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let r of t){let t=this.readMutation(r);t&&(t.typeOver&&(n=!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:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&ee(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Lr(this.view,t,e,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Er(this.view,e);return this.view.state==i&&this.view.update([]),n}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=Rr(e,t.previousSibling||t.target.previousSibling,-1),n=Rr(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):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),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),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Rr(t,e,i){for(;e;){let n=ke.get(e);if(n&&n.parent==t)return n;let r=e.parentNode;e=r!=t.dom?r:i>0?e.nextSibling:e.previousSibling}return null}class zr{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(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 hr(t.state||xt.create(t)),t.scrollTo&&t.scrollTo.is(vi)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(xi).map((t=>new Ai(t)));for(let t of this.plugins)t.update(this);this.observer=new Nr(this),this.inputState=new wn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Qi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}dispatch(...t){let e=1==t.length&&t[0]instanceof dt?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 new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,r=this.state;for(let e of t){if(e.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=e.state}if(this.destroyed)return void(this.viewState.state=r);let s=this.hasFocus,o=0,a=null;t.some((t=>t.annotation(Fn)))?(this.inputState.notifiedFocused=s,o=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,a=qn(r,s),a||(o=1));let l=this.observer.delayedAndroidKey,h=null;if(l?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(xt.phrases)!=this.state.facet(xt.phrases))return this.setState(r);e=Ri.create(this,r,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new wi(t.empty?t:z.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(vi)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=Hr.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Pi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(wr)!=e.state.facet(wr)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(di))try{t(e)}catch(t){bi(this.state,t,"update listener")}(a||h)&&Promise.resolve().then((()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!Er(this,h)&&l.force&&me(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new hr(t),this.plugins=t.facet(xi).map((t=>new Ai(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Qi(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(xi),i=t.state.facet(xi);if(e!=i){let n=[];for(let r of i){let i=e.indexOf(r);if(i<0)n.push(new Ai(r));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,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)}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(s<0)if(we(i))r=-1,s=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);r=t.from,s=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 a=[];4&o||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map((t=>{try{return t.read(this)}catch(t){return bi(this.state,t),Vr}})),h=Ri.create(this,this.state,[]),c=!1;h.flags|=o,e?e.flags|=o:e=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),c=this.docView.update(h));for(let t=0;t<a.length;t++)if(l[t]!=Vr)try{let e=a[t];e.write&&e.write(l[t],this)}catch(t){bi(this.state,t)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}{let t=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-s;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(di))t(e)}get themeClasses(){return br+" "+(this.state.facet(vr)?yr:kr)+" "+this.state.facet(wr)}updateAttrs(){let t=Wr(this,Mi,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ki)?"true":"false",class:"cm-content",style:`${ze.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Wr(this,Ci,e);let i=this.observer.ignore((()=>{let i=Ge(this.contentDOM,this.contentAttrs,e),n=Ge(this.dom,this.editorAttrs,t);return i||n}));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(zr.announce)&&(e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value)}mountStyles(){this.styleModules=this.state.facet(Pi);let t=this.state.facet(zr.cspNonce);jt.mount(this.root,this.styleModules.concat(Ar).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(2==this.updateState)throw new 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){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==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 gn(this,t,pn(this,t,e,i))}moveByGroup(t,e){return gn(this,t,pn(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return t=>{let e=n(t);return r==bt.Space&&(r=e),r==e}}(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let r=function(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==Ze.Text))return t;return i}(t,e.head),s=n&&r.type==Ze.Text&&(t.lineWrapping||r.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(r.from),o=t.posAtCoords({x:i==(n==zi.LTR)?e.right-1:e.left+1,y:(s.top+s.bottom)/2});if(null!=o)return z.cursor(o,i?-1:1)}return z.cursor(i?r.to:r.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return gn(this,t,function(t,e,i,n){let r=e.head,s=i?1:-1;if(r==(i?t.state.doc.length:0))return z.cursor(r,e.assoc);let o,a=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(r,e.assoc||-1),c=t.documentTop;if(h)null==a&&(a=h.left-l.left),o=s<0?h.top:h.bottom;else{let e=t.viewState.lineBlockAt(r);null==a&&(a=Math.min(l.right-l.left,t.defaultCharacterWidth*(r-e.from))),o=(s<0?e.top:e.bottom)+c}let u=l.left+a,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=o+(d+e)*s,n=dn(t,{x:u,y:i},!1,s);if(i<l.top||i>l.bottom||(s<0?n<r:n>r)){let e=t.docView.coordsForChar(n),r=!e||i<e.top?-1:1;return z.cursor(n,r,void 0,a)}}}(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(),dn(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 n=this.state.doc.lineAt(t),r=this.bidiSpans(n);return ae(i,r[Ki.find(r,t-n.from,-1,e)].dir==zi.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(mi)||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>Ir)return Ji(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||$i(n.isolates,e=Li(this,t.from,t.to))))return n.order;e||(e=Li(this,t.from,t.to));let n=function(t,e,i){if(!t)return[new Ki(0,0,e==Vi?1:0)];if(e==Ii&&!i.length&&!ji.test(t))return Ji(t.length);if(i.length)for(;t.length>Gi.length;)Gi[Gi.length]=256;let n=[],r=e==Ii?0:1;return Yi(t,r,r,i,0,t.length,n),n}(t.text,i,e);return this.bidiCache.push(new Hr(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ze.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{fe(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.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 vi.of(new wi("number"==typeof t?z.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 vi.of(new wi(z.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return Si.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return Si.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=jt.newName(),n=[wr.of(i),Pi.of(Sr(`.${i}`,t))];return e&&e.dark&&n.push(vr.of(!0)),n}static baseTheme(t){return U.lowest(Pi.of(Sr("."+br,t,xr)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&ke.get(i)||ke.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}zr.styleModule=Pi,zr.inputHandler=fi,zr.focusChangeEffect=pi,zr.perLineTextDirection=mi,zr.exceptionSink=ui,zr.updateListener=di,zr.editable=ki,zr.mouseSelectionStyle=ci,zr.dragMovesSelection=hi,zr.clickAddsSelectionRange=li,zr.decorations=Ti,zr.atomicRanges=Di,zr.bidiIsolatedRanges=Oi,zr.scrollMargins=Ei,zr.darkTheme=vr,zr.cspNonce=H.define({combine:t=>t.length?t[0]:""}),zr.contentAttributes=Ci,zr.editorAttributes=Mi,zr.lineWrapping=zr.contentAttributes.of({class:"cm-lineWrapping"}),zr.announce=ut.define();const Ir=4096,Vr={};class Hr{constructor(t,e,i,n,r,s){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=r,this.order=s}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:zi.LTR;for(let r=Math.max(0,t.length-10);r<t.length;r++){let s=t[r];s.dir!=n||e.touchesRange(s.from,s.to)||i.push(new Hr(e.mapPos(s.from,1),e.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return i}}function Wr(t,e,i){for(let n=t.state.facet(e),r=n.length-1;r>=0;r--){let e=n[r],s="function"==typeof e?e(t):e;s&&je(s,i)}return i}const Fr=ze.mac?"mac":ze.windows?"win":ze.linux?"linux":"key";function qr(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}const _r=U.default(zr.domEventHandlers({keydown:(t,e)=>Yr($r(e.state),t,e,"editor")})),jr=H.define({enables:_r}),Kr=new WeakMap;function $r(t){let e=t.facet(jr),i=Kr.get(e);return i||Kr.set(e,i=function(t,e=Fr){let i=Object.create(null),n=Object.create(null),r=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},s=(t,n,s,o,a)=>{var l,h;let c=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let n,r,s,o,a=i[i.length-1];"Space"==a&&(a=" ");for(let t=0;t<i.length-1;++t){const a=i[t];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==e?o=!0:r=!0}}return n&&(a="Alt-"+a),r&&(a="Ctrl-"+a),o&&(a="Meta-"+a),s&&(a="Shift-"+a),a}(t,e)));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");r(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=Gr={view:e,prefix:i,scope:t};return setTimeout((()=>{Gr==n&&(Gr=null)}),Ur),!0}]})}let d=u.join(" ");r(d,!1);let f=c[d]||(c[d]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(l=c._any)||void 0===l?void 0:l.run)||void 0===h?void 0:h.slice())||[]});s&&f.run.push(s),o&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let e in t)t[e].run.push(n.any)}let r=n[e]||n.key;if(r)for(let e of t)s(e,r,n.run,n.preventDefault,n.stopPropagation),n.shift&&s(e,"Shift-"+r,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let Gr=null;const Ur=4e3;function Yr(t,e,i,n){let r=function(t){var e=!(Yt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Jt&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Ut:Gt)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),s=A(x(r,0))==r.length&&" "!=r,o="",a=!1,l=!1,h=!1;Gr&&Gr.view==i&&Gr.scope==n&&(o=Gr.prefix+" ",xn.indexOf(e.keyCode)<0&&(l=!0,Gr=null));let c,u,d=new Set,f=t=>{if(t){for(let n of t.run)if(!d.has(n)&&(d.add(n),n(i,e)))return t.stopPropagation&&(h=!0),!0;t.preventDefault&&(t.stopPropagation&&(h=!0),l=!0)}return!1},p=t[n];return p&&(f(p[o+qr(r,e,!s)])?a=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ze.windows&&e.ctrlKey&&e.altKey)&&(c=Gt[e.keyCode])&&c!=r?(f(p[o+qr(c,e,!0)])||e.shiftKey&&(u=Ut[e.keyCode])!=r&&u!=c&&f(p[o+qr(u,e,!1)]))&&(a=!0):s&&e.shiftKey&&f(p[o+qr(r,e,!0)])&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&h&&e.stopPropagation(),a}const Jr={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};function Xr(t,e,i,n,r){e.lastIndex=0;for(let s,o=t.iterRange(i,n),a=i;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;s=e.exec(o.value);)r(a+s.index,s)}!ze.ios&&(Jr[".cm-line"].caretColor="transparent !important",Jr[".cm-content"]={caretColor:"transparent !important"});class Zr{constructor(t){const{regexp:e,decoration:i,decorate:n,boundary:r,maxLength:s=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(t,e,i,r)=>n(r,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,n,r)=>{let s=i(t,e,n);s&&r(n,n+t[0].length,s)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,n,r)=>r(n,n+t[0].length,i)}this.boundary=r,this.maxLength=s}createDeco(t){let e=new Ot,i=e.add.bind(e);for(let{from:e,to:n}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let n=[];for(let{from:r,to:s}of i)r=Math.max(t.state.doc.lineAt(r).from,r-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}(t,this.maxLength))Xr(t.state.doc,this.regexp,e,n,((e,n)=>this.addMatch(n,t,e,i)));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges(((e,r,s,o)=>{o>t.view.viewport.from&&s<t.view.viewport.to&&(i=Math.min(s,i),n=Math.max(o,n))})),t.viewportChanged||n-i>1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let r of t.visibleRanges){let s=Math.max(r.from,i),o=Math.min(r.to,n);if(o>s){let i=t.state.doc.lineAt(s),n=i.to<o?t.state.doc.lineAt(o):i,a=Math.max(r.from,i.from),l=Math.min(r.to,n.to);if(this.boundary){for(;s>i.from;s--)if(this.boundary.test(i.text[s-1-i.from])){a=s;break}for(;o<n.to;o++)if(this.boundary.test(n.text[o-n.from])){l=o;break}}let h,c=[],u=(t,e,i)=>c.push(i.range(t,e));if(i==n)for(this.regexp.lastIndex=a-i.from;(h=this.regexp.exec(i.text))&&h.index<l-i.from;)this.addMatch(h,t,h.index+i.from,u);else Xr(t.state.doc,this.regexp,a,l,((e,i)=>this.addMatch(i,t,e,u)));e=e.update({filterFrom:a,filterTo:l,filter:(t,e)=>t<a||e>l,add:c})}}return e}}const Qr=null!=/x/.unicode?"gu":"g",ts=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",Qr),es={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let is=null;const ns=H.define({combine(t){let e=St(t,{render:null,specialChars:ts,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==is&&"undefined"!=typeof document&&document.body){let e=document.body.style;is=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return is||!1}())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,Qr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Qr)),e}});function rs(t={}){return[ns.of(t),ss||(ss=Si.fromClass(class{constructor(t){this.view=t,this.decorations=Qe.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(ns)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new Zr({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:r}=i.state,s=x(e[0],0);if(9==s){let t=r.lineAt(n),e=i.state.tabSize,s=Wt(t.text,e,n-t.from);return Qe.replace({widget:new as((e-s%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Qe.replace({widget:new os(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(ns);t.startState.facet(ns)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]}let ss=null;class os extends Xe{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=function(t){return t>=32?"•":10==t?"␤":String.fromCharCode(9216+t)}(this.code),i=t.state.phrase("Control character")+" "+(es[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let r=document.createElement("span");return r.textContent=e,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class as extends Xe{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const ls=Qe.line({class:"cm-activeLine"}),hs=Si.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let n of t.state.selection.ranges){let r=t.lineBlockAt(n.head);r.from>e&&(i.push(ls.range(r.from)),e=r.from)}return Qe.set(i)}},{decorations:t=>t.decorations}),cs="-10000px";class us{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter((t=>t)),this.tooltipViews=this.tooltips.map(i)}update(t,e){var i;let n=t.state.facet(this.facet),r=n.filter((t=>t));if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let s=[],o=e?[]:null;for(let i=0;i<r.length;i++){let n=r[i],a=-1;if(n){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==n.create&&(a=t)}if(a<0)s[i]=this.createTooltipView(n),o&&(o[i]=!!n.above);else{let n=s[i]=this.tooltipViews[a];o&&(o[i]=e[a]),n.update&&n.update(t)}}}for(let t of this.tooltipViews)s.indexOf(t)<0&&(t.dom.remove(),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(o.forEach(((t,i)=>e[i]=t)),e.length=o.length),this.input=n,this.tooltips=r,this.tooltipViews=s,!0}}function ds(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const fs=H.define({combine:t=>{var e,i,n;return{position:ze.ios?"absolute":(null===(e=t.find((t=>t.position)))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find((t=>t.parent)))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=t.find((t=>t.tooltipSpace)))||void 0===n?void 0:n.tooltipSpace)||ds}}}),ps=new WeakMap,ms=Si.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(fs);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.manager=new us(t,vs,(t=>this.createTooltip(t))),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){this.intersectionObserver.disconnect();for(let t of 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,n=t.state.facet(fs);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let t of 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){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=cs,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);this.parent&&this.container.remove(),null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect(),e=1,i=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(ze.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(1!=this.view.scaleX||1!=this.view.scaleY)n=!0;else if(t.style.top==cs&&"0px"==t.style.left){let e=t.getBoundingClientRect();n=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(n||"absolute"==this.position)if(this.parent){let t=this.parent.getBoundingClientRect();t.width&&t.height&&(e=t.width/this.parent.offsetWidth,i=t.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:i}=this.view.viewState);return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,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(fs).tooltipSpace(this.view),scaleX:e,scaleY:i,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{editor:i,space:n,scaleX:r,scaleY:s}=t,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],h=this.manager.tooltipViews[a],{dom:c}=h,u=t.pos[a],d=t.size[a];if(!u||u.bottom<=Math.max(i.top,n.top)||u.top>=Math.min(i.bottom,n.bottom)||u.right<Math.max(i.left,n.left)-.1||u.left>Math.min(i.right,n.right)+.1){c.style.top=cs;continue}let f=l.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(e=ps.get(h))&&void 0!==e?e:d.bottom-d.top,w=h.offset||ws,v=this.view.textDirection==zi.LTR,b=d.width>n.right-n.left?v?n.left:n.right-d.width:v?Math.min(u.left-(f?14:0)+w.x,n.right-m):Math.max(n.left,u.left-m+(f?14:0)-w.x),k=this.above[a];!l.strictSide&&(k?u.top-(d.bottom-d.top)-w.y<n.top:u.bottom+(d.bottom-d.top)+w.y>n.bottom)&&k==n.bottom-u.bottom>u.top-n.top&&(k=this.above[a]=!k);let y=(k?u.top-n.top:n.bottom-u.bottom)-p;if(y<g&&!1!==h.resize){if(y<this.view.defaultLineHeight){c.style.top=cs;continue}ps.set(h,g),c.style.height=(g=y)/s+"px"}else c.style.height&&(c.style.height="");let x=k?u.top-g-p-w.y:u.bottom+p+w.y,S=b+m;if(!0!==h.overlap)for(let t of o)t.left<S&&t.right>b&&t.top<x+g&&t.bottom>x&&(x=k?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(x-t.parent.top)/s+"px",c.style.left=(b-t.parent.left)/r+"px"):(c.style.top=x/s+"px",c.style.left=b/r+"px"),f){let t=u.left+(v?w.x:-w.x)-(b+14-7);f.style.left=t/r+"px"}!0!==h.overlap&&o.push({left:b,top:x,right:S,bottom:x+g}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),h.positioned&&h.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=cs}},{eventObservers:{scroll(){this.maybeMeasure()}}}),gs=zr.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"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"}}}),ws={x:0,y:0},vs=H.define({enables:[ms,gs]}),bs=H.define();class ks{static create(t){return new ks(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new us(t,bs,(t=>this.createHostedView(t)))}createHostedView(t){let e=t.create(this.view);return e.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(e.dom),this.mounted&&e.mount&&e.mount(this.view),e}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(void 0!==n)if(void 0===e)e=n;else if(e!==n)return}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const ys=vs.compute([bs],(t=>{let e=t.facet(bs).filter((t=>t));return 0===e.length?null:{pos:Math.min(...e.map((t=>t.pos))),end:Math.max(...e.map((t=>{var e;return null!==(e=t.end)&&void 0!==e?e:t.pos}))),create:ks.create,above:e[0].above,arrow:e.some((t=>t.arrow))}}));class xs{constructor(t,e,i,n,r){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((()=>this.startHover()),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.nearest(e.target);if(!i)return;let n,r=1;if(i instanceof He)n=i.posAtStart;else{if(n=t.posAtCoords(e),null==n)return;let i=t.coordsAtPos(n);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let s=t.bidiSpans(t.state.doc.lineAt(n)).find((t=>t.from<=n&&t.to>=n)),o=s&&s.dir==zi.RTL?-1:1;r=e.x<i.left?-o:o}let s=this.source(t,n,r);if(null==s?void 0:s.then){let e=this.pending={pos:n};s.then((i=>{this.pending==e&&(this.pending=null,i&&t.dispatch({effects:this.setHover.of(i)}))}),(e=>bi(t.state,e,"hover tooltip")))}else s&&t.dispatch({effects:this.setHover.of(s)})}get tooltip(){let t=this.view.plugin(ms),e=t?t.manager.tooltips.findIndex((t=>t.create==ks.create)):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:n}=this;if(i&&n&&!function(t,e){let i=t.getBoundingClientRect();return e.clientX>=i.left-Ss&&e.clientX<=i.right+Ss&&e.clientY>=i.top-Ss&&e.clientY<=i.bottom+Ss}(n.dom,t)||this.pending){let{pos:n}=i||this.pending,r=null!==(e=null==i?void 0:i.end)&&void 0!==e?e:n;(n==r?this.view.posAtCoords(this.lastMove)==n:function(t,e,i,n,r,s){let o=t.scrollDOM.getBoundingClientRect(),a=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>n||o.right<n||o.top>r||Math.min(o.bottom,a)<r)return!1;let l=t.posAtCoords({x:n,y:r},!1);return l>=e&&l<=i}(this.view,n,r,t.clientX,t.clientY))||(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Ss=4;function As(t,e={}){let i=ut.define(),n=$.define({create:()=>null,update(t,n){if(t&&(e.hideOnChange&&(n.docChanged||n.selection)||e.hideOn&&e.hideOn(n,t)))return null;if(t&&n.docChanged){let e=n.changes.mapPos(t.pos,-1,C.TrackDel);if(null==e)return null;let i=Object.assign(Object.create(null),t);i.pos=e,null!=t.end&&(i.end=n.changes.mapPos(t.end)),t=i}for(let e of n.effects)e.is(i)&&(t=e.value),e.is(Ms)&&(t=null);return t},provide:t=>bs.from(t)});return[n,Si.define((r=>new xs(r,t,n,i,e.hoverTime||300))),ys]}const Ms=ut.define(),Cs=H.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function Ts(t,e){let i=t.plugin(Ds),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const Ds=Si.fromClass(class{constructor(t){this.input=t.state.facet(Es),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(Cs);this.top=new Os(t,!0,e.topContainer),this.bottom=new Os(t,!1,e.bottomContainer),this.top.sync(this.panels.filter((t=>t.top))),this.bottom.sync(this.panels.filter((t=>!t.top)));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(Cs);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Os(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Os(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Es);if(i!=this.input){let e=i.filter((t=>t)),n=[],r=[],s=[],o=[];for(let i of e){let e,a=this.specs.indexOf(i);a<0?(e=i(t.view),o.push(e)):(e=this.panels[a],e.update&&e.update(t)),n.push(e),(e.top?r:s).push(e)}this.specs=e,this.panels=n,this.top.sync(r),this.bottom.sync(s);for(let t of 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=>zr.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class Os{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));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=Ls(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Ls(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 Ls(t){let e=t.nextSibling;return t.remove(),e}const Es=H.define({enables:Ds});class Bs extends At{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Bs.prototype.elementClass="",Bs.prototype.toDOM=void 0,Bs.prototype.mapMode=C.TrackBefore,Bs.prototype.startSide=Bs.prototype.endSide=-1,Bs.prototype.point=!0;const Ps=H.define(),Ns={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Dt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Rs=H.define();function zs(t){return[Vs(),Rs.of(Object.assign(Object.assign({},Ns),t))]}const Is=H.define({combine:t=>t.some((t=>t))});function Vs(t){let e=[Hs];return t&&!1===t.fixed&&e.push(Is.of(!0)),e}const Hs=Si.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Rs).map((e=>new _s(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(Is),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(Is)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=Dt.iter(this.view.state.facet(Ps),this.view.viewport.from),n=[],r=this.gutters.map((t=>new qs(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let s of t.type)if(s.type==Ze.Text&&e){Fs(i,n,s.from);for(let t of r)t.line(this.view,s,n);e=!1}else if(s.widget)for(let t of r)t.widget(this.view,s)}else if(t.type==Ze.Text){Fs(i,n,t.from);for(let e of r)e.line(this.view,t,n)}else if(t.widget)for(let e of r)e.widget(this.view,t);for(let t of r)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(Rs),i=t.state.facet(Rs),n=t.docChanged||t.heightChanged||t.viewportChanged||!Dt.eq(t.startState.facet(Ps),t.state.facet(Ps),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let r=[];for(let n of i){let i=e.indexOf(n);i<0?r.push(new _s(this.view,n)):(this.gutters[i].update(t),r.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),r.indexOf(t)<0&&t.destroy();for(let t of r)this.dom.appendChild(t.dom);this.gutters=r}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>zr.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==zi.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function Ws(t){return Array.isArray(t)?t:[t]}function Fs(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class qs{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=Dt.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,r=(e.top-this.height)/t.scaleY,s=e.height/t.scaleY;if(this.i==n.elements.length){let e=new js(t,s,r,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,s,r,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];Fs(this.cursor,n,e.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(t,e,n);r&&n.unshift(r);let s=this.gutter;(0!=n.length||s.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e);i&&this.addElement(t,e,[i])}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class _s{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(n=>{let r,s=n.target;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let t=s.getBoundingClientRect();r=(t.top+t.bottom)/2}else r=n.clientY;let o=t.lineBlockAtHeight(r-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=Ws(e.markers(t)),e.initialSpacer&&(this.spacer=new js(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=Ws(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!Dt.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 js{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),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,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,s=0;;){let o=s,a=r<e.length?e[r++]:null,l=!1;if(a){let t=a.elementClass;t&&(i+=" "+t);for(let t=s;t<this.markers.length;t++)if(this.markers[t].compare(a)){o=t,l=!0;break}}else o=this.markers.length;for(;s<o;){let t=this.markers[s++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!a)break;a.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(a.toDOM(t),n)),l&&s++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}const Ks=H.define(),$s=H.define({combine:t=>St(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],r=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||r(t,e,i):r}return i}})});class Gs extends Bs{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function Us(t,e){return t.state.facet($s).formatNumber(e,t.state)}const Ys=Rs.compute([$s],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(Ks),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new Gs(Us(t,t.state.doc.lineAt(e.from).number)),widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet($s)!=t.state.facet($s),initialSpacer:t=>new Gs(Us(t,Xs(t.state.doc.lines))),updateSpacer(t,e){let i=Us(e.view,Xs(e.view.state.doc.lines));return i==t.number?t:new Gs(i)},domEventHandlers:t.facet($s).domEventHandlers})));function Js(t={}){return[$s.of(t),Vs(),Ys]}function Xs(t){let e=9;for(;e<t;)e=10*e+9;return e}const Zs=1024;let Qs=0;class to{constructor(t,e){this.from=t,this.to=e}}class eo{constructor(t={}){this.id=Qs++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=ro.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}eo.closedBy=new eo({deserialize:t=>t.split(" ")}),eo.openedBy=new eo({deserialize:t=>t.split(" ")}),eo.group=new eo({deserialize:t=>t.split(" ")}),eo.contextHash=new eo({perNode:!0}),eo.lookAhead=new eo({perNode:!0}),eo.mounted=new eo({perNode:!0});class io{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[eo.mounted.id]}}const no=Object.create(null);class ro{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):no,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new ro(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}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(eo.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 n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(eo.group),n=-1;n<(i?i.length:0);n++){let r=e[n<0?t.name:i[n]];if(r)return r}}}}ro.none=new ro("",Object.create(null),0,8);class so{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);t&&(n||(n=Object.assign({},i.props)),n[t[0].id]=t[1])}e.push(n?new ro(i.name,n,i.id,i.flags):i)}return new so(e)}}const oo=new WeakMap,ao=new WeakMap;var lo;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(lo||(lo={}));class ho{constructor(t,e,i,n,r){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[t,e]of r)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=io.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 So(this.topNode,t)}cursorAt(t,e=0,i=0){let n=oo.get(this)||this.topNode,r=new So(n);return r.moveTo(t,e),oo.set(this,r._tree),r}get topNode(){return new go(this,0,0,null)}resolve(t,e=0){let i=po(oo.get(this)||this.topNode,t,e,!1);return oo.set(this,i),i}resolveInner(t,e=0){let i=po(ao.get(this)||this.topNode,t,e,!0);return ao.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),r=null;for(let t=n instanceof go?n:n.context.parent;t;t=t.parent)if(t.index<0){let s=t.parent;(r||(r=[n])).push(s.resolve(e,i)),t=s}else{let s=io.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new go(s.tree,s.overlay[0].from+t.from,-1,t);(r||(r=[n])).push(po(o,e,i,!1))}}return r?yo(r):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:r=this.length}=t,s=t.mode||0,o=(s&lo.IncludeAnonymous)>0;for(let t=this.cursor(s|lo.IncludeAnonymous);;){let s=!1;if(t.from<=r&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;s=!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:To(ro.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new ho(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new ho(ro.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:r=Zs,reused:s=[],minRepeatType:o=n.types.length}=t,a=Array.isArray(i)?new co(i,i.length):i,l=n.types,h=0,c=0;function u(t,e,i,g,w,v){let{id:b,start:k,end:y,size:x}=a,S=c;for(;x<0;){if(a.next(),-1==x){let e=s[b];return i.push(e),void g.push(k-t)}if(-3==x)return void(h=b);if(-4==x)return void(c=b);throw new RangeError(`Unrecognized record size: ${x}`)}let A,M,C=l[b],T=k-t;if(y-k<=r&&(M=function(t,e){let i=a.fork(),n=0,s=0,l=0,h=i.end-r,c={size:0,start:0,skip:0};t:for(let r=i.pos-t;i.pos>r;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=l,l+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<r||i.start<h)break;let u=i.id>=o?4:0,d=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}s=d,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=l),c.size>4?c:void 0}(a.pos-e,w))){let e=new Uint16Array(M.size-M.skip),i=a.pos-M.size,r=e.length;for(;a.pos>i;)r=m(M.start,e,r);A=new uo(e,y-M.start,n),T=M.start-t}else{let t=a.pos-x;a.next();let e=[],i=[],n=b>=o?b:-1,s=0,l=y;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=l-r&&(f(e,i,k,s,a.end,l,n,S),s=e.length,l=a.end),a.next()):v>2500?d(k,t,e,i):u(k,t,e,i,n,v+1);if(n>=0&&s>0&&s<e.length&&f(e,i,k,s,k,l,n,S),e.reverse(),i.reverse(),n>-1&&s>0){let t=function(t){return(e,i,n)=>{let r,s,o=0,a=e.length-1;if(a>=0&&(r=e[a])instanceof ho){if(!a&&r.type==t&&r.length==n)return r;(s=r.prop(eo.lookAhead))&&(o=i[a]+r.length+s)}return p(t,e,i,n,o)}}(C);A=To(C,e,i,0,e.length,0,y-k,t,t)}else A=p(C,e,i,y-k,S-y)}i.push(A),g.push(T)}function d(t,e,i,s){let o=[],l=0,h=-1;for(;a.pos>e;){let{id:t,start:e,end:i,size:n}=a;if(n>4)a.next();else{if(h>-1&&e<h)break;h<0&&(h=i-r),o.push(t,e,i),l++,a.next()}}if(l){let e=new Uint16Array(4*l),r=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]-r,e[i++]=o[t+2]-r,e[i++]=i;i.push(new uo(e,o[2]-r,n)),s.push(r-t)}}function f(t,e,i,r,s,o,a,l){let h=[],c=[];for(;t.length>r;)h.push(t.pop()),c.push(e.pop()+i-s);t.push(p(n.types[a],h,c,o-s,l-o)),e.push(s-i)}function p(t,e,i,n,r=0,s){if(h){let t=[eo.contextHash,h];s=s?[t].concat(s):[t]}if(r>25){let t=[eo.lookAhead,r];s=s?[t].concat(s):[t]}return new ho(t,e,i,n,s)}function m(t,e,i){let{id:n,start:r,end:s,size:l}=a;if(a.next(),l>=0&&n<o){let o=i;if(l>4){let n=a.pos-(l-4);for(;a.pos>n;)i=m(t,e,i)}e[--i]=o,e[--i]=s-t,e[--i]=r-t,e[--i]=n}else-3==l?h=n:-4==l&&(c=n);return i}let g=[],w=[];for(;a.pos>0;)u(t.start||0,t.bufferStart||0,g,w,-1,0);let v=null!==(e=t.length)&&void 0!==e?e:g.length?w[0]+g[0].length:0;return new ho(l[t.topID],g.reverse(),w.reverse(),v)}(t)}}ho.empty=new ho(ro.none,[],[],0);class co{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 co(this.buffer,this.index)}}class uo{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ro.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),i==(t+=4))return r;let s=[];for(;t<i;)s.push(this.childString(t)),t=this.buffer[t+3];return r+"("+s.join(",")+")"}findChild(t,e,i,n,r){let{buffer:s}=this,o=-1;for(let a=t;a!=e&&!(fo(r,n,s[a+1],s[a+2])&&(o=a,i>0));a=s[a+3]);return o}slice(t,e,i){let n=this.buffer,r=new Uint16Array(e-t),s=0;for(let o=t,a=0;o<e;){r[a++]=n[o++],r[a++]=n[o++]-i;let e=r[a++]=n[o++]-i;r[a++]=n[o++]-t,s=Math.max(s,e)}return new uo(r,s,this.set)}}function fo(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function po(t,e,i,n){for(var r;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof go&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=n?0:lo.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof go&&n.index<0&&(null===(r=o.enter(e,i,s))||void 0===r?void 0:r.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,s);if(!n)return t;t=n}}class mo{cursor(t=0){return new So(this,t)}getChild(t,e=null,i=null){let n=wo(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return wo(this,t,e,i)}resolve(t,e=0){return po(this,t,e,!1)}resolveInner(t,e=0){return po(this,t,e,!0)}matchContext(t){return vo(this,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 go extends mo{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,r=0){for(let s=this;;){for(let{children:o,positions:a}=s._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],h=a[t]+s.from;if(fo(n,i,h,h+l.length))if(l instanceof uo){if(r&lo.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-h,n);if(o>-1)return new ko(new bo(s,l,t,h),null,o)}else if(r&lo.IncludeAnonymous||!l.type.isAnonymous||Ao(l)){let o;if(!(r&lo.IgnoreMounts)&&(o=io.get(l))&&!o.overlay)return new go(o.tree,h,t,s);let a=new go(l,h,t,s);return r&lo.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(r&lo.IncludeAnonymous||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,s=s._parent,!s)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 n;if(!(i&lo.IgnoreOverlays)&&(n=io.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:r}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?r>=i:r>i))return new go(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function wo(t,e,i,n){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(null!=i)for(;!r.type.is(i);)if(!r.nextSibling())return s;for(;;){if(null!=n&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return null==n?s:[]}}function vo(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class bo{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class ko extends mo{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return r<0?null:new ko(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&lo.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new ko(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new ko(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 ko(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let s=i.buffer[this.index+1];t.push(i.slice(n,r,s)),e.push(0)}return new ho(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function yo(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let r=t[n];(r.from>i.from||r.to<i.to)&&(i=r,e=n)}let n=i instanceof go&&i.index<0?null:i.parent,r=t.slice();return n?r[e]=n:r.splice(e,1),new xo(r,i)}class xo{constructor(t,e){this.heads=t,this.node=e}get next(){return yo(this.heads)}}class So{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 go)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:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof go?(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:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&lo.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&lo.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&lo.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:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,r=t<0?-1:i._tree.children.length;n!=r;n+=t){let t=i._tree.children[n];if(this.mode&lo.IncludeAnonymous||t instanceof uo||!t.type.isAnonymous||Ao(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)t:for(let n=this.index,r=this.stack.length;r>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,i=r+1;break t}n=this.stack[--r]}for(let t=i;t<this.stack.length;t++)e=new ko(this.buffer,e,this.stack[t]);return this.bufferNode=new ko(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return vo(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return vo(this.node,t,n);let s=i[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}}function Ao(t){return t.children.some((t=>t instanceof uo||!t.type.isAnonymous||Ao(t)))}const Mo=new WeakMap;function Co(t,e){if(!t.isAnonymous||e instanceof uo||e.type!=t)return 1;let i=Mo.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof ho)){i=1;break}i+=Co(t,n)}Mo.set(e,i)}return i}function To(t,e,i,n,r,s,o,a,l){let h=0;for(let i=n;i<r;i++)h+=Co(t,e[i]);let c=Math.ceil(1.5*h/8),u=[],d=[];return function e(i,n,r,o,a){for(let h=r;h<o;){let r=h,f=n[h],p=Co(t,i[h]);for(h++;h<o;h++){let e=Co(t,i[h]);if(p+e>=c)break;p+=e}if(h==r+1){if(p>c){let t=i[r];e(t.children,t.positions,0,t.children.length,n[r]+a);continue}u.push(i[r])}else{let e=n[h-1]+i[h-1].length-f;u.push(To(t,i,n,r,h,f,e,null,l))}d.push(f+a-s)}}(e,i,n,r,0),(a||l)(u,d,o)}class Do{constructor(t,e,i,n,r=!1,s=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(r?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new Do(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],r=1,s=t.length?t[0]:null;for(let o=0,a=0,l=0;;o++){let h=o<e.length?e[o]:null,c=h?h.fromA:1e9;if(c-a>=i)for(;s&&s.from<c;){let e=s;if(a>=e.from||c<=e.to||l){let t=Math.max(e.from,a)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new Do(t,i,e.tree,e.offset+l,o>0,!!h)}if(e&&n.push(e),s.to>c)break;s=r<t.length?t[r++]:null}if(!h)break;a=h.toA,l=h.toA-h.toB}return n}}class Oo{startParse(t,e,i){return"string"==typeof t&&(t=new Lo(t)),i=i?i.length?i.map((t=>new to(t.from,t.to))):[new to(0,0)]:[new to(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class Lo{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 eo({perNode:!0});let Eo=0;class Bo{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=Eo++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new Bo([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new No;return e=>e.modified.indexOf(t)>-1?e:No.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let Po=0;class No{constructor(){this.instances=[],this.id=Po++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,r=i.modified,n.length==r.length&&n.every(((t,e)=>t==r[e])));var n,r}));if(i)return i;let n=[],r=new Bo(n,t,e);for(let t of e)t.instances.push(r);let s=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].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 s)n.push(No.get(e,t));return r}}function Ro(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],r=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){r=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){r=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let o=i.length-1,a=i[o];if(!a)throw new RangeError("Invalid path: "+t);let l=new Io(n,r,o>0?i.slice(0,o):null);e[a]=l.sort(e[a])}}return zo.add(e)}const zo=new eo;class Io{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}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 Vo(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:n,all:r=null}=e||{};return{style:t=>{let e=r;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function Ho(t,e,i,n=0,r=t.length){let s=new Wo(n,Array.isArray(e)?e:[e],i);s.highlightRange(t.cursor(),n,r,"",s.highlighters),s.flush(r)}Io.empty=new Io([],2,null);class Wo{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,r){let{type:s,from:o,to:a}=t;if(o>=i||a<=e)return;s.isTop&&(r=this.highlighters.filter((t=>!t.scope||t.scope(s))));let l=n,h=function(t){let e=t.type.prop(zo);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||Io.empty,c=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(r,h.tags);if(c&&(l&&(l+=" "),l+=c,1==h.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(e,o),l),h.opaque)return;let u=t.tree&&t.tree.prop(eo.mounted);if(u&&u.overlay){let s=t.node.enter(u.overlay[0].from+o,1),h=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),c=t.firstChild();for(let d=0,f=o;;d++){let p=d<u.overlay.length?u.overlay[d]:null,m=p?p.from+o:a,g=Math.max(e,f),w=Math.min(i,m);if(g<w&&c)for(;t.from<w&&(this.highlightRange(t,g,w,n,r),this.startSpan(Math.min(w,t.to),l),!(t.to>=m)&&t.nextSibling()););if(!p||m>i)break;f=p.to+o,f>e&&(this.highlightRange(s.cursor(),Math.max(e,p.from+o),Math.min(i,f),"",h),this.startSpan(Math.min(i,f),l))}c&&t.parent()}else if(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,r),this.startSpan(Math.min(i,t.to),l)}}while(t.nextSibling());t.parent()}}}const Fo=Bo.define,qo=Fo(),_o=Fo(),jo=Fo(_o),Ko=Fo(_o),$o=Fo(),Go=Fo($o),Uo=Fo($o),Yo=Fo(),Jo=Fo(Yo),Xo=Fo(),Zo=Fo(),Qo=Fo(),ta=Fo(Qo),ea=Fo(),ia={comment:qo,lineComment:Fo(qo),blockComment:Fo(qo),docComment:Fo(qo),name:_o,variableName:Fo(_o),typeName:jo,tagName:Fo(jo),propertyName:Ko,attributeName:Fo(Ko),className:Fo(_o),labelName:Fo(_o),namespace:Fo(_o),macroName:Fo(_o),literal:$o,string:Go,docString:Fo(Go),character:Fo(Go),attributeValue:Fo(Go),number:Uo,integer:Fo(Uo),float:Fo(Uo),bool:Fo($o),regexp:Fo($o),escape:Fo($o),color:Fo($o),url:Fo($o),keyword:Xo,self:Fo(Xo),null:Fo(Xo),atom:Fo(Xo),unit:Fo(Xo),modifier:Fo(Xo),operatorKeyword:Fo(Xo),controlKeyword:Fo(Xo),definitionKeyword:Fo(Xo),moduleKeyword:Fo(Xo),operator:Zo,derefOperator:Fo(Zo),arithmeticOperator:Fo(Zo),logicOperator:Fo(Zo),bitwiseOperator:Fo(Zo),compareOperator:Fo(Zo),updateOperator:Fo(Zo),definitionOperator:Fo(Zo),typeOperator:Fo(Zo),controlOperator:Fo(Zo),punctuation:Qo,separator:Fo(Qo),bracket:ta,angleBracket:Fo(ta),squareBracket:Fo(ta),paren:Fo(ta),brace:Fo(ta),content:Yo,heading:Jo,heading1:Fo(Jo),heading2:Fo(Jo),heading3:Fo(Jo),heading4:Fo(Jo),heading5:Fo(Jo),heading6:Fo(Jo),contentSeparator:Fo(Yo),list:Fo(Yo),quote:Fo(Yo),emphasis:Fo(Yo),strong:Fo(Yo),link:Fo(Yo),monospace:Fo(Yo),strikethrough:Fo(Yo),inserted:Fo(),deleted:Fo(),changed:Fo(),invalid:Fo(),meta:ea,documentMeta:Fo(ea),annotation:Fo(ea),processingInstruction:Fo(ea),definition:Bo.defineModifier(),constant:Bo.defineModifier(),function:Bo.defineModifier(),standard:Bo.defineModifier(),local:Bo.defineModifier(),special:Bo.defineModifier()};var na;Vo([{tag:ia.link,class:"tok-link"},{tag:ia.heading,class:"tok-heading"},{tag:ia.emphasis,class:"tok-emphasis"},{tag:ia.strong,class:"tok-strong"},{tag:ia.keyword,class:"tok-keyword"},{tag:ia.atom,class:"tok-atom"},{tag:ia.bool,class:"tok-bool"},{tag:ia.url,class:"tok-url"},{tag:ia.labelName,class:"tok-labelName"},{tag:ia.inserted,class:"tok-inserted"},{tag:ia.deleted,class:"tok-deleted"},{tag:ia.literal,class:"tok-literal"},{tag:ia.string,class:"tok-string"},{tag:ia.number,class:"tok-number"},{tag:[ia.regexp,ia.escape,ia.special(ia.string)],class:"tok-string2"},{tag:ia.variableName,class:"tok-variableName"},{tag:ia.local(ia.variableName),class:"tok-variableName tok-local"},{tag:ia.definition(ia.variableName),class:"tok-variableName tok-definition"},{tag:ia.special(ia.variableName),class:"tok-variableName2"},{tag:ia.definition(ia.propertyName),class:"tok-propertyName tok-definition"},{tag:ia.typeName,class:"tok-typeName"},{tag:ia.namespace,class:"tok-namespace"},{tag:ia.className,class:"tok-className"},{tag:ia.macroName,class:"tok-macroName"},{tag:ia.propertyName,class:"tok-propertyName"},{tag:ia.operator,class:"tok-operator"},{tag:ia.comment,class:"tok-comment"},{tag:ia.meta,class:"tok-meta"},{tag:ia.invalid,class:"tok-invalid"},{tag:ia.punctuation,class:"tok-punctuation"}]);const ra=new eo;const sa=new eo;class oa{constructor(t,e,i=[],n=""){this.data=t,this.name=n,xt.prototype.hasOwnProperty("tree")||Object.defineProperty(xt.prototype,"tree",{get(){return la(this)}}),this.parser=e,this.extension=[wa.of(this),xt.languageData.of(((t,e,i)=>{let n=aa(t,e,i),r=n.type.prop(ra);if(!r)return[];let s=t.facet(r),o=n.type.prop(sa);if(o){let r=n.resolve(e-n.from,i);for(let e of o)if(e.test(r,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(s)}}return s}))].concat(i)}isActiveAt(t,e,i=-1){return aa(t,e,i).type.prop(ra)==this.data}findRegions(t){let e=t.facet(wa);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(ra)==this.data)return void i.push({from:e,to:e+t.length});let r=t.prop(eo.mounted);if(r){if(r.tree.prop(ra)==this.data){if(r.overlay)for(let t of r.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(r.overlay){let t=i.length;if(n(r.tree,r.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let r=t.children[i];r instanceof ho&&n(r,t.positions[i]+e)}};return n(la(t),0),i}get allowsNesting(){return!0}}function aa(t,e,i){let n=t.facet(wa),r=la(t).topNode;if(!n||n.allowsNesting)for(let t=r;t;t=t.enter(e,i,lo.ExcludeBuffers))t.type.isTop&&(r=t);return r}function la(t){let e=t.field(oa.state,!1);return e?e.tree:ho.empty}oa.setState=ut.define();class ha{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 ca=null;class ua{constructor(t,e,i=[],n,r,s,o,a){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new ua(t,e,[],ho.empty,0,i,[],null)}startParse(){return this.parser.startParse(new ha(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=ho.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 n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(Do.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,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(Do.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=ca;ca=this;try{return t()}finally{ca=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=da(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,r)=>e.push({fromA:t,toA:i,fromB:n,toB:r}))),i=Do.applyChanges(i,e),n=ho.empty,r=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&o.push({from:i,to:n})}}}return new ua(this.parser,e,i,n,r,s,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:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=da(this.fragments,i,n),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 Oo{createParse(e,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let e=ca;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new ho(ro.none,[],[],s-r)},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 ca}}function da(t,e,i){return Do.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class fa{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 fa(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=ua.create(t.facet(wa).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new fa(i)}}oa.state=$.define({create:fa.init,update(t,e){for(let t of e.effects)if(t.is(oa.setState))return t.value;return e.startState.facet(wa)!=e.state.facet(wa)?fa.init(e.state):t.apply(e)}});let pa=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(pa=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const ma="undefined"!=typeof navigator&&(null===(na=navigator.scheduling)||void 0===na?void 0:na.isInputPending)?()=>navigator.scheduling.isInputPending():null,ga=Si.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(oa.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(oa.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=pa(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(oa.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!ma?Math.max(25,t.timeRemaining()-5):1e9),o=r.context.treeLen<n&&i.doc.length>n+1e3,a=r.context.work((()=>ma&&ma()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:oa.setState.of(new fa(r.context))})),this.chunkBudget>0&&(!a||o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>bi(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()}}}),wa=H.define({combine:t=>t.length?t[0]:null,enables:t=>[oa.state,ga,zr.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});class va{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const ba=H.define(),ka=H.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 new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function ya(t){let e=t.facet(ka);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function xa(t,e){let i="",n=t.tabSize,r=t.facet(ka)[0];if("\t"==r){for(;e>=n;)i+="\t",e-=n;r=" "}for(let t=0;t<e;t++)i+=r;return i}function Sa(t,e){t instanceof xt&&(t=new Aa(t));for(let i of t.state.facet(ba)){let n=i(t,e);if(void 0!==n)return n}let i=la(t.state);return i.length>=e?function(t,e,i){let n=e.resolveStack(i),r=n.node.enterUnfinishedNodesBefore(i);if(r!=n.node){let t=[];for(let e=r;e!=n.node;e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Ca(n,t,i)}(t,i,e):null}class Aa{constructor(t,e={}){this.state=t,this.options=e,this.unit=ya(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return null!=n&&n>=i.from&&n<=i.to?r&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.countColumn(i,t-n),s=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return s>-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return Wt(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let t=r(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ma=new eo;function Ca(t,e,i){for(let n=t;n;n=n.next){let t=Ta(n.node);if(t)return t(Oa.create(e,i,n))}return 0}function Ta(t){let e=t.type.prop(Ma);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(eo.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>function(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==t.pos+o,l=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(i.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let t=i.to;;){let r=e.childAfter(t);if(!r||r==n)return null;if(!r.type.isSkipped)return r.from<o?i:null;t=r.to}}(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*i)}(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?Da:null}function Da(){return 0}class Oa extends Aa{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 Oa(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(La(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Ca(this.context.next,this.base,this.pos)}}function La(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}class Ea{constructor(t,e){let i;function n(t){let e=jt.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const r="string"==typeof e.all?e.all:e.all?n(e.all):void 0,s=e.scope;this.scope=s instanceof oa?t=>t.prop(ra)==s.data:s?t=>t==s:void 0,this.style=Vo(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:r}).style,this.module=i?new jt(i):null,this.themeType=e.themeType}static define(t,e){return new Ea(t,e||{})}}const Ba=H.define(),Pa=H.define({combine:t=>t.length?[t[0]]:null});function Na(t){let e=t.facet(Ba);return e.length?e:t.facet(Pa)}function Ra(t,e){let i,n=[Ia];return t instanceof Ea&&(t.module&&n.push(zr.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(Pa.of(t)):i?n.push(Ba.computeN([zr.darkTheme],(e=>e.facet(zr.darkTheme)==("dark"==i)?[t]:[]))):n.push(Ba.of(t)),n}class za{constructor(t){this.markCache=Object.create(null),this.tree=la(t.state),this.decorations=this.buildDeco(t,Na(t.state))}update(t){let e=la(t.state),i=Na(t.state),n=i!=Na(t.startState);e.length<t.view.viewport.to&&!n&&e.type==this.tree.type?this.decorations=this.decorations.map(t.changes):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i))}buildDeco(t,e){if(!e||!this.tree.length)return Qe.none;let i=new Ot;for(let{from:n,to:r}of t.visibleRanges)Ho(this.tree,e,((t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=Qe.mark({class:n})))}),n,r);return i.finish()}}const Ia=U.high(Si.fromClass(za,{decorations:t=>t.decorations})),Va=Ea.define([{tag:ia.meta,color:"#404740"},{tag:ia.link,textDecoration:"underline"},{tag:ia.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ia.emphasis,fontStyle:"italic"},{tag:ia.strong,fontWeight:"bold"},{tag:ia.strikethrough,textDecoration:"line-through"},{tag:ia.keyword,color:"#708"},{tag:[ia.atom,ia.bool,ia.url,ia.contentSeparator,ia.labelName],color:"#219"},{tag:[ia.literal,ia.inserted],color:"#164"},{tag:[ia.string,ia.deleted],color:"#a11"},{tag:[ia.regexp,ia.escape,ia.special(ia.string)],color:"#e40"},{tag:ia.definition(ia.variableName),color:"#00f"},{tag:ia.local(ia.variableName),color:"#30a"},{tag:[ia.typeName,ia.namespace],color:"#085"},{tag:ia.className,color:"#167"},{tag:[ia.special(ia.variableName),ia.macroName],color:"#256"},{tag:ia.definition(ia.propertyName),color:"#00c"},{tag:ia.comment,color:"#940"},{tag:ia.invalid,color:"#f00"}]),Ha=1e4,Wa="()[]{}",Fa=new eo;function qa(t,e,i){let n=t.prop(e<0?eo.openedBy:eo.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function _a(t){let e=t.type.prop(Fa);return e?e(t.node):t}function ja(t,e,i,n={}){let r=n.maxScanDistance||Ha,s=n.brackets||Wa,o=la(t),a=o.resolveInner(e,i);for(let t=a;t;t=t.parent){let n=qa(t.type,i,s);if(n&&t.from<t.to){let r=_a(t);if(r&&(i>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return Ka(0,0,i,t,r,n,s)}}return function(t,e,i,n,r,s,o){let a=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(a);if(l<0||l%2==0!=i>0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=s;){let s=c.value;i<0&&(t+=s.length);let a=e+t*i;for(let t=i>0?0:s.length-1,e=i>0?s.length:-1;t!=e;t+=i){let e=o.indexOf(s[t]);if(!(e<0||n.resolveInner(a+t,1).type!=r))if(e%2==0==i>0)u++;else{if(1==u)return{start:h,end:{from:a+t,to:a+t+1},matched:e>>1==l>>1};u--}}i>0&&(t+=s.length)}return c.done?{start:h,matched:!1}:null}(t,e,i,o,a.type,r,s)}function Ka(t,e,i,n,r,s,o){let a=n.parent,l={from:r.from,to:r.to},h=0,c=null==a?void 0:a.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do{if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&s.indexOf(c.type.name)>-1&&c.from<c.to){let t=_a(c);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(qa(c.type,i,o))h++;else if(qa(c.type,-i,o)){if(0==h){let t=_a(c);return{start:l,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}h--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}function $a(t,e,i,n=0,r=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let s=r;for(let r=n;r<e;r++)9==t.charCodeAt(r)?s+=i-s%i:s++;return s}class Ga{constructor(t,e,i,n){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,i=this.string.charAt(this.pos);if(e="string"==typeof t?i==t:i&&(t instanceof RegExp?t.test(i):t(i)),e)return++this.pos,i}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=$a(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!==(t=this.overrideIndent)&&void 0!==t?t:$a(this.string,null,this.tabSize)}match(t,e,i){if("string"==typeof t){let n=t=>i?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function Ua(t){if("object"!=typeof t)return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}const Ya=new WeakMap;class Ja extends oa{constructor(t){let e,i=(r=t.languageData,H.define({combine:r?t=>t.concat(r):void 0})),n={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||Ua,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||el};var r,s;super(i,new class extends Oo{createParse(t,i,n){return new Qa(e,t,i,n)}},[ba.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=ro.define({id:il.length,name:"Document",props:[ra.add((()=>t))],top:!0});return il.push(e),e}(i),e=this,this.streamParser=n,this.stateAfter=new eo({perNode:!0}),this.tokenTable=t.tokenTable?new al(n.tokenTable):ll}static define(t){return new Ja(t)}getIndent(t,e){let i,n=la(t.state),r=n.resolve(e);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let{overrideIndentation:s}=t.options;s&&(i=Ya.get(t.state),null!=i&&i<e-1e4&&(i=void 0));let o,a,l=Xa(this,n,0,r.from,null!=i?i:e);if(l?(a=l.state,o=l.pos+1):(a=this.streamParser.startState(t.unit),o=0),e-o>1e4)return null;for(;o<e;){let i=t.state.doc.lineAt(o),n=Math.min(e,i.to);if(i.length){let e=s?s(i.from):-1,r=new Ga(i.text,t.state.tabSize,t.unit,e<0?void 0:e);for(;r.pos<n-i.from;)tl(this.streamParser.token,r,a)}else this.streamParser.blankLine(a,t.unit);if(n==e)break;o=i.to+1}let h=t.lineAt(e);return s&&null==i&&Ya.set(t.state,h.from),this.streamParser.indent(a,/^\s*(.*)/.exec(h.text)[1],t)}get allowsNesting(){return!1}}function Xa(t,e,i,n,r){let s=i>=n&&i+e.length<=r&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:i+e.length};for(let s=e.children.length-1;s>=0;s--){let o=e.children[s],a=i+e.positions[s],l=o instanceof ho&&a<r&&Xa(t,o,a,n,r);if(l)return l}return null}function Za(t,e,i,n,r){if(r&&i<=0&&n>=e.length)return e;r||e.type!=t.topNode||(r=!0);for(let s=e.children.length-1;s>=0;s--){let o,a=e.positions[s],l=e.children[s];if(a<n&&l instanceof ho){if(!(o=Za(t,l,i-a,n-a,r)))break;return r?new ho(e.type,e.children.slice(0,s).concat(o),e.positions.slice(0,s+1),a+o.length):o}}return null}class Qa{constructor(t,e,i,n){this.lang=t,this.input=e,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let r=ua.get(),s=n[0].from,{state:o,tree:a}=function(t,e,i,n){for(let n of e){let e,r=n.from+(n.openStart?25:0),s=n.to-(n.openEnd?25:0),o=r<=i&&s>i&&Xa(t,n.tree,0-n.offset,i,s);if(o&&(e=Za(t,n.tree,i+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?ya(n):4),tree:ho.empty}}(t,i,s,null==r?void 0:r.state);this.state=o,this.parsedPos=this.chunkStart=s+a.length;for(let t=0;t<a.children.length;t++)this.chunks.push(a.children[t]),this.chunkPos.push(a.positions[t]);r&&this.parsedPos<r.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(ya(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let t=ua.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+2048);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=i)break;if(e=e.slice(0,n-(i-e.length)),t++,t==this.ranges.length)break;let r=this.ranges[t].from,s=this.lineAfter(r);e+=s,i=r+s.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,r=t+e;if(i>0?n>r:n>=r)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,n,r){if(this.ranges.length>1){e+=r=this.skipGapsTo(e,r,1);let t=this.chunk.length;i+=r=this.skipGapsTo(i,r,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,i,n),r}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:r}=this.lang,s=new Ga(e,t?t.state.tabSize:4,t?ya(t.state):2);if(s.eol())r.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=tl(r.token,s,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,4,n)),s.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=ho.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:nl,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new ho(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new ho(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function tl(t,e,i){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,i);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const el=Object.create(null),il=[ro.none],nl=new so(il),rl=[],sl=Object.create(null),ol=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"]])ol[t]=cl(el,e);class al{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),ol)}resolve(t){return t?this.table[t]||(this.table[t]=cl(this.extra,t)):0}}const ll=new al(el);function hl(t,e){rl.indexOf(t)>-1||(rl.push(t),console.warn(e))}function cl(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||ia[i];n?"function"==typeof n?e.length?e=e.map(n):hl(i,`Modifier ${i} used at start of tag`):e.length?hl(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:hl(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+i.map((t=>t.id)),s=sl[r];if(s)return s.id;let o=sl[r]=ro.define({id:il.length,name:n,props:[Ro({[n]:i})]});return il.push(o),o.id}function ul(t){var e,i,n=t.statementIndent,r=t.jsonld,s=t.json||r,o=t.typescript,a=t.wordCharacters||/[\w$\xa1-\uffff]/,l=function(){function t(t){return{type:t,style:"keyword"}}var e=t("keyword a"),i=t("keyword b"),n=t("keyword c"),r=t("keyword d"),s=t("operator"),o={type:"atom",style:"atom"};return{if:t("if"),while:e,with:e,else:i,do:i,try:i,finally:i,return:r,break:r,continue:r,new:t("new"),delete:n,void:n,throw:n,debugger:t("debugger"),var:t("var"),const:t("var"),let:t("var"),function:t("function"),catch:t("catch"),for:t("for"),switch:t("switch"),case:t("case"),default:t("default"),in:s,typeof:s,instanceof:s,true:o,false:o,null:o,undefined:o,NaN:o,Infinity:o,this:t("this"),class:t("class"),super:t("atom"),yield:n,export:t("export"),import:t("import"),extends:n,await:n}}(),h=/[+\-*&%=<>!?|~^@]/,c=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function u(t,n,r){return e=t,i=r,n}function d(t,e){var i,n=t.next();if('"'==n||"'"==n)return e.tokenize=(i=n,function(t,e){var n,s=!1;if(r&&"@"==t.peek()&&t.match(c))return e.tokenize=d,u("jsonld-keyword","meta");for(;null!=(n=t.next())&&(n!=i||s);)s=!s&&"\\"==n;return s||(e.tokenize=d),u("string","string")}),e.tokenize(t,e);if("."==n&&t.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return u("number","number");if("."==n&&t.match(".."))return u("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return u(n);if("="==n&&t.eat(">"))return u("=>","operator");if("0"==n&&t.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return u("number","number");if(/\d/.test(n))return t.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),u("number","number");if("/"==n)return t.eat("*")?(e.tokenize=f,f(t,e)):t.eat("/")?(t.skipToEnd(),u("comment","comment")):function(t,e,i){return e.tokenize==d&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(e.lastType)||"quasi"==e.lastType&&/\{\s*$/.test(t.string.slice(0,t.pos-1))}(t,e)?(function(t){for(var e,i=!1,n=!1;null!=(e=t.next());){if(!i){if("/"==e&&!n)return;"["==e?n=!0:n&&"]"==e&&(n=!1)}i=!i&&"\\"==e}}(t),t.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(t.eat("="),u("operator","operator",t.current()));if("`"==n)return e.tokenize=p,p(t,e);if("#"==n&&"!"==t.peek())return t.skipToEnd(),u("meta","meta");if("#"==n&&t.eatWhile(a))return u("variable","property");if("<"==n&&t.match("!--")||"-"==n&&t.match("->")&&!/\S/.test(t.string.slice(0,t.start)))return t.skipToEnd(),u("comment","comment");if(h.test(n))return">"==n&&e.lexical&&">"==e.lexical.type||(t.eat("=")?"!"!=n&&"="!=n||t.eat("="):/[<>*+\-|&?]/.test(n)&&(t.eat(n),">"==n&&t.eat(n))),"?"==n&&t.eat(".")?u("."):u("operator","operator",t.current());if(a.test(n)){t.eatWhile(a);var s=t.current();if("."!=e.lastType){if(l.propertyIsEnumerable(s)){var o=l[s];return u(o.type,o.style,s)}if("async"==s&&t.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",s)}return u("variable","variable",s)}}function f(t,e){for(var i,n=!1;i=t.next();){if("/"==i&&n){e.tokenize=d;break}n="*"==i}return u("comment","comment")}function p(t,e){for(var i,n=!1;null!=(i=t.next());){if(!n&&("`"==i||"$"==i&&t.eat("{"))){e.tokenize=d;break}n=!n&&"\\"==i}return u("quasi","string.special",t.current())}var m="([{}])";function g(t,e){e.fatArrowAt&&(e.fatArrowAt=null);var i=t.string.indexOf("=>",t.start);if(!(i<0)){if(o){var n=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(t.string.slice(t.start,i));n&&(i=n.index)}for(var r=0,s=!1,l=i-1;l>=0;--l){var h=t.string.charAt(l),c=m.indexOf(h);if(c>=0&&c<3){if(!r){++l;break}if(0==--r){"("==h&&(s=!0);break}}else if(c>=3&&c<6)++r;else if(a.test(h))s=!0;else if(/["'\/`]/.test(h))for(;;--l){if(0==l)return;if(t.string.charAt(l-1)==h&&"\\"!=t.string.charAt(l-2)){l--;break}}else if(s&&!r){++l;break}}s&&!r&&(e.fatArrowAt=l)}}var w={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function v(t,e,i,n,r,s){this.indented=t,this.column=e,this.type=i,this.prev=r,this.info=s,null!=n&&(this.align=n)}function b(t,e){for(var i=t.localVars;i;i=i.next)if(i.name==e)return!0;for(var n=t.context;n;n=n.prev)for(i=n.vars;i;i=i.next)if(i.name==e)return!0}var k={state:null,column:null,marked:null,cc:null};function y(){for(var t=arguments.length-1;t>=0;t--)k.cc.push(arguments[t])}function x(){return y.apply(null,arguments),!0}function S(t,e){for(var i=e;i;i=i.next)if(i.name==t)return!0;return!1}function A(e){var i=k.state;if(k.marked="def",i.context)if("var"==i.lexical.info&&i.context&&i.context.block){var n=M(e,i.context);if(null!=n)return void(i.context=n)}else if(!S(e,i.localVars))return void(i.localVars=new D(e,i.localVars));t.globalVars&&!S(e,i.globalVars)&&(i.globalVars=new D(e,i.globalVars))}function M(t,e){if(e){if(e.block){var i=M(t,e.prev);return i?i==e.prev?e:new T(i,e.vars,!0):null}return S(t,e.vars)?e:new T(e.prev,new D(t,e.vars),!1)}return null}function C(t){return"public"==t||"private"==t||"protected"==t||"abstract"==t||"readonly"==t}function T(t,e,i){this.prev=t,this.vars=e,this.block=i}function D(t,e){this.name=t,this.next=e}var O=new D("this",new D("arguments",null));function L(){k.state.context=new T(k.state.context,k.state.localVars,!1),k.state.localVars=O}function E(){k.state.context=new T(k.state.context,k.state.localVars,!0),k.state.localVars=null}function B(){k.state.localVars=k.state.context.vars,k.state.context=k.state.context.prev}function P(t,e){var i=function(){var i=k.state,n=i.indented;if("stat"==i.lexical.type)n=i.lexical.indented;else for(var r=i.lexical;r&&")"==r.type&&r.align;r=r.prev)n=r.indented;i.lexical=new v(n,k.stream.column(),t,null,i.lexical,e)};return i.lex=!0,i}function N(){var t=k.state;t.lexical.prev&&(")"==t.lexical.type&&(t.indented=t.lexical.indented),t.lexical=t.lexical.prev)}function R(t){return function e(i){return i==t?x():";"==t||"}"==i||")"==i||"]"==i?y():x(e)}}function z(t,e){return"var"==t?x(P("vardef",e),kt,R(";"),N):"keyword a"==t?x(P("form"),W,z,N):"keyword b"==t?x(P("form"),z,N):"keyword d"==t?k.stream.match(/^\s*$/,!1)?x():x(P("stat"),q,R(";"),N):"debugger"==t?x(R(";")):"{"==t?x(P("}"),E,rt,N,B):";"==t?x():"if"==t?("else"==k.state.lexical.info&&k.state.cc[k.state.cc.length-1]==N&&k.state.cc.pop()(),x(P("form"),W,z,N,Ct)):"function"==t?x(Lt):"for"==t?x(P("form"),E,Tt,z,B,N):"class"==t||o&&"interface"==e?(k.marked="keyword",x(P("form","class"==t?t:e),Rt,N)):"variable"==t?o&&"declare"==e?(k.marked="keyword",x(z)):o&&("module"==e||"enum"==e||"type"==e)&&k.stream.match(/^\s*\w/,!1)?(k.marked="keyword","enum"==e?x(Gt):"type"==e?x(Bt,R("operator"),ht,R(";")):x(P("form"),yt,R("{"),P("}"),rt,N,N)):o&&"namespace"==e?(k.marked="keyword",x(P("form"),V,z,N)):o&&"abstract"==e?(k.marked="keyword",x(z)):x(P("stat"),X):"switch"==t?x(P("form"),W,R("{"),P("}","switch"),E,rt,N,N,B):"case"==t?x(V,R(":")):"default"==t?x(R(":")):"catch"==t?x(P("form"),L,I,z,N,B):"export"==t?x(P("stat"),Ht,N):"import"==t?x(P("stat"),Ft,N):"async"==t?x(z):"@"==e?x(V,z):y(P("stat"),V,R(";"),N)}function I(t){if("("==t)return x(Pt,R(")"))}function V(t,e){return F(t,e,!1)}function H(t,e){return F(t,e,!0)}function W(t){return"("!=t?y():x(P(")"),q,R(")"),N)}function F(t,e,i){if(k.state.fatArrowAt==k.stream.start){var n=i?U:G;if("("==t)return x(L,P(")"),it(Pt,")"),N,R("=>"),n,B);if("variable"==t)return y(L,yt,R("=>"),n,B)}var r=i?j:_;return w.hasOwnProperty(t)?x(r):"function"==t?x(Lt,r):"class"==t||o&&"interface"==e?(k.marked="keyword",x(P("form"),Nt,N)):"keyword c"==t||"async"==t?x(i?H:V):"("==t?x(P(")"),q,R(")"),N,r):"operator"==t||"spread"==t?x(i?H:V):"["==t?x(P("]"),$t,N,r):"{"==t?nt(Q,"}",null,r):"quasi"==t?y(K,r):"new"==t?x(function(t){return function(e){return"."==e?x(t?J:Y):"variable"==e&&o?x(wt,t?j:_):y(t?H:V)}}(i)):x()}function q(t){return t.match(/[;\}\)\],]/)?y():y(V)}function _(t,e){return","==t?x(q):j(t,e,!1)}function j(t,e,i){var n=0==i?_:j,r=0==i?V:H;return"=>"==t?x(L,i?U:G,B):"operator"==t?/\+\+|--/.test(e)||o&&"!"==e?x(n):o&&"<"==e&&k.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?x(P(">"),it(ht,">"),N,n):"?"==e?x(V,R(":"),r):x(r):"quasi"==t?y(K,n):";"!=t?"("==t?nt(H,")","call",n):"."==t?x(Z,n):"["==t?x(P("]"),q,R("]"),N,n):o&&"as"==e?(k.marked="keyword",x(ht,n)):"regexp"==t?(k.state.lastType=k.marked="operator",k.stream.backUp(k.stream.pos-k.stream.start-1),x(r)):void 0:void 0}function K(t,e){return"quasi"!=t?y():"${"!=e.slice(e.length-2)?x(K):x(q,$)}function $(t){if("}"==t)return k.marked="string.special",k.state.tokenize=p,x(K)}function G(t){return g(k.stream,k.state),y("{"==t?z:V)}function U(t){return g(k.stream,k.state),y("{"==t?z:H)}function Y(t,e){if("target"==e)return k.marked="keyword",x(_)}function J(t,e){if("target"==e)return k.marked="keyword",x(j)}function X(t){return":"==t?x(N,z):y(_,R(";"),N)}function Z(t){if("variable"==t)return k.marked="property",x()}function Q(t,e){return"async"==t?(k.marked="property",x(Q)):"variable"==t||"keyword"==k.style?(k.marked="property","get"==e||"set"==e?x(tt):(o&&k.state.fatArrowAt==k.stream.start&&(i=k.stream.match(/^\s*:\s*/,!1))&&(k.state.fatArrowAt=k.stream.pos+i[0].length),x(et))):"number"==t||"string"==t?(k.marked=r?"property":k.style+" property",x(et)):"jsonld-keyword"==t?x(et):o&&C(e)?(k.marked="keyword",x(Q)):"["==t?x(V,st,R("]"),et):"spread"==t?x(H,et):"*"==e?(k.marked="keyword",x(Q)):":"==t?y(et):void 0;var i}function tt(t){return"variable"!=t?y(et):(k.marked="property",x(Lt))}function et(t){return":"==t?x(H):"("==t?y(Lt):void 0}function it(t,e,i){function n(r,s){if(i?i.indexOf(r)>-1:","==r){var o=k.state.lexical;return"call"==o.info&&(o.pos=(o.pos||0)+1),x((function(i,n){return i==e||n==e?y():y(t)}),n)}return r==e||s==e?x():i&&i.indexOf(";")>-1?y(t):x(R(e))}return function(i,r){return i==e||r==e?x():y(t,n)}}function nt(t,e,i){for(var n=3;n<arguments.length;n++)k.cc.push(arguments[n]);return x(P(e,i),it(t,e),N)}function rt(t){return"}"==t?x():y(z,rt)}function st(t,e){if(o){if(":"==t)return x(ht);if("?"==e)return x(st)}}function ot(t,e){if(o&&(":"==t||"in"==e))return x(ht)}function at(t){if(o&&":"==t)return k.stream.match(/^\s*\w+\s+is\b/,!1)?x(V,lt,ht):x(ht)}function lt(t,e){if("is"==e)return k.marked="keyword",x()}function ht(t,e){return"keyof"==e||"typeof"==e||"infer"==e||"readonly"==e?(k.marked="keyword",x("typeof"==e?H:ht)):"variable"==t||"void"==e?(k.marked="type",x(gt)):"|"==e||"&"==e?x(ht):"string"==t||"number"==t||"atom"==t?x(gt):"["==t?x(P("]"),it(ht,"]",","),N,gt):"{"==t?x(P("}"),ut,N,gt):"("==t?x(it(mt,")"),ct,gt):"<"==t?x(it(ht,">"),ht):"quasi"==t?y(ft,gt):void 0}function ct(t){if("=>"==t)return x(ht)}function ut(t){return t.match(/[\}\)\]]/)?x():","==t||";"==t?x(ut):y(dt,ut)}function dt(t,e){return"variable"==t||"keyword"==k.style?(k.marked="property",x(dt)):"?"==e||"number"==t||"string"==t?x(dt):":"==t?x(ht):"["==t?x(R("variable"),ot,R("]"),dt):"("==t?y(Et,dt):t.match(/[;\}\)\],]/)?void 0:x()}function ft(t,e){return"quasi"!=t?y():"${"!=e.slice(e.length-2)?x(ft):x(ht,pt)}function pt(t){if("}"==t)return k.marked="string.special",k.state.tokenize=p,x(ft)}function mt(t,e){return"variable"==t&&k.stream.match(/^\s*[?:]/,!1)||"?"==e?x(mt):":"==t?x(ht):"spread"==t?x(mt):y(ht)}function gt(t,e){return"<"==e?x(P(">"),it(ht,">"),N,gt):"|"==e||"."==t||"&"==e?x(ht):"["==t?x(ht,R("]"),gt):"extends"==e||"implements"==e?(k.marked="keyword",x(ht)):"?"==e?x(ht,R(":"),ht):void 0}function wt(t,e){if("<"==e)return x(P(">"),it(ht,">"),N,gt)}function vt(){return y(ht,bt)}function bt(t,e){if("="==e)return x(ht)}function kt(t,e){return"enum"==e?(k.marked="keyword",x(Gt)):y(yt,st,At,Mt)}function yt(t,e){return o&&C(e)?(k.marked="keyword",x(yt)):"variable"==t?(A(e),x()):"spread"==t?x(yt):"["==t?nt(St,"]"):"{"==t?nt(xt,"}"):void 0}function xt(t,e){return"variable"!=t||k.stream.match(/^\s*:/,!1)?("variable"==t&&(k.marked="property"),"spread"==t?x(yt):"}"==t?y():"["==t?x(V,R("]"),R(":"),xt):x(R(":"),yt,At)):(A(e),x(At))}function St(){return y(yt,At)}function At(t,e){if("="==e)return x(H)}function Mt(t){if(","==t)return x(kt)}function Ct(t,e){if("keyword b"==t&&"else"==e)return x(P("form","else"),z,N)}function Tt(t,e){return"await"==e?x(Tt):"("==t?x(P(")"),Dt,N):void 0}function Dt(t){return"var"==t?x(kt,Ot):"variable"==t?x(Ot):y(Ot)}function Ot(t,e){return")"==t?x():";"==t?x(Ot):"in"==e||"of"==e?(k.marked="keyword",x(V,Ot)):y(V,Ot)}function Lt(t,e){return"*"==e?(k.marked="keyword",x(Lt)):"variable"==t?(A(e),x(Lt)):"("==t?x(L,P(")"),it(Pt,")"),N,at,z,B):o&&"<"==e?x(P(">"),it(vt,">"),N,Lt):void 0}function Et(t,e){return"*"==e?(k.marked="keyword",x(Et)):"variable"==t?(A(e),x(Et)):"("==t?x(L,P(")"),it(Pt,")"),N,at,B):o&&"<"==e?x(P(">"),it(vt,">"),N,Et):void 0}function Bt(t,e){return"keyword"==t||"variable"==t?(k.marked="type",x(Bt)):"<"==e?x(P(">"),it(vt,">"),N):void 0}function Pt(t,e){return"@"==e&&x(V,Pt),"spread"==t?x(Pt):o&&C(e)?(k.marked="keyword",x(Pt)):o&&"this"==t?x(st,At):y(yt,st,At)}function Nt(t,e){return"variable"==t?Rt(t,e):zt(t,e)}function Rt(t,e){if("variable"==t)return A(e),x(zt)}function zt(t,e){return"<"==e?x(P(">"),it(vt,">"),N,zt):"extends"==e||"implements"==e||o&&","==t?("implements"==e&&(k.marked="keyword"),x(o?ht:V,zt)):"{"==t?x(P("}"),It,N):void 0}function It(t,e){return"async"==t||"variable"==t&&("static"==e||"get"==e||"set"==e||o&&C(e))&&k.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1)?(k.marked="keyword",x(It)):"variable"==t||"keyword"==k.style?(k.marked="property",x(Vt,It)):"number"==t||"string"==t?x(Vt,It):"["==t?x(V,st,R("]"),Vt,It):"*"==e?(k.marked="keyword",x(It)):o&&"("==t?y(Et,It):";"==t||","==t?x(It):"}"==t?x():"@"==e?x(V,It):void 0}function Vt(t,e){if("!"==e||"?"==e)return x(Vt);if(":"==t)return x(ht,At);if("="==e)return x(H);var i=k.state.lexical.prev;return y(i&&"interface"==i.info?Et:Lt)}function Ht(t,e){return"*"==e?(k.marked="keyword",x(Kt,R(";"))):"default"==e?(k.marked="keyword",x(V,R(";"))):"{"==t?x(it(Wt,"}"),Kt,R(";")):y(z)}function Wt(t,e){return"as"==e?(k.marked="keyword",x(R("variable"))):"variable"==t?y(H,Wt):void 0}function Ft(t){return"string"==t?x():"("==t?y(V):"."==t?y(_):y(qt,_t,Kt)}function qt(t,e){return"{"==t?nt(qt,"}"):("variable"==t&&A(e),"*"==e&&(k.marked="keyword"),x(jt))}function _t(t){if(","==t)return x(qt,_t)}function jt(t,e){if("as"==e)return k.marked="keyword",x(qt)}function Kt(t,e){if("from"==e)return k.marked="keyword",x(V)}function $t(t){return"]"==t?x():y(it(H,"]"))}function Gt(){return y(P("form"),yt,R("{"),P("}"),it(Ut,"}"),N,N)}function Ut(){return y(yt,At)}return L.lex=E.lex=!0,B.lex=!0,N.lex=!0,{name:t.name,startState:function(e){var i={tokenize:d,lastType:"sof",cc:[],lexical:new v(-e,0,"block",!1),localVars:t.localVars,context:t.localVars&&new T(null,null,!1),indented:0};return t.globalVars&&"object"==typeof t.globalVars&&(i.globalVars=t.globalVars),i},token:function(t,n){if(t.sol()&&(n.lexical.hasOwnProperty("align")||(n.lexical.align=!1),n.indented=t.indentation(),g(t,n)),n.tokenize!=f&&t.eatSpace())return null;var r=n.tokenize(t,n);return"comment"==e?r:(n.lastType="operator"!=e||"++"!=i&&"--"!=i?e:"incdec",function(t,e,i,n,r){var o=t.cc;for(k.state=t,k.stream=r,k.marked=null,k.cc=o,k.style=e,t.lexical.hasOwnProperty("align")||(t.lexical.align=!0);;)if((o.length?o.pop():s?V:z)(i,n)){for(;o.length&&o[o.length-1].lex;)o.pop()();return k.marked?k.marked:"variable"==i&&b(t,n)?"variableName.local":e}}(n,r,e,i,t))},indent:function(e,i,r){if(e.tokenize==f||e.tokenize==p)return null;if(e.tokenize!=d)return 0;var s,o=i&&i.charAt(0),a=e.lexical;if(!/^\s*else\b/.test(i))for(var l=e.cc.length-1;l>=0;--l){var c=e.cc[l];if(c==N)a=a.prev;else if(c!=Ct&&c!=B)break}for(;("stat"==a.type||"form"==a.type)&&("}"==o||(s=e.cc[e.cc.length-1])&&(s==_||s==j)&&!/^[,\.=+\-*:?[\(]/.test(i));)a=a.prev;n&&")"==a.type&&"stat"==a.prev.type&&(a=a.prev);var u=a.type,m=o==u;return"vardef"==u?a.indented+("operator"==e.lastType||","==e.lastType?a.info.length+1:0):"form"==u&&"{"==o?a.indented:"form"==u?a.indented+r.unit:"stat"==u?a.indented+(function(t,e){return"operator"==t.lastType||","==t.lastType||h.test(e.charAt(0))||/[,.]/.test(e.charAt(0))}(e,i)?n||r.unit:0):"switch"!=a.info||m||0==t.doubleIndentSwitch?a.align?a.column+(m?0:1):a.indented+(m?0:r.unit):a.indented+(/^(?:case|default)\b/.test(i)?r.unit:2*r.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:s?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}const dl=ul({name:"javascript"});function fl(t){var e,i,n=(t={...Nl,...t}).inline,r=t.tokenHooks,s=t.documentTypes||{},o=t.mediaTypes||{},a=t.mediaFeatures||{},l=t.mediaValueKeywords||{},h=t.propertyKeywords||{},c=t.nonStandardPropertyKeywords||{},u=t.fontProperties||{},d=t.counterDescriptors||{},f=t.colorKeywords||{},p=t.valueKeywords||{},m=t.allowNested,g=t.lineComment,w=!0===t.supportsAtComponent,v=!1!==t.highlightNonStandardPropertyKeywords;function b(t,i){return e=i,t}function k(t,e){var i=t.next();if(r[i]){var n=r[i](t,e);if(!1!==n)return n}return"@"==i?(t.eatWhile(/[\w\\\-]/),b("def",t.current())):"="==i||("~"==i||"|"==i)&&t.eat("=")?b(null,"compare"):'"'==i||"'"==i?(e.tokenize=y(i),e.tokenize(t,e)):"#"==i?(t.eatWhile(/[\w\\\-]/),b("atom","hash")):"!"==i?(t.match(/^\s*\w*/),b("keyword","important")):/\d/.test(i)||"."==i&&t.eat(/\d/)?(t.eatWhile(/[\w.%]/),b("number","unit")):"-"!==i?/[,+>*\/]/.test(i)?b(null,"select-op"):"."==i&&t.match(/^-?[_a-z][_a-z0-9-]*/i)?b("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(i)?b(null,i):t.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(t.current())&&(e.tokenize=x),b("variableName.function","variable")):/[\w\\\-]/.test(i)?(t.eatWhile(/[\w\\\-]/),b("property","word")):b(null,null):/[\d.]/.test(t.peek())?(t.eatWhile(/[\w.%]/),b("number","unit")):t.match(/^-[\w\\\-]*/)?(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?b("def","variable-definition"):b("variableName","variable")):t.match(/^\w+-/)?b("meta","meta"):void 0}function y(t){return function(e,i){for(var n,r=!1;null!=(n=e.next());){if(n==t&&!r){")"==t&&e.backUp(1);break}r=!r&&"\\"==n}return(n==t||!r&&")"!=t)&&(i.tokenize=null),b("string","string")}}function x(t,e){return t.next(),t.match(/^\s*[\"\')]/,!1)?e.tokenize=null:e.tokenize=y(")"),b(null,"(")}function S(t,e,i){this.type=t,this.indent=e,this.prev=i}function A(t,e,i,n){return t.context=new S(i,e.indentation()+(!1===n?0:e.indentUnit),t.context),i}function M(t){return t.context.prev&&(t.context=t.context.prev),t.context.type}function C(t,e,i){return O[i.context.type](t,e,i)}function T(t,e,i,n){for(var r=n||1;r>0;r--)i.context=i.context.prev;return C(t,e,i)}function D(t){var e=t.current().toLowerCase();i=p.hasOwnProperty(e)?"atom":f.hasOwnProperty(e)?"keyword":"variable"}var O={top:function(t,e,n){if("{"==t)return A(n,e,"block");if("}"==t&&n.context.prev)return M(n);if(w&&/@component/i.test(t))return A(n,e,"atComponentBlock");if(/^@(-moz-)?document$/i.test(t))return A(n,e,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(t))return A(n,e,"atBlock");if(/^@(font-face|counter-style)/i.test(t))return n.stateArg=t,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(t))return"keyframes";if(t&&"@"==t.charAt(0))return A(n,e,"at");if("hash"==t)i="builtin";else if("word"==t)i="tag";else{if("variable-definition"==t)return"maybeprop";if("interpolation"==t)return A(n,e,"interpolation");if(":"==t)return"pseudo";if(m&&"("==t)return A(n,e,"parens")}return n.context.type},block:function(t,e,n){if("word"==t){var r=e.current().toLowerCase();return h.hasOwnProperty(r)?(i="property","maybeprop"):c.hasOwnProperty(r)?(i=v?"string.special":"property","maybeprop"):m?(i=e.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(i="error","maybeprop")}return"meta"==t?"block":m||"hash"!=t&&"qualifier"!=t?O.top(t,e,n):(i="error","block")},maybeprop:function(t,e,i){return":"==t?A(i,e,"prop"):C(t,e,i)},prop:function(t,e,n){if(";"==t)return M(n);if("{"==t&&m)return A(n,e,"propBlock");if("}"==t||"{"==t)return T(t,e,n);if("("==t)return A(n,e,"parens");if("hash"!=t||/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(e.current())){if("word"==t)D(e);else if("interpolation"==t)return A(n,e,"interpolation")}else i="error";return"prop"},propBlock:function(t,e,n){return"}"==t?M(n):"word"==t?(i="property","maybeprop"):n.context.type},parens:function(t,e,i){return"{"==t||"}"==t?T(t,e,i):")"==t?M(i):"("==t?A(i,e,"parens"):"interpolation"==t?A(i,e,"interpolation"):("word"==t&&D(e),"parens")},pseudo:function(t,e,n){return"meta"==t?"pseudo":"word"==t?(i="variableName.constant",n.context.type):C(t,e,n)},documentTypes:function(t,e,n){return"word"==t&&s.hasOwnProperty(e.current())?(i="tag",n.context.type):O.atBlock(t,e,n)},atBlock:function(t,e,n){if("("==t)return A(n,e,"atBlock_parens");if("}"==t||";"==t)return T(t,e,n);if("{"==t)return M(n)&&A(n,e,m?"block":"top");if("interpolation"==t)return A(n,e,"interpolation");if("word"==t){var r=e.current().toLowerCase();i="only"==r||"not"==r||"and"==r||"or"==r?"keyword":o.hasOwnProperty(r)?"attribute":a.hasOwnProperty(r)?"property":l.hasOwnProperty(r)?"keyword":h.hasOwnProperty(r)?"property":c.hasOwnProperty(r)?v?"string.special":"property":p.hasOwnProperty(r)?"atom":f.hasOwnProperty(r)?"keyword":"error"}return n.context.type},atComponentBlock:function(t,e,n){return"}"==t?T(t,e,n):"{"==t?M(n)&&A(n,e,m?"block":"top",!1):("word"==t&&(i="error"),n.context.type)},atBlock_parens:function(t,e,i){return")"==t?M(i):"{"==t||"}"==t?T(t,e,i,2):O.atBlock(t,e,i)},restricted_atBlock_before:function(t,e,n){return"{"==t?A(n,e,"restricted_atBlock"):"word"==t&&"@counter-style"==n.stateArg?(i="variable","restricted_atBlock_before"):C(t,e,n)},restricted_atBlock:function(t,e,n){return"}"==t?(n.stateArg=null,M(n)):"word"==t?(i="@font-face"==n.stateArg&&!u.hasOwnProperty(e.current().toLowerCase())||"@counter-style"==n.stateArg&&!d.hasOwnProperty(e.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},keyframes:function(t,e,n){return"word"==t?(i="variable","keyframes"):"{"==t?A(n,e,"top"):C(t,e,n)},at:function(t,e,n){return";"==t?M(n):"{"==t||"}"==t?T(t,e,n):("word"==t?i="tag":"hash"==t&&(i="builtin"),"at")},interpolation:function(t,e,n){return"}"==t?M(n):"{"==t||";"==t?T(t,e,n):("word"==t?i="variable":"variable"!=t&&"("!=t&&")"!=t&&(i="error"),"interpolation")}};return{name:t.name,startState:function(){return{tokenize:null,state:n?"block":"top",stateArg:null,context:new S(n?"block":"top",0,null)}},token:function(t,n){if(!n.tokenize&&t.eatSpace())return null;var r=(n.tokenize||k)(t,n);return r&&"object"==typeof r&&(e=r[1],r=r[0]),i=r,"comment"!=e&&(n.state=O[n.state](e,t,n)),i},indent:function(t,e,i){var n=t.context,r=e&&e.charAt(0),s=n.indent;return"prop"!=n.type||"}"!=r&&")"!=r||(n=n.prev),n.prev&&("}"!=r||"block"!=n.type&&"top"!=n.type&&"interpolation"!=n.type&&"restricted_atBlock"!=n.type?(")"!=r||"parens"!=n.type&&"atBlock_parens"!=n.type)&&("{"!=r||"at"!=n.type&&"atBlock"!=n.type)||(s=Math.max(0,n.indent-i.unit)):s=(n=n.prev).indent),s},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:g,block:{open:"/*",close:"*/"}},autocomplete:Pl}}}function pl(t){for(var e={},i=0;i<t.length;++i)e[t[i].toLowerCase()]=!0;return e}ul({name:"json",json:!0}),ul({name:"json",jsonld:!0}),ul({name:"typescript",typescript:!0});var ml=["domain","regexp","url","url-prefix"],gl=pl(ml),wl=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],vl=pl(wl),bl=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover","prefers-color-scheme","dynamic-range","video-dynamic-range"],kl=pl(bl),yl=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],xl=pl(yl),Sl=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","all","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","binding","bleed","block-size","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-content","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","inset","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-height-step","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotate","rotation","rotation-point","row-gap","ruby-align","ruby-overhang","ruby-position","ruby-span","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-type","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-orientation","text-outline","text-overflow","text-rendering","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","touch-action","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","paint-order","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],Al=pl(Sl),Ml=["accent-color","aspect-ratio","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","content-visibility","margin-block","margin-block-end","margin-block-start","margin-inline","margin-inline-end","margin-inline-start","overflow-anchor","overscroll-behavior","padding-block","padding-block-end","padding-block-start","padding-inline","padding-inline-end","padding-inline-start","scroll-snap-stop","scrollbar-3d-light-color","scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-track-color","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","shape-inside","zoom"],Cl=pl(Ml),Tl=pl(["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"]),Dl=pl(["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"]),Ol=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],Ll=pl(Ol),El=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","blur","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","brightness","bullets","button","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","conic-gradient","contain","content","contents","content-box","context-menu","continuous","contrast","copy","counter","counters","cover","crop","cross","crosshair","cubic-bezier","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","drop-shadow","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","grayscale","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","hue-rotate","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","manipulation","match","matrix","matrix3d","media-play-button","media-slider","media-sliderthumb","media-volume-slider","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiple_mask_images","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeating-conic-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturate","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","sepia","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],Bl=pl(El),Pl=ml.concat(wl).concat(bl).concat(yl).concat(Sl).concat(Ml).concat(Ol).concat(El);const Nl={documentTypes:gl,mediaTypes:vl,mediaFeatures:kl,mediaValueKeywords:xl,propertyKeywords:Al,nonStandardPropertyKeywords:Cl,fontProperties:Tl,counterDescriptors:Dl,colorKeywords:Ll,valueKeywords:Bl,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=zl,zl(t,e))}}},Rl=fl({name:"css"});function zl(t,e){for(var i,n=!1;null!=(i=t.next());){if(n&&"/"==i){e.tokenize=null;break}n="*"==i}return["comment","comment"]}fl({name:"scss",mediaTypes:vl,mediaFeatures:kl,mediaValueKeywords:xl,propertyKeywords:Al,nonStandardPropertyKeywords:Cl,colorKeywords:Ll,valueKeywords:Bl,fontProperties:Tl,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=zl,zl(t,e)):["operator","operator"]},":":function(t){return!!t.match(/^\s*\{/,!1)&&[null,null]},$:function(t){return t.match(/^[\w-]+/),t.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName.special","variable"]},"#":function(t){return!!t.eat("{")&&[null,"interpolation"]}}}),fl({name:"less",mediaTypes:vl,mediaFeatures:kl,mediaValueKeywords:xl,propertyKeywords:Al,nonStandardPropertyKeywords:Cl,colorKeywords:Ll,valueKeywords:Bl,fontProperties:Tl,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=zl,zl(t,e)):["operator","operator"]},"@":function(t){return t.eat("{")?[null,"interpolation"]:!t.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)&&(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName","variable"])},"&":function(){return["atom","atom"]}}}),fl({name:"gss",documentTypes:gl,mediaTypes:vl,mediaFeatures:kl,propertyKeywords:Al,nonStandardPropertyKeywords:Cl,fontProperties:Tl,counterDescriptors:Dl,colorKeywords:Ll,valueKeywords:Bl,supportsAtComponent:!0,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=zl,zl(t,e))}}});const Il=ia,Vl=new class{get permittedHtmlTags(){return{b:!0,bdi:!0,del:!0,i:!0,ins:!0,u:!0,font:!0,big:!0,small:!0,sub:!0,sup:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,cite:!0,code:!0,em:!0,s:!0,strike:!0,strong:!0,tt:!0,var:!0,div:!0,center:!0,blockquote:!0,q:!0,ol:!0,ul:!0,dl:!0,table:!0,caption:!0,pre:!0,ruby:!0,rb:!0,rp:!0,rt:!0,rtc:!0,p:!0,span:!0,abbr:!0,dfn:!0,kbd:!0,samp:!0,data:!0,time:!0,mark:!0,br:!0,wbr:!0,hr:!0,li:!0,dt:!0,dd:!0,td:!0,th:!0,tr:!0,noinclude:!0,includeonly:!0,onlyinclude:!0}}get implicitlyClosedHtmlTags(){return{br:!0,hr:!0,wbr:!0}}get tags(){return{apostrophes:"character",apostrophesBold:"strong",apostrophesItalic:"emphasis",comment:"comment",doubleUnderscore:"controlKeyword",extLink:"url",extLinkBracket:"modifier",extLinkProtocol:"namespace",extLinkText:"labelName",hr:"contentSeparator",htmlTagAttribute:"attributeName",htmlTagBracket:"angleBracket",htmlTagName:"tagName",extTagAttribute:"attributeName",extTagBracket:"angleBracket",extTagName:"tagName",indenting:"operatorKeyword",linkBracket:"squareBracket",linkDelimiter:"operator",linkText:"string",linkToSection:"className",list:"list",parserFunction:"unit",parserFunctionBracket:"paren",parserFunctionDelimiter:"punctuation",parserFunctionName:"keyword",sectionHeader:"heading",sectionHeader1:"heading1",sectionHeader2:"heading2",sectionHeader3:"heading3",sectionHeader4:"heading4",sectionHeader5:"heading5",sectionHeader6:"heading6",signature:"quote",tableBracket:"null",tableDefinition:"definitionOperator",tableDelimiter:"typeOperator",template:"attributeValue",templateArgumentName:"definitionKeyword",templateBracket:"bracket",templateDelimiter:"separator",templateName:"moduleKeyword",templateVariable:"atom",templateVariableBracket:"brace",templateVariableName:"variableName",section:"mw-section",em:"mw-em",error:"mw-error",extTag:"mw-exttag",extGround:"mw-ext-ground",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",link:"mw-link",linkGround:"mw-link-ground",linkPageName:"mw-link-pagename",mnemonic:"mw-mnemonic",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateGround:"mw-template-ground",templateExtGround:"mw-template-ext-ground",templateLinkGround:"mw-template-link-ground",templateVariableDelimiter:"mw-templatevariable-delimiter",template2ExtGround:"mw-template2-ext-ground",template2Ground:"mw-template2-ground",template3ExtGround:"mw-template3-ext-ground",template3Ground:"mw-template3-ground",pre:"mw-tag-pre",nowiki:"mw-tag-nowiki"}}get tokenTable(){return{[this.tags.section]:Bo.define(),[this.tags.em]:Bo.define(),[this.tags.error]:Bo.define(),[this.tags.extTag]:Bo.define(),[this.tags.extGround]:Bo.define(),[this.tags.freeExtLink]:Bo.define(),[this.tags.freeExtLinkProtocol]:Bo.define(),[this.tags.link]:Bo.define(),[this.tags.linkGround]:Bo.define(),[this.tags.linkPageName]:Bo.define(),[this.tags.mnemonic]:Bo.define(),[this.tags.pageName]:Bo.define(),[this.tags.skipFormatting]:Bo.define(),[this.tags.strong]:Bo.define(),[this.tags.tableCaption]:Bo.define(),[this.tags.templateGround]:Bo.define(),[this.tags.templateExtGround]:Bo.define(),[this.tags.templateLinkGround]:Bo.define(),[this.tags.templateVariableDelimiter]:Bo.define(),[this.tags.template2ExtGround]:Bo.define(),[this.tags.template2Ground]:Bo.define(),[this.tags.template3ExtGround]:Bo.define(),[this.tags.template3Ground]:Bo.define(),[this.tags.pre]:Bo.define(),[this.tags.nowiki]:Bo.define()}}getHighlightStyle(t){return Ea.define([{tag:Il[this.tags.apostrophes],class:"cm-mw-apostrophes"},{tag:Il[this.tags.apostrophesBold],class:"cm-mw-apostrophes-bold"},{tag:Il[this.tags.apostrophesItalic],class:"cm-mw-apostrophes-italic"},{tag:Il[this.tags.comment],class:"cm-mw-comment"},{tag:Il[this.tags.doubleUnderscore],class:"cm-mw-double-underscore"},{tag:Il[this.tags.extLink],class:"cm-mw-extlink"},{tag:Il[this.tags.extLinkBracket],class:"cm-mw-extlink-bracket"},{tag:Il[this.tags.extLinkProtocol],class:"cm-mw-extlink-protocol"},{tag:Il[this.tags.extLinkText],class:"cm-mw-extlink-text"},{tag:Il[this.tags.hr],class:"cm-mw-hr"},{tag:Il[this.tags.htmlTagAttribute],class:"cm-mw-htmltag-attribute"},{tag:Il[this.tags.htmlTagBracket],class:"cm-mw-htmltag-bracket"},{tag:Il[this.tags.htmlTagName],class:"cm-mw-htmltag-name"},{tag:Il[this.tags.extTagAttribute],class:"cm-mw-exttag-attribute"},{tag:Il[this.tags.extTagBracket],class:"cm-mw-exttag-bracket"},{tag:Il[this.tags.extTagName],class:"cm-mw-exttag-name"},{tag:Il[this.tags.indenting],class:"cm-mw-indenting"},{tag:Il[this.tags.linkBracket],class:"cm-mw-link-bracket"},{tag:Il[this.tags.linkDelimiter],class:"cm-mw-link-delimiter"},{tag:Il[this.tags.linkText],class:"cm-mw-link-text"},{tag:Il[this.tags.linkToSection],class:"cm-mw-link-tosection"},{tag:Il[this.tags.list],class:"cm-mw-list"},{tag:Il[this.tags.parserFunction],class:"cm-mw-parserfunction"},{tag:Il[this.tags.parserFunctionBracket],class:"cm-mw-parserfunction-bracket"},{tag:Il[this.tags.parserFunctionDelimiter],class:"cm-mw-parserfunction-delimiter"},{tag:Il[this.tags.parserFunctionName],class:"cm-mw-parserfunction-name"},{tag:Il[this.tags.sectionHeader],class:"cm-mw-section-header"},{tag:Il[this.tags.sectionHeader1],class:"cm-mw-section-1"},{tag:Il[this.tags.sectionHeader2],class:"cm-mw-section-2"},{tag:Il[this.tags.sectionHeader3],class:"cm-mw-section-3"},{tag:Il[this.tags.sectionHeader4],class:"cm-mw-section-4"},{tag:Il[this.tags.sectionHeader5],class:"cm-mw-section-5"},{tag:Il[this.tags.sectionHeader6],class:"cm-mw-section-6"},{tag:Il[this.tags.signature],class:"cm-mw-signature"},{tag:Il[this.tags.tableBracket],class:"cm-mw-table-bracket"},{tag:Il[this.tags.tableDefinition],class:"cm-mw-table-definition"},{tag:Il[this.tags.tableDelimiter],class:"cm-mw-table-delimiter"},{tag:Il[this.tags.template],class:"cm-mw-template"},{tag:Il[this.tags.templateArgumentName],class:"cm-mw-template-argument-name"},{tag:Il[this.tags.templateBracket],class:"cm-mw-template-bracket"},{tag:Il[this.tags.templateDelimiter],class:"cm-mw-template-delimiter"},{tag:Il[this.tags.templateName],class:"cm-mw-pagename cm-mw-template-name"},{tag:Il[this.tags.templateVariable],class:"cm-mw-templatevariable"},{tag:Il[this.tags.templateVariableBracket],class:"cm-mw-templatevariable-bracket"},{tag:Il[this.tags.templateVariableName],class:"cm-mw-templatevariable-name"},{tag:t.tokenTable[this.tags.section],class:"cm-mw-section"},{tag:t.tokenTable[this.tags.em],class:"cm-mw-em"},{tag:t.tokenTable[this.tags.error],class:"cm-mw-error"},{tag:t.tokenTable[this.tags.extTag],class:"cm-mw-exttag"},{tag:t.tokenTable[this.tags.extGround],class:"cm-mw-ext-ground"},{tag:t.tokenTable[this.tags.freeExtLink],class:"cm-mw-free-extlink"},{tag:t.tokenTable[this.tags.freeExtLinkProtocol],class:"cm-mw-free-extlink-protocol"},{tag:t.tokenTable[this.tags.linkGround],class:"cm-mw-link-ground"},{tag:t.tokenTable[this.tags.linkPageName],class:"cm-mw-link-pagename"},{tag:t.tokenTable[this.tags.mnemonic],class:"cm-mw-mnemonic"},{tag:t.tokenTable[this.tags.pageName],class:"cm-mw-pagename"},{tag:t.tokenTable[this.tags.skipFormatting],class:"cm-mw-skipformatting"},{tag:t.tokenTable[this.tags.strong],class:"cm-mw-strong"},{tag:t.tokenTable[this.tags.tableCaption],class:"cm-mw-table-caption"},{tag:t.tokenTable[this.tags.templateGround],class:"cm-mw-template-ground"},{tag:t.tokenTable[this.tags.templateExtGround],class:"cm-mw-template-ext-ground"},{tag:t.tokenTable[this.tags.templateLinkGround],class:"cm-mw-template-link-ground"},{tag:t.tokenTable[this.tags.templateVariableDelimiter],class:"cm-mw-templatevariable-delimiter"},{tag:t.tokenTable[this.tags.template2ExtGround],class:"cm-mw-template2-ext-ground"},{tag:t.tokenTable[this.tags.template2Ground],class:"cm-mw-template2-ground"},{tag:t.tokenTable[this.tags.template3ExtGround],class:"cm-mw-template3-ext-ground"},{tag:t.tokenTable[this.tags.template3Ground],class:"cm-mw-template3-ground"},{tag:t.tokenTable[this.tags.pre],class:"cm-mw-tag-pre"},{tag:t.tokenTable[this.tags.nowiki],class:"cm-mw-tag-nowiki"}])}},Hl=t=>{const e={};for(const[i,n]of Object.entries(t))Object.assign(e,{[i]:Array.isArray(n)?[...n]:n});return e};class Wl{constructor(t){this.config=t,this.urlProtocols=new RegExp(`^(?:${t.urlProtocols})`,"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.tokens=[],this.oldTokens=[]}eatMnemonic(t,e,i){let n;return n=t.eat("#")?t.eat("x")?t.eatWhile(/[a-f\d]/i)&&t.eat(";"):t.eatWhile(/\d/)&&t.eat(";"):t.eatWhile(/[\w.\-:]/)&&t.eat(";"),n?i+=` ${Vl.tags.mnemonic}`:e}makeStyle(t,e,i){return this.isBold&&(t+=` ${Vl.tags.strong}`),this.isItalic&&(t+=` ${Vl.tags.em}`),this.makeLocalStyle(t,e,i)}makeLocalStyle(t,e,i){let n="";switch(e.nTemplate){case 0:break;case 1:n+="-template";break;case 2:n+="-template2";break;default:n+="-template3"}switch(e.nExt){case 0:break;case 1:n+="-ext";break;case 2:n+="-ext2";break;default:n+="-ext3"}return e.nLink>0&&(n+="-link"),""!==n&&(t=`mw${n}-ground ${t}`),i&&e[i]--,t.trim()}eatBlock(t,e,i=!0){return(n,r)=>(n.skipTo(e)?(i&&n.match(e),r.tokenize=r.stack.pop()):n.skipToEnd(),this.makeLocalStyle(t,r))}eatEnd(t){return(e,i)=>(e.skipToEnd(),i.tokenize=i.stack.pop(),this.makeLocalStyle(t,i))}eatChar(t,e){return(i,n)=>(n.tokenize=n.stack.pop(),i.eat(t)?this.makeLocalStyle(e,n):this.makeLocalStyle(Vl.tags.error,n))}eatSectionHeader(t){return(e,i)=>e.match(/^[^&<[{~]+/)?(e.eol()?(e.backUp(t),i.tokenize=this.eatEnd(Vl.tags.sectionHeader)):e.match(/^<!--(?!.*?-->.*?=)/,!1)&&(e.backUp(t),i.tokenize=this.eatBlock(Vl.tags.sectionHeader,"\x3c!--",!1)),Vl.tags.section):this.eatWikiText(Vl.tags.section,"")(e,i)}inVariable(t,e){return t.match(/^[^{}|]+/)?this.makeLocalStyle(Vl.tags.templateVariableName,e):t.eat("|")?(e.tokenize=this.inVariableDefault.bind(this),this.makeLocalStyle(Vl.tags.templateVariableDelimiter,e)):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.templateVariableBracket,e)):t.match("{{{")?(e.stack.push(e.tokenize),this.makeLocalStyle(Vl.tags.templateVariableBracket,e)):(t.next(),this.makeLocalStyle(Vl.tags.templateVariableName,e))}inVariableDefault(t,e){return t.match(/^[^{}[<&~]+/)?this.makeLocalStyle(Vl.tags.templateVariable,e):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.templateVariableBracket,e)):this.eatWikiText(Vl.tags.templateVariable,"")(t,e)}inParserFunctionName(t,e){return t.match(/^[^:}{~]+/)?this.makeLocalStyle(Vl.tags.parserFunctionName,e):t.eat(":")?(e.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(Vl.tags.parserFunctionDelimiter,e)):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(Vl.tags.parserFunction,"")(t,e)}inParserFunctionArguments(t,e){return t.match(/^[^|}{[<&~]+/)?this.makeLocalStyle(Vl.tags.parserFunction,e):t.eat("|")?this.makeLocalStyle(Vl.tags.parserFunctionDelimiter,e):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(Vl.tags.parserFunction,"")(t,e)}eatTemplatePageName(t){return(e,i)=>e.match(/^\s*\|\s*/)?(i.tokenize=this.eatTemplateArgument(!0),this.makeLocalStyle(Vl.tags.templateDelimiter,i)):e.match(/^\s*\}\}/)?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.templateBracket,i,"nTemplate")):e.match(/^\s*<!--.*?-->/)?this.makeLocalStyle(Vl.tags.comment,i):t&&e.sol()?(i.nTemplate--,i.tokenize=i.stack.pop(),""):e.match(/^\s*[^\s|}<{&~]+/)?(i.tokenize=this.eatTemplatePageName(!0),this.makeLocalStyle(Vl.tags.templateName,i)):e.eatSpace()?(e.eol(),this.makeLocalStyle(Vl.tags.templateName,i)):this.eatWikiText(Vl.tags.templateName,`${Vl.tags.templateName}-mnemonic`)(e,i)}eatTemplateArgument(t){return(e,i)=>t&&e.eatWhile(/[^=|}{[<&~]/)?e.eat("=")?(i.tokenize=this.eatTemplateArgument(!1),this.makeLocalStyle(Vl.tags.templateArgumentName,i)):this.makeLocalStyle(Vl.tags.template,i):e.eatWhile(/[^|}{[<&~]/)?this.makeLocalStyle(Vl.tags.template,i):e.eat("|")?(i.tokenize=this.eatTemplateArgument(!0),this.makeLocalStyle(Vl.tags.templateDelimiter,i)):e.match("}}")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.templateBracket,i,"nTemplate")):this.eatWikiText(Vl.tags.template,"")(e,i)}eatExternalLinkProtocol(t){return(e,i)=>{for(;t>0;)t--,e.next();return e.eol()?(i.nLink--,i.tokenize=i.stack.pop()):i.tokenize=this.inExternalLink.bind(this),this.makeLocalStyle(Vl.tags.extLinkProtocol,i)}}inExternalLink(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.match(/^\s*\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.extLinkBracket,e,"nLink")):t.eatSpace()?(e.tokenize=this.inExternalLinkText.bind(this),this.makeStyle("",e)):t.match(/^[^\s\]{&~']+/)||t.eatSpace()?("'"===t.peek()&&(t.match("''",!1)?e.tokenize=this.inExternalLinkText.bind(this):t.next()),this.makeStyle(Vl.tags.extLink,e)):this.eatWikiText(Vl.tags.extLink,"")(t,e)}inExternalLinkText(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.eat("]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.extLinkBracket,e,"nLink")):t.match(/^[^'\]{&~<]+/)?this.makeStyle(Vl.tags.extLinkText,e):this.eatWikiText(Vl.tags.extLinkText,"")(t,e)}inLink(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.match(/^\s*#\s*/)?(e.tokenize=this.inLinkToSection.bind(this),this.makeLocalStyle(Vl.tags.link,e)):t.match(/^\s*\|\s*/)?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(Vl.tags.linkDelimiter,e)):t.match(/^\s*\]\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.linkBracket,e,"nLink")):t.match(/^\s*[^\s#|\]&~{]+/)||t.eatSpace()?this.makeStyle(`${Vl.tags.linkPageName} ${Vl.tags.pageName}`,e):this.eatWikiText(`${Vl.tags.linkPageName} ${Vl.tags.pageName}`,Vl.tags.pageName)(t,e)}inLinkToSection(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.match(/^[^|\]&~{}]+/)?this.makeLocalStyle(Vl.tags.linkToSection,e):t.eat("|")?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(Vl.tags.linkDelimiter,e)):t.match("]]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.linkBracket,e,"nLink")):this.eatWikiText(Vl.tags.linkToSection,"")(t,e)}eatLinkText(){let t,e;return(i,n)=>{let r;return i.match("]]")?(n.tokenize=n.stack.pop(),this.makeLocalStyle(Vl.tags.linkBracket,n,"nLink")):i.match("'''")?(t=!t,this.makeLocalStyle(`${Vl.tags.linkText} ${Vl.tags.apostrophes}`,n)):i.match("''")?(e=!e,this.makeLocalStyle(`${Vl.tags.linkText} ${Vl.tags.apostrophes}`,n)):(r=Vl.tags.linkText,t&&(r+=` ${Vl.tags.strong}`),e&&(r+=` ${Vl.tags.em}`),i.match(/^[^'\]{&~<]+/)?this.makeStyle(r,n):this.eatWikiText(r,"")(i,n))}}eatTagName(t,e,i){return(n,r)=>{let s="";for(;t>0;)t--,s+=n.next();return n.eatSpace(),i?(e&&!Vl.implicitlyClosedHtmlTags[s]?r.tokenize=this.eatChar(">",Vl.tags.htmlTagBracket):r.tokenize=this.eatHtmlTagAttribute(s),this.makeLocalStyle(Vl.tags.htmlTagName,r)):(r.tokenize=e?this.eatChar(">",Vl.tags.extTagBracket):this.eatExtTagAttribute(s),this.makeLocalStyle(Vl.tags.extTagName,r))}}eatHtmlTagAttribute(t){return(e,i)=>e.match(/^(?:"[^<">]*"|'[^<'>]*'|[^>/<{&~])+/)?this.makeLocalStyle(Vl.tags.htmlTagAttribute,i):e.eat(">")?(t in Vl.implicitlyClosedHtmlTags||i.inHtmlTag.push(t),i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.htmlTagBracket,i)):e.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.htmlTagBracket,i)):this.eatWikiText(Vl.tags.htmlTagAttribute,"")(e,i)}eatExtTagAttribute(t){return(e,i)=>e.match(/^(?:"[^">]*"|'[^'>]*'|[^>/<{&~])+/)?this.makeLocalStyle(Vl.tags.extTagAttribute,i):e.eat(">")?(i.extName=t,t in this.config.tagModes&&(i.extMode=this[this.config.tagModes[t]],i.extState=i.extMode.startState(0)),i.tokenize=this.eatExtTagArea(t),this.makeLocalStyle(Vl.tags.extTagBracket,i)):e.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Vl.tags.extTagBracket,i)):this.eatWikiText(Vl.tags.extTagAttribute,"")(e,i)}eatExtTagArea(t){return(e,i)=>{const n=e.pos,r=new RegExp(`</${t}\\s*>`,"i").exec(n?e.string.slice(n):e.string);let s,o=!1;if(r){if(0===r.index)return i.tokenize=this.eatExtCloseTag(t),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(e,i);s=r.index+n,o=e.string,e.string=o.slice(0,s)}return i.stack.push(i.tokenize),i.tokenize=this.eatExtTokens(o),i.tokenize(e,i)}}eatExtCloseTag(t){return(e,i)=>(e.next(),e.next(),i.tokenize=this.eatTagName(t.length,!0,!1),this.makeLocalStyle(Vl.tags.extTagBracket,i))}eatExtTokens(t){return(e,i)=>{let n;return!1===i.extMode?(n=Vl.tags.extTag,e.skipToEnd()):(n=Vl.tags[i.extName],n+=` ${i.extMode.token(e,i.extState)}`),e.eol()&&(!1!==t&&(e.string=t),i.tokenize=i.stack.pop()),this.makeLocalStyle(n,i)}}eatStartTable(t,e){return t.match("{|"),t.eatSpace(),e.tokenize=this.inTableDefinition.bind(this),Vl.tags.tableBracket}inTableDefinition(t,e){return t.sol()?(e.tokenize=this.inTable.bind(this),this.inTable(t,e)):this.eatWikiText(Vl.tags.tableDefinition,"")(t,e)}inTableCaption(t,e){return t.sol()&&t.match(/^\s*[|!]/,!1)?(e.tokenize=this.inTable.bind(this),this.inTable(t,e)):this.eatWikiText(Vl.tags.tableCaption,"")(t,e)}inTable(t,e){if(t.sol()){if(t.eatSpace(),t.eat("|"))return t.eat("-")?(t.eatSpace(),e.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(Vl.tags.tableDelimiter,e)):t.eat("+")?(t.eatSpace(),e.tokenize=this.inTableCaption.bind(this),this.makeLocalStyle(Vl.tags.tableDelimiter,e)):t.eat("}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.tableBracket,e)):(t.eatSpace(),e.tokenize=this.eatTableRow(!0,!1),this.makeLocalStyle(Vl.tags.tableDelimiter,e));if(t.eat("!"))return t.eatSpace(),e.tokenize=this.eatTableRow(!0,!0),this.makeLocalStyle(Vl.tags.tableDelimiter,e)}return this.eatWikiText("","")(t,e)}eatTableRow(t,e){return(i,n)=>{if(i.sol()){if(i.match(/^\s*[|!]/,!1))return n.tokenize=this.inTable.bind(this),this.inTable(i,n)}else{if(i.match(/^[^'|{[<&~!]+/))return this.makeStyle(e?Vl.tags.strong:"",n);if(i.match("||")||e&&i.match("!!")||t&&i.eat("|"))return this.isBold=!1,this.isItalic=!1,t&&(n.tokenize=this.eatTableRow(!1,e)),this.makeLocalStyle(Vl.tags.tableDelimiter,n)}const r=e?Vl.tags.strong:"";return this.eatWikiText(r,r)(i,n)}}eatFreeExternalLinkProtocol(t,e){return t.match(this.urlProtocols),e.tokenize=this.eatFreeExternalLink.bind(this),this.makeLocalStyle(Vl.tags.freeExtLinkProtocol,e)}eatFreeExternalLink(t,e){if(t.eol());else if(t.match(/^[^\s{[\]<>~).,']*/))if("~"===t.peek()){if(!t.match(/^~{3,}/,!1))return t.match(/^~*/),this.makeLocalStyle(Vl.tags.freeExtLink,e)}else if("{"===t.peek()){if(!t.match("{{",!1))return t.next(),this.makeLocalStyle(Vl.tags.freeExtLink,e)}else if("'"===t.peek()){if(!t.match("''",!1))return t.next(),this.makeLocalStyle(Vl.tags.freeExtLink,e)}else if(t.match(/^[).,]+(?=[^\s{[\]<>~).,])/))return this.makeLocalStyle(Vl.tags.freeExtLink,e);return e.tokenize=e.stack.pop(),this.makeLocalStyle(Vl.tags.freeExtLink,e)}eatWikiText(t,e){return(i,n)=>{let r,s,o,a,l,h=!1;if(i.sol()){if(!i.match("//",!1)&&i.match(this.urlProtocols))return n.stack.push(n.tokenize),n.tokenize=this.eatFreeExternalLink.bind(this),this.makeLocalStyle(Vl.tags.freeExtLinkProtocol,n);switch(r=i.next(),r){case"-":if(i.match(/^-{3,}/))return Vl.tags.hr;break;case"=":if(s=i.match(/^(={0,5})(.+?(=\1\s*)(<!--(?!.*-->.*\S).*)?)$/),s)return i.backUp(s[2].length),n.stack.push(n.tokenize),n.tokenize=this.eatSectionHeader(s[3].length),`${Vl.tags.sectionHeader} ${Vl.tags[`sectionHeader${s[1].length+1}`]}`;break;case"*":case"#":return i.match(/^[*#]*:*/),Vl.tags.list;case":":return i.match(/^:*\{\|/,!1)&&(n.stack.push(n.tokenize),n.tokenize=this.eatStartTable.bind(this)),i.match(/^:*[*#]*/),Vl.tags.indenting;case" ":if(!i.match(/^\s*:*\{\|/,!1))return Vl.tags.skipFormatting;if(i.eatSpace(),i.match(/^:+/))return n.stack.push(n.tokenize),n.tokenize=this.eatStartTable.bind(this),Vl.tags.indenting;i.eat("{");case"{":if(i.match(/^(?:\||\{\{!\}\})/))return i.eatSpace(),n.stack.push(n.tokenize),n.tokenize=this.inTableDefinition.bind(this),Vl.tags.tableBracket}}else r=i.next();switch(r){case"&":return this.makeStyle(this.eatMnemonic(i,t,e),n);case"'":if(i.match(/^'*(?='{5})/)||i.match(/^'''(?!')/,!1))break;if(i.match("''"))return this.firstSingleLetterWord||i.match("''",!1)||this.prepareItalicForCorrection(i),this.isBold=!this.isBold,this.makeLocalStyle(Vl.tags.apostrophesBold,n);if(i.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(Vl.tags.apostrophesItalic,n);break;case"[":if(i.eat("[")){if(i.eatSpace(),/[^\]|[]/.test(i.peek()||""))return n.nLink++,n.stack.push(n.tokenize),n.tokenize=this.inLink.bind(this),this.makeLocalStyle(Vl.tags.linkBracket,n)}else if(o=i.match(this.urlProtocols),o)return n.nLink++,i.backUp(o[0].length),n.stack.push(n.tokenize),n.tokenize=this.eatExternalLinkProtocol(o[0].length),this.makeLocalStyle(Vl.tags.extLinkBracket,n);break;case"{":if(i.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))/))return i.eatSpace(),n.stack.push(n.tokenize),n.tokenize=this.inVariable.bind(this),this.makeLocalStyle(Vl.tags.templateVariableBracket,n);if(i.match(/^\{(?!\{(?!\{))\s*/))return"#"===i.peek()?(n.nExt++,n.stack.push(n.tokenize),n.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(Vl.tags.parserFunctionBracket,n)):(a=i.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/),!a||(i.backUp(a[0].length),":"!==a[2]&&void 0!==a[4]&&"}}"!==a[3]||!(a[1].toLowerCase()in this.config.functionSynonyms[0])&&!(a[1]in this.config.functionSynonyms[1]))?(n.nTemplate++,n.stack.push(n.tokenize),n.tokenize=this.eatTemplatePageName(!1),this.makeLocalStyle(Vl.tags.templateBracket,n)):(n.nExt++,n.stack.push(n.tokenize),n.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(Vl.tags.parserFunctionBracket,n)));break;case"<":if(h=Boolean(i.eat("/")),l=i.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+/),i.match("!--"))return c=this.eatBlock(Vl.tags.comment,"--\x3e"),n.stack.push(n.tokenize),n.tokenize=c,c(i,n);if(l){if(l=l[0].toLowerCase(),this.config.tags&&l in this.config.tags)return h?Vl.tags.error:(i.backUp(l.length),n.stack.push(n.tokenize),n.tokenize=this.eatTagName(l.length,h,!1),this.makeLocalStyle(Vl.tags.extTagBracket,n));if(l in Vl.permittedHtmlTags)return h&&l!==n.inHtmlTag.pop()?(i.pos++,Vl.tags.error):h&&l in Vl.implicitlyClosedHtmlTags?Vl.tags.error:(i.backUp(l.length),n.stack.push(n.tokenize),n.tokenize=this.eatTagName(l.length,h||l in Vl.implicitlyClosedHtmlTags,!0),this.makeLocalStyle(Vl.tags.htmlTagBracket,n));i.backUp(l.length)}break;case"~":if(i.match(/^~{2,4}/))return Vl.tags.signature;break;case"_":for(s=1;i.eat("_");)s++;if(s>2)return i.eol()||i.backUp(2),this.makeStyle(t,n);if(2===s&&(a=i.match(/^([^\s>}[\]<{'|&:~]+?)__/),a&&a[0]))return`__${a[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${a[0]}`in this.config.doubleUnderscore[1]?Vl.tags.doubleUnderscore:(i.eol()||i.backUp(2),this.makeStyle(t,n));break;default:if(/\s/.test(r||"")&&(i.eatSpace(),i.match(this.urlProtocols,!1)&&!i.match("//")))return n.stack.push(n.tokenize),n.tokenize=this.eatFreeExternalLinkProtocol.bind(this),this.makeStyle(t,n)}var c;return i.match(/^[^\s_>}[\]<{'|&:~=]+/),this.makeStyle(t,n)}}prepareItalicForCorrection(t){const e=t.pos,i=t.string.slice(0,e-3),n=i.slice(-1),r=i.slice(-2,-1);if(" "===n){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=e}else if(" "===r)this.firstSingleLetterWord=e;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=e}this.wasBold=this.isBold,this.wasItalic=this.isItalic}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText("",""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0}),copyState:t=>{const e=Hl(t);return t.extMode&&t.extMode.copyState&&(e.extState=t.extMode.copyState(t.extState)),e},token:(t,e)=>{let i,n,r,s=null,o=[];const a=[];if(this.oldTokens.length>0)return n=this.oldTokens.shift(),t.pos=n.pos,n.style;t.sol()&&(this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);do{if(i=e.tokenize(t,e),r=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,!r)return this.oldStyle=i,i;r!==s&&(s=r,o.length>0&&(a.push(...o),o=[])),o.push({pos:t.pos,style:i,state:(e.extMode&&e.extMode.copyState||Hl)(e)})}while(!t.eol());if(this.isBold&&this.isItalic){if(this.isItalic=this.wasItalic,this.isBold=this.wasBold,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,!(a.length>0))return t.pos=o[0].pos-2,this.oldStyle||"";a[a.length-1].pos++,this.oldTokens=a}else this.oldTokens=[...a,...o];return n=this.oldTokens.shift(),t.pos=n.pos,n.style},blankLine:t=>{t.extMode&&t.extMode.blankLine&&t.extMode.blankLine(t.extState,0)},tokenTable:Vl.tokenTable}}get"text/mediawiki"(){return this.mediawiki}eatNowiki(t){return e=>e.match(/^[^&]+/)?t:(e.next(),this.eatMnemonic(e,t,t))}get"mw-tag-pre"(){return{startState:()=>({}),token:this.eatNowiki(Vl.tags.pre)}}get"mw-tag-nowiki"(){return{startState:()=>({}),token:this.eatNowiki(Vl.tags.nowiki)}}}for(const[t,e]of Object.entries(i))Object.defineProperty(Wl.prototype,t,{get:()=>e});const Fl=t=>{const e=new Wl(t).mediawiki,i=Ja.define(e),n=Ra(Vl.getHighlightStyle(e));return new va(i,n)};function ql(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let r=t(e,i);return!!r&&(n(i.update(r)),!0)}}const _l=ql(Yl,0),jl=ql(Ul,0),Kl=ql(((t,e)=>Ul(t,e,function(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),r=i.to<=n.to?n:t.doc.lineAt(i.to),s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}(e))),0);function $l(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const Gl=50;function Ul(t,e,i=e.selection.ranges){let n=i.map((t=>$l(e,t.from).block));if(!n.every((t=>t)))return null;let r=i.map(((t,i)=>function(t,{open:e,close:i},n,r){let s,o,a=t.sliceDoc(n-Gl,n),l=t.sliceDoc(r,r+Gl),h=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(l)[0].length,u=a.length-h;if(a.slice(u-e.length,u)==e&&l.slice(c,c+i.length)==i)return{open:{pos:n-h,margin:h&&1},close:{pos:r+c,margin:c&&1}};r-n<=2*Gl?s=o=t.sliceDoc(n,r):(s=t.sliceDoc(n,n+Gl),o=t.sliceDoc(r-Gl,r));let d=/^\s*/.exec(s)[0].length,f=/\s*$/.exec(o)[0].length,p=o.length-f-i.length;return s.slice(d,d+e.length)==e&&o.slice(p,p+i.length)==i?{open:{pos:n+d+e.length,margin:/\s/.test(s.charAt(d+e.length))?1:0},close:{pos:r-f-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(e,n[i],t.from,t.to)));if(2!=t&&!r.every((t=>t)))return{changes:e.changes(i.map(((t,e)=>r[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}])))};if(1!=t&&r.some((t=>t))){let t=[];for(let e,i=0;i<r.length;i++)if(e=r[i]){let r=n[i],{open:s,close:o}=e;t.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:t}}return null}function Yl(t,e,i=e.selection.ranges){let n=[],r=-1;for(let{from:t,to:s}of i){let i=n.length,o=1e9,a=$l(e,t).line;if(a){for(let i=t;i<=s;){let l=e.doc.lineAt(i);if(l.from>r&&(t==s||s>l.from)){r=l.from;let t=/^\s*/.exec(l.text)[0].length,e=t==l.length,i=l.text.slice(t,t+a.length)==a?t:-1;t<l.text.length&&t<o&&(o=t),n.push({line:l,comment:i,token:a,indent:t,empty:e,single:!1})}i=l.to+1}if(o<1e9)for(let t=i;t<n.length;t++)n[t].indent<n[t].line.text.length&&(n[t].indent=o);n.length==i+1&&(n[i].single=!0)}}if(2!=t&&n.some((t=>t.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:i,indent:r,empty:s,single:o}of n)!o&&s||t.push({from:e.from+r,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&n.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:i,token:r}of n)if(i>=0){let n=e.from+i,s=n+r.length;" "==e.text[s-e.from]&&s++,t.push({from:n,to:s})}return{changes:t}}return null}const Jl=lt.define(),Xl=lt.define(),Zl=H.define(),Ql=H.define({combine:t=>St(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}),th=$.define({create:()=>wh.empty,update(t,e){let i=e.state.facet(Ql),n=e.annotation(Jl);if(n){let r=ah.fromTransaction(e,n.selection),s=n.side,o=0==s?t.undone:t.done;return o=r?lh(o,o.length,i.minDepth,r):dh(o,e.startState.selection),new wh(0==s?n.rest:o,0==s?o:n.rest)}let r=e.annotation(Xl);if("full"!=r&&"before"!=r||(t=t.isolate()),!1===e.annotation(dt.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let s=ah.fromTransaction(e),o=e.annotation(dt.time),a=e.annotation(dt.userEvent);return s?t=t.addChanges(s,o,a,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,i.newGroupDelay)),"full"!=r&&"after"!=r||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new wh(t.done.map(ah.fromJSON),t.undone.map(ah.fromJSON))});function eh(t={}){return[th,Ql.of(t),zr.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?nh:"historyRedo"==t.inputType?rh:null;return!!i&&(t.preventDefault(),i(e))}})]}function ih(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let r=i.field(th,!1);if(!r)return!1;let s=r.pop(t,i,e);return!!s&&(n(s),!0)}}const nh=ih(0,!1),rh=ih(1,!1),sh=ih(0,!0),oh=ih(1,!0);class ah{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new ah(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new ah(t.changes&&D.fromJSON(t.changes),[],t.mapped&&T.fromJSON(t.mapped),t.startSelection&&z.fromJSON(t.startSelection),t.selectionsAfter.map(z.fromJSON))}static fromTransaction(t,e){let i=ch;for(let e of t.startState.facet(Zl)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new ah(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,ch)}static selection(t){return new ah(void 0,ch,void 0,void 0,t)}}function lh(t,e,i,n){let r=e+1>i+20?e-i-1:0,s=t.slice(r,e);return s.push(n),s}function hh(t,e){return t.length?e.length?t.concat(e):t:e}const ch=[],uh=200;function dh(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-uh));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),lh(t,t.length-1,1e9,i.setSelAfter(n)))}return[ah.selection([e])]}function fh(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function ph(t,e){if(!t.length)return t;let i=t.length,n=ch;for(;i;){let r=mh(t[i-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,i);return e[i-1]=r,e}e=r.mapped,i--,n=r.selectionsAfter}return n.length?[ah.selection(n)]:ch}function mh(t,e,i){let n=hh(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):ch,i);if(!t.changes)return ah.selection(n);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new ah(r,ut.mapEffects(t.effects,e),o,t.startSelection.map(s),n)}const gh=/^(input\.type|delete)($|\.)/;class wh{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new wh(this.done,this.undone):this}addChanges(t,e,i,n,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&!o.changes.empty&&t.changes&&(!i||gh.test(i))&&(!o.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,function(t,e){let i=[],n=!1;return t.iterChangedRanges(((t,e)=>i.push(t,e))),e.iterChangedRanges(((t,e,r,s)=>{for(let t=0;t<i.length;){let e=i[t++],o=i[t++];s>=e&&r<=o&&(n=!0)}})),n}(o.changes,t.changes))||"input.type.compose"==i)?lh(s,s.length-1,n.minDepth,new ah(t.changes.compose(o.changes),hh(t.effects,o.effects),o.mapped,o.startSelection,ch)):lh(s,s.length,n.minDepth,t),new wh(s,ch,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ch;return r.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(s=r[r.length-1],o=t,s.ranges.length==o.ranges.length&&0===s.ranges.filter(((t,e)=>t.empty!=o.ranges[e].empty)).length)?this:new wh(dh(this.done,t),this.undone,e,i);var s,o}addMapping(t){return new wh(ph(this.done,t),ph(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let r=n[n.length-1],s=r.selectionsAfter[0]||e.selection;if(i&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Jl.of({side:t,rest:fh(n),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let i=1==n.length?ch:n.slice(0,n.length-1);return r.mapped&&(i=ph(i,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Jl.of({side:t,rest:i,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}wh.empty=new wh(ch,ch);const vh=[{key:"Mod-z",run:nh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:rh,preventDefault:!0},{linux:"Ctrl-Shift-z",run:rh,preventDefault:!0},{key:"Mod-u",run:sh,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:oh,preventDefault:!0}];function bh(t,e){return z.create(t.ranges.map(e),t.mainIndex)}function kh(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function yh({state:t,dispatch:e},i){let n=bh(t.selection,i);return!n.eq(t.selection)&&(e(kh(t,n)),!0)}function xh(t,e){return z.cursor(e?t.to:t.from)}function Sh(t,e){return yh(t,(i=>i.empty?t.moveByChar(i,e):xh(i,e)))}function Ah(t){return t.textDirectionAt(t.state.selection.main.head)==zi.LTR}const Mh=t=>Sh(t,!Ah(t)),Ch=t=>Sh(t,Ah(t));function Th(t,e){return yh(t,(i=>i.empty?t.moveByGroup(i,e):xh(i,e)))}function Dh(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Oh(t,e,i){let n,r,s=la(t).resolveInner(e.head),o=i?eo.closedBy:eo.openedBy;for(let n=e.head;;){let e=i?s.childAfter(n):s.childBefore(n);if(!e)break;Dh(t,e,o)?s=e:n=i?e.to:e.from}return r=s.type.prop(o)&&(n=i?ja(t,s.from,1):ja(t,s.to,-1))&&n.matched?i?n.end.to:n.end.from:i?s.to:s.from,z.cursor(r,i?-1:1)}function Lh(t,e){return yh(t,(i=>{if(!i.empty)return xh(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}"undefined"!=typeof Intl&&Intl.Segmenter;const Eh=t=>Lh(t,!1),Bh=t=>Lh(t,!0);function Ph(t){let e,i=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0;if(i){for(let e of t.state.facet(zr.scrollMargins)){let i=e(t);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(r=Math.max(null==i?void 0:i.bottom,r))}e=t.scrollDOM.clientHeight-n-r}else e=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:i,height:Math.max(t.defaultLineHeight,e-5)}}function Nh(t,e){let i,n=Ph(t),{state:r}=t,s=bh(r.selection,(i=>i.empty?t.moveVertically(i,e,n.height):xh(i,e)));if(s.eq(r.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(r.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),a=o.top+n.marginTop,l=o.bottom-n.marginBottom;e&&e.top>a&&e.bottom<l&&(i=zr.scrollIntoView(s.main.head,{y:"start",yMargin:e.top-a}))}return t.dispatch(kh(r,s),{effects:i}),!0}const Rh=t=>Nh(t,!1),zh=t=>Nh(t,!0);function Ih(t,e,i){let n=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,i);if(r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),!i&&r.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(r=z.cursor(n.from+i))}return r}function Vh(t,e){let i=bh(t.state.selection,(t=>{let i=e(t);return z.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(t.state.selection)&&(t.dispatch(kh(t.state,i)),!0)}function Hh(t,e){return Vh(t,(i=>t.moveByChar(i,e)))}const Wh=t=>Hh(t,!Ah(t)),Fh=t=>Hh(t,Ah(t));function qh(t,e){return Vh(t,(i=>t.moveByGroup(i,e)))}function _h(t,e){return Vh(t,(i=>t.moveVertically(i,e)))}const jh=t=>_h(t,!1),Kh=t=>_h(t,!0);function $h(t,e){return Vh(t,(i=>t.moveVertically(i,e,Ph(t).height)))}const Gh=t=>$h(t,!1),Uh=t=>$h(t,!0),Yh=({state:t,dispatch:e})=>(e(kh(t,{anchor:0})),!0),Jh=({state:t,dispatch:e})=>(e(kh(t,{anchor:t.doc.length})),!0),Xh=({state:t,dispatch:e})=>(e(kh(t,{anchor:t.selection.main.anchor,head:0})),!0),Zh=({state:t,dispatch:e})=>(e(kh(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function Qh(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,r=n.changeByRange((n=>{let{from:r,to:s}=n;if(r==s){let o=e(n);o<r?(i="delete.backward",o=tc(t,o,!1)):o>r&&(i="delete.forward",o=tc(t,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=tc(t,r,!1),s=tc(t,s,!0);return r==s?{range:n}:{changes:{from:r,to:s},range:z.cursor(r,r<n.head?-1:1)}}));return!r.changes.empty&&(t.dispatch(n.update(r,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?zr.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function tc(t,e,i){if(t instanceof zr)for(let n of t.state.facet(zr.atomicRanges).map((e=>e(t))))n.between(e,e,((t,n)=>{t<e&&n>e&&(e=i?n:t)}));return e}const ec=(t,e)=>Qh(t,(i=>{let n,r,s=i.from,{state:o}=t,a=o.doc.lineAt(s);if(!e&&s>a.from&&s<a.from+200&&!/[^ \t]/.test(n=a.text.slice(0,s-a.from))){if("\t"==n[n.length-1])return s-1;let t=Wt(n,o.tabSize)%ya(o)||ya(o);for(let e=0;e<t&&" "==n[n.length-1-e];e++)s--;r=s}else r=w(a.text,s-a.from,e,e)+a.from,r==s&&a.number!=(e?o.doc.lines:1)?r+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(a.text.slice(r-a.from,s-a.from))&&(r=w(a.text,r-a.from,!1,!1)+a.from);return r})),ic=t=>ec(t,!1),nc=t=>ec(t,!0),rc=(t,e)=>Qh(t,(i=>{let n=i.head,{state:r}=t,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let t=null;;){if(n==(e?s.to:s.from)){n==i.head&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let a=w(s.text,n-s.from,e)+s.from,l=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),h=o(l);if(null!=t&&h!=t)break;" "==l&&n==i.head||(t=h),n=a}return n})),sc=t=>rc(t,!1);function oc(t){let e=[],i=-1;for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=t.doc.lineAt(n.to);if(n.empty||n.to!=s.from||(s=t.doc.lineAt(n.to-1)),i>=r.number){let t=e[e.length-1];t.to=s.to,t.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});i=s.number+1}return e}function ac(t,e,i){if(t.readOnly)return!1;let n=[],r=[];for(let e of oc(t)){if(i?e.to==t.doc.length:0==e.from)continue;let s=t.doc.lineAt(i?e.to+1:e.from-1),o=s.length+1;if(i){n.push({from:e.to,to:s.to},{from:e.from,insert:s.text+t.lineBreak});for(let i of e.ranges)r.push(z.range(Math.min(t.doc.length,i.anchor+o),Math.min(t.doc.length,i.head+o)))}else{n.push({from:s.from,to:e.from},{from:e.to,insert:t.lineBreak+s.text});for(let t of e.ranges)r.push(z.range(t.anchor-o,t.head-o))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:z.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function lc(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of oc(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const hc=cc(!1);function cc(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let r=e.changeByRange((i=>{let{from:r,to:s}=i,o=e.doc.lineAt(r),a=!t&&r==s&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=la(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e);return r&&s&&r.to<=e&&s.from>=e&&(i=r.type.prop(eo.closedBy))&&i.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}(e,r);t&&(r=s=(s<=o.to?o:e.doc.lineAt(s)).to);let l=new Aa(e,{simulateBreak:r,simulateDoubleBreak:!!a}),h=Sa(l,r);for(null==h&&(h=Wt(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));s<o.to&&/\s/.test(o.text[s-o.from]);)s++;a?({from:r,to:s}=a):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);let c=["",xa(e,h)];return a&&c.push(xa(e,l.lineIndent(o.from,-1))),{changes:{from:r,to:s,insert:n.of(c)},range:z.cursor(r+1+c[1].length)}}));return i(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function uc(t,e){let i=-1;return t.changeByRange((n=>{let r=[];for(let s=n.from;s<=n.to;){let o=t.doc.lineAt(s);o.number>i&&(n.empty||n.to>o.from)&&(e(o,r,n),i=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:z.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const dc=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>yh(t,(e=>Oh(t.state,e,!Ah(t)))),shift:t=>Vh(t,(e=>Oh(t.state,e,!Ah(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>yh(t,(e=>Oh(t.state,e,Ah(t)))),shift:t=>Vh(t,(e=>Oh(t.state,e,Ah(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>ac(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>lc(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>ac(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>lc(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=z.create([i.main]):i.main.empty||(n=z.create([z.cursor(i.main.head)])),!!n&&(e(kh(t,n)),!0)}},{key:"Mod-Enter",run:cc(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=oc(t).map((({from:e,to:i})=>z.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:z.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=bh(t.selection,(e=>{var i;for(let n=la(t).resolveStack(e.from,1);n;n=n.next){let{node:t}=n;if((t.from<e.from&&t.to>=e.to||t.to>e.to&&t.from<=e.from)&&(null===(i=t.parent)||void 0===i?void 0:i.parent))return z.range(t.to,t.from)}return e}));return e(kh(t,i)),!0},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(uc(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=Wt(n,t.tabSize),s=0,o=xa(t,Math.max(0,r-ya(t)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;i.push({from:e.from+s,to:e.from+n.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(uc(t,((e,i)=>{i.push({from:e.from,insert:t.facet(ka)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new Aa(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),r=uc(t,((e,r,s)=>{let o=Sa(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let a=/^\s*/.exec(e.text)[0],l=xa(t,o);(a!=l||s.from<e.from+a.length)&&(i[e.from]=o,r.push({from:e.from,to:e.from+a.length,insert:l}))}));return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(oc(e).map((({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i})))),n=bh(e.selection,(e=>t.moveVertically(e,!0))).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(t,e,i){let n=!1,r=bh(t.selection,(e=>{let r=ja(t,e.head,-1)||ja(t,e.head,1)||e.head>0&&ja(t,e.head-1,1)||e.head<t.doc.length&&ja(t,e.head+1,-1);if(!r||!r.end)return e;n=!0;let s=r.start.from==e.head?r.end.to:r.end.from;return i?z.range(e.anchor,s):z.cursor(s)}));return!!n&&(e(kh(t,r)),!0)}(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=$l(t.state,i.from);return n.line?_l(t):!!n.block&&Kl(t)}},{key:"Alt-A",run:jl}].concat([{key:"ArrowLeft",run:Mh,shift:Wh,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Th(t,!Ah(t)),shift:t=>qh(t,!Ah(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>yh(t,(e=>Ih(t,e,!Ah(t)))),shift:t=>Vh(t,(e=>Ih(t,e,!Ah(t)))),preventDefault:!0},{key:"ArrowRight",run:Ch,shift:Fh,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Th(t,Ah(t)),shift:t=>qh(t,Ah(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>yh(t,(e=>Ih(t,e,Ah(t)))),shift:t=>Vh(t,(e=>Ih(t,e,Ah(t)))),preventDefault:!0},{key:"ArrowUp",run:Eh,shift:jh,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Yh,shift:Xh},{mac:"Ctrl-ArrowUp",run:Rh,shift:Gh},{key:"ArrowDown",run:Bh,shift:Kh,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Jh,shift:Zh},{mac:"Ctrl-ArrowDown",run:zh,shift:Uh},{key:"PageUp",run:Rh,shift:Gh},{key:"PageDown",run:zh,shift:Uh},{key:"Home",run:t=>yh(t,(e=>Ih(t,e,!1))),shift:t=>Vh(t,(e=>Ih(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:Yh,shift:Xh},{key:"End",run:t=>yh(t,(e=>Ih(t,e,!0))),shift:t=>Vh(t,(e=>Ih(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:Jh,shift:Zh},{key:"Enter",run:hc},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:ic,shift:ic},{key:"Delete",run:nc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:sc},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>rc(t,!0)},{mac:"Mod-Backspace",run:t=>Qh(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=>Qh(t,(e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}))}].concat([{key:"Ctrl-b",run:Mh,shift:Wh,preventDefault:!0},{key:"Ctrl-f",run:Ch,shift:Fh},{key:"Ctrl-p",run:Eh,shift:jh},{key:"Ctrl-n",run:Bh,shift:Kh},{key:"Ctrl-a",run:t=>yh(t,(e=>z.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>Vh(t,(e=>z.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>yh(t,(e=>z.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>Vh(t,(e=>z.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:nc},{key:"Ctrl-h",run:ic},{key:"Ctrl-k",run:t=>Qh(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:sc},{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:n.of(["",""])},range:z.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,n=t.doc.lineAt(i),r=i==n.from?i-1:w(n.text,i-n.from,!1)+n.from,s=i==n.to?i+1:w(n.text,i-n.from,!0)+n.from;return{changes:{from:r,to:s,insert:t.doc.slice(i,s).append(t.doc.slice(r,i))},range:z.cursor(s)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:zh}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));function fc(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var r=i[n];"string"==typeof r?t.setAttribute(n,r):null!=r&&(t[n]=r)}e++}for(;e<arguments.length;e++)pc(t,arguments[e]);return t}function pc(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var i=0;i<e.length;i++)pc(t,e[i])}}const mc="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class gc{constructor(t,e,i=0,n=t.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=r?t=>r(mc(t)):mc,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return x(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=S(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=A(t);let n=this.normalize(e);for(let t=0,r=i;;t++){let s=n.charCodeAt(t),o=this.match(s,r);if(t==n.length-1){if(o)return this.value=o,this;break}r==i&&t<e.length&&e.charCodeAt(t)==s&&r++}}}match(t,e){let i=null;for(let n=0;n<this.matches.length;n+=2){let r=this.matches[n],s=!1;this.query.charCodeAt(r)==t&&(r==this.query.length-1?i={from:this.matches[n+1],to:e+1}:(this.matches[n]++,s=!0)),s||(this.matches.splice(n,2),n-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?i={from:e,to:e+1}:this.matches.push(1,e)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"undefined"!=typeof Symbol&&(gc.prototype[Symbol.iterator]=function(){return this});const wc={from:-1,to:-1,match:/.*/.exec("")},vc="gm"+(null==/x/.unicode?"":"u");class bc{constructor(t,e,i,n=0,r=t.length){if(this.text=t,this.to=r,this.curLine="",this.done=!1,this.value=wc,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new xc(t,e,i,n,r);this.re=new RegExp(e,vc+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=t.iter();let s=t.lineAt(n);this.curLineStart=s.from,this.matchPos=Sc(t,n),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=Sc(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}const kc=new WeakMap;class yc{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=kc.get(t);if(!n||n.from>=i||n.to<=e){let n=new yc(e,t.sliceString(e,i));return kc.set(t,n),n}if(n.from==e&&n.to==i)return n;let{text:r,from:s}=n;return s>e&&(r=t.sliceString(e,s)+r,s=e),n.to<i&&(r+=t.sliceString(n.to,i)),kc.set(t,new yc(s,r)),new yc(e,r.slice(e-s,i-s))}}class xc{constructor(t,e,i,n,r){this.text=t,this.to=r,this.done=!1,this.value=wc,this.matchPos=Sc(t,n),this.re=new RegExp(e,vc+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=yc.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,match:e},this.matchPos=Sc(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=yc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Sc(t,e){if(e>=t.length)return e;let i,n=t.lineAt(e);for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}function Ac(t){let e=fc("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,r=n.doc.lineAt(n.selection.main.head),[,s,o,a,l]=i,h=a?+a.slice(1):0,c=o?+o:r.number;if(o&&l){let t=c/100;s&&(t=t*("-"==s?-1:1)+r.number/n.doc.lines),c=Math.round(n.doc.lines*t)}else o&&s&&(c=c*("-"==s?-1:1)+r.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,c))),d=z.cursor(u.from+Math.max(0,Math.min(h,u.length)));t.dispatch({effects:[Mc.of(!1),zr.scrollIntoView(d.from,{y:"center"})],selection:d}),t.focus()}return{dom:fc("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:Mc.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},fc("label",t.state.phrase("Go to line"),": ",e)," ",fc("button",{class:"cm-button",type:"submit"},t.state.phrase("go")))}}"undefined"!=typeof Symbol&&(bc.prototype[Symbol.iterator]=xc.prototype[Symbol.iterator]=function(){return this});const Mc=ut.define(),Cc=$.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(Mc)&&(t=i.value);return t},provide:t=>Es.from(t,(t=>t?Ac:null))}),Tc=zr.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Dc=H.define({combine:t=>St(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new nu(t),scrollToMatch:t=>zr.scrollIntoView(t)})});class Oc{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,vc),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new zc(this):new Bc(this)}getCursor(t,e=0,i){let n=t.doc?t:xt.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?Pc(this,n,e,i):Ec(this,n,e,i)}}class Lc{constructor(t){this.spec=t}}function Ec(t,e,i,n){return new gc(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?function(t,e){return(i,n,r,s)=>((s>i||s+r.length<n)&&(s=Math.max(0,i-2),r=t.sliceString(s,Math.min(t.length,n+2))),!(e(Nc(r,i-s))==bt.Word&&e(Rc(r,i-s))==bt.Word||e(Rc(r,n-s))==bt.Word&&e(Nc(r,n-s))==bt.Word))}(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}class Bc extends Lc{constructor(t){super(t)}nextMatch(t,e,i){let n=Ec(this.spec,t,i,t.doc.length).nextOverlapping();return n.done&&(n=Ec(this.spec,t,0,e).nextOverlapping()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let i=Math.max(e,n-1e4-this.spec.unquoted.length),r=Ec(this.spec,t,i,n),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(i==e)return null;n-=1e4}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=Ec(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let r=Ec(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function Pc(t,e,i,n){return new bc(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(r=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(r(Nc(i.input,i.index))!=bt.Word||r(Rc(i.input,i.index))!=bt.Word)&&(r(Rc(i.input,i.index+i[0].length))!=bt.Word||r(Nc(i.input,i.index+i[0].length))!=bt.Word)):void 0},i,n);var r}function Nc(t,e){return t.slice(w(t,e,!1),e)}function Rc(t,e){return t.slice(e,w(t,e))}class zc extends Lc{nextMatch(t,e,i){let n=Pc(this.spec,t,i,t.doc.length).next();return n.done&&(n=Pc(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let r=Math.max(e,i-1e4*n),s=Pc(this.spec,t,r,i),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==e||o.from>r+10))return o;if(r==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,((e,i)=>"$"==i?"$":"&"==i?t.match[0]:"0"!=i&&+i<t.match.length?t.match[i]:e)))}matchAll(t,e){let i=Pc(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let r=Pc(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}const Ic=ut.define(),Vc=ut.define(),Hc=$.define({create:t=>new Wc(Xc(t).create(),null),update(t,e){for(let i of e.effects)i.is(Ic)?t=new Wc(i.value.create(),t.panel):i.is(Vc)&&(t=new Wc(t.query,i.value?Jc:null));return t},provide:t=>Es.from(t,(t=>t.panel))});class Wc{constructor(t,e){this.query=t,this.panel=e}}const Fc=Qe.mark({class:"cm-searchMatch"}),qc=Qe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),_c=Si.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Hc))}update(t){let e=t.state.field(Hc);(e!=t.startState.field(Hc)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Qe.none;let{view:i}=this,n=new Ot;for(let e=0,r=i.visibleRanges,s=r.length;e<s;e++){let{from:o,to:a}=r[e];for(;e<s-1&&a>r[e+1].from-500;)a=r[++e].to;t.highlight(i.state,o,a,((t,e)=>{let r=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));n.add(t,e,r?qc:Fc)}))}return n.finish()}},{decorations:t=>t.decorations});function jc(t){return e=>{let i=e.state.field(Hc,!1);return i&&i.query.spec.valid?t(e,i):tu(e)}}const Kc=jc(((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let r=z.single(n.from,n.to),s=t.state.facet(Dc);return t.dispatch({selection:r,effects:[au(t,n),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),Qc(t),!0})),$c=jc(((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,r=e.prevMatch(i,n,n);if(!r)return!1;let s=z.single(r.from,r.to),o=t.state.facet(Dc);return t.dispatch({selection:s,effects:[au(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),Qc(t),!0})),Gc=jc(((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length||(t.dispatch({selection:z.create(i.map((t=>z.range(t.from,t.to)))),userEvent:"select.search.matches"}),0))})),Uc=jc(((t,{query:e})=>{let{state:i}=t,{from:n,to:r}=i.selection.main;if(i.readOnly)return!1;let s=e.nextMatch(i,n,n);if(!s)return!1;let o,a,l=[],h=[];if(s.from==n&&s.to==r&&(a=i.toText(e.getReplacement(s)),l.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(i,s.from,s.to),h.push(zr.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),s){let e=0==l.length||l[0].from>=s.to?0:s.to-s.from-a.length;o=z.single(s.from-e,s.to-e),h.push(au(t,s)),h.push(i.facet(Dc).scrollToMatch(o.main,t))}return t.dispatch({changes:l,selection:o,effects:h,userEvent:"input.replace"}),!0})),Yc=jc(((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map((t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}}));if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:zr.announce.of(n),userEvent:"input.replace.all"}),!0}));function Jc(t){return t.state.facet(Dc).createPanel(t)}function Xc(t,e){var i,n,r,s,o;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let h=t.facet(Dc);return new Oc({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:h.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==e?void 0:e.caseSensitive)&&void 0!==n?n:h.caseSensitive,literal:null!==(r=null==e?void 0:e.literal)&&void 0!==r?r:h.literal,regexp:null!==(s=null==e?void 0:e.regexp)&&void 0!==s?s:h.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:h.wholeWord})}function Zc(t){let e=Ts(t,Jc);return e&&e.dom.querySelector("[main-field]")}function Qc(t){let e=Zc(t);e&&e==t.root.activeElement&&e.select()}const tu=t=>{let e=t.state.field(Hc,!1);if(e&&e.panel){let i=Zc(t);if(i&&i!=t.root.activeElement){let n=Xc(t.state,e.query.spec);n.valid&&t.dispatch({effects:Ic.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[Vc.of(!0),e?Ic.of(Xc(t.state,e.query.spec)):ut.appendConfig.of(hu)]});return!0},eu=t=>{let e=t.state.field(Hc,!1);if(!e||!e.panel)return!1;let i=Ts(t,Jc);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Vc.of(!1)}),!0},iu=[{key:"Mod-f",run:tu,scope:"editor search-panel"},{key:"F3",run:Kc,shift:$c,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Kc,shift:$c,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:eu,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],o=0;for(let e=new gc(t.doc,t.sliceDoc(n,r));!e.next().done;){if(s.length>1e3)return!1;e.value.from==n&&(o=s.length),s.push(z.range(e.value.from,e.value.to))}return e(t.update({selection:z.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:t=>{let e=Ts(t,Ac);if(!e){let i=[Mc.of(!0)];null==t.state.field(Cc,!1)&&i.push(ut.appendConfig.of([Cc,Tc])),t.dispatch({effects:i}),e=Ts(t,Ac)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:i}=t,n=z.create(i.ranges.map((e=>t.wordAt(e.head)||z.cursor(e.head))),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)})({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=n)))return!1;let r=function(t,e){let{main:i,ranges:n}=t.selection,r=t.wordAt(i.head),s=r&&r.from==i.from&&r.to==i.to;for(let i=!1,r=new gc(t.doc,e,n[n.length-1].to);;){if(r.next(),!r.done){if(i&&n.some((t=>t.from==r.value.from)))continue;if(s){let e=t.wordAt(r.value.from);if(!e||e.from!=r.value.from||e.to!=r.value.to)continue}return r.value}if(i)return null;r=new gc(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(t,n);return!!r&&(e(t.update({selection:t.selection.addRange(z.range(r.from,r.to),!1),effects:zr.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class nu{constructor(t){this.view=t;let e=this.query=t.state.field(Hc).query.spec;function i(t,e,i){return fc("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=fc("input",{value:e.search,placeholder:ru(t,"Find"),"aria-label":ru(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=fc("input",{value:e.replace,placeholder:ru(t,"Replace"),"aria-label":ru(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=fc("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=fc("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=fc("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=fc("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>Kc(t)),[ru(t,"next")]),i("prev",(()=>$c(t)),[ru(t,"previous")]),i("select",(()=>Gc(t)),[ru(t,"all")]),fc("label",null,[this.caseField,ru(t,"match case")]),fc("label",null,[this.reField,ru(t,"regexp")]),fc("label",null,[this.wordField,ru(t,"by word")]),...t.state.readOnly?[]:[fc("br"),this.replaceField,i("replace",(()=>Uc(t)),[ru(t,"replace")]),i("replaceAll",(()=>Yc(t)),[ru(t,"replace all")])],fc("button",{name:"close",onclick:()=>eu(t),"aria-label":ru(t,"close"),type:"button"},["×"])])}commit(){let t=new Oc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Ic.of(t)}))}keydown(t){var e,i;i=t,Yr($r((e=this.view).state),i,e,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?$c:Kc)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),Uc(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(Ic)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Dc).top}}function ru(t,e){return t.state.phrase(e)}const su=30,ou=/[\s\.,:;?!]/;function au(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),r=t.state.doc.lineAt(i).to,s=Math.max(n.from,e-su),o=Math.min(r,i+su),a=t.state.sliceDoc(s,o);if(s!=n.from)for(let t=0;t<su;t++)if(!ou.test(a[t+1])&&ou.test(a[t])){a=a.slice(t);break}if(o!=r)for(let t=a.length-1;t>a.length-su;t--)if(!ou.test(a[t-1])&&ou.test(a[t])){a=a.slice(0,t);break}return zr.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const lu=zr.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),hu=[Hc,U.low(_c),lu];class cu{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class uu{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=t,r=i.facet(Mu).markerFilter;r&&(n=r(n));let s=Qe.set(n.map((t=>t.from==t.to||t.from==t.to-1&&i.doc.lineAt(t.from).to==t.from?Qe.widget({widget:new Du(t),diagnostic:t}).range(t.from):Qe.mark({attributes:{class:"cm-lintRange cm-lintRange-"+t.severity+(t.markClass?" "+t.markClass:"")},diagnostic:t}).range(t.from,t.to))),!0);return new uu(s,e,du(s))}}function du(t,e=null,i=0){let n=null;return t.between(i,1e9,((t,i,{spec:r})=>{if(!e||r.diagnostic==e)return n=new cu(t,i,r.diagnostic),!1})),n}function fu(t,e){let i=t.startState.doc.lineAt(e.pos);return!(!t.effects.some((t=>t.is(mu)))&&!t.changes.touchesRange(i.from,i.to))}function pu(t,e){return t.field(vu,!1)?e:e.concat(ut.appendConfig.of(qu))}const mu=ut.define(),gu=ut.define(),wu=ut.define(),vu=$.define({create:()=>new uu(Qe.none,null,null),update(t,e){if(e.docChanged){let i=t.diagnostics.map(e.changes),n=null;if(t.selected){let r=e.changes.mapPos(t.selected.from,1);n=du(i,t.selected.diagnostic,r)||du(i,null,r)}t=new uu(i,t.panel,n)}for(let i of e.effects)i.is(mu)?t=uu.init(i.value,t.panel,e.state):i.is(gu)?t=new uu(t.diagnostics,i.value?Lu.open:null,t.selected):i.is(wu)&&(t=new uu(t.diagnostics,t.panel,i.value));return t},provide:t=>[Es.from(t,(t=>t.panel)),zr.decorations.from(t,(t=>t.diagnostics))]}),bu=Qe.mark({class:"cm-lintRange cm-lintRange-active"});function ku(t,e,i){let{diagnostics:n}=t.state.field(vu),r=[],s=2e8,o=0;n.between(e-(i<0?1:0),e+(i>0?1:0),((t,n,{spec:a})=>{e>=t&&e<=n&&(t==n||(e>t||i>0)&&(e<n||i<0))&&(r.push(a.diagnostic),s=Math.min(t,s),o=Math.max(n,o))}));let a=t.state.facet(Mu).tooltipFilter;return a&&(r=a(r)),r.length?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create:()=>({dom:yu(t,r)})}:null}function yu(t,e){return fc("ul",{class:"cm-tooltip-lint"},e.map((e=>Tu(t,e,!1))))}const xu=t=>{let e=t.state.field(vu,!1);return!(!e||!e.panel||(t.dispatch({effects:gu.of(!1)}),0))},Su=[{key:"Mod-Shift-m",run:t=>{let e=t.state.field(vu,!1);e&&e.panel||t.dispatch({effects:pu(t.state,[gu.of(!0)])});let i=Ts(t,Lu.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(vu,!1);if(!e)return!1;let i=t.state.selection.main,n=e.diagnostics.iter(i.to+1);return!(!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==i.from&&n.to==i.to)||(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),0))}}],Au=Si.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(Mu);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:t}=this.view,{sources:e}=t.facet(Mu);Promise.all(e.map((t=>Promise.resolve(t(this.view))))).then((e=>{let i=e.reduce(((t,e)=>t.concat(e)));this.view.state.doc==t.doc&&this.view.dispatch(function(t,e){return{effects:pu(t,[mu.of(e)])}}(this.view.state,i))}),(t=>{bi(this.view.state,t)}))}}update(t){let e=t.state.facet(Mu);(t.docChanged||e!=t.startState.facet(Mu)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),Mu=H.define({combine:t=>Object.assign({sources:t.map((t=>t.source))},St(t.map((t=>t.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(t,e)=>t?e?i=>t(i)||e(i):t:e}))});function Cu(t){let e=[];if(t)t:for(let{name:i}of t){for(let t=0;t<i.length;t++){let n=i[t];if(/[a-zA-Z]/.test(n)&&!e.some((t=>t.toLowerCase()==n.toLowerCase()))){e.push(n);continue t}}e.push("")}return e}function Tu(t,e,i){var n;let r=i?Cu(e.actions):[];return fc("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},fc("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),null===(n=e.actions)||void 0===n?void 0:n.map(((i,n)=>{let s=!1,o=n=>{if(n.preventDefault(),s)return;s=!0;let r=du(t.state.field(vu).diagnostics,e);r&&i.apply(t,r.from,r.to)},{name:a}=i,l=r[n]?a.indexOf(r[n]):-1,h=l<0?a:[a.slice(0,l),fc("u",a.slice(l,l+1)),a.slice(l+1)];return fc("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${a}${l<0?"":` (access key "${r[n]})"`}.`},h)})),e.source&&fc("div",{class:"cm-diagnosticSource"},e.source))}class Du extends Xe{constructor(t){super(),this.diagnostic=t}eq(t){return t.diagnostic==this.diagnostic}toDOM(){return fc("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class Ou{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Tu(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Lu{constructor(t){this.view=t,this.items=[],this.list=fc("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e=>{if(27==e.keyCode)xu(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],n=Cu(i.actions);for(let r=0;r<n.length;r++)if(n[r].toUpperCase().charCodeAt(0)==e.keyCode){let e=du(this.view.state.field(vu).diagnostics,i);e&&i.actions[r].apply(t,e.from,e.to)}}}e.preventDefault()},onclick:t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)}}),this.dom=fc("div",{class:"cm-panel-lint"},this.list,fc("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>xu(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(vu).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(vu),i=0,n=!1,r=null;for(t.between(0,this.view.state.doc.length,((t,s,{spec:o})=>{let a,l=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==o.diagnostic){l=t;break}l<0?(a=new Ou(this.view,o.diagnostic),this.items.splice(i,0,a),n=!0):(a=this.items[l],l>i&&(this.items.splice(i,l-i),n=!0)),e&&a.diagnostic==e.diagnostic?a.dom.hasAttribute("aria-selected")||(a.dom.setAttribute("aria-selected","true"),r=a):a.dom.hasAttribute("aria-selected")&&a.dom.removeAttribute("aria-selected"),i++}));i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();0==this.items.length&&(this.items.push(new Ou(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let i=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/i:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;t!=i.dom;)e();t=i.dom.nextSibling}else this.list.insertBefore(i.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=du(this.view.state.field(vu).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:wu.of(e)})}static open(t){return new Lu(t)}}function Eu(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Bu(t){return Eu(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Pu=zr.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Bu("#d11")},".cm-lintRange-warning":{backgroundImage:Bu("orange")},".cm-lintRange-info":{backgroundImage:Bu("#999")},".cm-lintRange-hint":{backgroundImage:Bu("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Nu(t){return"error"==t?4:"warning"==t?3:"info"==t?2:1}class Ru extends Bs{constructor(t){super(),this.diagnostics=t,this.severity=t.reduce(((t,e)=>Nu(t)<Nu(e.severity)?e.severity:t),"hint")}toDOM(t){let e=document.createElement("div");e.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=t.state.facet(_u).tooltipFilter;return n&&(i=n(i)),i.length&&(e.onmouseover=()=>function(t,e,i){function n(){let n=t.elementAtHeight(e.getBoundingClientRect().top+5-t.documentTop);t.coordsAtPos(n.from)&&t.dispatch({effects:Hu.of({pos:n.from,above:!1,create:()=>({dom:yu(t,i),getCoords:()=>e.getBoundingClientRect()})})}),e.onmouseout=e.onmousemove=null,function(t,e){let i=n=>{let r=e.getBoundingClientRect();if(!(n.clientX>r.left-10&&n.clientX<r.right+10&&n.clientY>r.top-10&&n.clientY<r.bottom+10)){for(let t=n.target;t;t=t.parentNode)if(1==t.nodeType&&t.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",i),t.state.field(Wu)&&t.dispatch({effects:Hu.of(null)})}};window.addEventListener("mousemove",i)}(t,e)}let{hoverTime:r}=t.state.facet(_u),s=setTimeout(n,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(n,r)}}(t,e,i)),e}}function zu(t,e){let i=Object.create(null);for(let n of e){let e=t.lineAt(n.from);(i[e.from]||(i[e.from]=[])).push(n)}let n=[];for(let t in i)n.push(new Ru(i[t]).range(+t));return Dt.of(n,!0)}const Iu=zs({class:"cm-gutter-lint",markers:t=>t.state.field(Vu)}),Vu=$.define({create:()=>Dt.empty,update(t,e){t=t.map(e.changes);let i=e.state.facet(_u).markerFilter;for(let n of e.effects)if(n.is(mu)){let r=n.value;i&&(r=i(r||[])),t=zu(e.state.doc,r.slice(0))}return t}}),Hu=ut.define(),Wu=$.define({create:()=>null,update:(t,e)=>(t&&e.docChanged&&(t=fu(e,t)?null:Object.assign(Object.assign({},t),{pos:e.changes.mapPos(t.pos)})),e.effects.reduce(((t,e)=>e.is(Hu)?e.value:t),t)),provide:t=>vs.from(t)}),Fu=zr.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Eu('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Eu('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Eu('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),qu=[vu,zr.decorations.compute([vu],(t=>{let{selected:e,panel:i}=t.field(vu);return e&&i&&e.from!=e.to?Qe.set([bu.range(e.from,e.to)]):Qe.none})),As(ku,{hideOn:fu}),Pu],_u=H.define({combine:t=>St(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})});function ju(t={}){return[_u.of(t),Vu,Iu,Fu,Wu]}const Ku=Ra(Va),$u={plain:()=>[],javascript:()=>new va(Ja.define(dl),Ku),css:()=>new va(Ja.define(Rl),Ku),mediawiki:Fl,html:t=>Fl({...t,tags:{...t.tags,script:!0,style:!0},tagModes:{...t.tagModes,script:"javascript",style:"css"}})},Gu={};class Uu{constructor(t,e="plain",i){this.textarea=t;const{offsetHeight:n}=t;this.language=new J,this.linter=new J,this.lintGutter=new J;const r=[this.language.of($u[e](i)),this.linter.of([]),this.lintGutter.of([]),zr.contentAttributes.of({accesskey:t.accessKey,dir:t.dir,lang:t.lang}),Js(),zr.lineWrapping,eh(),rs(),hs,xt.transactionFilter.of((t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let i=t.newDoc,{head:n}=t.newSelection.main,r=i.lineAt(n);if(n>r.from+200)return t;let s=i.sliceString(r.from,n);if(!e.some((t=>t.test(s))))return t;let{state:o}=t,a=-1,l=[];for(let{head:t}of o.selection.ranges){let e=o.doc.lineAt(t);if(e.from==a)continue;a=e.from;let i=Sa(o,e.from);if(null==i)continue;let n=/^\s*/.exec(e.text)[0],r=xa(o,i);n!=r&&l.push({from:e.from,to:e.from+n.length,insert:r})}return l.length?[t,{changes:l,sequential:!0}]:t})),jr.of([...dc,...vh,...iu,...Su])];this.view=new zr({extensions:r,doc:t.value,parent:t.parentElement}),this.view.dom.style.minHeight="2em",this.view.dom.style.height=`${n}px`,this.view.requestMeasure(),t.style.display="none",t.form&&t.form.addEventListener("submit",(()=>{this.save()}))}setLanguage(t="plain",e){this.view.dispatch({effects:[this.language.reconfigure($u[t](e)),this.linter.reconfigure(t in Gu?Gu[t]:[]),this.lintGutter.reconfigure(t in Gu?ju():[])]})}lint(t){const e=this.language.get(this.view.state).language,i=e?e.name:"plain",n=t?function(t,e={}){return[Mu.of({source:t,config:e}),Au,qu]}(t):[];t?Gu[i]=n:delete Gu[i],this.view.dispatch({effects:[this.linter.reconfigure(n),this.lintGutter.reconfigure(t?ju():[])]})}update(){const t=this.linter.get(this.view.state);if(t.length>0){const e=this.view.plugin(t[1]);e.set=!0,e.force()}}save(){this.textarea.value=this.view.state.doc.toString()}}var Yu=e.a;export{Yu as CodeMirror6};