@bhsd/codemirror-mediawiki 2.0.14 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.min.js CHANGED
@@ -1,2 +1,23 @@
1
- /*! For license information please see main.min.js.LICENSE.txt */
2
- 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:()=>Wd});var i={};t.r(i),t.d(i,{css:()=>hd,javascript:()=>dd,lua:()=>xd});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 R(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 R(t),a=new R(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 R(t),o=new R(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 R{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 N{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 N(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 N(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=>N.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 N.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?N.create(e,t,48|r):N.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 K)||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 $=H.define({static:!0});class K{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 K(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($).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,$.of({field:this,create:t})]}get extension(){return this}}function U(t){return e=>new Y(e,t)}const G={highest:U(0),high:U(1),default:U(2),low:U(3),lowest:U(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 K)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 K?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 K&&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 Rt(s,a,r),h=new Rt(o,a,r);i.iterGaps(((t,e,i)=>Nt(l,t,h,e,i,n))),i.empty&&0==i.length&&Nt(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 Rt(r,o,0).goto(i),l=new Rt(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 Rt(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 Rt{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 Nt(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 Kt(t,r),n.mount(Array.isArray(e)?e:[e])}}let $t=new Map;class Kt{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=$t.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],$t.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 Ut={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:"'"},Gt={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++)Ut[48+Xt]=Ut[96+Xt]=String(Xt);for(Xt=1;Xt<=24;Xt++)Ut[Xt+111]="F"+Xt;for(Xt=65;Xt<=90;Xt++)Ut[Xt]=String.fromCharCode(Xt+32),Gt[Xt]=String.fromCharCode(Xt);for(var Zt in Ut)Gt.hasOwnProperty(Zt)||(Gt[Zt]=Ut[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,Re=!Le&&/Apple Computer/.test(Me.vendor),Ne=Re&&(/Mobile\/\w+/.test(Me.userAgent)||Me.maxTouchPoints>2);var ze={mac:Ne||/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:Ne,android:/Android\b/.test(Me.userAgent),webkit:Pe,safari:Re,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 $e=Object.create(null);function Ke(t,e,i){if(t==e)return!0;t||(t=$e),e||(e=$e);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 Ue(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 Ge(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){Ke(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&&(Ue(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))&&Ke(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&&Ke(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 Ri{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Ri(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 Ri(s+l,a+l,s,a).addToSet(i),n>h)break;r+=2}if(!a)return i;new Ri(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),s=a.toA,o=a.toB}}}class Ni{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 Ri(t,e,i,r)))),this.changedRanges=n}static create(t,e,i){return new Ni(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 $i{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 Ki(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||!Ki(n.inner,r.inner))return!1}return!0}const Ui=[];function Gi(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=Ui[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(Ui[t]==a)break t;break}t=s[e++].to}h++,u?u.push(p):(p.from>l&&o.push(new $i(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?Ui[f]!=a:Ui[f]==a))break;f++}u?Gi(t,l,f,n+1,r,u,o):l<f&&o.push(new $i(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=Ui[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(Ui[t-1]==a)break t;break}t=s[--i].from}u?u.push(p):(p.to<l&&o.push(new $i(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?Ui[f-1]!=a:Ui[f-1]==a))break;f--}u?Gi(t,f,l,n+1,r,u,o):f<l&&o.push(new $i(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),Ui[e]=4==r?2:r,7&r&&(n=r),i=r}for(let t=a,e=h,n=h;t<l;t++){let r=Ui[t];if(128==r)t<l-1&&e==Ui[t+1]&&24&e?r=Ui[t]=e:Ui[t]=256;else if(64==r){let r=t+1;for(;r<l&&64==Ui[r];)r++;let s=t&&8==e||r<i&&8==Ui[r]?1==n?1:8:256;for(let e=t;e<r;e++)Ui[e]=s;t=r-1}else 8==r&&1==n&&(Ui[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&&(Ui[o]=Ui[_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=Ui[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=Ui[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!=Ui[o])break;o++}let h=1==s,c=h==(1==(o<e?Ui[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),Ui[--e]=c;l=o}else s=o,l++}}}(r,s,n,a),Gi(t,r,s,e,i,n,o)}function Ji(t){return[new $i(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=$i.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 Ri(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 Ri(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:Ge(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 Ri(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=Ri.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 Rn=ze.ie&&ze.ie_version<=11;let Nn=null,zn=0,In=0;function Vn(t){if(!Rn)return t.detail;let e=Nn,i=In;return Nn=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,$n=["pre-wrap","normal","pre-line","break-spaces"];class Kn{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 $n.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=$n.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 Un{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Gn{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 Gn(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 Gn(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 Gn(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 Gn(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 Gn(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 Gn(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 Gn(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 Gn(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 Kn(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 Ri(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=Ri.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 Ri(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Un(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 Gn(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 Rr{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=Nr(e,t.previousSibling||t.target.previousSibling,-1),n=Nr(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 Nr(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 Rr(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=Ni.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=Ni.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=Ue(this.contentDOM,this.contentAttrs,e),n=Ue(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[$i.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||Ki(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 $i(0,0,e==Vi?1:0)];if(e==Ii&&!i.length&&!ji.test(t))return Ji(t.length);if(i.length)for(;t.length>Ui.length;)Ui[Ui.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 G.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=G.default(zr.domEventHandlers({keydown:(t,e)=>Yr(Kr(e.state),t,e,"editor")})),jr=H.define({enables:_r}),$r=new WeakMap;function Kr(t){let e=t.facet(jr),i=$r.get(e);return i||$r.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=Ur={view:e,prefix:i,scope:t};return setTimeout((()=>{Ur==n&&(Ur=null)}),Gr),!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 Ur=null;const Gr=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?Gt:Ut)[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;Ur&&Ur.view==i&&Ur.scope==n&&(o=Ur.prefix+" ",xn.indexOf(e.keyCode)<0&&(l=!0,Ur=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=Ut[e.keyCode])&&c!=r?(f(p[o+qr(c,e,!0)])||e.shiftKey&&(u=Gt[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}});let rs=null;class ss 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 os 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 as=Qe.line({class:"cm-activeLine"}),ls=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(as.range(r.from)),e=r.from)}return Qe.set(i)}},{decorations:t=>t.decorations}),hs="-10000px";class cs{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 us(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const ds=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)||us}}}),fs=new WeakMap,ps=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(ds);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 cs(t,ws,(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(ds);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=hs,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==hs&&"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(ds).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=hs;continue}let f=l.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(e=fs.get(h))&&void 0!==e?e:d.bottom-d.top,w=h.offset||gs,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=hs;continue}fs.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=hs}},{eventObservers:{scroll(){this.maybeMeasure()}}}),ms=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"}}}),gs={x:0,y:0},ws=H.define({enables:[ps,ms]}),vs=H.define();class bs{static create(t){return new bs(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new cs(t,vs,(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 ks=ws.compute([vs],(t=>{let e=t.facet(vs).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:bs.create,above:e[0].above,arrow:e.some((t=>t.arrow))}}));class ys{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(ps),e=t?t.manager.tooltips.findIndex((t=>t.create==bs.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-xs&&e.clientX<=i.right+xs&&e.clientY>=i.top-xs&&e.clientY<=i.bottom+xs}(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 xs=4;function Ss(t,e={}){let i=ut.define(),n=K.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(As)&&(t=null);return t},provide:t=>vs.from(t)});return[n,Si.define((r=>new ys(r,t,n,i,e.hoverTime||300))),ks]}const As=ut.define(),Ms=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 Cs(t,e){let i=t.plugin(Ts),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const Ts=Si.fromClass(class{constructor(t){this.input=t.state.facet(Ls),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(Ms);this.top=new Ds(t,!0,e.topContainer),this.bottom=new Ds(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(Ms);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ds(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ds(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Ls);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 Ds{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=Os(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Os(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 Os(t){let e=t.nextSibling;return t.remove(),e}const Ls=H.define({enables:Ts});class Es extends At{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Es.prototype.elementClass="",Es.prototype.toDOM=void 0,Es.prototype.mapMode=C.TrackBefore,Es.prototype.startSide=Es.prototype.endSide=-1,Es.prototype.point=!0;const Bs=H.define(),Ps={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Dt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Rs=H.define();function Ns(t){return[Is(),Rs.of(Object.assign(Object.assign({},Ps),t))]}const zs=H.define({combine:t=>t.some((t=>t))});function Is(t){let e=[Vs];return t&&!1===t.fixed&&e.push(zs.of(!0)),e}const Vs=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 qs(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(zs),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(zs)!=!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(Bs),this.view.viewport.from),n=[],r=this.gutters.map((t=>new Fs(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){Ws(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){Ws(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(Bs),t.state.facet(Bs),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 qs(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 Hs(t){return Array.isArray(t)?t:[t]}function Ws(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class Fs{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 _s(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=[];Ws(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 qs{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=Hs(e.markers(t)),e.initialSpacer&&(this.spacer=new _s(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=Hs(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 _s{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 js=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 Ks extends Es{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 Gs=Rs.compute([$s],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(js),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new Ks(Us(t,t.state.doc.lineAt(e.from).number)),widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet($s)!=t.state.facet($s),initialSpacer:t=>new Ks(Us(t,Js(t.state.doc.lines))),updateSpacer(t,e){let i=Us(e.view,Js(e.view.state.doc.lines));return i==t.number?t:new Ks(i)},domEventHandlers:t.facet($s).domEventHandlers})));function Ys(t={}){return[$s.of(t),Is(),Gs]}function Js(t){let e=9;for(;e<t;)e=10*e+9;return e}const Xs=new Map;function Zs(t){return Si.define((e=>({decorations:t.createDeco(e),update(e){this.decorations=t.updateDeco(e,this.decorations)}})),{decorations:t=>t.decorations})}const Qs=Zs(new Zr({regexp:/\t| +/g,decoration:t=>function(t){let e=Xs.get(t);return e||Xs.set(t,e=Qe.mark({attributes:"\t"===t?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":t.replace(/ /g,"·")}})),e}(t[0]),boundary:/\S/})),to=Zs(new Zr({regexp:/\s+$/g,decoration:Qe.mark({class:"cm-trailingSpace"}),boundary:/\S/})),eo=1024;let io=0;class no{constructor(t,e){this.from=t,this.to=e}}class ro{constructor(t={}){this.id=io++,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=ao.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}ro.closedBy=new ro({deserialize:t=>t.split(" ")}),ro.openedBy=new ro({deserialize:t=>t.split(" ")}),ro.group=new ro({deserialize:t=>t.split(" ")}),ro.contextHash=new ro({perNode:!0}),ro.lookAhead=new ro({perNode:!0}),ro.mounted=new ro({perNode:!0});class so{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[ro.mounted.id]}}const oo=Object.create(null);class ao{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):oo,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new ao(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(ro.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(ro.group),n=-1;n<(i?i.length:0);n++){let r=e[n<0?t.name:i[n]];if(r)return r}}}}ao.none=new ao("",Object.create(null),0,8);class lo{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 ao(i.name,n,i.id,i.flags):i)}return new lo(e)}}const ho=new WeakMap,co=new WeakMap;var uo;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(uo||(uo={}));class fo{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=so.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 Co(this.topNode,t)}cursorAt(t,e=0,i=0){let n=ho.get(this)||this.topNode,r=new Co(n);return r.moveTo(t,e),ho.set(this,r._tree),r}get topNode(){return new bo(this,0,0,null)}resolve(t,e=0){let i=wo(ho.get(this)||this.topNode,t,e,!1);return ho.set(this,i),i}resolveInner(t,e=0){let i=wo(co.get(this)||this.topNode,t,e,!0);return co.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 bo?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=so.get(t.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let o=new bo(s.tree,s.overlay[0].from+t.from,-1,t);(r||(r=[n])).push(wo(o,e,i,!1))}}return r?Ao(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&uo.IncludeAnonymous)>0;for(let t=this.cursor(s|uo.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:Lo(ao.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new fo(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new fo(ao.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:r=eo,reused:s=[],minRepeatType:o=n.types.length}=t,a=Array.isArray(i)?new po(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 mo(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 fo){if(!a&&r.type==t&&r.length==n)return r;(s=r.prop(ro.lookAhead))&&(o=i[a]+r.length+s)}return p(t,e,i,n,o)}}(C);A=Lo(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 mo(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=[ro.contextHash,h];s=s?[t].concat(s):[t]}if(r>25){let t=[ro.lookAhead,r];s=s?[t].concat(s):[t]}return new fo(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 fo(l[t.topID],g.reverse(),w.reverse(),v)}(t)}}fo.empty=new fo(ao.none,[],[],0);class po{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 po(this.buffer,this.index)}}class mo{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ao.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&&!(go(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 mo(r,s,this.set)}}function go(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 wo(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 bo&&t.index<0?null:t.parent;if(!e)return t;t=e}let s=n?0:uo.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof bo&&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 vo{cursor(t=0){return new Co(this,t)}getChild(t,e=null,i=null){let n=ko(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return ko(this,t,e,i)}resolve(t,e=0){return wo(this,t,e,!1)}resolveInner(t,e=0){return wo(this,t,e,!0)}matchContext(t){return yo(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 bo extends vo{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(go(n,i,h,h+l.length))if(l instanceof mo){if(r&uo.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-h,n);if(o>-1)return new So(new xo(s,l,t,h),null,o)}else if(r&uo.IncludeAnonymous||!l.type.isAnonymous||To(l)){let o;if(!(r&uo.IgnoreMounts)&&(o=so.get(l))&&!o.overlay)return new bo(o.tree,h,t,s);let a=new bo(l,h,t,s);return r&uo.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(r&uo.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&uo.IgnoreOverlays)&&(n=so.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 bo(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 ko(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 yo(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 xo{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class So extends vo{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 So(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&uo.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 So(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 So(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 So(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 fo(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ao(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 bo&&i.index<0?null:i.parent,r=t.slice();return n?r[e]=n:r.splice(e,1),new Mo(r,i)}class Mo{constructor(t,e){this.heads=t,this.node=e}get next(){return Ao(this.heads)}}class Co{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 bo)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 bo?(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&uo.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&uo.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&uo.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&uo.IncludeAnonymous||t instanceof mo||!t.type.isAnonymous||To(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 So(this.buffer,e,this.stack[t]);return this.bufferNode=new So(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 yo(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 yo(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 To(t){return t.children.some((t=>t instanceof mo||!t.type.isAnonymous||To(t)))}const Do=new WeakMap;function Oo(t,e){if(!t.isAnonymous||e instanceof mo||e.type!=t)return 1;let i=Do.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof fo)){i=1;break}i+=Oo(t,n)}Do.set(e,i)}return i}function Lo(t,e,i,n,r,s,o,a,l){let h=0;for(let i=n;i<r;i++)h+=Oo(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=Oo(t,i[h]);for(h++;h<o;h++){let e=Oo(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(Lo(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 Eo{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 Eo(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 Eo(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 Bo{startParse(t,e,i){return"string"==typeof t&&(t=new Po(t)),i=i?i.length?i.map((t=>new no(t.from,t.to))):[new no(0,0)]:[new no(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 Po{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 ro({perNode:!0});let Ro=0;class No{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=Ro++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new No([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new Io;return e=>e.modified.indexOf(t)>-1?e:Io.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let zo=0;class Io{constructor(){this.instances=[],this.id=zo++}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 No(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(Io.get(e,t));return r}}function Vo(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 Wo(n,r,o>0?i.slice(0,o):null);e[a]=l.sort(e[a])}}return Ho.add(e)}const Ho=new ro;class Wo{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 Fo(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 qo(t,e,i,n=0,r=t.length){let s=new _o(n,Array.isArray(e)?e:[e],i);s.highlightRange(t.cursor(),n,r,"",s.highlighters),s.flush(r)}Wo.empty=new Wo([],2,null);class _o{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(Ho);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||Wo.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(ro.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 jo=No.define,$o=jo(),Ko=jo(),Uo=jo(Ko),Go=jo(Ko),Yo=jo(),Jo=jo(Yo),Xo=jo(Yo),Zo=jo(),Qo=jo(Zo),ta=jo(),ea=jo(),ia=jo(),na=jo(ia),ra=jo(),sa={comment:$o,lineComment:jo($o),blockComment:jo($o),docComment:jo($o),name:Ko,variableName:jo(Ko),typeName:Uo,tagName:jo(Uo),propertyName:Go,attributeName:jo(Go),className:jo(Ko),labelName:jo(Ko),namespace:jo(Ko),macroName:jo(Ko),literal:Yo,string:Jo,docString:jo(Jo),character:jo(Jo),attributeValue:jo(Jo),number:Xo,integer:jo(Xo),float:jo(Xo),bool:jo(Yo),regexp:jo(Yo),escape:jo(Yo),color:jo(Yo),url:jo(Yo),keyword:ta,self:jo(ta),null:jo(ta),atom:jo(ta),unit:jo(ta),modifier:jo(ta),operatorKeyword:jo(ta),controlKeyword:jo(ta),definitionKeyword:jo(ta),moduleKeyword:jo(ta),operator:ea,derefOperator:jo(ea),arithmeticOperator:jo(ea),logicOperator:jo(ea),bitwiseOperator:jo(ea),compareOperator:jo(ea),updateOperator:jo(ea),definitionOperator:jo(ea),typeOperator:jo(ea),controlOperator:jo(ea),punctuation:ia,separator:jo(ia),bracket:na,angleBracket:jo(na),squareBracket:jo(na),paren:jo(na),brace:jo(na),content:Zo,heading:Qo,heading1:jo(Qo),heading2:jo(Qo),heading3:jo(Qo),heading4:jo(Qo),heading5:jo(Qo),heading6:jo(Qo),contentSeparator:jo(Zo),list:jo(Zo),quote:jo(Zo),emphasis:jo(Zo),strong:jo(Zo),link:jo(Zo),monospace:jo(Zo),strikethrough:jo(Zo),inserted:jo(),deleted:jo(),changed:jo(),invalid:jo(),meta:ra,documentMeta:jo(ra),annotation:jo(ra),processingInstruction:jo(ra),definition:No.defineModifier(),constant:No.defineModifier(),function:No.defineModifier(),standard:No.defineModifier(),local:No.defineModifier(),special:No.defineModifier()};var oa;Fo([{tag:sa.link,class:"tok-link"},{tag:sa.heading,class:"tok-heading"},{tag:sa.emphasis,class:"tok-emphasis"},{tag:sa.strong,class:"tok-strong"},{tag:sa.keyword,class:"tok-keyword"},{tag:sa.atom,class:"tok-atom"},{tag:sa.bool,class:"tok-bool"},{tag:sa.url,class:"tok-url"},{tag:sa.labelName,class:"tok-labelName"},{tag:sa.inserted,class:"tok-inserted"},{tag:sa.deleted,class:"tok-deleted"},{tag:sa.literal,class:"tok-literal"},{tag:sa.string,class:"tok-string"},{tag:sa.number,class:"tok-number"},{tag:[sa.regexp,sa.escape,sa.special(sa.string)],class:"tok-string2"},{tag:sa.variableName,class:"tok-variableName"},{tag:sa.local(sa.variableName),class:"tok-variableName tok-local"},{tag:sa.definition(sa.variableName),class:"tok-variableName tok-definition"},{tag:sa.special(sa.variableName),class:"tok-variableName2"},{tag:sa.definition(sa.propertyName),class:"tok-propertyName tok-definition"},{tag:sa.typeName,class:"tok-typeName"},{tag:sa.namespace,class:"tok-namespace"},{tag:sa.className,class:"tok-className"},{tag:sa.macroName,class:"tok-macroName"},{tag:sa.propertyName,class:"tok-propertyName"},{tag:sa.operator,class:"tok-operator"},{tag:sa.comment,class:"tok-comment"},{tag:sa.meta,class:"tok-meta"},{tag:sa.invalid,class:"tok-invalid"},{tag:sa.punctuation,class:"tok-punctuation"}]);const aa=new ro;const la=new ro;class ha{constructor(t,e,i=[],n=""){this.data=t,this.name=n,xt.prototype.hasOwnProperty("tree")||Object.defineProperty(xt.prototype,"tree",{get(){return ua(this)}}),this.parser=e,this.extension=[ka.of(this),xt.languageData.of(((t,e,i)=>{let n=ca(t,e,i),r=n.type.prop(aa);if(!r)return[];let s=t.facet(r),o=n.type.prop(la);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 ca(t,e,i).type.prop(aa)==this.data}findRegions(t){let e=t.facet(ka);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(aa)==this.data)return void i.push({from:e,to:e+t.length});let r=t.prop(ro.mounted);if(r){if(r.tree.prop(aa)==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 fo&&n(r,t.positions[i]+e)}};return n(ua(t),0),i}get allowsNesting(){return!0}}function ca(t,e,i){let n=t.facet(ka),r=ua(t).topNode;if(!n||n.allowsNesting)for(let t=r;t;t=t.enter(e,i,uo.ExcludeBuffers))t.type.isTop&&(r=t);return r}function ua(t){let e=t.field(ha.state,!1);return e?e.tree:fo.empty}ha.setState=ut.define();class da{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 fa=null;class pa{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 pa(t,e,[],fo.empty,0,i,[],null)}startParse(){return this.parser.startParse(new da(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=fo.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(Eo.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(Eo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=fa;fa=this;try{return t()}finally{fa=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=ma(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=Eo.applyChanges(i,e),n=fo.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 pa(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=ma(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 Bo{createParse(e,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let e=fa;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 fo(ao.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 fa}}function ma(t,e,i){return Eo.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class ga{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 ga(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=pa.create(t.facet(ka).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new ga(i)}}ha.state=K.define({create:ga.init,update(t,e){for(let t of e.effects)if(t.is(ha.setState))return t.value;return e.startState.facet(ka)!=e.state.facet(ka)?ga.init(e.state):t.apply(e)}});let wa=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(wa=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const va="undefined"!=typeof navigator&&(null===(oa=navigator.scheduling)||void 0===oa?void 0:oa.isInputPending)?()=>navigator.scheduling.isInputPending():null,ba=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(ha.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(ha.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=wa(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(ha.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!va?Math.max(25,t.timeRemaining()-5):1e9),o=r.context.treeLen<n&&i.doc.length>n+1e3,a=r.context.work((()=>va&&va()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:ha.setState.of(new ga(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()}}}),ka=H.define({combine:t=>t.length?t[0]:null,enables:t=>[ha.state,ba,zr.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});class ya{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const xa=H.define(),Sa=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 Aa(t){let e=t.facet(Sa);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Ma(t,e){let i="",n=t.tabSize,r=t.facet(Sa)[0];if("\t"==r){for(;e>=n;)i+="\t",e-=n;r=" "}for(let t=0;t<e;t++)i+=r;return i}function Ca(t,e){t instanceof xt&&(t=new Ta(t));for(let i of t.state.facet(xa)){let n=i(t,e);if(void 0!==n)return n}let i=ua(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 Oa(n,t,i)}(t,i,e):null}class Ta{constructor(t,e={}){this.state=t,this.options=e,this.unit=Aa(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 Da=new ro;function Oa(t,e,i){for(let n=t;n;n=n.next){let t=La(n.node);if(t)return t(Ba.create(e,i,n))}return 0}function La(t){let e=t.type.prop(Da);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(ro.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?Ea:null}function Ea(){return 0}class Ba extends Ta{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 Ba(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(Pa(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return Oa(this.context.next,this.base,this.pos)}}function Pa(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}class Ra{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 ha?t=>t.prop(aa)==s.data:s?t=>t==s:void 0,this.style=Fo(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 Ra(t,e||{})}}const Na=H.define(),za=H.define({combine:t=>t.length?[t[0]]:null});function Ia(t){let e=t.facet(Na);return e.length?e:t.facet(za)}function Va(t,e){let i,n=[Wa];return t instanceof Ra&&(t.module&&n.push(zr.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(za.of(t)):i?n.push(Na.computeN([zr.darkTheme],(e=>e.facet(zr.darkTheme)==("dark"==i)?[t]:[]))):n.push(Na.of(t)),n}class Ha{constructor(t){this.markCache=Object.create(null),this.tree=ua(t.state),this.decorations=this.buildDeco(t,Ia(t.state))}update(t){let e=ua(t.state),i=Ia(t.state),n=i!=Ia(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)qo(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 Wa=G.high(Si.fromClass(Ha,{decorations:t=>t.decorations})),Fa=Ra.define([{tag:sa.meta,color:"#404740"},{tag:sa.link,textDecoration:"underline"},{tag:sa.heading,textDecoration:"underline",fontWeight:"bold"},{tag:sa.emphasis,fontStyle:"italic"},{tag:sa.strong,fontWeight:"bold"},{tag:sa.strikethrough,textDecoration:"line-through"},{tag:sa.keyword,color:"#708"},{tag:[sa.atom,sa.bool,sa.url,sa.contentSeparator,sa.labelName],color:"#219"},{tag:[sa.literal,sa.inserted],color:"#164"},{tag:[sa.string,sa.deleted],color:"#a11"},{tag:[sa.regexp,sa.escape,sa.special(sa.string)],color:"#e40"},{tag:sa.definition(sa.variableName),color:"#00f"},{tag:sa.local(sa.variableName),color:"#30a"},{tag:[sa.typeName,sa.namespace],color:"#085"},{tag:sa.className,color:"#167"},{tag:[sa.special(sa.variableName),sa.macroName],color:"#256"},{tag:sa.definition(sa.propertyName),color:"#00c"},{tag:sa.comment,color:"#940"},{tag:sa.invalid,color:"#f00"}]),qa=zr.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),_a=1e4,ja="()[]{}",$a=H.define({combine:t=>St(t,{afterCursor:!0,brackets:ja,maxScanDistance:_a,renderMatch:Ga})}),Ka=Qe.mark({class:"cm-matchingBracket"}),Ua=Qe.mark({class:"cm-nonmatchingBracket"});function Ga(t){let e=[],i=t.matched?Ka:Ua;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}const Ya=K.define({create:()=>Qe.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],n=e.state.facet($a);for(let t of e.state.selection.ranges){if(!t.empty)continue;let r=tl(e.state,t.head,-1,n)||t.head>0&&tl(e.state,t.head-1,1,n)||n.afterCursor&&(tl(e.state,t.head,1,n)||t.head<e.state.doc.length&&tl(e.state,t.head+1,-1,n));r&&(i=i.concat(n.renderMatch(r,e.state)))}return Qe.set(i,!0)},provide:t=>zr.decorations.from(t)}),Ja=[Ya,qa],Xa=new ro;function Za(t,e,i){let n=t.prop(e<0?ro.openedBy:ro.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 Qa(t){let e=t.type.prop(Xa);return e?e(t.node):t}function tl(t,e,i,n={}){let r=n.maxScanDistance||_a,s=n.brackets||ja,o=ua(t),a=o.resolveInner(e,i);for(let t=a;t;t=t.parent){let n=Za(t.type,i,s);if(n&&t.from<t.to){let r=Qa(t);if(r&&(i>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return el(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 el(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=Qa(c);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(Za(c.type,i,o))h++;else if(Za(c.type,-i,o)){if(0==h){let t=Qa(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 il(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 nl{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=il(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:il(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 rl(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 sl=new WeakMap;class ol extends ha{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||rl,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||ul};var r,s;super(i,new class extends Bo{createParse(t,i,n){return new hl(e,t,i,n)}},[xa.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=ao.define({id:dl.length,name:"Document",props:[aa.add((()=>t))],top:!0});return dl.push(e),e}(i),e=this,this.streamParser=n,this.stateAfter=new ro({perNode:!0}),this.tokenTable=t.tokenTable?new wl(n.tokenTable):vl}static define(t){return new ol(t)}getIndent(t,e){let i,n=ua(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=sl.get(t.state),null!=i&&i<e-1e4&&(i=void 0));let o,a,l=al(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 nl(i.text,t.state.tabSize,t.unit,e<0?void 0:e);for(;r.pos<n-i.from;)cl(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&&sl.set(t.state,h.from),this.streamParser.indent(a,/^\s*(.*)/.exec(h.text)[1],t)}get allowsNesting(){return!1}}function al(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 fo&&a<r&&al(t,o,a,n,r);if(l)return l}return null}function ll(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 fo){if(!(o=ll(t,l,i-a,n-a,r)))break;return r?new fo(e.type,e.children.slice(0,s).concat(o),e.positions.slice(0,s+1),a+o.length):o}}return null}class hl{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=pa.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&&al(t,n.tree,0-n.offset,i,s);if(o&&(e=ll(t,n.tree,i+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?Aa(n):4),tree:fo.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(Aa(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let t=pa.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 nl(e,t?t.state.tabSize:4,t?Aa(t.state):2);if(s.eol())r.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=cl(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=fo.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:fl,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new fo(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 fo(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function cl(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 ul=Object.create(null),dl=[ao.none],fl=new lo(dl),pl=[],ml=Object.create(null),gl=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"]])gl[t]=kl(ul,e);class wl{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),gl)}resolve(t){return t?this.table[t]||(this.table[t]=kl(this.extra,t)):0}}const vl=new wl(ul);function bl(t,e){pl.indexOf(t)>-1||(pl.push(t),console.warn(e))}function kl(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||sa[i];n?"function"==typeof n?e.length?e=e.map(n):bl(i,`Modifier ${i} used at start of tag`):e.length?bl(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:bl(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=ml[r];if(s)return s.id;let o=ml[r]=ao.define({id:dl.length,name:n,props:[Vo({[n]:i})]});return dl.push(o),o.id}function yl(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 xl=yl(Dl,0),Sl=yl(Tl,0),Al=yl(((t,e)=>Tl(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 Ml(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const Cl=50;function Tl(t,e,i=e.selection.ranges){let n=i.map((t=>Ml(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-Cl,n),l=t.sliceDoc(r,r+Cl),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*Cl?s=o=t.sliceDoc(n,r):(s=t.sliceDoc(n,n+Cl),o=t.sliceDoc(r-Cl,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 Dl(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=Ml(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 Ol=lt.define(),Ll=lt.define(),El=H.define(),Bl=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)})}),Pl=K.define({create:()=>Jl.empty,update(t,e){let i=e.state.facet(Bl),n=e.annotation(Ol);if(n){let r=Wl.fromTransaction(e,n.selection),s=n.side,o=0==s?t.undone:t.done;return o=r?Fl(o,o.length,i.minDepth,r):$l(o,e.startState.selection),new Jl(0==s?n.rest:o,0==s?o:n.rest)}let r=e.annotation(Ll);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=Wl.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 Jl(t.done.map(Wl.fromJSON),t.undone.map(Wl.fromJSON))});function Rl(t={}){return[Pl,Bl.of(t),zr.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?zl:"historyRedo"==t.inputType?Il:null;return!!i&&(t.preventDefault(),i(e))}})]}function Nl(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let r=i.field(Pl,!1);if(!r)return!1;let s=r.pop(t,i,e);return!!s&&(n(s),!0)}}const zl=Nl(0,!1),Il=Nl(1,!1),Vl=Nl(0,!0),Hl=Nl(1,!0);class Wl{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 Wl(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 Wl(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=_l;for(let e of t.startState.facet(El)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new Wl(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,_l)}static selection(t){return new Wl(void 0,_l,void 0,void 0,t)}}function Fl(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 ql(t,e){return t.length?e.length?t.concat(e):t:e}const _l=[],jl=200;function $l(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-jl));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),Fl(t,t.length-1,1e9,i.setSelAfter(n)))}return[Wl.selection([e])]}function Kl(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 Ul(t,e){if(!t.length)return t;let i=t.length,n=_l;for(;i;){let r=Gl(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?[Wl.selection(n)]:_l}function Gl(t,e,i){let n=ql(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):_l,i);if(!t.changes)return Wl.selection(n);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Wl(r,ut.mapEffects(t.effects,e),o,t.startSelection.map(s),n)}const Yl=/^(input\.type|delete)($|\.)/;class Jl{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 Jl(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||Yl.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)?Fl(s,s.length-1,n.minDepth,new Wl(t.changes.compose(o.changes),ql(t.effects,o.effects),o.mapped,o.startSelection,_l)):Fl(s,s.length,n.minDepth,t),new Jl(s,_l,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:_l;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 Jl($l(this.done,t),this.undone,e,i);var s,o}addMapping(t){return new Jl(Ul(this.done,t),Ul(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:Ol.of({side:t,rest:Kl(n),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let i=1==n.length?_l:n.slice(0,n.length-1);return r.mapped&&(i=Ul(i,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Ol.of({side:t,rest:i,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Jl.empty=new Jl(_l,_l);const Xl=[{key:"Mod-z",run:zl,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Il,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Il,preventDefault:!0},{key:"Mod-u",run:Vl,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Hl,preventDefault:!0}];function Zl(t,e){return z.create(t.ranges.map(e),t.mainIndex)}function Ql(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function th({state:t,dispatch:e},i){let n=Zl(t.selection,i);return!n.eq(t.selection)&&(e(Ql(t,n)),!0)}function eh(t,e){return z.cursor(e?t.to:t.from)}function ih(t,e){return th(t,(i=>i.empty?t.moveByChar(i,e):eh(i,e)))}function nh(t){return t.textDirectionAt(t.state.selection.main.head)==zi.LTR}const rh=t=>ih(t,!nh(t)),sh=t=>ih(t,nh(t));function oh(t,e){return th(t,(i=>i.empty?t.moveByGroup(i,e):eh(i,e)))}function ah(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 lh(t,e,i){let n,r,s=ua(t).resolveInner(e.head),o=i?ro.closedBy:ro.openedBy;for(let n=e.head;;){let e=i?s.childAfter(n):s.childBefore(n);if(!e)break;ah(t,e,o)?s=e:n=i?e.to:e.from}return r=s.type.prop(o)&&(n=i?tl(t,s.from,1):tl(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 hh(t,e){return th(t,(i=>{if(!i.empty)return eh(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}"undefined"!=typeof Intl&&Intl.Segmenter;const ch=t=>hh(t,!1),uh=t=>hh(t,!0);function dh(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 fh(t,e){let i,n=dh(t),{state:r}=t,s=Zl(r.selection,(i=>i.empty?t.moveVertically(i,e,n.height):eh(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(Ql(r,s),{effects:i}),!0}const ph=t=>fh(t,!1),mh=t=>fh(t,!0);function gh(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 wh(t,e){let i=Zl(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(Ql(t.state,i)),!0)}function vh(t,e){return wh(t,(i=>t.moveByChar(i,e)))}const bh=t=>vh(t,!nh(t)),kh=t=>vh(t,nh(t));function yh(t,e){return wh(t,(i=>t.moveByGroup(i,e)))}function xh(t,e){return wh(t,(i=>t.moveVertically(i,e)))}const Sh=t=>xh(t,!1),Ah=t=>xh(t,!0);function Mh(t,e){return wh(t,(i=>t.moveVertically(i,e,dh(t).height)))}const Ch=t=>Mh(t,!1),Th=t=>Mh(t,!0),Dh=({state:t,dispatch:e})=>(e(Ql(t,{anchor:0})),!0),Oh=({state:t,dispatch:e})=>(e(Ql(t,{anchor:t.doc.length})),!0),Lh=({state:t,dispatch:e})=>(e(Ql(t,{anchor:t.selection.main.anchor,head:0})),!0),Eh=({state:t,dispatch:e})=>(e(Ql(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function Bh(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=Ph(t,o,!1)):o>r&&(i="delete.forward",o=Ph(t,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=Ph(t,r,!1),s=Ph(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 Ph(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 Rh=(t,e)=>Bh(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)%Aa(o)||Aa(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})),Nh=t=>Rh(t,!1),zh=t=>Rh(t,!0),Ih=(t,e)=>Bh(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})),Vh=t=>Ih(t,!1);function Hh(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 Wh(t,e,i){if(t.readOnly)return!1;let n=[],r=[];for(let e of Hh(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 Fh(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of Hh(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 qh=_h(!1);function _h(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=ua(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e);return r&&s&&r.to<=e&&s.from>=e&&(i=r.type.prop(ro.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 Ta(e,{simulateBreak:r,simulateDoubleBreak:!!a}),h=Ca(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=["",Ma(e,h)];return a&&c.push(Ma(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 jh(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 $h=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>th(t,(e=>lh(t.state,e,!nh(t)))),shift:t=>wh(t,(e=>lh(t.state,e,!nh(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>th(t,(e=>lh(t.state,e,nh(t)))),shift:t=>wh(t,(e=>lh(t.state,e,nh(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>Wh(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>Fh(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>Wh(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>Fh(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(Ql(t,n)),!0)}},{key:"Mod-Enter",run:_h(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=Hh(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=Zl(t.selection,(e=>{var i;for(let n=ua(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(Ql(t,i)),!0},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(jh(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=Wt(n,t.tabSize),s=0,o=Ma(t,Math.max(0,r-Aa(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(jh(t,((e,i)=>{i.push({from:e.from,insert:t.facet(Sa)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new Ta(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),r=jh(t,((e,r,s)=>{let o=Ca(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let a=/^\s*/.exec(e.text)[0],l=Ma(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(Hh(e).map((({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i})))),n=Zl(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=Zl(t.selection,(e=>{let r=tl(t,e.head,-1)||tl(t,e.head,1)||e.head>0&&tl(t,e.head-1,1)||e.head<t.doc.length&&tl(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(Ql(t,r)),!0)}(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=Ml(t.state,i.from);return n.line?xl(t):!!n.block&&Al(t)}},{key:"Alt-A",run:Sl}].concat([{key:"ArrowLeft",run:rh,shift:bh,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>oh(t,!nh(t)),shift:t=>yh(t,!nh(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>th(t,(e=>gh(t,e,!nh(t)))),shift:t=>wh(t,(e=>gh(t,e,!nh(t)))),preventDefault:!0},{key:"ArrowRight",run:sh,shift:kh,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>oh(t,nh(t)),shift:t=>yh(t,nh(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>th(t,(e=>gh(t,e,nh(t)))),shift:t=>wh(t,(e=>gh(t,e,nh(t)))),preventDefault:!0},{key:"ArrowUp",run:ch,shift:Sh,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Dh,shift:Lh},{mac:"Ctrl-ArrowUp",run:ph,shift:Ch},{key:"ArrowDown",run:uh,shift:Ah,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Oh,shift:Eh},{mac:"Ctrl-ArrowDown",run:mh,shift:Th},{key:"PageUp",run:ph,shift:Ch},{key:"PageDown",run:mh,shift:Th},{key:"Home",run:t=>th(t,(e=>gh(t,e,!1))),shift:t=>wh(t,(e=>gh(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:Dh,shift:Lh},{key:"End",run:t=>th(t,(e=>gh(t,e,!0))),shift:t=>wh(t,(e=>gh(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:Oh,shift:Eh},{key:"Enter",run:qh},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Nh,shift:Nh},{key:"Delete",run:zh},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Vh},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>Ih(t,!0)},{mac:"Mod-Backspace",run:t=>Bh(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=>Bh(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:rh,shift:bh,preventDefault:!0},{key:"Ctrl-f",run:sh,shift:kh},{key:"Ctrl-p",run:ch,shift:Sh},{key:"Ctrl-n",run:uh,shift:Ah},{key:"Ctrl-a",run:t=>th(t,(e=>z.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>wh(t,(e=>z.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>th(t,(e=>z.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>wh(t,(e=>z.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:zh},{key:"Ctrl-h",run:Nh},{key:"Ctrl-k",run:t=>Bh(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:Vh},{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:mh}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));function Kh(){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++)Uh(t,arguments[e]);return t}function Uh(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++)Uh(t,e[i])}}const Gh="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class Yh{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(Gh(t)):Gh,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&&(Yh.prototype[Symbol.iterator]=function(){return this});const Jh={from:-1,to:-1,match:/.*/.exec("")},Xh="gm"+(null==/x/.unicode?"":"u");class Zh{constructor(t,e,i,n=0,r=t.length){if(this.text=t,this.to=r,this.curLine="",this.done=!1,this.value=Jh,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new ec(t,e,i,n,r);this.re=new RegExp(e,Xh+((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=ic(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=ic(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 Qh=new WeakMap;class tc{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=Qh.get(t);if(!n||n.from>=i||n.to<=e){let n=new tc(e,t.sliceString(e,i));return Qh.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)),Qh.set(t,new tc(s,r)),new tc(e,r.slice(e-s,i-s))}}class ec{constructor(t,e,i,n,r){this.text=t,this.to=r,this.done=!1,this.value=Jh,this.matchPos=ic(t,n),this.re=new RegExp(e,Xh+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=tc.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=ic(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=tc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function ic(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 nc(t){let e=Kh("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:[rc.of(!1),zr.scrollIntoView(d.from,{y:"center"})],selection:d}),t.focus()}return{dom:Kh("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:rc.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},Kh("label",t.state.phrase("Go to line"),": ",e)," ",Kh("button",{class:"cm-button",type:"submit"},t.state.phrase("go")))}}"undefined"!=typeof Symbol&&(Zh.prototype[Symbol.iterator]=ec.prototype[Symbol.iterator]=function(){return this});const rc=ut.define(),sc=K.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(rc)&&(t=i.value);return t},provide:t=>Ls.from(t,(t=>t?nc:null))}),oc=zr.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),ac=H.define({combine:t=>St(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new zc(t),scrollToMatch:t=>zr.scrollIntoView(t)})});class lc{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,Xh),!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 mc(this):new uc(this)}getCursor(t,e=0,i){let n=t.doc?t:xt.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?dc(this,n,e,i):cc(this,n,e,i)}}class hc{constructor(t){this.spec=t}}function cc(t,e,i,n){return new Yh(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(fc(r,i-s))==bt.Word&&e(pc(r,i-s))==bt.Word||e(pc(r,n-s))==bt.Word&&e(fc(r,n-s))==bt.Word))}(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}class uc extends hc{constructor(t){super(t)}nextMatch(t,e,i){let n=cc(this.spec,t,i,t.doc.length).nextOverlapping();return n.done&&(n=cc(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=cc(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=cc(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=cc(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 dc(t,e,i,n){return new Zh(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(r=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(r(fc(i.input,i.index))!=bt.Word||r(pc(i.input,i.index))!=bt.Word)&&(r(pc(i.input,i.index+i[0].length))!=bt.Word||r(fc(i.input,i.index+i[0].length))!=bt.Word)):void 0},i,n);var r}function fc(t,e){return t.slice(w(t,e,!1),e)}function pc(t,e){return t.slice(e,w(t,e))}class mc extends hc{nextMatch(t,e,i){let n=dc(this.spec,t,i,t.doc.length).next();return n.done&&(n=dc(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=dc(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=dc(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=dc(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 gc=ut.define(),wc=ut.define(),vc=K.define({create:t=>new bc(Lc(t).create(),null),update(t,e){for(let i of e.effects)i.is(gc)?t=new bc(i.value.create(),t.panel):i.is(wc)&&(t=new bc(t.query,i.value?Oc:null));return t},provide:t=>Ls.from(t,(t=>t.panel))});class bc{constructor(t,e){this.query=t,this.panel=e}}const kc=Qe.mark({class:"cm-searchMatch"}),yc=Qe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),xc=Si.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(vc))}update(t){let e=t.state.field(vc);(e!=t.startState.field(vc)||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?yc:kc)}))}return n.finish()}},{decorations:t=>t.decorations});function Sc(t){return e=>{let i=e.state.field(vc,!1);return i&&i.query.spec.valid?t(e,i):Pc(e)}}const Ac=Sc(((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(ac);return t.dispatch({selection:r,effects:[Wc(t,n),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),Bc(t),!0})),Mc=Sc(((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(ac);return t.dispatch({selection:s,effects:[Wc(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),Bc(t),!0})),Cc=Sc(((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))})),Tc=Sc(((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(Wc(t,s)),h.push(i.facet(ac).scrollToMatch(o.main,t))}return t.dispatch({changes:l,selection:o,effects:h,userEvent:"input.replace"}),!0})),Dc=Sc(((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 Oc(t){return t.state.facet(ac).createPanel(t)}function Lc(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(ac);return new lc({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 Ec(t){let e=Cs(t,Oc);return e&&e.dom.querySelector("[main-field]")}function Bc(t){let e=Ec(t);e&&e==t.root.activeElement&&e.select()}const Pc=t=>{let e=t.state.field(vc,!1);if(e&&e.panel){let i=Ec(t);if(i&&i!=t.root.activeElement){let n=Lc(t.state,e.query.spec);n.valid&&t.dispatch({effects:gc.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[wc.of(!0),e?gc.of(Lc(t.state,e.query.spec)):ut.appendConfig.of(qc)]});return!0},Rc=t=>{let e=t.state.field(vc,!1);if(!e||!e.panel)return!1;let i=Cs(t,Oc);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:wc.of(!1)}),!0},Nc=[{key:"Mod-f",run:Pc,scope:"editor search-panel"},{key:"F3",run:Ac,shift:Mc,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Ac,shift:Mc,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Rc,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 Yh(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=Cs(t,nc);if(!e){let i=[rc.of(!0)];null==t.state.field(sc,!1)&&i.push(ut.appendConfig.of([sc,oc])),t.dispatch({effects:i}),e=Cs(t,nc)}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 Yh(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 Yh(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 zc{constructor(t){this.view=t;let e=this.query=t.state.field(vc).query.spec;function i(t,e,i){return Kh("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=Kh("input",{value:e.search,placeholder:Ic(t,"Find"),"aria-label":Ic(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Kh("input",{value:e.replace,placeholder:Ic(t,"Replace"),"aria-label":Ic(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Kh("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=Kh("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=Kh("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=Kh("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>Ac(t)),[Ic(t,"next")]),i("prev",(()=>Mc(t)),[Ic(t,"previous")]),i("select",(()=>Cc(t)),[Ic(t,"all")]),Kh("label",null,[this.caseField,Ic(t,"match case")]),Kh("label",null,[this.reField,Ic(t,"regexp")]),Kh("label",null,[this.wordField,Ic(t,"by word")]),...t.state.readOnly?[]:[Kh("br"),this.replaceField,i("replace",(()=>Tc(t)),[Ic(t,"replace")]),i("replaceAll",(()=>Dc(t)),[Ic(t,"replace all")])],Kh("button",{name:"close",onclick:()=>Rc(t),"aria-label":Ic(t,"close"),type:"button"},["×"])])}commit(){let t=new lc({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:gc.of(t)}))}keydown(t){var e,i;i=t,Yr(Kr((e=this.view).state),i,e,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?Mc:Ac)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),Tc(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(gc)&&!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(ac).top}}function Ic(t,e){return t.state.phrase(e)}const Vc=30,Hc=/[\s\.,:;?!]/;function Wc(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-Vc),o=Math.min(r,i+Vc),a=t.state.sliceDoc(s,o);if(s!=n.from)for(let t=0;t<Vc;t++)if(!Hc.test(a[t+1])&&Hc.test(a[t])){a=a.slice(t);break}if(o!=r)for(let t=a.length-1;t>a.length-Vc;t--)if(!Hc.test(a[t-1])&&Hc.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 Fc=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"}}),qc=[vc,G.low(xc),Fc];class _c{constructor(t,e,i){this.from=t,this.to=e,this.diagnostic=i}}class jc{constructor(t,e,i){this.diagnostics=t,this.panel=e,this.selected=i}static init(t,e,i){let n=t,r=i.facet(ru).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 lu(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 jc(s,e,$c(s))}}function $c(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 _c(t,i,r.diagnostic),!1})),n}function Kc(t,e){let i=t.startState.doc.lineAt(e.pos);return!(!t.effects.some((t=>t.is(Gc)))&&!t.changes.touchesRange(i.from,i.to))}function Uc(t,e){return t.field(Xc,!1)?e:e.concat(ut.appendConfig.of(xu))}const Gc=ut.define(),Yc=ut.define(),Jc=ut.define(),Xc=K.define({create:()=>new jc(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=$c(i,t.selected.diagnostic,r)||$c(i,null,r)}t=new jc(i,t.panel,n)}for(let i of e.effects)i.is(Gc)?t=jc.init(i.value,t.panel,e.state):i.is(Yc)?t=new jc(t.diagnostics,i.value?cu.open:null,t.selected):i.is(Jc)&&(t=new jc(t.diagnostics,t.panel,i.value));return t},provide:t=>[Ls.from(t,(t=>t.panel)),zr.decorations.from(t,(t=>t.diagnostics))]}),Zc=Qe.mark({class:"cm-lintRange cm-lintRange-active"});function Qc(t,e,i){let{diagnostics:n}=t.state.field(Xc),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(ru).tooltipFilter;return a&&(r=a(r)),r.length?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create:()=>({dom:tu(t,r)})}:null}function tu(t,e){return Kh("ul",{class:"cm-tooltip-lint"},e.map((e=>au(t,e,!1))))}const eu=t=>{let e=t.state.field(Xc,!1);e&&e.panel||t.dispatch({effects:Uc(t.state,[Yc.of(!0)])});let i=Cs(t,cu.open);return i&&i.dom.querySelector(".cm-panel-lint ul").focus(),!0},iu=t=>{let e=t.state.field(Xc,!1);return!(!e||!e.panel||(t.dispatch({effects:Yc.of(!1)}),0))},nu=Si.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(ru);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(ru);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:Uc(t,[Gc.of(e)])}}(this.view.state,i))}),(t=>{bi(this.view.state,t)}))}}update(t){let e=t.state.facet(ru);(t.docChanged||e!=t.startState.facet(ru)||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)}}),ru=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 su(t,e={}){return[ru.of({source:t,config:e}),nu,xu]}function ou(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 au(t,e,i){var n;let r=i?ou(e.actions):[];return Kh("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Kh("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=$c(t.state.field(Xc).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),Kh("u",a.slice(l,l+1)),a.slice(l+1)];return Kh("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${a}${l<0?"":` (access key "${r[n]})"`}.`},h)})),e.source&&Kh("div",{class:"cm-diagnosticSource"},e.source))}class lu extends Xe{constructor(t){super(),this.diagnostic=t}eq(t){return t.diagnostic==this.diagnostic}toDOM(){return Kh("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class hu{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=au(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class cu{constructor(t){this.view=t,this.items=[],this.list=Kh("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e=>{if(27==e.keyCode)iu(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=ou(i.actions);for(let r=0;r<n.length;r++)if(n[r].toUpperCase().charCodeAt(0)==e.keyCode){let e=$c(this.view.state.field(Xc).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=Kh("div",{class:"cm-panel-lint"},this.list,Kh("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>iu(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(Xc).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(Xc),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 hu(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 hu(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=$c(this.view.state.field(Xc).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:Jc.of(e)})}static open(t){return new cu(t)}}function uu(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 du(t){return uu(`<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 fu=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:du("#d11")},".cm-lintRange-warning":{backgroundImage:du("orange")},".cm-lintRange-info":{backgroundImage:du("#999")},".cm-lintRange-hint":{backgroundImage:du("#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 pu(t){return"error"==t?4:"warning"==t?3:"info"==t?2:1}class mu extends Es{constructor(t){super(),this.diagnostics=t,this.severity=t.reduce(((t,e)=>pu(t)<pu(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(Su).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:bu.of({pos:n.from,above:!1,create:()=>({dom:tu(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(ku)&&t.dispatch({effects:bu.of(null)})}};window.addEventListener("mousemove",i)}(t,e)}let{hoverTime:r}=t.state.facet(Su),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 gu(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 mu(i[t]).range(+t));return Dt.of(n,!0)}const wu=Ns({class:"cm-gutter-lint",markers:t=>t.state.field(vu)}),vu=K.define({create:()=>Dt.empty,update(t,e){t=t.map(e.changes);let i=e.state.facet(Su).markerFilter;for(let n of e.effects)if(n.is(Gc)){let r=n.value;i&&(r=i(r||[])),t=gu(e.state.doc,r.slice(0))}return t}}),bu=ut.define(),ku=K.define({create:()=>null,update:(t,e)=>(t&&e.docChanged&&(t=Kc(e,t)?null:Object.assign(Object.assign({},t),{pos:e.changes.mapPos(t.pos)})),e.effects.reduce(((t,e)=>e.is(bu)?e.value:t),t)),provide:t=>ws.from(t)}),yu=zr.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:uu('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:uu('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:uu('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),xu=[Xc,zr.decorations.compute([Xc],(t=>{let{selected:e,panel:i}=t.field(Xc);return e&&i&&e.from!=e.to?Qe.set([Zc.range(e.from,e.to)]):Qe.none})),Ss(Qc,{hideOn:Kc}),fu],Su=H.define({combine:t=>St(t,{hoverTime:300,markerFilter:null,tooltipFilter:null})});function Au(t={}){return[Su.of(t),vu,wu,yu,ku]}const Mu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Cu=ut.define({map(t,e){let i=e.mapPos(t,-1,C.TrackAfter);return null==i?void 0:i}}),Tu=new class extends At{};Tu.startSide=1,Tu.endSide=-1;const Du=K.define({create:()=>Dt.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(Cu)&&(t=t.update({add:[Tu.range(i.value,i.value+1)]}));return t}}),Ou="()[]{}<>";function Lu(t){for(let e=0;e<8;e+=2)if(Ou.charCodeAt(e)==t)return Ou.charAt(e+1);return S(t<128?t:t+1)}const Eu="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Bu=zr.inputHandler.of(((t,e,i,n)=>{if((Eu?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(n.length>2||2==n.length&&1==A(x(n,0))||e!=r.from||i!=r.to)return!1;let s=function(t,e){let i=function(t,e){return t.languageDataAt("closeBrackets",e)[0]||Mu}(t,t.selection.main.head),n=i.brackets||Mu.brackets;for(let r of n){let s=Lu(x(r,0));if(e==r)return s==r?Iu(t,r,n.indexOf(r+r+r)>-1,i):Nu(t,r,s,i.before||Mu.before);if(e==s&&Pu(t,t.selection.main.from))return zu(t,0,s)}return null}(t.state,n);return!!s&&(t.dispatch(s),!0)}));function Pu(t,e){let i=!1;return t.field(Du).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function Ru(t,e){let i=t.sliceString(e,e+2);return i.slice(0,A(x(i,0)))}function Nu(t,e,i,n){let r=null,s=t.changeByRange((s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:i,from:s.to}],effects:Cu.of(s.to+e.length),range:z.range(s.anchor+e.length,s.head+e.length)};let o=Ru(t.doc,s.head);return!o||/\s/.test(o)||n.indexOf(o)>-1?{changes:{insert:e+i,from:s.head},effects:Cu.of(s.head+e.length),range:z.cursor(s.head+e.length)}:{range:r=s}}));return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function zu(t,e,i){let n=null,r=t.changeByRange((e=>e.empty&&Ru(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:z.cursor(e.head+i.length)}:n={range:e}));return n?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Iu(t,e,i,n){let r=n.stringPrefixes||Mu.stringPrefixes,s=null,o=t.changeByRange((n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:Cu.of(n.to+e.length),range:z.range(n.anchor+e.length,n.head+e.length)};let o,a=n.head,l=Ru(t.doc,a);if(l==e){if(Vu(t,a))return{changes:{insert:e+e,from:a},effects:Cu.of(a+e.length),range:z.cursor(a+e.length)};if(Pu(t,a)){let n=i&&t.sliceDoc(a,a+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+n.length,insert:n},range:z.cursor(a+n.length)}}}else{if(i&&t.sliceDoc(a-2*e.length,a)==e+e&&(o=Hu(t,a-2*e.length,r))>-1&&Vu(t,o))return{changes:{insert:e+e+e+e,from:a},effects:Cu.of(a+e.length),range:z.cursor(a+e.length)};if(t.charCategorizer(a)(l)!=bt.Word&&Hu(t,a,r)>-1&&!function(t,e,i,n){let r=ua(t).resolveInner(e,-1),s=n.reduce(((t,e)=>Math.max(t,e.length)),0);for(let o=0;o<5;o++){let o=t.sliceDoc(r.from,Math.min(r.to,r.from+i.length+s)),a=o.indexOf(i);if(!a||a>-1&&n.indexOf(o.slice(0,a))>-1){let e=r.firstChild;for(;e&&e.from==r.from&&e.to-e.from>i.length+a;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let l=r.to==e&&r.parent;if(!l)break;r=l}return!1}(t,a,e,r))return{changes:{insert:e+e,from:a},effects:Cu.of(a+e.length),range:z.cursor(a+e.length)}}return{range:s=n}}));return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Vu(t,e){let i=ua(t).resolveInner(e+1);return i.parent&&i.from==e}function Hu(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=bt.Word)return e;for(let r of i){let i=e-r.length;if(t.sliceDoc(i,e)==r&&n(t.sliceDoc(i-1,i))!=bt.Word)return i}return-1}const Wu={permittedHtmlTags:{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},implicitlyClosedHtmlTags:{br:!0,hr:!0,wbr:!0},tags:{apostrophes:"mw-apostrophes",apostrophesBold:"mw-apostrophes-bold",apostrophesItalic:"mw-apostrophes-italic",comment:"mw-comment",doubleUnderscore:"mw-double-underscore",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",hr:"mw-hr",htmlTagAttribute:"mw-htmltag-attribute",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",extTagAttribute:"mw-exttag-attribute",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",indenting:"mw-indenting",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",sectionHeader:"mw-section-header",sectionHeader1:"mw-section-1",sectionHeader2:"mw-section-2",sectionHeader3:"mw-section-3",sectionHeader4:"mw-section-4",sectionHeader5:"mw-section-5",sectionHeader6:"mw-section-6",signature:"mw-signature",tableBracket:"mw-table-bracket",tableDefinition:"mw-table-definition",tableDelimiter:"mw-table-delimiter",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableName:"mw-templatevariable-name",section:"mw-section",em:"mw-em",error:"mw-error",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(){const t={};for(const e of Object.values(this.tags))t[e]=No.define();return t},getHighlightStyle(t){const e=Object.values(this.tags).map((e=>({tag:t.tokenTable[e],class:`cm-${e}${"templateName"===e?" cm-mw-pagename":""}`})));return Ra.define(e)}};function Fu(t){var e,i,n=(t={...ld,...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:ad}}}function qu(t){for(var e={},i=0;i<t.length;++i)e[t[i].toLowerCase()]=!0;return e}var _u=["domain","regexp","url","url-prefix"],ju=qu(_u),$u=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],Ku=qu($u),Uu=["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"],Gu=qu(Uu),Yu=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],Ju=qu(Yu),Xu=["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"],Zu=qu(Xu),Qu=["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"],td=qu(Qu),ed=qu(["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"]),id=qu(["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"]),nd=["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"],rd=qu(nd),sd=["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"],od=qu(sd),ad=_u.concat($u).concat(Uu).concat(Yu).concat(Xu).concat(Qu).concat(nd).concat(sd);const ld={documentTypes:ju,mediaTypes:Ku,mediaFeatures:Gu,mediaValueKeywords:Ju,propertyKeywords:Zu,nonStandardPropertyKeywords:td,fontProperties:ed,counterDescriptors:id,colorKeywords:rd,valueKeywords:od,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=cd,cd(t,e))}}},hd=Fu({name:"css"});function cd(t,e){for(var i,n=!1;null!=(i=t.next());){if(n&&"/"==i){e.tokenize=null;break}n="*"==i}return["comment","comment"]}function ud(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 R(){var t=k.state;t.lexical.prev&&(")"==t.lexical.type&&(t.indented=t.lexical.indented),t.lexical=t.lexical.prev)}function N(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,N(";"),R):"keyword a"==t?x(P("form"),W,z,R):"keyword b"==t?x(P("form"),z,R):"keyword d"==t?k.stream.match(/^\s*$/,!1)?x():x(P("stat"),q,N(";"),R):"debugger"==t?x(N(";")):"{"==t?x(P("}"),E,rt,R,B):";"==t?x():"if"==t?("else"==k.state.lexical.info&&k.state.cc[k.state.cc.length-1]==R&&k.state.cc.pop()(),x(P("form"),W,z,R,Ct)):"function"==t?x(Lt):"for"==t?x(P("form"),E,Tt,z,B,R):"class"==t||o&&"interface"==e?(k.marked="keyword",x(P("form","class"==t?t:e),Nt,R)):"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(Ut):"type"==e?x(Bt,N("operator"),ht,N(";")):x(P("form"),yt,N("{"),P("}"),rt,R,R)):o&&"namespace"==e?(k.marked="keyword",x(P("form"),V,z,R)):o&&"abstract"==e?(k.marked="keyword",x(z)):x(P("stat"),X):"switch"==t?x(P("form"),W,N("{"),P("}","switch"),E,rt,R,R,B):"case"==t?x(V,N(":")):"default"==t?x(N(":")):"catch"==t?x(P("form"),L,I,z,R,B):"export"==t?x(P("stat"),Ht,R):"import"==t?x(P("stat"),Ft,R):"async"==t?x(z):"@"==e?x(V,z):y(P("stat"),V,N(";"),R)}function I(t){if("("==t)return x(Pt,N(")"))}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,N(")"),R)}function F(t,e,i){if(k.state.fatArrowAt==k.stream.start){var n=i?G:U;if("("==t)return x(L,P(")"),it(Pt,")"),R,N("=>"),n,B);if("variable"==t)return y(L,yt,N("=>"),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"),Rt,R)):"keyword c"==t||"async"==t?x(i?H:V):"("==t?x(P(")"),q,N(")"),R,r):"operator"==t||"spread"==t?x(i?H:V):"["==t?x(P("]"),Kt,R,r):"{"==t?nt(Q,"}",null,r):"quasi"==t?y($,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?G:U,B):"operator"==t?/\+\+|--/.test(e)||o&&"!"==e?x(n):o&&"<"==e&&k.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?x(P(">"),it(ht,">"),R,n):"?"==e?x(V,N(":"),r):x(r):"quasi"==t?y($,n):";"!=t?"("==t?nt(H,")","call",n):"."==t?x(Z,n):"["==t?x(P("]"),q,N("]"),R,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 $(t,e){return"quasi"!=t?y():"${"!=e.slice(e.length-2)?x($):x(q,K)}function K(t){if("}"==t)return k.marked="string.special",k.state.tokenize=p,x($)}function U(t){return g(k.stream,k.state),y("{"==t?z:V)}function G(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(R,z):y(_,N(";"),R)}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,N("]"),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(N(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),R)}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,"]",","),R,gt):"{"==t?x(P("}"),ut,R,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(N("variable"),ot,N("]"),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,">"),R,gt):"|"==e||"."==t||"&"==e?x(ht):"["==t?x(ht,N("]"),gt):"extends"==e||"implements"==e?(k.marked="keyword",x(ht)):"?"==e?x(ht,N(":"),ht):void 0}function wt(t,e){if("<"==e)return x(P(">"),it(ht,">"),R,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(Ut)):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,N("]"),N(":"),xt):x(N(":"),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,R)}function Tt(t,e){return"await"==e?x(Tt):"("==t?x(P(")"),Dt,R):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,")"),R,at,z,B):o&&"<"==e?x(P(">"),it(vt,">"),R,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,")"),R,at,B):o&&"<"==e?x(P(">"),it(vt,">"),R,Et):void 0}function Bt(t,e){return"keyword"==t||"variable"==t?(k.marked="type",x(Bt)):"<"==e?x(P(">"),it(vt,">"),R):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 Rt(t,e){return"variable"==t?Nt(t,e):zt(t,e)}function Nt(t,e){if("variable"==t)return A(e),x(zt)}function zt(t,e){return"<"==e?x(P(">"),it(vt,">"),R,zt):"extends"==e||"implements"==e||o&&","==t?("implements"==e&&(k.marked="keyword"),x(o?ht:V,zt)):"{"==t?x(P("}"),It,R):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,N("]"),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($t,N(";"))):"default"==e?(k.marked="keyword",x(V,N(";"))):"{"==t?x(it(Wt,"}"),$t,N(";")):y(z)}function Wt(t,e){return"as"==e?(k.marked="keyword",x(N("variable"))):"variable"==t?y(H,Wt):void 0}function Ft(t){return"string"==t?x():"("==t?y(V):"."==t?y(_):y(qt,_t,$t)}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 $t(t,e){if("from"==e)return k.marked="keyword",x(V)}function Kt(t){return"]"==t?x():y(it(H,"]"))}function Ut(){return y(P("form"),yt,N("{"),P("}"),it(Gt,"}"),R,R)}function Gt(){return y(yt,At)}return L.lex=E.lex=!0,B.lex=!0,R.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==R)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:"$"}}}Fu({name:"scss",mediaTypes:Ku,mediaFeatures:Gu,mediaValueKeywords:Ju,propertyKeywords:Zu,nonStandardPropertyKeywords:td,colorKeywords:rd,valueKeywords:od,fontProperties:ed,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=cd,cd(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"]}}}),Fu({name:"less",mediaTypes:Ku,mediaFeatures:Gu,mediaValueKeywords:Ju,propertyKeywords:Zu,nonStandardPropertyKeywords:td,colorKeywords:rd,valueKeywords:od,fontProperties:ed,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=cd,cd(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"]}}}),Fu({name:"gss",documentTypes:ju,mediaTypes:Ku,mediaFeatures:Gu,propertyKeywords:Zu,nonStandardPropertyKeywords:td,fontProperties:ed,counterDescriptors:id,colorKeywords:rd,valueKeywords:od,supportsAtComponent:!0,tokenHooks:{"/":function(t,e){return!!t.eat("*")&&(e.tokenize=cd,cd(t,e))}}});const dd=ud({name:"javascript"});function fd(t){return new RegExp("^(?:"+t.join("|")+")$","i")}ud({name:"json",json:!0}),ud({name:"json",jsonld:!0}),ud({name:"typescript",typescript:!0});var pd=fd(["_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall","coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield","debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback","close","flush","lines","read","seek","setvbuf","write","io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write","math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh","os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname","package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall","string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper","table.concat","table.insert","table.maxn","table.remove","table.sort"]),md=fd(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),gd=fd(["function","if","repeat","do","\\(","{"]),wd=fd(["end","until","\\)","}"]),vd=new RegExp("^(?:"+["end","until","\\)","}","else","elseif"].join("|")+")","i");function bd(t){for(var e=0;t.eat("=");)++e;return t.eat("["),e}function kd(t,e){var i,n=t.next();return"-"==n&&t.eat("-")?t.eat("[")&&t.eat("[")?(e.cur=yd(bd(t),"comment"))(t,e):(t.skipToEnd(),"comment"):'"'==n||"'"==n?(e.cur=(i=n,function(t,e){for(var n,r=!1;null!=(n=t.next())&&(n!=i||r);)r=!r&&"\\"==n;return r||(e.cur=kd),"string"}))(t,e):"["==n&&/[\[=]/.test(t.peek())?(e.cur=yd(bd(t),"string"))(t,e):/\d/.test(n)?(t.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(n)?(t.eatWhile(/[\w\\\-_.]/),"variable"):null}function yd(t,e){return function(i,n){for(var r,s=null;null!=(r=i.next());)if(null==s)"]"==r&&(s=0);else if("="==r)++s;else{if("]"==r&&s==t){n.cur=kd;break}s=null}return e}}const xd={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:kd}},token:function(t,e){if(t.eatSpace())return null;var i=e.cur(t,e),n=t.current();return"variable"==i&&(md.test(n)?i="keyword":pd.test(n)&&(i="builtin")),"comment"!=i&&"string"!=i&&(gd.test(n)?++e.indentDepth:wd.test(n)&&--e.indentDepth),i},indent:function(t,e,i){var n=vd.test(e);return t.basecol+i.unit*(t.indentDepth-(n?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}},Sd=t=>{const e={};for(const[i,n]of Object.entries(t))Object.assign(e,{[i]:Array.isArray(n)?[...n]:n});return e};class Ad{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+=` ${Wu.tags.mnemonic}`:e}makeStyle(t,e,i){return this.isBold&&(t+=` ${Wu.tags.strong}`),this.isItalic&&(t+=` ${Wu.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(Wu.tags.error,n))}eatSectionHeader(t){return(e,i)=>e.match(/^[^&<[{~]+/)?(e.eol()?(e.backUp(t),i.tokenize=this.eatEnd(Wu.tags.sectionHeader)):e.match(/^<!--(?!.*?-->.*?=)/,!1)&&(e.backUp(t),i.tokenize=this.eatBlock(Wu.tags.sectionHeader,"\x3c!--",!1)),Wu.tags.section):this.eatWikiText(Wu.tags.section,"")(e,i)}inVariable(t,e){return t.match(/^[^{}|]+/)?this.makeLocalStyle(Wu.tags.templateVariableName,e):t.eat("|")?(e.tokenize=this.inVariableDefault.bind(this),this.makeLocalStyle(Wu.tags.templateVariableDelimiter,e)):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Wu.tags.templateVariableBracket,e)):t.match("{{{")?(e.stack.push(e.tokenize),this.makeLocalStyle(Wu.tags.templateVariableBracket,e)):(t.next(),this.makeLocalStyle(Wu.tags.templateVariableName,e))}inVariableDefault(t,e){return t.match(/^[^{}[<&~]+/)?this.makeLocalStyle(Wu.tags.templateVariable,e):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Wu.tags.templateVariableBracket,e)):this.eatWikiText(Wu.tags.templateVariable,"")(t,e)}inParserFunctionName(t,e){return t.match(/^[^:}{~]+/)?this.makeLocalStyle(Wu.tags.parserFunctionName,e):t.eat(":")?(e.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(Wu.tags.parserFunctionDelimiter,e)):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Wu.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(Wu.tags.parserFunction,"")(t,e)}inParserFunctionArguments(t,e){return t.match(/^[^|}{[<&~]+/)?this.makeLocalStyle(Wu.tags.parserFunction,e):t.eat("|")?this.makeLocalStyle(Wu.tags.parserFunctionDelimiter,e):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Wu.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(Wu.tags.parserFunction,"")(t,e)}eatTemplatePageName(t){return(e,i)=>e.match(/^\s*\|\s*/)?(i.tokenize=this.eatTemplateArgument(!0),this.makeLocalStyle(Wu.tags.templateDelimiter,i)):e.match(/^\s*\}\}/)?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Wu.tags.templateBracket,i,"nTemplate")):e.match(/^\s*<!--.*?-->/)?this.makeLocalStyle(Wu.tags.comment,i):t&&e.sol()?(i.nTemplate--,i.tokenize=i.stack.pop(),""):e.match(/^\s*[^\s|}<{&~]+/)?(i.tokenize=this.eatTemplatePageName(!0),this.makeLocalStyle(Wu.tags.templateName,i)):e.eatSpace()?(e.eol(),this.makeLocalStyle(Wu.tags.templateName,i)):this.eatWikiText(Wu.tags.templateName,`${Wu.tags.templateName}-mnemonic`)(e,i)}eatTemplateArgument(t){return(e,i)=>t&&e.eatWhile(/[^=|}{[<&~]/)?e.eat("=")?(i.tokenize=this.eatTemplateArgument(!1),this.makeLocalStyle(Wu.tags.templateArgumentName,i)):this.makeLocalStyle(Wu.tags.template,i):e.eatWhile(/[^|}{[<&~]/)?this.makeLocalStyle(Wu.tags.template,i):e.eat("|")?(i.tokenize=this.eatTemplateArgument(!0),this.makeLocalStyle(Wu.tags.templateDelimiter,i)):e.match("}}")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Wu.tags.templateBracket,i,"nTemplate")):this.eatWikiText(Wu.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(Wu.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(Wu.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(Wu.tags.extLink,e)):this.eatWikiText(Wu.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(Wu.tags.extLinkBracket,e,"nLink")):t.match(/^[^'\]{&~<]+/)?this.makeStyle(Wu.tags.extLinkText,e):this.eatWikiText(Wu.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(Wu.tags.link,e)):t.match(/^\s*\|\s*/)?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(Wu.tags.linkDelimiter,e)):t.match(/^\s*\]\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Wu.tags.linkBracket,e,"nLink")):t.match(/^\s*[^\s#|\]&~{]+/)||t.eatSpace()?this.makeStyle(`${Wu.tags.linkPageName} ${Wu.tags.pageName}`,e):this.eatWikiText(`${Wu.tags.linkPageName} ${Wu.tags.pageName}`,Wu.tags.pageName)(t,e)}inLinkToSection(t,e){return t.sol()?(e.nLink--,e.tokenize=e.stack.pop(),""):t.match(/^[^|\]&~{}]+/)?this.makeLocalStyle(Wu.tags.linkToSection,e):t.eat("|")?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(Wu.tags.linkDelimiter,e)):t.match("]]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Wu.tags.linkBracket,e,"nLink")):this.eatWikiText(Wu.tags.linkToSection,"")(t,e)}eatLinkText(){let t,e;return(i,n)=>{let r;return i.match("]]")?(n.tokenize=n.stack.pop(),this.makeLocalStyle(Wu.tags.linkBracket,n,"nLink")):i.match("'''")?(t=!t,this.makeLocalStyle(`${Wu.tags.linkText} ${Wu.tags.apostrophes}`,n)):i.match("''")?(e=!e,this.makeLocalStyle(`${Wu.tags.linkText} ${Wu.tags.apostrophes}`,n)):(r=Wu.tags.linkText,t&&(r+=` ${Wu.tags.strong}`),e&&(r+=` ${Wu.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&&!Wu.implicitlyClosedHtmlTags[s]?r.tokenize=this.eatChar(">",Wu.tags.htmlTagBracket):r.tokenize=this.eatHtmlTagAttribute(s),this.makeLocalStyle(Wu.tags.htmlTagName,r)):(r.tokenize=e?this.eatChar(">",Wu.tags.extTagBracket):this.eatExtTagAttribute(s),this.makeLocalStyle(Wu.tags.extTagName,r))}}eatHtmlTagAttribute(t){return(e,i)=>e.match(/^(?:"[^<">]*"|'[^<'>]*'|[^>/<{&~])+/)?this.makeLocalStyle(Wu.tags.htmlTagAttribute,i):e.eat(">")?(t in Wu.implicitlyClosedHtmlTags||i.inHtmlTag.push(t),i.tokenize=i.stack.pop(),this.makeLocalStyle(Wu.tags.htmlTagBracket,i)):e.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Wu.tags.htmlTagBracket,i)):this.eatWikiText(Wu.tags.htmlTagAttribute,"")(e,i)}eatExtTagAttribute(t){return(e,i)=>e.match(/^(?:"[^">]*"|'[^'>]*'|[^>/<{&~])+/)?this.makeLocalStyle(Wu.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(Wu.tags.extTagBracket,i)):e.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(Wu.tags.extTagBracket,i)):this.eatWikiText(Wu.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(Wu.tags.extTagBracket,i))}eatExtTokens(t){return(e,i)=>{let n;return!1===i.extMode?(n=Wu.tags.extTag,e.skipToEnd()):(n=Wu.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),Wu.tags.tableBracket}inTableDefinition(t,e){return t.sol()?(e.tokenize=this.inTable.bind(this),this.inTable(t,e)):this.eatWikiText(Wu.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(Wu.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(Wu.tags.tableDelimiter,e)):t.eat("+")?(t.eatSpace(),e.tokenize=this.inTableCaption.bind(this),this.makeLocalStyle(Wu.tags.tableDelimiter,e)):t.eat("}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(Wu.tags.tableBracket,e)):(t.eatSpace(),e.tokenize=this.eatTableRow(!0,!1),this.makeLocalStyle(Wu.tags.tableDelimiter,e));if(t.eat("!"))return t.eatSpace(),e.tokenize=this.eatTableRow(!0,!0),this.makeLocalStyle(Wu.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?Wu.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(Wu.tags.tableDelimiter,n)}const r=e?Wu.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(Wu.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(Wu.tags.freeExtLink,e)}else if("{"===t.peek()){if(!t.match("{{",!1))return t.next(),this.makeLocalStyle(Wu.tags.freeExtLink,e)}else if("'"===t.peek()){if(!t.match("''",!1))return t.next(),this.makeLocalStyle(Wu.tags.freeExtLink,e)}else if(t.match(/^[).,]+(?=[^\s{[\]<>~).,])/))return this.makeLocalStyle(Wu.tags.freeExtLink,e);return e.tokenize=e.stack.pop(),this.makeLocalStyle(Wu.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(Wu.tags.freeExtLinkProtocol,n);switch(r=i.next(),r){case"-":if(i.match(/^-{3,}/))return Wu.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),`${Wu.tags.sectionHeader} ${Wu.tags[`sectionHeader${s[1].length+1}`]}`;break;case"*":case"#":return i.match(/^[*#]*:*/),Wu.tags.list;case":":return i.match(/^:*\{\|/,!1)&&(n.stack.push(n.tokenize),n.tokenize=this.eatStartTable.bind(this)),i.match(/^:*[*#]*/),Wu.tags.indenting;case" ":if(!i.match(/^\s*:*\{\|/,!1))return Wu.tags.skipFormatting;if(i.eatSpace(),i.match(/^:+/))return n.stack.push(n.tokenize),n.tokenize=this.eatStartTable.bind(this),Wu.tags.indenting;i.eat("{");case"{":if(i.match(/^(?:\||\{\{!\}\})/))return i.eatSpace(),n.stack.push(n.tokenize),n.tokenize=this.inTableDefinition.bind(this),Wu.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(Wu.tags.apostrophesBold,n);if(i.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(Wu.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(Wu.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(Wu.tags.extLinkBracket,n);break;case"{":if(i.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))/))return i.eatSpace(),n.stack.push(n.tokenize),n.tokenize=this.inVariable.bind(this),this.makeLocalStyle(Wu.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(Wu.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(Wu.tags.templateBracket,n)):(n.nExt++,n.stack.push(n.tokenize),n.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(Wu.tags.parserFunctionBracket,n)));break;case"<":if(h=Boolean(i.eat("/")),l=i.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+/),i.match("!--"))return c=this.eatBlock(Wu.tags.comment,"--\x3e"),n.stack.push(n.tokenize),n.tokenize=c,c(i,n);if(l){if(l=l[0].toLowerCase(),l in this.config.tags)return h?Wu.tags.error:(i.backUp(l.length),n.stack.push(n.tokenize),n.tokenize=this.eatTagName(l.length,h,!1),this.makeLocalStyle(Wu.tags.extTagBracket,n));if(l in Wu.permittedHtmlTags)return h&&l!==n.inHtmlTag.pop()?(i.pos++,Wu.tags.error):h&&l in Wu.implicitlyClosedHtmlTags?Wu.tags.error:(i.backUp(l.length),n.stack.push(n.tokenize),n.tokenize=this.eatTagName(l.length,h||l in Wu.implicitlyClosedHtmlTags,!0),this.makeLocalStyle(Wu.tags.htmlTagBracket,n));i.backUp(l.length)}break;case"~":if(i.match(/^~{2,4}/))return Wu.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]?Wu.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=Sd(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||Sd)(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:Wu.tokenTable,languageData:{closeBrackets:{brackets:["(","[","{",'"']}}}}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(Wu.tags.pre)}}get"mw-tag-nowiki"(){return{startState:()=>({}),token:this.eatNowiki(Wu.tags.nowiki)}}}for(const[t,e]of Object.entries(i))Object.defineProperty(Ad.prototype,t,{get:()=>e});const Md=t=>{const e=new Ad(t).mediawiki,i=ol.define(e),n=Va(Wu.getHighlightStyle(e));return new ya(i,n)};var Cd,Td,Dd,Od,Ld,Ed,Bd=(t,e,i)=>{if(!e.has(t))throw TypeError("Cannot "+i)},Pd=(t,e,i)=>(Bd(t,e,"read from private field"),i?i.call(t):e.get(t)),Rd=(t,e,i)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,i)},Nd=(t,e,i,n)=>(Bd(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i);const zd={plain:()=>[],mediawiki:Md,html:t=>Md({...t,tags:{...t.tags,script:!0,style:!0},tagModes:{...t.tagModes,script:"javascript",style:"css"}})};for(const[t,e]of Object.entries(i))zd[t]=()=>new ya(ol.define(e));const Id={},Vd={highlightSpecialChars:[function(t={}){return[ns.of(t),rs||(rs=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 os((e-s%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Qe.replace({widget:new ss(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}))]},{}],highlightActiveLine:[function(){return ls},{}],highlightWhitespace:[function(){return Qs},{}],highlightTrailingWhitespace:[function(){return to},{}],bracketMatching:[function(t={}){return[$a.of(t),Ja]},{mediawiki:{brackets:"[]{}"}}],closeBrackets:[function(){return[Bu,Du]},{}]},Hd=(t,e)=>new Promise((i=>{if(e in window)return void i();const n=document.createElement("script");n.src=`https://testingcf.jsdelivr.net/${t}`,n.onload=()=>{i()},document.head.append(n)}));class Wd{constructor(t,e="plain",i){let n;Rd(this,Cd,void 0),Rd(this,Td,void 0),Rd(this,Dd,void 0),Rd(this,Od,void 0),Rd(this,Ld,void 0),Rd(this,Ed,void 0),Nd(this,Cd,t),this.lang=e,Nd(this,Td,new J),Nd(this,Dd,new J),Nd(this,Od,new J),Nd(this,Ld,new J);const r=[Pd(this,Td).of(zd[e](i)),Pd(this,Dd).of([]),Pd(this,Od).of([]),Pd(this,Ld).of(Sa.of("\t")),Va(Fa),zr.contentAttributes.of({accesskey:t.accessKey,dir:t.dir,lang:t.lang}),Ys(),zr.lineWrapping,Rl(),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=Ca(o,e.from);if(null==i)continue;let n=/^\s*/.exec(e.text)[0],r=Ma(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([...$h,...Xl,...Nc]),zr.updateListener.of((({state:{doc:e},docChanged:i})=>{i&&(clearTimeout(n),n=window.setTimeout((()=>{t.value=e.toString()}),400))}))];Nd(this,Ed,new zr({extensions:r,doc:t.value}));const{offsetHeight:s,selectionStart:o,selectionEnd:a,scrollTop:l}=t,{fontSize:h,lineHeight:c}=getComputedStyle(t),u=document.activeElement===t;t.parentNode.insertBefore(Pd(this,Ed).dom,t),Pd(this,Ed).dom.style.minHeight="2em",Pd(this,Ed).dom.style.height=`${s}px`,Pd(this,Ed).dom.style.fontSize=h,Pd(this,Ed).scrollDOM.style.lineHeight=c,Pd(this,Ed).requestMeasure(),Pd(this,Ed).dispatch({selection:{anchor:o,head:a}}),t.style.display="none",u&&Pd(this,Ed).focus(),window.requestAnimationFrame((()=>{Pd(this,Ed).scrollDOM.scrollTop=l}))}get textarea(){return Pd(this,Cd)}get view(){return Pd(this,Ed)}setLanguage(t="plain",e){var i;Pd(this,Ed).dispatch({effects:[Pd(this,Td).reconfigure(zd[t](e)),Pd(this,Dd).reconfigure(null!=(i=Id[t])?i:[])]}),this.lang=t,(Id[t]?eu:iu)(Pd(this,Ed))}lint(t){const{lang:e}=this,i=t?[su((e=>t(e.state.doc))),Au()]:[];t?Id[e]=i:delete Id[e],Pd(this,Ed).dispatch({effects:[Pd(this,Dd).reconfigure(i)]}),(t?eu:iu)(Pd(this,Ed))}update(){const t=Pd(this,Dd).get(Pd(this,Ed).state);if(t.length>0){const e=Pd(this,Ed).plugin(t[0][1]);e.set=!0,e.force()}}prefer(t){const{lang:e}=this;Pd(this,Ed).dispatch({effects:[Pd(this,Od).reconfigure(t.map((t=>{const[i,n]=Vd[t];return i(n[e])})))]})}setIndent(t){Pd(this,Ed).dispatch({effects:[Pd(this,Ld).reconfigure(Sa.of(t))]})}async getLinter(){switch(this.lang){case"mediawiki":{const t="combine/npm/wikiparser-node@1.1.5-b/extensions/dist/base.min.js,npm/wikiparser-node@1.1.5-b/extensions/dist/lint.min.js";await Hd(t,"wikiparse");const e=new wikiparse.Linter;return t=>e.codemirror(t.toString())}case"javascript":{await Hd("npm/eslint-linter-browserify","eslint");const t=new eslint.Linter,e={env:{browser:!0,es2018:!0},parserOptions:{ecmaVersion:9,sourceType:"module"},rules:{}};for(const[i,{meta:n}]of t.getRules())(null==n?void 0:n.docs.recommended)&&(e.rules[i]=2);return i=>t.verify(i.toString(),e).map((({message:t,severity:e,line:n,column:r,endLine:s,endColumn:o})=>{const a=i.line(n).from+r-1;return{message:t,severity:1===e?"warning":"error",from:a,to:void 0===s?a+1:i.line(s).from+o-1}}))}case"css":{await Hd("gh/openstyles/stylelint-bundle/dist/stylelint-bundle.min.js","stylelint");const t={rules:{"annotation-no-unknown":!0,"at-rule-no-unknown":!0,"block-no-empty":!0,"color-no-invalid-hex":!0,"comment-no-empty":!0,"custom-property-no-missing-var-function":!0,"declaration-block-no-duplicate-custom-properties":!0,"declaration-block-no-duplicate-properties":[!0,{ignore:["consecutive-duplicates-with-different-syntaxes"]}],"declaration-block-no-shorthand-property-overrides":!0,"font-family-no-duplicate-names":!0,"font-family-no-missing-generic-family-keyword":!0,"function-calc-no-unspaced-operator":!0,"function-linear-gradient-no-nonstandard-direction":!0,"function-no-unknown":!0,"keyframe-block-no-duplicate-selectors":!0,"keyframe-declaration-no-important":!0,"media-feature-name-no-unknown":!0,"media-query-no-invalid":!0,"named-grid-areas-no-invalid":!0,"no-descending-specificity":!0,"no-duplicate-at-import-rules":!0,"no-duplicate-selectors":!0,"no-empty-source":!0,"no-invalid-double-slash-comments":!0,"no-invalid-position-at-import-rule":!0,"no-irregular-whitespace":!0,"property-no-unknown":!0,"selector-anb-no-unmatchable":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":[!0,{ignore:["custom-elements"]}],"string-no-newline":!0,"unit-no-unknown":!0}};return async e=>{const{results:i}=await stylelint.lint({code:e.toString(),config:t});return i.flatMap((({warnings:t})=>t)).map((({text:t,severity:i,line:n,column:r,endLine:s,endColumn:o})=>({message:t,severity:i,from:e.line(n).from+r-1,to:void 0===s?e.line(n).to:e.line(s).from+o-1})))}}case"lua":return await Hd("npm/luaparse","luaparse"),t=>{try{luaparse.parse(t.toString())}catch(t){if(t instanceof luaparse.SyntaxError)return[{message:t.message,severity:"error",from:t.index,to:t.index}]}return[]};default:return()=>[]}}}Cd=new WeakMap,Td=new WeakMap,Dd=new WeakMap,Od=new WeakMap,Ld=new WeakMap,Ed=new WeakMap;var Fd=e.a;export{Fd as CodeMirror6};
1
+ var od=Object.defineProperty;var ld=(n,e)=>{for(var t in e)od(n,t,{get:e[t],enumerable:!0})};var ua=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var ee=(n,e,t)=>(ua(n,e,"read from private field"),t?t.call(n):e.get(n)),Gt=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},Ut=(n,e,t,i)=>(ua(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);var Z=class n{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=wi(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),gi.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=wi(this,e,t);let i=[];return this.decompose(e,t,i,0),gi.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new Xt(this),s=new Xt(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new Xt(this,e)}iterRange(e,t=this.length){return new Un(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Yn(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?n.empty:e.length<=32?new Ie(e):gi.from(Ie.split(e,[]))}},Ie=class n extends Z{constructor(e,t=ad(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new Fs(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(da(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Gn(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new n(l,o.length+s.length));else{let a=l.length>>1;i.push(new n(l.slice(0,a)),new n(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof n))return super.replace(e,t,i);[e,t]=wi(this,e,t);let r=Gn(this.text,Gn(i.text,da(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):gi.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=`
2
+ `){[e,t]=wi(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new n(i,r)),i=[],r=-1);return r>-1&&t.push(new n(i,r)),t}},gi=class n extends Z{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=wi(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new n(c,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
+ `){[e,t]=wi(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof n))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let p of e)i+=p.lines;if(i<32){let p=[];for(let g of e)g.flatten(p);return new Ie(p,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(p){let g;if(p.lines>s&&p instanceof n)for(let x of p.children)f(x);else p.lines>o&&(a>o||!a)?(u(),l.push(p)):p instanceof Ie&&a&&(g=c[c.length-1])instanceof Ie&&p.lines+g.lines<=32?(a+=p.lines,h+=p.length+1,c[c.length-1]=new Ie(g.text.concat(p.text),g.length+1+p.length)):(a+p.lines>r&&u(),a+=p.lines,h+=p.length+1,c.push(p))}function u(){a!=0&&(l.push(c.length==1?c[0]:n.from(c,h)),h=-1,a=c.length=0)}for(let p of e)f(p);return u(),l.length==1?l[0]:new n(l,t)}};Z.empty=new Ie([""],0);function ad(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Gn(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function da(n,e,t){return Gn(n,[""],e,t)}var Xt=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Ie?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof Ie?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
+ `,this;e--}else if(r instanceof Ie){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof Ie?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Un=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Xt(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Yn=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(Z.prototype[Symbol.iterator]=function(){return this.iter()},Xt.prototype[Symbol.iterator]=Un.prototype[Symbol.iterator]=Yn.prototype[Symbol.iterator]=function(){return this});var Fs=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function wi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}var bi="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;n<bi.length;n++)bi[n]+=bi[n-1];function hd(n){for(let e=1;e<bi.length;e+=2)if(bi[e]>n)return bi[e-1]<=n;return!1}function pa(n){return n>=127462&&n<=127487}var ma=8205;function be(n,e,t=!0,i=!0){return(t?xa:cd)(n,e,i)}function xa(n,e,t){if(e==n.length)return e;e&&va(n.charCodeAt(e))&&Sa(n.charCodeAt(e-1))&&e--;let i=$e(n,e);for(e+=wt(i);e<n.length;){let r=$e(n,e);if(i==ma||r==ma||t&&hd(r))e+=wt(r),i=r;else if(pa(r)){let s=0,o=e-2;for(;o>=0&&pa($e(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function cd(n,e,t){for(;e>0;){let i=xa(n,e-2,t);if(i<e)return i;e--}return 0}function va(n){return n>=56320&&n<57344}function Sa(n){return n>=55296&&n<56320}function $e(n,e){let t=n.charCodeAt(e);if(!Sa(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return va(i)?(t-55296<<10)+(i-56320)+65536:t}function er(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function wt(n){return n<65536?1:2}var Hs=/\r\n?|\n/,Ce=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Ce||(Ce={})),yt=class n{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){Vs(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new n(e)}composeDesc(e){return this.empty?e:e.empty?this:Ca(this,e)}mapDesc(e,t=!1){return e.empty?this:Ws(this,e,t)}mapPos(e,t=-1,i=Ce.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=Ce.Simple&&h>=e&&(i==Ce.TrackDel&&r<e&&h>e||i==Ce.TrackBefore&&r<e||i==Ce.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new n(e)}static create(e){return new n(e)}},De=class n extends yt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Vs(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Ws(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(Z.empty);i.push(o?e.slice(s,s+o):Z.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:Ca(this,e,!0)}map(e,t=!1){return e.empty?this:Ws(this,e,t,!0)}iterChanges(e,t=!1){Vs(this,e,t)}get desc(){return yt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new Zt(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);Me(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Me(t,c,f),f>0&&Mt(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);Me(t,c,-1),Me(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:yt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&Me(r,t-o,-1);let f=new n(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof n){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:p}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let g=p?typeof p=="string"?Z.of(p.split(i||Hs)):p:Z.empty,x=g.length;if(f==u&&x==0)return;f<o&&a(),f>o&&Me(r,f-o,-1),Me(r,u-f,x),Mt(s,r,g),o=u}}return h(e),a(!l),l}static empty(e){return new n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(Z.empty);i[r]=Z.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new n(t,i)}static createSet(e,t){return new n(e,t)}};function Me(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Mt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(Z.empty);n.push(t)}}function Vs(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=Z.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function Ws(n,e,t,i=!1){let r=[],s=i?[]:null,o=new Zt(n),l=new Zt(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Me(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(Me(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Me(r,0,o.ins),s&&Mt(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;Me(r,h,a<o.i?o.ins:0),s&&a<o.i&&Mt(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?De.createSet(r,s):yt.create(r);throw new Error("Mismatched change set lengths")}}function Ca(n,e,t=!1){let i=[],r=t?[]:null,s=new Zt(n),o=new Zt(e);for(let l=!1;;){if(s.done&&o.done)return r?De.createSet(i,r):yt.create(i);if(s.ins==0)Me(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Me(i,0,o.ins,l),r&&Mt(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Me(i,a,c,l),r&&c&&Mt(r,i,o.text)}else o.ins==-1?(Me(i,s.off?0:s.len,a,l),r&&Mt(r,i,s.textBit(a))):(Me(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Mt(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}var Zt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Z.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Z.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},mi=class n{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new n(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return L.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return L.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return L.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},L=class n{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:n.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].eq(e.ranges[t]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new n([this.main],0)}addRange(e,t=!0){return n.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,n.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new n(e.ranges.map(t=>mi.fromJSON(t)),e.main)}static single(e,t=e){return new n([n.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return n.normalized(e.slice(),t);i=s.to}return new n(e,t)}static cursor(e,t=0,i,r){return mi.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r!=null?r:16777215)<<6)}static range(e,t,i,r){let s=(i!=null?i:16777215)<<6|(r==null?7:Math.min(6,r));return t<e?mi.create(t,e,48|s):mi.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?n.range(a,l):n.range(l,a))}}return new n(e,t)}};function Aa(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Xs=0,I=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Xs++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new n(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Zs),!!e.static,e.enables)}of(e){return new ki([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ki(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ki(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Zs(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var ki=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Xs++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||js(f,c)){let p=i(f);if(l?!ga(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,u)=>{let p,g=u.config.address[s];if(g!=null){let x=Zn(u,g);if(this.dependencies.every(y=>y instanceof I?u.facet(y)===f.facet(y):y instanceof pe?u.field(y,!1)==f.field(y,!1):!0)||(l?ga(p=i(f),x,r):r(p=i(f),x)))return f.values[o]=x,0}else p=i(f);return f.values[o]=p,1}}}};function ga(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function js(n,e){let t=!1;for(let i of e)Ui(n,i)&1&&(t=!0);return t}function fd(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Zn(a,i[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Ui(a,h);return a.values[o]=l(a),1},update(a,h){if(!js(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=js(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Zs(t,f))return a.values[o]=u,0;let p=l(a);return e.compare(p,u)?(a.values[o]=u,0):(a.values[o]=p,1)}}}var ba=I.define({static:!0}),pe=class n{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new n(Xs++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ba).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,ba.of({field:this,create:e})]}get extension(){return this}},Yt={lowest:4,low:3,default:2,high:1,highest:0};function Gi(n){return e=>new Jn(e,n)}var Lt={highest:Gi(Yt.highest),high:Gi(Yt.high),default:Gi(Yt.default),low:Gi(Yt.low),lowest:Gi(Yt.lowest)},Jn=class{constructor(e,t){this.inner=e,this.prec=t}},xt=class n{of(e){return new Yi(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Yi=class{constructor(e,t){this.compartment=e,this.inner=t}},Xn=class n{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let u of ud(e,t,o))u instanceof pe?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(p=>u.slot(p));let c=i==null?void 0:i.config.facets;for(let u in s){let p=s[u],g=p[0].facet,x=c&&c[u]||[];if(p.every(y=>y.type==0))if(l[g.id]=a.length<<1|1,Zs(x,p))a.push(i.facet(g));else{let y=g.combine(p.map(v=>v.value));a.push(i&&g.compare(y,i.facet(g))?i.facet(g):y)}else{for(let y of p)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=h.length<<1,h.push(v=>y.dynamicSlot(v)));l[g.id]=h.length<<1,h.push(y=>fd(y,g,p))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function ud(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Yi&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof Yi){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof Jn)s(o.inner,o.prec);else if(o instanceof pe)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ki)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,Yt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(n,Yt.default),i.reduce((o,l)=>o.concat(l))}function Ui(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function Zn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Ta=I.define(),qs=I.define({combine:n=>n.some(e=>e),static:!0}),Ma=I.define({combine:n=>n.length?n[0]:void 0,static:!0}),La=I.define(),Da=I.define(),Oa=I.define(),Ea=I.define({combine:n=>n.length?n[0]:!1}),Ne=class{constructor(e,t){this.type=e,this.value=t}static define(){return new $s}},$s=class{of(e){return new Ne(this,e)}},Ks=class{constructor(e){this.map=e}of(e){return new J(this,e)}},J=class n{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new n(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ks(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}};J.reconfigure=J.define();J.appendConfig=J.define();var xe=class n{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Aa(i,t.newLength),s.some(l=>l.type==n.time)||(this.annotations=s.concat(n.time.of(Date.now())))}static create(e,t,i,r,s,o){return new n(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(n.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};xe.time=Ne.define();xe.userEvent=Ne.define();xe.addToHistory=Ne.define();xe.remote=Ne.define();function dd(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Ba(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=De.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:J.mapEffects(n.effects,r).concat(J.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function _s(n,e,t){let i=e.selection,r=yi(e.annotations);return e.userEvent&&(r=r.concat(xe.userEvent.of(e.userEvent))),{changes:e.changes instanceof De?e.changes:De.of(e.changes||[],t,n.facet(Ma)),selection:i&&(i instanceof L?i:L.single(i.anchor,i.head)),effects:yi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function Pa(n,e,t){let i=_s(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Ba(i,_s(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=xe.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return md(t?pd(r):r)}function pd(n){let e=n.startState,t=!0;for(let r of e.facet(La)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:dd(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=De.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=xe.create(e,r,n.selection&&n.selection.map(s),J.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Da);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof xe?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof xe?n=s[0]:n=Pa(e,yi(s),!1)}return n}function md(n){let e=n.startState,t=e.facet(Oa),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=Ba(i,_s(e,s,n.changes.newLength),!0))}return i==n?n:xe.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var gd=[];function yi(n){return n==null?gd:Array.isArray(n)?n:[n]}var fe=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(fe||(fe={})),bd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Gs;try{Gs=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function kd(n){if(Gs)return Gs.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||bd.test(t)))return!0}return!1}function yd(n){return e=>{if(!/\S/.test(e))return fe.Space;if(kd(e))return fe.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return fe.Word;return fe.Other}}var he=class n{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Ui(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Ui(this,i),Zn(this,i)}update(...e){return Pa(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(xt.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(J.reconfigure)?(t=null,i=l.value):l.is(J.appendConfig)&&(t=null,i=yi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Xn.resolve(i,r,this),s=new n(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(qs)?e.newSelection:e.newSelection.asSingle();new n(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:L.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=yi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=J.mapEffects(o,c).concat(J.mapEffects(yi(a.effects),f))}return{changes:r,selection:L.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof De?e:De.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return Z.of(e.split(this.facet(n.lineSeparator)||Hs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ui(this,t),Zn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof pe&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return n.create({doc:e.doc,selection:L.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Xn.resolve(e.extensions||[],new Map),i=e.doc instanceof Z?e.doc:Z.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||Hs)),r=e.selection?e.selection instanceof L?e.selection:L.single(e.selection.anchor,e.selection.head):L.single(0);return Aa(r,i.length),t.staticFacet(qs)||(r=r.asSingle()),new n(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(n.tabSize)}get lineBreak(){return this.facet(n.lineSeparator)||`
5
+ `}get readOnly(){return this.facet(Ea)}phrase(e,...t){for(let i of this.facet(n.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let r=[];for(let s of this.facet(Ta))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return yd(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=be(t,o,!1);if(s(t.slice(a,o))!=fe.Word)break;o=a}for(;l<r;){let a=be(t,l);if(s(t.slice(l,a))!=fe.Word)break;l=a}return o==l?null:L.range(o+i,l+i)}};he.allowMultipleSelections=qs;he.tabSize=I.define({combine:n=>n.length?n[0]:4});he.lineSeparator=Ma;he.readOnly=Ea;he.phrases=I.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(r=>n[r]==e[r])}});he.languageData=Ta;he.changeFilter=La;he.transactionFilter=Da;he.transactionExtender=Oa;xt.reconfigure=J.define();function ze(n,e,t={}){let i={};for(let r of n)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}var Ze=class{eq(e){return this==e}range(e,t=e){return Ji.create(e,t,this)}};Ze.prototype.startSide=Ze.prototype.endSide=0;Ze.prototype.point=!1;Ze.prototype.mapMode=Ce.TrackDel;var Ji=class n{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new n(e,t,i)}};function Us(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Ys=class n{constructor(e,t,i,r){this.from=e,this.to=t,this.value=i,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let i=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,p;if(c==f){let g=t.mapPos(c,h.startSide,h.mapMode);if(g==null||(u=p=g,h.startSide!=h.endSide&&(p=t.mapPos(c,h.endSide),p<u)))continue}else if(u=t.mapPos(c,h.startSide),p=t.mapPos(f,h.endSide),u>p||u==p&&h.startSide>0&&h.endSide<=0)continue;(p-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,p-u)),i.push(h),r.push(u-o),s.push(p-o))}return{mapped:i.length?new n(r,s,i,l):null,pos:o}}},ie=class n{constructor(e,t,i,r){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=r}static create(e,t,i,r){return new n(e,t,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Us)),this.isEmpty)return t.length?n.of(t):this;let l=new Qn(this,null,-1).goto(0),a=0,h=[],c=new ot;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(Ji.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?n.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),t.push(c),i.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new n(i,t,s||n.empty,r)}between(e,t,i){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Xi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Xi.from(e).goto(t)}static compare(e,t,i,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=ka(o,l,i),h=new Jt(o,a,s),c=new Jt(l,a,s);i.iterGaps((f,u,p)=>ya(h,f,c,u,p,r)),i.empty&&i.length==0&&ya(h,0,c,0,0,r)}static eq(e,t,i=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ka(s,o),a=new Jt(s,l,0).goto(i),h=new Jt(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Js(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,i,r,s=-1){let o=new Jt(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new ot;for(let r of e instanceof Ji?[e]:t?wd(e):e)i.add(r.from,r.to,r.value);return i.finish()}};ie.empty=new ie([],[],null,-1);function wd(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(Us(e,i)>0)return n.slice().sort(Us);e=i}return n}ie.empty.nextLayer=ie.empty;var ot=class n{finishChunk(e){this.chunks.push(new Ys(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new n)).add(e,t,i)}addInner(e,t,i){let r=e-this.lastTo||i.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ie.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=ie.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function ka(n,e,t){let i=new Map;for(let s of n)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+s.chunk[o].length))&&r.add(s.chunk[o])}return r}var Qn=class{constructor(e,t,i,r=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},Xi=class n{constructor(e){this.heap=e}static from(e,t=null,i=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&r.push(new Qn(o,t,i,s));return r.length==1?r[0]:new n(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)zs(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)zs(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),zs(this.heap,0)}}};function zs(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let r=n[i];if(i+1<n.length&&r.compare(n[i+1])>=0&&(r=n[i+1],i++),t.compare(r)<0)break;n[i]=t,n[e]=r,e=i}}var Jt=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Xi.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Kn(this.active,e),Kn(this.activeTo,e),Kn(this.activeRank,e),this.minActive=wa(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&this.activeRank[t]<=s;)t++;_n(this.active,t,i),_n(this.activeTo,t,r),_n(this.activeRank,t,s),e&&_n(e,t,this.cursor.from),this.minActive=wa(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&Kn(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let r=i.length-1;r>=0&&i[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function ya(n,e,t,i,r,s){n.goto(e),t.goto(i);let o=i+r,l=i,a=i-e;for(;;){let h=n.to+a-t.to||n.endSide-t.endSide,c=h<0?n.to+a:t.to,f=Math.min(c,o);if(n.point||t.point?n.point&&t.point&&(n.point==t.point||n.point.eq(t.point))&&Js(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,f,n.point,t.point):f>l&&!Js(n.active,t.active)&&s.compareRange(l,f,n.active,t.active),c>o)break;l=c,h<=0&&n.next(),h>=0&&t.next()}}function Js(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!n[t].eq(e[t]))return!1;return!0}function Kn(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function _n(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function wa(n,e){let t=-1,i=1e9;for(let r=0;r<e.length;r++)(e[r]-i||n[r].endSide-n[t].endSide)<0&&(t=r,i=e[r]);return t}function Dt(n,e,t=n.length){let i=0;for(let r=0;r<t;)n.charCodeAt(r)==9?(i+=e-i%e,r++):(i++,r=be(n,r));return i}function Ra(n,e,t,i){for(let r=0,s=0;;){if(s>=e)return r;if(r==n.length)break;s+=n.charCodeAt(r)==9?t-s%t:1,r=be(n,r)}return i===!0?-1:n.length}var Qs="\u037C",Ia=typeof Symbol=="undefined"?"__"+Qs:Symbol.for(Qs),eo=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Na=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},Ke=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let p in l){let g=l[p];if(/&/.test(p))s(p.split(/,\s*/).map(x=>o.map(y=>x.replace(/&/,y))).reduce((x,y)=>x.concat(y)),g,a);else if(g&&typeof g=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),g,c,u)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,x=>"-"+x.toLowerCase())+": "+g+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
6
+ `)}static newName(){let e=Na[Ia]||1;return Na[Ia]=e+1,Qs+e.toString(36)}static mount(e,t,i){let r=e[eo],s=i&&i.nonce;r?s&&r.setNonce(s):r=new to(e,s),r.mount(Array.isArray(t)?t:[t])}},za=new Map,to=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=za.get(i);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[eo]=s;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],za.set(i,this)}else{this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);let s=e.head||e;s.insertBefore(this.styleTag,s.firstChild)}this.modules=[],e[eo]=this}mount(e){let t=this.sheet,i=0,r=0;for(let s=0;s<e.length;s++){let o=e[s],l=this.modules.indexOf(o);if(l<r&&l>-1&&(this.modules.splice(l,1),r--,l=-1),l==-1){if(this.modules.splice(r++,0,o),t)for(let a=0;a<o.rules.length;a++)t.insertRule(o.rules[a],i++)}else{for(;r<l;)i+=this.modules[r++].rules.length;i+=o.rules.length,r++}}if(!t){let s="";for(let o=0;o<this.modules.length;o++)s+=this.modules[o].getRules()+`
7
+ `;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var vt={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:"'"},xi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},xd=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),vd=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ke=0;ke<10;ke++)vt[48+ke]=vt[96+ke]=String(ke);var ke;for(ke=1;ke<=24;ke++)vt[ke+111]="F"+ke;var ke;for(ke=65;ke<=90;ke++)vt[ke]=String.fromCharCode(ke+32),xi[ke]=String.fromCharCode(ke);var ke;for(tr in vt)xi.hasOwnProperty(tr)||(xi[tr]=vt[tr]);var tr;function Fa(n){var e=xd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||vd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?xi:vt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function mr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function co(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Sd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function fr(n,e){if(!e.anchorNode)return!1;try{return co(n,e.anchorNode)}catch(t){return!1}}function cn(n){return n.nodeType==3?Qt(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function gr(n,e,t,i){return t?Ha(n,e,t,i,-1)||Ha(n,e,t,i,1):!1}function fn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Ha(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:St(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=fn(n)+(r<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(r<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=r<0?St(n):0}else return!1}}function St(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Go(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Cd(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Ch(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Ad(n,e,t,i,r,s,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,p=c==a.body,g=1,x=1;if(p)u=Cd(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let M=c.getBoundingClientRect();({scaleX:g,scaleY:x}=Ch(c,M)),u={left:M.left,right:M.left+c.clientWidth*g,top:M.top,bottom:M.top+c.clientHeight*x}}let y=0,v=0;if(r=="nearest")e.top<u.top?(v=-(u.top-e.top+o),t>0&&e.bottom>u.bottom+v&&(v=e.bottom-u.bottom+v+o)):e.bottom>u.bottom&&(v=e.bottom-u.bottom+o,t<0&&e.top-v<u.top&&(v=-(u.top+v-e.top+o)));else{let M=e.bottom-e.top,O=u.bottom-u.top;v=(r=="center"&&M<=O?e.top+M/2-O/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-O+o)-u.top}if(i=="nearest"?e.left<u.left?(y=-(u.left-e.left+s),t>0&&e.right>u.right+y&&(y=e.right-u.right+y+s)):e.right>u.right&&(y=e.right-u.right+s,t<0&&e.left<u.left+y&&(y=-(u.left+y-e.left+s))):y=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,y||v)if(p)h.scrollBy(y,v);else{let M=0,O=0;if(v){let R=c.scrollTop;c.scrollTop+=v/x,O=(c.scrollTop-R)*x}if(y){let R=c.scrollLeft;c.scrollLeft+=y/g,M=(c.scrollLeft-R)*g}e={left:e.left-M,top:e.top-O,right:e.right-M,bottom:e.bottom-O},M&&Math.abs(M-y)<1&&(i="nearest"),O&&Math.abs(O-v)<1&&(r="nearest")}if(p)break;c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Td(n){let e=n.ownerDocument;for(let t=n.parentNode;t&&t!=e.body;)if(t.nodeType==1){if(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var fo=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?St(t):0),i,Math.min(e.focusOffset,i?St(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},vi=null;function Ah(n){if(n.setActive)return n.setActive();if(vi)return n.focus(vi);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(vi==null?{get preventScroll(){return vi={preventScroll:!0},!0}}:void 0),!vi){vi=!1;for(let t=0;t<e.length;){let i=e[t++],r=e[t++],s=e[t++];i.scrollTop!=r&&(i.scrollTop=r),i.scrollLeft!=s&&(i.scrollLeft=s)}}}var Va;function Qt(n,e,t=e){let i=Va||(Va=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Ti(n,e,t){let i={key:e,code:e,keyCode:t,which:t,cancelable:!0},r=new KeyboardEvent("keydown",i);r.synthetic=!0,n.dispatchEvent(r);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,n.dispatchEvent(s),r.defaultPrevented||s.defaultPrevented}function Md(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Th(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}function Ld(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,St(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=St(t))}else{if(t==n)return!0;i=fn(t),t=t.parentNode}}function Mh(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}var Oe=class n{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new n(e.parentNode,fn(e),t)}static after(e,t){return new n(e.parentNode,fn(e)+1,t)}},Uo=[],ue=class n{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:i.firstChild)){let l=n.get(s);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&s!=o.dom&&(t.written=!0),o.dom.parentNode==i)for(;s&&s!=o.dom;)s=Wa(s);else i.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:i.firstChild,s&&t&&t.node==i&&(t.written=!0);s;)s=Wa(s)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let r=St(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!n.get(i);)i=i.nextSibling;if(!i)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==i)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,i=0){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<this.children.length;a++){let f=this.children[a],u=h+f.length;if(h<e&&u>t)return f.domBoundsAround(e,t,h);if(u>=e&&r==-1&&(r=a,s=h),h>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?i+this.length:l,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=Uo){this.markDirty();for(let r=e;r<t;r++){let s=this.children[r];s.parent==this&&i.indexOf(s)<0&&s.destroy()}this.children.splice(e,t-e,...i);for(let r=0;r<i.length;r++)i[r].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new br(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,r,s,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}};ue.prototype.breakAfter=0;function Wa(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var br=class{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}};function Lh(n,e,t,i,r,s,o,l,a){let{children:h}=n,c=h.length?h[e]:null,f=s.length?s[s.length-1]:null,u=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!u&&s.length<2&&c.merge(t,r,s.length?f:null,t==0,l,a))){if(i<h.length){let p=h[i];p&&(r<p.length||p.breakAfter&&(f!=null&&f.breakAfter))?(e==i&&(p=p.split(r),r=0),!u&&f&&p.merge(0,r,f,!0,0,a)?s[s.length-1]=p:((r||p.children.length&&!p.children[0].length)&&p.merge(0,r,null,!1,0,a),s.push(p))):p!=null&&p.breakAfter&&(f?f.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,t>0&&(!o&&s.length&&c.merge(t,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(t<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(t,c.length,null,!1,l,0),e++));e<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[e].become(s[0]))e++,s.shift(),l=s.length?0:a;else break;!s.length&&e&&i<h.length&&!h[e-1].breakAfter&&h[i].merge(0,0,h[e-1],!1,l,a)&&e--,(e<i||s.length)&&n.replaceChildren(e,i,s)}}function Dh(n,e,t,i,r,s){let o=n.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:h,off:c}=o.findPos(e,-1),f=e-t;for(let u of i)f+=u.length;n.length+=f,Lh(n,h,c,l,a,i,0,r,s)}var Fe=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},uo=typeof document!="undefined"?document:{documentElement:{style:{}}},po=/Edge\/(\d+)/.exec(Fe.userAgent),Oh=/MSIE \d/.test(Fe.userAgent),mo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Fe.userAgent),Er=!!(Oh||mo||po),ja=!Er&&/gecko\/(\d+)/i.test(Fe.userAgent),io=!Er&&/Chrome\/(\d+)/.exec(Fe.userAgent),qa="webkitFontSmoothing"in uo.documentElement.style,Eh=!Er&&/Apple Computer/.test(Fe.vendor),$a=Eh&&(/Mobile\/\w+/.test(Fe.userAgent)||Fe.maxTouchPoints>2),H={mac:$a||/Mac/.test(Fe.platform),windows:/Win/.test(Fe.platform),linux:/Linux|X11/.test(Fe.platform),ie:Er,ie_version:Oh?uo.documentMode||6:mo?+mo[1]:po?+po[1]:0,gecko:ja,gecko_version:ja?+(/Firefox\/(\d+)/.exec(Fe.userAgent)||[0,0])[1]:0,chrome:!!io,chrome_version:io?+io[1]:0,ios:$a,android:/Android\b/.test(Fe.userAgent),webkit:qa,safari:Eh,webkit_version:qa?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:uo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Dd=256,Bt=class n extends ue{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof n)||this.length-(t-e)+i.length>Dd||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new n(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Oe(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Od(this.dom,e,t)}},Pt=class n extends ue{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let r of t)r.setParent(this)}setAttrs(e){if(Th(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,r,s,o){return i&&(!(i instanceof n&&i.mark.eq(this.mark))||e&&s<=0||t<this.length&&o<=0)?!1:(Dh(this,e,t,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(e){let t=[],i=0,r=-1,s=0;for(let l of this.children){let a=i+l.length;a>e&&t.push(i<e?l.split(e-i):l),r<0&&i>=e&&(r=s),i=a,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new n(this.mark,t,o)}domAtPos(e){return Bh(this,e)}coordsAt(e,t){return Rh(this,e,t)}};function Od(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let r=e,s=e,o=0;e==0&&t<0||e==i&&t>=0?H.chrome||H.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=Qt(n,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return H.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Go(a,o<0):a||null}var un=class n extends ue{static create(e,t,i){return new n(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=n.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof n&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return Z.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,r=this.posAtStart;return i?i.slice(r,r+this.length):Z.empty}domAtPos(e){return(this.length?e==0:this.side>0)?Oe.before(this.dom):Oe.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?r.length-1:0;s=r[l],!(e>0?l==0:l==r.length-1||s.top<s.bottom);l+=o?-1:1);return Go(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},dn=class n extends ue{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof n&&e.side==this.side}split(){return new n(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?Oe.before(this.dom):Oe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Z.empty}get isHidden(){return!0}};Bt.prototype.children=un.prototype.children=dn.prototype.children=Uo;function Bh(n,e){let t=n.dom,{children:i}=n,r=0;for(let s=0;r<i.length;r++){let o=i[r],l=s+o.length;if(!(l==s&&o.getSide()<=0)){if(e>s&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-s);if(e<=s)break;s=l}}for(let s=r;s>0;s--){let o=i[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s<i.length;s++){let o=i[s];if(o.dom.parentNode==t)return o.domAtPos(0)}return new Oe(t,0)}function Ph(n,e,t){let i,{children:r}=n;t>0&&e instanceof Pt&&r.length&&(i=r[r.length-1])instanceof Pt&&i.mark.eq(e.mark)?Ph(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function Rh(n,e,t){let i=null,r=-1,s=null,o=-1;function l(h,c){for(let f=0,u=0;f<h.children.length&&u<=c;f++){let p=h.children[f],g=u+p.length;g>=c&&(p.children.length?l(p,c-u):(!s||s.isHidden&&t>0)&&(g>c||u==g&&p.getSide()>0)?(s=p,o=c-u):(u<c||u==g&&p.getSide()<0&&!p.isHidden)&&(i=p,r=c-u)),u=g}}l(n,e);let a=(t<0?i:s)||i||s;return a?a.coordsAt(Math.max(0,a==i?r:o),t):Ed(n)}function Ed(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=cn(e);return t[t.length-1]||null}function go(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}var Ka=Object.create(null);function Yo(n,e,t){if(n==e)return!0;n||(n=Ka),e||(e=Ka);let i=Object.keys(n),r=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of i)if(s!=t&&(r.indexOf(s)==-1||n[s]!==e[s]))return!1;return!0}function bo(n,e,t){let i=!1;if(e)for(let r in e)t&&r in t||(i=!0,r=="style"?n.style.cssText="":n.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(i=!0,r=="style"?n.style.cssText=t[r]:n.setAttribute(r,t[r]));return i}function Bd(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}var Ae=class n extends ue{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,r,s,o){if(i){if(!(i instanceof n))return!1;this.dom||i.transferDOM(this)}return r&&this.setDeco(i?i.attrs:null),Dh(this,e,t,i?i.children.slice():[],s,o),!0}split(e){let t=new n;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:r}=this.childPos(e);r&&(t.append(this.children[i].split(r),0),this.children[i].merge(r,this.children[i].length,null,!1,0,0),i++);for(let s=i;s<this.children.length;s++)t.append(this.children[s],0);for(;i>0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Yo(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Ph(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=go(t,this.attrs||{})),i&&(this.attrs=go({class:i},this.attrs||{}))}domAtPos(e){return Bh(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Th(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(bo(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&ue.get(r)instanceof Pt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=ue.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!H.ios||!this.children.some(s=>s instanceof Bt))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Bt)||/[^ -~]/.test(i.text))return null;let r=cn(i.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=Rh(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=i.bottom-i.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight<s){let o=(s-r.textHeight)/2;return{top:i.top+o,bottom:i.bottom-o,left:i.left,right:i.left}}}return i}become(e){return!1}covers(){return!0}static find(e,t){for(let i=0,r=0;i<e.children.length;i++){let s=e.children[i],o=r+s.length;if(o>=t){if(s instanceof n)return s;if(o>t)break}r=o+s.breakAfter}return null}},Mi=class n extends ue{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,r,s,o){return i&&(!(i instanceof n)||!this.widget.compare(i.widget)||e>0&&s<=0||t<this.length&&o<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?Oe.before(this.dom):Oe.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new n(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Uo}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Z.empty}domBoundsAround(){return null}become(e){return e instanceof n&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){return this.widget.coordsAt(this.dom,e,t)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t==i?!1:e<0?t<0:i>0}},et=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}destroy(e){}},Qe=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Qe||(Qe={})),Y=class extends Ze{constructor(e,t,i,r){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=r}get heightRelevant(){return!1}static mark(e){return new pn(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Rt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=Ih(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Rt(e,i,r,t,e.widget||null,!0)}static line(e){return new mn(e)}static set(e,t=!1){return ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Y.none=ie.empty;var pn=class n extends Y{constructor(e){let{start:t,end:i}=Ih(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof n&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&Yo(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};pn.prototype.point=!1;var mn=class n extends Y{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Yo(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};mn.prototype.mapMode=Ce.TrackBefore;mn.prototype.point=!0;var Rt=class n extends Y{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ce.TrackBefore:Ce.TrackAfter:Ce.TrackDel}get type(){return this.startSide!=this.endSide?Qe.WidgetRange:this.startSide<=0?Qe.WidgetBefore:Qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Pd(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};Rt.prototype.point=!0;function Ih(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function Pd(n,e){return n==e||!!(n&&e&&n.compare(e))}function ko(n,e,t,i=0){let r=t.length-1;r>=0&&t[r]+i>=n?t[r]=Math.max(t[r],e):t.push(n,e)}var rn=class n{constructor(e,t,i,r){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Mi&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ae),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ir(new dn(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Mi)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(ir(new Bt(this.text.slice(this.textOff,this.textOff+r)),t),i),this.atCursorPos=!0,this.textOff+=r,e-=r,i=0}}span(e,t,i,r){this.buildText(t-e,i,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,i,r,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Rt){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof Rt)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Mi(i.widget||new kr("div"),l,i));else{let a=un.create(i.widget||new kr("span"),l,l?0:i.startSide),h=this.atCursorPos&&!a.isEditable&&s<=r.length&&(e<t||i.startSide>0),c=!a.isEditable&&(e<t||s>r.length||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),h&&(f.append(ir(new dn(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(ir(a,r),s),this.atCursorPos=c,this.pendingBuffer=c?e<t||s>r.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,i,r,s){let o=new n(e,t,i,s);return o.openEnd=ie.spans(r,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function ir(n,e){for(let t of e)n=new Pt(t,[n],n.length);return n}var kr=class extends et{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}},Nh=I.define(),zh=I.define(),Fh=I.define(),Hh=I.define(),yo=I.define(),Vh=I.define(),Wh=I.define(),jh=I.define({combine:n=>n.some(e=>e)}),Rd=I.define({combine:n=>n.some(e=>e)}),sn=class n{constructor(e,t="nearest",i="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new n(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new n(L.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},nr=J.define({map:(n,e)=>n.map(e)});function He(n,e,t){let i=n.facet(Hh);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var Br=I.define({combine:n=>n.length?n[0]:!0}),Id=0,Qi=I.define(),ye=class n{constructor(e,t,i,r,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=r,this.extension=s(this)}static define(e,t){let{eventHandlers:i,eventObservers:r,provide:s,decorations:o}=t||{};return new n(Id++,e,i,r,l=>{let a=[Qi.of(l)];return o&&a.push(gn.of(h=>{let c=h.plugin(l);return c?o(c):Y.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define(i=>new e(i),t)}},on=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(He(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(r){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){He(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){He(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},qh=I.define(),Jo=I.define(),gn=I.define(),Xo=I.define(),$h=I.define();function _a(n,e,t){let i=n.state.facet($h);if(!i.length)return i;let r=i.map(o=>o instanceof Function?o(n):o),s=[];return ie.spans(r,e,t,{point(){},span(o,l,a,h){let c=s;for(let f=a.length-1;f>=0;f--,h--){let u=a[f].spec.bidiIsolate,p;if(u!=null)if(h>0&&c.length&&(p=c[c.length-1]).to==o&&p.direction==u)p.to=l,c=p.inner;else{let g={from:o,to:l,direction:u,inner:[]};c.push(g),c=g.inner}}}}),s}var Kh=I.define();function _h(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(Kh)){let o=s(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:i,bottom:r}}var en=I.define(),ct=class n{constructor(e,t,i,r){this.fromA=e,this.toA=t,this.fromB=i,this.toB=r}join(e){return new n(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>i.toA)){if(r.toA<i.fromA)break;i=i.join(r),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let r=0,s=0,o=0,l=0;;r++){let a=r==e.length?null:e[r],h=o-l,c=a?a.fromB:1e9;for(;s<t.length&&t[s]<c;){let f=t[s],u=t[s+1],p=Math.max(l,f),g=Math.min(c,u);if(p<=g&&new n(p+h,g+h,p,g).addToSet(i),u>c)break;s+=2}if(!a)return i;new n(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}},yr=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=De.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new ct(s,o,l,a))),this.changedRanges=r}static create(e,t,i){return new n(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},ge=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(ge||(ge={})),bn=ge.LTR,Gh=ge.RTL;function Uh(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var Nd=Uh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),zd=Uh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),wo=Object.create(null),lt=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);wo[e]=t,wo[t]=-e}function Fd(n){return n<=247?Nd[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?zd[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var Hd=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,ht=class{get dir(){return this.level%2?Gh:bn}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}static find(e,t,i,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function Yh(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],r=e[t];if(i.from!=r.from||i.to!=r.to||i.direction!=r.direction||!Yh(i.inner,r.inner))return!1}return!0}var oe=[];function Vd(n,e,t,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=Fd(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),oe[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=oe[h];if(u==128)h<l-1&&c==oe[h+1]&&c&24?u=oe[h]=c:oe[h]=256;else if(u==64){let p=h+1;for(;p<l&&oe[p]==64;)p++;let g=h&&c==8||p<t&&oe[p]==8?f==1?1:8:256;for(let x=h;x<p;x++)oe[x]=g;h=p-1}else u==8&&f==1&&(oe[h]=1);c=u,u&7&&(f=u)}}}function Wd(n,e,t,i,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,p,g;f<c;f++)if(p=wo[u=n.charCodeAt(f)])if(p<0){for(let x=l-3;x>=0;x-=3)if(lt[x+1]==-p){let y=lt[x+2],v=y&2?r:y&4?y&1?s:r:0;v&&(oe[f]=oe[lt[x]]=v),l=x;break}}else{if(lt.length==189)break;lt[l++]=f,lt[l++]=u,lt[l++]=a}else if((g=oe[f])==2||g==1){let x=g==r;a=x?0:1;for(let y=l-3;y>=0;y-=3){let v=lt[y+2];if(v&2)break;if(x)lt[y+2]|=2;else{if(v&4)break;lt[y+2]|=4}}}}}function jd(n,e,t,i){for(let r=0,s=i;r<=t.length;r++){let o=r?t[r-1].to:n,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=oe[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(oe[c]==256)c++;else break;let f=s==1,u=(c<e?oe[c]:i)==1,p=f==u?f?1:2:i;for(let g=c,x=r,y=x?t[x-1].to:n;g>a;)g==y&&(g=t[--x].from,y=x?t[x-1].to:n),oe[--g]=p;a=c}else s=h,a++}}}function xo(n,e,t,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let x=oe[a];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h<s.length&&g==s[h].from){if(f)break e;let x=s[h];if(!c)for(let y=x.to,v=h+1;;){if(y==t)break e;if(v<s.length&&s[v].from==y)y=s[v++].to;else{if(oe[y]==l)break e;break}}if(h++,u)u.push(x);else{x.from>a&&o.push(new ht(a,x.from,p));let y=x.direction==bn!=!(p%2);vo(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.to}g=x.to}else{if(g==t||(c?oe[g]!=l:oe[g]==l))break;g++}u?xo(n,a,g,i+1,r,u,o):a<g&&o.push(new ht(a,g,p)),a=g}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let x=oe[a-1];x!=l&&(c=!1,f=x==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,g=a;e:for(;;)if(h&&g==s[h-1].to){if(f)break e;let x=s[--h];if(!c)for(let y=x.from,v=h;;){if(y==e)break e;if(v&&s[v-1].to==y)y=s[--v].from;else{if(oe[y-1]==l)break e;break}}if(u)u.push(x);else{x.to<a&&o.push(new ht(x.to,a,p));let y=x.direction==bn!=!(p%2);vo(n,y?i+1:i,r,x.inner,x.from,x.to,o),a=x.from}g=x.from}else{if(g==e||(c?oe[g-1]!=l:oe[g-1]==l))break;g--}u?xo(n,g,a,i+1,r,u,o):g<a&&o.push(new ht(g,a,p)),a=g}}function vo(n,e,t,i,r,s,o){let l=e%2?2:1;Vd(n,r,s,i,l),Wd(n,r,s,i,l),jd(r,s,i,l),xo(n,r,s,e,t,i,o)}function qd(n,e,t){if(!n)return[new ht(0,0,e==Gh?1:0)];if(e==bn&&!t.length&&!Hd.test(n))return Jh(n.length);if(t.length)for(;n.length>oe.length;)oe[oe.length]=256;let i=[],r=e==bn?0:1;return vo(n,r,r,t,0,n.length,i),i}function Jh(n){return[new ht(0,n,0)]}var Xh="";function $d(n,e,t,i,r){var s;let o=i.head-n.from,l=-1;if(o==0){if(!r||!n.length)return null;e[0].level!=t&&(o=e[0].side(!1,t),l=0)}else if(o==n.length){if(r)return null;let u=e[e.length-1];u.level!=t&&(o=u.side(!0,t),l=e.length-1)}l<0&&(l=ht.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc));let a=e[l];o==a.side(r,t)&&(a=e[l+=r?1:-1],o=a.side(!r,t));let h=r==(a.dir==t),c=be(n.text,o,h);if(Xh=n.text.slice(Math.min(o,c),Math.max(o,c)),c>a.from&&c<a.to)return L.cursor(c+n.from,h?-1:1,a.level);let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return!f&&a.level!=t?L.cursor(r?n.to:n.from,r?-1:1,t):f&&f.level<a.level?L.cursor(f.side(!r,t)+n.from,r?1:-1,f.level):L.cursor(c+n.from,r?-1:1,a.level)}var wr=class extends ue{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ae],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ct(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:c})=>c<this.minWidthFrom||h>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let r=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!Xd(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?_d(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new ct(h,c,e.changes.mapPos(h,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(H.ie||H.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=Yd(o,l,e.changes);return i=ct.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=H.chrome||H.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Mi&&o.widget instanceof xr&&s.push(o.dom);r.updateGaps(s)}updateChildren(e,t,i){let r=i?i.range.addToSet(e.slice()):e,s=this.childCursor(t);for(let o=r.length-1;;o--){let l=o>=0?r[o]:null;if(!l)break;let{fromA:a,toA:h,fromB:c,toB:f}=l,u,p,g,x;if(i&&i.range.fromB<f&&i.range.toB>c){let R=rn.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),F=rn.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);p=R.breakAtStart,g=R.openStart,x=F.openEnd;let q=this.compositionView(i);F.breakAtStart?q.breakAfter=1:F.content.length&&q.merge(q.length,q.length,F.content[0],!1,F.openStart,0)&&(q.breakAfter=F.content[0].breakAfter,F.content.shift()),R.content.length&&q.merge(0,0,R.content[R.content.length-1],!0,0,R.openEnd)&&R.content.pop(),u=R.content.concat(q).concat(F.content)}else({content:u,breakAtStart:p,openStart:g,openEnd:x}=rn.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:y,off:v}=s.findPos(h,1),{i:M,off:O}=s.findPos(a,-1);Lh(this,M,O,y,v,u,p,g,x)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new Bt(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Pt(r,[t],t.length);let i=new Ae;return i.append(t,0),i}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=ue.get(s);l&&l!=o&&(l.dom=null),o.setDOM(s)},i=this.childPos(e.range.fromB,1),r=this.children[i.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)i=r.childPos(i.off,1),r=r.children[i.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&fr(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(H.gecko&&l.empty&&!this.hasComposition&&Kd(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=h=new Oe(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||!gr(a.node,a.offset,c.anchorNode,c.anchorOffset)||!gr(h.node,h.offset,c.focusNode,c.focusOffset))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(c.focusNode)&&Jd(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=mr(this.view.root);if(f)if(l.empty){if(H.gecko){let u=Gd(a.node,a.offset);if(u&&u!=3){let p=Qh(a.node,a.offset,u==1?1:-1);p&&(a=new Oe(p.node,p.offset))}}f.collapse(a.node,a.offset),l.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(a.node,a.offset);try{f.extend(h.node,h.offset)}catch(u){}}else{let u=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),u.setEnd(h.node,h.offset),u.setStart(a.node,a.offset),f.removeAllRanges(),f.addRange(u)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new Oe(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new Oe(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=mr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=Ae.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(r,s)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let r=e.offset;!i&&r<t.childNodes.length;r++){let s=ue.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(0))}for(let r=e.offset-1;!i&&r>=0;r--){let s=ue.get(t.childNodes[r]);s instanceof Ae&&(i=s.domAtPos(s.length))}return i?new Oe(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=ue.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let r=this.children[t];if(i<r.length||r instanceof Ae)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,r=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],a=s-l.breakAfter,h=a-l.length;if(a<e)break;h<=e&&(h<e||l.covers(-1))&&(a>e||l.covers(1))&&(!i||l instanceof Ae&&!(i instanceof Ae&&t>=0))&&(i=l,r=h),s=h}return i?i.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Ae))return null;for(;r.children.length;){let{i:l,off:a}=r.childPos(i,1);for(;;l++){if(l==r.children.length)return null;if((r=r.children[l]).length)break}i=a}if(!(r instanceof Bt))return null;let s=be(r.text,i);if(s==i)return null;let o=Qt(r.dom,i,s).getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(l==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ge.LTR;for(let h=0,c=0;c<this.children.length;c++){let f=this.children[c],u=h+f.length;if(u>r)break;if(h>=i){let p=f.dom.getBoundingClientRect();if(t.push(p.height),o){let g=f.dom.lastChild,x=g?cn(g):[];if(x.length){let y=x[x.length-1],v=a?y.right-p.left:p.right-y.left;v>l&&(l=v,this.minWidth=s,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?ge.RTL:ge.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ae){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,r;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=cn(e.firstChild)[0];t=e.getBoundingClientRect().height,i=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new br(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Y.replace({widget:new xr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Y.set(e)}updateDeco(){let e=this.view.state.facet(gn).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;t<e.length+3;t++)this.dynamicDecorationMap[t]=!1;return this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!i)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=_h(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;Ad(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==ge.LTR)}};function Kd(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}var xr=class extends et{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}};function Zh(n,e){let t=n.observer.selectionRange,i=t.focusNode&&Qh(t.focusNode,t.focusOffset,0);if(!i)return null;let r=e-i.offset;return{from:r,to:r+i.node.nodeValue.length,node:i.node}}function _d(n,e,t){let i=Zh(n,t);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc,h=new ct(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let f=r.parentNode;;f=f.parentNode){let u=ue.get(f);if(u instanceof Pt)c.push({node:f,deco:u.mark});else{if(u instanceof Ae||f.nodeName=="DIV"&&f.parentNode==n.contentDOM)return{range:h,text:r,marks:c,line:f};if(f!=n.contentDOM)c.push({node:f,deco:new pn({inclusive:!0,attributes:Bd(f),tagName:f.tagName.toLowerCase()})});else return null}}}function Qh(n,e,t){if(t<=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r>0)i=i.childNodes[r-1],r=St(i);else break}if(t>=0)for(let i=n,r=e;;){if(i.nodeType==3)return{node:i,offset:r};if(i.nodeType==1&&r<i.childNodes.length&&t>=0)i=i.childNodes[r],r=0;else break}return null}function Gd(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}var Ud=class{constructor(){this.changes=[]}compareRange(e,t){ko(e,t,this.changes)}comparePoint(e,t){ko(e,t,this.changes)}};function Yd(n,e,t){let i=new Ud;return ie.compare(n,e,t,i),i.changes}function Jd(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Xd(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}function Zd(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return L.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=be(r.text,s,!1):l=be(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=be(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=be(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return L.range(o+r.from,l+r.from)}function Qd(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function ep(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function no(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function Ga(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function Ua(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function So(n,e,t){let i,r,s,o,l=!1,a,h,c,f;for(let g=n.firstChild;g;g=g.nextSibling){let x=cn(g);for(let y=0;y<x.length;y++){let v=x[y];r&&no(r,v)&&(v=Ga(Ua(v,r.bottom),r.top));let M=Qd(e,v),O=ep(t,v);if(M==0&&O==0)return g.nodeType==3?Ya(g,e,t):So(g,e,t);if(!i||o>O||o==O&&s>M){i=g,r=v,s=M,o=O;let R=O?t<v.top?-1:1:M?e<v.left?-1:1:0;l=!R||(R>0?y<x.length-1:y>0)}M==0?t>v.bottom&&(!c||c.bottom<v.bottom)?(a=g,c=v):t<v.top&&(!f||f.top>v.top)&&(h=g,f=v):c&&no(c,v)?c=Ua(c,v.bottom):f&&no(f,v)&&(f=Ga(f,v.top))}}if(c&&c.bottom>=t?(i=a,r=c):f&&f.top<=t&&(i=h,r=f),!i)return{node:n,offset:0};let u=Math.max(r.left,Math.min(r.right,e));if(i.nodeType==3)return Ya(i,u,t);if(l&&i.contentEditable!="false")return So(i,u,t);let p=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(r.left+r.right)/2?1:0);return{node:n,offset:p}}function Ya(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let a=Qt(n,l,l+1).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(c.top==c.bottom)continue;o||(o=e-c.left);let f=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f<s){let u=e>=(c.left+c.right)/2,p=u;if((H.chrome||H.gecko)&&Qt(n,l).getBoundingClientRect().left==c.right&&(p=!u),f<=0)return{node:n,offset:l+(p?1:0)};r=l+(p?1:0),s=f}}}return{node:n,offset:r>-1?r:o>0?n.nodeValue.length:0}}function ec(n,e,t,i=-1){var r,s;let o=n.contentDOM.getBoundingClientRect(),l=o.top+n.viewState.paddingTop,a,{docHeight:h}=n.viewState,{x:c,y:f}=e,u=f-l;if(u<0)return 0;if(u>h)return n.state.doc.length;for(let R=n.viewState.heightOracle.textHeight/2,F=!1;a=n.elementAtHeight(u),a.type!=Qe.Text;)for(;u=i>0?a.bottom+R:a.top-R,!(u>=0&&u<=h);){if(F)return t?null:0;F=!0,i=-i}f=l+u;let p=a.from;if(p<n.viewport.from)return n.viewport.from==0?0:t?null:Ja(n,o,a,c,f);if(p>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:Ja(n,o,a,c,f);let g=n.dom.ownerDocument,x=n.root.elementFromPoint?n.root:g,y=x.elementFromPoint(c,f);y&&!n.contentDOM.contains(y)&&(y=null),y||(c=Math.max(o.left+1,Math.min(o.right-1,c)),y=x.elementFromPoint(c,f),y&&!n.contentDOM.contains(y)&&(y=null));let v,M=-1;if(y&&((r=n.docView.nearest(y))===null||r===void 0?void 0:r.isEditable)!=!1){if(g.caretPositionFromPoint){let R=g.caretPositionFromPoint(c,f);R&&({offsetNode:v,offset:M}=R)}else if(g.caretRangeFromPoint){let R=g.caretRangeFromPoint(c,f);R&&({startContainer:v,startOffset:M}=R,(!n.contentDOM.contains(v)||H.safari&&tp(v,M,c)||H.chrome&&ip(v,M,c))&&(v=void 0))}}if(!v||!n.docView.dom.contains(v)){let R=Ae.find(n.docView,p);if(!R)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:M}=So(R.dom,c,f))}let O=n.docView.nearest(v);if(!O)return null;if(O.isWidget&&((s=O.dom)===null||s===void 0?void 0:s.nodeType)==1){let R=O.dom.getBoundingClientRect();return e.y<R.top||e.y<=R.bottom&&e.x<=(R.left+R.right)/2?O.posAtStart:O.posAtEnd}else return O.localPosFromDOM(v,M)+O.posAtStart}function Ja(n,e,t,i,r){let s=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(n.defaultLineHeight-l)*.5)/l);s+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Ra(o,s,n.state.tabSize)}function tp(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let r=n.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Qt(n,i-1,i).getBoundingClientRect().left>t}function ip(n,e,t){if(e!=0)return!1;for(let r=n;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let i=n.nodeType==1?n.getBoundingClientRect():Qt(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function np(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==Qe.Text))return i}return t}function rp(n,e,t,i){let r=np(n,e.head),s=!i||r.type!=Qe.Text||!(n.lineWrapping||r.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(r.from),a=n.posAtCoords({x:t==(l==ge.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return L.cursor(a,t?-1:1)}return L.cursor(t?r.to:r.from,t?-1:1)}function Xa(n,e,t,i){let r=n.state.doc.lineAt(e.head),s=n.bidiSpans(r),o=n.textDirectionAt(r.from);for(let l=e,a=null;;){let h=$d(r,s,o,l,t),c=Xh;if(!h){if(r.number==(t?n.state.doc.lines:1))return l;c=`
8
+ `,r=n.state.doc.line(r.number+(t?1:-1)),s=n.bidiSpans(r),h=L.cursor(t?r.from:r.to)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function sp(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==fe.Space&&(r=o),r==o}}function op(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return L.cursor(r,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(r,e.assoc||-1),c=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=i!=null?i:n.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let g=l+(u+p)*s,x=ec(n,{x:f,y:g},!1,s);if(g<a.top||g>a.bottom||(s<0?x<r:x>r)){let y=n.docView.coordsForChar(x),v=!y||g<y.top?-1:1;return L.cursor(x,v,void 0,o)}}}function ur(n,e,t){for(;;){let i=0;for(let r of n)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=i||t||(e-s<o-e?-1:1);e=a<0?s:o,i=a}});if(!i)return e}}function ro(n,e,t){let i=ur(n.state.facet(Xo).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:L.cursor(i,i<t.from?1:-1)}var Co=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,H.safari&&e.contentDOM.addEventListener("input",()=>null),H.gecko&&xp(e.contentDOM.ownerDocument)}handleEvent(e){!dp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,t);for(let r of i.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=lp(e),i=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&ic.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),H.android&&H.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return H.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=tc.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||ap.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,Ti(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:H.safari&&!H.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Za(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){He(t.state,r)}}}function lp(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let r=i.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(Za(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(Za(i.value,o))}}for(let i in tt)t(i).handlers.push(tt[i]);for(let i in it)t(i).observers.push(it[i]);return e}var tc=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ap="dthko",ic=[16,17,18,20,91,92,224,225],rr=6;function sr(n){return Math.max(0,n)*.7+8}function hp(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var Ao=class{constructor(e,t,i,r){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=Td(e.contentDOM),this.atoms=e.state.facet(Xo).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(he.allowMultipleSelections)&&cp(e,t),this.dragging=up(e,t)&&oc(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&hp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let i=0,r=0,s=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=_h(this.view);e.clientX-o.left<=s.left+rr?i=-sr(s.left-e.clientX):e.clientX+o.right>=s.right-rr&&(i=sr(e.clientX-s.right)),e.clientY-o.top<=s.top+rr?r=-sr(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-rr&&(r=sr(e.clientY-s.bottom)),this.setScrollSpeed(i,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let r=e.ranges[i],s=null;if(r.empty){let o=ur(this.atoms,r.from,0);o!=r.from&&(s=L.cursor(o,-1))}else{let o=ur(this.atoms,r.from,-1),l=ur(this.atoms,r.to,1);(o!=r.from||l!=r.to)&&(s=L.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?L.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection)||i.main.assoc!=t.state.selection.main.assoc&&this.dragging===!1)&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function cp(n,e){let t=n.state.facet(Nh);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function fp(n,e){let t=n.state.facet(zh);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function up(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=mr(n.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function dp(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=ue.get(t))&&i.ignoreEvent(e))return!1;return!0}var tt=Object.create(null),it=Object.create(null),nc=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function pp(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),rc(n,t.value)},50)}function rc(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(To!=null&&t.selection.ranges.every(a=>a.empty)&&To==s.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:L.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:L.cursor(a.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}it.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};tt.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);it.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};it.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};tt.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(Fh))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=bp(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Ao(n,e,t,i)),i&&n.observer.ignore(()=>Ah(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function Qa(n,e,t,i){if(i==1)return L.cursor(e,t);if(i==2)return Zd(n.state,e,t);{let r=Ae.find(n.docView,e),s=n.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<n.state.doc.length&&l==s.to&&l++,L.range(o,l)}}var sc=(n,e)=>n>=e.top&&n<=e.bottom,eh=(n,e,t)=>sc(e,t)&&n>=t.left&&n<=t.right;function mp(n,e,t,i){let r=Ae.find(n.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&eh(t,i,o))return-1;let l=r.coordsAt(s,1);return l&&eh(t,i,l)?1:o&&sc(i,o)?-1:1}function th(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:mp(n,t,e.clientX,e.clientY)}}var gp=H.ie&&H.ie_version<=11,ih=null,nh=0,rh=0;function oc(n){if(!gp)return n.detail;let e=ih,t=rh;return ih=n,rh=Date.now(),nh=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(nh+1)%3:1}function bp(n,e){let t=th(n,e),i=oc(e),r=n.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=th(n,s),h,c=Qa(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=Qa(n,t.pos,t.bias,i),u=Math.min(f.from,c.from),p=Math.max(f.to,c.to);c=u<c.from?L.range(u,p):L.range(p,u)}return o?r.replaceRange(r.main.extend(c.from,c.to)):l&&i==1&&r.ranges.length>1&&(h=kp(r,a.pos))?h:l?r.addRange(c):L.create([c])}}}function kp(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:r}=n.ranges[t];if(i<=e&&r>=e)return L.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}tt.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let r=n.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=L.range(s,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};tt.dragend=n=>(n.inputState.draggedContent=null,!1);function sh(n,e,t,i){if(!t)return;let r=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=n.inputState,o=i&&s&&fp(n,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}tt.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),r=0,s=()=>{++r==t.length&&sh(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return sh(n,e,i,!0),!0}return!1};tt.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=nc?null:e.clipboardData;return t?(rc(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(pp(n),!1)};function yp(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function wp(n){let e=[],t=[],i=!1;for(let r of n.selection.ranges)r.empty||(e.push(n.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of n.selection.ranges){let o=n.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),r=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}var To=null;tt.copy=tt.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=wp(n.state);if(!t&&!r)return!1;To=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=nc?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(yp(n,t),!1)};var lc=Ne.define();function ac(n,e){let t=[];for(let i of n.facet(Wh)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:lc.of(!0)}):null}function hc(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=ac(n.state,e);t?n.dispatch(t):n.update([])}},10)}it.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),hc(n)};it.blur=n=>{n.observer.clearSelectionRange(),hc(n)};it.compositionstart=it.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};it.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,H.chrome&&H.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};it.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};tt.beforeinput=(n,e)=>{var t;let i;if(H.chrome&&H.android&&(i=tc.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return!1};var oh=new Set;function xp(n){oh.has(n)||(oh.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var lh=["pre-wrap","normal","pre-line","break-spaces"],Mo=class{constructor(e){this.lineWrapping=e,this.doc=Z.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lh.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,i,r,s,o){let l=lh.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}},Lo=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},at=class n{constructor(e,t,i,r,s){this.from=e,this.length=t,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Rt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new n(this.from,this.length+e.length,this.top,this.height+e.height,t)}},ce=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(ce||(ce={})),dr=.001,Ve=class n{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>dr&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return n.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,ce.ByPosNoHeight,i.setDoc(t),0,0),p=u.to>=h?u:s.lineAt(h,ce.ByPosNoHeight,i,0,0);for(f+=p.to-h,h=p.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,ce.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let g=Oo.build(i.setDoc(o),e,c,f);s=s.replace(a,h,g)}return s.updateHeight(i,0)}static empty(){return new _e(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,r=0,s=0;for(;;)if(t==i)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Do(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};Ve.prototype.size=1;var vr=class extends Ve{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,r){return new at(r,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,r,s){return this.blockAt(0,i,r,s)}forEachLine(e,t,i,r,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,i,r,s))}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},_e=class n extends vr{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new at(r,this.length,i,this.height,this.breaks)}replace(e,t,i){let r=i[0];return i.length==1&&(r instanceof n||r instanceof Et&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Et?r=new n(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ve.of(i)}updateHeight(e,t=0,i=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},Et=class n extends Ve{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new at(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(s+h);return new at(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==ce.ByHeight)return this.blockAt(e,i,r,s);if(t==ce.ByPosNoHeight){let{from:p,to:g}=i.doc.lineAt(e);return new at(p,g-p,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,s),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new at(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,i,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,s);for(let c=e,f=r;c<=t;){let u=i.doc.lineAt(c);if(c==e){let g=u.number-l;f+=a*g+h*(e-s-g)}let p=a+h*u.length;o(new at(u.from,u.length,f,p,0)),f+=p,c=u.to+1}}replace(e,t,i){let r=this.length-t;if(r>0){let s=i[i.length-1];s instanceof n?i[i.length-1]=new n(s.length+r):i.push(null,new n(r-1))}if(e>0){let s=i[0];s instanceof n?i[0]=new n(e+s.length):i.unshift(new n(e-1),null)}return Ve.of(i)}decomposeLeft(e,t){t.push(new n(e-1),null)}decomposeRight(e,t){t.push(null,new n(this.length-e-1))}updateHeight(e,t=0,i=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new n(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++];a==-1?a=f:Math.abs(f-a)>=dr&&(a=-2);let u=new _e(c,f);u.outdated=!1,o.push(u),l+=c+1}l<=s&&o.push(null,new n(s-l).updateHeight(e,l));let h=Ve.of(o);return(a<0||Math.abs(h.height-this.height)>=dr||Math.abs(a-this.heightMetrics(e,t).perLine)>=dr)&&(e.heightChanged=!0),h}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Do=class extends Ve{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,i,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==ce.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,r,s):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==ce.ByPosNoHeight?ce.ByPosNoHeight:ce.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,r,s).join(h)}forEachLine(e,t,i,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,r,s,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,ce.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&ah(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),ah(s,l)}return Ve.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ve.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,i,r):s.updateHeight(e,t,i),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function ah(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Et&&(i=n[e+1])instanceof Et&&n.splice(e-1,3,new Et(t.length+1+i.length))}var vp=5,Oo=class n{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof _e?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new _e(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new vr(o,r,i)):(o||s||r>=vp)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new _e(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new Et(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof _e)return e;let t=new _e(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof _e)&&!this.isCovered?this.nodes.push(new _e(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof _e&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,t,i,r){let s=new n(i,e);return ie.spans(t,i,r,s,0),s.finish(i)}};function Sp(n,e,t){let i=new Eo;return ie.compare(n,e,t,i,0),i.changes}var Eo=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&ko(e,t,this.changes,5)}};function Cp(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,r=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=h==n.parentNode?u.bottom:Math.min(a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Ap(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var ln=class{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=t[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return Y.replace({widget:new Bo(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Bo=class extends et{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},Sr=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=hh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ge.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Jo).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Mo(t),this.stateDeco=e.facet(gn).filter(i=>typeof i!="function"),this.heightMap=Ve.empty().applyChanges(this.stateDeco,Z.empty,this.heightOracle.setDoc(e.doc),[new ct(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Y.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let r=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Si(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?hh:new Po(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:tn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(gn).filter(c=>typeof c!="function");let r=e.changedRanges,s=ct.extendWithRanges(r,Sp(i,this.stateDeco,e?e.changes:De.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),h&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Rd)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ge.RTL:ge.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:R,scaleY:F}=Ch(t,l);(this.scaleX!=R||this.scaleY!=F)&&(this.scaleX=R,this.scaleY=F,h|=8,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=Mh(e.scrollDOM);let g=(this.printing?Ap:Cp)(t,this.paddingTop),x=g.top-this.pixelViewport.top,y=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let M=l.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let R=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(R)&&(o=!0),o||r.lineWrapping&&Math.abs(M-this.contentDOMWidth)>r.charWidth){let{lineHeight:F,charWidth:q,textHeight:w}=e.docView.measureTextSize();o=F>0&&r.refresh(s,F,q,w,M/q,R),o&&(e.docView.minWidth=0,h|=8)}x>0&&y>0?c=Math.max(x,y):x<0&&y<0&&(c=Math.min(x,y)),r.heightChanged=!1;for(let F of this.viewports){let q=F.from==this.viewport.from?R:e.docView.measureVisibleLineHeights(F);this.heightMap=(o?Ve.empty().applyChanges(this.stateDeco,Z.empty,this.heightOracle,[new ct(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Lo(F.from,q))}r.heightChanged&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Si(r.lineAt(o-i*1e3,ce.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,ce.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,ce.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new Si(r.lineAt(u-1e3/2,ce.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,ce.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new Si(this.heightMap.lineAt(i,ce.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,ce.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,ce.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let r of e)t.touchesRange(r.from,r.to)||i.push(new ln(t.mapPos(r.from),t.mapPos(r.to),r.size));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=ge.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-h<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let y of g)if(y>h&&y<c){a(h,y-10,f,u),a(y+10,c,f,u);return}let x=Mp(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)<s&&Math.abs(y.to-c)<s&&!g.some(v=>y.from<v&&y.to>v));if(!x){if(c<f.to&&t&&i&&t.visibleRanges.some(y=>y.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(L.cursor(c),!1,!0).head;y>h&&(c=y)}x=new ln(h,c,this.gapSize(f,h,c,u))}l.push(x)};for(let h of this.viewportLines){if(h.length<o)continue;let c=Tp(h.from,h.to,this.stateDeco);if(c.total<o)continue;let f=this.scrollTarget?this.scrollTarget.range.head:null,u,p;if(i){let g=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(f!=null){let v=lr(c,f),M=((this.visibleBottom-this.visibleTop)/2+g)/h.height;x=v-M,y=v+M}else x=(this.visibleTop-h.top-g)/h.height,y=(this.visibleBottom-h.top+g)/h.height;u=or(c,x),p=or(c,y)}else{let g=c.total*this.heightOracle.charWidth,x=r*this.heightOracle.charWidth,y,v;if(f!=null){let M=lr(c,f),O=((this.pixelViewport.right-this.pixelViewport.left)/2+x)/g;y=M-O,v=M+O}else y=(this.pixelViewport.left-x)/g,v=(this.pixelViewport.right+x)/g;u=or(c,y),p=or(c,v)}u>h.from&&a(h.from,u,h,c),p<h.to&&a(p,h.to,h,c)}return l}gapSize(e,t,i,r){let s=lr(r,i)-lr(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){ln.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Y.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];ie.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||tn(this.heightMap.lineAt(e,ce.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return tn(this.heightMap.lineAt(this.scaler.fromDOM(e),ce.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return tn(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Si=class{constructor(e,t){this.from=e,this.to=t}};function Tp(n,e,t){let i=[],r=n,s=0;return ie.spans(t,n,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function or({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function lr(n,e){let t=0;for(let{from:i,to:r}of n.ranges){if(e<=r){t+=e-i;break}t+=r-i}return t/n.total}function Mp(n,e){for(let t of n)if(e(t))return t}var hh={toDOM(n){return n},fromDOM(n){return n},scale:1},Po=class{constructor(e,t,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,ce.ByPos,e,0,0).top,c=t.lineAt(a,ce.ByPos,e,0,0).bottom;return r+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,i=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}};function tn(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new at(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>tn(r,e)):n._content)}var ar=I.define({combine:n=>n.join(" ")}),Ro=I.define({combine:n=>n.indexOf(!0)>-1}),Io=Ke.newName(),cc=Ke.newName(),fc=Ke.newName(),uc={"&light":"."+cc,"&dark":"."+fc};function No(n,e,t){return new Ke(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return n;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):n+" "+i}})}var Lp=No("."+Io,{"&":{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"}},uc),nn="\uFFFF",zo=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(he.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=nn}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let l=ue.get(r),a=ue.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:ch(r))||ch(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=s+o}}readNode(e){if(e.cmIgnore)return;let t=ue.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Dp(e,i.node,i.offset)?t:0))}};function Dp(n,e,t){for(;;){if(!e||t<St(e))return!1;if(e==n)return!0;t=fn(e)+1,e=e.parentNode}}function ch(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}var Cr=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Fo=class{constructor(e,t,i,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=s||o?[]:Bp(e),a=new zo(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Pp(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!co(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!co(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=L.single(h,a)}}};function dc(n,e){let t,{newSel:i}=e,r=n.state.selection.main,s=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=r.from,h=null;(s===8||H.android&&e.text.length<l-o)&&(a=r.to,h="end");let c=Ep(n.state.doc.sliceString(o,l,nn),e.text,a-o,h);c&&(H.chrome&&s==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==nn+nn&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:Z.of(e.text.slice(c.from,c.toB).split(nn))})}else i&&(!n.hasFocus&&n.state.facet(Br)||i.main.eq(r))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!r.empty&&i&&i.main.empty?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,r.to)}:t&&t.from>=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:n.state.doc.slice(r.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,r.to))}:(H.mac||H.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Z.of([" "])}):H.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
9
+ `&&n.lineWrapping&&(i&&(i=L.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Z.of([" "])}),t){if(H.ios&&n.inputState.flushIOSKey()||H.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&Ti(n.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.length<t.to-t.from&&t.to>r.head)&&Ti(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Ti(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,a=()=>l||(l=Op(n,t,i));return n.state.facet(Vh).some(h=>h(n,t.from,t.to,o,a))||n.dispatch(a()),!0}else if(i&&!i.main.eq(r)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Op(n,e,t){let i,r=n.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let l=s.from<e.from?r.sliceDoc(s.from,e.from):"",a=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(n.state.toText(l+e.insert.sliceString(0,void 0,n.state.lineBreak)+a))}else{let l=r.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(r.selection.ranges.length>1&&n.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h=n.state.sliceDoc(e.from,e.to),c,f=t&&Zh(n,t.main.head);if(f){let g=e.insert.length-(e.to-e.from);c={from:f.from,to:f.to-g}}else c=n.state.doc.lineAt(s.head);let u=s.to-e.to,p=s.to-s.from;i=r.changeByRange(g=>{if(g.from==s.from&&g.to==s.to)return{changes:l,range:a||g.map(l)};let x=g.to-u,y=x-h.length;if(g.to-g.from!=p||n.state.sliceDoc(y,x)!=h||g.to>=c.from&&g.from<=c.to)return{range:g};let v=r.changes({from:y,to:x,insert:e.insert}),M=g.to-s.to;return{changes:v,range:a?L.range(Math.max(0,a.anchor+M),Math.max(0,a.head+M)):g.map(v)}})}else i={changes:l,selection:a&&r.selection.replaceRange(a)}}let o="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,o+=".compose",n.inputState.compositionFirstChange&&(o+=".start",n.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:o,scrollIntoView:!0})}function Ep(n,e,t,i){let r=Math.min(n.length,e.length),s=0;for(;s<r&&n.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&n.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Bp(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:r,focusOffset:s}=n.observer.selectionRange;return t&&(e.push(new Cr(t,i)),(r!=t||s!=i)&&e.push(new Cr(r,s))),e}function Pp(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?L.single(t+e,i+e):null}var Rp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},so=H.ie&&H.ie_version<=11,Ho=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new fo,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(H.ie&&H.ie_version<=11||H.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),so&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Br)?i.root.activeElement!=this.dom:!fr(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!i.state.selection.main.empty&&r.focusNode&&gr(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=H.safari&&e.root.nodeType==11&&Sd(this.dom.ownerDocument)==this.dom&&Ip(this.view)||mr(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=fr(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Ld(this.dom,t)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(t),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Rp),so&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),so&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ti(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:r}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),r=this.selectionChanged&&fr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Fo(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,r=dc(this.view,t);return this.view.state==i&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=fh(t,e.previousSibling||e.target.previousSibling,-1),r=fh(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function fh(n,e,t){for(;e;){let i=ue.get(e);if(i&&i.parent==n)return i;let r=e.parentNode;e=r!=n.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Ip(n){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return gr(l.node,l.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}var z=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(i=>i.forEach(r=>t(r,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Md(e.parent)||document,this.viewState=new Sr(e.state||he.create(e)),e.scrollTo&&e.scrollTo.is(nr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qi).map(i=>new on(i));for(let i of this.plugins)i.update(this);this.observer=new Ho(this),this.inputState=new Co(this),this.inputState.ensureHandlers(this.plugins),this.docView=new wr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}dispatch(...e){let t=e.length==1&&e[0]instanceof xe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(lc))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=ac(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(he.phrases)!=this.state.facet(he.phrases))return this.setState(s);r=yr.create(this,s,e),r.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:p}=u.state.selection;f=new sn(p.empty?p:L.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of u.effects)p.is(nr)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Ar.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(en)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(ar)!=r.state.facet(ar)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let u of this.state.facet(yo))try{u(r)}catch(p){He(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!dc(this,c)&&h.force&&Ti(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Sr(e),this.plugins=e.facet(Qi).map(i=>new on(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new wr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Qi),i=e.state.facet(Qi);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new on(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,r=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Mh(i))s=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(p=>{try{return p.read(this)}catch(g){return He(this.state,g),uh}}),f=yr.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f));for(let p=0;p<h.length;p++)if(c[p]!=uh)try{let g=h[p];g.write&&g.write(c[p],this)}catch(g){He(this.state,g)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let g=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(g>1||g<-1){r=r+g,i.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(yo))l(t)}get themeClasses(){return Io+" "+(this.state.facet(Ro)?fc:cc)+" "+this.state.facet(ar)}updateAttrs(){let e=dh(this,qh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Br)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),dh(this,Jo,t);let i=this.observer.ignore(()=>{let r=bo(this.contentDOM,this.contentAttrs,t),s=bo(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(en);let e=this.state.facet(n.cspNonce);Ke.mount(this.root,this.styleModules.concat(Lp).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return ro(this,e,Xa(this,e,t,i))}moveByGroup(e,t){return ro(this,e,Xa(this,e,t,i=>sp(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return rp(this,e,t,i)}moveVertically(e,t,i){return ro(this,e,op(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),ec(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[ht.find(s,e-r.from,-1,t)];return Go(i,o.dir==ge.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(jh)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Np)return Jh(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Yh(s.isolates,i=_a(this,e.from,e.to))))return s.order;i||(i=_a(this,e.from,e.to));let r=qd(e.text,t,i);return this.bidiCache.push(new Ar(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ah(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return nr.of(new sn(typeof e=="number"?L.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return nr.of(new sn(L.cursor(i.from),"start","start",i.top-e,t,!0))}static domEventHandlers(e){return ye.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ye.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Ke.newName(),r=[ar.of(i),en.of(No(`.${i}`,e))];return t&&t.dark&&r.push(Ro.of(!0)),r}static baseTheme(e){return Lt.lowest(en.of(No("."+Io,e,uc)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&ue.get(i)||ue.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}};z.styleModule=en;z.inputHandler=Vh;z.focusChangeEffect=Wh;z.perLineTextDirection=jh;z.exceptionSink=Hh;z.updateListener=yo;z.editable=Br;z.mouseSelectionStyle=Fh;z.dragMovesSelection=zh;z.clickAddsSelectionRange=Nh;z.decorations=gn;z.atomicRanges=Xo;z.bidiIsolatedRanges=$h;z.scrollMargins=Kh;z.darkTheme=Ro;z.cspNonce=I.define({combine:n=>n.length?n[0]:""});z.contentAttributes=Jo;z.editorAttributes=qh;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=J.define();var Np=4096,uh={},Ar=class n{constructor(e,t,i,r,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:ge.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&i.push(new n(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}};function dh(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(n):s;o&&go(o,t)}return t}var zp=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function Fp(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){let h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function hr(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var Hp=Lt.default(z.domEventHandlers({keydown(n,e){return gc(pc(e.state),n,e,"editor")}})),Pr=I.define({enables:Hp}),ph=new WeakMap;function pc(n){let e=n.facet(Pr),t=ph.get(e);return t||ph.set(e,t=Wp(e.reduce((i,r)=>i.concat(r),[]))),t}function mc(n,e,t){return gc(pc(n.state),e,n,t)}var Ot=null,Vp=4e3;function Wp(n,e=zp){let t=Object.create(null),i=Object.create(null),r=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,h,c)=>{var f,u;let p=t[o]||(t[o]=Object.create(null)),g=l.split(/ (?!$)/).map(v=>Fp(v,e));for(let v=1;v<g.length;v++){let M=g.slice(0,v).join(" ");r(M,!0),p[M]||(p[M]={preventDefault:!0,stopPropagation:!1,run:[O=>{let R=Ot={view:O,prefix:M,scope:o};return setTimeout(()=>{Ot==R&&(Ot=null)},Vp),!0}]})}let x=g.join(" ");r(x,!1);let y=p[x]||(p[x]={preventDefault:!1,stopPropagation:!1,run:((u=(f=p._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&y.run.push(a),h&&(y.preventDefault=!0),c&&(y.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in c)c[f].run.push(o.any)}let a=o[e]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}function gc(n,e,t,i){let r=Fa(e),s=$e(r,0),o=wt(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;Ot&&Ot.view==t&&Ot.scope==i&&(l=Ot.prefix+" ",ic.indexOf(e.keyCode)<0&&(h=!0,Ot=null));let f=new Set,u=y=>{if(y){for(let v of y.run)if(!f.has(v)&&(f.add(v),v(t,e)))return y.stopPropagation&&(c=!0),!0;y.preventDefault&&(y.stopPropagation&&(c=!0),h=!0)}return!1},p=n[i],g,x;return p&&(u(p[l+hr(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&(g=vt[e.keyCode])&&g!=r?(u(p[l+hr(g,e,!0)])||e.shiftKey&&(x=xi[e.keyCode])!=r&&x!=g&&u(p[l+hr(x,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(p[l+hr(r,e,!0)])&&(a=!0),!a&&u(p._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),a}var jp=!H.ios;var mh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};jp&&(mh[".cm-line"].caretColor="transparent !important",mh[".cm-content"]={caretColor:"transparent !important"});function gh(n,e,t,i,r){e.lastIndex=0;for(let s=n.iterRange(t,i),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function qp(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:r,to:s}of t)r=Math.max(n.state.doc.lineAt(r).from,r-e),s=Math.min(n.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}var kn=class{constructor(e){let{regexp:t,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,a,h,c)=>r(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new ot,i=t.add.bind(t);for(let{from:r,to:s}of qp(e,this.maxLength))gh(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>e.view.viewport.from&&l<e.view.viewport.to&&(i=Math.min(l,i),r=Math.max(a,r))}),e.viewportChanged||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),i,r):t}updateRange(e,t,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),l=Math.min(s.to,r);if(l>o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(s.from,a.from),f=Math.min(s.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],p,g=(x,y,v)=>u.push(v.range(x,y));if(a==h)for(this.regexp.lastIndex=c-a.from;(p=this.regexp.exec(a.text))&&p.index<f-a.from;)this.addMatch(p,e,p.index+a.from,g);else gh(e.state.doc,this.regexp,c,f,(x,y)=>this.addMatch(y,e,x,g));t=t.update({filterFrom:c,filterTo:f,filter:(x,y)=>x<c||y>f,add:u})}}return t}},Vo=/x/.unicode!=null?"gu":"g",$p=new RegExp(`[\0-\b
10
+ -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Vo),Kp={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"},oo=null;function _p(){var n;if(oo==null&&typeof document!="undefined"&&document.body){let e=document.body.style;oo=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return oo||!1}var pr=I.define({combine(n){let e=ze(n,{render:null,specialChars:$p,addSpecialChars:null});return(e.replaceTabs=!_p())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Vo)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Vo)),e}});function bc(n={}){return[pr.of(n),Gp()]}var bh=null;function Gp(){return bh||(bh=ye.fromClass(class{constructor(n){this.view=n,this.decorations=Y.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(pr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new kn({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=$e(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=Dt(o.text,l,i-o.from);return Y.replace({widget:new jo((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Y.replace({widget:new Wo(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(pr);n.startState.facet(pr)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}var Up="\u2022";function Yp(n){return n>=32?Up:n==10?"\u2424":String.fromCharCode(9216+n)}var Wo=class extends et{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Yp(this.code),i=e.state.phrase("Control character")+" "+(Kp[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}},jo=class extends et{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};function kc(){return Xp}var Jp=Y.line({class:"cm-activeLine"}),Xp=ye.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let r=n.lineBlockAt(i.head);r.from>e&&(t.push(Jp.range(r.from)),e=r.from)}return Y.set(t)}},{decorations:n=>n.decorations});var Zi="-10000px",Tr=class{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r),this.tooltipViews=this.tooltips.map(i)}update(e,t){var i;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<s.length;a++){let h=s[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(a.dom.remove(),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function Zp(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var lo=I.define({combine:n=>{var e,t,i;return{position:H.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Zp}}}),kh=new WeakMap,yc=ye.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(lo);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new Tr(n,yn,t=>this.createTooltip(t)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(lo);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Zi,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(n=t.destroy)===null||n===void 0||n.call(t);this.parent&&this.container.remove(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect(),e=1,t=1,i=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(H.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(this.view.scaleX!=1||this.view.scaleY!=1)i=!0;else if(r.style.top==Zi&&r.style.left=="0px"){let s=r.getBoundingClientRect();i=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(i||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(e=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((r,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(lo).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{editor:t,space:i,scaleX:r,scaleY:s}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=n.pos[l],u=n.size[l];if(!f||f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1){c.style.top=Zi;continue}let p=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,x=u.right-u.left,y=(e=kh.get(h))!==null&&e!==void 0?e:u.bottom-u.top,v=h.offset||em,M=this.view.textDirection==ge.LTR,O=u.width>i.right-i.left?M?i.left:i.right-u.width:M?Math.min(f.left-(p?14:0)+v.x,i.right-x):Math.max(i.left,f.left-x+(p?14:0)-v.x),R=this.above[l];!a.strictSide&&(R?f.top-(u.bottom-u.top)-v.y<i.top:f.bottom+(u.bottom-u.top)+v.y>i.bottom)&&R==i.bottom-f.bottom>f.top-i.top&&(R=this.above[l]=!R);let F=(R?f.top-i.top:i.bottom-f.bottom)-g;if(F<y&&h.resize!==!1){if(F<this.view.defaultLineHeight){c.style.top=Zi;continue}kh.set(h,y),c.style.height=(y=F)/s+"px"}else c.style.height&&(c.style.height="");let q=R?f.top-y-g-v.y:f.bottom+g+v.y,w=O+x;if(h.overlap!==!0)for(let D of o)D.left<w&&D.right>O&&D.top<q+y&&D.bottom>q&&(q=R?D.top-y-2-g:D.bottom+g+2);if(this.position=="absolute"?(c.style.top=(q-n.parent.top)/s+"px",c.style.left=(O-n.parent.left)/r+"px"):(c.style.top=q/s+"px",c.style.left=O/r+"px"),p){let D=f.left+(M?v.x:-v.x)-(O+14-7);p.style.left=D/r+"px"}h.overlap!==!0&&o.push({left:O,top:q,right:w,bottom:q+y}),c.classList.toggle("cm-tooltip-above",R),c.classList.toggle("cm-tooltip-below",!R),h.positioned&&h.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Zi}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Qp=z.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),em={x:0,y:0},yn=I.define({enables:[yc,Qp]}),Mr=I.define(),Lr=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Tr(e,Mr,t=>this.createHostedView(t))}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},tm=yn.compute([Mr],n=>{let e=n.facet(Mr).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Lr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),qo=class{constructor(e,t,i,r,s){this.view=e,this.source=t,this.field=i,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let r,s=1;if(i instanceof un)r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let l=e.coordsAtPos(r);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),h=a&&a.dir==ge.RTL?-1:1;s=t.x<l.left?-h:h}let o=this.source(e,r,s);if(o!=null&&o.then){let l=this.pending={pos:r};o.then(a=>{this.pending==l&&(this.pending=null,a&&e.dispatch({effects:this.setHover.of(a)}))},a=>He(e.state,a,"hover tooltip"))}else o&&e.dispatch({effects:this.setHover.of(o)})}get tooltip(){let e=this.view.plugin(yc),t=e?e.manager.tooltips.findIndex(i=>i.create==Lr.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i&&r&&!im(r.dom,e)||this.pending){let{pos:s}=i||this.pending,o=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!nm(this.view,s,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of(null)})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},cr=4;function im(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-cr&&e.clientX<=t.right+cr&&e.clientY>=t.top-cr&&e.clientY<=t.bottom+cr}function nm(n,e,t,i,r,s){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=n.posAtCoords({x:i,y:r},!1);return a>=e&&a<=t}function wc(n,e={}){let t=J.define(),i=pe.define({create(){return null},update(r,s){if(r&&(e.hideOnChange&&(s.docChanged||s.selection)||e.hideOn&&e.hideOn(s,r)))return null;if(r&&s.docChanged){let o=s.changes.mapPos(r.pos,-1,Ce.TrackDel);if(o==null)return null;let l=Object.assign(Object.create(null),r);l.pos=o,r.end!=null&&(l.end=s.changes.mapPos(r.end)),r=l}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(rm)&&(r=null);return r},provide:r=>Mr.from(r)});return[i,ye.define(r=>new qo(r,n,i,t,e.hoverTime||300)),tm]}var rm=J.define();var yh=I.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function ti(n,e){let t=n.plugin(xc),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var xc=ye.fromClass(class{constructor(n){this.input=n.state.facet(ei),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(yh);this.top=new Ci(n,!0,e.topContainer),this.bottom=new Ci(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(yh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Ci(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ci(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(ei);if(t!=this.input){let i=t.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(n.view),l.push(c)):(c=this.panels[h],c.update&&c.update(n)),r.push(c),(c.top?s:o).push(c)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Ci=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=wh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=wh(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function wh(n){let e=n.nextSibling;return n.remove(),e}var ei=I.define({enables:xc}),Ge=class extends Ze{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Ge.prototype.elementClass="";Ge.prototype.toDOM=void 0;Ge.prototype.mapMode=Ce.TrackBefore;Ge.prototype.startSide=Ge.prototype.endSide=-1;Ge.prototype.point=!0;var ao=I.define(),sm={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},an=I.define();function Zo(n){return[vc(),an.of(Object.assign(Object.assign({},sm),n))]}var $o=I.define({combine:n=>n.some(e=>e)});function vc(n){let e=[om];return n&&n.fixed===!1&&e.push($o.of(!0)),e}var om=ye.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(an).map(e=>new Dr(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet($o),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet($o)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=ie.iter(this.view.state.facet(ao),this.view.viewport.from),i=[],r=this.gutters.map(s=>new _o(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Qe.Text&&o){Ko(t,i,l.from);for(let a of r)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Qe.Text){Ko(t,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(an),t=n.state.facet(an),i=n.docChanged||n.heightChanged||n.viewportChanged||!ie.eq(n.startState.facet(ao),n.state.facet(ao),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(n)&&(i=!0);else{i=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Dr(this.view,s)):(this.gutters[o].update(n),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>z.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==ge.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function xh(n){return Array.isArray(n)?n:[n]}function Ko(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var _o=class{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ie.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Or(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let r=[];Ko(this.cursor,r,t.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Dr=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=xh(t.markers(e)),t.initialSpacer&&(this.spacer=new Or(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=xh(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!ie.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Or=class{constructor(e,t,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,r)}update(e,t,i,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),lm(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}};function lm(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}var am=I.define(),Ai=I.define({combine(n){return ze(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let r in t){let s=i[r],o=t[r];i[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return i}})}}),hn=class extends Ge{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function ho(n,e){return n.state.facet(Ai).formatNumber(e,n.state)}var hm=an.compute([Ai],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(am)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new hn(ho(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Ai)!=e.state.facet(Ai),initialSpacer(e){return new hn(ho(e,vh(e.state.doc.lines)))},updateSpacer(e,t){let i=ho(t.view,vh(t.view.state.doc.lines));return i==e.number?e:new hn(i)},domEventHandlers:n.facet(Ai).domEventHandlers}));function Sc(n={}){return[Ai.of(n),vc(),hm]}function vh(n){let e=9;for(;e<n;)e=e*10+9;return e}var Sh=new Map;function cm(n){let e=Sh.get(n);return e||Sh.set(n,e=Y.mark({attributes:n===" "?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":n.replace(/ /g,"\xB7")}})),e}function Cc(n){return ye.define(e=>({decorations:n.createDeco(e),update(t){this.decorations=n.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}var fm=Cc(new kn({regexp:/\t| +/g,decoration:n=>cm(n[0]),boundary:/\S/}));function Ac(){return fm}var um=Cc(new kn({regexp:/\s+$/g,decoration:Y.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function Tc(){return um}var dm=0,wn=class{constructor(e,t){this.from=e,this.to=t}},X=class{constructor(e={}){this.id=dm++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ee.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};X.closedBy=new X({deserialize:n=>n.split(" ")});X.openedBy=new X({deserialize:n=>n.split(" ")});X.group=new X({deserialize:n=>n.split(" ")});X.contextHash=new X({perNode:!0});X.lookAhead=new X({perNode:!0});X.mounted=new X({perNode:!0});var Li=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[X.mounted.id]}},pm=Object.create(null),Ee=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):pm,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(X.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(X.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};Ee.none=new Ee("",Object.create(null),0,8);var Nr=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);o&&(r||(r=Object.assign({},i.props)),r[o[0].id]=o[1])}t.push(r?new Ee(i.name,r,i.id,i.flags):i)}return new n(t)}},Rr=new WeakMap,Mc=new WeakMap,ve;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(ve||(ve={}));var de=class n{constructor(e,t,i,r,s){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Li.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Sn(this.topNode,e)}cursorAt(e,t=0,i=0){let r=Rr.get(this)||this.topNode,s=new Sn(r);return s.moveTo(e,t),Rr.set(this,s._tree),s}get topNode(){return new ft(this,0,0,null)}resolve(e,t=0){let i=xn(Rr.get(this)||this.topNode,e,t,!1);return Rr.set(this,i),i}resolveInner(e,t=0){let i=xn(Mc.get(this)||this.topNode,e,t,!0);return Mc.set(this,i),i}resolveStack(e,t=0){return mm(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&ve.IncludeAnonymous)>0;for(let a=this.cursor(o|ve.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:sl(Ee.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Ee.none,t,i,r)))}static build(e){return gm(e)}};de.empty=new de(Ee.none,[],[],0);var Qo=class n{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new n(this.buffer,this.index)}},It=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Ee.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Oc(s,r,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-i;let h=s[a++]=r[l++]-i;s[a++]=r[l++]-e,o=Math.max(o,h)}return new n(s,o,this.set)}};function Oc(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function xn(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof ft&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:ve.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof ft&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,s);if(!o)return n;n=o}}var zr=class{cursor(e=0){return new Sn(this,e)}getChild(e,t=null,i=null){let r=Lc(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Lc(this,e,t,i)}resolve(e,t=0){return xn(this,e,t,!1)}resolveInner(e,t=0){return xn(this,e,t,!0)}matchContext(e){return el(this,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},ft=class n extends zr{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from;if(Oc(r,i,f,f+c.length)){if(c instanceof It){if(s&ve.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,r);if(u>-1)return new vn(new tl(o,c,e,f),null,u)}else if(s&ve.IncludeAnonymous||!c.type.isAnonymous||rl(c)){let u;if(!(s&ve.IgnoreMounts)&&(u=Li.get(c))&&!u.overlay)return new n(u.tree,f,e,o);let p=new n(c,f,e,o);return s&ve.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(s&ve.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let r;if(!(i&ve.IgnoreOverlays)&&(r=Li.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:l}of r.overlay)if((t>0?o<=s:o<s)&&(t<0?l>=s:l>s))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Lc(n,e,t,i){let r=n.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function el(n,e,t=e.length-1){for(let i=n.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var tl=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},vn=class n extends zr{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new n(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&ve.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new n(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),t.push(0)}return new de(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Ec(n){if(!n.length)return null;let e=0,t=n[0];for(let s=1;s<n.length;s++){let o=n[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof ft&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new il(r,t)}var il=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Ec(this.heads)}};function mm(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof ft?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,t)),s=o}else{let o=Li.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new ft(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(xn(l,e,t,!1))}}return r?Ec(r):i}var Sn=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ft)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof ft?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&ve.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ve.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ve.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&ve.IncludeAnonymous||l instanceof It||!l.type.isAnonymous||rl(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)t=new vn(this.buffer,t,this.stack[r]);return this.bufferNode=new vn(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return el(this.node,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return el(this.node,e,r);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function rl(n){return n.children.some(e=>e instanceof It||!e.type.isAnonymous||rl(e))}function gm(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Qo(t,t.length):t,a=i.types,h=0,c=0;function f(F,q,w,D,b,U){let{id:$,start:G,end:K,size:k}=l,T=c;for(;k<0;)if(l.next(),k==-1){let j=s[$];w.push(j),D.push(G-F);return}else if(k==-3){h=$;return}else if(k==-4){c=$;return}else throw new RangeError(`Unrecognized record size: ${k}`);let A=a[$],V,le,we=G-F;if(K-G<=r&&(le=y(l.pos-q,b))){let j=new Uint16Array(le.size-le.skip),W=l.pos-le.size,_=j.length;for(;l.pos>W;)_=v(le.start,j,_);V=new It(j,K-le.start,i),we=le.start-F}else{let j=l.pos-k;l.next();let W=[],_=[],ae=$>=o?$:-1,Ct=0,te=K;for(;l.pos>j;)ae>=0&&l.id==ae&&l.size>=0?(l.end<=te-r&&(g(W,_,G,Ct,l.end,te,ae,T),Ct=W.length,te=l.end),l.next()):U>2500?u(G,j,W,_):f(G,j,W,_,ae,U+1);if(ae>=0&&Ct>0&&Ct<W.length&&g(W,_,G,Ct,G,te,ae,T),W.reverse(),_.reverse(),ae>-1&&Ct>0){let Te=p(A);V=sl(A,W,_,0,W.length,0,K-G,Te,Te)}else V=x(A,W,_,K-G,T-K)}w.push(V),D.push(we)}function u(F,q,w,D){let b=[],U=0,$=-1;for(;l.pos>q;){let{id:G,start:K,end:k,size:T}=l;if(T>4)l.next();else{if($>-1&&K<$)break;$<0&&($=k-r),b.push(G,K,k),U++,l.next()}}if(U){let G=new Uint16Array(U*4),K=b[b.length-2];for(let k=b.length-3,T=0;k>=0;k-=3)G[T++]=b[k],G[T++]=b[k+1]-K,G[T++]=b[k+2]-K,G[T++]=T;w.push(new It(G,b[2]-K,i)),D.push(K-F)}}function p(F){return(q,w,D)=>{let b=0,U=q.length-1,$,G;if(U>=0&&($=q[U])instanceof de){if(!U&&$.type==F&&$.length==D)return $;(G=$.prop(X.lookAhead))&&(b=w[U]+$.length+G)}return x(F,q,w,D,b)}}function g(F,q,w,D,b,U,$,G){let K=[],k=[];for(;F.length>D;)K.push(F.pop()),k.push(q.pop()+w-b);F.push(x(i.types[$],K,k,U-b,G-U)),q.push(b-w)}function x(F,q,w,D,b=0,U){if(h){let $=[X.contextHash,h];U=U?[$].concat(U):[$]}if(b>25){let $=[X.lookAhead,b];U=U?[$].concat(U):[$]}return new de(F,q,w,D,U)}function y(F,q){let w=l.fork(),D=0,b=0,U=0,$=w.end-r,G={size:0,start:0,skip:0};e:for(let K=w.pos-F;w.pos>K;){let k=w.size;if(w.id==q&&k>=0){G.size=D,G.start=b,G.skip=U,U+=4,D+=4,w.next();continue}let T=w.pos-k;if(k<0||T<K||w.start<$)break;let A=w.id>=o?4:0,V=w.start;for(w.next();w.pos>T;){if(w.size<0)if(w.size==-3)A+=4;else break e;else w.id>=o&&(A+=4);w.next()}b=V,D+=k,U+=A}return(q<0||D==F)&&(G.size=D,G.start=b,G.skip=U),G.size>4?G:void 0}function v(F,q,w){let{id:D,start:b,end:U,size:$}=l;if(l.next(),$>=0&&D<o){let G=w;if($>4){let K=l.pos-($-4);for(;l.pos>K;)w=v(F,q,w)}q[--w]=G,q[--w]=U-F,q[--w]=b-F,q[--w]=D}else $==-3?h=D:$==-4&&(c=D);return w}let M=[],O=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,M,O,-1,0);let R=(e=n.length)!==null&&e!==void 0?e:M.length?O[0]+M[0].length:0;return new de(a[n.topID],M.reverse(),O.reverse(),R)}var Dc=new WeakMap;function Ir(n,e){if(!n.isAnonymous||e instanceof It||e.type!=n)return 1;let t=Dc.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof de)){t=1;break}t+=Ir(n,i)}Dc.set(e,t)}return t}function sl(n,e,t,i,r,s,o,l,a){let h=0;for(let g=i;g<r;g++)h+=Ir(n,e[g]);let c=Math.ceil(h*1.5/8),f=[],u=[];function p(g,x,y,v,M){for(let O=y;O<v;){let R=O,F=x[O],q=Ir(n,g[O]);for(O++;O<v;O++){let w=Ir(n,g[O]);if(q+w>=c)break;q+=w}if(O==R+1){if(q>c){let w=g[R];p(w.children,w.positions,0,w.children.length,x[R]+M);continue}f.push(g[R])}else{let w=x[O-1]+g[O-1].length-F;f.push(sl(n,g,x,R,O,F,w,null,a))}u.push(F+M-s)}}return p(e,t,i,r,0),(l||a)(f,u,o)}var ii=class n{constructor(e,t,i,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let p=Math.max(u.from,a)-h,g=Math.min(u.to,f)-h;u=p>=g?null:new n(p,g,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}},Cn=class{startParse(e,t,i){return typeof e=="string"&&(e=new nl(e)),i=i?i.length?i.map(r=>new wn(r.from,r.to)):[new wn(0,0)]:[new wn(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let s=r.advance();if(s)return s}}},nl=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var pb=new X({perNode:!0});var bm=0,Pe=class n{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=bm++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new n([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new Wr;return t=>t.modified.indexOf(e)>-1?t:Wr.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}},km=0,Wr=class n{constructor(){this.instances=[],this.id=km++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&ym(t,l.modified));if(i)return i;let r=[],s=new Pe(r,e,t);for(let l of t)l.instances.push(s);let o=wm(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(n.get(l,a));return s}};function ym(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function wm(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Rc(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Di(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return Ic.add(e)}var Ic=new X,Di=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Di.empty=new Di([],2,null);function hl(n,e){let t=Object.create(null);for(let s of n)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function xm(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function Nc(n,e,t,i=0,r=n.length){let s=new ll(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var ll=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,s){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(o)));let h=r,c=vm(e)||Di.empty,f=xm(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(X.mounted);if(u&&u.overlay){let p=e.node.enter(u.overlay[0].from+l,1),g=this.highlighters.filter(y=>!y.scope||y.scope(u.tree.type)),x=e.firstChild();for(let y=0,v=l;;y++){let M=y<u.overlay.length?u.overlay[y]:null,O=M?M.from+l:a,R=Math.max(t,v),F=Math.min(i,O);if(R<F&&x)for(;e.from<F&&(this.highlightRange(e,R,F,r,s),this.startSpan(Math.min(F,e.to),h),!(e.to>=O||!e.nextSibling())););if(!M||O>i)break;v=M.to+l,v>t&&(this.highlightRange(p.cursor(),Math.max(t,M.from+l),Math.min(i,v),"",g),this.startSpan(Math.min(i,v),h))}x&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function vm(n){let e=n.type.prop(Ic);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var E=Pe.define,Fr=E(),Nt=E(),Bc=E(Nt),Pc=E(Nt),zt=E(),Hr=E(zt),ol=E(zt),pt=E(),ni=E(pt),ut=E(),dt=E(),al=E(),An=E(al),Vr=E(),P={comment:Fr,lineComment:E(Fr),blockComment:E(Fr),docComment:E(Fr),name:Nt,variableName:E(Nt),typeName:Bc,tagName:E(Bc),propertyName:Pc,attributeName:E(Pc),className:E(Nt),labelName:E(Nt),namespace:E(Nt),macroName:E(Nt),literal:zt,string:Hr,docString:E(Hr),character:E(Hr),attributeValue:E(Hr),number:ol,integer:E(ol),float:E(ol),bool:E(zt),regexp:E(zt),escape:E(zt),color:E(zt),url:E(zt),keyword:ut,self:E(ut),null:E(ut),atom:E(ut),unit:E(ut),modifier:E(ut),operatorKeyword:E(ut),controlKeyword:E(ut),definitionKeyword:E(ut),moduleKeyword:E(ut),operator:dt,derefOperator:E(dt),arithmeticOperator:E(dt),logicOperator:E(dt),bitwiseOperator:E(dt),compareOperator:E(dt),updateOperator:E(dt),definitionOperator:E(dt),typeOperator:E(dt),controlOperator:E(dt),punctuation:al,separator:E(al),bracket:An,angleBracket:E(An),squareBracket:E(An),paren:E(An),brace:E(An),content:pt,heading:ni,heading1:E(ni),heading2:E(ni),heading3:E(ni),heading4:E(ni),heading5:E(ni),heading6:E(ni),contentSeparator:E(pt),list:E(pt),quote:E(pt),emphasis:E(pt),strong:E(pt),link:E(pt),monospace:E(pt),strikethrough:E(pt),inserted:E(),deleted:E(),changed:E(),invalid:E(),meta:Vr,documentMeta:E(Vr),annotation:E(Vr),processingInstruction:E(Vr),definition:Pe.defineModifier(),constant:Pe.defineModifier(),function:Pe.defineModifier(),standard:Pe.defineModifier(),local:Pe.defineModifier(),special:Pe.defineModifier()},bb=hl([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var cl,Oi=new X;function Sm(n){return I.define({combine:n?e=>e.concat(n):void 0})}var Cm=new X,We=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,he.prototype.hasOwnProperty("tree")||Object.defineProperty(he.prototype,"tree",{get(){return Be(this)}}),this.parser=t,this.extension=[Ei.of(this),he.languageData.of((s,o,l)=>{let a=zc(s,o,l),h=a.type.prop(Oi);if(!h)return[];let c=s.facet(h),f=a.type.prop(Cm);if(f){let u=a.resolve(o-a.from,l);for(let p of f)if(p.test(u,s)){let g=s.facet(p.facet);return p.type=="replace"?g:g.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return zc(e,t,i).type.prop(Oi)==this.data}findRegions(e){let t=e.facet(Ei);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Oi)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(X.mounted);if(l){if(l.tree.prop(Oi)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let a=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof de&&r(h,s.positions[a]+o)}};return r(Be(e),0),i}get allowsNesting(){return!0}};We.setState=J.define();function zc(n,e,t){let i=n.facet(Ei),r=Be(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,ve.ExcludeBuffers))s.type.isTop&&(r=s);return r}function Be(n){let e=n.field(We.state,!1);return e?e.tree:de.empty}var pl=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Tn=null,Mn=class n{constructor(e,t,i=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],de.empty,0,i,[],null)}startParse(){return this.parser.startParse(new pl(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=de.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(ii.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ii.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Tn;Tn=this;try{return e()}finally{Tn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Fc(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=ii.applyChanges(i,a),r=de.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new n(this.parser,t,i,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=Fc(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Cn{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=Tn;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new de(Ee.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Tn}};function Fc(n,e,t){return ii.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var Ln=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Mn.create(e.facet(Ei).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};We.state=pe.define({create:Ln.init,update(n,e){for(let t of e.effects)if(t.is(We.setState))return t.value;return e.startState.facet(Ei)!=e.state.facet(Ei)?Ln.init(e.state):n.apply(e)}});var qc=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(qc=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var fl=typeof navigator!="undefined"&&(!((cl=navigator.scheduling)===null||cl===void 0)&&cl.isInputPending)?()=>navigator.scheduling.isInputPending():null,Am=ye.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(We.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(We.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=qc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(We.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!fl?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>fl&&fl()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:We.setState.of(new Ln(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>He(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ei=I.define({combine(n){return n.length?n[0]:null},enables:n=>[We.state,Am,z.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Bi=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var $c=I.define(),Ht=I.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Ft(n){let e=n.facet(Ht);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Ii(n,e){let t="",i=n.tabSize,r=n.facet(Ht)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function $r(n,e){n instanceof he&&(n=new ri(n));for(let i of n.state.facet($c)){let r=i(n,e);if(r!==void 0)return r}let t=Be(n.state);return t.length>=e?Mm(n,t,e):null}var ri=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ft(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Dt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Tm=new X;function Mm(n,e,t){let i=e.resolveStack(t),r=i.node.enterUnfinishedNodesBefore(t);if(r!=i.node){let s=[];for(let o=r;o!=i.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Kc(i,n,t)}function Kc(n,e,t){for(let i=n;i;i=i.next){let r=Dm(i.node);if(r)return r(ml.create(e,t,i))}return 0}function Lm(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Dm(n){let e=n.type.prop(Tm);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(X.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>Pm(o,!0,1,void 0,s&&!Lm(o)?r.from:void 0)}return n.parent==null?Om:null}function Om(){return 0}var ml=class n extends ri{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Em(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Kc(this.context.next,this.base,this.pos)}};function Em(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Bm(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.from<o?t:null;l=a.to}}function Pm(n,e,t,i,r){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==n.pos+o,a=e?Bm(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var Rm=200;function _c(){return he.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+Rm)return n;let s=t.sliceString(r.from,i);if(!e.some(h=>h.test(s)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=$r(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],p=Ii(o,f);u!=p&&a.push({from:c.from,to:c.from+u.length,insert:p})}return a.length?[n,{changes:a,sequential:!0}]:n})}var Pi=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=Ke.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof We?l=>l.prop(Oi)==o.data:o?l=>l==o:void 0,this.style=hl(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ke(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},gl=I.define(),Gc=I.define({combine(n){return n.length?[n[0]]:null}});function ul(n){let e=n.facet(gl);return e.length?e:n.facet(Gc)}function Kr(n,e){let t=[Im],i;return n instanceof Pi&&(n.module&&t.push(z.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(Gc.of(n)):i?t.push(gl.computeN([z.darkTheme],r=>r.facet(z.darkTheme)==(i=="dark")?[n]:[])):t.push(gl.of(n)),t}var bl=class{constructor(e){this.markCache=Object.create(null),this.tree=Be(e.state),this.decorations=this.buildDeco(e,ul(e.state))}update(e){let t=Be(e.state),i=ul(e.state),r=i!=ul(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i))}buildDeco(e,t){if(!t||!this.tree.length)return Y.none;let i=new ot;for(let{from:r,to:s}of e.visibleRanges)Nc(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Y.mark({class:a})))},r,s);return i.finish()}},Im=Lt.high(ye.fromClass(bl,{decorations:n=>n.decorations})),Uc=Pi.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),Nm=z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Yc=1e4,Jc="()[]{}",Xc=I.define({combine(n){return ze(n,{afterCursor:!0,brackets:Jc,maxScanDistance:Yc,renderMatch:Hm})}}),zm=Y.mark({class:"cm-matchingBracket"}),Fm=Y.mark({class:"cm-nonmatchingBracket"});function Hm(n){let e=[],t=n.matched?zm:Fm;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}var Vm=pe.define({create(){return Y.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(Xc);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=nt(e.state,r.head,-1,i)||r.head>0&&nt(e.state,r.head-1,1,i)||i.afterCursor&&(nt(e.state,r.head,1,i)||r.head<e.state.doc.length&&nt(e.state,r.head+1,-1,i));s&&(t=t.concat(i.renderMatch(s,e.state)))}return Y.set(t,!0)},provide:n=>z.decorations.from(n)}),Wm=[Vm,Nm];function Zc(n={}){return[Xc.of(n),Wm]}var jm=new X;function kl(n,e,t){let i=n.prop(e<0?X.openedBy:X.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function yl(n){let e=n.type.prop(jm);return e?e(n.node):n}function nt(n,e,t,i={}){let r=i.maxScanDistance||Yc,s=i.brackets||Jc,o=Be(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=kl(a.type,t,s);if(h&&a.from<a.to){let c=yl(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return qm(n,e,t,a,c,h,s)}}return $m(n,e,t,o,l.type,r,s)}function qm(n,e,t,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},h=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=yl(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(kl(c.type,t,o))h++;else if(kl(c.type,-t,o)){if(h==0){let f=yl(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function $m(n,e,t,i,r,s,o){let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let p=c.value;t<0&&(u+=p.length);let g=e+u*t;for(let x=t>0?0:p.length-1,y=t>0?p.length:-1;x!=y;x+=t){let v=o.indexOf(p[x]);if(!(v<0||i.resolveInner(g+x,1).type!=r))if(v%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:g+x,to:g+x+1},matched:v>>1==a>>1};f--}}t>0&&(u+=p.length)}return c.done?{start:h,matched:!1}:null}function Hc(n,e,t,i=0,r=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let s=r;for(let o=i;o<e;o++)n.charCodeAt(o)==9?s+=t-s%t:s++;return s}var jr=class{constructor(e,t,i,r){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Hc(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Hc(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let r=o=>i?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return r(s)==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}};function Km(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||_m,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||vl}}function _m(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}var Vc=new WeakMap,Ri=class n extends We{constructor(e){let t=Sm(e.languageData),i=Km(e),r,s=new class extends Cn{createParse(o,l,a){return new wl(r,o,l,a)}};super(t,s,[$c.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=Jm(t),r=this,this.streamParser=i,this.stateAfter=new X({perNode:!0}),this.tokenTable=e.tokenTable?new qr(i.tokenTable):Ym}static define(e){return new n(e)}getIndent(e,t){let i=Be(e.state),r=i.resolve(t);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let s,{overrideIndentation:o}=e.options;o&&(s=Vc.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let l=xl(this,i,0,r.from,s!=null?s:t),a,h;if(l?(h=l.state,a=l.pos+1):(h=this.streamParser.startState(e.unit),a=0),t-a>1e4)return null;for(;a<t;){let f=e.state.doc.lineAt(a),u=Math.min(t,f.to);if(f.length){let p=o?o(f.from):-1,g=new jr(f.text,e.state.tabSize,e.unit,p<0?void 0:p);for(;g.pos<u-f.from;)ef(this.streamParser.token,g,h)}else this.streamParser.blankLine(h,e.unit);if(u==t)break;a=f.to+1}let c=e.lineAt(t);return o&&s==null&&Vc.set(e.state,c.from),this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],e)}get allowsNesting(){return!1}};function xl(n,e,t,i,r){let s=t>=i&&t+e.length<=r&&e.prop(n.stateAfter);if(s)return{state:n.streamParser.copyState(s),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof de&&a<r&&xl(n,l,a,i,r);if(h)return h}return null}function Qc(n,e,t,i,r){if(r&&t<=0&&i>=e.length)return e;!r&&e.type==n.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],l=e.children[s],a;if(o<i&&l instanceof de){if(!(a=Qc(n,l,t-o,i-o,r)))break;return r?new de(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function Gm(n,e,t,i){for(let r of e){let s=r.from+(r.openStart?25:0),o=r.to-(r.openEnd?25:0),l=s<=t&&o>t&&xl(n,r.tree,0-r.offset,t,o),a;if(l&&(a=Qc(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:a}}return{state:n.streamParser.startState(i?Ft(i):4),tree:de.empty}}var wl=class{constructor(e,t,i,r){this.lang=e,this.input=t,this.fragments=i,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let s=Mn.get(),o=r[0].from,{state:l,tree:a}=Gm(e,i,o,s==null?void 0:s.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&(this.state=this.lang.streamParser.startState(Ft(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=Mn.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+2048);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
11
+ `&&(t="");else{let i=t.indexOf(`
12
+ `);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=i||(t=t.slice(0,s-(i-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(i>0?r>s:r>=s)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,r,s){if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let o=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-o}return this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),r=0,{streamParser:s}=this.lang,o=new jr(t,e?e.state.tabSize:4,e?Ft(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=ef(s.token,o,this.state);if(l&&(r=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,4,r)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=de.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Um,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new de(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new de(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function ef(n,e,t){e.start=e.pos;for(let i=0;i<10;i++){let r=n(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}var vl=Object.create(null),Dn=[Ee.none],Um=new Nr(Dn),Wc=[],jc=Object.create(null),tf=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])tf[n]=nf(vl,e);var qr=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),tf)}resolve(e){return e?this.table[e]||(this.table[e]=nf(this.extra,e)):0}},Ym=new qr(vl);function dl(n,e){Wc.indexOf(n)>-1||(Wc.push(n),console.warn(e))}function nf(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||P[h];c?typeof c=="function"?a.length?a=a.map(c):dl(h,`Modifier ${h} used at start of tag`):a.length?dl(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:dl(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(l=>l.id),s=jc[r];if(s)return s.id;let o=jc[r]=Ee.define({id:Dn.length,name:i,props:[Rc({[i]:t})]});return Dn.push(o),o.id}function Jm(n){let e=Ee.define({id:Dn.length,name:"Document",props:[Oi.add(()=>n)],top:!0});return Dn.push(e),e}var Xm=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Dl(n.state,t.from);return i.line?Zm(n):i.block?eg(n):!1};function Ll(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var Zm=Ll(ng,0);var Qm=Ll(ff,0);var eg=Ll((n,e)=>ff(n,e,ig(e)),0);function Dl(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var On=50;function tg(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-On,i),o=n.sliceDoc(r,r+On),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-i<=2*On?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+On),f=n.sliceDoc(r-On,r));let u=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(f)[0].length,g=f.length-p-t.length;return c.slice(u,u+e.length)==e&&f.slice(g,g+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-p-t.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function ig(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function ff(n,e,t=e.selection.ranges){let i=t.map(s=>Dl(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>tg(e,i[o],s.from,s.to));if(n!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(n!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=i[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function ng(n,e,t=e.selection.ranges){let i=[],r=-1;for(let{from:s,to:o}of t){let l=i.length,a=1e9,h=Dl(e,s).line;if(h){for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,p=u==f.length,g=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:g,token:h,indent:u,empty:p,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}var Cl=Ne.define(),rg=Ne.define(),sg=I.define(),uf=I.define({combine(n){return ze(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,r)=>e(i,r)||t(i,r)})}}),df=pe.define({create(){return si.empty},update(n,e){let t=e.state.facet(uf),i=e.annotation(Cl);if(i){let a=rt.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=Gr(c,c.length,t.minDepth,a):c=bf(c,e.startState.selection),new si(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(rg);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(xe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=rt.fromTransaction(e),o=e.annotation(xe.time),l=e.annotation(xe.userEvent);return s?n=n.addChanges(s,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new si(n.done.map(rt.fromJSON),n.undone.map(rt.fromJSON))}});function pf(n={}){return[df,uf.of(n),z.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?mf:e.inputType=="historyRedo"?Al:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ur(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(df,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var mf=Ur(0,!1),Al=Ur(1,!1),og=Ur(0,!0),lg=Ur(1,!0);var rt=class n{constructor(e,t,i,r,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&De.fromJSON(e.changes),[],e.mapped&&yt.fromJSON(e.mapped),e.startSelection&&L.fromJSON(e.startSelection),e.selectionsAfter.map(L.fromJSON))}static fromTransaction(e,t){let i=Ue;for(let r of e.startState.facet(sg)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ue)}static selection(e){return new n(void 0,Ue,void 0,void 0,e)}};function Gr(n,e,t,i){let r=e+1>t+20?e-t-1:0,s=n.slice(r,e);return s.push(i),s}function ag(n,e){let t=[],i=!1;return n.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function hg(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function gf(n,e){return n.length?e.length?n.concat(e):n:e}var Ue=[],cg=200;function bf(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-cg));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Gr(n,n.length-1,1e9,t.setSelAfter(i)))}else return[rt.selection([e])]}function fg(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Sl(n,e){if(!n.length)return n;let t=n.length,i=Ue;for(;t;){let r=ug(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=n.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[rt.selection(i)]:Ue}function ug(n,e,t){let i=gf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Ue,t);if(!n.changes)return rt.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new rt(r,J.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var dg=/^(input\.type|delete)($|\.)/,si=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||dg.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,ag(l.changes,e.changes))||i=="input.type.compose")?o=Gr(o,o.length-1,r.minDepth,new rt(e.changes.compose(l.changes),gf(e.effects,l.effects),l.mapped,l.startSelection,Ue)):o=Gr(o,o.length,r.minDepth,e),new n(o,Ue,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Ue;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&hg(s[s.length-1],e)?this:new n(bf(this.done,e),this.undone,t,i)}addMapping(e){return new n(Sl(this.done,e),Sl(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||t.selection;if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Cl.of({side:e,rest:fg(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Ue:r.slice(0,r.length-1);return s.mapped&&(l=Sl(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Cl.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};si.empty=new si(Ue,Ue);var kf=[{key:"Mod-z",run:mf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Al,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Al,preventDefault:!0},{key:"Mod-u",run:og,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:lg,preventDefault:!0}];function Ni(n,e){return L.create(n.ranges.map(e),n.mainIndex)}function mt(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function st({state:n,dispatch:e},t){let i=Ni(n.selection,t);return i.eq(n.selection)?!1:(e(mt(n,i)),!0)}function Yr(n,e){return L.cursor(e?n.to:n.from)}function yf(n,e){return st(n,t=>t.empty?n.moveByChar(t,e):Yr(t,e))}function Le(n){return n.textDirectionAt(n.state.selection.main.head)==ge.LTR}var wf=n=>yf(n,!Le(n)),xf=n=>yf(n,Le(n));function vf(n,e){return st(n,t=>t.empty?n.moveByGroup(t,e):Yr(t,e))}var pg=n=>vf(n,!Le(n)),mg=n=>vf(n,Le(n));var Bb=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function gg(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Jr(n,e,t){let i=Be(n).resolveInner(e.head),r=t?X.closedBy:X.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;gg(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?nt(n,i.from,1):nt(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,L.cursor(l,t?-1:1)}var bg=n=>st(n,e=>Jr(n.state,e,!Le(n))),kg=n=>st(n,e=>Jr(n.state,e,Le(n)));function Sf(n,e){return st(n,t=>{if(!t.empty)return Yr(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Cf=n=>Sf(n,!1),Af=n=>Sf(n,!0);function Tf(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(z.scrollMargins)){let o=s(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function Mf(n,e){let t=Tf(n),{state:i}=n,r=Ni(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):Yr(o,e));if(r.eq(i.selection))return!1;let s;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(s=z.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(mt(i,r),{effects:s}),!0}var rf=n=>Mf(n,!1),Tl=n=>Mf(n,!0);function Vt(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let s=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=L.cursor(i.from+s))}return r}var yg=n=>st(n,e=>Vt(n,e,!0)),wg=n=>st(n,e=>Vt(n,e,!1)),xg=n=>st(n,e=>Vt(n,e,!Le(n))),vg=n=>st(n,e=>Vt(n,e,Le(n))),Sg=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).from,1)),Cg=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).to,-1));function Ag(n,e,t){let i=!1,r=Ni(n.selection,s=>{let o=nt(n,s.head,-1)||nt(n,s.head,1)||s.head>0&&nt(n,s.head-1,1)||s.head<n.doc.length&&nt(n,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return t?L.range(s.anchor,l):L.cursor(l)});return i?(e(mt(n,r)),!0):!1}var Tg=({state:n,dispatch:e})=>Ag(n,e,!1);function Ye(n,e){let t=Ni(n.state.selection,i=>{let r=e(i);return L.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(mt(n.state,t)),!0)}function Lf(n,e){return Ye(n,t=>n.moveByChar(t,e))}var Df=n=>Lf(n,!Le(n)),Of=n=>Lf(n,Le(n));function Ef(n,e){return Ye(n,t=>n.moveByGroup(t,e))}var Mg=n=>Ef(n,!Le(n)),Lg=n=>Ef(n,Le(n));var Dg=n=>Ye(n,e=>Jr(n.state,e,!Le(n))),Og=n=>Ye(n,e=>Jr(n.state,e,Le(n)));function Bf(n,e){return Ye(n,t=>n.moveVertically(t,e))}var Pf=n=>Bf(n,!1),Rf=n=>Bf(n,!0);function If(n,e){return Ye(n,t=>n.moveVertically(t,e,Tf(n).height))}var sf=n=>If(n,!1),of=n=>If(n,!0),Eg=n=>Ye(n,e=>Vt(n,e,!0)),Bg=n=>Ye(n,e=>Vt(n,e,!1)),Pg=n=>Ye(n,e=>Vt(n,e,!Le(n))),Rg=n=>Ye(n,e=>Vt(n,e,Le(n))),Ig=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).from)),Ng=n=>Ye(n,e=>L.cursor(n.lineBlockAt(e.head).to)),lf=({state:n,dispatch:e})=>(e(mt(n,{anchor:0})),!0),af=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.doc.length})),!0),hf=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.selection.main.anchor,head:0})),!0),cf=({state:n,dispatch:e})=>(e(mt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),zg=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Fg=({state:n,dispatch:e})=>{let t=Xr(n).map(({from:i,to:r})=>L.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:L.create(t),userEvent:"select"})),!0},Hg=({state:n,dispatch:e})=>{let t=Ni(n.selection,i=>{var r;let s=Be(n).resolveStack(i.from,1);for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&(!((r=l.parent)===null||r===void 0)&&r.parent))return L.range(l.to,l.from)}return i});return e(mt(n,t)),!0},Vg=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=L.create([t.main]):t.main.empty||(i=L.create([L.cursor(t.main.head)])),i?(e(mt(n,i)),!0):!1};function En(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=_r(n,a,!1)):a>o&&(t="delete.forward",a=_r(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=_r(n,o,!1),l=_r(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:L.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?z.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function _r(n,e,t){if(n instanceof z)for(let i of n.state.facet(z.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var Nf=(n,e)=>En(n,t=>{let i=t.from,{state:r}=n,s=r.doc.lineAt(i),o,l;if(!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(o=s.text.slice(0,i-s.from))){if(o[o.length-1]==" ")return i-1;let a=Dt(o,r.tabSize),h=a%Ft(r)||Ft(r);for(let c=0;c<h&&o[o.length-1-c]==" ";c++)i--;l=i}else l=be(s.text,i-s.from,e,e)+s.from,l==i&&s.number!=(e?r.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=be(s.text,l-s.from,!1,!1)+s.from);return l}),Ml=n=>Nf(n,!1),zf=n=>Nf(n,!0),Ff=(n,e)=>En(n,t=>{let i=t.head,{state:r}=n,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let a=be(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,a)-s.from,Math.max(i,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),Hf=n=>Ff(n,!1),Wg=n=>Ff(n,!0),jg=n=>En(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var qg=n=>En(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),$g=n=>En(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var Kg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Z.of(["",""])},range:L.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},_g=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,s=n.doc.lineAt(r),o=r==s.from?r-1:be(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:be(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:n.doc.slice(r,l).append(n.doc.slice(o,r))},range:L.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Xr(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),s=n.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=n.doc.lineAt(i.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Vf(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Xr(n)){if(t?s.to==n.doc.length:s.from==0)continue;let o=n.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+n.lineBreak});for(let a of s.ranges)r.push(L.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:n.lineBreak+o.text});for(let a of s.ranges)r.push(L.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:L.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Gg=({state:n,dispatch:e})=>Vf(n,e,!1),Ug=({state:n,dispatch:e})=>Vf(n,e,!0);function Wf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of Xr(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Yg=({state:n,dispatch:e})=>Wf(n,e,!1),Jg=({state:n,dispatch:e})=>Wf(n,e,!0),Xg=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Xr(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Ni(e.selection,r=>n.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Zg(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Be(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(X.closedBy))&&s.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var Qg=jf(!1),e0=jf(!0);function jf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!n&&s==o&&Zg(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new ri(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=$r(h,s);for(c==null&&(c=Dt(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",Ii(e,c)];return a&&f.push(Ii(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Z.of(f)},range:L.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ol(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,r,i),t=l.number),o=l.to+1}let s=n.changes(r);return{changes:r,range:L.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var t0=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new ri(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=Ol(n,(s,o,l)=>{let a=$r(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Ii(n,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},i0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ol(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Ht)})}),{userEvent:"input.indent"})),!0),n0=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ol(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Dt(r,n.tabSize),o=0,l=Ii(n,Math.max(0,s-Ft(n)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0);var r0=[{key:"Ctrl-b",run:wf,shift:Df,preventDefault:!0},{key:"Ctrl-f",run:xf,shift:Of},{key:"Ctrl-p",run:Cf,shift:Pf},{key:"Ctrl-n",run:Af,shift:Rf},{key:"Ctrl-a",run:Sg,shift:Ig},{key:"Ctrl-e",run:Cg,shift:Ng},{key:"Ctrl-d",run:zf},{key:"Ctrl-h",run:Ml},{key:"Ctrl-k",run:jg},{key:"Ctrl-Alt-h",run:Hf},{key:"Ctrl-o",run:Kg},{key:"Ctrl-t",run:_g},{key:"Ctrl-v",run:Tl}],s0=[{key:"ArrowLeft",run:wf,shift:Df,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:pg,shift:Mg,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:xg,shift:Pg,preventDefault:!0},{key:"ArrowRight",run:xf,shift:Of,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:mg,shift:Lg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:vg,shift:Rg,preventDefault:!0},{key:"ArrowUp",run:Cf,shift:Pf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:lf,shift:hf},{mac:"Ctrl-ArrowUp",run:rf,shift:sf},{key:"ArrowDown",run:Af,shift:Rf,preventDefault:!0},{mac:"Cmd-ArrowDown",run:af,shift:cf},{mac:"Ctrl-ArrowDown",run:Tl,shift:of},{key:"PageUp",run:rf,shift:sf},{key:"PageDown",run:Tl,shift:of},{key:"Home",run:wg,shift:Bg,preventDefault:!0},{key:"Mod-Home",run:lf,shift:hf},{key:"End",run:yg,shift:Eg,preventDefault:!0},{key:"Mod-End",run:af,shift:cf},{key:"Enter",run:Qg},{key:"Mod-a",run:zg},{key:"Backspace",run:Ml,shift:Ml},{key:"Delete",run:zf},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Hf},{key:"Mod-Delete",mac:"Alt-Delete",run:Wg},{mac:"Mod-Backspace",run:qg},{mac:"Mod-Delete",run:$g}].concat(r0.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),qf=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:bg,shift:Dg},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:kg,shift:Og},{key:"Alt-ArrowUp",run:Gg},{key:"Shift-Alt-ArrowUp",run:Yg},{key:"Alt-ArrowDown",run:Ug},{key:"Shift-Alt-ArrowDown",run:Jg},{key:"Escape",run:Vg},{key:"Mod-Enter",run:e0},{key:"Alt-l",mac:"Ctrl-l",run:Fg},{key:"Mod-i",run:Hg,preventDefault:!0},{key:"Mod-[",run:n0},{key:"Mod-]",run:i0},{key:"Mod-Alt-\\",run:t0},{key:"Shift-Mod-k",run:Xg},{key:"Shift-Mod-\\",run:Tg},{key:"Mod-/",run:Xm},{key:"Alt-A",run:Qm}].concat(s0);function ne(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];typeof r=="string"?n.setAttribute(i,r):r!=null&&(n[i]=r)}e++}for(;e<arguments.length;e++)$f(n,arguments[e]);return n}function $f(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)$f(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}var Kf=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n,oi=class{constructor(e,t,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?l=>s(Kf(l)):Kf,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return $e(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=er(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=wt(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let l=r.charCodeAt(s),a=this.match(l,o);if(s==r.length-1){if(a)return this.value=a,this;break}o==i&&s<t.length&&t.charCodeAt(s)==l&&o++}}}match(e,t){let i=null;for(let r=0;r<this.matches.length;r+=2){let s=this.matches[r],o=!1;this.query.charCodeAt(s)==e&&(s==this.query.length-1?i={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:t+1}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}};typeof Symbol!="undefined"&&(oi.prototype[Symbol.iterator]=function(){return this});var Uf={from:-1,to:-1,match:/.*/.exec("")},zl="gm"+(/x/.unicode==null?"":"u"),es=class{constructor(e,t,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=Uf,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new is(e,t,i,r,s);this.re=new RegExp(t,zl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=ns(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,r=i+t[0].length;if(this.matchPos=ns(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},El=new WeakMap,ts=class n{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let r=El.get(e);if(!r||r.from>=i||r.to<=t){let l=new n(t,e.sliceString(t,i));return El.set(e,l),l}if(r.from==t&&r.to==i)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to<i&&(s+=e.sliceString(r.to,i)),El.set(e,new n(o,s)),new n(t,s.slice(t-o,i-o))}},is=class{constructor(e,t,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=Uf,this.matchPos=ns(e,r),this.re=new RegExp(t,zl+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=ts.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,r=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,t)))return this.value={from:i,to:r,match:t},this.matchPos=ns(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ts.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(es.prototype[Symbol.iterator]=is.prototype[Symbol.iterator]=function(){return this});function o0(n){try{return new RegExp(n,zl),!0}catch(e){return!1}}function ns(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function Bl(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=ne("input",{class:"cm-textfield",name:"line",value:e}),i=ne("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:rs.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},ne("label",n.state.phrase("Go to line"),": ",t)," ",ne("button",{class:"cm-button",type:"submit"},n.state.phrase("go")));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,h,c,f]=s,u=c?+c.slice(1):0,p=h?+h:l.number;if(h&&f){let y=p/100;a&&(y=y*(a=="-"?-1:1)+l.number/o.doc.lines),p=Math.round(o.doc.lines*y)}else h&&a&&(p=p*(a=="-"?-1:1)+l.number);let g=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),x=L.cursor(g.from+Math.max(0,Math.min(u,g.length)));n.dispatch({effects:[rs.of(!1),z.scrollIntoView(x.from,{y:"center"})],selection:x}),n.focus()}return{dom:i}}var rs=J.define(),_f=pe.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(rs)&&(n=t.value);return n},provide:n=>ei.from(n,e=>e?Bl:null)}),l0=n=>{let e=ti(n,Bl);if(!e){let t=[rs.of(!0)];n.state.field(_f,!1)==null&&t.push(J.appendConfig.of([_f,a0])),n.dispatch({effects:t}),e=ti(n,Bl)}return e&&e.dom.querySelector("input").select(),!0},a0=z.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});var h0=({state:n,dispatch:e})=>{let{selection:t}=n,i=L.create(t.ranges.map(r=>n.wordAt(r.head)||L.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function c0(n,e){let{main:t,ranges:i}=n.selection,r=n.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new oi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new oi(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(s){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}var f0=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return h0({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(s=>n.sliceDoc(s.from,s.to)!=i))return!1;let r=c0(n,i);return r?(e(n.update({selection:n.selection.addRange(L.range(r.from,r.to),!1),effects:z.scrollIntoView(r.to)})),!0):!1},Hi=I.define({combine(n){return ze(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Nl(e),scrollToMatch:e=>z.scrollIntoView(e)})}});var ss=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||o0(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
13
+ `:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new Rl(this):new Pl(this)}getCursor(e,t=0,i){let r=e.doc?e:he.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Fi(this,r,t,i):zi(this,r,t,i)}},os=class{constructor(e){this.spec=e}};function zi(n,e,t,i){return new oi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?u0(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function u0(n,e){return(t,i,r,s)=>((s>t||s+r.length<i)&&(s=Math.max(0,t-2),r=n.sliceString(s,Math.min(n.length,i+2))),(e(ls(r,t-s))!=fe.Word||e(as(r,t-s))!=fe.Word)&&(e(as(r,i-s))!=fe.Word||e(ls(r,i-s))!=fe.Word))}var Pl=class extends os{constructor(e){super(e)}nextMatch(e,t,i){let r=zi(this.spec,e,i,e.doc.length).nextOverlapping();return r.done&&(r=zi(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=i;;){let s=Math.max(t,r-1e4-this.spec.unquoted.length),o=zi(this.spec,e,s,r),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==t)return null;r-=1e4}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=zi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=zi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}};function Fi(n,e,t,i){return new es(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?d0(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ls(n,e){return n.slice(be(n,e,!1),e)}function as(n,e){return n.slice(e,be(n,e))}function d0(n){return(e,t,i)=>!i[0].length||(n(ls(i.input,i.index))!=fe.Word||n(as(i.input,i.index))!=fe.Word)&&(n(as(i.input,i.index+i[0].length))!=fe.Word||n(ls(i.input,i.index+i[0].length))!=fe.Word)}var Rl=class extends os{nextMatch(e,t,i){let r=Fi(this.spec,e,i,e.doc.length).next();return r.done&&(r=Fi(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,i){for(let r=1;;r++){let s=Math.max(t,i-r*1e4),o=Fi(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g,(t,i)=>i=="$"?"$":i=="&"?e.match[0]:i!="0"&&+i<e.match.length?e.match[i]:t))}matchAll(e,t){let i=Fi(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=t)return null;r.push(i.value)}return r}highlight(e,t,i,r){let s=Fi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}},Pn=J.define(),Fl=J.define(),Wt=pe.define({create(n){return new Bn(Il(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Pn)?n=new Bn(t.value.create(),n.panel):t.is(Fl)&&(n=new Bn(n.query,t.value?Hl:null));return n},provide:n=>ei.from(n,e=>e.panel)});var Bn=class{constructor(e,t){this.query=e,this.panel=t}},p0=Y.mark({class:"cm-searchMatch"}),m0=Y.mark({class:"cm-searchMatch cm-searchMatch-selected"}),g0=ye.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Wt))}update(n){let e=n.state.field(Wt);(e!=n.startState.field(Wt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Y.none;let{view:t}=this,i=new ot;for(let r=0,s=t.visibleRanges,o=s.length;r<o;r++){let{from:l,to:a}=s[r];for(;r<o-1&&a>s[r+1].from-2*250;)a=s[++r].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?m0:p0)})}return i.finish()}},{decorations:n=>n.decorations});function Rn(n){return e=>{let t=e.state.field(Wt,!1);return t&&t.query.spec.valid?n(e,t):Xf(e)}}var hs=Rn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=L.single(i.from,i.to),s=n.state.facet(Hi);return n.dispatch({selection:r,effects:[Vl(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),Jf(n),!0}),cs=Rn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=L.single(r.from,r.to),o=n.state.facet(Hi);return n.dispatch({selection:s,effects:[Vl(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),Jf(n),!0}),b0=Rn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:L.create(t.map(i=>L.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),k0=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:r}=t.main,s=[],o=0;for(let l=new oi(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(L.range(l.value.from,l.value.to))}return e(n.update({selection:L.create(s,o),userEvent:"select.search.matches"})),!0},Gf=Rn((n,{query:e})=>{let{state:t}=n,{from:i,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,i,i);if(!s)return!1;let o=[],l,a,h=[];if(s.from==i&&s.to==r&&(a=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(t,s.from,s.to),h.push(z.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),s){let c=o.length==0||o[0].from>=s.to?0:s.to-s.from-a.length;l=L.single(s.from-c,s.to-c),h.push(Vl(n,s)),h.push(t.facet(Hi).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),y0=Rn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:z.announce.of(i),userEvent:"input.replace.all"}),!0});function Hl(n){return n.state.facet(Hi).createPanel(n)}function Il(n,e){var t,i,r,s,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(Hi);return new ss({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(r=e==null?void 0:e.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Yf(n){let e=ti(n,Hl);return e&&e.dom.querySelector("[main-field]")}function Jf(n){let e=Yf(n);e&&e==n.root.activeElement&&e.select()}var Xf=n=>{let e=n.state.field(Wt,!1);if(e&&e.panel){let t=Yf(n);if(t&&t!=n.root.activeElement){let i=Il(n.state,e.query.spec);i.valid&&n.dispatch({effects:Pn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Fl.of(!0),e?Pn.of(Il(n.state,e.query.spec)):J.appendConfig.of(x0)]});return!0},Zf=n=>{let e=n.state.field(Wt,!1);if(!e||!e.panel)return!1;let t=ti(n,Hl);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Fl.of(!1)}),!0},Qf=[{key:"Mod-f",run:Xf,scope:"editor search-panel"},{key:"F3",run:hs,shift:cs,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:hs,shift:cs,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Zf,scope:"editor search-panel"},{key:"Mod-Shift-l",run:k0},{key:"Alt-g",run:l0},{key:"Mod-d",run:f0,preventDefault:!0}],Nl=class{constructor(e){this.view=e;let t=this.query=e.state.field(Wt).query.spec;this.commit=this.commit.bind(this),this.searchField=ne("input",{value:t.search,placeholder:je(e,"Find"),"aria-label":je(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ne("input",{value:t.replace,placeholder:je(e,"Replace"),"aria-label":je(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ne("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ne("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ne("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return ne("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=ne("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>hs(e),[je(e,"next")]),i("prev",()=>cs(e),[je(e,"previous")]),i("select",()=>b0(e),[je(e,"all")]),ne("label",null,[this.caseField,je(e,"match case")]),ne("label",null,[this.reField,je(e,"regexp")]),ne("label",null,[this.wordField,je(e,"by word")]),...e.state.readOnly?[]:[ne("br"),this.replaceField,i("replace",()=>Gf(e),[je(e,"replace")]),i("replaceAll",()=>y0(e),[je(e,"replace all")])],ne("button",{name:"close",onclick:()=>Zf(e),"aria-label":je(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new ss({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Pn.of(e)}))}keydown(e){mc(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?cs:hs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Gf(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Pn)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Hi).top}};function je(n,e){return n.state.phrase(e)}var Zr=30,Qr=/[\s\.,:;?!]/;function Vl(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),r=n.state.doc.lineAt(t).to,s=Math.max(i.from,e-Zr),o=Math.min(r,t+Zr),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<Zr;a++)if(!Qr.test(l[a+1])&&Qr.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-Zr;a--)if(!Qr.test(l[a-1])&&Qr.test(l[a])){l=l.slice(0,a);break}}return z.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}var w0=z.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),x0=[Wt,Lt.low(g0),w0];var Wl=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},li=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=e,s=i.facet(ai).markerFilter;s&&(r=s(r));let o=Y.set(r.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?Y.widget({widget:new jl(l),diagnostic:l}).range(l.from):Y.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l}).range(l.from,l.to)),!0);return new n(o,t,Vi(o))}};function Vi(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new Wl(r,s,o.diagnostic),!1}),i}function tu(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(ms))||n.changes.touchesRange(t.from,t.to))}function iu(n,e){return n.field(Je,!1)?e:e.concat(J.appendConfig.of(cu))}function v0(n,e){return{effects:iu(n,[ms.of(e)])}}var ms=J.define(),$l=J.define(),nu=J.define(),Je=pe.define({create(){return new li(Y.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Vi(t,n.selected.diagnostic,r)||Vi(t,null,r)}n=new li(t,n.panel,i)}for(let t of e.effects)t.is(ms)?n=li.init(t.value,n.panel,e.state):t.is($l)?n=new li(n.diagnostics,t.value?ps.open:null,n.selected):t.is(nu)&&(n=new li(n.diagnostics,n.panel,t.value));return n},provide:n=>[ei.from(n,e=>e.panel),z.decorations.from(n,e=>e.diagnostics)]});var S0=Y.mark({class:"cm-lintRange cm-lintRange-active"});function C0(n,e,t){let{diagnostics:i}=n.state.field(Je),r=[],s=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0))&&(r.push(c.diagnostic),s=Math.min(a,s),o=Math.max(h,o))});let l=n.state.facet(ai).tooltipFilter;return l&&(r=l(r)),r.length?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:ru(n,r)}}}:null}function ru(n,e){return ne("ul",{class:"cm-tooltip-lint"},e.map(t=>lu(n,t,!1)))}var Kl=n=>{let e=n.state.field(Je,!1);(!e||!e.panel)&&n.dispatch({effects:iu(n.state,[$l.of(!0)])});let t=ti(n,ps.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},In=n=>{let e=n.state.field(Je,!1);return!e||!e.panel?!1:(n.dispatch({effects:$l.of(!1)}),!0)};var A0=ye.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(ai);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(ai);Promise.all(t.map(i=>Promise.resolve(i(this.view)))).then(i=>{let r=i.reduce((s,o)=>s.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(v0(this.view.state,r))},i=>{He(this.view.state,i)})}}update(n){let e=n.state.facet(ai);(n.docChanged||e!=n.startState.facet(ai)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),ai=I.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},ze(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function su(n,e={}){return[ai.of({source:n,config:e}),A0,cu]}function ou(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function lu(n,e,t){var i;let r=t?ou(e.actions):[];return ne("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ne("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let p=Vi(n.state.field(Je).diagnostics,e);p&&s.apply(n,p.from,p.to)},{name:h}=s,c=r[o]?h.indexOf(r[o]):-1,f=c<0?h:[h.slice(0,c),ne("u",h.slice(c,c+1)),h.slice(c+1)];return ne("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&ne("div",{class:"cm-diagnosticSource"},e.source))}var jl=class extends et{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ne("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},ds=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=lu(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},ps=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)In(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=ou(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=Vi(this.view.state.field(Je).diagnostics,s);a&&s.actions[l].apply(e,a.from,a.to)}}else return;r.preventDefault()},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=ne("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=ne("div",{class:"cm-panel-lint"},this.list,ne("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>In(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Je).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Je),i=0,r=!1,s=null;for(e.between(0,this.view.state.doc.length,(o,l,{spec:a})=>{let h=-1,c;for(let f=i;f<this.items.length;f++)if(this.items[f].diagnostic==a.diagnostic){h=f;break}h<0?(c=new ds(this.view,a.diagnostic),this.items.splice(i,0,c),r=!0):(c=this.items[h],h>i&&(this.items.splice(i,h-i),r=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),s=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new ds(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{let a=l.height/this.list.offsetHeight;o.top<l.top?this.list.scrollTop-=(l.top-o.top)/a:o.bottom>l.bottom&&(this.list.scrollTop+=(o.bottom-l.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Je),i=Vi(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:nu.of(i)})}static open(e){return new n(e)}};function us(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function fs(n){return us(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var T0=z.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:fs("#d11")},".cm-lintRange-warning":{backgroundImage:fs("orange")},".cm-lintRange-info":{backgroundImage:fs("#999")},".cm-lintRange-hint":{backgroundImage:fs("#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 eu(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}var ql=class extends Ge{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((t,i)=>eu(t)<eu(i.severity)?i.severity:t,"hint")}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,r=e.state.facet(gs).tooltipFilter;return r&&(i=r(i)),i.length&&(t.onmouseover=()=>L0(e,t,i)),t}};function M0(n,e){let t=i=>{let r=e.getBoundingClientRect();if(!(i.clientX>r.left-10&&i.clientX<r.right+10&&i.clientY>r.top-10&&i.clientY<r.bottom+10)){for(let s=i.target;s;s=s.parentNode)if(s.nodeType==1&&s.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),n.state.field(hu)&&n.dispatch({effects:_l.of(null)})}};window.addEventListener("mousemove",t)}function L0(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:_l.of({pos:o.from,above:!1,create(){return{dom:ru(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,M0(n,e)}let{hoverTime:r}=n.state.facet(gs),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function D0(n,e){let t=Object.create(null);for(let r of e){let s=n.lineAt(r.from);(t[s.from]||(t[s.from]=[])).push(r)}let i=[];for(let r in t)i.push(new ql(t[r]).range(+r));return ie.of(i,!0)}var O0=Zo({class:"cm-gutter-lint",markers:n=>n.state.field(au)}),au=pe.define({create(){return ie.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet(gs).markerFilter;for(let i of e.effects)if(i.is(ms)){let r=i.value;t&&(r=t(r||[])),n=D0(e.state.doc,r.slice(0))}return n}}),_l=J.define(),hu=pe.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=tu(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(_l)?i.value:t,n)},provide:n=>yn.from(n)}),E0=z.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:us('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:us('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:us('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),cu=[Je,z.decorations.compute([Je],n=>{let{selected:e,panel:t}=n.field(Je);return!e||!t||e.from==e.to?Y.none:Y.set([S0.range(e.from,e.to)])}),wc(C0,{hideOn:tu}),T0],gs=I.define({combine(n){return ze(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function fu(n={}){return[gs.of(n),au,O0,E0,hu]}var bs={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},hi=J.define({map(n,e){let t=e.mapPos(n,-1,Ce.TrackAfter);return t==null?void 0:t}}),Ul=new class extends Ze{};Ul.startSide=1;Ul.endSide=-1;var pu=pe.define({create(){return ie.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(hi)&&(n=n.update({add:[Ul.range(t.value,t.value+1)]}));return n}});function mu(){return[I0,pu]}var Gl="()[]{}<>";function B0(n){for(let e=0;e<Gl.length;e+=2)if(Gl.charCodeAt(e)==n)return Gl.charAt(e+1);return er(n<128?n:n+1)}function P0(n,e){return n.languageDataAt("closeBrackets",e)[0]||bs}var R0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),I0=z.inputHandler.of((n,e,t,i)=>{if((R0?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&wt($e(i,0))==1||e!=r.from||t!=r.to)return!1;let s=N0(n.state,i);return s?(n.dispatch(s),!0):!1});function N0(n,e){let t=P0(n,n.selection.main.head),i=t.brackets||bs.brackets;for(let r of i){let s=B0($e(r,0));if(e==r)return s==r?H0(n,r,i.indexOf(r+r+r)>-1,t):z0(n,r,s,t.before||bs.before);if(e==s&&gu(n,n.selection.main.from))return F0(n,r,s)}return null}function gu(n,e){let t=!1;return n.field(pu).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Yl(n,e){let t=n.sliceString(e,e+2);return t.slice(0,wt($e(t,0)))}function z0(n,e,t,i){let r=null,s=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:hi.of(o.to+e.length),range:L.range(o.anchor+e.length,o.head+e.length)};let l=Yl(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:hi.of(o.head+e.length),range:L.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function F0(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&Yl(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:L.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function H0(n,e,t,i){let r=i.stringPrefixes||bs.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:hi.of(l.to+e.length),range:L.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Yl(n.doc,a),c;if(h==e){if(uu(n,a))return{changes:{insert:e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)};if(gu(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:L.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=du(n,a-2*e.length,r))>-1&&uu(n,c))return{changes:{insert:e+e+e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=fe.Word&&du(n,a,r)>-1&&!V0(n,a,e,r))return{changes:{insert:e+e,from:a},effects:hi.of(a+e.length),range:L.cursor(a+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function uu(n,e){let t=Be(n).resolveInner(e+1);return t.parent&&t.from==e}function V0(n,e,t,i){let r=Be(n).resolveInner(e,-1),s=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=r.firstChild;for(;c&&c.from==r.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function du(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=fe.Word)return e;for(let r of t){let s=e-r.length;if(n.sliceDoc(s,e)==r&&i(n.sliceDoc(s-1,s))!=fe.Word)return s}return-1}var S={permittedHtmlTags:new Set(["b","bdi","bdo","del","i","ins","u","font","big","small","sub","sup","h1","h2","h3","h4","h5","h6","cite","code","em","s","strike","strong","tt","var","div","center","blockquote","q","ol","ul","dl","table","caption","pre","ruby","rb","rp","rt","rtc","p","span","abbr","dfn","kbd","samp","data","time","mark","br","wbr","hr","li","dt","dd","td","th","tr","noinclude","includeonly","onlyinclude","img"]),implicitlyClosedHtmlTags:new Set(["br","hr","wbr","img"]),tags:{apostrophes:"mw-apostrophes",apostrophesBold:"mw-apostrophes-bold",apostrophesItalic:"mw-apostrophes-italic",comment:"mw-comment",doubleUnderscore:"mw-double-underscore",extLink:"mw-extlink",extLinkBracket:"mw-extlink-bracket",extLinkProtocol:"mw-extlink-protocol",extLinkText:"mw-extlink-text",hr:"mw-hr",htmlTagAttribute:"mw-htmltag-attribute",htmlTagBracket:"mw-htmltag-bracket",htmlTagName:"mw-htmltag-name",linkBracket:"mw-link-bracket",linkDelimiter:"mw-link-delimiter",linkText:"mw-link-text",linkToSection:"mw-link-tosection",list:"mw-list",parserFunction:"mw-parserfunction",parserFunctionBracket:"mw-parserfunction-bracket",parserFunctionDelimiter:"mw-parserfunction-delimiter",parserFunctionName:"mw-parserfunction-name",sectionHeader:"mw-section-header",sectionHeader1:"mw-section-1",sectionHeader2:"mw-section-2",sectionHeader3:"mw-section-3",sectionHeader4:"mw-section-4",sectionHeader5:"mw-section-5",sectionHeader6:"mw-section-6",signature:"mw-signature",tableBracket:"mw-table-bracket",tableDefinition:"mw-table-definition",tableDelimiter:"mw-table-delimiter",template:"mw-template",templateArgumentName:"mw-template-argument-name",templateBracket:"mw-template-bracket",templateDelimiter:"mw-template-delimiter",templateName:"mw-template-name",templateVariable:"mw-templatevariable",templateVariableBracket:"mw-templatevariable-bracket",templateVariableName:"mw-templatevariable-name",section:"mw-section",em:"mw-em",error:"mw-error",extGround:"mw-ext-ground",ext2Ground:"mw-ext2-ground",ext2LinkGround:"mw-ext2-link-ground",ext3Ground:"mw-ext3-ground",ext3LinkGround:"mw-ext3-link-ground",extLinkGround:"mw-ext-link-ground",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",htmlEntity:"mw-html-entity",link:"mw-link",linkGround:"mw-link-ground",linkPageName:"mw-link-pagename",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateExtGround:"mw-template-ext-ground",templateExt2Ground:"mw-template-ext2-ground",templateExt2LinkGround:"mw-template-ext2-link-ground",templateExt3Ground:"mw-template-ext3-ground",templateExt3LinkGround:"mw-template-ext3-link-ground",templateExtLinkGround:"mw-template-ext-link-ground",templateGround:"mw-template-ground",templateLinkGround:"mw-template-link-ground",templateVariableDelimiter:"mw-templatevariable-delimiter",template2ExtGround:"mw-template2-ext-ground",template2Ext2Ground:"mw-template2-ext2-ground",template2Ext3Ground:"mw-template2-ext3-ground",templatet2Ext2LinkGround:"mw-template2-ext2-link-ground",template2Ext3LinkGround:"mw-template2-ext3-link-ground",template2ExtLinkGround:"mw-template2-ext-link-ground",template2Ground:"mw-template2-ground",template2LinkGround:"mw-template2-link-ground",template3ExtGround:"mw-template3-ext-ground",template3Ext2Ground:"mw-template3-ext2-ground",template3Ext3Ground:"mw-template3-ext3-ground",template3ExtLinkGround:"mw-template3-ext-link-ground",template3Ext2LinkGround:"mw-template3-ext2-link-ground",template3Ext3LinkGround:"mw-template3-ext3-link-ground",template3Ground:"mw-template3-ground",template3LinkGround:"mw-template3-link-ground"},get tokenTable(){let n={};for(let e of Object.values(this.tags))n[e]=Pe.define();return n}};var Nn={};ld(Nn,{css:()=>Mu,javascript:()=>Lu,lua:()=>Eu});function ks(n){n={...$0,...n};var e=n.inline,t=n.tokenHooks,i=n.documentTypes||{},r=n.mediaTypes||{},s=n.mediaFeatures||{},o=n.mediaValueKeywords||{},l=n.propertyKeywords||{},a=n.nonStandardPropertyKeywords||{},h=n.fontProperties||{},c=n.counterDescriptors||{},f=n.colorKeywords||{},u=n.valueKeywords||{},p=n.allowNested,g=n.lineComment,x=n.supportsAtComponent===!0,y=n.highlightNonStandardPropertyKeywords!==!1,v,M;function O(k,T){return v=T,k}function R(k,T){var A=k.next();if(t[A]){var V=t[A](k,T);if(V!==!1)return V}if(A=="@")return k.eatWhile(/[\w\\\-]/),O("def",k.current());if(A=="="||(A=="~"||A=="|")&&k.eat("="))return O(null,"compare");if(A=='"'||A=="'")return T.tokenize=F(A),T.tokenize(k,T);if(A=="#")return k.eatWhile(/[\w\\\-]/),O("atom","hash");if(A=="!")return k.match(/^\s*\w*/),O("keyword","important");if(/\d/.test(A)||A=="."&&k.eat(/\d/))return k.eatWhile(/[\w.%]/),O("number","unit");if(A==="-"){if(/[\d.]/.test(k.peek()))return k.eatWhile(/[\w.%]/),O("number","unit");if(k.match(/^-[\w\\\-]*/))return k.eatWhile(/[\w\\\-]/),k.match(/^\s*:/,!1)?O("def","variable-definition"):O("variableName","variable");if(k.match(/^\w+-/))return O("meta","meta")}else return/[,+>*\/]/.test(A)?O(null,"select-op"):A=="."&&k.match(/^-?[_a-z][_a-z0-9-]*/i)?O("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(A)?O(null,A):k.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(k.current())&&(T.tokenize=q),O("variableName.function","variable")):/[\w\\\-]/.test(A)?(k.eatWhile(/[\w\\\-]/),O("property","word")):O(null,null)}function F(k){return function(T,A){for(var V=!1,le;(le=T.next())!=null;){if(le==k&&!V){k==")"&&T.backUp(1);break}V=!V&&le=="\\"}return(le==k||!V&&k!=")")&&(A.tokenize=null),O("string","string")}}function q(k,T){return k.next(),k.match(/^\s*[\"\')]/,!1)?T.tokenize=null:T.tokenize=F(")"),O(null,"(")}function w(k,T,A){this.type=k,this.indent=T,this.prev=A}function D(k,T,A,V){return k.context=new w(A,T.indentation()+(V===!1?0:T.indentUnit),k.context),A}function b(k){return k.context.prev&&(k.context=k.context.prev),k.context.type}function U(k,T,A){return K[A.context.type](k,T,A)}function $(k,T,A,V){for(var le=V||1;le>0;le--)A.context=A.context.prev;return U(k,T,A)}function G(k){var T=k.current().toLowerCase();u.hasOwnProperty(T)?M="atom":f.hasOwnProperty(T)?M="keyword":M="variable"}var K={};return K.top=function(k,T,A){if(k=="{")return D(A,T,"block");if(k=="}"&&A.context.prev)return b(A);if(x&&/@component/i.test(k))return D(A,T,"atComponentBlock");if(/^@(-moz-)?document$/i.test(k))return D(A,T,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(k))return D(A,T,"atBlock");if(/^@(font-face|counter-style)/i.test(k))return A.stateArg=k,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(k))return"keyframes";if(k&&k.charAt(0)=="@")return D(A,T,"at");if(k=="hash")M="builtin";else if(k=="word")M="tag";else{if(k=="variable-definition")return"maybeprop";if(k=="interpolation")return D(A,T,"interpolation");if(k==":")return"pseudo";if(p&&k=="(")return D(A,T,"parens")}return A.context.type},K.block=function(k,T,A){if(k=="word"){var V=T.current().toLowerCase();return l.hasOwnProperty(V)?(M="property","maybeprop"):a.hasOwnProperty(V)?(M=y?"string.special":"property","maybeprop"):p?(M=T.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(M="error","maybeprop")}else return k=="meta"?"block":!p&&(k=="hash"||k=="qualifier")?(M="error","block"):K.top(k,T,A)},K.maybeprop=function(k,T,A){return k==":"?D(A,T,"prop"):U(k,T,A)},K.prop=function(k,T,A){if(k==";")return b(A);if(k=="{"&&p)return D(A,T,"propBlock");if(k=="}"||k=="{")return $(k,T,A);if(k=="(")return D(A,T,"parens");if(k=="hash"&&!/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(T.current()))M="error";else if(k=="word")G(T);else if(k=="interpolation")return D(A,T,"interpolation");return"prop"},K.propBlock=function(k,T,A){return k=="}"?b(A):k=="word"?(M="property","maybeprop"):A.context.type},K.parens=function(k,T,A){return k=="{"||k=="}"?$(k,T,A):k==")"?b(A):k=="("?D(A,T,"parens"):k=="interpolation"?D(A,T,"interpolation"):(k=="word"&&G(T),"parens")},K.pseudo=function(k,T,A){return k=="meta"?"pseudo":k=="word"?(M="variableName.constant",A.context.type):U(k,T,A)},K.documentTypes=function(k,T,A){return k=="word"&&i.hasOwnProperty(T.current())?(M="tag",A.context.type):K.atBlock(k,T,A)},K.atBlock=function(k,T,A){if(k=="(")return D(A,T,"atBlock_parens");if(k=="}"||k==";")return $(k,T,A);if(k=="{")return b(A)&&D(A,T,p?"block":"top");if(k=="interpolation")return D(A,T,"interpolation");if(k=="word"){var V=T.current().toLowerCase();V=="only"||V=="not"||V=="and"||V=="or"?M="keyword":r.hasOwnProperty(V)?M="attribute":s.hasOwnProperty(V)?M="property":o.hasOwnProperty(V)?M="keyword":l.hasOwnProperty(V)?M="property":a.hasOwnProperty(V)?M=y?"string.special":"property":u.hasOwnProperty(V)?M="atom":f.hasOwnProperty(V)?M="keyword":M="error"}return A.context.type},K.atComponentBlock=function(k,T,A){return k=="}"?$(k,T,A):k=="{"?b(A)&&D(A,T,p?"block":"top",!1):(k=="word"&&(M="error"),A.context.type)},K.atBlock_parens=function(k,T,A){return k==")"?b(A):k=="{"||k=="}"?$(k,T,A,2):K.atBlock(k,T,A)},K.restricted_atBlock_before=function(k,T,A){return k=="{"?D(A,T,"restricted_atBlock"):k=="word"&&A.stateArg=="@counter-style"?(M="variable","restricted_atBlock_before"):U(k,T,A)},K.restricted_atBlock=function(k,T,A){return k=="}"?(A.stateArg=null,b(A)):k=="word"?(A.stateArg=="@font-face"&&!h.hasOwnProperty(T.current().toLowerCase())||A.stateArg=="@counter-style"&&!c.hasOwnProperty(T.current().toLowerCase())?M="error":M="property","maybeprop"):"restricted_atBlock"},K.keyframes=function(k,T,A){return k=="word"?(M="variable","keyframes"):k=="{"?D(A,T,"top"):U(k,T,A)},K.at=function(k,T,A){return k==";"?b(A):k=="{"||k=="}"?$(k,T,A):(k=="word"?M="tag":k=="hash"&&(M="builtin"),"at")},K.interpolation=function(k,T,A){return k=="}"?b(A):k=="{"||k==";"?$(k,T,A):(k=="word"?M="variable":k!="variable"&&k!="("&&k!=")"&&(M="error"),"interpolation")},{name:n.name,startState:function(){return{tokenize:null,state:e?"block":"top",stateArg:null,context:new w(e?"block":"top",0,null)}},token:function(k,T){if(!T.tokenize&&k.eatSpace())return null;var A=(T.tokenize||R)(k,T);return A&&typeof A=="object"&&(v=A[1],A=A[0]),M=A,v!="comment"&&(T.state=K[T.state](v,k,T)),M},indent:function(k,T,A){var V=k.context,le=T&&T.charAt(0),we=V.indent;return V.type=="prop"&&(le=="}"||le==")")&&(V=V.prev),V.prev&&(le=="}"&&(V.type=="block"||V.type=="top"||V.type=="interpolation"||V.type=="restricted_atBlock")?(V=V.prev,we=V.indent):(le==")"&&(V.type=="parens"||V.type=="atBlock_parens")||le=="{"&&(V.type=="at"||V.type=="atBlock"))&&(we=Math.max(0,V.indent-A.unit))),we},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:g,block:{open:"/*",close:"*/"}},autocomplete:q0}}}function gt(n){for(var e={},t=0;t<n.length;++t)e[n[t].toLowerCase()]=!0;return e}var bu=["domain","regexp","url","url-prefix"],ku=gt(bu),yu=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],ys=gt(yu),wu=["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"],ws=gt(wu),xu=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],Jl=gt(xu),vu=["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"],xs=gt(vu),Su=["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"],vs=gt(Su),W0=["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],Ss=gt(W0),j0=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],Cu=gt(j0),Au=["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"],Cs=gt(Au),Tu=["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"],As=gt(Tu),q0=bu.concat(yu).concat(wu).concat(xu).concat(vu).concat(Su).concat(Au).concat(Tu);var $0={documentTypes:ku,mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,fontProperties:Ss,counterDescriptors:Cu,colorKeywords:Cs,valueKeywords:As,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=jt,jt(n,e)):!1}}},Mu=ks({name:"css"});function jt(n,e){for(var t=!1,i;(i=n.next())!=null;){if(t&&i=="/"){e.tokenize=null;break}t=i=="*"}return["comment","comment"]}var Qb=ks({name:"scss",mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,colorKeywords:Cs,valueKeywords:As,fontProperties:Ss,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=jt,jt(n,e)):["operator","operator"]},":":function(n){return n.match(/^\s*\{/,!1)?[null,null]:!1},$:function(n){return n.match(/^[\w-]+/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName.special","variable"]},"#":function(n){return n.eat("{")?[null,"interpolation"]:!1}}}),ek=ks({name:"less",mediaTypes:ys,mediaFeatures:ws,mediaValueKeywords:Jl,propertyKeywords:xs,nonStandardPropertyKeywords:vs,colorKeywords:Cs,valueKeywords:As,fontProperties:Ss,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=jt,jt(n,e)):["operator","operator"]},"@":function(n){return n.eat("{")?[null,"interpolation"]:n.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)?!1:(n.eatWhile(/[\w\\\-]/),n.match(/^\s*:/,!1)?["def","variable-definition"]:["variableName","variable"])},"&":function(){return["atom","atom"]}}}),tk=ks({name:"gss",documentTypes:ku,mediaTypes:ys,mediaFeatures:ws,propertyKeywords:xs,nonStandardPropertyKeywords:vs,fontProperties:Ss,counterDescriptors:Cu,colorKeywords:Cs,valueKeywords:As,supportsAtComponent:!0,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=jt,jt(n,e)):!1}}});function Ts(n){var e=n.statementIndent,t=n.jsonld,i=n.json||t,r=n.typescript,s=n.wordCharacters||/[\w$\xa1-\uffff]/,o=function(){function d(Re){return{type:Re,style:"keyword"}}var m=d("keyword a"),C=d("keyword b"),B=d("keyword c"),N=d("keyword d"),Q=d("operator"),se={type:"atom",style:"atom"};return{if:d("if"),while:m,with:m,else:C,do:C,try:C,finally:C,return:N,break:N,continue:N,new:d("new"),delete:B,void:B,throw:B,debugger:d("debugger"),var:d("var"),const:d("var"),let:d("var"),function:d("function"),catch:d("catch"),for:d("for"),switch:d("switch"),case:d("case"),default:d("default"),in:Q,typeof:Q,instanceof:Q,true:se,false:se,null:se,undefined:se,NaN:se,Infinity:se,this:d("this"),class:d("class"),super:d("atom"),yield:B,export:d("export"),import:d("import"),extends:B,await:B}}(),l=/[+\-*&%=<>!?|~^@]/,a=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function h(d){for(var m=!1,C,B=!1;(C=d.next())!=null;){if(!m){if(C=="/"&&!B)return;C=="["?B=!0:B&&C=="]"&&(B=!1)}m=!m&&C=="\\"}}var c,f;function u(d,m,C){return c=d,f=C,m}function p(d,m){var C=d.next();if(C=='"'||C=="'")return m.tokenize=g(C),m.tokenize(d,m);if(C=="."&&d.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/))return u("number","number");if(C=="."&&d.match(".."))return u("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(C))return u(C);if(C=="="&&d.eat(">"))return u("=>","operator");if(C=="0"&&d.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/))return u("number","number");if(/\d/.test(C))return d.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/),u("number","number");if(C=="/")return d.eat("*")?(m.tokenize=x,x(d,m)):d.eat("/")?(d.skipToEnd(),u("comment","comment")):sd(d,m,1)?(h(d),d.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(d.eat("="),u("operator","operator",d.current()));if(C=="`")return m.tokenize=y,y(d,m);if(C=="#"&&d.peek()=="!")return d.skipToEnd(),u("meta","meta");if(C=="#"&&d.eatWhile(s))return u("variable","property");if(C=="<"&&d.match("!--")||C=="-"&&d.match("->")&&!/\S/.test(d.string.slice(0,d.start)))return d.skipToEnd(),u("comment","comment");if(l.test(C))return(C!=">"||!m.lexical||m.lexical.type!=">")&&(d.eat("=")?(C=="!"||C=="=")&&d.eat("="):/[<>*+\-|&?]/.test(C)&&(d.eat(C),C==">"&&d.eat(C))),C=="?"&&d.eat(".")?u("."):u("operator","operator",d.current());if(s.test(C)){d.eatWhile(s);var B=d.current();if(m.lastType!="."){if(o.propertyIsEnumerable(B)){var N=o[B];return u(N.type,N.style,B)}if(B=="async"&&d.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",B)}return u("variable","variable",B)}}function g(d){return function(m,C){var B=!1,N;if(t&&m.peek()=="@"&&m.match(a))return C.tokenize=p,u("jsonld-keyword","meta");for(;(N=m.next())!=null&&!(N==d&&!B);)B=!B&&N=="\\";return B||(C.tokenize=p),u("string","string")}}function x(d,m){for(var C=!1,B;B=d.next();){if(B=="/"&&C){m.tokenize=p;break}C=B=="*"}return u("comment","comment")}function y(d,m){for(var C=!1,B;(B=d.next())!=null;){if(!C&&(B=="`"||B=="$"&&d.eat("{"))){m.tokenize=p;break}C=!C&&B=="\\"}return u("quasi","string.special",d.current())}var v="([{}])";function M(d,m){m.fatArrowAt&&(m.fatArrowAt=null);var C=d.string.indexOf("=>",d.start);if(!(C<0)){if(r){var B=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(d.string.slice(d.start,C));B&&(C=B.index)}for(var N=0,Q=!1,se=C-1;se>=0;--se){var Re=d.string.charAt(se),qe=v.indexOf(Re);if(qe>=0&&qe<3){if(!N){++se;break}if(--N==0){Re=="("&&(Q=!0);break}}else if(qe>=3&&qe<6)++N;else if(s.test(Re))Q=!0;else if(/["'\/`]/.test(Re))for(;;--se){if(se==0)return;var _i=d.string.charAt(se-1);if(_i==Re&&d.string.charAt(se-2)!="\\"){se--;break}}else if(Q&&!N){++se;break}}Q&&!N&&(m.fatArrowAt=se)}}var O={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function R(d,m,C,B,N,Q){this.indented=d,this.column=m,this.type=C,this.prev=N,this.info=Q,B!=null&&(this.align=B)}function F(d,m){for(var C=d.localVars;C;C=C.next)if(C.name==m)return!0;for(var B=d.context;B;B=B.prev)for(var C=B.vars;C;C=C.next)if(C.name==m)return!0}function q(d,m,C,B,N){var Q=d.cc;for(w.state=d,w.stream=N,w.marked=null,w.cc=Q,w.style=m,d.lexical.hasOwnProperty("align")||(d.lexical.align=!0);;){var se=Q.length?Q.pop():i?te:ae;if(se(C,B)){for(;Q.length&&Q[Q.length-1].lex;)Q.pop()();return w.marked?w.marked:C=="variable"&&F(d,B)?"variableName.local":m}}}var w={state:null,column:null,marked:null,cc:null};function D(){for(var d=arguments.length-1;d>=0;d--)w.cc.push(arguments[d])}function b(){return D.apply(null,arguments),!0}function U(d,m){for(var C=m;C;C=C.next)if(C.name==d)return!0;return!1}function $(d){var m=w.state;if(w.marked="def",m.context){if(m.lexical.info=="var"&&m.context&&m.context.block){var C=G(d,m.context);if(C!=null){m.context=C;return}}else if(!U(d,m.localVars)){m.localVars=new T(d,m.localVars);return}}n.globalVars&&!U(d,m.globalVars)&&(m.globalVars=new T(d,m.globalVars))}function G(d,m){if(m)if(m.block){var C=G(d,m.prev);return C?C==m.prev?m:new k(C,m.vars,!0):null}else return U(d,m.vars)?m:new k(m.prev,new T(d,m.vars),!1);else return null}function K(d){return d=="public"||d=="private"||d=="protected"||d=="abstract"||d=="readonly"}function k(d,m,C){this.prev=d,this.vars=m,this.block=C}function T(d,m){this.name=d,this.next=m}var A=new T("this",new T("arguments",null));function V(){w.state.context=new k(w.state.context,w.state.localVars,!1),w.state.localVars=A}function le(){w.state.context=new k(w.state.context,w.state.localVars,!0),w.state.localVars=null}V.lex=le.lex=!0;function we(){w.state.localVars=w.state.context.vars,w.state.context=w.state.context.prev}we.lex=!0;function j(d,m){var C=function(){var B=w.state,N=B.indented;if(B.lexical.type=="stat")N=B.lexical.indented;else for(var Q=B.lexical;Q&&Q.type==")"&&Q.align;Q=Q.prev)N=Q.indented;B.lexical=new R(N,w.stream.column(),d,null,B.lexical,m)};return C.lex=!0,C}function W(){var d=w.state;d.lexical.prev&&(d.lexical.type==")"&&(d.indented=d.lexical.indented),d.lexical=d.lexical.prev)}W.lex=!0;function _(d){function m(C){return C==d?b():d==";"||C=="}"||C==")"||C=="]"?D():b(m)}return m}function ae(d,m){return d=="var"?b(j("vardef",m),Is,_(";"),W):d=="keyword a"?b(j("form"),Es,ae,W):d=="keyword b"?b(j("form"),ae,W):d=="keyword d"?w.stream.match(/^\s*$/,!1)?b():b(j("stat"),ci,_(";"),W):d=="debugger"?b(_(";")):d=="{"?b(j("}"),le,Vn,W,we):d==";"?b():d=="if"?(w.state.lexical.info=="else"&&w.state.cc[w.state.cc.length-1]==W&&w.state.cc.pop()(),b(j("form"),Es,ae,W,sa)):d=="function"?b(Tt):d=="for"?b(j("form"),le,oa,ae,we,W):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form",d=="class"?d:m),aa,W)):d=="variable"?r&&m=="declare"?(w.marked="keyword",b(ae)):r&&(m=="module"||m=="enum"||m=="type")&&w.stream.match(/^\s*\w/,!1)?(w.marked="keyword",m=="enum"?b(fa):m=="type"?b(la,_("operator"),re,_(";")):b(j("form"),Xe,_("{"),j("}"),Vn,W,W)):r&&m=="namespace"?(w.marked="keyword",b(j("form"),te,ae,W)):r&&m=="abstract"?(w.marked="keyword",b(ae)):b(j("stat"),Vu):d=="switch"?b(j("form"),Es,_("{"),j("}","switch"),le,Vn,W,W,we):d=="case"?b(te,_(":")):d=="default"?b(_(":")):d=="catch"?b(j("form"),V,Ct,ae,W,we):d=="export"?b(j("stat"),Qu,W):d=="import"?b(j("stat"),ed,W):d=="async"?b(ae):m=="@"?b(te,ae):D(j("stat"),te,_(";"),W)}function Ct(d){if(d=="(")return b(_t,_(")"))}function te(d,m){return ea(d,m,!1)}function Te(d,m){return ea(d,m,!0)}function Es(d){return d!="("?D():b(j(")"),ci,_(")"),W)}function ea(d,m,C){if(w.state.fatArrowAt==w.stream.start){var B=C?ia:ta;if(d=="(")return b(V,j(")"),Se(_t,")"),W,_("=>"),B,we);if(d=="variable")return D(V,Xe,_("=>"),B,we)}var N=C?fi:$t;return O.hasOwnProperty(d)?b(N):d=="function"?b(Tt,N):d=="class"||r&&m=="interface"?(w.marked="keyword",b(j("form"),Zu,W)):d=="keyword c"||d=="async"?b(C?Te:te):d=="("?b(j(")"),ci,_(")"),W,N):d=="operator"||d=="spread"?b(C?Te:te):d=="["?b(j("]"),id,W,N):d=="{"?$i(Hn,"}",null,N):d=="quasi"?D(Fn,N):d=="new"?b(zu(C)):b()}function ci(d){return d.match(/[;\}\)\],]/)?D():D(te)}function $t(d,m){return d==","?b(ci):fi(d,m,!1)}function fi(d,m,C){var B=C==!1?$t:fi,N=C==!1?te:Te;if(d=="=>")return b(V,C?ia:ta,we);if(d=="operator")return/\+\+|--/.test(m)||r&&m=="!"?b(B):r&&m=="<"&&w.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?b(j(">"),Se(re,">"),W,B):m=="?"?b(te,_(":"),N):b(N);if(d=="quasi")return D(Fn,B);if(d!=";"){if(d=="(")return $i(Te,")","call",B);if(d==".")return b(Wu,B);if(d=="[")return b(j("]"),ci,_("]"),W,B);if(r&&m=="as")return w.marked="keyword",b(re,B);if(d=="regexp")return w.state.lastType=w.marked="operator",w.stream.backUp(w.stream.pos-w.stream.start-1),b(N)}}function Fn(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Fn):b(ci,Nu)}function Nu(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Fn)}function ta(d){return M(w.stream,w.state),D(d=="{"?ae:te)}function ia(d){return M(w.stream,w.state),D(d=="{"?ae:Te)}function zu(d){return function(m){return m=="."?b(d?Hu:Fu):m=="variable"&&r?b(Gu,d?fi:$t):D(d?Te:te)}}function Fu(d,m){if(m=="target")return w.marked="keyword",b($t)}function Hu(d,m){if(m=="target")return w.marked="keyword",b(fi)}function Vu(d){return d==":"?b(W,ae):D($t,_(";"),W)}function Wu(d){if(d=="variable")return w.marked="property",b()}function Hn(d,m){if(d=="async")return w.marked="property",b(Hn);if(d=="variable"||w.style=="keyword"){if(w.marked="property",m=="get"||m=="set")return b(ju);var C;return r&&w.state.fatArrowAt==w.stream.start&&(C=w.stream.match(/^\s*:\s*/,!1))&&(w.state.fatArrowAt=w.stream.pos+C[0].length),b(Kt)}else{if(d=="number"||d=="string")return w.marked=t?"property":w.style+" property",b(Kt);if(d=="jsonld-keyword")return b(Kt);if(r&&K(m))return w.marked="keyword",b(Hn);if(d=="[")return b(te,ui,_("]"),Kt);if(d=="spread")return b(Te,Kt);if(m=="*")return w.marked="keyword",b(Hn);if(d==":")return D(Kt)}}function ju(d){return d!="variable"?D(Kt):(w.marked="property",b(Tt))}function Kt(d){if(d==":")return b(Te);if(d=="(")return D(Tt)}function Se(d,m,C){function B(N,Q){if(C?C.indexOf(N)>-1:N==","){var se=w.state.lexical;return se.info=="call"&&(se.pos=(se.pos||0)+1),b(function(Re,qe){return Re==m||qe==m?D():D(d)},B)}return N==m||Q==m?b():C&&C.indexOf(";")>-1?D(d):b(_(m))}return function(N,Q){return N==m||Q==m?b():D(d,B)}}function $i(d,m,C){for(var B=3;B<arguments.length;B++)w.cc.push(arguments[B]);return b(j(m,C),Se(d,m),W)}function Vn(d){return d=="}"?b():D(ae,Vn)}function ui(d,m){if(r){if(d==":")return b(re);if(m=="?")return b(ui)}}function qu(d,m){if(r&&(d==":"||m=="in"))return b(re)}function na(d){if(r&&d==":")return w.stream.match(/^\s*\w+\s+is\b/,!1)?b(te,$u,re):b(re)}function $u(d,m){if(m=="is")return w.marked="keyword",b()}function re(d,m){if(m=="keyof"||m=="typeof"||m=="infer"||m=="readonly")return w.marked="keyword",b(m=="typeof"?Te:re);if(d=="variable"||m=="void")return w.marked="type",b(bt);if(m=="|"||m=="&")return b(re);if(d=="string"||d=="number"||d=="atom")return b(bt);if(d=="[")return b(j("]"),Se(re,"]",","),W,bt);if(d=="{")return b(j("}"),Bs,W,bt);if(d=="(")return b(Se(Rs,")"),Ku,bt);if(d=="<")return b(Se(re,">"),re);if(d=="quasi")return D(Ps,bt)}function Ku(d){if(d=="=>")return b(re)}function Bs(d){return d.match(/[\}\)\]]/)?b():d==","||d==";"?b(Bs):D(Ki,Bs)}function Ki(d,m){if(d=="variable"||w.style=="keyword")return w.marked="property",b(Ki);if(m=="?"||d=="number"||d=="string")return b(Ki);if(d==":")return b(re);if(d=="[")return b(_("variable"),qu,_("]"),Ki);if(d=="(")return D(pi,Ki);if(!d.match(/[;\}\)\],]/))return b()}function Ps(d,m){return d!="quasi"?D():m.slice(m.length-2)!="${"?b(Ps):b(re,_u)}function _u(d){if(d=="}")return w.marked="string.special",w.state.tokenize=y,b(Ps)}function Rs(d,m){return d=="variable"&&w.stream.match(/^\s*[?:]/,!1)||m=="?"?b(Rs):d==":"?b(re):d=="spread"?b(Rs):D(re)}function bt(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,bt);if(m=="|"||d=="."||m=="&")return b(re);if(d=="[")return b(re,_("]"),bt);if(m=="extends"||m=="implements")return w.marked="keyword",b(re);if(m=="?")return b(re,_(":"),re)}function Gu(d,m){if(m=="<")return b(j(">"),Se(re,">"),W,bt)}function Wn(){return D(re,Uu)}function Uu(d,m){if(m=="=")return b(re)}function Is(d,m){return m=="enum"?(w.marked="keyword",b(fa)):D(Xe,ui,At,Ju)}function Xe(d,m){if(r&&K(m))return w.marked="keyword",b(Xe);if(d=="variable")return $(m),b();if(d=="spread")return b(Xe);if(d=="[")return $i(Yu,"]");if(d=="{")return $i(ra,"}")}function ra(d,m){return d=="variable"&&!w.stream.match(/^\s*:/,!1)?($(m),b(At)):(d=="variable"&&(w.marked="property"),d=="spread"?b(Xe):d=="}"?D():d=="["?b(te,_("]"),_(":"),ra):b(_(":"),Xe,At))}function Yu(){return D(Xe,At)}function At(d,m){if(m=="=")return b(Te)}function Ju(d){if(d==",")return b(Is)}function sa(d,m){if(d=="keyword b"&&m=="else")return b(j("form","else"),ae,W)}function oa(d,m){if(m=="await")return b(oa);if(d=="(")return b(j(")"),Xu,W)}function Xu(d){return d=="var"?b(Is,di):d=="variable"?b(di):D(di)}function di(d,m){return d==")"?b():d==";"?b(di):m=="in"||m=="of"?(w.marked="keyword",b(te,di)):D(te,di)}function Tt(d,m){if(m=="*")return w.marked="keyword",b(Tt);if(d=="variable")return $(m),b(Tt);if(d=="(")return b(V,j(")"),Se(_t,")"),W,na,ae,we);if(r&&m=="<")return b(j(">"),Se(Wn,">"),W,Tt)}function pi(d,m){if(m=="*")return w.marked="keyword",b(pi);if(d=="variable")return $(m),b(pi);if(d=="(")return b(V,j(")"),Se(_t,")"),W,na,we);if(r&&m=="<")return b(j(">"),Se(Wn,">"),W,pi)}function la(d,m){if(d=="keyword"||d=="variable")return w.marked="type",b(la);if(m=="<")return b(j(">"),Se(Wn,">"),W)}function _t(d,m){return m=="@"&&b(te,_t),d=="spread"?b(_t):r&&K(m)?(w.marked="keyword",b(_t)):r&&d=="this"?b(ui,At):D(Xe,ui,At)}function Zu(d,m){return d=="variable"?aa(d,m):jn(d,m)}function aa(d,m){if(d=="variable")return $(m),b(jn)}function jn(d,m){if(m=="<")return b(j(">"),Se(Wn,">"),W,jn);if(m=="extends"||m=="implements"||r&&d==",")return m=="implements"&&(w.marked="keyword"),b(r?re:te,jn);if(d=="{")return b(j("}"),kt,W)}function kt(d,m){if(d=="async"||d=="variable"&&(m=="static"||m=="get"||m=="set"||r&&K(m))&&w.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1))return w.marked="keyword",b(kt);if(d=="variable"||w.style=="keyword")return w.marked="property",b(qn,kt);if(d=="number"||d=="string")return b(qn,kt);if(d=="[")return b(te,ui,_("]"),qn,kt);if(m=="*")return w.marked="keyword",b(kt);if(r&&d=="(")return D(pi,kt);if(d==";"||d==",")return b(kt);if(d=="}")return b();if(m=="@")return b(te,kt)}function qn(d,m){if(m=="!"||m=="?")return b(qn);if(d==":")return b(re,At);if(m=="=")return b(Te);var C=w.state.lexical.prev,B=C&&C.info=="interface";return D(B?pi:Tt)}function Qu(d,m){return m=="*"?(w.marked="keyword",b(Ns,_(";"))):m=="default"?(w.marked="keyword",b(te,_(";"))):d=="{"?b(Se(ha,"}"),Ns,_(";")):D(ae)}function ha(d,m){if(m=="as")return w.marked="keyword",b(_("variable"));if(d=="variable")return D(Te,ha)}function ed(d){return d=="string"?b():d=="("?D(te):d=="."?D($t):D($n,ca,Ns)}function $n(d,m){return d=="{"?$i($n,"}"):(d=="variable"&&$(m),m=="*"&&(w.marked="keyword"),b(td))}function ca(d){if(d==",")return b($n,ca)}function td(d,m){if(m=="as")return w.marked="keyword",b($n)}function Ns(d,m){if(m=="from")return w.marked="keyword",b(te)}function id(d){return d=="]"?b():D(Se(Te,"]"))}function fa(){return D(j("form"),Xe,_("{"),j("}"),Se(nd,"}"),W,W)}function nd(){return D(Xe,At)}function rd(d,m){return d.lastType=="operator"||d.lastType==","||l.test(m.charAt(0))||/[,.]/.test(m.charAt(0))}function sd(d,m,C){return m.tokenize==p&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(m.lastType)||m.lastType=="quasi"&&/\{\s*$/.test(d.string.slice(0,d.pos-(C||0)))}return{name:n.name,startState:function(d){var m={tokenize:p,lastType:"sof",cc:[],lexical:new R(-d,0,"block",!1),localVars:n.localVars,context:n.localVars&&new k(null,null,!1),indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(m.globalVars=n.globalVars),m},token:function(d,m){if(d.sol()&&(m.lexical.hasOwnProperty("align")||(m.lexical.align=!1),m.indented=d.indentation(),M(d,m)),m.tokenize!=x&&d.eatSpace())return null;var C=m.tokenize(d,m);return c=="comment"?C:(m.lastType=c=="operator"&&(f=="++"||f=="--")?"incdec":c,q(m,C,c,f,d))},indent:function(d,m,C){if(d.tokenize==x||d.tokenize==y)return null;if(d.tokenize!=p)return 0;var B=m&&m.charAt(0),N=d.lexical,Q;if(!/^\s*else\b/.test(m))for(var se=d.cc.length-1;se>=0;--se){var Re=d.cc[se];if(Re==W)N=N.prev;else if(Re!=sa&&Re!=we)break}for(;(N.type=="stat"||N.type=="form")&&(B=="}"||(Q=d.cc[d.cc.length-1])&&(Q==$t||Q==fi)&&!/^[,\.=+\-*:?[\(]/.test(m));)N=N.prev;e&&N.type==")"&&N.prev.type=="stat"&&(N=N.prev);var qe=N.type,_i=B==qe;return qe=="vardef"?N.indented+(d.lastType=="operator"||d.lastType==","?N.info.length+1:0):qe=="form"&&B=="{"?N.indented:qe=="form"?N.indented+C.unit:qe=="stat"?N.indented+(rd(d,m)?e||C.unit:0):N.info=="switch"&&!_i&&n.doubleIndentSwitch!=!1?N.indented+(/^(?:case|default)\b/.test(m)?C.unit:2*C.unit):N.align?N.column+(_i?0:1):N.indented+(_i?0:C.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:i?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}var Lu=Ts({name:"javascript"}),nk=Ts({name:"json",json:!0}),rk=Ts({name:"json",jsonld:!0}),sk=Ts({name:"typescript",typescript:!0});function K0(n){return new RegExp("^(?:"+n.join("|")+")","i")}function Ms(n){return new RegExp("^(?:"+n.join("|")+")$","i")}var _0=Ms(["_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall","coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield","debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable","debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable","debug.setupvalue","debug.traceback","close","flush","lines","read","seek","setvbuf","write","io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin","io.stdout","io.tmpfile","io.type","io.write","math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg","math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max","math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh","math.sqrt","math.tan","math.tanh","os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale","os.time","os.tmpname","package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload","package.seeall","string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub","string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper","table.concat","table.insert","table.maxn","table.remove","table.sort"]),G0=Ms(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),U0=Ms(["function","if","repeat","do","\\(","{"]),Y0=Ms(["end","until","\\)","}"]),J0=K0(["end","until","\\)","}","else","elseif"]);function Du(n){for(var e=0;n.eat("=");)++e;return n.eat("["),e}function Xl(n,e){var t=n.next();return t=="-"&&n.eat("-")?n.eat("[")&&n.eat("[")?(e.cur=Ou(Du(n),"comment"))(n,e):(n.skipToEnd(),"comment"):t=='"'||t=="'"?(e.cur=X0(t))(n,e):t=="["&&/[\[=]/.test(n.peek())?(e.cur=Ou(Du(n),"string"))(n,e):/\d/.test(t)?(n.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(t)?(n.eatWhile(/[\w\\\-_.]/),"variable"):null}function Ou(n,e){return function(t,i){for(var r=null,s;(s=t.next())!=null;)if(r==null)s=="]"&&(r=0);else if(s=="=")++r;else if(s=="]"&&r==n){i.cur=Xl;break}else r=null;return e}}function X0(n){return function(e,t){for(var i=!1,r;(r=e.next())!=null&&!(r==n&&!i);)i=!i&&r=="\\";return i||(t.cur=Xl),"string"}}var Eu={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:Xl}},token:function(n,e){if(n.eatSpace())return null;var t=e.cur(n,e),i=n.current();return t=="variable"&&(G0.test(i)?t="keyword":_0.test(i)&&(t="builtin")),t!="comment"&&t!="string"&&(U0.test(i)?++e.indentDepth:Y0.test(i)&&--e.indentDepth),t},indent:function(n,e,t){var i=J0.test(e);return n.basecol+t.unit*(n.indentDepth-(i?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}};var Bu=n=>{let e={};for(let[t,i]of Object.entries(n))Object.assign(e,{[t]:Array.isArray(i)?[...i]:i});return e},Pu=document.createElement("span"),Z0=n=>(Pu.innerHTML=n,[...Pu.textContent].length===1),Ls=class{constructor(e){this.config=e,this.urlProtocols=new RegExp(`^(?:${e.urlProtocols})`,"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.tokens=[],this.oldTokens=[],this.tokenTable={...S.tokenTable};for(let t of Object.keys(e.tags))this.addTag(t)}get fileRegex(){let e=Object.entries(this.config.nsid).filter(([,t])=>t===6).map(([t])=>t).join("|");return new RegExp(`^\\s*(?:${e})\\s*:\\s*`,"iu")}addTag(e,t){var i,r;(i=this.tokenTable)[r=`mw-tag-${e}`]||(i[r]=Pe.define(t))}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}${e==="templateName"?" cm-mw-pagename":""}`}))}eatHtmlEntity(e,t){let i=e.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&Z0(`&${i[0]}`)?S.tags.htmlEntity:t}makeStyle(e,t,i){return this.makeLocalStyle(`${e} ${this.isBold?S.tags.strong:""} ${this.isItalic?S.tags.em:""}`,t,i)}makeLocalStyle(e,t,i){let r="";switch(t.nTemplate){case 0:break;case 1:r+="-template";break;case 2:r+="-template2";break;default:r+="-template3";break}switch(t.nExt){case 0:break;case 1:r+="-ext";break;case 2:r+="-ext2";break;default:r+="-ext3";break}return t.nLink>0&&(r+="-link"),i&&t[i]--,(r&&`mw${r}-ground `)+e}inBlock(e,t,i=!0){return(r,s)=>(r.skipTo(t)?(i&&r.match(t),s.tokenize=s.stack.pop()):r.skipToEnd(),this.makeLocalStyle(e,s))}eatEnd(e){return(t,i)=>(t.skipToEnd(),i.tokenize=i.stack.pop(),this.makeLocalStyle(e,i))}inChar(e,t){return(i,r)=>i.eat(e)?(r.tokenize=r.stack.pop(),this.makeLocalStyle(t,r)):(i.skipTo(e)||i.skipToEnd(),this.makeLocalStyle(S.tags.error,r))}inSectionHeader(e){return(t,i)=>t.match(/^[^&<[{~']+/u)?(t.eol()?(t.backUp(e),i.tokenize=this.eatEnd(S.tags.sectionHeader)):t.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(t.backUp(e),i.tokenize=this.inBlock(S.tags.sectionHeader,"<!--",!1)),this.makeLocalStyle(S.tags.section,i)):this.eatWikiText(S.tags.section)(t,i)}inVariable(e,t){return e.match(/^[^{}|]+/u)?this.makeLocalStyle(S.tags.templateVariableName,t):e.eat("|")?(t.tokenize=this.inVariableDefault(!0),this.makeLocalStyle(S.tags.templateVariableDelimiter,t)):e.match("}}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,t)):e.match("{{{")?(t.stack.push(t.tokenize),this.makeLocalStyle(S.tags.templateVariableBracket,t)):(e.next(),this.makeLocalStyle(S.tags.templateVariableName,t))}inVariableDefault(e){let t=S.tags[e?"templateVariable":"comment"];return(i,r)=>i.match(/^[^{}[<&~|]+/u)?this.makeStyle(t,r):i.match("}}}")?(r.tokenize=r.stack.pop(),this.makeLocalStyle(S.tags.templateVariableBracket,r)):i.eat("|")?(r.tokenize=this.inVariableDefault(!1),this.makeLocalStyle(S.tags.templateVariableDelimiter,r)):this.eatWikiText(t)(i,r)}inParserFunctionName(e,t){return e.match(/^[^:}{~|<>[\]]+/u)?this.makeLocalStyle(S.tags.parserFunctionName,t):e.eat(":")?(t.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(S.tags.parserFunctionDelimiter,t)):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.error)(e,t)}inParserFunctionArguments(e,t){return e.match(/^[^|}{[<&~]+/u)?this.makeLocalStyle(S.tags.parserFunction,t):e.eat("|")?this.makeLocalStyle(S.tags.parserFunctionDelimiter,t):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.parserFunctionBracket,t,"nExt")):this.eatWikiText(S.tags.parserFunction)(e,t)}inTemplatePageName(e){return(t,i)=>t.match(/^\s*\|\s*/u)?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match(/^\s*\}\}/u)?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):t.match(/^\s*<!--.*?-->/u)?this.makeLocalStyle(S.tags.comment,i):e&&t.sol()?(i.nTemplate--,i.tokenize=i.stack.pop(),""):t.match(/^\s*[^\s|&~{}<>[\]]+/u)?(i.tokenize=this.inTemplatePageName(!0),this.makeLocalStyle(S.tags.templateName,i)):t.match(/^(?:[<>[\]}]|\{(?!\{))/u)?this.makeLocalStyle(S.tags.error,i):t.eatSpace()?this.makeLocalStyle(S.tags.templateName,i):this.eatWikiText(S.tags.templateName)(t,i)}inTemplateArgument(e){return(t,i)=>e&&t.eatWhile(/[^=|}{[<&~]/u)?t.eat("=")?(i.tokenize=this.inTemplateArgument(!1),this.makeLocalStyle(S.tags.templateArgumentName,i)):this.makeLocalStyle(S.tags.template,i):t.eatWhile(/[^|}{[<&~]/u)?this.makeLocalStyle(S.tags.template,i):t.eat("|")?(i.tokenize=this.inTemplateArgument(!0),this.makeLocalStyle(S.tags.templateDelimiter,i)):t.match("}}")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.templateBracket,i,"nTemplate")):this.eatWikiText(S.tags.template)(t,i)}eatExternalLinkProtocol(e){return(t,i)=>{for(let r=0;r<e;r++)t.next();return t.eol()?(i.nLink--,i.tokenize=i.stack.pop()):i.tokenize=this.inExternalLink.bind(this),this.makeLocalStyle(S.tags.extLinkProtocol,i)}}inExternalLink(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.match(/^\s*\]/u)?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.eatSpace()?(t.tokenize=this.inExternalLinkText.bind(this),this.makeLocalStyle("",t)):e.match(/^[^\s\]{&~']+/u)?(e.peek()==="'"&&(e.match("''",!1)?t.tokenize=this.inExternalLinkText.bind(this):e.next()),this.makeLocalStyle(S.tags.extLink,t)):this.eatWikiText(S.tags.extLink)(e,t)}inExternalLinkText(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.eat("]")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.extLinkBracket,t,"nLink")):e.match(/^[^'\]{&~<]+/u)?this.makeStyle(S.tags.extLinkText,t):this.eatWikiText(S.tags.extLinkText)(e,t)}inLink(e){return(t,i)=>{if(t.sol())return i.nLink--,i.tokenize=i.stack.pop(),"";if(t.match(/^\s*#\s*/u))return i.tokenize=this.inLinkToSection(e),this.makeStyle(S.tags.link,i);if(t.match(/^\s*\|\s*/u))return i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i);if(t.match(/^\s*\]\]/u))return i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink");if(t.match(/^(?:[<>[\]}]|\{(?!\{))/u))return this.makeStyle(S.tags.error,i);let r=`${S.tags.linkPageName} ${S.tags.pageName}`;return t.match(/^[^#|[\]&~{}<>]+/u)?this.makeStyle(r,i):this.eatWikiText(r)(t,i)}}inLinkToSection(e){return(t,i)=>t.sol()?(i.nLink--,i.tokenize=i.stack.pop(),""):t.match(/^[^|\]&~{}]+/u)?this.makeStyle(S.tags.linkToSection,i):t.eat("|")?(i.tokenize=this.inLinkText(e),this.makeLocalStyle(S.tags.linkDelimiter,i)):t.match("]]")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,i,"nLink")):this.eatWikiText(S.tags.linkToSection)(t,i)}inLinkText(e){let t,i;return(r,s)=>{let o=`${S.tags.linkText} ${t?S.tags.strong:""} ${i?S.tags.em:""}`;if(r.match("]]"))return s.lbrack&&r.peek()==="]"?(r.backUp(1),s.lbrack=!1,this.makeStyle(o,s)):(s.tokenize=s.stack.pop(),this.makeLocalStyle(S.tags.linkBracket,s,"nLink"));if(e&&r.eat("|"))return this.makeLocalStyle(S.tags.linkDelimiter,s);if(r.match("'''"))return t=!t,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);if(r.match("''"))return i=!i,this.makeLocalStyle(`${S.tags.linkText} ${S.tags.apostrophes}`,s);let l=r.match(e?/^(?:[^'\]{&~<|[]|\[(?!\[))+/u:/^[^'\]{&~<]+/u);return l&&l[0].includes("[")&&(s.lbrack=!0),l?this.makeStyle(o,s):this.eatWikiText(o)(r,s)}}eatTagName(e,t,i){return(r,s)=>{let o="";for(let l=0;l<e;l++)o+=r.next();return r.eatSpace(),o=o.toLowerCase(),i?(s.tokenize=t?this.inChar(">",S.tags.htmlTagBracket):this.inHtmlTagAttribute(o),this.makeLocalStyle(S.tags.htmlTagName,s)):(s.tokenize=t?this.inChar(">",S.tags.extTagBracket):this.inExtTagAttribute(o),this.makeLocalStyle(S.tags.extTagName,s))}}inHtmlTagAttribute(e){return(t,i)=>t.match(/^[^>/<{]+/u)?this.makeLocalStyle(S.tags.htmlTagAttribute,i):t.match(/^\/?>/u)?(S.implicitlyClosedHtmlTags.has(e)||i.inHtmlTag.push(e),i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.htmlTagBracket,i)):this.eatWikiText(S.tags.htmlTagAttribute)(t,i)}eatNowiki(){return e=>e.match(/^[^&]+/u)?"":(e.next(),this.eatHtmlEntity(e,""))}inExtTagAttribute(e){return(t,i)=>t.match(/^[^>/]+/u)?this.makeLocalStyle(S.tags.extTagAttribute,i):t.eat(">")?(i.extName=e,e==="nowiki"||e==="pre"?(i.extMode={startState:()=>({}),token:this.eatNowiki()},i.extState={}):e in this.config.tagModes&&(i.extMode=this[this.config.tagModes[e]],i.extState=i.extMode.startState(0)),i.tokenize=this.eatExtTagArea(e),this.makeLocalStyle(S.tags.extTagBracket,i)):t.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalStyle(S.tags.extTagBracket,i)):this.eatWikiText(S.tags.extTagAttribute)(t,i)}eatExtTagArea(e){return(t,i)=>{let r=t.pos,s=new RegExp(`</${e}\\s*(?:>|$)`,"iu"),o=s.exec(r?t.string.slice(r):t.string),l=!1;if(o){if(o.index===0)return i.tokenize=this.eatExtCloseTag(e),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(t,i);let a=o.index+r;l=t.string,t.string=l.slice(0,a)}return i.stack.push(i.tokenize),i.tokenize=this.inExtTokens(l),i.tokenize(t,i)}}eatExtCloseTag(e){return(t,i)=>(t.next(),t.next(),i.tokenize=this.eatTagName(e.length,!0,!1),this.makeLocalStyle(S.tags.extTagBracket,i))}inExtTokens(e){return(t,i)=>{let r;return i.extMode===!1?(r=S.tags.extTag,t.skipToEnd()):r=`mw-tag-${i.extName} ${i.extMode.token(t,i.extState)}`,t.eol()&&(e!==!1&&(t.string=e),i.tokenize=i.stack.pop()),r}}eatStartTable(e,t){return e.match(/^(?:\{\||\{{3}\s*!\s*\}\})\s*/u),t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,t)}inTableDefinition(e,t){return e.sol()?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):this.eatWikiText(S.tags.tableDefinition)(e,t)}inTableCaption(e,t){return e.sol()&&e.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1)?(t.tokenize=this.inTable.bind(this),this.inTable(e,t)):e.match(/^\s*(?:\||\{\{\s*!\s*\}\}){2}/u,!1)?(t.tokenize=this.inTableRow(!1,!1),""):this.eatWikiText(S.tags.tableCaption)(e,t)}inTable(e,t){if(e.sol()){if(e.eatSpace(),e.match(/^(?:\||\{\{\s*!\s*\}\})/u))return e.match(/^-+\s*/u)?(t.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("+")?(e.eatSpace(),t.tokenize=this.inTableCaption.bind(this),this.makeLocalStyle(S.tags.tableDelimiter,t)):e.eat("}")?(t.tokenize=t.stack.pop(),this.makeLocalStyle(S.tags.tableBracket,t)):(e.eatSpace(),t.tokenize=this.inTableRow(!0,!1),this.makeLocalStyle(S.tags.tableDelimiter,t));if(e.eat("!"))return e.eatSpace(),t.tokenize=this.inTableRow(!0,!0),this.makeLocalStyle(S.tags.tableDelimiter,t)}return this.eatWikiText("")(e,t)}inTableRow(e,t){return(i,r)=>{if(i.sol()){if(i.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1))return r.tokenize=this.inTable.bind(this),this.inTable(i,r)}else{if(i.match(/^[^'|{[<&~!]+/u))return this.makeStyle(t?S.tags.strong:"",r);if(i.match(/^(?:\||\{\{\s*!\s*\}\}){2}/u)||t&&i.match("!!")||e&&i.match(/^(?:\||\{\{\s*!\s*\}\})/u))return this.isBold=!1,this.isItalic=!1,e&&(r.tokenize=this.inTableRow(!1,t)),this.makeLocalStyle(S.tags.tableDelimiter,r)}return this.eatWikiText(t?S.tags.strong:"")(i,r)}}eatFreeExternalLinkProtocol(e,t){return e.match(this.urlProtocols),t.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,t)}inFreeExternalLink(e,t){if(!e.eol()){let i=e.match(/^[^\s{[\]<>~).,;:!?'"]*/u);if(t.lpar||(t.lpar=i[0].includes("(")),e.peek()==="~"){if(e.match(/^~{1,2}(?!~)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="{"){if(e.match(/^\{(?!\{)/u))return this.makeStyle(S.tags.freeExtLink,t)}else if(e.peek()==="'"){if(e.match(/^'(?!')/u))return this.makeStyle(S.tags.freeExtLink,t)}else{if(t.lpar&&e.peek()===")")return e.next(),this.makeStyle(S.tags.freeExtLink,t);if(e.match(/^[).,;:!?]+(?=[^\s{[\]<>~).,;:!?'"]|~~?(?!~)|\{(?!\{)|'(?!'))/u))return this.makeStyle(S.tags.freeExtLink,t)}}return t.lpar=!1,t.tokenize=t.stack.pop(),this.makeStyle(S.tags.freeExtLink,t)}eatWikiText(e){return(t,i)=>{let r;if(t.sol()){if(t.match("//"))return this.makeStyle(e,i);if(t.match(this.urlProtocols))return i.stack.push(i.tokenize),i.tokenize=this.inFreeExternalLink.bind(this),this.makeStyle(S.tags.freeExtLinkProtocol,i);switch(r=t.next(),r){case"-":if(t.match(/^-{3,}/u))return S.tags.hr;break;case"=":{let o=t.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->.*\S).*)?)$/u);if(o)return t.backUp(o[2].length),i.stack.push(i.tokenize),i.tokenize=this.inSectionHeader(o[3].length),this.makeLocalStyle(`${S.tags.sectionHeader} ${S.tags[`sectionHeader${o[1].length+1}`]}`,i);break}case"*":case"#":case";":return t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case":":return t.match(/^:*(?:\{\||\{{3}\s*!\s*\}\})/u,!1)&&(i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this)),t.match(/^[*#;:]*/u),this.makeLocalStyle(S.tags.list,i);case" ":{let o=t.match(/^\s*(:+\s*)?(?=\{\||\{{3}\s*!\s*\}\})/u);if(o){if(o[1])return i.stack.push(i.tokenize),i.tokenize=this.eatStartTable.bind(this),this.makeLocalStyle(S.tags.list,i);t.eat("{")}else return S.tags.skipFormatting}case"{":if(t.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return i.stack.push(i.tokenize),i.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(S.tags.tableBracket,i);break;default:}}else r=t.next();switch(r){case"&":return this.makeStyle(this.eatHtmlEntity(t,e),i);case"'":if(t.match(/^'*(?='{5})/u)||t.match(/^'''(?!')/u,!1))break;if(t.match("''"))return this.firstSingleLetterWord||t.match("''",!1)||this.prepareItalicForCorrection(t),this.isBold=!this.isBold,this.makeLocalStyle(S.tags.apostrophesBold,i);if(t.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(S.tags.apostrophesItalic,i);break;case"[":if(t.eat("[")){if(t.eatSpace(),/[^\]|[]/u.test(t.peek()||""))return i.nLink++,i.stack.push(i.tokenize),i.lbrack=!1,i.tokenize=this.inLink(!!t.match(this.fileRegex,!1)),this.makeLocalStyle(S.tags.linkBracket,i)}else{let o=t.match(this.urlProtocols,!1);if(o)return i.nLink++,i.stack.push(i.tokenize),i.tokenize=this.eatExternalLinkProtocol(o[0].length),this.makeLocalStyle(S.tags.extLinkBracket,i)}break;case"{":if(t.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))/u))return t.eatSpace(),i.stack.push(i.tokenize),i.tokenize=this.inVariable.bind(this),this.makeLocalStyle(S.tags.templateVariableBracket,i);if(t.match(/^\{(?!\{(?!\{))\s*/u)){if(t.peek()==="#")return i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i);let o=t.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/u,!1);return o&&(o[2]===":"||o[4]===void 0||o[3]==="}}")&&(o[1].toLowerCase()in this.config.functionSynonyms[0]||o[1]in this.config.functionSynonyms[1])?(i.nExt++,i.stack.push(i.tokenize),i.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(S.tags.parserFunctionBracket,i)):(i.nTemplate++,i.stack.push(i.tokenize),i.tokenize=this.inTemplatePageName(!1),this.makeLocalStyle(S.tags.templateBracket,i))}break;case"<":{if(t.match("!--"))return i.stack.push(i.tokenize),i.tokenize=this.inBlock(S.tags.comment,"-->"),this.makeLocalStyle(S.tags.comment,i);let o=!!t.eat("/"),l=t.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+/u);if(l){let a=l[0].toLowerCase();if(a in this.config.tags)return o?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!1),this.makeLocalStyle(S.tags.extTagBracket,i));if(S.permittedHtmlTags.has(a))return o&&a!==i.inHtmlTag.pop()?(i.tokenize=this.inChar(">",S.tags.error),this.makeLocalStyle(S.tags.error,i)):o&&S.implicitlyClosedHtmlTags.has(a)?this.makeLocalStyle(S.tags.error,i):(t.backUp(a.length),i.stack.push(i.tokenize),i.tokenize=this.eatTagName(a.length,o,!0),this.makeLocalStyle(S.tags.htmlTagBracket,i));t.backUp(a.length)}break}case"~":if(t.match(/^~{2,4}/u))return S.tags.signature;break;case"_":{let o=1;for(;t.eat("_");)o++;if(o>2)return t.eol()||t.backUp(2),this.makeStyle(e,i);if(o===2){let l=t.match(/^\w+?__/u);if(l)return`__${l[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${l[0]}`in this.config.doubleUnderscore[1]?S.tags.doubleUnderscore:(t.eol()||t.backUp(2),this.makeStyle(e,i))}break}default:if(/\s/u.test(r||"")&&(t.eatSpace(),t.match(this.urlProtocols,!1)&&!t.match("//")))return i.stack.push(i.tokenize),i.tokenize=this.eatFreeExternalLinkProtocol.bind(this),this.makeStyle(e,i);break}return t.match(/^[^\s_>}[\]<{'|&:~=]+/u),this.makeStyle(e,i)}}prepareItalicForCorrection(e){let t=e.pos,i=e.string.slice(0,t-3),r=i.slice(-1),s=i.slice(-2,-1);if(r===" "){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=t}else if(s===" ")this.firstSingleLetterWord=t;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=t}this.wasBold=this.isBold,this.wasItalic=this.isItalic}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0,lpar:!1,lbrack:!1}),copyState:e=>{let t=Bu(e);return e.extMode&&e.extMode.copyState&&(t.extState=e.extMode.copyState(e.extState)),t},token:(e,t)=>{let i,r=null,s,o,l=[],a=[];if(this.oldTokens.length>0)return s=this.oldTokens.shift(),e.pos=s.pos,s.style;e.sol()&&(this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);do if(i=t.tokenize(e,t),o=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,o)o!==r&&(r=o,l.length>0&&(a.push(...l),l=[])),l.push({pos:e.pos,style:i,state:(t.extMode&&t.extMode.copyState||Bu)(t)});else return this.oldStyle=i,i;while(!e.eol());if(this.isBold&&this.isItalic)if(this.isItalic=this.wasItalic,this.isBold=this.wasBold,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,a.length>0)a[a.length-1].pos++,this.oldTokens=a;else return e.pos=l[0].pos-2,this.oldStyle||"";else this.oldTokens=[...a,...l];return s=this.oldTokens.shift(),e.pos=s.pos,s.style},blankLine:e=>{e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},tokenTable:this.tokenTable,languageData:{closeBrackets:{brackets:["(","[","{",'"']}}}}get"text/mediawiki"(){return this.mediawiki}};for(let[n,e]of Object.entries(Nn))Object.defineProperty(Ls.prototype,n,{get(){return e}});var Zl=n=>{let e=new Ls(n),t=e.mediawiki,i=Ri.define(t),r=Kr(Pi.define(e.getTagStyles()));return new Bi(i,r)},Ru=n=>Zl({...n,tags:{...n.tags,script:!0,style:!0},tagModes:{...n.tagModes,script:"javascript",style:"css"}});var Ql={plain:()=>[],mediawiki:Zl,html:Ru};for(let[n,e]of Object.entries(Nn))Ql[n]=()=>new Bi(Ri.define(e));var Ds={},Q0={highlightSpecialChars:[bc,{}],highlightActiveLine:[kc,{}],highlightWhitespace:[Ac,{}],highlightTrailingWhitespace:[Tc,{}],bracketMatching:[Zc,{mediawiki:{brackets:"[]{}"}}],closeBrackets:[mu,{}]},Os=(n,e)=>new Promise(t=>{if(e in window){t();return}let i=document.createElement("script");i.src=`https://testingcf.jsdelivr.net/${n}`,i.onload=()=>{t()},document.head.append(i)}),zn,Wi,qt,ji,qi,me,Iu=class{constructor(e,t="plain",i){Gt(this,zn,void 0);Gt(this,Wi,void 0);Gt(this,qt,void 0);Gt(this,ji,void 0);Gt(this,qi,void 0);Gt(this,me,void 0);Ut(this,zn,e),this.lang=t,Ut(this,Wi,new xt),Ut(this,qt,new xt),Ut(this,ji,new xt),Ut(this,qi,new xt);let r,s=[ee(this,Wi).of(Ql[t](i)),ee(this,qt).of([]),ee(this,ji).of([]),ee(this,qi).of(Ht.of(" ")),Kr(Uc),z.contentAttributes.of({accesskey:e.accessKey,dir:e.dir,lang:e.lang}),Sc(),z.lineWrapping,pf(),_c(),Pr.of([...qf,...kf,...Qf]),z.updateListener.of(({state:{doc:p},docChanged:g})=>{g&&(clearTimeout(r),r=window.setTimeout(()=>{e.value=p.toString()},400))})];Ut(this,me,new z({extensions:s,doc:e.value}));let{offsetHeight:o,selectionStart:l,selectionEnd:a,scrollTop:h}=e,{fontSize:c,lineHeight:f}=getComputedStyle(e),u=document.activeElement===e;e.parentNode.insertBefore(ee(this,me).dom,e),ee(this,me).dom.style.minHeight="2em",ee(this,me).dom.style.height=`${o}px`,ee(this,me).dom.style.fontSize=c,ee(this,me).scrollDOM.style.lineHeight=f,ee(this,me).requestMeasure(),ee(this,me).dispatch({selection:{anchor:l,head:a}}),e.style.display="none",u&&ee(this,me).focus(),window.requestAnimationFrame(()=>{ee(this,me).scrollDOM.scrollTop=h})}get textarea(){return ee(this,zn)}get view(){return ee(this,me)}setLanguage(e="plain",t){var i;ee(this,me).dispatch({effects:[ee(this,Wi).reconfigure(Ql[e](t)),ee(this,qt).reconfigure((i=Ds[e])!=null?i:[])]}),this.lang=e,(Ds[e]?Kl:In)(ee(this,me))}lint(e){let{lang:t}=this,i=e?[su(r=>e(r.state.doc)),fu()]:[];e?Ds[t]=i:delete Ds[t],ee(this,me).dispatch({effects:[ee(this,qt).reconfigure(i)]}),(e?Kl:In)(ee(this,me))}update(){let e=ee(this,qt).get(ee(this,me).state);if(e.length>0){let t=ee(this,me).plugin(e[0][1]);t.set=!0,t.force()}}prefer(e){let{lang:t}=this;ee(this,me).dispatch({effects:[ee(this,ji).reconfigure(e.map(i=>{let[r,s]=Q0[i];return r(s[t])}))]})}setIndent(e){ee(this,me).dispatch({effects:[ee(this,qi).reconfigure(Ht.of(e))]})}async getLinter(){switch(this.lang){case"mediawiki":{await Os("combine/npm/wikiparser-node@1.3.0-b/extensions/dist/base.min.js,npm/wikiparser-node@1.3.0-b/extensions/dist/lint.min.js","wikiparse");let t=new wikiparse.Linter;return i=>t.codemirror(i.toString())}case"javascript":{await Os("npm/eslint-linter-browserify","eslint");let e=new eslint.Linter,t={env:{browser:!0,es2018:!0},parserOptions:{ecmaVersion:9,sourceType:"module"},rules:{}};for(let[i,{meta:r}]of e.getRules())r!=null&&r.docs.recommended&&(t.rules[i]=2);return i=>e.verify(i.toString(),t).map(({message:r,severity:s,line:o,column:l,endLine:a,endColumn:h})=>{let c=i.line(o).from+l-1;return{message:r,severity:s===1?"warning":"error",from:c,to:a===void 0?c+1:i.line(a).from+h-1}})}case"css":{await Os("gh/openstyles/stylelint-bundle/dist/stylelint-bundle.min.js","stylelint");let e={rules:{"annotation-no-unknown":!0,"at-rule-no-unknown":!0,"block-no-empty":!0,"color-no-invalid-hex":!0,"comment-no-empty":!0,"custom-property-no-missing-var-function":!0,"declaration-block-no-duplicate-custom-properties":!0,"declaration-block-no-duplicate-properties":[!0,{ignore:["consecutive-duplicates-with-different-syntaxes"]}],"declaration-block-no-shorthand-property-overrides":!0,"font-family-no-duplicate-names":!0,"font-family-no-missing-generic-family-keyword":!0,"function-calc-no-unspaced-operator":!0,"function-linear-gradient-no-nonstandard-direction":!0,"function-no-unknown":!0,"keyframe-block-no-duplicate-selectors":!0,"keyframe-declaration-no-important":!0,"media-feature-name-no-unknown":!0,"media-query-no-invalid":!0,"named-grid-areas-no-invalid":!0,"no-descending-specificity":!0,"no-duplicate-at-import-rules":!0,"no-duplicate-selectors":!0,"no-empty-source":!0,"no-invalid-double-slash-comments":!0,"no-invalid-position-at-import-rule":!0,"no-irregular-whitespace":!0,"property-no-unknown":!0,"selector-anb-no-unmatchable":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":[!0,{ignore:["custom-elements"]}],"string-no-newline":!0,"unit-no-unknown":!0}};return async t=>{let{results:i}=await stylelint.lint({code:t.toString(),config:e});return i.flatMap(({warnings:r})=>r).map(({text:r,severity:s,line:o,column:l,endLine:a,endColumn:h})=>({message:r,severity:s,from:t.line(o).from+l-1,to:a===void 0?t.line(o).to:t.line(a).from+h-1}))}}case"lua":return await Os("npm/luaparse","luaparse"),e=>{try{luaparse.parse(e.toString())}catch(t){if(t instanceof luaparse.SyntaxError)return[{message:t.message,severity:"error",from:t.index,to:t.index}]}return[]};default:return()=>[]}}};zn=new WeakMap,Wi=new WeakMap,qt=new WeakMap,ji=new WeakMap,qi=new WeakMap,me=new WeakMap;export{Iu as CodeMirror6};
14
+ /**
15
+ * @author MusikAnimal and others
16
+ * @license GPL-2.0-or-later
17
+ * @link https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
18
+ */
19
+ /**
20
+ * @author pastakhov, MusikAnimal and others
21
+ * @license GPL-2.0-or-later
22
+ * @link https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror
23
+ */