@bhsd/codemirror-mediawiki 2.9.4 → 2.9.5
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/codemirror.d.ts +2 -1
- package/dist/config.d.ts +89 -0
- package/dist/escape.d.ts +2 -0
- package/dist/fold.d.ts +12 -0
- package/dist/linter.d.ts +33 -0
- package/dist/main.min.js +11 -11
- package/dist/matchTag.d.ts +3 -0
- package/dist/mw.min.js +4 -4
- package/dist/mw.min.js.map +4 -4
- package/dist/plugins.d.ts +3 -0
- package/dist/util.d.ts +7 -0
- package/i18n/en.json +1 -1
- package/i18n/zh-hans.json +1 -1
- package/i18n/zh-hant.json +1 -1
- package/mediawiki.css +8 -8
- package/package.json +9 -9
package/dist/main.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
1
|
+
var um=Object.defineProperty;var dm=(n,e)=>{for(var t in e)um(n,t,{get:e[t],enumerable:!0})};var So=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var V=(n,e,t)=>(So(n,e,"read from private field"),t?t.call(n):e.get(n)),Me=(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)},li=(n,e,t,i)=>(So(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);var _e=(n,e,t)=>(So(n,e,"access private method"),t);var Q=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]=Ii(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),Bi.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]=Ii(this,e,t);let i=[];return this.decompose(e,t,i,0),Bi.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 ci(this),s=new ci(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 ci(this,e)}iterRange(e,t=this.length){return new kr(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 wr(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 Ue(e):Bi.from(Ue.split(e,[]))}},Ue=class n extends Q{constructor(e,t=pm(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 Co(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new n(Th(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=yr(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]=Ii(this,e,t);let r=yr(this.text,yr(i.text,Th(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new n(r,s):Bi.from(n.split(r,[]),s)}sliceString(e,t=this.length,i=`
|
|
2
2
|
`){[e,t]=Ii(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}},Bi=class n extends Q{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]=Ii(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]=Ii(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 m of e)m.flatten(p);return new Ue(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 m;if(p.lines>s&&p instanceof n)for(let w of p.children)f(w);else p.lines>o&&(a>o||!a)?(u(),l.push(p)):p instanceof Ue&&a&&(m=c[c.length-1])instanceof Ue&&p.lines+m.lines<=32?(a+=p.lines,h+=p.length+1,c[c.length-1]=new Ue(m.text.concat(p.text),m.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)}};Q.empty=new Ue([""],0);function
|
|
4
|
-
`,this;e--}else if(r instanceof Ue){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 Ue?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)}},yr=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new ci(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!=""}},kr=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"&&(Q.prototype[Symbol.iterator]=function(){return this.iter()},ci.prototype[Symbol.iterator]=yr.prototype[Symbol.iterator]=kr.prototype[Symbol.iterator]=function(){return this});var To=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 Ii(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}var Pi="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<Pi.length;n++)Pi[n]+=Pi[n-1];function cm(n){for(let e=1;e<Pi.length;e+=2)if(Pi[e]>n)return Pi[e-1]<=n;return!1}function Th(n){return n>=127462&&n<=127487}var Ch=8205;function ke(n,e,t=!0,i=!0){return(t?Oh:fm)(n,e,i)}function Oh(n,e,t){if(e==n.length)return e;e&&Bh(n.charCodeAt(e))&&Ph(n.charCodeAt(e-1))&&e--;let i=Se(n,e);for(e+=Ve(i);e<n.length;){let r=Se(n,e);if(i==Ch||r==Ch||t&&cm(r))e+=Ve(r),i=r;else if(Th(r)){let s=0,o=e-2;for(;o>=0&&Th(Se(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function fm(n,e,t){for(;e>0;){let i=Oh(n,e-2,t);if(i<e)return i;e--}return 0}function Bh(n){return n>=56320&&n<57344}function Ph(n){return n>=55296&&n<56320}function Se(n,e){let t=n.charCodeAt(e);if(!Ph(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Bh(i)?(t-55296<<10)+(i-56320)+65536:t}function dn(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Ve(n){return n<65536?1:2}var Co=/\r\n?|\n/,De=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(De||(De={})),Et=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){Ao(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:Rh(this,e)}mapDesc(e,t=!1){return e.empty?this:Mo(this,e,t)}mapPos(e,t=-1,i=De.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!=De.Simple&&h>=e&&(i==De.TrackDel&&r<e&&h>e||i==De.TrackBefore&&r<e||i==De.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)}},Ie=class n extends Et{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 Ao(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Mo(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(Q.empty);i.push(o?e.slice(s,s+o):Q.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:Rh(this,e,!0)}map(e,t=!1){return e.empty?this:Mo(this,e,t,!0)}iterChanges(e,t=!1){Ao(this,e,t)}get desc(){return Et.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new fi(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);Be(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Be(t,c,f),f>0&&Ht(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);Be(t,c,-1),Be(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:Et.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&&Be(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 m=p?typeof p=="string"?Q.of(p.split(i||Co)):p:Q.empty,w=m.length;if(f==u&&w==0)return;f<o&&a(),f>o&&Be(r,f-o,-1),Be(r,u-f,w),Ht(s,r,m),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(Q.empty);i[r]=Q.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 Be(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 Ht(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(Q.empty);n.push(t)}}function Ao(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=Q.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 Mo(n,e,t,i=!1){let r=[],s=i?[]:null,o=new fi(n),l=new fi(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Be(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(Be(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Be(r,0,o.ins),s&&Ht(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;Be(r,h,a<o.i?o.ins:0),s&&a<o.i&&Ht(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?Ie.createSet(r,s):Et.create(r);throw new Error("Mismatched change set lengths")}}function Rh(n,e,t=!1){let i=[],r=t?[]:null,s=new fi(n),o=new fi(e);for(let l=!1;;){if(s.done&&o.done)return r?Ie.createSet(i,r):Et.create(i);if(s.ins==0)Be(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Be(i,0,o.ins,l),r&&Ht(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;Be(i,a,c,l),r&&c&&Ht(r,i,o.text)}else o.ins==-1?(Be(i,s.off?0:s.len,a,l),r&&Ht(r,i,s.textBit(a))):(Be(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Ht(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 fi=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?Q.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Q.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)}},Vt=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 D.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return D.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return D.range(e.anchor,e.head)}static create(e,t,i){return new n(e,t,i)}},D=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,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],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=>Vt.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 Vt.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?Vt.create(t,e,48|s):Vt.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 Nh(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var zo=0,z=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=zo++,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:Fo),!!e.static,e.enables)}of(e){return new Ri([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ri(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ri(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Fo(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Ri=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=zo++}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)||Do(f,c)){let p=i(f);if(l?!Ah(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,u)=>{let p,m=u.config.address[s];if(m!=null){let w=vr(u,m);if(this.dependencies.every(y=>y instanceof z?u.facet(y)===f.facet(y):y instanceof ce?u.field(y,!1)==f.field(y,!1):!0)||(l?Ah(p=i(f),w,r):r(p=i(f),w)))return f.values[o]=w,0}else p=i(f);return f.values[o]=p,1}}}};function Ah(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 Do(n,e){let t=!1;for(let i of e)hn(n,i)&1&&(t=!0);return t}function um(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=vr(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)hn(a,h);return a.values[o]=l(a),1},update(a,h){if(!Do(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=Do(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Fo(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 Mh=z.define({static:!0}),ce=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(zo++,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(Mh).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,Mh.of({field:this,create:e})]}get extension(){return this}},ai={lowest:4,low:3,default:2,high:1,highest:0};function an(n){return e=>new wr(e,n)}var gt={highest:an(ai.highest),high:an(ai.high),default:an(ai.default),low:an(ai.low),lowest:an(ai.lowest)},wr=class{constructor(e,t){this.inner=e,this.prec=t}},lt=class n{of(e){return new cn(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},cn=class{constructor(e,t){this.compartment=e,this.inner=t}},xr=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 dm(e,t,o))u instanceof ce?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],m=p[0].facet,w=c&&c[u]||[];if(p.every(y=>y.type==0))if(l[m.id]=a.length<<1|1,Fo(w,p))a.push(i.facet(m));else{let y=m.combine(p.map(v=>v.value));a.push(i&&m.compare(y,i.facet(m))?i.facet(m):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[m.id]=h.length<<1,h.push(y=>um(y,m,p))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function dm(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 cn&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof cn){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 wr)s(o.inner,o.prec);else if(o instanceof ce)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Ri)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,ai.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,ai.default),i.reduce((o,l)=>o.concat(l))}function hn(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 vr(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var Ih=z.define(),Lo=z.define({combine:n=>n.some(e=>e),static:!0}),zh=z.define({combine:n=>n.length?n[0]:void 0,static:!0}),Fh=z.define(),Hh=z.define(),Vh=z.define(),Wh=z.define({combine:n=>n.length?n[0]:!1}),We=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Eo}},Eo=class{of(e){return new We(this,e)}},Oo=class{constructor(e){this.map=e}of(e){return new X(this,e)}},X=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 Oo(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}};X.reconfigure=X.define();X.appendConfig=X.define();var ve=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&&Nh(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]=="."))}};ve.time=We.define();ve.userEvent=We.define();ve.addToHistory=We.define();ve.remote=We.define();function pm(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 jh(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=Ie.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:X.mapEffects(n.effects,r).concat(X.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function Bo(n,e,t){let i=e.selection,r=Ni(e.annotations);return e.userEvent&&(r=r.concat(ve.userEvent.of(e.userEvent))),{changes:e.changes instanceof Ie?e.changes:Ie.of(e.changes||[],t,n.facet(zh)),selection:i&&(i instanceof D?i:D.single(i.anchor,i.head)),effects:Ni(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function $h(n,e,t){let i=Bo(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=jh(i,Bo(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=ve.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return gm(t?mm(r):r)}function mm(n){let e=n.startState,t=!0;for(let r of e.facet(Fh)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:pm(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=Ie.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=ve.create(e,r,n.selection&&n.selection.map(s),X.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Hh);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof ve?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ve?n=s[0]:n=$h(e,Ni(s),!1)}return n}function gm(n){let e=n.startState,t=e.facet(Vh),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=jh(i,Bo(e,s,n.changes.newLength),!0))}return i==n?n:ve.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var bm=[];function Ni(n){return n==null?bm:Array.isArray(n)?n:[n]}var me=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(me||(me={})),ym=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Po;try{Po=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function km(n){if(Po)return Po.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||ym.test(t)))return!0}return!1}function wm(n){return e=>{if(!/\S/.test(e))return me.Space;if(km(e))return me.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return me.Word;return me.Other}}var se=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++)hn(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 hn(this,i),vr(this,i)}update(...e){return $h(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(lt.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(X.reconfigure)?(t=null,i=l.value):l.is(X.appendConfig)&&(t=null,i=Ni(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=xr.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(Lo)?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:D.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=Ni(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=X.mapEffects(o,c).concat(X.mapEffects(Ni(a.effects),f))}return{changes:r,selection:D.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Ie?e:Ie.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return Q.of(e.split(this.facet(n.lineSeparator)||Co))}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:(hn(this,t),vr(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 ce&&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:D.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=xr.resolve(e.extensions||[],new Map),i=e.doc instanceof Q?e.doc:Q.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||Co)),r=e.selection?e.selection instanceof D?e.selection:D.single(e.selection.anchor,e.selection.head):D.single(0);return Nh(r,i.length),t.staticFacet(Lo)||(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(Wh)}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(Ih))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return wm(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=ke(t,o,!1);if(s(t.slice(a,o))!=me.Word)break;o=a}for(;l<r;){let a=ke(t,l);if(s(t.slice(l,a))!=me.Word)break;l=a}return o==l?null:D.range(o+i,l+i)}};se.allowMultipleSelections=Lo;se.tabSize=z.define({combine:n=>n.length?n[0]:4});se.lineSeparator=zh;se.readOnly=Wh;se.phrases=z.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])}});se.languageData=Ih;se.changeFilter=Fh;se.transactionFilter=Hh;se.transactionExtender=Vh;lt.reconfigure=X.define();function Pe(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 at=class{eq(e){return this==e}range(e,t=e){return fn.create(e,t,this)}};at.prototype.startSide=at.prototype.endSide=0;at.prototype.point=!1;at.prototype.mapMode=De.TrackDel;var fn=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 Ro(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var No=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 m=t.mapPos(c,h.startSide,h.mapMode);if(m==null||(u=p=m,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(Ro)),this.isEmpty)return t.length?n.of(t):this;let l=new Sr(this,null,-1).goto(0),a=0,h=[],c=new mt;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(fn.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 un.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return un.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=Dh(o,l,i),h=new hi(o,a,s),c=new hi(l,a,s);i.iterGaps((f,u,p)=>Lh(h,f,c,u,p,r)),i.empty&&i.length==0&&Lh(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=Dh(s,o),a=new hi(s,l,0).goto(i),h=new hi(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Io(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 hi(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:o.point.startSide<0?c.length: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 mt;for(let r of e instanceof fn?[e]:t?xm(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=n.empty;r=r.nextLayer)t=new n(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};ie.empty=new ie([],[],null,-1);function xm(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(Ro(e,i)>0)return n.slice().sort(Ro);e=i}return n}ie.empty.nextLayer=ie.empty;var mt=class n{finishChunk(e){this.chunks.push(new No(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 Dh(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 Sr=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}},un=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 Sr(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--)So(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--)So(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(),So(this.heap,0)}}};function So(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 hi=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=un.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){mr(this.active,e),mr(this.activeTo,e),mr(this.activeRank,e),this.minActive=Eh(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;gr(this.active,t,i),gr(this.activeTo,t,r),gr(this.activeRank,t,s),e&&gr(e,t,this.cursor.from),this.minActive=Eh(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&&mr(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 Lh(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))&&Io(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,f,n.point,t.point):f>l&&!Io(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 Io(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 mr(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function gr(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function Eh(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 Wt(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=ke(n,r));return i}function qh(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=ke(n,r)}return i===!0?-1:n.length}var Ho="\u037C",Kh=typeof Symbol=="undefined"?"__"+Ho:Symbol.for(Ho),Vo=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),_h=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},tt=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 m=l[p];if(/&/.test(p))s(p.split(/,\s*/).map(w=>o.map(y=>w.replace(/&/,y))).reduce((w,y)=>w.concat(y)),m,a);else if(m&&typeof m=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),m,c,u)}else m!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,w=>"-"+w.toLowerCase())+": "+m+";")}(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=_h
|
|
7
|
-
`;this.styleTag.textContent=s}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var Ot={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:"'"},zi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},vm=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Sm=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(we=0;we<10;we++)Ot[48+we]=Ot[96+we]=String(we);var we;for(we=1;we<=24;we++)Ot[we+111]="F"+we;var we;for(we=65;we<=90;we++)Ot[we]=String.fromCharCode(we+32),zi[we]=String.fromCharCode(we);var we;for(Tr in Ot)zi.hasOwnProperty(Tr)||(zi[Tr]=Ot[Tr]);var Tr;function Gh(n){var e=vm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Sm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?zi:Ot)[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 Hr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Jo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Tm(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Rr(n,e){if(!e.anchorNode)return!1;try{return Jo(n,e.anchorNode)}catch(t){return!1}}function An(n){return n.nodeType==3?ui(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function kn(n,e,t,i){return t?Yh(n,e,t,i,-1)||Yh(n,e,t,i,1):!1}function Mn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Yh(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Bt(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=Mn(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?Bt(n):0}else return!1}}function Bt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Nl(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Cm(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Nc(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 Am(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,m=1,w=1;if(p)u=Cm(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 S=c.getBoundingClientRect();({scaleX:m,scaleY:w}=Nc(c,S)),u={left:S.left,right:S.left+c.clientWidth*m,top:S.top,bottom:S.top+c.clientHeight*w}}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 S=e.bottom-e.top,E=u.bottom-u.top;v=(r=="center"&&S<=E?e.top+S/2-E/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-E+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 S=0,E=0;if(v){let O=c.scrollTop;c.scrollTop+=v/w,E=(c.scrollTop-O)*w}if(y){let O=c.scrollLeft;c.scrollLeft+=y/m,S=(c.scrollLeft-O)*m}e={left:e.left-S,top:e.top-E,right:e.right-S,bottom:e.bottom-E},S&&Math.abs(S-y)<1&&(i="nearest"),E&&Math.abs(E-v)<1&&(r="nearest")}if(p)break;c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Mm(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 Xo=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?Bt(t):0),i,Math.min(e.focusOffset,i?Bt(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},Fi=null;function Ic(n){if(n.setActive)return n.setActive();if(Fi)return n.focus(Fi);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(Fi==null?{get preventScroll(){return Fi={preventScroll:!0},!0}}:void 0),!Fi){Fi=!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 Jh;function ui(n,e,t=e){let i=Jh||(Jh=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function ji(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 Dm(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function zc(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}function Lm(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Bt(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=Bt(t))}else{if(t==n)return!0;i=Mn(t),t=t.parentNode}}function Fc(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}var ze=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,Mn(e),t)}static after(e,t){return new n(e.parentNode,Mn(e)+1,t)}},Il=[],ge=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=Xh(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=Xh(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=Bt(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=Il){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 Vr(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}};ge.prototype.breakAfter=0;function Xh(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Vr=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 Hc(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 Vc(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,Hc(n,h,c,l,a,i,0,r,s)}var Ge=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},Zo=typeof document!="undefined"?document:{documentElement:{style:{}}},Qo=/Edge\/(\d+)/.exec(Ge.userAgent),Wc=/MSIE \d/.test(Ge.userAgent),el=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ge.userAgent),es=!!(Wc||el||Qo),Zh=!es&&/gecko\/(\d+)/i.test(Ge.userAgent),jo=!es&&/Chrome\/(\d+)/.exec(Ge.userAgent),Qh="webkitFontSmoothing"in Zo.documentElement.style,jc=!es&&/Apple Computer/.test(Ge.vendor),ec=jc&&(/Mobile\/\w+/.test(Ge.userAgent)||Ge.maxTouchPoints>2),W={mac:ec||/Mac/.test(Ge.platform),windows:/Win/.test(Ge.platform),linux:/Linux|X11/.test(Ge.platform),ie:es,ie_version:Wc?Zo.documentMode||6:el?+el[1]:Qo?+Qo[1]:0,gecko:Zh,gecko_version:Zh?+(/Firefox\/(\d+)/.exec(Ge.userAgent)||[0,0])[1]:0,chrome:!!jo,chrome_version:jo?+jo[1]:0,ios:ec,android:/Android\b/.test(Ge.userAgent),webkit:Qh,safari:jc,webkit_version:Qh?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Zo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Em=256,qt=class n extends ge{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>Em||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 ze(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 Om(this.dom,e,t)}},Kt=class n extends ge{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(zc(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:(Vc(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 $c(this,e)}coordsAt(e,t){return Kc(this,e,t)}};function Om(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?W.chrome||W.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=ui(n,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return W.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Nl(a,o<0):a||null}var Dn=class n extends ge{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.widget.editable||(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 Q.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):Q.empty}domAtPos(e){return(this.length?e==0:this.side>0)?ze.before(this.dom):ze.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 Nl(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)}},Ln=class n extends ge{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?ze.before(this.dom):ze.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Q.empty}get isHidden(){return!0}};qt.prototype.children=Dn.prototype.children=Ln.prototype.children=Il;function $c(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 ze(t,0)}function qc(n,e,t){let i,{children:r}=n;t>0&&e instanceof Kt&&r.length&&(i=r[r.length-1])instanceof Kt&&i.mark.eq(e.mark)?qc(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function Kc(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],m=u+p.length;m>=c&&(p.children.length?l(p,c-u):(!s||s.isHidden&&t>0)&&(m>c||u==m&&p.getSide()>0)?(s=p,o=c-u):(u<c||u==m&&p.getSide()<0&&!p.isHidden)&&(i=p,r=c-u)),u=m}}l(n,e);let a=(t<0?i:s)||i||s;return a?a.coordsAt(Math.max(0,a==i?r:o),t):Bm(n)}function Bm(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=An(e);return t[t.length-1]||null}function tl(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 tc=Object.create(null);function zl(n,e,t){if(n==e)return!0;n||(n=tc),e||(e=tc);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 il(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 Pm(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 Le=class n extends ge{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),Vc(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){zl(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){qc(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=tl(t,this.attrs||{})),i&&(this.attrs=tl({class:i},this.attrs||{}))}domAtPos(e){return $c(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(zc(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&&(il(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&&ge.get(r)instanceof Kt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=ge.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!W.ios||!this.children.some(s=>s instanceof qt))){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 qt)||/[^ -~]/.test(i.text))return null;let r=An(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=Kc(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}},$i=class n extends ge{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?ze.before(this.dom):ze.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 Il}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Q.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}},Je=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}get editable(){return!1}destroy(e){}},Fe=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Fe||(Fe={})),_=class extends at{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 En(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 _t(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}=_c(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new _t(e,i,r,t,e.widget||null,!0)}static line(e){return new On(e)}static set(e,t=!1){return ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};_.none=ie.empty;var En=class n extends _{constructor(e){let{start:t,end:i}=_c(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))&&zl(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)}};En.prototype.point=!1;var On=class n extends _{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&zl(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)}};On.prototype.mapMode=De.TrackBefore;On.prototype.point=!0;var _t=class n extends _{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?De.TrackBefore:De.TrackAfter:De.TrackDel}get type(){return this.startSide!=this.endSide?Fe.WidgetRange:this.startSide<=0?Fe.WidgetBefore:Fe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Rm(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)}};_t.prototype.point=!0;function _c(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 Rm(n,e){return n==e||!!(n&&e&&n.compare(e))}function nl(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 wn=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 $i&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Le),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Cr(new Ln(-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 $i)&&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(Cr(new qt(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 _t){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 _t)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new $i(i.widget||new Wr("div"),l,i));else{let a=Dn.create(i.widget||new Wr("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(Cr(new Ln(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(Cr(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 Cr(n,e){for(let t of e)n=new Kt(t,[n],n.length);return n}var Wr=class extends Je{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}},fe=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(fe||(fe={})),di=fe.LTR,Fl=fe.RTL;function Uc(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var Nm=Uc("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Im=Uc("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),rl=Object.create(null),bt=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);rl[e]=t,rl[t]=-e}function Gc(n){return n<=247?Nm[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?Im[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var zm=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,kt=class{get dir(){return this.level%2?Fl:di}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}forward(e,t){return e==(this.dir==t)}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 Yc(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||!Yc(i.inner,r.inner))return!1}return!0}var ue=[];function Fm(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=Gc(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),ue[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=ue[h];if(u==128)h<l-1&&c==ue[h+1]&&c&24?u=ue[h]=c:ue[h]=256;else if(u==64){let p=h+1;for(;p<l&&ue[p]==64;)p++;let m=h&&c==8||p<t&&ue[p]==8?f==1?1:8:256;for(let w=h;w<p;w++)ue[w]=m;h=p-1}else u==8&&f==1&&(ue[h]=1);c=u,u&7&&(f=u)}}}function Hm(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,m;f<c;f++)if(p=rl[u=n.charCodeAt(f)])if(p<0){for(let w=l-3;w>=0;w-=3)if(bt[w+1]==-p){let y=bt[w+2],v=y&2?r:y&4?y&1?s:r:0;v&&(ue[f]=ue[bt[w]]=v),l=w;break}}else{if(bt.length==189)break;bt[l++]=f,bt[l++]=u,bt[l++]=a}else if((m=ue[f])==2||m==1){let w=m==r;a=w?0:1;for(let y=l-3;y>=0;y-=3){let v=bt[y+2];if(v&2)break;if(w)bt[y+2]|=2;else{if(v&4)break;bt[y+2]|=4}}}}}function Vm(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=ue[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(ue[c]==256)c++;else break;let f=s==1,u=(c<e?ue[c]:i)==1,p=f==u?f?1:2:i;for(let m=c,w=r,y=w?t[w-1].to:n;m>a;)m==y&&(m=t[--w].from,y=w?t[w-1].to:n),ue[--m]=p;a=c}else s=h,a++}}}function sl(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 w=ue[a];w!=l&&(c=!1,f=w==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,m=a;e:for(;;)if(h<s.length&&m==s[h].from){if(f)break e;let w=s[h];if(!c)for(let y=w.to,v=h+1;;){if(y==t)break e;if(v<s.length&&s[v].from==y)y=s[v++].to;else{if(ue[y]==l)break e;break}}if(h++,u)u.push(w);else{w.from>a&&o.push(new kt(a,w.from,p));let y=w.direction==di!=!(p%2);ol(n,y?i+1:i,r,w.inner,w.from,w.to,o),a=w.to}m=w.to}else{if(m==t||(c?ue[m]!=l:ue[m]==l))break;m++}u?sl(n,a,m,i+1,r,u,o):a<m&&o.push(new kt(a,m,p)),a=m}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let w=ue[a-1];w!=l&&(c=!1,f=w==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,m=a;e:for(;;)if(h&&m==s[h-1].to){if(f)break e;let w=s[--h];if(!c)for(let y=w.from,v=h;;){if(y==e)break e;if(v&&s[v-1].to==y)y=s[--v].from;else{if(ue[y-1]==l)break e;break}}if(u)u.push(w);else{w.to<a&&o.push(new kt(w.to,a,p));let y=w.direction==di!=!(p%2);ol(n,y?i+1:i,r,w.inner,w.from,w.to,o),a=w.from}m=w.from}else{if(m==e||(c?ue[m-1]!=l:ue[m-1]==l))break;m--}u?sl(n,m,a,i+1,r,u,o):m<a&&o.push(new kt(m,a,p)),a=m}}function ol(n,e,t,i,r,s,o){let l=e%2?2:1;Fm(n,r,s,i,l),Hm(n,r,s,i,l),Vm(r,s,i,l),sl(n,r,s,e,t,i,o)}function Wm(n,e,t){if(!n)return[new kt(0,0,e==Fl?1:0)];if(e==di&&!t.length&&!zm.test(n))return Jc(n.length);if(t.length)for(;n.length>ue.length;)ue[ue.length]=256;let i=[],r=e==di?0:1;return ol(n,r,r,t,0,n.length,i),i}function Jc(n){return[new kt(0,n,0)]}var Xc="";function jm(n,e,t,i,r){var s;let o=i.head-n.from,l=kt.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],h=a.side(r,t);if(o==h){let u=l+=r?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!r,t),h=a.side(r,t)}let c=ke(n.text,o,a.forward(r,t));(c<a.from||c>a.to)&&(c=h),Xc=n.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return f&&c==h&&f.level+(r?0:1)<a.level?D.cursor(f.side(!r,t)+n.from,f.forward(r,t)?1:-1,f.level):D.cursor(c+n.from,a.forward(r,t)?-1:1,a.level)}function $m(n,e,t){for(let i=e;i<t;i++){let r=Gc(n.charCodeAt(i));if(r==1)return di;if(r==2||r==4)return Fl}return di}var Zc=z.define(),Qc=z.define(),ef=z.define(),tf=z.define(),ll=z.define(),nf=z.define(),rf=z.define(),sf=z.define({combine:n=>n.some(e=>e)}),of=z.define({combine:n=>n.some(e=>e)}),xn=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(D.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Ar=X.define({map:(n,e)=>n.map(e)});function Re(n,e,t){let i=n.facet(tf);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 ts=z.define({combine:n=>n.length?n[0]:!0}),qm=0,mn=z.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(qm++,e,i,r,l=>{let a=[mn.of(l)];return o&&a.push(Bn.of(h=>{let c=h.plugin(l);return c?o(c):_.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define(i=>new e(i),t)}},vn=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(Re(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){Re(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){Re(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},lf=z.define(),Hl=z.define(),Bn=z.define(),af=z.define(),Vl=z.define(),hf=z.define();function ic(n,e){let t=n.state.facet(hf);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return ie.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let h=s-e.from,c=o-e.from,f=r;for(let u=l.length-1;u>=0;u--,a--){let p=l[u].spec.bidiIsolate,m;if(p==null&&(p=$m(e.text,h,c)),a>0&&f.length&&(m=f[f.length-1]).to==h&&m.direction==p)m.to=c,f=m.inner;else{let w={from:h,to:c,direction:p,inner:[]};f.push(w),f=w.inner}}}}),r}var cf=z.define();function ff(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(cf)){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 gn=z.define(),wt=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),m=Math.min(c,u);if(p<=m&&new n(p+h,m+h,p,m).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}}},jr=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Ie.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 wt(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}},$r=class extends ge{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 Le],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new wt(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:!Xm(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?_m(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new wt(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,(W.ie||W.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=Ym(o,l,e.changes);return i=wt.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=W.chrome||W.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 $i&&o.widget instanceof qr&&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,m,w;if(i&&i.range.fromB<f&&i.range.toB>c){let O=wn.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),L=wn.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);p=O.breakAtStart,m=O.openStart,w=L.openEnd;let B=this.compositionView(i);L.breakAtStart?B.breakAfter=1:L.content.length&&B.merge(B.length,B.length,L.content[0],!1,L.openStart,0)&&(B.breakAfter=L.content[0].breakAfter,L.content.shift()),O.content.length&&B.merge(0,0,O.content[O.content.length-1],!0,0,O.openEnd)&&O.content.pop(),u=O.content.concat(B).concat(L.content)}else({content:u,breakAtStart:p,openStart:m,openEnd:w}=wn.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:y,off:v}=s.findPos(h,1),{i:S,off:E}=s.findPos(a,-1);Hc(this,S,E,y,v,u,p,m,w)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new qt(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Kt(r,[t],t.length);let i=new Le;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=ge.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&&Rr(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(W.gecko&&l.empty&&!this.hasComposition&&Km(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=h=new ze(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||(!kn(a.node,a.offset,c.anchorNode,c.anchorOffset)||!kn(h.node,h.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,l))&&(this.view.observer.ignore(()=>{W.android&&W.chrome&&this.dom.contains(c.focusNode)&&Jm(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=Hr(this.view.root);if(f)if(l.empty){if(W.gecko){let u=Um(a.node,a.offset);if(u&&u!=3){let p=df(a.node,a.offset,u==1?1:-1);p&&(a=new ze(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 ze(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new ze(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&kn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Hr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=Le.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=ge.get(t.childNodes[r]);s instanceof Le&&(i=s.domAtPos(0))}for(let r=e.offset-1;!i&&r>=0;r--){let s=ge.get(t.childNodes[r]);s instanceof Le&&(i=s.domAtPos(s.length))}return i?new ze(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=ge.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 Le)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 Le&&!(i instanceof Le&&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 Le))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 qt))return null;let s=ke(r.text,i);if(s==i)return null;let o=ui(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==fe.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 m=f.dom.lastChild,w=m?An(m):[];if(w.length){let y=w[w.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"?fe.RTL:fe.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Le){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=An(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 Vr(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(_.replace({widget:new qr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return _.set(e)}updateDeco(){let e=this.view.state.facet(Bn).map((r,s)=>(this.dynamicDecorationMap[s]=typeof r=="function")?r(this.view):r),t=!1,i=this.view.state.facet(af).map((r,s)=>{let o=typeof r=="function";return o&&(t=!0),o?r(this.view):r});i.length&&(this.dynamicDecorationMap[e.length]=t,e.push(ie.join(i)));for(let r=e.length;r<e.length+3;r++)this.dynamicDecorationMap[r]=!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=ff(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;Am(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==fe.LTR)}};function Km(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 qr=class extends Je{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function uf(n,e){let t=n.observer.selectionRange,i=t.focusNode&&df(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 _m(n,e,t){let i=uf(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 wt(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let f=r.parentNode;;f=f.parentNode){let u=ge.get(f);if(u instanceof Kt)c.push({node:f,deco:u.mark});else{if(u instanceof Le||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 En({inclusive:!0,attributes:Pm(f),tagName:f.tagName.toLowerCase()})});else return null}}}function df(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=Bt(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 Um(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 Gm=class{constructor(){this.changes=[]}compareRange(e,t){nl(e,t,this.changes)}comparePoint(e,t){nl(e,t,this.changes)}};function Ym(n,e,t){let i=new Gm;return ie.compare(n,e,t,i),i.changes}function Jm(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 Xm(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}function Zm(n,e,t=1){let i=n.charCategorizer(e),r=n.doc.lineAt(e),s=e-r.from;if(r.length==0)return D.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=ke(r.text,s,!1):l=ke(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=ke(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=ke(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return D.range(o+r.from,l+r.from)}function Qm(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function eg(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function $o(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function nc(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function rc(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function al(n,e,t){let i,r,s,o,l=!1,a,h,c,f;for(let m=n.firstChild;m;m=m.nextSibling){let w=An(m);for(let y=0;y<w.length;y++){let v=w[y];r&&$o(r,v)&&(v=nc(rc(v,r.bottom),r.top));let S=Qm(e,v),E=eg(t,v);if(S==0&&E==0)return m.nodeType==3?sc(m,e,t):al(m,e,t);if(!i||o>E||o==E&&s>S){i=m,r=v,s=S,o=E;let O=E?t<v.top?-1:1:S?e<v.left?-1:1:0;l=!O||(O>0?y<w.length-1:y>0)}S==0?t>v.bottom&&(!c||c.bottom<v.bottom)?(a=m,c=v):t<v.top&&(!f||f.top>v.top)&&(h=m,f=v):c&&$o(c,v)?c=rc(c,v.bottom):f&&$o(f,v)&&(f=nc(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 sc(i,u,t);if(l&&i.contentEditable!="false")return al(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 sc(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let a=ui(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((W.chrome||W.gecko)&&ui(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 pf(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 O=n.viewState.heightOracle.textHeight/2,L=!1;a=n.elementAtHeight(u),a.type!=Fe.Text;)for(;u=i>0?a.bottom+O:a.top-O,!(u>=0&&u<=h);){if(L)return t?null:0;L=!0,i=-i}f=l+u;let p=a.from;if(p<n.viewport.from)return n.viewport.from==0?0:t?null:oc(n,o,a,c,f);if(p>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:oc(n,o,a,c,f);let m=n.dom.ownerDocument,w=n.root.elementFromPoint?n.root:m,y=w.elementFromPoint(c,f);y&&!n.contentDOM.contains(y)&&(y=null),y||(c=Math.max(o.left+1,Math.min(o.right-1,c)),y=w.elementFromPoint(c,f),y&&!n.contentDOM.contains(y)&&(y=null));let v,S=-1;if(y&&((r=n.docView.nearest(y))===null||r===void 0?void 0:r.isEditable)!=!1){if(m.caretPositionFromPoint){let O=m.caretPositionFromPoint(c,f);O&&({offsetNode:v,offset:S}=O)}else if(m.caretRangeFromPoint){let O=m.caretRangeFromPoint(c,f);O&&({startContainer:v,startOffset:S}=O,(!n.contentDOM.contains(v)||W.safari&&tg(v,S,c)||W.chrome&&ig(v,S,c))&&(v=void 0))}}if(!v||!n.docView.dom.contains(v)){let O=Le.find(n.docView,p);if(!O)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:S}=al(O.dom,c,f))}let E=n.docView.nearest(v);if(!E)return null;if(E.isWidget&&((s=E.dom)===null||s===void 0?void 0:s.nodeType)==1){let O=E.dom.getBoundingClientRect();return e.y<O.top||e.y<=O.bottom&&e.x<=(O.left+O.right)/2?E.posAtStart:E.posAtEnd}else return E.localPosFromDOM(v,S)+E.posAtStart}function oc(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+qh(o,s,n.state.tabSize)}function tg(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 ui(n,i-1,i).getBoundingClientRect().left>t}function ig(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():ui(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function hl(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==Fe.Text))return i}return t}function ng(n,e,t,i){let r=hl(n,e.head),s=!i||r.type!=Fe.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==fe.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return D.cursor(a,t?-1:1)}return D.cursor(t?r.to:r.from,t?-1:1)}function lc(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=jm(r,s,o,l,t),c=Xc;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=n.visualLineSide(r,!t)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function rg(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==me.Space&&(r=o),r==o}}function sg(n,e,t,i){let r=e.head,s=t?1:-1;if(r==(t?n.state.doc.length:0))return D.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 m=l+(u+p)*s,w=pf(n,{x:f,y:m},!1,s);if(m<a.top||m>a.bottom||(s<0?w<r:w>r)){let y=n.docView.coordsForChar(w),v=!y||m<y.top?-1:1;return D.cursor(w,v,void 0,o)}}}function Nr(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 qo(n,e,t){let i=Nr(n.state.facet(Vl).map(r=>r(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:D.cursor(i,i<t.from?1:-1)}var cl=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,W.safari&&e.contentDOM.addEventListener("input",()=>null),W.gecko&&wg(e.contentDOM.ownerDocument)}handleEvent(e){!ug(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=og(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&&gf.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),W.android&&W.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return W.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=mf.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||lg.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,ji(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:W.safari&&!W.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 ac(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){Re(t.state,r)}}}function og(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(ac(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(ac(i.value,o))}}for(let i in ht)t(i).handlers.push(ht[i]);for(let i in ct)t(i).observers.push(ct[i]);return e}var mf=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],lg="dthko",gf=[16,17,18,20,91,92,224,225],Mr=6;function Dr(n){return Math.max(0,n)*.7+8}function ag(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var fl=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=Mm(e.contentDOM),this.atoms=e.state.facet(Vl).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(se.allowMultipleSelections)&&hg(e,t),this.dragging=fg(e,t)&&wf(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&&ag(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=ff(this.view);e.clientX-o.left<=s.left+Mr?i=-Dr(s.left-e.clientX):e.clientX+o.right>=s.right-Mr&&(i=Dr(e.clientX-s.right)),e.clientY-o.top<=s.top+Mr?r=-Dr(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-Mr&&(r=Dr(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=Nr(this.atoms,r.from,0);o!=r.from&&(s=D.cursor(o,-1))}else{let o=Nr(this.atoms,r.from,-1),l=Nr(this.atoms,r.to,1);(o!=r.from||l!=r.to)&&(s=D.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?D.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,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 hg(n,e){let t=n.state.facet(Zc);return t.length?t[0](e):W.mac?e.metaKey:e.ctrlKey}function cg(n,e){let t=n.state.facet(Qc);return t.length?t[0](e):W.mac?!e.altKey:!e.ctrlKey}function fg(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Hr(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 ug(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=ge.get(t))&&i.ignoreEvent(e))return!1;return!0}var ht=Object.create(null),ct=Object.create(null),bf=W.ie&&W.ie_version<15||W.ios&&W.webkit_version<604;function dg(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(),yf(n,t.value)},50)}function yf(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(ul!=null&&t.selection.ranges.every(a=>a.empty)&&ul==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:D.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:D.cursor(a.from+h.length)}}):i=t.replaceSelection(s);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ct.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};ht.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);ct.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};ct.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};ht.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(ef))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=gg(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new fl(n,e,t,i)),i&&n.observer.ignore(()=>Ic(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function hc(n,e,t,i){if(i==1)return D.cursor(e,t);if(i==2)return Zm(n.state,e,t);{let r=Le.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++,D.range(o,l)}}var kf=(n,e)=>n>=e.top&&n<=e.bottom,cc=(n,e,t)=>kf(e,t)&&n>=t.left&&n<=t.right;function pg(n,e,t,i){let r=Le.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&&cc(t,i,o))return-1;let l=r.coordsAt(s,1);return l&&cc(t,i,l)?1:o&&kf(i,o)?-1:1}function fc(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:pg(n,t,e.clientX,e.clientY)}}var mg=W.ie&&W.ie_version<=11,uc=null,dc=0,pc=0;function wf(n){if(!mg)return n.detail;let e=uc,t=pc;return uc=n,pc=Date.now(),dc=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(dc+1)%3:1}function gg(n,e){let t=fc(n,e),i=wf(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=fc(n,s),h,c=hc(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=hc(n,t.pos,t.bias,i),u=Math.min(f.from,c.from),p=Math.max(f.to,c.to);c=u<c.from?D.range(u,p):D.range(p,u)}return o?r.replaceRange(r.main.extend(c.from,c.to)):l&&i==1&&r.ranges.length>1&&(h=bg(r,a.pos))?h:l?r.addRange(c):D.create([c])}}}function bg(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 D.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}ht.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=D.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};ht.dragend=n=>(n.inputState.draggedContent=null,!1);function mc(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&&cg(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}ht.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&&mc(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 mc(n,e,i,!0),!0}return!1};ht.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=bf?null:e.clipboardData;return t?(yf(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(dg(n),!1)};function yg(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 kg(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 ul=null;ht.copy=ht.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=kg(n.state);if(!t&&!r)return!1;ul=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=bf?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(yg(n,t),!1)};var xf=We.define();function vf(n,e){let t=[];for(let i of n.facet(rf)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:xf.of(!0)}):null}function Sf(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=vf(n.state,e);t?n.dispatch(t):n.update([])}},10)}ct.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),Sf(n)};ct.blur=n=>{n.observer.clearSelectionRange(),Sf(n)};ct.compositionstart=ct.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};ct.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,W.chrome&&W.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};ct.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};ht.beforeinput=(n,e)=>{var t;let i;if(W.chrome&&W.android&&(i=mf.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 gc=new Set;function wg(n){gc.has(n)||(gc.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var bc=["pre-wrap","normal","pre-line","break-spaces"],dl=class{constructor(e){this.lineWrapping=e,this.doc=Q.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 bc.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=bc.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}},pl=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},yt=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"?Fe.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 _t?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)}},pe=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(pe||(pe={})),Ir=.001,Ye=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)>Ir&&(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,pe.ByPosNoHeight,i.setDoc(t),0,0),p=u.to>=h?u:s.lineAt(h,pe.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,pe.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let m=gl.build(i.setDoc(o),e,c,f);s=s.replace(a,h,m)}return s.updateHeight(i,0)}static empty(){return new it(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 ml(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};Ye.prototype.size=1;var Kr=class extends Ye{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,r){return new yt(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})`}},it=class n extends Kr{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new yt(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 $t&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof $t?r=new n(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ye.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:""})`}},$t=class n extends Ye{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 yt(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 yt(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==pe.ByHeight)return this.blockAt(e,i,r,s);if(t==pe.ByPosNoHeight){let{from:p,to:m}=i.doc.lineAt(e);return new yt(p,m-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 yt(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 m=u.number-l;f+=a*m+h*(e-s-m)}let p=a+h*u.length;o(new yt(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 Ye.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)>=Ir&&(a=-2);let u=new it(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=Ye.of(o);return(a<0||Math.abs(h.height-this.height)>=Ir||Math.abs(a-this.heightMetrics(e,t).perLine)>=Ir)&&(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})`}},ml=class extends Ye{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==pe.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==pe.ByPosNoHeight?pe.ByPosNoHeight:pe.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,pe.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&&yc(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),yc(s,l)}return Ye.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?Ye.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 yc(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof $t&&(i=n[e+1])instanceof $t&&n.splice(e-1,3,new $t(t.length+1+i.length))}var xg=5,gl=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 it?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new it(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 Kr(o,r,i)):(o||s||r>=xg)&&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 it(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new $t(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 it)return e;let t=new it(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 it)&&!this.isCovered?this.nodes.push(new it(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 it&&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 vg(n,e,t){let i=new bl;return ie.compare(n,e,t,i,0),i.changes}var bl=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&nl(e,t,this.changes,5)}};function Sg(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 Tg(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Sn=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 _.replace({widget:new yl(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},yl=class extends Je{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},_r=class{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=kc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=fe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Hl).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new dl(t),this.stateDeco=e.facet(Bn).filter(i=>typeof i!="function"),this.heightMap=Ye.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle.setDoc(e.doc),[new wt(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=_.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 Hi(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?kc:new kl(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:bn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Bn).filter(c=>typeof c!="function");let r=e.changedRanges,s=wt.extendWithRanges(r,vg(i,this.stateDeco,e?e.changes:Ie.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(of)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?fe.RTL:fe.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:O,scaleY:L}=Nc(t,l);(this.scaleX!=O||this.scaleY!=L)&&(this.scaleX=O,this.scaleY=L,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=Fc(e.scrollDOM);let m=(this.printing?Tg:Sg)(t,this.paddingTop),w=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;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 S=l.width;if((this.contentDOMWidth!=S||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let O=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(O)&&(o=!0),o||r.lineWrapping&&Math.abs(S-this.contentDOMWidth)>r.charWidth){let{lineHeight:L,charWidth:B,textHeight:x}=e.docView.measureTextSize();o=L>0&&r.refresh(s,L,B,x,S/B,O),o&&(e.docView.minWidth=0,h|=8)}w>0&&y>0?c=Math.max(w,y):w<0&&y<0&&(c=Math.min(w,y)),r.heightChanged=!1;for(let L of this.viewports){let B=L.from==this.viewport.from?O:e.docView.measureVisibleLineHeights(L);this.heightMap=(o?Ye.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle,[new wt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new pl(L.from,B))}r.heightChanged&&(h|=2)}let E=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return E&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||E)&&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 Hi(r.lineAt(o-i*1e3,pe.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,pe.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,pe.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 Hi(r.lineAt(u-1e3/2,pe.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,pe.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 Hi(this.heightMap.lineAt(i,pe.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,pe.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,pe.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,pe.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 Sn(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!=fe.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-h<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let y of m)if(y>h&&y<c){a(h,y-10,f,u),a(y+10,c,f,u);return}let w=Ag(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)<s&&Math.abs(y.to-c)<s&&!m.some(v=>y.from<v&&y.to>v));if(!w){if(c<f.to&&t&&i&&t.visibleRanges.some(y=>y.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(D.cursor(c),!1,!0).head;y>h&&(c=y)}w=new Sn(h,c,this.gapSize(f,h,c,u))}l.push(w)};for(let h of this.viewportLines){if(h.length<o)continue;let c=Cg(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 m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,w,y;if(f!=null){let v=Er(c,f),S=((this.visibleBottom-this.visibleTop)/2+m)/h.height;w=v-S,y=v+S}else w=(this.visibleTop-h.top-m)/h.height,y=(this.visibleBottom-h.top+m)/h.height;u=Lr(c,w),p=Lr(c,y)}else{let m=c.total*this.heightOracle.charWidth,w=r*this.heightOracle.charWidth,y,v;if(f!=null){let S=Er(c,f),E=((this.pixelViewport.right-this.pixelViewport.left)/2+w)/m;y=S-E,v=S+E}else y=(this.pixelViewport.left-w)/m,v=(this.pixelViewport.right+w)/m;u=Lr(c,y),p=Lr(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=Er(r,i)-Er(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){Sn.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=_.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)||bn(this.heightMap.lineAt(e,pe.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return bn(this.heightMap.lineAt(this.scaler.fromDOM(e),pe.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 bn(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}},Hi=class{constructor(e,t){this.from=e,this.to=t}};function Cg(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 Lr({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 Er(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 Ag(n,e){for(let t of n)if(e(t))return t}var kc={toDOM(n){return n},fromDOM(n){return n},scale:1},kl=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,pe.ByPos,e,0,0).top,c=t.lineAt(a,pe.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 bn(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new yt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>bn(r,e)):n._content)}var Or=z.define({combine:n=>n.join(" ")}),wl=z.define({combine:n=>n.indexOf(!0)>-1}),xl=tt.newName(),Tf=tt.newName(),Cf=tt.newName(),Af={"&light":"."+Tf,"&dark":"."+Cf};function vl(n,e,t){return new tt(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 Mg=vl("."+xl,{"&":{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-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&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"}},Af),yn="\uFFFF",Sl=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(se.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=yn}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=ge.get(r),a=ge.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:wc(r))||wc(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=ge.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+(Dg(e,i.node,i.offset)?t:0))}};function Dg(n,e,t){for(;;){if(!e||t<Bt(e))return!1;if(e==n)return!0;t=Mn(e)+1,e=e.parentNode}}function wc(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}var Ur=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Tl=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?[]:Og(e),a=new Sl(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Bg(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!Jo(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||!Jo(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),c=e.viewport;if((W.ios||W.chrome)&&e.state.selection.main.empty&&a!=h&&(c.from>0||c.to<e.state.doc.length)){let f=Math.min(a,h),u=Math.max(a,h),p=c.from-f,m=c.to-u;(p==0||p==1||f==0)&&(m==0||m==-1||u==e.state.doc.length)&&(a=0,h=e.state.doc.length)}this.newSel=D.single(h,a)}}};function Mf(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||W.android&&e.text.length<l-o)&&(a=r.to,h="end");let c=Eg(n.state.doc.sliceString(o,l,yn),e.text,a-o,h);c&&(W.chrome&&s==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==yn+yn&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:Q.of(e.text.slice(c.from,c.toB).split(yn))})}else i&&(!n.hasFocus&&n.state.facet(ts)||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))}:(W.mac||W.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=D.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Q.of([" "])}):W.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
9
|
-
`&&n.lineWrapping&&(i&&(i=D.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:Q.of([" "])}),t){if(W.ios&&n.inputState.flushIOSKey()||W.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&ji(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)&&ji(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&ji(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,a=()=>l||(l=Lg(n,t,i));return n.state.facet(nf).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 Lg(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&&uf(n,t.main.head);if(f){let m=e.insert.length-(e.to-e.from);c={from:f.from,to:f.to-m}}else c=n.state.doc.lineAt(s.head);let u=s.to-e.to,p=s.to-s.from;i=r.changeByRange(m=>{if(m.from==s.from&&m.to==s.to)return{changes:l,range:a||m.map(l)};let w=m.to-u,y=w-h.length;if(m.to-m.from!=p||n.state.sliceDoc(y,w)!=h||m.to>=c.from&&m.from<=c.to)return{range:m};let v=r.changes({from:y,to:w,insert:e.insert}),S=m.to-s.to;return{changes:v,range:a?D.range(Math.max(0,a.anchor+S),Math.max(0,a.head+S)):m.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 Eg(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 Og(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 Ur(t,i)),(r!=t||s!=i)&&e.push(new Ur(r,s))),e}function Bg(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?D.single(t+e,i+e):null}var Pg={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ko=W.ie&&W.ie_version<=11,Cl=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Xo,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);(W.ie&&W.ie_version<=11||W.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()}),Ko&&(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(ts)?i.root.activeElement!=this.dom:!Rr(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(W.ie&&W.ie_version<=11||W.android&&W.chrome)&&!i.state.selection.main.empty&&r.focusNode&&kn(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=W.safari&&e.root.nodeType==11&&Tm(this.dom.ownerDocument)==this.dom&&Rg(this.view)||Hr(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=Rr(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Lm(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,Pg),Ko&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ko&&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&&ji(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&&Rr(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 Tl(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=Mf(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=xc(t,e.previousSibling||e.target.previousSibling,-1),r=xc(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 xc(n,e,t){for(;e;){let i=ge.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 Rg(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 kn(l.node,l.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}var N=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),e.parent&&e.parent.appendChild(this.dom);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||Dm(e.parent)||document,this.viewState=new _r(e.state||se.create(e)),e.scrollTo&&e.scrollTo.is(Ar)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(mn).map(i=>new vn(i));for(let i of this.plugins)i.update(this);this.observer=new Cl(this),this.inputState=new cl(this),this.inputState.ensureHandlers(this.plugins),this.docView=new $r(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=e.length==1&&e[0]instanceof ve?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(xf))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=vf(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(se.phrases)!=this.state.facet(se.phrases))return this.setState(s);r=jr.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 xn(p.empty?p:D.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of u.effects)p.is(Ar)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Gr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(gn)!=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(Or)!=r.state.facet(Or)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let u of this.state.facet(ll))try{u(r)}catch(p){Re(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Mf(this,c)&&h.force&&ji(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 _r(e),this.plugins=e.facet(mn).map(i=>new vn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new $r(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(mn),i=e.state.facet(mn);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new vn(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(Fc(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(m){return Re(this.state,m),vc}}),f=jr.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]!=vc)try{let m=h[p];m.write&&m.write(c[p],this)}catch(m){Re(this.state,m)}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 m=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(m>1||m<-1){r=r+m,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(ll))l(t)}get themeClasses(){return xl+" "+(this.state.facet(wl)?Cf:Tf)+" "+this.state.facet(Or)}updateAttrs(){let e=Sc(this,lf,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ts)?"true":"false",class:"cm-content",style:`${W.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Sc(this,Hl,t);let i=this.observer.ignore(()=>{let r=il(this.contentDOM,this.contentAttrs,t),s=il(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(gn);let e=this.state.facet(n.cspNonce);tt.mount(this.root,this.styleModules.concat(Mg).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 qo(this,e,lc(this,e,t,i))}moveByGroup(e,t){return qo(this,e,lc(this,e,t,i=>rg(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return D.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return ng(this,e,t,i)}moveVertically(e,t,i){return qo(this,e,sg(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(),pf(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[kt.find(s,e-r.from,-1,t)];return Nl(i,o.dir==fe.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(sf)||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>Ng)return Jc(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||Yc(s.isolates,i=ic(this,e))))return s.order;i||(i=ic(this,e));let r=Wm(e.text,t,i);return this.bidiCache.push(new Gr(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||W.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ic(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 Ar.of(new xn(typeof e=="number"?D.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 Ar.of(new xn(D.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=tt.newName(),r=[Or.of(i),gn.of(vl(`.${i}`,e))];return t&&t.dark&&r.push(wl.of(!0)),r}static baseTheme(e){return gt.lowest(gn.of(vl("."+xl,e,Af)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&ge.get(i)||ge.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}};N.styleModule=gn;N.inputHandler=nf;N.focusChangeEffect=rf;N.perLineTextDirection=sf;N.exceptionSink=tf;N.updateListener=ll;N.editable=ts;N.mouseSelectionStyle=ef;N.dragMovesSelection=Qc;N.clickAddsSelectionRange=Zc;N.decorations=Bn;N.outerDecorations=af;N.atomicRanges=Vl;N.bidiIsolatedRanges=hf;N.scrollMargins=cf;N.darkTheme=wl;N.cspNonce=z.define({combine:n=>n.length?n[0]:""});N.contentAttributes=Hl;N.editorAttributes=lf;N.lineWrapping=N.contentAttributes.of({class:"cm-lineWrapping"});N.announce=X.define();var Ng=4096,vc={},Gr=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:fe.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 Sc(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&&tl(o,t)}return t}var Ig=W.mac?"mac":W.windows?"win":W.linux?"linux":"key";function zg(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 Br(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 Fg=gt.default(N.domEventHandlers({keydown(n,e){return Ef(Df(e.state),n,e,"editor")}})),ft=z.define({enables:Fg}),Tc=new WeakMap;function Df(n){let e=n.facet(ft),t=Tc.get(e);return t||Tc.set(e,t=Vg(e.reduce((i,r)=>i.concat(r),[]))),t}function Lf(n,e,t){return Ef(Df(n.state),e,n,t)}var jt=null,Hg=4e3;function Vg(n,e=Ig){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)),m=l.split(/ (?!$)/).map(v=>zg(v,e));for(let v=1;v<m.length;v++){let S=m.slice(0,v).join(" ");r(S,!0),p[S]||(p[S]={preventDefault:!0,stopPropagation:!1,run:[E=>{let O=jt={view:E,prefix:S,scope:o};return setTimeout(()=>{jt==O&&(jt=null)},Hg),!0}]})}let w=m.join(" ");r(w,!1);let y=p[w]||(p[w]={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 Ef(n,e,t,i){let r=Gh(e),s=Se(r,0),o=Ve(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;jt&&jt.view==t&&jt.scope==i&&(l=jt.prefix+" ",gf.indexOf(e.keyCode)<0&&(h=!0,jt=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],m,w;return p&&(u(p[l+Br(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(W.windows&&e.ctrlKey&&e.altKey)&&(m=Ot[e.keyCode])&&m!=r?(u(p[l+Br(m,e,!0)])||e.shiftKey&&(w=zi[e.keyCode])!=r&&w!=m&&u(p[l+Br(w,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(p[l+Br(r,e,!0)])&&(a=!0),!a&&u(p._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),a}var Pn=class n{constructor(e,t,i,r,s){this.className=e,this.left=t,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=Of(e);return[new n(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return Wg(e,t,i)}};function Of(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==fe.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Cc(n,e,t){let i=D.cursor(e);return{from:Math.max(t.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(t.to,n.moveToLineBoundary(i,!0,!0).from),type:Fe.Text}}function Wg(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),r=Math.min(t.to,n.viewport.to),s=n.textDirection==fe.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=Of(n),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),p=hl(n,i),m=hl(n,r),w=p.type==Fe.Text?p:null,y=m.type==Fe.Text?m:null;if(w&&(n.lineWrapping||p.widgetLineBreaks)&&(w=Cc(n,i,w)),y&&(n.lineWrapping||m.widgetLineBreaks)&&(y=Cc(n,r,y)),w&&y&&w.from==y.from)return S(E(t.from,t.to,w));{let L=w?E(t.from,null,w):O(p,!1),B=y?E(null,t.to,y):O(m,!0),x=[];return(w||p).to<(y||m).from-(w&&y?1:0)||p.widgetLineBreaks>1&&L.bottom+n.defaultLineHeight/2<B.top?x.push(v(f,L.bottom,u,B.top)):L.bottom<B.top&&n.elementAtHeight((L.bottom+B.top)/2).type==Fe.Text&&(L.bottom=B.top=(L.bottom+B.top)/2),S(L).concat(x).concat(S(B))}function v(L,B,x,M){return new Pn(e,L-a.left,B-a.top-.01,x-L,M-B+.01)}function S({top:L,bottom:B,horizontal:x}){let M=[];for(let b=0;b<x.length;b+=2)M.push(v(x[b],L,x[b+1],B));return M}function E(L,B,x){let M=1e9,b=-1e9,Y=[];function K(k,A,T,F,te){let le=n.coordsAtPos(k,k==x.to?-2:2),j=n.coordsAtPos(T,T==x.from?2:-2);!le||!j||(M=Math.min(le.top,j.top,M),b=Math.max(le.bottom,j.bottom,b),te==fe.LTR?Y.push(s&&A?f:le.left,s&&F?u:j.right):Y.push(!s&&F?f:j.left,!s&&A?u:le.right))}let U=L!=null?L:x.from,q=B!=null?B:x.to;for(let k of n.visibleRanges)if(k.to>U&&k.from<q)for(let A=Math.max(k.from,U),T=Math.min(k.to,q);;){let F=n.state.doc.lineAt(A);for(let te of n.bidiSpans(F)){let le=te.from+F.from,j=te.to+F.from;if(le>=T)break;j>A&&K(Math.max(le,A),L==null&&le<=U,Math.min(j,T),B==null&&j>=q,te.dir)}if(A=F.to+1,A>=T)break}return Y.length==0&&K(U,L==null,q,B==null,n.textDirection),{top:M,bottom:b,horizontal:Y}}function O(L,B){let x=l.top+(B?L.top:L.bottom);return{top:x,bottom:x,horizontal:[]}}}function jg(n,e){return n.constructor==e.constructor&&n.eq(e)}var Al=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(zr)!=e.state.facet(zr)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}setOrder(e){let t=0,i=e.facet(zr);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!jg(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},zr=z.define();function Bf(n){return[ye.define(e=>new Al(e,n)),zr.of(n)]}var Pf=!W.ios,Rn=z.define({combine(n){return Pe(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Rf(n={}){return[Rn.of(n),$g,qg,Kg,of.of(!0)]}function Nf(n){return n.startState.facet(Rn)!=n.state.facet(Rn)}var $g=Bf({above:!0,markers(n){let{state:e}=n,t=e.facet(Rn),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||Pf:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:D.cursor(r.head,r.head>r.anchor?-1:1);for(let a of Pn.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Nf(n);return t&&Ac(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Ac(e.state,n)},class:"cm-cursorLayer"});function Ac(n,e){e.style.animationDuration=n.facet(Rn).cursorBlinkRate+"ms"}var qg=Bf({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:Pn.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Nf(n)},class:"cm-selectionLayer"}),Ml={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Pf&&(Ml[".cm-line"].caretColor="transparent !important",Ml[".cm-content"]={caretColor:"transparent !important"});var Kg=gt.highest(N.theme(Ml));function Mc(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 _g(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 Nn=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 mt,i=t.add.bind(t);for(let{from:r,to:s}of _g(e,this.maxLength))Mc(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,m=(w,y,v)=>u.push(v.range(w,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,m);else Mc(e.state.doc,this.regexp,c,f,(w,y)=>this.addMatch(y,e,w,m));t=t.update({filterFrom:c,filterTo:f,filter:(w,y)=>w<c||y>f,add:u})}}return t}},Dl=/x/.unicode!=null?"gu":"g",Ug=new RegExp(`[\0-\b
|
|
10
|
-
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Dl),Gg={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"},_o=null;function Yg(){var n;if(_o==null&&typeof document!="undefined"&&document.body){let e=document.body.style;_o=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return _o||!1}var Fr=z.define({combine(n){let e=Pe(n,{render:null,specialChars:Ug,addSpecialChars:null});return(e.replaceTabs=!Yg())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Dl)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Dl)),e}});function If(n={}){return[Fr.of(n),Jg()]}var Dc=null;function Jg(){return Dc||(Dc=ye.fromClass(class{constructor(n){this.view=n,this.decorations=_.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Fr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Nn({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=Se(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=Wt(o.text,l,i-o.from);return _.replace({widget:new El((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=_.replace({widget:new Ll(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Fr);n.startState.facet(Fr)!=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 Xg="\u2022";function Zg(n){return n>=32?Xg:n==10?"\u2424":String.fromCharCode(9216+n)}var Ll=class extends Je{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Zg(this.code),i=e.state.phrase("Control character")+" "+(Gg[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}},El=class extends Je{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 zf(){return e0}var Qg=_.line({class:"cm-activeLine"}),e0=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(Qg.range(r.from)),e=r.from)}return _.set(t)}},{decorations:n=>n.decorations});var pn="-10000px",Yr=class{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}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,a?o[a-1]:null),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&&(this.removeTooltipView(a),(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 t0(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var Uo=z.define({combine:n=>{var e,t,i;return{position:W.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)||t0}}}),Lc=new WeakMap,Wl=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(Uo);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.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Yr(n,Ut,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),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(Uo);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,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.insertBefore(r,i)}return t.dom.style.position=this.position,t.dom.style.top=pn,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.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(W.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(r.style.top==pn&&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(Uo).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=pn;continue}let p=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,w=u.right-u.left,y=(e=Lc.get(h))!==null&&e!==void 0?e:u.bottom-u.top,v=h.offset||n0,S=this.view.textDirection==fe.LTR,E=u.width>i.right-i.left?S?i.left:i.right-u.width:S?Math.min(f.left-(p?14:0)+v.x,i.right-w):Math.max(i.left,f.left-w+(p?14:0)-v.x),O=this.above[l];!a.strictSide&&(O?f.top-(u.bottom-u.top)-v.y<i.top:f.bottom+(u.bottom-u.top)+v.y>i.bottom)&&O==i.bottom-f.bottom>f.top-i.top&&(O=this.above[l]=!O);let L=(O?f.top-i.top:i.bottom-f.bottom)-m;if(L<y&&h.resize!==!1){if(L<this.view.defaultLineHeight){c.style.top=pn;continue}Lc.set(h,y),c.style.height=(y=L)/s+"px"}else c.style.height&&(c.style.height="");let B=O?f.top-y-m-v.y:f.bottom+m+v.y,x=E+w;if(h.overlap!==!0)for(let M of o)M.left<x&&M.right>E&&M.top<B+y&&M.bottom>B&&(B=O?M.top-y-2-m:M.bottom+m+2);if(this.position=="absolute"?(c.style.top=(B-n.parent.top)/s+"px",c.style.left=(E-n.parent.left)/r+"px"):(c.style.top=B/s+"px",c.style.left=E/r+"px"),p){let M=f.left+(S?v.x:-v.x)-(E+14-7);p.style.left=M/r+"px"}h.overlap!==!0&&o.push({left:E,top:B,right:x,bottom:B+y}),c.classList.toggle("cm-tooltip-above",O),c.classList.toggle("cm-tooltip-below",!O),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=pn}},{eventObservers:{scroll(){this.maybeMeasure()}}}),i0=N.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"}}}),n0={x:0,y:0},Ut=z.define({enables:[Wl,i0]}),Jr=z.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])}),Xr=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 Yr(e,Jr,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}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")}},r0=Ut.compute([Jr],n=>{let e=n.facet(Jr);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:Xr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Ol=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.length)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 Dn)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==fe.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&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>Re(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(Wl),t=e?e.manager.tooltips.findIndex(i=>i.create==Xr.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;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:r,tooltip:s}=this;if(r.length&&s&&!s0(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,l=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!o0(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},Pr=4;function s0(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-Pr&&e.clientX<=t.right+Pr&&e.clientY>=t.top-Pr&&e.clientY<=t.bottom+Pr}function o0(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 Ff(n,e={}){let t=X.define(),i=ce.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let l of r){let a=s.changes.mapPos(l.pos,-1,De.TrackDel);if(a!=null){let h=Object.assign(Object.create(null),l);h.pos=a,h.end!=null&&(h.end=s.changes.mapPos(h.end)),o.push(h)}}r=o}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(l0)&&(r=[]);return r},provide:r=>Jr.from(r)});return[i,ye.define(r=>new Ol(r,n,i,t,e.hoverTime||300)),r0]}function jl(n,e){let t=n.plugin(Wl);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var l0=X.define();var Ec=z.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 mi(n,e){let t=n.plugin(Hf),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var Hf=ye.fromClass(class{constructor(n){this.input=n.state.facet(pi),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Ec);this.top=new Vi(n,!0,e.topContainer),this.bottom=new Vi(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(Ec);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Vi(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Vi(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(pi);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=>N.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Vi=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=Oc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Oc(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 Oc(n){let e=n.nextSibling;return n.remove(),e}var pi=z.define({enables:Hf}),nt=class extends at{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};nt.prototype.elementClass="";nt.prototype.toDOM=void 0;nt.prototype.mapMode=De.TrackBefore;nt.prototype.startSide=nt.prototype.endSide=-1;nt.prototype.point=!0;var Go=z.define(),a0={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Tn=z.define();function $l(n){return[Vf(),Tn.of(Object.assign(Object.assign({},a0),n))]}var Bl=z.define({combine:n=>n.some(e=>e)});function Vf(n){let e=[h0];return n&&n.fixed===!1&&e.push(Bl.of(!0)),e}var h0=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(Tn).map(e=>new Zr(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(Bl),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(Bl)!=!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(Go),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Rl(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==Fe.Text&&o){Pl(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==Fe.Text){Pl(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(Tn),t=n.state.facet(Tn),i=n.docChanged||n.heightChanged||n.viewportChanged||!ie.eq(n.startState.facet(Go),n.state.facet(Go),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 Zr(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=>N.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==fe.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function Bc(n){return Array.isArray(n)?n:[n]}function Pl(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var Rl=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 Qr(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=[];Pl(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()}}},Zr=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=Bc(t.markers(e)),t.initialSpacer&&(this.spacer=new Qr(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=Bc(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()}},Qr=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":""),c0(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 c0(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 f0=z.define(),Wi=z.define({combine(n){return Pe(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}})}}),Cn=class extends nt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Yo(n,e){return n.state.facet(Wi).formatNumber(e,n.state)}var u0=Tn.compute([Wi],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(f0)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new Cn(Yo(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Wi)!=e.state.facet(Wi),initialSpacer(e){return new Cn(Yo(e,Pc(e.state.doc.lines)))},updateSpacer(e,t){let i=Yo(t.view,Pc(t.view.state.doc.lines));return i==e.number?e:new Cn(i)},domEventHandlers:n.facet(Wi).domEventHandlers}));function Wf(n={}){return[Wi.of(n),Vf(),u0]}function Pc(n){let e=9;for(;e<n;)e=e*10+9;return e}var Rc=new Map;function d0(n){let e=Rc.get(n);return e||Rc.set(n,e=_.mark({attributes:n===" "?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":n.replace(/ /g,"\xB7")}})),e}function jf(n){return ye.define(e=>({decorations:n.createDeco(e),update(t){this.decorations=n.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}var p0=jf(new Nn({regexp:/\t| +/g,decoration:n=>d0(n[0]),boundary:/\S/}));function $f(){return p0}var m0=jf(new Nn({regexp:/\s+$/g,decoration:_.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function qf(){return m0}var g0=0,In=class{constructor(e,t){this.from=e,this.to=t}},Z=class{constructor(e={}){this.id=g0++,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=He.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};Z.closedBy=new Z({deserialize:n=>n.split(" ")});Z.openedBy=new Z({deserialize:n=>n.split(" ")});Z.group=new Z({deserialize:n=>n.split(" ")});Z.contextHash=new Z({perNode:!0});Z.lookAhead=new Z({perNode:!0});Z.mounted=new Z({perNode:!0});var qi=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[Z.mounted.id]}},b0=Object.create(null),He=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):b0,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(Z.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(Z.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};He.none=new He("",Object.create(null),0,8);var rs=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 He(i.name,r,i.id,i.flags):i)}return new n(t)}},is=new WeakMap,Kf=new WeakMap,Te;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(Te||(Te={}));var be=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=qi.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 Hn(this.topNode,e)}cursorAt(e,t=0,i=0){let r=is.get(this)||this.topNode,s=new Hn(r);return s.moveTo(e,t),is.set(this,s._tree),s}get topNode(){return new xt(this,0,0,null)}resolve(e,t=0){let i=zn(is.get(this)||this.topNode,e,t,!1);return is.set(this,i),i}resolveInner(e,t=0){let i=zn(Kf.get(this)||this.topNode,e,t,!0);return Kf.set(this,i),i}resolveStack(e,t=0){return y0(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&Te.IncludeAnonymous)>0;for(let a=this.cursor(o|Te.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:Jl(He.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(He.none,t,i,r)))}static build(e){return k0(e)}};be.empty=new be(He.none,[],[],0);var ql=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)}},Gt=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return He.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&&!(Gf(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 Gf(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 zn(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 xt&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:Te.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof xt&&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 ss=class{cursor(e=0){return new Hn(this,e)}getChild(e,t=null,i=null){let r=_f(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return _f(this,e,t,i)}resolve(e,t=0){return zn(this,e,t,!1)}resolveInner(e,t=0){return zn(this,e,t,!0)}matchContext(e){return Kl(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}},xt=class n extends ss{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(Gf(r,i,f,f+c.length)){if(c instanceof Gt){if(s&Te.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,r);if(u>-1)return new Fn(new _l(o,c,e,f),null,u)}else if(s&Te.IncludeAnonymous||!c.type.isAnonymous||Yl(c)){let u;if(!(s&Te.IgnoreMounts)&&(u=qi.get(c))&&!u.overlay)return new n(u.tree,f,e,o);let p=new n(c,f,e,o);return s&Te.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(s&Te.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&Te.IgnoreOverlays)&&(r=qi.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 _f(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 Kl(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 _l=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Fn=class n extends ss{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&Te.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 be(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Yf(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 xt&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new Ul(r,t)}var Ul=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Yf(this.heads)}};function y0(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof xt?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=qi.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new xt(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(zn(l,e,t,!1))}}return r?Yf(r):i}var Hn=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 xt)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 xt?(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&Te.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Te.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Te.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&Te.IncludeAnonymous||l instanceof Gt||!l.type.isAnonymous||Yl(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 Fn(this.buffer,t,this.stack[r]);return this.bufferNode=new Fn(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 Kl(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 Kl(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 Yl(n){return n.children.some(e=>e instanceof Gt||!e.type.isAnonymous||Yl(e))}function k0(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new ql(t,t.length):t,a=i.types,h=0,c=0;function f(L,B,x,M,b,Y){let{id:K,start:U,end:q,size:k}=l,A=c;for(;k<0;)if(l.next(),k==-1){let j=s[K];x.push(j),M.push(U-L);return}else if(k==-3){h=K;return}else if(k==-4){c=K;return}else throw new RangeError(`Unrecognized record size: ${k}`);let T=a[K],F,te,le=U-L;if(q-U<=r&&(te=y(l.pos-B,b))){let j=new Uint16Array(te.size-te.skip),$=l.pos-te.size,J=j.length;for(;l.pos>$;)J=v(te.start,j,J);F=new Gt(j,q-te.start,i),le=te.start-L}else{let j=l.pos-k;l.next();let $=[],J=[],de=K>=o?K:-1,It=0,re=q;for(;l.pos>j;)de>=0&&l.id==de&&l.size>=0?(l.end<=re-r&&(m($,J,U,It,l.end,re,de,A),It=$.length,re=l.end),l.next()):Y>2500?u(U,j,$,J):f(U,j,$,J,de,Y+1);if(de>=0&&It>0&&It<$.length&&m($,J,U,It,U,re,de,A),$.reverse(),J.reverse(),de>-1&&It>0){let Oe=p(T);F=Jl(T,$,J,0,$.length,0,q-U,Oe,Oe)}else F=w(T,$,J,q-U,A-q)}x.push(F),M.push(le)}function u(L,B,x,M){let b=[],Y=0,K=-1;for(;l.pos>B;){let{id:U,start:q,end:k,size:A}=l;if(A>4)l.next();else{if(K>-1&&q<K)break;K<0&&(K=k-r),b.push(U,q,k),Y++,l.next()}}if(Y){let U=new Uint16Array(Y*4),q=b[b.length-2];for(let k=b.length-3,A=0;k>=0;k-=3)U[A++]=b[k],U[A++]=b[k+1]-q,U[A++]=b[k+2]-q,U[A++]=A;x.push(new Gt(U,b[2]-q,i)),M.push(q-L)}}function p(L){return(B,x,M)=>{let b=0,Y=B.length-1,K,U;if(Y>=0&&(K=B[Y])instanceof be){if(!Y&&K.type==L&&K.length==M)return K;(U=K.prop(Z.lookAhead))&&(b=x[Y]+K.length+U)}return w(L,B,x,M,b)}}function m(L,B,x,M,b,Y,K,U){let q=[],k=[];for(;L.length>M;)q.push(L.pop()),k.push(B.pop()+x-b);L.push(w(i.types[K],q,k,Y-b,U-Y)),B.push(b-x)}function w(L,B,x,M,b=0,Y){if(h){let K=[Z.contextHash,h];Y=Y?[K].concat(Y):[K]}if(b>25){let K=[Z.lookAhead,b];Y=Y?[K].concat(Y):[K]}return new be(L,B,x,M,Y)}function y(L,B){let x=l.fork(),M=0,b=0,Y=0,K=x.end-r,U={size:0,start:0,skip:0};e:for(let q=x.pos-L;x.pos>q;){let k=x.size;if(x.id==B&&k>=0){U.size=M,U.start=b,U.skip=Y,Y+=4,M+=4,x.next();continue}let A=x.pos-k;if(k<0||A<q||x.start<K)break;let T=x.id>=o?4:0,F=x.start;for(x.next();x.pos>A;){if(x.size<0)if(x.size==-3)T+=4;else break e;else x.id>=o&&(T+=4);x.next()}b=F,M+=k,Y+=T}return(B<0||M==L)&&(U.size=M,U.start=b,U.skip=Y),U.size>4?U:void 0}function v(L,B,x){let{id:M,start:b,end:Y,size:K}=l;if(l.next(),K>=0&&M<o){let U=x;if(K>4){let q=l.pos-(K-4);for(;l.pos>q;)x=v(L,B,x)}B[--x]=U,B[--x]=Y-L,B[--x]=b-L,B[--x]=M}else K==-3?h=M:K==-4&&(c=M);return x}let S=[],E=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,S,E,-1,0);let O=(e=n.length)!==null&&e!==void 0?e:S.length?E[0]+S[0].length:0;return new be(a[n.topID],S.reverse(),E.reverse(),O)}var Uf=new WeakMap;function ns(n,e){if(!n.isAnonymous||e instanceof Gt||e.type!=n)return 1;let t=Uf.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof be)){t=1;break}t+=ns(n,i)}Uf.set(e,t)}return t}function Jl(n,e,t,i,r,s,o,l,a){let h=0;for(let m=i;m<r;m++)h+=ns(n,e[m]);let c=Math.ceil(h*1.5/8),f=[],u=[];function p(m,w,y,v,S){for(let E=y;E<v;){let O=E,L=w[E],B=ns(n,m[E]);for(E++;E<v;E++){let x=ns(n,m[E]);if(B+x>=c)break;B+=x}if(E==O+1){if(B>c){let x=m[O];p(x.children,x.positions,0,x.children.length,w[O]+S);continue}f.push(m[O])}else{let x=w[E-1]+m[E-1].length-L;f.push(Jl(n,m,w,O,E,L,x,null,a))}u.push(L+S-s)}}return p(e,t,i,r,0),(l||a)(f,u,o)}var gi=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,m=Math.min(u.to,f)-h;u=p>=m?null:new n(p,m,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}},Vn=class{startParse(e,t,i){return typeof e=="string"&&(e=new Gl(e)),i=i?i.length?i.map(r=>new In(r.from,r.to)):[new In(0,0)]:[new In(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}}},Gl=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 Jk=new Z({perNode:!0});var w0=0,je=class n{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=w0++}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 hs;return t=>t.modified.indexOf(e)>-1?t:hs.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}},x0=0,hs=class n{constructor(){this.instances=[],this.id=x0++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&v0(t,l.modified));if(i)return i;let r=[],s=new je(r,e,t);for(let l of t)l.instances.push(s);let o=S0(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 v0(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function S0(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 Zf(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 Ki(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return Qf.add(e)}var Qf=new Z,Ki=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}};Ki.empty=new Ki([],2,null);function ea(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 T0(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function eu(n,e,t,i=0,r=n.length){let s=new Zl(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var Zl=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=C0(e)||Ki.empty,f=T0(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(Z.mounted);if(u&&u.overlay){let p=e.node.enter(u.overlay[0].from+l,1),m=this.highlighters.filter(y=>!y.scope||y.scope(u.tree.type)),w=e.firstChild();for(let y=0,v=l;;y++){let S=y<u.overlay.length?u.overlay[y]:null,E=S?S.from+l:a,O=Math.max(t,v),L=Math.min(i,E);if(O<L&&w)for(;e.from<L&&(this.highlightRange(e,O,L,r,s),this.startSpan(Math.min(L,e.to),h),!(e.to>=E||!e.nextSibling())););if(!S||E>i)break;v=S.to+l,v>t&&(this.highlightRange(p.cursor(),Math.max(t,S.from+l),Math.min(i,v),"",m),this.startSpan(Math.min(i,v),h))}w&&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 C0(n){let e=n.type.prop(Qf);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var P=je.define,os=P(),Yt=P(),Jf=P(Yt),Xf=P(Yt),Jt=P(),ls=P(Jt),Xl=P(Jt),Tt=P(),bi=P(Tt),vt=P(),St=P(),Ql=P(),Wn=P(Ql),as=P(),I={comment:os,lineComment:P(os),blockComment:P(os),docComment:P(os),name:Yt,variableName:P(Yt),typeName:Jf,tagName:P(Jf),propertyName:Xf,attributeName:P(Xf),className:P(Yt),labelName:P(Yt),namespace:P(Yt),macroName:P(Yt),literal:Jt,string:ls,docString:P(ls),character:P(ls),attributeValue:P(ls),number:Xl,integer:P(Xl),float:P(Xl),bool:P(Jt),regexp:P(Jt),escape:P(Jt),color:P(Jt),url:P(Jt),keyword:vt,self:P(vt),null:P(vt),atom:P(vt),unit:P(vt),modifier:P(vt),operatorKeyword:P(vt),controlKeyword:P(vt),definitionKeyword:P(vt),moduleKeyword:P(vt),operator:St,derefOperator:P(St),arithmeticOperator:P(St),logicOperator:P(St),bitwiseOperator:P(St),compareOperator:P(St),updateOperator:P(St),definitionOperator:P(St),typeOperator:P(St),controlOperator:P(St),punctuation:Ql,separator:P(Ql),bracket:Wn,angleBracket:P(Wn),squareBracket:P(Wn),paren:P(Wn),brace:P(Wn),content:Tt,heading:bi,heading1:P(bi),heading2:P(bi),heading3:P(bi),heading4:P(bi),heading5:P(bi),heading6:P(bi),contentSeparator:P(Tt),list:P(Tt),quote:P(Tt),emphasis:P(Tt),strong:P(Tt),link:P(Tt),monospace:P(Tt),strikethrough:P(Tt),inserted:P(),deleted:P(),changed:P(),invalid:P(),meta:as,documentMeta:P(as),annotation:P(as),processingInstruction:P(as),definition:je.defineModifier(),constant:je.defineModifier(),function:je.defineModifier(),standard:je.defineModifier(),local:je.defineModifier(),special:je.defineModifier()},Qk=ea([{tag:I.link,class:"tok-link"},{tag:I.heading,class:"tok-heading"},{tag:I.emphasis,class:"tok-emphasis"},{tag:I.strong,class:"tok-strong"},{tag:I.keyword,class:"tok-keyword"},{tag:I.atom,class:"tok-atom"},{tag:I.bool,class:"tok-bool"},{tag:I.url,class:"tok-url"},{tag:I.labelName,class:"tok-labelName"},{tag:I.inserted,class:"tok-inserted"},{tag:I.deleted,class:"tok-deleted"},{tag:I.literal,class:"tok-literal"},{tag:I.string,class:"tok-string"},{tag:I.number,class:"tok-number"},{tag:[I.regexp,I.escape,I.special(I.string)],class:"tok-string2"},{tag:I.variableName,class:"tok-variableName"},{tag:I.local(I.variableName),class:"tok-variableName tok-local"},{tag:I.definition(I.variableName),class:"tok-variableName tok-definition"},{tag:I.special(I.variableName),class:"tok-variableName2"},{tag:I.definition(I.propertyName),class:"tok-propertyName tok-definition"},{tag:I.typeName,class:"tok-typeName"},{tag:I.namespace,class:"tok-namespace"},{tag:I.className,class:"tok-className"},{tag:I.macroName,class:"tok-macroName"},{tag:I.propertyName,class:"tok-propertyName"},{tag:I.operator,class:"tok-operator"},{tag:I.comment,class:"tok-comment"},{tag:I.meta,class:"tok-meta"},{tag:I.invalid,class:"tok-invalid"},{tag:I.punctuation,class:"tok-punctuation"}]);var ta,_i=new Z;function A0(n){return z.define({combine:n?e=>e.concat(n):void 0})}var M0=new Z,$e=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,se.prototype.hasOwnProperty("tree")||Object.defineProperty(se.prototype,"tree",{get(){return Ce(this)}}),this.parser=t,this.extension=[Ui.of(this),se.languageData.of((s,o,l)=>{let a=tu(s,o,l),h=a.type.prop(_i);if(!h)return[];let c=s.facet(h),f=a.type.prop(M0);if(f){let u=a.resolve(o-a.from,l);for(let p of f)if(p.test(u,s)){let m=s.facet(p.facet);return p.type=="replace"?m:m.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return tu(e,t,i).type.prop(_i)==this.data}findRegions(e){let t=e.facet(Ui);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(_i)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(Z.mounted);if(l){if(l.tree.prop(_i)==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 be&&r(h,s.positions[a]+o)}};return r(Ce(e),0),i}get allowsNesting(){return!0}};$e.setState=X.define();function tu(n,e,t){let i=n.facet(Ui),r=Ce(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,Te.ExcludeBuffers))s.type.isTop&&(r=s);return r}function Ce(n){let e=n.field($e.state,!1);return e?e.tree:be.empty}function Pt(n,e,t=50){var i;let r=(i=n.field($e.state,!1))===null||i===void 0?void 0:i.context;if(!r)return null;let s=r.viewport;r.updateViewport({from:0,to:e});let o=r.isDone(e)||r.work(t,e)?r.tree:null;return r.updateViewport(s),o}var sa=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)}},jn=null,$n=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,[],be.empty,0,i,[],null)}startParse(){return this.parser.startParse(new sa(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=be.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(gi.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(gi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=jn;jn=this;try{return e()}finally{jn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=iu(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=gi.applyChanges(i,a),r=be.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=iu(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 Vn{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=jn;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 be(He.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 jn}};function iu(n,e,t){return gi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var qn=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=$n.create(e.facet(Ui).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};$e.state=ce.define({create:qn.init,update(n,e){for(let t of e.effects)if(t.is($e.setState))return t.value;return e.startState.facet(Ui)!=e.state.facet(Ui)?qn.init(e.state):n.apply(e)}});var au=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(au=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var ia=typeof navigator!="undefined"&&(!((ta=navigator.scheduling)===null||ta===void 0)&&ta.isInputPending)?()=>navigator.scheduling.isInputPending():null,D0=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($e.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($e.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=au(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($e.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!ia?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>ia&&ia()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:$e.setState.of(new qn(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=>Re(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()}}}),Ui=z.define({combine(n){return n.length?n[0]:null},enables:n=>[$e.state,D0,N.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Gi=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var hu=z.define(),Zt=z.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 Xt(n){let e=n.facet(Zt);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Xi(n,e){let t="",i=n.tabSize,r=n.facet(Zt)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function us(n,e){n instanceof se&&(n=new yi(n));for(let i of n.state.facet(hu)){let r=i(n,e);if(r!==void 0)return r}let t=Ce(n.state);return t.length>=e?E0(n,t,e):null}var yi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Xt(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 Wt(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}},L0=new Z;function E0(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 cu(i,n,t)}function cu(n,e,t){for(let i=n;i;i=i.next){let r=B0(i.node);if(r)return r(oa.create(e,t,i))}return 0}function O0(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function B0(n){let e=n.type.prop(L0);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(Z.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>I0(o,!0,1,void 0,s&&!O0(o)?r.from:void 0)}return n.parent==null?P0:null}function P0(){return 0}var oa=class n extends yi{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(R0(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return cu(this.context.next,this.base,this.pos)}};function R0(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function N0(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 I0(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?N0(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var z0=200;function fu(){return se.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+z0)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=us(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],p=Xi(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})}function uu(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}var ds=X.define({map:uu}),Zi=X.define({map:uu});var ps=ce.define({create(){return _.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)if(t.is(ds)&&!H0(n,t.value.from,t.value.to)){let{preparePlaceholder:i}=e.state.facet(da),r=i?_.replace({widget:new la(i(e.state,t.value))}):nu;n=n.update({add:[r.range(t.value.from,t.value.to)]})}else t.is(Zi)&&(n=n.update({filter:(i,r)=>t.value.from!=i||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(r,s)=>{r<i&&s>i&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(r,s)=>s<=i||r>=i}))}return n},provide:n=>N.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,r)=>{t.push(i,r)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let i=n[t++],r=n[t++];if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(nu.range(i,r))}return _.set(e,!0)}});function ms(n){return n.field(ps,!1)||ie.empty}function F0(n,e,t){var i;let r=null;return(i=n.field(ps,!1))===null||i===void 0||i.between(e,t,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function H0(n,e,t){let i=!1;return n.between(e,e,(r,s)=>{r==e&&s==t&&(i=!0)}),i}var du=n=>{let e=n.state.field(ps,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,r)=>{t.push(Zi.of({from:i,to:r}))}),n.dispatch({effects:t}),!0};var V0={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},da=z.define({combine(n){return Pe(n,V0)}});function pu(n){let e=[ps,W0];return n&&e.push(da.of(n)),e}function mu(n,e){let{state:t}=n,i=t.facet(da),r=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=F0(n.state,l.from,l.to);a&&n.dispatch({effects:Zi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}var nu=_.replace({widget:new class extends Je{toDOM(n){return mu(n,null)}}}),la=class extends Je{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return mu(e,this.value)}};var W0=N.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),Yi=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=tt.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 $e?l=>l.prop(_i)==o.data:o?l=>l==o:void 0,this.style=ea(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new tt(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},aa=z.define(),gu=z.define({combine(n){return n.length?[n[0]]:null}});function na(n){let e=n.facet(aa);return e.length?e:n.facet(gu)}function gs(n,e){let t=[j0],i;return n instanceof Yi&&(n.module&&t.push(N.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(gu.of(n)):i?t.push(aa.computeN([N.darkTheme],r=>r.facet(N.darkTheme)==(i=="dark")?[n]:[])):t.push(aa.of(n)),t}var ha=class{constructor(e){this.markCache=Object.create(null),this.tree=Ce(e.state),this.decorations=this.buildDeco(e,na(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ce(e.state),i=na(e.state),r=i!=na(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return _.none;let i=new mt;for(let{from:r,to:s}of e.visibleRanges)eu(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=_.mark({class:a})))},r,s);return i.finish()}},j0=gt.high(ye.fromClass(ha,{decorations:n=>n.decorations})),bu=Yi.define([{tag:I.meta,color:"#404740"},{tag:I.link,textDecoration:"underline"},{tag:I.heading,textDecoration:"underline",fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strong,fontWeight:"bold"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.keyword,color:"#708"},{tag:[I.atom,I.bool,I.url,I.contentSeparator,I.labelName],color:"#219"},{tag:[I.literal,I.inserted],color:"#164"},{tag:[I.string,I.deleted],color:"#a11"},{tag:[I.regexp,I.escape,I.special(I.string)],color:"#e40"},{tag:I.definition(I.variableName),color:"#00f"},{tag:I.local(I.variableName),color:"#30a"},{tag:[I.typeName,I.namespace],color:"#085"},{tag:I.className,color:"#167"},{tag:[I.special(I.variableName),I.macroName],color:"#256"},{tag:I.definition(I.propertyName),color:"#00c"},{tag:I.comment,color:"#940"},{tag:I.invalid,color:"#f00"}]),$0=N.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),yu=1e4,ku="()[]{}",wu=z.define({combine(n){return Pe(n,{afterCursor:!0,brackets:ku,maxScanDistance:yu,renderMatch:_0})}}),q0=_.mark({class:"cm-matchingBracket"}),K0=_.mark({class:"cm-nonmatchingBracket"});function _0(n){let e=[],t=n.matched?q0:K0;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 U0=ce.define({create(){return _.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(wu);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=ut(e.state,r.head,-1,i)||r.head>0&&ut(e.state,r.head-1,1,i)||i.afterCursor&&(ut(e.state,r.head,1,i)||r.head<e.state.doc.length&&ut(e.state,r.head+1,-1,i));s&&(t=t.concat(i.renderMatch(s,e.state)))}return _.set(t,!0)},provide:n=>N.decorations.from(n)}),G0=[U0,$0];function xu(n={}){return[wu.of(n),G0]}var Y0=new Z;function ca(n,e,t){let i=n.prop(e<0?Z.openedBy:Z.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 fa(n){let e=n.type.prop(Y0);return e?e(n.node):n}function ut(n,e,t,i={}){let r=i.maxScanDistance||yu,s=i.brackets||ku,o=Ce(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=ca(a.type,t,s);if(h&&a.from<a.to){let c=fa(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return J0(n,e,t,a,c,h,s)}}return X0(n,e,t,o,l.type,r,s)}function J0(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=fa(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(ca(c.type,t,o))h++;else if(ca(c.type,-t,o)){if(h==0){let f=fa(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 X0(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 m=e+u*t;for(let w=t>0?0:p.length-1,y=t>0?p.length:-1;w!=y;w+=t){let v=o.indexOf(p[w]);if(!(v<0||i.resolveInner(m+w,1).type!=r))if(v%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:m+w,to:m+w+1},matched:v>>1==a>>1};f--}}t>0&&(u+=p.length)}return c.done?{start:h,matched:!1}:null}function ru(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 cs=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=ru(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:ru(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 Z0(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||Q0,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||ma}}function Q0(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 su=new WeakMap,Ji=class n extends $e{constructor(e){let t=A0(e.languageData),i=Z0(e),r,s=new class extends Vn{createParse(o,l,a){return new ua(r,o,l,a)}};super(t,s,[hu.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=nb(t),r=this,this.streamParser=i,this.stateAfter=new Z({perNode:!0}),this.tokenTable=e.tokenTable?new fs(i.tokenTable):ib}static define(e){return new n(e)}getIndent(e,t){let i=Ce(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=su.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let l=pa(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,m=new cs(f.text,e.state.tabSize,e.unit,p<0?void 0:p);for(;m.pos<u-f.from;)Su(this.streamParser.token,m,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&&su.set(e.state,c.from),this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],e)}get allowsNesting(){return!1}};function pa(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 be&&a<r&&pa(n,l,a,i,r);if(h)return h}return null}function vu(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 be){if(!(a=vu(n,l,t-o,i-o,r)))break;return r?new be(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function eb(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&&pa(n,r.tree,0-r.offset,t,o),a;if(l&&(a=vu(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:a}}return{state:n.streamParser.startState(i?Xt(i):4),tree:be.empty}}var ua=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=$n.get(),o=r[0].from,{state:l,tree:a}=eb(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(Xt(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=$n.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==`
|
|
3
|
+
`){[e,t]=Ii(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 m of e)m.flatten(p);return new Ue(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 m;if(p.lines>s&&p instanceof n)for(let w of p.children)f(w);else p.lines>o&&(a>o||!a)?(u(),l.push(p)):p instanceof Ue&&a&&(m=c[c.length-1])instanceof Ue&&p.lines+m.lines<=32?(a+=p.lines,h+=p.length+1,c[c.length-1]=new Ue(m.text.concat(p.text),m.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)}};Q.empty=new Ue([""],0);function pm(n){let e=-1;for(let t of n)e+=t.length+1;return e}function yr(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 Th(n,e,t){return yr(n,[""],e,t)}var ci=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 Ue?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 Ue?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 Ue){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 Ue?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)}},kr=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new ci(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!=""}},wr=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"&&(Q.prototype[Symbol.iterator]=function(){return this.iter()},ci.prototype[Symbol.iterator]=kr.prototype[Symbol.iterator]=wr.prototype[Symbol.iterator]=function(){return this});var Co=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 Ii(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}var Pi="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<Pi.length;n++)Pi[n]+=Pi[n-1];function mm(n){for(let e=1;e<Pi.length;e+=2)if(Pi[e]>n)return Pi[e-1]<=n;return!1}function Ch(n){return n>=127462&&n<=127487}var Ah=8205;function ke(n,e,t=!0,i=!0){return(t?Bh:gm)(n,e,i)}function Bh(n,e,t){if(e==n.length)return e;e&&Ph(n.charCodeAt(e))&&Rh(n.charCodeAt(e-1))&&e--;let i=Se(n,e);for(e+=Ve(i);e<n.length;){let r=Se(n,e);if(i==Ah||r==Ah||t&&mm(r))e+=Ve(r),i=r;else if(Ch(r)){let s=0,o=e-2;for(;o>=0&&Ch(Se(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function gm(n,e,t){for(;e>0;){let i=Bh(n,e-2,t);if(i<e)return i;e--}return 0}function Ph(n){return n>=56320&&n<57344}function Rh(n){return n>=55296&&n<56320}function Se(n,e){let t=n.charCodeAt(e);if(!Rh(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Ph(i)?(t-55296<<10)+(i-56320)+65536:t}function dn(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Ve(n){return n<65536?1:2}var Ao=/\r\n?|\n/,Le=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(Le||(Le={})),Et=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){Mo(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:Nh(this,e)}mapDesc(e,t=!1){return e.empty?this:Lo(this,e,t)}mapPos(e,t=-1,i=Le.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!=Le.Simple&&h>=e&&(i==Le.TrackDel&&r<e&&h>e||i==Le.TrackBefore&&r<e||i==Le.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)}},Ie=class n extends Et{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 Mo(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Lo(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(Q.empty);i.push(o?e.slice(s,s+o):Q.empty)}s+=o}return new n(t,i)}compose(e){return this.empty?e:e.empty?this:Nh(this,e,!0)}map(e,t=!1){return e.empty?this:Lo(this,e,t,!0)}iterChanges(e,t=!1){Mo(this,e,t)}get desc(){return Et.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new fi(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);Be(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Be(t,c,f),f>0&&Ht(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);Be(t,c,-1),Be(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new n(t,i),filtered:Et.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&&Be(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 m=p?typeof p=="string"?Q.of(p.split(i||Ao)):p:Q.empty,w=m.length;if(f==u&&w==0)return;f<o&&a(),f>o&&Be(r,f-o,-1),Be(r,u-f,w),Ht(s,r,m),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(Q.empty);i[r]=Q.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 Be(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 Ht(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(Q.empty);n.push(t)}}function Mo(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=Q.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 Lo(n,e,t,i=!1){let r=[],s=i?[]:null,o=new fi(n),l=new fi(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Be(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(Be(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Be(r,0,o.ins),s&&Ht(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;Be(r,h,a<o.i?o.ins:0),s&&a<o.i&&Ht(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?Ie.createSet(r,s):Et.create(r);throw new Error("Mismatched change set lengths")}}function Nh(n,e,t=!1){let i=[],r=t?[]:null,s=new fi(n),o=new fi(e);for(let l=!1;;){if(s.done&&o.done)return r?Ie.createSet(i,r):Et.create(i);if(s.ins==0)Be(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Be(i,0,o.ins,l),r&&Ht(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;Be(i,a,c,l),r&&c&&Ht(r,i,o.text)}else o.ins==-1?(Be(i,s.off?0:s.len,a,l),r&&Ht(r,i,s.textBit(a))):(Be(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Ht(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 fi=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?Q.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Q.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)}},Vt=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,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return 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,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],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=>Vt.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 Vt.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?Vt.create(t,e,48|s):Vt.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 Ih(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Fo=0,z=class n{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Fo++,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:Ho),!!e.static,e.enables)}of(e){return new Ri([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ri(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ri(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Ho(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}var Ri=class{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Fo++}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)||Do(f,c)){let p=i(f);if(l?!Mh(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,u)=>{let p,m=u.config.address[s];if(m!=null){let w=Sr(u,m);if(this.dependencies.every(y=>y instanceof z?u.facet(y)===f.facet(y):y instanceof ce?u.field(y,!1)==f.field(y,!1):!0)||(l?Mh(p=i(f),w,r):r(p=i(f),w)))return f.values[o]=w,0}else p=i(f);return f.values[o]=p,1}}}};function Mh(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 Do(n,e){let t=!1;for(let i of e)hn(n,i)&1&&(t=!0);return t}function bm(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=Sr(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)hn(a,h);return a.values[o]=l(a),1},update(a,h){if(!Do(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=Do(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Ho(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 Lh=z.define({static:!0}),ce=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(Fo++,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(Lh).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,Lh.of({field:this,create:e})]}get extension(){return this}},ai={lowest:4,low:3,default:2,high:1,highest:0};function an(n){return e=>new xr(e,n)}var gt={highest:an(ai.highest),high:an(ai.high),default:an(ai.default),low:an(ai.low),lowest:an(ai.lowest)},xr=class{constructor(e,t){this.inner=e,this.prec=t}},lt=class n{of(e){return new cn(this,e)}reconfigure(e){return n.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},cn=class{constructor(e,t){this.compartment=e,this.inner=t}},vr=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 ym(e,t,o))u instanceof ce?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],m=p[0].facet,w=c&&c[u]||[];if(p.every(y=>y.type==0))if(l[m.id]=a.length<<1|1,Ho(w,p))a.push(i.facet(m));else{let y=m.combine(p.map(v=>v.value));a.push(i&&m.compare(y,i.facet(m))?i.facet(m):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[m.id]=h.length<<1,h.push(y=>bm(y,m,p))}}let f=h.map(u=>u(l));return new n(e,o,f,l,a,s)}};function ym(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 cn&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof cn){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 xr)s(o.inner,o.prec);else if(o instanceof ce)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Ri)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,ai.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,ai.default),i.reduce((o,l)=>o.concat(l))}function hn(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 Sr(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}var zh=z.define(),Eo=z.define({combine:n=>n.some(e=>e),static:!0}),Fh=z.define({combine:n=>n.length?n[0]:void 0,static:!0}),Hh=z.define(),Vh=z.define(),Wh=z.define(),jh=z.define({combine:n=>n.length?n[0]:!1}),We=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Oo}},Oo=class{of(e){return new We(this,e)}},Bo=class{constructor(e){this.map=e}of(e){return new X(this,e)}},X=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 Bo(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}};X.reconfigure=X.define();X.appendConfig=X.define();var ve=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&&Ih(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]=="."))}};ve.time=We.define();ve.userEvent=We.define();ve.addToHistory=We.define();ve.remote=We.define();function km(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 $h(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=Ie.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:X.mapEffects(n.effects,r).concat(X.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function Po(n,e,t){let i=e.selection,r=Ni(e.annotations);return e.userEvent&&(r=r.concat(ve.userEvent.of(e.userEvent))),{changes:e.changes instanceof Ie?e.changes:Ie.of(e.changes||[],t,n.facet(Fh)),selection:i&&(i instanceof L?i:L.single(i.anchor,i.head)),effects:Ni(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function qh(n,e,t){let i=Po(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=$h(i,Po(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=ve.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return xm(t?wm(r):r)}function wm(n){let e=n.startState,t=!0;for(let r of e.facet(Hh)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:km(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=Ie.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=ve.create(e,r,n.selection&&n.selection.map(s),X.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(Vh);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof ve?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ve?n=s[0]:n=qh(e,Ni(s),!1)}return n}function xm(n){let e=n.startState,t=e.facet(Wh),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=$h(i,Po(e,s,n.changes.newLength),!0))}return i==n?n:ve.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}var vm=[];function Ni(n){return n==null?vm:Array.isArray(n)?n:[n]}var me=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(me||(me={})),Sm=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ro;try{Ro=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(n){}function Tm(n){if(Ro)return Ro.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"\x80"&&(t.toUpperCase()!=t.toLowerCase()||Sm.test(t)))return!0}return!1}function Cm(n){return e=>{if(!/\S/.test(e))return me.Space;if(Tm(e))return me.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return me.Word;return me.Other}}var se=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++)hn(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 hn(this,i),Sr(this,i)}update(...e){return qh(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(lt.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(X.reconfigure)?(t=null,i=l.value):l.is(X.appendConfig)&&(t=null,i=Ni(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=vr.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(Eo)?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=Ni(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=X.mapEffects(o,c).concat(X.mapEffects(Ni(a.effects),f))}return{changes:r,selection:L.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Ie?e:Ie.of(e,this.doc.length,this.facet(n.lineSeparator))}toText(e){return Q.of(e.split(this.facet(n.lineSeparator)||Ao))}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:(hn(this,t),Sr(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 ce&&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=vr.resolve(e.extensions||[],new Map),i=e.doc instanceof Q?e.doc:Q.of((e.doc||"").split(t.staticFacet(n.lineSeparator)||Ao)),r=e.selection?e.selection instanceof L?e.selection:L.single(e.selection.anchor,e.selection.head):L.single(0);return Ih(r,i.length),t.staticFacet(Eo)||(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(jh)}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(zh))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return Cm(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=ke(t,o,!1);if(s(t.slice(a,o))!=me.Word)break;o=a}for(;l<r;){let a=ke(t,l);if(s(t.slice(l,a))!=me.Word)break;l=a}return o==l?null:L.range(o+i,l+i)}};se.allowMultipleSelections=Eo;se.tabSize=z.define({combine:n=>n.length?n[0]:4});se.lineSeparator=Fh;se.readOnly=jh;se.phrases=z.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])}});se.languageData=zh;se.changeFilter=Hh;se.transactionFilter=Vh;se.transactionExtender=Wh;lt.reconfigure=X.define();function Pe(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 at=class{eq(e){return this==e}range(e,t=e){return fn.create(e,t,this)}};at.prototype.startSide=at.prototype.endSide=0;at.prototype.point=!1;at.prototype.mapMode=Le.TrackDel;var fn=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 No(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}var Io=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 m=t.mapPos(c,h.startSide,h.mapMode);if(m==null||(u=p=m,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(No)),this.isEmpty)return t.length?n.of(t):this;let l=new Tr(this,null,-1).goto(0),a=0,h=[],c=new mt;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(fn.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 un.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return un.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=Dh(o,l,i),h=new hi(o,a,s),c=new hi(l,a,s);i.iterGaps((f,u,p)=>Eh(h,f,c,u,p,r)),i.empty&&i.length==0&&Eh(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=Dh(s,o),a=new hi(s,l,0).goto(i),h=new hi(o,l,0).goto(i);for(;;){if(a.to!=h.to||!zo(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 hi(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:o.point.startSide<0?c.length: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 mt;for(let r of e instanceof fn?[e]:t?Am(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return n.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=n.empty;r=r.nextLayer)t=new n(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};ie.empty=new ie([],[],null,-1);function Am(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(No(e,i)>0)return n.slice().sort(No);e=i}return n}ie.empty.nextLayer=ie.empty;var mt=class n{finishChunk(e){this.chunks.push(new Io(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 Dh(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 Tr=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}},un=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 Tr(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--)To(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--)To(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(),To(this.heap,0)}}};function To(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 hi=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=un.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){gr(this.active,e),gr(this.activeTo,e),gr(this.activeRank,e),this.minActive=Oh(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;br(this.active,t,i),br(this.activeTo,t,r),br(this.activeRank,t,s),e&&br(e,t,this.cursor.from),this.minActive=Oh(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&&gr(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 Eh(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))&&zo(n.activeForPoint(n.to),t.activeForPoint(t.to))||s.comparePoint(l,f,n.point,t.point):f>l&&!zo(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 zo(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 gr(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function br(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function Oh(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 Wt(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=ke(n,r));return i}function Kh(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=ke(n,r)}return i===!0?-1:n.length}var Vo="\u037C",_h=typeof Symbol=="undefined"?"__"+Vo:Symbol.for(Vo),Wo=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Uh=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},tt=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 m=l[p];if(/&/.test(p))s(p.split(/,\s*/).map(w=>o.map(y=>w.replace(/&/,y))).reduce((w,y)=>w.concat(y)),m,a);else if(m&&typeof m=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),m,c,u)}else m!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,w=>"-"+w.toLowerCase())+": "+m+";")}(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=Uh[_h]||1;return Uh[_h]=e+1,Vo+e.toString(36)}static mount(e,t,i){let r=e[Wo],s=i&&i.nonce;r?s&&r.setNonce(s):r=new jo(e,s),r.mount(Array.isArray(t)?t:[t])}},Gh=new Map,jo=class{constructor(e,t){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Gh.get(i);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[Wo]=s;this.sheet=new r.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],Gh.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[Wo]=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 Ot={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:"'"},zi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Mm=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Lm=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(we=0;we<10;we++)Ot[48+we]=Ot[96+we]=String(we);var we;for(we=1;we<=24;we++)Ot[we+111]="F"+we;var we;for(we=65;we<=90;we++)Ot[we]=String.fromCharCode(we+32),zi[we]=String.fromCharCode(we);var we;for(Cr in Ot)zi.hasOwnProperty(Cr)||(zi[Cr]=Ot[Cr]);var Cr;function Yh(n){var e=Mm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Lm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?zi:Ot)[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 Vr(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Xo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Dm(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Nr(n,e){if(!e.anchorNode)return!1;try{return Xo(n,e.anchorNode)}catch(t){return!1}}function An(n){return n.nodeType==3?ui(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function kn(n,e,t,i){return t?Jh(n,e,t,i,-1)||Jh(n,e,t,i,1):!1}function Mn(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Jh(n,e,t,i,r){for(;;){if(n==t&&e==i)return!0;if(e==(r<0?0:Bt(n))){if(n.nodeName=="DIV")return!1;let s=n.parentNode;if(!s||s.nodeType!=1)return!1;e=Mn(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?Bt(n):0}else return!1}}function Bt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Il(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Em(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Ic(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 Om(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,m=1,w=1;if(p)u=Em(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 S=c.getBoundingClientRect();({scaleX:m,scaleY:w}=Ic(c,S)),u={left:S.left,right:S.left+c.clientWidth*m,top:S.top,bottom:S.top+c.clientHeight*w}}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 S=e.bottom-e.top,E=u.bottom-u.top;v=(r=="center"&&S<=E?e.top+S/2-E/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-E+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 S=0,E=0;if(v){let O=c.scrollTop;c.scrollTop+=v/w,E=(c.scrollTop-O)*w}if(y){let O=c.scrollLeft;c.scrollLeft+=y/m,S=(c.scrollLeft-O)*m}e={left:e.left-S,top:e.top-E,right:e.right-S,bottom:e.bottom-E},S&&Math.abs(S-y)<1&&(i="nearest"),E&&Math.abs(E-v)<1&&(r="nearest")}if(p)break;c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Bm(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 Zo=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?Bt(t):0),i,Math.min(e.focusOffset,i?Bt(i):0))}set(e,t,i,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=r}},Fi=null;function zc(n){if(n.setActive)return n.setActive();if(Fi)return n.focus(Fi);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(Fi==null?{get preventScroll(){return Fi={preventScroll:!0},!0}}:void 0),!Fi){Fi=!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 Xh;function ui(n,e,t=e){let i=Xh||(Xh=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function ji(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 Pm(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Fc(n){for(;n.attributes.length;)n.removeAttributeNode(n.attributes[0])}function Rm(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Bt(t));;)if(i){if(t.nodeType!=1)return!1;let r=t.childNodes[i-1];r.contentEditable=="false"?i--:(t=r,i=Bt(t))}else{if(t==n)return!0;i=Mn(t),t=t.parentNode}}function Hc(n){return n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}var ze=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,Mn(e),t)}static after(e,t){return new n(e.parentNode,Mn(e)+1,t)}},zl=[],ge=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=Zh(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=Zh(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=Bt(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=zl){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 Wr(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}};ge.prototype.breakAfter=0;function Zh(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Wr=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 Vc(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 Wc(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,Vc(n,h,c,l,a,i,0,r,s)}var Ge=typeof navigator!="undefined"?navigator:{userAgent:"",vendor:"",platform:""},Qo=typeof document!="undefined"?document:{documentElement:{style:{}}},el=/Edge\/(\d+)/.exec(Ge.userAgent),jc=/MSIE \d/.test(Ge.userAgent),tl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ge.userAgent),ts=!!(jc||tl||el),Qh=!ts&&/gecko\/(\d+)/i.test(Ge.userAgent),$o=!ts&&/Chrome\/(\d+)/.exec(Ge.userAgent),ec="webkitFontSmoothing"in Qo.documentElement.style,$c=!ts&&/Apple Computer/.test(Ge.vendor),tc=$c&&(/Mobile\/\w+/.test(Ge.userAgent)||Ge.maxTouchPoints>2),W={mac:tc||/Mac/.test(Ge.platform),windows:/Win/.test(Ge.platform),linux:/Linux|X11/.test(Ge.platform),ie:ts,ie_version:jc?Qo.documentMode||6:tl?+tl[1]:el?+el[1]:0,gecko:Qh,gecko_version:Qh?+(/Firefox\/(\d+)/.exec(Ge.userAgent)||[0,0])[1]:0,chrome:!!$o,chrome_version:$o?+$o[1]:0,ios:tc,android:/Android\b/.test(Ge.userAgent),webkit:ec,safari:$c,webkit_version:ec?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Qo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Nm=256,qt=class n extends ge{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>Nm||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 ze(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 Im(this.dom,e,t)}},Kt=class n extends ge{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(Fc(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:(Wc(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 qc(this,e)}coordsAt(e,t){return _c(this,e,t)}};function Im(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?W.chrome||W.gecko||(e?(r--,o=1):s<i&&(s++,o=-1)):t<0?r--:s<i&&s++;let l=ui(n,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return W.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Il(a,o<0):a||null}var Ln=class n extends ge{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.widget.editable||(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 Q.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):Q.empty}domAtPos(e){return(this.length?e==0:this.side>0)?ze.before(this.dom):ze.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 Il(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 ge{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?ze.before(this.dom):ze.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Q.empty}get isHidden(){return!0}};qt.prototype.children=Ln.prototype.children=Dn.prototype.children=zl;function qc(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 ze(t,0)}function Kc(n,e,t){let i,{children:r}=n;t>0&&e instanceof Kt&&r.length&&(i=r[r.length-1])instanceof Kt&&i.mark.eq(e.mark)?Kc(i,e.children[0],t-1):(r.push(e),e.setParent(n)),n.length+=e.length}function _c(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],m=u+p.length;m>=c&&(p.children.length?l(p,c-u):(!s||s.isHidden&&t>0)&&(m>c||u==m&&p.getSide()>0)?(s=p,o=c-u):(u<c||u==m&&p.getSide()<0&&!p.isHidden)&&(i=p,r=c-u)),u=m}}l(n,e);let a=(t<0?i:s)||i||s;return a?a.coordsAt(Math.max(0,a==i?r:o),t):zm(n)}function zm(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=An(e);return t[t.length-1]||null}function il(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 ic=Object.create(null);function Fl(n,e,t){if(n==e)return!0;n||(n=ic),e||(e=ic);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 nl(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 Fm(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 De=class n extends ge{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),Wc(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){Fl(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Kc(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=il(t,this.attrs||{})),i&&(this.attrs=il({class:i},this.attrs||{}))}domAtPos(e){return qc(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Fc(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&&(nl(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&&ge.get(r)instanceof Kt;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((i=ge.get(r))===null||i===void 0?void 0:i.isEditable)==!1&&(!W.ios||!this.children.some(s=>s instanceof qt))){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 qt)||/[^ -~]/.test(i.text))return null;let r=An(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=_c(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}},$i=class n extends ge{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?ze.before(this.dom):ze.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 zl}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Q.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}},Je=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}get editable(){return!1}destroy(e){}},Fe=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(Fe||(Fe={})),_=class extends at{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 En(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 _t(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}=Uc(e,t);i=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new _t(e,i,r,t,e.widget||null,!0)}static line(e){return new On(e)}static set(e,t=!1){return ie.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};_.none=ie.empty;var En=class n extends _{constructor(e){let{start:t,end:i}=Uc(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))&&Fl(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)}};En.prototype.point=!1;var On=class n extends _{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof n&&this.spec.class==e.spec.class&&Fl(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)}};On.prototype.mapMode=Le.TrackBefore;On.prototype.point=!0;var _t=class n extends _{constructor(e,t,i,r,s,o){super(t,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Le.TrackBefore:Le.TrackAfter:Le.TrackDel}get type(){return this.startSide!=this.endSide?Fe.WidgetRange:this.startSide<=0?Fe.WidgetBefore:Fe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof n&&Hm(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)}};_t.prototype.point=!0;function Uc(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 Hm(n,e){return n==e||!!(n&&e&&n.compare(e))}function rl(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 wn=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 $i&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new De),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ar(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 $i)&&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(Ar(new qt(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 _t){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 _t)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new $i(i.widget||new jr("div"),l,i));else{let a=Ln.create(i.widget||new jr("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(Ar(new Dn(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(Ar(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 Ar(n,e){for(let t of e)n=new Kt(t,[n],n.length);return n}var jr=class extends Je{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}},fe=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(fe||(fe={})),di=fe.LTR,Hl=fe.RTL;function Gc(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}var Vm=Gc("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Wm=Gc("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),sl=Object.create(null),bt=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);sl[e]=t,sl[t]=-e}function Yc(n){return n<=247?Vm[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?Wm[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}var jm=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,kt=class{get dir(){return this.level%2?Hl:di}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}forward(e,t){return e==(this.dir==t)}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 Jc(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||!Jc(i.inner,r.inner))return!1}return!0}var ue=[];function $m(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=Yc(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),ue[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=ue[h];if(u==128)h<l-1&&c==ue[h+1]&&c&24?u=ue[h]=c:ue[h]=256;else if(u==64){let p=h+1;for(;p<l&&ue[p]==64;)p++;let m=h&&c==8||p<t&&ue[p]==8?f==1?1:8:256;for(let w=h;w<p;w++)ue[w]=m;h=p-1}else u==8&&f==1&&(ue[h]=1);c=u,u&7&&(f=u)}}}function qm(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,m;f<c;f++)if(p=sl[u=n.charCodeAt(f)])if(p<0){for(let w=l-3;w>=0;w-=3)if(bt[w+1]==-p){let y=bt[w+2],v=y&2?r:y&4?y&1?s:r:0;v&&(ue[f]=ue[bt[w]]=v),l=w;break}}else{if(bt.length==189)break;bt[l++]=f,bt[l++]=u,bt[l++]=a}else if((m=ue[f])==2||m==1){let w=m==r;a=w?0:1;for(let y=l-3;y>=0;y-=3){let v=bt[y+2];if(v&2)break;if(w)bt[y+2]|=2;else{if(v&4)break;bt[y+2]|=4}}}}}function Km(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=ue[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(ue[c]==256)c++;else break;let f=s==1,u=(c<e?ue[c]:i)==1,p=f==u?f?1:2:i;for(let m=c,w=r,y=w?t[w-1].to:n;m>a;)m==y&&(m=t[--w].from,y=w?t[w-1].to:n),ue[--m]=p;a=c}else s=h,a++}}}function ol(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 w=ue[a];w!=l&&(c=!1,f=w==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,m=a;e:for(;;)if(h<s.length&&m==s[h].from){if(f)break e;let w=s[h];if(!c)for(let y=w.to,v=h+1;;){if(y==t)break e;if(v<s.length&&s[v].from==y)y=s[v++].to;else{if(ue[y]==l)break e;break}}if(h++,u)u.push(w);else{w.from>a&&o.push(new kt(a,w.from,p));let y=w.direction==di!=!(p%2);ll(n,y?i+1:i,r,w.inner,w.from,w.to,o),a=w.to}m=w.to}else{if(m==t||(c?ue[m]!=l:ue[m]==l))break;m++}u?ol(n,a,m,i+1,r,u,o):a<m&&o.push(new kt(a,m,p)),a=m}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let w=ue[a-1];w!=l&&(c=!1,f=w==16)}let u=!c&&l==1?[]:null,p=c?i:i+1,m=a;e:for(;;)if(h&&m==s[h-1].to){if(f)break e;let w=s[--h];if(!c)for(let y=w.from,v=h;;){if(y==e)break e;if(v&&s[v-1].to==y)y=s[--v].from;else{if(ue[y-1]==l)break e;break}}if(u)u.push(w);else{w.to<a&&o.push(new kt(w.to,a,p));let y=w.direction==di!=!(p%2);ll(n,y?i+1:i,r,w.inner,w.from,w.to,o),a=w.from}m=w.from}else{if(m==e||(c?ue[m-1]!=l:ue[m-1]==l))break;m--}u?ol(n,m,a,i+1,r,u,o):m<a&&o.push(new kt(m,a,p)),a=m}}function ll(n,e,t,i,r,s,o){let l=e%2?2:1;$m(n,r,s,i,l),qm(n,r,s,i,l),Km(r,s,i,l),ol(n,r,s,e,t,i,o)}function _m(n,e,t){if(!n)return[new kt(0,0,e==Hl?1:0)];if(e==di&&!t.length&&!jm.test(n))return Xc(n.length);if(t.length)for(;n.length>ue.length;)ue[ue.length]=256;let i=[],r=e==di?0:1;return ll(n,r,r,t,0,n.length,i),i}function Xc(n){return[new kt(0,n,0)]}var Zc="";function Um(n,e,t,i,r){var s;let o=i.head-n.from,l=kt.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),a=e[l],h=a.side(r,t);if(o==h){let u=l+=r?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!r,t),h=a.side(r,t)}let c=ke(n.text,o,a.forward(r,t));(c<a.from||c>a.to)&&(c=h),Zc=n.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return f&&c==h&&f.level+(r?0:1)<a.level?L.cursor(f.side(!r,t)+n.from,f.forward(r,t)?1:-1,f.level):L.cursor(c+n.from,a.forward(r,t)?-1:1,a.level)}function Gm(n,e,t){for(let i=e;i<t;i++){let r=Yc(n.charCodeAt(i));if(r==1)return di;if(r==2||r==4)return Hl}return di}var Qc=z.define(),ef=z.define(),tf=z.define(),nf=z.define(),al=z.define(),rf=z.define(),sf=z.define(),of=z.define({combine:n=>n.some(e=>e)}),lf=z.define({combine:n=>n.some(e=>e)}),xn=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)}},Mr=X.define({map:(n,e)=>n.map(e)});function Re(n,e,t){let i=n.facet(nf);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 is=z.define({combine:n=>n.length?n[0]:!0}),Ym=0,mn=z.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(Ym++,e,i,r,l=>{let a=[mn.of(l)];return o&&a.push(Bn.of(h=>{let c=h.plugin(l);return c?o(c):_.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return n.define(i=>new e(i),t)}},vn=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(Re(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){Re(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){Re(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},af=z.define(),Vl=z.define(),Bn=z.define(),hf=z.define(),Wl=z.define(),cf=z.define();function nc(n,e){let t=n.state.facet(cf);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(n):s),r=[];return ie.spans(i,e.from,e.to,{point(){},span(s,o,l,a){let h=s-e.from,c=o-e.from,f=r;for(let u=l.length-1;u>=0;u--,a--){let p=l[u].spec.bidiIsolate,m;if(p==null&&(p=Gm(e.text,h,c)),a>0&&f.length&&(m=f[f.length-1]).to==h&&m.direction==p)m.to=c,f=m.inner;else{let w={from:h,to:c,direction:p,inner:[]};f.push(w),f=w.inner}}}}),r}var ff=z.define();function uf(n){let e=0,t=0,i=0,r=0;for(let s of n.state.facet(ff)){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 gn=z.define(),wt=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),m=Math.min(c,u);if(p<=m&&new n(p+h,m+h,p,m).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}}},$r=class n{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Ie.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 wt(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}},qr=class extends ge{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 De],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new wt(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:!ig(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?Xm(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:c}=this.hasComposition;i=new wt(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,(W.ie||W.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=eg(o,l,e.changes);return i=wt.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=W.chrome||W.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 $i&&o.widget instanceof Kr&&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,m,w;if(i&&i.range.fromB<f&&i.range.toB>c){let O=wn.build(this.view.state.doc,c,i.range.fromB,this.decorations,this.dynamicDecorationMap),D=wn.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);p=O.breakAtStart,m=O.openStart,w=D.openEnd;let R=this.compositionView(i);D.breakAtStart?R.breakAfter=1:D.content.length&&R.merge(R.length,R.length,D.content[0],!1,D.openStart,0)&&(R.breakAfter=D.content[0].breakAfter,D.content.shift()),O.content.length&&R.merge(0,0,O.content[O.content.length-1],!0,0,O.openEnd)&&O.content.pop(),u=O.content.concat(R).concat(D.content)}else({content:u,breakAtStart:p,openStart:m,openEnd:w}=wn.build(this.view.state.doc,c,f,this.decorations,this.dynamicDecorationMap));let{i:y,off:v}=s.findPos(h,1),{i:S,off:E}=s.findPos(a,-1);Vc(this,S,E,y,v,u,p,m,w)}i&&this.fixCompositionDOM(i)}compositionView(e){let t=new qt(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Kt(r,[t],t.length);let i=new De;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=ge.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&&Nr(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(W.gecko&&l.empty&&!this.hasComposition&&Jm(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=h=new ze(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||(!kn(a.node,a.offset,c.anchorNode,c.anchorOffset)||!kn(h.node,h.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,l))&&(this.view.observer.ignore(()=>{W.android&&W.chrome&&this.dom.contains(c.focusNode)&&tg(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=Vr(this.view.root);if(f)if(l.empty){if(W.gecko){let u=Zm(a.node,a.offset);if(u&&u!=3){let p=pf(a.node,a.offset,u==1?1:-1);p&&(a=new ze(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 ze(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new ze(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&kn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Vr(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=De.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=ge.get(t.childNodes[r]);s instanceof De&&(i=s.domAtPos(0))}for(let r=e.offset-1;!i&&r>=0;r--){let s=ge.get(t.childNodes[r]);s instanceof De&&(i=s.domAtPos(s.length))}return i?new ze(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=ge.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 De)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 De&&!(i instanceof De&&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 De))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 qt))return null;let s=ke(r.text,i);if(s==i)return null;let o=ui(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==fe.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 m=f.dom.lastChild,w=m?An(m):[];if(w.length){let y=w[w.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"?fe.RTL:fe.LTR}measureTextSize(){for(let s of this.children)if(s instanceof De){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=An(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 Wr(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(_.replace({widget:new Kr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return _.set(e)}updateDeco(){let e=this.view.state.facet(Bn).map((r,s)=>(this.dynamicDecorationMap[s]=typeof r=="function")?r(this.view):r),t=!1,i=this.view.state.facet(hf).map((r,s)=>{let o=typeof r=="function";return o&&(t=!0),o?r(this.view):r});i.length&&(this.dynamicDecorationMap[e.length]=t,e.push(ie.join(i)));for(let r=e.length;r<e.length+3;r++)this.dynamicDecorationMap[r]=!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=uf(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;Om(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==fe.LTR)}};function Jm(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 Kr=class extends Je{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function df(n,e){let t=n.observer.selectionRange,i=t.focusNode&&pf(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 Xm(n,e,t){let i=df(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 wt(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let f=r.parentNode;;f=f.parentNode){let u=ge.get(f);if(u instanceof Kt)c.push({node:f,deco:u.mark});else{if(u instanceof De||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 En({inclusive:!0,attributes:Fm(f),tagName:f.tagName.toLowerCase()})});else return null}}}function pf(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=Bt(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 Zm(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 Qm=class{constructor(){this.changes=[]}compareRange(e,t){rl(e,t,this.changes)}comparePoint(e,t){rl(e,t,this.changes)}};function eg(n,e,t){let i=new Qm;return ie.compare(n,e,t,i),i.changes}function tg(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 ig(n,e){let t=!1;return e&&n.iterChangedRanges((i,r)=>{i<e.to&&r>e.from&&(t=!0)}),t}function ng(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=ke(r.text,s,!1):l=ke(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let h=ke(r.text,o,!1);if(i(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=ke(r.text,l);if(i(r.text.slice(l,h))!=a)break;l=h}return L.range(o+r.from,l+r.from)}function rg(n,e){return e.left>n?e.left-n:Math.max(0,n-e.right)}function sg(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function qo(n,e){return n.top<e.bottom-1&&n.bottom>e.top+1}function rc(n,e){return e<n.top?{top:e,left:n.left,right:n.right,bottom:n.bottom}:n}function sc(n,e){return e>n.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function hl(n,e,t){let i,r,s,o,l=!1,a,h,c,f;for(let m=n.firstChild;m;m=m.nextSibling){let w=An(m);for(let y=0;y<w.length;y++){let v=w[y];r&&qo(r,v)&&(v=rc(sc(v,r.bottom),r.top));let S=rg(e,v),E=sg(t,v);if(S==0&&E==0)return m.nodeType==3?oc(m,e,t):hl(m,e,t);if(!i||o>E||o==E&&s>S){i=m,r=v,s=S,o=E;let O=E?t<v.top?-1:1:S?e<v.left?-1:1:0;l=!O||(O>0?y<w.length-1:y>0)}S==0?t>v.bottom&&(!c||c.bottom<v.bottom)?(a=m,c=v):t<v.top&&(!f||f.top>v.top)&&(h=m,f=v):c&&qo(c,v)?c=sc(c,v.bottom):f&&qo(f,v)&&(f=rc(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 oc(i,u,t);if(l&&i.contentEditable!="false")return hl(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 oc(n,e,t){let i=n.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let a=ui(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((W.chrome||W.gecko)&&ui(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 mf(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 O=n.viewState.heightOracle.textHeight/2,D=!1;a=n.elementAtHeight(u),a.type!=Fe.Text;)for(;u=i>0?a.bottom+O:a.top-O,!(u>=0&&u<=h);){if(D)return t?null:0;D=!0,i=-i}f=l+u;let p=a.from;if(p<n.viewport.from)return n.viewport.from==0?0:t?null:lc(n,o,a,c,f);if(p>n.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:lc(n,o,a,c,f);let m=n.dom.ownerDocument,w=n.root.elementFromPoint?n.root:m,y=w.elementFromPoint(c,f);y&&!n.contentDOM.contains(y)&&(y=null),y||(c=Math.max(o.left+1,Math.min(o.right-1,c)),y=w.elementFromPoint(c,f),y&&!n.contentDOM.contains(y)&&(y=null));let v,S=-1;if(y&&((r=n.docView.nearest(y))===null||r===void 0?void 0:r.isEditable)!=!1){if(m.caretPositionFromPoint){let O=m.caretPositionFromPoint(c,f);O&&({offsetNode:v,offset:S}=O)}else if(m.caretRangeFromPoint){let O=m.caretRangeFromPoint(c,f);O&&({startContainer:v,startOffset:S}=O,(!n.contentDOM.contains(v)||W.safari&&og(v,S,c)||W.chrome&&lg(v,S,c))&&(v=void 0))}}if(!v||!n.docView.dom.contains(v)){let O=De.find(n.docView,p);if(!O)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:S}=hl(O.dom,c,f))}let E=n.docView.nearest(v);if(!E)return null;if(E.isWidget&&((s=E.dom)===null||s===void 0?void 0:s.nodeType)==1){let O=E.dom.getBoundingClientRect();return e.y<O.top||e.y<=O.bottom&&e.x<=(O.left+O.right)/2?E.posAtStart:E.posAtEnd}else return E.localPosFromDOM(v,S)+E.posAtStart}function lc(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+Kh(o,s,n.state.tabSize)}function og(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 ui(n,i-1,i).getBoundingClientRect().left>t}function lg(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():ui(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function cl(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==Fe.Text))return i}return t}function ag(n,e,t,i){let r=cl(n,e.head),s=!i||r.type!=Fe.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==fe.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 ac(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=Um(r,s,o,l,t),c=Zc;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=n.visualLineSide(r,!t)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function hg(n,e,t){let i=n.state.charCategorizer(e),r=i(t);return s=>{let o=i(s);return r==me.Space&&(r=o),r==o}}function cg(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 m=l+(u+p)*s,w=mf(n,{x:f,y:m},!1,s);if(m<a.top||m>a.bottom||(s<0?w<r:w>r)){let y=n.docView.coordsForChar(w),v=!y||m<y.top?-1:1;return L.cursor(w,v,void 0,o)}}}function Ir(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 Ko(n,e,t){let i=Ir(n.state.facet(Wl).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 fl=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,W.safari&&e.contentDOM.addEventListener("input",()=>null),W.gecko&&Cg(e.contentDOM.ownerDocument)}handleEvent(e){!bg(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=fg(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&&bf.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),W.android&&W.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return W.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=gf.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||ug.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,ji(this.view.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:W.safari&&!W.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 hc(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(r){Re(t.state,r)}}}function fg(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(hc(i.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(hc(i.value,o))}}for(let i in ht)t(i).handlers.push(ht[i]);for(let i in ct)t(i).observers.push(ct[i]);return e}var gf=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ug="dthko",bf=[16,17,18,20,91,92,224,225],Lr=6;function Dr(n){return Math.max(0,n)*.7+8}function dg(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}var ul=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=Bm(e.contentDOM),this.atoms=e.state.facet(Wl).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(se.allowMultipleSelections)&&pg(e,t),this.dragging=gg(e,t)&&xf(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&&dg(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=uf(this.view);e.clientX-o.left<=s.left+Lr?i=-Dr(s.left-e.clientX):e.clientX+o.right>=s.right-Lr&&(i=Dr(e.clientX-s.right)),e.clientY-o.top<=s.top+Lr?r=-Dr(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-Lr&&(r=Dr(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=Ir(this.atoms,r.from,0);o!=r.from&&(s=L.cursor(o,-1))}else{let o=Ir(this.atoms,r.from,-1),l=Ir(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,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 pg(n,e){let t=n.state.facet(Qc);return t.length?t[0](e):W.mac?e.metaKey:e.ctrlKey}function mg(n,e){let t=n.state.facet(ef);return t.length?t[0](e):W.mac?!e.altKey:!e.ctrlKey}function gg(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Vr(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 bg(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=ge.get(t))&&i.ignoreEvent(e))return!1;return!0}var ht=Object.create(null),ct=Object.create(null),yf=W.ie&&W.ie_version<15||W.ios&&W.webkit_version<604;function yg(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(),kf(n,t.value)},50)}function kf(n,e){let{state:t}=n,i,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(dl!=null&&t.selection.ranges.every(a=>a.empty)&&dl==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})}ct.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};ht.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now()),!1);ct.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};ct.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};ht.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(tf))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=xg(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new ul(n,e,t,i)),i&&n.observer.ignore(()=>zc(n.contentDOM));let r=n.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function cc(n,e,t,i){if(i==1)return L.cursor(e,t);if(i==2)return ng(n.state,e,t);{let r=De.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 wf=(n,e)=>n>=e.top&&n<=e.bottom,fc=(n,e,t)=>wf(e,t)&&n>=t.left&&n<=t.right;function kg(n,e,t,i){let r=De.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&&fc(t,i,o))return-1;let l=r.coordsAt(s,1);return l&&fc(t,i,l)?1:o&&wf(i,o)?-1:1}function uc(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:kg(n,t,e.clientX,e.clientY)}}var wg=W.ie&&W.ie_version<=11,dc=null,pc=0,mc=0;function xf(n){if(!wg)return n.detail;let e=dc,t=mc;return dc=n,mc=Date.now(),pc=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(pc+1)%3:1}function xg(n,e){let t=uc(n,e),i=xf(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=uc(n,s),h,c=cc(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=cc(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=vg(r,a.pos))?h:l?r.addRange(c):L.create([c])}}}function vg(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}ht.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};ht.dragend=n=>(n.inputState.draggedContent=null,!1);function gc(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&&mg(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}ht.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&&gc(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 gc(n,e,i,!0),!0}return!1};ht.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=yf?null:e.clipboardData;return t?(kf(n,t.getData("text/plain")||t.getData("text/uri-text")),!0):(yg(n),!1)};function Sg(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 Tg(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 dl=null;ht.copy=ht.cut=(n,e)=>{let{text:t,ranges:i,linewise:r}=Tg(n.state);if(!t&&!r)return!1;dl=r?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=yf?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Sg(n,t),!1)};var vf=We.define();function Sf(n,e){let t=[];for(let i of n.facet(sf)){let r=i(n,e);r&&t.push(r)}return t?n.update({effects:t,annotations:vf.of(!0)}):null}function Tf(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=Sf(n.state,e);t?n.dispatch(t):n.update([])}},10)}ct.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),Tf(n)};ct.blur=n=>{n.observer.clearSelectionRange(),Tf(n)};ct.compositionstart=ct.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};ct.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,W.chrome&&W.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50)};ct.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};ht.beforeinput=(n,e)=>{var t;let i;if(W.chrome&&W.android&&(i=gf.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 bc=new Set;function Cg(n){bc.has(n)||(bc.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}var yc=["pre-wrap","normal","pre-line","break-spaces"],pl=class{constructor(e){this.lineWrapping=e,this.doc=Q.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 yc.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=yc.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}},ml=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},yt=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"?Fe.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 _t?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)}},pe=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(pe||(pe={})),zr=.001,Ye=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)>zr&&(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,pe.ByPosNoHeight,i.setDoc(t),0,0),p=u.to>=h?u:s.lineAt(h,pe.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,pe.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let m=bl.build(i.setDoc(o),e,c,f);s=s.replace(a,h,m)}return s.updateHeight(i,0)}static empty(){return new it(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 gl(n.of(e.slice(0,t)),o,n.of(e.slice(i)))}};Ye.prototype.size=1;var _r=class extends Ye{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,r){return new yt(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})`}},it=class n extends _r{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,r){return new yt(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 $t&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof $t?r=new n(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Ye.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:""})`}},$t=class n extends Ye{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 yt(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 yt(c,f,i+l*h,l,0)}}lineAt(e,t,i,r,s){if(t==pe.ByHeight)return this.blockAt(e,i,r,s);if(t==pe.ByPosNoHeight){let{from:p,to:m}=i.doc.lineAt(e);return new yt(p,m-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 yt(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 m=u.number-l;f+=a*m+h*(e-s-m)}let p=a+h*u.length;o(new yt(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 Ye.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)>=zr&&(a=-2);let u=new it(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=Ye.of(o);return(a<0||Math.abs(h.height-this.height)>=zr||Math.abs(a-this.heightMetrics(e,t).perLine)>=zr)&&(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})`}},gl=class extends Ye{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==pe.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==pe.ByPosNoHeight?pe.ByPosNoHeight:pe.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,pe.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&&kc(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),kc(s,l)}return Ye.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?Ye.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 kc(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof $t&&(i=n[e+1])instanceof $t&&n.splice(e-1,3,new $t(t.length+1+i.length))}var Ag=5,bl=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 it?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new it(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 _r(o,r,i)):(o||s||r>=Ag)&&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 it(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new $t(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 it)return e;let t=new it(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 it)&&!this.isCovered?this.nodes.push(new it(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 it&&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 Mg(n,e,t){let i=new yl;return ie.compare(n,e,t,i,0),i.changes}var yl=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,r){(e<t||i&&i.heightRelevant||r&&r.heightRelevant)&&rl(e,t,this.changes,5)}};function Lg(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 Dg(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Sn=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 _.replace({widget:new kl(this.size*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},kl=class extends Je{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}},Ur=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=wc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=fe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Vl).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new pl(t),this.stateDeco=e.facet(Bn).filter(i=>typeof i!="function"),this.heightMap=Ye.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle.setDoc(e.doc),[new wt(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=_.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 Hi(s,o))}}this.viewports=e.sort((i,r)=>i.from-r.from),this.scaler=this.heightMap.height<=7e6?wc:new wl(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:bn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Bn).filter(c=>typeof c!="function");let r=e.changedRanges,s=wt.extendWithRanges(r,Mg(i,this.stateDeco,e?e.changes:Ie.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(lf)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?fe.RTL:fe.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:O,scaleY:D}=Ic(t,l);(this.scaleX!=O||this.scaleY!=D)&&(this.scaleX=O,this.scaleY=D,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=Hc(e.scrollDOM);let m=(this.printing?Dg:Lg)(t,this.paddingTop),w=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;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 S=l.width;if((this.contentDOMWidth!=S||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let O=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(O)&&(o=!0),o||r.lineWrapping&&Math.abs(S-this.contentDOMWidth)>r.charWidth){let{lineHeight:D,charWidth:R,textHeight:x}=e.docView.measureTextSize();o=D>0&&r.refresh(s,D,R,x,S/R,O),o&&(e.docView.minWidth=0,h|=8)}w>0&&y>0?c=Math.max(w,y):w<0&&y<0&&(c=Math.min(w,y)),r.heightChanged=!1;for(let D of this.viewports){let R=D.from==this.viewport.from?O:e.docView.measureVisibleLineHeights(D);this.heightMap=(o?Ye.empty().applyChanges(this.stateDeco,Q.empty,this.heightOracle,[new wt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new ml(D.from,R))}r.heightChanged&&(h|=2)}let E=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return E&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(h&2||E)&&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 Hi(r.lineAt(o-i*1e3,pe.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,pe.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,pe.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 Hi(r.lineAt(u-1e3/2,pe.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,pe.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 Hi(this.heightMap.lineAt(i,pe.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,pe.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,pe.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,pe.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 Sn(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!=fe.LTR&&!i)return[];let l=[],a=(h,c,f,u)=>{if(c-h<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let y of m)if(y>h&&y<c){a(h,y-10,f,u),a(y+10,c,f,u);return}let w=Og(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-h)<s&&Math.abs(y.to-c)<s&&!m.some(v=>y.from<v&&y.to>v));if(!w){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)}w=new Sn(h,c,this.gapSize(f,h,c,u))}l.push(w)};for(let h of this.viewportLines){if(h.length<o)continue;let c=Eg(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 m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,w,y;if(f!=null){let v=Or(c,f),S=((this.visibleBottom-this.visibleTop)/2+m)/h.height;w=v-S,y=v+S}else w=(this.visibleTop-h.top-m)/h.height,y=(this.visibleBottom-h.top+m)/h.height;u=Er(c,w),p=Er(c,y)}else{let m=c.total*this.heightOracle.charWidth,w=r*this.heightOracle.charWidth,y,v;if(f!=null){let S=Or(c,f),E=((this.pixelViewport.right-this.pixelViewport.left)/2+w)/m;y=S-E,v=S+E}else y=(this.pixelViewport.left-w)/m,v=(this.pixelViewport.right+w)/m;u=Er(c,y),p=Er(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=Or(r,i)-Or(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){Sn.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=_.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)||bn(this.heightMap.lineAt(e,pe.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return bn(this.heightMap.lineAt(this.scaler.fromDOM(e),pe.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 bn(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}},Hi=class{constructor(e,t){this.from=e,this.to=t}};function Eg(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 Er({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 Or(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 Og(n,e){for(let t of n)if(e(t))return t}var wc={toDOM(n){return n},fromDOM(n){return n},scale:1},wl=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,pe.ByPos,e,0,0).top,c=t.lineAt(a,pe.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 bn(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new yt(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(r=>bn(r,e)):n._content)}var Br=z.define({combine:n=>n.join(" ")}),xl=z.define({combine:n=>n.indexOf(!0)>-1}),vl=tt.newName(),Cf=tt.newName(),Af=tt.newName(),Mf={"&light":"."+Cf,"&dark":"."+Af};function Sl(n,e,t){return new tt(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 Bg=Sl("."+vl,{"&":{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-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&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"}},Mf),yn="\uFFFF",Tl=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(se.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=yn}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=ge.get(r),a=ge.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:xc(r))||xc(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=ge.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+(Pg(e,i.node,i.offset)?t:0))}};function Pg(n,e,t){for(;;){if(!e||t<Bt(e))return!1;if(e==n)return!0;t=Mn(e)+1,e=e.parentNode}}function xc(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}var Gr=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Cl=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?[]:Ig(e),a=new Tl(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=zg(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!Xo(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||!Xo(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),c=e.viewport;if((W.ios||W.chrome)&&e.state.selection.main.empty&&a!=h&&(c.from>0||c.to<e.state.doc.length)){let f=Math.min(a,h),u=Math.max(a,h),p=c.from-f,m=c.to-u;(p==0||p==1||f==0)&&(m==0||m==-1||u==e.state.doc.length)&&(a=0,h=e.state.doc.length)}this.newSel=L.single(h,a)}}};function Lf(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||W.android&&e.text.length<l-o)&&(a=r.to,h="end");let c=Ng(n.state.doc.sliceString(o,l,yn),e.text,a-o,h);c&&(W.chrome&&s==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==yn+yn&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:Q.of(e.text.slice(c.from,c.toB).split(yn))})}else i&&(!n.hasFocus&&n.state.facet(is)||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))}:(W.mac||W.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:Q.of([" "])}):W.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:Q.of([" "])}),t){if(W.ios&&n.inputState.flushIOSKey()||W.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&ji(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)&&ji(n.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&ji(n.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let l,a=()=>l||(l=Rg(n,t,i));return n.state.facet(rf).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 Rg(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&&df(n,t.main.head);if(f){let m=e.insert.length-(e.to-e.from);c={from:f.from,to:f.to-m}}else c=n.state.doc.lineAt(s.head);let u=s.to-e.to,p=s.to-s.from;i=r.changeByRange(m=>{if(m.from==s.from&&m.to==s.to)return{changes:l,range:a||m.map(l)};let w=m.to-u,y=w-h.length;if(m.to-m.from!=p||n.state.sliceDoc(y,w)!=h||m.to>=c.from&&m.from<=c.to)return{range:m};let v=r.changes({from:y,to:w,insert:e.insert}),S=m.to-s.to;return{changes:v,range:a?L.range(Math.max(0,a.anchor+S),Math.max(0,a.head+S)):m.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 Ng(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 Ig(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 Gr(t,i)),(r!=t||s!=i)&&e.push(new Gr(r,s))),e}function zg(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 Fg={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},_o=W.ie&&W.ie_version<=11,Al=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Zo,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);(W.ie&&W.ie_version<=11||W.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()}),_o&&(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(is)?i.root.activeElement!=this.dom:!Nr(i.dom,r))return;let s=r.anchorNode&&i.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(W.ie&&W.ie_version<=11||W.android&&W.chrome)&&!i.state.selection.main.empty&&r.focusNode&&kn(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=W.safari&&e.root.nodeType==11&&Dm(this.dom.ownerDocument)==this.dom&&Hg(this.view)||Vr(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=Nr(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Rm(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,Fg),_o&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),_o&&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&&ji(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&&Nr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Cl(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=Lf(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=vc(t,e.previousSibling||e.target.previousSibling,-1),r=vc(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 vc(n,e,t){for(;e;){let i=ge.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 Hg(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 kn(l.node,l.offset,s,o)&&([i,r,s,o]=[s,o,i,r]),{anchorNode:i,anchorOffset:r,focusNode:s,focusOffset:o}}var N=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),e.parent&&e.parent.appendChild(this.dom);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||Pm(e.parent)||document,this.viewState=new Ur(e.state||se.create(e)),e.scrollTo&&e.scrollTo.is(Mr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(mn).map(i=>new vn(i));for(let i of this.plugins)i.update(this);this.observer=new Al(this),this.inputState=new fl(this),this.inputState.ensureHandlers(this.plugins),this.docView=new qr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=e.length==1&&e[0]instanceof ve?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(vf))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Sf(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(se.phrases)!=this.state.facet(se.phrases))return this.setState(s);r=$r.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 xn(p.empty?p:L.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of u.effects)p.is(Mr)&&(f=p.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Yr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(gn)!=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(Br)!=r.state.facet(Br)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let u of this.state.facet(al))try{u(r)}catch(p){Re(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Lf(this,c)&&h.force&&ji(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 Ur(e),this.plugins=e.facet(mn).map(i=>new vn(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new qr(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(mn),i=e.state.facet(mn);if(t!=i){let r=[];for(let s of i){let o=t.indexOf(s);if(o<0)r.push(new vn(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(Hc(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(m){return Re(this.state,m),Sc}}),f=$r.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]!=Sc)try{let m=h[p];m.write&&m.write(c[p],this)}catch(m){Re(this.state,m)}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 m=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(m>1||m<-1){r=r+m,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(al))l(t)}get themeClasses(){return vl+" "+(this.state.facet(xl)?Af:Cf)+" "+this.state.facet(Br)}updateAttrs(){let e=Tc(this,af,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(is)?"true":"false",class:"cm-content",style:`${W.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Tc(this,Vl,t);let i=this.observer.ignore(()=>{let r=nl(this.contentDOM,this.contentAttrs,t),s=nl(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(gn);let e=this.state.facet(n.cspNonce);tt.mount(this.root,this.styleModules.concat(Bg).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 Ko(this,e,ac(this,e,t,i))}moveByGroup(e,t){return Ko(this,e,ac(this,e,t,i=>hg(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return L.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return ag(this,e,t,i)}moveVertically(e,t,i){return Ko(this,e,cg(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(),mf(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[kt.find(s,e-r.from,-1,t)];return Il(i,o.dir==fe.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(of)||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>Vg)return Xc(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||Jc(s.isolates,i=nc(this,e))))return s.order;i||(i=nc(this,e));let r=_m(e.text,t,i);return this.bidiCache.push(new Yr(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||W.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{zc(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 Mr.of(new xn(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 Mr.of(new xn(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=tt.newName(),r=[Br.of(i),gn.of(Sl(`.${i}`,e))];return t&&t.dark&&r.push(xl.of(!0)),r}static baseTheme(e){return gt.lowest(gn.of(Sl("."+vl,e,Mf)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&ge.get(i)||ge.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}};N.styleModule=gn;N.inputHandler=rf;N.focusChangeEffect=sf;N.perLineTextDirection=of;N.exceptionSink=nf;N.updateListener=al;N.editable=is;N.mouseSelectionStyle=tf;N.dragMovesSelection=ef;N.clickAddsSelectionRange=Qc;N.decorations=Bn;N.outerDecorations=hf;N.atomicRanges=Wl;N.bidiIsolatedRanges=cf;N.scrollMargins=ff;N.darkTheme=xl;N.cspNonce=z.define({combine:n=>n.length?n[0]:""});N.contentAttributes=Vl;N.editorAttributes=af;N.lineWrapping=N.contentAttributes.of({class:"cm-lineWrapping"});N.announce=X.define();var Vg=4096,Sc={},Yr=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:fe.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 Tc(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&&il(o,t)}return t}var Wg=W.mac?"mac":W.windows?"win":W.linux?"linux":"key";function jg(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 Pr(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 $g=gt.default(N.domEventHandlers({keydown(n,e){return Of(Df(e.state),n,e,"editor")}})),ft=z.define({enables:$g}),Cc=new WeakMap;function Df(n){let e=n.facet(ft),t=Cc.get(e);return t||Cc.set(e,t=Kg(e.reduce((i,r)=>i.concat(r),[]))),t}function Ef(n,e,t){return Of(Df(n.state),e,n,t)}var jt=null,qg=4e3;function Kg(n,e=Wg){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)),m=l.split(/ (?!$)/).map(v=>jg(v,e));for(let v=1;v<m.length;v++){let S=m.slice(0,v).join(" ");r(S,!0),p[S]||(p[S]={preventDefault:!0,stopPropagation:!1,run:[E=>{let O=jt={view:E,prefix:S,scope:o};return setTimeout(()=>{jt==O&&(jt=null)},qg),!0}]})}let w=m.join(" ");r(w,!1);let y=p[w]||(p[w]={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 Of(n,e,t,i){let r=Yh(e),s=Se(r,0),o=Ve(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;jt&&jt.view==t&&jt.scope==i&&(l=jt.prefix+" ",bf.indexOf(e.keyCode)<0&&(h=!0,jt=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],m,w;return p&&(u(p[l+Pr(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(W.windows&&e.ctrlKey&&e.altKey)&&(m=Ot[e.keyCode])&&m!=r?(u(p[l+Pr(m,e,!0)])||e.shiftKey&&(w=zi[e.keyCode])!=r&&w!=m&&u(p[l+Pr(w,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(p[l+Pr(r,e,!0)])&&(a=!0),!a&&u(p._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),a}var Pn=class n{constructor(e,t,i,r,s){this.className=e,this.left=t,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=Bf(e);return[new n(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return _g(e,t,i)}};function Bf(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==fe.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Ac(n,e,t){let i=L.cursor(e);return{from:Math.max(t.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(t.to,n.moveToLineBoundary(i,!0,!0).from),type:Fe.Text}}function _g(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),r=Math.min(t.to,n.viewport.to),s=n.textDirection==fe.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=Bf(n),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),p=cl(n,i),m=cl(n,r),w=p.type==Fe.Text?p:null,y=m.type==Fe.Text?m:null;if(w&&(n.lineWrapping||p.widgetLineBreaks)&&(w=Ac(n,i,w)),y&&(n.lineWrapping||m.widgetLineBreaks)&&(y=Ac(n,r,y)),w&&y&&w.from==y.from)return S(E(t.from,t.to,w));{let D=w?E(t.from,null,w):O(p,!1),R=y?E(null,t.to,y):O(m,!0),x=[];return(w||p).to<(y||m).from-(w&&y?1:0)||p.widgetLineBreaks>1&&D.bottom+n.defaultLineHeight/2<R.top?x.push(v(f,D.bottom,u,R.top)):D.bottom<R.top&&n.elementAtHeight((D.bottom+R.top)/2).type==Fe.Text&&(D.bottom=R.top=(D.bottom+R.top)/2),S(D).concat(x).concat(S(R))}function v(D,R,x,M){return new Pn(e,D-a.left,R-a.top-.01,x-D,M-R+.01)}function S({top:D,bottom:R,horizontal:x}){let M=[];for(let b=0;b<x.length;b+=2)M.push(v(x[b],D,x[b+1],R));return M}function E(D,R,x){let M=1e9,b=-1e9,Y=[];function K(k,A,T,F,te){let le=n.coordsAtPos(k,k==x.to?-2:2),j=n.coordsAtPos(T,T==x.from?2:-2);!le||!j||(M=Math.min(le.top,j.top,M),b=Math.max(le.bottom,j.bottom,b),te==fe.LTR?Y.push(s&&A?f:le.left,s&&F?u:j.right):Y.push(!s&&F?f:j.left,!s&&A?u:le.right))}let U=D!=null?D:x.from,q=R!=null?R:x.to;for(let k of n.visibleRanges)if(k.to>U&&k.from<q)for(let A=Math.max(k.from,U),T=Math.min(k.to,q);;){let F=n.state.doc.lineAt(A);for(let te of n.bidiSpans(F)){let le=te.from+F.from,j=te.to+F.from;if(le>=T)break;j>A&&K(Math.max(le,A),D==null&&le<=U,Math.min(j,T),R==null&&j>=q,te.dir)}if(A=F.to+1,A>=T)break}return Y.length==0&&K(U,D==null,q,R==null,n.textDirection),{top:M,bottom:b,horizontal:Y}}function O(D,R){let x=l.top+(R?D.top:D.bottom);return{top:x,bottom:x,horizontal:[]}}}function Ug(n,e){return n.constructor==e.constructor&&n.eq(e)}var Ml=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Fr)!=e.state.facet(Fr)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}setOrder(e){let t=0,i=e.facet(Fr);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!Ug(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[i].constructor&&r.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},Fr=z.define();function Pf(n){return[ye.define(e=>new Ml(e,n)),Fr.of(n)]}var Rf=!W.ios,Rn=z.define({combine(n){return Pe(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Nf(n={}){return[Rn.of(n),Gg,Yg,Jg,lf.of(!0)]}function If(n){return n.startState.facet(Rn)!=n.state.facet(Rn)}var Gg=Pf({above:!0,markers(n){let{state:e}=n,t=e.facet(Rn),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||Rf:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:L.cursor(r.head,r.head>r.anchor?-1:1);for(let a of Pn.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=If(n);return t&&Mc(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){Mc(e.state,n)},class:"cm-cursorLayer"});function Mc(n,e){e.style.animationDuration=n.facet(Rn).cursorBlinkRate+"ms"}var Yg=Pf({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:Pn.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||If(n)},class:"cm-selectionLayer"}),Ll={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Rf&&(Ll[".cm-line"].caretColor="transparent !important",Ll[".cm-content"]={caretColor:"transparent !important"});var Jg=gt.highest(N.theme(Ll));function Lc(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 Xg(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 Nn=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 mt,i=t.add.bind(t);for(let{from:r,to:s}of Xg(e,this.maxLength))Lc(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,m=(w,y,v)=>u.push(v.range(w,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,m);else Lc(e.state.doc,this.regexp,c,f,(w,y)=>this.addMatch(y,e,w,m));t=t.update({filterFrom:c,filterTo:f,filter:(w,y)=>w<c||y>f,add:u})}}return t}},Dl=/x/.unicode!=null?"gu":"g",Zg=new RegExp(`[\0-\b
|
|
10
|
+
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Dl),Qg={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"},Uo=null;function e0(){var n;if(Uo==null&&typeof document!="undefined"&&document.body){let e=document.body.style;Uo=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Uo||!1}var Hr=z.define({combine(n){let e=Pe(n,{render:null,specialChars:Zg,addSpecialChars:null});return(e.replaceTabs=!e0())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Dl)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Dl)),e}});function zf(n={}){return[Hr.of(n),t0()]}var Dc=null;function t0(){return Dc||(Dc=ye.fromClass(class{constructor(n){this.view=n,this.decorations=_.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Hr)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new Nn({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:r}=t.state,s=Se(e[0],0);if(s==9){let o=r.lineAt(i),l=t.state.tabSize,a=Wt(o.text,l,i-o.from);return _.replace({widget:new Ol((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=_.replace({widget:new El(n,s)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Hr);n.startState.facet(Hr)!=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 i0="\u2022";function n0(n){return n>=32?i0:n==10?"\u2424":String.fromCharCode(9216+n)}var El=class extends Je{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=n0(this.code),i=e.state.phrase("Control character")+" "+(Qg[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}},Ol=class extends Je{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 Ff(){return s0}var r0=_.line({class:"cm-activeLine"}),s0=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(r0.range(r.from)),e=r.from)}return _.set(t)}},{decorations:n=>n.decorations});var pn="-10000px",Jr=class{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}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,a?o[a-1]:null),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&&(this.removeTooltipView(a),(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 o0(n){let{win:e}=n;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var Go=z.define({combine:n=>{var e,t,i;return{position:W.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)||o0}}}),Ec=new WeakMap,jl=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(Go);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.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Jr(n,Ut,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),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(Go);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,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.insertBefore(r,i)}return t.dom.style.position=this.position,t.dom.style.top=pn,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.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(W.gecko)i=r.offsetParent!=this.container.ownerDocument.body;else if(r.style.top==pn&&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(Go).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=pn;continue}let p=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,w=u.right-u.left,y=(e=Ec.get(h))!==null&&e!==void 0?e:u.bottom-u.top,v=h.offset||a0,S=this.view.textDirection==fe.LTR,E=u.width>i.right-i.left?S?i.left:i.right-u.width:S?Math.min(f.left-(p?14:0)+v.x,i.right-w):Math.max(i.left,f.left-w+(p?14:0)-v.x),O=this.above[l];!a.strictSide&&(O?f.top-(u.bottom-u.top)-v.y<i.top:f.bottom+(u.bottom-u.top)+v.y>i.bottom)&&O==i.bottom-f.bottom>f.top-i.top&&(O=this.above[l]=!O);let D=(O?f.top-i.top:i.bottom-f.bottom)-m;if(D<y&&h.resize!==!1){if(D<this.view.defaultLineHeight){c.style.top=pn;continue}Ec.set(h,y),c.style.height=(y=D)/s+"px"}else c.style.height&&(c.style.height="");let R=O?f.top-y-m-v.y:f.bottom+m+v.y,x=E+w;if(h.overlap!==!0)for(let M of o)M.left<x&&M.right>E&&M.top<R+y&&M.bottom>R&&(R=O?M.top-y-2-m:M.bottom+m+2);if(this.position=="absolute"?(c.style.top=(R-n.parent.top)/s+"px",c.style.left=(E-n.parent.left)/r+"px"):(c.style.top=R/s+"px",c.style.left=E/r+"px"),p){let M=f.left+(S?v.x:-v.x)-(E+14-7);p.style.left=M/r+"px"}h.overlap!==!0&&o.push({left:E,top:R,right:x,bottom:R+y}),c.classList.toggle("cm-tooltip-above",O),c.classList.toggle("cm-tooltip-below",!O),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=pn}},{eventObservers:{scroll(){this.maybeMeasure()}}}),l0=N.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"}}}),a0={x:0,y:0},Ut=z.define({enables:[jl,l0]}),Xr=z.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])}),Zr=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 Jr(e,Xr,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}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")}},h0=Ut.compute([Xr],n=>{let e=n.facet(Xr);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:Zr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Bl=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.length)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 Ln)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==fe.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&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>Re(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(jl),t=e?e.manager.tooltips.findIndex(i=>i.create==Zr.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;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:r,tooltip:s}=this;if(r.length&&s&&!c0(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,l=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!f0(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},Rr=4;function c0(n,e){let t=n.getBoundingClientRect();return e.clientX>=t.left-Rr&&e.clientX<=t.right+Rr&&e.clientY>=t.top-Rr&&e.clientY<=t.bottom+Rr}function f0(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 Hf(n,e={}){let t=X.define(),i=ce.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let l of r){let a=s.changes.mapPos(l.pos,-1,Le.TrackDel);if(a!=null){let h=Object.assign(Object.create(null),l);h.pos=a,h.end!=null&&(h.end=s.changes.mapPos(h.end)),o.push(h)}}r=o}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(u0)&&(r=[]);return r},provide:r=>Xr.from(r)});return[i,ye.define(r=>new Bl(r,n,i,t,e.hoverTime||300)),h0]}function $l(n,e){let t=n.plugin(jl);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var u0=X.define();var Oc=z.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 mi(n,e){let t=n.plugin(Vf),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}var Vf=ye.fromClass(class{constructor(n){this.input=n.state.facet(pi),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Oc);this.top=new Vi(n,!0,e.topContainer),this.bottom=new Vi(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(Oc);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Vi(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Vi(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(pi);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=>N.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Vi=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=Bc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Bc(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 Bc(n){let e=n.nextSibling;return n.remove(),e}var pi=z.define({enables:Vf}),nt=class extends at{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};nt.prototype.elementClass="";nt.prototype.toDOM=void 0;nt.prototype.mapMode=Le.TrackBefore;nt.prototype.startSide=nt.prototype.endSide=-1;nt.prototype.point=!0;var Yo=z.define(),d0={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ie.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Tn=z.define();function ql(n){return[Wf(),Tn.of(Object.assign(Object.assign({},d0),n))]}var Pl=z.define({combine:n=>n.some(e=>e)});function Wf(n){let e=[p0];return n&&n.fixed===!1&&e.push(Pl.of(!0)),e}var p0=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(Tn).map(e=>new Qr(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(Pl),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(Pl)!=!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(Yo),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Nl(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==Fe.Text&&o){Rl(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==Fe.Text){Rl(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(Tn),t=n.state.facet(Tn),i=n.docChanged||n.heightChanged||n.viewportChanged||!ie.eq(n.startState.facet(Yo),n.state.facet(Yo),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 Qr(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=>N.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==fe.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function Pc(n){return Array.isArray(n)?n:[n]}function Rl(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}var Nl=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 es(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=[];Rl(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()}}},Qr=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=Pc(t.markers(e)),t.initialSpacer&&(this.spacer=new es(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=Pc(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()}},es=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":""),m0(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 m0(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 g0=z.define(),Wi=z.define({combine(n){return Pe(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}})}}),Cn=class extends nt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Jo(n,e){return n.state.facet(Wi).formatNumber(e,n.state)}var b0=Tn.compute([Wi],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(g0)},lineMarker(e,t,i){return i.some(r=>r.toDOM)?null:new Cn(Jo(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Wi)!=e.state.facet(Wi),initialSpacer(e){return new Cn(Jo(e,Rc(e.state.doc.lines)))},updateSpacer(e,t){let i=Jo(t.view,Rc(t.view.state.doc.lines));return i==e.number?e:new Cn(i)},domEventHandlers:n.facet(Wi).domEventHandlers}));function jf(n={}){return[Wi.of(n),Wf(),b0]}function Rc(n){let e=9;for(;e<n;)e=e*10+9;return e}var Nc=new Map;function y0(n){let e=Nc.get(n);return e||Nc.set(n,e=_.mark({attributes:n===" "?{class:"cm-highlightTab"}:{class:"cm-highlightSpace","data-display":n.replace(/ /g,"\xB7")}})),e}function $f(n){return ye.define(e=>({decorations:n.createDeco(e),update(t){this.decorations=n.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}var k0=$f(new Nn({regexp:/\t| +/g,decoration:n=>y0(n[0]),boundary:/\S/}));function qf(){return k0}var w0=$f(new Nn({regexp:/\s+$/g,decoration:_.mark({class:"cm-trailingSpace"}),boundary:/\S/}));function Kf(){return w0}var x0=0,In=class{constructor(e,t){this.from=e,this.to=t}},Z=class{constructor(e={}){this.id=x0++,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=He.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};Z.closedBy=new Z({deserialize:n=>n.split(" ")});Z.openedBy=new Z({deserialize:n=>n.split(" ")});Z.group=new Z({deserialize:n=>n.split(" ")});Z.contextHash=new Z({perNode:!0});Z.lookAhead=new Z({perNode:!0});Z.mounted=new Z({perNode:!0});var qi=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[Z.mounted.id]}},v0=Object.create(null),He=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):v0,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(Z.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(Z.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?i.name:r[s]];if(o)return o}}}};He.none=new He("",Object.create(null),0,8);var ss=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 He(i.name,r,i.id,i.flags):i)}return new n(t)}},ns=new WeakMap,_f=new WeakMap,Te;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays"})(Te||(Te={}));var be=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=qi.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 Hn(this.topNode,e)}cursorAt(e,t=0,i=0){let r=ns.get(this)||this.topNode,s=new Hn(r);return s.moveTo(e,t),ns.set(this,s._tree),s}get topNode(){return new xt(this,0,0,null)}resolve(e,t=0){let i=zn(ns.get(this)||this.topNode,e,t,!1);return ns.set(this,i),i}resolveInner(e,t=0){let i=zn(_f.get(this)||this.topNode,e,t,!0);return _f.set(this,i),i}resolveStack(e,t=0){return S0(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&Te.IncludeAnonymous)>0;for(let a=this.cursor(o|Te.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:Xl(He.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(He.none,t,i,r)))}static build(e){return T0(e)}};be.empty=new be(He.none,[],[],0);var Kl=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)}},Gt=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return He.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&&!(Yf(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 Yf(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 zn(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 xt&&n.index<0?null:n.parent;if(!o)return n;n=o}let s=i?0:Te.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof xt&&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 os=class{cursor(e=0){return new Hn(this,e)}getChild(e,t=null,i=null){let r=Uf(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return Uf(this,e,t,i)}resolve(e,t=0){return zn(this,e,t,!1)}resolveInner(e,t=0){return zn(this,e,t,!0)}matchContext(e){return _l(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}},xt=class n extends os{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(Yf(r,i,f,f+c.length)){if(c instanceof Gt){if(s&Te.ExcludeBuffers)continue;let u=c.findChild(0,c.buffer.length,t,i-f,r);if(u>-1)return new Fn(new Ul(o,c,e,f),null,u)}else if(s&Te.IncludeAnonymous||!c.type.isAnonymous||Jl(c)){let u;if(!(s&Te.IgnoreMounts)&&(u=qi.get(c))&&!u.overlay)return new n(u.tree,f,e,o);let p=new n(c,f,e,o);return s&Te.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,r)}}}if(s&Te.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&Te.IgnoreOverlays)&&(r=qi.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 Uf(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 _l(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 Ul=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Fn=class n extends os{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&Te.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 be(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Jf(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 xt&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new Gl(r,t)}var Gl=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Jf(this.heads)}};function S0(n,e,t){let i=n.resolveInner(e,t),r=null;for(let s=i instanceof xt?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=qi.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new xt(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(zn(l,e,t,!1))}}return r?Jf(r):i}var Hn=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 xt)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 xt?(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&Te.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Te.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Te.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&Te.IncludeAnonymous||l instanceof Gt||!l.type.isAnonymous||Jl(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 Fn(this.buffer,t,this.stack[r]);return this.bufferNode=new Fn(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 _l(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 _l(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 Jl(n){return n.children.some(e=>e instanceof Gt||!e.type.isAnonymous||Jl(e))}function T0(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Kl(t,t.length):t,a=i.types,h=0,c=0;function f(D,R,x,M,b,Y){let{id:K,start:U,end:q,size:k}=l,A=c;for(;k<0;)if(l.next(),k==-1){let j=s[K];x.push(j),M.push(U-D);return}else if(k==-3){h=K;return}else if(k==-4){c=K;return}else throw new RangeError(`Unrecognized record size: ${k}`);let T=a[K],F,te,le=U-D;if(q-U<=r&&(te=y(l.pos-R,b))){let j=new Uint16Array(te.size-te.skip),$=l.pos-te.size,J=j.length;for(;l.pos>$;)J=v(te.start,j,J);F=new Gt(j,q-te.start,i),le=te.start-D}else{let j=l.pos-k;l.next();let $=[],J=[],de=K>=o?K:-1,It=0,re=q;for(;l.pos>j;)de>=0&&l.id==de&&l.size>=0?(l.end<=re-r&&(m($,J,U,It,l.end,re,de,A),It=$.length,re=l.end),l.next()):Y>2500?u(U,j,$,J):f(U,j,$,J,de,Y+1);if(de>=0&&It>0&&It<$.length&&m($,J,U,It,U,re,de,A),$.reverse(),J.reverse(),de>-1&&It>0){let Oe=p(T);F=Xl(T,$,J,0,$.length,0,q-U,Oe,Oe)}else F=w(T,$,J,q-U,A-q)}x.push(F),M.push(le)}function u(D,R,x,M){let b=[],Y=0,K=-1;for(;l.pos>R;){let{id:U,start:q,end:k,size:A}=l;if(A>4)l.next();else{if(K>-1&&q<K)break;K<0&&(K=k-r),b.push(U,q,k),Y++,l.next()}}if(Y){let U=new Uint16Array(Y*4),q=b[b.length-2];for(let k=b.length-3,A=0;k>=0;k-=3)U[A++]=b[k],U[A++]=b[k+1]-q,U[A++]=b[k+2]-q,U[A++]=A;x.push(new Gt(U,b[2]-q,i)),M.push(q-D)}}function p(D){return(R,x,M)=>{let b=0,Y=R.length-1,K,U;if(Y>=0&&(K=R[Y])instanceof be){if(!Y&&K.type==D&&K.length==M)return K;(U=K.prop(Z.lookAhead))&&(b=x[Y]+K.length+U)}return w(D,R,x,M,b)}}function m(D,R,x,M,b,Y,K,U){let q=[],k=[];for(;D.length>M;)q.push(D.pop()),k.push(R.pop()+x-b);D.push(w(i.types[K],q,k,Y-b,U-Y)),R.push(b-x)}function w(D,R,x,M,b=0,Y){if(h){let K=[Z.contextHash,h];Y=Y?[K].concat(Y):[K]}if(b>25){let K=[Z.lookAhead,b];Y=Y?[K].concat(Y):[K]}return new be(D,R,x,M,Y)}function y(D,R){let x=l.fork(),M=0,b=0,Y=0,K=x.end-r,U={size:0,start:0,skip:0};e:for(let q=x.pos-D;x.pos>q;){let k=x.size;if(x.id==R&&k>=0){U.size=M,U.start=b,U.skip=Y,Y+=4,M+=4,x.next();continue}let A=x.pos-k;if(k<0||A<q||x.start<K)break;let T=x.id>=o?4:0,F=x.start;for(x.next();x.pos>A;){if(x.size<0)if(x.size==-3)T+=4;else break e;else x.id>=o&&(T+=4);x.next()}b=F,M+=k,Y+=T}return(R<0||M==D)&&(U.size=M,U.start=b,U.skip=Y),U.size>4?U:void 0}function v(D,R,x){let{id:M,start:b,end:Y,size:K}=l;if(l.next(),K>=0&&M<o){let U=x;if(K>4){let q=l.pos-(K-4);for(;l.pos>q;)x=v(D,R,x)}R[--x]=U,R[--x]=Y-D,R[--x]=b-D,R[--x]=M}else K==-3?h=M:K==-4&&(c=M);return x}let S=[],E=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,S,E,-1,0);let O=(e=n.length)!==null&&e!==void 0?e:S.length?E[0]+S[0].length:0;return new be(a[n.topID],S.reverse(),E.reverse(),O)}var Gf=new WeakMap;function rs(n,e){if(!n.isAnonymous||e instanceof Gt||e.type!=n)return 1;let t=Gf.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof be)){t=1;break}t+=rs(n,i)}Gf.set(e,t)}return t}function Xl(n,e,t,i,r,s,o,l,a){let h=0;for(let m=i;m<r;m++)h+=rs(n,e[m]);let c=Math.ceil(h*1.5/8),f=[],u=[];function p(m,w,y,v,S){for(let E=y;E<v;){let O=E,D=w[E],R=rs(n,m[E]);for(E++;E<v;E++){let x=rs(n,m[E]);if(R+x>=c)break;R+=x}if(E==O+1){if(R>c){let x=m[O];p(x.children,x.positions,0,x.children.length,w[O]+S);continue}f.push(m[O])}else{let x=w[E-1]+m[E-1].length-D;f.push(Xl(n,m,w,O,E,D,x,null,a))}u.push(D+S-s)}}return p(e,t,i,r,0),(l||a)(f,u,o)}var gi=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,m=Math.min(u.to,f)-h;u=p>=m?null:new n(p,m,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}},Vn=class{startParse(e,t,i){return typeof e=="string"&&(e=new Yl(e)),i=i?i.length?i.map(r=>new In(r.from,r.to)):[new In(0,0)]:[new In(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}}},Yl=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 tw=new Z({perNode:!0});var C0=0,je=class n{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=C0++}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 cs;return t=>t.modified.indexOf(e)>-1?t:cs.get(t.base||t,t.modified.concat(e).sort((i,r)=>i.id-r.id))}},A0=0,cs=class n{constructor(){this.instances=[],this.id=A0++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&M0(t,l.modified));if(i)return i;let r=[],s=new je(r,e,t);for(let l of t)l.instances.push(s);let o=L0(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 M0(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function L0(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 Qf(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 Ki(i,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return eu.add(e)}var eu=new Z,Ki=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}};Ki.empty=new Ki([],2,null);function ta(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 D0(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function tu(n,e,t,i=0,r=n.length){let s=new Ql(i,Array.isArray(e)?e:[e],t);s.highlightRange(n.cursor(),i,r,"",s.highlighters),s.flush(r)}var Ql=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=E0(e)||Ki.empty,f=D0(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(Z.mounted);if(u&&u.overlay){let p=e.node.enter(u.overlay[0].from+l,1),m=this.highlighters.filter(y=>!y.scope||y.scope(u.tree.type)),w=e.firstChild();for(let y=0,v=l;;y++){let S=y<u.overlay.length?u.overlay[y]:null,E=S?S.from+l:a,O=Math.max(t,v),D=Math.min(i,E);if(O<D&&w)for(;e.from<D&&(this.highlightRange(e,O,D,r,s),this.startSpan(Math.min(D,e.to),h),!(e.to>=E||!e.nextSibling())););if(!S||E>i)break;v=S.to+l,v>t&&(this.highlightRange(p.cursor(),Math.max(t,S.from+l),Math.min(i,v),"",m),this.startSpan(Math.min(i,v),h))}w&&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 E0(n){let e=n.type.prop(eu);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var B=je.define,ls=B(),Yt=B(),Xf=B(Yt),Zf=B(Yt),Jt=B(),as=B(Jt),Zl=B(Jt),Tt=B(),bi=B(Tt),vt=B(),St=B(),ea=B(),Wn=B(ea),hs=B(),I={comment:ls,lineComment:B(ls),blockComment:B(ls),docComment:B(ls),name:Yt,variableName:B(Yt),typeName:Xf,tagName:B(Xf),propertyName:Zf,attributeName:B(Zf),className:B(Yt),labelName:B(Yt),namespace:B(Yt),macroName:B(Yt),literal:Jt,string:as,docString:B(as),character:B(as),attributeValue:B(as),number:Zl,integer:B(Zl),float:B(Zl),bool:B(Jt),regexp:B(Jt),escape:B(Jt),color:B(Jt),url:B(Jt),keyword:vt,self:B(vt),null:B(vt),atom:B(vt),unit:B(vt),modifier:B(vt),operatorKeyword:B(vt),controlKeyword:B(vt),definitionKeyword:B(vt),moduleKeyword:B(vt),operator:St,derefOperator:B(St),arithmeticOperator:B(St),logicOperator:B(St),bitwiseOperator:B(St),compareOperator:B(St),updateOperator:B(St),definitionOperator:B(St),typeOperator:B(St),controlOperator:B(St),punctuation:ea,separator:B(ea),bracket:Wn,angleBracket:B(Wn),squareBracket:B(Wn),paren:B(Wn),brace:B(Wn),content:Tt,heading:bi,heading1:B(bi),heading2:B(bi),heading3:B(bi),heading4:B(bi),heading5:B(bi),heading6:B(bi),contentSeparator:B(Tt),list:B(Tt),quote:B(Tt),emphasis:B(Tt),strong:B(Tt),link:B(Tt),monospace:B(Tt),strikethrough:B(Tt),inserted:B(),deleted:B(),changed:B(),invalid:B(),meta:hs,documentMeta:B(hs),annotation:B(hs),processingInstruction:B(hs),definition:je.defineModifier(),constant:je.defineModifier(),function:je.defineModifier(),standard:je.defineModifier(),local:je.defineModifier(),special:je.defineModifier()},rw=ta([{tag:I.link,class:"tok-link"},{tag:I.heading,class:"tok-heading"},{tag:I.emphasis,class:"tok-emphasis"},{tag:I.strong,class:"tok-strong"},{tag:I.keyword,class:"tok-keyword"},{tag:I.atom,class:"tok-atom"},{tag:I.bool,class:"tok-bool"},{tag:I.url,class:"tok-url"},{tag:I.labelName,class:"tok-labelName"},{tag:I.inserted,class:"tok-inserted"},{tag:I.deleted,class:"tok-deleted"},{tag:I.literal,class:"tok-literal"},{tag:I.string,class:"tok-string"},{tag:I.number,class:"tok-number"},{tag:[I.regexp,I.escape,I.special(I.string)],class:"tok-string2"},{tag:I.variableName,class:"tok-variableName"},{tag:I.local(I.variableName),class:"tok-variableName tok-local"},{tag:I.definition(I.variableName),class:"tok-variableName tok-definition"},{tag:I.special(I.variableName),class:"tok-variableName2"},{tag:I.definition(I.propertyName),class:"tok-propertyName tok-definition"},{tag:I.typeName,class:"tok-typeName"},{tag:I.namespace,class:"tok-namespace"},{tag:I.className,class:"tok-className"},{tag:I.macroName,class:"tok-macroName"},{tag:I.propertyName,class:"tok-propertyName"},{tag:I.operator,class:"tok-operator"},{tag:I.comment,class:"tok-comment"},{tag:I.meta,class:"tok-meta"},{tag:I.invalid,class:"tok-invalid"},{tag:I.punctuation,class:"tok-punctuation"}]);var ia,_i=new Z;function O0(n){return z.define({combine:n?e=>e.concat(n):void 0})}var B0=new Z,$e=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,se.prototype.hasOwnProperty("tree")||Object.defineProperty(se.prototype,"tree",{get(){return Ce(this)}}),this.parser=t,this.extension=[Ui.of(this),se.languageData.of((s,o,l)=>{let a=iu(s,o,l),h=a.type.prop(_i);if(!h)return[];let c=s.facet(h),f=a.type.prop(B0);if(f){let u=a.resolve(o-a.from,l);for(let p of f)if(p.test(u,s)){let m=s.facet(p.facet);return p.type=="replace"?m:m.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return iu(e,t,i).type.prop(_i)==this.data}findRegions(e){let t=e.facet(Ui);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(_i)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(Z.mounted);if(l){if(l.tree.prop(_i)==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 be&&r(h,s.positions[a]+o)}};return r(Ce(e),0),i}get allowsNesting(){return!0}};$e.setState=X.define();function iu(n,e,t){let i=n.facet(Ui),r=Ce(n).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,t,Te.ExcludeBuffers))s.type.isTop&&(r=s);return r}function Ce(n){let e=n.field($e.state,!1);return e?e.tree:be.empty}function Pt(n,e,t=50){var i;let r=(i=n.field($e.state,!1))===null||i===void 0?void 0:i.context;if(!r)return null;let s=r.viewport;r.updateViewport({from:0,to:e});let o=r.isDone(e)||r.work(t,e)?r.tree:null;return r.updateViewport(s),o}var oa=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)}},jn=null,$n=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,[],be.empty,0,i,[],null)}startParse(){return this.parser.startParse(new oa(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=be.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(gi.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(gi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=jn;jn=this;try{return e()}finally{jn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=nu(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=gi.applyChanges(i,a),r=be.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=nu(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 Vn{createParse(t,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=jn;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 be(He.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 jn}};function nu(n,e,t){return gi.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var qn=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=$n.create(e.facet(Ui).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};$e.state=ce.define({create:qn.init,update(n,e){for(let t of e.effects)if(t.is($e.setState))return t.value;return e.startState.facet(Ui)!=e.state.facet(Ui)?qn.init(e.state):n.apply(e)}});var hu=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(hu=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var na=typeof navigator!="undefined"&&(!((ia=navigator.scheduling)===null||ia===void 0)&&ia.isInputPending)?()=>navigator.scheduling.isInputPending():null,P0=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($e.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($e.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=hu(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($e.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!na?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&i.doc.length>r+1e3,a=s.context.work(()=>na&&na()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:$e.setState.of(new qn(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=>Re(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()}}}),Ui=z.define({combine(n){return n.length?n[0]:null},enables:n=>[$e.state,P0,N.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),Gi=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var cu=z.define(),Zt=z.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 Xt(n){let e=n.facet(Zt);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Xi(n,e){let t="",i=n.tabSize,r=n.facet(Zt)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let s=0;s<e;s++)t+=r;return t}function ds(n,e){n instanceof se&&(n=new yi(n));for(let i of n.state.facet(cu)){let r=i(n,e);if(r!==void 0)return r}let t=Ce(n.state);return t.length>=e?N0(n,t,e):null}var yi=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Xt(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 Wt(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}},R0=new Z;function N0(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 fu(i,n,t)}function fu(n,e,t){for(let i=n;i;i=i.next){let r=z0(i.node);if(r)return r(la.create(e,t,i))}return 0}function I0(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function z0(n){let e=n.type.prop(R0);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(Z.closedBy))){let r=n.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>W0(o,!0,1,void 0,s&&!I0(o)?r.from:void 0)}return n.parent==null?F0:null}function F0(){return 0}var la=class n extends yi{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(H0(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return fu(this.context.next,this.base,this.pos)}};function H0(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function V0(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 W0(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?V0(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}var j0=200;function uu(){return se.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+j0)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=ds(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],p=Xi(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})}function du(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}var ps=X.define({map:du}),Zi=X.define({map:du});var ms=ce.define({create(){return _.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)if(t.is(ps)&&!q0(n,t.value.from,t.value.to)){let{preparePlaceholder:i}=e.state.facet(pa),r=i?_.replace({widget:new aa(i(e.state,t.value))}):ru;n=n.update({add:[r.range(t.value.from,t.value.to)]})}else t.is(Zi)&&(n=n.update({filter:(i,r)=>t.value.from!=i||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(r,s)=>{r<i&&s>i&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(r,s)=>s<=i||r>=i}))}return n},provide:n=>N.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,r)=>{t.push(i,r)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let i=n[t++],r=n[t++];if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(ru.range(i,r))}return _.set(e,!0)}});function gs(n){return n.field(ms,!1)||ie.empty}function $0(n,e,t){var i;let r=null;return(i=n.field(ms,!1))===null||i===void 0||i.between(e,t,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function q0(n,e,t){let i=!1;return n.between(e,e,(r,s)=>{r==e&&s==t&&(i=!0)}),i}var pu=n=>{let e=n.state.field(ms,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,r)=>{t.push(Zi.of({from:i,to:r}))}),n.dispatch({effects:t}),!0};var K0={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},pa=z.define({combine(n){return Pe(n,K0)}});function mu(n){let e=[ms,_0];return n&&e.push(pa.of(n)),e}function gu(n,e){let{state:t}=n,i=t.facet(pa),r=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=$0(n.state,l.from,l.to);a&&n.dispatch({effects:Zi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}var ru=_.replace({widget:new class extends Je{toDOM(n){return gu(n,null)}}}),aa=class extends Je{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return gu(e,this.value)}};var _0=N.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),Yi=class n{constructor(e,t){this.specs=e;let i;function r(l){let a=tt.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 $e?l=>l.prop(_i)==o.data:o?l=>l==o:void 0,this.style=ta(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new tt(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},ha=z.define(),bu=z.define({combine(n){return n.length?[n[0]]:null}});function ra(n){let e=n.facet(ha);return e.length?e:n.facet(bu)}function bs(n,e){let t=[U0],i;return n instanceof Yi&&(n.module&&t.push(N.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(bu.of(n)):i?t.push(ha.computeN([N.darkTheme],r=>r.facet(N.darkTheme)==(i=="dark")?[n]:[])):t.push(ha.of(n)),t}var ca=class{constructor(e){this.markCache=Object.create(null),this.tree=Ce(e.state),this.decorations=this.buildDeco(e,ra(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ce(e.state),i=ra(e.state),r=i!=ra(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return _.none;let i=new mt;for(let{from:r,to:s}of e.visibleRanges)tu(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=_.mark({class:a})))},r,s);return i.finish()}},U0=gt.high(ye.fromClass(ca,{decorations:n=>n.decorations})),yu=Yi.define([{tag:I.meta,color:"#404740"},{tag:I.link,textDecoration:"underline"},{tag:I.heading,textDecoration:"underline",fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strong,fontWeight:"bold"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.keyword,color:"#708"},{tag:[I.atom,I.bool,I.url,I.contentSeparator,I.labelName],color:"#219"},{tag:[I.literal,I.inserted],color:"#164"},{tag:[I.string,I.deleted],color:"#a11"},{tag:[I.regexp,I.escape,I.special(I.string)],color:"#e40"},{tag:I.definition(I.variableName),color:"#00f"},{tag:I.local(I.variableName),color:"#30a"},{tag:[I.typeName,I.namespace],color:"#085"},{tag:I.className,color:"#167"},{tag:[I.special(I.variableName),I.macroName],color:"#256"},{tag:I.definition(I.propertyName),color:"#00c"},{tag:I.comment,color:"#940"},{tag:I.invalid,color:"#f00"}]),G0=N.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ku=1e4,wu="()[]{}",xu=z.define({combine(n){return Pe(n,{afterCursor:!0,brackets:wu,maxScanDistance:ku,renderMatch:X0})}}),Y0=_.mark({class:"cm-matchingBracket"}),J0=_.mark({class:"cm-nonmatchingBracket"});function X0(n){let e=[],t=n.matched?Y0:J0;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 Z0=ce.define({create(){return _.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[],i=e.state.facet(xu);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=ut(e.state,r.head,-1,i)||r.head>0&&ut(e.state,r.head-1,1,i)||i.afterCursor&&(ut(e.state,r.head,1,i)||r.head<e.state.doc.length&&ut(e.state,r.head+1,-1,i));s&&(t=t.concat(i.renderMatch(s,e.state)))}return _.set(t,!0)},provide:n=>N.decorations.from(n)}),Q0=[Z0,G0];function vu(n={}){return[xu.of(n),Q0]}var eb=new Z;function fa(n,e,t){let i=n.prop(e<0?Z.openedBy:Z.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 ua(n){let e=n.type.prop(eb);return e?e(n.node):n}function ut(n,e,t,i={}){let r=i.maxScanDistance||ku,s=i.brackets||wu,o=Ce(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=fa(a.type,t,s);if(h&&a.from<a.to){let c=ua(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return tb(n,e,t,a,c,h,s)}}return ib(n,e,t,o,l.type,r,s)}function tb(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=ua(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(fa(c.type,t,o))h++;else if(fa(c.type,-t,o)){if(h==0){let f=ua(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 ib(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 m=e+u*t;for(let w=t>0?0:p.length-1,y=t>0?p.length:-1;w!=y;w+=t){let v=o.indexOf(p[w]);if(!(v<0||i.resolveInner(m+w,1).type!=r))if(v%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:m+w,to:m+w+1},matched:v>>1==a>>1};f--}}t>0&&(u+=p.length)}return c.done?{start:h,matched:!1}:null}function su(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 fs=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=su(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:su(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 nb(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||rb,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||ga}}function rb(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 ou=new WeakMap,Ji=class n extends $e{constructor(e){let t=O0(e.languageData),i=nb(e),r,s=new class extends Vn{createParse(o,l,a){return new da(r,o,l,a)}};super(t,s,[cu.of((o,l)=>this.getIndent(o,l))],e.name),this.topNode=ab(t),r=this,this.streamParser=i,this.stateAfter=new Z({perNode:!0}),this.tokenTable=e.tokenTable?new us(i.tokenTable):lb}static define(e){return new n(e)}getIndent(e,t){let i=Ce(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=ou.get(e.state),s!=null&&s<t-1e4&&(s=void 0));let l=ma(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,m=new fs(f.text,e.state.tabSize,e.unit,p<0?void 0:p);for(;m.pos<u-f.from;)Tu(this.streamParser.token,m,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&&ou.set(e.state,c.from),this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],e)}get allowsNesting(){return!1}};function ma(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 be&&a<r&&ma(n,l,a,i,r);if(h)return h}return null}function Su(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 be){if(!(a=Su(n,l,t-o,i-o,r)))break;return r?new be(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function sb(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&&ma(n,r.tree,0-r.offset,t,o),a;if(l&&(a=Su(n,r.tree,t+r.offset,l.pos+r.offset,!1)))return{state:l.state,tree:a}}return{state:n.streamParser.startState(i?Xt(i):4),tree:be.empty}}var da=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=$n.get(),o=r[0].from,{state:l,tree:a}=sb(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(Xt(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=$n.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
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 cs(t,e?e.state.tabSize:4,e?Xt(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=Su(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=be.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:tb,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new be(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 be(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Su(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 ma=Object.create(null),Kn=[He.none],tb=new rs(Kn),ou=[],lu=Object.create(null),Tu=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"]])Tu[n]=Cu(ma,e);var fs=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Tu)}resolve(e){return e?this.table[e]||(this.table[e]=Cu(this.extra,e)):0}},ib=new fs(ma);function ra(n,e){ou.indexOf(n)>-1||(ou.push(n),console.warn(e))}function Cu(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||I[h];c?typeof c=="function"?a.length?a=a.map(c):ra(h,`Modifier ${h} used at start of tag`):a.length?ra(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:ra(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=lu[r];if(s)return s.id;let o=lu[r]=He.define({id:Kn.length,name:i,props:[Zf({[i]:t})]});return Kn.push(o),o.id}function nb(n){let e=He.define({id:Kn.length,name:"Document",props:[_i.add(()=>n)],top:!0});return Kn.push(e),e}var lw={rtl:_.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:fe.RTL}),ltr:_.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:fe.LTR}),auto:_.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var rb=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=va(n.state,t.from);return i.line?sb(n):i.block?lb(n):!1};function xa(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 sb=xa(cb,0);var ob=xa(Pu,0);var lb=xa((n,e)=>Pu(n,e,hb(e)),0);function va(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var _n=50;function ab(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-_n,i),o=n.sliceDoc(r,r+_n),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*_n?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+_n),f=n.sliceDoc(r-_n,r));let u=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(f)[0].length,m=f.length-p-t.length;return c.slice(u,u+e.length)==e&&f.slice(m,m+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(m-1))?1:0}}:null}function hb(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 Pu(n,e,t=e.selection.ranges){let i=t.map(s=>va(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>ab(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 cb(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=va(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,m=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:m,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 ba=We.define(),fb=We.define(),ub=z.define(),Ru=z.define({combine(n){return Pe(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)})}}),Nu=ce.define({create(){return ki.empty},update(n,e){let t=e.state.facet(Ru),i=e.annotation(ba);if(i){let a=dt.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=ys(c,c.length,t.minDepth,a):c=Hu(c,e.startState.selection),new ki(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(fb);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(ve.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=dt.fromTransaction(e),o=e.annotation(ve.time),l=e.annotation(ve.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 ki(n.done.map(dt.fromJSON),n.undone.map(dt.fromJSON))}});function Iu(n={}){return[Nu,Ru.of(n),N.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?zu:e.inputType=="historyRedo"?ya:null;return i?(e.preventDefault(),i(t)):!1}})]}function ks(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(Nu,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var zu=ks(0,!1),ya=ks(1,!1),db=ks(0,!0),pb=ks(1,!0);var dt=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&&Ie.fromJSON(e.changes),[],e.mapped&&Et.fromJSON(e.mapped),e.startSelection&&D.fromJSON(e.startSelection),e.selectionsAfter.map(D.fromJSON))}static fromTransaction(e,t){let i=rt;for(let r of e.startState.facet(ub)){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,rt)}static selection(e){return new n(void 0,rt,void 0,void 0,e)}};function ys(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 mb(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 gb(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Fu(n,e){return n.length?e.length?n.concat(e):n:e}var rt=[],bb=200;function Hu(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-bb));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),ys(n,n.length-1,1e9,t.setSelAfter(i)))}else return[dt.selection([e])]}function yb(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 ga(n,e){if(!n.length)return n;let t=n.length,i=rt;for(;t;){let r=kb(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?[dt.selection(i)]:rt}function kb(n,e,t){let i=Fu(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):rt,t);if(!n.changes)return dt.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new dt(r,X.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var wb=/^(input\.type|delete)($|\.)/,ki=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||wb.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,mb(l.changes,e.changes))||i=="input.type.compose")?o=ys(o,o.length-1,r.minDepth,new dt(e.changes.compose(l.changes),Fu(e.effects,l.effects),l.mapped,l.startSelection,rt)):o=ys(o,o.length,r.minDepth,e),new n(o,rt,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:rt;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&gb(s[s.length-1],e)?this:new n(Hu(this.done,e),this.undone,t,i)}addMapping(e){return new n(ga(this.done,e),ga(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:ba.of({side:e,rest:yb(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?rt:r.slice(0,r.length-1);return s.mapped&&(l=ga(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:ba.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};ki.empty=new ki(rt,rt);var Vu=[{key:"Mod-z",run:zu,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ya,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ya,preventDefault:!0},{key:"Mod-u",run:db,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:pb,preventDefault:!0}];function Qi(n,e){return D.create(n.ranges.map(e),n.mainIndex)}function Ct(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function pt({state:n,dispatch:e},t){let i=Qi(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Ct(n,i)),!0)}function ws(n,e){return D.cursor(e?n.to:n.from)}function Wu(n,e){return pt(n,t=>t.empty?n.moveByChar(t,e):ws(t,e))}function Ne(n){return n.textDirectionAt(n.state.selection.main.head)==fe.LTR}var ju=n=>Wu(n,!Ne(n)),$u=n=>Wu(n,Ne(n));function qu(n,e){return pt(n,t=>t.empty?n.moveByGroup(t,e):ws(t,e))}var xb=n=>qu(n,!Ne(n)),vb=n=>qu(n,Ne(n));var gw=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Sb(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 xs(n,e,t){let i=Ce(n).resolveInner(e.head),r=t?Z.closedBy:Z.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;Sb(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?ut(n,i.from,1):ut(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,D.cursor(l,t?-1:1)}var Tb=n=>pt(n,e=>xs(n.state,e,!Ne(n))),Cb=n=>pt(n,e=>xs(n.state,e,Ne(n)));function Ku(n,e){return pt(n,t=>{if(!t.empty)return ws(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var _u=n=>Ku(n,!1),Uu=n=>Ku(n,!0);function Gu(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(N.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 Yu(n,e){let t=Gu(n),{state:i}=n,r=Qi(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):ws(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=N.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(Ct(i,r),{effects:s}),!0}var Au=n=>Yu(n,!1),ka=n=>Yu(n,!0);function Qt(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=D.cursor(i.from+s))}return r}var Ab=n=>pt(n,e=>Qt(n,e,!0)),Mb=n=>pt(n,e=>Qt(n,e,!1)),Db=n=>pt(n,e=>Qt(n,e,!Ne(n))),Lb=n=>pt(n,e=>Qt(n,e,Ne(n))),Eb=n=>pt(n,e=>D.cursor(n.lineBlockAt(e.head).from,1)),Ob=n=>pt(n,e=>D.cursor(n.lineBlockAt(e.head).to,-1));function Bb(n,e,t){let i=!1,r=Qi(n.selection,s=>{let o=ut(n,s.head,-1)||ut(n,s.head,1)||s.head>0&&ut(n,s.head-1,1)||s.head<n.doc.length&&ut(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?D.range(s.anchor,l):D.cursor(l)});return i?(e(Ct(n,r)),!0):!1}var Pb=({state:n,dispatch:e})=>Bb(n,e,!1);function st(n,e){let t=Qi(n.state.selection,i=>{let r=e(i);return D.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(Ct(n.state,t)),!0)}function Ju(n,e){return st(n,t=>n.moveByChar(t,e))}var Xu=n=>Ju(n,!Ne(n)),Zu=n=>Ju(n,Ne(n));function Qu(n,e){return st(n,t=>n.moveByGroup(t,e))}var Rb=n=>Qu(n,!Ne(n)),Nb=n=>Qu(n,Ne(n));var Ib=n=>st(n,e=>xs(n.state,e,!Ne(n))),zb=n=>st(n,e=>xs(n.state,e,Ne(n)));function ed(n,e){return st(n,t=>n.moveVertically(t,e))}var td=n=>ed(n,!1),id=n=>ed(n,!0);function nd(n,e){return st(n,t=>n.moveVertically(t,e,Gu(n).height))}var Mu=n=>nd(n,!1),Du=n=>nd(n,!0),Fb=n=>st(n,e=>Qt(n,e,!0)),Hb=n=>st(n,e=>Qt(n,e,!1)),Vb=n=>st(n,e=>Qt(n,e,!Ne(n))),Wb=n=>st(n,e=>Qt(n,e,Ne(n))),jb=n=>st(n,e=>D.cursor(n.lineBlockAt(e.head).from)),$b=n=>st(n,e=>D.cursor(n.lineBlockAt(e.head).to)),Lu=({state:n,dispatch:e})=>(e(Ct(n,{anchor:0})),!0),Eu=({state:n,dispatch:e})=>(e(Ct(n,{anchor:n.doc.length})),!0),Ou=({state:n,dispatch:e})=>(e(Ct(n,{anchor:n.selection.main.anchor,head:0})),!0),Bu=({state:n,dispatch:e})=>(e(Ct(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),qb=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Kb=({state:n,dispatch:e})=>{let t=vs(n).map(({from:i,to:r})=>D.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:D.create(t),userEvent:"select"})),!0},_b=({state:n,dispatch:e})=>{let t=Qi(n.selection,i=>{var r;let s=Ce(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 D.range(l.to,l.from)}return i});return e(Ct(n,t)),!0},Ub=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=D.create([t.main]):t.main.empty||(i=D.create([D.cursor(t.main.head)])),i?(e(Ct(n,i)),!0):!1};function Un(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=bs(n,a,!1)):a>o&&(t="delete.forward",a=bs(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=bs(n,o,!1),l=bs(n,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:D.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"?N.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function bs(n,e,t){if(n instanceof N)for(let i of n.state.facet(N.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var rd=(n,e)=>Un(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=Wt(o,r.tabSize),h=a%Xt(r)||Xt(r);for(let c=0;c<h&&o[o.length-1-c]==" ";c++)i--;l=i}else l=ke(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=ke(s.text,l-s.from,!1,!1)+s.from);return l}),wa=n=>rd(n,!1),sd=n=>rd(n,!0),od=(n,e)=>Un(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=ke(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}),ld=n=>od(n,!1),Gb=n=>od(n,!0),Yb=n=>Un(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var Jb=n=>Un(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Xb=n=>Un(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var Zb=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Q.of(["",""])},range:D.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Qb=({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:ke(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:ke(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:D.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function vs(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 ad(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of vs(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(D.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(D.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:D.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var ey=({state:n,dispatch:e})=>ad(n,e,!1),ty=({state:n,dispatch:e})=>ad(n,e,!0);function hd(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of vs(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 iy=({state:n,dispatch:e})=>hd(n,e,!1),ny=({state:n,dispatch:e})=>hd(n,e,!0),ry=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(vs(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Qi(e.selection,r=>n.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function sy(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ce(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(Z.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 oy=cd(!1),ly=cd(!0);function cd(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&&sy(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new yi(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=us(h,s);for(c==null&&(c=Wt(/^\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=["",Xi(e,c)];return a&&f.push(Xi(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Q.of(f)},range:D.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Sa(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:D.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}var ay=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new yi(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=Sa(n,(s,o,l)=>{let a=us(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Xi(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},hy=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Sa(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Zt)})}),{userEvent:"input.indent"})),!0),cy=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Sa(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Wt(r,n.tabSize),o=0,l=Xi(n,Math.max(0,s-Xt(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 fy=[{key:"Ctrl-b",run:ju,shift:Xu,preventDefault:!0},{key:"Ctrl-f",run:$u,shift:Zu},{key:"Ctrl-p",run:_u,shift:td},{key:"Ctrl-n",run:Uu,shift:id},{key:"Ctrl-a",run:Eb,shift:jb},{key:"Ctrl-e",run:Ob,shift:$b},{key:"Ctrl-d",run:sd},{key:"Ctrl-h",run:wa},{key:"Ctrl-k",run:Yb},{key:"Ctrl-Alt-h",run:ld},{key:"Ctrl-o",run:Zb},{key:"Ctrl-t",run:Qb},{key:"Ctrl-v",run:ka}],uy=[{key:"ArrowLeft",run:ju,shift:Xu,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:xb,shift:Rb,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Db,shift:Vb,preventDefault:!0},{key:"ArrowRight",run:$u,shift:Zu,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:vb,shift:Nb,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Lb,shift:Wb,preventDefault:!0},{key:"ArrowUp",run:_u,shift:td,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Lu,shift:Ou},{mac:"Ctrl-ArrowUp",run:Au,shift:Mu},{key:"ArrowDown",run:Uu,shift:id,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Eu,shift:Bu},{mac:"Ctrl-ArrowDown",run:ka,shift:Du},{key:"PageUp",run:Au,shift:Mu},{key:"PageDown",run:ka,shift:Du},{key:"Home",run:Mb,shift:Hb,preventDefault:!0},{key:"Mod-Home",run:Lu,shift:Ou},{key:"End",run:Ab,shift:Fb,preventDefault:!0},{key:"Mod-End",run:Eu,shift:Bu},{key:"Enter",run:oy},{key:"Mod-a",run:qb},{key:"Backspace",run:wa,shift:wa},{key:"Delete",run:sd},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ld},{key:"Mod-Delete",mac:"Alt-Delete",run:Gb},{mac:"Mod-Backspace",run:Jb},{mac:"Mod-Delete",run:Xb}].concat(fy.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),fd=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Tb,shift:Ib},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Cb,shift:zb},{key:"Alt-ArrowUp",run:ey},{key:"Shift-Alt-ArrowUp",run:iy},{key:"Alt-ArrowDown",run:ty},{key:"Shift-Alt-ArrowDown",run:ny},{key:"Escape",run:Ub},{key:"Mod-Enter",run:ly},{key:"Alt-l",mac:"Ctrl-l",run:Kb},{key:"Mod-i",run:_b,preventDefault:!0},{key:"Mod-[",run:cy},{key:"Mod-]",run:hy},{key:"Mod-Alt-\\",run:ay},{key:"Shift-Mod-k",run:ry},{key:"Shift-Mod-\\",run:Pb},{key:"Mod-/",run:rb},{key:"Alt-A",run:ob}].concat(uy);function oe(){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++)ud(n,arguments[e]);return n}function ud(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++)ud(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}var dd=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n,wi=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(dd(l)):dd,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 Se(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=dn(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Ve(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let l=r.charCodeAt(s),a=this.match(l,o,this.bufferPos+this.bufferStart);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,i){let r=null;for(let s=0;s<this.matches.length;s+=2){let o=this.matches[s],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[s+1],to:i}:(this.matches[s]++,l=!0)),l||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:i}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol!="undefined"&&(wi.prototype[Symbol.iterator]=function(){return this});var gd={from:-1,to:-1,match:/.*/.exec("")},Ea="gm"+(/x/.unicode==null?"":"u"),Cs=class{constructor(e,t,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=gd,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Ms(e,t,i,r,s);this.re=new RegExp(t,Ea+(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=Ds(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=Ds(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}}},Ta=new WeakMap,As=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=Ta.get(e);if(!r||r.from>=i||r.to<=t){let l=new n(t,e.sliceString(t,i));return Ta.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)),Ta.set(e,new n(o,s)),new n(t,s.slice(t-o,i-o))}},Ms=class{constructor(e,t,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=gd,this.matchPos=Ds(e,r),this.re=new RegExp(t,Ea+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=As.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=Ds(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=As.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(Cs.prototype[Symbol.iterator]=Ms.prototype[Symbol.iterator]=function(){return this});function dy(n){try{return new RegExp(n,Ea),!0}catch(e){return!1}}function Ds(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 Ca(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=oe("input",{class:"cm-textfield",name:"line",value:e}),i=oe("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:Ls.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},oe("label",n.state.phrase("Go to line"),": ",t)," ",oe("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 m=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),w=D.cursor(m.from+Math.max(0,Math.min(u,m.length)));n.dispatch({effects:[Ls.of(!1),N.scrollIntoView(w.from,{y:"center"})],selection:w}),n.focus()}return{dom:i}}var Ls=X.define(),pd=ce.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(Ls)&&(n=t.value);return n},provide:n=>pi.from(n,e=>e?Ca:null)}),py=n=>{let e=mi(n,Ca);if(!e){let t=[Ls.of(!0)];n.state.field(pd,!1)==null&&t.push(X.appendConfig.of([pd,my])),n.dispatch({effects:t}),e=mi(n,Ca)}return e&&e.dom.querySelector("input").select(),!0},my=N.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});var gy=({state:n,dispatch:e})=>{let{selection:t}=n,i=D.create(t.ranges.map(r=>n.wordAt(r.head)||D.cursor(r.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function by(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 wi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new wi(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 yy=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return gy({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=by(n,i);return r?(e(n.update({selection:n.selection.addRange(D.range(r.from,r.to),!1),effects:N.scrollIntoView(r.to)})),!0):!1},nn=z.define({combine(n){return Pe(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new La(e),scrollToMatch:e=>N.scrollIntoView(e)})}});var Es=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||dy(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 Ma(this):new Aa(this)}getCursor(e,t=0,i){let r=e.doc?e:se.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?tn(this,r,t,i):en(this,r,t,i)}},Os=class{constructor(e){this.spec=e}};function en(n,e,t,i){return new wi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?ky(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function ky(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(Bs(r,t-s))!=me.Word||e(Ps(r,t-s))!=me.Word)&&(e(Ps(r,i-s))!=me.Word||e(Bs(r,i-s))!=me.Word))}var Aa=class extends Os{constructor(e){super(e)}nextMatch(e,t,i){let r=en(this.spec,e,i,e.doc.length).nextOverlapping();return r.done&&(r=en(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=en(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=en(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=en(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 tn(n,e,t,i){return new Cs(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?wy(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function Bs(n,e){return n.slice(ke(n,e,!1),e)}function Ps(n,e){return n.slice(e,ke(n,e))}function wy(n){return(e,t,i)=>!i[0].length||(n(Bs(i.input,i.index))!=me.Word||n(Ps(i.input,i.index))!=me.Word)&&(n(Ps(i.input,i.index+i[0].length))!=me.Word||n(Bs(i.input,i.index+i[0].length))!=me.Word)}var Ma=class extends Os{nextMatch(e,t,i){let r=tn(this.spec,e,i,e.doc.length).next();return r.done&&(r=tn(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=tn(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=tn(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=tn(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)}},Yn=X.define(),Oa=X.define(),ei=ce.define({create(n){return new Gn(Da(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Yn)?n=new Gn(t.value.create(),n.panel):t.is(Oa)&&(n=new Gn(n.query,t.value?Ba:null));return n},provide:n=>pi.from(n,e=>e.panel)});var Gn=class{constructor(e,t){this.query=e,this.panel=t}},xy=_.mark({class:"cm-searchMatch"}),vy=_.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Sy=ye.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(ei))}update(n){let e=n.state.field(ei);(e!=n.startState.field(ei)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return _.none;let{view:t}=this,i=new mt;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?vy:xy)})}return i.finish()}},{decorations:n=>n.decorations});function Jn(n){return e=>{let t=e.state.field(ei,!1);return t&&t.query.spec.valid?n(e,t):kd(e)}}var Rs=Jn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let r=D.single(i.from,i.to),s=n.state.facet(nn);return n.dispatch({selection:r,effects:[Pa(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),yd(n),!0}),Ns=Jn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,r=e.prevMatch(t,i,i);if(!r)return!1;let s=D.single(r.from,r.to),o=n.state.facet(nn);return n.dispatch({selection:s,effects:[Pa(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),yd(n),!0}),Ty=Jn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:D.create(t.map(i=>D.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Cy=({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 wi(n.doc,n.sliceDoc(i,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(D.range(l.value.from,l.value.to))}return e(n.update({selection:D.create(s,o),userEvent:"select.search.matches"})),!0},md=Jn((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(N.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=D.single(s.from-c,s.to-c),h.push(Pa(n,s)),h.push(t.facet(nn).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),Ay=Jn((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:N.announce.of(i),userEvent:"input.replace.all"}),!0});function Ba(n){return n.state.facet(nn).createPanel(n)}function Da(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(nn);return new Es({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 bd(n){let e=mi(n,Ba);return e&&e.dom.querySelector("[main-field]")}function yd(n){let e=bd(n);e&&e==n.root.activeElement&&e.select()}var kd=n=>{let e=n.state.field(ei,!1);if(e&&e.panel){let t=bd(n);if(t&&t!=n.root.activeElement){let i=Da(n.state,e.query.spec);i.valid&&n.dispatch({effects:Yn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Oa.of(!0),e?Yn.of(Da(n.state,e.query.spec)):X.appendConfig.of(Dy)]});return!0},wd=n=>{let e=n.state.field(ei,!1);if(!e||!e.panel)return!1;let t=mi(n,Ba);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Oa.of(!1)}),!0},xd=[{key:"Mod-f",run:kd,scope:"editor search-panel"},{key:"F3",run:Rs,shift:Ns,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Rs,shift:Ns,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:wd,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Cy},{key:"Mod-Alt-g",run:py},{key:"Mod-d",run:yy,preventDefault:!0}],La=class{constructor(e){this.view=e;let t=this.query=e.state.field(ei).query.spec;this.commit=this.commit.bind(this),this.searchField=oe("input",{value:t.search,placeholder:Xe(e,"Find"),"aria-label":Xe(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=oe("input",{value:t.replace,placeholder:Xe(e,"Replace"),"aria-label":Xe(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=oe("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=oe("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=oe("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return oe("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=oe("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>Rs(e),[Xe(e,"next")]),i("prev",()=>Ns(e),[Xe(e,"previous")]),i("select",()=>Ty(e),[Xe(e,"all")]),oe("label",null,[this.caseField,Xe(e,"match case")]),oe("label",null,[this.reField,Xe(e,"regexp")]),oe("label",null,[this.wordField,Xe(e,"by word")]),...e.state.readOnly?[]:[oe("br"),this.replaceField,i("replace",()=>md(e),[Xe(e,"replace")]),i("replaceAll",()=>Ay(e),[Xe(e,"replace all")])],oe("button",{name:"close",onclick:()=>wd(e),"aria-label":Xe(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new Es({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:Yn.of(e)}))}keydown(e){Lf(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Ns:Rs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),md(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Yn)&&!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(nn).top}};function Xe(n,e){return n.state.phrase(e)}var Ss=30,Ts=/[\s\.,:;?!]/;function Pa(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-Ss),o=Math.min(r,t+Ss),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<Ss;a++)if(!Ts.test(l[a+1])&&Ts.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-Ss;a--)if(!Ts.test(l[a-1])&&Ts.test(l[a])){l=l.slice(0,a);break}}return N.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}var My=N.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"}}),Dy=[ei,gt.low(Sy),My];var Ra=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},xi=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(vi).markerFilter;s&&(r=s(r,i));let o=_.set(r.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?_.widget({widget:new Na(l),diagnostic:l}).range(l.from):_.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l,inclusive:!0}).range(l.from,l.to)),!0);return new n(o,t,rn(o))}};function rn(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 Ra(r,s,o.diagnostic),!1}),i}function Sd(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(Ws))||n.changes.touchesRange(t.from,t.to))}function Td(n,e){return n.field(Ze,!1)?e:e.concat(X.appendConfig.of(Pd))}function Ly(n,e){return{effects:Td(n,[Ws.of(e)])}}var Ws=X.define(),za=X.define(),Cd=X.define(),Ze=ce.define({create(){return new xi(_.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=rn(t,n.selected.diagnostic,r)||rn(t,null,r)}n=new xi(t,n.panel,i)}for(let t of e.effects)t.is(Ws)?n=xi.init(t.value,n.panel,e.state):t.is(za)?n=new xi(n.diagnostics,t.value?Vs.open:null,n.selected):t.is(Cd)&&(n=new xi(n.diagnostics,n.panel,t.value));return n},provide:n=>[pi.from(n,e=>e.panel),N.decorations.from(n,e=>e.diagnostics)]});var Ey=_.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function Oy(n,e,t){let{diagnostics:i}=n.state.field(Ze),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(vi).tooltipFilter;return l&&(r=l(r,n.state)),r.length?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:Ad(n,r)}}}:null}function Ad(n,e){return oe("ul",{class:"cm-tooltip-lint"},e.map(t=>Ed(n,t,!1)))}var Fa=n=>{let e=n.state.field(Ze,!1);(!e||!e.panel)&&n.dispatch({effects:Td(n.state,[za.of(!0)])});let t=mi(n,Vs.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Fs=n=>{let e=n.state.field(Ze,!1);return!e||!e.panel?!1:(n.dispatch({effects:za.of(!1)}),!0)},By=n=>{let e=n.state.field(Ze,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)};var Md=[{key:"Mod-Shift-m",run:Fa,preventDefault:!0},{key:"F8",run:By}],Py=ye.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(vi);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(vi);t.length&&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(Ly(this.view.state,r))},i=>{Re(this.view.state,i)})}}update(n){let e=n.state.facet(vi);(n.docChanged||e!=n.startState.facet(vi)||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)}}),vi=z.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},Pe(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 Dd(n,e={}){return[vi.of({source:n,config:e}),Py,Pd]}function Ld(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 Ed(n,e,t){var i;let r=t?Ld(e.actions):[];return oe("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},oe("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=rn(n.state.field(Ze).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),oe("u",h.slice(c,c+1)),h.slice(c+1)];return oe("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&oe("div",{class:"cm-diagnosticSource"},e.source))}var Na=class extends Je{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return oe("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},Hs=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ed(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Vs=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)Fs(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=Ld(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=rn(this.view.state.field(Ze).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=oe("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=oe("div",{class:"cm-panel-lint"},this.list,oe("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Fs(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Ze).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(Ze),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 Hs(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 Hs(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(Ze),i=rn(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Cd.of(i)})}static open(e){return new n(e)}};function zs(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 Is(n){return zs(`<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 Ry=N.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:Is("#d11")},".cm-lintRange-warning":{backgroundImage:Is("orange")},".cm-lintRange-info":{backgroundImage:Is("#999")},".cm-lintRange-hint":{backgroundImage:Is("#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 vd(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}var Ia=class extends nt{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((t,i)=>vd(t)<vd(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(js).tooltipFilter;return r&&(i=r(i,e.state)),i.length&&(t.onmouseover=()=>Iy(e,t,i)),t}};function Ny(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(Bd)&&n.dispatch({effects:Ha.of(null)})}};window.addEventListener("mousemove",t)}function Iy(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:Ha.of({pos:o.from,above:!1,create(){return{dom:Ad(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,Ny(n,e)}let{hoverTime:r}=n.state.facet(js),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function zy(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 Ia(t[r]).range(+r));return ie.of(i,!0)}var Fy=$l({class:"cm-gutter-lint",markers:n=>n.state.field(Od)}),Od=ce.define({create(){return ie.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet(js).markerFilter;for(let i of e.effects)if(i.is(Ws)){let r=i.value;t&&(r=t(r||[],e.state)),n=zy(e.state.doc,r.slice(0))}return n}}),Ha=X.define(),Bd=ce.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=Sd(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(Ha)?i.value:t,n)},provide:n=>Ut.from(n)}),Hy=N.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:zs('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:zs('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:zs('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Pd=[Ze,N.decorations.compute([Ze],n=>{let{selected:e,panel:t}=n.field(Ze);return!e||!t||e.from==e.to?_.none:_.set([Ey.range(e.from,e.to)])}),Ff(Oy,{hideOn:Sd}),Ry],js=z.define({combine(n){return Pe(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Rd(n={}){return[js.of(n),Od,Fy,Hy,Bd]}var qs=class{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=Ce(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),s=r.search(jd(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}};function Nd(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Vy(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let s=1;s<r.length;s++)t[r[s]]=!0}let i=Nd(e)+Nd(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Wy(n){let e=n.map(r=>typeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Vy(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}var Ks=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function ti(n){return n.selection.main.from}function jd(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?n:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}var jy=We.define();function $y(n,e,t,i){let{main:r}=n.selection,s=t-r.from,o=i-r.from;return Object.assign(Object.assign({},n.changeByRange(l=>l!=r&&t!=i&&n.sliceDoc(l.from+s,l.from+o)!=n.sliceDoc(t,i)?{range:l}:{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:e},range:D.cursor(l.from+s+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}var Id=new WeakMap;function qy(n){if(!Array.isArray(n))return n;let e=Id.get(n);return e||Id.set(n,e=Wy(n)),e}var _s=X.define(),Xn=X.define(),ja=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=Se(e,t),r=Ve(i);this.chars.push(i);let s=e.slice(t,t+r),o=s.toUpperCase();this.folded.push(Se(o==s?s.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,!0}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return!1;let{chars:t,folded:i,any:r,precise:s,byWord:o}=this;if(t.length==1){let S=Se(e,0),E=Ve(S),O=E==e.length?0:-100;if(S!=t[0])if(S==i[0])O+=-200;else return!1;return this.ret(O,[0,E])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let S=0,E=Math.min(e.length,200);S<E&&h<a;){let O=Se(e,S);(O==t[h]||O==i[h])&&(r[h++]=S),S+=Ve(O)}if(h<a)return!1}let c=0,f=0,u=!1,p=0,m=-1,w=-1,y=/[a-z]/.test(e),v=!0;for(let S=0,E=Math.min(e.length,200),O=0;S<E&&f<a;){let L=Se(e,S);l<0&&(c<a&&L==t[c]&&(s[c++]=S),p<a&&(L==t[p]||L==i[p]?(p==0&&(m=S),w=S+1,p++):p=0));let B,x=L<255?L>=48&&L<=57||L>=97&&L<=122?2:L>=65&&L<=90?1:0:(B=dn(L))!=B.toLowerCase()?1:B!=B.toUpperCase()?2:0;(!S||x==1&&y||O==0&&x!=0)&&(t[f]==L||i[f]==L&&(u=!0)?o[f++]=S:o.length&&(v=!1)),O=x,S+=Ve(L)}return f==a&&o[0]==0&&v?this.result(-100+(u?-200:0),o,e):p==a&&m==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):p==a?this.ret(-900-e.length,[m,w]):f==a?this.result(-100+(u?-200:0)+-700+(v?0:-1100),o,e):t.length==2?!1:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],s=0;for(let o of t){let l=o+(this.astral?Ve(Se(i,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-i.length,r)}},Ee=z.define({combine(n){return Pe(n,{activateOnTyping:!0,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ky,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>zd(e(i),t(i)),optionClass:(e,t)=>i=>zd(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function zd(n,e){return n?e?n+" "+e:n:e}function Ky(n,e,t,i,r,s){let o=n.textDirection==fe.RTL,l=o,a=!1,h="top",c,f,u=e.left-r.left,p=r.right-e.right,m=i.right-i.left,w=i.bottom-i.top;if(l&&u<Math.min(m,p)?l=!1:!l&&p<Math.min(m,u)&&(l=!0),m<=(l?u:p))c=Math.max(r.top,Math.min(t.top,r.bottom-w))-e.top,f=Math.min(400,l?u:p);else{a=!0,f=Math.min(400,(o?e.right:r.right-e.left)-30);let S=r.bottom-e.bottom;S>=w||S>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let y=(e.bottom-e.top)/s.offsetHeight,v=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${c/y}px; max-width: ${f/v}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function _y(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<s.length;){let c=s[h++],f=s[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function Va(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}var $a=class{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,l=e.state.facet(Ee);this.optionContent=_y(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Va(s.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(e,h[+f[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(Ee).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Xn.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:l}=i.open;(!r.open||r.open.options!=s)&&(this.range=Va(s.length,o,e.state.facet(Ee).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),l!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Va(t.options.length,t.selected,this.view.state.facet(Ee).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:r}=i;if(!r)return;let s=typeof r=="string"?document.createTextNode(r):r(i);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>Re(this.view.state,o,"completion info")):this.addInfoPane(s,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&Gy(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(Ee).positionInfo(this.view,t,r,i,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){let r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions"));let s=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=s&&(o>i.from||i.from==0))if(s=u,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let p=r.appendChild(document.createElement("completion-section"));p.textContent=u}}let c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let p=u(l,this.view.state,this.view,a);p&&c.appendChild(p)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}};function Uy(n,e){return t=>new $a(t,n,e)}function Gy(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/r:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function Fd(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Yy(n,e){let t=[],i=null,r=a=>{t.push(a);let{section:h}=a.completion;if(h){i||(i=[]);let c=typeof h=="string"?h:h.name;i.some(f=>f.name==c)||i.push(typeof h=="string"?{name:c}:h)}};for(let a of n)if(a.hasResult()){let h=a.result.getMatch;if(a.result.filter===!1)for(let c of a.result.options)r(new Ks(c,a.source,h?h(c):[],1e9-t.length));else{let c=new ja(e.sliceDoc(a.from,a.to));for(let f of a.result.options)if(c.match(f.label)){let u=f.displayLabel?h?h(f,c.matched):[]:c.matched;r(new Ks(f,a.source,u,c.score+(f.boost||0)))}}}if(i){let a=Object.create(null),h=0,c=(f,u)=>{var p,m;return((p=f.rank)!==null&&p!==void 0?p:1e9)-((m=u.rank)!==null&&m!==void 0?m:1e9)||(f.name<u.name?-1:1)};for(let f of i.sort(c))h-=1e5,a[f.name]=h;for(let f of t){let{section:u}=f.completion;u&&(f.score+=a[typeof u=="string"?u:u.name])}}let s=[],o=null,l=e.facet(Ee).compareCompletions;for(let a of t.sort((h,c)=>c.score-h.score||l(h.completion,c.completion))){let h=a.completion;!o||o.label!=h.label||o.detail!=h.detail||o.type!=null&&h.type!=null&&o.type!=h.type||o.apply!=h.apply||o.boost!=h.boost?s.push(a):Fd(a.completion)>Fd(o)&&(s[s.length-1]=a),o=a.completion}return s}var qa=class n{constructor(e,t,i,r,s,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new n(this.options,Hd(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,s){let o=Yy(e,t);if(!o.length)return r&&e.some(a=>a.state==1)?new n(r.options,r.attrs,r.tooltip,r.timestamp,r.selected,!0):null;let l=t.facet(Ee).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let a=r.options[r.selected].completion;for(let h=0;h<o.length;h++)if(o[h].completion==a){l=h;break}}return new n(o,Hd(i,l),{pos:e.reduce((a,h)=>h.hasResult()?Math.min(a,h.from):a,1e8),create:ek,above:s.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new n(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}},Ka=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(Zy,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Ee),s=(i.override||t.languageDataAt("autocomplete",ti(t)).map(qy)).map(l=>(this.active.find(h=>h.source==l)||new Rt(l,this.active.some(h=>h.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((l,a)=>l==this.active[a])&&(s=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!Jy(s,this.active)?o=qa.build(s,t,this.id,o,i):o&&o.disabled&&!s.some(l=>l.state==1)&&(o=null),!o&&s.every(l=>l.state!=1)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new Rt(l.source,0):l));for(let l of e.effects)l.is(qd)&&(o=o&&o.setSelected(l.value,this.id));return s==this.active&&o==this.open?this:new n(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:Xy}};function Jy(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult;)t++;for(;i<e.length&&!e[i].hasResult;)i++;let r=t==n.length,s=i==e.length;if(r||s)return r==s;if(n[t++].result!=e[i++].result)return!1}}var Xy={"aria-autocomplete":"list"};function Hd(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}var Zy=[];function _a(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}var Rt=class n{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=_a(e),r=this;i?r=r.handleUserEvent(e,i,t):e.docChanged?r=r.handleChange(e):e.selection&&r.state!=0&&(r=new n(r.source,0));for(let s of e.effects)if(s.is(_s))r=new n(r.source,1,s.value?ti(e.state):-1);else if(s.is(Xn))r=new n(r.source,0);else if(s.is($d))for(let o of s.value)o.source==r.source&&(r=o);return r}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new n(this.source,1)}handleChange(e){return e.changes.touchesRange(ti(e.startState))?new n(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new n(this.source,this.state,e.mapPos(this.explicitPos))}},Us=class n extends Rt{constructor(e,t,i,r,s){super(e,2,t),this.result=i,this.from=r,this.to=s}hasResult(){return!0}handleUserEvent(e,t,i){var r;let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=ti(e.state);if((this.explicitPos<0?l<=s:l<this.from)||l>o||t=="delete"&&ti(e.startState)==this.from)return new Rt(this.source,t=="input"&&i.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),h;return Qy(this.result.validFor,e.state,s,o)?new n(this.source,a,this.result,s,o):this.result.update&&(h=this.result.update(this.result,s,o,new qs(e.state,l,a>=0)))?new n(this.source,a,h,h.from,(r=h.to)!==null&&r!==void 0?r:ti(e.state)):new Rt(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Rt(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new n(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}};function Qy(n,e,t,i){if(!n)return!1;let r=e.sliceDoc(t,i);return typeof n=="function"?n(r,t,i,e):jd(n,!0).test(r)}var $d=X.define({map(n,e){return n.map(t=>t.map(e))}}),qd=X.define(),Qe=ce.define({create(){return Ka.start()},update(n,e){return n.update(e)},provide:n=>[Ut.from(n,e=>e.tooltip),N.contentAttributes.from(n,e=>e.attrs)]});function Kd(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(Qe).active.find(r=>r.source==e.source);return i instanceof Us?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},$y(n.state,t,i.from,i.to)),{annotations:jy.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}var ek=Uy(Qe,Kd);function $s(n,e="option"){return t=>{let i=t.state.field(Qe,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(Ee).interactionDelay)return!1;let r=1,s;e=="page"&&(s=jl(t,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+r*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:qd.of(l)}),!0}}var Ga=n=>{let e=n.state.field(Qe,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(Ee).interactionDelay?!1:Kd(n,e.open.options[e.open.selected])},tk=n=>n.state.field(Qe,!1)?(n.dispatch({effects:_s.of(!0)}),!0):!1,ik=n=>{let e=n.state.field(Qe,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Xn.of(null)}),!0)},Ua=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},nk=50,rk=1e3,sk=ye.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(Qe).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(Qe);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Qe)==e)return;let t=n.transactions.some(r=>(r.selection||r.docChanged)&&!_a(r));for(let r=0;r<this.running.length;r++){let s=this.running[r];if(t||s.updates.length+n.transactions.length>nk&&Date.now()-s.time>rk){for(let o of s.context.abortListeners)try{o()}catch(l){Re(this.view.state,l)}s.context.abortListeners=null,this.running.splice(r--,1)}else s.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(s=>s.is(_s)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.state.facet(Ee).activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.state==1&&!this.running.some(s=>s.active.source==r.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let r of n.transactions)_a(r)=="input"?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(Qe);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=ti(e),i=new qs(e,t,n.explicitPos==t),r=new Ua(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Xn.of(null)}),Re(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ee).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ee);for(let i=0;i<this.running.length;i++){let r=this.running[i];if(r.done===void 0)continue;if(this.running.splice(i--,1),r.done){let o=new Us(r.active.source,r.active.explicitPos,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:ti(r.updates.length?r.updates[0].startState:this.view.state));for(let l of r.updates)o=o.update(l,t);if(o.hasResult()){e.push(o);continue}}let s=this.view.state.field(Qe).active.find(o=>o.source==r.active.source);if(s&&s.state==1)if(r.done==null){let o=new Rt(r.active.source,0);for(let l of r.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:$d.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Qe,!1);if(e&&e.tooltip&&this.view.state.facet(Ee).closeOnBlur){let t=e.open&&jl(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Xn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:_s.of(!1)}),20),this.composing=0}}}),ok=N.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});var Gs={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Si=X.define({map(n,e){let t=e.mapPos(n,-1,De.TrackAfter);return t==null?void 0:t}}),Ya=new class extends at{};Ya.startSide=1;Ya.endSide=-1;var _d=ce.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(Si)&&(n=n.update({add:[Ya.range(t.value,t.value+1)]}));return n}});function Ud(){return[ck,_d]}var Wa="()[]{}<>";function lk(n){for(let e=0;e<Wa.length;e+=2)if(Wa.charCodeAt(e)==n)return Wa.charAt(e+1);return dn(n<128?n:n+1)}function ak(n,e){return n.languageDataAt("closeBrackets",e)[0]||Gs}var hk=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),ck=N.inputHandler.of((n,e,t,i)=>{if((hk?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&Ve(Se(i,0))==1||e!=r.from||t!=r.to)return!1;let s=fk(n.state,i);return s?(n.dispatch(s),!0):!1});function fk(n,e){let t=ak(n,n.selection.main.head),i=t.brackets||Gs.brackets;for(let r of i){let s=lk(Se(r,0));if(e==r)return s==r?pk(n,r,i.indexOf(r+r+r)>-1,t):uk(n,r,s,t.before||Gs.before);if(e==s&&Gd(n,n.selection.main.from))return dk(n,r,s)}return null}function Gd(n,e){let t=!1;return n.field(_d).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Ja(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Ve(Se(t,0)))}function uk(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:Si.of(o.to+e.length),range:D.range(o.anchor+e.length,o.head+e.length)};let l=Ja(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Si.of(o.head+e.length),range:D.cursor(o.head+e.length)}:{range:r=o}});return r?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function dk(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&Ja(n.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:D.cursor(s.head+t.length)}:i={range:s});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function pk(n,e,t,i){let r=i.stringPrefixes||Gs.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Si.of(l.to+e.length),range:D.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Ja(n.doc,a),c;if(h==e){if(Vd(n,a))return{changes:{insert:e+e,from:a},effects:Si.of(a+e.length),range:D.cursor(a+e.length)};if(Gd(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:D.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=Wd(n,a-2*e.length,r))>-1&&Vd(n,c))return{changes:{insert:e+e+e+e,from:a},effects:Si.of(a+e.length),range:D.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=me.Word&&Wd(n,a,r)>-1&&!mk(n,a,e,r))return{changes:{insert:e+e,from:a},effects:Si.of(a+e.length),range:D.cursor(a+e.length)}}return{range:s=l}});return s?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Vd(n,e){let t=Ce(n).resolveInner(e+1);return t.parent&&t.from==e}function mk(n,e,t,i){let r=Ce(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 Wd(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=me.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))!=me.Word)return s}return-1}function Yd(n={}){return[Qe,Ee.of(n),sk,gk,ok]}var Xa=[{key:"Ctrl-Space",run:tk},{key:"Escape",run:ik},{key:"ArrowDown",run:$s(!0)},{key:"ArrowUp",run:$s(!1)},{key:"PageDown",run:$s(!0,"page")},{key:"PageUp",run:$s(!1,"page")},{key:"Enter",run:Ga}],gk=gt.highest(ft.computeN([Ee],n=>n.facet(Ee).defaultKeymap?[Xa]:[]));var G={permittedHtmlTags:["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","meta","link"],implicitlyClosedHtmlTags:["br","hr","wbr","img","meta","link"],tags:{apostrophes:"mw-apostrophes",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",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",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",linkPageName:"mw-link-pagename",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateVariableDelimiter:"mw-templatevariable-delimiter"},get tokenTable(){let n={};for(let e of Object.values(this.tags))n[e]=je.define();return n}};var Zn={};am(Zn,{css:()=>op,javascript:()=>lp,json:()=>ap,lua:()=>fp});function Ys(n){n={...wk,...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,m=n.lineComment,w=n.supportsAtComponent===!0,y=n.highlightNonStandardPropertyKeywords!==!1,v,S;function E(k,A){return v=A,k}function O(k,A){var T=k.next();if(t[T]){var F=t[T](k,A);if(F!==!1)return F}if(T=="@")return k.eatWhile(/[\w\\\-]/),E("def",k.current());if(T=="="||(T=="~"||T=="|")&&k.eat("="))return E(null,"compare");if(T=='"'||T=="'")return A.tokenize=L(T),A.tokenize(k,A);if(T=="#")return k.eatWhile(/[\w\\\-]/),E("atom","hash");if(T=="!")return k.match(/^\s*\w*/),E("keyword","important");if(/\d/.test(T)||T=="."&&k.eat(/\d/))return k.eatWhile(/[\w.%]/),E("number","unit");if(T==="-"){if(/[\d.]/.test(k.peek()))return k.eatWhile(/[\w.%]/),E("number","unit");if(k.match(/^-[\w\\\-]*/))return k.eatWhile(/[\w\\\-]/),k.match(/^\s*:/,!1)?E("def","variable-definition"):E("variableName","variable");if(k.match(/^\w+-/))return E("meta","meta")}else return/[,+>*\/]/.test(T)?E(null,"select-op"):T=="."&&k.match(/^-?[_a-z][_a-z0-9-]*/i)?E("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(T)?E(null,T):k.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(k.current())&&(A.tokenize=B),E("variableName.function","variable")):/[\w\\\-]/.test(T)?(k.eatWhile(/[\w\\\-]/),E("property","word")):E(null,null)}function L(k){return function(A,T){for(var F=!1,te;(te=A.next())!=null;){if(te==k&&!F){k==")"&&A.backUp(1);break}F=!F&&te=="\\"}return(te==k||!F&&k!=")")&&(T.tokenize=null),E("string","string")}}function B(k,A){return k.next(),k.match(/^\s*[\"\')]/,!1)?A.tokenize=null:A.tokenize=L(")"),E(null,"(")}function x(k,A,T){this.type=k,this.indent=A,this.prev=T}function M(k,A,T,F){return k.context=new x(T,A.indentation()+(F===!1?0:A.indentUnit),k.context),T}function b(k){return k.context.prev&&(k.context=k.context.prev),k.context.type}function Y(k,A,T){return q[T.context.type](k,A,T)}function K(k,A,T,F){for(var te=F||1;te>0;te--)T.context=T.context.prev;return Y(k,A,T)}function U(k){var A=k.current().toLowerCase();u.hasOwnProperty(A)?S="atom":f.hasOwnProperty(A)?S="keyword":S="variable"}var q={};return q.top=function(k,A,T){if(k=="{")return M(T,A,"block");if(k=="}"&&T.context.prev)return b(T);if(w&&/@component/i.test(k))return M(T,A,"atComponentBlock");if(/^@(-moz-)?document$/i.test(k))return M(T,A,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(k))return M(T,A,"atBlock");if(/^@(font-face|counter-style)/i.test(k))return T.stateArg=k,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(k))return"keyframes";if(k&&k.charAt(0)=="@")return M(T,A,"at");if(k=="hash")S="builtin";else if(k=="word")S="tag";else{if(k=="variable-definition")return"maybeprop";if(k=="interpolation")return M(T,A,"interpolation");if(k==":")return"pseudo";if(p&&k=="(")return M(T,A,"parens")}return T.context.type},q.block=function(k,A,T){if(k=="word"){var F=A.current().toLowerCase();return l.hasOwnProperty(F)?(S="property","maybeprop"):a.hasOwnProperty(F)?(S=y?"string.special":"property","maybeprop"):p?(S=A.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(S="error","maybeprop")}else return k=="meta"?"block":!p&&(k=="hash"||k=="qualifier")?(S="error","block"):q.top(k,A,T)},q.maybeprop=function(k,A,T){return k==":"?M(T,A,"prop"):Y(k,A,T)},q.prop=function(k,A,T){if(k==";")return b(T);if(k=="{"&&p)return M(T,A,"propBlock");if(k=="}"||k=="{")return K(k,A,T);if(k=="(")return M(T,A,"parens");if(k=="hash"&&!/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(A.current()))S="error";else if(k=="word")U(A);else if(k=="interpolation")return M(T,A,"interpolation");return"prop"},q.propBlock=function(k,A,T){return k=="}"?b(T):k=="word"?(S="property","maybeprop"):T.context.type},q.parens=function(k,A,T){return k=="{"||k=="}"?K(k,A,T):k==")"?b(T):k=="("?M(T,A,"parens"):k=="interpolation"?M(T,A,"interpolation"):(k=="word"&&U(A),"parens")},q.pseudo=function(k,A,T){return k=="meta"?"pseudo":k=="word"?(S="variableName.constant",T.context.type):Y(k,A,T)},q.documentTypes=function(k,A,T){return k=="word"&&i.hasOwnProperty(A.current())?(S="tag",T.context.type):q.atBlock(k,A,T)},q.atBlock=function(k,A,T){if(k=="(")return M(T,A,"atBlock_parens");if(k=="}"||k==";")return K(k,A,T);if(k=="{")return b(T)&&M(T,A,p?"block":"top");if(k=="interpolation")return M(T,A,"interpolation");if(k=="word"){var F=A.current().toLowerCase();F=="only"||F=="not"||F=="and"||F=="or"?S="keyword":r.hasOwnProperty(F)?S="attribute":s.hasOwnProperty(F)?S="property":o.hasOwnProperty(F)?S="keyword":l.hasOwnProperty(F)?S="property":a.hasOwnProperty(F)?S=y?"string.special":"property":u.hasOwnProperty(F)?S="atom":f.hasOwnProperty(F)?S="keyword":S="error"}return T.context.type},q.atComponentBlock=function(k,A,T){return k=="}"?K(k,A,T):k=="{"?b(T)&&M(T,A,p?"block":"top",!1):(k=="word"&&(S="error"),T.context.type)},q.atBlock_parens=function(k,A,T){return k==")"?b(T):k=="{"||k=="}"?K(k,A,T,2):q.atBlock(k,A,T)},q.restricted_atBlock_before=function(k,A,T){return k=="{"?M(T,A,"restricted_atBlock"):k=="word"&&T.stateArg=="@counter-style"?(S="variable","restricted_atBlock_before"):Y(k,A,T)},q.restricted_atBlock=function(k,A,T){return k=="}"?(T.stateArg=null,b(T)):k=="word"?(T.stateArg=="@font-face"&&!h.hasOwnProperty(A.current().toLowerCase())||T.stateArg=="@counter-style"&&!c.hasOwnProperty(A.current().toLowerCase())?S="error":S="property","maybeprop"):"restricted_atBlock"},q.keyframes=function(k,A,T){return k=="word"?(S="variable","keyframes"):k=="{"?M(T,A,"top"):Y(k,A,T)},q.at=function(k,A,T){return k==";"?b(T):k=="{"||k=="}"?K(k,A,T):(k=="word"?S="tag":k=="hash"&&(S="builtin"),"at")},q.interpolation=function(k,A,T){return k=="}"?b(T):k=="{"||k==";"?K(k,A,T):(k=="word"?S="variable":k!="variable"&&k!="("&&k!=")"&&(S="error"),"interpolation")},{name:n.name,startState:function(){return{tokenize:null,state:e?"block":"top",stateArg:null,context:new x(e?"block":"top",0,null)}},token:function(k,A){if(!A.tokenize&&k.eatSpace())return null;var T=(A.tokenize||O)(k,A);return T&&typeof T=="object"&&(v=T[1],T=T[0]),S=T,v!="comment"&&(A.state=q[A.state](v,k,A)),S},indent:function(k,A,T){var F=k.context,te=A&&A.charAt(0),le=F.indent;return F.type=="prop"&&(te=="}"||te==")")&&(F=F.prev),F.prev&&(te=="}"&&(F.type=="block"||F.type=="top"||F.type=="interpolation"||F.type=="restricted_atBlock")?(F=F.prev,le=F.indent):(te==")"&&(F.type=="parens"||F.type=="atBlock_parens")||te=="{"&&(F.type=="at"||F.type=="atBlock"))&&(le=Math.max(0,F.indent-T.unit))),le},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:m,block:{open:"/*",close:"*/"}},autocomplete:kk}}}function At(n){for(var e={},t=0;t<n.length;++t)e[n[t].toLowerCase()]=!0;return e}var Jd=["domain","regexp","url","url-prefix"],Xd=At(Jd),Zd=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],Js=At(Zd),Qd=["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"],Xs=At(Qd),ep=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],Za=At(ep),tp=["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"],Zs=At(tp),ip=["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"],Qs=At(ip),bk=["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],eo=At(bk),yk=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],np=At(yk),rp=["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"],to=At(rp),sp=["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"],io=At(sp),kk=Jd.concat(Zd).concat(Qd).concat(ep).concat(tp).concat(ip).concat(rp).concat(sp);var wk={documentTypes:Xd,mediaTypes:Js,mediaFeatures:Xs,mediaValueKeywords:Za,propertyKeywords:Zs,nonStandardPropertyKeywords:Qs,fontProperties:eo,counterDescriptors:np,colorKeywords:to,valueKeywords:io,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=ii,ii(n,e)):!1}}},op=Ys({name:"css"});function ii(n,e){for(var t=!1,i;(i=n.next())!=null;){if(t&&i=="/"){e.tokenize=null;break}t=i=="*"}return["comment","comment"]}var zw=Ys({name:"scss",mediaTypes:Js,mediaFeatures:Xs,mediaValueKeywords:Za,propertyKeywords:Zs,nonStandardPropertyKeywords:Qs,colorKeywords:to,valueKeywords:io,fontProperties:eo,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=ii,ii(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}}}),Fw=Ys({name:"less",mediaTypes:Js,mediaFeatures:Xs,mediaValueKeywords:Za,propertyKeywords:Zs,nonStandardPropertyKeywords:Qs,colorKeywords:to,valueKeywords:io,fontProperties:eo,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=ii,ii(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"]}}}),Hw=Ys({name:"gss",documentTypes:Xd,mediaTypes:Js,mediaFeatures:Xs,propertyKeywords:Zs,nonStandardPropertyKeywords:Qs,fontProperties:eo,counterDescriptors:np,colorKeywords:to,valueKeywords:io,supportsAtComponent:!0,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=ii,ii(n,e)):!1}}});function no(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(Ke){return{type:Ke,style:"keyword"}}var g=d("keyword a"),C=d("keyword b"),R=d("keyword c"),H=d("keyword d"),ee=d("operator"),he={type:"atom",style:"atom"};return{if:d("if"),while:g,with:g,else:C,do:C,try:C,finally:C,return:H,break:H,continue:H,new:d("new"),delete:R,void:R,throw:R,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:ee,typeof:ee,instanceof:ee,true:he,false:he,null:he,undefined:he,NaN:he,Infinity:he,this:d("this"),class:d("class"),super:d("atom"),yield:R,export:d("export"),import:d("import"),extends:R,await:R}}(),l=/[+\-*&%=<>!?|~^@]/,a=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function h(d){for(var g=!1,C,R=!1;(C=d.next())!=null;){if(!g){if(C=="/"&&!R)return;C=="["?R=!0:R&&C=="]"&&(R=!1)}g=!g&&C=="\\"}}var c,f;function u(d,g,C){return c=d,f=C,g}function p(d,g){var C=d.next();if(C=='"'||C=="'")return g.tokenize=m(C),g.tokenize(d,g);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("*")?(g.tokenize=w,w(d,g)):d.eat("/")?(d.skipToEnd(),u("comment","comment")):om(d,g,1)?(h(d),d.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(d.eat("="),u("operator","operator",d.current()));if(C=="`")return g.tokenize=y,y(d,g);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!=">"||!g.lexical||g.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 R=d.current();if(g.lastType!="."){if(o.propertyIsEnumerable(R)){var H=o[R];return u(H.type,H.style,R)}if(R=="async"&&d.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",R)}return u("variable","variable",R)}}function m(d){return function(g,C){var R=!1,H;if(t&&g.peek()=="@"&&g.match(a))return C.tokenize=p,u("jsonld-keyword","meta");for(;(H=g.next())!=null&&!(H==d&&!R);)R=!R&&H=="\\";return R||(C.tokenize=p),u("string","string")}}function w(d,g){for(var C=!1,R;R=d.next();){if(R=="/"&&C){g.tokenize=p;break}C=R=="*"}return u("comment","comment")}function y(d,g){for(var C=!1,R;(R=d.next())!=null;){if(!C&&(R=="`"||R=="$"&&d.eat("{"))){g.tokenize=p;break}C=!C&&R=="\\"}return u("quasi","string.special",d.current())}var v="([{}])";function S(d,g){g.fatArrowAt&&(g.fatArrowAt=null);var C=d.string.indexOf("=>",d.start);if(!(C<0)){if(r){var R=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(d.string.slice(d.start,C));R&&(C=R.index)}for(var H=0,ee=!1,he=C-1;he>=0;--he){var Ke=d.string.charAt(he),et=v.indexOf(Ke);if(et>=0&&et<3){if(!H){++he;break}if(--H==0){Ke=="("&&(ee=!0);break}}else if(et>=3&&et<6)++H;else if(s.test(Ke))ee=!0;else if(/["'\/`]/.test(Ke))for(;;--he){if(he==0)return;var ln=d.string.charAt(he-1);if(ln==Ke&&d.string.charAt(he-2)!="\\"){he--;break}}else if(ee&&!H){++he;break}}ee&&!H&&(g.fatArrowAt=he)}}var E={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function O(d,g,C,R,H,ee){this.indented=d,this.column=g,this.type=C,this.prev=H,this.info=ee,R!=null&&(this.align=R)}function L(d,g){for(var C=d.localVars;C;C=C.next)if(C.name==g)return!0;for(var R=d.context;R;R=R.prev)for(var C=R.vars;C;C=C.next)if(C.name==g)return!0}function B(d,g,C,R,H){var ee=d.cc;for(x.state=d,x.stream=H,x.marked=null,x.cc=ee,x.style=g,d.lexical.hasOwnProperty("align")||(d.lexical.align=!0);;){var he=ee.length?ee.pop():i?re:de;if(he(C,R)){for(;ee.length&&ee[ee.length-1].lex;)ee.pop()();return x.marked?x.marked:C=="variable"&&L(d,R)?"variableName.local":g}}}var x={state:null,column:null,marked:null,cc:null};function M(){for(var d=arguments.length-1;d>=0;d--)x.cc.push(arguments[d])}function b(){return M.apply(null,arguments),!0}function Y(d,g){for(var C=g;C;C=C.next)if(C.name==d)return!0;return!1}function K(d){var g=x.state;if(x.marked="def",g.context){if(g.lexical.info=="var"&&g.context&&g.context.block){var C=U(d,g.context);if(C!=null){g.context=C;return}}else if(!Y(d,g.localVars)){g.localVars=new A(d,g.localVars);return}}n.globalVars&&!Y(d,g.globalVars)&&(g.globalVars=new A(d,g.globalVars))}function U(d,g){if(g)if(g.block){var C=U(d,g.prev);return C?C==g.prev?g:new k(C,g.vars,!0):null}else return Y(d,g.vars)?g:new k(g.prev,new A(d,g.vars),!1);else return null}function q(d){return d=="public"||d=="private"||d=="protected"||d=="abstract"||d=="readonly"}function k(d,g,C){this.prev=d,this.vars=g,this.block=C}function A(d,g){this.name=d,this.next=g}var T=new A("this",new A("arguments",null));function F(){x.state.context=new k(x.state.context,x.state.localVars,!1),x.state.localVars=T}function te(){x.state.context=new k(x.state.context,x.state.localVars,!0),x.state.localVars=null}F.lex=te.lex=!0;function le(){x.state.localVars=x.state.context.vars,x.state.context=x.state.context.prev}le.lex=!0;function j(d,g){var C=function(){var R=x.state,H=R.indented;if(R.lexical.type=="stat")H=R.lexical.indented;else for(var ee=R.lexical;ee&&ee.type==")"&&ee.align;ee=ee.prev)H=ee.indented;R.lexical=new O(H,x.stream.column(),d,null,R.lexical,g)};return C.lex=!0,C}function $(){var d=x.state;d.lexical.prev&&(d.lexical.type==")"&&(d.indented=d.lexical.indented),d.lexical=d.lexical.prev)}$.lex=!0;function J(d){function g(C){return C==d?b():d==";"||C=="}"||C==")"||C=="]"?M():b(g)}return g}function de(d,g){return d=="var"?b(j("vardef",g),wo,J(";"),$):d=="keyword a"?b(j("form"),go,de,$):d=="keyword b"?b(j("form"),de,$):d=="keyword d"?x.stream.match(/^\s*$/,!1)?b():b(j("stat"),Mi,J(";"),$):d=="debugger"?b(J(";")):d=="{"?b(j("}"),te,cr,$,le):d==";"?b():d=="if"?(x.state.lexical.info=="else"&&x.state.cc[x.state.cc.length-1]==$&&x.state.cc.pop()(),b(j("form"),go,de,$,gh)):d=="function"?b(Ft):d=="for"?b(j("form"),te,bh,de,le,$):d=="class"||r&&g=="interface"?(x.marked="keyword",b(j("form",d=="class"?d:g),kh,$)):d=="variable"?r&&g=="declare"?(x.marked="keyword",b(de)):r&&(g=="module"||g=="enum"||g=="type")&&x.stream.match(/^\s*\w/,!1)?(x.marked="keyword",g=="enum"?b(vh):g=="type"?b(yh,J("operator"),ae,J(";")):b(j("form"),ot,J("{"),j("}"),cr,$,$)):r&&g=="namespace"?(x.marked="keyword",b(j("form"),re,de,$)):r&&g=="abstract"?(x.marked="keyword",b(de)):b(j("stat"),Wp):d=="switch"?b(j("form"),go,J("{"),j("}","switch"),te,cr,$,$,le):d=="case"?b(re,J(":")):d=="default"?b(J(":")):d=="catch"?b(j("form"),F,It,de,$,le):d=="export"?b(j("stat"),em,$):d=="import"?b(j("stat"),tm,$):d=="async"?b(de):g=="@"?b(re,de):M(j("stat"),re,J(";"),$)}function It(d){if(d=="(")return b(oi,J(")"))}function re(d,g){return fh(d,g,!1)}function Oe(d,g){return fh(d,g,!0)}function go(d){return d!="("?M():b(j(")"),Mi,J(")"),$)}function fh(d,g,C){if(x.state.fatArrowAt==x.stream.start){var R=C?dh:uh;if(d=="(")return b(F,j(")"),Ae(oi,")"),$,J("=>"),R,le);if(d=="variable")return M(F,ot,J("=>"),R,le)}var H=C?Di:ri;return E.hasOwnProperty(d)?b(H):d=="function"?b(Ft,H):d=="class"||r&&g=="interface"?(x.marked="keyword",b(j("form"),Qp,$)):d=="keyword c"||d=="async"?b(C?Oe:re):d=="("?b(j(")"),Mi,J(")"),$,H):d=="operator"||d=="spread"?b(C?Oe:re):d=="["?b(j("]"),nm,$,H):d=="{"?sn(hr,"}",null,H):d=="quasi"?M(ar,H):d=="new"?b(Fp(C)):b()}function Mi(d){return d.match(/[;\}\)\],]/)?M():M(re)}function ri(d,g){return d==","?b(Mi):Di(d,g,!1)}function Di(d,g,C){var R=C==!1?ri:Di,H=C==!1?re:Oe;if(d=="=>")return b(F,C?dh:uh,le);if(d=="operator")return/\+\+|--/.test(g)||r&&g=="!"?b(R):r&&g=="<"&&x.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?b(j(">"),Ae(ae,">"),$,R):g=="?"?b(re,J(":"),H):b(H);if(d=="quasi")return M(ar,R);if(d!=";"){if(d=="(")return sn(Oe,")","call",R);if(d==".")return b(jp,R);if(d=="[")return b(j("]"),Mi,J("]"),$,R);if(r&&g=="as")return x.marked="keyword",b(ae,R);if(d=="regexp")return x.state.lastType=x.marked="operator",x.stream.backUp(x.stream.pos-x.stream.start-1),b(H)}}function ar(d,g){return d!="quasi"?M():g.slice(g.length-2)!="${"?b(ar):b(Mi,zp)}function zp(d){if(d=="}")return x.marked="string.special",x.state.tokenize=y,b(ar)}function uh(d){return S(x.stream,x.state),M(d=="{"?de:re)}function dh(d){return S(x.stream,x.state),M(d=="{"?de:Oe)}function Fp(d){return function(g){return g=="."?b(d?Vp:Hp):g=="variable"&&r?b(Gp,d?Di:ri):M(d?Oe:re)}}function Hp(d,g){if(g=="target")return x.marked="keyword",b(ri)}function Vp(d,g){if(g=="target")return x.marked="keyword",b(Di)}function Wp(d){return d==":"?b($,de):M(ri,J(";"),$)}function jp(d){if(d=="variable")return x.marked="property",b()}function hr(d,g){if(d=="async")return x.marked="property",b(hr);if(d=="variable"||x.style=="keyword"){if(x.marked="property",g=="get"||g=="set")return b($p);var C;return r&&x.state.fatArrowAt==x.stream.start&&(C=x.stream.match(/^\s*:\s*/,!1))&&(x.state.fatArrowAt=x.stream.pos+C[0].length),b(si)}else{if(d=="number"||d=="string")return x.marked=t?"property":x.style+" property",b(si);if(d=="jsonld-keyword")return b(si);if(r&&q(g))return x.marked="keyword",b(hr);if(d=="[")return b(re,Li,J("]"),si);if(d=="spread")return b(Oe,si);if(g=="*")return x.marked="keyword",b(hr);if(d==":")return M(si)}}function $p(d){return d!="variable"?M(si):(x.marked="property",b(Ft))}function si(d){if(d==":")return b(Oe);if(d=="(")return M(Ft)}function Ae(d,g,C){function R(H,ee){if(C?C.indexOf(H)>-1:H==","){var he=x.state.lexical;return he.info=="call"&&(he.pos=(he.pos||0)+1),b(function(Ke,et){return Ke==g||et==g?M():M(d)},R)}return H==g||ee==g?b():C&&C.indexOf(";")>-1?M(d):b(J(g))}return function(H,ee){return H==g||ee==g?b():M(d,R)}}function sn(d,g,C){for(var R=3;R<arguments.length;R++)x.cc.push(arguments[R]);return b(j(g,C),Ae(d,g),$)}function cr(d){return d=="}"?b():M(de,cr)}function Li(d,g){if(r){if(d==":")return b(ae);if(g=="?")return b(Li)}}function qp(d,g){if(r&&(d==":"||g=="in"))return b(ae)}function ph(d){if(r&&d==":")return x.stream.match(/^\s*\w+\s+is\b/,!1)?b(re,Kp,ae):b(ae)}function Kp(d,g){if(g=="is")return x.marked="keyword",b()}function ae(d,g){if(g=="keyof"||g=="typeof"||g=="infer"||g=="readonly")return x.marked="keyword",b(g=="typeof"?Oe:ae);if(d=="variable"||g=="void")return x.marked="type",b(Dt);if(g=="|"||g=="&")return b(ae);if(d=="string"||d=="number"||d=="atom")return b(Dt);if(d=="[")return b(j("]"),Ae(ae,"]",","),$,Dt);if(d=="{")return b(j("}"),bo,$,Dt);if(d=="(")return b(Ae(ko,")"),_p,Dt);if(d=="<")return b(Ae(ae,">"),ae);if(d=="quasi")return M(yo,Dt)}function _p(d){if(d=="=>")return b(ae)}function bo(d){return d.match(/[\}\)\]]/)?b():d==","||d==";"?b(bo):M(on,bo)}function on(d,g){if(d=="variable"||x.style=="keyword")return x.marked="property",b(on);if(g=="?"||d=="number"||d=="string")return b(on);if(d==":")return b(ae);if(d=="[")return b(J("variable"),qp,J("]"),on);if(d=="(")return M(Oi,on);if(!d.match(/[;\}\)\],]/))return b()}function yo(d,g){return d!="quasi"?M():g.slice(g.length-2)!="${"?b(yo):b(ae,Up)}function Up(d){if(d=="}")return x.marked="string.special",x.state.tokenize=y,b(yo)}function ko(d,g){return d=="variable"&&x.stream.match(/^\s*[?:]/,!1)||g=="?"?b(ko):d==":"?b(ae):d=="spread"?b(ko):M(ae)}function Dt(d,g){if(g=="<")return b(j(">"),Ae(ae,">"),$,Dt);if(g=="|"||d=="."||g=="&")return b(ae);if(d=="[")return b(ae,J("]"),Dt);if(g=="extends"||g=="implements")return x.marked="keyword",b(ae);if(g=="?")return b(ae,J(":"),ae)}function Gp(d,g){if(g=="<")return b(j(">"),Ae(ae,">"),$,Dt)}function fr(){return M(ae,Yp)}function Yp(d,g){if(g=="=")return b(ae)}function wo(d,g){return g=="enum"?(x.marked="keyword",b(vh)):M(ot,Li,zt,Xp)}function ot(d,g){if(r&&q(g))return x.marked="keyword",b(ot);if(d=="variable")return K(g),b();if(d=="spread")return b(ot);if(d=="[")return sn(Jp,"]");if(d=="{")return sn(mh,"}")}function mh(d,g){return d=="variable"&&!x.stream.match(/^\s*:/,!1)?(K(g),b(zt)):(d=="variable"&&(x.marked="property"),d=="spread"?b(ot):d=="}"?M():d=="["?b(re,J("]"),J(":"),mh):b(J(":"),ot,zt))}function Jp(){return M(ot,zt)}function zt(d,g){if(g=="=")return b(Oe)}function Xp(d){if(d==",")return b(wo)}function gh(d,g){if(d=="keyword b"&&g=="else")return b(j("form","else"),de,$)}function bh(d,g){if(g=="await")return b(bh);if(d=="(")return b(j(")"),Zp,$)}function Zp(d){return d=="var"?b(wo,Ei):d=="variable"?b(Ei):M(Ei)}function Ei(d,g){return d==")"?b():d==";"?b(Ei):g=="in"||g=="of"?(x.marked="keyword",b(re,Ei)):M(re,Ei)}function Ft(d,g){if(g=="*")return x.marked="keyword",b(Ft);if(d=="variable")return K(g),b(Ft);if(d=="(")return b(F,j(")"),Ae(oi,")"),$,ph,de,le);if(r&&g=="<")return b(j(">"),Ae(fr,">"),$,Ft)}function Oi(d,g){if(g=="*")return x.marked="keyword",b(Oi);if(d=="variable")return K(g),b(Oi);if(d=="(")return b(F,j(")"),Ae(oi,")"),$,ph,le);if(r&&g=="<")return b(j(">"),Ae(fr,">"),$,Oi)}function yh(d,g){if(d=="keyword"||d=="variable")return x.marked="type",b(yh);if(g=="<")return b(j(">"),Ae(fr,">"),$)}function oi(d,g){return g=="@"&&b(re,oi),d=="spread"?b(oi):r&&q(g)?(x.marked="keyword",b(oi)):r&&d=="this"?b(Li,zt):M(ot,Li,zt)}function Qp(d,g){return d=="variable"?kh(d,g):ur(d,g)}function kh(d,g){if(d=="variable")return K(g),b(ur)}function ur(d,g){if(g=="<")return b(j(">"),Ae(fr,">"),$,ur);if(g=="extends"||g=="implements"||r&&d==",")return g=="implements"&&(x.marked="keyword"),b(r?ae:re,ur);if(d=="{")return b(j("}"),Lt,$)}function Lt(d,g){if(d=="async"||d=="variable"&&(g=="static"||g=="get"||g=="set"||r&&q(g))&&x.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1))return x.marked="keyword",b(Lt);if(d=="variable"||x.style=="keyword")return x.marked="property",b(dr,Lt);if(d=="number"||d=="string")return b(dr,Lt);if(d=="[")return b(re,Li,J("]"),dr,Lt);if(g=="*")return x.marked="keyword",b(Lt);if(r&&d=="(")return M(Oi,Lt);if(d==";"||d==",")return b(Lt);if(d=="}")return b();if(g=="@")return b(re,Lt)}function dr(d,g){if(g=="!"||g=="?")return b(dr);if(d==":")return b(ae,zt);if(g=="=")return b(Oe);var C=x.state.lexical.prev,R=C&&C.info=="interface";return M(R?Oi:Ft)}function em(d,g){return g=="*"?(x.marked="keyword",b(xo,J(";"))):g=="default"?(x.marked="keyword",b(re,J(";"))):d=="{"?b(Ae(wh,"}"),xo,J(";")):M(de)}function wh(d,g){if(g=="as")return x.marked="keyword",b(J("variable"));if(d=="variable")return M(Oe,wh)}function tm(d){return d=="string"?b():d=="("?M(re):d=="."?M(ri):M(pr,xh,xo)}function pr(d,g){return d=="{"?sn(pr,"}"):(d=="variable"&&K(g),g=="*"&&(x.marked="keyword"),b(im))}function xh(d){if(d==",")return b(pr,xh)}function im(d,g){if(g=="as")return x.marked="keyword",b(pr)}function xo(d,g){if(g=="from")return x.marked="keyword",b(re)}function nm(d){return d=="]"?b():M(Ae(Oe,"]"))}function vh(){return M(j("form"),ot,J("{"),j("}"),Ae(rm,"}"),$,$)}function rm(){return M(ot,zt)}function sm(d,g){return d.lastType=="operator"||d.lastType==","||l.test(g.charAt(0))||/[,.]/.test(g.charAt(0))}function om(d,g,C){return g.tokenize==p&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(g.lastType)||g.lastType=="quasi"&&/\{\s*$/.test(d.string.slice(0,d.pos-(C||0)))}return{name:n.name,startState:function(d){var g={tokenize:p,lastType:"sof",cc:[],lexical:new O(-d,0,"block",!1),localVars:n.localVars,context:n.localVars&&new k(null,null,!1),indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(g.globalVars=n.globalVars),g},token:function(d,g){if(d.sol()&&(g.lexical.hasOwnProperty("align")||(g.lexical.align=!1),g.indented=d.indentation(),S(d,g)),g.tokenize!=w&&d.eatSpace())return null;var C=g.tokenize(d,g);return c=="comment"?C:(g.lastType=c=="operator"&&(f=="++"||f=="--")?"incdec":c,B(g,C,c,f,d))},indent:function(d,g,C){if(d.tokenize==w||d.tokenize==y)return null;if(d.tokenize!=p)return 0;var R=g&&g.charAt(0),H=d.lexical,ee;if(!/^\s*else\b/.test(g))for(var he=d.cc.length-1;he>=0;--he){var Ke=d.cc[he];if(Ke==$)H=H.prev;else if(Ke!=gh&&Ke!=le)break}for(;(H.type=="stat"||H.type=="form")&&(R=="}"||(ee=d.cc[d.cc.length-1])&&(ee==ri||ee==Di)&&!/^[,\.=+\-*:?[\(]/.test(g));)H=H.prev;e&&H.type==")"&&H.prev.type=="stat"&&(H=H.prev);var et=H.type,ln=R==et;return et=="vardef"?H.indented+(d.lastType=="operator"||d.lastType==","?H.info.length+1:0):et=="form"&&R=="{"?H.indented:et=="form"?H.indented+C.unit:et=="stat"?H.indented+(sm(d,g)?e||C.unit:0):H.info=="switch"&&!ln&&n.doubleIndentSwitch!=!1?H.indented+(/^(?:case|default)\b/.test(g)?C.unit:2*C.unit):H.align?H.column+(ln?0:1):H.indented+(ln?0:C.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:i?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}var lp=no({name:"javascript"}),ap=no({name:"json",json:!0}),Ww=no({name:"json",jsonld:!0}),jw=no({name:"typescript",typescript:!0});function xk(n){return new RegExp("^(?:"+n.join("|")+")","i")}function ro(n){return new RegExp("^(?:"+n.join("|")+")$","i")}var vk=ro(["_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"]),Sk=ro(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),Tk=ro(["function","if","repeat","do","\\(","{"]),Ck=ro(["end","until","\\)","}"]),Ak=xk(["end","until","\\)","}","else","elseif"]);function hp(n){for(var e=0;n.eat("=");)++e;return n.eat("["),e}function Qa(n,e){var t=n.next();return t=="-"&&n.eat("-")?n.eat("[")&&n.eat("[")?(e.cur=cp(hp(n),"comment"))(n,e):(n.skipToEnd(),"comment"):t=='"'||t=="'"?(e.cur=Mk(t))(n,e):t=="["&&/[\[=]/.test(n.peek())?(e.cur=cp(hp(n),"string"))(n,e):/\d/.test(t)?(n.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(t)?(n.eatWhile(/[\w\\\-_.]/),"variable"):null}function cp(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=Qa;break}else r=null;return e}}function Mk(n){return function(e,t){for(var i=!1,r;(r=e.next())!=null&&!(r==n&&!i);)i=!i&&r=="\\";return i||(t.cur=Qa),"string"}}var fp={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:Qa}},token:function(n,e){if(n.eatSpace())return null;var t=e.cur(n,e),i=n.current();return t=="variable"&&(Sk.test(i)?t="keyword":vk.test(i)&&(t="builtin")),t!="comment"&&t!="string"&&(Tk.test(i)?++e.indentDepth:Ck.test(i)&&--e.indentDepth),t},indent:function(n,e,t){var i=Ak.test(e);return n.basecol+t.unit*(n.indentDepth-(i?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}};var up=n=>{let e={};for(let[t,i]of Object.entries(n))Object.assign(e,{[t]:Array.isArray(i)?[...i]:i});return e},dp=document.createElement("span"),Dk=n=>n.startsWith("#")?!0:(dp.innerHTML=`&${n}`,[...dp.textContent].length===1),xe=(n,e)=>{n.stack.push(n.tokenize),n.tokenize=e},so=n=>n.sol()&&/[-=*#;:]/u.test(n.peek()||""),oo=class{constructor(e){this.config=e,this.urlProtocols=new RegExp(`^(?:${e.urlProtocols})(?=[^\\s[\\]<>])`,"iu"),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.oldTokens=[],this.tokenTable={...G.tokenTable},this.registerGroundTokens(),this.permittedHtmlTags=new Set([...G.permittedHtmlTags,...e.permittedHtmlTags||[]]),this.implicitlyClosedHtmlTags=new Set([...G.implicitlyClosedHtmlTags,...e.implicitlyClosedHtmlTags||[]]);for(let r of Object.keys(e.tags))this.addTag(r);let t=Object.entries(this.config.nsid).filter(([,r])=>r===6).map(([r])=>r).join("|");this.fileRegex=new RegExp(`^(?:${t})\\s*:`,"iu"),this.functionSynonyms=this.config.functionSynonyms.flatMap((r,s)=>Object.keys(r).map(o=>({type:s?"constant":"function",label:o}))),this.doubleUnderscore=this.config.doubleUnderscore.flatMap(Object.keys).map(r=>({type:"constant",label:r}));let i=Object.keys(e.tags);this.extTags=i.map(r=>({type:"type",label:r})),this.htmlTags=G.permittedHtmlTags.filter(r=>!i.includes(r)).map(r=>({type:"type",label:r}))}addTag(e,t){this.addToken(`mw-tag-${e}`,t)}addToken(e,t){var i;(i=this.tokenTable)[e]||(i[e]=je.define(t))}registerGroundTokens(){let e=["mw-ext-ground","mw-ext-link-ground","mw-ext2-ground","mw-ext2-link-ground","mw-ext3-ground","mw-ext3-link-ground","mw-link-ground","mw-template-ext-ground","mw-template-ext-link-ground","mw-template-ext2-ground","mw-template-ext2-link-ground","mw-template-ext3-ground","mw-template-ext3-link-ground","mw-template-ground","mw-template-link-ground","mw-template2-ext-ground","mw-template2-ext-link-ground","mw-template2-ext2-ground","mw-template2-ext2-link-ground","mw-template2-ext3-ground","mw-template2-ext3-link-ground","mw-template2-ground","mw-template2-link-ground","mw-template3-ext-ground","mw-template3-ext-link-ground","mw-template3-ext2-ground","mw-template3-ext2-link-ground","mw-template3-ext3-ground","mw-template3-ext3-link-ground","mw-template3-ground","mw-template3-link-ground","mw-section-1","mw-section-2","mw-section-3","mw-section-4","mw-section-5","mw-section-6"];for(let t of e)this.addToken(t)}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}`}))}makeTagStyle(e,t,i){return this.makeStyle(G.tags[e],t,i)}makeStyle(e,t,i){return this.makeLocalStyle(`${e} ${this.isBold||t.dt.n?G.tags.strong:""} ${this.isItalic?G.tags.em:""}`,t,i)}makeLocalTagStyle(e,t,i){return this.makeLocalStyle(G.tags[e],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}if(t.nLink&&(r+="-link"),i){t[i]--;let{dt:s}=t;s.n&&t[i]<s[i]&&(s.n=0)}return(r&&`mw${r}-ground `)+e}inBlock(e,t,i){return(r,s)=>(r.skipTo(t)?(i&&r.match(t),s.tokenize=s.stack.pop()):r.skipToEnd(),this.makeLocalTagStyle(e,s))}inChar(e,t){return(i,r)=>i.eat(e)?(r.tokenize=r.stack.pop(),this.makeLocalTagStyle(t,r)):(i.skipTo(e)||i.skipToEnd(),this.makeLocalTagStyle("error",r))}eatFreeExternalLinkProtocol(e,t){return e.match(this.urlProtocols),t.tokenize=this.inFreeExternalLink.bind(this),this.makeTagStyle("freeExtLinkProtocol",t)}inFreeExternalLink(e,t){if(!e.sol()){let i=e.match(/^[^\s{[\]<>~).,;:!?'"]*/u),r=e.peek();switch(t.lpar||(t.lpar=i[0].includes("(")),r){case"~":if(e.match(/^~~?(?!~)/u))return this.makeTagStyle("freeExtLink",t);break;case"{":if(e.match(/^\{(?!\{)/u))return this.makeTagStyle("freeExtLink",t);break;case"'":if(e.match(/^'(?!')/u))return this.makeTagStyle("freeExtLink",t);break;case")":if(t.lpar)return e.eatWhile(")"),this.makeTagStyle("freeExtLink",t);case".":case",":case";":case":":case"!":case"?":if(e.match(/^[).,;:!?]+(?=[^\s{[\]<>~).,;:!?'"]|~~?(?!~)|\{(?!\{)|'(?!'))/u))return this.makeTagStyle("freeExtLink",t)}}return t.lpar=!1,t.tokenize=t.stack.pop(),this.makeTagStyle("freeExtLink",t)}inSectionHeader(e){return(t,i)=>t.eatWhile(/[^&<[{~'_]/u)?(t.eol()?(t.backUp(e),i.tokenize=this.eatSectionHeader.bind(this)):t.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(t.backUp(e),i.tokenize=this.inBlock("sectionHeader","<!--")),this.makeLocalTagStyle("section",i)):this.eatWikiText(G.tags.section)(t,i)}eatSectionHeader(e,t){return e.skipToEnd(),t.tokenize=t.stack.pop(),this.makeLocalTagStyle("sectionHeader",t)}eatList(e,t){let i=e.match(/^[*#;:]*/u),{dt:r}=t;return i&&i[0].includes(";")&&(r.n+=i[0].split(";").length-1),r.n&&(r.nTemplate=t.nTemplate,r.nLink=t.nLink,r.nExt=t.nExt,r.nVar=t.nVar),this.makeLocalTagStyle("list",t)}eatStartTable(e,t){return e.match(/^(?:\{\||\{{3}\s*!\s*\}\})\s*/u),t.tokenize=this.inTableDefinition.bind(this),this.makeLocalTagStyle("tableBracket",t)}inTableDefinition(e,t){return e.sol()?(t.tokenize=this.inTable.bind(this),""):e.eatWhile(/[^&{<]/u)?this.makeLocalTagStyle("tableDefinition",t):this.eatWikiText(G.tags.tableDefinition)(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.makeLocalTagStyle("tableDelimiter",t)):e.match(/^\+\s*/u)?(t.tokenize=this.inTableCell(!0,2),this.makeLocalTagStyle("tableDelimiter",t)):e.eat("}")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("tableBracket",t)):(e.eatSpace(),t.tokenize=this.inTableCell(!0,0),this.makeLocalTagStyle("tableDelimiter",t));if(e.match(/^!\s*/u))return t.tokenize=this.inTableCell(!0,1),this.makeLocalTagStyle("tableDelimiter",t)}return this.eatWikiText(G.tags.error)(e,t)}inTableCell(e,t,i=!0){let r="";return t===2?r=G.tags.tableCaption:t===1&&(r=G.tags.strong),(s,o)=>{if(s.sol()){if(s.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1))return o.tokenize=this.inTable.bind(this),"";if(i)return o.tokenize=this.inTableCell(!1,t,!1),""}if(so(s))return this.eatWikiText(r)(s,o);if(s.eatWhile(i?/[^'{[<&~_|!]/u:/[^'{[<&~_:]/u))return this.makeStyle(r,o);if(i){if(s.match(/^(?:\||\{\{\s*!\s*\}\}){2}\s*/u)||t===1&&s.match(/^!!\s*/u))return this.isBold=!1,this.isItalic=!1,o.tokenize=this.inTableCell(!0,t),this.makeLocalTagStyle("tableDelimiter",o);if(e&&s.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return o.tokenize=this.inTableCell(!1,t),this.makeLocalTagStyle("tableDelimiter",o)}return this.eatWikiText(r)(s,o)}}eatHtmlEntity(e,t){let i=e.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&Dk(i[0])?G.tags.htmlEntity:t}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.makeLocalTagStyle("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.makeLocalTagStyle("extLinkBracket",t,"nLink")):e.eatSpace()||e.match(/^(?:[[<>"]|&[lg]t;|'{2,3}(?!')|'{5}(?!')|\{\{|~{3})/u,!1)?(t.tokenize=this.inExternalLinkText.bind(this),this.makeLocalStyle("",t)):(e.next(),e.eatWhile(/[^\s[\]<>"&~'{]/u),this.makeLocalTagStyle("extLink",t))}inExternalLinkText(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.eat("]")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("extLinkBracket",t,"nLink")):e.match(/^(?:[^'[\]{&~<]|\[(?!\[))+/u)?this.makeTagStyle("extLinkText",t):this.eatWikiText(G.tags.extLinkText)(e,t)}inLink(e){let t=`${G.tags.linkPageName} ${G.tags.pageName}`;return(i,r)=>{if(i.sol())return r.nLink--,r.lbrack=!1,r.tokenize=r.stack.pop(),"";let s=i.eatSpace();return i.match(/^#\s*/u)?(r.tokenize=this.inLinkToSection(e),this.makeTagStyle(e?"error":"linkToSection",r)):i.match(/^\|\s*/u)?(r.tokenize=this.inLinkText(e),this.makeLocalTagStyle("linkDelimiter",r)):i.match("]]")?(r.lbrack=!1,r.tokenize=r.stack.pop(),this.makeLocalTagStyle("linkBracket",r,"nLink")):i.match(/^(?:[>[}]+|\]|\{(?!\{))/u)?this.makeTagStyle("error",r):i.eatWhile(/[^#|[\]&{}<>]/u)||s?this.makeStyle(t,r):this.eatWikiText(t)(i,r)}}inLinkToSection(e){let t=e?"error":"linkToSection";return(i,r)=>i.sol()?(r.nLink--,r.lbrack=!1,r.tokenize=r.stack.pop(),""):i.eat("|")?(r.tokenize=this.inLinkText(e),this.makeLocalTagStyle("linkDelimiter",r)):i.match("]]")?(r.lbrack=!1,r.tokenize=r.stack.pop(),this.makeLocalTagStyle("linkBracket",r,"nLink")):i.eatWhile(/[^|\]&{}<]/u)?this.makeTagStyle(t,r):this.eatWikiText(G.tags[t])(i,r)}inLinkText(e){let t,i;return(r,s)=>{let o=`${G.tags.linkText} ${t?G.tags.strong:""} ${i?G.tags.em:""}`;if(r.match("]]"))return s.lbrack&&r.peek()==="]"?(r.backUp(1),s.lbrack=!1,this.makeStyle(o,s)):(s.lbrack=!1,s.tokenize=s.stack.pop(),this.makeLocalTagStyle("linkBracket",s,"nLink"));if(e&&r.eat("|"))return this.makeLocalTagStyle("linkDelimiter",s);if(r.peek()==="'"){switch(r.match(/^'+/u)[0].length){case 3:return t=!t,this.makeLocalTagStyle("apostrophes",s);case 5:t=!t;case 2:return i=!i,this.makeLocalTagStyle("apostrophes",s);case 4:r.backUp(3);case 1:break;default:r.backUp(5)}return this.makeStyle(o,s)}let l=e?new RegExp(`^(?:[^'\\]{&~<|[]|\\[(?!\\[|${this.config.urlProtocols}))+`,"iu"):/^[^'\]{&~<]+/u,a=r.match(l);return s.lbrack===void 0&&a&&a[0].includes("[")&&(s.lbrack=!0),a?this.makeStyle(o,s):this.eatWikiText(o)(r,s)}}inVariable(e,t){return e.eat("|")?(t.tokenize=this.inVariableDefault(!0),this.makeLocalTagStyle("templateVariableDelimiter",t)):e.match("}}}")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("templateVariableBracket",t,"nVar")):e.match("{{{")?(t.stack.push(t.tokenize),this.makeLocalTagStyle("templateVariableBracket",t)):e.match("<!--",!1)?(xe(t,this.inComment),""):(e.eatWhile(/[^{}|<]/u)||e.next(),this.makeLocalTagStyle("templateVariableName",t))}inVariableDefault(e){let t=G.tags[e?"templateVariable":"comment"];return(i,r)=>i.match("}}}")?(r.tokenize=r.stack.pop(),this.makeLocalTagStyle("templateVariableBracket",r,"nVar")):i.eat("|")?(e&&(r.tokenize=this.inVariableDefault()),this.makeLocalTagStyle("templateVariableDelimiter",r)):e&&so(i)||!i.eatWhile(e?/[^|{}[<&~'_:]/u:/[^|{}[<]/u)?this.eatWikiText(t)(i,r):this.makeStyle(t,r)}get inComment(){return this.inBlock("comment","-->",!0)}inParserFunctionName(e,t){return e.eatWhile(/[^:}{~|<>[\]]/u)?this.makeLocalTagStyle("parserFunctionName",t):e.eat(":")?(t.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalTagStyle("parserFunctionDelimiter",t)):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("parserFunctionBracket",t,"nExt")):this.eatWikiText(G.tags.error)(e,t)}inParserFunctionArguments(e,t){return e.eat("|")?this.makeLocalTagStyle("parserFunctionDelimiter",t):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("parserFunctionBracket",t,"nExt")):so(e)||!e.eatWhile(/[^|}{[<&~'_:]/u)?this.eatWikiText(G.tags.parserFunction)(e,t):this.makeLocalTagStyle("parserFunction",t)}inTemplatePageName(e,t){let i=t?G.tags.error:`${G.tags.templateName} ${G.tags.pageName}`;return(r,s)=>{let o=r.sol(),l=r.eatSpace();return r.eol()?this.makeLocalStyle(i,s):r.eat("|")?(s.tokenize=this.inTemplateArgument(!0),this.makeLocalTagStyle("templateDelimiter",s)):r.match("}}")?(s.tokenize=s.stack.pop(),this.makeLocalTagStyle("templateBracket",s,"nTemplate")):r.match("<!--",!1)?(xe(s,this.inComment),this.makeLocalStyle("",s)):e&&!t&&o?(s.nTemplate--,s.tokenize=s.stack.pop(),r.pos=0,""):!t&&r.eat("#")?(s.tokenize=this.inTemplatePageName(!0,!0),this.makeLocalTagStyle("error",s)):r.match(t?/^(?:[^|{}<]|([{}])(?!\1)|<(?!!--))+/u:/^[^|{}<>[\]#]+/u)?(s.tokenize=this.inTemplatePageName(!0,t),this.makeLocalStyle(i,s)):r.match(/^(?:[<>[\]}]|\{(?!\{))/u)?this.makeLocalTagStyle("error",s):l?this.makeLocalStyle(i,s):this.eatWikiText(i)(r,s)}}inTemplateArgument(e){let t=new RegExp(`^(?:[^=|}{[<]|\\[(?!\\[)|<(?!!--|(?:${Object.keys(this.config.tags).join("|")})[\\s/>]))*=`,"iu");return(i,r)=>{let s=i.eatSpace();return i.eol()?this.makeLocalTagStyle("template",r):i.match(/^\|\s*/u)?(r.tokenize=this.inTemplateArgument(!0),this.makeLocalTagStyle("templateDelimiter",r)):i.match("}}")?(r.tokenize=r.stack.pop(),this.makeLocalTagStyle("templateBracket",r,"nTemplate")):e&&i.match(t)?(r.tokenize=this.inTemplateArgument(),this.makeLocalTagStyle("templateArgumentName",r)):!so(i)&&i.eatWhile(/[^|}{[<&~'_:]/u)||s?this.makeLocalTagStyle("template",r):this.eatWikiText(G.tags.template)(i,r)}}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(">","htmlTagBracket"):this.inHtmlTagAttribute(o),this.makeLocalTagStyle("htmlTagName",s)):(s.tokenize=t?this.inChar(">","extTagBracket"):this.inExtTagAttribute(o),this.makeLocalTagStyle("extTagName",s))}}inHtmlTagAttribute(e){return(t,i)=>t.match(/^(?:"[^<">]*"|'[^<'>]*'[^>/<{])+/u)?this.makeLocalTagStyle("htmlTagAttribute",i):t.peek()==="<"?(i.tokenize=i.stack.pop(),""):t.match(/^\/?>/u)?(this.implicitlyClosedHtmlTags.has(e)||i.inHtmlTag.unshift(e),i.tokenize=i.stack.pop(),this.makeLocalTagStyle("htmlTagBracket",i)):this.eatWikiText(G.tags.htmlTagAttribute)(t,i)}get eatNowiki(){return e=>e.eatWhile(/[^&]/u)?"":(e.next(),this.eatHtmlEntity(e,""))}inExtTagAttribute(e){return(t,i)=>t.match(/^(?:"[^">]*"|'[^'>]*'|[^>/])+/u)?this.makeLocalTagStyle("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.makeLocalTagStyle("extTagBracket",i)):t.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalTagStyle("extTagBracket",i)):this.eatWikiText(G.tags.extTagAttribute)(t,i)}eatExtTagArea(e){return(t,i)=>{let r=t.pos,s=new RegExp(`</${e}\\s*(?:>|$)`,"iu").exec(r?t.string.slice(r):t.string),o=!1;if(s){if(s.index===0)return i.tokenize=this.eatExtCloseTag(e),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(t,i);o=t.string,t.string=o.slice(0,s.index+r)}return xe(i,this.inExtTokens(o)),i.tokenize(t,i)}}eatExtCloseTag(e){return(t,i)=>(t.next(),t.next(),i.tokenize=this.eatTagName(e.length,!0),this.makeLocalTagStyle("extTagBracket",i))}inExtTokens(e){return(t,i)=>{let r;return i.extMode===!1?(r=`mw-tag-${i.extName} ${G.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}}eatWikiText(e){return(t,i)=>{let r;if(t.eol())return"";if(t.sol()){if(t.match("//"))return this.makeStyle(e,i);if(t.match(this.urlProtocols))return xe(i,this.inFreeExternalLink.bind(this)),this.makeTagStyle("freeExtLinkProtocol",i);switch(r=t.next(),r){case"-":if(t.match(/^-{3,}/u))return G.tags.hr;break;case"=":{let s=t.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->\s*\S).*)?)$/u);if(s)return t.backUp(s[2].length),xe(i,this.inSectionHeader(s[3].length)),this.makeLocalStyle(`${G.tags.sectionHeader} mw-section-${s[1].length+1}`,i);break}case";":i.dt.n++;case"*":case"#":return this.eatList(t,i);case":":return t.match(/^:*\s*(?=\{\||\{{3}\s*!\s*\}\})/u)?(xe(i,this.eatStartTable.bind(this)),this.makeLocalTagStyle("list",i)):this.eatList(t,i);case" ":{let s=t.match(/^\s*(:+\s*)?(?=\{\||\{{3}\s*!\s*\}\})/u);if(s){if(s[1])return xe(i,this.eatStartTable.bind(this)),this.makeLocalTagStyle("list",i);t.eat("{")}else return G.tags.skipFormatting}case"{":if(t.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return xe(i,this.inTableDefinition.bind(this)),this.makeLocalTagStyle("tableBracket",i)}}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.makeLocalTagStyle("apostrophes",i);if(t.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalTagStyle("apostrophes",i);break;case"[":if(t.match(/^\[\s*/u)){if(/[^[\]|]/u.test(t.peek()||""))return i.nLink++,i.lbrack=void 0,xe(i,this.inLink(!!t.match(this.fileRegex,!1))),this.makeLocalTagStyle("linkBracket",i)}else{let s=t.match(this.urlProtocols,!1);if(s)return i.nLink++,xe(i,this.eatExternalLinkProtocol(s[0].length)),this.makeLocalTagStyle("extLinkBracket",i)}break;case"{":if(t.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))\s*/u))return i.nVar++,xe(i,this.inVariable.bind(this)),this.makeLocalTagStyle("templateVariableBracket",i);if(t.match(/^\{(?!\{(?!\{))\s*/u)){if(t.peek()==="#")return i.nExt++,xe(i,this.inParserFunctionName.bind(this)),this.makeLocalTagStyle("parserFunctionBracket",i);let s=t.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/u,!1);return s&&(s[2]===":"||s[4]===void 0||s[3]==="}}")&&(s[1].toLowerCase()in this.config.functionSynonyms[0]||s[1]in this.config.functionSynonyms[1])?(i.nExt++,xe(i,this.inParserFunctionName.bind(this)),this.makeLocalTagStyle("parserFunctionBracket",i)):(i.nTemplate++,xe(i,this.inTemplatePageName()),this.makeLocalTagStyle("templateBracket",i))}break;case"~":if(t.match(/^~{2,4}/u))return G.tags.signature;break;case"_":{let s=1;for(;t.eat("_");)s++;if(s>2)return t.eol()||t.backUp(2),this.makeStyle(e,i);if(s===2){let o=t.match(/^[\p{L}\d_]+?__/u);if(o)return`__${o[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${o[0]}`in this.config.doubleUnderscore[1]?G.tags.doubleUnderscore:(t.eol()||t.backUp(2),this.makeStyle(e,i))}break}case":":{let{dt:s}=i;if(s.n&&s.nTemplate===i.nTemplate&&s.nLink===i.nLink&&s.nExt===i.nExt&&s.nVar===i.nVar)return s.n--,this.makeLocalTagStyle("list",i);break}case"<":{if(t.match("!--",!1))return t.backUp(1),xe(i,this.inComment),"";let s=!!t.eat("/"),o=t.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+(?=[>/\s]|$)/u);if(o){let l=o[0].toLowerCase();if(l in this.config.tags)return s?(xe(i,this.inChar(">","error")),this.makeLocalTagStyle("error",i)):(t.backUp(l.length),xe(i,this.eatTagName(l.length,s)),this.makeLocalTagStyle("extTagBracket",i));if(this.permittedHtmlTags.has(l)){if(s)if(l===i.inHtmlTag[0])i.inHtmlTag.shift();else return xe(i,this.inChar(">","error")),this.makeLocalTagStyle("error",i);return t.backUp(l.length),xe(i,this.eatTagName(l.length,s,!0)),this.makeLocalTagStyle("htmlTagBracket",i)}t.backUp(l.length)}}}return/\s/u.test(r||"")&&(t.eatSpace(),t.match(this.urlProtocols,!1)&&!t.match("//"))?(xe(i,this.eatFreeExternalLinkProtocol.bind(this)),this.makeStyle(e,i)):(t.eatWhile(/[^\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 completionSource(){return e=>{var o,l,a;let{state:t,pos:i}=e,r=(o=Pt(t,i))==null?void 0:o.resolve(i,-1);if(!r)return null;let s=new Set(r.name.split("_"));if(s.has(G.tags.templateName)||s.has(G.tags.parserFunctionName))return{from:r.from,options:this.functionSynonyms,validFor:/^[^|{}<]*$/u};if(!s.has(G.tags.comment)&&!s.has(G.tags.templateVariableName)){let h=e.matchBefore(/__(?:(?!__)[\p{L}\d_])*$/u);if(h)return{from:h.from,options:this.doubleUnderscore,validFor:/^[\p{L}\d]*$/u};if(h=e.matchBefore(/<\/?[a-z\d]*$/iu),!h||h.to-h.from<2)return null;let c=/^[a-z\d]*$/iu;if(h.text[1]==="/"){let f=e.matchBefore(/<[a-z\d]+(?:\s[^<>]*)?>((?!<\/?[a-z]).)*<\/[a-z\d]*$/iu),u=(l=/^<([a-z\d]+)/iu.exec((f==null?void 0:f.text)||""))==null?void 0:l[1].toLowerCase(),p=(a=[...s].reverse().find(y=>y.startsWith("mw-tag-")))==null?void 0:a.slice(7),m=[...this.htmlTags.filter(({label:y})=>!this.implicitlyClosedHtmlTags.has(y)),...p?[{type:"type",label:p,boost:50}]:[]],w=this.permittedHtmlTags.has(u)&&m.findIndex(({label:y})=>y===u);return w!==!1&&w!==-1&&m.splice(w,1,{type:"type",label:u,boost:99}),{from:h.from+2,options:m,validFor:c}}return{from:h.from+1,options:[...this.htmlTags,...this.extTags],validFor:c}}return null}}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0,nVar:0,lpar:!1,lbrack:!1,dt:{n:0}}),copyState:e=>{let t=up(e);return t.dt={...e.dt},e.extMode&&e.extMode.copyState&&(t.extState=e.extMode.copyState(e.extState)),t},token:(e,t)=>{let i;if(this.oldTokens.length>0)return i=this.oldTokens.shift(),e.pos=i.pos,i.style;e.sol()&&(t.dt.n=0,this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);let r,s=null,o,l=[],a=[];do if(r=t.tokenize(e,t),o=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,o)o!==s&&(s=o,l.length>0&&(a.push(...l),l.length=0)),l.push({pos:e.pos,style:r,state:(t.extMode&&t.extMode.copyState||up)(t)});else return this.oldStyle=r,r;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 i=this.oldTokens.shift(),e.pos=i.pos,i.style},blankLine:e=>{e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},tokenTable:this.tokenTable,languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},closeBrackets:{brackets:["(","[","{",'"']},autocomplete:this.completionSource}}}get"text/mediawiki"(){return this.mediawiki}};for(let[n,e]of Object.entries(Zn))Object.defineProperty(oo.prototype,n,{get(){return e}});var eh=n=>{let e=new oo(n),t=Ji.define(e.mediawiki),i=gs(Yi.define(e.getTagStyles()));return new Gi(t,i)},pp=n=>eh({...n,tags:{...n.tags,script:!0,style:!0},tagModes:{...n.tagModes,script:"javascript",style:"css"},permittedHtmlTags:["html","base","title","menu","a","area","audio","map","track","video","embed","iframe","object","picture","source","canvas","col","colgroup","tbody","tfoot","thead","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","slot","template","dir","frame","frameset","marquee","param","xmp"],implicitlyClosedHtmlTags:["area","base","col","embed","frame","input","param","source","track"]});var mp={'"':"quot","'":"apos","<":"lt",">":"gt","&":"amp"," ":"nbsp"},gp=n=>e=>(lo.replaceSelections(e,n),!0),Lk=gp(n=>[...n].map(e=>{if(e in mp)return`&${mp[e]};`;let t=e.codePointAt(0);return t<256?`&#${t};`:`&#x${t.toString(16)};`}).join("")),Ek=gp(n=>{if(n.includes("%"))try{return decodeURIComponent(n)}catch(e){}return encodeURIComponent(n)}),bp=[{key:"Mod-[",run:Lk},{key:"Mod-]",run:Ek}];var Sp=n=>({name:e})=>e.includes(G.tags[n]),ih=Sp("templateBracket"),th=Sp("templateDelimiter"),nh=n=>/-template[a-z\d-]+ground/u.test(n.name)&&!ih(n),yp=(n,e)=>n.sliceDoc(e.from,e.from+1)==="{"?1:-1;function Tp(n,e,t){if(typeof e=="number"&&(t=Pt(n,e)),!t)return null;let i;if(typeof e=="number"?(i=t.resolve(e,-1),nh(i)||(i=t.resolve(e,1))):i=e,!nh(i))return null;let{prevSibling:r,nextSibling:s}=i,o=1,l=th(i)?i:null;for(;s;){if(ih(s)){if(o+=yp(n,s),o===0)break}else!l&&o===1&&th(s)&&(l=s);({nextSibling:s}=s)}if(!s)return null;for(o=-1;r;){if(ih(r)){if(o+=yp(n,r),o===0)break}else o===-1&&th(r)&&(l=r);({prevSibling:r}=r)}let a=l==null?void 0:l.to,h=s.from;return a&&a<h?{from:a,to:h}:null}var kp=n=>{let{selection:{main:{head:e}}}=n,t=Tp(n,e);if(t){let{from:i,to:r}=t,s=!1;return ms(n).between(i,r,(o,l)=>{o===i&&l===r&&(s=!0)}),s?null:{pos:e,above:!0,create:()=>{let o=document.createElement("div");return o.className="cm-tooltip-fold",o.textContent="\uFF0D",o.title=n.phrase("Fold template parameters"),o.dataset.from=String(i),o.dataset.to=String(r),{dom:o}}}}return null},wp=(n,e,t)=>{var i;return e.length>0?((i=n.dom.querySelector(".cm-tooltip-fold"))==null||i.remove(),n.dispatch({effects:e,selection:{anchor:t}}),!0):!1},xp=n=>Math.max(...n.selection.ranges.map(({to:e})=>e)),vp=(n,e,t,i,r,s,o=(l,{to:a})=>Math.max(l,a))=>{for(;i&&i.from<=r;){let l=Tp(n,i,e);if(l){t.push(ds.of(l)),i=e.resolve(l.to,1),s=o(s,l);continue}i=i.nextSibling}return s},Cp=[pu({placeholderDOM(n){let e=document.createElement("span");return e.textContent="\u2026",e.setAttribute("aria-label","folded code"),e.title=n.state.phrase("unfold"),e.className="cm-foldPlaceholder",e.addEventListener("click",({target:t})=>{let i=n.posAtDOM(t),{state:r}=n,{selection:s}=r;ms(r).between(i,i,(o,l)=>{o===i&&n.dispatch({effects:Zi.of({from:o,to:l}),selection:s})})}),e}}),ce.define({create:kp,update(n,{state:e,docChanged:t,selection:i}){return t||i?kp(e):n},provide(n){return Ut.from(n)}}),ft.of([{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run(n){let{state:e}=n,t=Pt(e,n.viewport.to);if(!t)return!1;let i=[],r=xp(e);for(let{from:s,to:o,empty:l}of e.selection.ranges){let a;l&&(a=t.resolve(s,-1)),(!a||!nh(a))&&(a=t.resolve(s,1)),r=vp(e,t,i,a,o,r)}return wp(n,i,r)}},{key:"Ctrl-Alt-[",run(n){let{state:e}=n,t=Ce(e),i=[],r=vp(e,t,i,t.topNode.firstChild,1/0,xp(e),(s,{from:o,to:l})=>o<=s&&l>s?l:s);return wp(n,i,r)}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run(n){let{state:e}=n,{selection:t}=e,i=[],r=ms(e);for(let{from:s,to:o}of t.ranges)r.between(s,o,(l,a)=>{i.push(Zi.of({from:l,to:a}))});return i.length>0?(n.dispatch({effects:i,selection:t}),!0):!1}},{key:"Ctrl-Alt-]",run:du}])],Ap=n=>e=>{let t=e.target.closest(".cm-tooltip-fold");if(t){e.preventDefault();let{dataset:i}=t,r=Number(i.from),s=Number(i.to);n.dispatch({effects:ds.of({from:r,to:s}),selection:{anchor:s}}),t.remove()}};var rh=class{get closing(){return Dp(this.first,this.type)}get selfClosing(){return G.implicitlyClosedHtmlTags.includes(this.name)||this.type==="ext"&&Dp(this.last,this.type)}get from(){return this.first.from}get to(){return this.last.to}constructor(e,t,i,r){this.type=e,this.name=t,this.first=i,this.last=r}},Mp=({name:n})=>/-(?:ext|html)tag-(?!bracket)/u.test(n),Lp=n=>({name:e},t)=>new RegExp(`-${t}tag-${n}`,"u").test(e),ao=Lp("bracket"),sh=Lp("name"),Dp=(n,e)=>ao(n,e)&&n.to-n.from>1,Ep=({name:n},e,t)=>e==="ext"&&new RegExp(`-tag-${t}(?![a-z])`,"u").test(n),oh=(n,{from:e,to:t})=>n.sliceDoc(e,t).trim(),Ok=({closing:n})=>n?-1:1,Op=(n,e)=>{let t=e.name.includes("exttag")?"ext":"html",{prevSibling:i}=e,r=e,s=sh(e,t)?e:null;for(;r.nextSibling&&!ao(r,t);)({nextSibling:r}=r);for(ao(r,t)&&oh(n,r)==="<"&&(r=r.prevSibling);i&&!ao(i,t);)s||(s=sh(i,t)?i:null),{prevSibling:i}=i;let o=oh(n,s);return new rh(t,o,i,r)},Bk=(n,e)=>{let{type:t,name:i,closing:r}=e,s=r?"prevSibling":"nextSibling",o=r?"first":"last",l=r?-1:1,a=e[o][s];for(;a;){if(sh(a,t)&&oh(n,a)===i&&!Ep(a,t,i)){let h=Op(n,a);if(l+=Ok(h),l===0)return h;a=h[o]}a=a[s]}return null},Pk=(n,e)=>{let t=Pt(n,e);if(!t)return null;let i=t.resolve(e,-1);if(!Mp(i)&&(i=t.resolve(e,1),!Mp(i)))return null;let r=Op(n,i);if(Ep(i,r.type,r.name))return{matched:!1,start:r};if(r.selfClosing)return{matched:!0,start:r};let s=Bk(n,r);return s?{matched:!0,start:r,end:s}:{matched:!1,start:r}},Rk=_.mark({class:"cm-matchingTag"}),Nk=_.mark({class:"cm-nonmatchingTag"}),Bp=ce.define({create(){return _.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[];for(let i of e.state.selection.ranges)if(i.empty){let r=Pk(e.state,i.head);if(r){let s=r.matched?Rk:Nk,{start:{from:o,to:l,closing:a},end:h}=r;t.push(s.range(o,l)),h&&t[a?"unshift":"push"](s.range(h.from,h.to))}}return _.set(t)},provide(n){return N.decorations.from(n)}});var ah={plain:()=>N.contentAttributes.of({spellcheck:"true"}),mediawiki:n=>[eh(n),N.contentAttributes.of({spellcheck:"true"})],html:pp};for(let[n,e]of Object.entries(Zn))ah[n]=()=>new Gi(Ji.define(e));var ho=(n=[])=>[(e=[])=>e,{mediawiki:n}],lh={highlightSpecialChars:[If,{}],highlightActiveLine:[zf,{}],highlightWhitespace:[$f,{}],highlightTrailingWhitespace:[qf,{}],bracketMatching:[xu,{mediawiki:{brackets:"[]{}"}}],closeBrackets:[Ud,{}],allowMultipleSelections:[()=>[se.allowMultipleSelections.of(!0),Rf()],{}],escape:ho(ft.of(bp)),codeFolding:ho(Cp),tagMatching:ho(Bp),autocompletion:ho([Yd({defaultKeymap:!1}),ft.of([...Xa,{key:"Tab",run:Ga}])])},co={},Pp={},Rp="https://testingcf.jsdelivr.net",fo=(n,e)=>new Promise(t=>{if(e in window){t();return}let i=document.createElement("script");i.src=`${Rp}/${n}`,i.onload=()=>{t()},document.head.append(i)}),Qn=(n,e,t)=>n.line(e).from+t-1,er=(n,e,t)=>{for(let i of n)e[i]=t?i:!0},qe,ne,tr,Ci,ir,nr,rr,sr,Mt,ni,Ai,Nt,Ti,uo,Np,or,hh,lr,ch,po,Ip,mo=class mo{constructor(e,t="plain",i){Me(this,Nt);Me(this,uo);Me(this,or);Me(this,lr);Me(this,po);Me(this,qe,void 0);Me(this,ne,void 0);Me(this,tr,new lt);Me(this,Ci,new lt);Me(this,ir,new lt);Me(this,nr,new lt);Me(this,rr,new lt);Me(this,sr,new lt);Me(this,Mt,void 0);Me(this,ni,!1);Me(this,Ai,new Set);li(this,qe,e),li(this,Mt,t);let r,{readOnly:s}=e,o=[V(this,tr).of(ah[t](i)),V(this,Ci).of([]),V(this,ir).of([]),V(this,nr).of(Zt.of(" ")),V(this,rr).of([]),V(this,sr).of([]),gs(bu),N.contentAttributes.of({accesskey:e.accessKey,tabindex:String(e.tabIndex)}),N.editorAttributes.of({dir:e.dir,lang:e.lang}),Wf(),N.lineWrapping,ft.of([...fd,...xd,...Md]),N.updateListener.of(({state:{doc:h},docChanged:c,focusChanged:f})=>{c&&(clearTimeout(r),r=window.setTimeout(()=>{e.value=h.toString()},400)),f&&e.dispatchEvent(new Event(V(this,ne).hasFocus?"focus":"blur"))}),...s?[se.readOnly.of(!0)]:[Iu(),fu(),ft.of(Vu)]];li(this,ne,new N({extensions:o,doc:e.value}));let{fontSize:l,lineHeight:a}=getComputedStyle(e);e.parentNode.insertBefore(V(this,ne).dom,e),_e(this,or,hh).call(this),V(this,ne).scrollDOM.style.fontSize=l,V(this,ne).scrollDOM.style.lineHeight=a,this.toggle(!0),V(this,ne).dom.addEventListener("click",Ap(V(this,ne)))}get textarea(){return V(this,qe)}get view(){return V(this,ne)}get lang(){return V(this,Mt)}get visible(){return V(this,ni)}setLanguage(e="plain",t){_e(this,Nt,Ti).call(this,[V(this,tr).reconfigure(ah[e](t)),V(this,Ci).reconfigure(co[e]||[])]),li(this,Mt,e),_e(this,lr,ch).call(this,!!co[e]),this.prefer({})}lint(e){let t=e?[Dd(i=>e(i.state.doc)),Rd()]:[];e?co[V(this,Mt)]=t:delete co[V(this,Mt)],_e(this,Nt,Ti).call(this,V(this,Ci).reconfigure(t)),_e(this,lr,ch).call(this,!!e)}update(){let e=_e(this,po,Ip).call(this);if(e){let t=V(this,ne).plugin(e[1]);t.set=!0,t.force()}}prefer(e){if(Array.isArray(e))li(this,Ai,new Set(e.filter(t=>lh[t])));else for(let[t,i]of Object.entries(e))i&&lh[t]?V(this,Ai).add(t):V(this,Ai).delete(t);_e(this,Nt,Ti).call(this,V(this,ir).reconfigure([...V(this,Ai)].map(t=>{let[i,r]=lh[t];return i(r[V(this,Mt)])})))}setIndent(e){_e(this,Nt,Ti).call(this,V(this,nr).reconfigure(Zt.of(e)))}async getLinter(e){var t,i,r;switch(V(this,Mt)){case"mediawiki":{let s="npm/wikiparser-node@1.6.2-b",o=`${s}/extensions/dist`,l=`combine/${o}/base.min.js,${o}/lint.min.js`,a=e==null?void 0:e.i18n;if(await fo(l,"wikiparse"),typeof a=="string")try{let c=await(await fetch(`${Rp}/${s}/i18n/${a.toLowerCase()}.json`)).json();wikiparse.setI18N(c)}catch(c){}let h=new wikiparse.Linter(e==null?void 0:e.include);return c=>h.codemirror(c.toString())}case"javascript":{await fo("npm/eslint-linter-browserify","eslint");let s=new eslint.Linter,o={env:{browser:!0,es2024:!0},parserOptions:{ecmaVersion:15,sourceType:"module"},rules:{},...e};for(let[l,{meta:a}]of s.getRules())(t=a==null?void 0:a.docs)!=null&&t.recommended&&((r=(i=o.rules)[l])!=null||(i[l]=2));return l=>s.verify(l.toString(),o).map(({ruleId:a,message:h,severity:c,line:f,column:u,endLine:p,endColumn:m,fix:w,suggestions:y=[]})=>{let v=Qn(l,f,u),S={source:"ESLint",message:`${h}${a?` (${a})`:""}`,severity:c===1?"warning":"error",from:v,to:p===void 0?v+1:Qn(l,p,m)};return(w||y.length>0)&&(S.actions=[...w?[{name:"fix",fix:w}]:[],...y.map(E=>({name:"suggestion",fix:E.fix}))].map(({name:E,fix:{range:[O,L],text:B}})=>({name:E,apply(x){x.dispatch({changes:{from:O,to:L,insert:B}})}}))),S})}case"css":{await fo("gh/openstyles/stylelint-bundle/dist/stylelint-bundle.min.js","stylelint");let s={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,...e==null?void 0:e.rules}};return async o=>{let{results:l}=await stylelint.lint({code:o.toString(),config:s});return l.flatMap(({warnings:a})=>a).map(({text:a,severity:h,line:c,column:f,endLine:u,endColumn:p})=>({source:"Stylelint",message:a,severity:h,from:Qn(o,c,f),to:u===void 0?o.line(c).to:Qn(o,u,p)}))}}case"lua":return await fo("npm/luaparse","luaparse"),luaparse.defaultOptions.luaVersion="5.3",s=>{try{luaparse.parse(s.toString())}catch(o){if(o instanceof luaparse.SyntaxError)return[{source:"luaparse",message:o.message.replace(/^\[\d+:\d+\]\s*/u,""),severity:"error",from:o.index,to:o.index}]}return[]};case"json":return s=>{var o,l,a;try{let h=s.toString();h.trim()&&JSON.parse(h)}catch(h){if(h instanceof SyntaxError){let{message:c}=h,f=(o=/\bline (\d+)/u.exec(c))==null?void 0:o[1],u=(l=/\bcolumn (\d+)/u.exec(c))==null?void 0:l[1],p=(a=/\bposition (\d+)/u.exec(c))==null?void 0:a[1],m=0;return p?m=Number(p):f&&u&&(m=Qn(s,Number(f),Number(u))),[{message:c,severity:"error",from:m,to:m}]}}return[]};default:return}}setContent(e){V(this,ne).dispatch({changes:{from:0,to:V(this,ne).state.doc.length,insert:e}})}toggle(e=!V(this,ni)){if(e&&!V(this,ni)){let{value:t,selectionStart:i,selectionEnd:r,scrollTop:s}=V(this,qe),o=document.activeElement===V(this,qe);this.setContent(t),_e(this,uo,Np).call(this),V(this,ne).dom.style.removeProperty("display"),V(this,qe).style.display="none",V(this,ne).requestMeasure(),V(this,ne).dispatch({selection:{anchor:i,head:r}}),o&&V(this,ne).focus(),requestAnimationFrame(()=>{V(this,ne).scrollDOM.scrollTop=s})}else if(!e&&V(this,ni)){let{state:{selection:{main:{from:t,to:i,head:r}}},hasFocus:s}=V(this,ne),{scrollDOM:{scrollTop:o}}=V(this,ne);V(this,ne).dom.style.setProperty("display","none","important"),V(this,qe).style.display="",V(this,qe).setSelectionRange(t,i,r===i?"forward":"backward"),s&&V(this,qe).focus(),requestAnimationFrame(()=>{V(this,qe).scrollTop=o})}li(this,ni,e)}extraKeys(e){_e(this,Nt,Ti).call(this,V(this,rr).reconfigure(ft.of(e)))}localize(e){Object.assign(Pp,e),_e(this,Nt,Ti).call(this,V(this,sr).reconfigure(se.phrases.of(Pp)))}getNodeAt(e){var t;return(t=Pt(V(this,ne).state,e))==null?void 0:t.resolve(e,1)}scrollTo(e=V(this,ne).state.selection.main){let t=N.scrollIntoView(typeof e=="number"||e instanceof Vt?e:D.range(e.anchor,e.head));t.value.isSnapshot=!0,V(this,ne).dispatch({effects:t})}static replaceSelections(e,t){let{state:i}=e;e.dispatch(i.changeByRange(({from:r,to:s})=>{let o=t(i.sliceDoc(r,s),{from:r,to:s});if(typeof o=="string")return{range:D.range(r,r+o.length),changes:{from:r,to:s,insert:o}};let[l,a,h=a]=o;return{range:D.range(a,h),changes:{from:r,to:s,insert:l}}}))}static getMwConfig(e){let t={tags:{},tagModes:mo.mwTagModes,doubleUnderscore:[{},{}],functionSynonyms:[e.parserFunction[0],{}],urlProtocols:`${e.protocol}|//`,nsid:e.nsid,img:{},variants:e.variants};er(e.ext,t.tags),er(e.doubleUnderscore[0].map(i=>`__${i}__`),t.doubleUnderscore[0]),er(e.doubleUnderscore[1].map(i=>`__${i}__`),t.doubleUnderscore[1]),er(e.parserFunction.slice(2).flat(),t.functionSynonyms[0],!0),er(e.parserFunction[1],t.functionSynonyms[1]);for(let[i,r]of Object.entries(e.img))t.img[i]=`img_${r}`;return t}};qe=new WeakMap,ne=new WeakMap,tr=new WeakMap,Ci=new WeakMap,ir=new WeakMap,nr=new WeakMap,rr=new WeakMap,sr=new WeakMap,Mt=new WeakMap,ni=new WeakMap,Ai=new WeakMap,Nt=new WeakSet,Ti=function(e){V(this,ne).dispatch({effects:e})},uo=new WeakSet,Np=function(){let{offsetHeight:e}=V(this,qe);V(this,ne).dom.style.height=e?`${e}px`:V(this,qe).style.height},or=new WeakSet,hh=function(e){V(this,ne).dom.style.minHeight=e?"calc(100px + 2em)":"2em"},lr=new WeakSet,ch=function(e){var t;(e?Fa:Fs)(V(this,ne)),(t=document.querySelector(".cm-panel-lint ul"))==null||t.blur(),_e(this,or,hh).call(this,e)},po=new WeakSet,Ip=function(){return V(this,Ci).get(V(this,ne).state)[0]},mo.mwTagModes={tab:"text/mediawiki",tabs:"text/mediawiki",indicator:"text/mediawiki",poem:"text/mediawiki",ref:"text/mediawiki",references:"text/mediawiki",option:"text/mediawiki",choose:"text/mediawiki",combooption:"text/mediawiki",combobox:"text/mediawiki",poll:"text/mediawiki",gallery:"text/mediawiki"};var lo=mo;export{Rp as CDN,lo as CodeMirror6};
|
|
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 fs(t,e?e.state.tabSize:4,e?Xt(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=Tu(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=be.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:ob,topID:0,maxBufferLength:2048,reused:this.chunkReused});e=new be(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 be(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Tu(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 ga=Object.create(null),Kn=[He.none],ob=new ss(Kn),lu=[],au=Object.create(null),Cu=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"]])Cu[n]=Au(ga,e);var us=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Cu)}resolve(e){return e?this.table[e]||(this.table[e]=Au(this.extra,e)):0}},lb=new us(ga);function sa(n,e){lu.indexOf(n)>-1||(lu.push(n),console.warn(e))}function Au(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||I[h];c?typeof c=="function"?a.length?a=a.map(c):sa(h,`Modifier ${h} used at start of tag`):a.length?sa(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:sa(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=au[r];if(s)return s.id;let o=au[r]=He.define({id:Kn.length,name:i,props:[Qf({[i]:t})]});return Kn.push(o),o.id}function ab(n){let e=He.define({id:Kn.length,name:"Document",props:[_i.add(()=>n)],top:!0});return Kn.push(e),e}var uw={rtl:_.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:fe.RTL}),ltr:_.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:fe.LTR}),auto:_.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var hb=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Sa(n.state,t.from);return i.line?cb(n):i.block?ub(n):!1};function va(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 cb=va(mb,0);var fb=va(Ru,0);var ub=va((n,e)=>Ru(n,e,pb(e)),0);function Sa(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var _n=50;function db(n,{open:e,close:t},i,r){let s=n.sliceDoc(i-_n,i),o=n.sliceDoc(r,r+_n),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*_n?c=f=n.sliceDoc(i,r):(c=n.sliceDoc(i,i+_n),f=n.sliceDoc(r-_n,r));let u=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(f)[0].length,m=f.length-p-t.length;return c.slice(u,u+e.length)==e&&f.slice(m,m+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(m-1))?1:0}}:null}function pb(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 Ru(n,e,t=e.selection.ranges){let i=t.map(s=>Sa(e,s.from).block);if(!i.every(s=>s))return null;let r=t.map((s,o)=>db(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 mb(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=Sa(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,m=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:m,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 ya=We.define(),gb=We.define(),bb=z.define(),Nu=z.define({combine(n){return Pe(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)})}}),Iu=ce.define({create(){return ki.empty},update(n,e){let t=e.state.facet(Nu),i=e.annotation(ya);if(i){let a=dt.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=ks(c,c.length,t.minDepth,a):c=Vu(c,e.startState.selection),new ki(h==0?i.rest:c,h==0?c:i.rest)}let r=e.annotation(gb);if((r=="full"||r=="before")&&(n=n.isolate()),e.annotation(ve.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let s=dt.fromTransaction(e),o=e.annotation(ve.time),l=e.annotation(ve.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 ki(n.done.map(dt.fromJSON),n.undone.map(dt.fromJSON))}});function zu(n={}){return[Iu,Nu.of(n),N.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Fu:e.inputType=="historyRedo"?ka:null;return i?(e.preventDefault(),i(t)):!1}})]}function ws(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let r=t.field(Iu,!1);if(!r)return!1;let s=r.pop(n,t,e);return s?(i(s),!0):!1}}var Fu=ws(0,!1),ka=ws(1,!1),yb=ws(0,!0),kb=ws(1,!0);var dt=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&&Ie.fromJSON(e.changes),[],e.mapped&&Et.fromJSON(e.mapped),e.startSelection&&L.fromJSON(e.startSelection),e.selectionsAfter.map(L.fromJSON))}static fromTransaction(e,t){let i=rt;for(let r of e.startState.facet(bb)){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,rt)}static selection(e){return new n(void 0,rt,void 0,void 0,e)}};function ks(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 wb(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 xb(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Hu(n,e){return n.length?e.length?n.concat(e):n:e}var rt=[],vb=200;function Vu(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-vb));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),ks(n,n.length-1,1e9,t.setSelAfter(i)))}else return[dt.selection([e])]}function Sb(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 ba(n,e){if(!n.length)return n;let t=n.length,i=rt;for(;t;){let r=Tb(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?[dt.selection(i)]:rt}function Tb(n,e,t){let i=Hu(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):rt,t);if(!n.changes)return dt.selection(i);let r=n.changes.map(e),s=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(s):s;return new dt(r,X.mapEffects(n.effects,e),o,n.startSelection.map(s),i)}var Cb=/^(input\.type|delete)($|\.)/,ki=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||Cb.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,wb(l.changes,e.changes))||i=="input.type.compose")?o=ks(o,o.length-1,r.minDepth,new dt(e.changes.compose(l.changes),Hu(e.effects,l.effects),l.mapped,l.startSelection,rt)):o=ks(o,o.length,r.minDepth,e),new n(o,rt,t,i)}addSelection(e,t,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:rt;return s.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&xb(s[s.length-1],e)?this:new n(Vu(this.done,e),this.undone,t,i)}addMapping(e){return new n(ba(this.done,e),ba(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:ya.of({side:e,rest:Sb(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?rt:r.slice(0,r.length-1);return s.mapped&&(l=ba(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:ya.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};ki.empty=new ki(rt,rt);var Wu=[{key:"Mod-z",run:Fu,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ka,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ka,preventDefault:!0},{key:"Mod-u",run:yb,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:kb,preventDefault:!0}];function Qi(n,e){return L.create(n.ranges.map(e),n.mainIndex)}function Ct(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function pt({state:n,dispatch:e},t){let i=Qi(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Ct(n,i)),!0)}function xs(n,e){return L.cursor(e?n.to:n.from)}function ju(n,e){return pt(n,t=>t.empty?n.moveByChar(t,e):xs(t,e))}function Ne(n){return n.textDirectionAt(n.state.selection.main.head)==fe.LTR}var $u=n=>ju(n,!Ne(n)),qu=n=>ju(n,Ne(n));function Ku(n,e){return pt(n,t=>t.empty?n.moveByGroup(t,e):xs(t,e))}var Ab=n=>Ku(n,!Ne(n)),Mb=n=>Ku(n,Ne(n));var xw=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Lb(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 vs(n,e,t){let i=Ce(n).resolveInner(e.head),r=t?Z.closedBy:Z.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;Lb(n,h,r)?i=h:a=t?h.to:h.from}let s=i.type.prop(r),o,l;return s&&(o=t?ut(n,i.from,1):ut(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 Db=n=>pt(n,e=>vs(n.state,e,!Ne(n))),Eb=n=>pt(n,e=>vs(n.state,e,Ne(n)));function _u(n,e){return pt(n,t=>{if(!t.empty)return xs(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var Uu=n=>_u(n,!1),Gu=n=>_u(n,!0);function Yu(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let s of n.state.facet(N.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 Ju(n,e){let t=Yu(n),{state:i}=n,r=Qi(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):xs(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=N.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(Ct(i,r),{effects:s}),!0}var Mu=n=>Ju(n,!1),wa=n=>Ju(n,!0);function Qt(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 Ob=n=>pt(n,e=>Qt(n,e,!0)),Bb=n=>pt(n,e=>Qt(n,e,!1)),Pb=n=>pt(n,e=>Qt(n,e,!Ne(n))),Rb=n=>pt(n,e=>Qt(n,e,Ne(n))),Nb=n=>pt(n,e=>L.cursor(n.lineBlockAt(e.head).from,1)),Ib=n=>pt(n,e=>L.cursor(n.lineBlockAt(e.head).to,-1));function zb(n,e,t){let i=!1,r=Qi(n.selection,s=>{let o=ut(n,s.head,-1)||ut(n,s.head,1)||s.head>0&&ut(n,s.head-1,1)||s.head<n.doc.length&&ut(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(Ct(n,r)),!0):!1}var Fb=({state:n,dispatch:e})=>zb(n,e,!1);function st(n,e){let t=Qi(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(Ct(n.state,t)),!0)}function Xu(n,e){return st(n,t=>n.moveByChar(t,e))}var Zu=n=>Xu(n,!Ne(n)),Qu=n=>Xu(n,Ne(n));function ed(n,e){return st(n,t=>n.moveByGroup(t,e))}var Hb=n=>ed(n,!Ne(n)),Vb=n=>ed(n,Ne(n));var Wb=n=>st(n,e=>vs(n.state,e,!Ne(n))),jb=n=>st(n,e=>vs(n.state,e,Ne(n)));function td(n,e){return st(n,t=>n.moveVertically(t,e))}var id=n=>td(n,!1),nd=n=>td(n,!0);function rd(n,e){return st(n,t=>n.moveVertically(t,e,Yu(n).height))}var Lu=n=>rd(n,!1),Du=n=>rd(n,!0),$b=n=>st(n,e=>Qt(n,e,!0)),qb=n=>st(n,e=>Qt(n,e,!1)),Kb=n=>st(n,e=>Qt(n,e,!Ne(n))),_b=n=>st(n,e=>Qt(n,e,Ne(n))),Ub=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).from)),Gb=n=>st(n,e=>L.cursor(n.lineBlockAt(e.head).to)),Eu=({state:n,dispatch:e})=>(e(Ct(n,{anchor:0})),!0),Ou=({state:n,dispatch:e})=>(e(Ct(n,{anchor:n.doc.length})),!0),Bu=({state:n,dispatch:e})=>(e(Ct(n,{anchor:n.selection.main.anchor,head:0})),!0),Pu=({state:n,dispatch:e})=>(e(Ct(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Yb=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Jb=({state:n,dispatch:e})=>{let t=Ss(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},Xb=({state:n,dispatch:e})=>{let t=Qi(n.selection,i=>{var r;let s=Ce(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(Ct(n,t)),!0},Zb=({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(Ct(n,i)),!0):!1};function Un(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=ys(n,a,!1)):a>o&&(t="delete.forward",a=ys(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=ys(n,o,!1),l=ys(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"?N.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function ys(n,e,t){if(n instanceof N)for(let i of n.state.facet(N.atomicRanges).map(r=>r(n)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}var sd=(n,e)=>Un(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=Wt(o,r.tabSize),h=a%Xt(r)||Xt(r);for(let c=0;c<h&&o[o.length-1-c]==" ";c++)i--;l=i}else l=ke(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=ke(s.text,l-s.from,!1,!1)+s.from);return l}),xa=n=>sd(n,!1),od=n=>sd(n,!0),ld=(n,e)=>Un(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=ke(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}),ad=n=>ld(n,!1),Qb=n=>ld(n,!0),ey=n=>Un(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var ty=n=>Un(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),iy=n=>Un(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var ny=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Q.of(["",""])},range:L.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},ry=({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:ke(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:ke(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 Ss(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 hd(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let s of Ss(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 sy=({state:n,dispatch:e})=>hd(n,e,!1),oy=({state:n,dispatch:e})=>hd(n,e,!0);function cd(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of Ss(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 ly=({state:n,dispatch:e})=>cd(n,e,!1),ay=({state:n,dispatch:e})=>cd(n,e,!0),hy=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Ss(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=Qi(e.selection,r=>n.moveVertically(r,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function cy(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ce(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(Z.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 fy=fd(!1),uy=fd(!0);function fd(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&&cy(e,s);n&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new yi(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=ds(h,s);for(c==null&&(c=Wt(/^\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=["",Xi(e,c)];return a&&f.push(Xi(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:Q.of(f)},range:L.cursor(s+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ta(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 dy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new yi(n,{overrideIndentation:s=>{let o=t[s];return o==null?-1:o}}),r=Ta(n,(s,o,l)=>{let a=ds(i,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Xi(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},py=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ta(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Zt)})}),{userEvent:"input.indent"})),!0),my=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ta(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Wt(r,n.tabSize),o=0,l=Xi(n,Math.max(0,s-Xt(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 gy=[{key:"Ctrl-b",run:$u,shift:Zu,preventDefault:!0},{key:"Ctrl-f",run:qu,shift:Qu},{key:"Ctrl-p",run:Uu,shift:id},{key:"Ctrl-n",run:Gu,shift:nd},{key:"Ctrl-a",run:Nb,shift:Ub},{key:"Ctrl-e",run:Ib,shift:Gb},{key:"Ctrl-d",run:od},{key:"Ctrl-h",run:xa},{key:"Ctrl-k",run:ey},{key:"Ctrl-Alt-h",run:ad},{key:"Ctrl-o",run:ny},{key:"Ctrl-t",run:ry},{key:"Ctrl-v",run:wa}],by=[{key:"ArrowLeft",run:$u,shift:Zu,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Ab,shift:Hb,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Pb,shift:Kb,preventDefault:!0},{key:"ArrowRight",run:qu,shift:Qu,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Mb,shift:Vb,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Rb,shift:_b,preventDefault:!0},{key:"ArrowUp",run:Uu,shift:id,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Eu,shift:Bu},{mac:"Ctrl-ArrowUp",run:Mu,shift:Lu},{key:"ArrowDown",run:Gu,shift:nd,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ou,shift:Pu},{mac:"Ctrl-ArrowDown",run:wa,shift:Du},{key:"PageUp",run:Mu,shift:Lu},{key:"PageDown",run:wa,shift:Du},{key:"Home",run:Bb,shift:qb,preventDefault:!0},{key:"Mod-Home",run:Eu,shift:Bu},{key:"End",run:Ob,shift:$b,preventDefault:!0},{key:"Mod-End",run:Ou,shift:Pu},{key:"Enter",run:fy},{key:"Mod-a",run:Yb},{key:"Backspace",run:xa,shift:xa},{key:"Delete",run:od},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ad},{key:"Mod-Delete",mac:"Alt-Delete",run:Qb},{mac:"Mod-Backspace",run:ty},{mac:"Mod-Delete",run:iy}].concat(gy.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),ud=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Db,shift:Wb},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Eb,shift:jb},{key:"Alt-ArrowUp",run:sy},{key:"Shift-Alt-ArrowUp",run:ly},{key:"Alt-ArrowDown",run:oy},{key:"Shift-Alt-ArrowDown",run:ay},{key:"Escape",run:Zb},{key:"Mod-Enter",run:uy},{key:"Alt-l",mac:"Ctrl-l",run:Jb},{key:"Mod-i",run:Xb,preventDefault:!0},{key:"Mod-[",run:my},{key:"Mod-]",run:py},{key:"Mod-Alt-\\",run:dy},{key:"Shift-Mod-k",run:hy},{key:"Shift-Mod-\\",run:Fb},{key:"Mod-/",run:hb},{key:"Alt-A",run:fb}].concat(by);function oe(){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++)dd(n,arguments[e]);return n}function dd(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++)dd(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}var pd=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n,wi=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(pd(l)):pd,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 Se(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=dn(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Ve(e);let r=this.normalize(t);for(let s=0,o=i;;s++){let l=r.charCodeAt(s),a=this.match(l,o,this.bufferPos+this.bufferStart);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,i){let r=null;for(let s=0;s<this.matches.length;s+=2){let o=this.matches[s],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[s+1],to:i}:(this.matches[s]++,l=!0)),l||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:i}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol!="undefined"&&(wi.prototype[Symbol.iterator]=function(){return this});var bd={from:-1,to:-1,match:/.*/.exec("")},Oa="gm"+(/x/.unicode==null?"":"u"),As=class{constructor(e,t,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=bd,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Ls(e,t,i,r,s);this.re=new RegExp(t,Oa+(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=Ds(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=Ds(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}}},Ca=new WeakMap,Ms=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=Ca.get(e);if(!r||r.from>=i||r.to<=t){let l=new n(t,e.sliceString(t,i));return Ca.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)),Ca.set(e,new n(o,s)),new n(t,s.slice(t-o,i-o))}},Ls=class{constructor(e,t,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=bd,this.matchPos=Ds(e,r),this.re=new RegExp(t,Oa+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=Ms.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=Ds(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Ms.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol!="undefined"&&(As.prototype[Symbol.iterator]=Ls.prototype[Symbol.iterator]=function(){return this});function yy(n){try{return new RegExp(n,Oa),!0}catch(e){return!1}}function Ds(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 Aa(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=oe("input",{class:"cm-textfield",name:"line",value:e}),i=oe("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),n.dispatch({effects:Es.of(!1)}),n.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},oe("label",n.state.phrase("Go to line"),": ",t)," ",oe("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 m=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),w=L.cursor(m.from+Math.max(0,Math.min(u,m.length)));n.dispatch({effects:[Es.of(!1),N.scrollIntoView(w.from,{y:"center"})],selection:w}),n.focus()}return{dom:i}}var Es=X.define(),md=ce.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(Es)&&(n=t.value);return n},provide:n=>pi.from(n,e=>e?Aa:null)}),ky=n=>{let e=mi(n,Aa);if(!e){let t=[Es.of(!0)];n.state.field(md,!1)==null&&t.push(X.appendConfig.of([md,wy])),n.dispatch({effects:t}),e=mi(n,Aa)}return e&&e.dom.querySelector("input").select(),!0},wy=N.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});var xy=({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 vy(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 wi(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new wi(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 Sy=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(s=>s.from===s.to))return xy({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=vy(n,i);return r?(e(n.update({selection:n.selection.addRange(L.range(r.from,r.to),!1),effects:N.scrollIntoView(r.to)})),!0):!1},nn=z.define({combine(n){return Pe(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Ea(e),scrollToMatch:e=>N.scrollIntoView(e)})}});var Os=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||yy(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 La(this):new Ma(this)}getCursor(e,t=0,i){let r=e.doc?e:se.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?tn(this,r,t,i):en(this,r,t,i)}},Bs=class{constructor(e){this.spec=e}};function en(n,e,t,i){return new wi(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),n.wholeWord?Ty(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Ty(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(Ps(r,t-s))!=me.Word||e(Rs(r,t-s))!=me.Word)&&(e(Rs(r,i-s))!=me.Word||e(Ps(r,i-s))!=me.Word))}var Ma=class extends Bs{constructor(e){super(e)}nextMatch(e,t,i){let r=en(this.spec,e,i,e.doc.length).nextOverlapping();return r.done&&(r=en(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=en(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=en(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=en(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 tn(n,e,t,i){return new As(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?Cy(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function Ps(n,e){return n.slice(ke(n,e,!1),e)}function Rs(n,e){return n.slice(e,ke(n,e))}function Cy(n){return(e,t,i)=>!i[0].length||(n(Ps(i.input,i.index))!=me.Word||n(Rs(i.input,i.index))!=me.Word)&&(n(Rs(i.input,i.index+i[0].length))!=me.Word||n(Ps(i.input,i.index+i[0].length))!=me.Word)}var La=class extends Bs{nextMatch(e,t,i){let r=tn(this.spec,e,i,e.doc.length).next();return r.done&&(r=tn(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=tn(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=tn(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=tn(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)}},Yn=X.define(),Ba=X.define(),ei=ce.define({create(n){return new Gn(Da(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Yn)?n=new Gn(t.value.create(),n.panel):t.is(Ba)&&(n=new Gn(n.query,t.value?Pa:null));return n},provide:n=>pi.from(n,e=>e.panel)});var Gn=class{constructor(e,t){this.query=e,this.panel=t}},Ay=_.mark({class:"cm-searchMatch"}),My=_.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ly=ye.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(ei))}update(n){let e=n.state.field(ei);(e!=n.startState.field(ei)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return _.none;let{view:t}=this,i=new mt;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?My:Ay)})}return i.finish()}},{decorations:n=>n.decorations});function Jn(n){return e=>{let t=e.state.field(ei,!1);return t&&t.query.spec.valid?n(e,t):wd(e)}}var Ns=Jn((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(nn);return n.dispatch({selection:r,effects:[Ra(n,i),s.scrollToMatch(r.main,n)],userEvent:"select.search"}),kd(n),!0}),Is=Jn((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(nn);return n.dispatch({selection:s,effects:[Ra(n,r),o.scrollToMatch(s.main,n)],userEvent:"select.search"}),kd(n),!0}),Dy=Jn((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)}),Ey=({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 wi(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},gd=Jn((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(N.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(Ra(n,s)),h.push(t.facet(nn).scrollToMatch(l.main,n))}return n.dispatch({changes:o,selection:l,effects:h,userEvent:"input.replace"}),!0}),Oy=Jn((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:N.announce.of(i),userEvent:"input.replace.all"}),!0});function Pa(n){return n.state.facet(nn).createPanel(n)}function Da(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(nn);return new Os({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 yd(n){let e=mi(n,Pa);return e&&e.dom.querySelector("[main-field]")}function kd(n){let e=yd(n);e&&e==n.root.activeElement&&e.select()}var wd=n=>{let e=n.state.field(ei,!1);if(e&&e.panel){let t=yd(n);if(t&&t!=n.root.activeElement){let i=Da(n.state,e.query.spec);i.valid&&n.dispatch({effects:Yn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Ba.of(!0),e?Yn.of(Da(n.state,e.query.spec)):X.appendConfig.of(Py)]});return!0},xd=n=>{let e=n.state.field(ei,!1);if(!e||!e.panel)return!1;let t=mi(n,Pa);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Ba.of(!1)}),!0},vd=[{key:"Mod-f",run:wd,scope:"editor search-panel"},{key:"F3",run:Ns,shift:Is,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Ns,shift:Is,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:xd,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Ey},{key:"Mod-Alt-g",run:ky},{key:"Mod-d",run:Sy,preventDefault:!0}],Ea=class{constructor(e){this.view=e;let t=this.query=e.state.field(ei).query.spec;this.commit=this.commit.bind(this),this.searchField=oe("input",{value:t.search,placeholder:Xe(e,"Find"),"aria-label":Xe(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=oe("input",{value:t.replace,placeholder:Xe(e,"Replace"),"aria-label":Xe(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=oe("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=oe("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=oe("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(r,s,o){return oe("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=oe("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>Ns(e),[Xe(e,"next")]),i("prev",()=>Is(e),[Xe(e,"previous")]),i("select",()=>Dy(e),[Xe(e,"all")]),oe("label",null,[this.caseField,Xe(e,"match case")]),oe("label",null,[this.reField,Xe(e,"regexp")]),oe("label",null,[this.wordField,Xe(e,"by word")]),...e.state.readOnly?[]:[oe("br"),this.replaceField,i("replace",()=>gd(e),[Xe(e,"replace")]),i("replaceAll",()=>Oy(e),[Xe(e,"replace all")])],oe("button",{name:"close",onclick:()=>xd(e),"aria-label":Xe(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new Os({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:Yn.of(e)}))}keydown(e){Ef(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Is:Ns)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),gd(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Yn)&&!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(nn).top}};function Xe(n,e){return n.state.phrase(e)}var Ts=30,Cs=/[\s\.,:;?!]/;function Ra(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-Ts),o=Math.min(r,t+Ts),l=n.state.sliceDoc(s,o);if(s!=i.from){for(let a=0;a<Ts;a++)if(!Cs.test(l[a+1])&&Cs.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-Ts;a--)if(!Cs.test(l[a-1])&&Cs.test(l[a])){l=l.slice(0,a);break}}return N.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}var By=N.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"}}),Py=[ei,gt.low(Ly),By];var Na=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},xi=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(vi).markerFilter;s&&(r=s(r,i));let o=_.set(r.map(l=>l.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?_.widget({widget:new Ia(l),diagnostic:l}).range(l.from):_.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity+(l.markClass?" "+l.markClass:"")},diagnostic:l,inclusive:!0}).range(l.from,l.to)),!0);return new n(o,t,rn(o))}};function rn(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 Na(r,s,o.diagnostic),!1}),i}function Td(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(js))||n.changes.touchesRange(t.from,t.to))}function Cd(n,e){return n.field(Ze,!1)?e:e.concat(X.appendConfig.of(Rd))}function Ry(n,e){return{effects:Cd(n,[js.of(e)])}}var js=X.define(),Fa=X.define(),Ad=X.define(),Ze=ce.define({create(){return new xi(_.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=rn(t,n.selected.diagnostic,r)||rn(t,null,r)}n=new xi(t,n.panel,i)}for(let t of e.effects)t.is(js)?n=xi.init(t.value,n.panel,e.state):t.is(Fa)?n=new xi(n.diagnostics,t.value?Ws.open:null,n.selected):t.is(Ad)&&(n=new xi(n.diagnostics,n.panel,t.value));return n},provide:n=>[pi.from(n,e=>e.panel),N.decorations.from(n,e=>e.diagnostics)]});var Ny=_.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function Iy(n,e,t){let{diagnostics:i}=n.state.field(Ze),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(vi).tooltipFilter;return l&&(r=l(r,n.state)),r.length?{pos:s,end:o,above:n.state.doc.lineAt(s).to<o,create(){return{dom:Md(n,r)}}}:null}function Md(n,e){return oe("ul",{class:"cm-tooltip-lint"},e.map(t=>Od(n,t,!1)))}var Ha=n=>{let e=n.state.field(Ze,!1);(!e||!e.panel)&&n.dispatch({effects:Cd(n.state,[Fa.of(!0)])});let t=mi(n,Ws.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Hs=n=>{let e=n.state.field(Ze,!1);return!e||!e.panel?!1:(n.dispatch({effects:Fa.of(!1)}),!0)},zy=n=>{let e=n.state.field(Ze,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)};var Ld=[{key:"Mod-Shift-m",run:Ha,preventDefault:!0},{key:"F8",run:zy}],Fy=ye.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(vi);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(vi);t.length&&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(Ry(this.view.state,r))},i=>{Re(this.view.state,i)})}}update(n){let e=n.state.facet(vi);(n.docChanged||e!=n.startState.facet(vi)||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)}}),vi=z.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},Pe(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 Dd(n,e={}){return[vi.of({source:n,config:e}),Fy,Rd]}function Ed(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 Od(n,e,t){var i;let r=t?Ed(e.actions):[];return oe("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},oe("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=rn(n.state.field(Ze).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),oe("u",h.slice(c,c+1)),h.slice(c+1)];return oe("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&oe("div",{class:"cm-diagnosticSource"},e.source))}var Ia=class extends Je{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return oe("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},Vs=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Od(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Ws=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)Hs(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=Ed(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=rn(this.view.state.field(Ze).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=oe("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=oe("div",{class:"cm-panel-lint"},this.list,oe("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Hs(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Ze).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(Ze),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 Vs(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 Vs(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(Ze),i=rn(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Ad.of(i)})}static open(e){return new n(e)}};function Fs(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 zs(n){return Fs(`<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 Hy=N.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:zs("#d11")},".cm-lintRange-warning":{backgroundImage:zs("orange")},".cm-lintRange-info":{backgroundImage:zs("#999")},".cm-lintRange-hint":{backgroundImage:zs("#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 Sd(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}var za=class extends nt{constructor(e){super(),this.diagnostics=e,this.severity=e.reduce((t,i)=>Sd(t)<Sd(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($s).tooltipFilter;return r&&(i=r(i,e.state)),i.length&&(t.onmouseover=()=>Wy(e,t,i)),t}};function Vy(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(Pd)&&n.dispatch({effects:Va.of(null)})}};window.addEventListener("mousemove",t)}function Wy(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:Va.of({pos:o.from,above:!1,create(){return{dom:Md(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,Vy(n,e)}let{hoverTime:r}=n.state.facet($s),s=setTimeout(i,r);e.onmouseout=()=>{clearTimeout(s),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(s),s=setTimeout(i,r)}}function jy(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 za(t[r]).range(+r));return ie.of(i,!0)}var $y=ql({class:"cm-gutter-lint",markers:n=>n.state.field(Bd)}),Bd=ce.define({create(){return ie.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet($s).markerFilter;for(let i of e.effects)if(i.is(js)){let r=i.value;t&&(r=t(r||[],e.state)),n=jy(e.state.doc,r.slice(0))}return n}}),Va=X.define(),Pd=ce.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=Td(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(Va)?i.value:t,n)},provide:n=>Ut.from(n)}),qy=N.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Fs('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Fs('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Fs('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Rd=[Ze,N.decorations.compute([Ze],n=>{let{selected:e,panel:t}=n.field(Ze);return!e||!t||e.from==e.to?_.none:_.set([Ny.range(e.from,e.to)])}),Hf(Iy,{hideOn:Td}),Hy],$s=z.define({combine(n){return Pe(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Nd(n={}){return[$s.of(n),Bd,$y,qy,Pd]}var Ks=class{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=Ce(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),s=r.search($d(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}};function Id(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Ky(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let s=1;s<r.length;s++)t[r[s]]=!0}let i=Id(e)+Id(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function _y(n){let e=n.map(r=>typeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Ky(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}var _s=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function ti(n){return n.selection.main.from}function $d(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?n:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}var Uy=We.define();function Gy(n,e,t,i){let{main:r}=n.selection,s=t-r.from,o=i-r.from;return Object.assign(Object.assign({},n.changeByRange(l=>l!=r&&t!=i&&n.sliceDoc(l.from+s,l.from+o)!=n.sliceDoc(t,i)?{range:l}:{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:e},range:L.cursor(l.from+s+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}var zd=new WeakMap;function Yy(n){if(!Array.isArray(n))return n;let e=zd.get(n);return e||zd.set(n,e=_y(n)),e}var Us=X.define(),Xn=X.define(),$a=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=Se(e,t),r=Ve(i);this.chars.push(i);let s=e.slice(t,t+r),o=s.toUpperCase();this.folded.push(Se(o==s?s.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,!0}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return!1;let{chars:t,folded:i,any:r,precise:s,byWord:o}=this;if(t.length==1){let S=Se(e,0),E=Ve(S),O=E==e.length?0:-100;if(S!=t[0])if(S==i[0])O+=-200;else return!1;return this.ret(O,[0,E])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let S=0,E=Math.min(e.length,200);S<E&&h<a;){let O=Se(e,S);(O==t[h]||O==i[h])&&(r[h++]=S),S+=Ve(O)}if(h<a)return!1}let c=0,f=0,u=!1,p=0,m=-1,w=-1,y=/[a-z]/.test(e),v=!0;for(let S=0,E=Math.min(e.length,200),O=0;S<E&&f<a;){let D=Se(e,S);l<0&&(c<a&&D==t[c]&&(s[c++]=S),p<a&&(D==t[p]||D==i[p]?(p==0&&(m=S),w=S+1,p++):p=0));let R,x=D<255?D>=48&&D<=57||D>=97&&D<=122?2:D>=65&&D<=90?1:0:(R=dn(D))!=R.toLowerCase()?1:R!=R.toUpperCase()?2:0;(!S||x==1&&y||O==0&&x!=0)&&(t[f]==D||i[f]==D&&(u=!0)?o[f++]=S:o.length&&(v=!1)),O=x,S+=Ve(D)}return f==a&&o[0]==0&&v?this.result(-100+(u?-200:0),o,e):p==a&&m==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):p==a?this.ret(-900-e.length,[m,w]):f==a?this.result(-100+(u?-200:0)+-700+(v?0:-1100),o,e):t.length==2?!1:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],s=0;for(let o of t){let l=o+(this.astral?Ve(Se(i,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-i.length,r)}},Ee=z.define({combine(n){return Pe(n,{activateOnTyping:!0,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Jy,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Fd(e(i),t(i)),optionClass:(e,t)=>i=>Fd(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function Fd(n,e){return n?e?n+" "+e:n:e}function Jy(n,e,t,i,r,s){let o=n.textDirection==fe.RTL,l=o,a=!1,h="top",c,f,u=e.left-r.left,p=r.right-e.right,m=i.right-i.left,w=i.bottom-i.top;if(l&&u<Math.min(m,p)?l=!1:!l&&p<Math.min(m,u)&&(l=!0),m<=(l?u:p))c=Math.max(r.top,Math.min(t.top,r.bottom-w))-e.top,f=Math.min(400,l?u:p);else{a=!0,f=Math.min(400,(o?e.right:r.right-e.left)-30);let S=r.bottom-e.bottom;S>=w||S>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let y=(e.bottom-e.top)/s.offsetHeight,v=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${c/y}px; max-width: ${f/v}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function Xy(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<s.length;){let c=s[h++],f=s[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function Wa(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}var qa=class{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,l=e.state.facet(Ee);this.optionContent=Xy(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Wa(s.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(e,h[+f[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(Ee).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Xn.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:l}=i.open;(!r.open||r.open.options!=s)&&(this.range=Wa(s.length,o,e.state.facet(Ee).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),l!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Wa(t.options.length,t.selected,this.view.state.facet(Ee).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:r}=i;if(!r)return;let s=typeof r=="string"?document.createTextNode(r):r(i);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>Re(this.view.state,o,"completion info")):this.addInfoPane(s,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&Qy(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(Ee).positionInfo(this.view,t,r,i,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){let r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions"));let s=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=s&&(o>i.from||i.from==0))if(s=u,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let p=r.appendChild(document.createElement("completion-section"));p.textContent=u}}let c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let p=u(l,this.view.state,this.view,a);p&&c.appendChild(p)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}};function Zy(n,e){return t=>new qa(t,n,e)}function Qy(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/r:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function Hd(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function ek(n,e){let t=[],i=null,r=a=>{t.push(a);let{section:h}=a.completion;if(h){i||(i=[]);let c=typeof h=="string"?h:h.name;i.some(f=>f.name==c)||i.push(typeof h=="string"?{name:c}:h)}};for(let a of n)if(a.hasResult()){let h=a.result.getMatch;if(a.result.filter===!1)for(let c of a.result.options)r(new _s(c,a.source,h?h(c):[],1e9-t.length));else{let c=new $a(e.sliceDoc(a.from,a.to));for(let f of a.result.options)if(c.match(f.label)){let u=f.displayLabel?h?h(f,c.matched):[]:c.matched;r(new _s(f,a.source,u,c.score+(f.boost||0)))}}}if(i){let a=Object.create(null),h=0,c=(f,u)=>{var p,m;return((p=f.rank)!==null&&p!==void 0?p:1e9)-((m=u.rank)!==null&&m!==void 0?m:1e9)||(f.name<u.name?-1:1)};for(let f of i.sort(c))h-=1e5,a[f.name]=h;for(let f of t){let{section:u}=f.completion;u&&(f.score+=a[typeof u=="string"?u:u.name])}}let s=[],o=null,l=e.facet(Ee).compareCompletions;for(let a of t.sort((h,c)=>c.score-h.score||l(h.completion,c.completion))){let h=a.completion;!o||o.label!=h.label||o.detail!=h.detail||o.type!=null&&h.type!=null&&o.type!=h.type||o.apply!=h.apply||o.boost!=h.boost?s.push(a):Hd(a.completion)>Hd(o)&&(s[s.length-1]=a),o=a.completion}return s}var Ka=class n{constructor(e,t,i,r,s,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new n(this.options,Vd(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,s){let o=ek(e,t);if(!o.length)return r&&e.some(a=>a.state==1)?new n(r.options,r.attrs,r.tooltip,r.timestamp,r.selected,!0):null;let l=t.facet(Ee).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let a=r.options[r.selected].completion;for(let h=0;h<o.length;h++)if(o[h].completion==a){l=h;break}}return new n(o,Vd(i,l),{pos:e.reduce((a,h)=>h.hasResult()?Math.min(a,h.from):a,1e8),create:sk,above:s.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new n(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}},_a=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(nk,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Ee),s=(i.override||t.languageDataAt("autocomplete",ti(t)).map(Yy)).map(l=>(this.active.find(h=>h.source==l)||new Rt(l,this.active.some(h=>h.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((l,a)=>l==this.active[a])&&(s=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!tk(s,this.active)?o=Ka.build(s,t,this.id,o,i):o&&o.disabled&&!s.some(l=>l.state==1)&&(o=null),!o&&s.every(l=>l.state!=1)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new Rt(l.source,0):l));for(let l of e.effects)l.is(Kd)&&(o=o&&o.setSelected(l.value,this.id));return s==this.active&&o==this.open?this:new n(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:ik}};function tk(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult;)t++;for(;i<e.length&&!e[i].hasResult;)i++;let r=t==n.length,s=i==e.length;if(r||s)return r==s;if(n[t++].result!=e[i++].result)return!1}}var ik={"aria-autocomplete":"list"};function Vd(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}var nk=[];function Ua(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}var Rt=class n{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=Ua(e),r=this;i?r=r.handleUserEvent(e,i,t):e.docChanged?r=r.handleChange(e):e.selection&&r.state!=0&&(r=new n(r.source,0));for(let s of e.effects)if(s.is(Us))r=new n(r.source,1,s.value?ti(e.state):-1);else if(s.is(Xn))r=new n(r.source,0);else if(s.is(qd))for(let o of s.value)o.source==r.source&&(r=o);return r}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new n(this.source,1)}handleChange(e){return e.changes.touchesRange(ti(e.startState))?new n(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new n(this.source,this.state,e.mapPos(this.explicitPos))}},Gs=class n extends Rt{constructor(e,t,i,r,s){super(e,2,t),this.result=i,this.from=r,this.to=s}hasResult(){return!0}handleUserEvent(e,t,i){var r;let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=ti(e.state);if((this.explicitPos<0?l<=s:l<this.from)||l>o||t=="delete"&&ti(e.startState)==this.from)return new Rt(this.source,t=="input"&&i.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),h;return rk(this.result.validFor,e.state,s,o)?new n(this.source,a,this.result,s,o):this.result.update&&(h=this.result.update(this.result,s,o,new Ks(e.state,l,a>=0)))?new n(this.source,a,h,h.from,(r=h.to)!==null&&r!==void 0?r:ti(e.state)):new Rt(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Rt(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new n(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}};function rk(n,e,t,i){if(!n)return!1;let r=e.sliceDoc(t,i);return typeof n=="function"?n(r,t,i,e):$d(n,!0).test(r)}var qd=X.define({map(n,e){return n.map(t=>t.map(e))}}),Kd=X.define(),Qe=ce.define({create(){return _a.start()},update(n,e){return n.update(e)},provide:n=>[Ut.from(n,e=>e.tooltip),N.contentAttributes.from(n,e=>e.attrs)]});function _d(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(Qe).active.find(r=>r.source==e.source);return i instanceof Gs?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},Gy(n.state,t,i.from,i.to)),{annotations:Uy.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}var sk=Zy(Qe,_d);function qs(n,e="option"){return t=>{let i=t.state.field(Qe,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(Ee).interactionDelay)return!1;let r=1,s;e=="page"&&(s=$l(t,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+r*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Kd.of(l)}),!0}}var Ya=n=>{let e=n.state.field(Qe,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(Ee).interactionDelay?!1:_d(n,e.open.options[e.open.selected])},ok=n=>n.state.field(Qe,!1)?(n.dispatch({effects:Us.of(!0)}),!0):!1,lk=n=>{let e=n.state.field(Qe,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Xn.of(null)}),!0)},Ga=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},ak=50,hk=1e3,ck=ye.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(Qe).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(Qe);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Qe)==e)return;let t=n.transactions.some(r=>(r.selection||r.docChanged)&&!Ua(r));for(let r=0;r<this.running.length;r++){let s=this.running[r];if(t||s.updates.length+n.transactions.length>ak&&Date.now()-s.time>hk){for(let o of s.context.abortListeners)try{o()}catch(l){Re(this.view.state,l)}s.context.abortListeners=null,this.running.splice(r--,1)}else s.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(s=>s.is(Us)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.state.facet(Ee).activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.state==1&&!this.running.some(s=>s.active.source==r.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let r of n.transactions)Ua(r)=="input"?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(Qe);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=ti(e),i=new Ks(e,t,n.explicitPos==t),r=new Ga(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Xn.of(null)}),Re(this.view.state,s)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ee).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ee);for(let i=0;i<this.running.length;i++){let r=this.running[i];if(r.done===void 0)continue;if(this.running.splice(i--,1),r.done){let o=new Gs(r.active.source,r.active.explicitPos,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:ti(r.updates.length?r.updates[0].startState:this.view.state));for(let l of r.updates)o=o.update(l,t);if(o.hasResult()){e.push(o);continue}}let s=this.view.state.field(Qe).active.find(o=>o.source==r.active.source);if(s&&s.state==1)if(r.done==null){let o=new Rt(r.active.source,0);for(let l of r.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:qd.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Qe,!1);if(e&&e.tooltip&&this.view.state.facet(Ee).closeOnBlur){let t=e.open&&$l(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Xn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Us.of(!1)}),20),this.composing=0}}}),fk=N.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});var Ys={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Si=X.define({map(n,e){let t=e.mapPos(n,-1,Le.TrackAfter);return t==null?void 0:t}}),Ja=new class extends at{};Ja.startSide=1;Ja.endSide=-1;var Ud=ce.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(Si)&&(n=n.update({add:[Ja.range(t.value,t.value+1)]}));return n}});function Gd(){return[mk,Ud]}var ja="()[]{}<>";function uk(n){for(let e=0;e<ja.length;e+=2)if(ja.charCodeAt(e)==n)return ja.charAt(e+1);return dn(n<128?n:n+1)}function dk(n,e){return n.languageDataAt("closeBrackets",e)[0]||Ys}var pk=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),mk=N.inputHandler.of((n,e,t,i)=>{if((pk?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&Ve(Se(i,0))==1||e!=r.from||t!=r.to)return!1;let s=gk(n.state,i);return s?(n.dispatch(s),!0):!1});function gk(n,e){let t=dk(n,n.selection.main.head),i=t.brackets||Ys.brackets;for(let r of i){let s=uk(Se(r,0));if(e==r)return s==r?kk(n,r,i.indexOf(r+r+r)>-1,t):bk(n,r,s,t.before||Ys.before);if(e==s&&Yd(n,n.selection.main.from))return yk(n,r,s)}return null}function Yd(n,e){let t=!1;return n.field(Ud).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Xa(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Ve(Se(t,0)))}function bk(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:Si.of(o.to+e.length),range:L.range(o.anchor+e.length,o.head+e.length)};let l=Xa(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Si.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 yk(n,e,t){let i=null,r=n.changeByRange(s=>s.empty&&Xa(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 kk(n,e,t,i){let r=i.stringPrefixes||Ys.stringPrefixes,s=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Si.of(l.to+e.length),range:L.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Xa(n.doc,a),c;if(h==e){if(Wd(n,a))return{changes:{insert:e+e,from:a},effects:Si.of(a+e.length),range:L.cursor(a+e.length)};if(Yd(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=jd(n,a-2*e.length,r))>-1&&Wd(n,c))return{changes:{insert:e+e+e+e,from:a},effects:Si.of(a+e.length),range:L.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=me.Word&&jd(n,a,r)>-1&&!wk(n,a,e,r))return{changes:{insert:e+e,from:a},effects:Si.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 Wd(n,e){let t=Ce(n).resolveInner(e+1);return t.parent&&t.from==e}function wk(n,e,t,i){let r=Ce(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 jd(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=me.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))!=me.Word)return s}return-1}function Jd(n={}){return[Qe,Ee.of(n),ck,xk,fk]}var Za=[{key:"Ctrl-Space",run:ok},{key:"Escape",run:lk},{key:"ArrowDown",run:qs(!0)},{key:"ArrowUp",run:qs(!1)},{key:"PageDown",run:qs(!0,"page")},{key:"PageUp",run:qs(!1,"page")},{key:"Enter",run:Ya}],xk=gt.highest(ft.computeN([Ee],n=>n.facet(Ee).defaultKeymap?[Za]:[]));var G={permittedHtmlTags:["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","meta","link"],implicitlyClosedHtmlTags:["br","hr","wbr","img","meta","link"],tags:{apostrophes:"mw-apostrophes",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",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",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",linkPageName:"mw-link-pagename",pageName:"mw-pagename",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateVariableDelimiter:"mw-templatevariable-delimiter"},get tokenTable(){let n={};for(let e of Object.values(this.tags))n[e]=je.define();return n}};var Zn={};dm(Zn,{css:()=>lp,javascript:()=>ap,json:()=>hp,lua:()=>up});function Js(n){n={...Ck,...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,m=n.lineComment,w=n.supportsAtComponent===!0,y=n.highlightNonStandardPropertyKeywords!==!1,v,S;function E(k,A){return v=A,k}function O(k,A){var T=k.next();if(t[T]){var F=t[T](k,A);if(F!==!1)return F}if(T=="@")return k.eatWhile(/[\w\\\-]/),E("def",k.current());if(T=="="||(T=="~"||T=="|")&&k.eat("="))return E(null,"compare");if(T=='"'||T=="'")return A.tokenize=D(T),A.tokenize(k,A);if(T=="#")return k.eatWhile(/[\w\\\-]/),E("atom","hash");if(T=="!")return k.match(/^\s*\w*/),E("keyword","important");if(/\d/.test(T)||T=="."&&k.eat(/\d/))return k.eatWhile(/[\w.%]/),E("number","unit");if(T==="-"){if(/[\d.]/.test(k.peek()))return k.eatWhile(/[\w.%]/),E("number","unit");if(k.match(/^-[\w\\\-]*/))return k.eatWhile(/[\w\\\-]/),k.match(/^\s*:/,!1)?E("def","variable-definition"):E("variableName","variable");if(k.match(/^\w+-/))return E("meta","meta")}else return/[,+>*\/]/.test(T)?E(null,"select-op"):T=="."&&k.match(/^-?[_a-z][_a-z0-9-]*/i)?E("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(T)?E(null,T):k.match(/^[\w-.]+(?=\()/)?(/^(url(-prefix)?|domain|regexp)$/i.test(k.current())&&(A.tokenize=R),E("variableName.function","variable")):/[\w\\\-]/.test(T)?(k.eatWhile(/[\w\\\-]/),E("property","word")):E(null,null)}function D(k){return function(A,T){for(var F=!1,te;(te=A.next())!=null;){if(te==k&&!F){k==")"&&A.backUp(1);break}F=!F&&te=="\\"}return(te==k||!F&&k!=")")&&(T.tokenize=null),E("string","string")}}function R(k,A){return k.next(),k.match(/^\s*[\"\')]/,!1)?A.tokenize=null:A.tokenize=D(")"),E(null,"(")}function x(k,A,T){this.type=k,this.indent=A,this.prev=T}function M(k,A,T,F){return k.context=new x(T,A.indentation()+(F===!1?0:A.indentUnit),k.context),T}function b(k){return k.context.prev&&(k.context=k.context.prev),k.context.type}function Y(k,A,T){return q[T.context.type](k,A,T)}function K(k,A,T,F){for(var te=F||1;te>0;te--)T.context=T.context.prev;return Y(k,A,T)}function U(k){var A=k.current().toLowerCase();u.hasOwnProperty(A)?S="atom":f.hasOwnProperty(A)?S="keyword":S="variable"}var q={};return q.top=function(k,A,T){if(k=="{")return M(T,A,"block");if(k=="}"&&T.context.prev)return b(T);if(w&&/@component/i.test(k))return M(T,A,"atComponentBlock");if(/^@(-moz-)?document$/i.test(k))return M(T,A,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(k))return M(T,A,"atBlock");if(/^@(font-face|counter-style)/i.test(k))return T.stateArg=k,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(k))return"keyframes";if(k&&k.charAt(0)=="@")return M(T,A,"at");if(k=="hash")S="builtin";else if(k=="word")S="tag";else{if(k=="variable-definition")return"maybeprop";if(k=="interpolation")return M(T,A,"interpolation");if(k==":")return"pseudo";if(p&&k=="(")return M(T,A,"parens")}return T.context.type},q.block=function(k,A,T){if(k=="word"){var F=A.current().toLowerCase();return l.hasOwnProperty(F)?(S="property","maybeprop"):a.hasOwnProperty(F)?(S=y?"string.special":"property","maybeprop"):p?(S=A.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(S="error","maybeprop")}else return k=="meta"?"block":!p&&(k=="hash"||k=="qualifier")?(S="error","block"):q.top(k,A,T)},q.maybeprop=function(k,A,T){return k==":"?M(T,A,"prop"):Y(k,A,T)},q.prop=function(k,A,T){if(k==";")return b(T);if(k=="{"&&p)return M(T,A,"propBlock");if(k=="}"||k=="{")return K(k,A,T);if(k=="(")return M(T,A,"parens");if(k=="hash"&&!/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(A.current()))S="error";else if(k=="word")U(A);else if(k=="interpolation")return M(T,A,"interpolation");return"prop"},q.propBlock=function(k,A,T){return k=="}"?b(T):k=="word"?(S="property","maybeprop"):T.context.type},q.parens=function(k,A,T){return k=="{"||k=="}"?K(k,A,T):k==")"?b(T):k=="("?M(T,A,"parens"):k=="interpolation"?M(T,A,"interpolation"):(k=="word"&&U(A),"parens")},q.pseudo=function(k,A,T){return k=="meta"?"pseudo":k=="word"?(S="variableName.constant",T.context.type):Y(k,A,T)},q.documentTypes=function(k,A,T){return k=="word"&&i.hasOwnProperty(A.current())?(S="tag",T.context.type):q.atBlock(k,A,T)},q.atBlock=function(k,A,T){if(k=="(")return M(T,A,"atBlock_parens");if(k=="}"||k==";")return K(k,A,T);if(k=="{")return b(T)&&M(T,A,p?"block":"top");if(k=="interpolation")return M(T,A,"interpolation");if(k=="word"){var F=A.current().toLowerCase();F=="only"||F=="not"||F=="and"||F=="or"?S="keyword":r.hasOwnProperty(F)?S="attribute":s.hasOwnProperty(F)?S="property":o.hasOwnProperty(F)?S="keyword":l.hasOwnProperty(F)?S="property":a.hasOwnProperty(F)?S=y?"string.special":"property":u.hasOwnProperty(F)?S="atom":f.hasOwnProperty(F)?S="keyword":S="error"}return T.context.type},q.atComponentBlock=function(k,A,T){return k=="}"?K(k,A,T):k=="{"?b(T)&&M(T,A,p?"block":"top",!1):(k=="word"&&(S="error"),T.context.type)},q.atBlock_parens=function(k,A,T){return k==")"?b(T):k=="{"||k=="}"?K(k,A,T,2):q.atBlock(k,A,T)},q.restricted_atBlock_before=function(k,A,T){return k=="{"?M(T,A,"restricted_atBlock"):k=="word"&&T.stateArg=="@counter-style"?(S="variable","restricted_atBlock_before"):Y(k,A,T)},q.restricted_atBlock=function(k,A,T){return k=="}"?(T.stateArg=null,b(T)):k=="word"?(T.stateArg=="@font-face"&&!h.hasOwnProperty(A.current().toLowerCase())||T.stateArg=="@counter-style"&&!c.hasOwnProperty(A.current().toLowerCase())?S="error":S="property","maybeprop"):"restricted_atBlock"},q.keyframes=function(k,A,T){return k=="word"?(S="variable","keyframes"):k=="{"?M(T,A,"top"):Y(k,A,T)},q.at=function(k,A,T){return k==";"?b(T):k=="{"||k=="}"?K(k,A,T):(k=="word"?S="tag":k=="hash"&&(S="builtin"),"at")},q.interpolation=function(k,A,T){return k=="}"?b(T):k=="{"||k==";"?K(k,A,T):(k=="word"?S="variable":k!="variable"&&k!="("&&k!=")"&&(S="error"),"interpolation")},{name:n.name,startState:function(){return{tokenize:null,state:e?"block":"top",stateArg:null,context:new x(e?"block":"top",0,null)}},token:function(k,A){if(!A.tokenize&&k.eatSpace())return null;var T=(A.tokenize||O)(k,A);return T&&typeof T=="object"&&(v=T[1],T=T[0]),S=T,v!="comment"&&(A.state=q[A.state](v,k,A)),S},indent:function(k,A,T){var F=k.context,te=A&&A.charAt(0),le=F.indent;return F.type=="prop"&&(te=="}"||te==")")&&(F=F.prev),F.prev&&(te=="}"&&(F.type=="block"||F.type=="top"||F.type=="interpolation"||F.type=="restricted_atBlock")?(F=F.prev,le=F.indent):(te==")"&&(F.type=="parens"||F.type=="atBlock_parens")||te=="{"&&(F.type=="at"||F.type=="atBlock"))&&(le=Math.max(0,F.indent-T.unit))),le},languageData:{indentOnInput:/^\s*\}$/,commentTokens:{line:m,block:{open:"/*",close:"*/"}},autocomplete:Tk}}}function At(n){for(var e={},t=0;t<n.length;++t)e[n[t].toLowerCase()]=!0;return e}var Xd=["domain","regexp","url","url-prefix"],Zd=At(Xd),Qd=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],Xs=At(Qd),ep=["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"],Zs=At(ep),tp=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive","dark","light","standard","high"],Qa=At(tp),ip=["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"],Qs=At(ip),np=["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"],eo=At(np),vk=["font-display","font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],to=At(vk),Sk=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],rp=At(Sk),sp=["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"],io=At(sp),op=["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"],no=At(op),Tk=Xd.concat(Qd).concat(ep).concat(tp).concat(ip).concat(np).concat(sp).concat(op);var Ck={documentTypes:Zd,mediaTypes:Xs,mediaFeatures:Zs,mediaValueKeywords:Qa,propertyKeywords:Qs,nonStandardPropertyKeywords:eo,fontProperties:to,counterDescriptors:rp,colorKeywords:io,valueKeywords:no,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=ii,ii(n,e)):!1}}},lp=Js({name:"css"});function ii(n,e){for(var t=!1,i;(i=n.next())!=null;){if(t&&i=="/"){e.tokenize=null;break}t=i=="*"}return["comment","comment"]}var jw=Js({name:"scss",mediaTypes:Xs,mediaFeatures:Zs,mediaValueKeywords:Qa,propertyKeywords:Qs,nonStandardPropertyKeywords:eo,colorKeywords:io,valueKeywords:no,fontProperties:to,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=ii,ii(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}}}),$w=Js({name:"less",mediaTypes:Xs,mediaFeatures:Zs,mediaValueKeywords:Qa,propertyKeywords:Qs,nonStandardPropertyKeywords:eo,colorKeywords:io,valueKeywords:no,fontProperties:to,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(n,e){return n.eat("/")?(n.skipToEnd(),["comment","comment"]):n.eat("*")?(e.tokenize=ii,ii(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"]}}}),qw=Js({name:"gss",documentTypes:Zd,mediaTypes:Xs,mediaFeatures:Zs,propertyKeywords:Qs,nonStandardPropertyKeywords:eo,fontProperties:to,counterDescriptors:rp,colorKeywords:io,valueKeywords:no,supportsAtComponent:!0,tokenHooks:{"/":function(n,e){return n.eat("*")?(e.tokenize=ii,ii(n,e)):!1}}});function ro(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(Ke){return{type:Ke,style:"keyword"}}var g=d("keyword a"),C=d("keyword b"),P=d("keyword c"),H=d("keyword d"),ee=d("operator"),he={type:"atom",style:"atom"};return{if:d("if"),while:g,with:g,else:C,do:C,try:C,finally:C,return:H,break:H,continue:H,new:d("new"),delete:P,void:P,throw:P,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:ee,typeof:ee,instanceof:ee,true:he,false:he,null:he,undefined:he,NaN:he,Infinity:he,this:d("this"),class:d("class"),super:d("atom"),yield:P,export:d("export"),import:d("import"),extends:P,await:P}}(),l=/[+\-*&%=<>!?|~^@]/,a=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function h(d){for(var g=!1,C,P=!1;(C=d.next())!=null;){if(!g){if(C=="/"&&!P)return;C=="["?P=!0:P&&C=="]"&&(P=!1)}g=!g&&C=="\\"}}var c,f;function u(d,g,C){return c=d,f=C,g}function p(d,g){var C=d.next();if(C=='"'||C=="'")return g.tokenize=m(C),g.tokenize(d,g);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("*")?(g.tokenize=w,w(d,g)):d.eat("/")?(d.skipToEnd(),u("comment","comment")):fm(d,g,1)?(h(d),d.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),u("regexp","string.special")):(d.eat("="),u("operator","operator",d.current()));if(C=="`")return g.tokenize=y,y(d,g);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!=">"||!g.lexical||g.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 P=d.current();if(g.lastType!="."){if(o.propertyIsEnumerable(P)){var H=o[P];return u(H.type,H.style,P)}if(P=="async"&&d.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/,!1))return u("async","keyword",P)}return u("variable","variable",P)}}function m(d){return function(g,C){var P=!1,H;if(t&&g.peek()=="@"&&g.match(a))return C.tokenize=p,u("jsonld-keyword","meta");for(;(H=g.next())!=null&&!(H==d&&!P);)P=!P&&H=="\\";return P||(C.tokenize=p),u("string","string")}}function w(d,g){for(var C=!1,P;P=d.next();){if(P=="/"&&C){g.tokenize=p;break}C=P=="*"}return u("comment","comment")}function y(d,g){for(var C=!1,P;(P=d.next())!=null;){if(!C&&(P=="`"||P=="$"&&d.eat("{"))){g.tokenize=p;break}C=!C&&P=="\\"}return u("quasi","string.special",d.current())}var v="([{}])";function S(d,g){g.fatArrowAt&&(g.fatArrowAt=null);var C=d.string.indexOf("=>",d.start);if(!(C<0)){if(r){var P=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(d.string.slice(d.start,C));P&&(C=P.index)}for(var H=0,ee=!1,he=C-1;he>=0;--he){var Ke=d.string.charAt(he),et=v.indexOf(Ke);if(et>=0&&et<3){if(!H){++he;break}if(--H==0){Ke=="("&&(ee=!0);break}}else if(et>=3&&et<6)++H;else if(s.test(Ke))ee=!0;else if(/["'\/`]/.test(Ke))for(;;--he){if(he==0)return;var ln=d.string.charAt(he-1);if(ln==Ke&&d.string.charAt(he-2)!="\\"){he--;break}}else if(ee&&!H){++he;break}}ee&&!H&&(g.fatArrowAt=he)}}var E={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,import:!0,"jsonld-keyword":!0};function O(d,g,C,P,H,ee){this.indented=d,this.column=g,this.type=C,this.prev=H,this.info=ee,P!=null&&(this.align=P)}function D(d,g){for(var C=d.localVars;C;C=C.next)if(C.name==g)return!0;for(var P=d.context;P;P=P.prev)for(var C=P.vars;C;C=C.next)if(C.name==g)return!0}function R(d,g,C,P,H){var ee=d.cc;for(x.state=d,x.stream=H,x.marked=null,x.cc=ee,x.style=g,d.lexical.hasOwnProperty("align")||(d.lexical.align=!0);;){var he=ee.length?ee.pop():i?re:de;if(he(C,P)){for(;ee.length&&ee[ee.length-1].lex;)ee.pop()();return x.marked?x.marked:C=="variable"&&D(d,P)?"variableName.local":g}}}var x={state:null,column:null,marked:null,cc:null};function M(){for(var d=arguments.length-1;d>=0;d--)x.cc.push(arguments[d])}function b(){return M.apply(null,arguments),!0}function Y(d,g){for(var C=g;C;C=C.next)if(C.name==d)return!0;return!1}function K(d){var g=x.state;if(x.marked="def",g.context){if(g.lexical.info=="var"&&g.context&&g.context.block){var C=U(d,g.context);if(C!=null){g.context=C;return}}else if(!Y(d,g.localVars)){g.localVars=new A(d,g.localVars);return}}n.globalVars&&!Y(d,g.globalVars)&&(g.globalVars=new A(d,g.globalVars))}function U(d,g){if(g)if(g.block){var C=U(d,g.prev);return C?C==g.prev?g:new k(C,g.vars,!0):null}else return Y(d,g.vars)?g:new k(g.prev,new A(d,g.vars),!1);else return null}function q(d){return d=="public"||d=="private"||d=="protected"||d=="abstract"||d=="readonly"}function k(d,g,C){this.prev=d,this.vars=g,this.block=C}function A(d,g){this.name=d,this.next=g}var T=new A("this",new A("arguments",null));function F(){x.state.context=new k(x.state.context,x.state.localVars,!1),x.state.localVars=T}function te(){x.state.context=new k(x.state.context,x.state.localVars,!0),x.state.localVars=null}F.lex=te.lex=!0;function le(){x.state.localVars=x.state.context.vars,x.state.context=x.state.context.prev}le.lex=!0;function j(d,g){var C=function(){var P=x.state,H=P.indented;if(P.lexical.type=="stat")H=P.lexical.indented;else for(var ee=P.lexical;ee&&ee.type==")"&&ee.align;ee=ee.prev)H=ee.indented;P.lexical=new O(H,x.stream.column(),d,null,P.lexical,g)};return C.lex=!0,C}function $(){var d=x.state;d.lexical.prev&&(d.lexical.type==")"&&(d.indented=d.lexical.indented),d.lexical=d.lexical.prev)}$.lex=!0;function J(d){function g(C){return C==d?b():d==";"||C=="}"||C==")"||C=="]"?M():b(g)}return g}function de(d,g){return d=="var"?b(j("vardef",g),xo,J(";"),$):d=="keyword a"?b(j("form"),bo,de,$):d=="keyword b"?b(j("form"),de,$):d=="keyword d"?x.stream.match(/^\s*$/,!1)?b():b(j("stat"),Mi,J(";"),$):d=="debugger"?b(J(";")):d=="{"?b(j("}"),te,fr,$,le):d==";"?b():d=="if"?(x.state.lexical.info=="else"&&x.state.cc[x.state.cc.length-1]==$&&x.state.cc.pop()(),b(j("form"),bo,de,$,bh)):d=="function"?b(Ft):d=="for"?b(j("form"),te,yh,de,le,$):d=="class"||r&&g=="interface"?(x.marked="keyword",b(j("form",d=="class"?d:g),wh,$)):d=="variable"?r&&g=="declare"?(x.marked="keyword",b(de)):r&&(g=="module"||g=="enum"||g=="type")&&x.stream.match(/^\s*\w/,!1)?(x.marked="keyword",g=="enum"?b(Sh):g=="type"?b(kh,J("operator"),ae,J(";")):b(j("form"),ot,J("{"),j("}"),fr,$,$)):r&&g=="namespace"?(x.marked="keyword",b(j("form"),re,de,$)):r&&g=="abstract"?(x.marked="keyword",b(de)):b(j("stat"),_p):d=="switch"?b(j("form"),bo,J("{"),j("}","switch"),te,fr,$,$,le):d=="case"?b(re,J(":")):d=="default"?b(J(":")):d=="catch"?b(j("form"),F,It,de,$,le):d=="export"?b(j("stat"),sm,$):d=="import"?b(j("stat"),om,$):d=="async"?b(de):g=="@"?b(re,de):M(j("stat"),re,J(";"),$)}function It(d){if(d=="(")return b(oi,J(")"))}function re(d,g){return uh(d,g,!1)}function Oe(d,g){return uh(d,g,!0)}function bo(d){return d!="("?M():b(j(")"),Mi,J(")"),$)}function uh(d,g,C){if(x.state.fatArrowAt==x.stream.start){var P=C?ph:dh;if(d=="(")return b(F,j(")"),Ae(oi,")"),$,J("=>"),P,le);if(d=="variable")return M(F,ot,J("=>"),P,le)}var H=C?Li:ri;return E.hasOwnProperty(d)?b(H):d=="function"?b(Ft,H):d=="class"||r&&g=="interface"?(x.marked="keyword",b(j("form"),rm,$)):d=="keyword c"||d=="async"?b(C?Oe:re):d=="("?b(j(")"),Mi,J(")"),$,H):d=="operator"||d=="spread"?b(C?Oe:re):d=="["?b(j("]"),am,$,H):d=="{"?sn(cr,"}",null,H):d=="quasi"?M(hr,H):d=="new"?b($p(C)):b()}function Mi(d){return d.match(/[;\}\)\],]/)?M():M(re)}function ri(d,g){return d==","?b(Mi):Li(d,g,!1)}function Li(d,g,C){var P=C==!1?ri:Li,H=C==!1?re:Oe;if(d=="=>")return b(F,C?ph:dh,le);if(d=="operator")return/\+\+|--/.test(g)||r&&g=="!"?b(P):r&&g=="<"&&x.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/,!1)?b(j(">"),Ae(ae,">"),$,P):g=="?"?b(re,J(":"),H):b(H);if(d=="quasi")return M(hr,P);if(d!=";"){if(d=="(")return sn(Oe,")","call",P);if(d==".")return b(Up,P);if(d=="[")return b(j("]"),Mi,J("]"),$,P);if(r&&g=="as")return x.marked="keyword",b(ae,P);if(d=="regexp")return x.state.lastType=x.marked="operator",x.stream.backUp(x.stream.pos-x.stream.start-1),b(H)}}function hr(d,g){return d!="quasi"?M():g.slice(g.length-2)!="${"?b(hr):b(Mi,jp)}function jp(d){if(d=="}")return x.marked="string.special",x.state.tokenize=y,b(hr)}function dh(d){return S(x.stream,x.state),M(d=="{"?de:re)}function ph(d){return S(x.stream,x.state),M(d=="{"?de:Oe)}function $p(d){return function(g){return g=="."?b(d?Kp:qp):g=="variable"&&r?b(Qp,d?Li:ri):M(d?Oe:re)}}function qp(d,g){if(g=="target")return x.marked="keyword",b(ri)}function Kp(d,g){if(g=="target")return x.marked="keyword",b(Li)}function _p(d){return d==":"?b($,de):M(ri,J(";"),$)}function Up(d){if(d=="variable")return x.marked="property",b()}function cr(d,g){if(d=="async")return x.marked="property",b(cr);if(d=="variable"||x.style=="keyword"){if(x.marked="property",g=="get"||g=="set")return b(Gp);var C;return r&&x.state.fatArrowAt==x.stream.start&&(C=x.stream.match(/^\s*:\s*/,!1))&&(x.state.fatArrowAt=x.stream.pos+C[0].length),b(si)}else{if(d=="number"||d=="string")return x.marked=t?"property":x.style+" property",b(si);if(d=="jsonld-keyword")return b(si);if(r&&q(g))return x.marked="keyword",b(cr);if(d=="[")return b(re,Di,J("]"),si);if(d=="spread")return b(Oe,si);if(g=="*")return x.marked="keyword",b(cr);if(d==":")return M(si)}}function Gp(d){return d!="variable"?M(si):(x.marked="property",b(Ft))}function si(d){if(d==":")return b(Oe);if(d=="(")return M(Ft)}function Ae(d,g,C){function P(H,ee){if(C?C.indexOf(H)>-1:H==","){var he=x.state.lexical;return he.info=="call"&&(he.pos=(he.pos||0)+1),b(function(Ke,et){return Ke==g||et==g?M():M(d)},P)}return H==g||ee==g?b():C&&C.indexOf(";")>-1?M(d):b(J(g))}return function(H,ee){return H==g||ee==g?b():M(d,P)}}function sn(d,g,C){for(var P=3;P<arguments.length;P++)x.cc.push(arguments[P]);return b(j(g,C),Ae(d,g),$)}function fr(d){return d=="}"?b():M(de,fr)}function Di(d,g){if(r){if(d==":")return b(ae);if(g=="?")return b(Di)}}function Yp(d,g){if(r&&(d==":"||g=="in"))return b(ae)}function mh(d){if(r&&d==":")return x.stream.match(/^\s*\w+\s+is\b/,!1)?b(re,Jp,ae):b(ae)}function Jp(d,g){if(g=="is")return x.marked="keyword",b()}function ae(d,g){if(g=="keyof"||g=="typeof"||g=="infer"||g=="readonly")return x.marked="keyword",b(g=="typeof"?Oe:ae);if(d=="variable"||g=="void")return x.marked="type",b(Lt);if(g=="|"||g=="&")return b(ae);if(d=="string"||d=="number"||d=="atom")return b(Lt);if(d=="[")return b(j("]"),Ae(ae,"]",","),$,Lt);if(d=="{")return b(j("}"),yo,$,Lt);if(d=="(")return b(Ae(wo,")"),Xp,Lt);if(d=="<")return b(Ae(ae,">"),ae);if(d=="quasi")return M(ko,Lt)}function Xp(d){if(d=="=>")return b(ae)}function yo(d){return d.match(/[\}\)\]]/)?b():d==","||d==";"?b(yo):M(on,yo)}function on(d,g){if(d=="variable"||x.style=="keyword")return x.marked="property",b(on);if(g=="?"||d=="number"||d=="string")return b(on);if(d==":")return b(ae);if(d=="[")return b(J("variable"),Yp,J("]"),on);if(d=="(")return M(Oi,on);if(!d.match(/[;\}\)\],]/))return b()}function ko(d,g){return d!="quasi"?M():g.slice(g.length-2)!="${"?b(ko):b(ae,Zp)}function Zp(d){if(d=="}")return x.marked="string.special",x.state.tokenize=y,b(ko)}function wo(d,g){return d=="variable"&&x.stream.match(/^\s*[?:]/,!1)||g=="?"?b(wo):d==":"?b(ae):d=="spread"?b(wo):M(ae)}function Lt(d,g){if(g=="<")return b(j(">"),Ae(ae,">"),$,Lt);if(g=="|"||d=="."||g=="&")return b(ae);if(d=="[")return b(ae,J("]"),Lt);if(g=="extends"||g=="implements")return x.marked="keyword",b(ae);if(g=="?")return b(ae,J(":"),ae)}function Qp(d,g){if(g=="<")return b(j(">"),Ae(ae,">"),$,Lt)}function ur(){return M(ae,em)}function em(d,g){if(g=="=")return b(ae)}function xo(d,g){return g=="enum"?(x.marked="keyword",b(Sh)):M(ot,Di,zt,im)}function ot(d,g){if(r&&q(g))return x.marked="keyword",b(ot);if(d=="variable")return K(g),b();if(d=="spread")return b(ot);if(d=="[")return sn(tm,"]");if(d=="{")return sn(gh,"}")}function gh(d,g){return d=="variable"&&!x.stream.match(/^\s*:/,!1)?(K(g),b(zt)):(d=="variable"&&(x.marked="property"),d=="spread"?b(ot):d=="}"?M():d=="["?b(re,J("]"),J(":"),gh):b(J(":"),ot,zt))}function tm(){return M(ot,zt)}function zt(d,g){if(g=="=")return b(Oe)}function im(d){if(d==",")return b(xo)}function bh(d,g){if(d=="keyword b"&&g=="else")return b(j("form","else"),de,$)}function yh(d,g){if(g=="await")return b(yh);if(d=="(")return b(j(")"),nm,$)}function nm(d){return d=="var"?b(xo,Ei):d=="variable"?b(Ei):M(Ei)}function Ei(d,g){return d==")"?b():d==";"?b(Ei):g=="in"||g=="of"?(x.marked="keyword",b(re,Ei)):M(re,Ei)}function Ft(d,g){if(g=="*")return x.marked="keyword",b(Ft);if(d=="variable")return K(g),b(Ft);if(d=="(")return b(F,j(")"),Ae(oi,")"),$,mh,de,le);if(r&&g=="<")return b(j(">"),Ae(ur,">"),$,Ft)}function Oi(d,g){if(g=="*")return x.marked="keyword",b(Oi);if(d=="variable")return K(g),b(Oi);if(d=="(")return b(F,j(")"),Ae(oi,")"),$,mh,le);if(r&&g=="<")return b(j(">"),Ae(ur,">"),$,Oi)}function kh(d,g){if(d=="keyword"||d=="variable")return x.marked="type",b(kh);if(g=="<")return b(j(">"),Ae(ur,">"),$)}function oi(d,g){return g=="@"&&b(re,oi),d=="spread"?b(oi):r&&q(g)?(x.marked="keyword",b(oi)):r&&d=="this"?b(Di,zt):M(ot,Di,zt)}function rm(d,g){return d=="variable"?wh(d,g):dr(d,g)}function wh(d,g){if(d=="variable")return K(g),b(dr)}function dr(d,g){if(g=="<")return b(j(">"),Ae(ur,">"),$,dr);if(g=="extends"||g=="implements"||r&&d==",")return g=="implements"&&(x.marked="keyword"),b(r?ae:re,dr);if(d=="{")return b(j("}"),Dt,$)}function Dt(d,g){if(d=="async"||d=="variable"&&(g=="static"||g=="get"||g=="set"||r&&q(g))&&x.stream.match(/^\s+#?[\w$\xa1-\uffff]/,!1))return x.marked="keyword",b(Dt);if(d=="variable"||x.style=="keyword")return x.marked="property",b(pr,Dt);if(d=="number"||d=="string")return b(pr,Dt);if(d=="[")return b(re,Di,J("]"),pr,Dt);if(g=="*")return x.marked="keyword",b(Dt);if(r&&d=="(")return M(Oi,Dt);if(d==";"||d==",")return b(Dt);if(d=="}")return b();if(g=="@")return b(re,Dt)}function pr(d,g){if(g=="!"||g=="?")return b(pr);if(d==":")return b(ae,zt);if(g=="=")return b(Oe);var C=x.state.lexical.prev,P=C&&C.info=="interface";return M(P?Oi:Ft)}function sm(d,g){return g=="*"?(x.marked="keyword",b(vo,J(";"))):g=="default"?(x.marked="keyword",b(re,J(";"))):d=="{"?b(Ae(xh,"}"),vo,J(";")):M(de)}function xh(d,g){if(g=="as")return x.marked="keyword",b(J("variable"));if(d=="variable")return M(Oe,xh)}function om(d){return d=="string"?b():d=="("?M(re):d=="."?M(ri):M(mr,vh,vo)}function mr(d,g){return d=="{"?sn(mr,"}"):(d=="variable"&&K(g),g=="*"&&(x.marked="keyword"),b(lm))}function vh(d){if(d==",")return b(mr,vh)}function lm(d,g){if(g=="as")return x.marked="keyword",b(mr)}function vo(d,g){if(g=="from")return x.marked="keyword",b(re)}function am(d){return d=="]"?b():M(Ae(Oe,"]"))}function Sh(){return M(j("form"),ot,J("{"),j("}"),Ae(hm,"}"),$,$)}function hm(){return M(ot,zt)}function cm(d,g){return d.lastType=="operator"||d.lastType==","||l.test(g.charAt(0))||/[,.]/.test(g.charAt(0))}function fm(d,g,C){return g.tokenize==p&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(g.lastType)||g.lastType=="quasi"&&/\{\s*$/.test(d.string.slice(0,d.pos-(C||0)))}return{name:n.name,startState:function(d){var g={tokenize:p,lastType:"sof",cc:[],lexical:new O(-d,0,"block",!1),localVars:n.localVars,context:n.localVars&&new k(null,null,!1),indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(g.globalVars=n.globalVars),g},token:function(d,g){if(d.sol()&&(g.lexical.hasOwnProperty("align")||(g.lexical.align=!1),g.indented=d.indentation(),S(d,g)),g.tokenize!=w&&d.eatSpace())return null;var C=g.tokenize(d,g);return c=="comment"?C:(g.lastType=c=="operator"&&(f=="++"||f=="--")?"incdec":c,R(g,C,c,f,d))},indent:function(d,g,C){if(d.tokenize==w||d.tokenize==y)return null;if(d.tokenize!=p)return 0;var P=g&&g.charAt(0),H=d.lexical,ee;if(!/^\s*else\b/.test(g))for(var he=d.cc.length-1;he>=0;--he){var Ke=d.cc[he];if(Ke==$)H=H.prev;else if(Ke!=bh&&Ke!=le)break}for(;(H.type=="stat"||H.type=="form")&&(P=="}"||(ee=d.cc[d.cc.length-1])&&(ee==ri||ee==Li)&&!/^[,\.=+\-*:?[\(]/.test(g));)H=H.prev;e&&H.type==")"&&H.prev.type=="stat"&&(H=H.prev);var et=H.type,ln=P==et;return et=="vardef"?H.indented+(d.lastType=="operator"||d.lastType==","?H.info.length+1:0):et=="form"&&P=="{"?H.indented:et=="form"?H.indented+C.unit:et=="stat"?H.indented+(cm(d,g)?e||C.unit:0):H.info=="switch"&&!ln&&n.doubleIndentSwitch!=!1?H.indented+(/^(?:case|default)\b/.test(g)?C.unit:2*C.unit):H.align?H.column+(ln?0:1):H.indented+(ln?0:C.unit)},languageData:{indentOnInput:/^\s*(?:case .*?:|default:|\{|\})$/,commentTokens:i?void 0:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]},wordChars:"$"}}}var ap=ro({name:"javascript"}),hp=ro({name:"json",json:!0}),_w=ro({name:"json",jsonld:!0}),Uw=ro({name:"typescript",typescript:!0});function Ak(n){return new RegExp("^(?:"+n.join("|")+")","i")}function so(n){return new RegExp("^(?:"+n.join("|")+")$","i")}var Mk=so(["_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"]),Lk=so(["and","break","elseif","false","nil","not","or","return","true","function","end","if","then","else","do","while","repeat","until","for","in","local"]),Dk=so(["function","if","repeat","do","\\(","{"]),Ek=so(["end","until","\\)","}"]),Ok=Ak(["end","until","\\)","}","else","elseif"]);function cp(n){for(var e=0;n.eat("=");)++e;return n.eat("["),e}function eh(n,e){var t=n.next();return t=="-"&&n.eat("-")?n.eat("[")&&n.eat("[")?(e.cur=fp(cp(n),"comment"))(n,e):(n.skipToEnd(),"comment"):t=='"'||t=="'"?(e.cur=Bk(t))(n,e):t=="["&&/[\[=]/.test(n.peek())?(e.cur=fp(cp(n),"string"))(n,e):/\d/.test(t)?(n.eatWhile(/[\w.%]/),"number"):/[\w_]/.test(t)?(n.eatWhile(/[\w\\\-_.]/),"variable"):null}function fp(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=eh;break}else r=null;return e}}function Bk(n){return function(e,t){for(var i=!1,r;(r=e.next())!=null&&!(r==n&&!i);)i=!i&&r=="\\";return i||(t.cur=eh),"string"}}var up={name:"lua",startState:function(){return{basecol:0,indentDepth:0,cur:eh}},token:function(n,e){if(n.eatSpace())return null;var t=e.cur(n,e),i=n.current();return t=="variable"&&(Lk.test(i)?t="keyword":Mk.test(i)&&(t="builtin")),t!="comment"&&t!="string"&&(Dk.test(i)?++e.indentDepth:Ek.test(i)&&--e.indentDepth),t},indent:function(n,e,t){var i=Ok.test(e);return n.basecol+t.unit*(n.indentDepth-(i?1:0))},languageData:{indentOnInput:/^\s*(?:end|until|else|\)|\})$/,commentTokens:{line:"--",block:{open:"--[[",close:"]]--"}}}};var dp=n=>{let e={};for(let[t,i]of Object.entries(n))Object.assign(e,{[t]:Array.isArray(i)?[...i]:i});return e},pp=document.createElement("span"),Pk=n=>n.startsWith("#")?!0:(pp.innerHTML=`&${n}`,[...pp.textContent].length===1),xe=(n,e)=>{n.stack.push(n.tokenize),n.tokenize=e},oo=n=>n.sol()&&/[-=*#;:]/u.test(n.peek()||""),lo=class{constructor(e){this.config=e,this.urlProtocols=new RegExp(`^(?:${e.urlProtocols})(?=[^\\s[\\]<>])`,"iu"),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.oldTokens=[],this.tokenTable={...G.tokenTable},this.registerGroundTokens(),this.permittedHtmlTags=new Set([...G.permittedHtmlTags,...e.permittedHtmlTags||[]]),this.implicitlyClosedHtmlTags=new Set([...G.implicitlyClosedHtmlTags,...e.implicitlyClosedHtmlTags||[]]);for(let r of Object.keys(e.tags))this.addTag(r);let t=Object.entries(this.config.nsid).filter(([,r])=>r===6).map(([r])=>r).join("|");this.fileRegex=new RegExp(`^(?:${t})\\s*:`,"iu"),this.functionSynonyms=this.config.functionSynonyms.flatMap((r,s)=>Object.keys(r).map(o=>({type:s?"constant":"function",label:o}))),this.doubleUnderscore=this.config.doubleUnderscore.flatMap(Object.keys).map(r=>({type:"constant",label:r}));let i=Object.keys(e.tags);this.extTags=i.map(r=>({type:"type",label:r})),this.htmlTags=G.permittedHtmlTags.filter(r=>!i.includes(r)).map(r=>({type:"type",label:r}))}addTag(e,t){this.addToken(`mw-tag-${e}`,t)}addToken(e,t){var i;(i=this.tokenTable)[e]||(i[e]=je.define(t))}registerGroundTokens(){let e=["mw-ext-ground","mw-ext-link-ground","mw-ext2-ground","mw-ext2-link-ground","mw-ext3-ground","mw-ext3-link-ground","mw-link-ground","mw-template-ext-ground","mw-template-ext-link-ground","mw-template-ext2-ground","mw-template-ext2-link-ground","mw-template-ext3-ground","mw-template-ext3-link-ground","mw-template-ground","mw-template-link-ground","mw-template2-ext-ground","mw-template2-ext-link-ground","mw-template2-ext2-ground","mw-template2-ext2-link-ground","mw-template2-ext3-ground","mw-template2-ext3-link-ground","mw-template2-ground","mw-template2-link-ground","mw-template3-ext-ground","mw-template3-ext-link-ground","mw-template3-ext2-ground","mw-template3-ext2-link-ground","mw-template3-ext3-ground","mw-template3-ext3-link-ground","mw-template3-ground","mw-template3-link-ground","mw-section--1","mw-section--2","mw-section--3","mw-section--4","mw-section--5","mw-section--6"];for(let t of e)this.addToken(t)}getTagStyles(){return Object.keys(this.tokenTable).map(e=>({tag:this.tokenTable[e],class:`cm-${e}`}))}makeTagStyle(e,t,i){return this.makeStyle(G.tags[e],t,i)}makeStyle(e,t,i){return this.makeLocalStyle(`${e} ${this.isBold||t.dt.n?G.tags.strong:""} ${this.isItalic?G.tags.em:""}`,t,i)}makeLocalTagStyle(e,t,i){return this.makeLocalStyle(G.tags[e],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}if(t.nLink&&(r+="-link"),i){t[i]--;let{dt:s}=t;s.n&&t[i]<s[i]&&(s.n=0)}return(r&&`mw${r}-ground `)+e}inBlock(e,t,i){return(r,s)=>(r.skipTo(t)?(i&&r.match(t),s.tokenize=s.stack.pop()):r.skipToEnd(),this.makeLocalTagStyle(e,s))}inChar(e,t){return(i,r)=>i.eat(e)?(r.tokenize=r.stack.pop(),this.makeLocalTagStyle(t,r)):(i.skipTo(e)||i.skipToEnd(),this.makeLocalTagStyle("error",r))}eatFreeExternalLinkProtocol(e,t){return e.match(this.urlProtocols),t.tokenize=this.inFreeExternalLink.bind(this),this.makeTagStyle("freeExtLinkProtocol",t)}inFreeExternalLink(e,t){if(!e.sol()){let i=e.match(/^[^\s{[\]<>~).,;:!?'"]*/u),r=e.peek();switch(t.lpar||(t.lpar=i[0].includes("(")),r){case"~":if(e.match(/^~~?(?!~)/u))return this.makeTagStyle("freeExtLink",t);break;case"{":if(e.match(/^\{(?!\{)/u))return this.makeTagStyle("freeExtLink",t);break;case"'":if(e.match(/^'(?!')/u))return this.makeTagStyle("freeExtLink",t);break;case")":if(t.lpar)return e.eatWhile(")"),this.makeTagStyle("freeExtLink",t);case".":case",":case";":case":":case"!":case"?":if(e.match(/^[).,;:!?]+(?=[^\s{[\]<>~).,;:!?'"]|~~?(?!~)|\{(?!\{)|'(?!'))/u))return this.makeTagStyle("freeExtLink",t)}}return t.lpar=!1,t.tokenize=t.stack.pop(),this.makeTagStyle("freeExtLink",t)}inSectionHeader(e){return(t,i)=>t.eatWhile(/[^&<[{~'_]/u)?(t.eol()?(t.backUp(e),i.tokenize=this.eatSectionHeader.bind(this)):t.match(/^<!--(?!.*?-->.*?=)/u,!1)&&(t.backUp(e),i.tokenize=this.inBlock("sectionHeader","<!--")),this.makeLocalTagStyle("section",i)):this.eatWikiText(G.tags.section)(t,i)}eatSectionHeader(e,t){return e.skipToEnd(),t.tokenize=t.stack.pop(),this.makeLocalTagStyle("sectionHeader",t)}eatList(e,t){let i=e.match(/^[*#;:]*/u),{dt:r}=t;return i&&i[0].includes(";")&&(r.n+=i[0].split(";").length-1),r.n&&(r.nTemplate=t.nTemplate,r.nLink=t.nLink,r.nExt=t.nExt,r.nVar=t.nVar),this.makeLocalTagStyle("list",t)}eatStartTable(e,t){return e.match(/^(?:\{\||\{{3}\s*!\s*\}\})\s*/u),t.tokenize=this.inTableDefinition.bind(this),this.makeLocalTagStyle("tableBracket",t)}inTableDefinition(e,t){return e.sol()?(t.tokenize=this.inTable.bind(this),""):e.eatWhile(/[^&{<]/u)?this.makeLocalTagStyle("tableDefinition",t):this.eatWikiText(G.tags.tableDefinition)(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.makeLocalTagStyle("tableDelimiter",t)):e.match(/^\+\s*/u)?(t.tokenize=this.inTableCell(!0,2),this.makeLocalTagStyle("tableDelimiter",t)):e.eat("}")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("tableBracket",t)):(e.eatSpace(),t.tokenize=this.inTableCell(!0,0),this.makeLocalTagStyle("tableDelimiter",t));if(e.match(/^!\s*/u))return t.tokenize=this.inTableCell(!0,1),this.makeLocalTagStyle("tableDelimiter",t)}return this.eatWikiText(G.tags.error)(e,t)}inTableCell(e,t,i=!0){let r="";return t===2?r=G.tags.tableCaption:t===1&&(r=G.tags.strong),(s,o)=>{if(s.sol()){if(s.match(/^\s*(?:[|!]|\{\{\s*!\s*\}\})/u,!1))return o.tokenize=this.inTable.bind(this),"";if(i)return o.tokenize=this.inTableCell(!1,t,!1),""}if(oo(s))return this.eatWikiText(r)(s,o);if(s.eatWhile(i?/[^'{[<&~_|!]/u:/[^'{[<&~_:]/u))return this.makeStyle(r,o);if(i){if(s.match(/^(?:\||\{\{\s*!\s*\}\}){2}\s*/u)||t===1&&s.match(/^!!\s*/u))return this.isBold=!1,this.isItalic=!1,o.tokenize=this.inTableCell(!0,t),this.makeLocalTagStyle("tableDelimiter",o);if(e&&s.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return o.tokenize=this.inTableCell(!1,t),this.makeLocalTagStyle("tableDelimiter",o)}return this.eatWikiText(r)(s,o)}}eatHtmlEntity(e,t){let i=e.match(/^(?:#x[a-f\d]+|#\d+|[a-z\d]+);/iu);return i&&Pk(i[0])?G.tags.htmlEntity:t}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.makeLocalTagStyle("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.makeLocalTagStyle("extLinkBracket",t,"nLink")):e.eatSpace()||e.match(/^(?:[[<>"]|&[lg]t;|'{2,3}(?!')|'{5}(?!')|\{\{|~{3})/u,!1)?(t.tokenize=this.inExternalLinkText.bind(this),this.makeLocalStyle("",t)):(e.next(),e.eatWhile(/[^\s[\]<>"&~'{]/u),this.makeLocalTagStyle("extLink",t))}inExternalLinkText(e,t){return e.sol()?(t.nLink--,t.tokenize=t.stack.pop(),""):e.eat("]")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("extLinkBracket",t,"nLink")):e.match(/^(?:[^'[\]{&~<]|\[(?!\[))+/u)?this.makeTagStyle("extLinkText",t):this.eatWikiText(G.tags.extLinkText)(e,t)}inLink(e){let t=`${G.tags.linkPageName} ${G.tags.pageName}`;return(i,r)=>{if(i.sol())return r.nLink--,r.lbrack=!1,r.tokenize=r.stack.pop(),"";let s=i.eatSpace();return i.match(/^#\s*/u)?(r.tokenize=this.inLinkToSection(e),this.makeTagStyle(e?"error":"linkToSection",r)):i.match(/^\|\s*/u)?(r.tokenize=this.inLinkText(e),this.makeLocalTagStyle("linkDelimiter",r)):i.match("]]")?(r.lbrack=!1,r.tokenize=r.stack.pop(),this.makeLocalTagStyle("linkBracket",r,"nLink")):i.match(/^(?:[>[}]+|\]|\{(?!\{))/u)?this.makeTagStyle("error",r):i.eatWhile(/[^#|[\]&{}<>]/u)||s?this.makeStyle(t,r):this.eatWikiText(t)(i,r)}}inLinkToSection(e){let t=e?"error":"linkToSection";return(i,r)=>i.sol()?(r.nLink--,r.lbrack=!1,r.tokenize=r.stack.pop(),""):i.eat("|")?(r.tokenize=this.inLinkText(e),this.makeLocalTagStyle("linkDelimiter",r)):i.match("]]")?(r.lbrack=!1,r.tokenize=r.stack.pop(),this.makeLocalTagStyle("linkBracket",r,"nLink")):i.eatWhile(/[^|\]&{}<]/u)?this.makeTagStyle(t,r):this.eatWikiText(G.tags[t])(i,r)}inLinkText(e){let t,i;return(r,s)=>{let o=`${G.tags.linkText} ${t?G.tags.strong:""} ${i?G.tags.em:""}`;if(r.match("]]"))return s.lbrack&&r.peek()==="]"?(r.backUp(1),s.lbrack=!1,this.makeStyle(o,s)):(s.lbrack=!1,s.tokenize=s.stack.pop(),this.makeLocalTagStyle("linkBracket",s,"nLink"));if(e&&r.eat("|"))return this.makeLocalTagStyle("linkDelimiter",s);if(r.peek()==="'"){switch(r.match(/^'+/u)[0].length){case 3:return t=!t,this.makeLocalTagStyle("apostrophes",s);case 5:t=!t;case 2:return i=!i,this.makeLocalTagStyle("apostrophes",s);case 4:r.backUp(3);case 1:break;default:r.backUp(5)}return this.makeStyle(o,s)}let l=e?new RegExp(`^(?:[^'\\]{&~<|[]|\\[(?!\\[|${this.config.urlProtocols}))+`,"iu"):/^[^'\]{&~<]+/u,a=r.match(l);return s.lbrack===void 0&&a&&a[0].includes("[")&&(s.lbrack=!0),a?this.makeStyle(o,s):this.eatWikiText(o)(r,s)}}inVariable(e,t){return e.eat("|")?(t.tokenize=this.inVariableDefault(!0),this.makeLocalTagStyle("templateVariableDelimiter",t)):e.match("}}}")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("templateVariableBracket",t,"nVar")):e.match("{{{")?(t.stack.push(t.tokenize),this.makeLocalTagStyle("templateVariableBracket",t)):e.match("<!--",!1)?(xe(t,this.inComment),""):(e.eatWhile(/[^{}|<]/u)||e.next(),this.makeLocalTagStyle("templateVariableName",t))}inVariableDefault(e){let t=G.tags[e?"templateVariable":"comment"];return(i,r)=>i.match("}}}")?(r.tokenize=r.stack.pop(),this.makeLocalTagStyle("templateVariableBracket",r,"nVar")):i.eat("|")?(e&&(r.tokenize=this.inVariableDefault()),this.makeLocalTagStyle("templateVariableDelimiter",r)):e&&oo(i)||!i.eatWhile(e?/[^|{}[<&~'_:]/u:/[^|{}[<]/u)?this.eatWikiText(t)(i,r):this.makeStyle(t,r)}get inComment(){return this.inBlock("comment","-->",!0)}inParserFunctionName(e,t){return e.eatWhile(/[^:}{~|<>[\]]/u)?this.makeLocalTagStyle("parserFunctionName",t):e.eat(":")?(t.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalTagStyle("parserFunctionDelimiter",t)):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("parserFunctionBracket",t,"nExt")):this.eatWikiText(G.tags.error)(e,t)}inParserFunctionArguments(e,t){return e.eat("|")?this.makeLocalTagStyle("parserFunctionDelimiter",t):e.match("}}")?(t.tokenize=t.stack.pop(),this.makeLocalTagStyle("parserFunctionBracket",t,"nExt")):oo(e)||!e.eatWhile(/[^|}{[<&~'_:]/u)?this.eatWikiText(G.tags.parserFunction)(e,t):this.makeLocalTagStyle("parserFunction",t)}inTemplatePageName(e,t){let i=t?G.tags.error:`${G.tags.templateName} ${G.tags.pageName}`;return(r,s)=>{let o=r.sol(),l=r.eatSpace();return r.eol()?this.makeLocalStyle(i,s):r.eat("|")?(s.tokenize=this.inTemplateArgument(!0),this.makeLocalTagStyle("templateDelimiter",s)):r.match("}}")?(s.tokenize=s.stack.pop(),this.makeLocalTagStyle("templateBracket",s,"nTemplate")):r.match("<!--",!1)?(xe(s,this.inComment),this.makeLocalStyle("",s)):e&&!t&&o?(s.nTemplate--,s.tokenize=s.stack.pop(),r.pos=0,""):!t&&r.eat("#")?(s.tokenize=this.inTemplatePageName(!0,!0),this.makeLocalTagStyle("error",s)):r.match(t?/^(?:[^|{}<]|([{}])(?!\1)|<(?!!--))+/u:/^[^|{}<>[\]#]+/u)?(s.tokenize=this.inTemplatePageName(!0,t),this.makeLocalStyle(i,s)):r.match(/^(?:[<>[\]}]|\{(?!\{))/u)?this.makeLocalTagStyle("error",s):l?this.makeLocalStyle(i,s):this.eatWikiText(i)(r,s)}}inTemplateArgument(e){let t=new RegExp(`^(?:[^=|}{[<]|\\[(?!\\[)|<(?!!--|(?:${Object.keys(this.config.tags).join("|")})[\\s/>]))*=`,"iu");return(i,r)=>{let s=i.eatSpace();return i.eol()?this.makeLocalTagStyle("template",r):i.match(/^\|\s*/u)?(r.tokenize=this.inTemplateArgument(!0),this.makeLocalTagStyle("templateDelimiter",r)):i.match("}}")?(r.tokenize=r.stack.pop(),this.makeLocalTagStyle("templateBracket",r,"nTemplate")):e&&i.match(t)?(r.tokenize=this.inTemplateArgument(),this.makeLocalTagStyle("templateArgumentName",r)):!oo(i)&&i.eatWhile(/[^|}{[<&~'_:]/u)||s?this.makeLocalTagStyle("template",r):this.eatWikiText(G.tags.template)(i,r)}}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(">","htmlTagBracket"):this.inHtmlTagAttribute(o),this.makeLocalTagStyle("htmlTagName",s)):(s.tokenize=t?this.inChar(">","extTagBracket"):this.inExtTagAttribute(o),this.makeLocalTagStyle("extTagName",s))}}inHtmlTagAttribute(e){return(t,i)=>t.match(/^(?:"[^<">]*"|'[^<'>]*'[^>/<{])+/u)?this.makeLocalTagStyle("htmlTagAttribute",i):t.peek()==="<"?(i.tokenize=i.stack.pop(),""):t.match(/^\/?>/u)?(this.implicitlyClosedHtmlTags.has(e)||i.inHtmlTag.unshift(e),i.tokenize=i.stack.pop(),this.makeLocalTagStyle("htmlTagBracket",i)):this.eatWikiText(G.tags.htmlTagAttribute)(t,i)}get eatNowiki(){return e=>e.eatWhile(/[^&]/u)?"":(e.next(),this.eatHtmlEntity(e,""))}inExtTagAttribute(e){return(t,i)=>t.match(/^(?:"[^">]*"|'[^'>]*'|[^>/])+/u)?this.makeLocalTagStyle("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.makeLocalTagStyle("extTagBracket",i)):t.match("/>")?(i.tokenize=i.stack.pop(),this.makeLocalTagStyle("extTagBracket",i)):this.eatWikiText(G.tags.extTagAttribute)(t,i)}eatExtTagArea(e){return(t,i)=>{let r=t.pos,s=new RegExp(`</${e}\\s*(?:>|$)`,"iu").exec(r?t.string.slice(r):t.string),o=!1;if(s){if(s.index===0)return i.tokenize=this.eatExtCloseTag(e),i.extName=!1,i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(t,i);o=t.string,t.string=o.slice(0,s.index+r)}return xe(i,this.inExtTokens(o)),i.tokenize(t,i)}}eatExtCloseTag(e){return(t,i)=>(t.next(),t.next(),i.tokenize=this.eatTagName(e.length,!0),this.makeLocalTagStyle("extTagBracket",i))}inExtTokens(e){return(t,i)=>{let r;return i.extMode===!1?(r=`mw-tag-${i.extName} ${G.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}}eatWikiText(e){return(t,i)=>{let r;if(t.eol())return"";if(t.sol()){if(t.match("//"))return this.makeStyle(e,i);if(t.match(this.urlProtocols))return xe(i,this.inFreeExternalLink.bind(this)),this.makeTagStyle("freeExtLinkProtocol",i);switch(r=t.next(),r){case"-":if(t.match(/^-{3,}/u))return G.tags.hr;break;case"=":{let s=t.match(/^(={0,5})(.+?(=\1\s*)(?:<!--(?!.*-->\s*\S).*)?)$/u);if(s)return t.backUp(s[2].length),xe(i,this.inSectionHeader(s[3].length)),this.makeLocalStyle(`${G.tags.sectionHeader} mw-section--${s[1].length+1}`,i);break}case";":i.dt.n++;case"*":case"#":return this.eatList(t,i);case":":return t.match(/^:*\s*(?=\{\||\{{3}\s*!\s*\}\})/u)?(xe(i,this.eatStartTable.bind(this)),this.makeLocalTagStyle("list",i)):this.eatList(t,i);case" ":{let s=t.match(/^\s*(:+\s*)?(?=\{\||\{{3}\s*!\s*\}\})/u);if(s){if(s[1])return xe(i,this.eatStartTable.bind(this)),this.makeLocalTagStyle("list",i);t.eat("{")}else return G.tags.skipFormatting}case"{":if(t.match(/^(?:\||\{\{\s*!\s*\}\})\s*/u))return xe(i,this.inTableDefinition.bind(this)),this.makeLocalTagStyle("tableBracket",i)}}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.makeLocalTagStyle("apostrophes",i);if(t.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalTagStyle("apostrophes",i);break;case"[":if(t.match(/^\[\s*/u)){if(/[^[\]|]/u.test(t.peek()||""))return i.nLink++,i.lbrack=void 0,xe(i,this.inLink(!!t.match(this.fileRegex,!1))),this.makeLocalTagStyle("linkBracket",i)}else{let s=t.match(this.urlProtocols,!1);if(s)return i.nLink++,xe(i,this.eatExternalLinkProtocol(s[0].length)),this.makeLocalTagStyle("extLinkBracket",i)}break;case"{":if(t.match(/^\{\{(?!\{|[^{}]*\}\}(?!\}))\s*/u))return i.nVar++,xe(i,this.inVariable.bind(this)),this.makeLocalTagStyle("templateVariableBracket",i);if(t.match(/^\{(?!\{(?!\{))\s*/u)){if(t.peek()==="#")return i.nExt++,xe(i,this.inParserFunctionName.bind(this)),this.makeLocalTagStyle("parserFunctionBracket",i);let s=t.match(/^([^\s}[\]<{'|&:]+)(:|\s*)(\}\}?)?(.)?/u,!1);return s&&(s[2]===":"||s[4]===void 0||s[3]==="}}")&&(s[1].toLowerCase()in this.config.functionSynonyms[0]||s[1]in this.config.functionSynonyms[1])?(i.nExt++,xe(i,this.inParserFunctionName.bind(this)),this.makeLocalTagStyle("parserFunctionBracket",i)):(i.nTemplate++,xe(i,this.inTemplatePageName()),this.makeLocalTagStyle("templateBracket",i))}break;case"~":if(t.match(/^~{2,4}/u))return G.tags.signature;break;case"_":{let s=1;for(;t.eat("_");)s++;if(s>2)return t.eol()||t.backUp(2),this.makeStyle(e,i);if(s===2){let o=t.match(/^[\p{L}\d_]+?__/u);if(o)return`__${o[0].toLowerCase()}`in this.config.doubleUnderscore[0]||`__${o[0]}`in this.config.doubleUnderscore[1]?G.tags.doubleUnderscore:(t.eol()||t.backUp(2),this.makeStyle(e,i))}break}case":":{let{dt:s}=i;if(s.n&&s.nTemplate===i.nTemplate&&s.nLink===i.nLink&&s.nExt===i.nExt&&s.nVar===i.nVar)return s.n--,this.makeLocalTagStyle("list",i);break}case"<":{if(t.match("!--",!1))return t.backUp(1),xe(i,this.inComment),"";let s=!!t.eat("/"),o=t.match(/^[^>/\s.*,[\]{}$^+?|\\'`~<=!@#%&()-]+(?=[>/\s]|$)/u);if(o){let l=o[0].toLowerCase();if(l in this.config.tags)return s?(xe(i,this.inChar(">","error")),this.makeLocalTagStyle("error",i)):(t.backUp(l.length),xe(i,this.eatTagName(l.length,s)),this.makeLocalTagStyle("extTagBracket",i));if(this.permittedHtmlTags.has(l)){if(s)if(l===i.inHtmlTag[0])i.inHtmlTag.shift();else return xe(i,this.inChar(">","error")),this.makeLocalTagStyle("error",i);return t.backUp(l.length),xe(i,this.eatTagName(l.length,s,!0)),this.makeLocalTagStyle("htmlTagBracket",i)}t.backUp(l.length)}}}return/\s/u.test(r||"")&&(t.eatSpace(),t.match(this.urlProtocols,!1)&&!t.match("//"))?(xe(i,this.eatFreeExternalLinkProtocol.bind(this)),this.makeStyle(e,i)):(t.eatWhile(/[^\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 completionSource(){return e=>{var o,l,a;let{state:t,pos:i}=e,r=(o=Pt(t,i))==null?void 0:o.resolve(i,-1);if(!r)return null;let s=new Set(r.name.split("_"));if(s.has(G.tags.templateName)||s.has(G.tags.parserFunctionName))return{from:r.from,options:this.functionSynonyms,validFor:/^[^|{}<]*$/u};if(!s.has(G.tags.comment)&&!s.has(G.tags.templateVariableName)){let h=e.matchBefore(/__(?:(?!__)[\p{L}\d_])*$/u);if(h)return{from:h.from,options:this.doubleUnderscore,validFor:/^[\p{L}\d]*$/u};if(h=e.matchBefore(/<\/?[a-z\d]*$/iu),!h||h.to-h.from<2)return null;let c=/^[a-z\d]*$/iu;if(h.text[1]==="/"){let f=e.matchBefore(/<[a-z\d]+(?:\s[^<>]*)?>((?!<\/?[a-z]).)*<\/[a-z\d]*$/iu),u=(l=/^<([a-z\d]+)/iu.exec((f==null?void 0:f.text)||""))==null?void 0:l[1].toLowerCase(),p=(a=[...s].reverse().find(y=>y.startsWith("mw-tag-")))==null?void 0:a.slice(7),m=[...this.htmlTags.filter(({label:y})=>!this.implicitlyClosedHtmlTags.has(y)),...p?[{type:"type",label:p,boost:50}]:[]],w=this.permittedHtmlTags.has(u)&&m.findIndex(({label:y})=>y===u);return w!==!1&&w!==-1&&m.splice(w,1,{type:"type",label:u,boost:99}),{from:h.from+2,options:m,validFor:c}}return{from:h.from+1,options:[...this.htmlTags,...this.extTags],validFor:c}}return null}}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0,nVar:0,lpar:!1,lbrack:!1,dt:{n:0}}),copyState:e=>{let t=dp(e);return t.dt={...e.dt},e.extMode&&e.extMode.copyState&&(t.extState=e.extMode.copyState(e.extState)),t},token:(e,t)=>{let i;if(this.oldTokens.length>0)return i=this.oldTokens.shift(),e.pos=i.pos,i.style;e.sol()&&(t.dt.n=0,this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);let r,s=null,o,l=[],a=[];do if(r=t.tokenize(e,t),o=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,o)o!==s&&(s=o,l.length>0&&(a.push(...l),l.length=0)),l.push({pos:e.pos,style:r,state:(t.extMode&&t.extMode.copyState||dp)(t)});else return this.oldStyle=r,r;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 i=this.oldTokens.shift(),e.pos=i.pos,i.style},blankLine:e=>{e.extMode&&e.extMode.blankLine&&e.extMode.blankLine(e.extState,0)},tokenTable:this.tokenTable,languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},closeBrackets:{brackets:["(","[","{",'"']},autocomplete:this.completionSource}}}get"text/mediawiki"(){return this.mediawiki}};for(let[n,e]of Object.entries(Zn))Object.defineProperty(lo.prototype,n,{get(){return e}});var th=n=>{let e=new lo(n),t=Ji.define(e.mediawiki),i=bs(Yi.define(e.getTagStyles()));return new Gi(t,i)},mp=n=>th({...n,tags:{...n.tags,script:!0,style:!0},tagModes:{...n.tagModes,script:"javascript",style:"css"},permittedHtmlTags:["html","base","title","menu","a","area","audio","map","track","video","embed","iframe","object","picture","source","canvas","col","colgroup","tbody","tfoot","thead","button","datalist","fieldset","form","input","label","legend","meter","optgroup","option","output","progress","select","textarea","details","dialog","slot","template","dir","frame","frameset","marquee","param","xmp"],implicitlyClosedHtmlTags:["area","base","col","embed","frame","input","param","source","track"]});var gp={'"':"quot","'":"apos","<":"lt",">":"gt","&":"amp"," ":"nbsp"},bp=n=>e=>(ao.replaceSelections(e,n),!0),Rk=bp(n=>[...n].map(e=>{if(e in gp)return`&${gp[e]};`;let t=e.codePointAt(0);return t<256?`&#${t};`:`&#x${t.toString(16)};`}).join("")),Nk=bp(n=>{if(n.includes("%"))try{return decodeURIComponent(n)}catch(e){}return encodeURIComponent(n)}),yp=[{key:"Mod-[",run:Rk},{key:"Mod-]",run:Nk}];var Tp=n=>({name:e})=>e.includes(G.tags[n]),nh=Tp("templateBracket"),ih=Tp("templateDelimiter"),rh=n=>/-template[a-z\d-]+ground/u.test(n.name)&&!nh(n),kp=(n,e)=>n.sliceDoc(e.from,e.from+1)==="{"?1:-1;function Cp(n,e,t){if(typeof e=="number"&&(t=Pt(n,e)),!t)return null;let i;if(typeof e=="number"?(i=t.resolve(e,-1),rh(i)||(i=t.resolve(e,1))):i=e,!rh(i))return null;let{prevSibling:r,nextSibling:s}=i,o=1,l=ih(i)?i:null;for(;s;){if(nh(s)){if(o+=kp(n,s),o===0)break}else!l&&o===1&&ih(s)&&(l=s);({nextSibling:s}=s)}if(!s)return null;for(o=-1;r;){if(nh(r)){if(o+=kp(n,r),o===0)break}else o===-1&&ih(r)&&(l=r);({prevSibling:r}=r)}let a=l==null?void 0:l.to,h=s.from;return a&&a<h?{from:a,to:h}:null}var wp=n=>{let{selection:{main:{head:e}}}=n,t=Cp(n,e);if(t){let{from:i,to:r}=t,s=!1;return gs(n).between(i,r,(o,l)=>{o===i&&l===r&&(s=!0)}),s?null:{pos:e,above:!0,create:()=>{let o=document.createElement("div");return o.className="cm-tooltip-fold",o.textContent="\uFF0D",o.title=n.phrase("Fold template parameters"),o.dataset.from=String(i),o.dataset.to=String(r),{dom:o}}}}return null},xp=(n,e,t)=>{var i;return e.length>0?((i=n.dom.querySelector(".cm-tooltip-fold"))==null||i.remove(),n.dispatch({effects:e,selection:{anchor:t}}),!0):!1},vp=n=>Math.max(...n.selection.ranges.map(({to:e})=>e)),Sp=(n,e,t,i,r,s,o=(l,{to:a})=>Math.max(l,a))=>{for(;i&&i.from<=r;){let l=Cp(n,i,e);if(l){t.push(ps.of(l)),i=e.resolve(l.to,1),s=o(s,l);continue}i=i.nextSibling}return s},Ap=[mu({placeholderDOM(n){let e=document.createElement("span");return e.textContent="\u2026",e.setAttribute("aria-label","folded code"),e.title=n.state.phrase("unfold"),e.className="cm-foldPlaceholder",e.addEventListener("click",({target:t})=>{let i=n.posAtDOM(t),{state:r}=n,{selection:s}=r;gs(r).between(i,i,(o,l)=>{o===i&&n.dispatch({effects:Zi.of({from:o,to:l}),selection:s})})}),e}}),ce.define({create:wp,update(n,{state:e,docChanged:t,selection:i}){return t||i?wp(e):n},provide(n){return Ut.from(n)}}),ft.of([{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run(n){let{state:e}=n,t=Pt(e,n.viewport.to);if(!t)return!1;let i=[],r=vp(e);for(let{from:s,to:o,empty:l}of e.selection.ranges){let a;l&&(a=t.resolve(s,-1)),(!a||!rh(a))&&(a=t.resolve(s,1)),r=Sp(e,t,i,a,o,r)}return xp(n,i,r)}},{key:"Ctrl-Alt-[",run(n){let{state:e}=n,t=Ce(e),i=[],r=Sp(e,t,i,t.topNode.firstChild,1/0,vp(e),(s,{from:o,to:l})=>o<=s&&l>s?l:s);return xp(n,i,r)}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run(n){let{state:e}=n,{selection:t}=e,i=[],r=gs(e);for(let{from:s,to:o}of t.ranges)r.between(s,o,(l,a)=>{i.push(Zi.of({from:l,to:a}))});return i.length>0?(n.dispatch({effects:i,selection:t}),!0):!1}},{key:"Ctrl-Alt-]",run:pu}])],Mp=n=>e=>{let t=e.target.closest(".cm-tooltip-fold");if(t){e.preventDefault();let{dataset:i}=t,r=Number(i.from),s=Number(i.to);n.dispatch({effects:ps.of({from:r,to:s}),selection:{anchor:s}}),t.remove()}};var sh=class{get closing(){return Dp(this.first,this.type)}get selfClosing(){return G.implicitlyClosedHtmlTags.includes(this.name)||this.type==="ext"&&Dp(this.last,this.type)}get from(){return this.first.from}get to(){return this.last.to}constructor(e,t,i,r){this.type=e,this.name=t,this.first=i,this.last=r}},Lp=({name:n})=>/-(?:ext|html)tag-(?!bracket)/u.test(n),Ep=n=>({name:e},t)=>new RegExp(`-${t}tag-${n}`,"u").test(e),ho=Ep("bracket"),oh=Ep("name"),Dp=(n,e)=>ho(n,e)&&n.to-n.from>1,Op=({name:n},e,t)=>e==="ext"&&new RegExp(`-tag-${t}(?![a-z])`,"u").test(n),lh=(n,{from:e,to:t})=>n.sliceDoc(e,t).trim(),Ik=({closing:n})=>n?-1:1,Bp=(n,e)=>{let t=e.name.includes("exttag")?"ext":"html",{prevSibling:i}=e,r=e,s=oh(e,t)?e:null;for(;r.nextSibling&&!ho(r,t);)({nextSibling:r}=r);for(ho(r,t)&&lh(n,r)==="<"&&(r=r.prevSibling);i&&!ho(i,t);)s||(s=oh(i,t)?i:null),{prevSibling:i}=i;let o=lh(n,s);return new sh(t,o,i,r)},zk=(n,e)=>{let{type:t,name:i,closing:r}=e,s=r?"prevSibling":"nextSibling",o=r?"first":"last",l=r?-1:1,a=e[o][s];for(;a;){if(oh(a,t)&&lh(n,a)===i&&!Op(a,t,i)){let h=Bp(n,a);if(l+=Ik(h),l===0)return h;a=h[o]}a=a[s]}return null},Fk=(n,e)=>{let t=Pt(n,e);if(!t)return null;let i=t.resolve(e,-1);if(!Lp(i)&&(i=t.resolve(e,1),!Lp(i)))return null;let r=Bp(n,i);if(Op(i,r.type,r.name))return{matched:!1,start:r};if(r.selfClosing)return{matched:!0,start:r};let s=zk(n,r);return s?{matched:!0,start:r,end:s}:{matched:!1,start:r}},Hk=_.mark({class:"cm-matchingTag"}),Vk=_.mark({class:"cm-nonmatchingTag"}),Pp=ce.define({create(){return _.none},update(n,e){if(!e.docChanged&&!e.selection)return n;let t=[];for(let i of e.state.selection.ranges)if(i.empty){let r=Fk(e.state,i.head);if(r){let s=r.matched?Hk:Vk,{start:{from:o,to:l,closing:a},end:h}=r;t.push(s.range(o,l)),h&&t[a?"unshift":"push"](s.range(h.from,h.to))}}return _.set(t)},provide(n){return N.decorations.from(n)}});var co="https://testingcf.jsdelivr.net",Qn=(n,e)=>new Promise(t=>{if(e in window){t();return}let i=document.createElement("script");i.src=`${co}/${n}`,i.onload=()=>{t()},document.head.append(i)});var Rp=async n=>{let e="npm/wikiparser-node@1.7.0-beta.1",t=`${e}/extensions/dist`,i=n==null?void 0:n.i18n;if(await Qn(`combine/${t}/base.min.js,${t}/lint.min.js`,"wikiparse"),typeof i=="string")try{let r=await(await fetch(`${co}/${e}/i18n/${i.toLowerCase()}.json`)).json();wikiparse.setI18N(r)}catch(r){}return new wikiparse.Linter(n==null?void 0:n.include)},Np=async n=>{var i,r,s;await Qn("npm/eslint-linter-browserify@8.57.0","eslint");let e=new eslint.Linter,t={env:{browser:!0,es2024:!0},parserOptions:{ecmaVersion:15,sourceType:"module"},rules:{},...n};for(let[o,{meta:l}]of e.getRules())(i=l==null?void 0:l.docs)!=null&&i.recommended&&((s=(r=t.rules)[o])!=null||(r[o]=2));return o=>e.verify(o,t)},Ip=async n=>{await Qn("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,...n==null?void 0:n.rules}};return async t=>(await stylelint.lint({code:t,config:e})).results.flatMap(({warnings:i})=>i)},zp=async()=>(await Qn("npm/luaparse","luaparse"),luaparse.defaultOptions.luaVersion="5.3",n=>{try{luaparse.parse(n.toString())}catch(e){if(e instanceof luaparse.SyntaxError)return[{source:"luaparse",message:e.message.replace(/^\[\d+:\d+\]\s*/u,""),severity:"error",from:e.index,to:e.index}]}return[]}),Fp=()=>n=>{var e,t,i;try{n.trim()&&JSON.parse(n)}catch(r){if(r instanceof SyntaxError){let{message:s}=r,o=(e=/\bline (\d+)/u.exec(s))==null?void 0:e[1],l=(t=/\bcolumn (\d+)/u.exec(s))==null?void 0:t[1],a=(i=/\bposition (\d+)/u.exec(s))==null?void 0:i[1];return[{message:s,severity:"error",line:o,column:l,position:a}]}}return[]};var hh={plain:()=>N.contentAttributes.of({spellcheck:"true"}),mediawiki:n=>[th(n),N.contentAttributes.of({spellcheck:"true"})],html:mp};for(let[n,e]of Object.entries(Zn))hh[n]=()=>new Gi(Ji.define(e));var fo=(n=[])=>[(e=[])=>e,{mediawiki:n}],ah={highlightSpecialChars:[zf,{}],highlightActiveLine:[Ff,{}],highlightWhitespace:[qf,{}],highlightTrailingWhitespace:[Kf,{}],bracketMatching:[vu,{mediawiki:{brackets:"[]{}"}}],closeBrackets:[Gd,{}],allowMultipleSelections:[()=>[se.allowMultipleSelections.of(!0),Nf()],{}],escape:fo(ft.of(yp)),codeFolding:fo(Ap),tagMatching:fo(Pp),autocompletion:fo([Jd({defaultKeymap:!1}),ft.of([...Za,{key:"Tab",run:Ya}])])},uo={},Hp={},er=(n,e,t)=>n.line(e).from+t-1,tr=(n,e,t)=>{for(let i of n)e[i]=t?i:!0},qe,ne,ir,Ci,nr,rr,sr,or,Mt,ni,Ai,Nt,Ti,po,Vp,lr,ch,ar,fh,mo,Wp,go=class go{constructor(e,t="plain",i){Me(this,Nt);Me(this,po);Me(this,lr);Me(this,ar);Me(this,mo);Me(this,qe,void 0);Me(this,ne,void 0);Me(this,ir,new lt);Me(this,Ci,new lt);Me(this,nr,new lt);Me(this,rr,new lt);Me(this,sr,new lt);Me(this,or,new lt);Me(this,Mt,void 0);Me(this,ni,!1);Me(this,Ai,new Set);li(this,qe,e),li(this,Mt,t);let r,{readOnly:s}=e,o=[V(this,ir).of(hh[t](i)),V(this,Ci).of([]),V(this,nr).of([]),V(this,rr).of(Zt.of(" ")),V(this,sr).of([]),V(this,or).of([]),bs(yu),N.contentAttributes.of({accesskey:e.accessKey,tabindex:String(e.tabIndex)}),N.editorAttributes.of({dir:e.dir,lang:e.lang}),jf(),N.lineWrapping,ft.of([...ud,...vd,...Ld]),N.updateListener.of(({state:{doc:h},docChanged:c,focusChanged:f})=>{c&&(clearTimeout(r),r=window.setTimeout(()=>{e.value=h.toString()},400)),f&&e.dispatchEvent(new Event(V(this,ne).hasFocus?"focus":"blur"))}),...s?[se.readOnly.of(!0)]:[zu(),uu(),ft.of(Wu)]];li(this,ne,new N({extensions:o,doc:e.value}));let{fontSize:l,lineHeight:a}=getComputedStyle(e);e.parentNode.insertBefore(V(this,ne).dom,e),_e(this,lr,ch).call(this),V(this,ne).scrollDOM.style.fontSize=l,V(this,ne).scrollDOM.style.lineHeight=a,this.toggle(!0),V(this,ne).dom.addEventListener("click",Mp(V(this,ne)))}get textarea(){return V(this,qe)}get view(){return V(this,ne)}get lang(){return V(this,Mt)}get visible(){return V(this,ni)}setLanguage(e="plain",t){_e(this,Nt,Ti).call(this,[V(this,ir).reconfigure(hh[e](t)),V(this,Ci).reconfigure(uo[e]||[])]),li(this,Mt,e),_e(this,ar,fh).call(this,!!uo[e]),this.prefer({})}lint(e){let t=e?[Dd(i=>e(i.state.doc)),Nd()]:[];e?uo[V(this,Mt)]=t:delete uo[V(this,Mt)],_e(this,Nt,Ti).call(this,V(this,Ci).reconfigure(t)),_e(this,ar,fh).call(this,!!e)}update(){let e=_e(this,mo,Wp).call(this);if(e){let t=V(this,ne).plugin(e[1]);t.set=!0,t.force()}}prefer(e){if(Array.isArray(e))li(this,Ai,new Set(e.filter(t=>ah[t])));else for(let[t,i]of Object.entries(e))i&&ah[t]?V(this,Ai).add(t):V(this,Ai).delete(t);_e(this,Nt,Ti).call(this,V(this,nr).reconfigure([...V(this,Ai)].map(t=>{let[i,r]=ah[t];return i(r[V(this,Mt)])})))}setIndent(e){_e(this,Nt,Ti).call(this,V(this,rr).reconfigure(Zt.of(e)))}async getLinter(e){switch(V(this,Mt)){case"mediawiki":{let t=await Rp(e);return i=>t.codemirror(i.toString())}case"javascript":{let t=await Np(e);return i=>t(i.toString()).map(({ruleId:r,message:s,severity:o,line:l,column:a,endLine:h,endColumn:c,fix:f,suggestions:u=[]})=>{let p=er(i,l,a),m={source:"ESLint",message:`${s}${r?` (${r})`:""}`,severity:o===1?"warning":"error",from:p,to:h===void 0?p+1:er(i,h,c)};return(f||u.length>0)&&(m.actions=[...f?[{name:"fix",fix:f}]:[],...u.map(w=>({name:"suggestion",fix:w.fix}))].map(({name:w,fix:{range:[y,v],text:S}})=>({name:w,apply(E){E.dispatch({changes:{from:y,to:v,insert:S}})}}))),m})}case"css":{let t=await Ip(e);return async i=>(await t(i.toString())).map(({text:r,severity:s,line:o,column:l,endLine:a,endColumn:h})=>({source:"Stylelint",message:r,severity:s,from:er(i,o,l),to:a===void 0?i.line(o).to:er(i,a,h)}))}case"lua":{let t=await zp();return i=>t(i.toString())}case"json":{let t=Fp();return i=>{let[r]=t(i.toString());if(r){let{message:s,line:o,column:l,position:a}=r,h=0;return a?h=Number(a):o&&l&&(h=er(i,Number(o),Number(l))),[{message:s,severity:"error",from:h,to:h}]}return[]}}default:return}}setContent(e){V(this,ne).dispatch({changes:{from:0,to:V(this,ne).state.doc.length,insert:e}})}toggle(e=!V(this,ni)){if(e&&!V(this,ni)){let{value:t,selectionStart:i,selectionEnd:r,scrollTop:s}=V(this,qe),o=document.activeElement===V(this,qe);this.setContent(t),_e(this,po,Vp).call(this),V(this,ne).dom.style.removeProperty("display"),V(this,qe).style.display="none",V(this,ne).requestMeasure(),V(this,ne).dispatch({selection:{anchor:i,head:r}}),o&&V(this,ne).focus(),requestAnimationFrame(()=>{V(this,ne).scrollDOM.scrollTop=s})}else if(!e&&V(this,ni)){let{state:{selection:{main:{from:t,to:i,head:r}}},hasFocus:s}=V(this,ne),{scrollDOM:{scrollTop:o}}=V(this,ne);V(this,ne).dom.style.setProperty("display","none","important"),V(this,qe).style.display="",V(this,qe).setSelectionRange(t,i,r===i?"forward":"backward"),s&&V(this,qe).focus(),requestAnimationFrame(()=>{V(this,qe).scrollTop=o})}li(this,ni,e)}extraKeys(e){_e(this,Nt,Ti).call(this,V(this,sr).reconfigure(ft.of(e)))}localize(e){Object.assign(Hp,e),_e(this,Nt,Ti).call(this,V(this,or).reconfigure(se.phrases.of(Hp)))}getNodeAt(e){var t;return(t=Pt(V(this,ne).state,e))==null?void 0:t.resolve(e,1)}scrollTo(e=V(this,ne).state.selection.main){let t=N.scrollIntoView(typeof e=="number"||e instanceof Vt?e:L.range(e.anchor,e.head));t.value.isSnapshot=!0,V(this,ne).dispatch({effects:t})}static replaceSelections(e,t){let{state:i}=e;e.dispatch(i.changeByRange(({from:r,to:s})=>{let o=t(i.sliceDoc(r,s),{from:r,to:s});if(typeof o=="string")return{range:L.range(r,r+o.length),changes:{from:r,to:s,insert:o}};let[l,a,h=a]=o;return{range:L.range(a,h),changes:{from:r,to:s,insert:l}}}))}static getMwConfig(e){let t={tags:{},tagModes:go.mwTagModes,doubleUnderscore:[{},{}],functionSynonyms:[e.parserFunction[0],{}],urlProtocols:`${e.protocol}|//`,nsid:e.nsid,img:{},variants:e.variants};tr(e.ext,t.tags),tr(e.doubleUnderscore[0].map(i=>`__${i}__`),t.doubleUnderscore[0]),tr(e.doubleUnderscore[1].map(i=>`__${i}__`),t.doubleUnderscore[1]),tr(e.parserFunction.slice(2).flat(),t.functionSynonyms[0],!0),tr(e.parserFunction[1],t.functionSynonyms[1]);for(let[i,r]of Object.entries(e.img))t.img[i]=`img_${r}`;return t}};qe=new WeakMap,ne=new WeakMap,ir=new WeakMap,Ci=new WeakMap,nr=new WeakMap,rr=new WeakMap,sr=new WeakMap,or=new WeakMap,Mt=new WeakMap,ni=new WeakMap,Ai=new WeakMap,Nt=new WeakSet,Ti=function(e){V(this,ne).dispatch({effects:e})},po=new WeakSet,Vp=function(){let{offsetHeight:e}=V(this,qe);V(this,ne).dom.style.height=e?`${e}px`:V(this,qe).style.height},lr=new WeakSet,ch=function(e){V(this,ne).dom.style.minHeight=e?"calc(100px + 2em)":"2em"},ar=new WeakSet,fh=function(e){var t;(e?Ha:Hs)(V(this,ne)),(t=document.querySelector(".cm-panel-lint ul"))==null||t.blur(),_e(this,lr,ch).call(this,e)},mo=new WeakSet,Wp=function(){return V(this,Ci).get(V(this,ne).state)[0]},go.mwTagModes={tab:"text/mediawiki",tabs:"text/mediawiki",indicator:"text/mediawiki",poem:"text/mediawiki",ref:"text/mediawiki",references:"text/mediawiki",option:"text/mediawiki",choose:"text/mediawiki",combooption:"text/mediawiki",combobox:"text/mediawiki",poll:"text/mediawiki",gallery:"text/mediawiki"};var ao=go;export{co as CDN,ao as CodeMirror6};
|
|
14
14
|
/**
|
|
15
15
|
* @author MusikAnimal and others
|
|
16
16
|
* @license GPL-2.0-or-later
|