diff --git a/playground/dist/index.js b/playground/dist/index.js index 3f36319e6..46f77e826 100644 --- a/playground/dist/index.js +++ b/playground/dist/index.js @@ -1,19 +1,19 @@ -var BC=Object.create;var Mc=Object.defineProperty;var jC=Object.getOwnPropertyDescriptor;var $C=Object.getOwnPropertyNames;var zC=Object.getPrototypeOf,FC=Object.prototype.hasOwnProperty;var VC=(t,e,r)=>e in t?Mc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Xy=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Dc=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),yr=(t,e)=>{for(var r in e)Mc(t,r,{get:e[r],enumerable:!0})},UC=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $C(e))!FC.call(t,i)&&i!==r&&Mc(t,i,{get:()=>e[i],enumerable:!(n=jC(e,i))||n.enumerable});return t};var Br=(t,e,r)=>(r=t!=null?BC(zC(t)):{},UC(e||!t||!t.__esModule?Mc(r,"default",{value:t,enumerable:!0}):r,t));var H=(t,e,r)=>(VC(t,typeof e!="symbol"?e+"":e,r),r),rd=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var g=(t,e,r)=>(rd(t,e,"read from private field"),r?r.call(t):e.get(t)),E=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},L=(t,e,r,n)=>(rd(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Qy=(t,e,r,n)=>({set _(i){L(t,e,i,r)},get _(){return g(t,e,n)}}),e0=(t,e,r)=>(rd(t,e,"access private method"),r);var tu=Dc((lj,Ow)=>{Ow.exports=function(t,e,r,n,i){var o,s;if(n===void 0)n=0;else if(n=n|0,n<0||n>=t.length)throw new RangeError("invalid lower bound");if(i===void 0)i=t.length-1;else if(i=i|0,i=t.length)throw new RangeError("invalid upper bound");for(;n<=i;)if(o=n+(i-n>>>1),s=+r(t[o],e,o,t),s<0)n=o+1;else if(s>0)i=o-1;else return o;return~n}});var ru=Dc((cj,Rw)=>{"use strict";Rw.exports=IR;function cs(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function IR(t){if(t=t||{},t.circles)return BR(t);return t.proto?n:r;function e(i,o){for(var s=Object.keys(i),a=new Array(s.length),l=0;l{(function(t){if(typeof pu=="object"&&typeof pu.exports=="object"){var e=t(Xy,Gw);e!==void 0&&(pu.exports=e)}else typeof define=="function"&&define.amd&&define(["require","exports"],t)})(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TextDocument=void 0;class r{constructor(c,f,u,h){this._uri=c,this._languageId=f,this._version=u,this._content=h,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(c){if(c){let f=this.offsetAt(c.start),u=this.offsetAt(c.end);return this._content.substring(f,u)}return this._content}update(c,f){for(let u of c)if(r.isIncremental(u)){let h=s(u.range),d=this.offsetAt(h.start),p=this.offsetAt(h.end);this._content=this._content.substring(0,d)+u.text+this._content.substring(p,this._content.length);let b=Math.max(h.start.line,0),m=Math.max(h.end.line,0),k=this._lineOffsets,S=o(u.text,!1,d);if(m-b===S.length)for(let w=0,C=S.length;wc?h=p:u=p+1}let d=u-1;return{line:d,character:c-f[d]}}offsetAt(c){let f=this.getLineOffsets();if(c.line>=f.length)return this._content.length;if(c.line<0)return 0;let u=f[c.line],h=c.line+1{let w=S.range.start.line-_.range.start.line;return w===0?S.range.start.character-_.range.start.character:w}),m=0,k=[];for(let S of b){let _=h.offsetAt(S.range.start);if(_m&&k.push(p.substring(m,_)),S.newText.length&&k.push(S.newText),m=h.offsetAt(S.range.end)}return k.push(p.substr(m)),k.join("")}l.applyEdits=u})(n=e.TextDocument||(e.TextDocument={}));function i(l,c){if(l.length<=1)return l;let f=l.length/2|0,u=l.slice(0,f),h=l.slice(f);i(u,c),i(h,c);let d=0,p=0,b=0;for(;df.line||c.line===f.line&&c.character>f.character?{start:f,end:c}:l}function a(l){let c=s(l.range);return c!==l.range?{newText:l.newText,range:c}:l}})});var Nx=Dc((zu,Dx)=>{(function(t,e){typeof zu=="object"&&typeof Dx<"u"?e(zu):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t["base64-arraybuffer"]={}))})(zu,function(t){"use strict";for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=typeof Uint8Array>"u"?[]:new Uint8Array(256),n=0;n>2],f+=e[(a[l]&3)<<4|a[l+1]>>4],f+=e[(a[l+1]&15)<<2|a[l+2]>>6],f+=e[a[l+2]&63];return c%3===2?f=f.substring(0,f.length-1)+"=":c%3===1&&(f=f.substring(0,f.length-2)+"=="),f},o=function(s){var a=s.length*.75,l=s.length,c,f=0,u,h,d,p;s[s.length-1]==="="&&(a--,s[s.length-2]==="="&&a--);var b=new ArrayBuffer(a),m=new Uint8Array(b);for(c=0;c>4,m[f++]=(h&15)<<4|d>>2,m[f++]=(d&3)<<6|p&63;return b};t.decode=o,t.encode=i,Object.defineProperty(t,"__esModule",{value:!0})})});var ee=class{constructor(){}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,r,n){let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(r,this.length,i,1),qt.from(i,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){let n=[];return this.decompose(e,r,n,0),qt.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new Mi(this),o=new Mi(e);for(let s=r,a=r;;){if(i.next(s),o.next(s),s=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(a+=i.value.length,i.done||a>=n)return!0}}iter(e=1){return new Mi(this,e)}iterRange(e,r=this.length){return new Ic(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new Bc(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ee.empty:e.length<=32?new xe(e):qt.from(xe.split(e,[]))}},xe=class extends ee{constructor(e,r=HC(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.text[o],a=i+s.length;if((r?n:a)>=e)return new id(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new xe(t0(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=Lc(o.text,s.text.slice(),0,o.length);if(a.length<=32)n.push(new xe(a,s.length+o.length));else{let l=a.length>>1;n.push(new xe(a.slice(0,l)),new xe(a.slice(l)))}}else n.push(o)}replace(e,r,n){if(!(n instanceof xe))return super.replace(e,r,n);let i=Lc(this.text,Lc(n.text,t0(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new xe(i,o):qt.from(xe.split(i,[]),o)}sliceString(e,r=this.length,n=` -`){let i="";for(let o=0,s=0;o<=r&&se&&s&&(i+=n),eo&&(i+=a.slice(Math.max(0,e-o),r-o)),o=l+1}return i}flatten(e){for(let r of this.text)e.push(r)}scanIdentical(){return 0}static split(e,r){let n=[],i=-1;for(let o of e)n.push(o),i+=o.length+1,n.length==32&&(r.push(new xe(n,i)),n=[],i=-1);return i>-1&&r.push(new xe(n,i)),r}},qt=class extends ee{constructor(e,r){super(),this.children=e,this.length=r,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.children[o],a=i+s.length,l=n+s.lines-1;if((r?l:a)>=e)return s.lineInner(e,r,n,i);i=a+1,n=l+1}}decompose(e,r,n,i){for(let o=0,s=0;s<=r&&o=s){let c=i&((s<=e?1:0)|(l>=r?2:0));s>=e&&l<=r&&!c?n.push(a):a.decompose(e-s,r-s,n,c)}s=l+1}}replace(e,r,n){if(n.lines=o&&r<=a){let l=s.replace(e-o,r-o,n),c=this.lines-s.lines+l.lines;if(l.lines>5-1&&l.lines>c>>5+1){let f=this.children.slice();return f[i]=l,new qt(f,this.length-(r-e)+n.length)}return super.replace(o,a,l)}o=a+1}return super.replace(e,r,n)}sliceString(e,r=this.length,n=` -`){let i="";for(let o=0,s=0;oe&&o&&(i+=n),es&&(i+=a.sliceString(e-s,r-s,n)),s=l+1}return i}flatten(e){for(let r of this.children)r.flatten(e)}scanIdentical(e,r){if(!(e instanceof qt))return 0;let n=0,[i,o,s,a]=r>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=r,o+=r){if(i==s||o==a)return n;let l=this.children[i],c=e.children[o];if(l!=c)return n+l.scanIdentical(c,r);n+=l.length+1}}static from(e,r=e.reduce((n,i)=>n+i.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new xe(d,r)}let i=Math.max(32,n>>5),o=i<<1,s=i>>1,a=[],l=0,c=-1,f=[];function u(d){let p;if(d.lines>o&&d instanceof qt)for(let b of d.children)u(b);else d.lines>s&&(l>s||!l)?(h(),a.push(d)):d instanceof xe&&l&&(p=f[f.length-1])instanceof xe&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,f[f.length-1]=new xe(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>i&&h(),l+=d.lines,c+=d.length+1,f.push(d))}function h(){l!=0&&(a.push(f.length==1?f[0]:qt.from(f,c)),c=-1,l=f.length=0)}for(let d of e)u(d);return h(),a.length==1?a[0]:new qt(a,r)}};ee.empty=new xe([""],0);function HC(t){let e=-1;for(let r of t)e+=r.length+1;return e}function Lc(t,e,r=0,n=1e9){for(let i=0,o=0,s=!0;o=r&&(l>n&&(a=a.slice(0,n-i)),i0?1:(e instanceof xe?e.text.length:e.children.length)<<1]}nextInner(e,r){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],o=this.offsets[n],s=o>>1,a=i instanceof xe?i.text.length:i.children.length;if(s==(r>0?a:0)){if(n==0)return this.done=!0,this.value="",this;r>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(r>0?0:1)){if(this.offsets[n]+=r,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(i instanceof xe){let l=i.text[s+(r<0?-1:0)];if(this.offsets[n]+=r,l.length>Math.max(0,e))return this.value=e==0?l:r>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[s+(r<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=r):(r<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(r>0?1:(l instanceof xe?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Ic=class{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new Mi(e,r>n?-1:1),this.pos=r>n?e.length:0,this.from=Math.min(r,n),this.to=Math.max(r,n)}nextInner(e,r){if(r<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,r<0?this.pos-this.to:this.from-this.pos);let n=r<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*r,this.value=i.length<=n?i:r<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Bc=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:r,lineBreak:n,value:i}=this.inner.next(e);return r?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(ee.prototype[Symbol.iterator]=function(){return this.iter()},Mi.prototype[Symbol.iterator]=Ic.prototype[Symbol.iterator]=Bc.prototype[Symbol.iterator]=function(){return this});var id=class{constructor(e,r,n,i){this.from=e,this.to=r,this.number=n,this.text=i}get length(){return this.to-this.from}},Lo="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;tt)return Lo[e-1]<=t;return!1}function r0(t){return t>=127462&&t<=127487}var n0=8205;function mt(t,e,r=!0,n=!0){return(r?c0:qC)(t,e,n)}function c0(t,e,r){if(e==t.length)return e;e&&f0(t.charCodeAt(e))&&u0(t.charCodeAt(e-1))&&e--;let n=$e(t,e);for(e+=xt(n);e=0&&r0($e(t,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function qC(t,e,r){for(;e>0;){let n=c0(t,e-2,r);if(n=56320&&t<57344}function u0(t){return t>=55296&&t<56320}function $e(t,e){let r=t.charCodeAt(e);if(!u0(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return f0(n)?(r-55296<<10)+(n-56320)+65536:r}function pa(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function xt(t){return t<65536?1:2}var od=/\r\n?|\n/,Je=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Je||(Je={})),Kt=class{constructor(e){this.sections=e}get length(){let e=0;for(let r=0;re)return o+(e-i);o+=a}else{if(n!=Je.Simple&&c>=e&&(n==Je.TrackDel&&ie||n==Je.TrackBefore&&ie))return null;if(c>e||c==e&&r<0&&!a)return e==i||r<0?o:o+l;o+=l}i=c}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return o}touchesRange(e,r=e){for(let n=0,i=0;n=0&&i<=r&&a>=e)return ir?"cover":!0;i=a}return!1}toString(){let e="";for(let r=0;r=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(r=>typeof r!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Kt(e)}},Ae=class extends Kt{constructor(e,r){super(e),this.inserted=r}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return sd(this,(r,n,i,o,s)=>e=e.replace(i,i+(n-r),s),!1),e}mapDesc(e,r=!1){return ad(this,e,r,!0)}invert(e){let r=this.sections.slice(),n=[];for(let i=0,o=0;i=0){r[i]=a,r[i+1]=s;let l=i>>1;for(;n.length0&&Ei(n,r,o.text),o.forward(f),a+=f}let c=e[s++];for(;a>1].toJSON()))}return e}static of(e,r,n){let i=[],o=[],s=0,a=null;function l(f=!1){if(!f&&!i.length)return;sh||u<0||h>r)throw new RangeError(`Invalid change range ${u} to ${h} (in doc of length ${r})`);let p=d?typeof d=="string"?ee.of(d.split(n||od)):d:ee.empty,b=p.length;if(u==h&&b==0)return;us&&pt(i,u-s,-1),pt(i,h-u,b),Ei(o,i,p),s=h}}return c(e),l(!a),a}static empty(e){return new Ae(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let r=[],n=[];for(let i=0;ia&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)r.push(o[0],0);else{for(;n.length=0&&r<=0&&r==t[i+1]?t[i]+=e:e==0&&t[i]==0?t[i+1]+=r:n?(t[i]+=e,t[i+1]+=r):t.push(e,r)}function Ei(t,e,r){if(r.length==0)return;let n=e.length-2>>1;if(n>1])),!(r||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],l=t.sections[s++];e(i,c,o,f,u),i=c,o=f}}}function ad(t,e,r,n=!1){let i=[],o=n?[]:null,s=new Di(t),a=new Di(e);for(let l=0,c=0;;)if(s.ins==-1)l+=s.len,s.next();else if(a.ins==-1&&c=0&&(s.done||cc&&!s.done&&l+s.len=0){let f=0,u=l+s.len;for(;;)if(a.ins>=0&&c>l&&c+a.lenl||s.ins>=0&&s.len>l)&&(a||n.length>c),o.forward2(l),s.forward(l)}}}}var Di=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return r>=e.length?ee.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?ee.empty:r[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Nn=class{constructor(e,r,n){this.from=e,this.to=r,this.flags=n}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,r=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,r):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new Nn(n,i,this.flags)}extend(e,r=e){if(e<=this.anchor&&r>=this.anchor)return A.range(e,r);let n=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return A.range(this.anchor,n)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return A.range(e.anchor,e.head)}},A=class{constructor(e,r=0){this.ranges=e,this.mainIndex=r}map(e,r=-1){return e.empty?this:A.create(this.ranges.map(n=>n.map(e,r)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.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 A(e.ranges.map(r=>Nn.fromJSON(r)),e.main)}static single(e,r=e){return new A([A.range(e,r)],0)}static create(e,r=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;ie?4:0))}};function KC(t,e=0){let r=t[e];t.sort((n,i)=>n.from-i.from),e=t.indexOf(r);for(let n=1;ni.head?A.range(a,s):A.range(s,a))}}return new A(t,e)}function d0(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}var md=0,j=class{constructor(e,r,n,i,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=i,this.extensions=o,this.id=md++,this.default=e([])}static define(e={}){return new j(e.combine||(r=>r),e.compareInput||((r,n)=>r===n),e.compare||(e.combine?(r,n)=>r===n:gd),!!e.static,e.enables)}of(e){return new Io([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Io(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Io(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}};function gd(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}var Io=class{constructor(e,r,n,i){this.dependencies=e,this.facet=r,this.type=n,this.value=i,this.id=md++}dynamicSlot(e){var r;let n=this.value,i=this.facet.compareInput,o=this.id,s=e[o]>>1,a=this.type==2,l=!1,c=!1,f=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:((r=e[u.id])!==null&&r!==void 0?r:1)&1||f.push(e[u.id]);return{create(u){return u.values[s]=n(u),1},update(u,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||ld(u,f)){let d=n(u);if(a?!i0(d,u.values[s],i):!i(d,u.values[s]))return u.values[s]=d,1}return 0},reconfigure:(u,h)=>{let d=n(u),p=h.config.address[o];if(p!=null){let b=$c(h,p);if(this.dependencies.every(m=>m instanceof j?h.facet(m)===u.facet(m):m instanceof ce?h.field(m,!1)==u.field(m,!1):!0)||(a?i0(d,b,i):i(d,b)))return u.values[s]=b,0}return u.values[s]=d,1}}}};function i0(t,e,r){if(t.length!=e.length)return!1;for(let n=0;nt[l.id]),i=r.map(l=>l.type),o=n.filter(l=>!(l&1)),s=t[e.id]>>1;function a(l){let c=[];for(let f=0;fn===i),e);return e.provide&&(r.provides=e.provide(r)),r}create(e){let r=e.facet(o0).find(n=>n.field==this);return(r?.create||this.createF)(e)}slot(e){let r=e[this.id]>>1;return{create:n=>(n.values[r]=this.create(n),1),update:(n,i)=>{let o=n.values[r],s=this.updateF(o,i);return this.compareF(o,s)?0:(n.values[r]=s,1)},reconfigure:(n,i)=>i.config.address[this.id]!=null?(n.values[r]=i.field(this),0):(n.values[r]=this.create(n),1)}}init(e){return[this,o0.of({field:this,create:e})]}get extension(){return this}},Po={lowest:4,low:3,default:2,high:1,highest:0};function ca(t){return e=>new jc(e,t)}var hn={highest:ca(Po.highest),high:ca(Po.high),default:ca(Po.default),low:ca(Po.low),lowest:ca(Po.lowest)},jc=class{constructor(e,r){this.inner=e,this.prec=r}},jo=class{of(e){return new ua(this,e)}reconfigure(e){return jo.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},ua=class{constructor(e,r){this.compartment=e,this.inner=r}},$o=class{constructor(e,r,n,i,o,s){for(this.base=e,this.compartments=r,this.dynamicSlots=n,this.address=i,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,r,n){let i=[],o=Object.create(null),s=new Map;for(let h of ZC(e,r,s))h instanceof ce?i.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of i)a[h.id]=c.length<<1,c.push(d=>h.slot(d));let f=n?.config.facets;for(let h in o){let d=o[h],p=d[0].facet,b=f&&f[h]||[];if(d.every(m=>m.type==0))if(a[p.id]=l.length<<1|1,gd(b,d))l.push(n.facet(p));else{let m=p.combine(d.map(k=>k.value));l.push(n&&p.compare(m,n.facet(p))?n.facet(p):m)}else{for(let m of d)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=c.length<<1,c.push(k=>m.dynamicSlot(k)));a[p.id]=c.length<<1,c.push(m=>GC(m,p,d))}}let u=c.map(h=>h(a));return new $o(e,s,u,a,l,o)}};function ZC(t,e,r){let n=[[],[],[],[],[]],i=new Map;function o(s,a){let l=i.get(s);if(l!=null){if(l<=a)return;let c=n[l].indexOf(s);c>-1&&n[l].splice(c,1),s instanceof ua&&r.delete(s.compartment)}if(i.set(s,a),Array.isArray(s))for(let c of s)o(c,a);else if(s instanceof ua){if(r.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;r.set(s.compartment,c),o(c,a)}else if(s instanceof jc)o(s.inner,s.prec);else if(s instanceof ce)n[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Io)n[a].push(s),s.facet.extensions&&o(s.facet.extensions,a);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(c,a)}}return o(t,Po.default),n.reduce((s,a)=>s.concat(a))}function fa(t,e){if(e&1)return 2;let r=e>>1,n=t.status[r];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[r]=4;let i=t.computeSlot(t,t.config.dynamicSlots[r]);return t.status[r]=2|i}function $c(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var p0=j.define(),m0=j.define({combine:t=>t.some(e=>e),static:!0}),g0=j.define({combine:t=>t.length?t[0]:void 0,static:!0}),y0=j.define(),b0=j.define(),k0=j.define(),v0=j.define({combine:t=>t.length?t[0]:!1}),br=class{constructor(e,r){this.type=e,this.value=r}static define(){return new cd}},cd=class{of(e){return new br(this,e)}},fd=class{constructor(e){this.map=e}of(e){return new W(this,e)}},W=class{constructor(e,r){this.type=e,this.value=r}map(e){let r=this.type.map(this.value,e);return r===void 0?void 0:r==this.value?this:new W(this.type,r)}is(e){return this.type==e}static define(e={}){return new fd(e.map||(r=>r))}static mapEffects(e,r){if(!e.length)return e;let n=[];for(let i of e){let o=i.map(r);o&&n.push(o)}return n}};W.reconfigure=W.define();W.appendConfig=W.define();var Te=class{constructor(e,r,n,i,o,s){this.startState=e,this.changes=r,this.selection=n,this.effects=i,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,n&&d0(n,r.newLength),o.some(a=>a.type==Te.time)||(this.annotations=o.concat(Te.time.of(Date.now())))}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 r of this.annotations)if(r.type==e)return r.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let r=this.annotation(Te.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}};Te.time=br.define();Te.userEvent=br.define();Te.addToHistory=br.define();Te.remote=br.define();function JC(t,e){let r=[];for(let n=0,i=0;;){let o,s;if(n=t[n]))o=t[n++],s=t[n++];else if(i=0;i--){let o=n[i](t);o instanceof Te?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof Te?t=o[0]:t=x0(e,Bo(o),!1)}return t}function XC(t){let e=t.startState,r=e.facet(k0),n=t;for(let i=r.length-1;i>=0;i--){let o=r[i](t);o&&Object.keys(o).length&&(n=w0(t,ud(e,o,t.changes.newLength),!0))}return n==t?t:new Te(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var QC=[];function Bo(t){return t==null?QC:Array.isArray(t)?t:[t]}var je=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(je||(je={})),eA=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,hd;try{hd=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function tA(t){if(hd)return hd.test(t);for(let e=0;e"\x80"&&(r.toUpperCase()!=r.toLowerCase()||eA.test(r)))return!0}return!1}function rA(t){return e=>{if(!/\S/.test(e))return je.Space;if(tA(e))return je.Word;for(let r=0;r-1)return je.Word;return je.Other}}var G=class{constructor(e,r,n,i,o,s){this.config=e,this.doc=r,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(let a=0;ai.set(l,a)),r=null),i.set(s.value.compartment,s.value.extension)):s.is(W.reconfigure)?(r=null,n=s.value):s.is(W.appendConfig)&&(r=null,n=Bo(n).concat(s.value));let o;r?o=e.startState.values.slice():(r=$o.resolve(n,i,this),o=new G(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values),new G(r,e.newDoc,e.newSelection,o,(s,a)=>a.update(s,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:e},range:A.cursor(r.from+e.length)}))}changeByRange(e){let r=this.selection,n=e(r.ranges[0]),i=this.changes(n.changes),o=[n.range],s=Bo(n.effects);for(let a=1;as.spec.fromJSON(a,l)))}return G.create({doc:e.doc,selection:A.fromJSON(e.selection),extensions:r.extensions?i.concat([r.extensions]):i})}static create(e={}){let r=$o.resolve(e.extensions||[],new Map),n=e.doc instanceof ee?e.doc:ee.of((e.doc||"").split(r.staticFacet(G.lineSeparator)||od)),i=e.selection?e.selection instanceof A?e.selection:A.single(e.selection.anchor,e.selection.head):A.single(0);return d0(i,n.length),r.staticFacet(m0)||(i=i.asSingle()),new G(r,n,i,r.dynamicSlots.map(()=>null),(o,s)=>s.create(o),null)}get tabSize(){return this.facet(G.tabSize)}get lineBreak(){return this.facet(G.lineSeparator)||` -`}get readOnly(){return this.facet(v0)}phrase(e){for(let r of this.facet(G.phrases))if(Object.prototype.hasOwnProperty.call(r,e))return r[e];return e}languageDataAt(e,r,n=-1){let i=[];for(let o of this.facet(p0))for(let s of o(this,r,n))Object.prototype.hasOwnProperty.call(s,e)&&i.push(s[e]);return i}charCategorizer(e){return rA(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:r,from:n,length:i}=this.doc.lineAt(e),o=this.charCategorizer(e),s=e-n,a=e-n;for(;s>0;){let l=mt(r,s,!1);if(o(r.slice(l,s))!=je.Word)break;s=l}for(;at.length?t[0]:4});G.lineSeparator=g0;G.readOnly=v0;G.phrases=j.define({compare(t,e){let r=Object.keys(t),n=Object.keys(e);return r.length==n.length&&r.every(i=>t[i]==e[i])}});G.languageData=p0;G.changeFilter=y0;G.transactionFilter=b0;G.transactionExtender=k0;jo.reconfigure=W.define();function gt(t,e,r={}){let n={};for(let i of t)for(let o of Object.keys(i)){let s=i[o],a=n[o];if(a===void 0)n[o]=s;else if(!(a===s||s===void 0))if(Object.hasOwnProperty.call(r,o))n[o]=r[o](a,s);else throw new Error("Config merge conflict for field "+o)}for(let i in e)n[i]===void 0&&(n[i]=e[i]);return n}var kr=class{eq(e){return this==e}range(e,r=e){return new ha(e,r,this)}};kr.prototype.startSide=kr.prototype.endSide=0;kr.prototype.point=!1;kr.prototype.mapMode=Je.TrackDel;var ha=class{constructor(e,r,n){this.from=e,this.to=r,this.value=n}};function dd(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var da=class{constructor(e,r,n,i){this.from=e,this.to=r,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,r,n,i=0){let o=n?this.to:this.from;for(let s=i,a=o.length;;){if(s==a)return s;let l=s+a>>1,c=o[l]-e||(n?this.value[l].endSide:this.value[l].startSide)-r;if(l==s)return c>=0?s:a;c>=0?a=l:s=l+1}}between(e,r,n,i){for(let o=this.findIndex(r,-1e9,!0),s=this.findIndex(n,1e9,!1,o);od||h==d&&c.startSide>0&&c.endSide<=0)continue;(d-h||c.endSide-c.startSide)<0||(s<0&&(s=h),c.point&&(a=Math.max(a,d-h)),n.push(c),i.push(h-s),o.push(d-s))}return{mapped:n.length?new da(i,o,n,a):null,pos:s}}},te=class{constructor(e,r,n=te.empty,i){this.chunkPos=e,this.chunk=r,this.nextLayer=n,this.maxPoint=i}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 r of this.chunk)e+=r.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:r=[],sort:n=!1,filterFrom:i=0,filterTo:o=this.length}=e,s=e.filter;if(r.length==0&&!s)return this;if(n&&(r=r.slice().sort(dd)),this.isEmpty)return r.length?te.of(r):this;let a=new zc(this,null,-1).goto(0),l=0,c=[],f=new Mt;for(;a.value||l=0){let u=r[l++];f.addInner(u.from,u.to,u.value)||c.push(u)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||oa.to||o=o&&e<=o+s.length&&s.between(o,e-o,r-o,n)===!1)return}this.nextLayer.between(e,r,n)}}iter(e=0){return Ni.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,r=0){return Ni.from(e).goto(r)}static compare(e,r,n,i,o=-1){let s=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=o),a=r.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=o),l=s0(s,a,n),c=new Ri(s,l,o),f=new Ri(a,l,o);n.iterGaps((u,h,d)=>a0(c,u,f,h,d,i)),n.empty&&n.length==0&&a0(c,0,f,0,0,i)}static eq(e,r,n=0,i){i==null&&(i=1e9);let o=e.filter(f=>!f.isEmpty&&r.indexOf(f)<0),s=r.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(o.length!=s.length)return!1;if(!o.length)return!0;let a=s0(o,s),l=new Ri(o,a,0).goto(n),c=new Ri(s,a,0).goto(n);for(;;){if(l.to!=c.to||!pd(l.active,c.active)||l.point&&(!c.point||!l.point.eq(c.point)))return!1;if(l.to>i)return!0;l.next(),c.next()}}static spans(e,r,n,i,o=-1){let s=new Ri(e,null,o).goto(r),a=r,l=s.openStart;for(;;){let c=Math.min(s.to,n);if(s.point?(i.point(a,c,s.point,s.activeForPoint(s.to),l,s.pointRank),l=s.openEnd(c)+(s.to>c?1:0)):c>a&&(i.span(a,c,s.active,l),l=s.openEnd(c)),s.to>n)break;a=s.to,s.next()}return l}static of(e,r=!1){let n=new Mt;for(let i of e instanceof ha?[e]:r?nA(e):e)n.add(i.from,i.to,i.value);return n.finish()}};te.empty=new te([],[],null,-1);function nA(t){if(t.length>1)for(let e=t[0],r=1;r0)return t.slice().sort(dd);e=n}return t}te.empty.nextLayer=te.empty;var Mt=class{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}finishChunk(e){this.chunks.push(new da(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=[])}add(e,r,n){this.addInner(e,r,n)||(this.nextLayer||(this.nextLayer=new Mt)).add(e,r,n)}addInner(e,r,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(r-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=r,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,r-e)),!0)}addChunk(e,r){if((e-this.lastTo||r.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,r.maxPoint),this.chunks.push(r),this.chunkPos.push(e);let n=r.value.length-1;return this.last=r.value[n],this.lastFrom=r.from[n]+e,this.lastTo=r.to[n]+e,!0}finish(){return this.finishInner(te.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let r=new te(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,r}};function s0(t,e,r){let n=new Map;for(let o of t)for(let s=0;s=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=n&&i.push(new zc(s,r,n,o));return i.length==1?i[0]:new Ni(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,r=-1e9){for(let n of this.heap)n.goto(e,r);for(let n=this.heap.length>>1;n>=0;n--)nd(this.heap,n);return this.next(),this}forward(e,r){for(let n of this.heap)n.forward(e,r);for(let n=this.heap.length>>1;n>=0;n--)nd(this.heap,n);(this.to-e||this.value.endSide-r)<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(),nd(this.heap,0)}}};function nd(t,e){for(let r=t[e];;){let n=(e<<1)+1;if(n>=t.length)break;let i=t[n];if(n+1=0&&(i=t[n+1],n++),r.compare(i)<0)break;t[n]=r,t[e]=i,e=n}}var Ri=class{constructor(e,r,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ni.from(e,r,n)}goto(e,r=-1e9){return this.cursor.goto(e,r),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=r,this.openStart=-1,this.next(),this}forward(e,r){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-r)<0;)this.removeActive(this.minActive);this.cursor.forward(e,r)}removeActive(e){Nc(this.active,e),Nc(this.activeTo,e),Nc(this.activeRank,e),this.minActive=l0(this.active,this.activeTo)}addActive(e){let r=0,{value:n,to:i,rank:o}=this.cursor;for(;r-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),n&&Nc(n,o)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(r&&this.cursor.to==this.to&&this.cursor.from=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&r.push(this.active[n]);return r.reverse()}openEnd(e){let r=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)r++;return r}};function a0(t,e,r,n,i,o){t.goto(e),r.goto(n);let s=n+i,a=n,l=n-e;for(;;){let c=t.to+l-r.to||t.endSide-r.endSide,f=c<0?t.to+l:r.to,u=Math.min(f,s);if(t.point||r.point?t.point&&r.point&&(t.point==r.point||t.point.eq(r.point))&&pd(t.activeForPoint(t.to+l),r.activeForPoint(r.to))||o.comparePoint(a,u,t.point,r.point):u>a&&!pd(t.active,r.active)&&o.compareRange(a,u,t.active,r.active),f>s)break;a=f,c<=0&&t.next(),c>=0&&r.next()}}function pd(t,e){if(t.length!=e.length)return!1;for(let r=0;r=e;n--)t[n+1]=t[n];t[e]=r}function l0(t,e){let r=-1,n=1e9;for(let i=0;i=e)return i;if(i==t.length)break;o+=t.charCodeAt(i)==9?r-o%r:1,i=mt(t,i)}return n===!0?-1:t.length}var yd="\u037C",S0=typeof Symbol>"u"?"__"+yd:Symbol.for(yd),bd=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),_0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Gt=class{constructor(e,r){this.rules=[];let{finish:n}=r||{};function i(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function o(s,a,l,c){let f=[],u=/^@(\w+)\b/.exec(s[0]),h=u&&u[1]=="keyframes";if(u&&a==null)return l.push(s[0]+";");for(let d in a){let p=a[d];if(/&/.test(d))o(d.split(/,\s*/).map(b=>s.map(m=>b.replace(/&/,m))).reduce((b,m)=>b.concat(m)),p,l);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");o(i(d),p,f,h)}else p!=null&&f.push(d.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+p+";")}(f.length||h)&&l.push((n&&!u&&!c?s.map(n):s).join(", ")+" {"+f.join(" ")+"}")}for(let s in e)o(i(s),e[s],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=_0[S0]||1;return _0[S0]=e+1,yd+e.toString(36)}static mount(e,r){(e[bd]||new kd(e)).mount(Array.isArray(r)?r:[r])}},Vc=null,kd=class{constructor(e){if(!e.head&&e.adoptedStyleSheets&&typeof CSSStyleSheet<"u"){if(Vc)return e.adoptedStyleSheets=[Vc.sheet].concat(e.adoptedStyleSheets),e[bd]=Vc;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),Vc=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[bd]=this}mount(e){let r=this.sheet,n=0,i=0;for(let o=0;o-1&&(this.modules.splice(a,1),i--,a=-1),a==-1){if(this.modules.splice(i++,0,s),r)for(let l=0;l",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},C0=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),iA=typeof navigator<"u"&&/Apple Computer/.test(navigator.vendor),oA=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),A0=typeof navigator<"u"&&/Mac/.test(navigator.platform),sA=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),aA=C0&&(A0||+C0[1]<57)||oA&&A0;for(De=0;De<10;De++)dn[48+De]=dn[96+De]=String(De);var De;for(De=1;De<=24;De++)dn[De+111]="F"+De;var De;for(De=65;De<=90;De++)dn[De]=String.fromCharCode(De+32),Hc[De]=String.fromCharCode(De);var De;for(Uc in dn)Hc.hasOwnProperty(Uc)||(Hc[Uc]=dn[Uc]);var Uc;function T0(t){var e=aA&&(t.ctrlKey||t.altKey||t.metaKey)||(iA||sA)&&t.shiftKey&&t.key&&t.key.length==1,r=!e&&t.key||(t.shiftKey?Hc:dn)[t.keyCode]||t.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}function Yc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Ho(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function lA(){let t=document.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Rd(t,e){if(!e.anchorNode)return!1;try{return Ho(t,e.anchorNode)}catch{return!1}}function Ca(t){return t.nodeType==3?Aa(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Xc(t,e,r,n){return r?O0(t,e,r,n,-1)||O0(t,e,r,n,1):!1}function Ed(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function O0(t,e,r,n,i){for(;;){if(t==r&&e==n)return!0;if(e==(i<0?0:Qc(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Ed(t)+(i<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?Qc(t):0}else return!1}}function Qc(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}var db={left:0,right:0,top:0,bottom:0};function mf(t,e){let r=e?t.left:t.right;return{left:r,right:r,top:t.top,bottom:t.bottom}}function cA(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function fA(t,e,r,n,i,o,s,a){let l=t.ownerDocument,c=l.defaultView;for(let f=t;f;)if(f.nodeType==1){let u,h=f==l.body;if(h)u=cA(c);else{if(f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.parentNode;continue}let b=f.getBoundingClientRect();u={left:b.left,right:b.left+f.clientWidth,top:b.top,bottom:b.top+f.clientHeight}}let d=0,p=0;if(i=="nearest")e.top0&&e.bottom>u.bottom+p&&(p=e.bottom-u.bottom+p+s)):e.bottom>u.bottom&&(p=e.bottom-u.bottom+s,r<0&&e.top-p0&&e.right>u.right+d&&(d=e.right-u.right+d+o)):e.right>u.right&&(d=e.right-u.right+o,r<0&&e.leftr)return u.domBoundsAround(e,r,c);if(h>=e&&i==-1&&(i=l,o=c),c>r&&u.dom.parentNode==this.dom){s=l,a=f;break}f=h,c=h+u.breakAfter}return{from:o,to:a<0?n+this.length:a,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s=0?this.children[s].dom:null}}markDirty(e=!1){this.dirty|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let r=this.parent;r;r=r.parent){if(e&&(r.dirty|=2),r.dirty&1)return;r.dirty|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.dirty&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let r=e.parent;if(!r)return e;e=r}}replaceChildren(e,r,n=dp){this.markDirty();for(let i=e;ithis.pos||e==this.pos&&(r>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function gb(t,e,r,n,i,o,s,a,l){let{children:c}=t,f=c.length?c[e]:null,u=o.length?o[o.length-1]:null,h=u?u.breakAfter:s;if(!(e==n&&f&&!s&&!h&&o.length<2&&f.merge(r,i,o.length?u:null,r==0,a,l))){if(n0&&(!s&&o.length&&f.merge(r,f.length,o[0],!1,a,0)?f.breakAfter=o.shift().breakAfter:(r2),F={mac:N0||/Mac/.test(Dt.platform),windows:/Win/.test(Dt.platform),linux:/Linux|X11/.test(Dt.platform),ie:gf,ie_version:bb?Dd.documentMode||6:Pd?+Pd[1]:Nd?+Nd[1]:0,gecko:M0,gecko_version:M0?+(/Firefox\/(\d+)/.exec(Dt.userAgent)||[0,0])[1]:0,chrome:!!vd,chrome_version:vd?+vd[1]:0,ios:N0,android:/Android\b/.test(Dt.userAgent),webkit:D0,safari:kb,webkit_version:D0?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Dd.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},hA=256,Fr=class extends ve{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,r,n){return n&&(!(n instanceof Fr)||this.length-(r-e)+n.length>hA)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(r),this.markDirty(),!0)}split(e){let r=new Fr(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),r}localPosFromDOM(e,r){return e==this.dom?r:r?this.text.length:0}domAtPos(e){return new Fe(this.dom,e)}domBoundsAround(e,r,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,r){return Ld(this.dom,e,r)}},Zt=class extends ve{constructor(e,r=[],n=0){super(),this.mark=e,this.children=r,this.length=n;for(let i of r)i.setParent(this)}setAttrs(e){if(mb(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let r in this.mark.attrs)e.setAttribute(r,this.mark.attrs[r]);return e}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.dirty|=6)}sync(e){this.dom?this.dirty&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e)}merge(e,r,n,i,o,s){return n&&(!(n instanceof Zt&&n.mark.eq(this.mark))||e&&o<=0||re&&r.push(n=e&&(i=o),n=l,o++}let s=this.length-e;return this.length=e,i>-1&&(this.children.length=i,this.markDirty()),new Zt(this.mark,r,s)}domAtPos(e){return wb(this.dom,this.children,e)}coordsAt(e,r){return Sb(this,e,r)}};function Ld(t,e,r){let n=t.nodeValue.length;e>n&&(e=n);let i=e,o=e,s=0;e==0&&r<0||e==n&&r>=0?F.chrome||F.gecko||(e?(i--,s=1):(o++,s=-1)):r<0?i--:o++;let a=Aa(t,i,o).getClientRects();if(!a.length)return db;let l=a[(s?s<0:r>=0)?0:a.length-1];return F.safari&&!s&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),s?mf(l,s<0):l||null}var $r=class extends ve{constructor(e,r,n){super(),this.widget=e,this.length=r,this.side=n,this.prevWidget=null}static create(e,r,n){return new(e.customView||$r)(e,r,n)}split(e){let r=$r.create(this.widget,this.length-e,this.side);return this.length-=e,r}sync(){(!this.dom||!this.widget.updateDOM(this.dom))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,r,n,i,o,s){return n&&(!(n instanceof $r)||!this.widget.compare(n.widget)||e>0&&o<=0||r0?n.length-1:0;i=n[o],!(e>0?o==0:o==n.length-1||i.top0?-1:1);return e==0&&r>0||e==this.length&&r<=0?i:mf(i,e==0)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},tf=class extends $r{domAtPos(e){let{topView:r,text:n}=this.widget;return r?Id(e,0,r,n,(i,o)=>i.domAtPos(o),i=>new Fe(n,Math.min(i,n.nodeValue.length))):new Fe(n,Math.min(e,n.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(e,r){let{topView:n,text:i}=this.widget;return n?vb(e,r,n,i):Math.min(r,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(e,r){let{topView:n,text:i}=this.widget;return n?Id(e,r,n,i,(o,s,a)=>o.coordsAt(s,a),(o,s)=>Ld(i,o,s)):Ld(i,e,r)}destroy(){var e;super.destroy(),(e=this.widget.topView)===null||e===void 0||e.destroy()}get isEditable(){return!0}};function Id(t,e,r,n,i,o){if(r instanceof Zt){for(let s of r.children){let a=Ho(s.dom,n),l=a?n.nodeValue.length:s.length;if(t0?-1:1);return n&&n.topr.top?{left:r.left,right:r.right,top:n.top,bottom:n.bottom}:r}get overrideDOMText(){return ee.empty}};Fr.prototype.children=$r.prototype.children=jn.prototype.children=dp;function dA(t,e){let r=t.parent,n=r?r.children.indexOf(t):-1;for(;r&&n>=0;)if(e<0?n>0:ni&&r0;n--){let i=e[n-1].dom;if(i.parentNode==t)return Fe.after(i)}return new Fe(t,0)}function xb(t,e,r){let n,{children:i}=t;r>0&&e instanceof Zt&&i.length&&(n=i[i.length-1])instanceof Zt&&n.mark.eq(e.mark)?xb(n,e.children[0],r-1):(i.push(e),e.setParent(t)),t.length+=e.length}function Sb(t,e,r){for(let o=0,s=0;s0?l>=e:l>e)&&(e0)){let f=0;if(l==o){if(a.getSide()<=0)continue;f=r=-a.getSide()}let u=a.coordsAt(Math.max(0,e-o),r);return f&&u?mf(u,r<0):u}o=l}let n=t.dom.lastChild;if(!n)return t.dom.getBoundingClientRect();let i=Ca(n);return i[i.length-1]||null}function Bd(t,e){for(let r in t)r=="class"&&e.class?e.class+=" "+t.class:r=="style"&&e.style?e.style+=";"+t.style:e[r]=t[r];return e}function pp(t,e){if(t==e)return!0;if(!t||!e)return!1;let r=Object.keys(t),n=Object.keys(e);if(r.length!=n.length)return!1;for(let i of r)if(n.indexOf(i)==-1||t[i]!==e[i])return!1;return!0}function jd(t,e,r){let n=null;if(e)for(let i in e)r&&i in r||t.removeAttribute(n=i);if(r)for(let i in r)e&&e[i]==r[i]||t.setAttribute(n=i,r[i]);return!!n}var Nt=class{eq(e){return!1}updateDOM(e){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}ignoreEvent(e){return!0}get customView(){return null}destroy(e){}},he=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(he||(he={})),$=class extends kr{constructor(e,r,n,i){super(),this.startSide=e,this.endSide=r,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(e){return new Wo(e)}static widget(e){let r=e.side||0,n=!!e.block;return r+=n?r>0?3e8:-4e8:r>0?1e8:-1e8,new mn(e,r,r,n,e.widget||null,!1)}static replace(e){let r=!!e.block,n,i;if(e.isBlockGap)n=-5e8,i=4e8;else{let{start:o,end:s}=_b(e,r);n=(o?r?-3e8:-1:5e8)-1,i=(s?r?2e8:1:-6e8)+1}return new mn(e,n,i,r,e.widget||null,!0)}static line(e){return new Pi(e)}static set(e,r=!1){return te.of(e,r)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};$.none=te.empty;var Wo=class extends ${constructor(e){let{start:r,end:n}=_b(e);super(r?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){return this==e||e instanceof Wo&&this.tagName==e.tagName&&this.class==e.class&&pp(this.attrs,e.attrs)}range(e,r=e){if(e>=r)throw new RangeError("Mark decorations may not be empty");return super.range(e,r)}};Wo.prototype.point=!1;var Pi=class extends ${constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Pi&&pp(this.spec.attributes,e.spec.attributes)}range(e,r=e){if(r!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,r)}};Pi.prototype.mapMode=Je.TrackBefore;Pi.prototype.point=!0;var mn=class extends ${constructor(e,r,n,i,o,s){super(r,n,o,e),this.block=i,this.isReplace=s,this.mapMode=i?r<=0?Je.TrackBefore:Je.TrackAfter:Je.TrackDel}get type(){return this.startSide=5}eq(e){return e instanceof mn&&pA(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,r=e){if(this.isReplace&&(e>r||e==r&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&r!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,r)}};mn.prototype.point=!0;function _b(t,e=!1){let{inclusiveStart:r,inclusiveEnd:n}=t;return r==null&&(r=t.inclusive),n==null&&(n=t.inclusive),{start:r??e,end:n??e}}function pA(t,e){return t==e||!!(t&&e&&t.compare(e))}function $d(t,e,r,n=0){let i=r.length-1;i>=0&&r[i]+n>=t?r[i]=Math.max(r[i],e):r.push(t,e)}var Ye=class extends ve{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,r,n,i,o,s){if(n){if(!(n instanceof Ye))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),yb(this,e,r,n?n.children:[],o,s),!0}split(e){let r=new Ye;if(r.breakAfter=this.breakAfter,this.length==0)return r;let{i:n,off:i}=this.childPos(e);i&&(r.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let o=n;o0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,r}transferDOM(e){this.dom&&(e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){pp(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,r){xb(this,e,r)}addLineDeco(e){let r=e.spec.attributes,n=e.spec.class;r&&(this.attrs=Bd(r,this.attrs||{})),n&&(this.attrs=Bd({class:n},this.attrs||{}))}domAtPos(e){return wb(this.dom,this.children,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.dirty|=6)}sync(e){var r;this.dom?this.dirty&4&&(mb(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&&(jd(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e);let n=this.dom.lastChild;for(;n&&ve.get(n)instanceof Zt;)n=n.lastChild;if(!n||!this.length||n.nodeName!="BR"&&((r=ve.get(n))===null||r===void 0?void 0:r.isEditable)==!1&&(!F.ios||!this.children.some(i=>i instanceof Fr))){let i=document.createElement("BR");i.cmIgnore=!0,this.dom.appendChild(i)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0;for(let r of this.children){if(!(r instanceof Fr))return null;let n=Ca(r.dom);if(n.length!=1)return null;e+=n[0].width}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length}}coordsAt(e,r){return Sb(this,e,r)}become(e){return!1}get type(){return he.Text}static find(e,r){for(let n=0,i=0;n=r){if(o instanceof Ye)return o;if(s>r)break}i=s+o.breakAfter}return null}},pn=class extends ve{constructor(e,r,n){super(),this.widget=e,this.length=r,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,r,n,i,o,s){return n&&(!(n instanceof pn)||!this.widget.compare(n.widget)||e>0&&o<=0||r0;){if(this.textOff==this.text.length){let{value:o,lineBreak:s,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(s){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer([]),this.curLine=null,e--;continue}else this.text=o,this.textOff=0}let i=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(r.slice(0,n)),this.getLine().append(Wc(new Fr(this.text.slice(this.textOff,this.textOff+i)),r),n),this.atCursorPos=!0,this.textOff+=i,e-=i,n=0}}span(e,r,n,i){this.buildText(r-e,n,i),this.pos=r,this.openStart<0&&(this.openStart=i)}point(e,r,n,i,o,s){if(this.disallowBlockEffectsFor[s]&&n instanceof mn){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(r>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let a=r-e;if(n instanceof mn)if(n.block){let{type:l}=n;l==he.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new pn(n.widget||new rf("div"),a,l))}else{let l=$r.create(n.widget||new rf("span"),a,n.startSide),c=this.atCursorPos&&!l.isEditable&&o<=i.length&&(e0),f=!l.isEditable&&(et.some(e=>e)}),qo=class{constructor(e,r="nearest",n="nearest",i=5,o=5){this.range=e,this.y=r,this.x=n,this.yMargin=i,this.xMargin=o}map(e){return e.empty?this:new qo(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}},P0=W.define({map:(t,e)=>t.map(e)});function at(t,e,r){let n=t.facet(Ob);n.length?n[0](e):window.onerror?window.onerror(String(e),r,void 0,void 0,e):r?console.error(r+":",e):console.error(e)}var Ma=j.define({combine:t=>t.length?t[0]:!0}),mA=0,ma=j.define(),de=class{constructor(e,r,n,i){this.id=e,this.create=r,this.domEventHandlers=n,this.extension=i(this)}static define(e,r){let{eventHandlers:n,provide:i,decorations:o}=r||{};return new de(mA++,e,n,s=>{let a=[ma.of(s)];return o&&a.push(Oa.of(l=>{let c=l.plugin(s);return c?o(c):$.none})),i&&a.push(i(s)),a})}static fromClass(e,r){return de.define(n=>new e(n),r)}},wa=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let r=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(r)}catch(n){if(at(r.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(r){at(e.state,r,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var r;if(!((r=this.value)===null||r===void 0)&&r.destroy)try{this.value.destroy()}catch(n){at(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Mb=j.define(),Db=j.define(),Oa=j.define(),Nb=j.define(),Pb=j.define(),ga=j.define(),vr=class{constructor(e,r,n,i){this.fromA=e,this.toA=r,this.fromB=n,this.toB=i}join(e){return new vr(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 r=e.length,n=this;for(;r>0;r--){let i=e[r-1];if(!(i.fromA>n.toA)){if(i.toAf)break;o+=2}if(!l)return n;new vr(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),s=l.toA,a=l.toB}}},Ko=class{constructor(e,r,n){this.view=e,this.state=r,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Ae.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let i=[];this.changes.iterChangedRanges((s,a,l,c)=>i.push(new vr(s,a,l,c))),this.changedRanges=i;let o=e.hasFocus;o!=e.inputState.notifiedFocused&&(e.inputState.notifiedFocused=o,this.flags|=1)}static create(e,r,n){return new Ko(e,r,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},ye=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(ye||(ye={})),Fd=ye.LTR,gA=ye.RTL;function Lb(t){let e=[];for(let r=0;r=r){if(a.level==n)return s;(o<0||(i!=0?i<0?a.fromr:e[o].level>a.level))&&(o=s)}}if(o<0)throw new RangeError("Index out of range");return o}},Se=[];function wA(t,e){let r=t.length,n=e==Fd?1:2,i=e==Fd?2:1;if(!t||n==1&&!vA.test(t))return Ib(r);for(let s=0,a=n,l=n;s=0;h-=3)if(jr[h+1]==-f){let d=jr[h+2],p=d&2?n:d&4?d&1?i:n:0;p&&(Se[s]=Se[jr[h]]=p),a=h;break}}else{if(jr.length==189)break;jr[a++]=s,jr[a++]=c,jr[a++]=l}else if((u=Se[s])==2||u==1){let h=u==n;l=h?0:1;for(let d=a-3;d>=0;d-=3){let p=jr[d+2];if(p&2)break;if(h)jr[d+2]|=2;else{if(p&4)break;jr[d+2]|=4}}}for(let s=0;sa;){let f=c,u=Se[--c]!=2;for(;c>a&&u==(Se[c-1]!=2);)c--;o.push(new Bn(c,f,u?2:1))}else o.push(new Bn(a,s,0))}else for(let s=0;s1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=s-1);n=o+s}}readNode(e){if(e.cmIgnore)return;let r=ve.get(e),n=r&&r.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let i=n.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.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,r){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==r&&(n.pos=this.text.length)}findPointInside(e,r){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+Math.min(r,n.offset))}};function L0(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}var of=class{constructor(e,r){this.node=e,this.offset=r,this.pos=-1}},sf=class extends ve{constructor(e){super(),this.view=e,this.compositionDeco=$.none,this.decorations=[],this.dynamicDecorationMap=[],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 Ye],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new vr(0,0,0,e.state.doc.length)],0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(e){let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:s,toA:a})=>athis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=$.none:(e.transactions.length||this.dirty)&&(this.compositionDeco=_A(this.view,e.changes)),(F.ie||F.chrome)&&!this.compositionDeco.size&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let n=this.decorations,i=this.updateDeco(),o=AA(n,i,e.changes);return r=vr.extendWithRanges(r,o),this.dirty==0&&r.length==0?!1:(this.updateInner(r,e.startState.doc.length),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,r){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,r);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";let o=F.chrome||F.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(o),this.dirty=0,o&&(o.written||n.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to=0?e[i]:null;if(!o)break;let{fromA:s,toA:a,fromB:l,toB:c}=o,{content:f,breakAtStart:u,openStart:h,openEnd:d}=Ta.build(this.view.state.doc,l,c,this.decorations,this.dynamicDecorationMap),{i:p,off:b}=n.findPos(a,1),{i:m,off:k}=n.findPos(s,-1);gb(this,m,k,p,b,f,u,h,d)}}updateSelection(e=!1,r=!1){if(e&&this.view.observer.readSelectionRange(),!(r||this.mayControlSelection())||F.ios&&this.view.inputState.rapidCompositionStart)return;let n=this.forceSelection;this.forceSelection=!1;let i=this.view.state.selection.main,o=this.domAtPos(i.anchor),s=i.empty?o:this.domAtPos(i.head);if(F.gecko&&i.empty&&SA(o)){let l=document.createTextNode("");this.view.observer.ignore(()=>o.node.insertBefore(l,o.node.childNodes[o.offset]||null)),o=s=new Fe(l,0),n=!0}let a=this.view.observer.selectionRange;(n||!a.focusNode||!Xc(o.node,o.offset,a.anchorNode,a.anchorOffset)||!Xc(s.node,s.offset,a.focusNode,a.focusOffset))&&(this.view.observer.ignore(()=>{F.android&&F.chrome&&this.dom.contains(a.focusNode)&&TA(a.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let l=Yc(this.root);if(i.empty){if(F.gecko){let c=CA(o.node,o.offset);if(c&&c!=3){let f=$b(o.node,o.offset,c==1?1:-1);f&&(o=new Fe(f,c==1?0:f.nodeValue.length))}}l.collapse(o.node,o.offset),i.bidiLevel!=null&&a.cursorBidiLevel!=null&&(a.cursorBidiLevel=i.bidiLevel)}else if(l.extend)l.collapse(o.node,o.offset),l.extend(s.node,s.offset);else{let c=document.createRange();i.anchor>i.head&&([o,s]=[s,o]),c.setEnd(s.node,s.offset),c.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(c)}}),this.view.observer.setSelectionRange(o,s)),this.impreciseAnchor=o.precise?null:new Fe(a.anchorNode,a.anchorOffset),this.impreciseHead=s.precise?null:new Fe(a.focusNode,a.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let e=this.view.state.selection.main,r=Yc(this.root);if(!e.empty||!e.assoc||!r.modify)return;let n=Ye.find(this,e.head);if(!n)return;let i=n.posAtStart;if(e.head==i||e.head==i+n.length)return;let o=this.coordsAt(e.head,-1),s=this.coordsAt(e.head,1);if(!o||!s||o.bottom>s.top)return;let a=this.domAtPos(e.head+e.assoc);r.collapse(a.node,a.offset),r.modify("move",e.assoc<0?"forward":"backward","lineboundary")}mayControlSelection(){return this.view.state.facet(Ma)?this.root.activeElement==this.dom:Rd(this.dom,this.view.observer.selectionRange)}nearest(e){for(let r=e;r;){let n=ve.get(r);if(n&&n.rootView==this)return n;r=r.parentNode}return null}posFromDOM(e,r){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,r)+n.posAtStart}domAtPos(e){let{i:r,off:n}=this.childCursor().findPos(e,-1);for(;rs||e==s&&o.type!=he.WidgetBefore&&o.type!=he.WidgetAfter&&(!i||r==2||this.children[i-1].breakAfter||this.children[i-1].type==he.WidgetBefore&&r>-2))return o.coordsAt(e-s,r);n=s}}measureVisibleLineHeights(e){let r=[],{from:n,to:i}=e,o=this.view.contentDOM.clientWidth,s=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==ye.LTR;for(let c=0,f=0;fi)break;if(c>=n){let d=u.dom.getBoundingClientRect();if(r.push(d.height),s){let p=u.dom.lastChild,b=p?Ca(p):[];if(b.length){let m=b[b.length-1],k=l?m.right-d.left:d.right-m.left;k>a&&(a=k,this.minWidth=o,this.minWidthFrom=c,this.minWidthTo=h)}}}c=h+u.breakAfter}return r}textDirectionAt(e){let{i:r}=this.childPos(e,1);return getComputedStyle(this.children[r].dom).direction=="rtl"?ye.RTL:ye.LTR}measureTextSize(){for(let i of this.children)if(i instanceof Ye){let o=i.measureTextSize();if(o)return o}let e=document.createElement("div"),r,n;return e.className="cm-line",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let i=Ca(e.firstChild)[0];r=e.getBoundingClientRect().height,n=i?i.width/27:7,e.remove()}),{lineHeight:r,charWidth:n}}childCursor(e=this.length){let r=this.children.length;return r&&(e-=this.children[--r].length),new ef(this.children,e,r)}computeBlockGapDeco(){let e=[],r=this.view.viewState;for(let n=0,i=0;;i++){let o=i==r.viewports.length?null:r.viewports[i],s=o?o.from-1:this.length;if(s>n){let a=r.lineBlockAt(s).bottom-r.lineBlockAt(n).top;e.push($.replace({widget:new af(a),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!o)break;n=o.to+1}return $.set(e)}updateDeco(){let e=this.view.state.facet(Oa).map((r,n)=>(this.dynamicDecorationMap[n]=typeof r=="function")?r(this.view):r);for(let r=e.length;rr.anchor?-1:1),i;if(!n)return;!r.empty&&(i=this.coordsAt(r.anchor,r.anchor>r.head?-1:1))&&(n={left:Math.min(n.left,i.left),top:Math.min(n.top,i.top),right:Math.max(n.right,i.right),bottom:Math.max(n.bottom,i.bottom)});let o=0,s=0,a=0,l=0;for(let f of this.view.state.facet(Pb).map(u=>u(this.view)))if(f){let{left:u,right:h,top:d,bottom:p}=f;u!=null&&(o=Math.max(o,u)),h!=null&&(s=Math.max(s,h)),d!=null&&(a=Math.max(a,d)),p!=null&&(l=Math.max(l,p))}let c={left:n.left-o,top:n.top-a,right:n.right+s,bottom:n.bottom+l};fA(this.view.scrollDOM,c,r.head0&&r<=0)t=t.childNodes[e-1],e=Qc(t);else if(t.nodeType==1&&e=0)t=t.childNodes[e],e=0;else return null}}function CA(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e0;){let c=mt(i.text,s,!1);if(n(i.text.slice(c,s))!=l)break;s=c}for(;at?e.left-t:Math.max(0,t-e.right)}function EA(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function wd(t,e){return t.tope.top+1}function I0(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Wd(t,e,r){let n,i,o,s,a,l,c,f;for(let d=t.firstChild;d;d=d.nextSibling){let p=Ca(d);for(let b=0;bS||s==S&&o>k)&&(n=d,i=m,o=k,s=S),k==0?r>m.bottom&&(!c||c.bottomm.top)&&(l=d,f=m):c&&wd(c,m)?c=B0(c,m.bottom):f&&wd(f,m)&&(f=I0(f,m.top))}}if(c&&c.bottom>=r?(n=a,i=c):f&&f.top<=r&&(n=l,i=f),!n)return{node:t,offset:0};let u=Math.max(i.left,Math.min(i.right,e));if(n.nodeType==3)return j0(n,u,r);if(!o&&n.contentEditable=="true")return Wd(n,u,r);let h=Array.prototype.indexOf.call(t.childNodes,n)+(e>=(i.left+i.right)/2?1:0);return{node:t,offset:h}}function j0(t,e,r){let n=t.nodeValue.length,i=-1,o=1e9,s=0;for(let a=0;ar?f.top-r:r-f.bottom)-1;if(f.left-1<=e&&f.right+1>=e&&u=(f.left+f.right)/2,d=h;if((F.chrome||F.gecko)&&Aa(t,a).getBoundingClientRect().left==f.right&&(d=!h),u<=0)return{node:t,offset:a+(d?1:0)};i=a+(d?1:0),o=u}}}return{node:t,offset:i>-1?i:s>0?t.nodeValue.length:0}}function zb(t,{x:e,y:r},n,i=-1){var o;let s=t.contentDOM.getBoundingClientRect(),a=s.top+t.viewState.paddingTop,l,{docHeight:c}=t.viewState,f=r-a;if(f<0)return 0;if(f>c)return t.state.doc.length;for(let k=t.defaultLineHeight/2,S=!1;l=t.elementAtHeight(f),l.type!=he.Text;)for(;f=i>0?l.bottom+k:l.top-k,!(f>=0&&f<=c);){if(S)return n?null:0;S=!0,i=-i}r=a+f;let u=l.from;if(ut.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:$0(t,s,l,e,r);let h=t.dom.ownerDocument,d=t.root.elementFromPoint?t.root:h,p=d.elementFromPoint(e,r);p&&!t.contentDOM.contains(p)&&(p=null),p||(e=Math.max(s.left+1,Math.min(s.right-1,e)),p=d.elementFromPoint(e,r),p&&!t.contentDOM.contains(p)&&(p=null));let b,m=-1;if(p&&((o=t.docView.nearest(p))===null||o===void 0?void 0:o.isEditable)!=!1){if(h.caretPositionFromPoint){let k=h.caretPositionFromPoint(e,r);k&&({offsetNode:b,offset:m}=k)}else if(h.caretRangeFromPoint){let k=h.caretRangeFromPoint(e,r);k&&({startContainer:b,startOffset:m}=k,F.safari&&MA(b,m,e)&&(b=void 0))}}if(!b||!t.docView.dom.contains(b)){let k=Ye.find(t.docView,u);if(!k)return f>l.top+l.height/2?l.to:l.from;({node:b,offset:m}=Wd(k.dom,e,r))}return t.docView.posFromDOM(b,m)}function $0(t,e,r,n,i){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&r.height>t.defaultLineHeight*1.5){let a=Math.floor((i-r.top)/t.defaultLineHeight);o+=a*t.viewState.heightOracle.lineLength}let s=t.state.sliceDoc(r.from,r.to);return r.from+Fc(s,o,t.state.tabSize)}function MA(t,e,r){let n;if(t.nodeType!=3||e!=(n=t.nodeValue.length))return!1;for(let i=t.nextSibling;i;i=i.nextSibling)if(i.nodeType!=1||i.nodeName!="BR")return!1;return Aa(t,n-1,n).getBoundingClientRect().left>r}function DA(t,e,r,n){let i=t.state.doc.lineAt(e.head),o=!n||!t.lineWrapping?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(o){let l=t.dom.getBoundingClientRect(),c=t.textDirectionAt(i.from),f=t.posAtCoords({x:r==(c==ye.LTR)?l.right-1:l.left+1,y:(o.top+o.bottom)/2});if(f!=null)return A.cursor(f,r?-1:1)}let s=Ye.find(t.docView,e.head),a=s?r?s.posAtEnd:s.posAtStart:r?i.to:i.from;return A.cursor(a,r?-1:1)}function z0(t,e,r,n){let i=t.state.doc.lineAt(e.head),o=t.bidiSpans(i),s=t.textDirectionAt(i.from);for(let a=e,l=null;;){let c=xA(i,o,s,a,r),f=Bb;if(!c){if(i.number==(r?t.state.doc.lines:1))return a;f=` -`,i=t.state.doc.line(i.number+(r?1:-1)),o=t.bidiSpans(i),c=A.cursor(r?i.from:i.to)}if(l){if(!l(f))return a}else{if(!n)return c;l=n(f)}a=c}}function NA(t,e,r){let n=t.state.charCategorizer(e),i=n(r);return o=>{let s=n(o);return i==je.Space&&(i=s),i==s}}function PA(t,e,r,n){let i=e.head,o=r?1:-1;if(i==(r?t.state.doc.length:0))return A.cursor(i,e.assoc);let s=e.goalColumn,a,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(i),f=t.documentTop;if(c)s==null&&(s=c.left-l.left),a=o<0?c.top:c.bottom;else{let d=t.viewState.lineBlockAt(i);s==null&&(s=Math.min(l.right-l.left,t.defaultCharacterWidth*(i-d.from))),a=(o<0?d.top:d.bottom)+f}let u=l.left+s,h=n??t.defaultLineHeight>>1;for(let d=0;;d+=10){let p=a+(h+d)*o,b=zb(t,{x:u,y:p},!1,o);if(pl.bottom||(o<0?bi))return A.cursor(b,e.assoc,void 0,s)}}function xd(t,e,r){let n=t.state.facet(Nb).map(i=>i(t));for(;;){let i=!1;for(let o of n)o.between(r.from-1,r.from+1,(s,a,l)=>{r.from>s&&r.fromr.from?A.cursor(s,1):A.cursor(a,-1),i=!0)});if(!i)return r}}var qd=class{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.rapidCompositionStart=!1,this.mouseSelection=null;for(let r in We){let n=We[r];e.contentDOM.addEventListener(r,i=>{!F0(e,i)||this.ignoreDuringComposition(i)||r=="keydown"&&this.keydown(e,i)||(this.mustFlushObserver(i)&&e.observer.forceFlush(),this.runCustomHandlers(r,e,i)?i.preventDefault():n(e,i))}),this.registeredEvents.push(r)}this.notifiedFocused=e.hasFocus,F.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,r){var n;let i;this.customHandlers=[];for(let o of r)if(i=(n=o.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:o.value,handlers:i});for(let s in i)this.registeredEvents.indexOf(s)<0&&s!="scroll"&&(this.registeredEvents.push(s),e.contentDOM.addEventListener(s,a=>{F0(e,a)&&this.runCustomHandlers(s,e,a)&&a.preventDefault()}))}}runCustomHandlers(e,r,n){for(let i of this.customHandlers){let o=i.handlers[e];if(o)try{if(o.call(i.plugin,n,r)||n.defaultPrevented)return!0}catch(s){at(r.state,s)}}return!1}runScrollHandlers(e,r){for(let n of this.customHandlers){let i=n.handlers.scroll;if(i)try{i.call(n.plugin,r,e)}catch(o){at(e.state,o)}}}keydown(e,r){if(this.lastKeyCode=r.keyCode,this.lastKeyTime=Date.now(),r.keyCode==9&&Date.now()i.keyCode==r.keyCode))&&!(r.ctrlKey||r.altKey||r.metaKey)&&!r.synthetic?(this.pendingIOSKey=n,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let r=this.pendingIOSKey;return r?(this.pendingIOSKey=void 0,va(e.contentDOM,r.key,r.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:F.safari&&Date.now()-this.compositionEndedAt<100?(this.compositionEndedAt=0,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229||e.type=="compositionend"&&!F.ios}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}},Fb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Vb=[16,17,18,20,91,92,224,225],Kd=class{constructor(e,r,n,i){this.view=e,this.style=n,this.mustSelect=i,this.lastEvent=r;let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=r.shiftKey,this.multiple=e.state.facet(G.allowMultipleSelections)&&LA(e,r),this.dragMove=IA(e,r),this.dragging=BA(e,r)&&mp(r)==1?null:!1,this.dragging===!1&&(r.preventDefault(),this.select(r))}move(e){if(e.buttons==0)return this.destroy();this.dragging===!1&&this.select(this.lastEvent=e)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(e){let r=this.style.get(e,this.extend,this.multiple);(this.mustSelect||!r.eq(this.view.state.selection)||r.main.assoc!=this.view.state.selection.main.assoc)&&this.view.dispatch({selection:r,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function LA(t,e){let r=t.state.facet(Cb);return r.length?r[0](e):F.mac?e.metaKey:e.ctrlKey}function IA(t,e){let r=t.state.facet(Ab);return r.length?r[0](e):F.mac?!e.altKey:!e.ctrlKey}function BA(t,e){let{main:r}=t.state.selection;if(r.empty)return!1;let n=Yc(t.root);if(n.rangeCount==0)return!0;let i=n.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function F0(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let r=e.target,n;r!=t.contentDOM;r=r.parentNode)if(!r||r.nodeType==11||(n=ve.get(r))&&n.ignoreEvent(e))return!1;return!0}var We=Object.create(null),Ub=F.ie&&F.ie_version<15||F.ios&&F.webkit_version<604;function jA(t){let e=t.dom.parentNode;if(!e)return;let r=e.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout(()=>{t.focus(),r.remove(),Hb(t,r.value)},50)}function Hb(t,e){let{state:r}=t,n,i=1,o=r.toText(e),s=o.lines==r.selection.ranges.length;if(Gd!=null&&r.selection.ranges.every(l=>l.empty)&&Gd==o.toString()){let l=-1;n=r.changeByRange(c=>{let f=r.doc.lineAt(c.from);if(f.from==l)return{range:c};l=f.from;let u=r.toText((s?o.line(i++).text:e)+r.lineBreak);return{changes:{from:f.from,insert:u},range:A.cursor(c.from+u.length)}})}else s?n=r.changeByRange(l=>{let c=o.line(i++);return{changes:{from:l.from,to:l.to,insert:c.text},range:A.cursor(l.from+c.length)}}):n=r.replaceSelection(o);t.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}We.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),e.keyCode==27?t.inputState.lastEscPress=Date.now():Vb.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0)};var Wb=0;We.touchstart=(t,e)=>{Wb=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};We.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};We.mousedown=(t,e)=>{if(t.observer.flush(),Wb>Date.now()-2e3&&mp(e)==1)return;let r=null;for(let n of t.state.facet(Tb))if(r=n(t,e),r)break;if(!r&&e.button==0&&(r=FA(t,e)),r){let n=t.root.activeElement!=t.contentDOM;n&&t.observer.ignore(()=>pb(t.contentDOM)),t.inputState.startMouseSelection(new Kd(t,e,r,n))}};function V0(t,e,r,n){if(n==1)return A.cursor(e,r);if(n==2)return OA(t.state,e,r);{let i=Ye.find(t.docView,e),o=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:o.from,a=i?i.posAtEnd:o.to;return at>=e.top&&t<=e.bottom,U0=(t,e,r)=>qb(e,r)&&t>=r.left&&t<=r.right;function $A(t,e,r,n){let i=Ye.find(t.docView,e);if(!i)return 1;let o=e-i.posAtStart;if(o==0)return 1;if(o==i.length)return-1;let s=i.coordsAt(o,-1);if(s&&U0(r,n,s))return-1;let a=i.coordsAt(o,1);return a&&U0(r,n,a)?1:s&&qb(n,s)?-1:1}function H0(t,e){let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:r,bias:$A(t,r,e.clientX,e.clientY)}}var zA=F.ie&&F.ie_version<=11,W0=null,q0=0,K0=0;function mp(t){if(!zA)return t.detail;let e=W0,r=K0;return W0=t,K0=Date.now(),q0=!e||r>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(q0+1)%3:1}function FA(t,e){let r=H0(t,e),n=mp(e),i=t.state.selection,o=r,s=e;return{update(a){a.docChanged&&(r&&(r.pos=a.changes.mapPos(r.pos)),i=i.map(a.changes),s=null)},get(a,l,c){let f;if(s&&a.clientX==s.clientX&&a.clientY==s.clientY?f=o:(f=o=H0(t,a),s=a),!f||!r)return i;let u=V0(t,f.pos,f.bias,n);if(r.pos!=f.pos&&!l){let h=V0(t,r.pos,r.bias,n),d=Math.min(h.from,u.from),p=Math.max(h.to,u.to);u=d{let{selection:{main:r}}=t.state,{mouseSelection:n}=t.inputState;n&&(n.dragging=r),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(r.from,r.to)),e.dataTransfer.effectAllowed="copyMove")};function G0(t,e,r,n){if(!r)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:o}=t.inputState,s=n&&o&&o.dragging&&o.dragMove?{from:o.dragging.from,to:o.dragging.to}:null,a={from:i,insert:r},l=t.state.changes(s?[s,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"})}We.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let r=e.dataTransfer.files;if(r&&r.length){e.preventDefault();let n=Array(r.length),i=0,o=()=>{++i==r.length&&G0(t,e,n.filter(s=>s!=null).join(t.state.lineBreak),!1)};for(let s=0;s{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[s]=a.result),o()},a.readAsText(r[s])}}else G0(t,e,e.dataTransfer.getData("Text"),!0)};We.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let r=Ub?null:e.clipboardData;r?(Hb(t,r.getData("text/plain")),e.preventDefault()):jA(t)};function VA(t,e){let r=t.dom.parentNode;if(!r)return;let n=r.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}function UA(t){let e=[],r=[],n=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),r.push(i));if(!e.length){let i=-1;for(let{from:o}of t.selection.ranges){let s=t.doc.lineAt(o);s.number>i&&(e.push(s.text),r.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),i=s.number}n=!0}return{text:e.join(t.lineBreak),ranges:r,linewise:n}}var Gd=null;We.copy=We.cut=(t,e)=>{let{text:r,ranges:n,linewise:i}=UA(t.state);if(!r&&!i)return;Gd=i?r:null;let o=Ub?null:e.clipboardData;o?(e.preventDefault(),o.clearData(),o.setData("text/plain",r)):VA(t,r),e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};function Kb(t){setTimeout(()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])},10)}We.focus=Kb;We.blur=t=>{t.observer.clearSelectionRange(),Kb(t)};function Gb(t,e){if(t.docView.compositionDeco.size){t.inputState.rapidCompositionStart=e;try{t.update([])}finally{t.inputState.rapidCompositionStart=!1}}}We.compositionstart=We.compositionupdate=t=>{t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0,t.docView.compositionDeco.size&&(t.observer.flush(),Gb(t,!0)))};We.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionFirstChange=null,setTimeout(()=>{t.inputState.composing<0&&Gb(t,!1)},50)};We.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};We.beforeinput=(t,e)=>{var r;let n;if(F.chrome&&F.android&&(n=Fb.find(i=>i.inputType==e.inputType))&&(t.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let i=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>i+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}};var Z0=["pre-wrap","normal","pre-line","break-spaces"],Zd=class{constructor(){this.doc=ee.empty,this.lineWrapping=!1,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(e,r){let n=this.doc.lineAt(r).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.ceil((r-e-n*this.lineLength*.5)/this.lineLength)),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Z0.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let r=!1;for(let n=0;n-1,a=Math.round(r)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=r,this.charWidth=n,this.lineLength=i,a){this.heightSamples={};for(let l=0;l0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,r){this.height!=r&&(Math.abs(this.height-r)>Gc&&(e.heightChanged=!0),this.height=r)}replace(e,r,n){return lt.of(n)}decomposeLeft(e,r){r.push(this)}decomposeRight(e,r){r.push(this)}applyChanges(e,r,n,i){let o=this;for(let s=i.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:f}=i[s],u=o.lineAt(a,ge.ByPosNoHeight,r,0,0),h=u.to>=l?u:o.lineAt(l,ge.ByPosNoHeight,r,0,0);for(f+=h.to-l,l=h.to;s>0&&u.from<=i[s-1].toA;)a=i[s-1].fromA,c=i[s-1].fromB,s--,ao*2){let a=e[r-1];a.break?e.splice(--r,1,a.left,null,a.right):e.splice(--r,1,a.left,a.right),n+=1+a.break,i-=a.size}else if(o>i*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,o-=a.size}else break;else if(i=o&&s(this.blockAt(0,n,i,o))}updateHeight(e,r=0,n=!1,i){return i&&i.from<=r&&i.more&&this.setHeight(e,i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},yt=class extends lf{constructor(e,r){super(e,r,he.Text),this.collapsed=0,this.widgetHeight=0}replace(e,r,n){let i=n[0];return n.length==1&&(i instanceof yt||i instanceof ze&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof ze?i=new yt(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):lt.of(n)}updateHeight(e,r=0,n=!1,i){return i&&i.from<=r&&i.more?this.setHeight(e,i.heights[i.index++]):(n||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},ze=class extends lt{constructor(e){super(e,0)}lines(e,r){let n=e.lineAt(r).number,i=e.lineAt(r+this.length).number;return{firstLine:n,lastLine:i,lineHeight:this.height/(i-n+1)}}blockAt(e,r,n,i){let{firstLine:o,lastLine:s,lineHeight:a}=this.lines(r,i),l=Math.max(0,Math.min(s-o,Math.floor((e-n)/a))),{from:c,length:f}=r.line(o+l);return new zr(c,f,n+a*l,a,he.Text)}lineAt(e,r,n,i,o){if(r==ge.ByHeight)return this.blockAt(e,n,i,o);if(r==ge.ByPosNoHeight){let{from:u,to:h}=n.lineAt(e);return new zr(u,h-u,0,0,he.Text)}let{firstLine:s,lineHeight:a}=this.lines(n,o),{from:l,length:c,number:f}=n.lineAt(e);return new zr(l,c,i+a*(f-s),a,he.Text)}forEachLine(e,r,n,i,o,s){let{firstLine:a,lineHeight:l}=this.lines(n,o);for(let c=Math.max(e,o),f=Math.min(o+this.length,r);c<=f;){let u=n.lineAt(c);c==e&&(i+=l*(u.number-a)),s(new zr(u.from,u.length,i,l,he.Text)),i+=l,c=u.to+1}}replace(e,r,n){let i=this.length-r;if(i>0){let o=n[n.length-1];o instanceof ze?n[n.length-1]=new ze(o.length+i):n.push(null,new ze(i-1))}if(e>0){let o=n[0];o instanceof ze?n[0]=new ze(e+o.length):n.unshift(new ze(e-1),null)}return lt.of(n)}decomposeLeft(e,r){r.push(new ze(e-1),null)}decomposeRight(e,r){r.push(null,new ze(this.length-e-1))}updateHeight(e,r=0,n=!1,i){let o=r+this.length;if(i&&i.from<=r+this.length&&i.more){let s=[],a=Math.max(r,i.from),l=-1,c=e.heightChanged;for(i.from>r&&s.push(new ze(i.from-r-1).updateHeight(e,r));a<=o&&i.more;){let u=e.doc.lineAt(a).length;s.length&&s.push(null);let h=i.heights[i.index++];l==-1?l=h:Math.abs(h-l)>=Gc&&(l=-2);let d=new yt(u,h);d.outdated=!1,s.push(d),a+=u+1}a<=o&&s.push(null,new ze(o-a).updateHeight(e,a));let f=lt.of(s);return e.heightChanged=c||l<0||Math.abs(f.height-this.height)>=Gc||Math.abs(l-this.lines(e.doc,r).lineHeight)>=Gc,f}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(r,r+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Yd=class extends lt{constructor(e,r,n){super(e.length+r+n.length,e.height+n.height,r|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,r,n,i){let o=n+this.left.height;return ea))return c;let f=r==ge.ByPosNoHeight?ge.ByPosNoHeight:ge.ByPos;return l?c.join(this.right.lineAt(a,f,n,s,a)):this.left.lineAt(a,f,n,i,o).join(c)}forEachLine(e,r,n,i,o,s){let a=i+this.left.height,l=o+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,r,n,a,l,s);else{let c=this.lineAt(l,ge.ByPos,n,i,o);e=e&&c.from<=r&&s(c),r>c.to&&this.right.forEachLine(c.to+1,r,n,a,l,s)}}replace(e,r,n){let i=this.left.length+this.break;if(rthis.left.length)return this.balanced(this.left,this.right.replace(e-i,r-i,n));let o=[];e>0&&this.decomposeLeft(e,o);let s=o.length;for(let a of n)o.push(a);if(e>0&&J0(o,s-1),r=n&&r.push(null)),e>n&&this.right.decomposeLeft(e-n,r)}decomposeRight(e,r){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,r);e2*r.size||r.size>2*e.size?lt.of(this.break?[e,null,r]:[e,r]):(this.left=e,this.right=r,this.height=e.height+r.height,this.outdated=e.outdated||r.outdated,this.size=e.size+r.size,this.length=e.length+this.break+r.length,this)}updateHeight(e,r=0,n=!1,i){let{left:o,right:s}=this,a=r+o.length+this.break,l=null;return i&&i.from<=r+o.length&&i.more?l=o=o.updateHeight(e,r,n,i):o.updateHeight(e,r,n),i&&i.from<=a+s.length&&i.more?l=s=s.updateHeight(e,a,n,i):s.updateHeight(e,a,n),l?this.balanced(o,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function J0(t,e){let r,n;t[e]==null&&(r=t[e-1])instanceof ze&&(n=t[e+1])instanceof ze&&t.splice(e-1,3,new ze(r.length+1+n.length))}var HA=5,Ra=class{constructor(e,r){this.pos=e,this.oracle=r,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,r){if(this.lineStart>-1){let n=Math.min(r,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof yt?i.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new yt(n-this.pos,-1)),this.writtenTo=n,r>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=r}point(e,r,n){if(e=HA)&&this.addLineDeco(i,o)}else r>e&&this.span(e,r);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:r}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=r,this.writtenToe&&this.nodes.push(new yt(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,r){let n=new ze(r-e);return this.oracle.doc.lineAt(e).to==r&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof yt)return e;let r=new yt(0,-1);return this.nodes.push(r),r}addBlock(e){this.enterLine(),e.type==he.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,e.type!=he.WidgetBefore&&(this.covering=e)}addLineDeco(e,r){let n=this.ensureLine();n.length+=r,n.collapsed+=r,n.widgetHeight=Math.max(n.widgetHeight,e),this.writtenTo=this.pos=this.pos+r}finish(e){let r=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(r instanceof yt)&&!this.isCovered?this.nodes.push(new yt(0,-1)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();n=Math.max(n,u.left),i=Math.min(i,u.right),o=Math.max(o,u.top),s=Math.min(s,u.bottom)}l=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(l.nodeType==11)l=l.host;else break;return{left:n-r.left,right:Math.max(n,i)-r.left,top:o-(r.top+e),bottom:Math.max(o,s)-(r.top+e)}}function KA(t,e){let r=t.getBoundingClientRect();return{left:0,right:r.right-r.left,top:e,bottom:r.bottom-(r.top+e)}}var xa=class{constructor(e,r,n){this.from=e,this.to=r,this.size=n}static same(e,r){if(e.length!=r.length)return!1;for(let n=0;ntypeof r!="function"),this.heightMap=lt.empty().applyChanges(this.stateDeco,ee.empty,this.heightOracle.setDoc(e.doc),[new vr(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(r=>r.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:r}=this.state.selection;for(let n=0;n<=1;n++){let i=n?r.head:r.anchor;if(!e.some(({from:o,to:s})=>i>=o&&i<=s)){let{from:o,to:s}=this.lineBlockAt(i);e.push(new Fo(o,s))}}this.viewports=e.sort((n,i)=>n.from-i.from),this.scaler=this.heightMap.height<=7e6?Q0:new ep(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:ya(e,this.scaler))})}update(e,r=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Oa).filter(c=>typeof c!="function");let i=e.changedRanges,o=vr.extendWithRanges(i,WA(n,this.stateDeco,e?e.changes:Ae.empty(this.state.doc.length))),s=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),this.heightMap.height!=s&&(e.flags|=2);let a=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(r&&(r.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,r));let l=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),l&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),r&&(this.scrollTarget=r),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(e){let r=e.contentDOM,n=window.getComputedStyle(r),i=this.heightOracle,o=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?ye.RTL:ye.LTR;let s=this.heightOracle.mustRefreshForWrapping(o),a=s||this.mustMeasureContent||this.contentDOMHeight!=r.clientHeight;this.contentDOMHeight=r.clientHeight,this.mustMeasureContent=!1;let l=0,c=0,f=parseInt(n.paddingTop)||0,u=parseInt(n.paddingBottom)||0;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,l|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=8);let h=(this.printing?KA:qA)(r,this.paddingTop),d=h.top-this.pixelViewport.top,p=h.bottom-this.pixelViewport.bottom;this.pixelViewport=h;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView)return 0;let m=r.clientWidth;if((this.contentDOMWidth!=m||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=m,this.editorHeight=e.scrollDOM.clientHeight,l|=8),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(S)&&(s=!0),s||i.lineWrapping&&Math.abs(m-this.contentDOMWidth)>i.charWidth){let{lineHeight:_,charWidth:w}=e.docView.measureTextSize();s=i.refresh(o,_,w,m/w,S),s&&(e.docView.minWidth=0,l|=8)}d>0&&p>0?c=Math.max(d,p):d<0&&p<0&&(c=Math.min(d,p)),i.heightChanged=!1;for(let _ of this.viewports){let w=_.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(_);this.heightMap=this.heightMap.updateHeight(i,0,s,new Jd(_.from,w))}i.heightChanged&&(l|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(l&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,r){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,o=this.state.doc,{visibleTop:s,visibleBottom:a}=this,l=new Fo(i.lineAt(s-n*1e3,ge.ByHeight,o,0,0).from,i.lineAt(a+(1-n)*1e3,ge.ByHeight,o,0,0).to);if(r){let{head:c}=r.range;if(cl.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=i.lineAt(c,ge.ByPos,o,0,0),h;r.y=="center"?h=(u.top+u.bottom)/2-f/2:r.y=="start"||r.y=="nearest"&&c=a+Math.max(10,Math.min(n,250)))&&i>s-2*1e3&&on.from&&a.push({from:n.from,to:o}),s=n.from&&l.from<=n.to&&X0(a,l.from-10,l.from+10),!l.empty&&l.to>=n.from&&l.to<=n.to&&X0(a,l.to-10,l.to+10);for(let{from:c,to:f}of a)f-c>1e3&&r.push(ZA(e,u=>u.from>=n.from&&u.to<=n.to&&Math.abs(u.from-c)<1e3&&Math.abs(u.to-f)<1e3)||new xa(c,f,this.gapSize(n,c,f,i)))}return r}gapSize(e,r,n,i){let o=Y0(i,n)-Y0(i,r);return this.heightOracle.lineWrapping?e.height*o:i.total*this.heightOracle.charWidth*o}updateLineGaps(e){xa.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=$.set(e.map(r=>r.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let r=[];te.spans(e,this.viewport.from,this.viewport.to,{span(i,o){r.push({from:i,to:o})},point(){}},20);let n=r.length!=this.visibleRanges.length||this.visibleRanges.some((i,o)=>i.from!=r[o].from||i.to!=r[o].to);return this.visibleRanges=r,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(r=>r.from<=e&&r.to>=e)||ya(this.heightMap.lineAt(e,ge.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(e){return ya(this.heightMap.lineAt(this.scaler.fromDOM(e),ge.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(e){return ya(this.heightMap.blockAt(this.scaler.fromDOM(e),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Fo=class{constructor(e,r){this.from=e,this.to=r}};function GA(t,e,r){let n=[],i=t,o=0;return te.spans(r,t,e,{span(){},point(s,a){s>i&&(n.push({from:i,to:s}),o+=s-i),i=a}},20),i=1)return e[e.length-1].to;let n=Math.floor(t*r);for(let i=0;;i++){let{from:o,to:s}=e[i],a=s-o;if(n<=a)return o+n;n-=a}}function Y0(t,e){let r=0;for(let{from:n,to:i}of t.ranges){if(e<=i){r+=e-n;break}r+=i-n}return r/t.total}function X0(t,e,r){for(let n=0;ne){let o=[];i.fromr&&o.push({from:r,to:i.to}),t.splice(n,1,...o),n+=o.length-1}}}function ZA(t,e){for(let r of t)if(e(r))return r}var Q0={toDOM(t){return t},fromDOM(t){return t},scale:1},ep=class{constructor(e,r,n){let i=0,o=0,s=0;this.viewports=n.map(({from:a,to:l})=>{let c=r.lineAt(a,ge.ByPos,e,0,0).top,f=r.lineAt(l,ge.ByPos,e,0,0).bottom;return i+=f-c,{from:a,to:l,top:c,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(r.height-i);for(let a of this.viewports)a.domTop=s+(a.top-o)*this.scale,s=a.domBottom=a.domTop+(a.bottom-a.top),o=a.bottom}toDOM(e){for(let r=0,n=0,i=0;;r++){let o=rya(i,e)):t.type)}var Kc=j.define({combine:t=>t.join(" ")}),tp=j.define({combine:t=>t.indexOf(!0)>-1}),rp=Gt.newName(),Zb=Gt.newName(),Jb=Gt.newName(),Yb={"&light":"."+Zb,"&dark":"."+Jb};function np(t,e,r){return new Gt(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,i=>{if(i=="&")return t;if(!r||!r[i])throw new RangeError(`Unsupported selector: ${i}`);return r[i]}):t+" "+n}})}var JA=np("."+rp,{"&.cm-editor":{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,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",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"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor, .cm-dropCursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{display:"flex",height:"100%",boxSizing:"border-box",left: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",display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".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"}},Yb),YA={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Sd=F.ie&&F.ie_version<=11,ip=class{constructor(e,r,n){this.view=e,this.onChange=r,this.onScrollChanged=n,this.active=!1,this.selectionRange=new Md,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.scrollTargets=[],this.intersection=null,this.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(i=>{for(let o of i)this.queue.push(o);(F.ie&&F.ie_version<=11||F.ios&&e.composing)&&i.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Sd&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),window.addEventListener("resize",this.onResize=this.onResize.bind(this)),typeof ResizeObserver=="function"&&(this.resize=new ResizeObserver(()=>{this.view.docView.lastUpdate{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),i.length>0&&i[i.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(i=>{i.length>0&&i[i.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange(),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}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((r,n)=>r!=e[n]))){this.gapIntersection.disconnect();for(let r of e)this.gapIntersection.observe(r);this.gaps=e}}onSelectionChange(e){if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,n=this.selectionRange;if(r.state.facet(Ma)?r.root.activeElement!=this.dom:!Rd(r.dom,n))return;let i=n.anchorNode&&r.docView.nearest(n.anchorNode);i&&i.ignoreEvent(e)||((F.ie&&F.ie_version<=11||F.android&&F.chrome)&&!r.state.selection.main.empty&&n.focusNode&&Xc(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1))}readSelectionRange(){let{root:e}=this.view,r=Yc(e),n=F.safari&&e.nodeType==11&&lA()==this.view.contentDOM&&XA(this.view)||r;return this.selectionRange.eq(n)?!1:(this.selectionRange.setRange(n),this.selectionChanged=!0)}setSelectionRange(e,r){this.selectionRange.set(e.node,e.offset,r.node,r.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,r=null;for(let n=this.dom;n;)if(n.nodeType==1)!r&&e{let n=this.delayedAndroidKey;this.delayedAndroidKey=null;let i=this.view.state;this.readSelectionRange(),va(this.view.contentDOM,n.key,n.keyCode)?this.processRecords():this.flush(),this.view.state==i&&this.view.update([])}),(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:r})}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=window.setTimeout(()=>{this.delayedFlush=-1,this.flush()},20))}forceFlush(){this.delayedFlush>=0&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}processRecords(){let e=this.queue;for(let o of this.observer.takeRecords())e.push(o);e.length&&(this.queue=[]);let r=-1,n=-1,i=!1;for(let o of e){let s=this.readMutation(o);s&&(s.typeOver&&(i=!0),r==-1?{from:r,to:n}=s:(r=Math.min(s.from,r),n=Math.max(s.to,n)))}return{from:r,to:n,typeOver:i}}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return;e&&this.readSelectionRange();let{from:r,to:n,typeOver:i}=this.processRecords(),o=this.selectionChanged&&Rd(this.dom,this.selectionRange);if(r<0&&!o)return;this.selectionChanged=!1;let s=this.view.state;this.onChange(r,n,i),this.view.state==s&&this.view.update([])}readMutation(e){let r=this.view.docView.nearest(e.target);if(!r||r.ignoreMutation(e))return null;if(r.markDirty(e.type=="attributes"),e.type=="attributes"&&(r.dirty|=4),e.type=="childList"){let n=eb(r,e.previousSibling||e.target.previousSibling,-1),i=eb(r,e.nextSibling||e.target.nextSibling,1);return{from:n?r.posAfter(n):r.posAtStart,to:i?r.posBefore(i):r.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}destroy(){var e,r,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(r=this.gapIntersection)===null||r===void 0||r.disconnect(),(n=this.resize)===null||n===void 0||n.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("beforeprint",this.onPrint),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout)}};function eb(t,e,r){for(;e;){let n=ve.get(e);if(n&&n.parent==t)return n;let i=e.parentNode;e=i!=t.dom?i:r>0?e.nextSibling:e.previousSibling}return null}function XA(t){let e=null;function r(l){l.preventDefault(),l.stopImmediatePropagation(),e=l.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),!e)return null;let n=e.startContainer,i=e.startOffset,o=e.endContainer,s=e.endOffset,a=t.docView.domAtPos(t.state.selection.main.anchor);return Xc(a.node,a.offset,o,s)&&([n,i,o,s]=[o,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:o,focusOffset:s}}function QA(t,e,r,n){let i,o,s=t.state.selection.main;if(e>-1){let a=t.docView.domBoundsAround(e,r,0);if(!a||t.state.readOnly)return;let{from:l,to:c}=a,f=t.docView.impreciseHead||t.docView.impreciseAnchor?[]:t2(t),u=new nf(f,t.state);u.readRange(a.startDOM,a.endDOM);let h=s.from,d=null;(t.inputState.lastKeyCode===8&&t.inputState.lastKeyTime>Date.now()-100||F.android&&u.text.length=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:F.mac&&i&&i.from==i.to&&i.from==s.head-1&&i.insert.toString()=="."&&(i={from:s.from,to:s.to,insert:ee.of([" "])}),i){let a=t.state;if(F.ios&&t.inputState.flushIOSKey(t)||F.android&&(i.from==s.from&&i.to==s.to&&i.insert.length==1&&i.insert.lines==2&&va(t.contentDOM,"Enter",13)||i.from==s.from-1&&i.to==s.to&&i.insert.length==0&&va(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&i.insert.length==0&&va(t.contentDOM,"Delete",46)))return;let l=i.insert.toString();if(t.state.facet(Rb).some(u=>u(t,i.from,i.to,l)))return;t.inputState.composing>=0&&t.inputState.composing++;let c;if(i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!o||o.main.empty&&o.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let u=s.fromi.to?a.sliceDoc(i.to,s.to):"";c=a.replaceSelection(t.state.toText(u+i.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let u=a.changes(i),h=o&&!a.selection.main.eq(o.main)&&o.main.to<=u.newLength?o.main:void 0;if(a.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let d=t.state.sliceDoc(i.from,i.to),p=jb(t)||t.state.doc.lineAt(s.head),b=s.to-i.to,m=s.to-s.from;c=a.changeByRange(k=>{if(k.from==s.from&&k.to==s.to)return{changes:u,range:h||k.map(u)};let S=k.to-b,_=S-d.length;if(k.to-k.from!=m||t.state.sliceDoc(_,S)!=d||p&&k.to>=p.from&&k.from<=p.to)return{range:k};let w=a.changes({from:_,to:S,insert:i.insert}),C=k.to-s.to;return{changes:w,range:h?A.range(Math.max(0,h.anchor+C),Math.max(0,h.head+C)):k.map(w)}})}else c={changes:u,selection:h&&a.selection.replaceRange(h)}}let f="input.type";t.composing&&(f+=".compose",t.inputState.compositionFirstChange&&(f+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(c,{scrollIntoView:!0,userEvent:f})}else if(o&&!o.main.eq(s)){let a=!1,l="select";t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(a=!0),l=t.inputState.lastSelectionOrigin),t.dispatch({selection:o,scrollIntoView:a,userEvent:l})}}}function e2(t,e,r,n){let i=Math.min(t.length,e.length),o=0;for(;o0&&a>0&&t.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if(n=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s=s?o-r:0;o-=l,a=o+(a-s),s=o}else if(a=a?o-r:0;o-=l,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function t2(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:o}=t.observer.selectionRange;return r&&(e.push(new of(r,n)),(i!=r||o!=n)&&e.push(new of(i,o))),e}function r2(t,e){if(t.length==0)return null;let r=t[0].pos,n=t.length==2?t[1].pos:r;return r>-1&&n>-1?A.single(r+e,n+e):null}var B=class{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.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(r=>this.update([r])),this.dispatch=this.dispatch.bind(this),this.root=e.root||uA(e.parent)||document,this.viewState=new cf(e.state||G.create()),this.plugins=this.state.facet(ma).map(r=>new wa(r));for(let r of this.plugins)r.update(this);this.observer=new ip(this,(r,n,i)=>{QA(this,r,n,i)},r=>{this.inputState.runScrollHandlers(this,r),this.observer.intersecting&&this.measure()}),this.inputState=new qd(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new sf(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}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}dispatch(...e){this._dispatch(e.length==1&&e[0]instanceof Te?e[0]:this.state.update(...e))}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let r=!1,n=!1,i,o=this.state;for(let a of e){if(a.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=a.state}if(this.destroyed){this.viewState.state=o;return}if(o.facet(G.phrases)!=this.state.facet(G.phrases))return this.setState(o);i=Ko.create(this,o,e);let s=this.viewState.scrollTarget;try{this.updateState=2;for(let a of e){if(s&&(s=s.map(a.changes)),a.scrollIntoView){let{main:l}=a.state.selection;s=new qo(l.empty?l:A.cursor(l.head,l.head>l.anchor?-1:1))}for(let l of a.effects)l.is(P0)&&(s=l.value)}this.viewState.update(i,s),this.bidiCache=Go.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),r=this.docView.update(i),this.state.facet(ga)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(r,e.some(a=>a.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Kc)!=i.state.facet(Kc)&&(this.viewState.mustMeasureContent=!0),(r||n||s||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!i.empty)for(let a of this.state.facet(zd))a(i)}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 r=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new cf(e),this.plugins=e.facet(ma).map(n=>new wa(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new sf(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}r&&this.focus(),this.requestMeasure()}updatePlugins(e){let r=e.startState.facet(ma),n=e.state.facet(ma);if(r!=n){let i=[];for(let o of n){let s=r.indexOf(o);if(s<0)i.push(new wa(o));else{let a=this.plugins[s];a.mustUpdate=e,i.push(a)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=i,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.flush();let r=null;try{for(let n=0;;n++){this.updateState=1;let i=this.viewport,o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(n>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let a=s.map(u=>{try{return u.read(this)}catch(h){return at(this.state,h),tb}}),l=Ko.create(this,this.state,[]),c=!1,f=!1;l.flags|=o,r?r.flags|=o:r=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),c=this.docView.update(l));for(let u=0;u{let i=jd(this.contentDOM,this.contentAttrs,r),o=jd(this.dom,this.editorAttrs,e);return i||o});return this.editorAttrs=e,this.contentAttrs=r,n}showAnnouncements(e){let r=!0;for(let n of e)for(let i of n.effects)if(i.is(B.announce)){r&&(this.announceDOM.textContent=""),r=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(ga),Gt.mount(this.root,this.styleModules.concat(JA).reverse())}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=requestAnimationFrame(()=>this.measure())),e){if(e.key!=null){for(let r=0;rn.spec==e)||null),r&&r.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}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,r,n){return xd(this,e,z0(this,e,r,n))}moveByGroup(e,r){return xd(this,e,z0(this,e,r,n=>NA(this,e.head,n)))}moveToLineBoundary(e,r,n=!0){return DA(this,e,r,n)}moveVertically(e,r,n){return xd(this,e,PA(this,e,r,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,r=0){return this.docView.posFromDOM(e,r)}posAtCoords(e,r=!0){return this.readMeasured(),zb(this,e,r)}coordsAtPos(e,r=1){this.readMeasured();let n=this.docView.coordsAt(e,r);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),o=this.bidiSpans(i),s=o[Bn.find(o,e-i.from,-1,r)];return mf(n,s.dir==ye.LTR==r>0)}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(Eb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>n2)return Ib(e.length);let r=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==r)return i.order;let n=wA(e.text,r);return this.bidiCache.push(new Go(e.from,e.to,r,n)),n}get hasFocus(){var e;return(document.hasFocus()||F.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{pb(this.contentDOM),this.docView.updateSelection()})}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,r={}){return P0.of(new qo(typeof e=="number"?A.cursor(e):e,r.y,r.x,r.yMargin,r.xMargin))}static domEventHandlers(e){return de.define(()=>({}),{eventHandlers:e})}static theme(e,r){let n=Gt.newName(),i=[Kc.of(n),ga.of(np(`.${n}`,e))];return r&&r.dark&&i.push(tp.of(!0)),i}static baseTheme(e){return hn.lowest(ga.of(np("."+rp,e,Yb)))}};B.styleModule=ga;B.inputHandler=Rb;B.perLineTextDirection=Eb;B.exceptionSink=Ob;B.updateListener=zd;B.editable=Ma;B.mouseSelectionStyle=Tb;B.dragMovesSelection=Ab;B.clickAddsSelectionRange=Cb;B.decorations=Oa;B.atomicRanges=Nb;B.scrollMargins=Pb;B.darkTheme=tp;B.contentAttributes=Db;B.editorAttributes=Mb;B.lineWrapping=B.contentAttributes.of({class:"cm-lineWrapping"});B.announce=W.define();var n2=4096,tb={},Go=class{constructor(e,r,n,i){this.from=e,this.to=r,this.dir=n,this.order=i}static update(e,r){if(r.empty)return e;let n=[],i=e.length?e[e.length-1].dir:ye.LTR;for(let o=Math.max(0,e.length-10);o=0;i--){let o=n[i],s=typeof o=="function"?o(t):o;s&&Bd(s,r)}return r}var i2=F.mac?"mac":F.windows?"win":F.linux?"linux":"key";function o2(t,e){let r=t.split(/-(?!$)/),n=r[r.length-1];n=="Space"&&(n=" ");let i,o,s,a;for(let l=0;ln.concat(i),[]))),r}function Qb(t,e,r){return ek(Xb(t.state),e,t,r)}var Ln=null,a2=4e3;function l2(t,e=i2){let r=Object.create(null),n=Object.create(null),i=(s,a)=>{let l=n[s];if(l==null)n[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},o=(s,a,l,c)=>{let f=r[s]||(r[s]=Object.create(null)),u=a.split(/ (?!$)/).map(p=>o2(p,e));for(let p=1;p{let k=Ln={view:m,prefix:b,scope:s};return setTimeout(()=>{Ln==k&&(Ln=null)},a2),!0}]})}let h=u.join(" ");i(h,!1);let d=f[h]||(f[h]={preventDefault:!1,commands:[]});d.commands.push(l),c&&(d.preventDefault=!0)};for(let s of t){let a=s[e]||s.key;if(a)for(let l of s.scope?s.scope.split(" "):["editor"])o(l,a,s.run,s.preventDefault),s.shift&&o(l,"Shift-"+a,s.shift,s.preventDefault)}return r}function ek(t,e,r,n){let i=T0(e),o=i.length==1&&i!=" ",s="",a=!1;Ln&&Ln.view==r&&Ln.scope==n&&(s=Ln.prefix+" ",(a=Vb.indexOf(e.keyCode)<0)&&(Ln=null));let l=u=>{if(u){for(let h of u.commands)if(h(r))return!0;u.preventDefault&&(a=!0)}return!1},c=t[n],f;if(c){if(l(c[s+_d(i,e,!o)]))return!0;if(o&&(e.shiftKey||e.altKey||e.metaKey)&&(f=dn[e.keyCode])&&f!=i){if(l(c[s+_d(f,e,!0)]))return!0}else if(o&&e.shiftKey&&l(c[s+_d(i,e,!0)]))return!0}return a}var tk=!F.ios,ba=j.define({combine(t){return gt(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,r)=>Math.min(e,r),drawRangeCursor:(e,r)=>e||r})}});function rk(t={}){return[ba.of(t),c2,f2]}var ff=class{constructor(e,r,n,i,o){this.left=e,this.top=r,this.width=n,this.height=i,this.className=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width>=0&&(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}},c2=de.fromClass(class{constructor(t){this.view=t,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=t.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=t.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),t.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(ba).cursorBlinkRate+"ms"}update(t){let e=t.startState.facet(ba)!=t.state.facet(ba);(e||t.selectionSet||t.geometryChanged||t.viewportChanged)&&this.view.requestMeasure(this.measureReq),t.transactions.some(r=>r.scrollIntoView)&&(this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}readPos(){let{state:t}=this.view,e=t.facet(ba),r=t.selection.ranges.map(i=>i.empty?[]:u2(this.view,i)).reduce((i,o)=>i.concat(o)),n=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty?!o||tk:e.drawRangeCursor){let s=h2(this.view,i,o);s&&n.push(s)}}return{rangePieces:r,cursors:n}}drawSel({rangePieces:t,cursors:e}){if(t.length!=this.rangePieces.length||t.some((r,n)=>!r.eq(this.rangePieces[n]))){this.selectionLayer.textContent="";for(let r of t)this.selectionLayer.appendChild(r.draw());this.rangePieces=t}if(e.length!=this.cursors.length||e.some((r,n)=>!r.eq(this.cursors[n]))){let r=this.cursorLayer.children;if(r.length!==e.length){this.cursorLayer.textContent="";for(let n of e)this.cursorLayer.appendChild(n.draw())}else e.forEach((n,i)=>n.adjust(r[i]));this.cursors=e}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}}),nk={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};tk&&(nk[".cm-line"].caretColor="transparent !important");var f2=hn.highest(B.theme(nk));function ik(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==ye.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function ib(t,e,r){let n=A.cursor(e);return{from:Math.max(r.from,t.moveToLineBoundary(n,!1,!0).from),to:Math.min(r.to,t.moveToLineBoundary(n,!0,!0).from),type:he.Text}}function ob(t,e){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){for(let n of r.type)if(n.to>e||n.to==e&&(n.to==r.to||n.type==he.Text))return n}return r}function u2(t,e){if(e.to<=t.viewport.from||e.from>=t.viewport.to)return[];let r=Math.max(e.from,t.viewport.from),n=Math.min(e.to,t.viewport.to),i=t.textDirection==ye.LTR,o=t.contentDOM,s=o.getBoundingClientRect(),a=ik(t),l=window.getComputedStyle(o.firstChild),c=s.left+parseInt(l.paddingLeft)+Math.min(0,parseInt(l.textIndent)),f=s.right-parseInt(l.paddingRight),u=ob(t,r),h=ob(t,n),d=u.type==he.Text?u:null,p=h.type==he.Text?h:null;if(t.lineWrapping&&(d&&(d=ib(t,r,d)),p&&(p=ib(t,n,p))),d&&p&&d.from==p.from)return m(k(e.from,e.to,d));{let _=d?k(e.from,null,d):S(u,!1),w=p?k(null,e.to,p):S(h,!0),C=[];return(d||u).to<(p||h).from-1?C.push(b(c,_.bottom,f,w.top)):_.bottomM&&ae.from=ot)break;Ze>me&&O(Math.max(st,me),_==null&&st<=M,Math.min(Ze,ot),w==null&&Ze>=I,Me.dir)}if(me=Be.to+1,me>=ot)break}return T.length==0&&O(M,_==null,I,w==null,t.textDirection),{top:R,bottom:x,horizontal:T}}function S(_,w){let C=s.top+(w?_.top:_.bottom);return{top:C,bottom:C,horizontal:[]}}}function h2(t,e,r){let n=t.coordsAtPos(e.head,e.assoc||1);if(!n)return null;let i=ik(t);return new ff(n.left-i.left,n.top-i.top,-1,n.bottom-n.top,r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}var ok=W.define({map(t,e){return t==null?null:e.mapPos(t)}}),ka=ce.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((r,n)=>n.is(ok)?n.value:r,t)}}),d2=de.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let r=t.state.field(ka);r==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(ka)!=r||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let t=this.view.state.field(ka),e=t!=null&&this.view.coordsAtPos(t);if(!e)return null;let r=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-r.left+this.view.scrollDOM.scrollLeft,top:e.top-r.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(t){this.cursor&&(t?(this.cursor.style.left=t.left+"px",this.cursor.style.top=t.top+"px",this.cursor.style.height=t.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(ka)!=t&&this.view.dispatch({effects:ok.of(t)})}},{eventHandlers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function sk(){return[ka,d2]}function sb(t,e,r,n,i){e.lastIndex=0;for(let o=t.iterRange(r,n),s=r,a;!o.next().done;s+=o.value.length)if(!o.lineBreak)for(;a=e.exec(o.value);)i(s+a.index,s+a.index+a[0].length,a)}function p2(t,e){let r=t.visibleRanges;if(r.length==1&&r[0].from==t.viewport.from&&r[0].to==t.viewport.to)return r;let n=[];for(let{from:i,to:o}of r)i=Math.max(t.state.doc.lineAt(i).from,i-e),o=Math.min(t.state.doc.lineAt(o).to,o+e),n.length&&n[n.length-1].to>=i?n[n.length-1].to=o:n.push({from:i,to:o});return n}var op=class{constructor(e){let{regexp:r,decoration:n,boundary:i,maxLength:o=1e3}=e;if(!r.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=r,this.getDeco=typeof n=="function"?n:()=>n,this.boundary=i,this.maxLength=o}createDeco(e){let r=new Mt;for(let{from:n,to:i}of p2(e,this.maxLength))sb(e.state.doc,this.regexp,n,i,(o,s,a)=>r.add(o,s,this.getDeco(a,e,o)));return r.finish()}updateDeco(e,r){let n=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((o,s,a,l)=>{l>e.view.viewport.from&&a1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,r.map(e.changes),n,i):r}updateRange(e,r,n,i){for(let o of e.visibleRanges){let s=Math.max(o.from,n),a=Math.min(o.to,i);if(a>s){let l=e.state.doc.lineAt(s),c=l.tol.from;s--)if(this.boundary.test(l.text[s-1-l.from])){f=s;break}for(;ah.push(this.getDeco(m,e,p).range(p,b)));r=r.update({filterFrom:f,filterTo:u,filter:(p,b)=>pu,add:h})}}return r}},sp=/x/.unicode!=null?"gu":"g",m2=new RegExp(`[\0-\b --\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\uFEFF\uFFF9-\uFFFC]`,sp),g2={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",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},Cd=null;function y2(){var t;if(Cd==null&&typeof document<"u"&&document.body){let e=document.body.style;Cd=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return Cd||!1}var Zc=j.define({combine(t){let e=gt(t,{render:null,specialChars:m2,addSpecialChars:null});return(e.replaceTabs=!y2())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,sp)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,sp)),e}});function ak(t={}){return[Zc.of(t),b2()]}var ab=null;function b2(){return ab||(ab=de.fromClass(class{constructor(t){this.view=t,this.decorations=$.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Zc)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new op({regexp:t.specialChars,decoration:(e,r,n)=>{let{doc:i}=r.state,o=$e(e[0],0);if(o==9){let s=i.lineAt(n),a=r.state.tabSize,l=Pn(s.text,a,n-s.from);return $.replace({widget:new lp((a-l%a)*this.view.defaultCharacterWidth)})}return this.decorationCache[o]||(this.decorationCache[o]=$.replace({widget:new ap(t,o)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Zc);t.startState.facet(Zc)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}var k2="\u2022";function v2(t){return t>=32?k2:t==10?"\u2424":String.fromCharCode(9216+t)}var ap=class extends Nt{constructor(e,r){super(),this.options=e,this.code=r}eq(e){return e.code==this.code}toDOM(e){let r=v2(this.code),n=e.state.phrase("Control character")+" "+(g2[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,n,r);if(i)return i;let o=document.createElement("span");return o.textContent=r,o.title=n,o.setAttribute("aria-label",n),o.className="cm-specialChar",o}ignoreEvent(){return!1}},lp=class extends Nt{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 lk(){return x2}var w2=$.line({class:"cm-activeLine"}),x2=de.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,r=[];for(let n of t.state.selection.ranges){if(!n.empty)return $.none;let i=t.lineBlockAt(n.head);i.from>e&&(r.push(w2.range(i.from)),e=i.from)}return $.set(r)}},{decorations:t=>t.decorations});var cp=2e3;function S2(t,e,r){let n=Math.min(e.line,r.line),i=Math.max(e.line,r.line),o=[];if(e.off>cp||r.off>cp||e.col<0||r.col<0){let s=Math.min(e.off,r.off),a=Math.max(e.off,r.off);for(let l=n;l<=i;l++){let c=t.doc.line(l);c.length<=a&&o.push(A.range(c.from+s,c.to+a))}}else{let s=Math.min(e.col,r.col),a=Math.max(e.col,r.col);for(let l=n;l<=i;l++){let c=t.doc.line(l),f=Fc(c.text,s,t.tabSize,!0);if(f>-1){let u=Fc(c.text,a,t.tabSize);o.push(A.range(c.from+f,c.from+u))}}}return o}function _2(t,e){let r=t.coordsAtPos(t.viewport.from);return r?Math.round(Math.abs((r.left-e)/t.defaultCharacterWidth)):-1}function lb(t,e){let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(r),i=r-n.from,o=i>cp?-1:i==n.length?_2(t,e.clientX):Pn(n.text,t.state.tabSize,r-n.from);return{line:n.number,col:o,off:i}}function C2(t,e){let r=lb(t,e),n=t.state.selection;return r?{update(i){if(i.docChanged){let o=i.changes.mapPos(i.startState.doc.line(r.line).from),s=i.state.doc.lineAt(o);r={line:s.number,col:r.col,off:Math.min(r.off,s.length)},n=n.map(i.changes)}},get(i,o,s){let a=lb(t,i);if(!a)return n;let l=S2(t.state,r,a);return l.length?s?A.create(l.concat(n.ranges)):A.create(l):n}}:null}function ck(t){let e=t?.eventFilter||(r=>r.altKey&&r.button==0);return B.mouseSelectionStyle.of((r,n)=>e(n)?C2(r,n):null)}var A2={Alt:[18,t=>t.altKey],Control:[17,t=>t.ctrlKey],Shift:[16,t=>t.shiftKey],Meta:[91,t=>t.metaKey]},T2={style:"cursor: crosshair"};function fk(t={}){let[e,r]=A2[t.key||"Alt"],n=de.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventHandlers:{keydown(i){this.set(i.keyCode==e||r(i))},keyup(i){(i.keyCode==e||!r(i))&&this.set(!1)}}});return[n,B.contentAttributes.of(i=>{var o;return!((o=i.plugin(n))===null||o===void 0)&&o.isDown?T2:null})]}var Ad="-10000px",uf=class{constructor(e,r,n){this.facet=r,this.createTooltipView=n,this.input=e.state.facet(r),this.tooltips=this.input.filter(i=>i),this.tooltipViews=this.tooltips.map(n)}update(e){let r=e.state.facet(this.facet),n=r.filter(o=>o);if(r===this.input){for(let o of this.tooltipViews)o.update&&o.update(e);return!1}let i=[];for(let o=0;o{var e,r,n;return{position:F.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((r=t.find(i=>i.parent))===null||r===void 0?void 0:r.parent)||null,tooltipSpace:((n=t.find(i=>i.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||O2}}}),uk=de.fromClass(class{constructor(t){var e;this.view=t,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let r=t.state.facet(Td);this.position=r.position,this.parent=r.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new uf(t,Da,n=>this.createTooltip(n)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),(e=t.dom.ownerDocument.defaultView)===null||e===void 0||e.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t);e&&this.observeIntersection();let r=e||t.geometryChanged,n=t.state.facet(Td);if(n.position!=this.position){this.position=n.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;r=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);r=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);r&&this.maybeMeasure()}createTooltip(t){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",e.dom.appendChild(r)}return e.dom.style.position=this.position,e.dom.style.top=Ad,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;(t=this.view.dom.ownerDocument.defaultView)===null||t===void 0||t.removeEventListener("resize",this.measureSoon);for(let{dom:r}of this.manager.tooltipViews)r.remove();(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect();return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map((e,r)=>{let n=this.manager.tooltipViews[r];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Td).tooltipSpace(this.view)}}writeMeasure(t){let{editor:e,space:r}=t,n=[];for(let i=0;i=Math.min(e.bottom,r.bottom)||l.rightMath.min(e.right,r.right)+.1){a.style.top=Ad;continue}let f=o.arrow?s.dom.querySelector(".cm-tooltip-arrow"):null,u=f?7:0,h=c.right-c.left,d=c.bottom-c.top,p=s.offset||E2,b=this.view.textDirection==ye.LTR,m=c.width>r.right-r.left?b?r.left:r.right-c.width:b?Math.min(l.left-(f?14:0)+p.x,r.right-h):Math.max(r.left,l.left-h+(f?14:0)-p.x),k=!!o.above;!o.strictSide&&(k?l.top-(c.bottom-c.top)-p.yr.bottom)&&k==r.bottom-l.bottom>l.top-r.top&&(k=!k);let S=k?l.top-d-u-p.y:l.bottom+u+p.y,_=m+h;if(s.overlap!==!0)for(let w of n)w.left<_&&w.right>m&&w.topS&&(S=k?w.top-d-2-u:w.bottom+u+2);this.position=="absolute"?(a.style.top=S-t.parent.top+"px",a.style.left=m-t.parent.left+"px"):(a.style.top=S+"px",a.style.left=m+"px"),f&&(f.style.left=`${l.left+(b?p.x:-p.x)-(m+14-7)}px`),s.overlap!==!0&&n.push({left:m,top:S,right:_,bottom:S+d}),a.classList.toggle("cm-tooltip-above",k),a.classList.toggle("cm-tooltip-below",!k),s.positioned&&s.positioned()}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Ad}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),R2=B.baseTheme({".cm-tooltip":{zIndex:100},"&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"}}}),E2={x:0,y:0},Da=j.define({enables:[uk,R2]}),hf=j.define(),Ea=class{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new uf(e,hf,r=>this.createHostedView(r))}static create(e){return new Ea(e)}createHostedView(e){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(r.dom),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let r of this.manager.tooltipViews)r.mount&&r.mount(e);this.mounted=!0}positioned(){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned()}update(e){this.manager.update(e)}},M2=Da.compute([hf],t=>{let e=t.facet(hf).filter(r=>r);return e.length===0?null:{pos:Math.min(...e.map(r=>r.pos)),end:Math.max(...e.filter(r=>r.end!=null).map(r=>r.end)),create:Ea.create,above:e[0].above,arrow:e.some(r=>r.arrow)}}),fp=class{constructor(e,r,n,i,o){this.view=e,this.source=r,this.field=n,this.setHover=i,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;en.bottom||e.xn.right+this.view.defaultCharacterWidth)return;let i=this.view.bidiSpans(this.view.state.doc.lineAt(r)).find(a=>a.from<=r&&a.to>=r),o=i&&i.dir==ye.RTL?-1:1,s=this.source(this.view,r,e.x{this.pending==a&&(this.pending=null,l&&this.view.dispatch({effects:this.setHover.of(l)}))},l=>at(this.view.state,l,"hover tooltip"))}else s&&this.view.dispatch({effects:this.setHover.of(s)})}mousemove(e){var r;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 n=this.active;if(n&&!D2(this.lastMove.target)||this.pending){let{pos:i}=n||this.pending,o=(r=n?.end)!==null&&r!==void 0?r:i;(i==o?this.view.posAtCoords(this.lastMove)!=i:!N2(this.view,i,o,e.clientX,e.clientY,6))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}};function D2(t){for(let e=t;e;e=e.parentNode)if(e.nodeType==1&&e.classList.contains("cm-tooltip"))return!0;return!1}function N2(t,e,r,n,i,o){let s=document.createRange(),a=t.domAtPos(e),l=t.domAtPos(r);s.setEnd(l.node,l.offset),s.setStart(a.node,a.offset);let c=s.getClientRects();s.detach();for(let f=0;fhf.from(i)});return[n,de.define(i=>new fp(i,t,n,r,e.hoverTime||300)),M2]}function dk(t,e){let r=t.plugin(uk);if(!r)return null;let n=r.manager.tooltips.indexOf(e);return n<0?null:r.manager.tooltipViews[n]}var P2=W.define();var cb=j.define({combine(t){let e,r;for(let n of t)e=e||n.topContainer,r=r||n.bottomContainer;return{topContainer:e,bottomContainer:r}}});function Bi(t,e){let r=t.plugin(pk),n=r?r.specs.indexOf(e):-1;return n>-1?r.panels[n]:null}var pk=de.fromClass(class{constructor(t){this.input=t.state.facet(Li),this.specs=this.input.filter(r=>r),this.panels=this.specs.map(r=>r(t));let e=t.state.facet(cb);this.top=new Vo(t,!0,e.topContainer),this.bottom=new Vo(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(r=>r.top)),this.bottom.sync(this.panels.filter(r=>!r.top));for(let r of this.panels)r.dom.classList.add("cm-panel"),r.mount&&r.mount()}update(t){let e=t.state.facet(cb);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Vo(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Vo(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let r=t.state.facet(Li);if(r!=this.input){let n=r.filter(l=>l),i=[],o=[],s=[],a=[];for(let l of n){let c=this.specs.indexOf(l),f;c<0?(f=l(t.view),a.push(f)):(f=this.panels[c],f.update&&f.update(t)),i.push(f),(f.top?o:s).push(f)}this.specs=n,this.panels=i,this.top.sync(o),this.bottom.sync(s);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>B.scrollMargins.of(e=>{let r=e.plugin(t);return r&&{top:r.top.scrollMargin(),bottom:r.bottom.scrollMargin()}})}),Vo=class{constructor(e,r,n){this.view=e,this.top=r,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let r of this.panels)r.destroy&&e.indexOf(r)<0&&r.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 r=this.container||this.view.dom;r.insertBefore(this.dom,this.top?r.firstChild:null)}let e=this.dom.firstChild;for(let r of this.panels)if(r.dom.parentNode==this.dom){for(;e!=r.dom;)e=fb(e);e=e.nextSibling}else this.dom.insertBefore(r.dom,e);for(;e;)e=fb(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 fb(t){let e=t.nextSibling;return t.remove(),e}var Li=j.define({enables:pk}),Pt=class extends kr{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Pt.prototype.elementClass="";Pt.prototype.toDOM=void 0;Pt.prototype.mapMode=Je.TrackBefore;Pt.prototype.startSide=Pt.prototype.endSide=-1;Pt.prototype.point=!0;var Jc=j.define(),L2={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>te.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Sa=j.define();function gp(t){return[mk(),Sa.of(Object.assign(Object.assign({},L2),t))]}var up=j.define({combine:t=>t.some(e=>e)});function mk(t){let e=[I2];return t&&t.fixed===!1&&e.push(up.of(!0)),e}var I2=de.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=t.state.facet(Sa).map(e=>new df(t,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!t.state.facet(up),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,r=t.view.viewport,n=Math.min(e.to,r.to)-Math.max(e.from,r.from);this.syncGutters(n<(r.to-r.from)*.8)}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(up)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let r=te.iter(this.view.state.facet(Jc),this.view.viewport.from),n=[],i=this.gutters.map(o=>new hp(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks){let s;if(Array.isArray(o.type)){for(let a of o.type)if(a.type==he.Text){s=a;break}}else s=o.type==he.Text?o:void 0;if(s){n.length&&(n=[]),gk(r,n,o.from);for(let a of i)a.line(this.view,s,n)}}for(let o of i)o.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(Sa),r=t.state.facet(Sa),n=t.docChanged||t.heightChanged||t.viewportChanged||!te.eq(t.startState.facet(Jc),t.state.facet(Jc),t.view.viewport.from,t.view.viewport.to);if(e==r)for(let i of this.gutters)i.update(t)&&(n=!0);else{n=!0;let i=[];for(let o of r){let s=e.indexOf(o);s<0?i.push(new df(this.view,o)):(this.gutters[s].update(t),i.push(this.gutters[s]))}for(let o of this.gutters)o.dom.remove(),i.indexOf(o)<0&&o.destroy();for(let o of i)this.dom.appendChild(o.dom);this.gutters=i}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>B.scrollMargins.of(e=>{let r=e.plugin(t);return!r||r.gutters.length==0||!r.fixed?null:e.textDirection==ye.LTR?{left:r.dom.offsetWidth}:{right:r.dom.offsetWidth}})});function ub(t){return Array.isArray(t)?t:[t]}function gk(t,e,r){for(;t.value&&t.from<=r;)t.from==r&&e.push(t.value),t.next()}var hp=class{constructor(e,r,n){this.gutter=e,this.height=n,this.localMarkers=[],this.i=0,this.cursor=te.iter(e.markers,r.from)}line(e,r,n){this.localMarkers.length&&(this.localMarkers=[]),gk(this.cursor,this.localMarkers,r.from);let i=n.length?this.localMarkers.concat(n):this.localMarkers,o=this.gutter.config.lineMarker(e,r,i);o&&i.unshift(o);let s=this.gutter;if(i.length==0&&!s.config.renderEmptyElements)return;let a=r.top-this.height;if(this.i==s.elements.length){let l=new pf(e,r.height,a,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,r.height,a,i);this.height=r.bottom,this.i++}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let r=e.elements.pop();e.dom.removeChild(r.dom),r.destroy()}}},df=class{constructor(e,r){this.view=e,this.config=r,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in r.domEventHandlers)this.dom.addEventListener(n,i=>{let o=e.lineBlockAtHeight(i.clientY-e.documentTop);r.domEventHandlers[n](e,o,i)&&i.preventDefault()});this.markers=ub(r.markers(e)),r.initialSpacer&&(this.spacer=new pf(e,0,0,[r.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let r=this.markers;if(this.markers=ub(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let n=e.view.viewport;return!te.eq(this.markers,r,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},pf=class{constructor(e,r,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,r,n,i)}update(e,r,n,i){this.height!=r&&(this.dom.style.height=(this.height=r)+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),B2(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,r){let n="cm-gutterElement",i=this.dom.firstChild;for(let o=0,s=0;;){let a=s,l=oo(a,l,c)||s(a,l,c):s}return n}})}}),_a=class extends Pt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Od(t,e){return t.state.facet(Uo).formatNumber(e,t.state)}var $2=Sa.compute([Uo],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(j2)},lineMarker(e,r,n){return n.some(i=>i.toDOM)?null:new _a(Od(e,e.state.doc.lineAt(r.from).number))},lineMarkerChange:e=>e.startState.facet(Uo)!=e.state.facet(Uo),initialSpacer(e){return new _a(Od(e,hb(e.state.doc.lines)))},updateSpacer(e,r){let n=Od(r.view,hb(r.view.state.doc.lines));return n==e.number?e:new _a(n)},domEventHandlers:t.facet(Uo).domEventHandlers}));function yk(t={}){return[Uo.of(t),mk(),$2]}function hb(t){let e=9;for(;e{let e=[],r=-1;for(let n of t.selection.ranges)if(n.empty){let i=t.doc.lineAt(n.head).from;i>r&&(r=i,e.push(z2.range(i)))}return te.of(e)});function bk(){return F2}var V2=0,Na=class{constructor(e,r){this.from=e,this.to=r}},Z=class{constructor(e={}){this.id=V2++,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=bt.match(e)),r=>{let n=e(r);return n===void 0?null:[this,n]}}};Z.closedBy=new Z({deserialize:t=>t.split(" ")});Z.openedBy=new Z({deserialize:t=>t.split(" ")});Z.group=new Z({deserialize:t=>t.split(" ")});Z.contextHash=new Z({perNode:!0});Z.lookAhead=new Z({perNode:!0});Z.mounted=new Z({perNode:!0});var U2=Object.create(null),bt=class{constructor(e,r,n,i=0){this.name=e,this.props=r,this.id=n,this.flags=i}static define(e){let r=e.props&&e.props.length?Object.create(null):U2,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new bt(e.name||"",r,e.id,n);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(i)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");r[o[0].id]=o[1]}}return i}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 r=this.prop(Z.group);return r?r.indexOf(e)>-1:!1}return this.id==e}static match(e){let r=Object.create(null);for(let n in e)for(let i of n.split(" "))r[i]=e[n];return n=>{for(let i=n.prop(Z.group),o=-1;o<(i?i.length:0);o++){let s=r[o<0?n.name:i[o]];if(s)return s}}}};bt.none=new bt("",Object.create(null),0,8);var yf=new WeakMap,kk=new WeakMap,Xe;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(Xe||(Xe={}));var Ve=class{constructor(e,r,n,i,o){if(this.type=e,this.children=r,this.positions=n,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);for(let[s,a]of o)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=this.prop(Z.mounted);if(e&&!e.overlay)return e.tree.toString();let r="";for(let n of this.children){let i=n.toString();i&&(r&&(r+=","),r+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(r.length?"("+r+")":""):r}cursor(e=0){return new Jo(this.topNode,e)}cursorAt(e,r=0,n=0){let i=yf.get(this)||this.topNode,o=new Jo(i);return o.moveTo(e,r),yf.set(this,o._tree),o}get topNode(){return new wr(this,0,0,null)}resolve(e,r=0){let n=Zo(yf.get(this)||this.topNode,e,r,!1);return yf.set(this,n),n}resolveInner(e,r=0){let n=Zo(kk.get(this)||this.topNode,e,r,!0);return kk.set(this,n),n}iterate(e){let{enter:r,leave:n,from:i=0,to:o=this.length}=e;for(let s=this.cursor((e.mode||0)|Xe.IncludeAnonymous);;){let a=!1;if(s.from<=o&&s.to>=i&&(s.type.isAnonymous||r(s)!==!1)){if(s.firstChild())continue;a=!0}for(;a&&n&&!s.type.isAnonymous&&n(s),!s.nextSibling();){if(!s.parent())return;a=!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 r in this.props)e.push([+r,this.props[r]]);return e}balance(e={}){return this.children.length<=8?this:vp(bt.none,this.children,this.positions,0,this.children.length,0,this.length,(r,n,i)=>new Ve(this.type,r,n,i,this.propValues),e.makeTree||((r,n,i)=>new Ve(bt.none,r,n,i)))}static build(e){return H2(e)}};Ve.empty=new Ve(bt.none,[],[],0);var Pa=class{constructor(e,r){this.buffer=e,this.index=r}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 Pa(this.buffer,this.index)}},gn=class{constructor(e,r,n){this.buffer=e,this.length=r,this.set=n}get type(){return bt.none}toString(){let e=[];for(let r=0;r0));l=s[l+3]);return a}slice(e,r,n,i){let o=this.buffer,s=new Uint16Array(r-e);for(let a=e,l=0;a=e&&re;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function xk(t,e){let r=t.childBefore(e);for(;r;){let n=r.lastChild;if(!n||n.to!=r.to)break;n.type.isError&&n.from==n.to?(t=r,r=n.prevSibling):r=n}return t}function Zo(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to0?a.length:-1;e!=c;e+=r){let f=a[e],u=l[e]+s.from;if(wk(i,n,u,u+f.length)){if(f instanceof gn){if(o&Xe.ExcludeBuffers)continue;let h=f.findChild(0,f.buffer.length,r,n-u,i);if(h>-1)return new Vr(new yp(s,f,e,u),null,h)}else if(o&Xe.IncludeAnonymous||!f.type.isAnonymous||kp(f)){let h;if(!(o&Xe.IgnoreMounts)&&f.props&&(h=f.prop(Z.mounted))&&!h.overlay)return new wr(h.tree,u,e,s);let d=new wr(f,u,e,s);return o&Xe.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(r<0?f.children.length-1:0,r,n,i)}}}if(o&Xe.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+r:e=r<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,r,n=0){let i;if(!(n&Xe.IgnoreOverlays)&&(i=this._tree.prop(Z.mounted))&&i.overlay){let o=e-this.from;for(let{from:s,to:a}of i.overlay)if((r>0?s<=o:s=o:a>o))return new wr(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,r,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new Jo(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,r=0){return Zo(this,e,r,!1)}resolveInner(e,r=0){return Zo(this,e,r,!0)}enterUnfinishedNodesBefore(e){return xk(this,e)}getChild(e,r=null,n=null){let i=kf(this,e,r,n);return i.length?i[0]:null}getChildren(e,r=null,n=null){return kf(this,e,r,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return vf(this,e)}};function kf(t,e,r,n){let i=t.cursor(),o=[];if(!i.firstChild())return o;if(r!=null){for(;!i.type.is(r);)if(!i.nextSibling())return o}for(;;){if(n!=null&&i.type.is(n))return o;if(i.type.is(e)&&o.push(i.node),!i.nextSibling())return n==null?o:[]}}function vf(t,e,r=e.length-1){for(let n=t.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}var yp=class{constructor(e,r,n,i){this.parent=e,this.buffer=r,this.index=n,this.start=i}},Vr=class{constructor(e,r,n){this.context=e,this._parent=r,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}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]}child(e,r,n){let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],e,r-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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,r,n=0){if(n&Xe.ExcludeBuffers)return null;let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],r>0?1:-1,e-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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,r=e.buffer[this.index+3];return r<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,r):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,r=this._parent?this._parent.index+4:0;return this.index==r?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(r,this.index,-1,0,4))}cursor(e=0){return new Jo(this,e)}get tree(){return null}toTree(){let e=[],r=[],{buffer:n}=this.context,i=this.index+4,o=n.buffer[this.index+3];if(o>i){let s=n.buffer[this.index+1],a=n.buffer[this.index+2];e.push(n.slice(i,o,s,a)),r.push(0)}return new Ve(this.type,e,r,this.to-this.from)}resolve(e,r=0){return Zo(this,e,r,!1)}resolveInner(e,r=0){return Zo(this,e,r,!0)}enterUnfinishedNodesBefore(e){return xk(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,r=null,n=null){let i=kf(this,e,r,n);return i.length?i[0]:null}getChildren(e,r=null,n=null){return kf(this,e,r,n)}get node(){return this}matchContext(e){return vf(this,e)}},Jo=class{constructor(e,r=0){if(this.mode=r,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof wr)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,r){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=r||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return e?e instanceof wr?(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,r,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,r,n,this.mode));let{buffer:i}=this.buffer,o=i.findChild(this.index+4,i.buffer[this.index+3],e,r-this.buffer.start,n);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}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,r,n=this.mode){return this.buffer?n&Xe.ExcludeBuffers?!1:this.enterChild(1,e,r):this.yield(this._tree.enter(e,r,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Xe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Xe.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:r}=this.buffer,n=this.stack.length-1;if(e<0){let i=n<0?0:this.stack[n]+4;if(this.index!=i)return this.yieldBuf(r.findChild(i,this.index,-1,0,4))}else{let i=r.buffer[this.index+3];if(i<(n<0?r.buffer.length:r.buffer[this.stack[n]+3]))return this.yieldBuf(i)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let r,n,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let o=r+e,s=e<0?-1:n._tree.children.length;o!=s;o+=e){let a=n._tree.children[o];if(this.mode&Xe.IncludeAnonymous||a instanceof gn||!a.type.isAnonymous||kp(a))return!1}return!0}move(e,r){if(r&&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,r=0){for(;(this.from==this.to||(r<1?this.from>=e:this.from>e)||(r>-1?this.to<=e:this.to=0;){for(let s=e;s;s=s._parent)if(s.index==i){if(i==this.index)return s;r=s,n=o+1;break e}i=this.stack[--o]}for(let i=n;i=0;o--){if(o<0)return vf(this.node,e,i);let s=n[r.buffer[this.stack[o]]];if(!s.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}};function kp(t){return t.children.some(e=>e instanceof gn||!e.type.isAnonymous||kp(e))}function H2(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=1024,reused:o=[],minRepeatType:s=n.types.length}=t,a=Array.isArray(r)?new Pa(r,r.length):r,l=n.types,c=0,f=0;function u(w,C,R,x,T){let{id:O,start:M,end:I,size:ae}=a,me=f;for(;ae<0;)if(a.next(),ae==-1){let Ze=o[O];R.push(Ze),x.push(M-w);return}else if(ae==-3){c=O;return}else if(ae==-4){f=O;return}else throw new RangeError(`Unrecognized record size: ${ae}`);let ot=l[O],Be,Me,st=M-w;if(I-M<=i&&(Me=b(a.pos-C,T))){let Ze=new Uint16Array(Me.size-Me.skip),gr=a.pos-Me.size,un=Ze.length;for(;a.pos>gr;)un=m(Me.start,Ze,un);Be=new gn(Ze,I-Me.start,n),st=Me.start-w}else{let Ze=a.pos-ae;a.next();let gr=[],un=[],Oi=O>=s?O:-1,No=0,Ec=I;for(;a.pos>Ze;)Oi>=0&&a.id==Oi&&a.size>=0?(a.end<=Ec-i&&(d(gr,un,M,No,a.end,Ec,Oi,me),No=gr.length,Ec=a.end),a.next()):u(M,Ze,gr,un,Oi);if(Oi>=0&&No>0&&No-1&&No>0){let Yy=h(ot);Be=vp(ot,gr,un,0,gr.length,0,I-M,Yy,Yy)}else Be=p(ot,gr,un,I-M,me-I)}R.push(Be),x.push(st)}function h(w){return(C,R,x)=>{let T=0,O=C.length-1,M,I;if(O>=0&&(M=C[O])instanceof Ve){if(!O&&M.type==w&&M.length==x)return M;(I=M.prop(Z.lookAhead))&&(T=R[O]+M.length+I)}return p(w,C,R,x,T)}}function d(w,C,R,x,T,O,M,I){let ae=[],me=[];for(;w.length>x;)ae.push(w.pop()),me.push(C.pop()+R-T);w.push(p(n.types[M],ae,me,O-T,I-O)),C.push(T-R)}function p(w,C,R,x,T=0,O){if(c){let M=[Z.contextHash,c];O=O?[M].concat(O):[M]}if(T>25){let M=[Z.lookAhead,T];O=O?[M].concat(O):[M]}return new Ve(w,C,R,x,O)}function b(w,C){let R=a.fork(),x=0,T=0,O=0,M=R.end-i,I={size:0,start:0,skip:0};e:for(let ae=R.pos-w;R.pos>ae;){let me=R.size;if(R.id==C&&me>=0){I.size=x,I.start=T,I.skip=O,O+=4,x+=4,R.next();continue}let ot=R.pos-me;if(me<0||ot=s?4:0,Me=R.start;for(R.next();R.pos>ot;){if(R.size<0)if(R.size==-3)Be+=4;else break e;else R.id>=s&&(Be+=4);R.next()}T=Me,x+=me,O+=Be}return(C<0||x==w)&&(I.size=x,I.start=T,I.skip=O),I.size>4?I:void 0}function m(w,C,R){let{id:x,start:T,end:O,size:M}=a;if(a.next(),M>=0&&x4){let ae=a.pos-(M-4);for(;a.pos>ae;)R=m(w,C,R)}C[--R]=I,C[--R]=O-w,C[--R]=T-w,C[--R]=x}else M==-3?c=x:M==-4&&(f=x);return R}let k=[],S=[];for(;a.pos>0;)u(t.start||0,t.bufferStart||0,k,S,-1);let _=(e=t.length)!==null&&e!==void 0?e:k.length?S[0]+k[0].length:0;return new Ve(l[t.topID],k.reverse(),S.reverse(),_)}var vk=new WeakMap;function bf(t,e){if(!t.isAnonymous||e instanceof gn||e.type!=t)return 1;let r=vk.get(e);if(r==null){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof Ve)){r=1;break}r+=bf(t,n)}vk.set(e,r)}return r}function vp(t,e,r,n,i,o,s,a,l){let c=0;for(let p=n;p=f)break;R+=x}if(_==w+1){if(R>f){let x=p[w];d(x.children,x.positions,0,x.children.length,b[w]+S);continue}u.push(p[w])}else{let x=b[_-1]+p[_-1].length-C;u.push(vp(t,p,b,w,_,C,x,null,l))}h.push(C+S-o)}}return d(e,r,n,i,0),(a||l)(u,h,s)}var Ur=class{constructor(e,r,n,i,o=!1,s=!1){this.from=e,this.to=r,this.tree=n,this.offset=i,this.open=(o?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,r=[],n=!1){let i=[new Ur(0,e.length,e,0,!1,n)];for(let o of r)o.to>e.length&&i.push(o);return i}static applyChanges(e,r,n=128){if(!r.length)return e;let i=[],o=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let f=a=n)for(;s&&s.from=h.from||u<=h.to||c){let d=Math.max(h.from,l)-c,p=Math.min(h.to,u)-c;h=d>=p?null:new Ur(d,p,h.tree,h.offset+c,a>0,!!f)}if(h&&i.push(h),s.to>u)break;s=onew Na(i.from,i.to)):[new Na(0,0)]:[new Na(0,e.length)],this.createParse(e,r||[],n)}parse(e,r,n){let i=this.startParse(e,r,n);for(;;){let o=i.advance();if(o)return o}}},bp=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,r){return this.string.slice(e,r)}};var sB=new Z({perNode:!0});var W2=0,Jt=class{constructor(e,r,n){this.set=e,this.base=r,this.modified=n,this.id=W2++}static define(e){if(e?.base)throw new Error("Can not derive from a modified tag");let r=new Jt([],null,[]);if(r.set.push(r),e)for(let n of e.set)r.set.push(n);return r}static defineModifier(){let e=new Yo;return r=>r.modified.indexOf(e)>-1?r:Yo.get(r.base||r,r.modified.concat(e).sort((n,i)=>n.id-i.id))}},q2=0,Yo=class{constructor(){this.instances=[],this.id=q2++}static get(e,r){if(!r.length)return e;let n=r[0].instances.find(a=>a.base==e&&K2(r,a.modified));if(n)return n;let i=[],o=new Jt(i,e,r);for(let a of r)a.instances.push(o);let s=Ck(r);for(let a of e.set)for(let l of s)i.push(Yo.get(a,l));return o}};function K2(t,e){return t.length==e.length&&t.every((r,n)=>r==e[n])}function Ck(t){let e=[t];for(let r=0;r0&&u+3==i.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(o.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),u+=h[0].length,u==i.length)break;let d=i[u++];if(u==i.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+i);a=i.slice(u)}let l=o.length-1,c=o[l];if(!c)throw new RangeError("Invalid path: "+i);let f=new xp(n,s,l>0?o.slice(0,l):null);e[c]=f.sort(e[c])}}return Tk.add(e)}var Tk=new Z,xp=class{constructor(e,r,n,i){this.tags=e,this.mode=r,this.context=n,this.next=i}sort(e){return!e||e.depth{let s=i;for(let a of o)for(let l of a.set){let c=r[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:n}}function G2(t,e){let r=null;for(let n of t){let i=n.style(e);i&&(r=r?r+" "+i:i)}return r}function Ok(t,e,r,n=0,i=t.length){let o=new Sp(n,Array.isArray(e)?e:[e],r);o.highlightRange(t.cursor(),n,i,"",o.highlighters),o.flush(i)}var Sp=class{constructor(e,r,n){this.at=e,this.highlighters=r,this.span=n,this.class=""}startSpan(e,r){r!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=r)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,r,n,i,o){let{type:s,from:a,to:l}=e;if(a>=n||l<=r)return;s.isTop&&(o=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=i,f=s.prop(Tk),u=!1;for(;f;){if(!f.context||e.matchContext(f.context)){let d=G2(o,f.tags);d&&(c&&(c+=" "),c+=d,f.mode==1?i+=(i?" ":"")+d:f.mode==0&&(u=!0));break}f=f.next}if(this.startSpan(e.from,c),u)return;let h=e.tree&&e.tree.prop(Z.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(m=>!m.scope||m.scope(h.tree.type)),b=e.firstChild();for(let m=0,k=a;;m++){let S=m=_||!e.nextSibling())););if(!S||_>n)break;k=S.to+a,k>r&&(this.highlightRange(d.cursor(),Math.max(r,S.from+a),Math.min(n,k),i,p),this.startSpan(k,c))}b&&e.parent()}else if(e.firstChild()){do if(!(e.to<=r)){if(e.from>=n)break;this.highlightRange(e,r,n,i,o),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}},D=Jt.define,xf=D(),$n=D(),Sk=D($n),_k=D($n),zn=D(),Sf=D(zn),wp=D(zn),qr=D(),ji=D(qr),Hr=D(),Wr=D(),_p=D(),La=D(_p),_f=D(),N={comment:xf,lineComment:D(xf),blockComment:D(xf),docComment:D(xf),name:$n,variableName:D($n),typeName:Sk,tagName:D(Sk),propertyName:_k,attributeName:D(_k),className:D($n),labelName:D($n),namespace:D($n),macroName:D($n),literal:zn,string:Sf,docString:D(Sf),character:D(Sf),attributeValue:D(Sf),number:wp,integer:D(wp),float:D(wp),bool:D(zn),regexp:D(zn),escape:D(zn),color:D(zn),url:D(zn),keyword:Hr,self:D(Hr),null:D(Hr),atom:D(Hr),unit:D(Hr),modifier:D(Hr),operatorKeyword:D(Hr),controlKeyword:D(Hr),definitionKeyword:D(Hr),moduleKeyword:D(Hr),operator:Wr,derefOperator:D(Wr),arithmeticOperator:D(Wr),logicOperator:D(Wr),bitwiseOperator:D(Wr),compareOperator:D(Wr),updateOperator:D(Wr),definitionOperator:D(Wr),typeOperator:D(Wr),controlOperator:D(Wr),punctuation:_p,separator:D(_p),bracket:La,angleBracket:D(La),squareBracket:D(La),paren:D(La),brace:D(La),content:qr,heading:ji,heading1:D(ji),heading2:D(ji),heading3:D(ji),heading4:D(ji),heading5:D(ji),heading6:D(ji),contentSeparator:D(qr),list:D(qr),quote:D(qr),emphasis:D(qr),strong:D(qr),link:D(qr),monospace:D(qr),strikethrough:D(qr),inserted:D(),deleted:D(),changed:D(),invalid:D(),meta:_f,documentMeta:D(_f),annotation:D(_f),processingInstruction:D(_f),definition:Jt.defineModifier(),constant:Jt.defineModifier(),function:Jt.defineModifier(),standard:Jt.defineModifier(),local:Jt.defineModifier(),special:Jt.defineModifier()},cB=Cp([{tag:N.link,class:"tok-link"},{tag:N.heading,class:"tok-heading"},{tag:N.emphasis,class:"tok-emphasis"},{tag:N.strong,class:"tok-strong"},{tag:N.keyword,class:"tok-keyword"},{tag:N.atom,class:"tok-atom"},{tag:N.bool,class:"tok-bool"},{tag:N.url,class:"tok-url"},{tag:N.labelName,class:"tok-labelName"},{tag:N.inserted,class:"tok-inserted"},{tag:N.deleted,class:"tok-deleted"},{tag:N.literal,class:"tok-literal"},{tag:N.string,class:"tok-string"},{tag:N.number,class:"tok-number"},{tag:[N.regexp,N.escape,N.special(N.string)],class:"tok-string2"},{tag:N.variableName,class:"tok-variableName"},{tag:N.local(N.variableName),class:"tok-variableName tok-local"},{tag:N.definition(N.variableName),class:"tok-variableName tok-definition"},{tag:N.special(N.variableName),class:"tok-variableName2"},{tag:N.definition(N.propertyName),class:"tok-propertyName tok-definition"},{tag:N.typeName,class:"tok-typeName"},{tag:N.namespace,class:"tok-namespace"},{tag:N.className,class:"tok-className"},{tag:N.macroName,class:"tok-macroName"},{tag:N.propertyName,class:"tok-propertyName"},{tag:N.operator,class:"tok-operator"},{tag:N.comment,class:"tok-comment"},{tag:N.meta,class:"tok-meta"},{tag:N.invalid,class:"tok-invalid"},{tag:N.punctuation,class:"tok-punctuation"}]);var Ap,Cf=new Z;var Yt=class{constructor(e,r,n=[]){this.data=e,G.prototype.hasOwnProperty("tree")||Object.defineProperty(G.prototype,"tree",{get(){return qe(this)}}),this.parser=r,this.extension=[Vn.of(this),G.languageData.of((i,o,s)=>i.facet(Rk(i,o,s)))].concat(n)}isActiveAt(e,r,n=-1){return Rk(e,r,n)==this.data}findRegions(e){let r=e.facet(Vn);if(r?.data==this.data)return[{from:0,to:e.doc.length}];if(!r||!r.allowsNesting)return[];let n=[],i=(o,s)=>{if(o.prop(Cf)==this.data){n.push({from:s,to:s+o.length});return}let a=o.prop(Z.mounted);if(a){if(a.tree.prop(Cf)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+s,to:l.to+s});else n.push({from:s,to:s+o.length});return}else if(a.overlay){let l=n.length;if(i(a.tree,a.overlay[0].from+s),n.length>l)return}}for(let l=0;l=this.cursorPos?this.doc.sliceString(e,r):this.string.slice(e-n,r-n)}},Ia=null,Xo=class{constructor(e,r,n=[],i,o,s,a,l){this.parser=e,this.state=r,this.fragments=n,this.tree=i,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,r,n){return new Xo(e,r,[],Ve.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Ep(this.state.doc),this.fragments)}work(e,r){return r!=null&&r>=this.state.doc.length&&(r=void 0),this.tree!=Ve.empty&&this.isDone(r??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),r!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>r)&&r=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(r=this.parse.advance()););}),this.treeLen=e,this.tree=r,this.fragments=this.withoutTempSkipped(Ur.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let r=Ia;Ia=this;try{return e()}finally{Ia=r}}withoutTempSkipped(e){for(let r;r=this.tempSkipped.pop();)e=Ek(e,r.from,r.to);return e}changes(e,r){let{fragments:n,tree:i,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,f,u,h)=>l.push({fromA:c,toA:f,fromB:u,toB:h})),n=Ur.applyChanges(n,l),i=Ve.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let f=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);fe.from&&(this.fragments=Ek(this.fragments,i,o),this.skipped.splice(n--,1))}return this.skipped.length>=r?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,r){this.skipped.push({from:e,to:r})}static getSkippingParser(e){return new class extends wf{createParse(r,n,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let l=Ia;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new Ve(bt.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let r=this.fragments;return this.treeLen>=e&&r.length&&r[0].from==0&&r[0].to>=e}static get(){return Ia}};function Ek(t,e,r){return Ur.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}var Fn=class{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let r=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),r.viewport.to);return r.work(20,n)||r.takeTree(),new Fn(r)}static init(e){let r=Math.min(3e3,e.doc.length),n=Xo.create(e.facet(Vn).parser,e,{from:0,to:r});return n.work(20,r)||n.takeTree(),new Fn(n)}};Yt.state=ce.define({create:Fn.init,update(t,e){for(let r of e.effects)if(r.is(Yt.setState))return r.value;return e.startState.facet(Vn)!=e.state.facet(Vn)?Fn.init(e.state):t.apply(e)}});var Nk=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Nk=t=>{let e=-1,r=setTimeout(()=>{e=requestIdleCallback(t,{timeout:500-100})},100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});var Tp=typeof navigator<"u"&&(!((Ap=navigator.scheduling)===null||Ap===void 0)&&Ap.isInputPending)?()=>navigator.scheduling.isInputPending():null,Z2=de.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 r=this.view.state.field(Yt.state).context;(r.updateViewport(e.view.viewport)||this.view.viewport.to>r.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(r)}scheduleWork(){if(this.working)return;let{state:e}=this.view,r=e.field(Yt.state);(r.tree!=r.context.tree||!r.context.isDone(e.doc.length))&&(this.working=Nk(this.work))}work(e){this.working=null;let r=Date.now();if(this.chunkEndi+1e3,l=o.context.work(()=>Tp&&Tp()||Date.now()>s,i+(a?0:1e5));this.chunkBudget-=Date.now()-r,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:Yt.setState.of(new Fn(o.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(r=>at(this.view.state,r)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Vn=j.define({combine(t){return t.length?t[0]:null},enables:[Yt.state,Z2]});var J2=j.define(),$a=j.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function za(t){let e=t.facet($a);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function es(t,e){let r="",n=t.tabSize;if(t.facet($a).charCodeAt(0)==9)for(;e>=n;)r+=" ",e-=n;for(let i=0;i=n.from&&i<=n.to?o&&i==e?{text:"",from:e}:(r<0?i-1&&(o+=s-this.countColumn(n,n.search(/\S|$/))),o}countColumn(e,r=e.length){return Pn(e,this.state.tabSize,r)}lineIndent(e,r=1){let{text:n,from:i}=this.lineAt(e,r),o=this.options.overrideIndentation;if(o){let s=o(i);if(s>-1)return s}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Y2=new Z;function X2(t,e,r){return Pk(e.resolveInner(r).enterUnfinishedNodesBefore(r),r,t)}function Q2(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function eT(t){let e=t.type.prop(Y2);if(e)return e;let r=t.firstChild,n;if(r&&(n=r.type.prop(Z.closedBy))){let i=t.lastChild,o=i&&n.indexOf(i.name)>-1;return s=>iT(s,!0,1,void 0,o&&!Q2(s)?i.from:void 0)}return t.parent==null?tT:null}function Pk(t,e,r){for(;t;t=t.parent){let n=eT(t);if(n)return n(ja.create(r,e,t))}return null}function tT(){return 0}var ja=class extends $i{constructor(e,r,n){super(e.state,e.options),this.base=e,this.pos=r,this.node=n}static create(e,r,n){return new ja(e,r,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let r=this.node.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(rT(r,this.node))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?Pk(e,this.pos,this.base):0}};function rT(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}function nT(t){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let i=t.options.simulateBreak,o=t.state.doc.lineAt(r.from),s=i==null||i<=o.from?o.to:Math.min(o.to,i);for(let a=r.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped)return l.from{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let r=t.newDoc,{head:n}=t.newSelection.main,i=r.lineAt(n);if(n>i.from+oT)return t;let o=r.sliceString(i.from,n);if(!e.some(c=>c.test(o)))return t;let{state:s}=t,a=-1,l=[];for(let{head:c}of s.selection.ranges){let f=s.doc.lineAt(c);if(f.from==a)continue;a=f.from;let u=Of(s,f.from);if(u==null)continue;let h=/^\s*/.exec(f.text)[0],d=es(s,u);h!=d&&l.push({from:f.from,to:f.from+h.length,insert:d})}return l.length?[t,{changes:l,sequential:!0}]:t})}var sT=j.define(),aT=new Z;function lT(t,e,r){let n=qe(t);if(n.lengthr)continue;if(o&&s.from=e&&l.to>r&&(o=l)}}return o}function cT(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Af(t,e,r){for(let n of t.facet(sT)){let i=n(t,e,r);if(i)return i}return lT(t,e,r)}function Ik(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}var Rf=W.define({map:Ik}),Fa=W.define({map:Ik});function Bk(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some(n=>n.from<=r&&n.to>=r)||e.push(t.lineBlockAt(r));return e}var zi=ce.define({create(){return $.none},update(t,e){t=t.map(e.changes);for(let r of e.effects)r.is(Rf)&&!fT(t,r.value.from,r.value.to)?t=t.update({add:[gT.range(r.value.from,r.value.to)]}):r.is(Fa)&&(t=t.update({filter:(n,i)=>r.value.from!=n||r.value.to!=i,filterFrom:r.value.from,filterTo:r.value.to}));if(e.selection){let r=!1,{head:n}=e.selection.main;t.between(n,n,(i,o)=>{in&&(r=!0)}),r&&(t=t.update({filterFrom:n,filterTo:n,filter:(i,o)=>o<=n||i>=n}))}return t},provide:t=>B.decorations.from(t)});function Tf(t,e,r){var n;let i=null;return(n=t.field(zi,!1))===null||n===void 0||n.between(e,r,(o,s)=>{(!i||i.from>o)&&(i={from:o,to:s})}),i}function fT(t,e,r){let n=!1;return t.between(e,e,(i,o)=>{i==e&&o==r&&(n=!0)}),n}function jk(t,e){return t.field(zi,!1)?e:e.concat(W.appendConfig.of(Vk()))}var uT=t=>{for(let e of Bk(t)){let r=Af(t.state,e.from,e.to);if(r)return t.dispatch({effects:jk(t.state,[Rf.of(r),$k(t,r)])}),!0}return!1},hT=t=>{if(!t.state.field(zi,!1))return!1;let e=[];for(let r of Bk(t)){let n=Tf(t.state,r.from,r.to);n&&e.push(Fa.of(n),$k(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function $k(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return B.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${i}.`)}var dT=t=>{let{state:e}=t,r=[];for(let n=0;n{let e=t.state.field(zi,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,(n,i)=>{r.push(Fa.of({from:n,to:i}))}),t.dispatch({effects:r}),!0},zk=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:uT},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:hT},{key:"Ctrl-Alt-[",run:dT},{key:"Ctrl-Alt-]",run:pT}],mT={placeholderDOM:null,placeholderText:"\u2026"},Fk=j.define({combine(t){return gt(t,mT)}});function Vk(t){let e=[zi,bT];return t&&e.push(Fk.of(t)),e}var gT=$.replace({widget:new class extends Nt{toDOM(t){let{state:e}=t,r=e.facet(Fk),n=o=>{let s=t.lineBlockAt(t.posAtDOM(o.target)),a=Tf(t.state,s.from,s.to);a&&t.dispatch({effects:Fa.of(a)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,n);let i=document.createElement("span");return i.textContent=r.placeholderText,i.setAttribute("aria-label",e.phrase("folded code")),i.title=e.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=n,i}}}),yT={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{}},Ba=class extends Pt{constructor(e,r){super(),this.config=e,this.open=r}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let r=document.createElement("span");return r.textContent=this.open?this.config.openText:this.config.closedText,r.title=e.state.phrase(this.open?"Fold line":"Unfold line"),r}};function Uk(t={}){let e=Object.assign(Object.assign({},yT),t),r=new Ba(e,!0),n=new Ba(e,!1),i=de.fromClass(class{constructor(s){this.from=s.viewport.from,this.markers=this.buildMarkers(s)}update(s){(s.docChanged||s.viewportChanged||s.startState.facet(Vn)!=s.state.facet(Vn)||s.startState.field(zi,!1)!=s.state.field(zi,!1)||qe(s.startState)!=qe(s.state))&&(this.markers=this.buildMarkers(s.view))}buildMarkers(s){let a=new Mt;for(let l of s.viewportLineBlocks){let c=Tf(s.state,l.from,l.to)?n:Af(s.state,l.from,l.to)?r:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:o}=e;return[i,gp({class:"cm-foldGutter",markers(s){var a;return((a=s.plugin(i))===null||a===void 0?void 0:a.markers)||te.empty},initialSpacer(){return new Ba(e,!1)},domEventHandlers:Object.assign(Object.assign({},o),{click:(s,a,l)=>{if(o.click&&o.click(s,a,l))return!0;let c=Tf(s.state,a.from,a.to);if(c)return s.dispatch({effects:Fa.of(c)}),!0;let f=Af(s.state,a.from,a.to);return f?(s.dispatch({effects:Rf.of(f)}),!0):!1}})}),Vk()]}var bT=B.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"}}),Qo=class{constructor(e,r){let n;function i(a){let l=Gt.newName();return(n||(n=Object.create(null)))["."+l]=a,l}let o=typeof r.all=="string"?r.all:r.all?i(r.all):void 0,s=r.scope;this.scope=s instanceof Yt?a=>a.prop(Cf)==s.data:s?a=>a==s:void 0,this.style=Cp(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=n?new Gt(n):null,this.themeType=r.themeType}static define(e,r){return new Qo(e,r||{})}},Mp=j.define(),Hk=j.define({combine(t){return t.length?[t[0]]:null}});function Op(t){let e=t.facet(Mp);return e.length?e:t.facet(Hk)}function Wk(t,e){let r=[kT],n;return t instanceof Qo&&(t.module&&r.push(B.styleModule.of(t.module)),n=t.themeType),e?.fallback?r.push(Hk.of(t)):n?r.push(Mp.computeN([B.darkTheme],i=>i.facet(B.darkTheme)==(n=="dark")?[t]:[])):r.push(Mp.of(t)),r}var Dp=class{constructor(e){this.markCache=Object.create(null),this.tree=qe(e.state),this.decorations=this.buildDeco(e,Op(e.state))}update(e){let r=qe(e.state),n=Op(e.state),i=n!=Op(e.startState);r.length{n.add(s,a,this.markCache[l]||(this.markCache[l]=$.mark({class:l})))},i,o);return n.finish()}},kT=hn.high(de.fromClass(Dp,{decorations:t=>t.decorations})),qk=Qo.define([{tag:N.meta,color:"#7a757a"},{tag:N.link,textDecoration:"underline"},{tag:N.heading,textDecoration:"underline",fontWeight:"bold"},{tag:N.emphasis,fontStyle:"italic"},{tag:N.strong,fontWeight:"bold"},{tag:N.strikethrough,textDecoration:"line-through"},{tag:N.keyword,color:"#708"},{tag:[N.atom,N.bool,N.url,N.contentSeparator,N.labelName],color:"#219"},{tag:[N.literal,N.inserted],color:"#164"},{tag:[N.string,N.deleted],color:"#a11"},{tag:[N.regexp,N.escape,N.special(N.string)],color:"#e40"},{tag:N.definition(N.variableName),color:"#00f"},{tag:N.local(N.variableName),color:"#30a"},{tag:[N.typeName,N.namespace],color:"#085"},{tag:N.className,color:"#167"},{tag:[N.special(N.variableName),N.macroName],color:"#256"},{tag:N.definition(N.propertyName),color:"#00c"},{tag:N.comment,color:"#940"},{tag:N.invalid,color:"#f00"}]),vT=B.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Kk=1e4,Gk="()[]{}",Zk=j.define({combine(t){return gt(t,{afterCursor:!0,brackets:Gk,maxScanDistance:Kk,renderMatch:ST})}}),wT=$.mark({class:"cm-matchingBracket"}),xT=$.mark({class:"cm-nonmatchingBracket"});function ST(t){let e=[],r=t.matched?wT:xT;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}var _T=ce.define({create(){return $.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let r=[],n=e.state.facet(Zk);for(let i of e.state.selection.ranges){if(!i.empty)continue;let o=xr(e.state,i.head,-1,n)||i.head>0&&xr(e.state,i.head-1,1,n)||n.afterCursor&&(xr(e.state,i.head,1,n)||i.headB.decorations.from(t)}),CT=[_T,vT];function Jk(t={}){return[Zk.of(t),CT]}function Np(t,e,r){let n=t.prop(e<0?Z.openedBy:Z.closedBy);if(n)return n;if(t.name.length==1){let i=r.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[r[i+e]]}return null}function xr(t,e,r,n={}){let i=n.maxScanDistance||Kk,o=n.brackets||Gk,s=qe(t),a=s.resolveInner(e,r);for(let l=a;l;l=l.parent){let c=Np(l.type,r,o);if(c&&l.from=n.to){if(l==0&&i.indexOf(c.type.name)>-1&&c.from0)return null;let c={from:r<0?e-1:e,to:r>0?e+1:e},f=t.doc.iterRange(e,r>0?t.doc.length:0),u=0;for(let h=0;!f.next().done&&h<=o;){let d=f.value;r<0&&(h+=d.length);let p=e+h*r;for(let b=r>0?0:d.length-1,m=r>0?d.length:-1;b!=m;b+=r){let k=s.indexOf(d[b]);if(!(k<0||n.resolve(p+b,1).type!=i))if(k%2==0==r>0)u++;else{if(u==1)return{start:c,end:{from:p+b,to:p+b+1},matched:k>>1==l>>1};u--}}r>0&&(h+=d.length)}return f.done?{start:c,matched:!1}:null}var OT=Object.create(null),Mk=[bt.none];var Dk=[],RT=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","typeName"],["attribute","propertyName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])RT[t]=ET(OT,e);function Rp(t,e){Dk.indexOf(t)>-1||(Dk.push(t),console.warn(e))}function ET(t,e){let r=null;for(let o of e.split(".")){let s=t[o]||N[o];s?typeof s=="function"?r?r=s(r):Rp(o,`Modifier ${o} used at start of tag`):r?Rp(o,`Tag ${o} used as modifier`):r=s:Rp(o,`Unknown highlighting tag ${o}`)}if(!r)return 0;let n=e.replace(/ /g,"_"),i=bt.define({id:Mk.length,name:n,props:[Ak({[n]:r})]});return Mk.push(i),i.id}var Mf=class{constructor(e,r,n){this.state=e,this.pos=r,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let r=qe(this.state).resolveInner(this.pos,-1);for(;r&&e.indexOf(r.name)<0;)r=r.parent;return r?{from:r.from,to:this.pos,text:this.state.sliceDoc(r.from,this.pos),type:r.type}:null}matchBefore(e){let r=this.state.doc.lineAt(this.pos),n=Math.max(r.from,this.pos-250),i=r.text.slice(n-r.from,this.pos-r.from),o=i.search(iv(e,!1));return o<0?null:{from:n+o,to:this.pos,text:i.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,r){e=="abort"&&this.abortListeners&&this.abortListeners.push(r)}};function Yk(t){let e=Object.keys(t).join(""),r=/\w/.test(e);return r&&(e=e.replace(/\w/g,"")),`[${r?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function MT(t){let e=Object.create(null),r=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let o=1;otypeof i=="string"?{label:i}:i),[r,n]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:MT(e);return i=>{let o=i.matchBefore(n);return o||i.explicit?{from:o?o.from:i.pos,options:e,validFor:r}:null}}var Df=class{constructor(e,r,n){this.completion=e,this.source=r,this.match=n}};function Un(t){return t.selection.main.head}function iv(t,e){var r;let{source:n}=t,i=e&&n[0]!="^",o=n[n.length-1]!="$";return!i&&!o?t:new RegExp(`${i?"^":""}(?:${n})${o?"$":""}`,(r=t.flags)!==null&&r!==void 0?r:t.ignoreCase?"i":"")}function NT(t,e,r,n){return t.changeByRange(i=>{if(i==t.selection.main)return{changes:{from:r,to:n,insert:e},range:A.cursor(r+e.length)};let o=n-r;return!i.empty||o&&t.sliceDoc(i.from-o,i.from)!=t.sliceDoc(r,n)?{range:i}:{changes:{from:i.from-o,to:i.from,insert:e},range:A.cursor(i.from-o+e.length)}})}function ov(t,e){let r=e.completion.apply||e.completion.label,n=e.source;typeof r=="string"?t.dispatch(NT(t.state,r,n.from,n.to)):r(t,e.completion,n.from,n.to)}var Xk=new WeakMap;function PT(t){if(!Array.isArray(t))return t;let e=Xk.get(t);return e||Xk.set(t,e=DT(t)),e}var Lp=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let r=0;r=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(R=pa(C))!=R.toLowerCase()?1:R!=R.toUpperCase()?2:0;(!S||x==1&&m||w==0&&x!=0)&&(r[u]==C||n[u]==C&&(h=!0)?s[u++]=S:s.length&&(k=!1)),w=x,S+=xt(C)}return u==l&&s[0]==0&&k?this.result(-100+(h?-200:0),s,e):d==l&&p==0?[-200-e.length,0,b]:a>-1?[-700-e.length,a,a+this.pattern.length]:d==l?[-200+-700-e.length,p,b]:u==l?this.result(-100+(h?-200:0)+-700+(k?0:-1100),s,e):r.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,r,n){let i=[e-n.length],o=1;for(let s of r){let a=s+(this.astral?xt($e(n,s)):1);o>1&&i[o-1]==s?i[o-1]=a:(i[o++]=s,i[o++]=a)}return i}},Hn=j.define({combine(t){return gt(t,{activateOnTyping:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[]},{defaultKeymap:(e,r)=>e&&r,closeOnBlur:(e,r)=>e&&r,icons:(e,r)=>e&&r,optionClass:(e,r)=>n=>LT(e(n),r(n)),addToOptions:(e,r)=>e.concat(r)})}});function LT(t,e){return t?e?t+" "+e:t:e}function IT(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(r){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),r.type&&n.classList.add(...r.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(r,n,i){let o=document.createElement("span");o.className="cm-completionLabel";let{label:s}=r,a=0;for(let l=1;la&&o.appendChild(document.createTextNode(s.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(s.slice(c,f))),u.className="cm-completionMatchedText",a=f}return ar.position-n.position).map(r=>r.render)}function Qk(t,e,r){if(t<=r)return{from:0,to:t};if(e<=t>>1){let i=Math.floor(e/r);return{from:i*r,to:(i+1)*r}}let n=Math.floor((t-e)/r);return{from:t-(n+1)*r,to:t-n*r}}var Ip=class{constructor(e,r){this.view=e,this.stateField=r,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:a=>this.positionInfo(a),key:this};let n=e.state.field(r),{options:i,selected:o}=n.open,s=e.state.facet(Hn);this.optionContent=IT(s),this.optionClass=s.optionClass,this.range=Qk(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",a=>{for(let l=a.target,c;l&&l!=this.dom;l=l.parentNode)if(l.nodeName=="LI"&&(c=/-(\d+)$/.exec(l.id))&&+c[1]{this.info&&this.view.requestMeasure(this.placeInfo)})}mount(){this.updateSel()}update(e){e.state.field(this.stateField)!=e.startState.field(this.stateField)&&this.updateSel()}positioned(){this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),r=e.open;if((r.selected=this.range.to)&&(this.range=Qk(r.options.length,r.selected,this.view.state.facet(Hn).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(r.options,e.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})),this.updateSelectedOption(r.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:n}=r.options[r.selected],{info:i}=n;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(n);if(!o)return;"then"in o?o.then(s=>{s&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(s)}).catch(s=>at(this.view.state,s,"completion info")):this.addInfoPane(o)}}addInfoPane(e){let r=this.info=document.createElement("div");r.className="cm-tooltip cm-completionInfo",r.appendChild(e),this.dom.appendChild(r),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let r=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),r=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return r&&jT(this.list,r),r}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let r=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect();if(i.top>Math.min(innerHeight,r.bottom)-10||i.bottomnew Ip(e,t)}function jT(t,e){let r=t.getBoundingClientRect(),n=e.getBoundingClientRect();n.topr.bottom&&(t.scrollTop+=n.bottom-r.bottom)}function ev(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function $T(t,e){let r=[],n=0;for(let s of t)if(s.hasResult())if(s.result.filter===!1){let a=s.result.getMatch;for(let l of s.result.options){let c=[1e9-n++];if(a)for(let f of a(l))c.push(f);r.push(new Df(l,s,c))}}else{let a=new Lp(e.sliceDoc(s.from,s.to)),l;for(let c of s.result.options)(l=a.match(c.label))&&(c.boost!=null&&(l[0]+=c.boost),r.push(new Df(c,s,l)))}let i=[],o=null;for(let s of r.sort(UT))!o||o.label!=s.completion.label||o.detail!=s.completion.detail||o.type!=null&&s.completion.type!=null&&o.type!=s.completion.type||o.apply!=s.completion.apply?i.push(s):ev(s.completion)>ev(o)&&(i[i.length-1]=s),o=s.completion;return i}var Vi=class{constructor(e,r,n,i,o){this.options=e,this.attrs=r,this.tooltip=n,this.timestamp=i,this.selected=o}setSelected(e,r){return e==this.selected||e>=this.options.length?this:new Vi(this.options,tv(r,e),this.tooltip,this.timestamp,e)}static build(e,r,n,i,o){let s=$T(e,r);if(!s.length)return null;let a=0;if(i&&i.selected){let l=i.options[i.selected].completion;for(let c=0;cc.hasResult()?Math.min(l,c.from):l,1e8),create:BT(Xt),above:o.aboveCursor},i?i.timestamp:Date.now(),a)}map(e){return new Vi(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}},ts=class{constructor(e,r,n){this.active=e,this.id=r,this.open=n}static start(){return new ts(VT,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:r}=e,n=r.facet(Hn),o=(n.override||r.languageDataAt("autocomplete",Un(r)).map(PT)).map(a=>(this.active.find(c=>c.source==a)||new ct(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));o.length==this.active.length&&o.every((a,l)=>a==this.active[l])&&(o=this.active);let s=e.selection||o.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!zT(o,this.active)?Vi.build(o,r,this.id,this.open,n):this.open&&e.docChanged?this.open.map(e.changes):this.open;!s&&o.every(a=>a.state!=1)&&o.some(a=>a.hasResult())&&(o=o.map(a=>a.hasResult()?new ct(a.source,0):a));for(let a of e.effects)a.is(av)&&(s=s&&s.setSelected(a.value,this.id));return o==this.active&&s==this.open?this:new ts(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:FT}};function zT(t,e){if(t==e)return!0;for(let r=0,n=0;;){for(;rs||r=="delete"&&Un(e.startState)==this.from)return new ct(this.source,r=="input"&&n.activateOnTyping?1:0);let l=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),c;return HT(this.result.validFor,e.state,o,s)?new Ui(this.source,l,this.result,o,s):this.result.update&&(c=this.result.update(this.result,o,s,new Mf(e.state,a,l>=0)))?new Ui(this.source,l,c,c.from,(i=c.to)!==null&&i!==void 0?i:Un(e.state)):new ct(this.source,1,l)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new ct(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Ui(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}};function HT(t,e,r,n){if(!t)return!1;let i=e.sliceDoc(r,n);return typeof t=="function"?t(i,r,n,e):iv(t,!0).test(i)}var $p=W.define(),Nf=W.define(),sv=W.define({map(t,e){return t.map(r=>r.map(e))}}),av=W.define(),Xt=ce.define({create(){return ts.start()},update(t,e){return t.update(e)},provide:t=>[Da.from(t,e=>e.tooltip),B.contentAttributes.from(t,e=>e.attrs)]}),lv=75;function Ef(t,e="option"){return r=>{let n=r.state.field(Xt,!1);if(!n||!n.open||Date.now()-n.open.timestamp=a&&(s=e=="page"?a-1:0),r.dispatch({effects:av.of(s)}),!0}}var WT=t=>{let e=t.state.field(Xt,!1);return t.state.readOnly||!e||!e.open||Date.now()-e.open.timestampt.state.field(Xt,!1)?(t.dispatch({effects:$p.of(!0)}),!0):!1,KT=t=>{let e=t.state.field(Xt,!1);return!e||!e.active.some(r=>r.state!=0)?!1:(t.dispatch({effects:Nf.of(null)}),!0)},jp=class{constructor(e,r){this.active=e,this.context=r,this.time=Date.now(),this.updates=[],this.done=void 0}},rv=50,GT=50,ZT=1e3,JT=de.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of t.state.field(Xt).active)e.state==1&&this.startQuery(e)}update(t){let e=t.state.field(Xt);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Xt)==e)return;let r=t.transactions.some(n=>(n.selection||n.docChanged)&&!Bp(n));for(let n=0;nGT&&Date.now()-i.time>ZT){for(let o of i.context.abortListeners)try{o()}catch(s){at(this.view.state,s)}i.context.abortListeners=null,this.running.splice(n--,1)}else i.updates.push(...t.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some(n=>n.state==1&&!this.running.some(i=>i.active.source==n.source))?setTimeout(()=>this.startUpdate(),rv):-1,this.composing!=0)for(let n of t.transactions)Bp(n)=="input"?this.composing=2:this.composing==2&&n.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:t}=this.view,e=t.field(Xt);for(let r of e.active)r.state==1&&!this.running.some(n=>n.active.source==r.source)&&this.startQuery(r)}startQuery(t){let{state:e}=this.view,r=Un(e),n=new Mf(e,r,t.explicitPos==r),i=new jp(t,n);this.running.push(i),Promise.resolve(t.source(n)).then(o=>{i.context.aborted||(i.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Nf.of(null)}),at(this.view.state,o)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),rv))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],r=this.view.state.facet(Hn);for(let n=0;ns.source==i.active.source);if(o&&o.state==1)if(i.done==null){let s=new ct(i.active.source,0);for(let a of i.updates)s=s.update(a,r);s.state!=1&&e.push(s)}else this.startQuery(o)}e.length&&this.view.dispatch({effects:sv.of(e)})}},{eventHandlers:{blur(){let t=this.view.state.field(Xt,!1);t&&t.tooltip&&this.view.state.facet(Hn).closeOnBlur&&this.view.dispatch({effects:Nf.of(null)})},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:$p.of(!1)}),20),this.composing=0}}}),YT=B.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",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".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:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",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"},".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 Pf={brackets:["(","[","{","'",'"'],before:")]}:;>"},Fi=W.define({map(t,e){let r=e.mapPos(t,-1,Je.TrackAfter);return r??void 0}}),zp=W.define({map(t,e){return e.mapPos(t)}}),Fp=new class extends kr{};Fp.startSide=1;Fp.endSide=-1;var cv=ce.define({create(){return te.empty},update(t,e){if(e.selection){let r=e.state.doc.lineAt(e.selection.main.head).from,n=e.startState.doc.lineAt(e.startState.selection.main.head).from;r!=e.changes.mapPos(n,-1)&&(t=te.empty)}t=t.map(e.changes);for(let r of e.effects)r.is(Fi)?t=t.update({add:[Fp.range(r.value,r.value+1)]}):r.is(zp)&&(t=t.update({filter:n=>n!=r.value}));return t}});function fv(){return[QT,cv]}var Pp="()[]{}<>";function uv(t){for(let e=0;e{if((XT?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(n.length>2||n.length==2&&xt($e(n,0))==1||e!=i.from||r!=i.to)return!1;let o=tO(t.state,n);return o?(t.dispatch(o),!0):!1}),eO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=hv(t,t.selection.main.head).brackets||Pf.brackets,i=null,o=t.changeByRange(s=>{if(s.empty){let a=rO(t.doc,s.head);for(let l of n)if(l==a&&Lf(t.doc,s.head)==uv($e(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:A.cursor(s.head-l.length),userEvent:"delete.backward"}}return{range:i=s}});return i||e(t.update(o,{scrollIntoView:!0})),!i},dv=[{key:"Backspace",run:eO}];function tO(t,e){let r=hv(t,t.selection.main.head),n=r.brackets||Pf.brackets;for(let i of n){let o=uv($e(i,0));if(e==i)return o==i?oO(t,i,n.indexOf(i+i+i)>-1):nO(t,i,o,r.before||Pf.before);if(e==o&&pv(t,t.selection.main.from))return iO(t,i,o)}return null}function pv(t,e){let r=!1;return t.field(cv).between(0,t.doc.length,n=>{n==e&&(r=!0)}),r}function Lf(t,e){let r=t.sliceString(e,e+2);return r.slice(0,xt($e(r,0)))}function rO(t,e){let r=t.sliceString(e-2,e);return xt($e(r,0))==r.length?r:r.slice(1)}function nO(t,e,r,n){let i=null,o=t.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:r,from:s.to}],effects:Fi.of(s.to+e.length),range:A.range(s.anchor+e.length,s.head+e.length)};let a=Lf(t.doc,s.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+r,from:s.head},effects:Fi.of(s.head+e.length),range:A.cursor(s.head+e.length)}:{range:i=s}});return i?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function iO(t,e,r){let n=null,i=t.selection.ranges.map(o=>o.empty&&Lf(t.doc,o.head)==r?A.cursor(o.head+r.length):n=o);return n?null:t.update({selection:A.create(i,t.selection.mainIndex),scrollIntoView:!0,effects:t.selection.ranges.map(({from:o})=>zp.of(o))})}function oO(t,e,r){let n=null,i=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:e,from:o.to}],effects:Fi.of(o.to+e.length),range:A.range(o.anchor+e.length,o.head+e.length)};let s=o.head,a=Lf(t.doc,s);if(a==e){if(nv(t,s))return{changes:{insert:e+e,from:s},effects:Fi.of(s+e.length),range:A.cursor(s+e.length)};if(pv(t,s)){let l=r&&t.sliceDoc(s,s+e.length*3)==e+e+e;return{range:A.cursor(s+e.length*(l?3:1)),effects:zp.of(s)}}}else{if(r&&t.sliceDoc(s-2*e.length,s)==e+e&&nv(t,s-2*e.length))return{changes:{insert:e+e+e+e,from:s},effects:Fi.of(s+e.length),range:A.cursor(s+e.length)};if(t.charCategorizer(s)(a)!=je.Word){let l=t.sliceDoc(s-1,s);if(l!=e&&t.charCategorizer(s)(l)!=je.Word&&!sO(t,s,e))return{changes:{insert:e+e,from:s},effects:Fi.of(s+e.length),range:A.cursor(s+e.length)}}}return{range:n=o}});return n?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function nv(t,e){let r=qe(t).resolveInner(e+1);return r.parent&&r.from==e}function sO(t,e,r){let n=qe(t).resolveInner(e,-1);for(let i=0;i<5;i++){if(t.sliceDoc(n.from,n.from+r.length)==r)return!0;let o=n.to==e&&n.parent;if(!o)break;n=o}return!1}function If(t={}){return[Xt,Hn.of(t),JT,aO,YT]}var Vp=[{key:"Ctrl-Space",run:qT},{key:"Escape",run:KT},{key:"ArrowDown",run:Ef(!0)},{key:"ArrowUp",run:Ef(!1)},{key:"PageDown",run:Ef(!0,"page")},{key:"PageUp",run:Ef(!1,"page")},{key:"Enter",run:WT}],aO=hn.highest(Ii.computeN([Hn],t=>t.facet(Hn).defaultKeymap?[Vp]:[]));var lO=t=>{let e=Gp(t.state);return e.line?cO(t):e.block?uO(t):!1};function Kp(t,e){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let i=t(e,r);return i?(n(r.update(i)),!0):!1}}var cO=Kp(pO,0);var fO=Kp(Av,0);var uO=Kp((t,e)=>Av(t,e,dO(e)),0);function Gp(t,e=t.selection.main.head){let r=t.languageDataAt("commentTokens",e);return r.length?r[0]:{}}var Va=50;function hO(t,{open:e,close:r},n,i){let o=t.sliceDoc(n-Va,n),s=t.sliceDoc(i,i+Va),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,c=o.length-a;if(o.slice(c-e.length,c)==e&&s.slice(l,l+r.length)==r)return{open:{pos:n-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let f,u;i-n<=2*Va?f=u=t.sliceDoc(n,i):(f=t.sliceDoc(n,n+Va),u=t.sliceDoc(i-Va,i));let h=/^\s*/.exec(f)[0].length,d=/\s*$/.exec(u)[0].length,p=u.length-d-r.length;return f.slice(h,h+e.length)==e&&u.slice(p,p+r.length)==r?{open:{pos:n+h+e.length,margin:/\s/.test(f.charAt(h+e.length))?1:0},close:{pos:i-d-r.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function dO(t){let e=[];for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),i=r.to<=n.to?n:t.doc.lineAt(r.to),o=e.length-1;o>=0&&e[o].to>n.from?e[o].to=i.to:e.push({from:n.from,to:i.to})}return e}function Av(t,e,r=e.selection.ranges){let n=r.map(o=>Gp(e,o.from).block);if(!n.every(o=>o))return null;let i=r.map((o,s)=>hO(e,n[s],o.from,o.to));if(t!=2&&!i.every(o=>o))return{changes:e.changes(r.map((o,s)=>i[s]?[]:[{from:o.from,insert:n[s].open+" "},{from:o.to,insert:" "+n[s].close}]))};if(t!=1&&i.some(o=>o)){let o=[];for(let s=0,a;si&&(o==s||s>f.from)){i=f.from;let u=Gp(e,c).line;if(!u)continue;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+u.length)==u?h:-1;ho.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:f,single:u}of n)(u||!f)&&o.push({from:a.from+c,insert:l+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of n)if(a>=0){let c=s.from+a,f=c+l.length;s.text[f-s.from]==" "&&f++,o.push({from:c,to:f})}return{changes:o}}return null}var Hp=br.define(),mO=br.define(),gO=j.define(),Tv=j.define({combine(t){return gt(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}});function yO(t){let e=0;return t.iterChangedRanges((r,n)=>e=n),e}var Ov=ce.define({create(){return er.empty},update(t,e){let r=e.state.facet(Tv),n=e.annotation(Hp);if(n){let l=e.docChanged?A.single(yO(e.changes)):void 0,c=ft.fromTransaction(e,l),f=n.side,u=f==0?t.undone:t.done;return c?u=Bf(u,u.length,r.minDepth,c):u=Nv(u,e.startState.selection),new er(f==0?n.rest:u,f==0?u:n.rest)}let i=e.annotation(mO);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Te.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=ft.fromTransaction(e),s=e.annotation(Te.time),a=e.annotation(Te.userEvent);return o?t=t.addChanges(o,s,a,r.newGroupDelay,r.minDepth):e.selection&&(t=t.addSelection(e.startState.selection,s,a,r.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new er(t.done.map(ft.fromJSON),t.undone.map(ft.fromJSON))}});function Rv(t={}){return[Ov,Tv.of(t),B.domEventHandlers({beforeinput(e,r){let n=e.inputType=="historyUndo"?Ev:e.inputType=="historyRedo"?Mv:null;return n?(e.preventDefault(),n(r)):!1}})]}function jf(t,e){return function({state:r,dispatch:n}){if(!e&&r.readOnly)return!1;let i=r.field(Ov,!1);if(!i)return!1;let o=i.pop(t,r,e);return o?(n(o),!0):!1}}var Ev=jf(0,!1),Mv=jf(1,!1),bO=jf(0,!0),kO=jf(1,!0);var ft=class{constructor(e,r,n,i,o){this.changes=e,this.effects=r,this.mapped=n,this.startSelection=i,this.selectionsAfter=o}setSelAfter(e){return new ft(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,r,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new ft(e.changes&&Ae.fromJSON(e.changes),[],e.mapped&&Kt.fromJSON(e.mapped),e.startSelection&&A.fromJSON(e.startSelection),e.selectionsAfter.map(A.fromJSON))}static fromTransaction(e,r){let n=Qt;for(let i of e.startState.facet(gO)){let o=i(e);o.length&&(n=n.concat(o))}return!n.length&&e.changes.empty?null:new ft(e.changes.invert(e.startState.doc),n,void 0,r||e.startState.selection,Qt)}static selection(e){return new ft(void 0,Qt,void 0,void 0,e)}};function Bf(t,e,r,n){let i=e+1>r+20?e-r-1:0,o=t.slice(i,e);return o.push(n),o}function vO(t,e){let r=[],n=!1;return t.iterChangedRanges((i,o)=>r.push(i,o)),e.iterChangedRanges((i,o,s,a)=>{for(let l=0;l=c&&s<=f&&(n=!0)}}),n}function wO(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((r,n)=>r.empty!=e.ranges[n].empty).length===0}function Dv(t,e){return t.length?e.length?t.concat(e):t:e}var Qt=[],xO=200;function Nv(t,e){if(t.length){let r=t[t.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-xO));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),Bf(t,t.length-1,1e9,r.setSelAfter(n)))}else return[ft.selection([e])]}function SO(t){let e=t[t.length-1],r=t.slice();return r[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),r}function Up(t,e){if(!t.length)return t;let r=t.length,n=Qt;for(;r;){let i=_O(t[r-1],e,n);if(i.changes&&!i.changes.empty||i.effects.length){let o=t.slice(0,r);return o[r-1]=i,o}else e=i.mapped,r--,n=i.selectionsAfter}return n.length?[ft.selection(n)]:Qt}function _O(t,e,r){let n=Dv(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Qt,r);if(!t.changes)return ft.selection(n);let i=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new ft(i,W.mapEffects(t.effects,e),s,t.startSelection.map(o),n)}var CO=/^(input\.type|delete)($|\.)/,er=class{constructor(e,r,n=0,i=void 0){this.done=e,this.undone=r,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new er(this.done,this.undone):this}addChanges(e,r,n,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||CO.test(n))&&(!a.selectionsAfter.length&&r-this.prevTime0&&r-this.prevTimer.empty?t.moveByChar(r,e):$f(r,e))}function tr(t){return t.textDirectionAt(t.state.selection.main.head)==ye.LTR}var Iv=t=>Lv(t,!tr(t)),Bv=t=>Lv(t,tr(t));function jv(t,e){return yn(t,r=>r.empty?t.moveByGroup(r,e):$f(r,e))}var AO=t=>jv(t,!tr(t)),TO=t=>jv(t,tr(t));function OO(t,e,r){if(e.type.prop(r))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function zf(t,e,r){let n=qe(t).resolveInner(e.head),i=r?Z.closedBy:Z.openedBy;for(let l=e.head;;){let c=r?n.childAfter(l):n.childBefore(l);if(!c)break;OO(t,c,i)?n=c:l=r?c.to:c.from}let o=n.type.prop(i),s,a;return o&&(s=r?xr(t,n.from,1):xr(t,n.to,-1))&&s.matched?a=r?s.end.to:s.end.from:a=r?n.to:n.from,A.cursor(a,r?-1:1)}var RO=t=>yn(t,e=>zf(t.state,e,!tr(t))),EO=t=>yn(t,e=>zf(t.state,e,tr(t)));function $v(t,e){return yn(t,r=>{if(!r.empty)return $f(r,e);let n=t.moveVertically(r,e);return n.head!=r.head?n:t.moveToLineBoundary(r,e)})}var zv=t=>$v(t,!1),Fv=t=>$v(t,!0);function Vv(t,e){let{state:r}=t,n=rs(r.selection,a=>a.empty?t.moveVertically(a,e,Math.min(t.dom.clientHeight,innerHeight)):$f(a,e));if(n.eq(r.selection))return!1;let i=t.coordsAtPos(r.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),s;return i&&i.top>o.top&&i.bottomVv(t,!1),Wp=t=>Vv(t,!0);function Ff(t,e,r){let n=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,r);if(i.head==e.head&&i.head!=(r?n.to:n.from)&&(i=t.moveToLineBoundary(e,r,!1)),!r&&i.head==n.from&&n.length){let o=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&e.head!=n.from+o&&(i=A.cursor(n.from+o))}return i}var gv=t=>yn(t,e=>Ff(t,e,!0)),yv=t=>yn(t,e=>Ff(t,e,!1)),MO=t=>yn(t,e=>A.cursor(t.lineBlockAt(e.head).from,1)),DO=t=>yn(t,e=>A.cursor(t.lineBlockAt(e.head).to,-1));function NO(t,e,r){let n=!1,i=rs(t.selection,o=>{let s=xr(t,o.head,-1)||xr(t,o.head,1)||o.head>0&&xr(t,o.head-1,1)||o.headNO(t,e,!1);function Gr(t,e){let r=rs(t.state.selection,n=>{let i=e(n);return A.range(n.anchor,i.head,i.goalColumn)});return r.eq(t.state.selection)?!1:(t.dispatch(Kr(t.state,r)),!0)}function Uv(t,e){return Gr(t,r=>t.moveByChar(r,e))}var Hv=t=>Uv(t,!tr(t)),Wv=t=>Uv(t,tr(t));function qv(t,e){return Gr(t,r=>t.moveByGroup(r,e))}var LO=t=>qv(t,!tr(t)),IO=t=>qv(t,tr(t));var BO=t=>Gr(t,e=>zf(t.state,e,!tr(t))),jO=t=>Gr(t,e=>zf(t.state,e,tr(t)));function Kv(t,e){return Gr(t,r=>t.moveVertically(r,e))}var Gv=t=>Kv(t,!1),Zv=t=>Kv(t,!0);function Jv(t,e){return Gr(t,r=>t.moveVertically(r,e,Math.min(t.dom.clientHeight,innerHeight)))}var bv=t=>Jv(t,!1),kv=t=>Jv(t,!0),vv=t=>Gr(t,e=>Ff(t,e,!0)),wv=t=>Gr(t,e=>Ff(t,e,!1)),$O=t=>Gr(t,e=>A.cursor(t.lineBlockAt(e.head).from)),zO=t=>Gr(t,e=>A.cursor(t.lineBlockAt(e.head).to)),xv=({state:t,dispatch:e})=>(e(Kr(t,{anchor:0})),!0),Sv=({state:t,dispatch:e})=>(e(Kr(t,{anchor:t.doc.length})),!0),_v=({state:t,dispatch:e})=>(e(Kr(t,{anchor:t.selection.main.anchor,head:0})),!0),Cv=({state:t,dispatch:e})=>(e(Kr(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),FO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),VO=({state:t,dispatch:e})=>{let r=Hf(t).map(({from:n,to:i})=>A.range(n,Math.min(i+1,t.doc.length)));return e(t.update({selection:A.create(r),userEvent:"select"})),!0},UO=({state:t,dispatch:e})=>{let r=rs(t.selection,n=>{var i;let o=qe(t).resolveInner(n.head,1);for(;!(o.from=n.to||o.to>n.to&&o.from<=n.from||!(!((i=o.parent)===null||i===void 0)&&i.parent));)o=o.parent;return A.range(o.to,o.from)});return e(Kr(t,r)),!0},HO=({state:t,dispatch:e})=>{let r=t.selection,n=null;return r.ranges.length>1?n=A.create([r.main]):r.main.empty||(n=A.create([A.cursor(r.main.head)])),n?(e(Kr(t,n)),!0):!1};function Vf({state:t,dispatch:e},r){if(t.readOnly)return!1;let n="delete.selection",i=t.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=r(s);ls&&(n="delete.forward"),s=Math.min(s,l),a=Math.max(a,l)}return s==a?{range:o}:{changes:{from:s,to:a},range:A.cursor(s)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:n})),!0)}function Uf(t,e,r){if(t instanceof B)for(let n of t.state.facet(B.atomicRanges).map(i=>i(t)))n.between(e,e,(i,o)=>{ie&&(e=r?o:i)});return e}var Yv=(t,e)=>Vf(t,r=>{let{state:n}=t,i=n.doc.lineAt(r),o,s;if(!e&&r>i.from&&rYv(t,!1),Xv=t=>Yv(t,!0),Qv=(t,e)=>Vf(t,r=>{let n=r,{state:i}=t,o=i.doc.lineAt(n),s=i.charCategorizer(n);for(let a=null;;){if(n==(e?o.to:o.from)){n==r&&o.number!=(e?i.doc.lines:1)&&(n+=e?1:-1);break}let l=mt(o.text,n-o.from,e)+o.from,c=o.text.slice(Math.min(n,l)-o.from,Math.max(n,l)-o.from),f=s(c);if(a!=null&&f!=a)break;(c!=" "||n!=r)&&(a=f),n=l}return Uf(t,n,e)}),ew=t=>Qv(t,!1),WO=t=>Qv(t,!0),tw=t=>Vf(t,e=>{let r=t.lineBlockAt(e).to;return Uf(t,eVf(t,e=>{let r=t.lineBlockAt(e).from;return Uf(t,e>r?r:Math.max(0,e-1),!1)});var KO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:ee.of(["",""])},range:A.cursor(n.from)}));return e(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},GO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let i=n.from,o=t.doc.lineAt(i),s=i==o.from?i-1:mt(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:mt(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(s,i))},range:A.cursor(a)}});return r.changes.empty?!1:(e(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Hf(t){let e=[],r=-1;for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),o=t.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=t.doc.lineAt(n.to-1)),r>=i.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(n)}else e.push({from:i.from,to:o.to,ranges:[n]});r=o.number+1}return e}function rw(t,e,r){if(t.readOnly)return!1;let n=[],i=[];for(let o of Hf(t)){if(r?o.to==t.doc.length:o.from==0)continue;let s=t.doc.lineAt(r?o.to+1:o.from-1),a=s.length+1;if(r){n.push({from:o.to,to:s.to},{from:o.from,insert:s.text+t.lineBreak});for(let l of o.ranges)i.push(A.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{n.push({from:s.from,to:o.from},{from:o.to,insert:t.lineBreak+s.text});for(let l of o.ranges)i.push(A.range(l.anchor-a,l.head-a))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:A.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}var ZO=({state:t,dispatch:e})=>rw(t,e,!1),JO=({state:t,dispatch:e})=>rw(t,e,!0);function nw(t,e,r){if(t.readOnly)return!1;let n=[];for(let i of Hf(t))r?n.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):n.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var YO=({state:t,dispatch:e})=>nw(t,e,!1),XO=({state:t,dispatch:e})=>nw(t,e,!0),QO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,r=e.changes(Hf(e).map(({from:i,to:o})=>(i>0?i--:ot.moveVertically(i,!0)).map(r);return t.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function eR(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let r=qe(t).resolveInner(e),n=r.childBefore(e),i=r.childAfter(e),o;return n&&i&&n.to<=e&&i.from>=e&&(o=n.type.prop(Z.closedBy))&&o.indexOf(i.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(i.from).from?{from:n.to,to:i.from}:null}var tR=iw(!1),rR=iw(!0);function iw(t){return({state:e,dispatch:r})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:o,to:s}=i,a=e.doc.lineAt(o),l=!t&&o==s&&eR(e,o);t&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new $i(e,{simulateBreak:o,simulateDoubleBreak:!!l}),f=Of(c,o);for(f==null&&(f=/^\s*/.exec(e.doc.lineAt(o).text)[0].length);sa.from&&o{let i=[];for(let s=n.from;s<=n.to;){let a=t.doc.lineAt(s);a.number>r&&(n.empty||n.to>a.from)&&(e(a,i,n),r=a.number),s=a.to+1}let o=t.changes(i);return{changes:i,range:A.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}var nR=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=Object.create(null),n=new $i(t,{overrideIndentation:o=>{let s=r[o];return s??-1}}),i=Zp(t,(o,s,a)=>{let l=Of(n,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let c=/^\s*/.exec(o.text)[0],f=es(t,l);(c!=f||a.fromt.readOnly?!1:(e(t.update(Zp(t,(r,n)=>{n.push({from:r.from,insert:t.facet($a)})}),{userEvent:"input.indent"})),!0),sw=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Zp(t,(r,n)=>{let i=/^\s*/.exec(r.text)[0];if(!i)return;let o=Pn(i,t.tabSize),s=0,a=es(t,Math.max(0,o-za(t)));for(;s({mac:t.key,run:t.run,shift:t.shift}))),aw=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:RO,shift:BO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:EO,shift:jO},{key:"Alt-ArrowUp",run:ZO},{key:"Shift-Alt-ArrowUp",run:YO},{key:"Alt-ArrowDown",run:JO},{key:"Shift-Alt-ArrowDown",run:XO},{key:"Escape",run:HO},{key:"Mod-Enter",run:rR},{key:"Alt-l",mac:"Ctrl-l",run:VO},{key:"Mod-i",run:UO,preventDefault:!0},{key:"Mod-[",run:sw},{key:"Mod-]",run:ow},{key:"Mod-Alt-\\",run:nR},{key:"Shift-Mod-k",run:QO},{key:"Shift-Mod-\\",run:PO},{key:"Mod-/",run:lO},{key:"Alt-A",run:fO}].concat(oR),lw={key:"Tab",run:ow,shift:sw};function ue(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)){var i=r[n];typeof i=="string"?t.setAttribute(n,i):i!=null&&(t[n]=i)}e++}for(;et.normalize("NFKD"):t=>t,Kn=class{constructor(e,r,n=0,i=e.length,o){this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=o?s=>o(fw(s)):fw,this.query=this.normalize(r)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return $e(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let r=pa(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=xt(e);let i=this.normalize(r);for(let o=0,s=n;;o++){let a=i.charCodeAt(o),l=this.match(a,s);if(l)return this.value=l,this;if(o==i.length-1)break;s==n&&othis.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 r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,i=n+r[0].length;if(this.matchPos=i+(n==i?1:0),n==this.curLine.length&&this.nextLine(),nthis.value.to)return this.value={from:n,to:i,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=n||i.to<=r){let a=new Wn(r,e.sliceString(r,n));return Jp.set(e,a),a}if(i.from==r&&i.to==n)return i;let{text:o,from:s}=i;return s>r&&(o=e.sliceString(r,s)+o,s=r),i.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r&&this.flat.tothis.flat.text.length-10&&(r=null),r){let n=this.flat.from+r.index,i=n+r[0].length;return this.value={from:n,to:i,match:r},this.matchPos=i+(n==i?1:0),this}else{if(this.flat.to==this.to)return this.done=!0,this;this.flat=Wn.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}};typeof Symbol<"u"&&(Kf.prototype[Symbol.iterator]=Gf.prototype[Symbol.iterator]=function(){return this});function sR(t){try{return new RegExp(t,rm),!0}catch{return!1}}function Yp(t){let e=ue("input",{class:"cm-textfield",name:"line"}),r=ue("form",{class:"cm-gotoLine",onkeydown:i=>{i.keyCode==27?(i.preventDefault(),t.dispatch({effects:Zf.of(!1)}),t.focus()):i.keyCode==13&&(i.preventDefault(),n())},onsubmit:i=>{i.preventDefault(),n()}},ue("label",t.state.phrase("Go to line"),": ",e)," ",ue("button",{class:"cm-button",type:"submit"},t.state.phrase("go")));function n(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:o}=t,s=o.doc.lineAt(o.selection.main.head),[,a,l,c,f]=i,u=c?+c.slice(1):0,h=l?+l:s.number;if(l&&f){let p=h/100;a&&(p=p*(a=="-"?-1:1)+s.number/o.doc.lines),h=Math.round(o.doc.lines*p)}else l&&a&&(h=h*(a=="-"?-1:1)+s.number);let d=o.doc.line(Math.max(1,Math.min(o.doc.lines,h)));t.dispatch({effects:Zf.of(!1),selection:A.cursor(d.from+Math.max(0,Math.min(u,d.length))),scrollIntoView:!0}),t.focus()}return{dom:r}}var Zf=W.define(),uw=ce.define({create(){return!0},update(t,e){for(let r of e.effects)r.is(Zf)&&(t=r.value);return t},provide:t=>Li.from(t,e=>e?Yp:null)}),aR=t=>{let e=Bi(t,Yp);if(!e){let r=[Zf.of(!0)];t.state.field(uw,!1)==null&&r.push(W.appendConfig.of([uw,lR])),t.dispatch({effects:r}),e=Bi(t,Yp)}return e&&e.dom.querySelector("input").focus(),!0},lR=B.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),cR={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},mw=j.define({combine(t){return gt(t,cR,{highlightWordAroundCursor:(e,r)=>e||r,minSelectionLength:Math.min,maxMatches:Math.min})}});function gw(t){let e=[pR,dR];return t&&e.push(mw.of(t)),e}var fR=$.mark({class:"cm-selectionMatch"}),uR=$.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function hw(t,e,r,n){return(r==0||t(e.sliceDoc(r-1,r))!=je.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=je.Word)}function hR(t,e,r,n){return t(e.sliceDoc(r,r+1))==je.Word&&t(e.sliceDoc(n-1,n))==je.Word}var dR=de.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(mw),{state:r}=t,n=r.selection;if(n.ranges.length>1)return $.none;let i=n.main,o,s=null;if(i.empty){if(!e.highlightWordAroundCursor)return $.none;let l=r.wordAt(i.head);if(!l)return $.none;s=r.charCategorizer(i.head),o=r.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l200)return $.none;if(e.wholeWords){if(o=r.sliceDoc(i.from,i.to),s=r.charCategorizer(i.head),!(hw(s,r,i.from,i.to)&&hR(s,r,i.from,i.to)))return $.none}else if(o=r.sliceDoc(i.from,i.to).trim(),!o)return $.none}let a=[];for(let l of t.visibleRanges){let c=new Kn(r.doc,o,l.from,l.to);for(;!c.next().done;){let{from:f,to:u}=c.value;if((!s||hw(s,r,f,u))&&(i.empty&&f<=i.from&&u>=i.to?a.push(uR.range(f,u)):(f>=i.to||u<=i.from)&&a.push(fR.range(f,u)),a.length>e.maxMatches))return $.none}}return $.set(a)}},{decorations:t=>t.decorations}),pR=B.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),mR=({state:t,dispatch:e})=>{let{selection:r}=t,n=A.create(r.ranges.map(i=>t.wordAt(i.head)||A.cursor(i.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function gR(t,e){let{main:r,ranges:n}=t.selection,i=t.wordAt(r.head),o=i&&i.from==r.from&&i.to==r.to;for(let s=!1,a=new Kn(t.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new Kn(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),s=!0}else{if(s&&n.some(l=>l.from==a.value.from))continue;if(o){let l=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var yR=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(o=>o.from===o.to))return mR({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(o=>t.sliceDoc(o.from,o.to)!=n))return!1;let i=gR(t,n);return i?(e(t.update({selection:t.selection.addRange(A.range(i.from,i.to),!1),effects:B.scrollIntoView(i.to)})),!0):!1},nm=j.define({combine(t){var e;return{top:t.reduce((r,n)=>r??n.top,void 0)||!1,caseSensitive:t.reduce((r,n)=>r??n.caseSensitive,void 0)||!1,createPanel:((e=t.find(r=>r.createPanel))===null||e===void 0?void 0:e.createPanel)||(r=>new tm(r))}}});var Jf=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||sR(this.search)),this.unquoted=e.literal?this.search:this.search.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?` -`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp}create(){return this.regexp?new Qp(this):new Xp(this)}getCursor(e,r=0,n=e.length){return this.regexp?is(this,e,r,n):ns(this,e,r,n)}},Yf=class{constructor(e){this.spec=e}};function ns(t,e,r,n){return new Kn(e,t.unquoted,r,n,t.caseSensitive?void 0:i=>i.toLowerCase())}var Xp=class extends Yf{constructor(e){super(e)}nextMatch(e,r,n){let i=ns(this.spec,e,n,e.length).nextOverlapping();return i.done&&(i=ns(this.spec,e,0,r).nextOverlapping()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=n;;){let o=Math.max(r,i-1e4-this.spec.unquoted.length),s=ns(this.spec,e,o,i),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(o==r)return null;i-=1e4}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.length)}getReplacement(e){return this.spec.replace}matchAll(e,r){let n=ns(this.spec,e,0,e.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=ns(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.length));for(;!o.next().done;)i(o.value.from,o.value.to)}};function is(t,e,r,n){return new Kf(e,t.search,t.caseSensitive?void 0:{ignoreCase:!0},r,n)}var Qp=class extends Yf{nextMatch(e,r,n){let i=is(this.spec,e,n,e.length).next();return i.done&&(i=is(this.spec,e,0,r).next()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=1;;i++){let o=Math.max(r,n-i*1e4),s=is(this.spec,e,o,n),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==r||a.from>o+10))return a;if(o==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.length)}getReplacement(e){return this.spec.replace.replace(/\$([$&\d+])/g,(r,n)=>n=="$"?"$":n=="&"?e.match[0]:n!="0"&&+n=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=is(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.length));for(;!o.next().done;)i(o.value.from,o.value.to)}},Ha=W.define(),im=W.define(),qn=ce.define({create(t){return new Ua(em(t).create(),null)},update(t,e){for(let r of e.effects)r.is(Ha)?t=new Ua(r.value.create(),t.panel):r.is(im)&&(t=new Ua(t.query,r.value?om:null));return t},provide:t=>Li.from(t,e=>e.panel)});var Ua=class{constructor(e,r){this.query=e,this.panel=r}},bR=$.mark({class:"cm-searchMatch"}),kR=$.mark({class:"cm-searchMatch cm-searchMatch-selected"}),vR=de.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(qn))}update(t){let e=t.state.field(qn);(e!=t.startState.field(qn)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return $.none;let{view:r}=this,n=new Mt;for(let i=0,o=r.visibleRanges,s=o.length;io[i+1].from-2*250;)l=o[++i].to;t.highlight(r.state.doc,a,l,(c,f)=>{let u=r.state.selection.ranges.some(h=>h.from==c&&h.to==f);n.add(c,f,u?kR:bR)})}return n.finish()}},{decorations:t=>t.decorations});function Wa(t){return e=>{let r=e.state.field(qn,!1);return r&&r.query.spec.valid?t(e,r):yw(e)}}var Xf=Wa((t,{query:e})=>{let{from:r,to:n}=t.state.selection.main,i=e.nextMatch(t.state.doc,r,n);return!i||i.from==r&&i.to==n?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:sm(t,i),userEvent:"select.search"}),!0)}),Qf=Wa((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main,o=e.prevMatch(r.doc,n,i);return o?(t.dispatch({selection:{anchor:o.from,head:o.to},scrollIntoView:!0,effects:sm(t,o),userEvent:"select.search"}),!0):!1}),wR=Wa((t,{query:e})=>{let r=e.matchAll(t.state.doc,1e3);return!r||!r.length?!1:(t.dispatch({selection:A.create(r.map(n=>A.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),xR=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:i}=r.main,o=[],s=0;for(let a=new Kn(t.doc,t.sliceDoc(n,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==n&&(s=o.length),o.push(A.range(a.value.from,a.value.to))}return e(t.update({selection:A.create(o,s),userEvent:"select.search.matches"})),!0},dw=Wa((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main;if(r.readOnly)return!1;let o=e.nextMatch(r.doc,n,n);if(!o)return!1;let s=[],a,l;if(o.from==n&&o.to==i&&(l=r.toText(e.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=e.nextMatch(r.doc,o.from,o.to)),o){let c=s.length==0||s[0].from>=o.to?0:o.to-o.from-l.length;a={anchor:o.from-c,head:o.to-c}}return t.dispatch({changes:s,selection:a,scrollIntoView:!!a,effects:o?sm(t,o):void 0,userEvent:"input.replace"}),!0}),SR=Wa((t,{query:e})=>{if(t.state.readOnly)return!1;let r=e.matchAll(t.state.doc,1e9).map(n=>{let{from:i,to:o}=n;return{from:i,to:o,insert:e.getReplacement(n)}});return r.length?(t.dispatch({changes:r,userEvent:"input.replace.all"}),!0):!1});function om(t){return t.state.facet(nm).createPanel(t)}function em(t,e){var r;let n=t.selection.main,i=n.empty||n.to>n.from+100?"":t.sliceDoc(n.from,n.to),o=(r=e?.caseSensitive)!==null&&r!==void 0?r:t.facet(nm).caseSensitive;return e&&!i?e:new Jf({search:i.replace(/\n/g,"\\n"),caseSensitive:o})}var yw=t=>{let e=t.state.field(qn,!1);if(e&&e.panel){let r=Bi(t,om);if(!r)return!1;let n=r.dom.querySelector("[name=search]");if(n!=t.root.activeElement){let i=em(t.state,e.query.spec);i.valid&&t.dispatch({effects:Ha.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[im.of(!0),e?Ha.of(em(t.state,e.query.spec)):W.appendConfig.of(CR)]});return!0},bw=t=>{let e=t.state.field(qn,!1);if(!e||!e.panel)return!1;let r=Bi(t,om);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:im.of(!1)}),!0},kw=[{key:"Mod-f",run:yw,scope:"editor search-panel"},{key:"F3",run:Xf,shift:Qf,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Xf,shift:Qf,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:bw,scope:"editor search-panel"},{key:"Mod-Shift-l",run:xR},{key:"Alt-g",run:aR},{key:"Mod-d",run:yR,preventDefault:!0}],tm=class{constructor(e){this.view=e;let r=this.query=e.state.field(qn).query.spec;this.commit=this.commit.bind(this),this.searchField=ue("input",{value:r.search,placeholder:rr(e,"Find"),"aria-label":rr(e,"Find"),class:"cm-textfield",name:"search",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ue("input",{value:r.replace,placeholder:rr(e,"Replace"),"aria-label":rr(e,"Replace"),class:"cm-textfield",name:"replace",onchange:this.commit,onkeyup:this.commit}),this.caseField=ue("input",{type:"checkbox",name:"case",checked:r.caseSensitive,onchange:this.commit}),this.reField=ue("input",{type:"checkbox",name:"re",checked:r.regexp,onchange:this.commit});function n(i,o,s){return ue("button",{class:"cm-button",name:i,onclick:o,type:"button"},s)}this.dom=ue("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>Xf(e),[rr(e,"next")]),n("prev",()=>Qf(e),[rr(e,"previous")]),n("select",()=>wR(e),[rr(e,"all")]),ue("label",null,[this.caseField,rr(e,"match case")]),ue("label",null,[this.reField,rr(e,"regexp")]),...e.state.readOnly?[]:[ue("br"),this.replaceField,n("replace",()=>dw(e),[rr(e,"replace")]),n("replaceAll",()=>SR(e),[rr(e,"replace all")]),ue("button",{name:"close",onclick:()=>bw(e),"aria-label":rr(e,"close"),type:"button"},["\xD7"])]])}commit(){let e=new Jf({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Ha.of(e)}))}keydown(e){Qb(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Qf:Xf)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),dw(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(Ha)&&!n.value.eq(this.query)&&this.setQuery(n.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}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(nm).top}};function rr(t,e){return t.state.phrase(e)}var Wf=30,qf=/[\s\.,:;?!]/;function sm(t,{from:e,to:r}){let n=t.state.doc.lineAt(e).from,i=t.state.doc.lineAt(r).to,o=Math.max(n,e-Wf),s=Math.min(i,r+Wf),a=t.state.sliceDoc(o,s);if(o!=n){for(let l=0;la.length-Wf;l--)if(!qf.test(a[l-1])&&qf.test(a[l])){a=a.slice(0,l);break}}return B.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${t.state.doc.lineAt(e).number}`)}var _R=B.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"}}),CR=[qn,hn.lowest(vR),_R];var lm=class{constructor(e,r,n){this.from=e,this.to=r,this.diagnostic=n}},bn=class{constructor(e,r,n){this.diagnostics=e,this.panel=r,this.selected=n}static init(e,r,n){let i=e,o=n.facet(os).markerFilter;o&&(i=o(i));let s=$.set(i.map(a=>a.from==a.to||a.from==a.to-1&&n.doc.lineAt(a.from).to==a.from?$.widget({widget:new cm(a),diagnostic:a}).range(a.from):$.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity},diagnostic:a}).range(a.from,a.to)),!0);return new bn(s,r,ss(s))}};function ss(t,e=null,r=0){let n=null;return t.between(r,1e9,(i,o,{spec:s})=>{if(!(e&&s.diagnostic!=e))return n=new lm(i,o,s.diagnostic),!1}),n}function AR(t,e){return!!(t.effects.some(r=>r.is(fm))||t.changes.touchesRange(e.pos))}function ww(t,e){return t.field(Lt,!1)?e:e.concat(W.appendConfig.of([Lt,B.decorations.compute([Lt],r=>{let{selected:n,panel:i}=r.field(Lt);return!n||!i||n.from==n.to?$.none:$.set([OR.range(n.from,n.to)])}),hk(RR,{hideOn:AR}),LR]))}function TR(t,e){return{effects:ww(t,[fm.of(e)])}}var fm=W.define(),um=W.define(),xw=W.define(),Lt=ce.define({create(){return new bn($.none,null,null)},update(t,e){if(e.docChanged){let r=t.diagnostics.map(e.changes),n=null;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);n=ss(r,t.selected.diagnostic,i)||ss(r,null,i)}t=new bn(r,t.panel,n)}for(let r of e.effects)r.is(fm)?t=bn.init(r.value,t.panel,e.state):r.is(um)?t=new bn(t.diagnostics,r.value?as.open:null,t.selected):r.is(xw)&&(t=new bn(t.diagnostics,t.panel,r.value));return t},provide:t=>[Li.from(t,e=>e.panel),B.decorations.from(t,e=>e.diagnostics)]});var OR=$.mark({class:"cm-lintRange cm-lintRange-active"});function RR(t,e,r){let{diagnostics:n}=t.state.field(Lt),i=[],o=2e8,s=0;n.between(e-(r<0?1:0),e+(r>0?1:0),(l,c,{spec:f})=>{e>=l&&e<=c&&(l==c||(e>l||r>0)&&(eCw(t,r,!1)))}var MR=t=>{let e=t.state.field(Lt,!1);(!e||!e.panel)&&t.dispatch({effects:ww(t.state,[um.of(!0)])});let r=Bi(t,as.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},vw=t=>{let e=t.state.field(Lt,!1);return!e||!e.panel?!1:(t.dispatch({effects:um.of(!1)}),!0)},DR=t=>{let e=t.state.field(Lt,!1);if(!e)return!1;let r=t.state.selection.main,n=e.diagnostics.iter(r.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==r.from&&n.to==r.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Sw=[{key:"Mod-Shift-m",run:MR},{key:"F8",run:DR}],NR=de.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(os);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let t=Date.now();if(tPromise.resolve(n(this.view)))).then(n=>{let i=n.reduce((o,s)=>o.concat(s));this.view.state.doc==e.doc&&this.view.dispatch(TR(this.view.state,i))},n=>{at(this.view.state,n)})}}update(t){let e=t.state.facet(os);(t.docChanged||e!=t.startState.facet(os))&&(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)}}),os=j.define({combine(t){return Object.assign({sources:t.map(e=>e.source)},gt(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null}))},enables:NR});function _w(t){let e=[];if(t)e:for(let{name:r}of t){for(let n=0;no.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function Cw(t,e,r){var n;let i=r?_w(e.actions):[];return ue("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ue("span",{class:"cm-diagnosticText"},e.message),(n=e.actions)===null||n===void 0?void 0:n.map((o,s)=>{let a=u=>{u.preventDefault();let h=ss(t.state.field(Lt).diagnostics,e);h&&o.apply(t,h.from,h.to)},{name:l}=o,c=i[s]?l.indexOf(i[s]):-1,f=c<0?l:[l.slice(0,c),ue("u",l.slice(c,c+1)),l.slice(c+1)];return ue("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${l}${c<0?"":` (access key "${i[s]})"`}.`},f)}),e.source&&ue("div",{class:"cm-diagnosticSource"},e.source))}var cm=class extends Nt{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ue("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},eu=class{constructor(e,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Cw(e,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},as=class{constructor(e){this.view=e,this.items=[];let r=i=>{if(i.keyCode==27)vw(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=_w(o.actions);for(let a=0;a{for(let o=0;ovw(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(Lt).selected;if(!e)return-1;for(let r=0;r{let c=-1,f;for(let u=n;un&&(this.items.splice(n,c-n),i=!0)),r&&f.diagnostic==r.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),o=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),n++});n({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:s,panel:a})=>{s.topa.bottom&&(this.list.scrollTop+=s.bottom-a.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function r(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)r();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)r()}moveSelection(e){if(this.selectedIndex<0)return;let r=this.view.state.field(Lt),n=ss(r.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:xw.of(n)})}static open(e){return new as(e)}};function PR(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function am(t){return PR(``,'width="6" height="3"')}var LR=B.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-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:am("#d11")},".cm-lintRange-warning":{backgroundImage:am("orange")},".cm-lintRange-info":{backgroundImage:am("#999")},".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-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}}});var Aw=[yk(),bk(),ak(),Rv(),Uk(),rk(),sk(),G.allowMultipleSelections.of(!0),Lk(),Wk(qk,{fallback:!0}),Jk(),fv(),If(),ck(),fk(),lk(),gw(),Ii.of([...dv,...aw,...kw,...Pv,...zk,...Vp,...Sw])];var nr=Object.freeze({assertDefined(t){if(t===void 0)throw new Error(`'${nr.stringify(t)}' is 'undefined'`)},assertNever(t){throw new Error(`'${nr.stringify(t)}' is not of type 'never'`)},assertTrue(t,e){if(!t)throw new Error(`Assertion failed: ${e}. '${nr.stringify(t)}' should be true.`)},estimateMemoryUsage(t){let n=0,i=new Set,o=[t];for(;o.length;){let s=o.pop();switch(typeof s){case"bigint":{let a=Math.ceil(Math.log2(Number(s)));n+=(2+Math.ceil(a/64))*8;break}case"boolean":n+=8;break;case"number":n+=8;break;case"object":if(n+=8,!s||i.has(s))break;n+=8;for(let a of Object.values(s))o.push(a),n+=8;i.add(s);break;case"string":n+=s.length*2;break;case"symbol":n+=8;break;default:break}}return n},stringify(t){if(t&&typeof t=="object")try{let e=new Set;return JSON.stringify(t,(r,n)=>n&&typeof n=="object"?e.has(n)?"[Circular]":(e.add(n),n):n)}catch{return`{ ${Object.entries(t).map(([r,n])=>`'${r}': '${String(n)}'`).join(", ")} }`}else return typeof t=="symbol"?String(t):`${t}`}});var Tw=Object.freeze({is(t){return t.startsWith("http:")||t.startsWith("https:")}}),rj=Object.freeze({mock(t){return new hm(t)}}),hm=class{options;constructor(e){this.options=e}async get(e){if(!this.options.fixtures[e])throw new Error(`404 not found: ${e}`);let r=this.options.fixtures[e];return r instanceof Uint8Array?r:typeof r=="string"?new TextEncoder().encode(r):new TextEncoder().encode(JSON.stringify(r))}};var ls;(function(t){function e(){return console}t.create=e;function r(){return new dm}t.noop=r})(ls||(ls={}));var dm=class{error(){}info(){}log(){}warn(){}};var qa=class{parent;constructor(e){this.parent=e}undoOps=[];redoOps=[];addUndoOp(e){this.undoOps.push(e),this.parent?.addUndoOp(e)}addRedoOp(e){this.redoOps.push(e),this.parent?.addRedoOp(e)}set(e,r,n,i=e){let o=Reflect.get(e,r,i),s=()=>{Reflect.set(e,r,n,i)},a=()=>{Reflect.set(e,r,o,i)};this.addRedoOp(s),this.addUndoOp(a),s()}undo(){for(let e=this.undoOps.length-1;e>=0;e--)this.undoOps[e]()}redo(){this.redoOps.forEach(e=>e())}};var Mw=Br(tu(),1),Dw=Br(ru(),1),It=URL;function nu(t=e=>e[0]){return(e,r,n)=>{let i=new Map,o=n.value;return n.value=function(...s){let a=t(s);if(i.has(a))return i.get(a);let l=o.apply(this,s).then(c=>(i.delete(a),c),c=>(i.delete(a),Promise.reject(c)));return i.set(a,l),l},n}}var q;(function(t){t.TagPrefix="#",t.NamespacePathSep=":",t.PathSep="/",t.DefaultNamespace="minecraft";function e(n){switch(n.indexOf(t.NamespacePathSep)){case-1:return`${t.DefaultNamespace}${t.NamespacePathSep}${n}`;case 0:return`${t.DefaultNamespace}${n}`;default:return n}}t.lengthen=e;function r(n){return n.replace(/^(?:minecraft)?:/,"")}t.shorten=r})(q||(q={}));function ir(t){return new TextDecoder().decode(t)}var Ue;(function(t){function e(n,i){return Array.isArray(n)?n.every(o=>i(o)):i(n)}t.is=e;function r(n){return Array.isArray(n)?n:[n]}t.toArray=r})(Ue||(Ue={}));var Gn;(function(t){function e(r){return typeof r=="string"}t.isString=e})(Gn||(Gn={}));async function pm(t,e){return JSON.parse(ir(await t.archive.gunzip(e)))}function Ew(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ka(t,e){let r=(0,Dw.default)()(t);for(let[n,i]of Object.entries(e))Ew(r[n])&&Ew(i)?r[n]=Ka(r[n],i):i===void 0?delete r[n]:r[n]=i;return r}var Zn;(function(t){let e=Symbol("LazyDiscriminator");function r(s){return{discriminator:e,getter:s}}t.create=r;function n(s){return s?.discriminator===e}t.isComplex=n;function i(s){return n(s)&&!("value"in s)}t.isUnresolved=i;function o(s){return i(s)?s.value=s.getter():s}t.resolve=o})(Zn||(Zn={}));function Ga(t,e,r){let n={};e=e.map(q.lengthen);for(let i of e)r.symbols.query(r.doc,t,i).forEachMember((o,s)=>{let a=Object.keys(s.visibleMembers),l=n[o]??=new Set,c=s.symbol?.relations?.default;c&&l.add(c.path[c.path.length-1]);for(let f of a)l.add(f)});return Object.fromEntries(Object.entries(n).map(([i,o])=>[i,[...o]]))}var Nw=Mw.default;function Pw(t){return!!t[Symbol.iterator]}function Za(t,e){return e>=0?t?.[e]:t?.[t.length+e]}function iu(t,e,r){if(t.has(e)){let n=t.get(e);return r.update&&(n=r.update(n,e,t),t.set(e,n)),n}else if(r.insert){let n=r.insert(e,t);return t.set(e,n),n}else throw new Error(`No key ${e} in map and no insert handler provided`)}function ou(t){return typeof t=="function"||!!t&&typeof t=="object"}function Lw(t){let e=new It(t);return e.pathname=e.pathname.replace(/%3A/gi,":"),e.toString()}var jR=Object.freeze({create(t){return new Proxy(t,new mm)}}),mm=class{map=new Map;get(e,r,n){let i=Reflect.get(e,r,n);return r!=="prototype"&&ou(i)?iu(this.map,r,{insert:()=>jR.create(i)}):i}set(e,r,n,i){throw new TypeError(`Cannot set property '${String(r)}' on a readonly proxy`)}deleteProperty(e,r){throw new TypeError(`Cannot delete property '${String(r)}' on a readonly proxy`)}};var gm=Symbol("StateBranchOff"),ym=Symbol("IsStateProxy"),bm=Symbol("OriginState"),km=Symbol("RedoStateChanges"),vm=Symbol("UndoStateChanges"),Qe=Object.freeze({branchOff(t){return t[gm]()},create(t){if(Qe.is(t))throw new TypeError("Cannot create a proxy over a proxy. You might want to use branchOff instead.");return xm(t,new qa)},dereference(t){return Qe.is(t)?t[bm]:t},is(t){return t?.[ym]},redoChanges(t){t[km]()},undoChanges(t){t[vm]()}}),su,Iw,wm=class{constructor(e){E(this,su);H(this,"rootOps");H(this,"map",new Map);this.rootOps=e}get(e,r,n){switch(r){case gm:return()=>e0(this,su,Iw).call(this,e);case ym:return!0;case bm:return e;case km:return()=>this.rootOps.redo();case vm:return()=>this.rootOps.undo()}let i=Reflect.get(e,r,n);return r!=="prototype"&&ou(i)?iu(this.map,r,{insert:()=>xm(i,this.rootOps)}):i}set(e,r,n,i){if(r===gm||r===ym||r===bm||r===km||r===vm)throw new TypeError(`Cannot set ${String(r)}`);return this.rootOps.set(e,r,Qe.dereference(n),i),!0}};su=new WeakSet,Iw=function(e){return xm(e,new qa(this.rootOps))};function xm(t,e){return new Proxy(t,new wm(e))}var au=class{_map=new Map;_reversedMap=new Map;constructor(e=[]){for(let[r,n]of e)this._map.set(r,n),this._reversedMap.set(n,r)}get size(){return this._map.size}clear(){this._map.clear(),this._reversedMap.clear()}delete(e){let r=this._map.get(e),n=this._map.delete(e);return r!==void 0&&this._reversedMap.delete(r),n}deleteValue(e){let r=this._reversedMap.get(e),n=this._reversedMap.delete(e);return r!==void 0&&this._map.delete(r),n}get(e){return this._map.get(e)}getKey(e){return this._reversedMap.get(e)}has(e){return this._map.has(e)}hasValue(e){return this._reversedMap.has(e)}set(e,r){return this._map.set(e,r),this._reversedMap.set(r,e),this}forEach(e,r){for(let[n,i]of this._map)e.apply(r,[i,n,this])}entries(){return this._map.entries()}keys(){return this._map.keys()}values(){return this._map.values()}[Symbol.iterator](){return this._map.entries()}[Symbol.toStringTag]="TwoWayMap"};var jw=Br(tu(),1);var $R=`\r +var zC=Object.create;var Mc=Object.defineProperty;var FC=Object.getOwnPropertyDescriptor;var VC=Object.getOwnPropertyNames;var UC=Object.getPrototypeOf,HC=Object.prototype.hasOwnProperty;var WC=(t,e,r)=>e in t?Mc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var t0=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Dc=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),yr=(t,e)=>{for(var r in e)Mc(t,r,{get:e[r],enumerable:!0})},qC=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of VC(e))!HC.call(t,i)&&i!==r&&Mc(t,i,{get:()=>e[i],enumerable:!(n=FC(e,i))||n.enumerable});return t};var Br=(t,e,r)=>(r=t!=null?zC(UC(t)):{},qC(e||!t||!t.__esModule?Mc(r,"default",{value:t,enumerable:!0}):r,t));var H=(t,e,r)=>(WC(t,typeof e!="symbol"?e+"":e,r),r),od=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var g=(t,e,r)=>(od(t,e,"read from private field"),r?r.call(t):e.get(t)),E=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},L=(t,e,r,n)=>(od(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),r0=(t,e,r,n)=>({set _(i){L(t,e,i,r)},get _(){return g(t,e,n)}}),n0=(t,e,r)=>(od(t,e,"access private method"),r);var tu=Dc((uj,Mw)=>{Mw.exports=function(t,e,r,n,i){var o,s;if(n===void 0)n=0;else if(n=n|0,n<0||n>=t.length)throw new RangeError("invalid lower bound");if(i===void 0)i=t.length-1;else if(i=i|0,i=t.length)throw new RangeError("invalid upper bound");for(;n<=i;)if(o=n+(i-n>>>1),s=+r(t[o],e,o,t),s<0)n=o+1;else if(s>0)i=o-1;else return o;return~n}});var ru=Dc((hj,Dw)=>{"use strict";Dw.exports=$R;function cs(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function $R(t){if(t=t||{},t.circles)return zR(t);return t.proto?n:r;function e(i,o){for(var s=Object.keys(i),a=new Array(s.length),l=0;l{(function(t){if(typeof pu=="object"&&typeof pu.exports=="object"){var e=t(t0,Yw);e!==void 0&&(pu.exports=e)}else typeof define=="function"&&define.amd&&define(["require","exports"],t)})(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TextDocument=void 0;class r{constructor(c,f,u,h){this._uri=c,this._languageId=f,this._version=u,this._content=h,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(c){if(c){let f=this.offsetAt(c.start),u=this.offsetAt(c.end);return this._content.substring(f,u)}return this._content}update(c,f){for(let u of c)if(r.isIncremental(u)){let h=s(u.range),d=this.offsetAt(h.start),p=this.offsetAt(h.end);this._content=this._content.substring(0,d)+u.text+this._content.substring(p,this._content.length);let b=Math.max(h.start.line,0),m=Math.max(h.end.line,0),k=this._lineOffsets,S=o(u.text,!1,d);if(m-b===S.length)for(let w=0,C=S.length;wc?h=p:u=p+1}let d=u-1;return{line:d,character:c-f[d]}}offsetAt(c){let f=this.getLineOffsets();if(c.line>=f.length)return this._content.length;if(c.line<0)return 0;let u=f[c.line],h=c.line+1{let w=S.range.start.line-_.range.start.line;return w===0?S.range.start.character-_.range.start.character:w}),m=0,k=[];for(let S of b){let _=h.offsetAt(S.range.start);if(_m&&k.push(p.substring(m,_)),S.newText.length&&k.push(S.newText),m=h.offsetAt(S.range.end)}return k.push(p.substr(m)),k.join("")}l.applyEdits=u})(n=e.TextDocument||(e.TextDocument={}));function i(l,c){if(l.length<=1)return l;let f=l.length/2|0,u=l.slice(0,f),h=l.slice(f);i(u,c),i(h,c);let d=0,p=0,b=0;for(;df.line||c.line===f.line&&c.character>f.character?{start:f,end:c}:l}function a(l){let c=s(l.range);return c!==l.range?{newText:l.newText,range:c}:l}})});var Ix=Dc((zu,Lx)=>{(function(t,e){typeof zu=="object"&&typeof Lx<"u"?e(zu):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t["base64-arraybuffer"]={}))})(zu,function(t){"use strict";for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=typeof Uint8Array>"u"?[]:new Uint8Array(256),n=0;n>2],f+=e[(a[l]&3)<<4|a[l+1]>>4],f+=e[(a[l+1]&15)<<2|a[l+2]>>6],f+=e[a[l+2]&63];return c%3===2?f=f.substring(0,f.length-1)+"=":c%3===1&&(f=f.substring(0,f.length-2)+"=="),f},o=function(s){var a=s.length*.75,l=s.length,c,f=0,u,h,d,p;s[s.length-1]==="="&&(a--,s[s.length-2]==="="&&a--);var b=new ArrayBuffer(a),m=new Uint8Array(b);for(c=0;c>4,m[f++]=(h&15)<<4|d>>2,m[f++]=(d&3)<<6|p&63;return b};t.decode=o,t.encode=i,Object.defineProperty(t,"__esModule",{value:!0})})});var ee=class{constructor(){}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,r,n){let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(r,this.length,i,1),qt.from(i,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){let n=[];return this.decompose(e,r,n,0),qt.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new Mi(this),o=new Mi(e);for(let s=r,a=r;;){if(i.next(s),o.next(s),s=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(a+=i.value.length,i.done||a>=n)return!0}}iter(e=1){return new Mi(this,e)}iterRange(e,r=this.length){return new Ic(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new Bc(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ee.empty:e.length<=32?new Se(e):qt.from(Se.split(e,[]))}},Se=class extends ee{constructor(e,r=KC(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.text[o],a=i+s.length;if((r?n:a)>=e)return new ad(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Se(i0(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=Lc(o.text,s.text.slice(),0,o.length);if(a.length<=32)n.push(new Se(a,s.length+o.length));else{let l=a.length>>1;n.push(new Se(a.slice(0,l)),new Se(a.slice(l)))}}else n.push(o)}replace(e,r,n){if(!(n instanceof Se))return super.replace(e,r,n);let i=Lc(this.text,Lc(n.text,i0(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Se(i,o):qt.from(Se.split(i,[]),o)}sliceString(e,r=this.length,n=` +`){let i="";for(let o=0,s=0;o<=r&&se&&s&&(i+=n),eo&&(i+=a.slice(Math.max(0,e-o),r-o)),o=l+1}return i}flatten(e){for(let r of this.text)e.push(r)}scanIdentical(){return 0}static split(e,r){let n=[],i=-1;for(let o of e)n.push(o),i+=o.length+1,n.length==32&&(r.push(new Se(n,i)),n=[],i=-1);return i>-1&&r.push(new Se(n,i)),r}},qt=class extends ee{constructor(e,r){super(),this.children=e,this.length=r,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.children[o],a=i+s.length,l=n+s.lines-1;if((r?l:a)>=e)return s.lineInner(e,r,n,i);i=a+1,n=l+1}}decompose(e,r,n,i){for(let o=0,s=0;s<=r&&o=s){let c=i&((s<=e?1:0)|(l>=r?2:0));s>=e&&l<=r&&!c?n.push(a):a.decompose(e-s,r-s,n,c)}s=l+1}}replace(e,r,n){if(n.lines=o&&r<=a){let l=s.replace(e-o,r-o,n),c=this.lines-s.lines+l.lines;if(l.lines>5-1&&l.lines>c>>5+1){let f=this.children.slice();return f[i]=l,new qt(f,this.length-(r-e)+n.length)}return super.replace(o,a,l)}o=a+1}return super.replace(e,r,n)}sliceString(e,r=this.length,n=` +`){let i="";for(let o=0,s=0;oe&&o&&(i+=n),es&&(i+=a.sliceString(e-s,r-s,n)),s=l+1}return i}flatten(e){for(let r of this.children)r.flatten(e)}scanIdentical(e,r){if(!(e instanceof qt))return 0;let n=0,[i,o,s,a]=r>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=r,o+=r){if(i==s||o==a)return n;let l=this.children[i],c=e.children[o];if(l!=c)return n+l.scanIdentical(c,r);n+=l.length+1}}static from(e,r=e.reduce((n,i)=>n+i.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new Se(d,r)}let i=Math.max(32,n>>5),o=i<<1,s=i>>1,a=[],l=0,c=-1,f=[];function u(d){let p;if(d.lines>o&&d instanceof qt)for(let b of d.children)u(b);else d.lines>s&&(l>s||!l)?(h(),a.push(d)):d instanceof Se&&l&&(p=f[f.length-1])instanceof Se&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,f[f.length-1]=new Se(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>i&&h(),l+=d.lines,c+=d.length+1,f.push(d))}function h(){l!=0&&(a.push(f.length==1?f[0]:qt.from(f,c)),c=-1,l=f.length=0)}for(let d of e)u(d);return h(),a.length==1?a[0]:new qt(a,r)}};ee.empty=new Se([""],0);function KC(t){let e=-1;for(let r of t)e+=r.length+1;return e}function Lc(t,e,r=0,n=1e9){for(let i=0,o=0,s=!0;o=r&&(l>n&&(a=a.slice(0,n-i)),i0?1:(e instanceof Se?e.text.length:e.children.length)<<1]}nextInner(e,r){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],o=this.offsets[n],s=o>>1,a=i instanceof Se?i.text.length:i.children.length;if(s==(r>0?a:0)){if(n==0)return this.done=!0,this.value="",this;r>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(r>0?0:1)){if(this.offsets[n]+=r,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(i instanceof Se){let l=i.text[s+(r<0?-1:0)];if(this.offsets[n]+=r,l.length>Math.max(0,e))return this.value=e==0?l:r>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[s+(r<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=r):(r<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(r>0?1:(l instanceof Se?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Ic=class{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new Mi(e,r>n?-1:1),this.pos=r>n?e.length:0,this.from=Math.min(r,n),this.to=Math.max(r,n)}nextInner(e,r){if(r<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,r<0?this.pos-this.to:this.from-this.pos);let n=r<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*r,this.value=i.length<=n?i:r<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Bc=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:r,lineBreak:n,value:i}=this.inner.next(e);return r?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(ee.prototype[Symbol.iterator]=function(){return this.iter()},Mi.prototype[Symbol.iterator]=Ic.prototype[Symbol.iterator]=Bc.prototype[Symbol.iterator]=function(){return this});var ad=class{constructor(e,r,n,i){this.from=e,this.to=r,this.number=n,this.text=i}get length(){return this.to-this.from}},Lo="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;tt)return Lo[e-1]<=t;return!1}function o0(t){return t>=127462&&t<=127487}var s0=8205;function gt(t,e,r=!0,n=!0){return(r?h0:ZC)(t,e,n)}function h0(t,e,r){if(e==t.length)return e;e&&d0(t.charCodeAt(e))&&p0(t.charCodeAt(e-1))&&e--;let n=$e(t,e);for(e+=St(n);e=0&&o0($e(t,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function ZC(t,e,r){for(;e>0;){let n=h0(t,e-2,r);if(n=56320&&t<57344}function p0(t){return t>=55296&&t<56320}function $e(t,e){let r=t.charCodeAt(e);if(!p0(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return d0(n)?(r-55296<<10)+(n-56320)+65536:r}function pa(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function St(t){return t<65536?1:2}var ld=/\r\n?|\n/,Je=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Je||(Je={})),Kt=class{constructor(e){this.sections=e}get length(){let e=0;for(let r=0;re)return o+(e-i);o+=a}else{if(n!=Je.Simple&&c>=e&&(n==Je.TrackDel&&ie||n==Je.TrackBefore&&ie))return null;if(c>e||c==e&&r<0&&!a)return e==i||r<0?o:o+l;o+=l}i=c}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return o}touchesRange(e,r=e){for(let n=0,i=0;n=0&&i<=r&&a>=e)return ir?"cover":!0;i=a}return!1}toString(){let e="";for(let r=0;r=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(r=>typeof r!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Kt(e)}},Oe=class extends Kt{constructor(e,r){super(e),this.inserted=r}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return cd(this,(r,n,i,o,s)=>e=e.replace(i,i+(n-r),s),!1),e}mapDesc(e,r=!1){return fd(this,e,r,!0)}invert(e){let r=this.sections.slice(),n=[];for(let i=0,o=0;i=0){r[i]=a,r[i+1]=s;let l=i>>1;for(;n.length0&&Ei(n,r,o.text),o.forward(f),a+=f}let c=e[s++];for(;a>1].toJSON()))}return e}static of(e,r,n){let i=[],o=[],s=0,a=null;function l(f=!1){if(!f&&!i.length)return;sh||u<0||h>r)throw new RangeError(`Invalid change range ${u} to ${h} (in doc of length ${r})`);let p=d?typeof d=="string"?ee.of(d.split(n||ld)):d:ee.empty,b=p.length;if(u==h&&b==0)return;us&&mt(i,u-s,-1),mt(i,h-u,b),Ei(o,i,p),s=h}}return c(e),l(!a),a}static empty(e){return new Oe(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let r=[],n=[];for(let i=0;ia&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)r.push(o[0],0);else{for(;n.length=0&&r<=0&&r==t[i+1]?t[i]+=e:e==0&&t[i]==0?t[i+1]+=r:n?(t[i]+=e,t[i+1]+=r):t.push(e,r)}function Ei(t,e,r){if(r.length==0)return;let n=e.length-2>>1;if(n>1])),!(r||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],l=t.sections[s++];e(i,c,o,f,u),i=c,o=f}}}function fd(t,e,r,n=!1){let i=[],o=n?[]:null,s=new Di(t),a=new Di(e);for(let l=0,c=0;;)if(s.ins==-1)l+=s.len,s.next();else if(a.ins==-1&&c=0&&(s.done||cc&&!s.done&&l+s.len=0){let f=0,u=l+s.len;for(;;)if(a.ins>=0&&c>l&&c+a.lenl||s.ins>=0&&s.len>l)&&(a||n.length>c),o.forward2(l),s.forward(l)}}}}var Di=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return r>=e.length?ee.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?ee.empty:r[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Nn=class{constructor(e,r,n){this.from=e,this.to=r,this.flags=n}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,r=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,r):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new Nn(n,i,this.flags)}extend(e,r=e){if(e<=this.anchor&&r>=this.anchor)return A.range(e,r);let n=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return A.range(this.anchor,n)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return A.range(e.anchor,e.head)}},A=class{constructor(e,r=0){this.ranges=e,this.mainIndex=r}map(e,r=-1){return e.empty?this:A.create(this.ranges.map(n=>n.map(e,r)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.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 A(e.ranges.map(r=>Nn.fromJSON(r)),e.main)}static single(e,r=e){return new A([A.range(e,r)],0)}static create(e,r=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;ie?4:0))}};function JC(t,e=0){let r=t[e];t.sort((n,i)=>n.from-i.from),e=t.indexOf(r);for(let n=1;ni.head?A.range(a,s):A.range(s,a))}}return new A(t,e)}function g0(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}var bd=0,j=class{constructor(e,r,n,i,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=i,this.extensions=o,this.id=bd++,this.default=e([])}static define(e={}){return new j(e.combine||(r=>r),e.compareInput||((r,n)=>r===n),e.compare||(e.combine?(r,n)=>r===n:kd),!!e.static,e.enables)}of(e){return new Io([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Io(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Io(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}};function kd(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}var Io=class{constructor(e,r,n,i){this.dependencies=e,this.facet=r,this.type=n,this.value=i,this.id=bd++}dynamicSlot(e){var r;let n=this.value,i=this.facet.compareInput,o=this.id,s=e[o]>>1,a=this.type==2,l=!1,c=!1,f=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?c=!0:((r=e[u.id])!==null&&r!==void 0?r:1)&1||f.push(e[u.id]);return{create(u){return u.values[s]=n(u),1},update(u,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||ud(u,f)){let d=n(u);if(a?!a0(d,u.values[s],i):!i(d,u.values[s]))return u.values[s]=d,1}return 0},reconfigure:(u,h)=>{let d=n(u),p=h.config.address[o];if(p!=null){let b=$c(h,p);if(this.dependencies.every(m=>m instanceof j?h.facet(m)===u.facet(m):m instanceof ce?h.field(m,!1)==u.field(m,!1):!0)||(a?a0(d,b,i):i(d,b)))return u.values[s]=b,0}return u.values[s]=d,1}}}};function a0(t,e,r){if(t.length!=e.length)return!1;for(let n=0;nt[l.id]),i=r.map(l=>l.type),o=n.filter(l=>!(l&1)),s=t[e.id]>>1;function a(l){let c=[];for(let f=0;fn===i),e);return e.provide&&(r.provides=e.provide(r)),r}create(e){let r=e.facet(l0).find(n=>n.field==this);return(r?.create||this.createF)(e)}slot(e){let r=e[this.id]>>1;return{create:n=>(n.values[r]=this.create(n),1),update:(n,i)=>{let o=n.values[r],s=this.updateF(o,i);return this.compareF(o,s)?0:(n.values[r]=s,1)},reconfigure:(n,i)=>i.config.address[this.id]!=null?(n.values[r]=i.field(this),0):(n.values[r]=this.create(n),1)}}init(e){return[this,l0.of({field:this,create:e})]}get extension(){return this}},Po={lowest:4,low:3,default:2,high:1,highest:0};function ca(t){return e=>new jc(e,t)}var hn={highest:ca(Po.highest),high:ca(Po.high),default:ca(Po.default),low:ca(Po.low),lowest:ca(Po.lowest)},jc=class{constructor(e,r){this.inner=e,this.prec=r}},jo=class{of(e){return new ua(this,e)}reconfigure(e){return jo.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},ua=class{constructor(e,r){this.compartment=e,this.inner=r}},$o=class{constructor(e,r,n,i,o,s){for(this.base=e,this.compartments=r,this.dynamicSlots=n,this.address=i,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,r,n){let i=[],o=Object.create(null),s=new Map;for(let h of XC(e,r,s))h instanceof ce?i.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of i)a[h.id]=c.length<<1,c.push(d=>h.slot(d));let f=n?.config.facets;for(let h in o){let d=o[h],p=d[0].facet,b=f&&f[h]||[];if(d.every(m=>m.type==0))if(a[p.id]=l.length<<1|1,kd(b,d))l.push(n.facet(p));else{let m=p.combine(d.map(k=>k.value));l.push(n&&p.compare(m,n.facet(p))?n.facet(p):m)}else{for(let m of d)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=c.length<<1,c.push(k=>m.dynamicSlot(k)));a[p.id]=c.length<<1,c.push(m=>YC(m,p,d))}}let u=c.map(h=>h(a));return new $o(e,s,u,a,l,o)}};function XC(t,e,r){let n=[[],[],[],[],[]],i=new Map;function o(s,a){let l=i.get(s);if(l!=null){if(l<=a)return;let c=n[l].indexOf(s);c>-1&&n[l].splice(c,1),s instanceof ua&&r.delete(s.compartment)}if(i.set(s,a),Array.isArray(s))for(let c of s)o(c,a);else if(s instanceof ua){if(r.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;r.set(s.compartment,c),o(c,a)}else if(s instanceof jc)o(s.inner,s.prec);else if(s instanceof ce)n[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Io)n[a].push(s),s.facet.extensions&&o(s.facet.extensions,a);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(c,a)}}return o(t,Po.default),n.reduce((s,a)=>s.concat(a))}function fa(t,e){if(e&1)return 2;let r=e>>1,n=t.status[r];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[r]=4;let i=t.computeSlot(t,t.config.dynamicSlots[r]);return t.status[r]=2|i}function $c(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}var y0=j.define(),b0=j.define({combine:t=>t.some(e=>e),static:!0}),k0=j.define({combine:t=>t.length?t[0]:void 0,static:!0}),v0=j.define(),w0=j.define(),x0=j.define(),S0=j.define({combine:t=>t.length?t[0]:!1}),br=class{constructor(e,r){this.type=e,this.value=r}static define(){return new hd}},hd=class{of(e){return new br(this,e)}},dd=class{constructor(e){this.map=e}of(e){return new W(this,e)}},W=class{constructor(e,r){this.type=e,this.value=r}map(e){let r=this.type.map(this.value,e);return r===void 0?void 0:r==this.value?this:new W(this.type,r)}is(e){return this.type==e}static define(e={}){return new dd(e.map||(r=>r))}static mapEffects(e,r){if(!e.length)return e;let n=[];for(let i of e){let o=i.map(r);o&&n.push(o)}return n}};W.reconfigure=W.define();W.appendConfig=W.define();var Re=class{constructor(e,r,n,i,o,s){this.startState=e,this.changes=r,this.selection=n,this.effects=i,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,n&&g0(n,r.newLength),o.some(a=>a.type==Re.time)||(this.annotations=o.concat(Re.time.of(Date.now())))}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 r of this.annotations)if(r.type==e)return r.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let r=this.annotation(Re.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}};Re.time=br.define();Re.userEvent=br.define();Re.addToHistory=br.define();Re.remote=br.define();function QC(t,e){let r=[];for(let n=0,i=0;;){let o,s;if(n=t[n]))o=t[n++],s=t[n++];else if(i=0;i--){let o=n[i](t);o instanceof Re?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof Re?t=o[0]:t=C0(e,Bo(o),!1)}return t}function tA(t){let e=t.startState,r=e.facet(x0),n=t;for(let i=r.length-1;i>=0;i--){let o=r[i](t);o&&Object.keys(o).length&&(n=_0(t,pd(e,o,t.changes.newLength),!0))}return n==t?t:new Re(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}var rA=[];function Bo(t){return t==null?rA:Array.isArray(t)?t:[t]}var je=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(je||(je={})),nA=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,md;try{md=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function iA(t){if(md)return md.test(t);for(let e=0;e"\x80"&&(r.toUpperCase()!=r.toLowerCase()||nA.test(r)))return!0}return!1}function oA(t){return e=>{if(!/\S/.test(e))return je.Space;if(iA(e))return je.Word;for(let r=0;r-1)return je.Word;return je.Other}}var G=class{constructor(e,r,n,i,o,s){this.config=e,this.doc=r,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(let a=0;ai.set(l,a)),r=null),i.set(s.value.compartment,s.value.extension)):s.is(W.reconfigure)?(r=null,n=s.value):s.is(W.appendConfig)&&(r=null,n=Bo(n).concat(s.value));let o;r?o=e.startState.values.slice():(r=$o.resolve(n,i,this),o=new G(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values),new G(r,e.newDoc,e.newSelection,o,(s,a)=>a.update(s,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:e},range:A.cursor(r.from+e.length)}))}changeByRange(e){let r=this.selection,n=e(r.ranges[0]),i=this.changes(n.changes),o=[n.range],s=Bo(n.effects);for(let a=1;as.spec.fromJSON(a,l)))}return G.create({doc:e.doc,selection:A.fromJSON(e.selection),extensions:r.extensions?i.concat([r.extensions]):i})}static create(e={}){let r=$o.resolve(e.extensions||[],new Map),n=e.doc instanceof ee?e.doc:ee.of((e.doc||"").split(r.staticFacet(G.lineSeparator)||ld)),i=e.selection?e.selection instanceof A?e.selection:A.single(e.selection.anchor,e.selection.head):A.single(0);return g0(i,n.length),r.staticFacet(b0)||(i=i.asSingle()),new G(r,n,i,r.dynamicSlots.map(()=>null),(o,s)=>s.create(o),null)}get tabSize(){return this.facet(G.tabSize)}get lineBreak(){return this.facet(G.lineSeparator)||` +`}get readOnly(){return this.facet(S0)}phrase(e){for(let r of this.facet(G.phrases))if(Object.prototype.hasOwnProperty.call(r,e))return r[e];return e}languageDataAt(e,r,n=-1){let i=[];for(let o of this.facet(y0))for(let s of o(this,r,n))Object.prototype.hasOwnProperty.call(s,e)&&i.push(s[e]);return i}charCategorizer(e){return oA(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:r,from:n,length:i}=this.doc.lineAt(e),o=this.charCategorizer(e),s=e-n,a=e-n;for(;s>0;){let l=gt(r,s,!1);if(o(r.slice(l,s))!=je.Word)break;s=l}for(;at.length?t[0]:4});G.lineSeparator=k0;G.readOnly=S0;G.phrases=j.define({compare(t,e){let r=Object.keys(t),n=Object.keys(e);return r.length==n.length&&r.every(i=>t[i]==e[i])}});G.languageData=y0;G.changeFilter=v0;G.transactionFilter=w0;G.transactionExtender=x0;jo.reconfigure=W.define();function yt(t,e,r={}){let n={};for(let i of t)for(let o of Object.keys(i)){let s=i[o],a=n[o];if(a===void 0)n[o]=s;else if(!(a===s||s===void 0))if(Object.hasOwnProperty.call(r,o))n[o]=r[o](a,s);else throw new Error("Config merge conflict for field "+o)}for(let i in e)n[i]===void 0&&(n[i]=e[i]);return n}var kr=class{eq(e){return this==e}range(e,r=e){return new ha(e,r,this)}};kr.prototype.startSide=kr.prototype.endSide=0;kr.prototype.point=!1;kr.prototype.mapMode=Je.TrackDel;var ha=class{constructor(e,r,n){this.from=e,this.to=r,this.value=n}};function gd(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var da=class{constructor(e,r,n,i){this.from=e,this.to=r,this.value=n,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,r,n,i=0){let o=n?this.to:this.from;for(let s=i,a=o.length;;){if(s==a)return s;let l=s+a>>1,c=o[l]-e||(n?this.value[l].endSide:this.value[l].startSide)-r;if(l==s)return c>=0?s:a;c>=0?a=l:s=l+1}}between(e,r,n,i){for(let o=this.findIndex(r,-1e9,!0),s=this.findIndex(n,1e9,!1,o);od||h==d&&c.startSide>0&&c.endSide<=0)continue;(d-h||c.endSide-c.startSide)<0||(s<0&&(s=h),c.point&&(a=Math.max(a,d-h)),n.push(c),i.push(h-s),o.push(d-s))}return{mapped:n.length?new da(i,o,n,a):null,pos:s}}},te=class{constructor(e,r,n=te.empty,i){this.chunkPos=e,this.chunk=r,this.nextLayer=n,this.maxPoint=i}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 r of this.chunk)e+=r.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:r=[],sort:n=!1,filterFrom:i=0,filterTo:o=this.length}=e,s=e.filter;if(r.length==0&&!s)return this;if(n&&(r=r.slice().sort(gd)),this.isEmpty)return r.length?te.of(r):this;let a=new zc(this,null,-1).goto(0),l=0,c=[],f=new Dt;for(;a.value||l=0){let u=r[l++];f.addInner(u.from,u.to,u.value)||c.push(u)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||oa.to||o=o&&e<=o+s.length&&s.between(o,e-o,r-o,n)===!1)return}this.nextLayer.between(e,r,n)}}iter(e=0){return Ni.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,r=0){return Ni.from(e).goto(r)}static compare(e,r,n,i,o=-1){let s=e.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=o),a=r.filter(u=>u.maxPoint>0||!u.isEmpty&&u.maxPoint>=o),l=c0(s,a,n),c=new Ri(s,l,o),f=new Ri(a,l,o);n.iterGaps((u,h,d)=>f0(c,u,f,h,d,i)),n.empty&&n.length==0&&f0(c,0,f,0,0,i)}static eq(e,r,n=0,i){i==null&&(i=1e9);let o=e.filter(f=>!f.isEmpty&&r.indexOf(f)<0),s=r.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(o.length!=s.length)return!1;if(!o.length)return!0;let a=c0(o,s),l=new Ri(o,a,0).goto(n),c=new Ri(s,a,0).goto(n);for(;;){if(l.to!=c.to||!yd(l.active,c.active)||l.point&&(!c.point||!l.point.eq(c.point)))return!1;if(l.to>i)return!0;l.next(),c.next()}}static spans(e,r,n,i,o=-1){let s=new Ri(e,null,o).goto(r),a=r,l=s.openStart;for(;;){let c=Math.min(s.to,n);if(s.point?(i.point(a,c,s.point,s.activeForPoint(s.to),l,s.pointRank),l=s.openEnd(c)+(s.to>c?1:0)):c>a&&(i.span(a,c,s.active,l),l=s.openEnd(c)),s.to>n)break;a=s.to,s.next()}return l}static of(e,r=!1){let n=new Dt;for(let i of e instanceof ha?[e]:r?sA(e):e)n.add(i.from,i.to,i.value);return n.finish()}};te.empty=new te([],[],null,-1);function sA(t){if(t.length>1)for(let e=t[0],r=1;r0)return t.slice().sort(gd);e=n}return t}te.empty.nextLayer=te.empty;var Dt=class{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}finishChunk(e){this.chunks.push(new da(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=[])}add(e,r,n){this.addInner(e,r,n)||(this.nextLayer||(this.nextLayer=new Dt)).add(e,r,n)}addInner(e,r,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(r-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=r,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,r-e)),!0)}addChunk(e,r){if((e-this.lastTo||r.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,r.maxPoint),this.chunks.push(r),this.chunkPos.push(e);let n=r.value.length-1;return this.last=r.value[n],this.lastFrom=r.from[n]+e,this.lastTo=r.to[n]+e,!0}finish(){return this.finishInner(te.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let r=new te(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,r}};function c0(t,e,r){let n=new Map;for(let o of t)for(let s=0;s=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=n&&i.push(new zc(s,r,n,o));return i.length==1?i[0]:new Ni(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,r=-1e9){for(let n of this.heap)n.goto(e,r);for(let n=this.heap.length>>1;n>=0;n--)sd(this.heap,n);return this.next(),this}forward(e,r){for(let n of this.heap)n.forward(e,r);for(let n=this.heap.length>>1;n>=0;n--)sd(this.heap,n);(this.to-e||this.value.endSide-r)<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(),sd(this.heap,0)}}};function sd(t,e){for(let r=t[e];;){let n=(e<<1)+1;if(n>=t.length)break;let i=t[n];if(n+1=0&&(i=t[n+1],n++),r.compare(i)<0)break;t[n]=r,t[e]=i,e=n}}var Ri=class{constructor(e,r,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ni.from(e,r,n)}goto(e,r=-1e9){return this.cursor.goto(e,r),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=r,this.openStart=-1,this.next(),this}forward(e,r){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-r)<0;)this.removeActive(this.minActive);this.cursor.forward(e,r)}removeActive(e){Nc(this.active,e),Nc(this.activeTo,e),Nc(this.activeRank,e),this.minActive=u0(this.active,this.activeTo)}addActive(e){let r=0,{value:n,to:i,rank:o}=this.cursor;for(;r-1&&(this.activeTo[o]-this.cursor.from||this.active[o].endSide-this.cursor.startSide)<0){if(this.activeTo[o]>e){this.to=this.activeTo[o],this.endSide=this.active[o].endSide;break}this.removeActive(o),n&&Nc(n,o)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(r&&this.cursor.to==this.to&&this.cursor.from=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&r.push(this.active[n]);return r.reverse()}openEnd(e){let r=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)r++;return r}};function f0(t,e,r,n,i,o){t.goto(e),r.goto(n);let s=n+i,a=n,l=n-e;for(;;){let c=t.to+l-r.to||t.endSide-r.endSide,f=c<0?t.to+l:r.to,u=Math.min(f,s);if(t.point||r.point?t.point&&r.point&&(t.point==r.point||t.point.eq(r.point))&&yd(t.activeForPoint(t.to+l),r.activeForPoint(r.to))||o.comparePoint(a,u,t.point,r.point):u>a&&!yd(t.active,r.active)&&o.compareRange(a,u,t.active,r.active),f>s)break;a=f,c<=0&&t.next(),c>=0&&r.next()}}function yd(t,e){if(t.length!=e.length)return!1;for(let r=0;r=e;n--)t[n+1]=t[n];t[e]=r}function u0(t,e){let r=-1,n=1e9;for(let i=0;i=e)return i;if(i==t.length)break;o+=t.charCodeAt(i)==9?r-o%r:1,i=gt(t,i)}return n===!0?-1:t.length}var vd="\u037C",A0=typeof Symbol>"u"?"__"+vd:Symbol.for(vd),wd=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),T0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Gt=class{constructor(e,r){this.rules=[];let{finish:n}=r||{};function i(s){return/^@/.test(s)?[s]:s.split(/,\s*/)}function o(s,a,l,c){let f=[],u=/^@(\w+)\b/.exec(s[0]),h=u&&u[1]=="keyframes";if(u&&a==null)return l.push(s[0]+";");for(let d in a){let p=a[d];if(/&/.test(d))o(d.split(/,\s*/).map(b=>s.map(m=>b.replace(/&/,m))).reduce((b,m)=>b.concat(m)),p,l);else if(p&&typeof p=="object"){if(!u)throw new RangeError("The value of a property ("+d+") should be a primitive value.");o(i(d),p,f,h)}else p!=null&&f.push(d.replace(/_.*/,"").replace(/[A-Z]/g,b=>"-"+b.toLowerCase())+": "+p+";")}(f.length||h)&&l.push((n&&!u&&!c?s.map(n):s).join(", ")+" {"+f.join(" ")+"}")}for(let s in e)o(i(s),e[s],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=T0[A0]||1;return T0[A0]=e+1,vd+e.toString(36)}static mount(e,r){(e[wd]||new xd(e)).mount(Array.isArray(r)?r:[r])}},Vc=null,xd=class{constructor(e){if(!e.head&&e.adoptedStyleSheets&&typeof CSSStyleSheet<"u"){if(Vc)return e.adoptedStyleSheets=[Vc.sheet].concat(e.adoptedStyleSheets),e[wd]=Vc;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),Vc=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[wd]=this}mount(e){let r=this.sheet,n=0,i=0;for(let o=0;o-1&&(this.modules.splice(a,1),i--,a=-1),a==-1){if(this.modules.splice(i++,0,s),r)for(let l=0;l",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},O0=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),aA=typeof navigator<"u"&&/Apple Computer/.test(navigator.vendor),lA=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),R0=typeof navigator<"u"&&/Mac/.test(navigator.platform),cA=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),fA=O0&&(R0||+O0[1]<57)||lA&&R0;for(Ne=0;Ne<10;Ne++)dn[48+Ne]=dn[96+Ne]=String(Ne);var Ne;for(Ne=1;Ne<=24;Ne++)dn[Ne+111]="F"+Ne;var Ne;for(Ne=65;Ne<=90;Ne++)dn[Ne]=String.fromCharCode(Ne+32),Hc[Ne]=String.fromCharCode(Ne);var Ne;for(Uc in dn)Hc.hasOwnProperty(Uc)||(Hc[Uc]=dn[Uc]);var Uc;function E0(t){var e=fA&&(t.ctrlKey||t.altKey||t.metaKey)||(aA||cA)&&t.shiftKey&&t.key&&t.key.length==1,r=!e&&t.key||(t.shiftKey?Hc:dn)[t.keyCode]||t.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}function Yc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Ho(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function uA(){let t=document.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Dd(t,e){if(!e.anchorNode)return!1;try{return Ho(t,e.anchorNode)}catch{return!1}}function Ca(t){return t.nodeType==3?Aa(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function Xc(t,e,r,n){return r?M0(t,e,r,n,-1)||M0(t,e,r,n,1):!1}function Nd(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function M0(t,e,r,n,i){for(;;){if(t==r&&e==n)return!0;if(e==(i<0?0:Qc(t))){if(t.nodeName=="DIV")return!1;let o=t.parentNode;if(!o||o.nodeType!=1)return!1;e=Nd(t)+(i<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?Qc(t):0}else return!1}}function Qc(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}var gb={left:0,right:0,top:0,bottom:0};function mf(t,e){let r=e?t.left:t.right;return{left:r,right:r,top:t.top,bottom:t.bottom}}function hA(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function dA(t,e,r,n,i,o,s,a){let l=t.ownerDocument,c=l.defaultView;for(let f=t;f;)if(f.nodeType==1){let u,h=f==l.body;if(h)u=hA(c);else{if(f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.parentNode;continue}let b=f.getBoundingClientRect();u={left:b.left,right:b.left+f.clientWidth,top:b.top,bottom:b.top+f.clientHeight}}let d=0,p=0;if(i=="nearest")e.top0&&e.bottom>u.bottom+p&&(p=e.bottom-u.bottom+p+s)):e.bottom>u.bottom&&(p=e.bottom-u.bottom+s,r<0&&e.top-p0&&e.right>u.right+d&&(d=e.right-u.right+d+o)):e.right>u.right&&(d=e.right-u.right+o,r<0&&e.leftr)return u.domBoundsAround(e,r,c);if(h>=e&&i==-1&&(i=l,o=c),c>r&&u.dom.parentNode==this.dom){s=l,a=f;break}f=h,c=h+u.breakAfter}return{from:o,to:a<0?n+this.length:a,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s=0?this.children[s].dom:null}}markDirty(e=!1){this.dirty|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let r=this.parent;r;r=r.parent){if(e&&(r.dirty|=2),r.dirty&1)return;r.dirty|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.dirty&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let r=e.parent;if(!r)return e;e=r}}replaceChildren(e,r,n=gp){this.markDirty();for(let i=e;ithis.pos||e==this.pos&&(r>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function kb(t,e,r,n,i,o,s,a,l){let{children:c}=t,f=c.length?c[e]:null,u=o.length?o[o.length-1]:null,h=u?u.breakAfter:s;if(!(e==n&&f&&!s&&!h&&o.length<2&&f.merge(r,i,o.length?u:null,r==0,a,l))){if(n0&&(!s&&o.length&&f.merge(r,f.length,o[0],!1,a,0)?f.breakAfter=o.shift().breakAfter:(r2),F={mac:I0||/Mac/.test(Nt.platform),windows:/Win/.test(Nt.platform),linux:/Linux|X11/.test(Nt.platform),ie:gf,ie_version:wb?Ld.documentMode||6:Bd?+Bd[1]:Id?+Id[1]:0,gecko:P0,gecko_version:P0?+(/Firefox\/(\d+)/.exec(Nt.userAgent)||[0,0])[1]:0,chrome:!!Sd,chrome_version:Sd?+Sd[1]:0,ios:I0,android:/Android\b/.test(Nt.userAgent),webkit:L0,safari:xb,webkit_version:L0?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Ld.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},mA=256,Fr=class extends ve{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,r,n){return n&&(!(n instanceof Fr)||this.length-(r-e)+n.length>mA)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(r),this.markDirty(),!0)}split(e){let r=new Fr(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),r}localPosFromDOM(e,r){return e==this.dom?r:r?this.text.length:0}domAtPos(e){return new Fe(this.dom,e)}domBoundsAround(e,r,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,r){return jd(this.dom,e,r)}},Zt=class extends ve{constructor(e,r=[],n=0){super(),this.mark=e,this.children=r,this.length=n;for(let i of r)i.setParent(this)}setAttrs(e){if(bb(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let r in this.mark.attrs)e.setAttribute(r,this.mark.attrs[r]);return e}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.dirty|=6)}sync(e){this.dom?this.dirty&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e)}merge(e,r,n,i,o,s){return n&&(!(n instanceof Zt&&n.mark.eq(this.mark))||e&&o<=0||re&&r.push(n=e&&(i=o),n=l,o++}let s=this.length-e;return this.length=e,i>-1&&(this.children.length=i,this.markDirty()),new Zt(this.mark,r,s)}domAtPos(e){return _b(this.dom,this.children,e)}coordsAt(e,r){return Ab(this,e,r)}};function jd(t,e,r){let n=t.nodeValue.length;e>n&&(e=n);let i=e,o=e,s=0;e==0&&r<0||e==n&&r>=0?F.chrome||F.gecko||(e?(i--,s=1):(o++,s=-1)):r<0?i--:o++;let a=Aa(t,i,o).getClientRects();if(!a.length)return gb;let l=a[(s?s<0:r>=0)?0:a.length-1];return F.safari&&!s&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),s?mf(l,s<0):l||null}var $r=class extends ve{constructor(e,r,n){super(),this.widget=e,this.length=r,this.side=n,this.prevWidget=null}static create(e,r,n){return new(e.customView||$r)(e,r,n)}split(e){let r=$r.create(this.widget,this.length-e,this.side);return this.length-=e,r}sync(){(!this.dom||!this.widget.updateDOM(this.dom))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,r,n,i,o,s){return n&&(!(n instanceof $r)||!this.widget.compare(n.widget)||e>0&&o<=0||r0?n.length-1:0;i=n[o],!(e>0?o==0:o==n.length-1||i.top0?-1:1);return e==0&&r>0||e==this.length&&r<=0?i:mf(i,e==0)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},tf=class extends $r{domAtPos(e){let{topView:r,text:n}=this.widget;return r?$d(e,0,r,n,(i,o)=>i.domAtPos(o),i=>new Fe(n,Math.min(i,n.nodeValue.length))):new Fe(n,Math.min(e,n.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(e,r){let{topView:n,text:i}=this.widget;return n?Sb(e,r,n,i):Math.min(r,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(e,r){let{topView:n,text:i}=this.widget;return n?$d(e,r,n,i,(o,s,a)=>o.coordsAt(s,a),(o,s)=>jd(i,o,s)):jd(i,e,r)}destroy(){var e;super.destroy(),(e=this.widget.topView)===null||e===void 0||e.destroy()}get isEditable(){return!0}};function $d(t,e,r,n,i,o){if(r instanceof Zt){for(let s of r.children){let a=Ho(s.dom,n),l=a?n.nodeValue.length:s.length;if(t0?-1:1);return n&&n.topr.top?{left:r.left,right:r.right,top:n.top,bottom:n.bottom}:r}get overrideDOMText(){return ee.empty}};Fr.prototype.children=$r.prototype.children=jn.prototype.children=gp;function gA(t,e){let r=t.parent,n=r?r.children.indexOf(t):-1;for(;r&&n>=0;)if(e<0?n>0:ni&&r0;n--){let i=e[n-1].dom;if(i.parentNode==t)return Fe.after(i)}return new Fe(t,0)}function Cb(t,e,r){let n,{children:i}=t;r>0&&e instanceof Zt&&i.length&&(n=i[i.length-1])instanceof Zt&&n.mark.eq(e.mark)?Cb(n,e.children[0],r-1):(i.push(e),e.setParent(t)),t.length+=e.length}function Ab(t,e,r){for(let o=0,s=0;s0?l>=e:l>e)&&(e0)){let f=0;if(l==o){if(a.getSide()<=0)continue;f=r=-a.getSide()}let u=a.coordsAt(Math.max(0,e-o),r);return f&&u?mf(u,r<0):u}o=l}let n=t.dom.lastChild;if(!n)return t.dom.getBoundingClientRect();let i=Ca(n);return i[i.length-1]||null}function zd(t,e){for(let r in t)r=="class"&&e.class?e.class+=" "+t.class:r=="style"&&e.style?e.style+=";"+t.style:e[r]=t[r];return e}function yp(t,e){if(t==e)return!0;if(!t||!e)return!1;let r=Object.keys(t),n=Object.keys(e);if(r.length!=n.length)return!1;for(let i of r)if(n.indexOf(i)==-1||t[i]!==e[i])return!1;return!0}function Fd(t,e,r){let n=null;if(e)for(let i in e)r&&i in r||t.removeAttribute(n=i);if(r)for(let i in r)e&&e[i]==r[i]||t.setAttribute(n=i,r[i]);return!!n}var Pt=class{eq(e){return!1}updateDOM(e){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}ignoreEvent(e){return!0}get customView(){return null}destroy(e){}},he=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(he||(he={})),$=class extends kr{constructor(e,r,n,i){super(),this.startSide=e,this.endSide=r,this.widget=n,this.spec=i}get heightRelevant(){return!1}static mark(e){return new Wo(e)}static widget(e){let r=e.side||0,n=!!e.block;return r+=n?r>0?3e8:-4e8:r>0?1e8:-1e8,new mn(e,r,r,n,e.widget||null,!1)}static replace(e){let r=!!e.block,n,i;if(e.isBlockGap)n=-5e8,i=4e8;else{let{start:o,end:s}=Tb(e,r);n=(o?r?-3e8:-1:5e8)-1,i=(s?r?2e8:1:-6e8)+1}return new mn(e,n,i,r,e.widget||null,!0)}static line(e){return new Pi(e)}static set(e,r=!1){return te.of(e,r)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};$.none=te.empty;var Wo=class extends ${constructor(e){let{start:r,end:n}=Tb(e);super(r?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){return this==e||e instanceof Wo&&this.tagName==e.tagName&&this.class==e.class&&yp(this.attrs,e.attrs)}range(e,r=e){if(e>=r)throw new RangeError("Mark decorations may not be empty");return super.range(e,r)}};Wo.prototype.point=!1;var Pi=class extends ${constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Pi&&yp(this.spec.attributes,e.spec.attributes)}range(e,r=e){if(r!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,r)}};Pi.prototype.mapMode=Je.TrackBefore;Pi.prototype.point=!0;var mn=class extends ${constructor(e,r,n,i,o,s){super(r,n,o,e),this.block=i,this.isReplace=s,this.mapMode=i?r<=0?Je.TrackBefore:Je.TrackAfter:Je.TrackDel}get type(){return this.startSide=5}eq(e){return e instanceof mn&&yA(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,r=e){if(this.isReplace&&(e>r||e==r&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&r!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,r)}};mn.prototype.point=!0;function Tb(t,e=!1){let{inclusiveStart:r,inclusiveEnd:n}=t;return r==null&&(r=t.inclusive),n==null&&(n=t.inclusive),{start:r??e,end:n??e}}function yA(t,e){return t==e||!!(t&&e&&t.compare(e))}function Vd(t,e,r,n=0){let i=r.length-1;i>=0&&r[i]+n>=t?r[i]=Math.max(r[i],e):r.push(t,e)}var Ye=class extends ve{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,r,n,i,o,s){if(n){if(!(n instanceof Ye))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),vb(this,e,r,n?n.children:[],o,s),!0}split(e){let r=new Ye;if(r.breakAfter=this.breakAfter,this.length==0)return r;let{i:n,off:i}=this.childPos(e);i&&(r.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let o=n;o0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,r}transferDOM(e){this.dom&&(e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){yp(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,r){Cb(this,e,r)}addLineDeco(e){let r=e.spec.attributes,n=e.spec.class;r&&(this.attrs=zd(r,this.attrs||{})),n&&(this.attrs=zd({class:n},this.attrs||{}))}domAtPos(e){return _b(this.dom,this.children,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.dirty|=6)}sync(e){var r;this.dom?this.dirty&4&&(bb(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&&(Fd(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e);let n=this.dom.lastChild;for(;n&&ve.get(n)instanceof Zt;)n=n.lastChild;if(!n||!this.length||n.nodeName!="BR"&&((r=ve.get(n))===null||r===void 0?void 0:r.isEditable)==!1&&(!F.ios||!this.children.some(i=>i instanceof Fr))){let i=document.createElement("BR");i.cmIgnore=!0,this.dom.appendChild(i)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0;for(let r of this.children){if(!(r instanceof Fr))return null;let n=Ca(r.dom);if(n.length!=1)return null;e+=n[0].width}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length}}coordsAt(e,r){return Ab(this,e,r)}become(e){return!1}get type(){return he.Text}static find(e,r){for(let n=0,i=0;n=r){if(o instanceof Ye)return o;if(s>r)break}i=s+o.breakAfter}return null}},pn=class extends ve{constructor(e,r,n){super(),this.widget=e,this.length=r,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,r,n,i,o,s){return n&&(!(n instanceof pn)||!this.widget.compare(n.widget)||e>0&&o<=0||r0;){if(this.textOff==this.text.length){let{value:o,lineBreak:s,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(s){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer([]),this.curLine=null,e--;continue}else this.text=o,this.textOff=0}let i=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(r.slice(0,n)),this.getLine().append(Wc(new Fr(this.text.slice(this.textOff,this.textOff+i)),r),n),this.atCursorPos=!0,this.textOff+=i,e-=i,n=0}}span(e,r,n,i){this.buildText(r-e,n,i),this.pos=r,this.openStart<0&&(this.openStart=i)}point(e,r,n,i,o,s){if(this.disallowBlockEffectsFor[s]&&n instanceof mn){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(r>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let a=r-e;if(n instanceof mn)if(n.block){let{type:l}=n;l==he.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new pn(n.widget||new rf("div"),a,l))}else{let l=$r.create(n.widget||new rf("span"),a,n.startSide),c=this.atCursorPos&&!l.isEditable&&o<=i.length&&(e0),f=!l.isEditable&&(et.some(e=>e)}),qo=class{constructor(e,r="nearest",n="nearest",i=5,o=5){this.range=e,this.y=r,this.x=n,this.yMargin=i,this.xMargin=o}map(e){return e.empty?this:new qo(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}},B0=W.define({map:(t,e)=>t.map(e)});function lt(t,e,r){let n=t.facet(Mb);n.length?n[0](e):window.onerror?window.onerror(String(e),r,void 0,void 0,e):r?console.error(r+":",e):console.error(e)}var Ma=j.define({combine:t=>t.length?t[0]:!0}),bA=0,ma=j.define(),de=class{constructor(e,r,n,i){this.id=e,this.create=r,this.domEventHandlers=n,this.extension=i(this)}static define(e,r){let{eventHandlers:n,provide:i,decorations:o}=r||{};return new de(bA++,e,n,s=>{let a=[ma.of(s)];return o&&a.push(Oa.of(l=>{let c=l.plugin(s);return c?o(c):$.none})),i&&a.push(i(s)),a})}static fromClass(e,r){return de.define(n=>new e(n),r)}},wa=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let r=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(r)}catch(n){if(lt(r.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(r){lt(e.state,r,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var r;if(!((r=this.value)===null||r===void 0)&&r.destroy)try{this.value.destroy()}catch(n){lt(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Pb=j.define(),Lb=j.define(),Oa=j.define(),Ib=j.define(),Bb=j.define(),ga=j.define(),vr=class{constructor(e,r,n,i){this.fromA=e,this.toA=r,this.fromB=n,this.toB=i}join(e){return new vr(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 r=e.length,n=this;for(;r>0;r--){let i=e[r-1];if(!(i.fromA>n.toA)){if(i.toAf)break;o+=2}if(!l)return n;new vr(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),s=l.toA,a=l.toB}}},Ko=class{constructor(e,r,n){this.view=e,this.state=r,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Oe.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let i=[];this.changes.iterChangedRanges((s,a,l,c)=>i.push(new vr(s,a,l,c))),this.changedRanges=i;let o=e.hasFocus;o!=e.inputState.notifiedFocused&&(e.inputState.notifiedFocused=o,this.flags|=1)}static create(e,r,n){return new Ko(e,r,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},ye=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(ye||(ye={})),Hd=ye.LTR,kA=ye.RTL;function jb(t){let e=[];for(let r=0;r=r){if(a.level==n)return s;(o<0||(i!=0?i<0?a.fromr:e[o].level>a.level))&&(o=s)}}if(o<0)throw new RangeError("Index out of range");return o}},_e=[];function _A(t,e){let r=t.length,n=e==Hd?1:2,i=e==Hd?2:1;if(!t||n==1&&!SA.test(t))return $b(r);for(let s=0,a=n,l=n;s=0;h-=3)if(jr[h+1]==-f){let d=jr[h+2],p=d&2?n:d&4?d&1?i:n:0;p&&(_e[s]=_e[jr[h]]=p),a=h;break}}else{if(jr.length==189)break;jr[a++]=s,jr[a++]=c,jr[a++]=l}else if((u=_e[s])==2||u==1){let h=u==n;l=h?0:1;for(let d=a-3;d>=0;d-=3){let p=jr[d+2];if(p&2)break;if(h)jr[d+2]|=2;else{if(p&4)break;jr[d+2]|=4}}}for(let s=0;sa;){let f=c,u=_e[--c]!=2;for(;c>a&&u==(_e[c-1]!=2);)c--;o.push(new Bn(c,f,u?2:1))}else o.push(new Bn(a,s,0))}else for(let s=0;s1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=s-1);n=o+s}}readNode(e){if(e.cmIgnore)return;let r=ve.get(e),n=r&&r.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let i=n.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.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,r){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==r&&(n.pos=this.text.length)}findPointInside(e,r){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+Math.min(r,n.offset))}};function j0(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}var of=class{constructor(e,r){this.node=e,this.offset=r,this.pos=-1}},sf=class extends ve{constructor(e){super(),this.view=e,this.compositionDeco=$.none,this.decorations=[],this.dynamicDecorationMap=[],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 Ye],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new vr(0,0,0,e.state.doc.length)],0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(e){let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:s,toA:a})=>athis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=$.none:(e.transactions.length||this.dirty)&&(this.compositionDeco=TA(this.view,e.changes)),(F.ie||F.chrome)&&!this.compositionDeco.size&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let n=this.decorations,i=this.updateDeco(),o=RA(n,i,e.changes);return r=vr.extendWithRanges(r,o),this.dirty==0&&r.length==0?!1:(this.updateInner(r,e.startState.doc.length),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,r){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,r);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";let o=F.chrome||F.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(o),this.dirty=0,o&&(o.written||n.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to=0?e[i]:null;if(!o)break;let{fromA:s,toA:a,fromB:l,toB:c}=o,{content:f,breakAtStart:u,openStart:h,openEnd:d}=Ta.build(this.view.state.doc,l,c,this.decorations,this.dynamicDecorationMap),{i:p,off:b}=n.findPos(a,1),{i:m,off:k}=n.findPos(s,-1);kb(this,m,k,p,b,f,u,h,d)}}updateSelection(e=!1,r=!1){if(e&&this.view.observer.readSelectionRange(),!(r||this.mayControlSelection())||F.ios&&this.view.inputState.rapidCompositionStart)return;let n=this.forceSelection;this.forceSelection=!1;let i=this.view.state.selection.main,o=this.domAtPos(i.anchor),s=i.empty?o:this.domAtPos(i.head);if(F.gecko&&i.empty&&AA(o)){let l=document.createTextNode("");this.view.observer.ignore(()=>o.node.insertBefore(l,o.node.childNodes[o.offset]||null)),o=s=new Fe(l,0),n=!0}let a=this.view.observer.selectionRange;(n||!a.focusNode||!Xc(o.node,o.offset,a.anchorNode,a.anchorOffset)||!Xc(s.node,s.offset,a.focusNode,a.focusOffset))&&(this.view.observer.ignore(()=>{F.android&&F.chrome&&this.dom.contains(a.focusNode)&&EA(a.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let l=Yc(this.root);if(i.empty){if(F.gecko){let c=OA(o.node,o.offset);if(c&&c!=3){let f=Vb(o.node,o.offset,c==1?1:-1);f&&(o=new Fe(f,c==1?0:f.nodeValue.length))}}l.collapse(o.node,o.offset),i.bidiLevel!=null&&a.cursorBidiLevel!=null&&(a.cursorBidiLevel=i.bidiLevel)}else if(l.extend)l.collapse(o.node,o.offset),l.extend(s.node,s.offset);else{let c=document.createRange();i.anchor>i.head&&([o,s]=[s,o]),c.setEnd(s.node,s.offset),c.setStart(o.node,o.offset),l.removeAllRanges(),l.addRange(c)}}),this.view.observer.setSelectionRange(o,s)),this.impreciseAnchor=o.precise?null:new Fe(a.anchorNode,a.anchorOffset),this.impreciseHead=s.precise?null:new Fe(a.focusNode,a.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let e=this.view.state.selection.main,r=Yc(this.root);if(!e.empty||!e.assoc||!r.modify)return;let n=Ye.find(this,e.head);if(!n)return;let i=n.posAtStart;if(e.head==i||e.head==i+n.length)return;let o=this.coordsAt(e.head,-1),s=this.coordsAt(e.head,1);if(!o||!s||o.bottom>s.top)return;let a=this.domAtPos(e.head+e.assoc);r.collapse(a.node,a.offset),r.modify("move",e.assoc<0?"forward":"backward","lineboundary")}mayControlSelection(){return this.view.state.facet(Ma)?this.root.activeElement==this.dom:Dd(this.dom,this.view.observer.selectionRange)}nearest(e){for(let r=e;r;){let n=ve.get(r);if(n&&n.rootView==this)return n;r=r.parentNode}return null}posFromDOM(e,r){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,r)+n.posAtStart}domAtPos(e){let{i:r,off:n}=this.childCursor().findPos(e,-1);for(;rs||e==s&&o.type!=he.WidgetBefore&&o.type!=he.WidgetAfter&&(!i||r==2||this.children[i-1].breakAfter||this.children[i-1].type==he.WidgetBefore&&r>-2))return o.coordsAt(e-s,r);n=s}}measureVisibleLineHeights(e){let r=[],{from:n,to:i}=e,o=this.view.contentDOM.clientWidth,s=o>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==ye.LTR;for(let c=0,f=0;fi)break;if(c>=n){let d=u.dom.getBoundingClientRect();if(r.push(d.height),s){let p=u.dom.lastChild,b=p?Ca(p):[];if(b.length){let m=b[b.length-1],k=l?m.right-d.left:d.right-m.left;k>a&&(a=k,this.minWidth=o,this.minWidthFrom=c,this.minWidthTo=h)}}}c=h+u.breakAfter}return r}textDirectionAt(e){let{i:r}=this.childPos(e,1);return getComputedStyle(this.children[r].dom).direction=="rtl"?ye.RTL:ye.LTR}measureTextSize(){for(let i of this.children)if(i instanceof Ye){let o=i.measureTextSize();if(o)return o}let e=document.createElement("div"),r,n;return e.className="cm-line",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let i=Ca(e.firstChild)[0];r=e.getBoundingClientRect().height,n=i?i.width/27:7,e.remove()}),{lineHeight:r,charWidth:n}}childCursor(e=this.length){let r=this.children.length;return r&&(e-=this.children[--r].length),new ef(this.children,e,r)}computeBlockGapDeco(){let e=[],r=this.view.viewState;for(let n=0,i=0;;i++){let o=i==r.viewports.length?null:r.viewports[i],s=o?o.from-1:this.length;if(s>n){let a=r.lineBlockAt(s).bottom-r.lineBlockAt(n).top;e.push($.replace({widget:new af(a),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!o)break;n=o.to+1}return $.set(e)}updateDeco(){let e=this.view.state.facet(Oa).map((r,n)=>(this.dynamicDecorationMap[n]=typeof r=="function")?r(this.view):r);for(let r=e.length;rr.anchor?-1:1),i;if(!n)return;!r.empty&&(i=this.coordsAt(r.anchor,r.anchor>r.head?-1:1))&&(n={left:Math.min(n.left,i.left),top:Math.min(n.top,i.top),right:Math.max(n.right,i.right),bottom:Math.max(n.bottom,i.bottom)});let o=0,s=0,a=0,l=0;for(let f of this.view.state.facet(Bb).map(u=>u(this.view)))if(f){let{left:u,right:h,top:d,bottom:p}=f;u!=null&&(o=Math.max(o,u)),h!=null&&(s=Math.max(s,h)),d!=null&&(a=Math.max(a,d)),p!=null&&(l=Math.max(l,p))}let c={left:n.left-o,top:n.top-a,right:n.right+s,bottom:n.bottom+l};dA(this.view.scrollDOM,c,r.head0&&r<=0)t=t.childNodes[e-1],e=Qc(t);else if(t.nodeType==1&&e=0)t=t.childNodes[e],e=0;else return null}}function OA(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e0;){let c=gt(i.text,s,!1);if(n(i.text.slice(c,s))!=l)break;s=c}for(;at?e.left-t:Math.max(0,t-e.right)}function NA(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function _d(t,e){return t.tope.top+1}function $0(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Gd(t,e,r){let n,i,o,s,a,l,c,f;for(let d=t.firstChild;d;d=d.nextSibling){let p=Ca(d);for(let b=0;bS||s==S&&o>k)&&(n=d,i=m,o=k,s=S),k==0?r>m.bottom&&(!c||c.bottomm.top)&&(l=d,f=m):c&&_d(c,m)?c=z0(c,m.bottom):f&&_d(f,m)&&(f=$0(f,m.top))}}if(c&&c.bottom>=r?(n=a,i=c):f&&f.top<=r&&(n=l,i=f),!n)return{node:t,offset:0};let u=Math.max(i.left,Math.min(i.right,e));if(n.nodeType==3)return F0(n,u,r);if(!o&&n.contentEditable=="true")return Gd(n,u,r);let h=Array.prototype.indexOf.call(t.childNodes,n)+(e>=(i.left+i.right)/2?1:0);return{node:t,offset:h}}function F0(t,e,r){let n=t.nodeValue.length,i=-1,o=1e9,s=0;for(let a=0;ar?f.top-r:r-f.bottom)-1;if(f.left-1<=e&&f.right+1>=e&&u=(f.left+f.right)/2,d=h;if((F.chrome||F.gecko)&&Aa(t,a).getBoundingClientRect().left==f.right&&(d=!h),u<=0)return{node:t,offset:a+(d?1:0)};i=a+(d?1:0),o=u}}}return{node:t,offset:i>-1?i:s>0?t.nodeValue.length:0}}function Ub(t,{x:e,y:r},n,i=-1){var o;let s=t.contentDOM.getBoundingClientRect(),a=s.top+t.viewState.paddingTop,l,{docHeight:c}=t.viewState,f=r-a;if(f<0)return 0;if(f>c)return t.state.doc.length;for(let k=t.defaultLineHeight/2,S=!1;l=t.elementAtHeight(f),l.type!=he.Text;)for(;f=i>0?l.bottom+k:l.top-k,!(f>=0&&f<=c);){if(S)return n?null:0;S=!0,i=-i}r=a+f;let u=l.from;if(ut.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:V0(t,s,l,e,r);let h=t.dom.ownerDocument,d=t.root.elementFromPoint?t.root:h,p=d.elementFromPoint(e,r);p&&!t.contentDOM.contains(p)&&(p=null),p||(e=Math.max(s.left+1,Math.min(s.right-1,e)),p=d.elementFromPoint(e,r),p&&!t.contentDOM.contains(p)&&(p=null));let b,m=-1;if(p&&((o=t.docView.nearest(p))===null||o===void 0?void 0:o.isEditable)!=!1){if(h.caretPositionFromPoint){let k=h.caretPositionFromPoint(e,r);k&&({offsetNode:b,offset:m}=k)}else if(h.caretRangeFromPoint){let k=h.caretRangeFromPoint(e,r);k&&({startContainer:b,startOffset:m}=k,F.safari&&PA(b,m,e)&&(b=void 0))}}if(!b||!t.docView.dom.contains(b)){let k=Ye.find(t.docView,u);if(!k)return f>l.top+l.height/2?l.to:l.from;({node:b,offset:m}=Gd(k.dom,e,r))}return t.docView.posFromDOM(b,m)}function V0(t,e,r,n,i){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&r.height>t.defaultLineHeight*1.5){let a=Math.floor((i-r.top)/t.defaultLineHeight);o+=a*t.viewState.heightOracle.lineLength}let s=t.state.sliceDoc(r.from,r.to);return r.from+Fc(s,o,t.state.tabSize)}function PA(t,e,r){let n;if(t.nodeType!=3||e!=(n=t.nodeValue.length))return!1;for(let i=t.nextSibling;i;i=i.nextSibling)if(i.nodeType!=1||i.nodeName!="BR")return!1;return Aa(t,n-1,n).getBoundingClientRect().left>r}function LA(t,e,r,n){let i=t.state.doc.lineAt(e.head),o=!n||!t.lineWrapping?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(o){let l=t.dom.getBoundingClientRect(),c=t.textDirectionAt(i.from),f=t.posAtCoords({x:r==(c==ye.LTR)?l.right-1:l.left+1,y:(o.top+o.bottom)/2});if(f!=null)return A.cursor(f,r?-1:1)}let s=Ye.find(t.docView,e.head),a=s?r?s.posAtEnd:s.posAtStart:r?i.to:i.from;return A.cursor(a,r?-1:1)}function U0(t,e,r,n){let i=t.state.doc.lineAt(e.head),o=t.bidiSpans(i),s=t.textDirectionAt(i.from);for(let a=e,l=null;;){let c=CA(i,o,s,a,r),f=zb;if(!c){if(i.number==(r?t.state.doc.lines:1))return a;f=` +`,i=t.state.doc.line(i.number+(r?1:-1)),o=t.bidiSpans(i),c=A.cursor(r?i.from:i.to)}if(l){if(!l(f))return a}else{if(!n)return c;l=n(f)}a=c}}function IA(t,e,r){let n=t.state.charCategorizer(e),i=n(r);return o=>{let s=n(o);return i==je.Space&&(i=s),i==s}}function BA(t,e,r,n){let i=e.head,o=r?1:-1;if(i==(r?t.state.doc.length:0))return A.cursor(i,e.assoc);let s=e.goalColumn,a,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(i),f=t.documentTop;if(c)s==null&&(s=c.left-l.left),a=o<0?c.top:c.bottom;else{let d=t.viewState.lineBlockAt(i);s==null&&(s=Math.min(l.right-l.left,t.defaultCharacterWidth*(i-d.from))),a=(o<0?d.top:d.bottom)+f}let u=l.left+s,h=n??t.defaultLineHeight>>1;for(let d=0;;d+=10){let p=a+(h+d)*o,b=Ub(t,{x:u,y:p},!1,o);if(pl.bottom||(o<0?bi))return A.cursor(b,e.assoc,void 0,s)}}function Cd(t,e,r){let n=t.state.facet(Ib).map(i=>i(t));for(;;){let i=!1;for(let o of n)o.between(r.from-1,r.from+1,(s,a,l)=>{r.from>s&&r.fromr.from?A.cursor(s,1):A.cursor(a,-1),i=!0)});if(!i)return r}}var Zd=class{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.rapidCompositionStart=!1,this.mouseSelection=null;for(let r in We){let n=We[r];e.contentDOM.addEventListener(r,i=>{!H0(e,i)||this.ignoreDuringComposition(i)||r=="keydown"&&this.keydown(e,i)||(this.mustFlushObserver(i)&&e.observer.forceFlush(),this.runCustomHandlers(r,e,i)?i.preventDefault():n(e,i))}),this.registeredEvents.push(r)}this.notifiedFocused=e.hasFocus,F.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,r){var n;let i;this.customHandlers=[];for(let o of r)if(i=(n=o.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:o.value,handlers:i});for(let s in i)this.registeredEvents.indexOf(s)<0&&s!="scroll"&&(this.registeredEvents.push(s),e.contentDOM.addEventListener(s,a=>{H0(e,a)&&this.runCustomHandlers(s,e,a)&&a.preventDefault()}))}}runCustomHandlers(e,r,n){for(let i of this.customHandlers){let o=i.handlers[e];if(o)try{if(o.call(i.plugin,n,r)||n.defaultPrevented)return!0}catch(s){lt(r.state,s)}}return!1}runScrollHandlers(e,r){for(let n of this.customHandlers){let i=n.handlers.scroll;if(i)try{i.call(n.plugin,r,e)}catch(o){lt(e.state,o)}}}keydown(e,r){if(this.lastKeyCode=r.keyCode,this.lastKeyTime=Date.now(),r.keyCode==9&&Date.now()i.keyCode==r.keyCode))&&!(r.ctrlKey||r.altKey||r.metaKey)&&!r.synthetic?(this.pendingIOSKey=n,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let r=this.pendingIOSKey;return r?(this.pendingIOSKey=void 0,va(e.contentDOM,r.key,r.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:F.safari&&Date.now()-this.compositionEndedAt<100?(this.compositionEndedAt=0,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229||e.type=="compositionend"&&!F.ios}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}},Hb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Wb=[16,17,18,20,91,92,224,225],Jd=class{constructor(e,r,n,i){this.view=e,this.style=n,this.mustSelect=i,this.lastEvent=r;let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=r.shiftKey,this.multiple=e.state.facet(G.allowMultipleSelections)&&jA(e,r),this.dragMove=$A(e,r),this.dragging=zA(e,r)&&bp(r)==1?null:!1,this.dragging===!1&&(r.preventDefault(),this.select(r))}move(e){if(e.buttons==0)return this.destroy();this.dragging===!1&&this.select(this.lastEvent=e)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(e){let r=this.style.get(e,this.extend,this.multiple);(this.mustSelect||!r.eq(this.view.state.selection)||r.main.assoc!=this.view.state.selection.main.assoc)&&this.view.dispatch({selection:r,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function jA(t,e){let r=t.state.facet(Ob);return r.length?r[0](e):F.mac?e.metaKey:e.ctrlKey}function $A(t,e){let r=t.state.facet(Rb);return r.length?r[0](e):F.mac?!e.altKey:!e.ctrlKey}function zA(t,e){let{main:r}=t.state.selection;if(r.empty)return!1;let n=Yc(t.root);if(n.rangeCount==0)return!0;let i=n.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function H0(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let r=e.target,n;r!=t.contentDOM;r=r.parentNode)if(!r||r.nodeType==11||(n=ve.get(r))&&n.ignoreEvent(e))return!1;return!0}var We=Object.create(null),qb=F.ie&&F.ie_version<15||F.ios&&F.webkit_version<604;function FA(t){let e=t.dom.parentNode;if(!e)return;let r=e.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout(()=>{t.focus(),r.remove(),Kb(t,r.value)},50)}function Kb(t,e){let{state:r}=t,n,i=1,o=r.toText(e),s=o.lines==r.selection.ranges.length;if(Yd!=null&&r.selection.ranges.every(l=>l.empty)&&Yd==o.toString()){let l=-1;n=r.changeByRange(c=>{let f=r.doc.lineAt(c.from);if(f.from==l)return{range:c};l=f.from;let u=r.toText((s?o.line(i++).text:e)+r.lineBreak);return{changes:{from:f.from,insert:u},range:A.cursor(c.from+u.length)}})}else s?n=r.changeByRange(l=>{let c=o.line(i++);return{changes:{from:l.from,to:l.to,insert:c.text},range:A.cursor(l.from+c.length)}}):n=r.replaceSelection(o);t.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}We.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),e.keyCode==27?t.inputState.lastEscPress=Date.now():Wb.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0)};var Gb=0;We.touchstart=(t,e)=>{Gb=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};We.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};We.mousedown=(t,e)=>{if(t.observer.flush(),Gb>Date.now()-2e3&&bp(e)==1)return;let r=null;for(let n of t.state.facet(Eb))if(r=n(t,e),r)break;if(!r&&e.button==0&&(r=HA(t,e)),r){let n=t.root.activeElement!=t.contentDOM;n&&t.observer.ignore(()=>yb(t.contentDOM)),t.inputState.startMouseSelection(new Jd(t,e,r,n))}};function W0(t,e,r,n){if(n==1)return A.cursor(e,r);if(n==2)return MA(t.state,e,r);{let i=Ye.find(t.docView,e),o=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:o.from,a=i?i.posAtEnd:o.to;return at>=e.top&&t<=e.bottom,q0=(t,e,r)=>Zb(e,r)&&t>=r.left&&t<=r.right;function VA(t,e,r,n){let i=Ye.find(t.docView,e);if(!i)return 1;let o=e-i.posAtStart;if(o==0)return 1;if(o==i.length)return-1;let s=i.coordsAt(o,-1);if(s&&q0(r,n,s))return-1;let a=i.coordsAt(o,1);return a&&q0(r,n,a)?1:s&&Zb(n,s)?-1:1}function K0(t,e){let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:r,bias:VA(t,r,e.clientX,e.clientY)}}var UA=F.ie&&F.ie_version<=11,G0=null,Z0=0,J0=0;function bp(t){if(!UA)return t.detail;let e=G0,r=J0;return G0=t,J0=Date.now(),Z0=!e||r>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Z0+1)%3:1}function HA(t,e){let r=K0(t,e),n=bp(e),i=t.state.selection,o=r,s=e;return{update(a){a.docChanged&&(r&&(r.pos=a.changes.mapPos(r.pos)),i=i.map(a.changes),s=null)},get(a,l,c){let f;if(s&&a.clientX==s.clientX&&a.clientY==s.clientY?f=o:(f=o=K0(t,a),s=a),!f||!r)return i;let u=W0(t,f.pos,f.bias,n);if(r.pos!=f.pos&&!l){let h=W0(t,r.pos,r.bias,n),d=Math.min(h.from,u.from),p=Math.max(h.to,u.to);u=d{let{selection:{main:r}}=t.state,{mouseSelection:n}=t.inputState;n&&(n.dragging=r),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(r.from,r.to)),e.dataTransfer.effectAllowed="copyMove")};function Y0(t,e,r,n){if(!r)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:o}=t.inputState,s=n&&o&&o.dragging&&o.dragMove?{from:o.dragging.from,to:o.dragging.to}:null,a={from:i,insert:r},l=t.state.changes(s?[s,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"})}We.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let r=e.dataTransfer.files;if(r&&r.length){e.preventDefault();let n=Array(r.length),i=0,o=()=>{++i==r.length&&Y0(t,e,n.filter(s=>s!=null).join(t.state.lineBreak),!1)};for(let s=0;s{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[s]=a.result),o()},a.readAsText(r[s])}}else Y0(t,e,e.dataTransfer.getData("Text"),!0)};We.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let r=qb?null:e.clipboardData;r?(Kb(t,r.getData("text/plain")),e.preventDefault()):FA(t)};function WA(t,e){let r=t.dom.parentNode;if(!r)return;let n=r.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}function qA(t){let e=[],r=[],n=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),r.push(i));if(!e.length){let i=-1;for(let{from:o}of t.selection.ranges){let s=t.doc.lineAt(o);s.number>i&&(e.push(s.text),r.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),i=s.number}n=!0}return{text:e.join(t.lineBreak),ranges:r,linewise:n}}var Yd=null;We.copy=We.cut=(t,e)=>{let{text:r,ranges:n,linewise:i}=qA(t.state);if(!r&&!i)return;Yd=i?r:null;let o=qb?null:e.clipboardData;o?(e.preventDefault(),o.clearData(),o.setData("text/plain",r)):WA(t,r),e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};function Jb(t){setTimeout(()=>{t.hasFocus!=t.inputState.notifiedFocused&&t.update([])},10)}We.focus=Jb;We.blur=t=>{t.observer.clearSelectionRange(),Jb(t)};function Yb(t,e){if(t.docView.compositionDeco.size){t.inputState.rapidCompositionStart=e;try{t.update([])}finally{t.inputState.rapidCompositionStart=!1}}}We.compositionstart=We.compositionupdate=t=>{t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0,t.docView.compositionDeco.size&&(t.observer.flush(),Yb(t,!0)))};We.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionFirstChange=null,setTimeout(()=>{t.inputState.composing<0&&Yb(t,!1)},50)};We.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};We.beforeinput=(t,e)=>{var r;let n;if(F.chrome&&F.android&&(n=Hb.find(i=>i.inputType==e.inputType))&&(t.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let i=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>i+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}};var X0=["pre-wrap","normal","pre-line","break-spaces"],Xd=class{constructor(){this.doc=ee.empty,this.lineWrapping=!1,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(e,r){let n=this.doc.lineAt(r).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.ceil((r-e-n*this.lineLength*.5)/this.lineLength)),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return X0.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let r=!1;for(let n=0;n-1,a=Math.round(r)!=Math.round(this.lineHeight)||this.lineWrapping!=s;if(this.lineWrapping=s,this.lineHeight=r,this.charWidth=n,this.lineLength=i,a){this.heightSamples={};for(let l=0;l0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,r){this.height!=r&&(Math.abs(this.height-r)>Gc&&(e.heightChanged=!0),this.height=r)}replace(e,r,n){return ct.of(n)}decomposeLeft(e,r){r.push(this)}decomposeRight(e,r){r.push(this)}applyChanges(e,r,n,i){let o=this;for(let s=i.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:f}=i[s],u=o.lineAt(a,ge.ByPosNoHeight,r,0,0),h=u.to>=l?u:o.lineAt(l,ge.ByPosNoHeight,r,0,0);for(f+=h.to-l,l=h.to;s>0&&u.from<=i[s-1].toA;)a=i[s-1].fromA,c=i[s-1].fromB,s--,ao*2){let a=e[r-1];a.break?e.splice(--r,1,a.left,null,a.right):e.splice(--r,1,a.left,a.right),n+=1+a.break,i-=a.size}else if(o>i*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,o-=a.size}else break;else if(i=o&&s(this.blockAt(0,n,i,o))}updateHeight(e,r=0,n=!1,i){return i&&i.from<=r&&i.more&&this.setHeight(e,i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},bt=class extends lf{constructor(e,r){super(e,r,he.Text),this.collapsed=0,this.widgetHeight=0}replace(e,r,n){let i=n[0];return n.length==1&&(i instanceof bt||i instanceof ze&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof ze?i=new bt(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):ct.of(n)}updateHeight(e,r=0,n=!1,i){return i&&i.from<=r&&i.more?this.setHeight(e,i.heights[i.index++]):(n||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},ze=class extends ct{constructor(e){super(e,0)}lines(e,r){let n=e.lineAt(r).number,i=e.lineAt(r+this.length).number;return{firstLine:n,lastLine:i,lineHeight:this.height/(i-n+1)}}blockAt(e,r,n,i){let{firstLine:o,lastLine:s,lineHeight:a}=this.lines(r,i),l=Math.max(0,Math.min(s-o,Math.floor((e-n)/a))),{from:c,length:f}=r.line(o+l);return new zr(c,f,n+a*l,a,he.Text)}lineAt(e,r,n,i,o){if(r==ge.ByHeight)return this.blockAt(e,n,i,o);if(r==ge.ByPosNoHeight){let{from:u,to:h}=n.lineAt(e);return new zr(u,h-u,0,0,he.Text)}let{firstLine:s,lineHeight:a}=this.lines(n,o),{from:l,length:c,number:f}=n.lineAt(e);return new zr(l,c,i+a*(f-s),a,he.Text)}forEachLine(e,r,n,i,o,s){let{firstLine:a,lineHeight:l}=this.lines(n,o);for(let c=Math.max(e,o),f=Math.min(o+this.length,r);c<=f;){let u=n.lineAt(c);c==e&&(i+=l*(u.number-a)),s(new zr(u.from,u.length,i,l,he.Text)),i+=l,c=u.to+1}}replace(e,r,n){let i=this.length-r;if(i>0){let o=n[n.length-1];o instanceof ze?n[n.length-1]=new ze(o.length+i):n.push(null,new ze(i-1))}if(e>0){let o=n[0];o instanceof ze?n[0]=new ze(e+o.length):n.unshift(new ze(e-1),null)}return ct.of(n)}decomposeLeft(e,r){r.push(new ze(e-1),null)}decomposeRight(e,r){r.push(null,new ze(this.length-e-1))}updateHeight(e,r=0,n=!1,i){let o=r+this.length;if(i&&i.from<=r+this.length&&i.more){let s=[],a=Math.max(r,i.from),l=-1,c=e.heightChanged;for(i.from>r&&s.push(new ze(i.from-r-1).updateHeight(e,r));a<=o&&i.more;){let u=e.doc.lineAt(a).length;s.length&&s.push(null);let h=i.heights[i.index++];l==-1?l=h:Math.abs(h-l)>=Gc&&(l=-2);let d=new bt(u,h);d.outdated=!1,s.push(d),a+=u+1}a<=o&&s.push(null,new ze(o-a).updateHeight(e,a));let f=ct.of(s);return e.heightChanged=c||l<0||Math.abs(f.height-this.height)>=Gc||Math.abs(l-this.lines(e.doc,r).lineHeight)>=Gc,f}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(r,r+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},ep=class extends ct{constructor(e,r,n){super(e.length+r+n.length,e.height+n.height,r|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,r,n,i){let o=n+this.left.height;return ea))return c;let f=r==ge.ByPosNoHeight?ge.ByPosNoHeight:ge.ByPos;return l?c.join(this.right.lineAt(a,f,n,s,a)):this.left.lineAt(a,f,n,i,o).join(c)}forEachLine(e,r,n,i,o,s){let a=i+this.left.height,l=o+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,r,n,a,l,s);else{let c=this.lineAt(l,ge.ByPos,n,i,o);e=e&&c.from<=r&&s(c),r>c.to&&this.right.forEachLine(c.to+1,r,n,a,l,s)}}replace(e,r,n){let i=this.left.length+this.break;if(rthis.left.length)return this.balanced(this.left,this.right.replace(e-i,r-i,n));let o=[];e>0&&this.decomposeLeft(e,o);let s=o.length;for(let a of n)o.push(a);if(e>0&&Q0(o,s-1),r=n&&r.push(null)),e>n&&this.right.decomposeLeft(e-n,r)}decomposeRight(e,r){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,r);e2*r.size||r.size>2*e.size?ct.of(this.break?[e,null,r]:[e,r]):(this.left=e,this.right=r,this.height=e.height+r.height,this.outdated=e.outdated||r.outdated,this.size=e.size+r.size,this.length=e.length+this.break+r.length,this)}updateHeight(e,r=0,n=!1,i){let{left:o,right:s}=this,a=r+o.length+this.break,l=null;return i&&i.from<=r+o.length&&i.more?l=o=o.updateHeight(e,r,n,i):o.updateHeight(e,r,n),i&&i.from<=a+s.length&&i.more?l=s=s.updateHeight(e,a,n,i):s.updateHeight(e,a,n),l?this.balanced(o,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Q0(t,e){let r,n;t[e]==null&&(r=t[e-1])instanceof ze&&(n=t[e+1])instanceof ze&&t.splice(e-1,3,new ze(r.length+1+n.length))}var KA=5,Ra=class{constructor(e,r){this.pos=e,this.oracle=r,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,r){if(this.lineStart>-1){let n=Math.min(r,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof bt?i.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new bt(n-this.pos,-1)),this.writtenTo=n,r>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=r}point(e,r,n){if(e=KA)&&this.addLineDeco(i,o)}else r>e&&this.span(e,r);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:r}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=r,this.writtenToe&&this.nodes.push(new bt(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,r){let n=new ze(r-e);return this.oracle.doc.lineAt(e).to==r&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof bt)return e;let r=new bt(0,-1);return this.nodes.push(r),r}addBlock(e){this.enterLine(),e.type==he.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,e.type!=he.WidgetBefore&&(this.covering=e)}addLineDeco(e,r){let n=this.ensureLine();n.length+=r,n.collapsed+=r,n.widgetHeight=Math.max(n.widgetHeight,e),this.writtenTo=this.pos=this.pos+r}finish(e){let r=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(r instanceof bt)&&!this.isCovered?this.nodes.push(new bt(0,-1)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();n=Math.max(n,u.left),i=Math.min(i,u.right),o=Math.max(o,u.top),s=Math.min(s,u.bottom)}l=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(l.nodeType==11)l=l.host;else break;return{left:n-r.left,right:Math.max(n,i)-r.left,top:o-(r.top+e),bottom:Math.max(o,s)-(r.top+e)}}function JA(t,e){let r=t.getBoundingClientRect();return{left:0,right:r.right-r.left,top:e,bottom:r.bottom-(r.top+e)}}var xa=class{constructor(e,r,n){this.from=e,this.to=r,this.size=n}static same(e,r){if(e.length!=r.length)return!1;for(let n=0;ntypeof r!="function"),this.heightMap=ct.empty().applyChanges(this.stateDeco,ee.empty,this.heightOracle.setDoc(e.doc),[new vr(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(r=>r.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:r}=this.state.selection;for(let n=0;n<=1;n++){let i=n?r.head:r.anchor;if(!e.some(({from:o,to:s})=>i>=o&&i<=s)){let{from:o,to:s}=this.lineBlockAt(i);e.push(new Fo(o,s))}}this.viewports=e.sort((n,i)=>n.from-i.from),this.scaler=this.heightMap.height<=7e6?rb:new np(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:ya(e,this.scaler))})}update(e,r=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Oa).filter(c=>typeof c!="function");let i=e.changedRanges,o=vr.extendWithRanges(i,GA(n,this.stateDeco,e?e.changes:Oe.empty(this.state.doc.length))),s=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),this.heightMap.height!=s&&(e.flags|=2);let a=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(r&&(r.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,r));let l=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),l&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),r&&(this.scrollTarget=r),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(e){let r=e.contentDOM,n=window.getComputedStyle(r),i=this.heightOracle,o=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?ye.RTL:ye.LTR;let s=this.heightOracle.mustRefreshForWrapping(o),a=s||this.mustMeasureContent||this.contentDOMHeight!=r.clientHeight;this.contentDOMHeight=r.clientHeight,this.mustMeasureContent=!1;let l=0,c=0,f=parseInt(n.paddingTop)||0,u=parseInt(n.paddingBottom)||0;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,l|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=8);let h=(this.printing?JA:ZA)(r,this.paddingTop),d=h.top-this.pixelViewport.top,p=h.bottom-this.pixelViewport.bottom;this.pixelViewport=h;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView)return 0;let m=r.clientWidth;if((this.contentDOMWidth!=m||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=m,this.editorHeight=e.scrollDOM.clientHeight,l|=8),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(S)&&(s=!0),s||i.lineWrapping&&Math.abs(m-this.contentDOMWidth)>i.charWidth){let{lineHeight:_,charWidth:w}=e.docView.measureTextSize();s=i.refresh(o,_,w,m/w,S),s&&(e.docView.minWidth=0,l|=8)}d>0&&p>0?c=Math.max(d,p):d<0&&p<0&&(c=Math.min(d,p)),i.heightChanged=!1;for(let _ of this.viewports){let w=_.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(_);this.heightMap=this.heightMap.updateHeight(i,0,s,new Qd(_.from,w))}i.heightChanged&&(l|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(l&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,r){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,o=this.state.doc,{visibleTop:s,visibleBottom:a}=this,l=new Fo(i.lineAt(s-n*1e3,ge.ByHeight,o,0,0).from,i.lineAt(a+(1-n)*1e3,ge.ByHeight,o,0,0).to);if(r){let{head:c}=r.range;if(cl.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),u=i.lineAt(c,ge.ByPos,o,0,0),h;r.y=="center"?h=(u.top+u.bottom)/2-f/2:r.y=="start"||r.y=="nearest"&&c=a+Math.max(10,Math.min(n,250)))&&i>s-2*1e3&&on.from&&a.push({from:n.from,to:o}),s=n.from&&l.from<=n.to&&tb(a,l.from-10,l.from+10),!l.empty&&l.to>=n.from&&l.to<=n.to&&tb(a,l.to-10,l.to+10);for(let{from:c,to:f}of a)f-c>1e3&&r.push(XA(e,u=>u.from>=n.from&&u.to<=n.to&&Math.abs(u.from-c)<1e3&&Math.abs(u.to-f)<1e3)||new xa(c,f,this.gapSize(n,c,f,i)))}return r}gapSize(e,r,n,i){let o=eb(i,n)-eb(i,r);return this.heightOracle.lineWrapping?e.height*o:i.total*this.heightOracle.charWidth*o}updateLineGaps(e){xa.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=$.set(e.map(r=>r.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let r=[];te.spans(e,this.viewport.from,this.viewport.to,{span(i,o){r.push({from:i,to:o})},point(){}},20);let n=r.length!=this.visibleRanges.length||this.visibleRanges.some((i,o)=>i.from!=r[o].from||i.to!=r[o].to);return this.visibleRanges=r,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(r=>r.from<=e&&r.to>=e)||ya(this.heightMap.lineAt(e,ge.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(e){return ya(this.heightMap.lineAt(this.scaler.fromDOM(e),ge.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(e){return ya(this.heightMap.blockAt(this.scaler.fromDOM(e),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},Fo=class{constructor(e,r){this.from=e,this.to=r}};function YA(t,e,r){let n=[],i=t,o=0;return te.spans(r,t,e,{span(){},point(s,a){s>i&&(n.push({from:i,to:s}),o+=s-i),i=a}},20),i=1)return e[e.length-1].to;let n=Math.floor(t*r);for(let i=0;;i++){let{from:o,to:s}=e[i],a=s-o;if(n<=a)return o+n;n-=a}}function eb(t,e){let r=0;for(let{from:n,to:i}of t.ranges){if(e<=i){r+=e-n;break}r+=i-n}return r/t.total}function tb(t,e,r){for(let n=0;ne){let o=[];i.fromr&&o.push({from:r,to:i.to}),t.splice(n,1,...o),n+=o.length-1}}}function XA(t,e){for(let r of t)if(e(r))return r}var rb={toDOM(t){return t},fromDOM(t){return t},scale:1},np=class{constructor(e,r,n){let i=0,o=0,s=0;this.viewports=n.map(({from:a,to:l})=>{let c=r.lineAt(a,ge.ByPos,e,0,0).top,f=r.lineAt(l,ge.ByPos,e,0,0).bottom;return i+=f-c,{from:a,to:l,top:c,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(r.height-i);for(let a of this.viewports)a.domTop=s+(a.top-o)*this.scale,s=a.domBottom=a.domTop+(a.bottom-a.top),o=a.bottom}toDOM(e){for(let r=0,n=0,i=0;;r++){let o=rya(i,e)):t.type)}var Kc=j.define({combine:t=>t.join(" ")}),ip=j.define({combine:t=>t.indexOf(!0)>-1}),op=Gt.newName(),Xb=Gt.newName(),Qb=Gt.newName(),ek={"&light":"."+Xb,"&dark":"."+Qb};function sp(t,e,r){return new Gt(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,i=>{if(i=="&")return t;if(!r||!r[i])throw new RangeError(`Unsupported selector: ${i}`);return r[i]}):t+" "+n}})}var QA=sp("."+op,{"&.cm-editor":{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,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",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"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor, .cm-dropCursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{display:"flex",height:"100%",boxSizing:"border-box",left: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",display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".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"}},ek),e2={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ad=F.ie&&F.ie_version<=11,ap=class{constructor(e,r,n){this.view=e,this.onChange=r,this.onScrollChanged=n,this.active=!1,this.selectionRange=new Pd,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.scrollTargets=[],this.intersection=null,this.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(i=>{for(let o of i)this.queue.push(o);(F.ie&&F.ie_version<=11||F.ios&&e.composing)&&i.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Ad&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),window.addEventListener("resize",this.onResize=this.onResize.bind(this)),typeof ResizeObserver=="function"&&(this.resize=new ResizeObserver(()=>{this.view.docView.lastUpdate{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),i.length>0&&i[i.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(i=>{i.length>0&&i[i.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange(),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}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((r,n)=>r!=e[n]))){this.gapIntersection.disconnect();for(let r of e)this.gapIntersection.observe(r);this.gaps=e}}onSelectionChange(e){if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,n=this.selectionRange;if(r.state.facet(Ma)?r.root.activeElement!=this.dom:!Dd(r.dom,n))return;let i=n.anchorNode&&r.docView.nearest(n.anchorNode);i&&i.ignoreEvent(e)||((F.ie&&F.ie_version<=11||F.android&&F.chrome)&&!r.state.selection.main.empty&&n.focusNode&&Xc(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1))}readSelectionRange(){let{root:e}=this.view,r=Yc(e),n=F.safari&&e.nodeType==11&&uA()==this.view.contentDOM&&t2(this.view)||r;return this.selectionRange.eq(n)?!1:(this.selectionRange.setRange(n),this.selectionChanged=!0)}setSelectionRange(e,r){this.selectionRange.set(e.node,e.offset,r.node,r.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,r=null;for(let n=this.dom;n;)if(n.nodeType==1)!r&&e{let n=this.delayedAndroidKey;this.delayedAndroidKey=null;let i=this.view.state;this.readSelectionRange(),va(this.view.contentDOM,n.key,n.keyCode)?this.processRecords():this.flush(),this.view.state==i&&this.view.update([])}),(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:r})}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=window.setTimeout(()=>{this.delayedFlush=-1,this.flush()},20))}forceFlush(){this.delayedFlush>=0&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}processRecords(){let e=this.queue;for(let o of this.observer.takeRecords())e.push(o);e.length&&(this.queue=[]);let r=-1,n=-1,i=!1;for(let o of e){let s=this.readMutation(o);s&&(s.typeOver&&(i=!0),r==-1?{from:r,to:n}=s:(r=Math.min(s.from,r),n=Math.max(s.to,n)))}return{from:r,to:n,typeOver:i}}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return;e&&this.readSelectionRange();let{from:r,to:n,typeOver:i}=this.processRecords(),o=this.selectionChanged&&Dd(this.dom,this.selectionRange);if(r<0&&!o)return;this.selectionChanged=!1;let s=this.view.state;this.onChange(r,n,i),this.view.state==s&&this.view.update([])}readMutation(e){let r=this.view.docView.nearest(e.target);if(!r||r.ignoreMutation(e))return null;if(r.markDirty(e.type=="attributes"),e.type=="attributes"&&(r.dirty|=4),e.type=="childList"){let n=nb(r,e.previousSibling||e.target.previousSibling,-1),i=nb(r,e.nextSibling||e.target.nextSibling,1);return{from:n?r.posAfter(n):r.posAtStart,to:i?r.posBefore(i):r.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}destroy(){var e,r,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(r=this.gapIntersection)===null||r===void 0||r.disconnect(),(n=this.resize)===null||n===void 0||n.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("beforeprint",this.onPrint),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout)}};function nb(t,e,r){for(;e;){let n=ve.get(e);if(n&&n.parent==t)return n;let i=e.parentNode;e=i!=t.dom?i:r>0?e.nextSibling:e.previousSibling}return null}function t2(t){let e=null;function r(l){l.preventDefault(),l.stopImmediatePropagation(),e=l.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),!e)return null;let n=e.startContainer,i=e.startOffset,o=e.endContainer,s=e.endOffset,a=t.docView.domAtPos(t.state.selection.main.anchor);return Xc(a.node,a.offset,o,s)&&([n,i,o,s]=[o,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:o,focusOffset:s}}function r2(t,e,r,n){let i,o,s=t.state.selection.main;if(e>-1){let a=t.docView.domBoundsAround(e,r,0);if(!a||t.state.readOnly)return;let{from:l,to:c}=a,f=t.docView.impreciseHead||t.docView.impreciseAnchor?[]:i2(t),u=new nf(f,t.state);u.readRange(a.startDOM,a.endDOM);let h=s.from,d=null;(t.inputState.lastKeyCode===8&&t.inputState.lastKeyTime>Date.now()-100||F.android&&u.text.length=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:F.mac&&i&&i.from==i.to&&i.from==s.head-1&&i.insert.toString()=="."&&(i={from:s.from,to:s.to,insert:ee.of([" "])}),i){let a=t.state;if(F.ios&&t.inputState.flushIOSKey(t)||F.android&&(i.from==s.from&&i.to==s.to&&i.insert.length==1&&i.insert.lines==2&&va(t.contentDOM,"Enter",13)||i.from==s.from-1&&i.to==s.to&&i.insert.length==0&&va(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&i.insert.length==0&&va(t.contentDOM,"Delete",46)))return;let l=i.insert.toString();if(t.state.facet(Db).some(u=>u(t,i.from,i.to,l)))return;t.inputState.composing>=0&&t.inputState.composing++;let c;if(i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!o||o.main.empty&&o.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let u=s.fromi.to?a.sliceDoc(i.to,s.to):"";c=a.replaceSelection(t.state.toText(u+i.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let u=a.changes(i),h=o&&!a.selection.main.eq(o.main)&&o.main.to<=u.newLength?o.main:void 0;if(a.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let d=t.state.sliceDoc(i.from,i.to),p=Fb(t)||t.state.doc.lineAt(s.head),b=s.to-i.to,m=s.to-s.from;c=a.changeByRange(k=>{if(k.from==s.from&&k.to==s.to)return{changes:u,range:h||k.map(u)};let S=k.to-b,_=S-d.length;if(k.to-k.from!=m||t.state.sliceDoc(_,S)!=d||p&&k.to>=p.from&&k.from<=p.to)return{range:k};let w=a.changes({from:_,to:S,insert:i.insert}),C=k.to-s.to;return{changes:w,range:h?A.range(Math.max(0,h.anchor+C),Math.max(0,h.head+C)):k.map(w)}})}else c={changes:u,selection:h&&a.selection.replaceRange(h)}}let f="input.type";t.composing&&(f+=".compose",t.inputState.compositionFirstChange&&(f+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(c,{scrollIntoView:!0,userEvent:f})}else if(o&&!o.main.eq(s)){let a=!1,l="select";t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(a=!0),l=t.inputState.lastSelectionOrigin),t.dispatch({selection:o,scrollIntoView:a,userEvent:l})}}}function n2(t,e,r,n){let i=Math.min(t.length,e.length),o=0;for(;o0&&a>0&&t.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if(n=="end"){let l=Math.max(0,o-Math.min(s,a));r-=s+l-o}if(s=s?o-r:0;o-=l,a=o+(a-s),s=o}else if(a=a?o-r:0;o-=l,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function i2(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:o}=t.observer.selectionRange;return r&&(e.push(new of(r,n)),(i!=r||o!=n)&&e.push(new of(i,o))),e}function o2(t,e){if(t.length==0)return null;let r=t[0].pos,n=t.length==2?t[1].pos:r;return r>-1&&n>-1?A.single(r+e,n+e):null}var B=class{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.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(r=>this.update([r])),this.dispatch=this.dispatch.bind(this),this.root=e.root||pA(e.parent)||document,this.viewState=new cf(e.state||G.create()),this.plugins=this.state.facet(ma).map(r=>new wa(r));for(let r of this.plugins)r.update(this);this.observer=new ap(this,(r,n,i)=>{r2(this,r,n,i)},r=>{this.inputState.runScrollHandlers(this,r),this.observer.intersecting&&this.measure()}),this.inputState=new Zd(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new sf(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}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}dispatch(...e){this._dispatch(e.length==1&&e[0]instanceof Re?e[0]:this.state.update(...e))}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let r=!1,n=!1,i,o=this.state;for(let a of e){if(a.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=a.state}if(this.destroyed){this.viewState.state=o;return}if(o.facet(G.phrases)!=this.state.facet(G.phrases))return this.setState(o);i=Ko.create(this,o,e);let s=this.viewState.scrollTarget;try{this.updateState=2;for(let a of e){if(s&&(s=s.map(a.changes)),a.scrollIntoView){let{main:l}=a.state.selection;s=new qo(l.empty?l:A.cursor(l.head,l.head>l.anchor?-1:1))}for(let l of a.effects)l.is(B0)&&(s=l.value)}this.viewState.update(i,s),this.bidiCache=Go.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),r=this.docView.update(i),this.state.facet(ga)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(r,e.some(a=>a.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Kc)!=i.state.facet(Kc)&&(this.viewState.mustMeasureContent=!0),(r||n||s||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!i.empty)for(let a of this.state.facet(Ud))a(i)}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 r=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new cf(e),this.plugins=e.facet(ma).map(n=>new wa(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new sf(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}r&&this.focus(),this.requestMeasure()}updatePlugins(e){let r=e.startState.facet(ma),n=e.state.facet(ma);if(r!=n){let i=[];for(let o of n){let s=r.indexOf(o);if(s<0)i.push(new wa(o));else{let a=this.plugins[s];a.mustUpdate=e,i.push(a)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=i,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.flush();let r=null;try{for(let n=0;;n++){this.updateState=1;let i=this.viewport,o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(n>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let a=s.map(u=>{try{return u.read(this)}catch(h){return lt(this.state,h),ib}}),l=Ko.create(this,this.state,[]),c=!1,f=!1;l.flags|=o,r?r.flags|=o:r=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),c=this.docView.update(l));for(let u=0;u{let i=Fd(this.contentDOM,this.contentAttrs,r),o=Fd(this.dom,this.editorAttrs,e);return i||o});return this.editorAttrs=e,this.contentAttrs=r,n}showAnnouncements(e){let r=!0;for(let n of e)for(let i of n.effects)if(i.is(B.announce)){r&&(this.announceDOM.textContent=""),r=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(ga),Gt.mount(this.root,this.styleModules.concat(QA).reverse())}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=requestAnimationFrame(()=>this.measure())),e){if(e.key!=null){for(let r=0;rn.spec==e)||null),r&&r.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}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,r,n){return Cd(this,e,U0(this,e,r,n))}moveByGroup(e,r){return Cd(this,e,U0(this,e,r,n=>IA(this,e.head,n)))}moveToLineBoundary(e,r,n=!0){return LA(this,e,r,n)}moveVertically(e,r,n){return Cd(this,e,BA(this,e,r,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,r=0){return this.docView.posFromDOM(e,r)}posAtCoords(e,r=!0){return this.readMeasured(),Ub(this,e,r)}coordsAtPos(e,r=1){this.readMeasured();let n=this.docView.coordsAt(e,r);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),o=this.bidiSpans(i),s=o[Bn.find(o,e-i.from,-1,r)];return mf(n,s.dir==ye.LTR==r>0)}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(Nb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>s2)return $b(e.length);let r=this.textDirectionAt(e.from);for(let i of this.bidiCache)if(i.from==e.from&&i.dir==r)return i.order;let n=_A(e.text,r);return this.bidiCache.push(new Go(e.from,e.to,r,n)),n}get hasFocus(){var e;return(document.hasFocus()||F.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{yb(this.contentDOM),this.docView.updateSelection()})}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,r={}){return B0.of(new qo(typeof e=="number"?A.cursor(e):e,r.y,r.x,r.yMargin,r.xMargin))}static domEventHandlers(e){return de.define(()=>({}),{eventHandlers:e})}static theme(e,r){let n=Gt.newName(),i=[Kc.of(n),ga.of(sp(`.${n}`,e))];return r&&r.dark&&i.push(ip.of(!0)),i}static baseTheme(e){return hn.lowest(ga.of(sp("."+op,e,ek)))}};B.styleModule=ga;B.inputHandler=Db;B.perLineTextDirection=Nb;B.exceptionSink=Mb;B.updateListener=Ud;B.editable=Ma;B.mouseSelectionStyle=Eb;B.dragMovesSelection=Rb;B.clickAddsSelectionRange=Ob;B.decorations=Oa;B.atomicRanges=Ib;B.scrollMargins=Bb;B.darkTheme=ip;B.contentAttributes=Lb;B.editorAttributes=Pb;B.lineWrapping=B.contentAttributes.of({class:"cm-lineWrapping"});B.announce=W.define();var s2=4096,ib={},Go=class{constructor(e,r,n,i){this.from=e,this.to=r,this.dir=n,this.order=i}static update(e,r){if(r.empty)return e;let n=[],i=e.length?e[e.length-1].dir:ye.LTR;for(let o=Math.max(0,e.length-10);o=0;i--){let o=n[i],s=typeof o=="function"?o(t):o;s&&zd(s,r)}return r}var a2=F.mac?"mac":F.windows?"win":F.linux?"linux":"key";function l2(t,e){let r=t.split(/-(?!$)/),n=r[r.length-1];n=="Space"&&(n=" ");let i,o,s,a;for(let l=0;ln.concat(i),[]))),r}function rk(t,e,r){return nk(tk(t.state),e,t,r)}var Ln=null,f2=4e3;function u2(t,e=a2){let r=Object.create(null),n=Object.create(null),i=(s,a)=>{let l=n[s];if(l==null)n[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},o=(s,a,l,c)=>{let f=r[s]||(r[s]=Object.create(null)),u=a.split(/ (?!$)/).map(p=>l2(p,e));for(let p=1;p{let k=Ln={view:m,prefix:b,scope:s};return setTimeout(()=>{Ln==k&&(Ln=null)},f2),!0}]})}let h=u.join(" ");i(h,!1);let d=f[h]||(f[h]={preventDefault:!1,commands:[]});d.commands.push(l),c&&(d.preventDefault=!0)};for(let s of t){let a=s[e]||s.key;if(a)for(let l of s.scope?s.scope.split(" "):["editor"])o(l,a,s.run,s.preventDefault),s.shift&&o(l,"Shift-"+a,s.shift,s.preventDefault)}return r}function nk(t,e,r,n){let i=E0(e),o=i.length==1&&i!=" ",s="",a=!1;Ln&&Ln.view==r&&Ln.scope==n&&(s=Ln.prefix+" ",(a=Wb.indexOf(e.keyCode)<0)&&(Ln=null));let l=u=>{if(u){for(let h of u.commands)if(h(r))return!0;u.preventDefault&&(a=!0)}return!1},c=t[n],f;if(c){if(l(c[s+Td(i,e,!o)]))return!0;if(o&&(e.shiftKey||e.altKey||e.metaKey)&&(f=dn[e.keyCode])&&f!=i){if(l(c[s+Td(f,e,!0)]))return!0}else if(o&&e.shiftKey&&l(c[s+Td(i,e,!0)]))return!0}return a}var ik=!F.ios,ba=j.define({combine(t){return yt(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,r)=>Math.min(e,r),drawRangeCursor:(e,r)=>e||r})}});function ok(t={}){return[ba.of(t),h2,d2]}var ff=class{constructor(e,r,n,i,o){this.left=e,this.top=r,this.width=n,this.height=i,this.className=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width>=0&&(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}},h2=de.fromClass(class{constructor(t){this.view=t,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=t.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=t.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),t.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(ba).cursorBlinkRate+"ms"}update(t){let e=t.startState.facet(ba)!=t.state.facet(ba);(e||t.selectionSet||t.geometryChanged||t.viewportChanged)&&this.view.requestMeasure(this.measureReq),t.transactions.some(r=>r.scrollIntoView)&&(this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}readPos(){let{state:t}=this.view,e=t.facet(ba),r=t.selection.ranges.map(i=>i.empty?[]:p2(this.view,i)).reduce((i,o)=>i.concat(o)),n=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty?!o||ik:e.drawRangeCursor){let s=m2(this.view,i,o);s&&n.push(s)}}return{rangePieces:r,cursors:n}}drawSel({rangePieces:t,cursors:e}){if(t.length!=this.rangePieces.length||t.some((r,n)=>!r.eq(this.rangePieces[n]))){this.selectionLayer.textContent="";for(let r of t)this.selectionLayer.appendChild(r.draw());this.rangePieces=t}if(e.length!=this.cursors.length||e.some((r,n)=>!r.eq(this.cursors[n]))){let r=this.cursorLayer.children;if(r.length!==e.length){this.cursorLayer.textContent="";for(let n of e)this.cursorLayer.appendChild(n.draw())}else e.forEach((n,i)=>n.adjust(r[i]));this.cursors=e}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}}),sk={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};ik&&(sk[".cm-line"].caretColor="transparent !important");var d2=hn.highest(B.theme(sk));function ak(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==ye.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function ab(t,e,r){let n=A.cursor(e);return{from:Math.max(r.from,t.moveToLineBoundary(n,!1,!0).from),to:Math.min(r.to,t.moveToLineBoundary(n,!0,!0).from),type:he.Text}}function lb(t,e){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){for(let n of r.type)if(n.to>e||n.to==e&&(n.to==r.to||n.type==he.Text))return n}return r}function p2(t,e){if(e.to<=t.viewport.from||e.from>=t.viewport.to)return[];let r=Math.max(e.from,t.viewport.from),n=Math.min(e.to,t.viewport.to),i=t.textDirection==ye.LTR,o=t.contentDOM,s=o.getBoundingClientRect(),a=ak(t),l=window.getComputedStyle(o.firstChild),c=s.left+parseInt(l.paddingLeft)+Math.min(0,parseInt(l.textIndent)),f=s.right-parseInt(l.paddingRight),u=lb(t,r),h=lb(t,n),d=u.type==he.Text?u:null,p=h.type==he.Text?h:null;if(t.lineWrapping&&(d&&(d=ab(t,r,d)),p&&(p=ab(t,n,p))),d&&p&&d.from==p.from)return m(k(e.from,e.to,d));{let _=d?k(e.from,null,d):S(u,!1),w=p?k(null,e.to,p):S(h,!0),C=[];return(d||u).to<(p||h).from-1?C.push(b(c,_.bottom,f,w.top)):_.bottomM&&ae.from=st)break;Ze>me&&O(Math.max(at,me),_==null&&at<=M,Math.min(Ze,st),w==null&&Ze>=I,De.dir)}if(me=Be.to+1,me>=st)break}return T.length==0&&O(M,_==null,I,w==null,t.textDirection),{top:R,bottom:x,horizontal:T}}function S(_,w){let C=s.top+(w?_.top:_.bottom);return{top:C,bottom:C,horizontal:[]}}}function m2(t,e,r){let n=t.coordsAtPos(e.head,e.assoc||1);if(!n)return null;let i=ak(t);return new ff(n.left-i.left,n.top-i.top,-1,n.bottom-n.top,r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}var lk=W.define({map(t,e){return t==null?null:e.mapPos(t)}}),ka=ce.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((r,n)=>n.is(lk)?n.value:r,t)}}),g2=de.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let r=t.state.field(ka);r==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(ka)!=r||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let t=this.view.state.field(ka),e=t!=null&&this.view.coordsAtPos(t);if(!e)return null;let r=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-r.left+this.view.scrollDOM.scrollLeft,top:e.top-r.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(t){this.cursor&&(t?(this.cursor.style.left=t.left+"px",this.cursor.style.top=t.top+"px",this.cursor.style.height=t.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(ka)!=t&&this.view.dispatch({effects:lk.of(t)})}},{eventHandlers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function ck(){return[ka,g2]}function cb(t,e,r,n,i){e.lastIndex=0;for(let o=t.iterRange(r,n),s=r,a;!o.next().done;s+=o.value.length)if(!o.lineBreak)for(;a=e.exec(o.value);)i(s+a.index,s+a.index+a[0].length,a)}function y2(t,e){let r=t.visibleRanges;if(r.length==1&&r[0].from==t.viewport.from&&r[0].to==t.viewport.to)return r;let n=[];for(let{from:i,to:o}of r)i=Math.max(t.state.doc.lineAt(i).from,i-e),o=Math.min(t.state.doc.lineAt(o).to,o+e),n.length&&n[n.length-1].to>=i?n[n.length-1].to=o:n.push({from:i,to:o});return n}var lp=class{constructor(e){let{regexp:r,decoration:n,boundary:i,maxLength:o=1e3}=e;if(!r.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=r,this.getDeco=typeof n=="function"?n:()=>n,this.boundary=i,this.maxLength=o}createDeco(e){let r=new Dt;for(let{from:n,to:i}of y2(e,this.maxLength))cb(e.state.doc,this.regexp,n,i,(o,s,a)=>r.add(o,s,this.getDeco(a,e,o)));return r.finish()}updateDeco(e,r){let n=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((o,s,a,l)=>{l>e.view.viewport.from&&a1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,r.map(e.changes),n,i):r}updateRange(e,r,n,i){for(let o of e.visibleRanges){let s=Math.max(o.from,n),a=Math.min(o.to,i);if(a>s){let l=e.state.doc.lineAt(s),c=l.tol.from;s--)if(this.boundary.test(l.text[s-1-l.from])){f=s;break}for(;ah.push(this.getDeco(m,e,p).range(p,b)));r=r.update({filterFrom:f,filterTo:u,filter:(p,b)=>pu,add:h})}}return r}},cp=/x/.unicode!=null?"gu":"g",b2=new RegExp(`[\0-\b +-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\uFEFF\uFFF9-\uFFFC]`,cp),k2={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",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},Od=null;function v2(){var t;if(Od==null&&typeof document<"u"&&document.body){let e=document.body.style;Od=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return Od||!1}var Zc=j.define({combine(t){let e=yt(t,{render:null,specialChars:b2,addSpecialChars:null});return(e.replaceTabs=!v2())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,cp)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,cp)),e}});function fk(t={}){return[Zc.of(t),w2()]}var fb=null;function w2(){return fb||(fb=de.fromClass(class{constructor(t){this.view=t,this.decorations=$.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Zc)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new lp({regexp:t.specialChars,decoration:(e,r,n)=>{let{doc:i}=r.state,o=$e(e[0],0);if(o==9){let s=i.lineAt(n),a=r.state.tabSize,l=Pn(s.text,a,n-s.from);return $.replace({widget:new up((a-l%a)*this.view.defaultCharacterWidth)})}return this.decorationCache[o]||(this.decorationCache[o]=$.replace({widget:new fp(t,o)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Zc);t.startState.facet(Zc)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}var x2="\u2022";function S2(t){return t>=32?x2:t==10?"\u2424":String.fromCharCode(9216+t)}var fp=class extends Pt{constructor(e,r){super(),this.options=e,this.code=r}eq(e){return e.code==this.code}toDOM(e){let r=S2(this.code),n=e.state.phrase("Control character")+" "+(k2[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,n,r);if(i)return i;let o=document.createElement("span");return o.textContent=r,o.title=n,o.setAttribute("aria-label",n),o.className="cm-specialChar",o}ignoreEvent(){return!1}},up=class extends Pt{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 uk(){return C2}var _2=$.line({class:"cm-activeLine"}),C2=de.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,r=[];for(let n of t.state.selection.ranges){if(!n.empty)return $.none;let i=t.lineBlockAt(n.head);i.from>e&&(r.push(_2.range(i.from)),e=i.from)}return $.set(r)}},{decorations:t=>t.decorations});var hp=2e3;function A2(t,e,r){let n=Math.min(e.line,r.line),i=Math.max(e.line,r.line),o=[];if(e.off>hp||r.off>hp||e.col<0||r.col<0){let s=Math.min(e.off,r.off),a=Math.max(e.off,r.off);for(let l=n;l<=i;l++){let c=t.doc.line(l);c.length<=a&&o.push(A.range(c.from+s,c.to+a))}}else{let s=Math.min(e.col,r.col),a=Math.max(e.col,r.col);for(let l=n;l<=i;l++){let c=t.doc.line(l),f=Fc(c.text,s,t.tabSize,!0);if(f>-1){let u=Fc(c.text,a,t.tabSize);o.push(A.range(c.from+f,c.from+u))}}}return o}function T2(t,e){let r=t.coordsAtPos(t.viewport.from);return r?Math.round(Math.abs((r.left-e)/t.defaultCharacterWidth)):-1}function ub(t,e){let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(r),i=r-n.from,o=i>hp?-1:i==n.length?T2(t,e.clientX):Pn(n.text,t.state.tabSize,r-n.from);return{line:n.number,col:o,off:i}}function O2(t,e){let r=ub(t,e),n=t.state.selection;return r?{update(i){if(i.docChanged){let o=i.changes.mapPos(i.startState.doc.line(r.line).from),s=i.state.doc.lineAt(o);r={line:s.number,col:r.col,off:Math.min(r.off,s.length)},n=n.map(i.changes)}},get(i,o,s){let a=ub(t,i);if(!a)return n;let l=A2(t.state,r,a);return l.length?s?A.create(l.concat(n.ranges)):A.create(l):n}}:null}function hk(t){let e=t?.eventFilter||(r=>r.altKey&&r.button==0);return B.mouseSelectionStyle.of((r,n)=>e(n)?O2(r,n):null)}var R2={Alt:[18,t=>t.altKey],Control:[17,t=>t.ctrlKey],Shift:[16,t=>t.shiftKey],Meta:[91,t=>t.metaKey]},E2={style:"cursor: crosshair"};function dk(t={}){let[e,r]=R2[t.key||"Alt"],n=de.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventHandlers:{keydown(i){this.set(i.keyCode==e||r(i))},keyup(i){(i.keyCode==e||!r(i))&&this.set(!1)}}});return[n,B.contentAttributes.of(i=>{var o;return!((o=i.plugin(n))===null||o===void 0)&&o.isDown?E2:null})]}var Rd="-10000px",uf=class{constructor(e,r,n){this.facet=r,this.createTooltipView=n,this.input=e.state.facet(r),this.tooltips=this.input.filter(i=>i),this.tooltipViews=this.tooltips.map(n)}update(e){let r=e.state.facet(this.facet),n=r.filter(o=>o);if(r===this.input){for(let o of this.tooltipViews)o.update&&o.update(e);return!1}let i=[];for(let o=0;o{var e,r,n;return{position:F.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((r=t.find(i=>i.parent))===null||r===void 0?void 0:r.parent)||null,tooltipSpace:((n=t.find(i=>i.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||M2}}}),pk=de.fromClass(class{constructor(t){var e;this.view=t,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let r=t.state.facet(Ed);this.position=r.position,this.parent=r.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new uf(t,Da,n=>this.createTooltip(n)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),(e=t.dom.ownerDocument.defaultView)===null||e===void 0||e.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t);e&&this.observeIntersection();let r=e||t.geometryChanged,n=t.state.facet(Ed);if(n.position!=this.position){this.position=n.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;r=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);r=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);r&&this.maybeMeasure()}createTooltip(t){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",e.dom.appendChild(r)}return e.dom.style.position=this.position,e.dom.style.top=Rd,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;(t=this.view.dom.ownerDocument.defaultView)===null||t===void 0||t.removeEventListener("resize",this.measureSoon);for(let{dom:r}of this.manager.tooltipViews)r.remove();(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect();return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map((e,r)=>{let n=this.manager.tooltipViews[r];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Ed).tooltipSpace(this.view)}}writeMeasure(t){let{editor:e,space:r}=t,n=[];for(let i=0;i=Math.min(e.bottom,r.bottom)||l.rightMath.min(e.right,r.right)+.1){a.style.top=Rd;continue}let f=o.arrow?s.dom.querySelector(".cm-tooltip-arrow"):null,u=f?7:0,h=c.right-c.left,d=c.bottom-c.top,p=s.offset||N2,b=this.view.textDirection==ye.LTR,m=c.width>r.right-r.left?b?r.left:r.right-c.width:b?Math.min(l.left-(f?14:0)+p.x,r.right-h):Math.max(r.left,l.left-h+(f?14:0)-p.x),k=!!o.above;!o.strictSide&&(k?l.top-(c.bottom-c.top)-p.yr.bottom)&&k==r.bottom-l.bottom>l.top-r.top&&(k=!k);let S=k?l.top-d-u-p.y:l.bottom+u+p.y,_=m+h;if(s.overlap!==!0)for(let w of n)w.left<_&&w.right>m&&w.topS&&(S=k?w.top-d-2-u:w.bottom+u+2);this.position=="absolute"?(a.style.top=S-t.parent.top+"px",a.style.left=m-t.parent.left+"px"):(a.style.top=S+"px",a.style.left=m+"px"),f&&(f.style.left=`${l.left+(b?p.x:-p.x)-(m+14-7)}px`),s.overlap!==!0&&n.push({left:m,top:S,right:_,bottom:S+d}),a.classList.toggle("cm-tooltip-above",k),a.classList.toggle("cm-tooltip-below",!k),s.positioned&&s.positioned()}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Rd}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),D2=B.baseTheme({".cm-tooltip":{zIndex:100},"&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"}}}),N2={x:0,y:0},Da=j.define({enables:[pk,D2]}),hf=j.define(),Ea=class{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new uf(e,hf,r=>this.createHostedView(r))}static create(e){return new Ea(e)}createHostedView(e){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(r.dom),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let r of this.manager.tooltipViews)r.mount&&r.mount(e);this.mounted=!0}positioned(){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned()}update(e){this.manager.update(e)}},P2=Da.compute([hf],t=>{let e=t.facet(hf).filter(r=>r);return e.length===0?null:{pos:Math.min(...e.map(r=>r.pos)),end:Math.max(...e.filter(r=>r.end!=null).map(r=>r.end)),create:Ea.create,above:e[0].above,arrow:e.some(r=>r.arrow)}}),dp=class{constructor(e,r,n,i,o){this.view=e,this.source=r,this.field=n,this.setHover=i,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;en.bottom||e.xn.right+this.view.defaultCharacterWidth)return;let i=this.view.bidiSpans(this.view.state.doc.lineAt(r)).find(a=>a.from<=r&&a.to>=r),o=i&&i.dir==ye.RTL?-1:1,s=this.source(this.view,r,e.x{this.pending==a&&(this.pending=null,l&&this.view.dispatch({effects:this.setHover.of(l)}))},l=>lt(this.view.state,l,"hover tooltip"))}else s&&this.view.dispatch({effects:this.setHover.of(s)})}mousemove(e){var r;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 n=this.active;if(n&&!L2(this.lastMove.target)||this.pending){let{pos:i}=n||this.pending,o=(r=n?.end)!==null&&r!==void 0?r:i;(i==o?this.view.posAtCoords(this.lastMove)!=i:!I2(this.view,i,o,e.clientX,e.clientY,6))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}};function L2(t){for(let e=t;e;e=e.parentNode)if(e.nodeType==1&&e.classList.contains("cm-tooltip"))return!0;return!1}function I2(t,e,r,n,i,o){let s=document.createRange(),a=t.domAtPos(e),l=t.domAtPos(r);s.setEnd(l.node,l.offset),s.setStart(a.node,a.offset);let c=s.getClientRects();s.detach();for(let f=0;fhf.from(i)});return[n,de.define(i=>new dp(i,t,n,r,e.hoverTime||300)),P2]}function gk(t,e){let r=t.plugin(pk);if(!r)return null;let n=r.manager.tooltips.indexOf(e);return n<0?null:r.manager.tooltipViews[n]}var B2=W.define();var hb=j.define({combine(t){let e,r;for(let n of t)e=e||n.topContainer,r=r||n.bottomContainer;return{topContainer:e,bottomContainer:r}}});function Bi(t,e){let r=t.plugin(yk),n=r?r.specs.indexOf(e):-1;return n>-1?r.panels[n]:null}var yk=de.fromClass(class{constructor(t){this.input=t.state.facet(Li),this.specs=this.input.filter(r=>r),this.panels=this.specs.map(r=>r(t));let e=t.state.facet(hb);this.top=new Vo(t,!0,e.topContainer),this.bottom=new Vo(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(r=>r.top)),this.bottom.sync(this.panels.filter(r=>!r.top));for(let r of this.panels)r.dom.classList.add("cm-panel"),r.mount&&r.mount()}update(t){let e=t.state.facet(hb);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Vo(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Vo(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let r=t.state.facet(Li);if(r!=this.input){let n=r.filter(l=>l),i=[],o=[],s=[],a=[];for(let l of n){let c=this.specs.indexOf(l),f;c<0?(f=l(t.view),a.push(f)):(f=this.panels[c],f.update&&f.update(t)),i.push(f),(f.top?o:s).push(f)}this.specs=n,this.panels=i,this.top.sync(o),this.bottom.sync(s);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>B.scrollMargins.of(e=>{let r=e.plugin(t);return r&&{top:r.top.scrollMargin(),bottom:r.bottom.scrollMargin()}})}),Vo=class{constructor(e,r,n){this.view=e,this.top=r,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let r of this.panels)r.destroy&&e.indexOf(r)<0&&r.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 r=this.container||this.view.dom;r.insertBefore(this.dom,this.top?r.firstChild:null)}let e=this.dom.firstChild;for(let r of this.panels)if(r.dom.parentNode==this.dom){for(;e!=r.dom;)e=db(e);e=e.nextSibling}else this.dom.insertBefore(r.dom,e);for(;e;)e=db(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 db(t){let e=t.nextSibling;return t.remove(),e}var Li=j.define({enables:yk}),Lt=class extends kr{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Lt.prototype.elementClass="";Lt.prototype.toDOM=void 0;Lt.prototype.mapMode=Je.TrackBefore;Lt.prototype.startSide=Lt.prototype.endSide=-1;Lt.prototype.point=!0;var Jc=j.define(),j2={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>te.empty,lineMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Sa=j.define();function kp(t){return[bk(),Sa.of(Object.assign(Object.assign({},j2),t))]}var pp=j.define({combine:t=>t.some(e=>e)});function bk(t){let e=[$2];return t&&t.fixed===!1&&e.push(pp.of(!0)),e}var $2=de.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=t.state.facet(Sa).map(e=>new df(t,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!t.state.facet(pp),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,r=t.view.viewport,n=Math.min(e.to,r.to)-Math.max(e.from,r.from);this.syncGutters(n<(r.to-r.from)*.8)}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(pp)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let r=te.iter(this.view.state.facet(Jc),this.view.viewport.from),n=[],i=this.gutters.map(o=>new mp(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks){let s;if(Array.isArray(o.type)){for(let a of o.type)if(a.type==he.Text){s=a;break}}else s=o.type==he.Text?o:void 0;if(s){n.length&&(n=[]),kk(r,n,o.from);for(let a of i)a.line(this.view,s,n)}}for(let o of i)o.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(Sa),r=t.state.facet(Sa),n=t.docChanged||t.heightChanged||t.viewportChanged||!te.eq(t.startState.facet(Jc),t.state.facet(Jc),t.view.viewport.from,t.view.viewport.to);if(e==r)for(let i of this.gutters)i.update(t)&&(n=!0);else{n=!0;let i=[];for(let o of r){let s=e.indexOf(o);s<0?i.push(new df(this.view,o)):(this.gutters[s].update(t),i.push(this.gutters[s]))}for(let o of this.gutters)o.dom.remove(),i.indexOf(o)<0&&o.destroy();for(let o of i)this.dom.appendChild(o.dom);this.gutters=i}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>B.scrollMargins.of(e=>{let r=e.plugin(t);return!r||r.gutters.length==0||!r.fixed?null:e.textDirection==ye.LTR?{left:r.dom.offsetWidth}:{right:r.dom.offsetWidth}})});function pb(t){return Array.isArray(t)?t:[t]}function kk(t,e,r){for(;t.value&&t.from<=r;)t.from==r&&e.push(t.value),t.next()}var mp=class{constructor(e,r,n){this.gutter=e,this.height=n,this.localMarkers=[],this.i=0,this.cursor=te.iter(e.markers,r.from)}line(e,r,n){this.localMarkers.length&&(this.localMarkers=[]),kk(this.cursor,this.localMarkers,r.from);let i=n.length?this.localMarkers.concat(n):this.localMarkers,o=this.gutter.config.lineMarker(e,r,i);o&&i.unshift(o);let s=this.gutter;if(i.length==0&&!s.config.renderEmptyElements)return;let a=r.top-this.height;if(this.i==s.elements.length){let l=new pf(e,r.height,a,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,r.height,a,i);this.height=r.bottom,this.i++}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let r=e.elements.pop();e.dom.removeChild(r.dom),r.destroy()}}},df=class{constructor(e,r){this.view=e,this.config=r,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in r.domEventHandlers)this.dom.addEventListener(n,i=>{let o=e.lineBlockAtHeight(i.clientY-e.documentTop);r.domEventHandlers[n](e,o,i)&&i.preventDefault()});this.markers=pb(r.markers(e)),r.initialSpacer&&(this.spacer=new pf(e,0,0,[r.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let r=this.markers;if(this.markers=pb(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let n=e.view.viewport;return!te.eq(this.markers,r,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},pf=class{constructor(e,r,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,r,n,i)}update(e,r,n,i){this.height!=r&&(this.dom.style.height=(this.height=r)+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),z2(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,r){let n="cm-gutterElement",i=this.dom.firstChild;for(let o=0,s=0;;){let a=s,l=oo(a,l,c)||s(a,l,c):s}return n}})}}),_a=class extends Lt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Md(t,e){return t.state.facet(Uo).formatNumber(e,t.state)}var V2=Sa.compute([Uo],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(F2)},lineMarker(e,r,n){return n.some(i=>i.toDOM)?null:new _a(Md(e,e.state.doc.lineAt(r.from).number))},lineMarkerChange:e=>e.startState.facet(Uo)!=e.state.facet(Uo),initialSpacer(e){return new _a(Md(e,mb(e.state.doc.lines)))},updateSpacer(e,r){let n=Md(r.view,mb(r.view.state.doc.lines));return n==e.number?e:new _a(n)},domEventHandlers:t.facet(Uo).domEventHandlers}));function vk(t={}){return[Uo.of(t),bk(),V2]}function mb(t){let e=9;for(;e{let e=[],r=-1;for(let n of t.selection.ranges)if(n.empty){let i=t.doc.lineAt(n.head).from;i>r&&(r=i,e.push(U2.range(i)))}return te.of(e)});function wk(){return H2}var W2=0,Na=class{constructor(e,r){this.from=e,this.to=r}},Z=class{constructor(e={}){this.id=W2++,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=kt.match(e)),r=>{let n=e(r);return n===void 0?null:[this,n]}}};Z.closedBy=new Z({deserialize:t=>t.split(" ")});Z.openedBy=new Z({deserialize:t=>t.split(" ")});Z.group=new Z({deserialize:t=>t.split(" ")});Z.contextHash=new Z({perNode:!0});Z.lookAhead=new Z({perNode:!0});Z.mounted=new Z({perNode:!0});var q2=Object.create(null),kt=class{constructor(e,r,n,i=0){this.name=e,this.props=r,this.id=n,this.flags=i}static define(e){let r=e.props&&e.props.length?Object.create(null):q2,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new kt(e.name||"",r,e.id,n);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(i)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");r[o[0].id]=o[1]}}return i}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 r=this.prop(Z.group);return r?r.indexOf(e)>-1:!1}return this.id==e}static match(e){let r=Object.create(null);for(let n in e)for(let i of n.split(" "))r[i]=e[n];return n=>{for(let i=n.prop(Z.group),o=-1;o<(i?i.length:0);o++){let s=r[o<0?n.name:i[o]];if(s)return s}}}};kt.none=new kt("",Object.create(null),0,8);var yf=new WeakMap,xk=new WeakMap,Xe;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(Xe||(Xe={}));var Ve=class{constructor(e,r,n,i,o){if(this.type=e,this.children=r,this.positions=n,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);for(let[s,a]of o)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=this.prop(Z.mounted);if(e&&!e.overlay)return e.tree.toString();let r="";for(let n of this.children){let i=n.toString();i&&(r&&(r+=","),r+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(r.length?"("+r+")":""):r}cursor(e=0){return new Jo(this.topNode,e)}cursorAt(e,r=0,n=0){let i=yf.get(this)||this.topNode,o=new Jo(i);return o.moveTo(e,r),yf.set(this,o._tree),o}get topNode(){return new wr(this,0,0,null)}resolve(e,r=0){let n=Zo(yf.get(this)||this.topNode,e,r,!1);return yf.set(this,n),n}resolveInner(e,r=0){let n=Zo(xk.get(this)||this.topNode,e,r,!0);return xk.set(this,n),n}iterate(e){let{enter:r,leave:n,from:i=0,to:o=this.length}=e;for(let s=this.cursor((e.mode||0)|Xe.IncludeAnonymous);;){let a=!1;if(s.from<=o&&s.to>=i&&(s.type.isAnonymous||r(s)!==!1)){if(s.firstChild())continue;a=!0}for(;a&&n&&!s.type.isAnonymous&&n(s),!s.nextSibling();){if(!s.parent())return;a=!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 r in this.props)e.push([+r,this.props[r]]);return e}balance(e={}){return this.children.length<=8?this:Sp(kt.none,this.children,this.positions,0,this.children.length,0,this.length,(r,n,i)=>new Ve(this.type,r,n,i,this.propValues),e.makeTree||((r,n,i)=>new Ve(kt.none,r,n,i)))}static build(e){return K2(e)}};Ve.empty=new Ve(kt.none,[],[],0);var Pa=class{constructor(e,r){this.buffer=e,this.index=r}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 Pa(this.buffer,this.index)}},gn=class{constructor(e,r,n){this.buffer=e,this.length=r,this.set=n}get type(){return kt.none}toString(){let e=[];for(let r=0;r0));l=s[l+3]);return a}slice(e,r,n,i){let o=this.buffer,s=new Uint16Array(r-e);for(let a=e,l=0;a=e&&re;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function Ck(t,e){let r=t.childBefore(e);for(;r;){let n=r.lastChild;if(!n||n.to!=r.to)break;n.type.isError&&n.from==n.to?(t=r,r=n.prevSibling):r=n}return t}function Zo(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to0?a.length:-1;e!=c;e+=r){let f=a[e],u=l[e]+s.from;if(_k(i,n,u,u+f.length)){if(f instanceof gn){if(o&Xe.ExcludeBuffers)continue;let h=f.findChild(0,f.buffer.length,r,n-u,i);if(h>-1)return new Vr(new vp(s,f,e,u),null,h)}else if(o&Xe.IncludeAnonymous||!f.type.isAnonymous||xp(f)){let h;if(!(o&Xe.IgnoreMounts)&&f.props&&(h=f.prop(Z.mounted))&&!h.overlay)return new wr(h.tree,u,e,s);let d=new wr(f,u,e,s);return o&Xe.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(r<0?f.children.length-1:0,r,n,i)}}}if(o&Xe.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+r:e=r<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,r,n=0){let i;if(!(n&Xe.IgnoreOverlays)&&(i=this._tree.prop(Z.mounted))&&i.overlay){let o=e-this.from;for(let{from:s,to:a}of i.overlay)if((r>0?s<=o:s=o:a>o))return new wr(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,r,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new Jo(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,r=0){return Zo(this,e,r,!1)}resolveInner(e,r=0){return Zo(this,e,r,!0)}enterUnfinishedNodesBefore(e){return Ck(this,e)}getChild(e,r=null,n=null){let i=kf(this,e,r,n);return i.length?i[0]:null}getChildren(e,r=null,n=null){return kf(this,e,r,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return vf(this,e)}};function kf(t,e,r,n){let i=t.cursor(),o=[];if(!i.firstChild())return o;if(r!=null){for(;!i.type.is(r);)if(!i.nextSibling())return o}for(;;){if(n!=null&&i.type.is(n))return o;if(i.type.is(e)&&o.push(i.node),!i.nextSibling())return n==null?o:[]}}function vf(t,e,r=e.length-1){for(let n=t.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[r]&&e[r]!=n.name)return!1;r--}}return!0}var vp=class{constructor(e,r,n,i){this.parent=e,this.buffer=r,this.index=n,this.start=i}},Vr=class{constructor(e,r,n){this.context=e,this._parent=r,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}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]}child(e,r,n){let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],e,r-this.context.start,n);return o<0?null:new Vr(this.context,this,o)}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,r,n=0){if(n&Xe.ExcludeBuffers)return null;let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],r>0?1:-1,e-this.context.start,r);return o<0?null:new Vr(this.context,this,o)}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,r=e.buffer[this.index+3];return r<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,r):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,r=this._parent?this._parent.index+4:0;return this.index==r?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(r,this.index,-1,0,4))}cursor(e=0){return new Jo(this,e)}get tree(){return null}toTree(){let e=[],r=[],{buffer:n}=this.context,i=this.index+4,o=n.buffer[this.index+3];if(o>i){let s=n.buffer[this.index+1],a=n.buffer[this.index+2];e.push(n.slice(i,o,s,a)),r.push(0)}return new Ve(this.type,e,r,this.to-this.from)}resolve(e,r=0){return Zo(this,e,r,!1)}resolveInner(e,r=0){return Zo(this,e,r,!0)}enterUnfinishedNodesBefore(e){return Ck(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,r=null,n=null){let i=kf(this,e,r,n);return i.length?i[0]:null}getChildren(e,r=null,n=null){return kf(this,e,r,n)}get node(){return this}matchContext(e){return vf(this,e)}},Jo=class{constructor(e,r=0){if(this.mode=r,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof wr)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,r){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=r||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return e?e instanceof wr?(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,r,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,r,n,this.mode));let{buffer:i}=this.buffer,o=i.findChild(this.index+4,i.buffer[this.index+3],e,r-this.buffer.start,n);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}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,r,n=this.mode){return this.buffer?n&Xe.ExcludeBuffers?!1:this.enterChild(1,e,r):this.yield(this._tree.enter(e,r,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Xe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Xe.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:r}=this.buffer,n=this.stack.length-1;if(e<0){let i=n<0?0:this.stack[n]+4;if(this.index!=i)return this.yieldBuf(r.findChild(i,this.index,-1,0,4))}else{let i=r.buffer[this.index+3];if(i<(n<0?r.buffer.length:r.buffer[this.stack[n]+3]))return this.yieldBuf(i)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let r,n,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let o=r+e,s=e<0?-1:n._tree.children.length;o!=s;o+=e){let a=n._tree.children[o];if(this.mode&Xe.IncludeAnonymous||a instanceof gn||!a.type.isAnonymous||xp(a))return!1}return!0}move(e,r){if(r&&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,r=0){for(;(this.from==this.to||(r<1?this.from>=e:this.from>e)||(r>-1?this.to<=e:this.to=0;){for(let s=e;s;s=s._parent)if(s.index==i){if(i==this.index)return s;r=s,n=o+1;break e}i=this.stack[--o]}for(let i=n;i=0;o--){if(o<0)return vf(this.node,e,i);let s=n[r.buffer[this.stack[o]]];if(!s.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}};function xp(t){return t.children.some(e=>e instanceof gn||!e.type.isAnonymous||xp(e))}function K2(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=1024,reused:o=[],minRepeatType:s=n.types.length}=t,a=Array.isArray(r)?new Pa(r,r.length):r,l=n.types,c=0,f=0;function u(w,C,R,x,T){let{id:O,start:M,end:I,size:ae}=a,me=f;for(;ae<0;)if(a.next(),ae==-1){let Ze=o[O];R.push(Ze),x.push(M-w);return}else if(ae==-3){c=O;return}else if(ae==-4){f=O;return}else throw new RangeError(`Unrecognized record size: ${ae}`);let st=l[O],Be,De,at=M-w;if(I-M<=i&&(De=b(a.pos-C,T))){let Ze=new Uint16Array(De.size-De.skip),gr=a.pos-De.size,un=Ze.length;for(;a.pos>gr;)un=m(De.start,Ze,un);Be=new gn(Ze,I-De.start,n),at=De.start-w}else{let Ze=a.pos-ae;a.next();let gr=[],un=[],Oi=O>=s?O:-1,No=0,Ec=I;for(;a.pos>Ze;)Oi>=0&&a.id==Oi&&a.size>=0?(a.end<=Ec-i&&(d(gr,un,M,No,a.end,Ec,Oi,me),No=gr.length,Ec=a.end),a.next()):u(M,Ze,gr,un,Oi);if(Oi>=0&&No>0&&No-1&&No>0){let e0=h(st);Be=Sp(st,gr,un,0,gr.length,0,I-M,e0,e0)}else Be=p(st,gr,un,I-M,me-I)}R.push(Be),x.push(at)}function h(w){return(C,R,x)=>{let T=0,O=C.length-1,M,I;if(O>=0&&(M=C[O])instanceof Ve){if(!O&&M.type==w&&M.length==x)return M;(I=M.prop(Z.lookAhead))&&(T=R[O]+M.length+I)}return p(w,C,R,x,T)}}function d(w,C,R,x,T,O,M,I){let ae=[],me=[];for(;w.length>x;)ae.push(w.pop()),me.push(C.pop()+R-T);w.push(p(n.types[M],ae,me,O-T,I-O)),C.push(T-R)}function p(w,C,R,x,T=0,O){if(c){let M=[Z.contextHash,c];O=O?[M].concat(O):[M]}if(T>25){let M=[Z.lookAhead,T];O=O?[M].concat(O):[M]}return new Ve(w,C,R,x,O)}function b(w,C){let R=a.fork(),x=0,T=0,O=0,M=R.end-i,I={size:0,start:0,skip:0};e:for(let ae=R.pos-w;R.pos>ae;){let me=R.size;if(R.id==C&&me>=0){I.size=x,I.start=T,I.skip=O,O+=4,x+=4,R.next();continue}let st=R.pos-me;if(me<0||st=s?4:0,De=R.start;for(R.next();R.pos>st;){if(R.size<0)if(R.size==-3)Be+=4;else break e;else R.id>=s&&(Be+=4);R.next()}T=De,x+=me,O+=Be}return(C<0||x==w)&&(I.size=x,I.start=T,I.skip=O),I.size>4?I:void 0}function m(w,C,R){let{id:x,start:T,end:O,size:M}=a;if(a.next(),M>=0&&x4){let ae=a.pos-(M-4);for(;a.pos>ae;)R=m(w,C,R)}C[--R]=I,C[--R]=O-w,C[--R]=T-w,C[--R]=x}else M==-3?c=x:M==-4&&(f=x);return R}let k=[],S=[];for(;a.pos>0;)u(t.start||0,t.bufferStart||0,k,S,-1);let _=(e=t.length)!==null&&e!==void 0?e:k.length?S[0]+k[0].length:0;return new Ve(l[t.topID],k.reverse(),S.reverse(),_)}var Sk=new WeakMap;function bf(t,e){if(!t.isAnonymous||e instanceof gn||e.type!=t)return 1;let r=Sk.get(e);if(r==null){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof Ve)){r=1;break}r+=bf(t,n)}Sk.set(e,r)}return r}function Sp(t,e,r,n,i,o,s,a,l){let c=0;for(let p=n;p=f)break;R+=x}if(_==w+1){if(R>f){let x=p[w];d(x.children,x.positions,0,x.children.length,b[w]+S);continue}u.push(p[w])}else{let x=b[_-1]+p[_-1].length-C;u.push(Sp(t,p,b,w,_,C,x,null,l))}h.push(C+S-o)}}return d(e,r,n,i,0),(a||l)(u,h,s)}var Ur=class{constructor(e,r,n,i,o=!1,s=!1){this.from=e,this.to=r,this.tree=n,this.offset=i,this.open=(o?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,r=[],n=!1){let i=[new Ur(0,e.length,e,0,!1,n)];for(let o of r)o.to>e.length&&i.push(o);return i}static applyChanges(e,r,n=128){if(!r.length)return e;let i=[],o=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let f=a=n)for(;s&&s.from=h.from||u<=h.to||c){let d=Math.max(h.from,l)-c,p=Math.min(h.to,u)-c;h=d>=p?null:new Ur(d,p,h.tree,h.offset+c,a>0,!!f)}if(h&&i.push(h),s.to>u)break;s=onew Na(i.from,i.to)):[new Na(0,0)]:[new Na(0,e.length)],this.createParse(e,r||[],n)}parse(e,r,n){let i=this.startParse(e,r,n);for(;;){let o=i.advance();if(o)return o}}},wp=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,r){return this.string.slice(e,r)}};var cB=new Z({perNode:!0});var G2=0,Jt=class{constructor(e,r,n){this.set=e,this.base=r,this.modified=n,this.id=G2++}static define(e){if(e?.base)throw new Error("Can not derive from a modified tag");let r=new Jt([],null,[]);if(r.set.push(r),e)for(let n of e.set)r.set.push(n);return r}static defineModifier(){let e=new Yo;return r=>r.modified.indexOf(e)>-1?r:Yo.get(r.base||r,r.modified.concat(e).sort((n,i)=>n.id-i.id))}},Z2=0,Yo=class{constructor(){this.instances=[],this.id=Z2++}static get(e,r){if(!r.length)return e;let n=r[0].instances.find(a=>a.base==e&&J2(r,a.modified));if(n)return n;let i=[],o=new Jt(i,e,r);for(let a of r)a.instances.push(o);let s=Ok(r);for(let a of e.set)for(let l of s)i.push(Yo.get(a,l));return o}};function J2(t,e){return t.length==e.length&&t.every((r,n)=>r==e[n])}function Ok(t){let e=[t];for(let r=0;r0&&u+3==i.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(o.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),u+=h[0].length,u==i.length)break;let d=i[u++];if(u==i.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+i);a=i.slice(u)}let l=o.length-1,c=o[l];if(!c)throw new RangeError("Invalid path: "+i);let f=new Cp(n,s,l>0?o.slice(0,l):null);e[c]=f.sort(e[c])}}return Ek.add(e)}var Ek=new Z,Cp=class{constructor(e,r,n,i){this.tags=e,this.mode=r,this.context=n,this.next=i}sort(e){return!e||e.depth{let s=i;for(let a of o)for(let l of a.set){let c=r[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:n}}function Y2(t,e){let r=null;for(let n of t){let i=n.style(e);i&&(r=r?r+" "+i:i)}return r}function Mk(t,e,r,n=0,i=t.length){let o=new Ap(n,Array.isArray(e)?e:[e],r);o.highlightRange(t.cursor(),n,i,"",o.highlighters),o.flush(i)}var Ap=class{constructor(e,r,n){this.at=e,this.highlighters=r,this.span=n,this.class=""}startSpan(e,r){r!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=r)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,r,n,i,o){let{type:s,from:a,to:l}=e;if(a>=n||l<=r)return;s.isTop&&(o=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=i,f=s.prop(Ek),u=!1;for(;f;){if(!f.context||e.matchContext(f.context)){let d=Y2(o,f.tags);d&&(c&&(c+=" "),c+=d,f.mode==1?i+=(i?" ":"")+d:f.mode==0&&(u=!0));break}f=f.next}if(this.startSpan(e.from,c),u)return;let h=e.tree&&e.tree.prop(Z.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(m=>!m.scope||m.scope(h.tree.type)),b=e.firstChild();for(let m=0,k=a;;m++){let S=m=_||!e.nextSibling())););if(!S||_>n)break;k=S.to+a,k>r&&(this.highlightRange(d.cursor(),Math.max(r,S.from+a),Math.min(n,k),i,p),this.startSpan(k,c))}b&&e.parent()}else if(e.firstChild()){do if(!(e.to<=r)){if(e.from>=n)break;this.highlightRange(e,r,n,i,o),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}},D=Jt.define,xf=D(),$n=D(),Ak=D($n),Tk=D($n),zn=D(),Sf=D(zn),_p=D(zn),qr=D(),ji=D(qr),Hr=D(),Wr=D(),Tp=D(),La=D(Tp),_f=D(),N={comment:xf,lineComment:D(xf),blockComment:D(xf),docComment:D(xf),name:$n,variableName:D($n),typeName:Ak,tagName:D(Ak),propertyName:Tk,attributeName:D(Tk),className:D($n),labelName:D($n),namespace:D($n),macroName:D($n),literal:zn,string:Sf,docString:D(Sf),character:D(Sf),attributeValue:D(Sf),number:_p,integer:D(_p),float:D(_p),bool:D(zn),regexp:D(zn),escape:D(zn),color:D(zn),url:D(zn),keyword:Hr,self:D(Hr),null:D(Hr),atom:D(Hr),unit:D(Hr),modifier:D(Hr),operatorKeyword:D(Hr),controlKeyword:D(Hr),definitionKeyword:D(Hr),moduleKeyword:D(Hr),operator:Wr,derefOperator:D(Wr),arithmeticOperator:D(Wr),logicOperator:D(Wr),bitwiseOperator:D(Wr),compareOperator:D(Wr),updateOperator:D(Wr),definitionOperator:D(Wr),typeOperator:D(Wr),controlOperator:D(Wr),punctuation:Tp,separator:D(Tp),bracket:La,angleBracket:D(La),squareBracket:D(La),paren:D(La),brace:D(La),content:qr,heading:ji,heading1:D(ji),heading2:D(ji),heading3:D(ji),heading4:D(ji),heading5:D(ji),heading6:D(ji),contentSeparator:D(qr),list:D(qr),quote:D(qr),emphasis:D(qr),strong:D(qr),link:D(qr),monospace:D(qr),strikethrough:D(qr),inserted:D(),deleted:D(),changed:D(),invalid:D(),meta:_f,documentMeta:D(_f),annotation:D(_f),processingInstruction:D(_f),definition:Jt.defineModifier(),constant:Jt.defineModifier(),function:Jt.defineModifier(),standard:Jt.defineModifier(),local:Jt.defineModifier(),special:Jt.defineModifier()},hB=Op([{tag:N.link,class:"tok-link"},{tag:N.heading,class:"tok-heading"},{tag:N.emphasis,class:"tok-emphasis"},{tag:N.strong,class:"tok-strong"},{tag:N.keyword,class:"tok-keyword"},{tag:N.atom,class:"tok-atom"},{tag:N.bool,class:"tok-bool"},{tag:N.url,class:"tok-url"},{tag:N.labelName,class:"tok-labelName"},{tag:N.inserted,class:"tok-inserted"},{tag:N.deleted,class:"tok-deleted"},{tag:N.literal,class:"tok-literal"},{tag:N.string,class:"tok-string"},{tag:N.number,class:"tok-number"},{tag:[N.regexp,N.escape,N.special(N.string)],class:"tok-string2"},{tag:N.variableName,class:"tok-variableName"},{tag:N.local(N.variableName),class:"tok-variableName tok-local"},{tag:N.definition(N.variableName),class:"tok-variableName tok-definition"},{tag:N.special(N.variableName),class:"tok-variableName2"},{tag:N.definition(N.propertyName),class:"tok-propertyName tok-definition"},{tag:N.typeName,class:"tok-typeName"},{tag:N.namespace,class:"tok-namespace"},{tag:N.className,class:"tok-className"},{tag:N.macroName,class:"tok-macroName"},{tag:N.propertyName,class:"tok-propertyName"},{tag:N.operator,class:"tok-operator"},{tag:N.comment,class:"tok-comment"},{tag:N.meta,class:"tok-meta"},{tag:N.invalid,class:"tok-invalid"},{tag:N.punctuation,class:"tok-punctuation"}]);var Rp,Cf=new Z;var Yt=class{constructor(e,r,n=[]){this.data=e,G.prototype.hasOwnProperty("tree")||Object.defineProperty(G.prototype,"tree",{get(){return qe(this)}}),this.parser=r,this.extension=[Vn.of(this),G.languageData.of((i,o,s)=>i.facet(Dk(i,o,s)))].concat(n)}isActiveAt(e,r,n=-1){return Dk(e,r,n)==this.data}findRegions(e){let r=e.facet(Vn);if(r?.data==this.data)return[{from:0,to:e.doc.length}];if(!r||!r.allowsNesting)return[];let n=[],i=(o,s)=>{if(o.prop(Cf)==this.data){n.push({from:s,to:s+o.length});return}let a=o.prop(Z.mounted);if(a){if(a.tree.prop(Cf)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+s,to:l.to+s});else n.push({from:s,to:s+o.length});return}else if(a.overlay){let l=n.length;if(i(a.tree,a.overlay[0].from+s),n.length>l)return}}for(let l=0;l=this.cursorPos?this.doc.sliceString(e,r):this.string.slice(e-n,r-n)}},Ia=null,Xo=class{constructor(e,r,n=[],i,o,s,a,l){this.parser=e,this.state=r,this.fragments=n,this.tree=i,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,r,n){return new Xo(e,r,[],Ve.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Np(this.state.doc),this.fragments)}work(e,r){return r!=null&&r>=this.state.doc.length&&(r=void 0),this.tree!=Ve.empty&&this.isDone(r??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),r!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>r)&&r=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(r=this.parse.advance()););}),this.treeLen=e,this.tree=r,this.fragments=this.withoutTempSkipped(Ur.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let r=Ia;Ia=this;try{return e()}finally{Ia=r}}withoutTempSkipped(e){for(let r;r=this.tempSkipped.pop();)e=Nk(e,r.from,r.to);return e}changes(e,r){let{fragments:n,tree:i,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,f,u,h)=>l.push({fromA:c,toA:f,fromB:u,toB:h})),n=Ur.applyChanges(n,l),i=Ve.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let f=e.mapPos(c.from,1),u=e.mapPos(c.to,-1);fe.from&&(this.fragments=Nk(this.fragments,i,o),this.skipped.splice(n--,1))}return this.skipped.length>=r?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,r){this.skipped.push({from:e,to:r})}static getSkippingParser(e){return new class extends wf{createParse(r,n,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let l=Ia;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new Ve(kt.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let r=this.fragments;return this.treeLen>=e&&r.length&&r[0].from==0&&r[0].to>=e}static get(){return Ia}};function Nk(t,e,r){return Ur.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}var Fn=class{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let r=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),r.viewport.to);return r.work(20,n)||r.takeTree(),new Fn(r)}static init(e){let r=Math.min(3e3,e.doc.length),n=Xo.create(e.facet(Vn).parser,e,{from:0,to:r});return n.work(20,r)||n.takeTree(),new Fn(n)}};Yt.state=ce.define({create:Fn.init,update(t,e){for(let r of e.effects)if(r.is(Yt.setState))return r.value;return e.startState.facet(Vn)!=e.state.facet(Vn)?Fn.init(e.state):t.apply(e)}});var Ik=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Ik=t=>{let e=-1,r=setTimeout(()=>{e=requestIdleCallback(t,{timeout:500-100})},100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});var Ep=typeof navigator<"u"&&(!((Rp=navigator.scheduling)===null||Rp===void 0)&&Rp.isInputPending)?()=>navigator.scheduling.isInputPending():null,X2=de.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 r=this.view.state.field(Yt.state).context;(r.updateViewport(e.view.viewport)||this.view.viewport.to>r.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(r)}scheduleWork(){if(this.working)return;let{state:e}=this.view,r=e.field(Yt.state);(r.tree!=r.context.tree||!r.context.isDone(e.doc.length))&&(this.working=Ik(this.work))}work(e){this.working=null;let r=Date.now();if(this.chunkEndi+1e3,l=o.context.work(()=>Ep&&Ep()||Date.now()>s,i+(a?0:1e5));this.chunkBudget-=Date.now()-r,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:Yt.setState.of(new Fn(o.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(r=>lt(this.view.state,r)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Vn=j.define({combine(t){return t.length?t[0]:null},enables:[Yt.state,X2]});var Q2=j.define(),$a=j.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function za(t){let e=t.facet($a);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function es(t,e){let r="",n=t.tabSize;if(t.facet($a).charCodeAt(0)==9)for(;e>=n;)r+=" ",e-=n;for(let i=0;i=n.from&&i<=n.to?o&&i==e?{text:"",from:e}:(r<0?i-1&&(o+=s-this.countColumn(n,n.search(/\S|$/))),o}countColumn(e,r=e.length){return Pn(e,this.state.tabSize,r)}lineIndent(e,r=1){let{text:n,from:i}=this.lineAt(e,r),o=this.options.overrideIndentation;if(o){let s=o(i);if(s>-1)return s}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},eT=new Z;function tT(t,e,r){return Bk(e.resolveInner(r).enterUnfinishedNodesBefore(r),r,t)}function rT(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function nT(t){let e=t.type.prop(eT);if(e)return e;let r=t.firstChild,n;if(r&&(n=r.type.prop(Z.closedBy))){let i=t.lastChild,o=i&&n.indexOf(i.name)>-1;return s=>aT(s,!0,1,void 0,o&&!rT(s)?i.from:void 0)}return t.parent==null?iT:null}function Bk(t,e,r){for(;t;t=t.parent){let n=nT(t);if(n)return n(ja.create(r,e,t))}return null}function iT(){return 0}var ja=class extends $i{constructor(e,r,n){super(e.state,e.options),this.base=e,this.pos=r,this.node=n}static create(e,r,n){return new ja(e,r,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let r=this.node.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(oT(r,this.node))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?Bk(e,this.pos,this.base):0}};function oT(t,e){for(let r=e;r;r=r.parent)if(t==r)return!0;return!1}function sT(t){let e=t.node,r=e.childAfter(e.from),n=e.lastChild;if(!r)return null;let i=t.options.simulateBreak,o=t.state.doc.lineAt(r.from),s=i==null||i<=o.from?o.to:Math.min(o.to,i);for(let a=r.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped)return l.from{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let r=t.newDoc,{head:n}=t.newSelection.main,i=r.lineAt(n);if(n>i.from+lT)return t;let o=r.sliceString(i.from,n);if(!e.some(c=>c.test(o)))return t;let{state:s}=t,a=-1,l=[];for(let{head:c}of s.selection.ranges){let f=s.doc.lineAt(c);if(f.from==a)continue;a=f.from;let u=Of(s,f.from);if(u==null)continue;let h=/^\s*/.exec(f.text)[0],d=es(s,u);h!=d&&l.push({from:f.from,to:f.from+h.length,insert:d})}return l.length?[t,{changes:l,sequential:!0}]:t})}var cT=j.define(),fT=new Z;function uT(t,e,r){let n=qe(t);if(n.lengthr)continue;if(o&&s.from=e&&l.to>r&&(o=l)}}return o}function hT(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Af(t,e,r){for(let n of t.facet(cT)){let i=n(t,e,r);if(i)return i}return uT(t,e,r)}function $k(t,e){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return r>=n?void 0:{from:r,to:n}}var Rf=W.define({map:$k}),Fa=W.define({map:$k});function zk(t){let e=[];for(let{head:r}of t.state.selection.ranges)e.some(n=>n.from<=r&&n.to>=r)||e.push(t.lineBlockAt(r));return e}var zi=ce.define({create(){return $.none},update(t,e){t=t.map(e.changes);for(let r of e.effects)r.is(Rf)&&!dT(t,r.value.from,r.value.to)?t=t.update({add:[kT.range(r.value.from,r.value.to)]}):r.is(Fa)&&(t=t.update({filter:(n,i)=>r.value.from!=n||r.value.to!=i,filterFrom:r.value.from,filterTo:r.value.to}));if(e.selection){let r=!1,{head:n}=e.selection.main;t.between(n,n,(i,o)=>{in&&(r=!0)}),r&&(t=t.update({filterFrom:n,filterTo:n,filter:(i,o)=>o<=n||i>=n}))}return t},provide:t=>B.decorations.from(t)});function Tf(t,e,r){var n;let i=null;return(n=t.field(zi,!1))===null||n===void 0||n.between(e,r,(o,s)=>{(!i||i.from>o)&&(i={from:o,to:s})}),i}function dT(t,e,r){let n=!1;return t.between(e,e,(i,o)=>{i==e&&o==r&&(n=!0)}),n}function Fk(t,e){return t.field(zi,!1)?e:e.concat(W.appendConfig.of(Wk()))}var pT=t=>{for(let e of zk(t)){let r=Af(t.state,e.from,e.to);if(r)return t.dispatch({effects:Fk(t.state,[Rf.of(r),Vk(t,r)])}),!0}return!1},mT=t=>{if(!t.state.field(zi,!1))return!1;let e=[];for(let r of zk(t)){let n=Tf(t.state,r.from,r.to);n&&e.push(Fa.of(n),Vk(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function Vk(t,e,r=!0){let n=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return B.announce.of(`${t.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${i}.`)}var gT=t=>{let{state:e}=t,r=[];for(let n=0;n{let e=t.state.field(zi,!1);if(!e||!e.size)return!1;let r=[];return e.between(0,t.state.doc.length,(n,i)=>{r.push(Fa.of({from:n,to:i}))}),t.dispatch({effects:r}),!0},Uk=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:pT},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:mT},{key:"Ctrl-Alt-[",run:gT},{key:"Ctrl-Alt-]",run:yT}],bT={placeholderDOM:null,placeholderText:"\u2026"},Hk=j.define({combine(t){return yt(t,bT)}});function Wk(t){let e=[zi,wT];return t&&e.push(Hk.of(t)),e}var kT=$.replace({widget:new class extends Pt{toDOM(t){let{state:e}=t,r=e.facet(Hk),n=o=>{let s=t.lineBlockAt(t.posAtDOM(o.target)),a=Tf(t.state,s.from,s.to);a&&t.dispatch({effects:Fa.of(a)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,n);let i=document.createElement("span");return i.textContent=r.placeholderText,i.setAttribute("aria-label",e.phrase("folded code")),i.title=e.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=n,i}}}),vT={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{}},Ba=class extends Lt{constructor(e,r){super(),this.config=e,this.open=r}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let r=document.createElement("span");return r.textContent=this.open?this.config.openText:this.config.closedText,r.title=e.state.phrase(this.open?"Fold line":"Unfold line"),r}};function qk(t={}){let e=Object.assign(Object.assign({},vT),t),r=new Ba(e,!0),n=new Ba(e,!1),i=de.fromClass(class{constructor(s){this.from=s.viewport.from,this.markers=this.buildMarkers(s)}update(s){(s.docChanged||s.viewportChanged||s.startState.facet(Vn)!=s.state.facet(Vn)||s.startState.field(zi,!1)!=s.state.field(zi,!1)||qe(s.startState)!=qe(s.state))&&(this.markers=this.buildMarkers(s.view))}buildMarkers(s){let a=new Dt;for(let l of s.viewportLineBlocks){let c=Tf(s.state,l.from,l.to)?n:Af(s.state,l.from,l.to)?r:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:o}=e;return[i,kp({class:"cm-foldGutter",markers(s){var a;return((a=s.plugin(i))===null||a===void 0?void 0:a.markers)||te.empty},initialSpacer(){return new Ba(e,!1)},domEventHandlers:Object.assign(Object.assign({},o),{click:(s,a,l)=>{if(o.click&&o.click(s,a,l))return!0;let c=Tf(s.state,a.from,a.to);if(c)return s.dispatch({effects:Fa.of(c)}),!0;let f=Af(s.state,a.from,a.to);return f?(s.dispatch({effects:Rf.of(f)}),!0):!1}})}),Wk()]}var wT=B.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"}}),Qo=class{constructor(e,r){let n;function i(a){let l=Gt.newName();return(n||(n=Object.create(null)))["."+l]=a,l}let o=typeof r.all=="string"?r.all:r.all?i(r.all):void 0,s=r.scope;this.scope=s instanceof Yt?a=>a.prop(Cf)==s.data:s?a=>a==s:void 0,this.style=Op(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=n?new Gt(n):null,this.themeType=r.themeType}static define(e,r){return new Qo(e,r||{})}},Pp=j.define(),Kk=j.define({combine(t){return t.length?[t[0]]:null}});function Mp(t){let e=t.facet(Pp);return e.length?e:t.facet(Kk)}function Gk(t,e){let r=[xT],n;return t instanceof Qo&&(t.module&&r.push(B.styleModule.of(t.module)),n=t.themeType),e?.fallback?r.push(Kk.of(t)):n?r.push(Pp.computeN([B.darkTheme],i=>i.facet(B.darkTheme)==(n=="dark")?[t]:[])):r.push(Pp.of(t)),r}var Lp=class{constructor(e){this.markCache=Object.create(null),this.tree=qe(e.state),this.decorations=this.buildDeco(e,Mp(e.state))}update(e){let r=qe(e.state),n=Mp(e.state),i=n!=Mp(e.startState);r.length{n.add(s,a,this.markCache[l]||(this.markCache[l]=$.mark({class:l})))},i,o);return n.finish()}},xT=hn.high(de.fromClass(Lp,{decorations:t=>t.decorations})),Zk=Qo.define([{tag:N.meta,color:"#7a757a"},{tag:N.link,textDecoration:"underline"},{tag:N.heading,textDecoration:"underline",fontWeight:"bold"},{tag:N.emphasis,fontStyle:"italic"},{tag:N.strong,fontWeight:"bold"},{tag:N.strikethrough,textDecoration:"line-through"},{tag:N.keyword,color:"#708"},{tag:[N.atom,N.bool,N.url,N.contentSeparator,N.labelName],color:"#219"},{tag:[N.literal,N.inserted],color:"#164"},{tag:[N.string,N.deleted],color:"#a11"},{tag:[N.regexp,N.escape,N.special(N.string)],color:"#e40"},{tag:N.definition(N.variableName),color:"#00f"},{tag:N.local(N.variableName),color:"#30a"},{tag:[N.typeName,N.namespace],color:"#085"},{tag:N.className,color:"#167"},{tag:[N.special(N.variableName),N.macroName],color:"#256"},{tag:N.definition(N.propertyName),color:"#00c"},{tag:N.comment,color:"#940"},{tag:N.invalid,color:"#f00"}]),ST=B.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Jk=1e4,Yk="()[]{}",Xk=j.define({combine(t){return yt(t,{afterCursor:!0,brackets:Yk,maxScanDistance:Jk,renderMatch:AT})}}),_T=$.mark({class:"cm-matchingBracket"}),CT=$.mark({class:"cm-nonmatchingBracket"});function AT(t){let e=[],r=t.matched?_T:CT;return e.push(r.range(t.start.from,t.start.to)),t.end&&e.push(r.range(t.end.from,t.end.to)),e}var TT=ce.define({create(){return $.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let r=[],n=e.state.facet(Xk);for(let i of e.state.selection.ranges){if(!i.empty)continue;let o=xr(e.state,i.head,-1,n)||i.head>0&&xr(e.state,i.head-1,1,n)||n.afterCursor&&(xr(e.state,i.head,1,n)||i.headB.decorations.from(t)}),OT=[TT,ST];function Qk(t={}){return[Xk.of(t),OT]}function Ip(t,e,r){let n=t.prop(e<0?Z.openedBy:Z.closedBy);if(n)return n;if(t.name.length==1){let i=r.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[r[i+e]]}return null}function xr(t,e,r,n={}){let i=n.maxScanDistance||Jk,o=n.brackets||Yk,s=qe(t),a=s.resolveInner(e,r);for(let l=a;l;l=l.parent){let c=Ip(l.type,r,o);if(c&&l.from=n.to){if(l==0&&i.indexOf(c.type.name)>-1&&c.from0)return null;let c={from:r<0?e-1:e,to:r>0?e+1:e},f=t.doc.iterRange(e,r>0?t.doc.length:0),u=0;for(let h=0;!f.next().done&&h<=o;){let d=f.value;r<0&&(h+=d.length);let p=e+h*r;for(let b=r>0?0:d.length-1,m=r>0?d.length:-1;b!=m;b+=r){let k=s.indexOf(d[b]);if(!(k<0||n.resolve(p+b,1).type!=i))if(k%2==0==r>0)u++;else{if(u==1)return{start:c,end:{from:p+b,to:p+b+1},matched:k>>1==l>>1};u--}}r>0&&(h+=d.length)}return f.done?{start:c,matched:!1}:null}var MT=Object.create(null),Pk=[kt.none];var Lk=[],DT=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","typeName"],["attribute","propertyName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])DT[t]=NT(MT,e);function Dp(t,e){Lk.indexOf(t)>-1||(Lk.push(t),console.warn(e))}function NT(t,e){let r=null;for(let o of e.split(".")){let s=t[o]||N[o];s?typeof s=="function"?r?r=s(r):Dp(o,`Modifier ${o} used at start of tag`):r?Dp(o,`Tag ${o} used as modifier`):r=s:Dp(o,`Unknown highlighting tag ${o}`)}if(!r)return 0;let n=e.replace(/ /g,"_"),i=kt.define({id:Pk.length,name:n,props:[Rk({[n]:r})]});return Pk.push(i),i.id}var Mf=class{constructor(e,r,n){this.state=e,this.pos=r,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let r=qe(this.state).resolveInner(this.pos,-1);for(;r&&e.indexOf(r.name)<0;)r=r.parent;return r?{from:r.from,to:this.pos,text:this.state.sliceDoc(r.from,this.pos),type:r.type}:null}matchBefore(e){let r=this.state.doc.lineAt(this.pos),n=Math.max(r.from,this.pos-250),i=r.text.slice(n-r.from,this.pos-r.from),o=i.search(av(e,!1));return o<0?null:{from:n+o,to:this.pos,text:i.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,r){e=="abort"&&this.abortListeners&&this.abortListeners.push(r)}};function ev(t){let e=Object.keys(t).join(""),r=/\w/.test(e);return r&&(e=e.replace(/\w/g,"")),`[${r?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function PT(t){let e=Object.create(null),r=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let o=1;otypeof i=="string"?{label:i}:i),[r,n]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:PT(e);return i=>{let o=i.matchBefore(n);return o||i.explicit?{from:o?o.from:i.pos,options:e,validFor:r}:null}}var Df=class{constructor(e,r,n){this.completion=e,this.source=r,this.match=n}};function Un(t){return t.selection.main.head}function av(t,e){var r;let{source:n}=t,i=e&&n[0]!="^",o=n[n.length-1]!="$";return!i&&!o?t:new RegExp(`${i?"^":""}(?:${n})${o?"$":""}`,(r=t.flags)!==null&&r!==void 0?r:t.ignoreCase?"i":"")}function IT(t,e,r,n){return t.changeByRange(i=>{if(i==t.selection.main)return{changes:{from:r,to:n,insert:e},range:A.cursor(r+e.length)};let o=n-r;return!i.empty||o&&t.sliceDoc(i.from-o,i.from)!=t.sliceDoc(r,n)?{range:i}:{changes:{from:i.from-o,to:i.from,insert:e},range:A.cursor(i.from-o+e.length)}})}function lv(t,e){let r=e.completion.apply||e.completion.label,n=e.source;typeof r=="string"?t.dispatch(IT(t.state,r,n.from,n.to)):r(t,e.completion,n.from,n.to)}var tv=new WeakMap;function BT(t){if(!Array.isArray(t))return t;let e=tv.get(t);return e||tv.set(t,e=LT(t)),e}var jp=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let r=0;r=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(R=pa(C))!=R.toLowerCase()?1:R!=R.toUpperCase()?2:0;(!S||x==1&&m||w==0&&x!=0)&&(r[u]==C||n[u]==C&&(h=!0)?s[u++]=S:s.length&&(k=!1)),w=x,S+=St(C)}return u==l&&s[0]==0&&k?this.result(-100+(h?-200:0),s,e):d==l&&p==0?[-200-e.length,0,b]:a>-1?[-700-e.length,a,a+this.pattern.length]:d==l?[-200+-700-e.length,p,b]:u==l?this.result(-100+(h?-200:0)+-700+(k?0:-1100),s,e):r.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,r,n){let i=[e-n.length],o=1;for(let s of r){let a=s+(this.astral?St($e(n,s)):1);o>1&&i[o-1]==s?i[o-1]=a:(i[o++]=s,i[o++]=a)}return i}},Hn=j.define({combine(t){return yt(t,{activateOnTyping:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[]},{defaultKeymap:(e,r)=>e&&r,closeOnBlur:(e,r)=>e&&r,icons:(e,r)=>e&&r,optionClass:(e,r)=>n=>jT(e(n),r(n)),addToOptions:(e,r)=>e.concat(r)})}});function jT(t,e){return t?e?t+" "+e:t:e}function $T(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(r){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),r.type&&n.classList.add(...r.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(r,n,i){let o=document.createElement("span");o.className="cm-completionLabel";let{label:s}=r,a=0;for(let l=1;la&&o.appendChild(document.createTextNode(s.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(s.slice(c,f))),u.className="cm-completionMatchedText",a=f}return ar.position-n.position).map(r=>r.render)}function rv(t,e,r){if(t<=r)return{from:0,to:t};if(e<=t>>1){let i=Math.floor(e/r);return{from:i*r,to:(i+1)*r}}let n=Math.floor((t-e)/r);return{from:t-(n+1)*r,to:t-n*r}}var $p=class{constructor(e,r){this.view=e,this.stateField=r,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:a=>this.positionInfo(a),key:this};let n=e.state.field(r),{options:i,selected:o}=n.open,s=e.state.facet(Hn);this.optionContent=$T(s),this.optionClass=s.optionClass,this.range=rv(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",a=>{for(let l=a.target,c;l&&l!=this.dom;l=l.parentNode)if(l.nodeName=="LI"&&(c=/-(\d+)$/.exec(l.id))&&+c[1]{this.info&&this.view.requestMeasure(this.placeInfo)})}mount(){this.updateSel()}update(e){e.state.field(this.stateField)!=e.startState.field(this.stateField)&&this.updateSel()}positioned(){this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),r=e.open;if((r.selected=this.range.to)&&(this.range=rv(r.options.length,r.selected,this.view.state.facet(Hn).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(r.options,e.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})),this.updateSelectedOption(r.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:n}=r.options[r.selected],{info:i}=n;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(n);if(!o)return;"then"in o?o.then(s=>{s&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(s)}).catch(s=>lt(this.view.state,s,"completion info")):this.addInfoPane(o)}}addInfoPane(e){let r=this.info=document.createElement("div");r.className="cm-tooltip cm-completionInfo",r.appendChild(e),this.dom.appendChild(r),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let r=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),r=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return r&&FT(this.list,r),r}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let r=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect();if(i.top>Math.min(innerHeight,r.bottom)-10||i.bottomnew $p(e,t)}function FT(t,e){let r=t.getBoundingClientRect(),n=e.getBoundingClientRect();n.topr.bottom&&(t.scrollTop+=n.bottom-r.bottom)}function nv(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function VT(t,e){let r=[],n=0;for(let s of t)if(s.hasResult())if(s.result.filter===!1){let a=s.result.getMatch;for(let l of s.result.options){let c=[1e9-n++];if(a)for(let f of a(l))c.push(f);r.push(new Df(l,s,c))}}else{let a=new jp(e.sliceDoc(s.from,s.to)),l;for(let c of s.result.options)(l=a.match(c.label))&&(c.boost!=null&&(l[0]+=c.boost),r.push(new Df(c,s,l)))}let i=[],o=null;for(let s of r.sort(qT))!o||o.label!=s.completion.label||o.detail!=s.completion.detail||o.type!=null&&s.completion.type!=null&&o.type!=s.completion.type||o.apply!=s.completion.apply?i.push(s):nv(s.completion)>nv(o)&&(i[i.length-1]=s),o=s.completion;return i}var Vi=class{constructor(e,r,n,i,o){this.options=e,this.attrs=r,this.tooltip=n,this.timestamp=i,this.selected=o}setSelected(e,r){return e==this.selected||e>=this.options.length?this:new Vi(this.options,iv(r,e),this.tooltip,this.timestamp,e)}static build(e,r,n,i,o){let s=VT(e,r);if(!s.length)return null;let a=0;if(i&&i.selected){let l=i.options[i.selected].completion;for(let c=0;cc.hasResult()?Math.min(l,c.from):l,1e8),create:zT(Xt),above:o.aboveCursor},i?i.timestamp:Date.now(),a)}map(e){return new Vi(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}},ts=class{constructor(e,r,n){this.active=e,this.id=r,this.open=n}static start(){return new ts(WT,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:r}=e,n=r.facet(Hn),o=(n.override||r.languageDataAt("autocomplete",Un(r)).map(BT)).map(a=>(this.active.find(c=>c.source==a)||new ft(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));o.length==this.active.length&&o.every((a,l)=>a==this.active[l])&&(o=this.active);let s=e.selection||o.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!UT(o,this.active)?Vi.build(o,r,this.id,this.open,n):this.open&&e.docChanged?this.open.map(e.changes):this.open;!s&&o.every(a=>a.state!=1)&&o.some(a=>a.hasResult())&&(o=o.map(a=>a.hasResult()?new ft(a.source,0):a));for(let a of e.effects)a.is(fv)&&(s=s&&s.setSelected(a.value,this.id));return o==this.active&&s==this.open?this:new ts(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:HT}};function UT(t,e){if(t==e)return!0;for(let r=0,n=0;;){for(;rs||r=="delete"&&Un(e.startState)==this.from)return new ft(this.source,r=="input"&&n.activateOnTyping?1:0);let l=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),c;return KT(this.result.validFor,e.state,o,s)?new Ui(this.source,l,this.result,o,s):this.result.update&&(c=this.result.update(this.result,o,s,new Mf(e.state,a,l>=0)))?new Ui(this.source,l,c,c.from,(i=c.to)!==null&&i!==void 0?i:Un(e.state)):new ft(this.source,1,l)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new ft(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Ui(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}};function KT(t,e,r,n){if(!t)return!1;let i=e.sliceDoc(r,n);return typeof t=="function"?t(i,r,n,e):av(t,!0).test(i)}var Vp=W.define(),Nf=W.define(),cv=W.define({map(t,e){return t.map(r=>r.map(e))}}),fv=W.define(),Xt=ce.define({create(){return ts.start()},update(t,e){return t.update(e)},provide:t=>[Da.from(t,e=>e.tooltip),B.contentAttributes.from(t,e=>e.attrs)]}),uv=75;function Ef(t,e="option"){return r=>{let n=r.state.field(Xt,!1);if(!n||!n.open||Date.now()-n.open.timestamp=a&&(s=e=="page"?a-1:0),r.dispatch({effects:fv.of(s)}),!0}}var GT=t=>{let e=t.state.field(Xt,!1);return t.state.readOnly||!e||!e.open||Date.now()-e.open.timestampt.state.field(Xt,!1)?(t.dispatch({effects:Vp.of(!0)}),!0):!1,JT=t=>{let e=t.state.field(Xt,!1);return!e||!e.active.some(r=>r.state!=0)?!1:(t.dispatch({effects:Nf.of(null)}),!0)},Fp=class{constructor(e,r){this.active=e,this.context=r,this.time=Date.now(),this.updates=[],this.done=void 0}},ov=50,YT=50,XT=1e3,QT=de.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of t.state.field(Xt).active)e.state==1&&this.startQuery(e)}update(t){let e=t.state.field(Xt);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Xt)==e)return;let r=t.transactions.some(n=>(n.selection||n.docChanged)&&!zp(n));for(let n=0;nYT&&Date.now()-i.time>XT){for(let o of i.context.abortListeners)try{o()}catch(s){lt(this.view.state,s)}i.context.abortListeners=null,this.running.splice(n--,1)}else i.updates.push(...t.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some(n=>n.state==1&&!this.running.some(i=>i.active.source==n.source))?setTimeout(()=>this.startUpdate(),ov):-1,this.composing!=0)for(let n of t.transactions)zp(n)=="input"?this.composing=2:this.composing==2&&n.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:t}=this.view,e=t.field(Xt);for(let r of e.active)r.state==1&&!this.running.some(n=>n.active.source==r.source)&&this.startQuery(r)}startQuery(t){let{state:e}=this.view,r=Un(e),n=new Mf(e,r,t.explicitPos==r),i=new Fp(t,n);this.running.push(i),Promise.resolve(t.source(n)).then(o=>{i.context.aborted||(i.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Nf.of(null)}),lt(this.view.state,o)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),ov))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],r=this.view.state.facet(Hn);for(let n=0;ns.source==i.active.source);if(o&&o.state==1)if(i.done==null){let s=new ft(i.active.source,0);for(let a of i.updates)s=s.update(a,r);s.state!=1&&e.push(s)}else this.startQuery(o)}e.length&&this.view.dispatch({effects:cv.of(e)})}},{eventHandlers:{blur(){let t=this.view.state.field(Xt,!1);t&&t.tooltip&&this.view.state.facet(Hn).closeOnBlur&&this.view.dispatch({effects:Nf.of(null)})},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Vp.of(!1)}),20),this.composing=0}}}),eO=B.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",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".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:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",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"},".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 Pf={brackets:["(","[","{","'",'"'],before:")]}:;>"},Fi=W.define({map(t,e){let r=e.mapPos(t,-1,Je.TrackAfter);return r??void 0}}),Up=W.define({map(t,e){return e.mapPos(t)}}),Hp=new class extends kr{};Hp.startSide=1;Hp.endSide=-1;var hv=ce.define({create(){return te.empty},update(t,e){if(e.selection){let r=e.state.doc.lineAt(e.selection.main.head).from,n=e.startState.doc.lineAt(e.startState.selection.main.head).from;r!=e.changes.mapPos(n,-1)&&(t=te.empty)}t=t.map(e.changes);for(let r of e.effects)r.is(Fi)?t=t.update({add:[Hp.range(r.value,r.value+1)]}):r.is(Up)&&(t=t.update({filter:n=>n!=r.value}));return t}});function dv(){return[rO,hv]}var Bp="()[]{}<>";function pv(t){for(let e=0;e{if((tO?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(n.length>2||n.length==2&&St($e(n,0))==1||e!=i.from||r!=i.to)return!1;let o=iO(t.state,n);return o?(t.dispatch(o),!0):!1}),nO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=mv(t,t.selection.main.head).brackets||Pf.brackets,i=null,o=t.changeByRange(s=>{if(s.empty){let a=oO(t.doc,s.head);for(let l of n)if(l==a&&Lf(t.doc,s.head)==pv($e(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:A.cursor(s.head-l.length),userEvent:"delete.backward"}}return{range:i=s}});return i||e(t.update(o,{scrollIntoView:!0})),!i},gv=[{key:"Backspace",run:nO}];function iO(t,e){let r=mv(t,t.selection.main.head),n=r.brackets||Pf.brackets;for(let i of n){let o=pv($e(i,0));if(e==i)return o==i?lO(t,i,n.indexOf(i+i+i)>-1):sO(t,i,o,r.before||Pf.before);if(e==o&&yv(t,t.selection.main.from))return aO(t,i,o)}return null}function yv(t,e){let r=!1;return t.field(hv).between(0,t.doc.length,n=>{n==e&&(r=!0)}),r}function Lf(t,e){let r=t.sliceString(e,e+2);return r.slice(0,St($e(r,0)))}function oO(t,e){let r=t.sliceString(e-2,e);return St($e(r,0))==r.length?r:r.slice(1)}function sO(t,e,r,n){let i=null,o=t.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:r,from:s.to}],effects:Fi.of(s.to+e.length),range:A.range(s.anchor+e.length,s.head+e.length)};let a=Lf(t.doc,s.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+r,from:s.head},effects:Fi.of(s.head+e.length),range:A.cursor(s.head+e.length)}:{range:i=s}});return i?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function aO(t,e,r){let n=null,i=t.selection.ranges.map(o=>o.empty&&Lf(t.doc,o.head)==r?A.cursor(o.head+r.length):n=o);return n?null:t.update({selection:A.create(i,t.selection.mainIndex),scrollIntoView:!0,effects:t.selection.ranges.map(({from:o})=>Up.of(o))})}function lO(t,e,r){let n=null,i=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:e,from:o.to}],effects:Fi.of(o.to+e.length),range:A.range(o.anchor+e.length,o.head+e.length)};let s=o.head,a=Lf(t.doc,s);if(a==e){if(sv(t,s))return{changes:{insert:e+e,from:s},effects:Fi.of(s+e.length),range:A.cursor(s+e.length)};if(yv(t,s)){let l=r&&t.sliceDoc(s,s+e.length*3)==e+e+e;return{range:A.cursor(s+e.length*(l?3:1)),effects:Up.of(s)}}}else{if(r&&t.sliceDoc(s-2*e.length,s)==e+e&&sv(t,s-2*e.length))return{changes:{insert:e+e+e+e,from:s},effects:Fi.of(s+e.length),range:A.cursor(s+e.length)};if(t.charCategorizer(s)(a)!=je.Word){let l=t.sliceDoc(s-1,s);if(l!=e&&t.charCategorizer(s)(l)!=je.Word&&!cO(t,s,e))return{changes:{insert:e+e,from:s},effects:Fi.of(s+e.length),range:A.cursor(s+e.length)}}}return{range:n=o}});return n?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function sv(t,e){let r=qe(t).resolveInner(e+1);return r.parent&&r.from==e}function cO(t,e,r){let n=qe(t).resolveInner(e,-1);for(let i=0;i<5;i++){if(t.sliceDoc(n.from,n.from+r.length)==r)return!0;let o=n.to==e&&n.parent;if(!o)break;n=o}return!1}function If(t={}){return[Xt,Hn.of(t),QT,fO,eO]}var Wp=[{key:"Ctrl-Space",run:ZT},{key:"Escape",run:JT},{key:"ArrowDown",run:Ef(!0)},{key:"ArrowUp",run:Ef(!1)},{key:"PageDown",run:Ef(!0,"page")},{key:"PageUp",run:Ef(!1,"page")},{key:"Enter",run:GT}],fO=hn.highest(Ii.computeN([Hn],t=>t.facet(Hn).defaultKeymap?[Wp]:[]));var uO=t=>{let e=Yp(t.state);return e.line?hO(t):e.block?pO(t):!1};function Jp(t,e){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let i=t(e,r);return i?(n(r.update(i)),!0):!1}}var hO=Jp(yO,0);var dO=Jp(Rv,0);var pO=Jp((t,e)=>Rv(t,e,gO(e)),0);function Yp(t,e=t.selection.main.head){let r=t.languageDataAt("commentTokens",e);return r.length?r[0]:{}}var Va=50;function mO(t,{open:e,close:r},n,i){let o=t.sliceDoc(n-Va,n),s=t.sliceDoc(i,i+Va),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,c=o.length-a;if(o.slice(c-e.length,c)==e&&s.slice(l,l+r.length)==r)return{open:{pos:n-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let f,u;i-n<=2*Va?f=u=t.sliceDoc(n,i):(f=t.sliceDoc(n,n+Va),u=t.sliceDoc(i-Va,i));let h=/^\s*/.exec(f)[0].length,d=/\s*$/.exec(u)[0].length,p=u.length-d-r.length;return f.slice(h,h+e.length)==e&&u.slice(p,p+r.length)==r?{open:{pos:n+h+e.length,margin:/\s/.test(f.charAt(h+e.length))?1:0},close:{pos:i-d-r.length,margin:/\s/.test(u.charAt(p-1))?1:0}}:null}function gO(t){let e=[];for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),i=r.to<=n.to?n:t.doc.lineAt(r.to),o=e.length-1;o>=0&&e[o].to>n.from?e[o].to=i.to:e.push({from:n.from,to:i.to})}return e}function Rv(t,e,r=e.selection.ranges){let n=r.map(o=>Yp(e,o.from).block);if(!n.every(o=>o))return null;let i=r.map((o,s)=>mO(e,n[s],o.from,o.to));if(t!=2&&!i.every(o=>o))return{changes:e.changes(r.map((o,s)=>i[s]?[]:[{from:o.from,insert:n[s].open+" "},{from:o.to,insert:" "+n[s].close}]))};if(t!=1&&i.some(o=>o)){let o=[];for(let s=0,a;si&&(o==s||s>f.from)){i=f.from;let u=Yp(e,c).line;if(!u)continue;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+u.length)==u?h:-1;ho.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:f,single:u}of n)(u||!f)&&o.push({from:a.from+c,insert:l+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of n)if(a>=0){let c=s.from+a,f=c+l.length;s.text[f-s.from]==" "&&f++,o.push({from:c,to:f})}return{changes:o}}return null}var Kp=br.define(),bO=br.define(),kO=j.define(),Ev=j.define({combine(t){return yt(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}});function vO(t){let e=0;return t.iterChangedRanges((r,n)=>e=n),e}var Mv=ce.define({create(){return er.empty},update(t,e){let r=e.state.facet(Ev),n=e.annotation(Kp);if(n){let l=e.docChanged?A.single(vO(e.changes)):void 0,c=ut.fromTransaction(e,l),f=n.side,u=f==0?t.undone:t.done;return c?u=Bf(u,u.length,r.minDepth,c):u=Iv(u,e.startState.selection),new er(f==0?n.rest:u,f==0?u:n.rest)}let i=e.annotation(bO);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Re.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=ut.fromTransaction(e),s=e.annotation(Re.time),a=e.annotation(Re.userEvent);return o?t=t.addChanges(o,s,a,r.newGroupDelay,r.minDepth):e.selection&&(t=t.addSelection(e.startState.selection,s,a,r.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new er(t.done.map(ut.fromJSON),t.undone.map(ut.fromJSON))}});function Dv(t={}){return[Mv,Ev.of(t),B.domEventHandlers({beforeinput(e,r){let n=e.inputType=="historyUndo"?Nv:e.inputType=="historyRedo"?Pv:null;return n?(e.preventDefault(),n(r)):!1}})]}function jf(t,e){return function({state:r,dispatch:n}){if(!e&&r.readOnly)return!1;let i=r.field(Mv,!1);if(!i)return!1;let o=i.pop(t,r,e);return o?(n(o),!0):!1}}var Nv=jf(0,!1),Pv=jf(1,!1),wO=jf(0,!0),xO=jf(1,!0);var ut=class{constructor(e,r,n,i,o){this.changes=e,this.effects=r,this.mapped=n,this.startSelection=i,this.selectionsAfter=o}setSelAfter(e){return new ut(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,r,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new ut(e.changes&&Oe.fromJSON(e.changes),[],e.mapped&&Kt.fromJSON(e.mapped),e.startSelection&&A.fromJSON(e.startSelection),e.selectionsAfter.map(A.fromJSON))}static fromTransaction(e,r){let n=Qt;for(let i of e.startState.facet(kO)){let o=i(e);o.length&&(n=n.concat(o))}return!n.length&&e.changes.empty?null:new ut(e.changes.invert(e.startState.doc),n,void 0,r||e.startState.selection,Qt)}static selection(e){return new ut(void 0,Qt,void 0,void 0,e)}};function Bf(t,e,r,n){let i=e+1>r+20?e-r-1:0,o=t.slice(i,e);return o.push(n),o}function SO(t,e){let r=[],n=!1;return t.iterChangedRanges((i,o)=>r.push(i,o)),e.iterChangedRanges((i,o,s,a)=>{for(let l=0;l=c&&s<=f&&(n=!0)}}),n}function _O(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((r,n)=>r.empty!=e.ranges[n].empty).length===0}function Lv(t,e){return t.length?e.length?t.concat(e):t:e}var Qt=[],CO=200;function Iv(t,e){if(t.length){let r=t[t.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-CO));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),Bf(t,t.length-1,1e9,r.setSelAfter(n)))}else return[ut.selection([e])]}function AO(t){let e=t[t.length-1],r=t.slice();return r[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),r}function qp(t,e){if(!t.length)return t;let r=t.length,n=Qt;for(;r;){let i=TO(t[r-1],e,n);if(i.changes&&!i.changes.empty||i.effects.length){let o=t.slice(0,r);return o[r-1]=i,o}else e=i.mapped,r--,n=i.selectionsAfter}return n.length?[ut.selection(n)]:Qt}function TO(t,e,r){let n=Lv(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Qt,r);if(!t.changes)return ut.selection(n);let i=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new ut(i,W.mapEffects(t.effects,e),s,t.startSelection.map(o),n)}var OO=/^(input\.type|delete)($|\.)/,er=class{constructor(e,r,n=0,i=void 0){this.done=e,this.undone=r,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new er(this.done,this.undone):this}addChanges(e,r,n,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||OO.test(n))&&(!a.selectionsAfter.length&&r-this.prevTime0&&r-this.prevTimer.empty?t.moveByChar(r,e):$f(r,e))}function tr(t){return t.textDirectionAt(t.state.selection.main.head)==ye.LTR}var $v=t=>jv(t,!tr(t)),zv=t=>jv(t,tr(t));function Fv(t,e){return yn(t,r=>r.empty?t.moveByGroup(r,e):$f(r,e))}var RO=t=>Fv(t,!tr(t)),EO=t=>Fv(t,tr(t));function MO(t,e,r){if(e.type.prop(r))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function zf(t,e,r){let n=qe(t).resolveInner(e.head),i=r?Z.closedBy:Z.openedBy;for(let l=e.head;;){let c=r?n.childAfter(l):n.childBefore(l);if(!c)break;MO(t,c,i)?n=c:l=r?c.to:c.from}let o=n.type.prop(i),s,a;return o&&(s=r?xr(t,n.from,1):xr(t,n.to,-1))&&s.matched?a=r?s.end.to:s.end.from:a=r?n.to:n.from,A.cursor(a,r?-1:1)}var DO=t=>yn(t,e=>zf(t.state,e,!tr(t))),NO=t=>yn(t,e=>zf(t.state,e,tr(t)));function Vv(t,e){return yn(t,r=>{if(!r.empty)return $f(r,e);let n=t.moveVertically(r,e);return n.head!=r.head?n:t.moveToLineBoundary(r,e)})}var Uv=t=>Vv(t,!1),Hv=t=>Vv(t,!0);function Wv(t,e){let{state:r}=t,n=rs(r.selection,a=>a.empty?t.moveVertically(a,e,Math.min(t.dom.clientHeight,innerHeight)):$f(a,e));if(n.eq(r.selection))return!1;let i=t.coordsAtPos(r.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),s;return i&&i.top>o.top&&i.bottomWv(t,!1),Gp=t=>Wv(t,!0);function Ff(t,e,r){let n=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,r);if(i.head==e.head&&i.head!=(r?n.to:n.from)&&(i=t.moveToLineBoundary(e,r,!1)),!r&&i.head==n.from&&n.length){let o=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&e.head!=n.from+o&&(i=A.cursor(n.from+o))}return i}var kv=t=>yn(t,e=>Ff(t,e,!0)),vv=t=>yn(t,e=>Ff(t,e,!1)),PO=t=>yn(t,e=>A.cursor(t.lineBlockAt(e.head).from,1)),LO=t=>yn(t,e=>A.cursor(t.lineBlockAt(e.head).to,-1));function IO(t,e,r){let n=!1,i=rs(t.selection,o=>{let s=xr(t,o.head,-1)||xr(t,o.head,1)||o.head>0&&xr(t,o.head-1,1)||o.headIO(t,e,!1);function Gr(t,e){let r=rs(t.state.selection,n=>{let i=e(n);return A.range(n.anchor,i.head,i.goalColumn)});return r.eq(t.state.selection)?!1:(t.dispatch(Kr(t.state,r)),!0)}function qv(t,e){return Gr(t,r=>t.moveByChar(r,e))}var Kv=t=>qv(t,!tr(t)),Gv=t=>qv(t,tr(t));function Zv(t,e){return Gr(t,r=>t.moveByGroup(r,e))}var jO=t=>Zv(t,!tr(t)),$O=t=>Zv(t,tr(t));var zO=t=>Gr(t,e=>zf(t.state,e,!tr(t))),FO=t=>Gr(t,e=>zf(t.state,e,tr(t)));function Jv(t,e){return Gr(t,r=>t.moveVertically(r,e))}var Yv=t=>Jv(t,!1),Xv=t=>Jv(t,!0);function Qv(t,e){return Gr(t,r=>t.moveVertically(r,e,Math.min(t.dom.clientHeight,innerHeight)))}var wv=t=>Qv(t,!1),xv=t=>Qv(t,!0),Sv=t=>Gr(t,e=>Ff(t,e,!0)),_v=t=>Gr(t,e=>Ff(t,e,!1)),VO=t=>Gr(t,e=>A.cursor(t.lineBlockAt(e.head).from)),UO=t=>Gr(t,e=>A.cursor(t.lineBlockAt(e.head).to)),Cv=({state:t,dispatch:e})=>(e(Kr(t,{anchor:0})),!0),Av=({state:t,dispatch:e})=>(e(Kr(t,{anchor:t.doc.length})),!0),Tv=({state:t,dispatch:e})=>(e(Kr(t,{anchor:t.selection.main.anchor,head:0})),!0),Ov=({state:t,dispatch:e})=>(e(Kr(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),HO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),WO=({state:t,dispatch:e})=>{let r=Hf(t).map(({from:n,to:i})=>A.range(n,Math.min(i+1,t.doc.length)));return e(t.update({selection:A.create(r),userEvent:"select"})),!0},qO=({state:t,dispatch:e})=>{let r=rs(t.selection,n=>{var i;let o=qe(t).resolveInner(n.head,1);for(;!(o.from=n.to||o.to>n.to&&o.from<=n.from||!(!((i=o.parent)===null||i===void 0)&&i.parent));)o=o.parent;return A.range(o.to,o.from)});return e(Kr(t,r)),!0},KO=({state:t,dispatch:e})=>{let r=t.selection,n=null;return r.ranges.length>1?n=A.create([r.main]):r.main.empty||(n=A.create([A.cursor(r.main.head)])),n?(e(Kr(t,n)),!0):!1};function Vf({state:t,dispatch:e},r){if(t.readOnly)return!1;let n="delete.selection",i=t.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=r(s);ls&&(n="delete.forward"),s=Math.min(s,l),a=Math.max(a,l)}return s==a?{range:o}:{changes:{from:s,to:a},range:A.cursor(s)}});return i.changes.empty?!1:(e(t.update(i,{scrollIntoView:!0,userEvent:n})),!0)}function Uf(t,e,r){if(t instanceof B)for(let n of t.state.facet(B.atomicRanges).map(i=>i(t)))n.between(e,e,(i,o)=>{ie&&(e=r?o:i)});return e}var ew=(t,e)=>Vf(t,r=>{let{state:n}=t,i=n.doc.lineAt(r),o,s;if(!e&&r>i.from&&rew(t,!1),tw=t=>ew(t,!0),rw=(t,e)=>Vf(t,r=>{let n=r,{state:i}=t,o=i.doc.lineAt(n),s=i.charCategorizer(n);for(let a=null;;){if(n==(e?o.to:o.from)){n==r&&o.number!=(e?i.doc.lines:1)&&(n+=e?1:-1);break}let l=gt(o.text,n-o.from,e)+o.from,c=o.text.slice(Math.min(n,l)-o.from,Math.max(n,l)-o.from),f=s(c);if(a!=null&&f!=a)break;(c!=" "||n!=r)&&(a=f),n=l}return Uf(t,n,e)}),nw=t=>rw(t,!1),GO=t=>rw(t,!0),iw=t=>Vf(t,e=>{let r=t.lineBlockAt(e).to;return Uf(t,eVf(t,e=>{let r=t.lineBlockAt(e).from;return Uf(t,e>r?r:Math.max(0,e-1),!1)});var JO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:ee.of(["",""])},range:A.cursor(n.from)}));return e(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},YO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let i=n.from,o=t.doc.lineAt(i),s=i==o.from?i-1:gt(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:gt(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(s,i))},range:A.cursor(a)}});return r.changes.empty?!1:(e(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Hf(t){let e=[],r=-1;for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),o=t.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=t.doc.lineAt(n.to-1)),r>=i.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(n)}else e.push({from:i.from,to:o.to,ranges:[n]});r=o.number+1}return e}function ow(t,e,r){if(t.readOnly)return!1;let n=[],i=[];for(let o of Hf(t)){if(r?o.to==t.doc.length:o.from==0)continue;let s=t.doc.lineAt(r?o.to+1:o.from-1),a=s.length+1;if(r){n.push({from:o.to,to:s.to},{from:o.from,insert:s.text+t.lineBreak});for(let l of o.ranges)i.push(A.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{n.push({from:s.from,to:o.from},{from:o.to,insert:t.lineBreak+s.text});for(let l of o.ranges)i.push(A.range(l.anchor-a,l.head-a))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:A.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}var XO=({state:t,dispatch:e})=>ow(t,e,!1),QO=({state:t,dispatch:e})=>ow(t,e,!0);function sw(t,e,r){if(t.readOnly)return!1;let n=[];for(let i of Hf(t))r?n.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):n.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var eR=({state:t,dispatch:e})=>sw(t,e,!1),tR=({state:t,dispatch:e})=>sw(t,e,!0),rR=t=>{if(t.state.readOnly)return!1;let{state:e}=t,r=e.changes(Hf(e).map(({from:i,to:o})=>(i>0?i--:ot.moveVertically(i,!0)).map(r);return t.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function nR(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let r=qe(t).resolveInner(e),n=r.childBefore(e),i=r.childAfter(e),o;return n&&i&&n.to<=e&&i.from>=e&&(o=n.type.prop(Z.closedBy))&&o.indexOf(i.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(i.from).from?{from:n.to,to:i.from}:null}var iR=aw(!1),oR=aw(!0);function aw(t){return({state:e,dispatch:r})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:o,to:s}=i,a=e.doc.lineAt(o),l=!t&&o==s&&nR(e,o);t&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new $i(e,{simulateBreak:o,simulateDoubleBreak:!!l}),f=Of(c,o);for(f==null&&(f=/^\s*/.exec(e.doc.lineAt(o).text)[0].length);sa.from&&o{let i=[];for(let s=n.from;s<=n.to;){let a=t.doc.lineAt(s);a.number>r&&(n.empty||n.to>a.from)&&(e(a,i,n),r=a.number),s=a.to+1}let o=t.changes(i);return{changes:i,range:A.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}var sR=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=Object.create(null),n=new $i(t,{overrideIndentation:o=>{let s=r[o];return s??-1}}),i=Xp(t,(o,s,a)=>{let l=Of(n,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let c=/^\s*/.exec(o.text)[0],f=es(t,l);(c!=f||a.fromt.readOnly?!1:(e(t.update(Xp(t,(r,n)=>{n.push({from:r.from,insert:t.facet($a)})}),{userEvent:"input.indent"})),!0),cw=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Xp(t,(r,n)=>{let i=/^\s*/.exec(r.text)[0];if(!i)return;let o=Pn(i,t.tabSize),s=0,a=es(t,Math.max(0,o-za(t)));for(;s({mac:t.key,run:t.run,shift:t.shift}))),fw=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:DO,shift:zO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:NO,shift:FO},{key:"Alt-ArrowUp",run:XO},{key:"Shift-Alt-ArrowUp",run:eR},{key:"Alt-ArrowDown",run:QO},{key:"Shift-Alt-ArrowDown",run:tR},{key:"Escape",run:KO},{key:"Mod-Enter",run:oR},{key:"Alt-l",mac:"Ctrl-l",run:WO},{key:"Mod-i",run:qO,preventDefault:!0},{key:"Mod-[",run:cw},{key:"Mod-]",run:lw},{key:"Mod-Alt-\\",run:sR},{key:"Shift-Mod-k",run:rR},{key:"Shift-Mod-\\",run:BO},{key:"Mod-/",run:uO},{key:"Alt-A",run:dO}].concat(lR),uw={key:"Tab",run:lw,shift:cw};function ue(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,r=arguments[1];if(r&&typeof r=="object"&&r.nodeType==null&&!Array.isArray(r)){for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)){var i=r[n];typeof i=="string"?t.setAttribute(n,i):i!=null&&(t[n]=i)}e++}for(;et.normalize("NFKD"):t=>t,Kn=class{constructor(e,r,n=0,i=e.length,o){this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=o?s=>o(dw(s)):dw,this.query=this.normalize(r)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return $e(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let r=pa(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=St(e);let i=this.normalize(r);for(let o=0,s=n;;o++){let a=i.charCodeAt(o),l=this.match(a,s);if(l)return this.value=l,this;if(o==i.length-1)break;s==n&&othis.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 r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,i=n+r[0].length;if(this.matchPos=i+(n==i?1:0),n==this.curLine.length&&this.nextLine(),nthis.value.to)return this.value={from:n,to:i,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=n||i.to<=r){let a=new Wn(r,e.sliceString(r,n));return Qp.set(e,a),a}if(i.from==r&&i.to==n)return i;let{text:o,from:s}=i;return s>r&&(o=e.sliceString(r,s)+o,s=r),i.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r&&this.flat.tothis.flat.text.length-10&&(r=null),r){let n=this.flat.from+r.index,i=n+r[0].length;return this.value={from:n,to:i,match:r},this.matchPos=i+(n==i?1:0),this}else{if(this.flat.to==this.to)return this.done=!0,this;this.flat=Wn.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}};typeof Symbol<"u"&&(Kf.prototype[Symbol.iterator]=Gf.prototype[Symbol.iterator]=function(){return this});function cR(t){try{return new RegExp(t,om),!0}catch{return!1}}function em(t){let e=ue("input",{class:"cm-textfield",name:"line"}),r=ue("form",{class:"cm-gotoLine",onkeydown:i=>{i.keyCode==27?(i.preventDefault(),t.dispatch({effects:Zf.of(!1)}),t.focus()):i.keyCode==13&&(i.preventDefault(),n())},onsubmit:i=>{i.preventDefault(),n()}},ue("label",t.state.phrase("Go to line"),": ",e)," ",ue("button",{class:"cm-button",type:"submit"},t.state.phrase("go")));function n(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:o}=t,s=o.doc.lineAt(o.selection.main.head),[,a,l,c,f]=i,u=c?+c.slice(1):0,h=l?+l:s.number;if(l&&f){let p=h/100;a&&(p=p*(a=="-"?-1:1)+s.number/o.doc.lines),h=Math.round(o.doc.lines*p)}else l&&a&&(h=h*(a=="-"?-1:1)+s.number);let d=o.doc.line(Math.max(1,Math.min(o.doc.lines,h)));t.dispatch({effects:Zf.of(!1),selection:A.cursor(d.from+Math.max(0,Math.min(u,d.length))),scrollIntoView:!0}),t.focus()}return{dom:r}}var Zf=W.define(),pw=ce.define({create(){return!0},update(t,e){for(let r of e.effects)r.is(Zf)&&(t=r.value);return t},provide:t=>Li.from(t,e=>e?em:null)}),fR=t=>{let e=Bi(t,em);if(!e){let r=[Zf.of(!0)];t.state.field(pw,!1)==null&&r.push(W.appendConfig.of([pw,uR])),t.dispatch({effects:r}),e=Bi(t,em)}return e&&e.dom.querySelector("input").focus(),!0},uR=B.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),hR={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},bw=j.define({combine(t){return yt(t,hR,{highlightWordAroundCursor:(e,r)=>e||r,minSelectionLength:Math.min,maxMatches:Math.min})}});function kw(t){let e=[yR,gR];return t&&e.push(bw.of(t)),e}var dR=$.mark({class:"cm-selectionMatch"}),pR=$.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function mw(t,e,r,n){return(r==0||t(e.sliceDoc(r-1,r))!=je.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=je.Word)}function mR(t,e,r,n){return t(e.sliceDoc(r,r+1))==je.Word&&t(e.sliceDoc(n-1,n))==je.Word}var gR=de.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(bw),{state:r}=t,n=r.selection;if(n.ranges.length>1)return $.none;let i=n.main,o,s=null;if(i.empty){if(!e.highlightWordAroundCursor)return $.none;let l=r.wordAt(i.head);if(!l)return $.none;s=r.charCategorizer(i.head),o=r.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l200)return $.none;if(e.wholeWords){if(o=r.sliceDoc(i.from,i.to),s=r.charCategorizer(i.head),!(mw(s,r,i.from,i.to)&&mR(s,r,i.from,i.to)))return $.none}else if(o=r.sliceDoc(i.from,i.to).trim(),!o)return $.none}let a=[];for(let l of t.visibleRanges){let c=new Kn(r.doc,o,l.from,l.to);for(;!c.next().done;){let{from:f,to:u}=c.value;if((!s||mw(s,r,f,u))&&(i.empty&&f<=i.from&&u>=i.to?a.push(pR.range(f,u)):(f>=i.to||u<=i.from)&&a.push(dR.range(f,u)),a.length>e.maxMatches))return $.none}}return $.set(a)}},{decorations:t=>t.decorations}),yR=B.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),bR=({state:t,dispatch:e})=>{let{selection:r}=t,n=A.create(r.ranges.map(i=>t.wordAt(i.head)||A.cursor(i.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function kR(t,e){let{main:r,ranges:n}=t.selection,i=t.wordAt(r.head),o=i&&i.from==r.from&&i.to==r.to;for(let s=!1,a=new Kn(t.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new Kn(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),s=!0}else{if(s&&n.some(l=>l.from==a.value.from))continue;if(o){let l=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var vR=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(o=>o.from===o.to))return bR({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(o=>t.sliceDoc(o.from,o.to)!=n))return!1;let i=kR(t,n);return i?(e(t.update({selection:t.selection.addRange(A.range(i.from,i.to),!1),effects:B.scrollIntoView(i.to)})),!0):!1},sm=j.define({combine(t){var e;return{top:t.reduce((r,n)=>r??n.top,void 0)||!1,caseSensitive:t.reduce((r,n)=>r??n.caseSensitive,void 0)||!1,createPanel:((e=t.find(r=>r.createPanel))===null||e===void 0?void 0:e.createPanel)||(r=>new im(r))}}});var Jf=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||cR(this.search)),this.unquoted=e.literal?this.search:this.search.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?` +`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp}create(){return this.regexp?new rm(this):new tm(this)}getCursor(e,r=0,n=e.length){return this.regexp?is(this,e,r,n):ns(this,e,r,n)}},Yf=class{constructor(e){this.spec=e}};function ns(t,e,r,n){return new Kn(e,t.unquoted,r,n,t.caseSensitive?void 0:i=>i.toLowerCase())}var tm=class extends Yf{constructor(e){super(e)}nextMatch(e,r,n){let i=ns(this.spec,e,n,e.length).nextOverlapping();return i.done&&(i=ns(this.spec,e,0,r).nextOverlapping()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=n;;){let o=Math.max(r,i-1e4-this.spec.unquoted.length),s=ns(this.spec,e,o,i),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(o==r)return null;i-=1e4}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.length)}getReplacement(e){return this.spec.replace}matchAll(e,r){let n=ns(this.spec,e,0,e.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=ns(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.length));for(;!o.next().done;)i(o.value.from,o.value.to)}};function is(t,e,r,n){return new Kf(e,t.search,t.caseSensitive?void 0:{ignoreCase:!0},r,n)}var rm=class extends Yf{nextMatch(e,r,n){let i=is(this.spec,e,n,e.length).next();return i.done&&(i=is(this.spec,e,0,r).next()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=1;;i++){let o=Math.max(r,n-i*1e4),s=is(this.spec,e,o,n),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==r||a.from>o+10))return a;if(o==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.length)}getReplacement(e){return this.spec.replace.replace(/\$([$&\d+])/g,(r,n)=>n=="$"?"$":n=="&"?e.match[0]:n!="0"&&+n=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=is(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.length));for(;!o.next().done;)i(o.value.from,o.value.to)}},Ha=W.define(),am=W.define(),qn=ce.define({create(t){return new Ua(nm(t).create(),null)},update(t,e){for(let r of e.effects)r.is(Ha)?t=new Ua(r.value.create(),t.panel):r.is(am)&&(t=new Ua(t.query,r.value?lm:null));return t},provide:t=>Li.from(t,e=>e.panel)});var Ua=class{constructor(e,r){this.query=e,this.panel=r}},wR=$.mark({class:"cm-searchMatch"}),xR=$.mark({class:"cm-searchMatch cm-searchMatch-selected"}),SR=de.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(qn))}update(t){let e=t.state.field(qn);(e!=t.startState.field(qn)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return $.none;let{view:r}=this,n=new Dt;for(let i=0,o=r.visibleRanges,s=o.length;io[i+1].from-2*250;)l=o[++i].to;t.highlight(r.state.doc,a,l,(c,f)=>{let u=r.state.selection.ranges.some(h=>h.from==c&&h.to==f);n.add(c,f,u?xR:wR)})}return n.finish()}},{decorations:t=>t.decorations});function Wa(t){return e=>{let r=e.state.field(qn,!1);return r&&r.query.spec.valid?t(e,r):vw(e)}}var Xf=Wa((t,{query:e})=>{let{from:r,to:n}=t.state.selection.main,i=e.nextMatch(t.state.doc,r,n);return!i||i.from==r&&i.to==n?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:cm(t,i),userEvent:"select.search"}),!0)}),Qf=Wa((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main,o=e.prevMatch(r.doc,n,i);return o?(t.dispatch({selection:{anchor:o.from,head:o.to},scrollIntoView:!0,effects:cm(t,o),userEvent:"select.search"}),!0):!1}),_R=Wa((t,{query:e})=>{let r=e.matchAll(t.state.doc,1e3);return!r||!r.length?!1:(t.dispatch({selection:A.create(r.map(n=>A.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),CR=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:i}=r.main,o=[],s=0;for(let a=new Kn(t.doc,t.sliceDoc(n,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==n&&(s=o.length),o.push(A.range(a.value.from,a.value.to))}return e(t.update({selection:A.create(o,s),userEvent:"select.search.matches"})),!0},gw=Wa((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main;if(r.readOnly)return!1;let o=e.nextMatch(r.doc,n,n);if(!o)return!1;let s=[],a,l;if(o.from==n&&o.to==i&&(l=r.toText(e.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=e.nextMatch(r.doc,o.from,o.to)),o){let c=s.length==0||s[0].from>=o.to?0:o.to-o.from-l.length;a={anchor:o.from-c,head:o.to-c}}return t.dispatch({changes:s,selection:a,scrollIntoView:!!a,effects:o?cm(t,o):void 0,userEvent:"input.replace"}),!0}),AR=Wa((t,{query:e})=>{if(t.state.readOnly)return!1;let r=e.matchAll(t.state.doc,1e9).map(n=>{let{from:i,to:o}=n;return{from:i,to:o,insert:e.getReplacement(n)}});return r.length?(t.dispatch({changes:r,userEvent:"input.replace.all"}),!0):!1});function lm(t){return t.state.facet(sm).createPanel(t)}function nm(t,e){var r;let n=t.selection.main,i=n.empty||n.to>n.from+100?"":t.sliceDoc(n.from,n.to),o=(r=e?.caseSensitive)!==null&&r!==void 0?r:t.facet(sm).caseSensitive;return e&&!i?e:new Jf({search:i.replace(/\n/g,"\\n"),caseSensitive:o})}var vw=t=>{let e=t.state.field(qn,!1);if(e&&e.panel){let r=Bi(t,lm);if(!r)return!1;let n=r.dom.querySelector("[name=search]");if(n!=t.root.activeElement){let i=nm(t.state,e.query.spec);i.valid&&t.dispatch({effects:Ha.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[am.of(!0),e?Ha.of(nm(t.state,e.query.spec)):W.appendConfig.of(OR)]});return!0},ww=t=>{let e=t.state.field(qn,!1);if(!e||!e.panel)return!1;let r=Bi(t,lm);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:am.of(!1)}),!0},xw=[{key:"Mod-f",run:vw,scope:"editor search-panel"},{key:"F3",run:Xf,shift:Qf,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Xf,shift:Qf,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ww,scope:"editor search-panel"},{key:"Mod-Shift-l",run:CR},{key:"Alt-g",run:fR},{key:"Mod-d",run:vR,preventDefault:!0}],im=class{constructor(e){this.view=e;let r=this.query=e.state.field(qn).query.spec;this.commit=this.commit.bind(this),this.searchField=ue("input",{value:r.search,placeholder:rr(e,"Find"),"aria-label":rr(e,"Find"),class:"cm-textfield",name:"search",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ue("input",{value:r.replace,placeholder:rr(e,"Replace"),"aria-label":rr(e,"Replace"),class:"cm-textfield",name:"replace",onchange:this.commit,onkeyup:this.commit}),this.caseField=ue("input",{type:"checkbox",name:"case",checked:r.caseSensitive,onchange:this.commit}),this.reField=ue("input",{type:"checkbox",name:"re",checked:r.regexp,onchange:this.commit});function n(i,o,s){return ue("button",{class:"cm-button",name:i,onclick:o,type:"button"},s)}this.dom=ue("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>Xf(e),[rr(e,"next")]),n("prev",()=>Qf(e),[rr(e,"previous")]),n("select",()=>_R(e),[rr(e,"all")]),ue("label",null,[this.caseField,rr(e,"match case")]),ue("label",null,[this.reField,rr(e,"regexp")]),...e.state.readOnly?[]:[ue("br"),this.replaceField,n("replace",()=>gw(e),[rr(e,"replace")]),n("replaceAll",()=>AR(e),[rr(e,"replace all")]),ue("button",{name:"close",onclick:()=>ww(e),"aria-label":rr(e,"close"),type:"button"},["\xD7"])]])}commit(){let e=new Jf({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Ha.of(e)}))}keydown(e){rk(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Qf:Xf)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),gw(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(Ha)&&!n.value.eq(this.query)&&this.setQuery(n.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}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(sm).top}};function rr(t,e){return t.state.phrase(e)}var Wf=30,qf=/[\s\.,:;?!]/;function cm(t,{from:e,to:r}){let n=t.state.doc.lineAt(e).from,i=t.state.doc.lineAt(r).to,o=Math.max(n,e-Wf),s=Math.min(i,r+Wf),a=t.state.sliceDoc(o,s);if(o!=n){for(let l=0;la.length-Wf;l--)if(!qf.test(a[l-1])&&qf.test(a[l])){a=a.slice(0,l);break}}return B.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${t.state.doc.lineAt(e).number}`)}var TR=B.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"}}),OR=[qn,hn.lowest(SR),TR];var um=class{constructor(e,r,n){this.from=e,this.to=r,this.diagnostic=n}},bn=class{constructor(e,r,n){this.diagnostics=e,this.panel=r,this.selected=n}static init(e,r,n){let i=e,o=n.facet(os).markerFilter;o&&(i=o(i));let s=$.set(i.map(a=>a.from==a.to||a.from==a.to-1&&n.doc.lineAt(a.from).to==a.from?$.widget({widget:new hm(a),diagnostic:a}).range(a.from):$.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity},diagnostic:a}).range(a.from,a.to)),!0);return new bn(s,r,ss(s))}};function ss(t,e=null,r=0){let n=null;return t.between(r,1e9,(i,o,{spec:s})=>{if(!(e&&s.diagnostic!=e))return n=new um(i,o,s.diagnostic),!1}),n}function RR(t,e){return!!(t.effects.some(r=>r.is(dm))||t.changes.touchesRange(e.pos))}function _w(t,e){return t.field(It,!1)?e:e.concat(W.appendConfig.of([It,B.decorations.compute([It],r=>{let{selected:n,panel:i}=r.field(It);return!n||!i||n.from==n.to?$.none:$.set([MR.range(n.from,n.to)])}),mk(DR,{hideOn:RR}),jR]))}function ER(t,e){return{effects:_w(t,[dm.of(e)])}}var dm=W.define(),pm=W.define(),Cw=W.define(),It=ce.define({create(){return new bn($.none,null,null)},update(t,e){if(e.docChanged){let r=t.diagnostics.map(e.changes),n=null;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);n=ss(r,t.selected.diagnostic,i)||ss(r,null,i)}t=new bn(r,t.panel,n)}for(let r of e.effects)r.is(dm)?t=bn.init(r.value,t.panel,e.state):r.is(pm)?t=new bn(t.diagnostics,r.value?as.open:null,t.selected):r.is(Cw)&&(t=new bn(t.diagnostics,t.panel,r.value));return t},provide:t=>[Li.from(t,e=>e.panel),B.decorations.from(t,e=>e.diagnostics)]});var MR=$.mark({class:"cm-lintRange cm-lintRange-active"});function DR(t,e,r){let{diagnostics:n}=t.state.field(It),i=[],o=2e8,s=0;n.between(e-(r<0?1:0),e+(r>0?1:0),(l,c,{spec:f})=>{e>=l&&e<=c&&(l==c||(e>l||r>0)&&(eOw(t,r,!1)))}var PR=t=>{let e=t.state.field(It,!1);(!e||!e.panel)&&t.dispatch({effects:_w(t.state,[pm.of(!0)])});let r=Bi(t,as.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},Sw=t=>{let e=t.state.field(It,!1);return!e||!e.panel?!1:(t.dispatch({effects:pm.of(!1)}),!0)},LR=t=>{let e=t.state.field(It,!1);if(!e)return!1;let r=t.state.selection.main,n=e.diagnostics.iter(r.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==r.from&&n.to==r.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Aw=[{key:"Mod-Shift-m",run:PR},{key:"F8",run:LR}],IR=de.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(os);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let t=Date.now();if(tPromise.resolve(n(this.view)))).then(n=>{let i=n.reduce((o,s)=>o.concat(s));this.view.state.doc==e.doc&&this.view.dispatch(ER(this.view.state,i))},n=>{lt(this.view.state,n)})}}update(t){let e=t.state.facet(os);(t.docChanged||e!=t.startState.facet(os))&&(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)}}),os=j.define({combine(t){return Object.assign({sources:t.map(e=>e.source)},yt(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null}))},enables:IR});function Tw(t){let e=[];if(t)e:for(let{name:r}of t){for(let n=0;no.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function Ow(t,e,r){var n;let i=r?Tw(e.actions):[];return ue("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ue("span",{class:"cm-diagnosticText"},e.message),(n=e.actions)===null||n===void 0?void 0:n.map((o,s)=>{let a=u=>{u.preventDefault();let h=ss(t.state.field(It).diagnostics,e);h&&o.apply(t,h.from,h.to)},{name:l}=o,c=i[s]?l.indexOf(i[s]):-1,f=c<0?l:[l.slice(0,c),ue("u",l.slice(c,c+1)),l.slice(c+1)];return ue("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${l}${c<0?"":` (access key "${i[s]})"`}.`},f)}),e.source&&ue("div",{class:"cm-diagnosticSource"},e.source))}var hm=class extends Pt{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return ue("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},eu=class{constructor(e,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ow(e,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},as=class{constructor(e){this.view=e,this.items=[];let r=i=>{if(i.keyCode==27)Sw(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=Tw(o.actions);for(let a=0;a{for(let o=0;oSw(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(It).selected;if(!e)return-1;for(let r=0;r{let c=-1,f;for(let u=n;un&&(this.items.splice(n,c-n),i=!0)),r&&f.diagnostic==r.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),o=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),n++});n({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:s,panel:a})=>{s.topa.bottom&&(this.list.scrollTop+=s.bottom-a.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function r(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)r();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)r()}moveSelection(e){if(this.selectedIndex<0)return;let r=this.view.state.field(It),n=ss(r.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Cw.of(n)})}static open(e){return new as(e)}};function BR(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function fm(t){return BR(``,'width="6" height="3"')}var jR=B.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-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:fm("#d11")},".cm-lintRange-warning":{backgroundImage:fm("orange")},".cm-lintRange-info":{backgroundImage:fm("#999")},".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-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}}});var Rw=[vk(),wk(),fk(),Dv(),qk(),ok(),ck(),G.allowMultipleSelections.of(!0),jk(),Gk(Zk,{fallback:!0}),Qk(),dv(),If(),hk(),dk(),uk(),kw(),Ii.of([...gv,...fw,...xw,...Bv,...Uk,...Wp,...Aw])];var nr=Object.freeze({assertDefined(t){if(t===void 0)throw new Error(`'${nr.stringify(t)}' is 'undefined'`)},assertNever(t){throw new Error(`'${nr.stringify(t)}' is not of type 'never'`)},assertTrue(t,e){if(!t)throw new Error(`Assertion failed: ${e}. '${nr.stringify(t)}' should be true.`)},estimateMemoryUsage(t){let n=0,i=new Set,o=[t];for(;o.length;){let s=o.pop();switch(typeof s){case"bigint":{let a=Math.ceil(Math.log2(Number(s)));n+=(2+Math.ceil(a/64))*8;break}case"boolean":n+=8;break;case"number":n+=8;break;case"object":if(n+=8,!s||i.has(s))break;n+=8;for(let a of Object.values(s))o.push(a),n+=8;i.add(s);break;case"string":n+=s.length*2;break;case"symbol":n+=8;break;default:break}}return n},stringify(t){if(t&&typeof t=="object")try{let e=new Set;return JSON.stringify(t,(r,n)=>n&&typeof n=="object"?e.has(n)?"[Circular]":(e.add(n),n):n)}catch{return`{ ${Object.entries(t).map(([r,n])=>`'${r}': '${String(n)}'`).join(", ")} }`}else return typeof t=="symbol"?String(t):`${t}`}});var Ew=Object.freeze({is(t){return t.startsWith("http:")||t.startsWith("https:")}}),oj=Object.freeze({mock(t){return new mm(t)}}),mm=class{options;constructor(e){this.options=e}async get(e){if(!this.options.fixtures[e])throw new Error(`404 not found: ${e}`);let r=this.options.fixtures[e];return r instanceof Uint8Array?r:typeof r=="string"?new TextEncoder().encode(r):new TextEncoder().encode(JSON.stringify(r))}};var ls;(function(t){function e(){return console}t.create=e;function r(){return new gm}t.noop=r})(ls||(ls={}));var gm=class{error(){}info(){}log(){}warn(){}};var qa=class{parent;constructor(e){this.parent=e}undoOps=[];redoOps=[];addUndoOp(e){this.undoOps.push(e),this.parent?.addUndoOp(e)}addRedoOp(e){this.redoOps.push(e),this.parent?.addRedoOp(e)}set(e,r,n,i=e){let o=Reflect.get(e,r,i),s=()=>{Reflect.set(e,r,n,i)},a=()=>{Reflect.set(e,r,o,i)};this.addRedoOp(s),this.addUndoOp(a),s()}undo(){for(let e=this.undoOps.length-1;e>=0;e--)this.undoOps[e]()}redo(){this.redoOps.forEach(e=>e())}};var Pw=Br(tu(),1),Lw=Br(ru(),1),Bt=URL;function nu(t=e=>e[0]){return(e,r,n)=>{let i=new Map,o=n.value;return n.value=function(...s){let a=t(s);if(i.has(a))return i.get(a);let l=o.apply(this,s).then(c=>(i.delete(a),c),c=>(i.delete(a),Promise.reject(c)));return i.set(a,l),l},n}}var q;(function(t){t.TagPrefix="#",t.NamespacePathSep=":",t.PathSep="/",t.DefaultNamespace="minecraft";function e(n){switch(n.indexOf(t.NamespacePathSep)){case-1:return`${t.DefaultNamespace}${t.NamespacePathSep}${n}`;case 0:return`${t.DefaultNamespace}${n}`;default:return n}}t.lengthen=e;function r(n){return n.replace(/^(?:minecraft)?:/,"")}t.shorten=r})(q||(q={}));function ir(t){return new TextDecoder().decode(t)}var Ue;(function(t){function e(n,i){return Array.isArray(n)?n.every(o=>i(o)):i(n)}t.is=e;function r(n){return Array.isArray(n)?n:[n]}t.toArray=r})(Ue||(Ue={}));var Gn;(function(t){function e(r){return typeof r=="string"}t.isString=e})(Gn||(Gn={}));async function ym(t,e){return JSON.parse(ir(await t.archive.gunzip(e)))}function Nw(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ka(t,e){let r=(0,Lw.default)()(t);for(let[n,i]of Object.entries(e))Nw(r[n])&&Nw(i)?r[n]=Ka(r[n],i):i===void 0?delete r[n]:r[n]=i;return r}var Zn;(function(t){let e=Symbol("LazyDiscriminator");function r(s){return{discriminator:e,getter:s}}t.create=r;function n(s){return s?.discriminator===e}t.isComplex=n;function i(s){return n(s)&&!("value"in s)}t.isUnresolved=i;function o(s){return i(s)?s.value=s.getter():s}t.resolve=o})(Zn||(Zn={}));function Ga(t,e,r){let n={};e=e.map(q.lengthen);for(let i of e)r.symbols.query(r.doc,t,i).forEachMember((o,s)=>{let a=Object.keys(s.visibleMembers),l=n[o]??=new Set,c=s.symbol?.relations?.default;c&&l.add(c.path[c.path.length-1]);for(let f of a)l.add(f)});return Object.fromEntries(Object.entries(n).map(([i,o])=>[i,[...o]]))}var Iw=Pw.default;function Bw(t){return!!t[Symbol.iterator]}function Za(t,e){return e>=0?t?.[e]:t?.[t.length+e]}function iu(t,e,r){if(t.has(e)){let n=t.get(e);return r.update&&(n=r.update(n,e,t),t.set(e,n)),n}else if(r.insert){let n=r.insert(e,t);return t.set(e,n),n}else throw new Error(`No key ${e} in map and no insert handler provided`)}function ou(t){return typeof t=="function"||!!t&&typeof t=="object"}function jw(t){let e=new Bt(t);return e.pathname=e.pathname.replace(/%3A/gi,":"),e.toString()}var FR=Object.freeze({create(t){return new Proxy(t,new bm)}}),bm=class{map=new Map;get(e,r,n){let i=Reflect.get(e,r,n);return r!=="prototype"&&ou(i)?iu(this.map,r,{insert:()=>FR.create(i)}):i}set(e,r,n,i){throw new TypeError(`Cannot set property '${String(r)}' on a readonly proxy`)}deleteProperty(e,r){throw new TypeError(`Cannot delete property '${String(r)}' on a readonly proxy`)}};var km=Symbol("StateBranchOff"),vm=Symbol("IsStateProxy"),wm=Symbol("OriginState"),xm=Symbol("RedoStateChanges"),Sm=Symbol("UndoStateChanges"),Qe=Object.freeze({branchOff(t){return t[km]()},create(t){if(Qe.is(t))throw new TypeError("Cannot create a proxy over a proxy. You might want to use branchOff instead.");return Cm(t,new qa)},dereference(t){return Qe.is(t)?t[wm]:t},is(t){return t?.[vm]},redoChanges(t){t[xm]()},undoChanges(t){t[Sm]()}}),su,$w,_m=class{constructor(e){E(this,su);H(this,"rootOps");H(this,"map",new Map);this.rootOps=e}get(e,r,n){switch(r){case km:return()=>n0(this,su,$w).call(this,e);case vm:return!0;case wm:return e;case xm:return()=>this.rootOps.redo();case Sm:return()=>this.rootOps.undo()}let i=Reflect.get(e,r,n);return r!=="prototype"&&ou(i)?iu(this.map,r,{insert:()=>Cm(i,this.rootOps)}):i}set(e,r,n,i){if(r===km||r===vm||r===wm||r===xm||r===Sm)throw new TypeError(`Cannot set ${String(r)}`);return this.rootOps.set(e,r,Qe.dereference(n),i),!0}};su=new WeakSet,$w=function(e){return Cm(e,new qa(this.rootOps))};function Cm(t,e){return new Proxy(t,new _m(e))}var au=class{_map=new Map;_reversedMap=new Map;constructor(e=[]){for(let[r,n]of e)this._map.set(r,n),this._reversedMap.set(n,r)}get size(){return this._map.size}clear(){this._map.clear(),this._reversedMap.clear()}delete(e){let r=this._map.get(e),n=this._map.delete(e);return r!==void 0&&this._reversedMap.delete(r),n}deleteValue(e){let r=this._reversedMap.get(e),n=this._reversedMap.delete(e);return r!==void 0&&this._map.delete(r),n}get(e){return this._map.get(e)}getKey(e){return this._reversedMap.get(e)}has(e){return this._map.has(e)}hasValue(e){return this._reversedMap.has(e)}set(e,r){return this._map.set(e,r),this._reversedMap.set(r,e),this}forEach(e,r){for(let[n,i]of this._map)e.apply(r,[i,n,this])}entries(){return this._map.entries()}keys(){return this._map.keys()}values(){return this._map.values()}[Symbol.iterator](){return this._map.entries()}[Symbol.toStringTag]="TwoWayMap"};var Fw=Br(tu(),1);var VR=`\r `,Hi="\r",Wi=` -`,Bw=Object.freeze([" ",` -`,"\r"," "]),qi=class{string;indexMap;innerCursor=0;constructor(e,r=[]){this.string=e,this.indexMap=r}get cursor(){return Zr.toOuterOffset(this.indexMap,this.innerCursor)}getCharRange(e=0){return Zr.toOuterRange(this.indexMap,v.create(this.innerCursor+e,this.innerCursor+e+1))}peek(e=1,r=0){return this.string.slice(this.innerCursor+r,this.innerCursor+r+e)}tryPeek(e,r=0){return this.peek(e.length,r)===e}tryPeekAfterWhitespace(e){let r=this.string.length-this.innerCursor,n=0;for(;n="0"&&e<="9"}static isBrigadierQuote(e){return e==='"'||e==="'"}static isNewline(e){return e===`\r +`,zw=Object.freeze([" ",` +`,"\r"," "]),qi=class{string;indexMap;innerCursor=0;constructor(e,r=[]){this.string=e,this.indexMap=r}get cursor(){return Zr.toOuterOffset(this.indexMap,this.innerCursor)}getCharRange(e=0){return Zr.toOuterRange(this.indexMap,v.create(this.innerCursor+e,this.innerCursor+e+1))}peek(e=1,r=0){return this.string.slice(this.innerCursor+r,this.innerCursor+r+e)}tryPeek(e,r=0){return this.peek(e.length,r)===e}tryPeekAfterWhitespace(e){let r=this.string.length-this.innerCursor,n=0;for(;n="0"&&e<="9"}static isBrigadierQuote(e){return e==='"'||e==="'"}static isNewline(e){return e===`\r `||e==="\r"||e===` -`}static isSpace(e){return e===" "||e===" "}static isWhitespace(e){return _e.isSpace(e)||_e.isNewline(e)}};var Ja;(function(t){function e(r){return typeof r=="function"&&(r=r()),r instanceof qi&&(r=r.cursor),r}t.get=e})(Ja||(Ja={}));var v;(function(t){function e(m){let k=typeof m=="function"?m():m;return t.is(k)?t.create(k.start,k.end):Sm.is(k)?t.create(k.range.start,k.range.end):t.create(k)}t.get=e;function r(m,k){return m=Ja.get(m),{start:m,end:k!==void 0?Ja.get(k):m}}t.create=r;function n(m,k){return{start:t.get(m).start,end:t.get(k).end}}t.span=n;function i(m){return!!m&&typeof m=="object"&&typeof m.start=="number"&&typeof m.end=="number"}t.is=i,t.Beginning=Object.freeze(t.create(0,1)),t.Full=Object.freeze(t.create(0,Number.POSITIVE_INFINITY));function o(m){return`[${m.start}, ${m.end})`}t.toString=o;function s(m,k,S=!1){return m=e(m),m.start<=k&&(S?k<=m.end:kk.end:m.start>=k.end)?1:0}t.compare=d;function p(m,k,S=!1){return(S?m.endk?1:0}t.compareOffset=p;function b(m,k,S=k){return m=e(m),{start:m.start+k,end:m.end+S}}t.translate=b})(v||(v={}));var Sm;(function(t){function e(r){return!!r&&typeof r=="object"&&v.is(r.range)}t.is=e})(Sm||(Sm={}));var Zr;(function(t){function e(a,l,c,f,u){let h=l;for(let d of a){if(v.contains(d[c],l,u))return u?d[f].end:d[f].start;if(v.endsBefore(d[c],l))h=l-d[c].end+d[f].end;else break}return h}function r(a,l){return e(a,l,"outer","inner",!1)}t.toInnerOffset=r;function n(a,l){return v.create(r(a,l.start),e(a,l.end,"outer","inner",!0))}t.toInnerRange=n;function i(a,l){return e(a,l,"inner","outer",!1)}t.toOuterOffset=i;function o(a,l){return v.create(i(a,l.start),e(a,l.end,"inner","outer",!0))}t.toOuterRange=o;function s(a,l){return l.map(c=>({inner:c.inner,outer:o(a,c.outer)}))}t.merge=s})(Zr||(Zr={}));var kt;(function(t){function e(s,a){return typeof s=="object"?r(s):n(s,a)}t.create=e;function r(s){return{line:s.line??0,character:s.character??0}}function n(s,a){return r({line:s,character:a})}t.Beginning=t.create(0,0),t.Infinity=t.create(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);function i(s){return`<${s.line}, ${s.character}>`}t.toString=i;function o(s,a){return s.linec.line?!1:l.line=l.character:!0)&&(a.line===c.line?a.characterp(b.range,m,d))}t.findChildIndex=n;function i(u,h,d=!1){return u.children?.[n(u,h,d)]}t.findChild=i;function o(u,h,d=!1){if(!u.children)return-1;let p=-1;for(let[b,m]of u.children.entries())if(v.endsBefore(m.range,h,d))p=b;else break;return p}t.findLastChildIndex=o;function s(u,h,d=!1){return u.children?.[o(u,h,d)]}t.findLastChild=s;function a({node:u,needle:h,endInclusive:d=!1,predicate:p=()=>!0}){let b,m=v.contains(u,h,d)?u:void 0;for(;m&&p(m);)b=m,m=i(m,h,d);return b}t.findDeepestChild=a;function l({node:u,needle:h,endInclusive:d=!1,predicate:p=()=>!0}){let b=v.contains(u,h,d)?u:void 0;for(;b&&!p(b);)b=i(b,h,d);return b}t.findShallowestChild=l;function*c(u){let h=u;for(;h;)h.locals&&(yield h.locals),h=u.parent}t.getLocalsToRoot=c;function*f(u){u.locals&&(yield u.locals);for(let h of u.children??[])yield*f(h)}t.getLocalsToLeaves=f})(Ke||(Ke={}));var fu;(function(t){function e(n){return n.type==="boolean"}t.is=e;function r(n){return{type:"boolean",range:v.get(n)}}t.mock=r})(fu||(fu={}));var Ya=Object.freeze({is(t){return t?.type==="comment"}});var $w;(function(t){function e(r){return r.type==="error"}t.is=e})($w||($w={}));var fs;(function(t){function e(r){return[...r.parserErrors,...r.binderErrors??[],...r.checkerErrors??[],...r.linterErrors??[]]}t.getErrors=e})(fs||(fs={}));var Sr;(function(t){function e(n){return n.type==="float"}t.is=e;function r(n){return{type:"float",range:v.get(n),value:0}}t.mock=r})(Sr||(Sr={}));var Ki;(function(t){function e(n){return n.type==="integer"}t.is=e;function r(n){return{type:"integer",range:v.get(n),value:0}}t.mock=r})(Ki||(Ki={}));var uu;(function(t){function e(r){return r?.type==="item"}t.is=e})(uu||(uu={}));var Ne;(function(t){function e(n){return n?.type==="literal"}t.is=e;function r(n,i){return{type:"literal",range:v.get(n),options:i,value:""}}t.mock=r})(Ne||(Ne={}));var zw;(function(t){function e(n){return n.type==="long"}t.is=e;function r(n){return{type:"long",range:v.get(n),value:0n}}t.mock=r})(zw||(zw={}));var kn;(function(t){function e(r){return r?.type==="pair"}t.is=e})(kn||(kn={}));var U;(function(t){let e=q.TagPrefix,r=q.NamespacePathSep,n=q.PathSep,i=q.DefaultNamespace;function o(l){return l?.type==="resource_location"}t.is=o;function s(l,c){return{type:"resource_location",range:v.get(l),options:c}}t.mock=s;function a(l,c="origin",f=!1){let u=l.path?l.path.join(n):"",h;switch(c){case"origin":h=l.namespace!==void 0?`${l.namespace}${r}${u}`:u;break;case"full":h=`${l.namespace||i}${r}${u}`;break;case"short":h=l.namespace&&l.namespace!==i?`${l.namespace}${r}${u}`:u;break}return f&&l.isTag?`${e}${h}`:h}t.toString=a})(U||(U={}));var Qa=Symbol("SequenceUtilDiscriminator"),Xa;(function(t){function e(r){return!!r&&r[Qa]}t.is=e})(Xa||(Xa={}));var hu;(function(t){function e(r,n){return r?r.includes(n):!1}t.is=e})(hu||(hu={}));var Fw=new Map([['"','"'],["'","'"],["\\","\\"],["b","\b"],["f","\f"],["n",` -`],["r","\r"],["t"," "]]),et;(function(t){function e(n){return n?.type==="string"}t.is=e;function r(n,i){return n=v.get(n),{type:"string",range:n,options:i,value:"",valueMap:[{inner:v.create(0),outer:v.create(n.start)}]}}t.mock=r})(et||(et={}));var or;(function(t){function e(n){return n?.type==="symbol"}t.is=e;function r(n,i){return{type:"symbol",range:v.get(n),options:i,value:""}}t.mock=r})(or||(or={}));var Vw={array:"an array",boolean:"a boolean","bug-of-mc":"Due to a bug of Minecraft (%0%), %1%. Please Mojang, fix your game","code-action.block-state-sort-keys":"Sort block state","code-action.command-replaceitem":"Update this command to /item \u2026 replace","code-action.fix-file":"Fix all auto-fixable problems in this file","code-action.fix-workspace":"Fix all auto-fixable problems in the workspace","code-action.id-attribute-datafix":"Update this attribute name to 1.16","code-action.id-complete-default-namespace":"Complete default namespace","code-action.id-create-file":"Create %0% in the same data pack","code-action.id-omit-default-namespace":"Omit default namespace","code-action.id-zombified-piglin-datafix":"Change this ID to Zombified Piglin's","code-action.nbt-compound-sort-keys":"Sort NBT compound tag","code-action.nbt-type-to-byte":"Convert to an NBT byte tag","code-action.nbt-type-to-double":"Convert to an NBT double tag","code-action.nbt-type-to-float":"Convert to an NBT float tag","code-action.nbt-type-to-int":"Convert to an NBT int tag","code-action.nbt-type-to-long":"Convert to an NBT long tag","code-action.nbt-type-to-short":"Convert to an NBT short tag","code-action.nbt-uuid-datafix":"Update this UUID to 1.16","code-action.selector-sort-keys":"Sort selector argument","code-action.string-double-quote":"Quote this string with double quotation marks","code-action.string-single-quote":"Quote this string with single quotation marks","code-action.string-unquote":"Unquote this string","code-action.vector-align-0.0":"Align this vector to block origin","code-action.vector-align-0.5":"Align this vector to block center",comment:"a comment starting with %0%","conjunction.and_2":" and ","conjunction.and_3+_1":", ","conjunction.and_3+_2":", and ","conjunction.or_2":" or ","conjunction.or_3+_1":", ","conjunction.or_3+_2":", or ","datafix.error.command-replaceitem":"/replaceitem was removed in 20w46a (the second snapshot of 1.17) in favour of /item","duplicate-key":"Duplicate key %0%","ending-quote":"an ending quote %0%",entity:"an entity","error.unparseable-content":"Encountered unparseable content",expected:"Expected %0%","expected-got":"Expected %0% but got %1%",float:"a float","float.between":"a float between %0% and %1%",integer:"an integer","integer.between":"an integer between %0% and %1%","json.doc.advancement.display":"Advancement display settings. If present, the advancement will be visible in the advancement tabs.","json.checker.array.length-between":"%0% with length between %1% and %2%","json.checker.object.field.union-empty-members":"Disallowed property","json.checker.item.duplicate":"Duplicate list item","json.checker.property.deprecated":"Property %0% is deprecated","json.checker.property.missing":"Missing property %0%","json.checker.property.unknown":"Unknown property %0%","json.checker.string.hex-color":"a 6-digit hexadecimal number","json.checker.tag-entry.duplicate":"Duplicate tag entry","json.node.array":"an array","json.node.boolean":"a boolean","json.node.null":"a null","json.node.number":"a number","json.node.object":"an object","json.node.string":"a string","key-not-following-convention":"Invalid key %0% which doesn't follow %1% convention","linter.diagnostic-message-wrapper":"%0% (rule: %1%)","linter.name-convention.illegal":"Name %0% doesn't match %1%","linter.undeclared-symbol.message":"Cannot find %0% %1%","linter-config-validator.name-convention.type":"Expects a string that contains a regular expression describing the name","linter-config-validator.wrapper":"%0%. See [the documentation](%1) for more information",long:"a long","mcfunction.checker.command.data-modify-unapplicable-operation":"Operation %0% can only be used on %1%; the target path has type %2% instead","mcfunction.completer.block.states.default-value":"Default: %0%","mcfunction.parser.entity-selector.arguments.not-applicable":"%0% is not applicable here","mcfunction.parser.entity-selector.arguments.unknown":"Unknown entity selector argument %0%","mcfunction.parser.entity-selector.entities-disallowed":"The selector contains non-player entities","mcfunction.parser.entity-selector.multiple-disallowed":"The selector contains multiple entities","mcfunction.parser.entity-selector.player-name.too-long":"Player names cannot be longer than %0% characters","mcfunction.parser.eoc-unexpected":"Expected more arguments","mcfunction.parser.leading-slash":"a leading slash %0%","mcfunction.parser.no-permission":"Permission level %0% is required, which is higher than %1% defined in config","mcfunction.parser.objective.too-long":"Objective names cannot be longer than %0% characters","mcfunction.parser.range.min>max":"The minimum value %0% is larger than the maximum value %1%","mcfunction.parser.score_holder.fake-name.too-long":"Fake names cannot be longer than %0% characters","mcfunction.parser.sep":"a space (%0%)","mcfunction.parser.trailing":"Trailing data encountered: %0%","mcfunction.parser.unknown-parser":"Parser %0% hasn't been supported yet","mcfunction.parser.uuid.invalid":"Invalid UUID format","mcfunction.parser.vector.local-disallowed":"Local coordinates disallowed","mcfunction.parser.vector.mixed":"Cannot mix local coordinates and world coordinates together","mcfunction.signature-help.command-documentation":"[Minecraft Wiki: `%0%` command](https://minecraft.fandom.com/wiki/Commands/%0%)","mcfunction.signature-help.argument-parser-documentation":"[Minecraft Wiki: `%0%` argument parser](https://minecraft.fandom.com/wiki/Argument_types#%0%)","missing-key":"Missing key %0%","nbt.checker.block-states.fake-boolean":"Boolean block state values should be quoted","nbt.checker.block-states.unexpected-value-type":"Block state values should be either a string or an int","nbt.checker.block-states.unknown-state":"Unknown block state %0% for the following block(s): %1%","nbt.checker.boolean.out-of-range":"A boolean value should be either %0% or %1%","nbt.checker.collection.length-between":"%0% with length between %1% and %2%","nbt.checker.compound.field.union-empty-members":"Disallowed property","nbt.checker.path.index-out-of-bound":"The provided index %0% is out of bound, as the collection can only have at most %1% elements","nbt.checker.path.unexpected-filter":"Compound filters can only be used on compound tags","nbt.checker.path.unexpected-index":"Indices can only be used on array or list tags","nbt.checker.path.unexpected-key":"String keys can only be specified for compound tags","nbt.node":"a tag","nbt.node.byte":"a byte tag","nbt.node.byte_array":"a byte array tag","nbt.node.compound":"a compound tag","nbt.node.double":"a double tag","nbt.node.float":"a float tag","nbt.node.int":"an int tag","nbt.node.int_array":"an int array tag","nbt.node.list":"a list tag","nbt.node.long":"a long tag","nbt.node.long_array":"a long array tag","nbt.node.path.end":"the end of path","nbt.node.path.filter":"a compound filter","nbt.node.path.index":"an index","nbt.node.path.key":"a key","nbt.node.short":"a short tag","nbt.node.string":"a string tag","nbt.parser.number.out-of-range":"This looks like %0%, but it is actually %1% due to the numeral value being out of [%2%, %3%]","mcdoc.binder.dispatcher-statement.duplicated-key":"Duplicated dispatcher case %0%","mcdoc.binder.dispatcher-statement.duplicated-key.related":"%0% has already been dispatched here","mcdoc.binder.duplicated-declaration":"Duplicated declaration for %0%","mcdoc.binder.duplicated-declaration.related":"%0% is already declared here","mcdoc.binder.out-of-root":"File %0% is not under the root directory of any mcdoc project; semantic checking will be skipped","mcdoc.binder.path.super-from-root":"Cannot access super of the project root","mcdoc.binder.path.unknown-identifier":"Identifier %0% does not exist in module %1%","mcdoc.binder.path.unknown-module":"Module %0% does not exist","mcdoc.node.compound-definition":"a compound definition","mcdoc.node.enum-definition":"an enum definition","mcdoc.node.identifier":"an identifier","mcdoc.checker.entry.empty-mod-seg":"You cannot put \u201Cmod.mcdoc\u201D under a root directly","mcdoc.checker.inject-clause.unmatched-injection":"Cannot inject %0% with %1%","mcdoc.checker.type-not-assignable":"Type %0% is not assignable to type %1%","mcdoc.parser.compound-definition.field-type":"a field type","mcdoc.parser.float.illegal":"Encountered illegal float number","mcdoc.parser.identifier.reserved-word":"%0% is a reserved word and cannot be used as an identifier name","mcdoc.parser.identifier.illegal":"%0% doesn't follow the format of %1%","mcdoc.parser.index-body.dynamic-index-not-allowed":"Dynamic indexing is not allowed","mcdoc.parser.inject-clause.definition-expected":"Expected either an enum inject or a compound inject","mcdoc.parser.keyword.separation":"a separation","mcdoc.parser.resource-location.colon-expected":"Expected the colon (%0%) of resource locations","mcdoc.parser.syntax.doc-comment-unexpected":"Doc comments are not allowed here; you might want to replace the three slashes with two slashes","not-matching-any-child":"Invalid argument type",nothing:"nothing",number:"a number","number-range":"a number range","number-range.missing-min-and-max":"Expected either a minimum value or a maximum value","number.<=":"a number smaller than or equal to %0%","number.>=":"a number greater than or equal to %0%","number.between":"a number between %0% and %1%",object:"an object",objective:"an objective","objective-not-following-convention":"Invalid objective %0% which doesn't follow %1% convention","parser.float.illegal":"Illegal float numeral that doesn't follow %0%","parser.integer.illegal":"Illegal integer that doesn't follow %0%","parser.list.value":"a value","parser.list.trailing-sep":"Trailing separation","parser.record.key":"a key","parser.record.trailing-end":"Trailing separation","parser.record.unexpected-char":"Unexpected character %0%","parser.record.value":"a value","parser.resource-location.illegal":"Illegal character(s): %0%","parser.resource-location.namespace-expected":"Namespaces cannot be omitted here","parser.resource-location.tag-diallowed":"Tags are not allowed here","parser.string.illegal-brigadier":"Encountered non-[0-9A-Za-z_.+-] characters in %0%","parser.string.illegal-escape":"Unexpected escape character %0%","parser.string.illegal-quote":"Only %0% can be used to quote strings here","parser.string.illegal-unicode-escape":"Hexadecimal digit expected","punc.period":".","punc.quote":"\u201C%0%\u201D",quote:`a quote (\u201C'\u201D or \u201C"\u201D)`,quote_prefer_double:'Double quote (\u201C"\u201D) is preferable here',quote_prefer_single:"Single quote (\u201C'\u201D) is preferable here","resource-location":"a resource location","score-holder":"a score holder","scoreholder-not-following-convention":"Invalid score_holder %0% which doesn't follow %1% convention","server.new-version":"The Data-pack Language Server has been updated to a newer version: %0%","server.progress.fixing-workspace.begin":"Fixing all auto-fixable problems in the workspace","server.progress.fixing-workspace.report":"fixing %0%","server.progress.preparing.title":"Preparing Spyglass language features","server.remove-cache-file":"The cache file of DHP was moved to a storage location provided by VSCode. You can safely delete the ugly \u201C.datapack\u201D folder in your workspace root.","server.show-release-notes":"Show Release Notes",string:"a string",tag:"a tag","tag-not-following-convention":"Invalid tag %0% which doesn't follow %1% convention",team:"a team","team-not-following-convention":"Invalid team %0% which doesn't follow %1% convention","time-unit":"a time unit","too-many-block-affected":"Too many blocks in the specified area (maximum %0%, specified %1%)","too-many-chunk-affected":"Too many chunks in the specified area (maximum %0%, specified %1%)","unexpected-character":"Found non [a-z0-9/._-] character(s)","unexpected-datapack-tag":"Tags are not allowed here","unexpected-default-namespace":"Default namespace should be omitted here","unexpected-leading-slash":"Unexpected leading slash \u201C/\u201D","unexpected-local-coordinate":"Local coordinate %0% is not allowed","unexpected-nbt":"This tag doesn't exist here","unexpected-nbt-array-type":"Invalid array type %0%. Should be one of \u201CB\u201D, \u201CI\u201D, and \u201CL\u201D","unexpected-nbt-path-filter":"Compound filters are only used for compound tags","unexpected-nbt-path-index":"Indices are only used for lists/arrays tags","unexpected-nbt-path-key":"Keys are only used for compound tags","unexpected-nbt-path-sub":"The current tag doesn't have extra items","unexpected-omitted-default-namespace":"Default namespace shouldn't be omitted here","unexpected-relative-coordinate":"Relative coordinate %0% is not allowed","unexpected-scoreboard-sub-slot":"Only \u201Csidebar\u201D has sub slots","unknown-command":"Unknown command %0%","unknown-escape":"Unexpected escape character %0%","unknown-key":"Unknown key %0%","unquoted-string":"an unquoted string","unsorted-keys":"Unsorted keys",uuid:"a UUID",vector:"a vector"};var Uw={en:Vw},zR="en";function y(t,...e){let r=Uw[zR][t]??Uw.en[t];return FR(r,e)??""}function P(t){return y("punc.quote",t)}function FR(t,e){return t?.replace(/%\d+%/g,r=>{let n=parseInt(r.slice(1,-1)),i=e[n];return typeof i!="string"&&i?.[Symbol.iterator]&&(i=vn(i)),`${i??r}`})}function vn(t,e=!0,r="or"){let n=o=>e?P(o):o,i=(typeof t=="string"?[t]:Array.from(t)).map(n);switch(i.length){case 0:return y("nothing");case 1:return i[0];case 2:return i[0]+y(`conjunction.${r}_2`)+i[1];default:return`${i.slice(0,-1).join(y(`conjunction.${r}_3+_1`))}${y(`conjunction.${r}_3+_2`)}${i[i.length-1]}`}}function Oe(...t){let e=VR(t);return(r,n)=>{let i={type:"literal",range:v.create(r),options:e,value:""};for(let o of e.pool)if(r.trySkip(o))return i.value=o,i.range.end=r.cursor,i;return n.err.report(y("expected",e.pool),i),i}}function VR(t){let e;return typeof t[0]=="object"?e=t[0]:e={pool:t},e.pool=e.pool.sort((r,n)=>n.length-r.length),e}var _m=Br(ru(),1);var Cm=Object.freeze(["mcdoc","mcdoc/dispatcher"]),Gi=Object.freeze(["activity","attribute","block","block_entity_type","block_predicate_type","chunk_status","custom_stat","enchantment","entity_type","float_provider_type","fluid","game_event","height_provider_type","int_provider_type","item","loot_condition_type","loot_function_type","loot_nbt_provider_type","loot_number_provider_type","loot_pool_entry_type","loot_score_provider_type","memory_module_type","menu","mob_effect","motive","particle_type","point_of_interest_type","pos_rule_test","position_source_type","potion","recipe_serializer","recipe_type","rule_test","schedule","sensor_type","sound_event","stat_type","villager_profession","villager_type","worldgen/biome_source","worldgen/block_placer_type","worldgen/block_state_provider_type","worldgen/carver","worldgen/chunk_generator","worldgen/decorator","worldgen/feature","worldgen/feature_size_type","worldgen/foliage_placer_type","worldgen/material_condition","worldgen/material_rule","worldgen/placement_modifier_type","worldgen/structure_feature","worldgen/structure_piece","worldgen/structure_pool_element","worldgen/structure_processor","worldgen/surface_builder","worldgen/tree_decorator_type","worldgen/trunk_placer_type"]),Kw=Object.freeze(["worldgen/biome","worldgen/configured_carver","worldgen/configured_feature","worldgen/configured_structure_feature","worldgen/configured_surface_builder","worldgen/density_function","worldgen/noise","worldgen/noise_settings","worldgen/placed_feature","worldgen/processor_list","worldgen/template_pool"]),Am=Object.freeze(["function",...Gi,...Kw]),UR=Object.freeze(Am.map(t=>`tag/${t}`)),hs=Object.freeze(["advancement","dimension","dimension_type","function","item_modifier","loot_table","predicate","recipe","structure",...UR,...Kw]),HR=Object.freeze(["attribute_modifier_uuid","bossbar","objective","score_holder","storage","tag","team"]),WR=Object.freeze([...hs,...HR]),Z$=Object.freeze([...WR,...Cm,...Gi]),qR=Object.freeze(["bossbar","storage","mcdoc/dispatcher",...hs,...Gi]),Hw;(function(t){function e(r){return qR.includes(r)}t.is=e})(Hw||(Hw={}));var St;(function(t){function e(i){return i?{category:i.category,path:i.path}:void 0}t.fromSymbol=e;function r(i){return JSON.stringify({category:i.category,path:i.path})}t.toString=r;function n(i){return JSON.parse(i)}t.fromString=n})(St||(St={}));var us,Ww=class{constructor(){E(this,us,new Set)}add(e){e&&g(this,us).add(St.toString(e))}has(e){return g(this,us).has(St.toString(e))}collect(){return[...g(this,us)].map(St.fromString)}};us=new WeakMap;var Zi=Object.freeze(["definition","declaration","implementation","reference","typeDefinition"]),el;(function(t){function e(r){return Zi.includes(r)}t.is=e})(el||(el={}));var qw;(function(t){function e(r,n,...i){if(Pw(r)){for(let s of r){let a=e(s,n,...i);if(a)return a}return}let o=r[n];for(let s of i);}t.get=e})(qw||(qw={}));var du;(function(t){function e(r,n,i,o,s){return{...cu.create(r,n),...i?{fullRange:v.get(i),fullPosRange:Jn.from(i,r)}:{},...o?{contributor:o}:{},...s||{}}}t.create=e})(du||(du={}));var tl;(function(t){function e(o){let s=(c,f,u,h,d)=>{c.category=h,c.identifier=d[d.length-1],c.path=d,c.parentMap=f,u&&(c.parentSymbol=u),c.members&&a(c.members,c,h,d)},a=(c,f,u,h)=>{for(let[d,p]of Object.entries(c))s(p,c,f,u,[...h,d])},l=(0,_m.default)()(o);for(let[c,f]of Object.entries(l))a(f,void 0,c,[]);return l}t.link=e;function r(o){let s=c=>{delete c.category,delete c.identifier,delete c.parentMap,delete c.parentSymbol,delete c.path,c.members&&a(c.members)},a=c=>{for(let f of Object.values(c))s(f)},l=(0,_m.default)({circles:!0})(o);for(let c of Object.values(l))a(c);return l}t.unlink=r;function n(o){return JSON.stringify(r(o))}t.serialize=n;function i(o){return e(JSON.parse(o))}t.deserialize=i})(tl||(tl={}));var Zw=Br(mu(),1);var yu=function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(i<3?s(o):i>3?s(e,r,o):s(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},Xn,Ji,rl,Qn,Yi,sr,_t=class{constructor(e,r,n,i=!1){E(this,Xn,void 0);E(this,Ji,void 0);E(this,rl,void 0);E(this,Qn,new Set);E(this,Yi,Object.create(null));E(this,sr,void 0);H(this,"_delayedOps",[]);H(this,"_inDelayMode");L(this,Ji,new r),L(this,rl,r),L(this,Xn,e),L(this,sr,n),this._inDelayMode=i,this.on("symbolCreated",({symbol:o})=>{g(this,Qn).add(St.toString(o))}).on("symbolRemoved",({symbol:o})=>{g(this,Qn).delete(St.toString(o))}).on("symbolLocationCreated",({symbol:o,location:s})=>{let a=g(this,Yi)[s.contributor??"undefined"]??=Object.create(null),l=a[s.uri]??=new Set,c=St.toString(o);l.add(c),g(this,Qn).delete(c)}).on("symbolLocationRemoved",({symbol:o})=>{let s=St.toString(o);g(this,Qn).add(s)})}get global(){return g(this,Xn)}on(e,r){return g(this,Ji).on(e,r),this}once(e,r){return g(this,Ji).once(e,r),this}emit(e,...r){return g(this,Ji).emit(e,...r)}buildCache(){_t.forEachSymbol(this.global,e=>{this.emit("symbolCreated",{symbol:e}),_t.forEachLocationOfSymbol(e,({type:r,location:n})=>{this.emit("symbolLocationCreated",{symbol:e,type:r,location:n})})})}clone(){return new _t(g(this,Xn),g(this,rl),g(this,sr),!0)}applyDelayedEdits(){this._delayedOps.forEach(e=>e()),this._delayedOps=[],this._inDelayMode=!1}contributeAs(e,r){let n=g(this,sr);L(this,sr,e);try{r()}finally{L(this,sr,n)}return this}async contributeAsAsync(e,r){let n=g(this,sr);L(this,sr,e);try{await r()}finally{L(this,sr,n)}return this}clear({uri:e,contributor:r,predicate:n=()=>!0}){let i=()=>r?g(this,Yi)[r]?[g(this,Yi)[r]]:[]:Object.values(g(this,Yi)),o=()=>{let c=i();return(e?c.map(u=>u[e]??new Set):c.map(u=>Object.values(u)).flat()).map(u=>[...u]).flat().map(St.fromString)},s=()=>e?[g(this,Xn)]:[g(this,Xn)],a=o(),l=s();for(let c of l){for(let f of a){let{symbol:u}=_t.lookupTable(c,f.category,f.path);u&&this.removeLocationsFromSymbol(u,e?h=>h.location.uri===e&&n(h):n)}this.trim(c)}}lookup(e,r,n){for(;n;){if(n.locals){let i=_t.lookupTable(n.locals,e,r);if(i.symbol)return i}n=n.parent}return _t.lookupTable(this.global,e,r)}query(e,r,...n){let i=_t.toUri(e),{parentSymbol:o,parentMap:s,symbol:a}=this.lookup(r,n,Rm(e)?e.node:void 0),l=a?_t.isVisible(a,i):!0;return new gu({category:r,doc:e,contributor:g(this,sr),map:l?s:void 0,parentSymbol:o,path:n,symbol:l?a:void 0,util:this})}getVisibleSymbols(e,r){let n=this.lookup(e,[],void 0).parentMap??void 0;return _t.filterVisibleSymbols(r,n)}static toUri(e){return typeof e=="string"?e:Rm(e)?e.doc.uri:e.uri}trim(e){let r=n=>{n&&_t.isTrimmable(n)&&(delete n.parentMap[n.identifier],this.emit("symbolRemoved",{symbol:n}),r(n.parentSymbol))};for(let n of g(this,Qn)){let i=St.fromString(n),{symbol:o}=_t.lookupTable(e,i.category,i.path);r(o)}}removeLocationsFromSymbol(e,r){for(let n of Zi)e[n]&&(e[n]=e[n].reduce((i,o)=>(r({location:o,symbol:e,type:n})?this.emit("symbolLocationRemoved",{symbol:e,type:n,location:o}):i.push(o),i),[]))}enterMap(e,r,n,i,o,s,a,l){let c=r[o];return c?this.amendSymbol(c,s,a,l):c=this.createSymbol(n,e,r,i,o,s,a,l),this.emit("symbolAmended",{symbol:c}),c}static lookupTable(e,r,n){let i=e[r],o,s;for(let a=0;a=0;s--){let a=e[s],l=this.lookupTable(a,r,n);if(l.symbol)return l;!o&&!i&&(l.parentSymbol||l.parentMap)&&(o=l.parentSymbol,i=l.parentMap)}return{parentSymbol:o,parentMap:i,symbol:void 0}}createSymbol(e,r,n,i,o,s,a,l){let c=n[o]={category:e,identifier:o,...r?{parentSymbol:r}:{},parentMap:n,path:i,...s.data};return this.emit("symbolCreated",{symbol:c}),this.amendSymbolUsage(c,s.usage,a,l),c}amendSymbol(e,r,n,i){this.amendSymbolMetadata(e,r.data),this.amendSymbolUsage(e,r.usage,n,i)}amendSymbolMetadata(e,r){if(r){if("data"in r&&(e.data=r.data),"desc"in r&&(e.desc=r.desc),r.relations&&Object.keys(r.relations).length){e.relations??={};for(let n of Object.keys(r.relations))e.relations[n]=r.relations[n]}if("subcategory"in r&&(e.subcategory=r.subcategory),"visibility"in r){let n=i=>i===void 0||i===2||i===3;if(e.visibility===r.visibility||n(e.visibility)&&n(r.visibility))e.visibility=r.visibility;else throw new Error(`Cannot change visibility from ${e.visibility} to ${r.visibility}: ${JSON.stringify(St.fromSymbol(e))}`)}r.visibilityRestriction?.length&&(e.visibilityRestriction=(e.visibilityRestriction??[]).concat(r.visibilityRestriction))}}amendSymbolUsage(e,r,n,i){if(r){let o=r.type??"reference",s=e[o]??=[],a=v.get((Om.is(r)?r.node:r.range)??0),l=du.create(n,a,r.fullRange,i,{accessType:r.accessType,skipRenaming:r.skipRenaming});n.uri.startsWith("file:")||(delete l.range,delete l.posRange,delete l.fullRange,delete l.fullPosRange),s.push(l),this.emit("symbolLocationCreated",{symbol:e,type:o,location:l})}}resolveAlias(e){return e?.relations?.aliasOf?this.resolveAlias(this.lookup(e.relations.aliasOf.category,e.relations.aliasOf.path).symbol):e}static filterVisibleSymbols(e,r={}){let n={};for(let[i,o]of Object.entries(r))_t.isVisible(o,e)&&(n[i]=o);return n}static isTrimmable(e){return!Object.keys(e.members??{}).length&&!e.declaration?.length&&!e.definition?.length&&!e.implementation?.length&&!e.reference?.length&&!e.typeDefinition?.length}static isVisible(e,r){switch(e.visibility){case 3:return!1;case 0:case 1:case 2:default:return!0}}static isDeclared(e){return!!(e?.declaration?.length||e?.definition?.length)}static isDefined(e){return!!(e?.definition?.length||e?.definition?.length&&e?.implementation?.length)}static isImplemented(e){return!!(e?.implementation?.length||e?.definition?.length)}static isReferenced(e){return!!e?.reference?.length}static isTypeDefined(e){return!!e?.typeDefinition?.length}static getDeclaredLocation(e){return e.declaration?.[0]??e.definition?.[0]??(()=>{throw new Error(`Cannot get declared location of ${JSON.stringify(St.fromSymbol(e))}`)})()}static forEachSymbolInMap(e,r){for(let n of Object.values(e))r(n),n.members&&this.forEachSymbolInMap(n.members,r)}static forEachSymbol(e,r){for(let n of Object.values(e))this.forEachSymbolInMap(n,r)}static forEachLocationOfSymbol(e,r){for(let n of Zi)e[n]?.forEach(i=>r({type:n,location:i}))}static isVisibilityInGlobal(e){return e===void 0||e===2||e===3}static areVisibilitiesCompatible(e,r){return this.isVisibilityInGlobal(e)&&this.isVisibilityInGlobal(r)||e===0&&r===0||e===1&&r===1}},Le=_t;Xn=new WeakMap,Ji=new WeakMap,rl=new WeakMap,Qn=new WeakMap,Yi=new WeakMap,sr=new WeakMap;yu([bu()],Le.prototype,"clear",null);yu([bu()],Le.prototype,"trim",null);yu([bu()],Le.prototype,"removeLocationsFromSymbol",null);var Tm;(function(t){function e(r){return!!r?.range}t.is=e})(Tm||(Tm={}));var Om;(function(t){function e(r){return!!r?.node}t.is=e})(Om||(Om={}));var Jr,ei,Xi,ds,nl,Yr,wn,Pe,Em=class{constructor({category:e,contributor:r,doc:n,map:i,parentSymbol:o,path:s,symbol:a,util:l}){H(this,"category");H(this,"path");E(this,Jr,void 0);E(this,ei,void 0);E(this,Xi,void 0);E(this,ds,void 0);E(this,nl,!1);E(this,Yr,void 0);E(this,wn,void 0);E(this,Pe,void 0);H(this,"util");this.category=e,this.path=s,typeof n=="string"?(n=Zw.TextDocument.create(n,"",0,""),L(this,Xi,!0)):Rm(n)&&(L(this,ei,n.node),n=n.doc),L(this,Jr,n),L(this,ds,r),L(this,Yr,i),L(this,wn,o),L(this,Pe,a),this.util=l}get symbol(){return g(this,Pe)}get visibleMembers(){return Le.filterVisibleSymbols(g(this,Jr).uri,this.path.length===0?g(this,Yr):g(this,Pe)?.members)}heyGimmeDaSymbol(){return g(this,Pe)}getData(e){let r=g(this,Pe)?.data;return e(r)?r:void 0}with(e){return e(this),this}if(e,r){return e.call(this,g(this,Pe),this)&&(r.call(this,g(this,Pe),this),L(this,nl,!0)),this}ifUnknown(e){return this.if(r=>r===void 0,e)}ifKnown(e){return this.if(r=>r!==void 0,e)}ifDeclared(e){return this.if(r=>Le.isDeclared(r),e)}ifDefined(e){return this.if(Le.isDefined,e)}ifImplemented(e){return this.if(Le.isImplemented,e)}ifReferenced(e){return this.if(Le.isReferenced,e)}ifTypeDefined(e){return this.if(Le.isTypeDefined,e)}else(e){return g(this,nl)||e.call(this,g(this,Pe),this),this}elseEnter(e){return this.else(()=>this.enter(e))}elseResolveAlias(){return this.else(()=>this.resolveAlias())}_enter(e){let r=i=>i.data?.visibility??this.symbol?.visibility??2,n=i=>{let o=r(i);if(g(this,Yr)&&Le.areVisibilitiesCompatible(o,g(this,Pe)?.visibility))return g(this,Yr);if(this.path.length>1){if(g(this,wn)){if(!Le.areVisibilitiesCompatible(o,g(this,wn).visibility))throw new Error(`Cannot enter member \u201C${this.getPath()}\u201D of ${Yn.stringifyVisibility(o)} visibility to parent of ${Yn.stringifyVisibility(g(this,wn).visibility)} visibility`);return g(this,wn).members??={}}}else{let s;if(Le.isVisibilityInGlobal(o))s=this.util.global;else if(o===1){if(!g(this,ei))throw new Error(`Cannot enter \u201C${this.getPath()}\u201D with ${Yn.stringifyVisibility(o)} visibility as no node is supplied`);let a=g(this,ei);for(;a;){if(a.type==="file"){s=a.locals;break}a=a.parent}if(!s)throw new Error(`Cannot enter \u201C${this.getPath()}\u201D with ${Yn.stringifyVisibility(o)} visibility as no file node is supplied`)}else{if(!g(this,ei))throw new Error(`Cannot enter \u201C${this.getPath()}\u201D with ${Yn.stringifyVisibility(o)} visibility as no node is supplied`);let a=g(this,ei);for(;a;){if(a.locals){s=a.locals;break}a=a.parent}if(!s)throw new Error(`Cannot enter \u201C${this.getPath()}\u201D with ${Yn.stringifyVisibility(o)} visibility as no node with locals is supplied`)}return s[this.category]??={}}throw new Error(`Cannot create the symbol map for \u201C${this.getPath()}\u201D`)};g(this,Xi)&&Tm.is(e.usage)&&(e.usage.range=v.create(0,0)),L(this,Yr,n(e)),L(this,Pe,this.util.enterMap(g(this,wn),g(this,Yr),this.category,this.path,this.path[this.path.length-1],e,g(this,Jr),g(this,ds))),e.usage?.node&&(e.usage.node.symbol=g(this,Pe))}enter(e){return this._enter(e),this}amend(e){return this.ifKnown(()=>this.enter(e))}resolveAlias(){if(g(this,Pe)){let e=this.util.resolveAlias(g(this,Pe));if(!e)throw new Error("The current symbol points to an non-existent symbol.");L(this,Pe,e),L(this,Yr,e.parentMap)}return this}member(){let e,r,n;if(arguments.length===2?(e=g(this,Xi)?g(this,Jr).uri:g(this,Jr),r=arguments[0],n=arguments[1]):(e=arguments[0],r=arguments[1],n=arguments[2]),g(this,Pe)===void 0)throw new Error(`Tried to query member symbol \u201C${r}\u201D from an undefined symbol (path \u201C${this.path.join(".")}\u201D)`);let i=typeof e=="string"&&e===g(this,Jr).uri&&!g(this,Xi)?g(this,Jr):e,o=g(this,Pe).members,s=o?.[r],a=new Em({category:this.category,doc:i,contributor:g(this,ds),map:o,parentSymbol:g(this,Pe),path:[...this.path,r],symbol:s,util:this.util});return n(a),this}onEach(e,r){for(let n of e)r.call(this,n,this);return this}forEachMember(e){return this.onEach(Object.keys(this.visibleMembers),r=>this.member(r,n=>e(r,n)))}getPath(){return`${this.category}.${this.path.join("/")}`}},gu=Em;Jr=new WeakMap,ei=new WeakMap,Xi=new WeakMap,ds=new WeakMap,nl=new WeakMap,Yr=new WeakMap,wn=new WeakMap,Pe=new WeakMap;yu([bu(t=>t.util)],gu.prototype,"_enter",null);var Yn;(function(t){let e="+ ";function r(c,f){if(c!==f)throw new Error(`Assertion error: ${c} !== ${f}`)}function n(c){return c.map(f=>i(f)).join(` +`}static isSpace(e){return e===" "||e===" "}static isWhitespace(e){return Ce.isSpace(e)||Ce.isNewline(e)}};var Ja;(function(t){function e(r){return typeof r=="function"&&(r=r()),r instanceof qi&&(r=r.cursor),r}t.get=e})(Ja||(Ja={}));var v;(function(t){function e(m){let k=typeof m=="function"?m():m;return t.is(k)?t.create(k.start,k.end):Am.is(k)?t.create(k.range.start,k.range.end):t.create(k)}t.get=e;function r(m,k){return m=Ja.get(m),{start:m,end:k!==void 0?Ja.get(k):m}}t.create=r;function n(m,k){return{start:t.get(m).start,end:t.get(k).end}}t.span=n;function i(m){return!!m&&typeof m=="object"&&typeof m.start=="number"&&typeof m.end=="number"}t.is=i,t.Beginning=Object.freeze(t.create(0,1)),t.Full=Object.freeze(t.create(0,Number.POSITIVE_INFINITY));function o(m){return`[${m.start}, ${m.end})`}t.toString=o;function s(m,k,S=!1){return m=e(m),m.start<=k&&(S?k<=m.end:kk.end:m.start>=k.end)?1:0}t.compare=d;function p(m,k,S=!1){return(S?m.endk?1:0}t.compareOffset=p;function b(m,k,S=k){return m=e(m),{start:m.start+k,end:m.end+S}}t.translate=b})(v||(v={}));var Am;(function(t){function e(r){return!!r&&typeof r=="object"&&v.is(r.range)}t.is=e})(Am||(Am={}));var Zr;(function(t){function e(a,l,c,f,u){let h=l;for(let d of a){if(v.contains(d[c],l,u))return u?d[f].end:d[f].start;if(v.endsBefore(d[c],l))h=l-d[c].end+d[f].end;else break}return h}function r(a,l){return e(a,l,"outer","inner",!1)}t.toInnerOffset=r;function n(a,l){return v.create(r(a,l.start),e(a,l.end,"outer","inner",!0))}t.toInnerRange=n;function i(a,l){return e(a,l,"inner","outer",!1)}t.toOuterOffset=i;function o(a,l){return v.create(i(a,l.start),e(a,l.end,"inner","outer",!0))}t.toOuterRange=o;function s(a,l){return l.map(c=>({inner:c.inner,outer:o(a,c.outer)}))}t.merge=s})(Zr||(Zr={}));var vt;(function(t){function e(s,a){return typeof s=="object"?r(s):n(s,a)}t.create=e;function r(s){return{line:s.line??0,character:s.character??0}}function n(s,a){return r({line:s,character:a})}t.Beginning=t.create(0,0),t.Infinity=t.create(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);function i(s){return`<${s.line}, ${s.character}>`}t.toString=i;function o(s,a){return s.linec.line?!1:l.line=l.character:!0)&&(a.line===c.line?a.characterp(b.range,m,d))}t.findChildIndex=n;function i(u,h,d=!1){return u.children?.[n(u,h,d)]}t.findChild=i;function o(u,h,d=!1){if(!u.children)return-1;let p=-1;for(let[b,m]of u.children.entries())if(v.endsBefore(m.range,h,d))p=b;else break;return p}t.findLastChildIndex=o;function s(u,h,d=!1){return u.children?.[o(u,h,d)]}t.findLastChild=s;function a({node:u,needle:h,endInclusive:d=!1,predicate:p=()=>!0}){let b,m=v.contains(u,h,d)?u:void 0;for(;m&&p(m);)b=m,m=i(m,h,d);return b}t.findDeepestChild=a;function l({node:u,needle:h,endInclusive:d=!1,predicate:p=()=>!0}){let b=v.contains(u,h,d)?u:void 0;for(;b&&!p(b);)b=i(b,h,d);return b}t.findShallowestChild=l;function*c(u){let h=u;for(;h;)h.locals&&(yield h.locals),h=u.parent}t.getLocalsToRoot=c;function*f(u){u.locals&&(yield u.locals);for(let h of u.children??[])yield*f(h)}t.getLocalsToLeaves=f})(Ke||(Ke={}));var fu;(function(t){function e(n){return n.type==="boolean"}t.is=e;function r(n){return{type:"boolean",range:v.get(n)}}t.mock=r})(fu||(fu={}));var Ya=Object.freeze({is(t){return t?.type==="comment"}});var Vw;(function(t){function e(r){return r.type==="error"}t.is=e})(Vw||(Vw={}));var fs;(function(t){function e(r){return[...r.parserErrors,...r.binderErrors??[],...r.checkerErrors??[],...r.linterErrors??[]]}t.getErrors=e})(fs||(fs={}));var Sr;(function(t){function e(n){return n.type==="float"}t.is=e;function r(n){return{type:"float",range:v.get(n),value:0}}t.mock=r})(Sr||(Sr={}));var Ki;(function(t){function e(n){return n.type==="integer"}t.is=e;function r(n){return{type:"integer",range:v.get(n),value:0}}t.mock=r})(Ki||(Ki={}));var uu;(function(t){function e(r){return r?.type==="item"}t.is=e})(uu||(uu={}));var Ae;(function(t){function e(n){return n?.type==="literal"}t.is=e;function r(n,i){return{type:"literal",range:v.get(n),options:i,value:""}}t.mock=r})(Ae||(Ae={}));var Uw;(function(t){function e(n){return n.type==="long"}t.is=e;function r(n){return{type:"long",range:v.get(n),value:0n}}t.mock=r})(Uw||(Uw={}));var kn;(function(t){function e(r){return r?.type==="pair"}t.is=e})(kn||(kn={}));var U;(function(t){let e=q.TagPrefix,r=q.NamespacePathSep,n=q.PathSep,i=q.DefaultNamespace;function o(l){return l?.type==="resource_location"}t.is=o;function s(l,c){return{type:"resource_location",range:v.get(l),options:c}}t.mock=s;function a(l,c="origin",f=!1){let u=l.path?l.path.join(n):"",h;switch(c){case"origin":h=l.namespace!==void 0?`${l.namespace}${r}${u}`:u;break;case"full":h=`${l.namespace||i}${r}${u}`;break;case"short":h=l.namespace&&l.namespace!==i?`${l.namespace}${r}${u}`:u;break}return f&&l.isTag?`${e}${h}`:h}t.toString=a})(U||(U={}));var Qa=Symbol("SequenceUtilDiscriminator"),Xa;(function(t){function e(r){return!!r&&r[Qa]}t.is=e})(Xa||(Xa={}));var hu;(function(t){function e(r,n){return r?r.includes(n):!1}t.is=e})(hu||(hu={}));var Hw=new Map([['"','"'],["'","'"],["\\","\\"],["b","\b"],["f","\f"],["n",` +`],["r","\r"],["t"," "]]),et;(function(t){function e(n){return n?.type==="string"}t.is=e;function r(n,i){return n=v.get(n),{type:"string",range:n,options:i,value:"",valueMap:[{inner:v.create(0),outer:v.create(n.start)}]}}t.mock=r})(et||(et={}));var or;(function(t){function e(n){return n?.type==="symbol"}t.is=e;function r(n,i){return{type:"symbol",range:v.get(n),options:i,value:""}}t.mock=r})(or||(or={}));var Ww={array:"an array",boolean:"a boolean","bug-of-mc":"Due to a bug of Minecraft (%0%), %1%. Please Mojang, fix your game","code-action.block-state-sort-keys":"Sort block state","code-action.command-replaceitem":"Update this command to /item \u2026 replace","code-action.fix-file":"Fix all auto-fixable problems in this file","code-action.fix-workspace":"Fix all auto-fixable problems in the workspace","code-action.id-attribute-datafix":"Update this attribute name to 1.16","code-action.id-complete-default-namespace":"Complete default namespace","code-action.id-create-file":"Create %0% in the same data pack","code-action.id-omit-default-namespace":"Omit default namespace","code-action.id-zombified-piglin-datafix":"Change this ID to Zombified Piglin's","code-action.nbt-compound-sort-keys":"Sort NBT compound tag","code-action.nbt-type-to-byte":"Convert to an NBT byte tag","code-action.nbt-type-to-double":"Convert to an NBT double tag","code-action.nbt-type-to-float":"Convert to an NBT float tag","code-action.nbt-type-to-int":"Convert to an NBT int tag","code-action.nbt-type-to-long":"Convert to an NBT long tag","code-action.nbt-type-to-short":"Convert to an NBT short tag","code-action.nbt-uuid-datafix":"Update this UUID to 1.16","code-action.selector-sort-keys":"Sort selector argument","code-action.string-double-quote":"Quote this string with double quotation marks","code-action.string-single-quote":"Quote this string with single quotation marks","code-action.string-unquote":"Unquote this string","code-action.vector-align-0.0":"Align this vector to block origin","code-action.vector-align-0.5":"Align this vector to block center",comment:"a comment starting with %0%","conjunction.and_2":" and ","conjunction.and_3+_1":", ","conjunction.and_3+_2":", and ","conjunction.or_2":" or ","conjunction.or_3+_1":", ","conjunction.or_3+_2":", or ","datafix.error.command-replaceitem":"/replaceitem was removed in 20w46a (the second snapshot of 1.17) in favour of /item","duplicate-key":"Duplicate key %0%","ending-quote":"an ending quote %0%",entity:"an entity","error.unparseable-content":"Encountered unparseable content",expected:"Expected %0%","expected-got":"Expected %0% but got %1%",float:"a float","float.between":"a float between %0% and %1%",integer:"an integer","integer.between":"an integer between %0% and %1%","json.doc.advancement.display":"Advancement display settings. If present, the advancement will be visible in the advancement tabs.","json.checker.array.length-between":"%0% with length between %1% and %2%","json.checker.object.field.union-empty-members":"Disallowed property","json.checker.item.duplicate":"Duplicate list item","json.checker.property.deprecated":"Property %0% is deprecated","json.checker.property.missing":"Missing property %0%","json.checker.property.unknown":"Unknown property %0%","json.checker.string.hex-color":"a 6-digit hexadecimal number","json.checker.tag-entry.duplicate":"Duplicate tag entry","json.node.array":"an array","json.node.boolean":"a boolean","json.node.null":"a null","json.node.number":"a number","json.node.object":"an object","json.node.string":"a string","key-not-following-convention":"Invalid key %0% which doesn't follow %1% convention","linter.diagnostic-message-wrapper":"%0% (rule: %1%)","linter.name-convention.illegal":"Name %0% doesn't match %1%","linter.undeclared-symbol.message":"Cannot find %0% %1%","linter-config-validator.name-convention.type":"Expects a string that contains a regular expression describing the name","linter-config-validator.wrapper":"%0%. See [the documentation](%1) for more information",long:"a long","mcfunction.checker.command.data-modify-unapplicable-operation":"Operation %0% can only be used on %1%; the target path has type %2% instead","mcfunction.completer.block.states.default-value":"Default: %0%","mcfunction.parser.entity-selector.arguments.not-applicable":"%0% is not applicable here","mcfunction.parser.entity-selector.arguments.unknown":"Unknown entity selector argument %0%","mcfunction.parser.entity-selector.entities-disallowed":"The selector contains non-player entities","mcfunction.parser.entity-selector.multiple-disallowed":"The selector contains multiple entities","mcfunction.parser.entity-selector.player-name.too-long":"Player names cannot be longer than %0% characters","mcfunction.parser.eoc-unexpected":"Expected more arguments","mcfunction.parser.leading-slash":"a leading slash %0%","mcfunction.parser.no-permission":"Permission level %0% is required, which is higher than %1% defined in config","mcfunction.parser.objective.too-long":"Objective names cannot be longer than %0% characters","mcfunction.parser.range.min>max":"The minimum value %0% is larger than the maximum value %1%","mcfunction.parser.score_holder.fake-name.too-long":"Fake names cannot be longer than %0% characters","mcfunction.parser.sep":"a space (%0%)","mcfunction.parser.trailing":"Trailing data encountered: %0%","mcfunction.parser.unknown-parser":"Parser %0% hasn't been supported yet","mcfunction.parser.uuid.invalid":"Invalid UUID format","mcfunction.parser.vector.local-disallowed":"Local coordinates disallowed","mcfunction.parser.vector.mixed":"Cannot mix local coordinates and world coordinates together","mcfunction.signature-help.command-documentation":"[Minecraft Wiki: `%0%` command](https://minecraft.fandom.com/wiki/Commands/%0%)","mcfunction.signature-help.argument-parser-documentation":"[Minecraft Wiki: `%0%` argument parser](https://minecraft.fandom.com/wiki/Argument_types#%0%)","missing-key":"Missing key %0%","nbt.checker.block-states.fake-boolean":"Boolean block state values should be quoted","nbt.checker.block-states.unexpected-value-type":"Block state values should be either a string or an int","nbt.checker.block-states.unknown-state":"Unknown block state %0% for the following block(s): %1%","nbt.checker.boolean.out-of-range":"A boolean value should be either %0% or %1%","nbt.checker.collection.length-between":"%0% with length between %1% and %2%","nbt.checker.compound.field.union-empty-members":"Disallowed property","nbt.checker.path.index-out-of-bound":"The provided index %0% is out of bound, as the collection can only have at most %1% elements","nbt.checker.path.unexpected-filter":"Compound filters can only be used on compound tags","nbt.checker.path.unexpected-index":"Indices can only be used on array or list tags","nbt.checker.path.unexpected-key":"String keys can only be specified for compound tags","nbt.node":"a tag","nbt.node.byte":"a byte tag","nbt.node.byte_array":"a byte array tag","nbt.node.compound":"a compound tag","nbt.node.double":"a double tag","nbt.node.float":"a float tag","nbt.node.int":"an int tag","nbt.node.int_array":"an int array tag","nbt.node.list":"a list tag","nbt.node.long":"a long tag","nbt.node.long_array":"a long array tag","nbt.node.path.end":"the end of path","nbt.node.path.filter":"a compound filter","nbt.node.path.index":"an index","nbt.node.path.key":"a key","nbt.node.short":"a short tag","nbt.node.string":"a string tag","nbt.parser.number.out-of-range":"This looks like %0%, but it is actually %1% due to the numeral value being out of [%2%, %3%]","mcdoc.binder.dispatcher-statement.duplicated-key":"Duplicated dispatcher case %0%","mcdoc.binder.dispatcher-statement.duplicated-key.related":"%0% has already been dispatched here","mcdoc.binder.duplicated-declaration":"Duplicated declaration for %0%","mcdoc.binder.duplicated-declaration.related":"%0% is already declared here","mcdoc.binder.out-of-root":"File %0% is not under the root directory of any mcdoc project; semantic checking will be skipped","mcdoc.binder.path.super-from-root":"Cannot access super of the project root","mcdoc.binder.path.unknown-identifier":"Identifier %0% does not exist in module %1%","mcdoc.binder.path.unknown-module":"Module %0% does not exist","mcdoc.node.compound-definition":"a compound definition","mcdoc.node.enum-definition":"an enum definition","mcdoc.node.identifier":"an identifier","mcdoc.checker.entry.empty-mod-seg":"You cannot put \u201Cmod.mcdoc\u201D under a root directly","mcdoc.checker.inject-clause.unmatched-injection":"Cannot inject %0% with %1%","mcdoc.checker.type-not-assignable":"Type %0% is not assignable to type %1%","mcdoc.parser.compound-definition.field-type":"a field type","mcdoc.parser.float.illegal":"Encountered illegal float number","mcdoc.parser.identifier.reserved-word":"%0% is a reserved word and cannot be used as an identifier name","mcdoc.parser.identifier.illegal":"%0% doesn't follow the format of %1%","mcdoc.parser.index-body.dynamic-index-not-allowed":"Dynamic indexing is not allowed","mcdoc.parser.inject-clause.definition-expected":"Expected either an enum inject or a compound inject","mcdoc.parser.keyword.separation":"a separation","mcdoc.parser.resource-location.colon-expected":"Expected the colon (%0%) of resource locations","mcdoc.parser.syntax.doc-comment-unexpected":"Doc comments are not allowed here; you might want to replace the three slashes with two slashes","not-matching-any-child":"Invalid argument type",nothing:"nothing",number:"a number","number-range":"a number range","number-range.missing-min-and-max":"Expected either a minimum value or a maximum value","number.<=":"a number smaller than or equal to %0%","number.>=":"a number greater than or equal to %0%","number.between":"a number between %0% and %1%",object:"an object",objective:"an objective","objective-not-following-convention":"Invalid objective %0% which doesn't follow %1% convention","parser.float.illegal":"Illegal float numeral that doesn't follow %0%","parser.integer.illegal":"Illegal integer that doesn't follow %0%","parser.list.value":"a value","parser.list.trailing-sep":"Trailing separation","parser.record.key":"a key","parser.record.trailing-end":"Trailing separation","parser.record.unexpected-char":"Unexpected character %0%","parser.record.value":"a value","parser.resource-location.illegal":"Illegal character(s): %0%","parser.resource-location.namespace-expected":"Namespaces cannot be omitted here","parser.resource-location.tag-diallowed":"Tags are not allowed here","parser.string.illegal-brigadier":"Encountered non-[0-9A-Za-z_.+-] characters in %0%","parser.string.illegal-escape":"Unexpected escape character %0%","parser.string.illegal-quote":"Only %0% can be used to quote strings here","parser.string.illegal-unicode-escape":"Hexadecimal digit expected","punc.period":".","punc.quote":"\u201C%0%\u201D",quote:`a quote (\u201C'\u201D or \u201C"\u201D)`,quote_prefer_double:'Double quote (\u201C"\u201D) is preferable here',quote_prefer_single:"Single quote (\u201C'\u201D) is preferable here","resource-location":"a resource location","score-holder":"a score holder","scoreholder-not-following-convention":"Invalid score_holder %0% which doesn't follow %1% convention","server.new-version":"The Data-pack Language Server has been updated to a newer version: %0%","server.progress.fixing-workspace.begin":"Fixing all auto-fixable problems in the workspace","server.progress.fixing-workspace.report":"fixing %0%","server.progress.preparing.title":"Preparing Spyglass language features","server.remove-cache-file":"The cache file of DHP was moved to a storage location provided by VSCode. You can safely delete the ugly \u201C.datapack\u201D folder in your workspace root.","server.show-release-notes":"Show Release Notes",string:"a string",tag:"a tag","tag-not-following-convention":"Invalid tag %0% which doesn't follow %1% convention",team:"a team","team-not-following-convention":"Invalid team %0% which doesn't follow %1% convention","time-unit":"a time unit","too-many-block-affected":"Too many blocks in the specified area (maximum %0%, specified %1%)","too-many-chunk-affected":"Too many chunks in the specified area (maximum %0%, specified %1%)","unexpected-character":"Found non [a-z0-9/._-] character(s)","unexpected-datapack-tag":"Tags are not allowed here","unexpected-default-namespace":"Default namespace should be omitted here","unexpected-leading-slash":"Unexpected leading slash \u201C/\u201D","unexpected-local-coordinate":"Local coordinate %0% is not allowed","unexpected-nbt":"This tag doesn't exist here","unexpected-nbt-array-type":"Invalid array type %0%. Should be one of \u201CB\u201D, \u201CI\u201D, and \u201CL\u201D","unexpected-nbt-path-filter":"Compound filters are only used for compound tags","unexpected-nbt-path-index":"Indices are only used for lists/arrays tags","unexpected-nbt-path-key":"Keys are only used for compound tags","unexpected-nbt-path-sub":"The current tag doesn't have extra items","unexpected-omitted-default-namespace":"Default namespace shouldn't be omitted here","unexpected-relative-coordinate":"Relative coordinate %0% is not allowed","unexpected-scoreboard-sub-slot":"Only \u201Csidebar\u201D has sub slots","unknown-command":"Unknown command %0%","unknown-escape":"Unexpected escape character %0%","unknown-key":"Unknown key %0%","unquoted-string":"an unquoted string","unsorted-keys":"Unsorted keys",uuid:"a UUID",vector:"a vector"};var qw={en:Ww},UR="en";function y(t,...e){let r=qw[UR][t]??qw.en[t];return HR(r,e)??""}function P(t){return y("punc.quote",t)}function HR(t,e){return t?.replace(/%\d+%/g,r=>{let n=parseInt(r.slice(1,-1)),i=e[n];return typeof i!="string"&&i?.[Symbol.iterator]&&(i=vn(i)),`${i??r}`})}function vn(t,e=!0,r="or"){let n=o=>e?P(o):o,i=(typeof t=="string"?[t]:Array.from(t)).map(n);switch(i.length){case 0:return y("nothing");case 1:return i[0];case 2:return i[0]+y(`conjunction.${r}_2`)+i[1];default:return`${i.slice(0,-1).join(y(`conjunction.${r}_3+_1`))}${y(`conjunction.${r}_3+_2`)}${i[i.length-1]}`}}function we(...t){let e=WR(t);return(r,n)=>{let i={type:"literal",range:v.create(r),options:e,value:""};for(let o of e.pool)if(r.trySkip(o))return i.value=o,i.range.end=r.cursor,i;return n.err.report(y("expected",e.pool),i),i}}function WR(t){let e;return typeof t[0]=="object"?e=t[0]:e={pool:t},e.pool=e.pool.sort((r,n)=>n.length-r.length),e}var Tm=Br(ru(),1);var Om=Object.freeze(["mcdoc","mcdoc/dispatcher"]),Gi=Object.freeze(["activity","attribute","block","block_entity_type","block_predicate_type","chunk_status","custom_stat","enchantment","entity_type","float_provider_type","fluid","game_event","height_provider_type","int_provider_type","item","loot_condition_type","loot_function_type","loot_nbt_provider_type","loot_number_provider_type","loot_pool_entry_type","loot_score_provider_type","memory_module_type","menu","mob_effect","motive","particle_type","point_of_interest_type","pos_rule_test","position_source_type","potion","recipe_serializer","recipe_type","rule_test","schedule","sensor_type","sound_event","stat_type","villager_profession","villager_type","worldgen/biome_source","worldgen/block_placer_type","worldgen/block_state_provider_type","worldgen/carver","worldgen/chunk_generator","worldgen/decorator","worldgen/feature","worldgen/feature_size_type","worldgen/foliage_placer_type","worldgen/material_condition","worldgen/material_rule","worldgen/placement_modifier_type","worldgen/structure_feature","worldgen/structure_piece","worldgen/structure_pool_element","worldgen/structure_processor","worldgen/surface_builder","worldgen/tree_decorator_type","worldgen/trunk_placer_type"]),Jw=Object.freeze(["worldgen/biome","worldgen/configured_carver","worldgen/configured_feature","worldgen/configured_structure_feature","worldgen/configured_surface_builder","worldgen/density_function","worldgen/noise","worldgen/noise_settings","worldgen/placed_feature","worldgen/processor_list","worldgen/template_pool"]),Rm=Object.freeze(["function",...Gi,...Jw]),qR=Object.freeze(Rm.map(t=>`tag/${t}`)),hs=Object.freeze(["advancement","chat_type","damage_type","dimension","dimension_type","function","item_modifier","loot_table","predicate","recipe","structure","trim_material","trim_pattern",...qR,...Jw]),KR=Object.freeze(["attribute_modifier_uuid","bossbar","objective","score_holder","storage","tag","team"]),GR=Object.freeze([...hs,...KR]),X$=Object.freeze([...GR,...Om,...Gi]),ZR=Object.freeze(["bossbar","storage","mcdoc/dispatcher",...hs,...Gi]),Kw;(function(t){function e(r){return ZR.includes(r)}t.is=e})(Kw||(Kw={}));var _t;(function(t){function e(i){return i?{category:i.category,path:i.path}:void 0}t.fromSymbol=e;function r(i){return JSON.stringify({category:i.category,path:i.path})}t.toString=r;function n(i){return JSON.parse(i)}t.fromString=n})(_t||(_t={}));var us,Gw=class{constructor(){E(this,us,new Set)}add(e){e&&g(this,us).add(_t.toString(e))}has(e){return g(this,us).has(_t.toString(e))}collect(){return[...g(this,us)].map(_t.fromString)}};us=new WeakMap;var Zi=Object.freeze(["definition","declaration","implementation","reference","typeDefinition"]),el;(function(t){function e(r){return Zi.includes(r)}t.is=e})(el||(el={}));var Zw;(function(t){function e(r,n,...i){if(Bw(r)){for(let s of r){let a=e(s,n,...i);if(a)return a}return}let o=r[n];for(let s of i);}t.get=e})(Zw||(Zw={}));var du;(function(t){function e(r,n,i,o,s){return{...cu.create(r,n),...i?{fullRange:v.get(i),fullPosRange:Jn.from(i,r)}:{},...o?{contributor:o}:{},...s||{}}}t.create=e})(du||(du={}));var tl;(function(t){function e(o){let s=(c,f,u,h,d)=>{c.category=h,c.identifier=d[d.length-1],c.path=d,c.parentMap=f,u&&(c.parentSymbol=u),c.members&&a(c.members,c,h,d)},a=(c,f,u,h)=>{for(let[d,p]of Object.entries(c))s(p,c,f,u,[...h,d])},l=(0,Tm.default)()(o);for(let[c,f]of Object.entries(l))a(f,void 0,c,[]);return l}t.link=e;function r(o){let s=c=>{delete c.category,delete c.identifier,delete c.parentMap,delete c.parentSymbol,delete c.path,c.members&&a(c.members)},a=c=>{for(let f of Object.values(c))s(f)},l=(0,Tm.default)({circles:!0})(o);for(let c of Object.values(l))a(c);return l}t.unlink=r;function n(o){return JSON.stringify(r(o))}t.serialize=n;function i(o){return e(JSON.parse(o))}t.deserialize=i})(tl||(tl={}));var Xw=Br(mu(),1);var yu=function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(i<3?s(o):i>3?s(e,r,o):s(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},Xn,Ji,rl,Qn,Yi,sr,Ct=class{constructor(e,r,n,i=!1){E(this,Xn,void 0);E(this,Ji,void 0);E(this,rl,void 0);E(this,Qn,new Set);E(this,Yi,Object.create(null));E(this,sr,void 0);H(this,"_delayedOps",[]);H(this,"_inDelayMode");L(this,Ji,new r),L(this,rl,r),L(this,Xn,e),L(this,sr,n),this._inDelayMode=i,this.on("symbolCreated",({symbol:o})=>{g(this,Qn).add(_t.toString(o))}).on("symbolRemoved",({symbol:o})=>{g(this,Qn).delete(_t.toString(o))}).on("symbolLocationCreated",({symbol:o,location:s})=>{let a=g(this,Yi)[s.contributor??"undefined"]??=Object.create(null),l=a[s.uri]??=new Set,c=_t.toString(o);l.add(c),g(this,Qn).delete(c)}).on("symbolLocationRemoved",({symbol:o})=>{let s=_t.toString(o);g(this,Qn).add(s)})}get global(){return g(this,Xn)}on(e,r){return g(this,Ji).on(e,r),this}once(e,r){return g(this,Ji).once(e,r),this}emit(e,...r){return g(this,Ji).emit(e,...r)}buildCache(){Ct.forEachSymbol(this.global,e=>{this.emit("symbolCreated",{symbol:e}),Ct.forEachLocationOfSymbol(e,({type:r,location:n})=>{this.emit("symbolLocationCreated",{symbol:e,type:r,location:n})})})}clone(){return new Ct(g(this,Xn),g(this,rl),g(this,sr),!0)}applyDelayedEdits(){this._delayedOps.forEach(e=>e()),this._delayedOps=[],this._inDelayMode=!1}contributeAs(e,r){let n=g(this,sr);L(this,sr,e);try{r()}finally{L(this,sr,n)}return this}async contributeAsAsync(e,r){let n=g(this,sr);L(this,sr,e);try{await r()}finally{L(this,sr,n)}return this}clear({uri:e,contributor:r,predicate:n=()=>!0}){let i=()=>r?g(this,Yi)[r]?[g(this,Yi)[r]]:[]:Object.values(g(this,Yi)),o=()=>{let c=i();return(e?c.map(u=>u[e]??new Set):c.map(u=>Object.values(u)).flat()).map(u=>[...u]).flat().map(_t.fromString)},s=()=>e?[g(this,Xn)]:[g(this,Xn)],a=o(),l=s();for(let c of l){for(let f of a){let{symbol:u}=Ct.lookupTable(c,f.category,f.path);u&&this.removeLocationsFromSymbol(u,e?h=>h.location.uri===e&&n(h):n)}this.trim(c)}}lookup(e,r,n){for(;n;){if(n.locals){let i=Ct.lookupTable(n.locals,e,r);if(i.symbol)return i}n=n.parent}return Ct.lookupTable(this.global,e,r)}query(e,r,...n){let i=Ct.toUri(e),{parentSymbol:o,parentMap:s,symbol:a}=this.lookup(r,n,Dm(e)?e.node:void 0),l=a?Ct.isVisible(a,i):!0;return new gu({category:r,doc:e,contributor:g(this,sr),map:l?s:void 0,parentSymbol:o,path:n,symbol:l?a:void 0,util:this})}getVisibleSymbols(e,r){let n=this.lookup(e,[],void 0).parentMap??void 0;return Ct.filterVisibleSymbols(r,n)}static toUri(e){return typeof e=="string"?e:Dm(e)?e.doc.uri:e.uri}trim(e){let r=n=>{n&&Ct.isTrimmable(n)&&(delete n.parentMap[n.identifier],this.emit("symbolRemoved",{symbol:n}),r(n.parentSymbol))};for(let n of g(this,Qn)){let i=_t.fromString(n),{symbol:o}=Ct.lookupTable(e,i.category,i.path);r(o)}}removeLocationsFromSymbol(e,r){for(let n of Zi)e[n]&&(e[n]=e[n].reduce((i,o)=>(r({location:o,symbol:e,type:n})?this.emit("symbolLocationRemoved",{symbol:e,type:n,location:o}):i.push(o),i),[]))}enterMap(e,r,n,i,o,s,a,l){let c=r[o];return c?this.amendSymbol(c,s,a,l):c=this.createSymbol(n,e,r,i,o,s,a,l),this.emit("symbolAmended",{symbol:c}),c}static lookupTable(e,r,n){let i=e[r],o,s;for(let a=0;a=0;s--){let a=e[s],l=this.lookupTable(a,r,n);if(l.symbol)return l;!o&&!i&&(l.parentSymbol||l.parentMap)&&(o=l.parentSymbol,i=l.parentMap)}return{parentSymbol:o,parentMap:i,symbol:void 0}}createSymbol(e,r,n,i,o,s,a,l){let c=n[o]={category:e,identifier:o,...r?{parentSymbol:r}:{},parentMap:n,path:i,...s.data};return this.emit("symbolCreated",{symbol:c}),this.amendSymbolUsage(c,s.usage,a,l),c}amendSymbol(e,r,n,i){this.amendSymbolMetadata(e,r.data),this.amendSymbolUsage(e,r.usage,n,i)}amendSymbolMetadata(e,r){if(r){if("data"in r&&(e.data=r.data),"desc"in r&&(e.desc=r.desc),r.relations&&Object.keys(r.relations).length){e.relations??={};for(let n of Object.keys(r.relations))e.relations[n]=r.relations[n]}if("subcategory"in r&&(e.subcategory=r.subcategory),"visibility"in r){let n=i=>i===void 0||i===2||i===3;if(e.visibility===r.visibility||n(e.visibility)&&n(r.visibility))e.visibility=r.visibility;else throw new Error(`Cannot change visibility from ${e.visibility} to ${r.visibility}: ${JSON.stringify(_t.fromSymbol(e))}`)}r.visibilityRestriction?.length&&(e.visibilityRestriction=(e.visibilityRestriction??[]).concat(r.visibilityRestriction))}}amendSymbolUsage(e,r,n,i){if(r){let o=r.type??"reference",s=e[o]??=[],a=v.get((Mm.is(r)?r.node:r.range)??0),l=du.create(n,a,r.fullRange,i,{accessType:r.accessType,skipRenaming:r.skipRenaming});n.uri.startsWith("file:")||(delete l.range,delete l.posRange,delete l.fullRange,delete l.fullPosRange),s.push(l),this.emit("symbolLocationCreated",{symbol:e,type:o,location:l})}}resolveAlias(e){return e?.relations?.aliasOf?this.resolveAlias(this.lookup(e.relations.aliasOf.category,e.relations.aliasOf.path).symbol):e}static filterVisibleSymbols(e,r={}){let n={};for(let[i,o]of Object.entries(r))Ct.isVisible(o,e)&&(n[i]=o);return n}static isTrimmable(e){return!Object.keys(e.members??{}).length&&!e.declaration?.length&&!e.definition?.length&&!e.implementation?.length&&!e.reference?.length&&!e.typeDefinition?.length}static isVisible(e,r){switch(e.visibility){case 3:return!1;case 0:case 1:case 2:default:return!0}}static isDeclared(e){return!!(e?.declaration?.length||e?.definition?.length)}static isDefined(e){return!!(e?.definition?.length||e?.definition?.length&&e?.implementation?.length)}static isImplemented(e){return!!(e?.implementation?.length||e?.definition?.length)}static isReferenced(e){return!!e?.reference?.length}static isTypeDefined(e){return!!e?.typeDefinition?.length}static getDeclaredLocation(e){return e.declaration?.[0]??e.definition?.[0]??(()=>{throw new Error(`Cannot get declared location of ${JSON.stringify(_t.fromSymbol(e))}`)})()}static forEachSymbolInMap(e,r){for(let n of Object.values(e))r(n),n.members&&this.forEachSymbolInMap(n.members,r)}static forEachSymbol(e,r){for(let n of Object.values(e))this.forEachSymbolInMap(n,r)}static forEachLocationOfSymbol(e,r){for(let n of Zi)e[n]?.forEach(i=>r({type:n,location:i}))}static isVisibilityInGlobal(e){return e===void 0||e===2||e===3}static areVisibilitiesCompatible(e,r){return this.isVisibilityInGlobal(e)&&this.isVisibilityInGlobal(r)||e===0&&r===0||e===1&&r===1}},Le=Ct;Xn=new WeakMap,Ji=new WeakMap,rl=new WeakMap,Qn=new WeakMap,Yi=new WeakMap,sr=new WeakMap;yu([bu()],Le.prototype,"clear",null);yu([bu()],Le.prototype,"trim",null);yu([bu()],Le.prototype,"removeLocationsFromSymbol",null);var Em;(function(t){function e(r){return!!r?.range}t.is=e})(Em||(Em={}));var Mm;(function(t){function e(r){return!!r?.node}t.is=e})(Mm||(Mm={}));var Jr,ei,Xi,ds,nl,Yr,wn,Pe,Nm=class{constructor({category:e,contributor:r,doc:n,map:i,parentSymbol:o,path:s,symbol:a,util:l}){H(this,"category");H(this,"path");E(this,Jr,void 0);E(this,ei,void 0);E(this,Xi,void 0);E(this,ds,void 0);E(this,nl,!1);E(this,Yr,void 0);E(this,wn,void 0);E(this,Pe,void 0);H(this,"util");this.category=e,this.path=s,typeof n=="string"?(n=Xw.TextDocument.create(n,"",0,""),L(this,Xi,!0)):Dm(n)&&(L(this,ei,n.node),n=n.doc),L(this,Jr,n),L(this,ds,r),L(this,Yr,i),L(this,wn,o),L(this,Pe,a),this.util=l}get symbol(){return g(this,Pe)}get visibleMembers(){return Le.filterVisibleSymbols(g(this,Jr).uri,this.path.length===0?g(this,Yr):g(this,Pe)?.members)}heyGimmeDaSymbol(){return g(this,Pe)}getData(e){let r=g(this,Pe)?.data;return e(r)?r:void 0}with(e){return e(this),this}if(e,r){return e.call(this,g(this,Pe),this)&&(r.call(this,g(this,Pe),this),L(this,nl,!0)),this}ifUnknown(e){return this.if(r=>r===void 0,e)}ifKnown(e){return this.if(r=>r!==void 0,e)}ifDeclared(e){return this.if(r=>Le.isDeclared(r),e)}ifDefined(e){return this.if(Le.isDefined,e)}ifImplemented(e){return this.if(Le.isImplemented,e)}ifReferenced(e){return this.if(Le.isReferenced,e)}ifTypeDefined(e){return this.if(Le.isTypeDefined,e)}else(e){return g(this,nl)||e.call(this,g(this,Pe),this),this}elseEnter(e){return this.else(()=>this.enter(e))}elseResolveAlias(){return this.else(()=>this.resolveAlias())}_enter(e){let r=i=>i.data?.visibility??this.symbol?.visibility??2,n=i=>{let o=r(i);if(g(this,Yr)&&Le.areVisibilitiesCompatible(o,g(this,Pe)?.visibility))return g(this,Yr);if(this.path.length>1){if(g(this,wn)){if(!Le.areVisibilitiesCompatible(o,g(this,wn).visibility))throw new Error(`Cannot enter member \u201C${this.getPath()}\u201D of ${Yn.stringifyVisibility(o)} visibility to parent of ${Yn.stringifyVisibility(g(this,wn).visibility)} visibility`);return g(this,wn).members??={}}}else{let s;if(Le.isVisibilityInGlobal(o))s=this.util.global;else if(o===1){if(!g(this,ei))throw new Error(`Cannot enter \u201C${this.getPath()}\u201D with ${Yn.stringifyVisibility(o)} visibility as no node is supplied`);let a=g(this,ei);for(;a;){if(a.type==="file"){s=a.locals;break}a=a.parent}if(!s)throw new Error(`Cannot enter \u201C${this.getPath()}\u201D with ${Yn.stringifyVisibility(o)} visibility as no file node is supplied`)}else{if(!g(this,ei))throw new Error(`Cannot enter \u201C${this.getPath()}\u201D with ${Yn.stringifyVisibility(o)} visibility as no node is supplied`);let a=g(this,ei);for(;a;){if(a.locals){s=a.locals;break}a=a.parent}if(!s)throw new Error(`Cannot enter \u201C${this.getPath()}\u201D with ${Yn.stringifyVisibility(o)} visibility as no node with locals is supplied`)}return s[this.category]??={}}throw new Error(`Cannot create the symbol map for \u201C${this.getPath()}\u201D`)};g(this,Xi)&&Em.is(e.usage)&&(e.usage.range=v.create(0,0)),L(this,Yr,n(e)),L(this,Pe,this.util.enterMap(g(this,wn),g(this,Yr),this.category,this.path,this.path[this.path.length-1],e,g(this,Jr),g(this,ds))),e.usage?.node&&(e.usage.node.symbol=g(this,Pe))}enter(e){return this._enter(e),this}amend(e){return this.ifKnown(()=>this.enter(e))}resolveAlias(){if(g(this,Pe)){let e=this.util.resolveAlias(g(this,Pe));if(!e)throw new Error("The current symbol points to an non-existent symbol.");L(this,Pe,e),L(this,Yr,e.parentMap)}return this}member(){let e,r,n;if(arguments.length===2?(e=g(this,Xi)?g(this,Jr).uri:g(this,Jr),r=arguments[0],n=arguments[1]):(e=arguments[0],r=arguments[1],n=arguments[2]),g(this,Pe)===void 0)throw new Error(`Tried to query member symbol \u201C${r}\u201D from an undefined symbol (path \u201C${this.path.join(".")}\u201D)`);let i=typeof e=="string"&&e===g(this,Jr).uri&&!g(this,Xi)?g(this,Jr):e,o=g(this,Pe).members,s=o?.[r],a=new Nm({category:this.category,doc:i,contributor:g(this,ds),map:o,parentSymbol:g(this,Pe),path:[...this.path,r],symbol:s,util:this.util});return n(a),this}onEach(e,r){for(let n of e)r.call(this,n,this);return this}forEachMember(e){return this.onEach(Object.keys(this.visibleMembers),r=>this.member(r,n=>e(r,n)))}getPath(){return`${this.category}.${this.path.join("/")}`}},gu=Nm;Jr=new WeakMap,ei=new WeakMap,Xi=new WeakMap,ds=new WeakMap,nl=new WeakMap,Yr=new WeakMap,wn=new WeakMap,Pe=new WeakMap;yu([bu(t=>t.util)],gu.prototype,"_enter",null);var Yn;(function(t){let e="+ ";function r(c,f){if(c!==f)throw new Error(`Assertion error: ${c} !== ${f}`)}function n(c){return c.map(f=>i(f)).join(` ------------ `)}t.stringifySymbolStack=n;function i(c,f=""){let u=[];for(let h of Object.keys(c)){let d=c[h];u.push([h,o(d,`${f}${e}`)])}return u.map(h=>`CATEGORY ${h[0]} ${h[1]}`).join(` @@ -30,37 +30,37 @@ ${s(c.parentSymbol,e)} parentMap: ${o(c.parentMap,e)} symbol: -${s(c.symbol,e)}`}t.stringifyLookupResult=l})(Yn||(Yn={}));function bu(t=e=>e){return(e,r,n)=>{let i=n.value;return n.value=function(...o){let s=t(this);s._inDelayMode?s._delayedOps.push(i.bind(this,...o)):i.apply(this,o)},n}}function Rm(t){return!!t.doc}var Y;(function(t){function*e(x,T){for(let O of T)x.startsWith(O)&&(yield decodeURIComponent(x.slice(O.length)))}t.getRels=e;function r(x,T){return e(x,T).next().value}t.getRel=r;function n(x){return x.endsWith("/")}t.isRootUri=n;function i(x){return n(x)?x:`${x}/`}t.ensureEndingSlash=i;function o(x,T){return i(x)+(T.startsWith("/")?T.slice(1):T)}t.join=o;function s(x){return x.startsWith("file:")}t.isFileUri=s;function a(x){let T=x.lastIndexOf(".");return T>=0?x.slice(T):void 0}t.extname=a;function l(x){let T=x.lastIndexOf("/");return T>=0?x.slice(T+1):x}t.basename=l;function c(x,T){return new It(".",T)}t.getParentOfFile=c;async function f(x,T,O=511){try{await x.fs.mkdir(T,{mode:O,recursive:!0})}catch(M){if(!x.error.isKind(M,"EEXIST"))throw M}}t.ensureDir=f;async function u(x,T,O=511){return f(x,c(x,T),O)}t.ensureParentOfFile=u;async function h(x,T,O){return x.fs.chmod(T,O)}t.chmod=h;async function d(x,T){try{await h(x,T,438)}catch(O){if(!x.error.isKind(O,"ENOENT"))throw O}}t.ensureWritable=d;async function p(x,T){return h(x,T,292)}t.markReadOnly=p;async function b(x,T){return x.fs.readFile(T)}t.readFile=b;async function m(x,T,O,M=438){return await u(x,T),await d(x,T),x.fs.writeFile(T,O,{mode:M})}t.writeFile=m;async function k(x,T){return JSON.parse(ir(await b(x,T)))}t.readJson=k;async function S(x,T,O){return m(x,T,JSON.stringify(O))}t.writeJson=S;async function _(x,T){return x.archive.gunzip(await b(x,T))}t.readGzippedFile=_;async function w(x,T,O){return typeof O=="string"&&(O=new TextEncoder().encode(O)),m(x,T,await x.archive.gzip(O))}t.writeGzippedFile=w;async function C(x,T){return JSON.parse(ir(await _(x,T)))}t.readGzippedJson=C;async function R(x,T,O){return w(x,T,JSON.stringify(O))}t.writeGzippedJson=R})(Y||(Y={}));var Mm=2,ku;(function(t){function e(){return{files:{},roots:{},symbolRegistrars:{}}}t.create=e})(ku||(ku={}));var Qi,wu,vu=class{constructor(e,r){H(this,"cacheRoot");H(this,"project");H(this,"checksums",ku.create());H(this,"errors",{});E(this,Qi,!1);E(this,wu,void 0);this.cacheRoot=e,this.project=r,this.project.on("documentUpdated",async({doc:n})=>{if(g(this,Qi))try{this.checksums.files[n.uri]=await this.project.externals.crypto.getSha1(n.getText())}catch(i){this.project.externals.error.isKind(i,"EISDIR")||this.project.logger.error(`[CacheService#hash-file] ${n.uri}`)}}),this.project.on("rootsUpdated",async({roots:n})=>{if(g(this,Qi))for(let i of n)try{this.checksums.roots[i]=await this.project.fs.hash(i)}catch(o){this.project.externals.error.isKind(o,"EISDIR")||this.project.logger.error(`[CacheService#hash-root] ${i}`)}}),this.project.on("symbolRegistrarExecuted",({id:n,checksum:i})=>{i!==void 0&&(this.checksums.symbolRegistrars[n]=i)}),this.project.on("documentErrored",({uri:n,errors:i})=>{this.errors[n]=i})}async getCacheFileUri(){return g(this,wu)??L(this,wu,new It(`symbols/${await this.project.externals.crypto.getSha1(this.project.projectRoot)}.json.gz`,this.cacheRoot).toString())}async load(){let e=this.project.profilers.get("cache#load"),r={symbols:{}},n;try{n=await this.getCacheFileUri(),this.project.logger.info(`[CacheService#load] symbolCachePath = \u201C${n}\u201D`);let i=await Y.readGzippedJson(this.project.externals,n);e.task("Read File"),i.version===Mm?(this.checksums=i.checksums,this.errors=i.errors,r.symbols=tl.link(i.symbols),e.task("Link Symbols")):this.project.logger.info(`[CacheService#load] Unsupported cache format ${i.version}; expected ${Mm}`)}catch(i){this.project.externals.error.isKind(i,"ENOENT")||this.project.logger.error("[CacheService#load] ",i)}return e.finalize(),r}async validate(){let e={addedFiles:[],changedFiles:[],removedFiles:[],unchangedFiles:[]},r=[];for(let[n,i]of Object.entries(this.checksums.roots))try{await this.project.fs.hash(n)===i&&r.push(n)}catch(o){this.project.externals.error.isKind(o,"EISDIR")||this.project.logger.error(`[CacheService#hash-file] ${n}`)}for(let[n,i]of Object.entries(this.checksums.files)){if(r.some(o=>n.startsWith(o))){e.unchangedFiles.push(n);continue}try{await this.project.fs.hash(n)===i?e.unchangedFiles.push(n):e.changedFiles.push(n)}catch(o){this.project.externals.error.isKind(o,"ENOENT")||this.project.externals.error.isKind(o,"EISDIR")?e.removedFiles.push(n):(this.project.logger.error(`[CacheService#validate] ${n}`,o),e.changedFiles.push(n))}}for(let n of this.project.getTrackedFiles())n in this.checksums.files||e.addedFiles.push(n);return L(this,Qi,!0),e}async save(){let e=this.project.profilers.get("cache#save"),r;try{r=await this.getCacheFileUri();let n={version:Mm,projectRoot:this.project.projectRoot,checksums:this.checksums,symbols:tl.unlink(this.project.symbols.global),errors:this.errors};return e.task("Unlink Symbols"),await Y.writeGzippedJson(this.project.externals,r,n),e.task("Write File").finalize(),!0}catch(n){this.project.logger.error(`[CacheService#save] path = \u201C${r}\u201D`,n)}return!1}async hasFileChangedSinceCache(e){return this.checksums.files[e.uri]!==await this.project.externals.crypto.getSha1(e.getText())}reset(){return L(this,Qi,!1),this.checksums=ku.create(),this.errors={},{symbols:{}}}};Qi=new WeakMap,wu=new WeakMap;var Jw=Br(ru(),1);var ps;(function(t){function e(n){return n==="hint"||n==="information"||n==="warning"||n==="error"}t.is=e;function r(n){switch(n){case"error":return 3;case"hint":return 0;case"information":return 1;case"warning":return 2}}t.toErrorSeverity=r})(ps||(ps={}));var gs;(function(t){function e(r){if(r!=null)return ps.is(r)?{ruleSeverity:ps.toErrorSeverity(r),ruleValue:!0}:Array.isArray(r)&&ps.is(r[0])?{ruleSeverity:ps.toErrorSeverity(r[0]),ruleValue:r[1]}:{ruleSeverity:2,ruleValue:r}}t.destruct=e})(gs||(gs={}));var il;(function(t){function e(o){return Ue.is(o,r.is)||i.is(o)}t.is=e;let r;(function(o){function s(a){if(!a||typeof a!="object")return!1;let l=a;return(l.if===void 0||Ue.is(l.if,n.is))&&(l.then===void 0||i.is(l.then))&&(l.override===void 0||Ue.is(l.override,o.is))}o.is=s})(r=t.Complex||(t.Complex={}));let n;(function(o){function s(a){if(!a||typeof a!="object")return!1;let l=a;return(l.category===void 0||Ue.is(l.category,Gn.isString))&&(l.pattern===void 0||Ue.is(l.pattern,Gn.isString))&&(l.excludePattern===void 0||Ue.is(l.excludePattern,Gn.isString))&&(l.namespace===void 0||Ue.is(l.namespace,Gn.isString))&&(l.excludeNamespace===void 0||Ue.is(l.excludeNamespace,Gn.isString))}o.is=s})(n=t.Condition||(t.Condition={}));let i;(function(o){function s(c){return c!==void 0&&["block","file","public"].includes(c.declare)}o.isDeclare=s;function a(c){return c!==void 0&&["inherit","hint","information","warning","error"].includes(c.report)}o.isReport=a;function l(c){if(!c||typeof c!="object")return!1;let f=c;return s(f)||a(f)}o.is=l})(i=t.Action||(t.Action={}))})(il||(il={}));var Dm={env:{dataSource:"GitHub",dependencies:["@vanilla-mcdoc"],feature:{codeActions:!0,colors:!0,completions:!0,documentHighlighting:!0,documentLinks:!0,foldingRanges:!0,formatting:!0,hover:!0,inlayHint:{enabledNodes:["mcfunction:command_child/unknown"]},semanticColoring:!0,selectionRanges:!0,signatures:!0},gameVersion:"Auto",language:"Default",permissionLevel:2,plugins:[],mcmetaSummaryOverrides:{}},format:{blockStateBracketSpacing:{inside:0},blockStateCommaSpacing:{before:0,after:1},blockStateEqualSpacing:{before:0,after:0},blockStateTrailingComma:!1,eol:"auto",nbtArrayBracketSpacing:{inside:0},nbtArrayCommaSpacing:{before:0,after:1},nbtArraySemicolonSpacing:{after:1},nbtArrayTrailingComma:!1,nbtByteSuffix:"b",nbtCompoundBracketSpacing:{inside:0},nbtCompoundColonSpacing:{before:0,after:1},nbtCompoundCommaSpacing:{before:0,after:1},nbtCompoundTrailingComma:!1,nbtDoubleOmitSuffix:!1,nbtDoubleSuffix:"d",nbtFloatSuffix:"f",nbtListBracketSpacing:{inside:0},nbtListCommaSpacing:{before:0,after:1},nbtListTrailingComma:!1,nbtLongSuffix:"L",nbtShortSuffix:"s",selectorBracketSpacing:{inside:0},selectorCommaSpacing:{before:0,after:1},selectorEqualSpacing:{before:0,after:0},selectorTrailingComma:!1,timeOmitTickUnit:!1},lint:{blockStateSortKeys:null,nbtCompoundSortKeys:null,selectorSortKeys:null,commandStringQuote:null,nbtKeyQuote:null,nbtPathQuote:null,nbtStringQuote:null,selectorKeyQuote:null,idOmitDefaultNamespace:null,nameOfNbtKey:null,nameOfObjective:null,nameOfScoreHolder:null,nameOfTag:null,nameOfTeam:null,nbtArrayLengthCheck:!0,nbtBoolean:null,nbtListLengthCheck:null,nbtTypeCheck:"loosely",undeclaredSymbol:[{if:[{category:Gi,namespace:"minecraft"},{category:[...hs,"bossbar","objective","team"]}],then:{report:"warning"}},{then:{declare:"block"}}]},snippet:{executeIfScoreSet:"execute if score ${1:score_holder} ${2:objective} = ${1:score_holder} ${2:objective} $0",summonAec:'summon minecraft:area_effect_cloud ~ ~ ~ {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["${1:tag}"]}'}},eo,ms=class{constructor(e,r=Dm){H(this,"project");H(this,"defaultConfig");E(this,eo,void 0);this.project=e,this.defaultConfig=r,L(this,eo,new e.externals.event.EventEmitter);let n=async({uri:i})=>{ms.isConfigFile(i)&&this.emit("changed",{config:await this.load()})};e.on("fileCreated",n),e.on("fileModified",n),e.on("fileDeleted",n)}on(e,r){return g(this,eo).on(e,r),this}once(e,r){return g(this,eo).once(e,r),this}emit(e,...r){return g(this,eo).emit(e,...r)}async load(){let e=this.defaultConfig;for(let r of ms.ConfigFileNames){let n=this.project.projectRoot+r;try{e=JSON.parse(ir(await this.project.externals.fs.readFile(n)))}catch(i){if(this.project.externals.error.isKind(i,"ENOENT"))continue;this.emit("error",{error:i,uri:n})}break}return ms.merge(this.defaultConfig,e)}static isConfigFile(e){return ms.ConfigFileNames.some(r=>e.endsWith(`/${r}`))}static merge(e,...r){let n=(0,Jw.default)()(e);for(let i of r)for(let o of["env","format","lint","snippet"])n[o]={...n[o],...i[o]};return n}},to=ms;eo=new WeakMap,H(to,"ConfigFileNames",Object.freeze(["spyglass.json",".spyglassrc.json"]));var Nm=Symbol("IsAsyncBinder"),ti=Object.freeze({create(t){return t},is(t){return!t[Nm]}}),ol=Object.freeze({create(t){return Object.assign(t,{[Nm]:!0})},is(t){return t[Nm]}});var sl={};yr(sl,{any:()=>KR,attempt:()=>Pm,dispatchSync:()=>JR,fallback:()=>ZR,noop:()=>GR,registerBinders:()=>YR,resourceLocation:()=>Xw,symbol:()=>Qw});function Ct(t,e,r,n){Yw(t,e,r,n,[])}function Yw(t,e,r,n,i){if(r(t,i)&&n(t,i),!(!t.children||!e(t,i)))for(let o of t.children??[])i.unshift(t),Yw(o,e,r,n,i),i.shift()}function Pm(t,e,r){let n={...r,err:new ut,symbols:r.symbols.clone()},i=()=>{Qe.undoChanges(e);let o=n.err.errors.map(s=>s.range.end-s.range.start).reduce((s,a)=>s+a,0);return{errorAmount:n.err.errors.length,totalErrorSpan:o,updateNodeAndCtx:()=>{r.err.absorb(n.err),Qe.redoChanges(e),n.symbols.applyDelayedEdits()}}};return ti.is(t)?(t(e,n),i()):(async()=>(await t(e,n),i()))()}function KR(t){if(t.length===0)throw new Error("Expected at least one binder");let e=(r,n)=>r.errorAmount-n.errorAmount||r.totalErrorSpan-n.totalErrorSpan;return t.every(ti.is)?ti.create((r,n)=>{t.map(o=>Pm(o,r,n)).sort(e)[0].updateNodeAndCtx()}):ol.create(async(r,n)=>{(await Promise.all(t.map(o=>Pm(o,r,n)))).sort(e)[0].updateNodeAndCtx()})}var GR=ti.create(()=>{}),ZR=ol.create(async(t,e)=>{let r=[];Ct(t,n=>!e.meta.hasBinder(n.type),n=>e.meta.hasBinder(n.type),n=>{let o=e.meta.getBinder(n.type)(n,e);o instanceof Promise&&r.push(o)}),await Promise.all(r)}),JR=ti.create((t,e)=>{for(let r of t.children??[])e.meta.hasBinder(r.type)&&e.meta.getBinder(r.type)(r,e)}),Xw=ti.create((t,e)=>{let r=U.toString(t,"full"),n=q.lengthen(t.options.namespacePathSep==="."?r.replace(/\./g,q.NamespacePathSep):r);if(t.options.category&&e.symbols.query(e.doc,t.isTag?`tag/${t.options.category}`:t.options.category,n).enter({usage:{type:t.options.usageType,node:t,accessType:t.options.accessType}}),t.options.pool&&!t.options.allowUnknown){t.options.pool.includes(n)||e.err.report(y("expected",t.options.pool),t,3);return}}),Qw=ti.create((t,e)=>{if(t.value){let r=t.options.parentPath?[...t.options.parentPath,t.value]:[t.value];e.symbols.query(e.doc,t.options.category,...r).enter({usage:{type:t.options.usageType,node:t,accessType:t.options.accessType}})}});function YR(t){t.registerBinder("resource_location",Xw),t.registerBinder("symbol",Qw)}var tt={};yr(tt,{any:()=>XR,attempt:()=>ex,dispatchSync:()=>tE,fallback:()=>eE,noop:()=>QR,registerCheckers:()=>rE,resourceLocation:()=>tx,symbol:()=>rx});function ex(t,e,r){let n={...r,err:new ut,symbols:r.symbols.clone()};t(e,n),Qe.undoChanges(e);let i=n.err.errors.map(o=>o.range.end-o.range.start).reduce((o,s)=>o+s,0);return{errorAmount:n.err.errors.length,totalErrorSpan:i,updateNodeAndCtx:()=>{r.err.absorb(n.err),Qe.redoChanges(e),n.symbols.applyDelayedEdits()}}}function XR(t){if(t.length===0)throw new Error("Expected at least one checker");return(e,r)=>{t.map(i=>ex(i,e,r)).sort((i,o)=>i.errorAmount-o.errorAmount||i.totalErrorSpan-o.totalErrorSpan)[0].updateNodeAndCtx()}}var QR=()=>{},eE=async(t,e)=>{let r=[];Ct(t,n=>!e.meta.hasChecker(n.type),n=>e.meta.hasChecker(n.type),n=>{let o=e.meta.getChecker(n.type)(n,e);o instanceof Promise&&r.push(o)}),await Promise.all(r)},tE=(t,e)=>{for(let r of t.children??[])e.meta.hasChecker(r.type)&&e.meta.getChecker(r.type)(r,e)},tx=(t,e)=>{},rx=(t,e)=>{};function rE(t){t.registerChecker("resource_location",tx),t.registerChecker("symbol",rx)}var ht;(function(t){t.NamedColors=new Map([["aqua",5636095],["black",0],["blue",5592575],["dark_aqua",43690],["dark_blue",170],["dark_gray",5592405],["dark_green",43520],["dark_purple",11141290],["dark_red",11141120],["gold",16755200],["gray",11184810],["green",5635925],["light_purple",16733695],["red",16733525],["white",16777215],["yellow",16777045]]),t.ColorNames=[...t.NamedColors.keys()];function e(s,a,l,c){return[s,a,l,c]}t.fromDecRGBA=e;function r(s,a,l){return e(s,a,l,1)}t.fromDecRGB=r;function n(s,a,l,c){return e(s/255,a/255,l/255,c/255)}t.fromIntRGBA=n;function i(s,a,l){return n(s,a,l,255)}t.fromIntRGB=i;function o(s){if(s<0)return r(1,1,1);let a=s%256;s>>=8;let l=s%256;s>>=8;let c=s%256;return i(c,l,a)}t.fromCompositeInt=o})(ht||(ht={}));var Bt;(function(t){t[t.DecRGBA=0]="DecRGBA",t[t.DecRGB=1]="DecRGB",t[t.IntRGBA=2]="IntRGBA",t[t.IntRGB=3]="IntRGB",t[t.HexRGBA=4]="HexRGBA",t[t.HexRGB=5]="HexRGB",t[t.CompositeInt=6]="CompositeInt"})(Bt||(Bt={}));var xu;(function(t){function e(n,i,o){let s=r(n,i);return{label:s,text:s,range:o}}t.fromColorFormat=e;function r(n,i){let o=s=>parseFloat(s.toFixed(3));switch(n){case Bt.DecRGBA:return i.map(s=>o(s)).join(" ");case Bt.DecRGB:return i.slice(0,3).map(s=>o(s)).join(" ");case Bt.IntRGBA:return i.map(s=>Math.round(s*255)).join(" ");case Bt.IntRGB:return i.slice(0,3).map(s=>Math.round(s*255)).join(" ");case Bt.HexRGBA:return`#${Math.round((i[0]*255<<24)+(i[1]*255<<16)+i[2]*255<<8+i[3]*255).toString(16).padStart(8,"0")}`;case Bt.HexRGB:return`#${Math.round((i[0]*255<<16)+(i[1]*255<<8)+i[2]*255).toString(16).padStart(6,"0")}`;case Bt.CompositeInt:return`${Math.round((i[0]*255<<16)+(i[1]*255<<8)+i[2]*255)}`}}})(xu||(xu={}));var Ie={};yr(Ie,{boolean:()=>nx,comment:()=>ix,error:()=>ox,fallback:()=>nE,literal:()=>sx,number:()=>Su,registerColorizers:()=>iE,resourceLocation:()=>ax,string:()=>lx,symbol:()=>cx});var Ce;(function(t){function e(n,i,o){return{range:v.get(n),type:i,modifiers:o}}t.create=e;function r(n,i,o,s){let a=[],l=Math.min(i.start,n[0]?.range.start??1/0);for(let c of n)c.range.start>l&&a.push(t.create(v.create(l,c.range.start),o,s)),a.push(c),l=c.range.end;return l{let r=[];return Ct(t,n=>!e.meta.hasColorizer(n.type)&&(!e.range||v.intersects(n.range,e.range)),n=>e.meta.hasColorizer(n.type),n=>{let o=e.meta.getColorizer(n.type)(n,e);r.push(...o)}),Object.freeze(r)},nx=t=>[Ce.create(t,"literal")],ix=t=>[Ce.create(t,"comment")],ox=t=>[],sx=t=>[Ce.create(t,t.options.colorTokenType??"literal")],Su=t=>[Ce.create(t,"number")],ax=(t,e)=>{let r;switch(t.options.category){case"function":case"tag/function":r="function";break;default:r="resourceLocation";break}return[Ce.create(t,r)]},lx=(t,e)=>{if(t.children){let n=e.meta.getColorizer(t.children[0].type)(t.children[0],e);return Ce.fillGap(n,t.range,t.options.colorTokenType??"string")}else return[Ce.create(t,t.options.colorTokenType??"string")]},cx=t=>[Ce.create(t,"variable")];function iE(t){t.registerColorizer("boolean",nx),t.registerColorizer("comment",ix),t.registerColorizer("error",ox),t.registerColorizer("float",Su),t.registerColorizer("integer",Su),t.registerColorizer("long",Su),t.registerColorizer("literal",sx),t.registerColorizer("resource_location",ax),t.registerColorizer("string",lx),t.registerColorizer("symbol",cx)}var re={};yr(re,{boolean:()=>ux,dispatch:()=>Lm,fallback:()=>oE,file:()=>sE,literal:()=>hx,noop:()=>ll,record:()=>aE,registerCompleters:()=>lE,resourceLocation:()=>dx,string:()=>px,symbol:()=>mx});var fx=Br(tu(),1);var pe;(function(t){function e(i,o,s){let a=s?.insertText===void 0&&r(i);return{...s,label:i,range:v.get(o),...a?{insertText:n(i)}:{}}}t.create=e;function r(i){return/[\\$}]/.test(i)}t.needsEscape=r;function n(i){return i.replace(/([\\$}])/g,"\\$1")}t.escape=n})(pe||(pe={}));var xn,ro,al=class{constructor(){E(this,xn,"");E(this,ro,1)}literal(e){return L(this,xn,g(this,xn)+pe.escape(e)),this}placeholder(...e){return e.length===0?L(this,xn,g(this,xn)+`\${${g(this,ro)}}`):e.length===1?L(this,xn,g(this,xn)+`\${${g(this,ro)}:${pe.escape(e[0])}}`):L(this,xn,g(this,xn)+`\${${g(this,ro)}|${e.map(r=>r.replace(/([\\$},|])/g,"\\$1")).join(",")}|}`),L(this,ro,g(this,ro)+1),this}exitPlace(){return L(this,xn,g(this,xn)+"$0"),this}build(){return g(this,xn)}if(e,r){return e&&r(this),this}};xn=new WeakMap,ro=new WeakMap;var Lm=(t,e)=>{let r=Ke.findShallowestChild({node:t,needle:e.offset,endInclusive:!0,predicate:n=>e.meta.hasCompleter(n.type)});return r?e.meta.getCompleter(r.type)(r,e):[]},oE=Lm,ux=(t,e)=>[pe.create("false",t,{kind:21}),pe.create("true",t,{kind:21})],sE=(t,e)=>e.meta.getCompleterForLanguageID(e.doc.languageId)(t.children[0],e),hx=t=>{let e=new Map([["enum",13],["enumMember",20],["function",3],["keyword",14],["literal",14],["number",21],["operator",24],["property",10],["resourceLocation",17],["variable",6]]).get(t.options.colorTokenType??"keyword")??14;return t.options.pool.map(r=>pe.create(r,t,{kind:e}))??[]},ll=()=>[];function aE(t){return(e,r)=>{if(!v.contains(v.translate(e,1,-1),r.offset,!0))return[];let n=h=>t.key(e,h,r,h?.key??r.offset,!1,!1,o),i=h=>t.key(e,h,r,h??r.offset,!0,l||!!h?.end,o),o=e.children.filter(h=>!!h.key).map(h=>h.key),s=(0,fx.default)(e.children,r.offset,(h,d)=>h.end?v.compareOffset(v.translate(h,0,-1),d,!0):v.compareOffset(h.range,d,!0)),a=s>=0?e.children[s]:void 0,l=!!e.children.find(h=>h.range.start>r.offset);if(!a)return i(void 0);let{key:c,sep:f,value:u}=a;return!c&&!f&&!u?i(void 0):c&&v.contains(c,r.offset,!0)||f&&r.offset<=f.start||u&&r.offset=f.end||c&&r.offset>c.range.end?t.value(e,a,r):[]}}var dx=(t,e)=>{let r=gs.destruct(e.config.lint.idOmitDefaultNamespace),n=!t.options.isPredicate&&t.namespace==="",i=t.options.isPredicate||r?.ruleValue!==!0,o=!t.options.isPredicate&&r?.ruleValue!==!1,s=c=>a(Object.keys(e.symbols.getVisibleSymbols(c,e.doc.uri))),a=c=>{let f=`${q.DefaultNamespace}${q.NamespacePathSep}`,u=[],h=[];for(let p of c)p.startsWith(f)?u.push(p):h.push(p);let d=[...h,...i?u:[],...o?u.map(p=>p.slice(f.length)):[],...n?u.map(p=>p.slice(q.DefaultNamespace.length)):[]];return t.options.namespacePathSep==="."?d.map(p=>p.replace(q.NamespacePathSep,".")):d};return(t.options.pool?a(t.options.pool):[...s(t.options.category),...t.options.allowTag?s(`tag/${t.options.category}`).map(c=>`${q.TagPrefix}${c}`):[]]).map(c=>pe.create(c,t,{kind:3}))},px=(t,e)=>t.children?.length?Lm(t.children[0],e):t.options.quotes&&t.value===""?t.options.quotes.map(r=>pe.create(`${r}${r}`,t,{insertText:`${r}$1${r}`,kind:12})):[],mx=(t,e)=>Object.keys(e.symbols.query(e.doc,t.options.category,...t.options.parentPath??[]).visibleMembers).map(r=>pe.create(r,t,{kind:6}));function lE(t){t.registerCompleter("boolean",ux),t.registerCompleter("comment",ll),t.registerCompleter("float",ll),t.registerCompleter("integer",ll),t.registerCompleter("long",ll),t.registerCompleter("literal",hx),t.registerCompleter("resource_location",dx),t.registerCompleter("string",px),t.registerCompleter("symbol",mx)}var Xr={};yr(Xr,{boolean:()=>yx,comment:()=>bx,fallback:()=>cE,file:()=>gx,float:()=>kx,integer:()=>vx,literal:()=>wx,long:()=>xx,registerFormatters:()=>fE,resourceLocation:()=>Sx,string:()=>_x});var cE=t=>{throw new Error(`No formatter registered for type ${t.type}`)},gx=(t,e)=>t.children.map(r=>e.meta.getFormatter(r.type)(r,e)).join(""),yx=t=>t.value?"true":"false",bx=t=>"#"+t.comment,kx=t=>t.value.toString(),vx=t=>t.value.toFixed(),wx=t=>t.value,xx=t=>t.value.toString(),Sx=t=>U.toString(t,"origin",!0),_x=t=>`"${t.value}"`;function fE(t){t.registerFormatter("file",gx),t.registerFormatter("boolean",yx),t.registerFormatter("comment",bx),t.registerFormatter("float",kx),t.registerFormatter("integer",vx),t.registerFormatter("long",xx),t.registerFormatter("literal",wx),t.registerFormatter("resource_location",Sx),t.registerFormatter("string",_x)}function Im(t,e=0){let r=t.indentLevel+e;return t.insertSpaces?" ".repeat(r*t.tabSize):" ".repeat(r)}function Bm(t,e=1){return{...t,indentLevel:t.indentLevel+e,indent(r){return Im(this,r)}}}var ni={};yr(ni,{configValidator:()=>ri,nameConvention:()=>cl,noop:()=>uE,quote:()=>hE,registerLinters:()=>dE});var Cx=(t,e)=>{};var uE=()=>{};function cl(t){return(e,r)=>{if(typeof e[t]!="string")throw new Error(`Trying to access property "${t}" of node type "${e.type}"`);let n=e[t];try{let i=new RegExp(r.ruleValue);n.match(i)||r.err.lint(y("linter.name-convention.illegal",P(n),P(r.ruleValue)),e)}catch(i){r.logger.error(`[nameConvention linter] The value \u201C${r.ruleValue}\u201D set for rule \u201C${r.ruleName}\u201D is not a valid regular expression.`,i)}}}var hE=(t,e)=>{let r=e.ruleValue,n=t.options.unquotable?[...t.value].some(l=>!jm(l,t.options.unquotable)):!0,i=r.always||n,o=r.always===!1&&!n,s=e.src.slice(t.range.start,t.range.start+1),a=!!t.options.quotes?.includes(s);i&&a&&(r.avoidEscape,r.type)},ri;(function(t){function e(o){return`https://spyglassmc.com/user/lint/${o}`}function r(o,s){return`[Invalid Linter Config] [${o}] ${y("linter-config-validator.wrapper",s,e(o))}`}function n(o,s,a){if(typeof s!="string")return a.error(r(o,y("linter-config-validator.name-convention.type"))),!1;try{new RegExp(s)}catch(l){return a.error(r(o,y("")),l),!1}return!0}t.nameConvention=n;function i(o,s,a){return il.is(s)}t.symbolLinterConfig=i})(ri||(ri={}));function dE(t){t.registerLinter("nameOfObjective",{configValidator:ri.nameConvention,linter:cl("value"),nodePredicate:e=>e.symbol&&e.symbol.category==="objective"}),t.registerLinter("nameOfScoreHolder",{configValidator:ri.nameConvention,linter:cl("value"),nodePredicate:e=>e.symbol&&e.symbol.category==="score_holder"}),t.registerLinter("nameOfTag",{configValidator:ri.nameConvention,linter:cl("value"),nodePredicate:e=>e.symbol&&e.symbol.category==="tag"}),t.registerLinter("nameOfTeam",{configValidator:ri.nameConvention,linter:cl("value"),nodePredicate:e=>e.symbol&&e.symbol.category==="team"}),t.registerLinter("undeclaredSymbol",{configValidator:ri.symbolLinterConfig,linter:Cx,nodePredicate:e=>e.symbol&&!Cm.includes(e.symbol.category)})}var ut=class{errors=[];constructor(){}report(e,r,n=3,i){this.errors.push(lu.create(e,v.get(r),n,i))}dump(){let e=Object.freeze(this.errors);return this.errors=[],e}absorb(e){this.errors.push(...e.errors)}},ys=class extends ut{ruleName;ruleSeverity;constructor(e,r){super(),this.ruleName=e,this.ruleSeverity=r}lint(e,r,n,i){return this.report(y("linter.diagnostic-message-wrapper",e,this.ruleName),r,i??this.ruleSeverity,n)}static fromErrorReporter(e,r,n){let i=new ys(r,n);return i.errors=e.errors,i}};var fl;(function(t){function e(r){return{fs:r.fs,logger:r.logger,meta:r.meta,profilers:r.profilers,roots:r.roots,project:r.ctx}}t.create=e})(fl||(fl={}));var _u;(function(t){function e(r,n){return{...fl.create(r),config:r.config,doc:n.doc,err:n.err??new ut}}t.create=e})(_u||(_u={}));var _r;(function(t){function e(r,n){return{...fl.create(r),config:r.config,doc:n.doc,src:n.src??new qi(n.doc.getText()),symbols:r.symbols}}t.create=e})(_r||(_r={}));var $m;(function(t){function e(r,n){return{..._r.create(r,n),range:n.range}}t.create=e})($m||($m={}));var zm;(function(t){function e(r,n){return{..._r.create(r,n),offset:n.offset}}t.create=e})(zm||(zm={}));var Cu;(function(t){function e(r,n){return{..._r.create(r,n),err:n.err??new ut,ensureBindingStarted:r.ensureBindingStarted?.bind(r)}}t.create=e})(Cu||(Cu={}));var Au;(function(t){function e(r,n){return{..._r.create(r,n),err:n.err??new ut,ensureBindingStarted:r.ensureBindingStarted?.bind(r)}}t.create=e})(Au||(Au={}));var Tu;(function(t){function e(r,n){return{..._r.create(r,n),err:n.err,ruleName:n.ruleName,ruleValue:n.ruleValue}}t.create=e})(Tu||(Tu={}));var Ou;(function(t){function e(r,n){return{..._r.create(r,n),...n,indentLevel:0,indent(i){return Im(this,i)}}}t.create=e})(Ou||(Ou={}));var Ru;(function(t){function e(r,n){return $m.create(r,n)}t.create=e})(Ru||(Ru={}));var Eu;(function(t){function e(r,n){return{..._r.create(r,n),offset:n.offset,triggerCharacter:n.triggerCharacter}}t.create=e})(Eu||(Eu={}));var Mu;(function(t){function e(r,n){return zm.create(r,n)}t.create=e})(Mu||(Mu={}));var Du;(function(t){function e(r){return{...fl.create(r),symbols:r.symbols}}t.create=e})(Du||(Du={}));var Nu;(function(t){function e(r){return r.startsWith("@")}t.is=e})(Nu||(Nu={}));var ii,Pu=class{constructor(e,r,n){H(this,"cacheRoot");H(this,"externals");H(this,"logger");E(this,ii,new Map);this.cacheRoot=e,this.externals=r,this.logger=n}async download(e,r={}){let{id:n,cache:i,uri:o,options:s,transformer:a,ttl:l}=e;if(l&&g(this,ii).has(o)){let{buffer:h,time:d}=g(this,ii).get(o);if(d<=performance.now()+l)return this.logger.info(`[Downloader] [${n}] Skipped thanks to valid cache in memory`),await a(h);g(this,ii).delete(o)}let c,f,u;if(i){let{checksumJob:h,checksumExtension:d}=i;r.cacheUri=f=new It(`downloader/${n}`,this.cacheRoot).toString(),u=new It(`downloader/${n}${d}`,this.cacheRoot).toString();try{r.checksum=c=await this.download({...h,id:n+d});try{let p=ir(await Y.readFile(this.externals,u)).slice(0,-1);if(c===p)try{let b=await Y.readFile(this.externals,f);l&&g(this,ii).set(o,{buffer:b,time:performance.now()});let m=i.deserializer??(S=>S),k=await a(m(b));return this.logger.info(`[Downloader] [${n}] Skipped downloading thanks to cache ${p}`),k}catch(b){if(this.logger.error(`[Downloader] [${n}] Loading cached file \u201C${f}\u201D`,b),this.externals.error.isKind(b,"ENOENT"))try{await this.externals.fs.unlink(u)}catch(m){this.logger.error(`[Downloader] [${n}] Removing invalid cache checksum \u201C${u}\u201D`,m)}}}catch(p){this.externals.error.isKind(p,"ENOENT")||this.logger.error(`[Downloader] [${n}] Loading cache checksum \u201C${u}\u201D`,p)}}catch(p){this.logger.error(`[Downloader] [${n}] Fetching latest checksum \u201C${h.uri}\u201D`,p)}}try{let h=await this.externals.downloader.get(o,s);if(l&&g(this,ii).set(o,{buffer:h,time:performance.now()}),i&&f&&u){if(c)try{await Y.writeFile(this.externals,u,`${c} -`)}catch(d){this.logger.error(`[Downloader] [${n}] Saving cache checksum \u201C${u}\u201D`,d)}try{let d=i.serializer??(p=>p);await Y.writeFile(this.externals,f,d(h))}catch(d){this.logger.error(`[Downloader] [${n}] Caching file \u201C${f}\u201D`,d)}}return this.logger.info(`[Downloader] [${n}] Downloaded from \u201C${o}\u201D`),await a(h)}catch(h){if(this.logger.error(`[Downloader] [${n}] Downloading \u201C${o}\u201D`,h),i&&f)try{let d=await Y.readFile(this.externals,f),p=i.deserializer??(m=>m),b=await a(p(d));return this.logger.warn(`[Downloader] [${n}] Fell back to cached file \u201C${f}\u201D`),b}catch(d){this.logger.error(`[Downloader] [${n}] Fallback: loading cached file \u201C${f}\u201D`,d)}}}};ii=new WeakMap;var ul;(function(t){function e(r,n){let i=Y.ensureEndingSlash(new It("virtual-uris/",n).toString());return new Fm(r,i)}t.create=e})(ul||(ul={}));var Fm=class{externals;virtualUrisRoot;supporters=new Map;map=new au;constructor(e,r){this.externals=e,this.virtualUrisRoot=r}register(e,r,n=!1){if(!n&&this.supporters.has(e))throw new Error(`The protocol \u201C${e}\u201D is already associated with another supporter.`);this.supporters.set(e,r)}unregister(e){this.supporters.delete(e)}getSupportedProtocol(e){let r=new It(e).protocol;if(!this.supporters.has(r))throw new Error(`The protocol \u201C${r}\u201D is unsupported.`);return r}async hash(e){let r=this.getSupportedProtocol(e);return this.supporters.get(r).hash(e)}readFile(e){let r=this.getSupportedProtocol(e);return this.supporters.get(r).readFile(e)}*listFiles(){for(let e of this.supporters.values())yield*e.listFiles()}*listRoots(){for(let e of this.supporters.values())yield*e.listRoots()}async mapToDisk(e){if(Y.isFileUri(e))return e;if(this.virtualUrisRoot)try{let r=this.map.getKey(e);if(r===void 0){r=`${this.virtualUrisRoot}${await this.externals.crypto.getSha1(e)}/${Y.basename(e)}`;let n=await this.readFile(e);await Y.writeFile(this.externals,r,n,292),this.map.set(r,e)}return r}catch{}}mapFromDisk(e){return this.virtualUrisRoot?this.map.get(e)??e:e}},bs=class{externals;roots;files;protocol="file:";constructor(e,r,n){this.externals=e,this.roots=r,this.files=n}async hash(e){return Vm(this.externals,e)}readFile(e){return this.externals.fs.readFile(e)}*listFiles(){for(let e of this.files.values())yield*e}listRoots(){return this.roots}async mapToDisk(e){return e}static async create(e,r,n){let i=[],o=new Map;for(let{uri:s}of e)try{Y.isFileUri(s)&&(await r.fs.stat(s)).isDirectory()&&(s=Y.ensureEndingSlash(s),i.push(s),o.set(s,await r.fs.getAllFiles(s)))}catch(a){n.error(`[FileUriSupporter#create] Bad dependency \u201C${s}\u201D`,a)}return new bs(r,i,o)}},jt=class{externals;entries;protocol=jt.Protocol;constructor(e,r){this.externals=e,this.entries=r}async hash(e){let{archiveUri:r,pathInArchive:n}=jt.decodeUri(new It(e));return n?this.externals.crypto.getSha1(this.getDataInArchive(r,n)):Vm(this.externals,r)}async readFile(e){let{archiveUri:r,pathInArchive:n}=jt.decodeUri(new It(e));return this.getDataInArchive(r,n)}getDataInArchive(e,r){let n=this.entries.get(e);if(!n)throw new Error(`Archive \u201C${e}\u201D has not been loaded into the memory`);let i=n.get(r);if(!i)throw new Error(`Path \u201C${r}\u201D does not exist in archive \u201C${e}\u201D`);if(i.type!=="file")throw new Error(`Path \u201C${r}\u201D in archive \u201C${e}\u201D is not a file`);return i.data}*listFiles(){for(let[e,r]of this.entries.entries())for(let n of r.values())yield jt.getUri(e,n.path)}*listRoots(){for(let e of this.entries.keys())yield jt.getUri(e)}static getUri(e,r=""){return`${jt.Protocol}${encodeURIComponent(e)}?path=${encodeURIComponent(r.replace(/\\/g,"/"))}`}static decodeUri(e){if(e.protocol!==jt.Protocol)throw new Error(`Expected protocol \u201C${jt.Protocol}\u201D in \u201C${e}\u201D`);let r=e.searchParams.get("path");if(!r)throw new Error(`Missing path in archive uri \u201C${e.toString()}\u201D`);return{archiveUri:decodeURIComponent(e.pathname),pathInArchive:r.charAt(0)==="/"?r.slice(1):r}}static async create(e,r,n,i){let o=new Map;for(let{uri:s,info:a}of e)try{if(s.startsWith("file:")&&jt.SupportedArchiveExtnames.some(l=>s.endsWith(l))&&(await r.fs.stat(s)).isFile()){let l=jt.getUri(s),c=i[l];if(c!==void 0){let u=await Vm(r,s);if(c===u){n.info(`[SpyglassUriSupporter#create] Skipped decompressing \u201C${s}\u201D thanks to cache ${u}`);continue}}let f=await r.archive.decompressBall(await r.fs.readFile(s),{stripLevel:typeof a?.startDepth=="number"?a.startDepth:0});o.set(s,new Map(f.map(u=>[u.path.replace(/\\/g,"/"),u])))}}catch(l){n.error(`[SpyglassUriSupporter#create] Bad dependency \u201C${s}\u201D`,l)}return new jt(r,o)}},no=jt;H(no,"Protocol","archive:"),H(no,"SupportedArchiveExtnames",[".tar",".tar.bz2",".tar.gz",".zip"]);async function Vm(t,e){return t.crypto.getSha1(await t.fs.readFile(e))}var hl;(function(t){function e(r,n){return{range:v.get(r),markdown:n}}t.create=e})(hl||(hl={}));var $t,ks,vs,ws,xs,dl,Ss,pl,ml,_s,gl,yl,bl,Cs,Lu=class{constructor(){E(this,$t,new Map);E(this,ks,new Map);E(this,vs,new Map);E(this,ws,new Map);E(this,xs,new Map);E(this,dl,new Map);E(this,Ss,new Map);E(this,pl,new Set);E(this,ml,new Map);E(this,_s,new Map);E(this,gl,new Set);E(this,yl,new Map);E(this,bl,new Set);E(this,Cs,()=>0);sl.registerBinders(this),tt.registerCheckers(this),Ie.registerColorizers(this),re.registerCompleters(this),Xr.registerFormatters(this),ni.registerLinters(this)}registerLanguage(e,r){g(this,$t).set(e,r)}getLanguages(){return Array.from(g(this,$t).keys())}isSupportedLanguage(e){return g(this,$t).has(e)}getSupportedFileExtensions(){return[...g(this,$t).values()].flatMap(e=>e.extensions)}getTriggerCharacters(){return Array.from(g(this,$t).values()).flatMap(e=>e.triggerCharacters??[])}getLanguageID(e){for(let[r,{extensions:n}]of g(this,$t))if(n.includes(e))return r}hasBinder(e){return g(this,ks).has(e)}getBinder(e){return g(this,ks).get(e)??sl.fallback}registerBinder(e,r){g(this,ks).set(e,r)}hasChecker(e){return g(this,vs).has(e)}getChecker(e){return g(this,vs).get(e)??tt.fallback}registerChecker(e,r){g(this,vs).set(e,r)}hasColorizer(e){return g(this,ws).has(e)}getColorizer(e){return g(this,ws).get(e)??Ie.fallback}registerColorizer(e,r){g(this,ws).set(e,r)}hasCompleter(e){return g(this,xs).has(e)}getCompleter(e){return g(this,xs).get(e)??re.fallback}registerCompleter(e,r){g(this,xs).set(e,r)}shouldComplete(e,r){let n=g(this,$t).get(e);return!r||!!n?.triggerCharacters?.includes(r)}getCompleterForLanguageID(e){return g(this,$t).get(e)?.completer??re.fallback}getDependencyProvider(e){return g(this,dl).get(e)}registerDependencyProvider(e,r){g(this,dl).set(e,r)}hasFormatter(e){return g(this,Ss).has(e)}getFormatter(e){return g(this,Ss).get(e)??Xr.fallback}registerFormatter(e,r){g(this,Ss).set(e,r)}registerInlayHintProvider(e){g(this,pl).add(e)}get inlayHintProviders(){return g(this,pl)}getLinter(e){return g(this,ml).get(e)??{configValidator:()=>!1,linter:ni.noop,nodePredicate:()=>!1}}registerLinter(e,r){g(this,ml).set(e,r)}hasParser(e){return g(this,_s).has(e)}getParser(e){let r=g(this,_s).get(e);if(!r)throw new Error(`There is no parser '${e}'`);return r}getParserLazily(e){return Zn.create(()=>this.getParser(e))}registerParser(e,r){g(this,_s).set(e,r)}getParserForLanguageId(e){if(g(this,$t).has(e))return g(this,$t).get(e).parser;throw new Error(`There is no parser registered for language ID '${e}'`)}registerSignatureHelpProvider(e){g(this,gl).add(e)}get signatureHelpProviders(){return g(this,gl)}registerSymbolRegistrar(e,r){g(this,yl).set(e,r)}get symbolRegistrars(){return g(this,yl)}registerUriBinder(e){g(this,bl).add(e)}get uriBinders(){return g(this,bl)}setUriSorter(e){let r=g(this,Cs);L(this,Cs,(n,i)=>e(n,i,r))}get uriSorter(){return g(this,Cs)}};$t=new WeakMap,ks=new WeakMap,vs=new WeakMap,ws=new WeakMap,xs=new WeakMap,dl=new WeakMap,Ss=new WeakMap,pl=new WeakMap,ml=new WeakMap,_s=new WeakMap,gl=new WeakMap,yl=new WeakMap,bl=new WeakMap,Cs=new WeakMap;var kl,vl,io,As,Cr,Ts,Os,Um=class{constructor(e,r,n){H(this,"id");H(this,"logger");H(this,"n");E(this,kl,!1);E(this,vl,void 0);E(this,io,void 0);E(this,As,0);E(this,Cr,[]);E(this,Ts,1/0);E(this,Os,0);this.id=e,this.logger=r,this.n=n,L(this,vl,L(this,io,performance.now()))}task(e){if(g(this,kl))throw new Error("The profiler has already been finalized");Qy(this,As)._++;let r=performance.now(),n=r-g(this,io);return L(this,io,r),L(this,Ts,Math.min(g(this,Ts),n)),L(this,Os,Math.max(g(this,Os),n)),g(this,Cr).push([e,n]),g(this,Cr).sort((i,o)=>o[1]-i[1]),g(this,Cr).length>this.n&&L(this,Cr,g(this,Cr).slice(0,-1)),this}finalize(){L(this,kl,!0);let e=g(this,Cr).reduce((n,[i])=>Math.max(n,i.length),0),r=g(this,io)-g(this,vl);this.logger.info(`[Profiler: ${this.id}] == Summary ==`),this.logger.info(`[Profiler: ${this.id}] Total tasks: ${g(this,As)} done in ${r} ms`),this.logger.info(`[Profiler: ${this.id}] Min/Avg/Max: ${g(this,Ts)} / ${r/g(this,As)} / ${g(this,Os)} ms`),this.logger.info(`[Profiler: ${this.id}] Top ${Math.min(this.n,g(this,Cr).length)} task(s):`);for(let[n,i]of g(this,Cr))this.logger.info(`[Profiler: ${this.id}] ${n}${" ".repeat(e-n.length)} - ${i} ms (${i/r*100}%)`)}};kl=new WeakMap,vl=new WeakMap,io=new WeakMap,As=new WeakMap,Cr=new WeakMap,Ts=new WeakMap,Os=new WeakMap;var Ax="Total",wl,xl,oo,Rs,oi,Hm=class{constructor(e,r){H(this,"id");H(this,"logger");E(this,wl,!1);E(this,xl,void 0);E(this,oo,void 0);E(this,Rs,[]);E(this,oi,0);this.id=e,this.logger=r,L(this,xl,L(this,oo,performance.now()))}task(e){if(g(this,wl))throw new Error("The profiler is finalized.");let r=performance.now(),n=r-g(this,oo);return L(this,oo,r),g(this,Rs).push([e,n]),L(this,oi,Math.max(g(this,oi),e.length)),this.logger.info(`[Profiler: ${this.id}] Done: ${e} in ${n} ms`),this}finalize(){L(this,wl,!0),g(this,Rs).push([Ax,g(this,oo)-g(this,xl)]),L(this,oi,Math.max(g(this,oi),Ax.length)),this.logger.info(`[Profiler: ${this.id}] == Summary ==`);for(let[e,r]of g(this,Rs))this.logger.info(`[Profiler: ${this.id}] ${e}${" ".repeat(g(this,oi)-e.length)} - ${r} ms`)}};wl=new WeakMap,xl=new WeakMap,oo=new WeakMap,Rs=new WeakMap,oi=new WeakMap;var Wm=class{task(){return this}finalize(){}},Sl,qm=class{constructor(e,r){H(this,"logger");E(this,Sl,void 0);this.logger=e,L(this,Sl,new Set(r))}get(e,r="total",n){if(g(this,Sl).has(e))switch(r){case"top-n":return new Um(e,this.logger,n);case"total":return new Hm(e,this.logger);default:return nr.assertNever(r)}else return new Wm}static noop(){return new qm(ls.noop(),[])}},si=qm;Sl=new WeakMap;var Iu=Br(mu(),1);var Km=function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(i<3?s(o):i>3?s(e,r,o):s(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},pE=6e5,ai,_l,li,Qr,Es,Sn,ao,Ms,Cl,Al,_n,Ds,ci,Cn,Tl,lo,Ns,Ps,co,At,fo,so=class{constructor({cacheRoot:e,defaultConfig:r,downloader:n,externals:i,fs:o=ul.create(i,e),initializers:s=[],logger:a=ls.create(),profilers:l=si.noop(),projectRoot:c}){E(this,ai,new Set);E(this,_l,void 0);H(this,"cacheService");E(this,li,new Set);E(this,Qr,new Map);E(this,Es,void 0);E(this,Sn,new Set);E(this,ao,void 0);E(this,Ms,void 0);E(this,Cl,void 0);E(this,Al,void 0);E(this,_n,new Set);E(this,Ds,void 0);E(this,ci,!1);E(this,Cn,!1);H(this,"config");H(this,"downloader");H(this,"externals");H(this,"fs");H(this,"logger");H(this,"meta",new Lu);H(this,"profilers");H(this,"projectRoot");H(this,"symbols");E(this,Tl,void 0);E(this,lo,void 0);E(this,Ns,[]);E(this,Ps,void 0);E(this,co,void 0);E(this,At,new Map);E(this,fo,0);L(this,co,e),L(this,ao,new i.event.EventEmitter),this.externals=i,this.fs=o,L(this,Ms,s),this.logger=a,this.profilers=l,this.projectRoot=c,this.cacheService=new vu(e,this),L(this,Es,new to(this,r)),this.downloader=n??new Pu(e,i,a),this.symbols=new Le({},i.event.EventEmitter),L(this,Ps,{}),this.logger.info(`[Project] [init] cacheRoot = \u201C${e}\u201D`),g(this,Es).on("changed",({config:f})=>{this.config=f,this.logger.info("[Project] [Config] Changed")}).on("error",({error:f,uri:u})=>this.logger.error(`[Project] [Config] Failed loading \u201C${u}\u201D`,f)),this.setInitPromise(),this.setReadyPromise(),L(this,_l,setInterval(()=>this.cacheService.save(),pE)),this.on("documentUpdated",({doc:f,node:u})=>{this.emit("documentErrored",{errors:fs.getErrors(u).map(h=>lu.withPosRange(h,f)),uri:f.uri,version:f.version})}).on("documentRemoved",({uri:f})=>{this.emit("documentErrored",{errors:[],uri:f})}).on("fileCreated",async({uri:f})=>(f.endsWith(so.RootSuffix)&&this.updateRoots(),this.bindUri(f),this.ensureBindingStarted(f))).on("fileModified",async({uri:f})=>{g(this,Sn).delete(f),this.isOnlyWatched(f)&&await this.ensureBindingStarted(f)}).on("fileDeleted",({uri:f})=>{f.endsWith(so.RootSuffix)&&this.updateRoots(),g(this,Sn).delete(f),this.symbols.clear({uri:f}),this.tryClearingCache(f)}).on("ready",()=>{L(this,Cn,!0)})}get isReady(){return g(this,Cn)}get roots(){return g(this,Ns)}get ctx(){return g(this,Ps)}get cacheRoot(){return g(this,co)}updateRoots(){let e=[...g(this,Tl),this.projectRoot],r=new Set(e);for(let n of this.getTrackedFiles())n.endsWith(so.RootSuffix)&&e.some(i=>n.startsWith(i))&&r.add(n.slice(0,1-so.RootSuffix.length));L(this,Ns,[...r].sort((n,i)=>i.length-n.length)),this.emit("rootsUpdated",{roots:g(this,Ns)})}on(e,r){return g(this,ao).on(e,r),this}once(e,r){return g(this,ao).once(e,r),this}emit(e,...r){return g(this,ao).emit(e,...r)}getTrackedFiles(){let e=this.meta.getSupportedFileExtensions();return[...g(this,lo),...g(this,_n)].filter(r=>e.includes(Y.extname(r)??""))}setInitPromise(){let e=async()=>{this.config=await g(this,Es).load()},r=async()=>{let i={cacheRoot:this.cacheRoot,config:this.config,downloader:this.downloader,externals:this.externals,logger:this.logger,meta:this.meta,projectRoot:this.projectRoot},o=await Promise.allSettled(g(this,Ms).map(a=>a(i))),s={};o.forEach(async(a,l)=>{a.status==="rejected"?this.logger.error(`[Project] [callInitializers] [${l}] \u201C${g(this,Ms)[l].name}\u201D`,a.reason):a.value&&(s={...s,...a.value})}),L(this,Ps,s)};L(this,Cl,(async()=>{let i=this.profilers.get("project#init"),{symbols:o}=await this.cacheService.load();this.symbols=new Le(o,this.externals.event.EventEmitter),this.symbols.buildCache(),i.task("Load Cache"),await e(),i.task("Load Config"),await r(),i.task("Initialize").finalize()})())}setReadyPromise(){let e=async()=>{let o=[];for(let s of this.config.env.dependencies)if(Nu.is(s)){let a=this.meta.getDependencyProvider(s);if(a)try{o.push(await a()),this.logger.info(`[Project] [getDependencies] Executed provider \u201C${s}\u201D`)}catch(l){this.logger.error(`[Project] [getDependencies] Bad provider \u201C${s}\u201D`,l)}else this.logger.error(`[Project] [getDependencies] Bad dependency \u201C${s}\u201D: no associated provider`)}else o.push({uri:s});return o},r=async()=>{let o=await e(),s=await bs.create(o,this.externals,this.logger),a=await no.create(o,this.externals,this.logger,this.cacheService.checksums.roots);this.fs.register("file:",s,!0),this.fs.register(no.Protocol,a,!0)},n=()=>new Promise(o=>{g(this,_n).clear(),L(this,ci,!1),L(this,Ds,this.externals.fs.watch(this.projectRoot).once("ready",()=>{L(this,ci,!0),o()}).on("add",s=>{g(this,_n).add(s),g(this,ci)&&this.emit("fileCreated",{uri:s})}).on("change",s=>{g(this,ci)&&this.emit("fileModified",{uri:s})}).on("unlink",s=>{g(this,_n).delete(s),g(this,ci)&&this.emit("fileDeleted",{uri:s})}).on("error",s=>{this.logger.error("[Project] [chokidar]",s)}))}),i=async()=>{await this.init();let o=this.profilers.get("project#ready");await Promise.all([r(),n()]),L(this,lo,new Set(this.fs.listFiles())),L(this,Tl,new Set(this.fs.listRoots())),this.updateRoots(),o.task("List URIs");for(let[u,{checksum:h,registrar:d}]of this.meta.symbolRegistrars){let p=this.cacheService.checksums.symbolRegistrars[u];p===void 0||h!==p?(this.symbols.clear({contributor:`symbol_registrar/${u}`}),this.symbols.contributeAs(`symbol_registrar/${u}`,()=>{d(this.symbols,{logger:this.logger})}),this.emit("symbolRegistrarExecuted",{id:u,checksum:h})):this.logger.info(`[SymbolRegistrar] Skipped \u201C${u}\u201D thanks to cache ${h}`)}o.task("Register Symbols");for(let[u,h]of Object.entries(this.cacheService.errors))this.emit("documentErrored",{errors:h,uri:u});o.task("Pop Errors");let{addedFiles:s,changedFiles:a,removedFiles:l}=await this.cacheService.validate();for(let u of l)this.emit("fileDeleted",{uri:u});o.task("Validate Cache"),s.length>0&&this.bindUri(s),o.task("Bind URIs");let c=[...s,...a].sort(this.meta.uriSorter);o.task("Sort URIs");let f=this.profilers.get("project#ready#bind","top-n",50);for(let u of c)await this.ensureBindingStarted(u),f.task(u);f.finalize(),o.task("Bind Files"),o.finalize(),this.emit("ready",{})};L(this,Cn,!1),L(this,Al,i())}async init(){return await g(this,Cl),this}async ready(){return await g(this,Al),this}async close(){clearInterval(g(this,_l)),await g(this,Ds).close(),await this.cacheService.save()}async restart(){try{await g(this,Ds).close(),g(this,ai).clear(),g(this,Sn).clear(),this.setReadyPromise(),await this.ready()}catch(e){this.logger.error("[Project#reset]",e)}}resetCache(){this.logger.info("[Project#resetCache] Initiated...");for(let r of Object.keys(this.cacheService.errors))this.emit("documentErrored",{errors:[],uri:r});let{symbols:e}=this.cacheService.reset();return this.symbols=new Le(e,this.externals.event.EventEmitter),this.symbols.buildCache(),this.restart()}normalizeUri(e){return this.fs.mapFromDisk(Lw(e))}removeCachedTextDocument(e){let r=g(this,At).get(e);r&&!(r instanceof Promise)&&L(this,fo,g(this,fo)-r.getText().length),g(this,At).delete(e)}async read(e){let r=s=>{let a=Y.extname(s)??".plaintext";return this.meta.getLanguageID(a)??a.slice(1)},n=async s=>{let a=r(s);if(this.meta.isSupportedLanguage(a))try{let l=ir(await this.fs.readFile(s));return Iu.TextDocument.create(s,a,-1,l)}catch(l){this.logger.warn(`[Project] [read] Failed creating TextDocument for \u201C${s}\u201D`,l);return}},i=()=>{let s=g(this,At).keys();for(;g(this,fo)>so.TextDocumentCacheMaxLength;){let a=s.next();if(a.done)throw new Error(`[Project] [read] Cache is too large with length ${g(this,fo)} even though it's empty; make sure to call 'removeCachedTextDocument()' instead of 'this.#textDocumentCache.delete()'`);this.removeCachedTextDocument(a.value)}},o=async s=>{if(g(this,At).has(s)){let a=g(this,At).get(s);return g(this,At).delete(s),g(this,At).set(s,a),a}else{let a=n(s);g(this,At).set(s,a);let l=await a;return g(this,At).get(s)===a&&(l?(g(this,At).set(s,l),L(this,fo,g(this,fo)+l.getText().length),i()):g(this,At).delete(s)),l}};if(e=this.normalizeUri(e),g(this,li).has(e)){let s=g(this,Qr).get(e);if(s)return s.doc;throw new Error(`[Project] [read] Client-managed URI \u201C${e}\u201D does not have a TextDocument in the cache`)}return o(e)}parse(e){let r=_u.create(this,{doc:e}),n=new _e(e.getText());return Tx()(n,r)}async bind(e,r){if(!r.binderErrors)try{g(this,ai).add(e.uri);let n=this.meta.getBinder(r.type),i=Cu.create(this,{doc:e});i.symbols.clear({contributor:"binder",uri:e.uri}),await i.symbols.contributeAsAsync("binder",async()=>{let o=Qe.create(r);await n(o,i),r.binderErrors=i.err.dump()}),g(this,ai).delete(e.uri),g(this,Sn).add(e.uri)}catch(n){this.logger.error(`[Project] [bind] Failed for \u201C${e.uri}\u201D #${e.version}`,n)}}async check(e,r){if(!r.checkerErrors)try{let n=this.meta.getChecker(r.type),i=Au.create(this,{doc:e});i.symbols.clear({contributor:"checker",uri:e.uri}),await i.symbols.contributeAsAsync("checker",async()=>{await n(Qe.create(r),i),r.checkerErrors=i.err.dump(),this.lint(e,r)})}catch(n){this.logger.error(`[Project] [check] Failed for \u201C${e.uri}\u201D #${e.version}`,n)}}lint(e,r){if(!r.linterErrors){r.linterErrors=[];try{for(let[n,i]of Object.entries(this.config.lint)){let o=gs.destruct(i);if(!o)continue;let{ruleSeverity:s,ruleValue:a}=o,{configValidator:l,linter:c,nodePredicate:f}=this.meta.getLinter(n);if(!l(n,a,this.logger))continue;let u=Tu.create(this,{doc:e,err:new ys(n,s),ruleName:n,ruleValue:a});Ct(r,()=>!0,()=>!0,h=>{if(f(h)){let d=Qe.create(h);c(d,u)}}),r.linterErrors.push(...u.err.dump())}}catch(n){this.logger.error(`[Project] [lint] Failed for \u201C${e.uri}\u201D #${e.version}`,n)}}}async ensureBindingStarted(e){if(e=this.normalizeUri(e),g(this,Sn).has(e)||g(this,ai).has(e))return;g(this,ai).add(e);let r=await this.read(e);if(!r||!await this.cacheService.hasFileChangedSinceCache(r))return;let n=this.parse(r);await this.bind(r,n),this.emit("documentUpdated",{doc:r,node:n})}bindUri(e){let r=Du.create(this);typeof e=="string"&&r.symbols.clear({contributor:"uri_binder",uri:e}),r.symbols.contributeAs("uri_binder",()=>{let n=Array.isArray(e)?e:[e];for(let i of this.meta.uriBinders)i(n,r)})}async onDidOpen(e,r,n,i){if(e=this.normalizeUri(e),!Y.isFileUri(e))return;let o=Iu.TextDocument.create(e,r,n,i),s=this.parse(o);g(this,li).add(e),g(this,Qr).set(e,{doc:o,node:s}),g(this,Cn)&&(await this.bind(o,s),await this.check(o,s))}async onDidChange(e,r,n){if(e=this.normalizeUri(e),g(this,Sn).delete(e),!Y.isFileUri(e))return;let i=g(this,Qr).get(e)?.doc;if(!i)throw new Error(`TextDocument for \u201C${e}\u201D is ${i?"a Promise":"not cached"}. This should not happen. Did the language client send a didChange notification without sending a didOpen one, or is there a logic error on our side resulting the 'read' function overriding the 'TextDocument' created in the 'didOpen' notification handler?`);Iu.TextDocument.update(i,r,n);let o=this.parse(i);g(this,Qr).set(e,{doc:i,node:o}),g(this,Cn)&&(await this.bind(i,o),await this.check(i,o))}onDidClose(e){e=this.normalizeUri(e),Y.isFileUri(e)&&(g(this,li).delete(e),g(this,Qr).delete(e),this.tryClearingCache(e))}async ensureClientManagedChecked(e){e=this.normalizeUri(e);let r=g(this,Qr).get(e);if(r){let{doc:n,node:i}=r;return g(this,Cn)&&(await this.bind(n,i),await this.check(n,i),this.emit("documentUpdated",r)),r}}getClientManaged(e){return e=this.normalizeUri(e),g(this,Qr).get(e)}async showCacheRoot(){if(g(this,co))try{await this.externals.fs.showFile(g(this,co))}catch(e){this.logger.error("[Service#showCacheRoot]",e)}}tryClearingCache(e){this.shouldRemove(e)&&(this.removeCachedTextDocument(e),this.emit("documentRemoved",{uri:e}))}shouldRemove(e){return!g(this,li).has(e)&&!g(this,lo).has(e)&&!g(this,_n).has(e)}isOnlyWatched(e){return g(this,_n).has(e)&&!g(this,li).has(e)&&!g(this,lo).has(e)}},An=so;ai=new WeakMap,_l=new WeakMap,li=new WeakMap,Qr=new WeakMap,Es=new WeakMap,Sn=new WeakMap,ao=new WeakMap,Ms=new WeakMap,Cl=new WeakMap,Al=new WeakMap,_n=new WeakMap,Ds=new WeakMap,ci=new WeakMap,Cn=new WeakMap,Tl=new WeakMap,lo=new WeakMap,Ns=new WeakMap,Ps=new WeakMap,co=new WeakMap,At=new WeakMap,fo=new WeakMap,H(An,"RootSuffix","/pack.mcmeta"),H(An,"TextDocumentCacheMaxLength",268435456);Km([nu()],An.prototype,"bind",null);Km([nu()],An.prototype,"check",null);Km([nu()],An.prototype,"ensureClientManagedChecked",null);var Bu;(function(t){function e(r,n){return{range:v.get(r),locations:n}}t.create=e})(Bu||(Bu={}));var ju=class{isDebugging;logger;profilers;project;constructor({isDebugging:e=!1,logger:r,profilers:n=si.noop(),project:i}){this.isDebugging=e,this.logger=r,this.profilers=n,this.project=new An({logger:r,profilers:n,...i})}debug(e){this.isDebugging&&this.logger.info(`[DEBUG] ${e}`)}colorize(e,r,n){try{return this.debug(`Colorizing '${r.uri}' # ${r.version}`),this.project.meta.getColorizer(e.type)(e,Ru.create(this.project,{doc:r,range:n}))}catch(i){this.logger.error(`[Service] [colorize] Failed for \u201C${r.uri}\u201D #${r.version}`,i)}return[]}getColorInfo(e,r){try{this.debug(`Getting color info for '${r.uri}' # ${r.version}`);let n=[];return Ct(e,i=>!0,i=>i.color,i=>n.push({color:Array.isArray(i.color)?i.color:i.color.value,range:Array.isArray(i.color)?i.range:i.color.range??i.range})),n}catch(n){this.logger.error(`[Service] [getColorInfo] Failed for \u201C${r.uri}\u201D #${r.version}`,n)}return[]}getColorPresentation(e,r,n,i){try{this.debug(`Getting color presentation for '${r.uri}' # ${r.version} @ ${v.toString(n)}`);let o=Ke.findDeepestChild({node:e,needle:n.start});for(;o;){let s=o.color;if(s&&!Array.isArray(s)){let a=s.range??o.range;return s.format.map(l=>xu.fromColorFormat(l,i,a))}o=o.parent}}catch(o){this.logger.error(`[Service] [getColorPresentation] Failed for \u201C${r.uri}\u201D #${r.version}`,o)}return[]}complete(e,r,n,i){try{if(this.debug(`Getting completion for '${r.uri}' # ${r.version} @ ${n}`),this.project.meta.shouldComplete(r.languageId,i))return re.file(e,Eu.create(this.project,{doc:r,offset:n,triggerCharacter:i}))}catch(o){this.logger.error(`[Service] [complete] Failed for \u201C${r.uri}\u201D #${r.version}`,o)}return[]}dataHackPubify(e){let r=[["ata","ack","ub","elper","lus"],["ah","uh","ew","elpa","lush"]],n=r[Math.floor(Math.random()*r.length)];return[...e].map((i,o)=>`${i.toUpperCase()}${n[o%n.length]}`).join(" ")}format(e,r,n,i){try{return this.debug(`Formatting '${r.uri}' # ${r.version}`),this.project.meta.getFormatter(e.type)(e,Ou.create(this.project,{doc:r,tabSize:n,insertSpaces:i}))}catch(o){throw this.logger.error(`[Service] [format] Failed for \u201C${r.uri}\u201D #${r.version}`,o),o}}getHover(e,r,n){try{this.debug(`Getting hover for '${r.uri}' # ${r.version} @ ${n}`);let i=Ke.findDeepestChild({node:e,needle:n});for(;i;){let o=this.project.symbols.resolveAlias(i.symbol);if(o){let s=`\`\`\`typescript +${s(c.symbol,e)}`}t.stringifyLookupResult=l})(Yn||(Yn={}));function bu(t=e=>e){return(e,r,n)=>{let i=n.value;return n.value=function(...o){let s=t(this);s._inDelayMode?s._delayedOps.push(i.bind(this,...o)):i.apply(this,o)},n}}function Dm(t){return!!t.doc}var Y;(function(t){function*e(x,T){for(let O of T)x.startsWith(O)&&(yield decodeURIComponent(x.slice(O.length)))}t.getRels=e;function r(x,T){return e(x,T).next().value}t.getRel=r;function n(x){return x.endsWith("/")}t.isRootUri=n;function i(x){return n(x)?x:`${x}/`}t.ensureEndingSlash=i;function o(x,T){return i(x)+(T.startsWith("/")?T.slice(1):T)}t.join=o;function s(x){return x.startsWith("file:")}t.isFileUri=s;function a(x){let T=x.lastIndexOf(".");return T>=0?x.slice(T):void 0}t.extname=a;function l(x){let T=x.lastIndexOf("/");return T>=0?x.slice(T+1):x}t.basename=l;function c(x,T){return new Bt(".",T)}t.getParentOfFile=c;async function f(x,T,O=511){try{await x.fs.mkdir(T,{mode:O,recursive:!0})}catch(M){if(!x.error.isKind(M,"EEXIST"))throw M}}t.ensureDir=f;async function u(x,T,O=511){return f(x,c(x,T),O)}t.ensureParentOfFile=u;async function h(x,T,O){return x.fs.chmod(T,O)}t.chmod=h;async function d(x,T){try{await h(x,T,438)}catch(O){if(!x.error.isKind(O,"ENOENT"))throw O}}t.ensureWritable=d;async function p(x,T){return h(x,T,292)}t.markReadOnly=p;async function b(x,T){return x.fs.readFile(T)}t.readFile=b;async function m(x,T,O,M=438){return await u(x,T),await d(x,T),x.fs.writeFile(T,O,{mode:M})}t.writeFile=m;async function k(x,T){return JSON.parse(ir(await b(x,T)))}t.readJson=k;async function S(x,T,O){return m(x,T,JSON.stringify(O))}t.writeJson=S;async function _(x,T){return x.archive.gunzip(await b(x,T))}t.readGzippedFile=_;async function w(x,T,O){return typeof O=="string"&&(O=new TextEncoder().encode(O)),m(x,T,await x.archive.gzip(O))}t.writeGzippedFile=w;async function C(x,T){return JSON.parse(ir(await _(x,T)))}t.readGzippedJson=C;async function R(x,T,O){return w(x,T,JSON.stringify(O))}t.writeGzippedJson=R})(Y||(Y={}));var Pm=2,ku;(function(t){function e(){return{files:{},roots:{},symbolRegistrars:{}}}t.create=e})(ku||(ku={}));var Qi,wu,vu=class{constructor(e,r){H(this,"cacheRoot");H(this,"project");H(this,"checksums",ku.create());H(this,"errors",{});E(this,Qi,!1);E(this,wu,void 0);this.cacheRoot=e,this.project=r,this.project.on("documentUpdated",async({doc:n})=>{if(g(this,Qi))try{this.checksums.files[n.uri]=await this.project.externals.crypto.getSha1(n.getText())}catch(i){this.project.externals.error.isKind(i,"EISDIR")||this.project.logger.error(`[CacheService#hash-file] ${n.uri}`)}}),this.project.on("rootsUpdated",async({roots:n})=>{if(g(this,Qi))for(let i of n)try{this.checksums.roots[i]=await this.project.fs.hash(i)}catch(o){this.project.externals.error.isKind(o,"EISDIR")||this.project.logger.error(`[CacheService#hash-root] ${i}`)}}),this.project.on("symbolRegistrarExecuted",({id:n,checksum:i})=>{i!==void 0&&(this.checksums.symbolRegistrars[n]=i)}),this.project.on("documentErrored",({uri:n,errors:i})=>{this.errors[n]=i})}async getCacheFileUri(){return g(this,wu)??L(this,wu,new Bt(`symbols/${await this.project.externals.crypto.getSha1(this.project.projectRoot)}.json.gz`,this.cacheRoot).toString())}async load(){let e=this.project.profilers.get("cache#load"),r={symbols:{}},n;try{n=await this.getCacheFileUri(),this.project.logger.info(`[CacheService#load] symbolCachePath = \u201C${n}\u201D`);let i=await Y.readGzippedJson(this.project.externals,n);e.task("Read File"),i.version===Pm?(this.checksums=i.checksums,this.errors=i.errors,r.symbols=tl.link(i.symbols),e.task("Link Symbols")):this.project.logger.info(`[CacheService#load] Unsupported cache format ${i.version}; expected ${Pm}`)}catch(i){this.project.externals.error.isKind(i,"ENOENT")||this.project.logger.error("[CacheService#load] ",i)}return e.finalize(),r}async validate(){let e={addedFiles:[],changedFiles:[],removedFiles:[],unchangedFiles:[]},r=[];for(let[n,i]of Object.entries(this.checksums.roots))try{await this.project.fs.hash(n)===i&&r.push(n)}catch(o){this.project.externals.error.isKind(o,"EISDIR")||this.project.logger.error(`[CacheService#hash-file] ${n}`)}for(let[n,i]of Object.entries(this.checksums.files)){if(r.some(o=>n.startsWith(o))){e.unchangedFiles.push(n);continue}try{await this.project.fs.hash(n)===i?e.unchangedFiles.push(n):e.changedFiles.push(n)}catch(o){this.project.externals.error.isKind(o,"ENOENT")||this.project.externals.error.isKind(o,"EISDIR")?e.removedFiles.push(n):(this.project.logger.error(`[CacheService#validate] ${n}`,o),e.changedFiles.push(n))}}for(let n of this.project.getTrackedFiles())n in this.checksums.files||e.addedFiles.push(n);return L(this,Qi,!0),e}async save(){let e=this.project.profilers.get("cache#save"),r;try{r=await this.getCacheFileUri();let n={version:Pm,projectRoot:this.project.projectRoot,checksums:this.checksums,symbols:tl.unlink(this.project.symbols.global),errors:this.errors};return e.task("Unlink Symbols"),await Y.writeGzippedJson(this.project.externals,r,n),e.task("Write File").finalize(),!0}catch(n){this.project.logger.error(`[CacheService#save] path = \u201C${r}\u201D`,n)}return!1}async hasFileChangedSinceCache(e){return this.checksums.files[e.uri]!==await this.project.externals.crypto.getSha1(e.getText())}reset(){return L(this,Qi,!1),this.checksums=ku.create(),this.errors={},{symbols:{}}}};Qi=new WeakMap,wu=new WeakMap;var Qw=Br(ru(),1);var ps;(function(t){function e(n){return n==="hint"||n==="information"||n==="warning"||n==="error"}t.is=e;function r(n){switch(n){case"error":return 3;case"hint":return 0;case"information":return 1;case"warning":return 2}}t.toErrorSeverity=r})(ps||(ps={}));var gs;(function(t){function e(r){if(r!=null)return ps.is(r)?{ruleSeverity:ps.toErrorSeverity(r),ruleValue:!0}:Array.isArray(r)&&ps.is(r[0])?{ruleSeverity:ps.toErrorSeverity(r[0]),ruleValue:r[1]}:{ruleSeverity:2,ruleValue:r}}t.destruct=e})(gs||(gs={}));var il;(function(t){function e(o){return Ue.is(o,r.is)||i.is(o)}t.is=e;let r;(function(o){function s(a){if(!a||typeof a!="object")return!1;let l=a;return(l.if===void 0||Ue.is(l.if,n.is))&&(l.then===void 0||i.is(l.then))&&(l.override===void 0||Ue.is(l.override,o.is))}o.is=s})(r=t.Complex||(t.Complex={}));let n;(function(o){function s(a){if(!a||typeof a!="object")return!1;let l=a;return(l.category===void 0||Ue.is(l.category,Gn.isString))&&(l.pattern===void 0||Ue.is(l.pattern,Gn.isString))&&(l.excludePattern===void 0||Ue.is(l.excludePattern,Gn.isString))&&(l.namespace===void 0||Ue.is(l.namespace,Gn.isString))&&(l.excludeNamespace===void 0||Ue.is(l.excludeNamespace,Gn.isString))}o.is=s})(n=t.Condition||(t.Condition={}));let i;(function(o){function s(c){return c!==void 0&&["block","file","public"].includes(c.declare)}o.isDeclare=s;function a(c){return c!==void 0&&["inherit","hint","information","warning","error"].includes(c.report)}o.isReport=a;function l(c){if(!c||typeof c!="object")return!1;let f=c;return s(f)||a(f)}o.is=l})(i=t.Action||(t.Action={}))})(il||(il={}));var Lm={env:{dataSource:"GitHub",dependencies:["@vanilla-mcdoc"],feature:{codeActions:!0,colors:!0,completions:!0,documentHighlighting:!0,documentLinks:!0,foldingRanges:!0,formatting:!0,hover:!0,inlayHint:{enabledNodes:["mcfunction:command_child/unknown"]},semanticColoring:!0,selectionRanges:!0,signatures:!0},gameVersion:"Auto",language:"Default",permissionLevel:2,plugins:[],mcmetaSummaryOverrides:{}},format:{blockStateBracketSpacing:{inside:0},blockStateCommaSpacing:{before:0,after:1},blockStateEqualSpacing:{before:0,after:0},blockStateTrailingComma:!1,eol:"auto",nbtArrayBracketSpacing:{inside:0},nbtArrayCommaSpacing:{before:0,after:1},nbtArraySemicolonSpacing:{after:1},nbtArrayTrailingComma:!1,nbtByteSuffix:"b",nbtCompoundBracketSpacing:{inside:0},nbtCompoundColonSpacing:{before:0,after:1},nbtCompoundCommaSpacing:{before:0,after:1},nbtCompoundTrailingComma:!1,nbtDoubleOmitSuffix:!1,nbtDoubleSuffix:"d",nbtFloatSuffix:"f",nbtListBracketSpacing:{inside:0},nbtListCommaSpacing:{before:0,after:1},nbtListTrailingComma:!1,nbtLongSuffix:"L",nbtShortSuffix:"s",selectorBracketSpacing:{inside:0},selectorCommaSpacing:{before:0,after:1},selectorEqualSpacing:{before:0,after:0},selectorTrailingComma:!1,timeOmitTickUnit:!1},lint:{blockStateSortKeys:null,nbtCompoundSortKeys:null,selectorSortKeys:null,commandStringQuote:null,nbtKeyQuote:null,nbtPathQuote:null,nbtStringQuote:null,selectorKeyQuote:null,idOmitDefaultNamespace:null,nameOfNbtKey:null,nameOfObjective:null,nameOfScoreHolder:null,nameOfTag:null,nameOfTeam:null,nbtArrayLengthCheck:!0,nbtBoolean:null,nbtListLengthCheck:null,nbtTypeCheck:"loosely",undeclaredSymbol:[{if:[{category:Gi,namespace:"minecraft"},{category:[...hs,"bossbar","objective","team"]}],then:{report:"warning"}},{then:{declare:"block"}}]},snippet:{executeIfScoreSet:"execute if score ${1:score_holder} ${2:objective} = ${1:score_holder} ${2:objective} $0",summonAec:'summon minecraft:area_effect_cloud ~ ~ ~ {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["${1:tag}"]}'}},eo,ms=class{constructor(e,r=Lm){H(this,"project");H(this,"defaultConfig");E(this,eo,void 0);this.project=e,this.defaultConfig=r,L(this,eo,new e.externals.event.EventEmitter);let n=async({uri:i})=>{ms.isConfigFile(i)&&this.emit("changed",{config:await this.load()})};e.on("fileCreated",n),e.on("fileModified",n),e.on("fileDeleted",n)}on(e,r){return g(this,eo).on(e,r),this}once(e,r){return g(this,eo).once(e,r),this}emit(e,...r){return g(this,eo).emit(e,...r)}async load(){let e=this.defaultConfig;for(let r of ms.ConfigFileNames){let n=this.project.projectRoot+r;try{e=JSON.parse(ir(await this.project.externals.fs.readFile(n)))}catch(i){if(this.project.externals.error.isKind(i,"ENOENT"))continue;this.emit("error",{error:i,uri:n})}break}return ms.merge(this.defaultConfig,e)}static isConfigFile(e){return ms.ConfigFileNames.some(r=>e.endsWith(`/${r}`))}static merge(e,...r){let n=(0,Qw.default)()(e);for(let i of r)for(let o of["env","format","lint","snippet"])n[o]={...n[o],...i[o]};return n}},to=ms;eo=new WeakMap,H(to,"ConfigFileNames",Object.freeze(["spyglass.json",".spyglassrc.json"]));var Im=Symbol("IsAsyncBinder"),ti=Object.freeze({create(t){return t},is(t){return!t[Im]}}),ol=Object.freeze({create(t){return Object.assign(t,{[Im]:!0})},is(t){return t[Im]}});var sl={};yr(sl,{any:()=>JR,attempt:()=>Bm,dispatchSync:()=>QR,fallback:()=>XR,noop:()=>YR,registerBinders:()=>eE,resourceLocation:()=>tx,symbol:()=>rx});function At(t,e,r,n){ex(t,e,r,n,[])}function ex(t,e,r,n,i){if(r(t,i)&&n(t,i),!(!t.children||!e(t,i)))for(let o of t.children??[])i.unshift(t),ex(o,e,r,n,i),i.shift()}function Bm(t,e,r){let n={...r,err:new ht,symbols:r.symbols.clone()},i=()=>{Qe.undoChanges(e);let o=n.err.errors.map(s=>s.range.end-s.range.start).reduce((s,a)=>s+a,0);return{errorAmount:n.err.errors.length,totalErrorSpan:o,updateNodeAndCtx:()=>{r.err.absorb(n.err),Qe.redoChanges(e),n.symbols.applyDelayedEdits()}}};return ti.is(t)?(t(e,n),i()):(async()=>(await t(e,n),i()))()}function JR(t){if(t.length===0)throw new Error("Expected at least one binder");let e=(r,n)=>r.errorAmount-n.errorAmount||r.totalErrorSpan-n.totalErrorSpan;return t.every(ti.is)?ti.create((r,n)=>{t.map(o=>Bm(o,r,n)).sort(e)[0].updateNodeAndCtx()}):ol.create(async(r,n)=>{(await Promise.all(t.map(o=>Bm(o,r,n)))).sort(e)[0].updateNodeAndCtx()})}var YR=ti.create(()=>{}),XR=ol.create(async(t,e)=>{let r=[];At(t,n=>!e.meta.hasBinder(n.type),n=>e.meta.hasBinder(n.type),n=>{let o=e.meta.getBinder(n.type)(n,e);o instanceof Promise&&r.push(o)}),await Promise.all(r)}),QR=ti.create((t,e)=>{for(let r of t.children??[])e.meta.hasBinder(r.type)&&e.meta.getBinder(r.type)(r,e)}),tx=ti.create((t,e)=>{let r=U.toString(t,"full"),n=q.lengthen(t.options.namespacePathSep==="."?r.replace(/\./g,q.NamespacePathSep):r);if(t.options.category&&e.symbols.query(e.doc,t.isTag?`tag/${t.options.category}`:t.options.category,n).enter({usage:{type:t.options.usageType,node:t,accessType:t.options.accessType}}),t.options.pool&&!t.options.allowUnknown){t.options.pool.includes(n)||e.err.report(y("expected",t.options.pool),t,3);return}}),rx=ti.create((t,e)=>{if(t.value){let r=t.options.parentPath?[...t.options.parentPath,t.value]:[t.value];e.symbols.query(e.doc,t.options.category,...r).enter({usage:{type:t.options.usageType,node:t,accessType:t.options.accessType}})}});function eE(t){t.registerBinder("resource_location",tx),t.registerBinder("symbol",rx)}var tt={};yr(tt,{any:()=>tE,attempt:()=>nx,dispatchSync:()=>iE,fallback:()=>nE,noop:()=>rE,registerCheckers:()=>oE,resourceLocation:()=>ix,symbol:()=>ox});function nx(t,e,r){let n={...r,err:new ht,symbols:r.symbols.clone()};t(e,n),Qe.undoChanges(e);let i=n.err.errors.map(o=>o.range.end-o.range.start).reduce((o,s)=>o+s,0);return{errorAmount:n.err.errors.length,totalErrorSpan:i,updateNodeAndCtx:()=>{r.err.absorb(n.err),Qe.redoChanges(e),n.symbols.applyDelayedEdits()}}}function tE(t){if(t.length===0)throw new Error("Expected at least one checker");return(e,r)=>{t.map(i=>nx(i,e,r)).sort((i,o)=>i.errorAmount-o.errorAmount||i.totalErrorSpan-o.totalErrorSpan)[0].updateNodeAndCtx()}}var rE=()=>{},nE=async(t,e)=>{let r=[];At(t,n=>!e.meta.hasChecker(n.type),n=>e.meta.hasChecker(n.type),n=>{let o=e.meta.getChecker(n.type)(n,e);o instanceof Promise&&r.push(o)}),await Promise.all(r)},iE=(t,e)=>{for(let r of t.children??[])e.meta.hasChecker(r.type)&&e.meta.getChecker(r.type)(r,e)},ix=(t,e)=>{},ox=(t,e)=>{};function oE(t){t.registerChecker("resource_location",ix),t.registerChecker("symbol",ox)}var dt;(function(t){t.NamedColors=new Map([["aqua",5636095],["black",0],["blue",5592575],["dark_aqua",43690],["dark_blue",170],["dark_gray",5592405],["dark_green",43520],["dark_purple",11141290],["dark_red",11141120],["gold",16755200],["gray",11184810],["green",5635925],["light_purple",16733695],["red",16733525],["white",16777215],["yellow",16777045]]),t.ColorNames=[...t.NamedColors.keys()];function e(s,a,l,c){return[s,a,l,c]}t.fromDecRGBA=e;function r(s,a,l){return e(s,a,l,1)}t.fromDecRGB=r;function n(s,a,l,c){return e(s/255,a/255,l/255,c/255)}t.fromIntRGBA=n;function i(s,a,l){return n(s,a,l,255)}t.fromIntRGB=i;function o(s){if(s<0)return r(1,1,1);let a=s%256;s>>=8;let l=s%256;s>>=8;let c=s%256;return i(c,l,a)}t.fromCompositeInt=o})(dt||(dt={}));var jt;(function(t){t[t.DecRGBA=0]="DecRGBA",t[t.DecRGB=1]="DecRGB",t[t.IntRGBA=2]="IntRGBA",t[t.IntRGB=3]="IntRGB",t[t.HexRGBA=4]="HexRGBA",t[t.HexRGB=5]="HexRGB",t[t.CompositeInt=6]="CompositeInt"})(jt||(jt={}));var xu;(function(t){function e(n,i,o){let s=r(n,i);return{label:s,text:s,range:o}}t.fromColorFormat=e;function r(n,i){let o=s=>parseFloat(s.toFixed(3));switch(n){case jt.DecRGBA:return i.map(s=>o(s)).join(" ");case jt.DecRGB:return i.slice(0,3).map(s=>o(s)).join(" ");case jt.IntRGBA:return i.map(s=>Math.round(s*255)).join(" ");case jt.IntRGB:return i.slice(0,3).map(s=>Math.round(s*255)).join(" ");case jt.HexRGBA:return`#${Math.round((i[0]*255<<24)+(i[1]*255<<16)+i[2]*255<<8+i[3]*255).toString(16).padStart(8,"0")}`;case jt.HexRGB:return`#${Math.round((i[0]*255<<16)+(i[1]*255<<8)+i[2]*255).toString(16).padStart(6,"0")}`;case jt.CompositeInt:return`${Math.round((i[0]*255<<16)+(i[1]*255<<8)+i[2]*255)}`}}})(xu||(xu={}));var Ie={};yr(Ie,{boolean:()=>sx,comment:()=>ax,error:()=>lx,fallback:()=>sE,literal:()=>cx,number:()=>Su,registerColorizers:()=>aE,resourceLocation:()=>fx,string:()=>ux,symbol:()=>hx});var Te;(function(t){function e(n,i,o){return{range:v.get(n),type:i,modifiers:o}}t.create=e;function r(n,i,o,s){let a=[],l=Math.min(i.start,n[0]?.range.start??1/0);for(let c of n)c.range.start>l&&a.push(t.create(v.create(l,c.range.start),o,s)),a.push(c),l=c.range.end;return l{let r=[];return At(t,n=>!e.meta.hasColorizer(n.type)&&(!e.range||v.intersects(n.range,e.range)),n=>e.meta.hasColorizer(n.type),n=>{let o=e.meta.getColorizer(n.type)(n,e);r.push(...o)}),Object.freeze(r)},sx=t=>[Te.create(t,"literal")],ax=t=>[Te.create(t,"comment")],lx=t=>[],cx=t=>[Te.create(t,t.options.colorTokenType??"literal")],Su=t=>[Te.create(t,"number")],fx=(t,e)=>{let r;switch(t.options.category){case"function":case"tag/function":r="function";break;default:r="resourceLocation";break}return[Te.create(t,r)]},ux=(t,e)=>{if(t.children){let n=e.meta.getColorizer(t.children[0].type)(t.children[0],e);return Te.fillGap(n,t.range,t.options.colorTokenType??"string")}else return[Te.create(t,t.options.colorTokenType??"string")]},hx=t=>[Te.create(t,"variable")];function aE(t){t.registerColorizer("boolean",sx),t.registerColorizer("comment",ax),t.registerColorizer("error",lx),t.registerColorizer("float",Su),t.registerColorizer("integer",Su),t.registerColorizer("long",Su),t.registerColorizer("literal",cx),t.registerColorizer("resource_location",fx),t.registerColorizer("string",ux),t.registerColorizer("symbol",hx)}var re={};yr(re,{boolean:()=>px,dispatch:()=>jm,fallback:()=>lE,file:()=>cE,literal:()=>mx,noop:()=>ll,record:()=>fE,registerCompleters:()=>uE,resourceLocation:()=>gx,string:()=>yx,symbol:()=>bx});var dx=Br(tu(),1);var pe;(function(t){function e(i,o,s){let a=s?.insertText===void 0&&r(i);return{...s,label:i,range:v.get(o),...a?{insertText:n(i)}:{}}}t.create=e;function r(i){return/[\\$}]/.test(i)}t.needsEscape=r;function n(i){return i.replace(/([\\$}])/g,"\\$1")}t.escape=n})(pe||(pe={}));var xn,ro,al=class{constructor(){E(this,xn,"");E(this,ro,1)}literal(e){return L(this,xn,g(this,xn)+pe.escape(e)),this}placeholder(...e){return e.length===0?L(this,xn,g(this,xn)+`\${${g(this,ro)}}`):e.length===1?L(this,xn,g(this,xn)+`\${${g(this,ro)}:${pe.escape(e[0])}}`):L(this,xn,g(this,xn)+`\${${g(this,ro)}|${e.map(r=>r.replace(/([\\$},|])/g,"\\$1")).join(",")}|}`),L(this,ro,g(this,ro)+1),this}exitPlace(){return L(this,xn,g(this,xn)+"$0"),this}build(){return g(this,xn)}if(e,r){return e&&r(this),this}};xn=new WeakMap,ro=new WeakMap;var jm=(t,e)=>{let r=Ke.findShallowestChild({node:t,needle:e.offset,endInclusive:!0,predicate:n=>e.meta.hasCompleter(n.type)});return r?e.meta.getCompleter(r.type)(r,e):[]},lE=jm,px=(t,e)=>[pe.create("false",t,{kind:21}),pe.create("true",t,{kind:21})],cE=(t,e)=>e.meta.getCompleterForLanguageID(e.doc.languageId)(t.children[0],e),mx=t=>{let e=new Map([["enum",13],["enumMember",20],["function",3],["keyword",14],["literal",14],["number",21],["operator",24],["property",10],["resourceLocation",17],["variable",6]]).get(t.options.colorTokenType??"keyword")??14;return t.options.pool.map(r=>pe.create(r,t,{kind:e}))??[]},ll=()=>[];function fE(t){return(e,r)=>{if(!v.contains(v.translate(e,1,-1),r.offset,!0))return[];let n=h=>t.key(e,h,r,h?.key??r.offset,!1,!1,o),i=h=>t.key(e,h,r,h??r.offset,!0,l||!!h?.end,o),o=e.children.filter(h=>!!h.key).map(h=>h.key),s=(0,dx.default)(e.children,r.offset,(h,d)=>h.end?v.compareOffset(v.translate(h,0,-1),d,!0):v.compareOffset(h.range,d,!0)),a=s>=0?e.children[s]:void 0,l=!!e.children.find(h=>h.range.start>r.offset);if(!a)return i(void 0);let{key:c,sep:f,value:u}=a;return!c&&!f&&!u?i(void 0):c&&v.contains(c,r.offset,!0)||f&&r.offset<=f.start||u&&r.offset=f.end||c&&r.offset>c.range.end?t.value(e,a,r):[]}}var gx=(t,e)=>{let r=gs.destruct(e.config.lint.idOmitDefaultNamespace),n=!t.options.isPredicate&&t.namespace==="",i=t.options.isPredicate||r?.ruleValue!==!0,o=!t.options.isPredicate&&r?.ruleValue!==!1,s=c=>a(Object.keys(e.symbols.getVisibleSymbols(c,e.doc.uri))),a=c=>{let f=`${q.DefaultNamespace}${q.NamespacePathSep}`,u=[],h=[];for(let p of c)p.startsWith(f)?u.push(p):h.push(p);let d=[...h,...i?u:[],...o?u.map(p=>p.slice(f.length)):[],...n?u.map(p=>p.slice(q.DefaultNamespace.length)):[]];return t.options.namespacePathSep==="."?d.map(p=>p.replace(q.NamespacePathSep,".")):d};return(t.options.pool?a(t.options.pool):[...s(t.options.category),...t.options.allowTag?s(`tag/${t.options.category}`).map(c=>`${q.TagPrefix}${c}`):[]]).map(c=>pe.create(c,t,{kind:3}))},yx=(t,e)=>t.children?.length?jm(t.children[0],e):t.options.quotes&&t.value===""?t.options.quotes.map(r=>pe.create(`${r}${r}`,t,{insertText:`${r}$1${r}`,kind:12})):[],bx=(t,e)=>Object.keys(e.symbols.query(e.doc,t.options.category,...t.options.parentPath??[]).visibleMembers).map(r=>pe.create(r,t,{kind:6}));function uE(t){t.registerCompleter("boolean",px),t.registerCompleter("comment",ll),t.registerCompleter("float",ll),t.registerCompleter("integer",ll),t.registerCompleter("long",ll),t.registerCompleter("literal",mx),t.registerCompleter("resource_location",gx),t.registerCompleter("string",yx),t.registerCompleter("symbol",bx)}var Xr={};yr(Xr,{boolean:()=>vx,comment:()=>wx,fallback:()=>hE,file:()=>kx,float:()=>xx,integer:()=>Sx,literal:()=>_x,long:()=>Cx,registerFormatters:()=>dE,resourceLocation:()=>Ax,string:()=>Tx});var hE=t=>{throw new Error(`No formatter registered for type ${t.type}`)},kx=(t,e)=>t.children.map(r=>e.meta.getFormatter(r.type)(r,e)).join(""),vx=t=>t.value?"true":"false",wx=t=>"#"+t.comment,xx=t=>t.value.toString(),Sx=t=>t.value.toFixed(),_x=t=>t.value,Cx=t=>t.value.toString(),Ax=t=>U.toString(t,"origin",!0),Tx=t=>`"${t.value}"`;function dE(t){t.registerFormatter("file",kx),t.registerFormatter("boolean",vx),t.registerFormatter("comment",wx),t.registerFormatter("float",xx),t.registerFormatter("integer",Sx),t.registerFormatter("long",Cx),t.registerFormatter("literal",_x),t.registerFormatter("resource_location",Ax),t.registerFormatter("string",Tx)}function $m(t,e=0){let r=t.indentLevel+e;return t.insertSpaces?" ".repeat(r*t.tabSize):" ".repeat(r)}function zm(t,e=1){return{...t,indentLevel:t.indentLevel+e,indent(r){return $m(this,r)}}}var ni={};yr(ni,{configValidator:()=>ri,nameConvention:()=>cl,noop:()=>pE,quote:()=>mE,registerLinters:()=>gE});var Ox=(t,e)=>{};var pE=()=>{};function cl(t){return(e,r)=>{if(typeof e[t]!="string")throw new Error(`Trying to access property "${t}" of node type "${e.type}"`);let n=e[t];try{let i=new RegExp(r.ruleValue);n.match(i)||r.err.lint(y("linter.name-convention.illegal",P(n),P(r.ruleValue)),e)}catch(i){r.logger.error(`[nameConvention linter] The value \u201C${r.ruleValue}\u201D set for rule \u201C${r.ruleName}\u201D is not a valid regular expression.`,i)}}}var mE=(t,e)=>{let r=e.ruleValue,n=t.options.unquotable?[...t.value].some(l=>!Fm(l,t.options.unquotable)):!0,i=r.always||n,o=r.always===!1&&!n,s=e.src.slice(t.range.start,t.range.start+1),a=!!t.options.quotes?.includes(s);i&&a&&(r.avoidEscape,r.type)},ri;(function(t){function e(o){return`https://spyglassmc.com/user/lint/${o}`}function r(o,s){return`[Invalid Linter Config] [${o}] ${y("linter-config-validator.wrapper",s,e(o))}`}function n(o,s,a){if(typeof s!="string")return a.error(r(o,y("linter-config-validator.name-convention.type"))),!1;try{new RegExp(s)}catch(l){return a.error(r(o,y("")),l),!1}return!0}t.nameConvention=n;function i(o,s,a){return il.is(s)}t.symbolLinterConfig=i})(ri||(ri={}));function gE(t){t.registerLinter("nameOfObjective",{configValidator:ri.nameConvention,linter:cl("value"),nodePredicate:e=>e.symbol&&e.symbol.category==="objective"}),t.registerLinter("nameOfScoreHolder",{configValidator:ri.nameConvention,linter:cl("value"),nodePredicate:e=>e.symbol&&e.symbol.category==="score_holder"}),t.registerLinter("nameOfTag",{configValidator:ri.nameConvention,linter:cl("value"),nodePredicate:e=>e.symbol&&e.symbol.category==="tag"}),t.registerLinter("nameOfTeam",{configValidator:ri.nameConvention,linter:cl("value"),nodePredicate:e=>e.symbol&&e.symbol.category==="team"}),t.registerLinter("undeclaredSymbol",{configValidator:ri.symbolLinterConfig,linter:Ox,nodePredicate:e=>e.symbol&&!Om.includes(e.symbol.category)})}var ht=class{errors=[];constructor(){}report(e,r,n=3,i){this.errors.push(lu.create(e,v.get(r),n,i))}dump(){let e=Object.freeze(this.errors);return this.errors=[],e}absorb(e){this.errors.push(...e.errors)}},ys=class extends ht{ruleName;ruleSeverity;constructor(e,r){super(),this.ruleName=e,this.ruleSeverity=r}lint(e,r,n,i){return this.report(y("linter.diagnostic-message-wrapper",e,this.ruleName),r,i??this.ruleSeverity,n)}static fromErrorReporter(e,r,n){let i=new ys(r,n);return i.errors=e.errors,i}};var fl;(function(t){function e(r){return{fs:r.fs,logger:r.logger,meta:r.meta,profilers:r.profilers,roots:r.roots,project:r.ctx}}t.create=e})(fl||(fl={}));var _u;(function(t){function e(r,n){return{...fl.create(r),config:r.config,doc:n.doc,err:n.err??new ht}}t.create=e})(_u||(_u={}));var _r;(function(t){function e(r,n){return{...fl.create(r),config:r.config,doc:n.doc,src:n.src??new qi(n.doc.getText()),symbols:r.symbols}}t.create=e})(_r||(_r={}));var Vm;(function(t){function e(r,n){return{..._r.create(r,n),range:n.range}}t.create=e})(Vm||(Vm={}));var Um;(function(t){function e(r,n){return{..._r.create(r,n),offset:n.offset}}t.create=e})(Um||(Um={}));var Cu;(function(t){function e(r,n){return{..._r.create(r,n),err:n.err??new ht,ensureBindingStarted:r.ensureBindingStarted?.bind(r)}}t.create=e})(Cu||(Cu={}));var Au;(function(t){function e(r,n){return{..._r.create(r,n),err:n.err??new ht,ensureBindingStarted:r.ensureBindingStarted?.bind(r)}}t.create=e})(Au||(Au={}));var Tu;(function(t){function e(r,n){return{..._r.create(r,n),err:n.err,ruleName:n.ruleName,ruleValue:n.ruleValue}}t.create=e})(Tu||(Tu={}));var Ou;(function(t){function e(r,n){return{..._r.create(r,n),...n,indentLevel:0,indent(i){return $m(this,i)}}}t.create=e})(Ou||(Ou={}));var Ru;(function(t){function e(r,n){return Vm.create(r,n)}t.create=e})(Ru||(Ru={}));var Eu;(function(t){function e(r,n){return{..._r.create(r,n),offset:n.offset,triggerCharacter:n.triggerCharacter}}t.create=e})(Eu||(Eu={}));var Mu;(function(t){function e(r,n){return Um.create(r,n)}t.create=e})(Mu||(Mu={}));var Du;(function(t){function e(r){return{...fl.create(r),symbols:r.symbols}}t.create=e})(Du||(Du={}));var Nu;(function(t){function e(r){return r.startsWith("@")}t.is=e})(Nu||(Nu={}));var ii,Pu=class{constructor(e,r,n){H(this,"cacheRoot");H(this,"externals");H(this,"logger");E(this,ii,new Map);this.cacheRoot=e,this.externals=r,this.logger=n}async download(e,r={}){let{id:n,cache:i,uri:o,options:s,transformer:a,ttl:l}=e;if(l&&g(this,ii).has(o)){let{buffer:h,time:d}=g(this,ii).get(o);if(d<=performance.now()+l)return this.logger.info(`[Downloader] [${n}] Skipped thanks to valid cache in memory`),await a(h);g(this,ii).delete(o)}let c,f,u;if(i){let{checksumJob:h,checksumExtension:d}=i;r.cacheUri=f=new Bt(`downloader/${n}`,this.cacheRoot).toString(),u=new Bt(`downloader/${n}${d}`,this.cacheRoot).toString();try{r.checksum=c=await this.download({...h,id:n+d});try{let p=ir(await Y.readFile(this.externals,u)).slice(0,-1);if(c===p)try{let b=await Y.readFile(this.externals,f);l&&g(this,ii).set(o,{buffer:b,time:performance.now()});let m=i.deserializer??(S=>S),k=await a(m(b));return this.logger.info(`[Downloader] [${n}] Skipped downloading thanks to cache ${p}`),k}catch(b){if(this.logger.error(`[Downloader] [${n}] Loading cached file \u201C${f}\u201D`,b),this.externals.error.isKind(b,"ENOENT"))try{await this.externals.fs.unlink(u)}catch(m){this.logger.error(`[Downloader] [${n}] Removing invalid cache checksum \u201C${u}\u201D`,m)}}}catch(p){this.externals.error.isKind(p,"ENOENT")||this.logger.error(`[Downloader] [${n}] Loading cache checksum \u201C${u}\u201D`,p)}}catch(p){this.logger.error(`[Downloader] [${n}] Fetching latest checksum \u201C${h.uri}\u201D`,p)}}try{let h=await this.externals.downloader.get(o,s);if(l&&g(this,ii).set(o,{buffer:h,time:performance.now()}),i&&f&&u){if(c)try{await Y.writeFile(this.externals,u,`${c} +`)}catch(d){this.logger.error(`[Downloader] [${n}] Saving cache checksum \u201C${u}\u201D`,d)}try{let d=i.serializer??(p=>p);await Y.writeFile(this.externals,f,d(h))}catch(d){this.logger.error(`[Downloader] [${n}] Caching file \u201C${f}\u201D`,d)}}return this.logger.info(`[Downloader] [${n}] Downloaded from \u201C${o}\u201D`),await a(h)}catch(h){if(this.logger.error(`[Downloader] [${n}] Downloading \u201C${o}\u201D`,h),i&&f)try{let d=await Y.readFile(this.externals,f),p=i.deserializer??(m=>m),b=await a(p(d));return this.logger.warn(`[Downloader] [${n}] Fell back to cached file \u201C${f}\u201D`),b}catch(d){this.logger.error(`[Downloader] [${n}] Fallback: loading cached file \u201C${f}\u201D`,d)}}}};ii=new WeakMap;var ul;(function(t){function e(r,n){let i=Y.ensureEndingSlash(new Bt("virtual-uris/",n).toString());return new Hm(r,i)}t.create=e})(ul||(ul={}));var Hm=class{externals;virtualUrisRoot;supporters=new Map;map=new au;constructor(e,r){this.externals=e,this.virtualUrisRoot=r}register(e,r,n=!1){if(!n&&this.supporters.has(e))throw new Error(`The protocol \u201C${e}\u201D is already associated with another supporter.`);this.supporters.set(e,r)}unregister(e){this.supporters.delete(e)}getSupportedProtocol(e){let r=new Bt(e).protocol;if(!this.supporters.has(r))throw new Error(`The protocol \u201C${r}\u201D is unsupported.`);return r}async hash(e){let r=this.getSupportedProtocol(e);return this.supporters.get(r).hash(e)}readFile(e){let r=this.getSupportedProtocol(e);return this.supporters.get(r).readFile(e)}*listFiles(){for(let e of this.supporters.values())yield*e.listFiles()}*listRoots(){for(let e of this.supporters.values())yield*e.listRoots()}async mapToDisk(e){if(Y.isFileUri(e))return e;if(this.virtualUrisRoot)try{let r=this.map.getKey(e);if(r===void 0){r=`${this.virtualUrisRoot}${await this.externals.crypto.getSha1(e)}/${Y.basename(e)}`;let n=await this.readFile(e);await Y.writeFile(this.externals,r,n,292),this.map.set(r,e)}return r}catch{}}mapFromDisk(e){return this.virtualUrisRoot?this.map.get(e)??e:e}},bs=class{externals;roots;files;protocol="file:";constructor(e,r,n){this.externals=e,this.roots=r,this.files=n}async hash(e){return Wm(this.externals,e)}readFile(e){return this.externals.fs.readFile(e)}*listFiles(){for(let e of this.files.values())yield*e}listRoots(){return this.roots}async mapToDisk(e){return e}static async create(e,r,n){let i=[],o=new Map;for(let{uri:s}of e)try{Y.isFileUri(s)&&(await r.fs.stat(s)).isDirectory()&&(s=Y.ensureEndingSlash(s),i.push(s),o.set(s,await r.fs.getAllFiles(s)))}catch(a){n.error(`[FileUriSupporter#create] Bad dependency \u201C${s}\u201D`,a)}return new bs(r,i,o)}},$t=class{externals;entries;protocol=$t.Protocol;constructor(e,r){this.externals=e,this.entries=r}async hash(e){let{archiveUri:r,pathInArchive:n}=$t.decodeUri(new Bt(e));return n?this.externals.crypto.getSha1(this.getDataInArchive(r,n)):Wm(this.externals,r)}async readFile(e){let{archiveUri:r,pathInArchive:n}=$t.decodeUri(new Bt(e));return this.getDataInArchive(r,n)}getDataInArchive(e,r){let n=this.entries.get(e);if(!n)throw new Error(`Archive \u201C${e}\u201D has not been loaded into the memory`);let i=n.get(r);if(!i)throw new Error(`Path \u201C${r}\u201D does not exist in archive \u201C${e}\u201D`);if(i.type!=="file")throw new Error(`Path \u201C${r}\u201D in archive \u201C${e}\u201D is not a file`);return i.data}*listFiles(){for(let[e,r]of this.entries.entries())for(let n of r.values())yield $t.getUri(e,n.path)}*listRoots(){for(let e of this.entries.keys())yield $t.getUri(e)}static getUri(e,r=""){return`${$t.Protocol}${encodeURIComponent(e)}?path=${encodeURIComponent(r.replace(/\\/g,"/"))}`}static decodeUri(e){if(e.protocol!==$t.Protocol)throw new Error(`Expected protocol \u201C${$t.Protocol}\u201D in \u201C${e}\u201D`);let r=e.searchParams.get("path");if(!r)throw new Error(`Missing path in archive uri \u201C${e.toString()}\u201D`);return{archiveUri:decodeURIComponent(e.pathname),pathInArchive:r.charAt(0)==="/"?r.slice(1):r}}static async create(e,r,n,i){let o=new Map;for(let{uri:s,info:a}of e)try{if(s.startsWith("file:")&&$t.SupportedArchiveExtnames.some(l=>s.endsWith(l))&&(await r.fs.stat(s)).isFile()){let l=$t.getUri(s),c=i[l];if(c!==void 0){let u=await Wm(r,s);if(c===u){n.info(`[SpyglassUriSupporter#create] Skipped decompressing \u201C${s}\u201D thanks to cache ${u}`);continue}}let f=await r.archive.decompressBall(await r.fs.readFile(s),{stripLevel:typeof a?.startDepth=="number"?a.startDepth:0});o.set(s,new Map(f.map(u=>[u.path.replace(/\\/g,"/"),u])))}}catch(l){n.error(`[SpyglassUriSupporter#create] Bad dependency \u201C${s}\u201D`,l)}return new $t(r,o)}},no=$t;H(no,"Protocol","archive:"),H(no,"SupportedArchiveExtnames",[".tar",".tar.bz2",".tar.gz",".zip"]);async function Wm(t,e){return t.crypto.getSha1(await t.fs.readFile(e))}var hl;(function(t){function e(r,n){return{range:v.get(r),markdown:n}}t.create=e})(hl||(hl={}));var zt,ks,vs,ws,xs,dl,Ss,pl,ml,_s,gl,yl,bl,Cs,Lu=class{constructor(){E(this,zt,new Map);E(this,ks,new Map);E(this,vs,new Map);E(this,ws,new Map);E(this,xs,new Map);E(this,dl,new Map);E(this,Ss,new Map);E(this,pl,new Set);E(this,ml,new Map);E(this,_s,new Map);E(this,gl,new Set);E(this,yl,new Map);E(this,bl,new Set);E(this,Cs,()=>0);sl.registerBinders(this),tt.registerCheckers(this),Ie.registerColorizers(this),re.registerCompleters(this),Xr.registerFormatters(this),ni.registerLinters(this)}registerLanguage(e,r){g(this,zt).set(e,r)}getLanguages(){return Array.from(g(this,zt).keys())}isSupportedLanguage(e){return g(this,zt).has(e)}getSupportedFileExtensions(){return[...g(this,zt).values()].flatMap(e=>e.extensions)}getTriggerCharacters(){return Array.from(g(this,zt).values()).flatMap(e=>e.triggerCharacters??[])}getLanguageID(e){for(let[r,{extensions:n}]of g(this,zt))if(n.includes(e))return r}hasBinder(e){return g(this,ks).has(e)}getBinder(e){return g(this,ks).get(e)??sl.fallback}registerBinder(e,r){g(this,ks).set(e,r)}hasChecker(e){return g(this,vs).has(e)}getChecker(e){return g(this,vs).get(e)??tt.fallback}registerChecker(e,r){g(this,vs).set(e,r)}hasColorizer(e){return g(this,ws).has(e)}getColorizer(e){return g(this,ws).get(e)??Ie.fallback}registerColorizer(e,r){g(this,ws).set(e,r)}hasCompleter(e){return g(this,xs).has(e)}getCompleter(e){return g(this,xs).get(e)??re.fallback}registerCompleter(e,r){g(this,xs).set(e,r)}shouldComplete(e,r){let n=g(this,zt).get(e);return!r||!!n?.triggerCharacters?.includes(r)}getCompleterForLanguageID(e){return g(this,zt).get(e)?.completer??re.fallback}getDependencyProvider(e){return g(this,dl).get(e)}registerDependencyProvider(e,r){g(this,dl).set(e,r)}hasFormatter(e){return g(this,Ss).has(e)}getFormatter(e){return g(this,Ss).get(e)??Xr.fallback}registerFormatter(e,r){g(this,Ss).set(e,r)}registerInlayHintProvider(e){g(this,pl).add(e)}get inlayHintProviders(){return g(this,pl)}getLinter(e){return g(this,ml).get(e)??{configValidator:()=>!1,linter:ni.noop,nodePredicate:()=>!1}}registerLinter(e,r){g(this,ml).set(e,r)}hasParser(e){return g(this,_s).has(e)}getParser(e){let r=g(this,_s).get(e);if(!r)throw new Error(`There is no parser '${e}'`);return r}getParserLazily(e){return Zn.create(()=>this.getParser(e))}registerParser(e,r){g(this,_s).set(e,r)}getParserForLanguageId(e){if(g(this,zt).has(e))return g(this,zt).get(e).parser;throw new Error(`There is no parser registered for language ID '${e}'`)}registerSignatureHelpProvider(e){g(this,gl).add(e)}get signatureHelpProviders(){return g(this,gl)}registerSymbolRegistrar(e,r){g(this,yl).set(e,r)}get symbolRegistrars(){return g(this,yl)}registerUriBinder(e){g(this,bl).add(e)}get uriBinders(){return g(this,bl)}setUriSorter(e){let r=g(this,Cs);L(this,Cs,(n,i)=>e(n,i,r))}get uriSorter(){return g(this,Cs)}};zt=new WeakMap,ks=new WeakMap,vs=new WeakMap,ws=new WeakMap,xs=new WeakMap,dl=new WeakMap,Ss=new WeakMap,pl=new WeakMap,ml=new WeakMap,_s=new WeakMap,gl=new WeakMap,yl=new WeakMap,bl=new WeakMap,Cs=new WeakMap;var kl,vl,io,As,Cr,Ts,Os,qm=class{constructor(e,r,n){H(this,"id");H(this,"logger");H(this,"n");E(this,kl,!1);E(this,vl,void 0);E(this,io,void 0);E(this,As,0);E(this,Cr,[]);E(this,Ts,1/0);E(this,Os,0);this.id=e,this.logger=r,this.n=n,L(this,vl,L(this,io,performance.now()))}task(e){if(g(this,kl))throw new Error("The profiler has already been finalized");r0(this,As)._++;let r=performance.now(),n=r-g(this,io);return L(this,io,r),L(this,Ts,Math.min(g(this,Ts),n)),L(this,Os,Math.max(g(this,Os),n)),g(this,Cr).push([e,n]),g(this,Cr).sort((i,o)=>o[1]-i[1]),g(this,Cr).length>this.n&&L(this,Cr,g(this,Cr).slice(0,-1)),this}finalize(){L(this,kl,!0);let e=g(this,Cr).reduce((n,[i])=>Math.max(n,i.length),0),r=g(this,io)-g(this,vl);this.logger.info(`[Profiler: ${this.id}] == Summary ==`),this.logger.info(`[Profiler: ${this.id}] Total tasks: ${g(this,As)} done in ${r} ms`),this.logger.info(`[Profiler: ${this.id}] Min/Avg/Max: ${g(this,Ts)} / ${r/g(this,As)} / ${g(this,Os)} ms`),this.logger.info(`[Profiler: ${this.id}] Top ${Math.min(this.n,g(this,Cr).length)} task(s):`);for(let[n,i]of g(this,Cr))this.logger.info(`[Profiler: ${this.id}] ${n}${" ".repeat(e-n.length)} - ${i} ms (${i/r*100}%)`)}};kl=new WeakMap,vl=new WeakMap,io=new WeakMap,As=new WeakMap,Cr=new WeakMap,Ts=new WeakMap,Os=new WeakMap;var Rx="Total",wl,xl,oo,Rs,oi,Km=class{constructor(e,r){H(this,"id");H(this,"logger");E(this,wl,!1);E(this,xl,void 0);E(this,oo,void 0);E(this,Rs,[]);E(this,oi,0);this.id=e,this.logger=r,L(this,xl,L(this,oo,performance.now()))}task(e){if(g(this,wl))throw new Error("The profiler is finalized.");let r=performance.now(),n=r-g(this,oo);return L(this,oo,r),g(this,Rs).push([e,n]),L(this,oi,Math.max(g(this,oi),e.length)),this.logger.info(`[Profiler: ${this.id}] Done: ${e} in ${n} ms`),this}finalize(){L(this,wl,!0),g(this,Rs).push([Rx,g(this,oo)-g(this,xl)]),L(this,oi,Math.max(g(this,oi),Rx.length)),this.logger.info(`[Profiler: ${this.id}] == Summary ==`);for(let[e,r]of g(this,Rs))this.logger.info(`[Profiler: ${this.id}] ${e}${" ".repeat(g(this,oi)-e.length)} - ${r} ms`)}};wl=new WeakMap,xl=new WeakMap,oo=new WeakMap,Rs=new WeakMap,oi=new WeakMap;var Gm=class{task(){return this}finalize(){}},Sl,Zm=class{constructor(e,r){H(this,"logger");E(this,Sl,void 0);this.logger=e,L(this,Sl,new Set(r))}get(e,r="total",n){if(g(this,Sl).has(e))switch(r){case"top-n":return new qm(e,this.logger,n);case"total":return new Km(e,this.logger);default:return nr.assertNever(r)}else return new Gm}static noop(){return new Zm(ls.noop(),[])}},si=Zm;Sl=new WeakMap;var Iu=Br(mu(),1);var Jm=function(t,e,r,n){var i=arguments.length,o=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(i<3?s(o):i>3?s(e,r,o):s(e,r))||o);return i>3&&o&&Object.defineProperty(e,r,o),o},yE=6e5,ai,_l,li,Qr,Es,Sn,ao,Ms,Cl,Al,_n,Ds,ci,Cn,Tl,lo,Ns,Ps,co,Tt,fo,so=class{constructor({cacheRoot:e,defaultConfig:r,downloader:n,externals:i,fs:o=ul.create(i,e),initializers:s=[],logger:a=ls.create(),profilers:l=si.noop(),projectRoot:c}){E(this,ai,new Set);E(this,_l,void 0);H(this,"cacheService");E(this,li,new Set);E(this,Qr,new Map);E(this,Es,void 0);E(this,Sn,new Set);E(this,ao,void 0);E(this,Ms,void 0);E(this,Cl,void 0);E(this,Al,void 0);E(this,_n,new Set);E(this,Ds,void 0);E(this,ci,!1);E(this,Cn,!1);H(this,"config");H(this,"downloader");H(this,"externals");H(this,"fs");H(this,"logger");H(this,"meta",new Lu);H(this,"profilers");H(this,"projectRoot");H(this,"symbols");E(this,Tl,void 0);E(this,lo,void 0);E(this,Ns,[]);E(this,Ps,void 0);E(this,co,void 0);E(this,Tt,new Map);E(this,fo,0);L(this,co,e),L(this,ao,new i.event.EventEmitter),this.externals=i,this.fs=o,L(this,Ms,s),this.logger=a,this.profilers=l,this.projectRoot=c,this.cacheService=new vu(e,this),L(this,Es,new to(this,r)),this.downloader=n??new Pu(e,i,a),this.symbols=new Le({},i.event.EventEmitter),L(this,Ps,{}),this.logger.info(`[Project] [init] cacheRoot = \u201C${e}\u201D`),g(this,Es).on("changed",({config:f})=>{this.config=f,this.logger.info("[Project] [Config] Changed")}).on("error",({error:f,uri:u})=>this.logger.error(`[Project] [Config] Failed loading \u201C${u}\u201D`,f)),this.setInitPromise(),this.setReadyPromise(),L(this,_l,setInterval(()=>this.cacheService.save(),yE)),this.on("documentUpdated",({doc:f,node:u})=>{this.emit("documentErrored",{errors:fs.getErrors(u).map(h=>lu.withPosRange(h,f)),uri:f.uri,version:f.version})}).on("documentRemoved",({uri:f})=>{this.emit("documentErrored",{errors:[],uri:f})}).on("fileCreated",async({uri:f})=>(f.endsWith(so.RootSuffix)&&this.updateRoots(),this.bindUri(f),this.ensureBindingStarted(f))).on("fileModified",async({uri:f})=>{g(this,Sn).delete(f),this.isOnlyWatched(f)&&await this.ensureBindingStarted(f)}).on("fileDeleted",({uri:f})=>{f.endsWith(so.RootSuffix)&&this.updateRoots(),g(this,Sn).delete(f),this.symbols.clear({uri:f}),this.tryClearingCache(f)}).on("ready",()=>{L(this,Cn,!0)})}get isReady(){return g(this,Cn)}get roots(){return g(this,Ns)}get ctx(){return g(this,Ps)}get cacheRoot(){return g(this,co)}updateRoots(){let e=[...g(this,Tl),this.projectRoot],r=new Set(e);for(let n of this.getTrackedFiles())n.endsWith(so.RootSuffix)&&e.some(i=>n.startsWith(i))&&r.add(n.slice(0,1-so.RootSuffix.length));L(this,Ns,[...r].sort((n,i)=>i.length-n.length)),this.emit("rootsUpdated",{roots:g(this,Ns)})}on(e,r){return g(this,ao).on(e,r),this}once(e,r){return g(this,ao).once(e,r),this}emit(e,...r){return g(this,ao).emit(e,...r)}getTrackedFiles(){let e=this.meta.getSupportedFileExtensions();return[...g(this,lo),...g(this,_n)].filter(r=>e.includes(Y.extname(r)??""))}setInitPromise(){let e=async()=>{this.config=await g(this,Es).load()},r=async()=>{let i={cacheRoot:this.cacheRoot,config:this.config,downloader:this.downloader,externals:this.externals,logger:this.logger,meta:this.meta,projectRoot:this.projectRoot},o=await Promise.allSettled(g(this,Ms).map(a=>a(i))),s={};o.forEach(async(a,l)=>{a.status==="rejected"?this.logger.error(`[Project] [callInitializers] [${l}] \u201C${g(this,Ms)[l].name}\u201D`,a.reason):a.value&&(s={...s,...a.value})}),L(this,Ps,s)};L(this,Cl,(async()=>{let i=this.profilers.get("project#init"),{symbols:o}=await this.cacheService.load();this.symbols=new Le(o,this.externals.event.EventEmitter),this.symbols.buildCache(),i.task("Load Cache"),await e(),i.task("Load Config"),await r(),i.task("Initialize").finalize()})())}setReadyPromise(){let e=async()=>{let o=[];for(let s of this.config.env.dependencies)if(Nu.is(s)){let a=this.meta.getDependencyProvider(s);if(a)try{o.push(await a()),this.logger.info(`[Project] [getDependencies] Executed provider \u201C${s}\u201D`)}catch(l){this.logger.error(`[Project] [getDependencies] Bad provider \u201C${s}\u201D`,l)}else this.logger.error(`[Project] [getDependencies] Bad dependency \u201C${s}\u201D: no associated provider`)}else o.push({uri:s});return o},r=async()=>{let o=await e(),s=await bs.create(o,this.externals,this.logger),a=await no.create(o,this.externals,this.logger,this.cacheService.checksums.roots);this.fs.register("file:",s,!0),this.fs.register(no.Protocol,a,!0)},n=()=>new Promise(o=>{g(this,_n).clear(),L(this,ci,!1),L(this,Ds,this.externals.fs.watch(this.projectRoot).once("ready",()=>{L(this,ci,!0),o()}).on("add",s=>{g(this,_n).add(s),g(this,ci)&&this.emit("fileCreated",{uri:s})}).on("change",s=>{g(this,ci)&&this.emit("fileModified",{uri:s})}).on("unlink",s=>{g(this,_n).delete(s),g(this,ci)&&this.emit("fileDeleted",{uri:s})}).on("error",s=>{this.logger.error("[Project] [chokidar]",s)}))}),i=async()=>{await this.init();let o=this.profilers.get("project#ready");await Promise.all([r(),n()]),L(this,lo,new Set(this.fs.listFiles())),L(this,Tl,new Set(this.fs.listRoots())),this.updateRoots(),o.task("List URIs");for(let[u,{checksum:h,registrar:d}]of this.meta.symbolRegistrars){let p=this.cacheService.checksums.symbolRegistrars[u];p===void 0||h!==p?(this.symbols.clear({contributor:`symbol_registrar/${u}`}),this.symbols.contributeAs(`symbol_registrar/${u}`,()=>{d(this.symbols,{logger:this.logger})}),this.emit("symbolRegistrarExecuted",{id:u,checksum:h})):this.logger.info(`[SymbolRegistrar] Skipped \u201C${u}\u201D thanks to cache ${h}`)}o.task("Register Symbols");for(let[u,h]of Object.entries(this.cacheService.errors))this.emit("documentErrored",{errors:h,uri:u});o.task("Pop Errors");let{addedFiles:s,changedFiles:a,removedFiles:l}=await this.cacheService.validate();for(let u of l)this.emit("fileDeleted",{uri:u});o.task("Validate Cache"),s.length>0&&this.bindUri(s),o.task("Bind URIs");let c=[...s,...a].sort(this.meta.uriSorter);o.task("Sort URIs");let f=this.profilers.get("project#ready#bind","top-n",50);for(let u of c)await this.ensureBindingStarted(u),f.task(u);f.finalize(),o.task("Bind Files"),o.finalize(),this.emit("ready",{})};L(this,Cn,!1),L(this,Al,i())}async init(){return await g(this,Cl),this}async ready(){return await g(this,Al),this}async close(){clearInterval(g(this,_l)),await g(this,Ds).close(),await this.cacheService.save()}async restart(){try{await g(this,Ds).close(),g(this,ai).clear(),g(this,Sn).clear(),this.setReadyPromise(),await this.ready()}catch(e){this.logger.error("[Project#reset]",e)}}resetCache(){this.logger.info("[Project#resetCache] Initiated...");for(let r of Object.keys(this.cacheService.errors))this.emit("documentErrored",{errors:[],uri:r});let{symbols:e}=this.cacheService.reset();return this.symbols=new Le(e,this.externals.event.EventEmitter),this.symbols.buildCache(),this.restart()}normalizeUri(e){return this.fs.mapFromDisk(jw(e))}removeCachedTextDocument(e){let r=g(this,Tt).get(e);r&&!(r instanceof Promise)&&L(this,fo,g(this,fo)-r.getText().length),g(this,Tt).delete(e)}async read(e){let r=s=>{let a=Y.extname(s)??".plaintext";return this.meta.getLanguageID(a)??a.slice(1)},n=async s=>{let a=r(s);if(this.meta.isSupportedLanguage(a))try{let l=ir(await this.fs.readFile(s));return Iu.TextDocument.create(s,a,-1,l)}catch(l){this.logger.warn(`[Project] [read] Failed creating TextDocument for \u201C${s}\u201D`,l);return}},i=()=>{let s=g(this,Tt).keys();for(;g(this,fo)>so.TextDocumentCacheMaxLength;){let a=s.next();if(a.done)throw new Error(`[Project] [read] Cache is too large with length ${g(this,fo)} even though it's empty; make sure to call 'removeCachedTextDocument()' instead of 'this.#textDocumentCache.delete()'`);this.removeCachedTextDocument(a.value)}},o=async s=>{if(g(this,Tt).has(s)){let a=g(this,Tt).get(s);return g(this,Tt).delete(s),g(this,Tt).set(s,a),a}else{let a=n(s);g(this,Tt).set(s,a);let l=await a;return g(this,Tt).get(s)===a&&(l?(g(this,Tt).set(s,l),L(this,fo,g(this,fo)+l.getText().length),i()):g(this,Tt).delete(s)),l}};if(e=this.normalizeUri(e),g(this,li).has(e)){let s=g(this,Qr).get(e);if(s)return s.doc;throw new Error(`[Project] [read] Client-managed URI \u201C${e}\u201D does not have a TextDocument in the cache`)}return o(e)}parse(e){let r=_u.create(this,{doc:e}),n=new Ce(e.getText());return Ex()(n,r)}async bind(e,r){if(!r.binderErrors)try{g(this,ai).add(e.uri);let n=this.meta.getBinder(r.type),i=Cu.create(this,{doc:e});i.symbols.clear({contributor:"binder",uri:e.uri}),await i.symbols.contributeAsAsync("binder",async()=>{let o=Qe.create(r);await n(o,i),r.binderErrors=i.err.dump()}),g(this,ai).delete(e.uri),g(this,Sn).add(e.uri)}catch(n){this.logger.error(`[Project] [bind] Failed for \u201C${e.uri}\u201D #${e.version}`,n)}}async check(e,r){if(!r.checkerErrors)try{let n=this.meta.getChecker(r.type),i=Au.create(this,{doc:e});i.symbols.clear({contributor:"checker",uri:e.uri}),await i.symbols.contributeAsAsync("checker",async()=>{await n(Qe.create(r),i),r.checkerErrors=i.err.dump(),this.lint(e,r)})}catch(n){this.logger.error(`[Project] [check] Failed for \u201C${e.uri}\u201D #${e.version}`,n)}}lint(e,r){if(!r.linterErrors){r.linterErrors=[];try{for(let[n,i]of Object.entries(this.config.lint)){let o=gs.destruct(i);if(!o)continue;let{ruleSeverity:s,ruleValue:a}=o,{configValidator:l,linter:c,nodePredicate:f}=this.meta.getLinter(n);if(!l(n,a,this.logger))continue;let u=Tu.create(this,{doc:e,err:new ys(n,s),ruleName:n,ruleValue:a});At(r,()=>!0,()=>!0,h=>{if(f(h)){let d=Qe.create(h);c(d,u)}}),r.linterErrors.push(...u.err.dump())}}catch(n){this.logger.error(`[Project] [lint] Failed for \u201C${e.uri}\u201D #${e.version}`,n)}}}async ensureBindingStarted(e){if(e=this.normalizeUri(e),g(this,Sn).has(e)||g(this,ai).has(e))return;g(this,ai).add(e);let r=await this.read(e);if(!r||!await this.cacheService.hasFileChangedSinceCache(r))return;let n=this.parse(r);await this.bind(r,n),this.emit("documentUpdated",{doc:r,node:n})}bindUri(e){let r=Du.create(this);typeof e=="string"&&r.symbols.clear({contributor:"uri_binder",uri:e}),r.symbols.contributeAs("uri_binder",()=>{let n=Array.isArray(e)?e:[e];for(let i of this.meta.uriBinders)i(n,r)})}async onDidOpen(e,r,n,i){if(e=this.normalizeUri(e),!Y.isFileUri(e))return;let o=Iu.TextDocument.create(e,r,n,i),s=this.parse(o);g(this,li).add(e),g(this,Qr).set(e,{doc:o,node:s}),g(this,Cn)&&(await this.bind(o,s),await this.check(o,s))}async onDidChange(e,r,n){if(e=this.normalizeUri(e),g(this,Sn).delete(e),!Y.isFileUri(e))return;let i=g(this,Qr).get(e)?.doc;if(!i)throw new Error(`TextDocument for \u201C${e}\u201D is ${i?"a Promise":"not cached"}. This should not happen. Did the language client send a didChange notification without sending a didOpen one, or is there a logic error on our side resulting the 'read' function overriding the 'TextDocument' created in the 'didOpen' notification handler?`);Iu.TextDocument.update(i,r,n);let o=this.parse(i);g(this,Qr).set(e,{doc:i,node:o}),g(this,Cn)&&(await this.bind(i,o),await this.check(i,o))}onDidClose(e){e=this.normalizeUri(e),Y.isFileUri(e)&&(g(this,li).delete(e),g(this,Qr).delete(e),this.tryClearingCache(e))}async ensureClientManagedChecked(e){e=this.normalizeUri(e);let r=g(this,Qr).get(e);if(r){let{doc:n,node:i}=r;return g(this,Cn)&&(await this.bind(n,i),await this.check(n,i),this.emit("documentUpdated",r)),r}}getClientManaged(e){return e=this.normalizeUri(e),g(this,Qr).get(e)}async showCacheRoot(){if(g(this,co))try{await this.externals.fs.showFile(g(this,co))}catch(e){this.logger.error("[Service#showCacheRoot]",e)}}tryClearingCache(e){this.shouldRemove(e)&&(this.removeCachedTextDocument(e),this.emit("documentRemoved",{uri:e}))}shouldRemove(e){return!g(this,li).has(e)&&!g(this,lo).has(e)&&!g(this,_n).has(e)}isOnlyWatched(e){return g(this,_n).has(e)&&!g(this,li).has(e)&&!g(this,lo).has(e)}},An=so;ai=new WeakMap,_l=new WeakMap,li=new WeakMap,Qr=new WeakMap,Es=new WeakMap,Sn=new WeakMap,ao=new WeakMap,Ms=new WeakMap,Cl=new WeakMap,Al=new WeakMap,_n=new WeakMap,Ds=new WeakMap,ci=new WeakMap,Cn=new WeakMap,Tl=new WeakMap,lo=new WeakMap,Ns=new WeakMap,Ps=new WeakMap,co=new WeakMap,Tt=new WeakMap,fo=new WeakMap,H(An,"RootSuffix","/pack.mcmeta"),H(An,"TextDocumentCacheMaxLength",268435456);Jm([nu()],An.prototype,"bind",null);Jm([nu()],An.prototype,"check",null);Jm([nu()],An.prototype,"ensureClientManagedChecked",null);var Bu;(function(t){function e(r,n){return{range:v.get(r),locations:n}}t.create=e})(Bu||(Bu={}));var ju=class{isDebugging;logger;profilers;project;constructor({isDebugging:e=!1,logger:r,profilers:n=si.noop(),project:i}){this.isDebugging=e,this.logger=r,this.profilers=n,this.project=new An({logger:r,profilers:n,...i})}debug(e){this.isDebugging&&this.logger.info(`[DEBUG] ${e}`)}colorize(e,r,n){try{return this.debug(`Colorizing '${r.uri}' # ${r.version}`),this.project.meta.getColorizer(e.type)(e,Ru.create(this.project,{doc:r,range:n}))}catch(i){this.logger.error(`[Service] [colorize] Failed for \u201C${r.uri}\u201D #${r.version}`,i)}return[]}getColorInfo(e,r){try{this.debug(`Getting color info for '${r.uri}' # ${r.version}`);let n=[];return At(e,i=>!0,i=>i.color,i=>n.push({color:Array.isArray(i.color)?i.color:i.color.value,range:Array.isArray(i.color)?i.range:i.color.range??i.range})),n}catch(n){this.logger.error(`[Service] [getColorInfo] Failed for \u201C${r.uri}\u201D #${r.version}`,n)}return[]}getColorPresentation(e,r,n,i){try{this.debug(`Getting color presentation for '${r.uri}' # ${r.version} @ ${v.toString(n)}`);let o=Ke.findDeepestChild({node:e,needle:n.start});for(;o;){let s=o.color;if(s&&!Array.isArray(s)){let a=s.range??o.range;return s.format.map(l=>xu.fromColorFormat(l,i,a))}o=o.parent}}catch(o){this.logger.error(`[Service] [getColorPresentation] Failed for \u201C${r.uri}\u201D #${r.version}`,o)}return[]}complete(e,r,n,i){try{if(this.debug(`Getting completion for '${r.uri}' # ${r.version} @ ${n}`),this.project.meta.shouldComplete(r.languageId,i))return re.file(e,Eu.create(this.project,{doc:r,offset:n,triggerCharacter:i}))}catch(o){this.logger.error(`[Service] [complete] Failed for \u201C${r.uri}\u201D #${r.version}`,o)}return[]}dataHackPubify(e){let r=[["ata","ack","ub","elper","lus"],["ah","uh","ew","elpa","lush"]],n=r[Math.floor(Math.random()*r.length)];return[...e].map((i,o)=>`${i.toUpperCase()}${n[o%n.length]}`).join(" ")}format(e,r,n,i){try{return this.debug(`Formatting '${r.uri}' # ${r.version}`),this.project.meta.getFormatter(e.type)(e,Ou.create(this.project,{doc:r,tabSize:n,insertSpaces:i}))}catch(o){throw this.logger.error(`[Service] [format] Failed for \u201C${r.uri}\u201D #${r.version}`,o),o}}getHover(e,r,n){try{this.debug(`Getting hover for '${r.uri}' # ${r.version} @ ${n}`);let i=Ke.findDeepestChild({node:e,needle:n});for(;i;){let o=this.project.symbols.resolveAlias(i.symbol);if(o){let s=`\`\`\`typescript (${o.category}${o.subcategory?`/${o.subcategory}`:""}) ${o.identifier} \`\`\``+(o.desc?` ****** -${o.desc}`:"");return hl.create(i.range,s)}if(i.hover)return hl.create(i.range,i.hover);i=i.parent}}catch(i){this.logger.error(`[Service] [getHover] Failed for \u201C${r.uri}\u201D #${r.version}`,i)}}getInlayHints(e,r,n){try{this.debug(`Getting inlay hints for '${r.uri}' # ${r.version}`);let i=[],o=_r.create(this.project,{doc:r});for(let s of this.project.meta.inlayHintProviders)i.push(...s(e,o));return i}catch(i){this.logger.error(`[Service] [getInlayHints] Failed for \u201C${r.uri}\u201D #${r.version}`,i)}return[]}getSignatureHelp(e,r,n){try{this.debug(`Getting signature help for '${r.uri}' # ${r.version} @ ${n}`);let i=Mu.create(this.project,{doc:r,offset:n});for(let o of this.project.meta.signatureHelpProviders){let s=o(e,i);if(s)return s}}catch(i){this.logger.error(`[Service] [getSignatureHelp] Failed for \u201C${r.uri}\u201D #${r.version}`,i)}}async getSymbolLocations(e,r,n,i=Zi,o=!1){try{this.debug(`Getting symbol locations of usage '${i.join(",")}' for '${r.uri}' # ${r.version} @ ${n} with currentFileOnly=${o}`);let s=Ke.findDeepestChild({node:e,needle:n});for(;s;){let a=this.project.symbols.resolveAlias(s.symbol);if(a){let l=[];for(let f of i){let u=a[f]??[];o&&(u=u.filter(h=>h.uri===r.uri)),l.push(...u)}let c=[];for(let f of l){let u=Y.isFileUri(f.uri)?f.uri:await this.project.fs.mapToDisk(f.uri);u&&c.push({...f,uri:u})}return Bu.create(s.range,c.length?c:void 0)}s=s.parent}}catch(s){this.logger.error(`[Service] [getSymbolLocations] Failed for \u201C${r.uri}\u201D #${r.version}`,s)}}};var V=Symbol("Failure");function zt(t,e,r){let n=e.clone(),i={...r,err:new ut};return{result:t(n,i),endCursor:n.cursor,errorAmount:i.err.errors.length,updateSrcAndCtx:()=>{e.innerCursor=n.innerCursor,r.err.absorb(i.err)}}}function be(t,e){return(r,n)=>{let i={[Qa]:!0,children:[],range:v.create(r)};for(let[o,s]of t.entries()){let a=typeof s=="function"?s:s.get(i);if(a===void 0)continue;o>0&&e&&i.children.push(...e(r,n));let l=a(r,n);if(l===V)return V;if(l===void 0)continue;Xa.is(l)?i.children.push(...l.children):i.children.push(l)}return i.range.end=r.cursor,i}}function Ls(t,e){return(r,n)=>{let i={[Qa]:!0,children:[],range:v.create(r)};for(;r.canRead();){e&&i.children.push(...e(r,n));let{result:o,updateSrcAndCtx:s}=zt(t,r,n);if(o===V)break;s(),Xa.is(o)?i.children.push(...o.children):i.children.push(o)}return i.range.end=r.cursor,i}}function ar(t,e){return(r,n)=>{let i=t.map((o,s)=>({attempt:zt(o,r,n),index:s})).filter(({attempt:o})=>o.result!==V).sort((o,s)=>s.attempt.endCursor-o.attempt.endCursor||o.attempt.errorAmount-s.attempt.errorAmount);return i.length===0?(e&&(e.index=-1),V):(i[0].attempt.updateSrcAndCtx(),e&&(e.index=i[0].index),i[0].attempt.result)}}function oe(t){return(e,r)=>{let n=e.cursor,{endCursor:i,updateSrcAndCtx:o,result:s}=zt(t,e,r);return i-n>0?(o(),s):V}}function Ol(t){return(e,r)=>{let n=e.cursor,{errorAmount:i,updateSrcAndCtx:o,result:s}=zt(t,e,r);return i?V:(o(),s)}}function ke(t){return(e,r)=>{let{result:n,updateSrcAndCtx:i}=zt(t,e,r);if(n!==V)return i(),n}}function ne(t){return(e,r)=>{for(let{predicate:n,prefix:i,parser:o,regex:s}of t)if(n?.(e)??(i!==void 0?e.tryPeek(i):void 0)??(s&&e.matchPattern(s))??!0)return(typeof o=="object"?o.get():o)(e,r);throw new Error("The select parser util was called with non-exhaustive cases")}}function J(t,e){return(r,n)=>{let i=t(r,n);return i===V?V:e(i,r,n)}}function se(t,e){return J(e,r=>{let{type:n,...i}=r,o={type:t,...i};return delete o[Qa],o})}function Is(t,e,r,n){return J(t,(i,o,s)=>(e(i,o,s)||s.err.report(r,i.range,n),i))}function Tn(t,...e){let r=e.flat();return(n,i)=>{let o=n.clone();o.string=o.string.slice(0,r.reduce((a,l)=>{let c=o.string.indexOf(l,o.innerCursor);return Math.min(a,c===-1?1/0:c)},1/0));let s=t(o,i);return n.cursor=o.cursor,s}}var $u=J(Oe("false","true"),t=>({type:"boolean",range:t.range,value:t.value===""?void 0:t.value==="true"}));function Rl({singleLinePrefixes:t,includesEol:e}){return(r,n)=>{let i=r.cursor,o={type:"comment",range:v.create(i),comment:""};for(let s of t)if(r.peek(s.length)===s)return e?r.nextLine():r.skipLine(),o.range.end=r.cursor,o.comment=r.sliceToCursor(i+s.length),o;return V}}var Ox=(t,e)=>{if(!t.canRead())return;let r={type:"error",range:v.create(t,()=>t.skipRemaining())};return e.err.report(y("error.unparseable-content"),r),r};function Tx(){return(t,e)=>{let n={type:"file",range:v.create(t,t.string.length),children:[],locals:Object.create(null),parserErrors:[]};t.skipWhitespace();let o=e.meta.getParserForLanguageId(e.doc.languageId)(t,e);return o&&o!==V&&n.children.push(o),t.skipWhitespace().canRead()&&n.children.push(Ox(t,e)),Ke.setParents(n),n.parserErrors=e.err.dump(),n}}var mE=(t,e,r,n)=>{r.err.report(y("expected",y("float.between",n.min??"-\u221E",n.max??"+\u221E")),t,3)};function en(t){return(e,r)=>{let n={type:"float",range:v.create(e),value:0};for((e.peek()==="-"||e.peek()==="+")&&e.skip();e.canRead()&&_e.isDigit(e.peek());)e.skip();if(e.trySkip("."))for(;e.canRead()&&_e.isDigit(e.peek());)e.skip();if(e.peek().toLowerCase()==="e")for(e.skip(),(e.peek()==="-"||e.peek()==="+")&&e.skip();e.canRead()&&_e.isDigit(e.peek());)e.skip();n.range.end=e.cursor;let i=e.sliceToCursor(n.range.start);if(n.value=parseFloat(i)||0,i)t.pattern.test(i)?(t.min&&n.valuet.max)&&(t.onOutOfRange??mE)(n,e,r,t):r.err.report(y("parser.float.illegal",t.pattern),n);else{if(t.failsOnEmpty)return V;r.err.report(y("expected",y("float")),n)}return n}}var gE=(t,e,r,n)=>{r.err.report(y("expected",y("integer.between",n.min??"-\u221E",n.max??"+\u221E")),t,3)};function Ar(t){return(e,r)=>{let n={type:"integer",range:v.create(e),value:0};for((e.peek()==="-"||e.peek()==="+")&&e.skip();e.canRead()&&_e.isDigit(e.peek());)e.skip();n.range.end=e.cursor;let i=e.sliceToCursor(n.range.start),o=i==="-"||i==="+";if(o||(n.value=Number(i)),i)!t.pattern.test(i)||o?r.err.report(y("parser.integer.illegal",t.pattern),n):(t.min!==void 0&&n.valuet.max)&&(t.onOutOfRange??gE)(n,e,r,t);else{if(t.failsOnEmpty)return V;r.err.report(y("expected",y("integer")),n)}return n}}function fi({start:t,value:e,sep:r,trailingSep:n,end:i}){return(o,s)=>{let a={type:"list",range:v.create(o),children:[]};if(o.trySkip(t)){o.skipWhitespace();let l=!1,c=!1;for(;o.canRead()&&o.peek(i.length)!==i;){let f=o.cursor,u;l&&!c&&s.err.report(y("expected",P(r)),o),o.skipWhitespace();let{result:h,endCursor:d,updateSrcAndCtx:p}=zt(e,o,s);h===V||d===o.cursor?s.err.report(y("expected",y("parser.list.value")),v.create(o,()=>o.skipUntilOrEnd(r,i,"\r",` -`))):(p(),u=h);let b;o.skipWhitespace(),l=!0,(c=o.peek(r.length)===r)&&(b=v.create(o,()=>o.skip(r.length))),a.children.push({type:"item",range:v.create(f,o),...u?{children:[u]}:{},value:u,sep:b}),o.skipWhitespace()}c&&!n&&s.err.report(y("parser.list.trailing-sep"),a.children[a.children.length-1].sep),o.trySkip(i)||s.err.report(y("expected",P(i)),o)}else s.err.report(y("expected",P(t)),o);return a.range.end=o.cursor,a}}var yE=(t,e,r,n)=>{r.err.report(y("expected",y("long.between",n.min??"-\u221E",n.max??"+\u221E")),t,3)};function El(t){return(e,r)=>{let n={type:"long",range:v.create(e),value:0n};for((e.peek()==="-"||e.peek()==="+")&&e.skip();e.canRead()&&_e.isDigit(e.peek());)e.skip();n.range.end=e.cursor;let i=e.sliceToCursor(n.range.start),o=!1;try{n.value=BigInt(i)}catch{o=!0}if(i)!t.pattern.test(i)||o?r.err.report(y("parser.long.illegal",t.pattern),n):(t.min&&n.valuet.max)&&(t.onOutOfRange??yE)(n,e,r,t);else{if(t.failsOnEmpty)return V;r.err.report(y("expected",y("long")),n)}return n}}function Tr({start:t,pair:e,end:r}){return(n,i)=>{let o={type:"record",range:v.create(n),children:[]};if(n.trySkip(t)){n.skipWhitespace();let s=!1,a=!1;for(;n.canRead()&&n.peek(r.length)!==r;){let l=n.cursor,c,f;s&&!a&&i.err.report(y("expected",P(e.end)),n);let u=n.cursor,{result:h,updateSrcAndCtx:d,endCursor:p}=zt(e.key,n,i);h===V||p-u===0&&![e.sep,e.end,r,"\r",` +${o.desc}`:"");return hl.create(i.range,s)}if(i.hover)return hl.create(i.range,i.hover);i=i.parent}}catch(i){this.logger.error(`[Service] [getHover] Failed for \u201C${r.uri}\u201D #${r.version}`,i)}}getInlayHints(e,r,n){try{this.debug(`Getting inlay hints for '${r.uri}' # ${r.version}`);let i=[],o=_r.create(this.project,{doc:r});for(let s of this.project.meta.inlayHintProviders)i.push(...s(e,o));return i}catch(i){this.logger.error(`[Service] [getInlayHints] Failed for \u201C${r.uri}\u201D #${r.version}`,i)}return[]}getSignatureHelp(e,r,n){try{this.debug(`Getting signature help for '${r.uri}' # ${r.version} @ ${n}`);let i=Mu.create(this.project,{doc:r,offset:n});for(let o of this.project.meta.signatureHelpProviders){let s=o(e,i);if(s)return s}}catch(i){this.logger.error(`[Service] [getSignatureHelp] Failed for \u201C${r.uri}\u201D #${r.version}`,i)}}async getSymbolLocations(e,r,n,i=Zi,o=!1){try{this.debug(`Getting symbol locations of usage '${i.join(",")}' for '${r.uri}' # ${r.version} @ ${n} with currentFileOnly=${o}`);let s=Ke.findDeepestChild({node:e,needle:n});for(;s;){let a=this.project.symbols.resolveAlias(s.symbol);if(a){let l=[];for(let f of i){let u=a[f]??[];o&&(u=u.filter(h=>h.uri===r.uri)),l.push(...u)}let c=[];for(let f of l){let u=Y.isFileUri(f.uri)?f.uri:await this.project.fs.mapToDisk(f.uri);u&&c.push({...f,uri:u})}return Bu.create(s.range,c.length?c:void 0)}s=s.parent}}catch(s){this.logger.error(`[Service] [getSymbolLocations] Failed for \u201C${r.uri}\u201D #${r.version}`,s)}}};var V=Symbol("Failure");function Ft(t,e,r){let n=e.clone(),i={...r,err:new ht};return{result:t(n,i),endCursor:n.cursor,errorAmount:i.err.errors.length,updateSrcAndCtx:()=>{e.innerCursor=n.innerCursor,r.err.absorb(i.err)}}}function be(t,e){return(r,n)=>{let i={[Qa]:!0,children:[],range:v.create(r)};for(let[o,s]of t.entries()){let a=typeof s=="function"?s:s.get(i);if(a===void 0)continue;o>0&&e&&i.children.push(...e(r,n));let l=a(r,n);if(l===V)return V;if(l===void 0)continue;Xa.is(l)?i.children.push(...l.children):i.children.push(l)}return i.range.end=r.cursor,i}}function Ls(t,e){return(r,n)=>{let i={[Qa]:!0,children:[],range:v.create(r)};for(;r.canRead();){e&&i.children.push(...e(r,n));let{result:o,updateSrcAndCtx:s}=Ft(t,r,n);if(o===V)break;s(),Xa.is(o)?i.children.push(...o.children):i.children.push(o)}return i.range.end=r.cursor,i}}function ar(t,e){return(r,n)=>{let i=t.map((o,s)=>({attempt:Ft(o,r,n),index:s})).filter(({attempt:o})=>o.result!==V).sort((o,s)=>s.attempt.endCursor-o.attempt.endCursor||o.attempt.errorAmount-s.attempt.errorAmount);return i.length===0?(e&&(e.index=-1),V):(i[0].attempt.updateSrcAndCtx(),e&&(e.index=i[0].index),i[0].attempt.result)}}function oe(t){return(e,r)=>{let n=e.cursor,{endCursor:i,updateSrcAndCtx:o,result:s}=Ft(t,e,r);return i-n>0?(o(),s):V}}function Ol(t){return(e,r)=>{let n=e.cursor,{errorAmount:i,updateSrcAndCtx:o,result:s}=Ft(t,e,r);return i?V:(o(),s)}}function ke(t){return(e,r)=>{let{result:n,updateSrcAndCtx:i}=Ft(t,e,r);if(n!==V)return i(),n}}function ne(t){return(e,r)=>{for(let{predicate:n,prefix:i,parser:o,regex:s}of t)if(n?.(e)??(i!==void 0?e.tryPeek(i):void 0)??(s&&e.matchPattern(s))??!0)return(typeof o=="object"?o.get():o)(e,r);throw new Error("The select parser util was called with non-exhaustive cases")}}function J(t,e){return(r,n)=>{let i=t(r,n);return i===V?V:e(i,r,n)}}function se(t,e){return J(e,r=>{let{type:n,...i}=r,o={type:t,...i};return delete o[Qa],o})}function Is(t,e,r,n){return J(t,(i,o,s)=>(e(i,o,s)||s.err.report(r,i.range,n),i))}function Tn(t,...e){let r=e.flat();return(n,i)=>{let o=n.clone();o.string=o.string.slice(0,r.reduce((a,l)=>{let c=o.string.indexOf(l,o.innerCursor);return Math.min(a,c===-1?1/0:c)},1/0));let s=t(o,i);return n.cursor=o.cursor,s}}var $u=J(we("false","true"),t=>({type:"boolean",range:t.range,value:t.value===""?void 0:t.value==="true"}));function Rl({singleLinePrefixes:t,includesEol:e}){return(r,n)=>{let i=r.cursor,o={type:"comment",range:v.create(i),comment:""};for(let s of t)if(r.peek(s.length)===s)return e?r.nextLine():r.skipLine(),o.range.end=r.cursor,o.comment=r.sliceToCursor(i+s.length),o;return V}}var Mx=(t,e)=>{if(!t.canRead())return;let r={type:"error",range:v.create(t,()=>t.skipRemaining())};return e.err.report(y("error.unparseable-content"),r),r};function Ex(){return(t,e)=>{let n={type:"file",range:v.create(t,t.string.length),children:[],locals:Object.create(null),parserErrors:[]};t.skipWhitespace();let o=e.meta.getParserForLanguageId(e.doc.languageId)(t,e);return o&&o!==V&&n.children.push(o),t.skipWhitespace().canRead()&&n.children.push(Mx(t,e)),Ke.setParents(n),n.parserErrors=e.err.dump(),n}}var bE=(t,e,r,n)=>{r.err.report(y("expected",y("float.between",n.min??"-\u221E",n.max??"+\u221E")),t,3)};function en(t){return(e,r)=>{let n={type:"float",range:v.create(e),value:0};for((e.peek()==="-"||e.peek()==="+")&&e.skip();e.canRead()&&Ce.isDigit(e.peek());)e.skip();if(e.trySkip("."))for(;e.canRead()&&Ce.isDigit(e.peek());)e.skip();if(e.peek().toLowerCase()==="e")for(e.skip(),(e.peek()==="-"||e.peek()==="+")&&e.skip();e.canRead()&&Ce.isDigit(e.peek());)e.skip();n.range.end=e.cursor;let i=e.sliceToCursor(n.range.start);if(n.value=parseFloat(i)||0,i)t.pattern.test(i)?(t.min&&n.valuet.max)&&(t.onOutOfRange??bE)(n,e,r,t):r.err.report(y("parser.float.illegal",t.pattern),n);else{if(t.failsOnEmpty)return V;r.err.report(y("expected",y("float")),n)}return n}}var kE=(t,e,r,n)=>{r.err.report(y("expected",y("integer.between",n.min??"-\u221E",n.max??"+\u221E")),t,3)};function Ar(t){return(e,r)=>{let n={type:"integer",range:v.create(e),value:0};for((e.peek()==="-"||e.peek()==="+")&&e.skip();e.canRead()&&Ce.isDigit(e.peek());)e.skip();n.range.end=e.cursor;let i=e.sliceToCursor(n.range.start),o=i==="-"||i==="+";if(o||(n.value=Number(i)),i)!t.pattern.test(i)||o?r.err.report(y("parser.integer.illegal",t.pattern),n):(t.min!==void 0&&n.valuet.max)&&(t.onOutOfRange??kE)(n,e,r,t);else{if(t.failsOnEmpty)return V;r.err.report(y("expected",y("integer")),n)}return n}}function fi({start:t,value:e,sep:r,trailingSep:n,end:i}){return(o,s)=>{let a={type:"list",range:v.create(o),children:[]};if(o.trySkip(t)){o.skipWhitespace();let l=!1,c=!1;for(;o.canRead()&&o.peek(i.length)!==i;){let f=o.cursor,u;l&&!c&&s.err.report(y("expected",P(r)),o),o.skipWhitespace();let{result:h,endCursor:d,updateSrcAndCtx:p}=Ft(e,o,s);h===V||d===o.cursor?s.err.report(y("expected",y("parser.list.value")),v.create(o,()=>o.skipUntilOrEnd(r,i,"\r",` +`))):(p(),u=h);let b;o.skipWhitespace(),l=!0,(c=o.peek(r.length)===r)&&(b=v.create(o,()=>o.skip(r.length))),a.children.push({type:"item",range:v.create(f,o),...u?{children:[u]}:{},value:u,sep:b}),o.skipWhitespace()}c&&!n&&s.err.report(y("parser.list.trailing-sep"),a.children[a.children.length-1].sep),o.trySkip(i)||s.err.report(y("expected",P(i)),o)}else s.err.report(y("expected",P(t)),o);return a.range.end=o.cursor,a}}var vE=(t,e,r,n)=>{r.err.report(y("expected",y("long.between",n.min??"-\u221E",n.max??"+\u221E")),t,3)};function El(t){return(e,r)=>{let n={type:"long",range:v.create(e),value:0n};for((e.peek()==="-"||e.peek()==="+")&&e.skip();e.canRead()&&Ce.isDigit(e.peek());)e.skip();n.range.end=e.cursor;let i=e.sliceToCursor(n.range.start),o=!1;try{n.value=BigInt(i)}catch{o=!0}if(i)!t.pattern.test(i)||o?r.err.report(y("parser.long.illegal",t.pattern),n):(t.min&&n.valuet.max)&&(t.onOutOfRange??vE)(n,e,r,t);else{if(t.failsOnEmpty)return V;r.err.report(y("expected",y("long")),n)}return n}}function Tr({start:t,pair:e,end:r}){return(n,i)=>{let o={type:"record",range:v.create(n),children:[]};if(n.trySkip(t)){n.skipWhitespace();let s=!1,a=!1;for(;n.canRead()&&n.peek(r.length)!==r;){let l=n.cursor,c,f;s&&!a&&i.err.report(y("expected",P(e.end)),n);let u=n.cursor,{result:h,updateSrcAndCtx:d,endCursor:p}=Ft(e.key,n,i);h===V||p-u===0&&![e.sep,e.end,r,"\r",` `," "," "].includes(n.peek())?i.err.report(y("expected",y("parser.record.key")),v.create(n,()=>n.skipUntilOrEnd(e.sep,e.end,r,"\r",` -`))):(d(),c=h);let b;n.skipWhitespace(),n.peek(e.sep.length)===e.sep?b=v.create(n,()=>n.skip(e.sep.length)):i.err.report(y("expected",P(e.sep)),n),n.skipWhitespace();let m=typeof e.value=="function"?e.value:e.value.get(o,c),k=n.cursor,{result:S,updateSrcAndCtx:_,endCursor:w}=zt(m,n,i);S===V||w-k===0&&![e.sep,e.end,r,"\r",` +`))):(d(),c=h);let b;n.skipWhitespace(),n.peek(e.sep.length)===e.sep?b=v.create(n,()=>n.skip(e.sep.length)):i.err.report(y("expected",P(e.sep)),n),n.skipWhitespace();let m=typeof e.value=="function"?e.value:e.value.get(o,c),k=n.cursor,{result:S,updateSrcAndCtx:_,endCursor:w}=Ft(m,n,i);S===V||w-k===0&&![e.sep,e.end,r,"\r",` `," "," "].includes(n.peek())?i.err.report(y("expected",y("parser.record.value")),v.create(n,()=>n.skipUntilOrEnd(e.sep,e.end,r,"\r",` -`))):(_(),f=S);let C;n.skipWhitespace(),s=!0,(a=n.peek(e.end.length)===e.end)&&(C=v.create(n,()=>n.skip(e.end.length))),o.children.push({type:"pair",range:v.create(l,n),...c||f?{children:[c,f].filter(R=>!!R)}:{},key:c,sep:b,value:f,end:C}),n.skipWhitespace()}a&&!e.trailingEnd&&i.err.report(y("parser.record.trailing-end"),o.children[o.children.length-1].end),n.trySkip(r)||i.err.report(y("expected",P(r)),n)}else i.err.report(y("expected",P(t)),n);return o.range.end=n.cursor,o}}var bE=new Set([" ","\r",` -`,"=",",",'"',"'","{","}","[","]","(",")",";"]),Rx=new Set(["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","_","-","."]);function Re(t){return(e,r)=>{let n={type:"resource_location",range:v.create(e),options:t};e.trySkip(q.TagPrefix)&&(n.isTag=!0);let i=e.cursor;for(;e.canReadInLine()&&!bE.has(e.peek());)e.skip();let o=e.sliceToCursor(i);if(n.range.end=e.cursor,o.length===0)r.err.report(y("expected",y("resource-location")),n);else{let s=o.indexOf(t.namespacePathSep??q.NamespacePathSep);s>=0&&(n.namespace=o.slice(0,s));let a=o.slice(s+1);n.path=a.split(q.PathSep);let l=[...new Set([...[...n.namespace??[]].filter(c=>!Rx.has(c)),...[...a].filter(c=>c!=="/"&&!Rx.has(c))])];l.length&&r.err.report(y("parser.resource-location.illegal",vn(l,!0,"and")),n),n.isTag&&!t.allowTag&&r.err.report(y("parser.resource-location.tag-diallowed"),n),!n.namespace&&t.isPredicate&&r.err.report(y("parser.resource-location.namespace-expected"),n)}return n}}var Ex=Br(mu(),1);function dt(t){return(e,r)=>{let n={type:"string",range:v.create(e),options:t,value:"",valueMap:[]},i=e.cursor;if(t.quotes?.length&&(e.peek()==='"'||e.peek()==="'")){let o=e.read(),s=e.cursor;for(;e.canRead()&&e.peek()!==o;){let a=e.peek();if(t.escapable&&a==="\\"){let l=e.cursor;e.skip();let c=e.read();if(c==="\\"||c===o||hu.is(t.escapable.characters,c))n.valueMap.push({inner:v.create(n.value.length,n.value.length+1),outer:v.create(l,e)}),n.value+=Fw.get(c);else if(t.escapable.unicode&&c==="u"){let f=e.peek(4);/^[0-9a-f]{4}$/i.test(f)?(e.skip(4),n.valueMap.push({inner:v.create(n.value.length,n.value.length+1),outer:v.create(l,e)}),n.value+=String.fromCharCode(parseInt(f,16))):(r.err.report(y("parser.string.illegal-unicode-escape"),v.create(e,e.getCharRange(3).end)),n.valueMap.push({inner:v.create(n.value.length,n.value.length+1),outer:v.create(l,e)}),n.value+=c)}else t.escapable.allowUnknown||r.err.report(y("parser.string.illegal-escape",P(c)),e.getCharRange(-1)),n.valueMap.push({inner:v.create(n.value.length,n.value.length+1),outer:v.create(l,e)}),n.value+=c}else e.skip(),n.value+=a}e.trySkip(o)||r.err.report(y("expected",P(o)),e),t.quotes.includes(o)||r.err.report(y("parser.string.illegal-quote",t.quotes),n),i=s}else if(t.unquotable){for(;e.canRead()&&jm(e.peek(),t.unquotable);)n.value+=e.read();!n.value&&!t.unquotable.allowEmpty&&r.err.report(y("expected",y("string")),e)}else r.err.report(y("expected",t.quotes),e);if(n.valueMap.unshift({inner:v.create(0),outer:v.create(i)}),t.value?.parser){let o=uo(t.value.parser,n.value,n.valueMap,r);o!==V&&(n.children=[o])}return n.range.end=e.cursor,n}}function uo(t,e,r,n){let i=new _e(e,r),o={...n,doc:Ex.TextDocument.create(n.doc.uri,n.doc.languageId,n.doc.version,e)};return t(i,o)}var kE=Object.freeze(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","_",".","+","-"]),vE=new Set(kE),Mx=/^[0-9A-Za-z_\.\+\-]*$/,Ml={allowEmpty:!0,allowList:vE},ui={escapable:{},quotes:['"',"'"],unquotable:Ml},ho=dt(ui);function jm(t,e){return e.allowList?.has(t)??!e.blockList?.has(t)}function Bs(t){let e=wE(t);return(r,n)=>{let i={type:"symbol",range:v.create(r),options:e,value:r.readRemaining()};return i.range.end=r.cursor,i}}function wE(t){return typeof t=="string"?{category:t}:t}var ih=Br(Nx(),1);function Fs(t){let e=t.length;for(;--e>=0;)t[e]=0}var xE=0,b1=1,SE=2,_E=3,CE=258,hg=29,ql=256,jl=ql+1+hg,zs=30,dg=19,k1=2*jl+1,po=15,Gm=16,AE=7,pg=256,v1=16,w1=17,x1=18,lg=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),qu=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),TE=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),S1=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),OE=512,Rn=new Array((jl+2)*2);Fs(Rn);var Ll=new Array(zs*2);Fs(Ll);var $l=new Array(OE);Fs($l);var zl=new Array(CE-_E+1);Fs(zl);var mg=new Array(hg);Fs(mg);var Ju=new Array(zs);Fs(Ju);function Zm(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}var _1,C1,A1;function Jm(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}var T1=t=>t<256?$l[t]:$l[256+(t>>>7)],Fl=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255},Tt=(t,e,r)=>{t.bi_valid>Gm-r?(t.bi_buf|=e<>Gm-t.bi_valid,t.bi_valid+=r-Gm):(t.bi_buf|=e<{Tt(t,r[e*2],r[e*2+1])},O1=(t,e)=>{let r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1},RE=t=>{t.bi_valid===16?(Fl(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)},EE=(t,e)=>{let r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length,c,f,u,h,d,p,b=0;for(h=0;h<=po;h++)t.bl_count[h]=0;for(r[t.heap[t.heap_max]*2+1]=0,c=t.heap_max+1;cl&&(h=l,b++),r[f*2+1]=h,!(f>n)&&(t.bl_count[h]++,d=0,f>=a&&(d=s[f-a]),p=r[f*2],t.opt_len+=p*(h+d),o&&(t.static_len+=p*(i[f*2+1]+d)));if(b!==0){do{for(h=l-1;t.bl_count[h]===0;)h--;t.bl_count[h]--,t.bl_count[h+1]+=2,t.bl_count[l]--,b-=2}while(b>0);for(h=l;h!==0;h--)for(f=t.bl_count[h];f!==0;)u=t.heap[--c],!(u>n)&&(r[u*2+1]!==h&&(t.opt_len+=(h-r[u*2+1])*r[u*2],r[u*2+1]=h),f--)}},R1=(t,e,r)=>{let n=new Array(po+1),i=0,o,s;for(o=1;o<=po;o++)n[o]=i=i+r[o-1]<<1;for(s=0;s<=e;s++){let a=t[s*2+1];a!==0&&(t[s*2]=O1(n[a]++,a))}},ME=()=>{let t,e,r,n,i,o=new Array(po+1);for(r=0,n=0;n>=7;n{let e;for(e=0;e{t.bi_valid>8?Fl(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},DE=(t,e,r,n)=>{M1(t),n&&(Fl(t,r),Fl(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r},Px=(t,e,r,n)=>{let i=e*2,o=r*2;return t[i]{let n=t.heap[r],i=r<<1;for(;i<=t.heap_len&&(i{let n,i,o=0,s,a;if(t.last_lit!==0)do n=t.pending_buf[t.d_buf+o*2]<<8|t.pending_buf[t.d_buf+o*2+1],i=t.pending_buf[t.l_buf+o],o++,n===0?rn(t,i,e):(s=zl[i],rn(t,s+ql+1,e),a=lg[s],a!==0&&(i-=mg[s],Tt(t,i,a)),n--,s=T1(n),rn(t,s,r),a=qu[s],a!==0&&(n-=Ju[s],Tt(t,n,a)));while(o{let r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.elems,s,a,l=-1,c;for(t.heap_len=0,t.heap_max=k1,s=0;s>1;s>=1;s--)Ym(t,r,s);c=o;do s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Ym(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,r[c*2]=r[s*2]+r[a*2],t.depth[c]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,r[s*2+1]=r[a*2+1]=c,t.heap[1]=c++,Ym(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],EE(t,e),R1(r,l,t.bl_count)},Ix=(t,e,r)=>{let n,i=-1,o,s=e[0*2+1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),e[(r+1)*2+1]=65535,n=0;n<=r;n++)o=s,s=e[(n+1)*2+1],!(++a{let n,i=-1,o,s=e[0*2+1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),n=0;n<=r;n++)if(o=s,s=e[(n+1)*2+1],!(++a{let e;for(Ix(t,t.dyn_ltree,t.l_desc.max_code),Ix(t,t.dyn_dtree,t.d_desc.max_code),cg(t,t.bl_desc),e=dg-1;e>=3&&t.bl_tree[S1[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},PE=(t,e,r,n)=>{let i;for(Tt(t,e-257,5),Tt(t,r-1,5),Tt(t,n-4,4),i=0;i{let e=4093624447,r;for(r=0;r<=31;r++,e>>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return 0;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return 1;for(r=32;r{jx||(ME(),jx=!0),t.l_desc=new Jm(t.dyn_ltree,_1),t.d_desc=new Jm(t.dyn_dtree,C1),t.bl_desc=new Jm(t.bl_tree,A1),t.bi_buf=0,t.bi_valid=0,E1(t)},D1=(t,e,r,n)=>{Tt(t,(xE<<1)+(n?1:0),3),DE(t,e,r,!0)},BE=t=>{Tt(t,b1<<1,3),rn(t,pg,Rn),RE(t)},jE=(t,e,r,n)=>{let i,o,s=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=LE(t)),cg(t,t.l_desc),cg(t,t.d_desc),s=NE(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&e!==-1?D1(t,e,r,n):t.strategy===4||o===i?(Tt(t,(b1<<1)+(n?1:0),3),Lx(t,Rn,Ll)):(Tt(t,(SE<<1)+(n?1:0),3),PE(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),Lx(t,t.dyn_ltree,t.dyn_dtree)),E1(t),n&&M1(t)},$E=(t,e,r)=>(t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=r&255,t.last_lit++,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(zl[r]+ql+1)*2]++,t.dyn_dtree[T1(e)*2]++),t.last_lit===t.lit_bufsize-1),zE=IE,FE=D1,VE=jE,UE=$E,HE=BE,WE={_tr_init:zE,_tr_stored_block:FE,_tr_flush_block:VE,_tr_tally:UE,_tr_align:HE},qE=(t,e,r,n)=>{let i=t&65535|0,o=t>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do i=i+e[n++]|0,o=o+i|0;while(--s);i%=65521,o%=65521}return i|o<<16|0},Vl=qE,KE=()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t}return e},GE=new Uint32Array(KE()),ZE=(t,e,r,n)=>{let i=GE,o=n+r;t^=-1;for(let s=n;s>>8^i[(t^e[s])&255];return t^-1},Ge=ZE,go={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},vo={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:JE,_tr_stored_block:YE,_tr_flush_block:XE,_tr_tally:gi,_tr_align:QE}=WE,{Z_NO_FLUSH:wo,Z_PARTIAL_FLUSH:eM,Z_FULL_FLUSH:tM,Z_FINISH:yi,Z_BLOCK:$x,Z_OK:nn,Z_STREAM_END:zx,Z_STREAM_ERROR:lr,Z_DATA_ERROR:rM,Z_BUF_ERROR:Xm,Z_DEFAULT_COMPRESSION:nM,Z_FILTERED:iM,Z_HUFFMAN_ONLY:Fu,Z_RLE:oM,Z_FIXED:sM,Z_DEFAULT_STRATEGY:aM,Z_UNKNOWN:lM,Z_DEFLATED:Qu}=vo,cM=9,fM=15,uM=8,hM=29,dM=256,fg=dM+1+hM,pM=30,mM=19,gM=2*fg+1,yM=15,X=3,pi=258,Or=pi+X+1,bM=32,eh=42,ug=69,Ku=73,Gu=91,Zu=103,mo=113,Nl=666,He=1,Kl=2,yo=3,Vs=4,kM=3,mi=(t,e)=>(t.msg=go[e],e),Fx=t=>(t<<1)-(t>4?9:0),di=t=>{let e=t.length;for(;--e>=0;)t[e]=0},vM=(t,e,r)=>(e<{let e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0))},rt=(t,e)=>{XE(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,hi(t.strm)},ie=(t,e)=>{t.pending_buf[t.pending++]=e},Dl=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255},wM=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),i===0?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),t.state.wrap===1?t.adler=Vl(t.adler,e,i,r):t.state.wrap===2&&(t.adler=Ge(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},N1=(t,e)=>{let r=t.max_chain_length,n=t.strstart,i,o,s=t.prev_length,a=t.nice_match,l=t.strstart>t.w_size-Or?t.strstart-(t.w_size-Or):0,c=t.window,f=t.w_mask,u=t.prev,h=t.strstart+pi,d=c[n+s-1],p=c[n+s];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do if(i=e,!(c[i+s]!==p||c[i+s-1]!==d||c[i]!==c[n]||c[++i]!==c[n+1])){n+=2,i++;do;while(c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&ns){if(t.match_start=e,s=o,o>=a)break;d=c[n+s-1],p=c[n+s]}}while((e=u[e&f])>l&&--r!==0);return s<=t.lookahead?s:t.lookahead},bo=t=>{let e=t.w_size,r,n,i,o,s;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Or)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do i=t.head[--r],t.head[r]=i>=e?i-e:0;while(--n);n=e,r=n;do i=t.prev[--r],t.prev[r]=i>=e?i-e:0;while(--n);o+=e}if(t.strm.avail_in===0)break;if(n=wM(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=n,t.lookahead+t.insert>=X)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=bi(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=bi(t,t.ins_h,t.window[s+X-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert{let r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(bo(t),t.lookahead===0&&e===wo)return He;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;let n=t.block_start+r;if((t.strstart===0||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,rt(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-Or&&(rt(t,!1),t.strm.avail_out===0))return He}return t.insert=0,e===yi?(rt(t,!0),t.strm.avail_out===0?yo:Vs):(t.strstart>t.block_start&&(rt(t,!1),t.strm.avail_out===0),He)},Qm=(t,e)=>{let r,n;for(;;){if(t.lookahead=X&&(t.ins_h=bi(t,t.ins_h,t.window[t.strstart+X-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),r!==0&&t.strstart-r<=t.w_size-Or&&(t.match_length=N1(t,r)),t.match_length>=X)if(n=gi(t,t.strstart-t.match_start,t.match_length-X),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=X){t.match_length--;do t.strstart++,t.ins_h=bi(t,t.ins_h,t.window[t.strstart+X-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=bi(t,t.ins_h,t.window[t.strstart+1]);else n=gi(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(rt(t,!1),t.strm.avail_out===0))return He}return t.insert=t.strstart{let r,n,i;for(;;){if(t.lookahead=X&&(t.ins_h=bi(t,t.ins_h,t.window[t.strstart+X-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=X-1,r!==0&&t.prev_length4096)&&(t.match_length=X-1)),t.prev_length>=X&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-X,n=gi(t,t.strstart-1-t.prev_match,t.prev_length-X),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=i&&(t.ins_h=bi(t,t.ins_h,t.window[t.strstart+X-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=X-1,t.strstart++,n&&(rt(t,!1),t.strm.avail_out===0))return He}else if(t.match_available){if(n=gi(t,0,t.window[t.strstart-1]),n&&rt(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return He}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=gi(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart{let r,n,i,o,s=t.window;for(;;){if(t.lookahead<=pi){if(bo(t),t.lookahead<=pi&&e===wo)return He;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=X&&t.strstart>0&&(i=t.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){o=t.strstart+pi;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=X?(r=gi(t,1,t.match_length-X),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=gi(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(rt(t,!1),t.strm.avail_out===0))return He}return t.insert=0,e===yi?(rt(t,!0),t.strm.avail_out===0?yo:Vs):t.last_lit&&(rt(t,!1),t.strm.avail_out===0)?He:Kl},_M=(t,e)=>{let r;for(;;){if(t.lookahead===0&&(bo(t),t.lookahead===0)){if(e===wo)return He;break}if(t.match_length=0,r=gi(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(rt(t,!1),t.strm.avail_out===0))return He}return t.insert=0,e===yi?(rt(t,!0),t.strm.avail_out===0?yo:Vs):t.last_lit&&(rt(t,!1),t.strm.avail_out===0)?He:Kl};function tn(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}var Pl=[new tn(0,0,0,0,xM),new tn(4,4,8,4,Qm),new tn(4,5,16,8,Qm),new tn(4,6,32,32,Qm),new tn(4,4,16,16,js),new tn(8,16,32,32,js),new tn(8,16,128,128,js),new tn(8,32,128,256,js),new tn(32,128,258,1024,js),new tn(32,258,258,4096,js)],CM=t=>{t.window_size=2*t.w_size,di(t.head),t.max_lazy_match=Pl[t.level].max_lazy,t.good_match=Pl[t.level].good_length,t.nice_match=Pl[t.level].nice_length,t.max_chain_length=Pl[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=X-1,t.match_available=0,t.ins_h=0};function AM(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qu,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(gM*2),this.dyn_dtree=new Uint16Array((2*pM+1)*2),this.bl_tree=new Uint16Array((2*mM+1)*2),di(this.dyn_ltree),di(this.dyn_dtree),di(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(yM+1),this.heap=new Uint16Array(2*fg+1),di(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*fg+1),di(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var P1=t=>{if(!t||!t.state)return mi(t,lr);t.total_in=t.total_out=0,t.data_type=lM;let e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?eh:mo,t.adler=e.wrap===2?0:1,e.last_flush=wo,JE(e),nn},L1=t=>{let e=P1(t);return e===nn&&CM(t.state),e},TM=(t,e)=>!t||!t.state||t.state.wrap!==2?lr:(t.state.gzhead=e,nn),I1=(t,e,r,n,i,o)=>{if(!t)return lr;let s=1;if(e===nM&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>cM||r!==Qu||n<8||n>15||e<0||e>9||o<0||o>sM)return mi(t,lr);n===8&&(n=9);let a=new AM;return t.state=a,a.strm=t,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<I1(t,e,Qu,fM,uM,aM),RM=(t,e)=>{let r,n;if(!t||!t.state||e>$x||e<0)return t?mi(t,lr):lr;let i=t.state;if(!t.output||!t.input&&t.avail_in!==0||i.status===Nl&&e!==yi)return mi(t,t.avail_out===0?Xm:lr);i.strm=t;let o=i.last_flush;if(i.last_flush=e,i.status===eh)if(i.wrap===2)t.adler=0,ie(i,31),ie(i,139),ie(i,8),i.gzhead?(ie(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),ie(i,i.gzhead.time&255),ie(i,i.gzhead.time>>8&255),ie(i,i.gzhead.time>>16&255),ie(i,i.gzhead.time>>24&255),ie(i,i.level===9?2:i.strategy>=Fu||i.level<2?4:0),ie(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(ie(i,i.gzhead.extra.length&255),ie(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=Ge(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=ug):(ie(i,0),ie(i,0),ie(i,0),ie(i,0),ie(i,0),ie(i,i.level===9?2:i.strategy>=Fu||i.level<2?4:0),ie(i,kM),i.status=mo);else{let s=Qu+(i.w_bits-8<<4)<<8,a=-1;i.strategy>=Fu||i.level<2?a=0:i.level<6?a=1:i.level===6?a=2:a=3,s|=a<<6,i.strstart!==0&&(s|=bM),s+=31-s%31,i.status=mo,Dl(i,s),i.strstart!==0&&(Dl(i,t.adler>>>16),Dl(i,t.adler&65535)),t.adler=1}if(i.status===ug)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),hi(t),r=i.pending,i.pending===i.pending_buf_size));)ie(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Ku)}else i.status=Ku;if(i.status===Ku)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),hi(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}i.gzindexr&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),n===0&&(i.gzindex=0,i.status=Gu)}else i.status=Gu;if(i.status===Gu)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),hi(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}i.gzindexr&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),n===0&&(i.status=Zu)}else i.status=Zu;if(i.status===Zu&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&hi(t),i.pending+2<=i.pending_buf_size&&(ie(i,t.adler&255),ie(i,t.adler>>8&255),t.adler=0,i.status=mo)):i.status=mo),i.pending!==0){if(hi(t),t.avail_out===0)return i.last_flush=-1,nn}else if(t.avail_in===0&&Fx(e)<=Fx(o)&&e!==yi)return mi(t,Xm);if(i.status===Nl&&t.avail_in!==0)return mi(t,Xm);if(t.avail_in!==0||i.lookahead!==0||e!==wo&&i.status!==Nl){let s=i.strategy===Fu?_M(i,e):i.strategy===oM?SM(i,e):Pl[i.level].func(i,e);if((s===yo||s===Vs)&&(i.status=Nl),s===He||s===yo)return t.avail_out===0&&(i.last_flush=-1),nn;if(s===Kl&&(e===eM?QE(i):e!==$x&&(YE(i,0,0,!1),e===tM&&(di(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),hi(t),t.avail_out===0))return i.last_flush=-1,nn}return e!==yi?nn:i.wrap<=0?zx:(i.wrap===2?(ie(i,t.adler&255),ie(i,t.adler>>8&255),ie(i,t.adler>>16&255),ie(i,t.adler>>24&255),ie(i,t.total_in&255),ie(i,t.total_in>>8&255),ie(i,t.total_in>>16&255),ie(i,t.total_in>>24&255)):(Dl(i,t.adler>>>16),Dl(i,t.adler&65535)),hi(t),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?nn:zx)},EM=t=>{if(!t||!t.state)return lr;let e=t.state.status;return e!==eh&&e!==ug&&e!==Ku&&e!==Gu&&e!==Zu&&e!==mo&&e!==Nl?mi(t,lr):(t.state=null,e===mo?mi(t,rM):nn)},MM=(t,e)=>{let r=e.length;if(!t||!t.state)return lr;let n=t.state,i=n.wrap;if(i===2||i===1&&n.status!==eh||n.lookahead)return lr;if(i===1&&(t.adler=Vl(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){i===0&&(di(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(e.subarray(r-n.w_size,r),0),e=l,r=n.w_size}let o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,bo(n);n.lookahead>=X;){let l=n.strstart,c=n.lookahead-(X-1);do n.ins_h=bi(n,n.ins_h,n.window[l+X-1]),n.prev[l&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=l,l++;while(--c);n.strstart=l,n.lookahead=X-1,bo(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=X-1,n.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,n.wrap=i,nn},DM=OM,NM=I1,PM=L1,LM=P1,IM=TM,BM=RM,jM=EM,$M=MM,zM="pako deflate (from Nodeca project)",Il={deflateInit:DM,deflateInit2:NM,deflateReset:PM,deflateResetKeep:LM,deflateSetHeader:IM,deflate:BM,deflateEnd:jM,deflateSetDictionary:$M,deflateInfo:zM},FM=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),VM=function(t){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)FM(r,n)&&(t[n]=r[n])}}return t},UM=t=>{let e=0;for(let n=0,i=t.length;n=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ul[254]=Ul[254]=1;var HM=t=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let e,r,n,i,o,s=t.length,a=0;for(i=0;i>>6,e[o++]=128|r&63):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|r&63):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|r&63);return e},WM=(t,e)=>{if(e<65534&&t.subarray&&B1)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n{let r=e||t.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,e));let n,i,o=new Array(r*2);for(i=0,n=0;n4){o[i++]=65533,n+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&n1){o[i++]=65533;continue}s<65536?o[i++]=s:(s-=65536,o[i++]=55296|s>>10&1023,o[i++]=56320|s&1023)}return WM(o,i)},KM=(t,e)=>{e=e||t.length,e>t.length&&(e=t.length);let r=e-1;for(;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+Ul[t[r]]>e?r:e},Hl={string2buf:HM,buf2string:qM,utf8border:KM};function GM(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var j1=GM,$1=Object.prototype.toString,{Z_NO_FLUSH:ZM,Z_SYNC_FLUSH:JM,Z_FULL_FLUSH:YM,Z_FINISH:XM,Z_OK:Yu,Z_STREAM_END:QM,Z_DEFAULT_COMPRESSION:eD,Z_DEFAULT_STRATEGY:tD,Z_DEFLATED:rD}=vo;function Gl(t){this.options=th.assign({level:eD,method:rD,chunkSize:16384,windowBits:15,memLevel:8,strategy:tD},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new j1,this.strm.avail_out=0;let r=Il.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Yu)throw new Error(go[r]);if(e.header&&Il.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=Hl.string2buf(e.dictionary):$1.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,r=Il.deflateSetDictionary(this.strm,n),r!==Yu)throw new Error(go[r]);this._dict_set=!0}}Gl.prototype.push=function(t,e){let r=this.strm,n=this.options.chunkSize,i,o;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?XM:ZM,typeof t=="string"?r.input=Hl.string2buf(t):$1.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===JM||o===YM)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(i=Il.deflate(r,o),i===QM)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Il.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Yu;if(r.avail_out===0){this.onData(r.output);continue}if(o>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};Gl.prototype.onData=function(t){this.chunks.push(t)};Gl.prototype.onEnd=function(t){t===Yu&&(this.result=th.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function gg(t,e){let r=new Gl(e);if(r.push(t,!0),r.err)throw r.msg||go[r.err];return r.result}function nD(t,e){return e=e||{},e.raw=!0,gg(t,e)}function iD(t,e){return e=e||{},e.gzip=!0,gg(t,e)}var oD=Gl,sD=gg,aD=nD,lD=iD,cD=vo,fD={Deflate:oD,deflate:sD,deflateRaw:aD,gzip:lD,constants:cD},Vu=30,uD=12,hD=function(e,r){let n,i,o,s,a,l,c,f,u,h,d,p,b,m,k,S,_,w,C,R,x,T,O,M,I=e.state;n=e.next_in,O=e.input,i=n+(e.avail_in-5),o=e.next_out,M=e.output,s=o-(r-e.avail_out),a=o+(e.avail_out-257),l=I.dmax,c=I.wsize,f=I.whave,u=I.wnext,h=I.window,d=I.hold,p=I.bits,b=I.lencode,m=I.distcode,k=(1<>>24,d>>>=w,p-=w,w=_>>>16&255,w===0)M[o++]=_&65535;else if(w&16){C=_&65535,w&=15,w&&(p>>=w,p-=w),p<15&&(d+=O[n++]<>>24,d>>>=w,p-=w,w=_>>>16&255,w&16){if(R=_&65535,w&=15,pl){e.msg="invalid distance too far back",I.mode=Vu;break e}if(d>>>=w,p-=w,w=o-s,R>w){if(w=R-w,w>f&&I.sane){e.msg="invalid distance too far back",I.mode=Vu;break e}if(x=0,T=h,u===0){if(x+=c-w,w2;)M[o++]=T[x++],M[o++]=T[x++],M[o++]=T[x++],C-=3;C&&(M[o++]=T[x++],C>1&&(M[o++]=T[x++]))}else{x=o-R;do M[o++]=M[x++],M[o++]=M[x++],M[o++]=M[x++],C-=3;while(C>2);C&&(M[o++]=M[x++],C>1&&(M[o++]=M[x++]))}}else if(w&64){e.msg="invalid distance code",I.mode=Vu;break e}else{_=m[(_&65535)+(d&(1<>3,n-=C,p-=C<<3,d&=(1<{let l=a.bits,c=0,f=0,u=0,h=0,d=0,p=0,b=0,m=0,k=0,S=0,_,w,C,R,x,T=null,O=0,M,I=new Uint16Array($s+1),ae=new Uint16Array($s+1),me=null,ot=0,Be,Me,st;for(c=0;c<=$s;c++)I[c]=0;for(f=0;f=1&&I[h]===0;h--);if(d>h&&(d=h),h===0)return i[o++]=1<<24|64<<16|0,i[o++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u0&&(t===Hx||h!==1))return-1;for(ae[1]=0,c=1;c<$s;c++)ae[c+1]=ae[c]+I[c];for(f=0;fVx||t===Wx&&k>Ux)return 1;for(;;){Be=c-b,s[f]M?(Me=me[ot+s[f]],st=T[O+s[f]]):(Me=32+64,st=0),_=1<>b)+w]=Be<<24|Me<<16|st|0;while(w!==0);for(_=1<>=1;if(_!==0?(S&=_-1,S+=_):S=0,f++,--I[c]===0){if(c===h)break;c=e[r+s[f]]}if(c>d&&(S&R)!==C){for(b===0&&(b=d),x+=u,p=c-b,m=1<Vx||t===Wx&&k>Ux)return 1;C=S&R,i[C]=d<<24|p<<16|x-o|0}}return S!==0&&(i[x+S]=c-b<<24|64<<16|0),a.bits=d,0},Bl=yD,bD=0,z1=1,F1=2,{Z_FINISH:qx,Z_BLOCK:kD,Z_TREES:Uu,Z_OK:ko,Z_STREAM_END:vD,Z_NEED_DICT:wD,Z_STREAM_ERROR:cr,Z_DATA_ERROR:V1,Z_MEM_ERROR:U1,Z_BUF_ERROR:xD,Z_DEFLATED:Kx}=vo,H1=1,Gx=2,Zx=3,Jx=4,Yx=5,Xx=6,Qx=7,e1=8,t1=9,r1=10,Xu=11,On=12,tg=13,n1=14,rg=15,i1=16,o1=17,s1=18,a1=19,Hu=20,Wu=21,l1=22,c1=23,f1=24,u1=25,h1=26,ng=27,d1=28,p1=29,we=30,W1=31,SD=32,_D=852,CD=592,AD=15,TD=AD,m1=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function OD(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var q1=t=>{if(!t||!t.state)return cr;let e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=H1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(_D),e.distcode=e.distdyn=new Int32Array(CD),e.sane=1,e.back=-1,ko},K1=t=>{if(!t||!t.state)return cr;let e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,q1(t)},G1=(t,e)=>{let r;if(!t||!t.state)return cr;let n=t.state;return e<0?(r=0,e=-e):(r=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?cr:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,K1(t))},Z1=(t,e)=>{if(!t)return cr;let r=new OD;t.state=r,r.window=null;let n=G1(t,e);return n!==ko&&(t.state=null),n},RD=t=>Z1(t,TD),g1=!0,ig,og,ED=t=>{if(g1){ig=new Int32Array(512),og=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Bl(z1,t.lens,0,288,ig,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Bl(F1,t.lens,0,32,og,0,t.work,{bits:5}),g1=!1}t.lencode=ig,t.lenbits=9,t.distcode=og,t.distbits=5},J1=(t,e,r,n)=>{let i,o=t.state;return o.window===null&&(o.wsize=1<=o.wsize?(o.window.set(e.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(e.subarray(r-n,r-n+i),o.wnext),n-=i,n?(o.window.set(e.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave{let r,n,i,o,s,a,l,c,f,u,h,d,p,b,m=0,k,S,_,w,C,R,x,T,O=new Uint8Array(4),M,I,ae=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return cr;r=t.state,r.mode===On&&(r.mode=tg),s=t.next_out,i=t.output,l=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,c=r.hold,f=r.bits,u=a,h=l,T=ko;e:for(;;)switch(r.mode){case H1:if(r.wrap===0){r.mode=tg;break}for(;f<16;){if(a===0)break e;a--,c+=n[o++]<>>8&255,r.check=Ge(r.check,O,2,0),c=0,f=0,r.mode=Gx;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((c&255)<<8)+(c>>8))%31){t.msg="incorrect header check",r.mode=we;break}if((c&15)!==Kx){t.msg="unknown compression method",r.mode=we;break}if(c>>>=4,f-=4,x=(c&15)+8,r.wbits===0)r.wbits=x;else if(x>r.wbits){t.msg="invalid window size",r.mode=we;break}r.dmax=1<>8&1),r.flags&512&&(O[0]=c&255,O[1]=c>>>8&255,r.check=Ge(r.check,O,2,0)),c=0,f=0,r.mode=Zx;case Zx:for(;f<32;){if(a===0)break e;a--,c+=n[o++]<>>8&255,O[2]=c>>>16&255,O[3]=c>>>24&255,r.check=Ge(r.check,O,4,0)),c=0,f=0,r.mode=Jx;case Jx:for(;f<16;){if(a===0)break e;a--,c+=n[o++]<>8),r.flags&512&&(O[0]=c&255,O[1]=c>>>8&255,r.check=Ge(r.check,O,2,0)),c=0,f=0,r.mode=Yx;case Yx:if(r.flags&1024){for(;f<16;){if(a===0)break e;a--,c+=n[o++]<>>8&255,r.check=Ge(r.check,O,2,0)),c=0,f=0}else r.head&&(r.head.extra=null);r.mode=Xx;case Xx:if(r.flags&1024&&(d=r.length,d>a&&(d=a),d&&(r.head&&(x=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+d),x)),r.flags&512&&(r.check=Ge(r.check,n,d,o)),a-=d,o+=d,r.length-=d),r.length))break e;r.length=0,r.mode=Qx;case Qx:if(r.flags&2048){if(a===0)break e;d=0;do x=n[o+d++],r.head&&x&&r.length<65536&&(r.head.name+=String.fromCharCode(x));while(x&&d>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=On;break;case r1:for(;f<32;){if(a===0)break e;a--,c+=n[o++]<>>=f&7,f-=f&7,r.mode=ng;break}for(;f<3;){if(a===0)break e;a--,c+=n[o++]<>>=1,f-=1,c&3){case 0:r.mode=n1;break;case 1:if(ED(r),r.mode=Hu,e===Uu){c>>>=2,f-=2;break e}break;case 2:r.mode=o1;break;case 3:t.msg="invalid block type",r.mode=we}c>>>=2,f-=2;break;case n1:for(c>>>=f&7,f-=f&7;f<32;){if(a===0)break e;a--,c+=n[o++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=we;break}if(r.length=c&65535,c=0,f=0,r.mode=rg,e===Uu)break e;case rg:r.mode=i1;case i1:if(d=r.length,d){if(d>a&&(d=a),d>l&&(d=l),d===0)break e;i.set(n.subarray(o,o+d),s),a-=d,o+=d,l-=d,s+=d,r.length-=d;break}r.mode=On;break;case o1:for(;f<14;){if(a===0)break e;a--,c+=n[o++]<>>=5,f-=5,r.ndist=(c&31)+1,c>>>=5,f-=5,r.ncode=(c&15)+4,c>>>=4,f-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=we;break}r.have=0,r.mode=s1;case s1:for(;r.have>>=3,f-=3}for(;r.have<19;)r.lens[ae[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,M={bits:r.lenbits},T=Bl(bD,r.lens,0,19,r.lencode,0,r.work,M),r.lenbits=M.bits,T){t.msg="invalid code lengths set",r.mode=we;break}r.have=0,r.mode=a1;case a1:for(;r.have>>24,S=m>>>16&255,_=m&65535,!(k<=f);){if(a===0)break e;a--,c+=n[o++]<>>=k,f-=k,r.lens[r.have++]=_;else{if(_===16){for(I=k+2;f>>=k,f-=k,r.have===0){t.msg="invalid bit length repeat",r.mode=we;break}x=r.lens[r.have-1],d=3+(c&3),c>>>=2,f-=2}else if(_===17){for(I=k+3;f>>=k,f-=k,x=0,d=3+(c&7),c>>>=3,f-=3}else{for(I=k+7;f>>=k,f-=k,x=0,d=11+(c&127),c>>>=7,f-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=we;break}for(;d--;)r.lens[r.have++]=x}}if(r.mode===we)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=we;break}if(r.lenbits=9,M={bits:r.lenbits},T=Bl(z1,r.lens,0,r.nlen,r.lencode,0,r.work,M),r.lenbits=M.bits,T){t.msg="invalid literal/lengths set",r.mode=we;break}if(r.distbits=6,r.distcode=r.distdyn,M={bits:r.distbits},T=Bl(F1,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,M),r.distbits=M.bits,T){t.msg="invalid distances set",r.mode=we;break}if(r.mode=Hu,e===Uu)break e;case Hu:r.mode=Wu;case Wu:if(a>=6&&l>=258){t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=a,r.hold=c,r.bits=f,hD(t,h),s=t.next_out,i=t.output,l=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,c=r.hold,f=r.bits,r.mode===On&&(r.back=-1);break}for(r.back=0;m=r.lencode[c&(1<>>24,S=m>>>16&255,_=m&65535,!(k<=f);){if(a===0)break e;a--,c+=n[o++]<>w)],k=m>>>24,S=m>>>16&255,_=m&65535,!(w+k<=f);){if(a===0)break e;a--,c+=n[o++]<>>=w,f-=w,r.back+=w}if(c>>>=k,f-=k,r.back+=k,r.length=_,S===0){r.mode=h1;break}if(S&32){r.back=-1,r.mode=On;break}if(S&64){t.msg="invalid literal/length code",r.mode=we;break}r.extra=S&15,r.mode=l1;case l1:if(r.extra){for(I=r.extra;f>>=r.extra,f-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=c1;case c1:for(;m=r.distcode[c&(1<>>24,S=m>>>16&255,_=m&65535,!(k<=f);){if(a===0)break e;a--,c+=n[o++]<>w)],k=m>>>24,S=m>>>16&255,_=m&65535,!(w+k<=f);){if(a===0)break e;a--,c+=n[o++]<>>=w,f-=w,r.back+=w}if(c>>>=k,f-=k,r.back+=k,S&64){t.msg="invalid distance code",r.mode=we;break}r.offset=_,r.extra=S&15,r.mode=f1;case f1:if(r.extra){for(I=r.extra;f>>=r.extra,f-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=we;break}r.mode=u1;case u1:if(l===0)break e;if(d=h-l,r.offset>d){if(d=r.offset-d,d>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=we;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),b=r.window}else b=i,p=s-r.offset,d=r.length;d>l&&(d=l),l-=d,r.length-=d;do i[s++]=b[p++];while(--d);r.length===0&&(r.mode=Wu);break;case h1:if(l===0)break e;i[s++]=r.length,l--,r.mode=Wu;break;case ng:if(r.wrap){for(;f<32;){if(a===0)break e;a--,c|=n[o++]<{if(!t||!t.state)return cr;let e=t.state;return e.window&&(e.window=null),t.state=null,ko},ND=(t,e)=>{if(!t||!t.state)return cr;let r=t.state;return r.wrap&2?(r.head=e,e.done=!1,ko):cr},PD=(t,e)=>{let r=e.length,n,i,o;return!t||!t.state||(n=t.state,n.wrap!==0&&n.mode!==Xu)?cr:n.mode===Xu&&(i=1,i=Vl(i,e,r,0),i!==n.check)?V1:(o=J1(t,e,r,r),o?(n.mode=W1,U1):(n.havedict=1,ko))},LD=K1,ID=G1,BD=q1,jD=RD,$D=Z1,zD=MD,FD=DD,VD=ND,UD=PD,HD="pako inflate (from Nodeca project)",En={inflateReset:LD,inflateReset2:ID,inflateResetKeep:BD,inflateInit:jD,inflateInit2:$D,inflate:zD,inflateEnd:FD,inflateGetHeader:VD,inflateSetDictionary:UD,inflateInfo:HD};function WD(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var qD=WD,Y1=Object.prototype.toString,{Z_NO_FLUSH:KD,Z_FINISH:GD,Z_OK:Wl,Z_STREAM_END:sg,Z_NEED_DICT:ag,Z_STREAM_ERROR:ZD,Z_DATA_ERROR:y1,Z_MEM_ERROR:JD}=vo;function Zl(t){this.options=th.assign({chunkSize:1024*64,windowBits:15,to:""},t||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new j1,this.strm.avail_out=0;let r=En.inflateInit2(this.strm,e.windowBits);if(r!==Wl)throw new Error(go[r]);if(this.header=new qD,En.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Hl.string2buf(e.dictionary):Y1.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=En.inflateSetDictionary(this.strm,e.dictionary),r!==Wl)))throw new Error(go[r])}Zl.prototype.push=function(t,e){let r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,o,s,a;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?GD:KD,Y1.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=En.inflate(r,s),o===ag&&i&&(o=En.inflateSetDictionary(r,i),o===Wl?o=En.inflate(r,s):o===y1&&(o=ag));r.avail_in>0&&o===sg&&r.state.wrap>0&&t[r.next_in]!==0;)En.inflateReset(r),o=En.inflate(r,s);switch(o){case ZD:case y1:case ag:case JD:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===sg))if(this.options.to==="string"){let l=Hl.utf8border(r.output,r.next_out),c=r.next_out-l,f=Hl.buf2string(r.output,l);r.next_out=c,r.avail_out=n-c,c&&r.output.set(r.output.subarray(l,l+c),0),this.onData(f)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(o===Wl&&a===0)){if(o===sg)return o=En.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(r.avail_in===0)break}}return!0};Zl.prototype.onData=function(t){this.chunks.push(t)};Zl.prototype.onEnd=function(t){t===Wl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=th.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function yg(t,e){let r=new Zl(e);if(r.push(t),r.err)throw r.msg||go[r.err];return r.result}function YD(t,e){return e=e||{},e.raw=!0,yg(t,e)}var XD=Zl,QD=yg,eN=YD,tN=yg,rN=vo,nN={Inflate:XD,inflate:QD,inflateRaw:eN,ungzip:tN,constants:rN},{Deflate:iN,deflate:oN,deflateRaw:sN,gzip:aN}=fD,{Inflate:lN,inflate:cN,inflateRaw:fN,ungzip:uN}=nN,hN=iN,dN=oN,pN=sN,mN=aN,gN=lN,yN=cN,bN=fN,kN=uN,vN=vo,bg={Deflate:hN,deflate:dN,deflateRaw:pN,gzip:mN,Inflate:gN,inflate:yN,inflateRaw:bN,ungzip:kN,constants:vN};var on,kg=class{constructor(){E(this,on,new Map)}emit(e,...r){let n=g(this,on).get(e);if(!n?.all?.size)return!1;for(let i of n.all)i(...r),n.once.has(i)&&(n.all.delete(i),n.once.delete(i));return!1}on(e,r){return g(this,on).has(e)||g(this,on).set(e,{all:new Set,once:new Set}),g(this,on).get(e).all.add(r),this}once(e,r){g(this,on).has(e)||g(this,on).set(e,{all:new Set,once:new Set});let n=g(this,on).get(e);return n.all.add(r),n.once.add(r),this}};on=new WeakMap;var vg=class{async get(e,r={}){let n=new Headers;for(let[o,s]of Object.entries(r?.headers??{})){let a=typeof s=="string"?[s]:s;for(let l of a)n.append(o,l)}let i=await fetch(e,{headers:n,redirect:"follow"});if(i.ok)return new Uint8Array(await i.arrayBuffer());throw new Error(`Status code ${i.status}: ${i.ok}`)}},wg=class{on(e,r){return e==="ready"&&r(),this}once(e,r){return e==="ready"&&r(),this}async close(){}},nh=class{states;constructor(){this.states=JSON.parse(localStorage.getItem(nh.LocalStorageKey)??"{}")}saveStates(){localStorage.setItem(nh.LocalStorageKey,JSON.stringify(this.states))}async chmod(e,r){}async getAllFiles(e){return[]}async mkdir(e,r){if(e=Y.ensureEndingSlash(e.toString()),this.states[e])throw new Error(`EEXIST: ${e}`);this.states[e]={type:"directory"},this.saveStates()}async readFile(e){e=e.toString();let r=this.states[e];if(r){if(r.type==="directory")throw new Error(`EISDIR: ${e}`)}else throw new Error(`ENOENT: ${e}`);return new Uint8Array((0,ih.decode)(r.content))}async showFile(e){throw new Error("showFile not supported on browser")}async stat(e){e=e.toString();let r=this.states[e];if(!r)throw new Error(`ENOENT: ${e}`);return{isDirectory:()=>r.type==="directory",isFile:()=>r.type==="file"}}async unlink(e){if(e=e.toString(),!this.states[e])throw new Error(`ENOENT: ${e}`);delete this.states[e],this.saveStates()}watch(e){return new wg}async writeFile(e,r,n){e=e.toString(),typeof r=="string"&&(r=new TextEncoder().encode(r)),r=(0,ih.encode)(r),this.states[e]={type:"file",content:r},this.saveStates()}},rh=nh;H(rh,"LocalStorageKey","spyglassmc-browser-fs");var xg={archive:{decompressBall(t,e){throw new Error("decompressBall not supported on browser.")},async gunzip(t){return bg.inflate(t)},async gzip(t){return bg.gzip(t)}},crypto:{async getSha1(t){typeof t=="string"&&(t=new TextEncoder().encode(t));let e=await crypto.subtle.digest("SHA-1",t);return wN(new Uint8Array(e))}},downloader:new vg,error:{isKind(t,e){return t instanceof Error&&t.message.startsWith(e)}},event:{EventEmitter:kg},fs:new rh};function wN(t){let e="";for(let r of t)e+=r.toString(16).padStart(2,"0");return e}Object.freeze(xg);var Co={};yr(Co,{TypeDefSymbolData:()=>$g,fileModule:()=>nS,module_:()=>iS,registerMcdocBinders:()=>zg});var x5=Object.freeze({is(t){return t?.type==="mcdoc:module"}}),Q1=Object.freeze({is(t){return Ya.is(t)||Sg.is(t)||So.is(t)||Ig.is(t)||_o.is(t)||oc.is(t)||uh.is(t)}}),Sg=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),location:t.children.find(U.is),index:t.children.find(ki.is),target:t.children.find(sn.is),typeParams:t.children.find(lh.is)}},is(t){return t?.type==="mcdoc:dispatch_statement"}}),vt=Object.freeze({is(t){return t?.type==="mcdoc:literal"}}),ki=Object.freeze({destruct(t){return{parallelIndices:t.children.filter(xN.is)}},is(t){return t?.type==="mcdoc:index_body"}}),xN=Object.freeze({is(t){return _g.is(t)||Jl.is(t)}}),_g=Object.freeze({is(t){return vt.is(t)||fr.is(t)||et.is(t)||U.is(t)}}),fr=Object.freeze({is(t){return t?.type==="mcdoc:identifier"}}),Jl=Object.freeze({destruct(t){return{keys:t.children.filter(SN.is)}},is(t){return t?.type==="mcdoc:dynamic_index"}}),SN=Object.freeze({is(t){return vt.is(t)||fr.is(t)||et.is(t)}}),sn=Object.freeze({is(t){return _N.is(t)||CN.is(t)||Dg.is(t)||Rg.is(t)||Eg.is(t)||Mg.is(t)||Xl.is(t)||Ql.is(t)||So.is(t)||_o.is(t)||ec.is(t)||nc.is(t)||ic.is(t)}}),Cg=Object.freeze({destruct(t){return{appendixes:t.children.filter(e=>ki.is(e)||Yl.is(e)),attributes:t.children.filter(Mn.is)}}}),Mn=Object.freeze({destruct(t){return{name:t.children.find(fr.is),value:t.children.find(eS.is)}},is(t){return t?.type==="mcdoc:attribute"}}),eS=Object.freeze({is(t){return sn.is(t)||Ag.is(t)}}),Ag=Object.freeze({destruct(t){return{positional:t.children.find(Tg.is),named:t.children.find(Og.is)}},is(t){return t?.type==="mcdoc:attribute/tree"}}),Tg=Object.freeze({destruct(t){return{values:t.children.filter(eS.is)}},is(t){return t?.type==="mcdoc:attribute/tree/pos"}}),Og=Object.freeze({destruct(t){let e={values:[]},r;for(let n of t.children)Ya.is(n)||(fr.is(n)||et.is(n)?r=n:r&&(e.values.push({key:r,value:n}),r=void 0));return e},is(t){return t?.type==="mcdoc:attribute/tree/named"}}),Yl=Object.freeze({destruct(t){return{args:t.children.filter(sn.is)}},is(t){return t?.type==="mcdoc:type_arg_block"}}),_N=Object.freeze({is(t){return t?.type==="mcdoc:type/any"}}),CN=Object.freeze({is(t){return t?.type==="mcdoc:type/boolean"}}),Us=Object.freeze({destruct(t){return rS(t)},is(t){return t?.type==="mcdoc:int_range"}}),Rg=Object.freeze({destruct(t){return{value:t.children.find(AN.is)}},is(t){return t?.type==="mcdoc:type/literal"}}),AN=Object.freeze({is(t){return vt.is(t)||xo.is(t)||et.is(t)}}),xo=Object.freeze({destruct(t){return{value:t.children.find(Sr.is),suffix:t.children.find(vt.is)}},is(t){return t?.type==="mcdoc:typed_number"}}),Eg=Object.freeze({destruct(t){return{numericKind:t.children.find(vt.is),valueRange:t.children.find(oh.is)||t.children.find(Us.is)}},is(t){return t?.type==="mcdoc:type/numeric_type"}}),Rr="<";function tS(t){let e=t&2?Rr:"",r=t&1?Rr:"";return`${e}..${r}`}function rS(t){let e,r,n;return t.children.length===1?(e=0,r=n=t.children[0]):t.children.length===3?(e=i(t.children[1]),r=t.children[0],n=t.children[2]):vt.is(t.children[0])?(e=i(t.children[0]),n=t.children[1]):(e=i(t.children[1]),r=t.children[0]),{kind:e,min:r,max:n};function i(o){let s=0;return o.value.startsWith(Rr)&&(s|=2),o.value.endsWith(Rr)&&(s|=1),s}}var oh=Object.freeze({destruct(t){return rS(t)},is(t){return t?.type==="mcdoc:float_range"}}),Mg=Object.freeze({destruct(t){let e,r,n=!1;for(let i of t.children)vt.is(i)&&i.value==="[]"?n=!0:Us.is(i)&&(n?e=i:r=i);return{arrayKind:t.children.find(vt.is),lengthRange:e,valueRange:r}},is(t){return t?.type==="mcdoc:type/primitive_array"}}),Xl=Object.freeze({destruct(t){return{item:t.children.find(sn.is),lengthRange:t.children.find(Us.is)}},is(t){return t?.type==="mcdoc:type/list"}}),Dg=Object.freeze({destruct(t){return{lengthRange:t.children.find(Us.is)}},is(t){return t?.type==="mcdoc:type/string"}}),Ql=Object.freeze({destruct(t){return{items:t.children.filter(sn.is)}},is(t){return t?.type==="mcdoc:type/tuple"}}),X1=new Set(["byte","short","int","long","float","double","string"]),So=Object.freeze({kinds:X1,destruct(t){return{block:t.children.find(sh.is),docComments:t.children.find(Hs.is),enumKind:e(t),identifier:t.children.find(fr.is),keyword:t.children.find(vt.is)};function e(r){for(let n of r.children.filter(vt.is))if(X1.has(n.value))return n.value}},is(t){return t?.type==="mcdoc:enum"}}),Hs=Object.freeze({asText(t){if(!t)return;let e=t.children.map(r=>r.comment);return e.every(r=>r.length===0||r.startsWith(" "))&&(e=e.map(r=>r.slice(1))),e.join(` -`)},is(t){return t?.type==="mcdoc:doc_comments"}}),sh=Object.freeze({destruct(t){return{fields:t.children.filter(ah.is)}},is(t){return t?.type==="mcdoc:enum/block"}}),ah=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),identifier:t.children.find(fr.is),value:t.children.find(TN.is)}},is(t){return t?.type==="mcdoc:enum/field"}}),TN=Object.freeze({is(t){return xo.is(t)||et.is(t)}}),S5=Object.freeze({is(t){return Mn.is(t)||Hs.is(t)}}),_o=Object.freeze({destruct(t){return{block:t.children.find(ch.is),docComments:t.children.find(Hs.is),identifier:t.children.find(fr.is),keyword:t.children.find(vt.is)}},is(t){return t?.type==="mcdoc:struct"}}),ec=Object.freeze({destruct(t){return{path:t.children.find(tc.is)}},is(t){return t?.type==="mcdoc:type/reference"}}),lh=Object.freeze({destruct(t){return{params:t.children.filter(Ng.is)}},is(t){return t?.type==="mcdoc:type_param_block"}}),Ng=Object.freeze({destruct(t){return{identifier:t.children.find(fr.is)}},is(t){return t?.type==="mcdoc:type_param"}}),tc=Object.freeze({destruct(t){let e=Za(t?.children,-1);return{children:t?.children??[],isAbsolute:t?.isAbsolute,lastIdentifier:fr.is(e)?e:void 0}},is(t){return t?.type==="mcdoc:path"}}),ch=Object.freeze({destruct(t){return{fields:t.children.filter(Pg.is)}},is(t){return t?.type==="mcdoc:struct/block"}}),Pg=Object.freeze({is(t){return Ws.is(t)||fh.is(t)}}),Ws=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),key:t.children.find(Lg.is),type:t.children.find(sn.is),isOptional:t.isOptional}},is(t){return t?.type==="mcdoc:struct/field/pair"}}),Lg=Object.freeze({is(t){return et.is(t)||fr.is(t)||rc.is(t)}}),rc=Object.freeze({destruct(t){return{type:t.children.find(sn.is)}},is(t){return t?.type==="mcdoc:struct/map_key"}}),fh=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),type:t.children.find(sn.is)}},is(t){return t?.type==="mcdoc:struct/field/spread"}}),nc=Object.freeze({destruct(t){return{location:t.children.find(U.is),index:t.children.find(ki.is)}},is(t){return t?.type==="mcdoc:type/dispatcher"}}),ic=Object.freeze({destruct(t){return{members:t.children.filter(sn.is)}},is(t){return t?.type==="mcdoc:type/union"}}),Ig=Object.freeze({destruct(t){return{injection:t.children.find(ON.is)}},is(t){return t?.type==="mcdoc:injection"}}),ON=Object.freeze({is(t){return Bg.is(t)||RN.is(t)}}),Bg=Object.freeze({is(t){return t?.type==="mcdoc:injection/enum"}}),RN=Object.freeze({is(t){return t?.type==="mcdoc:injection/struct"}}),oc=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),docComments:t.children.find(Hs.is),identifier:t.children.find(fr.is),keyword:t.children.find(vt.is),typeParams:t.children.find(lh.is),rhs:t.children.find(sn.is)}},is(t){return t?.type==="mcdoc:type_alias"}}),uh=Object.freeze({destruct(t){return{binding:t.children.find(fr.is),path:t.children.find(tc.is)}},is(t){return t?.type==="mcdoc:use_statement"}});var EN=Object.freeze({is(t){return!!t&&typeof t=="object"&&typeof t.nextAnonymousIndex=="number"}}),$g=Object.freeze({is(t){return!!t&&typeof t=="object"&&typeof t.typeDef=="object"}}),nS=ol.create(async(t,e)=>{let r=FN(e.doc.uri,e);if(!r){e.err.report(y("mcdoc.binder.out-of-root",P(e.doc.uri)),v.Beginning,0);return}let n={...e,moduleIdentifier:r};return iS(t,n)});async function iS(t,e){let r={nextAnonymousIndex:0};e.symbols.query({doc:e.doc,node:t},"mcdoc",e.moduleIdentifier).amend({data:{data:r}}),MN(t,e);for(let n of t.children)switch(n.type){case"mcdoc:dispatch_statement":await DN(n,e);break;case"mcdoc:enum":aS(n,e);break;case"mcdoc:injection":await LN(n,e);break;case"mcdoc:struct":await lS(n,e);break;case"mcdoc:type_alias":await BN(n,e);break;case"mcdoc:use_statement":await jN(n,e);break}}function MN(t,e){Ct(t,()=>!0,Q1.is,c=>{switch(c.type){case"mcdoc:enum":r(c);break;case"mcdoc:struct":n(c);break;case"mcdoc:type_alias":i(c);break;case"mcdoc:use_statement":o(c);break}});function r(c){s("enum",c,So.destruct,f=>({typeDef:hS(f,e)}))}function n(c){s("struct",c,_o.destruct,f=>({typeDef:dS(f,e)}))}function i(c){s("type_alias",c,oc.destruct,f=>{let{attributes:u,rhs:h,typeParams:d}=oc.destruct(f);if(!h)return;let p={typeDef:an(h,e)};return d&&oS(c,d,p,e),p.typeDef=Fg(p.typeDef,u,e),p})}function o(c){let{binding:f,path:u}=uh.destruct(c);if(!u)return;let{lastIdentifier:h}=tc.destruct(u),d=f??h;d&&e.symbols.query({doc:e.doc,node:c},"mcdoc",`${e.moduleIdentifier}::${d.value}`).ifDeclared(p=>qs(e,p,d)).elseEnter({data:{subcategory:"use_statement_binding",visibility:1},usage:{type:"definition",node:d,fullRange:c}})}function s(c,f,u,h){let{docComments:d,identifier:p,keyword:b}=u(f),m=p?.value??l(f,e);e.symbols.query({doc:e.doc,node:f},"mcdoc",`${e.moduleIdentifier}::${m}`).ifDeclared(k=>qs(e,k,p??f)).elseEnter({data:{data:h(f),desc:Hs.asText(d),subcategory:c},usage:{type:"definition",node:p??b,fullRange:p&&f}})}function a(c,f){let u=f.symbols.query({doc:f.doc,node:c},"mcdoc",f.moduleIdentifier).getData(EN.is);if(!u)throw new Error(`No symbol data for module '${f.moduleIdentifier}'`);return u.nextAnonymousIndex++}function l(c,f){return``}}function oS(t,e,r,n){t.locals=Object.create(null),r.typeDef={kind:"template",child:r.typeDef,typeParams:[]};let{params:i}=lh.destruct(e);for(let o of i){let{identifier:s}=Ng.destruct(o);if(s.value){let a=`${n.moduleIdentifier}::${s.value}`;n.symbols.query({doc:n.doc,node:t},"mcdoc",a).ifDeclared(l=>qs(n,l,s)).elseEnter({data:{visibility:0},usage:{type:"declaration",node:s,fullRange:o}}),r.typeDef.typeParams.push({path:a})}}}async function DN(t,e){let{attributes:r,location:n,index:i,target:o,typeParams:s}=Sg.destruct(t);if(!(n&&i&&o))return;let a=U.toString(n,"full");e.symbols.query(e.doc,"mcdoc/dispatcher",a).enter({usage:{type:"reference",node:n,fullRange:t}});let{parallelIndices:l}=ki.destruct(i);if(l.length){let c={typeDef:an(o,e)};s&&oS(t,s,c,e),c.typeDef=Fg(c.typeDef,r,e);for(let f of l)Jl.is(f)||e.symbols.query(e.doc,"mcdoc/dispatcher",a,ac(f)).ifDeclared(u=>qs(e,u,f,{localeString:"mcdoc.binder.dispatcher-statement.duplicated-key"})).elseEnter({data:{data:c},usage:{type:"definition",node:f,fullRange:t}})}await vi(o,e)}async function vi(t,e){if(nc.is(t))await NN(t,e);else if(So.is(t))aS(t,e);else if(Xl.is(t)){let{item:n}=Xl.destruct(t);await vi(n,e)}else if(ec.is(t)){let{path:n}=ec.destruct(t);await sS(n,e)}else if(_o.is(t))await lS(t,e);else if(Ql.is(t)){let{items:n}=Ql.destruct(t);for(let i of n)await vi(i,e)}else if(ic.is(t)){let{members:n}=ic.destruct(t);for(let i of n)await vi(i,e)}let{appendixes:r}=Cg.destruct(t);for(let n of r)if(Yl.is(n)){let{args:i}=Yl.destruct(n);for(let o of i)await vi(o,e)}}async function NN(t,e){let{index:r,location:n}=nc.destruct(t),i=U.toString(n,"full");e.symbols.query(e.doc,"mcdoc/dispatcher",i).enter({usage:{type:"reference",node:n,fullRange:t}});let{parallelIndices:o}=ki.destruct(r);for(let s of o)Jl.is(s)||e.symbols.query(e.doc,"mcdoc/dispatcher",i,ac(s)).enter({usage:{type:"reference",node:s,fullRange:t}})}async function sS(t,e){for(let{identifiers:r,node:n,indexRight:i}of cS(t,e,{reportErrors:!0}))if(r?.length){if(i===1){let o=hh(r),s=zN(o,e);if(!s){e.err.report(y("mcdoc.binder.path.unknown-module",P(o)),t,2);return}await e.ensureBindingStarted(s)}e.symbols.query({doc:e.doc,node:n},"mcdoc",hh(r)).ifDeclared((o,s)=>s.enter({usage:{type:"reference",node:n,fullRange:t,skipRenaming:vt.is(n)}})).else(()=>{i===0&&e.err.report(y("mcdoc.binder.path.unknown-identifier",P(Za(r,-1)),P(hh(r.slice(0,-1)))),t,2)})}}function aS(t,e){let{block:r,identifier:n,keyword:i}=So.destruct(t),o=n?.symbol??i.symbol;if(o?.subcategory!=="enum")return;let s=e.symbols.query({doc:e.doc,node:t},"mcdoc",...o.path);nr.assertDefined(s.symbol),PN(r,e,s)}function PN(t,e,r,n={}){let{fields:i}=sh.destruct(t);for(let o of i){let{identifier:s}=ah.destruct(o);r.member(s.value,a=>a.ifDeclared(l=>qs(e,l,s)).elseEnter({usage:{type:"definition",node:s,fullRange:o}}))}}async function LN(t,e){let{injection:r}=Ig.destruct(t);Bg.is(r)}async function lS(t,e){let{block:r,identifier:n,keyword:i}=_o.destruct(t),o=n?.symbol??i.symbol;if(o?.subcategory!=="struct")return;let s=e.symbols.query({doc:e.doc,node:t},"mcdoc",...o.path);nr.assertDefined(s.symbol),await IN(r,e,s)}async function IN(t,e,r,n={}){let{fields:i}=ch.destruct(t);for(let o of i)if(Ws.is(o)){let{key:s,type:a}=Ws.destruct(o);rc.is(s)||r.member(s.value,l=>l.ifDeclared(c=>qs(e,c,s)).elseEnter({usage:{type:"definition",node:s,fullRange:o}})),await vi(a,e)}else{let{type:s}=fh.destruct(o);await vi(s,e)}}async function BN(t,e){let{identifier:r,rhs:n,typeParams:i}=oc.destruct(t);r?.value&&n&&await vi(n,e)}async function jN(t,e){let{path:r}=uh.destruct(t);if(r)return sS(r,e)}function zg(t){t.registerBinder("mcdoc:module",nS)}function qs(t,e,r,n={localeString:"mcdoc.binder.duplicated-declaration"}){t.err.report(y(n.localeString,P(e.identifier)),r,2,{related:[{location:Le.getDeclaredLocation(e),message:y(`${n.localeString}.related`,P(e.identifier))}]})}function*cS(t,e,r={}){let{children:n,isAbsolute:i}=tc.destruct(t),o=i?[]:e.moduleIdentifier.slice(2).split("::");for(let[s,a]of n.entries()){switch(a.type){case"mcdoc:identifier":o.push(a.value);break;case"mcdoc:literal":if(o.length===0){r.reportErrors&&e.err.report(y("mcdoc.binder.path.super-from-root"),a);return}o.pop();break;default:nr.assertNever(a)}yield{identifiers:o,node:a,index:s,indexRight:n.length-1-s}}}function $N(t,e,r={}){return Za([...cS(t,e,r)],-1)?.identifiers}function zN(t,e){return e.symbols.global.mcdoc?.[t]?.definition?.[0]?.uri}function FN(t,e){return Object.values(e.symbols.global.mcdoc??{}).find(r=>r.subcategory==="module"&&r.definition?.some(n=>n.uri===t))?.identifier}function hh(t){return t?`::${t.join("::")}`:void 0}function an(t,e){switch(t.type){case"mcdoc:enum":return hS(t,e);case"mcdoc:struct":return dS(t,e);case"mcdoc:type/any":return rP(t,e);case"mcdoc:type/boolean":return nP(t,e);case"mcdoc:type/dispatcher":return iP(t,e);case"mcdoc:type/list":return oP(t,e);case"mcdoc:type/literal":return sP(t,e);case"mcdoc:type/numeric_type":return cP(t,e);case"mcdoc:type/primitive_array":return fP(t,e);case"mcdoc:type/string":return uP(t,e);case"mcdoc:type/reference":return hP(t,e);case"mcdoc:type/tuple":return dP(t,e);case"mcdoc:type/union":return pP(t,e);default:return nr.assertNever(t)}}function Ft(t,e,r,n={}){let{attributes:i,appendixes:o}=Cg.destruct(t),s=e;for(let a of o)if(ki.is(a)){if(n.skipFirstIndexBody){n.skipFirstIndexBody=!1;continue}s={kind:"indexed",child:s,parallelIndices:uS(a,r)}}else s={kind:"concrete",child:s,typeArgs:KN(a,r)};return s=Fg(s,i,r),s}function Fg(t,e,r){for(let n of e)t={kind:"attributed",attribute:fS(n,r),child:t};return t}function Vg(t,e){return VN(t.map(r=>fS(r,e)))}function VN(t){return t.length?t:void 0}function fS(t,e){let{name:r,value:n}=Mn.destruct(t);return{name:r.value,value:n&&jg(n,e)}}function jg(t,e){return t.type==="mcdoc:attribute/tree"?{kind:"tree",values:UN(t,e)}:an(t,e)}function UN(t,e){let r={},{named:n,positional:i}=Ag.destruct(t);if(i){let{values:o}=Tg.destruct(i);for(let[s,a]of o.entries())r[s]=jg(a,e)}if(n){let{values:o}=Og.destruct(n);for(let{key:s,value:a}of o)r[s.value]=jg(a,e)}return r}function uS(t,e){let{parallelIndices:r}=ki.destruct(t);return r.map(n=>HN(n,e))}function HN(t,e){return _g.is(t)?WN(t,e):qN(t,e)}function WN(t,e){return{kind:"static",value:ac(t)}}function qN(t,e){let{keys:r}=Jl.destruct(t);return{kind:"dynamic",accessor:r.map(ac)}}function KN(t,e){let{args:r}=Yl.destruct(t);return r.map(n=>an(n,e))}function hS(t,e){let{block:r,enumKind:n,identifier:i}=So.destruct(t),o=i?.symbol??t.symbol;return o&&$g.is(o.data)&&o.data.typeDef.kind==="enum"?o.data.typeDef:Ft(t,{kind:"enum",enumKind:n,values:GN(r,e)},e)}function GN(t,e){let{fields:r}=sh.destruct(t);return r.map(n=>ZN(n,e))}function ZN(t,e){let{attributes:r,identifier:n,value:i}=ah.destruct(t);return{attributes:Vg(r,e),identifier:n.value,value:JN(i,e)}}function JN(t,e){if(xo.is(t)){let{value:r}=xo.destruct(t);return r.value}return t.value}function dS(t,e){let{block:r,identifier:n}=_o.destruct(t),i=n?.symbol??t.symbol;return i&&$g.is(i.data)&&i.data.typeDef.kind==="struct"?i.data.typeDef:Ft(t,{kind:"struct",fields:YN(r,e)},e)}function YN(t,e){let{fields:r}=ch.destruct(t);return r.map(n=>XN(n,e))}function XN(t,e){return Ws.is(t)?QN(t,e):tP(t,e)}function QN(t,e){let{attributes:r,key:n,type:i,isOptional:o}=Ws.destruct(t);return{kind:"pair",attributes:Vg(r,e),key:eP(n,e),type:an(i,e),optional:o}}function eP(t,e){if(rc.is(t)){let{type:r}=rc.destruct(t);return an(r,e)}else return ac(t)}function tP(t,e){let{attributes:r,type:n}=fh.destruct(t);return{kind:"spread",attributes:Vg(r,e),type:an(n,e)}}function rP(t,e){return Ft(t,{kind:"any"},e)}function nP(t,e){return Ft(t,{kind:"boolean"},e)}function iP(t,e){let{index:r,location:n}=nc.destruct(t);return Ft(t,{kind:"dispatcher",parallelIndices:uS(r,e),registry:U.toString(n,"full")},e,{skipFirstIndexBody:!0})}function oP(t,e){let{item:r,lengthRange:n}=Xl.destruct(t);return Ft(t,{kind:"list",item:an(r,e),lengthRange:sc(n,e)},e)}function sc(t,e){if(!t)return;let{kind:r,min:n,max:i}=oh.is(t)?oh.destruct(t):Us.destruct(t);return{kind:r,min:n?.value,max:i?.value}}function sP(t,e){let{value:r}=Rg.destruct(t);return Ft(t,{kind:"literal",value:aP(r,e)},e)}function aP(t,e){if(vt.is(t))return{kind:"boolean",value:t.value==="true"};if(xo.is(t)){let{suffix:r,value:n}=xo.destruct(t);return{kind:"number",value:n.value,suffix:lP(r,e)}}else return{kind:"string",value:t.value}}function lP(t,e){return t?.value?.toLowerCase()}function cP(t,e){let{numericKind:r,valueRange:n}=Eg.destruct(t);return Ft(t,{kind:r.value,valueRange:sc(n,e)},e)}function fP(t,e){let{arrayKind:r,lengthRange:n,valueRange:i}=Mg.destruct(t);return Ft(t,{kind:`${r.value}_array`,lengthRange:sc(n,e),valueRange:sc(i,e)},e)}function uP(t,e){let{lengthRange:r}=Dg.destruct(t);return Ft(t,{kind:"string",lengthRange:sc(r,e)},e)}function hP(t,e){let{path:r}=ec.destruct(t);return Ft(t,{kind:"reference",path:hh($N(r,e))},e)}function dP(t,e){let{items:r}=Ql.destruct(t);return Ft(t,{kind:"tuple",items:r.map(n=>an(n,e))},e)}function pP(t,e){let{members:r}=ic.destruct(t);return Ft(t,{kind:"union",members:r.map(n=>an(n,e))},e)}function ac(t){return U.is(t)?U.toString(t,"short"):t.value}var mP=t=>[Ce.create(t,"variable")],gP=t=>[Ce.create(t,t.colorTokenType??"literal")];function pS(t){t.registerColorizer("mcdoc:literal",gP),t.registerColorizer("mcdoc:identifier",mP)}var gS=Object.freeze(["fallback","none","unknown"]),D5=Object.freeze({kind:"union",members:[]});var yP=Object.freeze(["b","s","l","f","d"]),yS=Object.freeze([...yP,"B","S","L","F","D"]),Hg=Object.freeze(["byte","short","int","long"]),ph=Object.freeze(["float","double"]),N5=Object.freeze([...Hg,...ph]),Wg=Object.freeze(["byte","int","long"]),P5=Object.freeze(Wg.map(t=>`${t}_array`)),dh;(function(t){function e(r){let n=o=>{if(!o)return"";let{kind:s,min:a,max:l}=o;return a===l?` @ ${a}`:` @ ${a??""}${tS(s)}${l??""}`},i=o=>{let s=[];for(let a of Ue.toArray(o))a===void 0?s.push("()"):s.push(a.kind==="static"?`[${a.value}]`:`[[${a.accessor.map(l=>typeof l=="string"?l:l.keyword).join(".")}]]`);return`[${s.join(", ")}]`};if(r===void 0)return"";switch(r.kind){case"any":case"boolean":return r.kind;case"attributed":return`#[${r.attribute.name}${r.attribute.value?"=":""}] ${e(r.child)}`;case"byte":return`byte${n(r.valueRange)}`;case"byte_array":return`byte${n(r.valueRange)}[]${n(r.lengthRange)}`;case"concrete":return`${e(r.child)}${r.typeArgs.length?`<${r.typeArgs.map(e).join(", ")}>`:""}`;case"dispatcher":return`${r.registry??"spyglass:unknown"}[${i(r.parallelIndices)}]`;case"double":return`double${n(r.valueRange)}`;case"enum":return"";case"float":return`float${n(r.valueRange)}`;case"indexed":return`${e(r.child)}${i(r.parallelIndices)}`;case"int":return`int${n(r.valueRange)}`;case"int_array":return`int${n(r.valueRange)}[]${n(r.lengthRange)}`;case"list":return`[${e(r.item)}]${n(r.lengthRange)}`;case"literal":return`${r.value}`;case"long":return`long${n(r.valueRange)}`;case"long_array":return`long${n(r.valueRange)}[]${n(r.lengthRange)}`;case"reference":return r.path??"";case"short":return`short${n(r.valueRange)}`;case"string":return`string${n(r.lengthRange)}`;case"struct":return"";case"template":return`${e(r.child)}${r.typeParams.length?`<${r.typeParams.map(o=>`?${o.path}`).join(", ")}>`:""}`;case"tuple":return`[${r.items.map(o=>e(o)).join(",")}${r.items.length===1?",":""}]`;case"union":return`(${r.members.map(e).join(" | ")})`;case"unsafe":return"unsafe";default:return nr.assertNever(r)}}t.toString=e})(dh||(dh={}));var nt;(function(t){t[t.Nah=0]="Nah",t[t.Assignable=1]="Assignable",t[t.StrictlyAssignable=3]="StrictlyAssignable"})(nt||(nt={}));var lc=(t,e)=>{if(!e)return!0;if(!t)return!1;let{min:r,max:n}=t,{min:i,max:o}=e;return(i===void 0||r!==void 0&&r>=i)&&(o===void 0||n!==void 0&&n<=o)},Gs=t=>{let e=new Set,r=n=>{for(let i of e){if((Ks(n,i)&nt.StrictlyAssignable)===nt.StrictlyAssignable)return;(Ks(i,n)&nt.StrictlyAssignable)===nt.StrictlyAssignable&&e.delete(i)}e.add(n)};for(let n of t.members)n.kind==="union"?Gs(n).members.forEach(r):r(n);return{kind:"union",members:[...e]}};var bP=t=>(t=Gs(t),t.members.length===1?t.members[0]:t),cc=t=>({kind:"list",item:Ug(t.item),...t.lengthRange?{lengthRange:{...t.lengthRange}}:{}}),Ug=t=>(t.kind==="union"?t=bP(t):t.kind==="list"&&(t=cc(t)),t),Ks=(t,e,r=[])=>{let n=s=>s?nt.StrictlyAssignable:nt.Nah,i=s=>s?nt.Assignable:nt.Nah,o;return t=Ug(t),e=Ug(e),t.kind==="any"||t.kind==="reference"||e.kind==="reference"?o=nt.Assignable:e.kind==="any"?o=nt.StrictlyAssignable:t.kind==="union"?o=i(t.members.every(s=>Ks(s,e,r))):e.kind==="union"?o=i(e.members.some(s=>Ks(t,s))):t.kind==="boolean"?o=n(e.kind==="boolean"||e.kind==="byte"):t.kind==="byte"?e.kind==="boolean"?o=Ks(t,{kind:"byte",valueRange:{kind:0,min:0,max:1}},r):e.kind==="byte"?o=n(lc(t.valueRange,e.valueRange)):e.kind==="enum"?o=i(!e.enumKind||e.enumKind==="byte"):o=nt.Nah:t.kind==="byte_array"||t.kind==="int_array"||t.kind==="long_array"?o=n(e.kind===t.kind&&lc(t.lengthRange,e.lengthRange)&&lc(t.valueRange,e.valueRange)):t.kind==="struct"||t.kind==="dispatcher"?o=i(e.kind==="struct"||e.kind==="dispatcher"):t.kind==="enum"?o=i((e.kind==="byte"||e.kind==="float"||e.kind==="double"||e.kind==="int"||e.kind==="long"||e.kind==="short"||e.kind==="string")&&(!t.enumKind||t.enumKind===e.kind)):t.kind==="float"||t.kind==="double"||t.kind==="int"||t.kind==="long"||t.kind==="short"?e.kind===t.kind?o=n(lc(t.valueRange,e.valueRange)):e.kind==="enum"?o=i(!e.enumKind||e.enumKind===t.kind):o=nt.Nah:t.kind==="list"?e.kind==="list"&&lc(t.lengthRange,e.lengthRange)?o=Ks(t.item,e.item,r):o=nt.Nah:t.kind==="string"?e.kind==="string"?o=nt.StrictlyAssignable:o=i(e.kind==="enum"&&(!e.enumKind||e.enumKind==="string")):o=nt.Nah,o||r.push(y("mcdoc.checker.type-not-assignable",P(dh.toString(t)),P(dh.toString(e)))),o};var CS=Is(Rl({singleLinePrefixes:new Set(["//"])}),(t,e)=>!e.slice(t).startsWith("///"),y("mcdoc.parser.syntax.doc-comment-unexpected"));function AS(t=!1){return(e,r)=>{let n=[];for(e.skipWhitespace();e.canRead()&&e.peek(2)==="//"&&(!t||e.peek(3)!=="///");){let i=CS(e,r);n.push(i),e.skipWhitespace()}return n}}function z(t,e=!1){return(r,n)=>{r.skipWhitespace();let i=be(t,AS(e))(r,n);return r.skipWhitespace(),i}}function Mr(t,e=!1){return Ls(t,AS(e))}function Er(t,e){return(r,n)=>{let i={type:"mcdoc:literal",range:v.create(r),value:"",colorTokenType:e?.colorTokenType};return i.value=r.readIf(o=>e?.allowedChars?.has(o)??(e?.specialChars?.has(o)||/[a-z]/i.test(o))),i.range.end=r.cursor,Ue.toArray(t).every(o=>o!==i.value)&&n.err.report(y("expected-got",vn(t),P(i.value)),i),i}}function Rt(t,e={colorTokenType:"keyword"}){return(r,n)=>{let i=Er(t,e)(r,n);return Ue.toArray(t).includes(i.value)?i:V}}function Q(t){return(e,r)=>{e.skipWhitespace(),e.trySkip(t)||r.err.report(y("expected-got",P(t),P(e.peek())),e)}}function fe(t){return(e,r)=>{if(e.skipWhitespace(),!e.trySkip(t))return V}}function qg(t){return Is(Re(t),e=>e.namespace!==void 0,y("mcdoc.parser.resource-location.colon-expected",P(q.NamespacePathSep)))}var kP=Object.freeze(["\0","","","","","","","\x07","\b"," ",` -`,"\v","\f","\r","","","\x7F"]),Zs=Tn(dt({escapable:{characters:["b","f","n","r","t","\\",'"'],unicode:!0},quotes:['"']}),...kP),ur=(t,e)=>{let r=/^[\p{L}\p{Nl}]$/u,n=/^[\p{L}\p{Nl}\u200C\u200D\p{Mn}\p{Mc}\p{Nd}\p{Pc}]$/u,i=new Set(["any","boolean","byte","double","enum","false","float","int","long","short","string","struct","super","true"]),o={type:"mcdoc:identifier",range:v.create(t),options:{category:"mcdoc"},value:""},s=t.innerCursor;if(r.test(t.peek()))for(t.skip();n.test(t.peek());)t.skip();else e.err.report(y("expected",y("mcdoc.node.identifier")),t);return o.value=t.string.slice(s,t.innerCursor),o.range.end=t.cursor,i.has(o.value)&&e.err.report(y("mcdoc.parser.identifier.reserved-word",P(o.value)),o),o};function Kg(t){let e=ne([{prefix:"%",parser:Er(["%key","%parent"],{specialChars:new Set(["%"])})},{prefix:'"',parser:Zs},{parser:ur}]),r=se("mcdoc:dynamic_index",z([Q("["),e,Ls(be([fe("."),e])),Q("]")])),n=ne([{prefix:"%",parser:Er(gS.map(i=>`%${i}`),{specialChars:new Set(["%"])})},{prefix:'"',parser:Zs},{prefix:"[",parser:t?.noDynamic?Is(r,()=>!1,y("mcdoc.parser.index-body.dynamic-index-not-allowed")):r},{parser:ar([qg({category:"mcdoc/dispatcher",accessType:t?.accessType}),ur])}]);return se("mcdoc:index_body",z([Q("["),n,Mr(z([fe(","),oe(n)])),ke(fe(",")),Q("]")]))}var bS=ne([{prefix:"super",parser:Er("super")},{parser:ur}]),gh=(t,e)=>{let r;return t.trySkip("::")&&(r=!0),J(be([bS,Ls(be([fe("::"),bS]))]),n=>({type:"mcdoc:path",children:n.children,range:n.range,isAbsolute:r}))(t,e)},kS=se("mcdoc:attribute/tree/pos",z([{get:()=>mh},Mr(z([fe(","),{get:()=>oe(mh)}],!0),!0)],!0)),vS=z([ne([{prefix:'"',parser:Zs},{parser:ur}]),ne([{prefix:"=",parser:z([Q("="),{get:()=>mh}],!0)},{parser:{get:()=>Gg}}])],!0),wS=se("mcdoc:attribute/tree/named",z([vS,Mr(z([fe(","),oe(vS)],!0),!0)],!0)),vP=ar([z([wS,ke(fe(","))]),z([kS,Q(","),wS,ke(fe(","))]),z([kS,ke(fe(","))])]),wP=Object.freeze({"(":")","[":"]","{":"}"}),Gg=(t,e)=>{let r=t.trySkip("(")?"(":t.trySkip("[")?"[":t.trySkip("{")?"{":void 0;if(!r)return V;let n=vP(t,e),i={type:"mcdoc:attribute/tree",range:n.range,children:n.children,delim:r};return t.trySkip(wP[r]),i},mh=ne([{predicate:t=>["(","[","{"].includes(t.peek()),parser:Gg},{parser:{get:()=>Ot}}]),xP=se("mcdoc:attribute",z([fe("#["),ur,ne([{prefix:"=",parser:z([Q("="),mh,Q("]")],!0)},{predicate:t=>["(","[","{"].includes(t.peek()),parser:z([Gg,Q("]")],!0)},{parser:Q("]")}])],!0)),yh=Ls(xP),xS=se("mcdoc:type_param",z([ur])),SP=se("mcdoc:type_param_block",z([Q("<"),ne([{prefix:">",parser:Q(">")},{parser:z([xS,Mr(z([fe(","),oe(xS)])),ke(fe(",")),Q(">")])}])])),Zg=()=>{},TS=ne([{prefix:"<",parser:SP},{parser:Zg}]),_P=se("mcdoc:dispatch_statement",z([yh,Rt("dispatch"),qg({category:"mcdoc/dispatcher",accessType:1}),Kg({noDynamic:!0}),TS,Er("to"),{get:()=>Ot}],!0)),CP=Rl({singleLinePrefixes:new Set(["///"]),includesEol:!0}),AP=se("mcdoc:doc_comments",Ls(CP,t=>(t.skipWhitespace(),[]))),uc=z([ke(oe(AP)),yh]),OS=Er(["byte","short","int","long","string","float","double"],{colorTokenType:"type"}),RS=en({pattern:/^[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)?|[0-9]*\.[0-9]+(?:[eE][-+]?[0-9]+)?)$/}),ES=se("mcdoc:typed_number",be([RS,ke(Rt(yS,{colorTokenType:"keyword"}))])),TP=ne([{prefix:'"',parser:Zs},{parser:ES}]),SS=se("mcdoc:enum/field",z([uc,ur,Q("="),TP],!0)),MS=se("mcdoc:enum/block",z([Q("{"),ne([{prefix:"}",parser:Q("}")},{parser:z([SS,Mr(z([fe(","),oe(SS)],!0),!0),ke(fe(",")),Q("}")],!0)}])],!0)),DS=se("mcdoc:enum",z([uc,Rt("enum"),Q("("),OS,Q(")"),ke(Ol(ur)),MS],!0)),OP=se("mcdoc:struct/map_key",z([Q("["),{get:()=>Ot},Q("]")],!0)),RP=ne([{prefix:'"',parser:Zs},{prefix:"[",parser:OP},{parser:ur}]),EP=(t,e)=>{let r,n=z([uc,RP],!0)(t,e);t.trySkip("?")&&(r=!0);let i=z([Q(":"),{get:()=>Ot}],!0)(t,e);return{type:"mcdoc:struct/field/pair",children:[...n.children,...i.children],range:v.span(n,i),isOptional:r}},MP=se("mcdoc:struct/field/spread",z([yh,fe("..."),{get:()=>Ot}],!0)),_S=ar([MP,EP]),NS=se("mcdoc:struct/block",z([Q("{"),ne([{prefix:"}",parser:Q("}")},{parser:z([_S,Mr(z([fe(","),oe(_S)],!0),!0),ke(fe(",")),Q("}")],!0)}])],!0)),PS=se("mcdoc:struct",z([uc,Rt("struct"),ke(oe(ur)),NS],!0)),DP=se("mcdoc:injection/enum",z([Er("enum"),Q("("),OS,Q(")"),gh,MS])),NP=se("mcdoc:injection/struct",z([Er("struct"),gh,NS])),PP=se("mcdoc:injection",z([Rt("inject"),ne([{prefix:"enum",parser:DP},{parser:NP}])])),LP=se("mcdoc:type_alias",z([uc,Rt("type"),ur,TS,Q("="),{get:()=>Ot}],!0)),IP=se("mcdoc:use_statement",z([Rt("use"),gh,ne([{prefix:"as",parser:z([Er("as"),ur])},{parser:Zg}])],!0)),BP=ar([CS,_P,DS,PP,PS,LP,IP]),LS=se("mcdoc:module",Mr(BP,!0)),jP=se("mcdoc:type_arg_block",z([fe("<"),ne([{prefix:">",parser:Q(">")},{parser:z([{get:()=>Ot},Mr(z([fe(","),{get:()=>oe(Ot)}],!0),!0),ke(fe(",")),Q(">")],!0)}])]));function Dr(t,e){return se(t,z([yh,e,Mr(ne([{prefix:"<",parser:jP},{parser:Ol(Kg())}]))],!0))}var $P=Dr("mcdoc:type/any",Rt("any",{colorTokenType:"type"})),zP=Dr("mcdoc:type/boolean",Rt("boolean",{colorTokenType:"type"})),FP=Ar({pattern:/^(?:0|[-+]?[1-9][0-9]*)$/});function IS(t,e){let r=i=>i.tryPeek("..")||i.tryPeek(`${Rr}..`),n=Er(["..",`..${Rr}`,`${Rr}..`,`${Rr}..${Rr}`],{allowedChars:new Set([".",Rr])});return se(t,ne([{predicate:r,parser:be([n,e])},{parser:be([Tn(e,".."),ne([{predicate:r,parser:be([n,ke(oe(e))])},{parser:Zg}])])}]))}var VP=IS("mcdoc:int_range",FP),fc=ke((t,e)=>t.trySkip("@")?(t.skipWhitespace(),VP(t,e)):V),UP=Dr("mcdoc:type/string",z([Rt("string",{colorTokenType:"type"}),fc])),HP=Dr("mcdoc:type/literal",ne([{predicate:t=>t.tryPeek("false")||t.tryPeek("true"),parser:Rt(["false","true"],{colorTokenType:"type"})},{prefix:'"',parser:oe(Zs)},{parser:Ol(ES)}])),WP=IS("mcdoc:float_range",RS),qP=ke((t,e)=>t.trySkip("@")?(t.skipWhitespace(),WP(t,e)):V),KP=Dr("mcdoc:type/numeric_type",ne([{predicate:t=>ph.some(e=>t.tryPeek(e)),parser:z([Rt(ph,{colorTokenType:"type"}),qP])},{parser:z([Rt(Hg,{colorTokenType:"type"}),fc])}])),GP=Dr("mcdoc:type/primitive_array",z([Er(Wg),fc,Rt("[]",{allowedChars:new Set(["[","]"]),colorTokenType:"type"}),fc])),ZP=Dr("mcdoc:type/list",z([fe("["),{get:()=>Ot},Q("]"),fc],!0)),JP=Dr("mcdoc:type/tuple",z([fe("["),{get:()=>Ot},fe(","),ne([{prefix:"]",parser:Q("]")},{parser:z([{get:()=>Ot},Mr(z([fe(","),{get:()=>oe(Ot)}],!0),!0),ke(fe(",")),Q("]")],!0)}])],!0)),YP=Dr("mcdoc:type/dispatcher",z([Ol(qg({category:"mcdoc/dispatcher"})),Kg()])),XP=Dr("mcdoc:type/union",z([fe("("),ne([{prefix:")",parser:Q(")")},{parser:z([{get:()=>Ot},Mr(z([fe("|"),{get:()=>oe(Ot)}],!0),!0),ke(fe("|")),Q(")")],!0)}])])),QP=Dr("mcdoc:type/reference",z([gh])),Ot=ar([$P,zP,YP,DS,ZP,HP,KP,GP,UP,PS,JP,XP,QP]);function BS(t){return`::${t.join("::")}`}var Js=".mcdoc",jS="mcdoc/",$S=(t,e)=>{let r=[];for(let n of t){if(!n.endsWith(Js))continue;let i=Y.getRel(n,e.roots);i&&(i=i.slice(0,-Js.length).replace(/(^|\/)mod$/,""),r.push([n,i]))}r.every(([n,i])=>i.startsWith(jS))&&(r=r.map(([n,i])=>[n,i.slice(jS.length)]));for(let[n,i]of r)e.symbols.query(n,"mcdoc",BS(i.split("/"))).ifKnown(()=>{}).elseEnter({data:{subcategory:"module"},usage:{type:"definition"}})},zS=(t,e,r)=>t.endsWith(Js)&&!e.endsWith(Js)?-1:!t.endsWith(Js)&&e.endsWith(Js)?1:r(t,e);var FS=({meta:t})=>{t.registerLanguage("mcdoc",{extensions:[".mcdoc"],parser:LS}),t.registerUriBinder($S),t.setUriSorter(zS),zg(t),pS(t)};function VS(t){t.registerColorizer("nbt:byte",Ie.number),t.registerColorizer("nbt:short",Ie.number),t.registerColorizer("nbt:int",Ie.number),t.registerColorizer("nbt:long",Ie.number),t.registerColorizer("nbt:float",Ie.number),t.registerColorizer("nbt:double",Ie.number)}var ln={};yr(ln,{byteArray:()=>Xg,compound:()=>wi,entry:()=>xi,intArray:()=>Qg,list:()=>Yg,longArray:()=>ey,path:()=>ty,primitive:()=>Ao,string:()=>Jg});function hr(t){return y(`nbt.node.${t.replace(/^nbt:/,"")}`)}var wi=(t,e)=>se("nbt:compound",Tr({start:"{",pair:{key:oe(dt({...ui,colorTokenType:"property"})),sep:":",value:xi,end:",",trailingEnd:!1},end:"}"}))(t,e);var HS=(2-2**-23)*2**127,rL=[{pattern:/^[-+]?(?:0|[1-9][0-9]*)b$/i,type:"nbt:byte",hasSuffix:!0,group:2,min:-128,max:127},{pattern:/^[-+]?(?:0|[1-9][0-9]*)s$/i,type:"nbt:short",hasSuffix:!0,group:2,min:-32768,max:32767},{pattern:/^[-+]?(?:0|[1-9][0-9]*)$/,type:"nbt:int",hasSuffix:!1,group:2,min:-2147483648,max:2147483647},{pattern:/^[-+]?(?:0|[1-9][0-9]*)l$/i,type:"nbt:long",hasSuffix:!0,group:3,min:-9223372036854775808n,max:9223372036854775807n},{pattern:/^[-+]?(?:[0-9]+\.?|[0-9]*\.[0-9]+)(?:e[-+]?[0-9]+)?f$/i,type:"nbt:float",hasSuffix:!0,group:1,min:-HS,max:HS},{pattern:/^[-+]?(?:[0-9]+\.|[0-9]*\.[0-9]+)(?:e[-+]?[0-9]+)?$/i,type:"nbt:double",hasSuffix:!1,group:1,min:-Number.MAX_VALUE,max:Number.MAX_VALUE},{pattern:/^[-+]?(?:[0-9]+\.?|[0-9]*\.[0-9]+)(?:e[-+]?[0-9]+)?d$/i,type:"nbt:double",hasSuffix:!0,group:1,min:-Number.MAX_VALUE,max:Number.MAX_VALUE},{pattern:/^true$/i,type:"nbt:byte",value:1,group:0},{pattern:/^false$/i,type:"nbt:byte",value:0,group:0}],Jg=ho,Ao=(t,e)=>{if(_e.isBrigadierQuote(t.peek()))return Jg(t,e);let{result:r,updateSrcAndCtx:n}=zt(Jg,t,e);for(let i of rL)if(i.pattern.test(r.value)){if(i.group===0){let f={type:"nbt:byte",range:r.range,value:i.value};return n(),f}let o=!1,s=()=>o=!0,a=i.group===2?Ar({pattern:/./,min:i.min,max:i.max,onOutOfRange:s}):i.group===3?El({pattern:/./,min:i.min,max:i.max,onOutOfRange:s}):en({pattern:/./,min:i.min,max:i.max,onOutOfRange:s}),{result:l,updateSrcAndCtx:c}=zt(a,t,e);if(o){e.err.report(y("nbt.parser.number.out-of-range",hr(i.type),y("nbt.node.string"),i.min,i.max),r,2);break}return c(),i.hasSuffix&&(t.skip(),l.range.end++),{...l,type:i.type}}return n(),r};var xi=(t,e)=>oe(ne([{predicate:r=>r.tryPeek("[B;"),parser:Xg},{predicate:r=>r.tryPeek("[I;"),parser:Qg},{predicate:r=>r.tryPeek("[L;"),parser:ey},{predicate:r=>r.tryPeek("["),parser:Yg},{predicate:r=>r.tryPeek("{"),parser:wi},{parser:Ao}]))(t,e);var Yg=(t,e)=>{let n=fi({start:"[",value:xi,sep:",",trailingSep:!1,end:"]"})(t,e);if(n.type="nbt:list",n.valueType=n.children[0]?.value?.type,n.valueType)for(let{value:i}of n.children)i&&i.type!==n.valueType&&e.err.report(y("expected-got",hr(n.valueType),hr(i.type)),i);return n},Xg=(t,e)=>{let n=fi({start:"[B;",value:Ao,sep:",",trailingSep:!1,end:"]"})(t,e);n.type="nbt:byte_array";for(let{value:i}of n.children)i&&i.type!=="nbt:byte"&&e.err.report(y("expected-got",y("nbt.node.byte"),hr(i.type)),i);return n},Qg=(t,e)=>{let n=fi({start:"[I;",value:Ao,sep:",",trailingSep:!1,end:"]"})(t,e);n.type="nbt:int_array";for(let{value:i}of n.children)i&&i.type!=="nbt:int"&&e.err.report(y("expected-got",y("nbt.node.int"),hr(i.type)),i);return n},ey=(t,e)=>{let n=fi({start:"[L;",value:Ao,sep:",",trailingSep:!1,end:"]"})(t,e);n.type="nbt:long_array";for(let{value:i}of n.children)i&&i.type!=="nbt:long"&&e.err.report(y("expected-got",y("nbt.node.long"),hr(i.type)),i);return n};var ty=(t,e)=>{let r={type:"nbt:path",children:[],range:v.create(t)},n=["filter","key"],i=WS(t),o;for(;o!==t.cursor&&(n.includes(i)||e.err.report(y("expected-got",vn(n.map(qS),!1,"or"),qS(i)),t),i!=="end");)o=t.cursor,n=sL[i](r.children,t,e),i=WS(t);return r.range.end=t.cursor,r},nL=(t,e,r)=>(t.push(wi(e,r)),e.trySkip(".")?["key"]:["end"]),iL=(t,e,r)=>{let n={type:"nbt:path/index",children:void 0,range:v.create(e)};if(!e.trySkip("["))throw new Error(`NBT path index parser called at illegal position: \u201C${e.peek()}\u201D at ${e.cursor}`);e.skipSpace();let i=e.peek();return i==="{"?n.children=[wi(e,r)]:i!=="]"&&(n.children=[Ar({pattern:/^-?\d+$/})(e,r)]),e.skipSpace(),e.trySkip("]")||r.err.report(y("expected-got",P("]"),P(e.peek())),e),n.range.end=e.cursor,t.push(n),e.trySkip(".")?["index","key"]:["end","index"]},oL=(t,e,r)=>{let n=dt({colorTokenType:"property",escapable:{},quotes:['"'],unquotable:{blockList:new Set([` -`,"\r"," "," ",'"',"[","]",".","{","}"])}})(e,r);return t.push(n),e.trySkip(".")?["index","key"]:["end","filter","index"]};function WS(t){switch(t.peek()){case"":case" ":case` -`:case"\r":return"end";case"{":return"filter";case"[":return"index";default:return"key"}}function qS(t){return y(`nbt.node.path.${t}`)}var sL={filter:nL,index:iL,key:oL};var it={};yr(it,{blockStates:()=>yy,compound:()=>e_,definition:()=>QS,enum_:()=>fL,fieldValue:()=>dc,index:()=>XS,path:()=>uL});var KS;(function(t){function e(r){return ry.is(r)||Nr.is(r)||hy.is(r)}t.is=e})(KS||(KS={}));var ry;(function(t){function e(r){return ny.is(r)||et.is(r)}t.is=e})(ry||(ry={}));var ny;(function(t){function e(r){return iy.is(r)||cy.is(r)}t.is=e})(ny||(ny={}));var iy;(function(t){function e(r){return oy.is(r)||sy.is(r)||ay.is(r)||ly.is(r)}t.is=e})(iy||(iy={}));var oy;(function(t){function e(r){return r?.type==="nbt:byte"}t.is=e})(oy||(oy={}));var sy;(function(t){function e(r){return r?.type==="nbt:short"}t.is=e})(sy||(sy={}));var ay;(function(t){function e(r){return r?.type==="nbt:int"}t.is=e})(ay||(ay={}));var ly;(function(t){function e(r){return r?.type==="nbt:long"}t.is=e})(ly||(ly={}));var cy;(function(t){function e(r){return fy.is(r)||uy.is(r)}t.is=e})(cy||(cy={}));var fy;(function(t){function e(r){return r?.type==="nbt:float"}t.is=e})(fy||(fy={}));var uy;(function(t){function e(r){return r?.type==="nbt:double"}t.is=e})(uy||(uy={}));var Nr;(function(t){function e(r){return r?.type==="nbt:compound"}t.is=e})(Nr||(Nr={}));var hy;(function(t){function e(r){return hc.is(r)||dy.is(r)}t.is=e})(hy||(hy={}));var hc;(function(t){function e(r){return r?.type==="nbt:list"}t.is=e})(hc||(hc={}));var dy;(function(t){function e(r){return py.is(r)||my.is(r)||gy.is(r)}t.is=e})(dy||(dy={}));var py;(function(t){function e(r){return r?.type==="nbt:byte_array"}t.is=e})(py||(py={}));var my;(function(t){function e(r){return r?.type==="nbt:int_array"}t.is=e})(my||(my={}));var gy;(function(t){function e(r){return r?.type==="nbt:long_array"}t.is=e})(gy||(gy={}));var Ys;(function(t){function e(r){return r?.type==="nbt:path"}t.is=e})(Ys||(Ys={}));var GS;(function(t){function e(r){return r?.type==="nbt:path/index"}t.is=e})(GS||(GS={}));var aL={"minecraft:brain_coral_fan":["minecraft:brain_coral_fan","minecraft:brain_coral_wall_fan"],"minecraft:bubble_coral_fan":["minecraft:bubble_coral_fan","minecraft:bubble_coral_wall_fan"],"minecraft:fire_coral_fan":["minecraft:fire_coral_fan","minecraft:fire_coral_wall_fan"],"minecraft:horn_coral_fan":["minecraft:horn_coral_fan","minecraft:horn_coral_wall_fan"],"minecraft:tube_coral_fan":["minecraft:tube_coral_fan","minecraft:tube_coral_wall_fan"],"minecraft:creeper_head":["minecraft:creeper_head","minecraft:creeper_wall_head"],"minecraft:dragon_head":["minecraft:dragon_head","minecraft:dragon_wall_head"],"minecraft:player_head":["minecraft:player_head","minecraft:player_wall_head"],"minecraft:skeleton_skull":["minecraft:skeleton_skull","minecraft:skeleton_wall_skull"],"minecraft:wither_skeleton_skull":["minecraft:wither_skeleton_skull","minecraft:wither_skeleton_wall_skull"],"minecraft:dead_brain_coral_fan":["minecraft:dead_brain_coral_fan","minecraft:dead_brain_coral_wall_fan"],"minecraft:dead_bubble_coral_fan":["minecraft:dead_bubble_coral_fan","minecraft:dead_bubble_coral_wall_fan"],"minecraft:dead_fire_coral_fan":["minecraft:dead_fire_coral_fan","minecraft:dead_fire_coral_wall_fan"],"minecraft:dead_horn_coral_fan":["minecraft:dead_horn_coral_fan","minecraft:dead_horn_coral_wall_fan"],"minecraft:dead_tube_coral_fan":["minecraft:dead_tube_coral_fan","minecraft:dead_tube_coral_wall_fan"],"minecraft:torch":["minecraft:torch","minecraft:wall_torch"],"minecraft:soul_torch":["minecraft:soul_torch","minecraft:soul_wall_torch"],"minecraft:redstone_torch":["minecraft:redstone_torch","minecraft:redstone_wall_torch"],"minecraft:beetroot_seeds":["minecraft:beetroots"],"minecraft:carrot":["minecraft:carrots"],"minecraft:cocoa_beans":["minecraft:cocoa"],"minecraft:glow_berries":["minecraft:cave_vines"],"minecraft:melon_seeds":["minecraft:melon_stem"],"minecraft:potato":["minecraft:potatoes"],"minecraft:pumpkin_seeds":["minecraft:pumpkin_stem"],"minecraft:redstone":["minecraft:redstone_wire"],"minecraft:string":["minecraft:tripwire"],"minecraft:sweat_berries":["minecraft:sweat_berry_bush"],"minecraft:wheat_seeds":["minecraft:wheat"]};function ZS(t){return aL[t]}function JS(t){if(t==="minecraft:armor_stand")return t;let e=t.match(/^minecraft:([a-z0-9_]+)_spawn_egg$/);if(e)return`minecraft:${e[1]}`}var lL={"::minecraft::block::banner::Banner.CustomName":"mcfunction:component","::minecraft::block::brewingstand::BrewingStand.CustomName":"mcfunction:component","::minecraft::block::commandblock::CommandBlock.Command":"mcfunction:command","::minecraft::block::commandblock::CommandBlock.CustomName":"mcfunction:component","::minecraft::block::container::ContainerBase.CustomName":"mcfunction:component","::minecraft::block::enchantingtable::EnchantingTable.CustomName":"mcfunction:component","::minecraft::block::furnace::Furnace.CustomName":"mcfunction:component","::minecraft::block::hopper::Hopper.CustomName":"mcfunction:component","::minecraft::block::sign::Sign.Text1":"mcfunction:component","::minecraft::block::sign::Sign.Text2":"mcfunction:component","::minecraft::block::sign::Sign.Text3":"mcfunction:component","::minecraft::block::sign::Sign.Text4":"mcfunction:component","::minecraft::entity::effectcloud::EffectCloud.Particle":"mcfunction:particle","::minecraft::entity::minecart::CommandMinecart.Command":"mcfunction:command","::minecraft::entity::mob::LivingEntity.Team":"mcfunction:team","::minecraft::entity::EntityBase.Tags[]":"mcfunction:tag","::minecraft::item::blockitem::BlockItem.CanPlaceOn[]":"mcfunction:block_predicate","::minecraft::item::book::WrittenBook.pages[]":"mcfunction:component","::minecraft::item::ItemBase.CanDestroy[]":"mcfunction:block_predicate"};function YS(t){return lL[t]}function XS(t,e,r={}){switch(t){case"custom:blockitemstates":let n=ZS(e);return n?yy(n,r):tt.noop;case"custom:blockstates":return yy([e],r);case"custom:spawnitemtag":let i=JS(e);return i?XS("entity_type",i,r):tt.noop;default:let o=cL(t);return o?(s,a)=>{QS(o,r)(s,a)}:tt.noop}}function cL(t){switch(t){case"block":return"::java::server::world::block::BlockEntity";case"entity_type":return"::java::server::world::entity::AnyEntity";case"item":return"::java::server::world::item::AnyItem";default:return}}function QS(t,e={}){return(r,n)=>{let o=n.symbols.query(n.doc,"mcdoc",t).getData(Co.TypeDefSymbolData.is)?.typeDef;if(o)switch(o.kind){case"struct":e_(o,e)(r,n);break;default:n.logger.error(`[nbt.checker.definition] Expected a struct type, but got ${o.kind}`)}}}function yy(t,e={}){return(r,n)=>{let i=Ga("block",t,n);for(let{key:o,value:s}of r.children)if(!(!o||!s)){if(s.type==="nbt:byte"&&(n.src.slice(s.range).toLowerCase()==="false"||n.src.slice(s.range).toLowerCase()==="true")){n.err.report(y("nbt.checker.block-states.fake-boolean"),s,2);continue}else if(s.type!=="string"&&s.type!=="nbt:int"){n.err.report(y("nbt.checker.block-states.unexpected-value-type"),s,2);continue}if(Object.keys(i).includes(o.value)){let a=i[o.value];a.includes(s.value.toString())||n.err.report(y("expected-got",a,P(s.value.toString())),s,2)}else n.err.report(y("nbt.checker.block-states.unknown-state",P(o.value),t),o,2)}}}function e_(t,e={}){return(r,n)=>{for(let{key:i,value:o}of r.children){if(!i||!o)continue;let s=i.value,a=t.fields.find(l=>l.kind==="pair"&&l.key===s);a?dc(a.type,e)(o,n):e.allowUnknownKey||n.err.report(y("unknown-key",P(s)),i,2)}}}function fL(t,e={}){return t?(r,n)=>{}:tt.noop}function uL(t,e){return(r,n)=>{}}function dc(t,e){let r=(i,{kind:o,min:s=-1/0,max:a=1/0})=>{let l=(c,f,u)=>u?c{if(t.kind!=="any"&&t.kind!=="dispatcher"&&t.kind!=="enum"&&t.kind!=="literal"&&t.kind!=="reference"&&t.kind!=="union"&&t.kind!=="attributed"&&t.kind!=="unsafe"&&t.kind!=="concrete"&&t.kind!=="indexed"&&t.kind!=="template"&&i.type!==n[t.kind]){o.err.report(y("expected",hr(n[t.kind])),i,2);return}switch(t.kind){case"boolean":i=i,i.value!==0&&i.value!==1&&o.err.report(y("nbt.checker.boolean.out-of-range",P("0b"),P("1b")),i,2);break;case"byte_array":case"int_array":case"long_array":if(i=i,t.lengthRange&&!r(i.children.length,t.lengthRange)&&o.err.report(y("expected",y("nbt.checker.collection.length-between",hr(i.type),t.lengthRange.min??"-\u221E",t.lengthRange.max??"+\u221E")),i,2),t.valueRange)for(let{value:l}of i.children)l&&!r(Number(l.value),t.valueRange)&&o.err.report(y("number.between",t.valueRange.min??"-\u221E",t.valueRange.max??"+\u221E"),i,2);break;case"byte":case"short":case"int":case"long":case"float":case"double":i=i,t.valueRange&&!r(Number(i.value),t.valueRange)&&o.err.report(y("number.between",t.valueRange.min??"-\u221E",t.valueRange.max??"+\u221E"),i,2);break;case"dispatcher":i=i;break;case"list":i=i,t=cc(t),t.lengthRange&&!r(i.children.length,t.lengthRange)&&o.err.report(y("expected",y("nbt.checker.collection.length-between",hr(i.type),t.lengthRange.min??"-\u221E",t.lengthRange.max??"+\u221E")),i,2);for(let{value:l}of i.children)l&&dc(t.item,e)(l,o);break;case"string":i=i;let s="",a=i;if(uu.is(i.parent)&&hc.is(i.parent.parent)&&(s="[]",a=i.parent.parent),kn.is(a.parent)){let l=a.parent.key?.symbol?.parentSymbol?.path.join("::"),c=a.parent.key?.value,f=`${l}.${c}${s}`,u=YS(f);if(u)try{let h=o.meta.getParser(u),d=uo(h,i.value,i.valueMap,o);d!==V&&(i.children=[d],d.parent=i)}catch(h){o.logger.error("[nbt.checker.fieldValue#string]",h)}}break;case"reference":i=i;break;case"union":t=Gs(t),t.members.length===0?o.err.report(y("nbt.checker.compound.field.union-empty-members"),kn.is(i.parent)?i.parent.key??i.parent:i,2):tt.any(t.members.map(l=>dc(l,e)))(i,o);break;case"attributed":dc(t.child,e)(i,o);break}}}var t_=({meta:t})=>{t.registerLanguage("nbt",{extensions:[".snbt"],parser:xi}),t.registerParser("nbt:entry",xi),t.registerParser("nbt:compound",wi),t.registerParser("nbt:path",ty),VS(t)};var Vt;(function(t){function e(r,n){return Math.sign(Number(r.slice(2))-Number(n.slice(2)))}t.cmp=e})(Vt||(Vt={}));var ky={5:/^1\.15.*$/,6:/^1\.16.*$/,7:/^1\.17.*$/,8:/^1\.18(\.1)?$/,9:/^1\.18.*$/,10:/^1\.19.*$/},kh;(function(t){function e(r){let n=r?.pack?.pack_format?.toString();if(!n)throw new Error("\u201Cpack.pack_format\u201D undefined");if(!Object.keys(ky).includes(n))throw new Error(`Unknown pack_format \u201C${n}\u201D`)}t.assert=e})(kh||(kh={}));function r_(t,{packMcmeta:e,versions:r}){function n(i){i<0&&(i=0);let o=r[i];return{id:o.id,name:o.name,release:o.release_target??"1.99",isLatest:i===0}}if(r.length===0)throw new Error("mcmeta version list is empty");if(t=t.toLowerCase(),r=r.sort((i,o)=>o.data_version-i.data_version),t==="auto"){if(e){let i=ky[e.pack.pack_format];if(i)return n(r.findIndex(o=>i.test(o.release_target)))}return n(0)}else{if(t==="latest release")return n(r.findIndex(i=>i.type==="release"));if(t==="latest snapshot")return n(r.findIndex(i=>i.type==="snapshot"))}return n(r.findIndex(i=>t===i.id.toLowerCase()||t===i.name.toLowerCase()))}var hL={fastly:"https://fastly.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}",github:"https://raw.githubusercontent.com/${user}/${repo}/${tag}/${path}",jsdelivr:"https://cdn.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}"};function n_(t,e,r){let n=e?"summary":`${t}-summary`;function i(o){let a=(hL[r.toLowerCase()]??r).replace(/\${user}/g,"misode").replace(/\${repo}/g,"mcmeta").replace(/\${tag}/g,n).replace(/\${path}/g,o);if(!Tw.is(a))throw new Error(`Expected a remote URI from data source template but got ${a}`);return a}return{blocks:i("blocks/data.json.gz"),commands:i("commands/data.json.gz"),registries:i("registries/data.json.gz")}}function i_(t){let e="mcmeta://summary/registries.json";function r(i,o,s){let a=`${i[0].toUpperCase()}${i.slice(1)}`;for(let[l,[c,f]]of Object.entries(o)){let u=e;s.query(u,i,q.lengthen(l)).onEach(Object.entries(c),([h,d],p)=>{let b=f[h];p.member(`${u}#${a}_states`,h,m=>{m.enter({data:{subcategory:"state"},usage:{type:"declaration"}}).onEach(d,k=>{m.member(k,S=>{S.enter({data:{subcategory:"state_value"},usage:{type:"declaration"}}),k===b&&m.amend({data:{relations:{default:{category:i,path:S.path}}}})})})})})}}function n(i,o){function s(a){return hs.includes(a)||Gi.includes(a)}for(let[a,l]of Object.entries(i))if(s(a))for(let c of l)o.query(e,a,q.lengthen(c)).enter({usage:{type:"declaration"}})}return i=>{n(t.registries,i),r("block",t.blocks,i),r("fluid",t.fluids,i)}}var o_={flowing_lava:[{falling:["false","true"],level:["1","2","3","4","5","6","7","8"]},{falling:"false",level:"1"}],flowing_water:[{falling:["false","true"],level:["1","2","3","4","5","6","7","8"]},{falling:"false",level:"1"}],lava:[{falling:["false","true"]},{falling:"false"}],water:[{falling:["false","true"]},{falling:"false"}]};var vh=15e3;async function s_(t,e){return e.download({id:"mc-je/versions.json.gz",uri:"https://raw.githubusercontent.com/misode/mcmeta/summary/versions/data.json.gz",transformer:r=>pm(t,r),cache:vy("misode","mcmeta","refs/heads/summary"),ttl:vh})}async function a_(t,e,r,n,i,o,s={}){let a=dL({defaultBranch:"summary",getTag:m=>`${m}-summary`,isLatest:i,version:n}),l=n_(n,i,o),c;async function f(m,k){if(k)try{let S=await Y.readJson(t,k.path);return k.replace?S:Ka(m,S)}catch(S){r.error(`[je] [mcmeta-overrides] Failed loading customized mcmeta summary file \u201C${k.path}\u201D`,S)}return m}let u=async(m,k)=>{let S={},_=await e.download({id:`mc-je/${n}/${m}.json.gz`,uri:l[m],transformer:w=>pm(t,w),cache:vy("misode","mcmeta",a),ttl:vh},S);return c||=S.checksum,f(_,k)},[h,d,p,b]=[await u("blocks",s.blocks),await u("commands",s.commands),await f(o_,s.fluids),await u("registries",s.registries)];return{blocks:h,commands:d,fluids:p,registries:b,checksum:c}}function dL({defaultBranch:t,getTag:e,isLatest:r,version:n}){return r?`refs/heads/${t}`:`refs/tags/${e(n)}`}var l_={headers:{Accept:"application/vnd.github.v3+json","User-Agent":"SpyglassMC"}};function vy(t,e,r){return{checksumExtension:".commit-sha",checksumJob:{uri:`https://api.github.com/repos/${t}/${e}/git/${r}`,transformer:n=>{let i=JSON.parse(ir(n));if(Array.isArray(i))return i[0].object.sha;if(i.message===void 0)return i.object.sha;throw new Error(i.message)},options:l_,ttl:vh}}}async function c_(t){let e="SpyglassMC",r="vanilla-mcdoc",n="refs/heads/main",i={};return await t.download({id:"mc-je/vanilla-mcdoc.tar.gz",uri:`https://api.github.com/repos/${e}/${r}/tarball/${n}`,transformer:o=>o,cache:vy(e,r,n),options:l_,ttl:vh},i),{info:{startDepth:1},uri:i.cacheUri}}var mL=(()=>{let t=new Set(["block","fluid","function","game_event","item","worldgen/block_placer_type","worldgen/surface_builder"]),e=new Map([["advancements",{category:"advancement",extname:".json"}],["dimension",{category:"dimension",extname:".json",since:"1.16"}],["dimension_type",{category:"dimension_type",extname:".json",since:"1.16"}],["functions",{category:"function",extname:".mcfunction"}],["item_modifiers",{category:"item_modifier",extname:".json",since:"1.17"}],["loot_tables",{category:"loot_table",extname:".json"}],["predicates",{category:"predicate",extname:".json"}],["recipes",{category:"recipe",extname:".json"}],["tags/blocks",{category:"tag/block",extname:".json"}],["tags/entity_types",{category:"tag/entity_type",extname:".json"}],["tags/fluids",{category:"tag/fluid",extname:".json"}],["tags/functions",{category:"tag/function",extname:".json"}],["tags/game_events",{category:"tag/game_event",extname:".json",since:"1.17"}],["tags/items",{category:"tag/item",extname:".json"}],["worldgen/biome",{category:"worldgen/biome",extname:".json",since:"1.16"}],["worldgen/configured_carver",{category:"worldgen/configured_carver",extname:".json",since:"1.16"}],["worldgen/configured_feature",{category:"worldgen/configured_feature",extname:".json",since:"1.16"}],["worldgen/configured_structure_feature",{category:"worldgen/configured_structure_feature",extname:".json",since:"1.16"}],["worldgen/configured_surface_builder",{category:"worldgen/configured_surface_builder",extname:".json",since:"1.16",until:"1.17"}],["worldgen/density_function",{category:"worldgen/density_function",extname:".json",since:"1.18"}],["worldgen/noise",{category:"worldgen/noise",extname:".json",since:"1.18"}],["worldgen/noise_settings",{category:"worldgen/noise_settings",extname:".json",since:"1.16"}],["worldgen/placed_feature",{category:"worldgen/placed_feature",extname:".json",since:"1.18"}],["worldgen/processor_list",{category:"worldgen/processor_list",extname:".json",since:"1.16"}],["worldgen/template_pool",{category:"worldgen/template_pool",extname:".json",since:"1.16"}]]);for(let r of Am)t.has(r)||e.set(`tags/${r}`,{category:`tag/${r}`,extname:".json",since:"1.18"});return e})();function*gL(t,e){yield*Y.getRels(t,e);let r=t.split("/");for(let n=r.length-2;n>=0;n--)r[n]==="data"&&(yield r.slice(n).join("/"))}function wy(t,e){let r=/^data\/([^\/]+)\/((?:tags\/|worldgen\/)?[a-z_]+)\/(.*)(\.(?:mcfunction|json))$/,n=gL(t,e.roots);for(let i of n){let o=i.match(r);if(!o)continue;let s=mL.get(o[2]);if(!s||s.extname!==o[4])continue;let a=e.project.loadedVersion;if(!(!a||!yL(a,s.since,s.until)))return{category:s.category,namespace:o[1],identifier:o[3]}}}var f_=(t,e)=>{for(let r of t){let n=wy(r,e);n&&e.symbols.query(r,n.category,`${n.namespace}:${n.identifier}`).enter({usage:{type:"definition"}})}};function yL(t,e,r){return!(e&&Vt.cmp(t,e)<0||r&&Vt.cmp(r,t)<0)}var bL=t=>[Ce.create(t,"literal")],kL=t=>[Ce.create(t,"literal")],vL=(t,e)=>{let r=[];for(let n of t.children)if(n.key&&r.push(Ce.create(n.key,"property")),n.value){let i=e.meta.getColorizer(n.value.type);r.push(...i(n.value,e))}return r};function u_(t){t.registerColorizer("json:boolean",bL),t.registerColorizer("json:null",kL),t.registerColorizer("json:number",Ie.number),t.registerColorizer("json:object",vL),t.registerColorizer("json:string",Ie.string)}var mc={};yr(mc,{JsonStringOptions:()=>wh,array:()=>_y,entry:()=>Si,json:()=>m_,number:()=>xy,object:()=>Sy,string:()=>pc});var d_=(t,e)=>{let r=t.cursor;return t.trySkip("false")?{type:"json:boolean",range:v.create(r,t),value:!1}:t.trySkip("true")?{type:"json:boolean",range:v.create(r,t),value:!0}:V};var p_=(t,e)=>{let r=t.cursor;return t.trySkip("null")?{type:"json:null",range:v.create(r,t)}:V};var xy=(t,e)=>{let n=en({pattern:/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?$/})(t,e);return n.type="json:number",n};var wh={escapable:{characters:["b","f","n","r","t"],unicode:!0},quotes:['"']},pc=(t,e)=>{let n=dt(wh)(t,e);return n.type="json:string",n};var Sy=(t,e)=>se("json:object",Tr({start:"{",pair:{key:pc,sep:":",value:Si,end:",",trailingEnd:!1},end:"}"}))(t,e);var wL=new Set(["0","1","2","3","4","5","6","7","8","9","-"]);function m_(t=!1){return(e,r)=>{let n=ne([{predicate:i=>i.tryPeek("["),parser:_y},{predicate:i=>i.tryPeek("false")||i.tryPeek("true"),parser:d_},{predicate:i=>i.tryPeek("null"),parser:p_},{predicate:i=>wL.has(i.peek()),parser:xy},{predicate:i=>i.tryPeek("{"),parser:Sy},{parser:pc}])(e,r);return t&&r.err.dump(),n}}var Si=m_(!0);var _y=(t,e)=>{let n=fi({start:"[",value:Si,sep:",",trailingSep:!1,end:"]"})(t,e);return n.type="json:array",n};var xh;(function(t){function e(n){return Pr.is(n)||Oo.is(n)||dr.is(n)||Xs.is(n)||gc.is(n)||Ty.is(n)}t.is=e;function r(n){return t.is(n)||Cy.is(n)||Ay.is(n)}t.isRelated=r})(xh||(xh={}));var To;(function(t){function e(i){return i.type==="json:array"}t.isArray=e;function r(i){return i.type==="json:object"}t.isObject=r;function n(i){return i.type==="json:string"}t.isString=n})(To||(To={}));var Pr;(function(t){function e(n){return n?.type==="json:object"}t.is=e;function r(n){return{type:"json:object",range:v.get(n),children:[]}}t.mock=r})(Pr||(Pr={}));var Cy;(function(t){function e(r){return r.type==="pair"}t.is=e})(Cy||(Cy={}));var Oo;(function(t){function e(n){return n?.type==="json:array"}t.is=e;function r(n){return{type:"json:array",range:v.get(n),children:[]}}t.mock=r})(Oo||(Oo={}));var Ay;(function(t){function e(r){return r.type==="item"}t.is=e})(Ay||(Ay={}));var Sh;(function(t){function e(r){return r.type==="json:string"}t.is=e})(Sh||(Sh={}));var dr;(function(t){function e(n){return n?.type==="json:string"}t.is=e;function r(n){return{...et.mock(n,wh),type:"json:string"}}t.mock=r})(dr||(dr={}));var Xs;(function(t){function e(r){return r.type==="json:number"}t.is=e})(Xs||(Xs={}));var gc;(function(t){function e(r){return r.type==="json:boolean"}t.is=e})(gc||(gc={}));var Ty;(function(t){function e(r){return r.type==="json:null"}t.is=e})(Ty||(Ty={}));var g_=[` -`,":",'"'],Oy={"json:object":"{$1}","json:array":"[$1]","json:string":'"$1"',"json:boolean":"${1|false,true|}","json:number":"${1:0}"},xL=(t,e)=>re.dispatch(t,e),SL=re.record({key:(t,e,r,n,i,o)=>t.expectation?bc(t.expectation.filter(To.isObject).flatMap(s=>TL(n,t,s,r,i,o,e?.key?.value))):[],value:(t,e,r)=>e.value&&!v.isEmpty(e.value)?re.dispatch(e.value,r):t.expectation?bc(t.expectation.filter(To.isObject).filter(n=>n.fields).map(n=>n.fields.find(i=>i.key===e.key?.value)).flatMap(n=>y_(r.offset,n.value,r))):[]}),_L=(t,e)=>{let r=Nw(t.children,e.offset,(i,o)=>i.sep?v.compareOffset(v.translate(i,0,-1),o,!0):v.compareOffset(i.range,o,!0)),n=r>=0?t.children[r]:void 0;return n?.value?re.dispatch(n.value,e):t.expectation&&v.contains(v.translate(t,1,-1),e.offset,!0)?bc(t.expectation.filter(To.isArray).filter(i=>i.items).flatMap(i=>y_(e.offset,i.items,e))):[]},CL=t=>["false","true"].map(e=>yc(t,e)),AL=(t,e)=>t.children?.length?re.string(t,e):t.expectation?bc(t.expectation.filter(To.isString).flatMap(r=>Ry(t,r,e))):[];function TL(t,e,r,n,i,o,s){return r.fields?r.fields.filter(a=>a.key===s||!e.children.find(l=>a.key===l.key?.value)).map(a=>OL(t,a,i,o)):r.keys?r.keys.flatMap(a=>Ry(t,a,n).map(l=>({...l,...i?{insertText:`${l.insertText}: ${o?",":""}`}:{}}))):[]}function OL(t,e,r,n){let i=e.value?.[0]?Oy[e.value[0].type]:"";return pe.create(e.key,t,{kind:10,detail:e.value?.map(o=>o.typedoc).join(" | "),sortText:`${e.deprecated?2:e.opt?1:0}${e.key}`,deprecated:e.deprecated,filterText:`"${e.key}"`,insertText:`"${e.key}"${r?`: ${i}`:""}${n?",":""}`})}function y_(t,e,r){return bc(e.flatMap(n=>{switch(n.type){case"json:object":case"json:array":return[yc(t,Oy[n.type])];case"json:string":return Ry(r.offset,n,r);case"json:boolean":return["false","true"].map(i=>yc(t,i));case"json:number":return[yc(t,"0")]}}))}function Ry(t,e,r){return Array.isArray(e.pool)?e.pool.map(n=>pe.create(n,t,{kind:12,filterText:`"${n}"`,insertText:`"${n}"`})):[yc(t,Oy[e.type])]}function yc(t,e){return pe.create(e.replace("$1",""),t,{kind:12,insertText:e})}function bc(t){let e=[],r=new Set;return t.forEach(n=>{r.has(n.label)||(r.add(n.label),e.push(n))}),e}function b_(t){t.registerCompleter("json:entry",xL),t.registerCompleter("json:array",_L),t.registerCompleter("json:boolean",CL),t.registerCompleter("json:object",SL),t.registerCompleter("json:string",AL)}var RL=(t,e)=>t.children.length===0?"[]":`[ -${t.children.map(n=>{let i=n.value&&e.meta.getFormatter(n.value.type)(n.value,Bm(e));return`${e.indent(1)}${i??""}`}).join(`, +`))):(_(),f=S);let C;n.skipWhitespace(),s=!0,(a=n.peek(e.end.length)===e.end)&&(C=v.create(n,()=>n.skip(e.end.length))),o.children.push({type:"pair",range:v.create(l,n),...c||f?{children:[c,f].filter(R=>!!R)}:{},key:c,sep:b,value:f,end:C}),n.skipWhitespace()}a&&!e.trailingEnd&&i.err.report(y("parser.record.trailing-end"),o.children[o.children.length-1].end),n.trySkip(r)||i.err.report(y("expected",P(r)),n)}else i.err.report(y("expected",P(t)),n);return o.range.end=n.cursor,o}}var wE=new Set([" ","\r",` +`,"=",",",'"',"'","{","}","[","]","(",")",";"]),Dx=new Set(["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","_","-","."]);function Ee(t){return(e,r)=>{let n={type:"resource_location",range:v.create(e),options:t};e.trySkip(q.TagPrefix)&&(n.isTag=!0);let i=e.cursor;for(;e.canReadInLine()&&!wE.has(e.peek());)e.skip();let o=e.sliceToCursor(i);if(n.range.end=e.cursor,o.length===0)r.err.report(y("expected",y("resource-location")),n);else{let s=o.indexOf(t.namespacePathSep??q.NamespacePathSep);s>=0&&(n.namespace=o.slice(0,s));let a=o.slice(s+1);n.path=a.split(q.PathSep);let l=[...new Set([...[...n.namespace??[]].filter(c=>!Dx.has(c)),...[...a].filter(c=>c!=="/"&&!Dx.has(c))])];l.length&&r.err.report(y("parser.resource-location.illegal",vn(l,!0,"and")),n),n.isTag&&!t.allowTag&&r.err.report(y("parser.resource-location.tag-diallowed"),n),!n.namespace&&t.isPredicate&&r.err.report(y("parser.resource-location.namespace-expected"),n)}return n}}var Nx=Br(mu(),1);function pt(t){return(e,r)=>{let n={type:"string",range:v.create(e),options:t,value:"",valueMap:[]},i=e.cursor;if(t.quotes?.length&&(e.peek()==='"'||e.peek()==="'")){let o=e.read(),s=e.cursor;for(;e.canRead()&&e.peek()!==o;){let a=e.peek();if(t.escapable&&a==="\\"){let l=e.cursor;e.skip();let c=e.read();if(c==="\\"||c===o||hu.is(t.escapable.characters,c))n.valueMap.push({inner:v.create(n.value.length,n.value.length+1),outer:v.create(l,e)}),n.value+=Hw.get(c);else if(t.escapable.unicode&&c==="u"){let f=e.peek(4);/^[0-9a-f]{4}$/i.test(f)?(e.skip(4),n.valueMap.push({inner:v.create(n.value.length,n.value.length+1),outer:v.create(l,e)}),n.value+=String.fromCharCode(parseInt(f,16))):(r.err.report(y("parser.string.illegal-unicode-escape"),v.create(e,e.getCharRange(3).end)),n.valueMap.push({inner:v.create(n.value.length,n.value.length+1),outer:v.create(l,e)}),n.value+=c)}else t.escapable.allowUnknown||r.err.report(y("parser.string.illegal-escape",P(c)),e.getCharRange(-1)),n.valueMap.push({inner:v.create(n.value.length,n.value.length+1),outer:v.create(l,e)}),n.value+=c}else e.skip(),n.value+=a}e.trySkip(o)||r.err.report(y("expected",P(o)),e),t.quotes.includes(o)||r.err.report(y("parser.string.illegal-quote",t.quotes),n),i=s}else if(t.unquotable){for(;e.canRead()&&Fm(e.peek(),t.unquotable);)n.value+=e.read();!n.value&&!t.unquotable.allowEmpty&&r.err.report(y("expected",y("string")),e)}else r.err.report(y("expected",t.quotes),e);if(n.valueMap.unshift({inner:v.create(0),outer:v.create(i)}),t.value?.parser){let o=uo(t.value.parser,n.value,n.valueMap,r);o!==V&&(n.children=[o])}return n.range.end=e.cursor,n}}function uo(t,e,r,n){let i=new Ce(e,r),o={...n,doc:Nx.TextDocument.create(n.doc.uri,n.doc.languageId,n.doc.version,e)};return t(i,o)}var xE=Object.freeze(["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","_",".","+","-"]),SE=new Set(xE),Px=/^[0-9A-Za-z_\.\+\-]*$/,Ml={allowEmpty:!0,allowList:SE},ui={escapable:{},quotes:['"',"'"],unquotable:Ml},ho=pt(ui);function Fm(t,e){return e.allowList?.has(t)??!e.blockList?.has(t)}function Bs(t){let e=_E(t);return(r,n)=>{let i={type:"symbol",range:v.create(r),options:e,value:r.readRemaining()};return i.range.end=r.cursor,i}}function _E(t){return typeof t=="string"?{category:t}:t}var ih=Br(Ix(),1);function Fs(t){let e=t.length;for(;--e>=0;)t[e]=0}var CE=0,w1=1,AE=2,TE=3,OE=258,mg=29,ql=256,jl=ql+1+mg,zs=30,gg=19,x1=2*jl+1,po=15,Ym=16,RE=7,yg=256,S1=16,_1=17,C1=18,ug=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),qu=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),EE=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),A1=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ME=512,Rn=new Array((jl+2)*2);Fs(Rn);var Ll=new Array(zs*2);Fs(Ll);var $l=new Array(ME);Fs($l);var zl=new Array(OE-TE+1);Fs(zl);var bg=new Array(mg);Fs(bg);var Ju=new Array(zs);Fs(Ju);function Xm(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}var T1,O1,R1;function Qm(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}var E1=t=>t<256?$l[t]:$l[256+(t>>>7)],Fl=(t,e)=>{t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255},Ot=(t,e,r)=>{t.bi_valid>Ym-r?(t.bi_buf|=e<>Ym-t.bi_valid,t.bi_valid+=r-Ym):(t.bi_buf|=e<{Ot(t,r[e*2],r[e*2+1])},M1=(t,e)=>{let r=0;do r|=t&1,t>>>=1,r<<=1;while(--e>0);return r>>>1},DE=t=>{t.bi_valid===16?(Fl(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)},NE=(t,e)=>{let r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length,c,f,u,h,d,p,b=0;for(h=0;h<=po;h++)t.bl_count[h]=0;for(r[t.heap[t.heap_max]*2+1]=0,c=t.heap_max+1;cl&&(h=l,b++),r[f*2+1]=h,!(f>n)&&(t.bl_count[h]++,d=0,f>=a&&(d=s[f-a]),p=r[f*2],t.opt_len+=p*(h+d),o&&(t.static_len+=p*(i[f*2+1]+d)));if(b!==0){do{for(h=l-1;t.bl_count[h]===0;)h--;t.bl_count[h]--,t.bl_count[h+1]+=2,t.bl_count[l]--,b-=2}while(b>0);for(h=l;h!==0;h--)for(f=t.bl_count[h];f!==0;)u=t.heap[--c],!(u>n)&&(r[u*2+1]!==h&&(t.opt_len+=(h-r[u*2+1])*r[u*2],r[u*2+1]=h),f--)}},D1=(t,e,r)=>{let n=new Array(po+1),i=0,o,s;for(o=1;o<=po;o++)n[o]=i=i+r[o-1]<<1;for(s=0;s<=e;s++){let a=t[s*2+1];a!==0&&(t[s*2]=M1(n[a]++,a))}},PE=()=>{let t,e,r,n,i,o=new Array(po+1);for(r=0,n=0;n>=7;n{let e;for(e=0;e{t.bi_valid>8?Fl(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},LE=(t,e,r,n)=>{P1(t),n&&(Fl(t,r),Fl(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r},Bx=(t,e,r,n)=>{let i=e*2,o=r*2;return t[i]{let n=t.heap[r],i=r<<1;for(;i<=t.heap_len&&(i{let n,i,o=0,s,a;if(t.last_lit!==0)do n=t.pending_buf[t.d_buf+o*2]<<8|t.pending_buf[t.d_buf+o*2+1],i=t.pending_buf[t.l_buf+o],o++,n===0?rn(t,i,e):(s=zl[i],rn(t,s+ql+1,e),a=ug[s],a!==0&&(i-=bg[s],Ot(t,i,a)),n--,s=E1(n),rn(t,s,r),a=qu[s],a!==0&&(n-=Ju[s],Ot(t,n,a)));while(o{let r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.elems,s,a,l=-1,c;for(t.heap_len=0,t.heap_max=x1,s=0;s>1;s>=1;s--)eg(t,r,s);c=o;do s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],eg(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,r[c*2]=r[s*2]+r[a*2],t.depth[c]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,r[s*2+1]=r[a*2+1]=c,t.heap[1]=c++,eg(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],NE(t,e),D1(r,l,t.bl_count)},$x=(t,e,r)=>{let n,i=-1,o,s=e[0*2+1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),e[(r+1)*2+1]=65535,n=0;n<=r;n++)o=s,s=e[(n+1)*2+1],!(++a{let n,i=-1,o,s=e[0*2+1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),n=0;n<=r;n++)if(o=s,s=e[(n+1)*2+1],!(++a{let e;for($x(t,t.dyn_ltree,t.l_desc.max_code),$x(t,t.dyn_dtree,t.d_desc.max_code),hg(t,t.bl_desc),e=gg-1;e>=3&&t.bl_tree[A1[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e},BE=(t,e,r,n)=>{let i;for(Ot(t,e-257,5),Ot(t,r-1,5),Ot(t,n-4,4),i=0;i{let e=4093624447,r;for(r=0;r<=31;r++,e>>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return 0;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return 1;for(r=32;r{Fx||(PE(),Fx=!0),t.l_desc=new Qm(t.dyn_ltree,T1),t.d_desc=new Qm(t.dyn_dtree,O1),t.bl_desc=new Qm(t.bl_tree,R1),t.bi_buf=0,t.bi_valid=0,N1(t)},L1=(t,e,r,n)=>{Ot(t,(CE<<1)+(n?1:0),3),LE(t,e,r,!0)},zE=t=>{Ot(t,w1<<1,3),rn(t,yg,Rn),DE(t)},FE=(t,e,r,n)=>{let i,o,s=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=jE(t)),hg(t,t.l_desc),hg(t,t.d_desc),s=IE(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&e!==-1?L1(t,e,r,n):t.strategy===4||o===i?(Ot(t,(w1<<1)+(n?1:0),3),jx(t,Rn,Ll)):(Ot(t,(AE<<1)+(n?1:0),3),BE(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),jx(t,t.dyn_ltree,t.dyn_dtree)),N1(t),n&&P1(t)},VE=(t,e,r)=>(t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=r&255,t.last_lit++,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(zl[r]+ql+1)*2]++,t.dyn_dtree[E1(e)*2]++),t.last_lit===t.lit_bufsize-1),UE=$E,HE=L1,WE=FE,qE=VE,KE=zE,GE={_tr_init:UE,_tr_stored_block:HE,_tr_flush_block:WE,_tr_tally:qE,_tr_align:KE},ZE=(t,e,r,n)=>{let i=t&65535|0,o=t>>>16&65535|0,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do i=i+e[n++]|0,o=o+i|0;while(--s);i%=65521,o%=65521}return i|o<<16|0},Vl=ZE,JE=()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t}return e},YE=new Uint32Array(JE()),XE=(t,e,r,n)=>{let i=YE,o=n+r;t^=-1;for(let s=n;s>>8^i[(t^e[s])&255];return t^-1},Ge=XE,go={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},vo={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:QE,_tr_stored_block:eM,_tr_flush_block:tM,_tr_tally:gi,_tr_align:rM}=GE,{Z_NO_FLUSH:wo,Z_PARTIAL_FLUSH:nM,Z_FULL_FLUSH:iM,Z_FINISH:yi,Z_BLOCK:Vx,Z_OK:nn,Z_STREAM_END:Ux,Z_STREAM_ERROR:lr,Z_DATA_ERROR:oM,Z_BUF_ERROR:tg,Z_DEFAULT_COMPRESSION:sM,Z_FILTERED:aM,Z_HUFFMAN_ONLY:Fu,Z_RLE:lM,Z_FIXED:cM,Z_DEFAULT_STRATEGY:fM,Z_UNKNOWN:uM,Z_DEFLATED:Qu}=vo,hM=9,dM=15,pM=8,mM=29,gM=256,dg=gM+1+mM,yM=30,bM=19,kM=2*dg+1,vM=15,X=3,pi=258,Or=pi+X+1,wM=32,eh=42,pg=69,Ku=73,Gu=91,Zu=103,mo=113,Nl=666,He=1,Kl=2,yo=3,Vs=4,xM=3,mi=(t,e)=>(t.msg=go[e],e),Hx=t=>(t<<1)-(t>4?9:0),di=t=>{let e=t.length;for(;--e>=0;)t[e]=0},SM=(t,e,r)=>(e<{let e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0))},rt=(t,e)=>{tM(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,hi(t.strm)},ie=(t,e)=>{t.pending_buf[t.pending++]=e},Dl=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255},_M=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),i===0?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),t.state.wrap===1?t.adler=Vl(t.adler,e,i,r):t.state.wrap===2&&(t.adler=Ge(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},I1=(t,e)=>{let r=t.max_chain_length,n=t.strstart,i,o,s=t.prev_length,a=t.nice_match,l=t.strstart>t.w_size-Or?t.strstart-(t.w_size-Or):0,c=t.window,f=t.w_mask,u=t.prev,h=t.strstart+pi,d=c[n+s-1],p=c[n+s];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do if(i=e,!(c[i+s]!==p||c[i+s-1]!==d||c[i]!==c[n]||c[++i]!==c[n+1])){n+=2,i++;do;while(c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&c[++n]===c[++i]&&ns){if(t.match_start=e,s=o,o>=a)break;d=c[n+s-1],p=c[n+s]}}while((e=u[e&f])>l&&--r!==0);return s<=t.lookahead?s:t.lookahead},bo=t=>{let e=t.w_size,r,n,i,o,s;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Or)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do i=t.head[--r],t.head[r]=i>=e?i-e:0;while(--n);n=e,r=n;do i=t.prev[--r],t.prev[r]=i>=e?i-e:0;while(--n);o+=e}if(t.strm.avail_in===0)break;if(n=_M(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=n,t.lookahead+t.insert>=X)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=bi(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=bi(t,t.ins_h,t.window[s+X-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert{let r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(bo(t),t.lookahead===0&&e===wo)return He;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;let n=t.block_start+r;if((t.strstart===0||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,rt(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-Or&&(rt(t,!1),t.strm.avail_out===0))return He}return t.insert=0,e===yi?(rt(t,!0),t.strm.avail_out===0?yo:Vs):(t.strstart>t.block_start&&(rt(t,!1),t.strm.avail_out===0),He)},rg=(t,e)=>{let r,n;for(;;){if(t.lookahead=X&&(t.ins_h=bi(t,t.ins_h,t.window[t.strstart+X-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),r!==0&&t.strstart-r<=t.w_size-Or&&(t.match_length=I1(t,r)),t.match_length>=X)if(n=gi(t,t.strstart-t.match_start,t.match_length-X),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=X){t.match_length--;do t.strstart++,t.ins_h=bi(t,t.ins_h,t.window[t.strstart+X-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=bi(t,t.ins_h,t.window[t.strstart+1]);else n=gi(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(rt(t,!1),t.strm.avail_out===0))return He}return t.insert=t.strstart{let r,n,i;for(;;){if(t.lookahead=X&&(t.ins_h=bi(t,t.ins_h,t.window[t.strstart+X-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=X-1,r!==0&&t.prev_length4096)&&(t.match_length=X-1)),t.prev_length>=X&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-X,n=gi(t,t.strstart-1-t.prev_match,t.prev_length-X),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=i&&(t.ins_h=bi(t,t.ins_h,t.window[t.strstart+X-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=X-1,t.strstart++,n&&(rt(t,!1),t.strm.avail_out===0))return He}else if(t.match_available){if(n=gi(t,0,t.window[t.strstart-1]),n&&rt(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return He}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=gi(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart{let r,n,i,o,s=t.window;for(;;){if(t.lookahead<=pi){if(bo(t),t.lookahead<=pi&&e===wo)return He;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=X&&t.strstart>0&&(i=t.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){o=t.strstart+pi;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=X?(r=gi(t,1,t.match_length-X),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=gi(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(rt(t,!1),t.strm.avail_out===0))return He}return t.insert=0,e===yi?(rt(t,!0),t.strm.avail_out===0?yo:Vs):t.last_lit&&(rt(t,!1),t.strm.avail_out===0)?He:Kl},TM=(t,e)=>{let r;for(;;){if(t.lookahead===0&&(bo(t),t.lookahead===0)){if(e===wo)return He;break}if(t.match_length=0,r=gi(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(rt(t,!1),t.strm.avail_out===0))return He}return t.insert=0,e===yi?(rt(t,!0),t.strm.avail_out===0?yo:Vs):t.last_lit&&(rt(t,!1),t.strm.avail_out===0)?He:Kl};function tn(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}var Pl=[new tn(0,0,0,0,CM),new tn(4,4,8,4,rg),new tn(4,5,16,8,rg),new tn(4,6,32,32,rg),new tn(4,4,16,16,js),new tn(8,16,32,32,js),new tn(8,16,128,128,js),new tn(8,32,128,256,js),new tn(32,128,258,1024,js),new tn(32,258,258,4096,js)],OM=t=>{t.window_size=2*t.w_size,di(t.head),t.max_lazy_match=Pl[t.level].max_lazy,t.good_match=Pl[t.level].good_length,t.nice_match=Pl[t.level].nice_length,t.max_chain_length=Pl[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=X-1,t.match_available=0,t.ins_h=0};function RM(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qu,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(kM*2),this.dyn_dtree=new Uint16Array((2*yM+1)*2),this.bl_tree=new Uint16Array((2*bM+1)*2),di(this.dyn_ltree),di(this.dyn_dtree),di(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(vM+1),this.heap=new Uint16Array(2*dg+1),di(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*dg+1),di(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var B1=t=>{if(!t||!t.state)return mi(t,lr);t.total_in=t.total_out=0,t.data_type=uM;let e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?eh:mo,t.adler=e.wrap===2?0:1,e.last_flush=wo,QE(e),nn},j1=t=>{let e=B1(t);return e===nn&&OM(t.state),e},EM=(t,e)=>!t||!t.state||t.state.wrap!==2?lr:(t.state.gzhead=e,nn),$1=(t,e,r,n,i,o)=>{if(!t)return lr;let s=1;if(e===sM&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>hM||r!==Qu||n<8||n>15||e<0||e>9||o<0||o>cM)return mi(t,lr);n===8&&(n=9);let a=new RM;return t.state=a,a.strm=t,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<$1(t,e,Qu,dM,pM,fM),DM=(t,e)=>{let r,n;if(!t||!t.state||e>Vx||e<0)return t?mi(t,lr):lr;let i=t.state;if(!t.output||!t.input&&t.avail_in!==0||i.status===Nl&&e!==yi)return mi(t,t.avail_out===0?tg:lr);i.strm=t;let o=i.last_flush;if(i.last_flush=e,i.status===eh)if(i.wrap===2)t.adler=0,ie(i,31),ie(i,139),ie(i,8),i.gzhead?(ie(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),ie(i,i.gzhead.time&255),ie(i,i.gzhead.time>>8&255),ie(i,i.gzhead.time>>16&255),ie(i,i.gzhead.time>>24&255),ie(i,i.level===9?2:i.strategy>=Fu||i.level<2?4:0),ie(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(ie(i,i.gzhead.extra.length&255),ie(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=Ge(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=pg):(ie(i,0),ie(i,0),ie(i,0),ie(i,0),ie(i,0),ie(i,i.level===9?2:i.strategy>=Fu||i.level<2?4:0),ie(i,xM),i.status=mo);else{let s=Qu+(i.w_bits-8<<4)<<8,a=-1;i.strategy>=Fu||i.level<2?a=0:i.level<6?a=1:i.level===6?a=2:a=3,s|=a<<6,i.strstart!==0&&(s|=wM),s+=31-s%31,i.status=mo,Dl(i,s),i.strstart!==0&&(Dl(i,t.adler>>>16),Dl(i,t.adler&65535)),t.adler=1}if(i.status===pg)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),hi(t),r=i.pending,i.pending===i.pending_buf_size));)ie(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Ku)}else i.status=Ku;if(i.status===Ku)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),hi(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}i.gzindexr&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),n===0&&(i.gzindex=0,i.status=Gu)}else i.status=Gu;if(i.status===Gu)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),hi(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}i.gzindexr&&(t.adler=Ge(t.adler,i.pending_buf,i.pending-r,r)),n===0&&(i.status=Zu)}else i.status=Zu;if(i.status===Zu&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&hi(t),i.pending+2<=i.pending_buf_size&&(ie(i,t.adler&255),ie(i,t.adler>>8&255),t.adler=0,i.status=mo)):i.status=mo),i.pending!==0){if(hi(t),t.avail_out===0)return i.last_flush=-1,nn}else if(t.avail_in===0&&Hx(e)<=Hx(o)&&e!==yi)return mi(t,tg);if(i.status===Nl&&t.avail_in!==0)return mi(t,tg);if(t.avail_in!==0||i.lookahead!==0||e!==wo&&i.status!==Nl){let s=i.strategy===Fu?TM(i,e):i.strategy===lM?AM(i,e):Pl[i.level].func(i,e);if((s===yo||s===Vs)&&(i.status=Nl),s===He||s===yo)return t.avail_out===0&&(i.last_flush=-1),nn;if(s===Kl&&(e===nM?rM(i):e!==Vx&&(eM(i,0,0,!1),e===iM&&(di(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),hi(t),t.avail_out===0))return i.last_flush=-1,nn}return e!==yi?nn:i.wrap<=0?Ux:(i.wrap===2?(ie(i,t.adler&255),ie(i,t.adler>>8&255),ie(i,t.adler>>16&255),ie(i,t.adler>>24&255),ie(i,t.total_in&255),ie(i,t.total_in>>8&255),ie(i,t.total_in>>16&255),ie(i,t.total_in>>24&255)):(Dl(i,t.adler>>>16),Dl(i,t.adler&65535)),hi(t),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?nn:Ux)},NM=t=>{if(!t||!t.state)return lr;let e=t.state.status;return e!==eh&&e!==pg&&e!==Ku&&e!==Gu&&e!==Zu&&e!==mo&&e!==Nl?mi(t,lr):(t.state=null,e===mo?mi(t,oM):nn)},PM=(t,e)=>{let r=e.length;if(!t||!t.state)return lr;let n=t.state,i=n.wrap;if(i===2||i===1&&n.status!==eh||n.lookahead)return lr;if(i===1&&(t.adler=Vl(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){i===0&&(di(n.head),n.strstart=0,n.block_start=0,n.insert=0);let l=new Uint8Array(n.w_size);l.set(e.subarray(r-n.w_size,r),0),e=l,r=n.w_size}let o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,bo(n);n.lookahead>=X;){let l=n.strstart,c=n.lookahead-(X-1);do n.ins_h=bi(n,n.ins_h,n.window[l+X-1]),n.prev[l&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=l,l++;while(--c);n.strstart=l,n.lookahead=X-1,bo(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=X-1,n.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,n.wrap=i,nn},LM=MM,IM=$1,BM=j1,jM=B1,$M=EM,zM=DM,FM=NM,VM=PM,UM="pako deflate (from Nodeca project)",Il={deflateInit:LM,deflateInit2:IM,deflateReset:BM,deflateResetKeep:jM,deflateSetHeader:$M,deflate:zM,deflateEnd:FM,deflateSetDictionary:VM,deflateInfo:UM},HM=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),WM=function(t){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(let n in r)HM(r,n)&&(t[n]=r[n])}}return t},qM=t=>{let e=0;for(let n=0,i=t.length;n=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ul[254]=Ul[254]=1;var KM=t=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let e,r,n,i,o,s=t.length,a=0;for(i=0;i>>6,e[o++]=128|r&63):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|r&63):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|r&63);return e},GM=(t,e)=>{if(e<65534&&t.subarray&&z1)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n{let r=e||t.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,e));let n,i,o=new Array(r*2);for(i=0,n=0;n4){o[i++]=65533,n+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&n1){o[i++]=65533;continue}s<65536?o[i++]=s:(s-=65536,o[i++]=55296|s>>10&1023,o[i++]=56320|s&1023)}return GM(o,i)},JM=(t,e)=>{e=e||t.length,e>t.length&&(e=t.length);let r=e-1;for(;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+Ul[t[r]]>e?r:e},Hl={string2buf:KM,buf2string:ZM,utf8border:JM};function YM(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var F1=YM,V1=Object.prototype.toString,{Z_NO_FLUSH:XM,Z_SYNC_FLUSH:QM,Z_FULL_FLUSH:eD,Z_FINISH:tD,Z_OK:Yu,Z_STREAM_END:rD,Z_DEFAULT_COMPRESSION:nD,Z_DEFAULT_STRATEGY:iD,Z_DEFLATED:oD}=vo;function Gl(t){this.options=th.assign({level:nD,method:oD,chunkSize:16384,windowBits:15,memLevel:8,strategy:iD},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new F1,this.strm.avail_out=0;let r=Il.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Yu)throw new Error(go[r]);if(e.header&&Il.deflateSetHeader(this.strm,e.header),e.dictionary){let n;if(typeof e.dictionary=="string"?n=Hl.string2buf(e.dictionary):V1.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,r=Il.deflateSetDictionary(this.strm,n),r!==Yu)throw new Error(go[r]);this._dict_set=!0}}Gl.prototype.push=function(t,e){let r=this.strm,n=this.options.chunkSize,i,o;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?tD:XM,typeof t=="string"?r.input=Hl.string2buf(t):V1.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===QM||o===eD)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(i=Il.deflate(r,o),i===rD)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Il.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Yu;if(r.avail_out===0){this.onData(r.output);continue}if(o>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0};Gl.prototype.onData=function(t){this.chunks.push(t)};Gl.prototype.onEnd=function(t){t===Yu&&(this.result=th.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function kg(t,e){let r=new Gl(e);if(r.push(t,!0),r.err)throw r.msg||go[r.err];return r.result}function sD(t,e){return e=e||{},e.raw=!0,kg(t,e)}function aD(t,e){return e=e||{},e.gzip=!0,kg(t,e)}var lD=Gl,cD=kg,fD=sD,uD=aD,hD=vo,dD={Deflate:lD,deflate:cD,deflateRaw:fD,gzip:uD,constants:hD},Vu=30,pD=12,mD=function(e,r){let n,i,o,s,a,l,c,f,u,h,d,p,b,m,k,S,_,w,C,R,x,T,O,M,I=e.state;n=e.next_in,O=e.input,i=n+(e.avail_in-5),o=e.next_out,M=e.output,s=o-(r-e.avail_out),a=o+(e.avail_out-257),l=I.dmax,c=I.wsize,f=I.whave,u=I.wnext,h=I.window,d=I.hold,p=I.bits,b=I.lencode,m=I.distcode,k=(1<>>24,d>>>=w,p-=w,w=_>>>16&255,w===0)M[o++]=_&65535;else if(w&16){C=_&65535,w&=15,w&&(p>>=w,p-=w),p<15&&(d+=O[n++]<>>24,d>>>=w,p-=w,w=_>>>16&255,w&16){if(R=_&65535,w&=15,pl){e.msg="invalid distance too far back",I.mode=Vu;break e}if(d>>>=w,p-=w,w=o-s,R>w){if(w=R-w,w>f&&I.sane){e.msg="invalid distance too far back",I.mode=Vu;break e}if(x=0,T=h,u===0){if(x+=c-w,w2;)M[o++]=T[x++],M[o++]=T[x++],M[o++]=T[x++],C-=3;C&&(M[o++]=T[x++],C>1&&(M[o++]=T[x++]))}else{x=o-R;do M[o++]=M[x++],M[o++]=M[x++],M[o++]=M[x++],C-=3;while(C>2);C&&(M[o++]=M[x++],C>1&&(M[o++]=M[x++]))}}else if(w&64){e.msg="invalid distance code",I.mode=Vu;break e}else{_=m[(_&65535)+(d&(1<>3,n-=C,p-=C<<3,d&=(1<{let l=a.bits,c=0,f=0,u=0,h=0,d=0,p=0,b=0,m=0,k=0,S=0,_,w,C,R,x,T=null,O=0,M,I=new Uint16Array($s+1),ae=new Uint16Array($s+1),me=null,st=0,Be,De,at;for(c=0;c<=$s;c++)I[c]=0;for(f=0;f=1&&I[h]===0;h--);if(d>h&&(d=h),h===0)return i[o++]=1<<24|64<<16|0,i[o++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u0&&(t===Kx||h!==1))return-1;for(ae[1]=0,c=1;c<$s;c++)ae[c+1]=ae[c]+I[c];for(f=0;fWx||t===Gx&&k>qx)return 1;for(;;){Be=c-b,s[f]M?(De=me[st+s[f]],at=T[O+s[f]]):(De=32+64,at=0),_=1<>b)+w]=Be<<24|De<<16|at|0;while(w!==0);for(_=1<>=1;if(_!==0?(S&=_-1,S+=_):S=0,f++,--I[c]===0){if(c===h)break;c=e[r+s[f]]}if(c>d&&(S&R)!==C){for(b===0&&(b=d),x+=u,p=c-b,m=1<Wx||t===Gx&&k>qx)return 1;C=S&R,i[C]=d<<24|p<<16|x-o|0}}return S!==0&&(i[x+S]=c-b<<24|64<<16|0),a.bits=d,0},Bl=vD,wD=0,U1=1,H1=2,{Z_FINISH:Zx,Z_BLOCK:xD,Z_TREES:Uu,Z_OK:ko,Z_STREAM_END:SD,Z_NEED_DICT:_D,Z_STREAM_ERROR:cr,Z_DATA_ERROR:W1,Z_MEM_ERROR:q1,Z_BUF_ERROR:CD,Z_DEFLATED:Jx}=vo,K1=1,Yx=2,Xx=3,Qx=4,e1=5,t1=6,r1=7,n1=8,i1=9,o1=10,Xu=11,On=12,ig=13,s1=14,og=15,a1=16,l1=17,c1=18,f1=19,Hu=20,Wu=21,u1=22,h1=23,d1=24,p1=25,m1=26,sg=27,g1=28,y1=29,xe=30,G1=31,AD=32,TD=852,OD=592,RD=15,ED=RD,b1=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function MD(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Z1=t=>{if(!t||!t.state)return cr;let e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=K1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(TD),e.distcode=e.distdyn=new Int32Array(OD),e.sane=1,e.back=-1,ko},J1=t=>{if(!t||!t.state)return cr;let e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Z1(t)},Y1=(t,e)=>{let r;if(!t||!t.state)return cr;let n=t.state;return e<0?(r=0,e=-e):(r=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15)?cr:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,J1(t))},X1=(t,e)=>{if(!t)return cr;let r=new MD;t.state=r,r.window=null;let n=Y1(t,e);return n!==ko&&(t.state=null),n},DD=t=>X1(t,ED),k1=!0,ag,lg,ND=t=>{if(k1){ag=new Int32Array(512),lg=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Bl(U1,t.lens,0,288,ag,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Bl(H1,t.lens,0,32,lg,0,t.work,{bits:5}),k1=!1}t.lencode=ag,t.lenbits=9,t.distcode=lg,t.distbits=5},Q1=(t,e,r,n)=>{let i,o=t.state;return o.window===null&&(o.wsize=1<=o.wsize?(o.window.set(e.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(e.subarray(r-n,r-n+i),o.wnext),n-=i,n?(o.window.set(e.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave{let r,n,i,o,s,a,l,c,f,u,h,d,p,b,m=0,k,S,_,w,C,R,x,T,O=new Uint8Array(4),M,I,ae=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return cr;r=t.state,r.mode===On&&(r.mode=ig),s=t.next_out,i=t.output,l=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,c=r.hold,f=r.bits,u=a,h=l,T=ko;e:for(;;)switch(r.mode){case K1:if(r.wrap===0){r.mode=ig;break}for(;f<16;){if(a===0)break e;a--,c+=n[o++]<>>8&255,r.check=Ge(r.check,O,2,0),c=0,f=0,r.mode=Yx;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((c&255)<<8)+(c>>8))%31){t.msg="incorrect header check",r.mode=xe;break}if((c&15)!==Jx){t.msg="unknown compression method",r.mode=xe;break}if(c>>>=4,f-=4,x=(c&15)+8,r.wbits===0)r.wbits=x;else if(x>r.wbits){t.msg="invalid window size",r.mode=xe;break}r.dmax=1<>8&1),r.flags&512&&(O[0]=c&255,O[1]=c>>>8&255,r.check=Ge(r.check,O,2,0)),c=0,f=0,r.mode=Xx;case Xx:for(;f<32;){if(a===0)break e;a--,c+=n[o++]<>>8&255,O[2]=c>>>16&255,O[3]=c>>>24&255,r.check=Ge(r.check,O,4,0)),c=0,f=0,r.mode=Qx;case Qx:for(;f<16;){if(a===0)break e;a--,c+=n[o++]<>8),r.flags&512&&(O[0]=c&255,O[1]=c>>>8&255,r.check=Ge(r.check,O,2,0)),c=0,f=0,r.mode=e1;case e1:if(r.flags&1024){for(;f<16;){if(a===0)break e;a--,c+=n[o++]<>>8&255,r.check=Ge(r.check,O,2,0)),c=0,f=0}else r.head&&(r.head.extra=null);r.mode=t1;case t1:if(r.flags&1024&&(d=r.length,d>a&&(d=a),d&&(r.head&&(x=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+d),x)),r.flags&512&&(r.check=Ge(r.check,n,d,o)),a-=d,o+=d,r.length-=d),r.length))break e;r.length=0,r.mode=r1;case r1:if(r.flags&2048){if(a===0)break e;d=0;do x=n[o+d++],r.head&&x&&r.length<65536&&(r.head.name+=String.fromCharCode(x));while(x&&d>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=On;break;case o1:for(;f<32;){if(a===0)break e;a--,c+=n[o++]<>>=f&7,f-=f&7,r.mode=sg;break}for(;f<3;){if(a===0)break e;a--,c+=n[o++]<>>=1,f-=1,c&3){case 0:r.mode=s1;break;case 1:if(ND(r),r.mode=Hu,e===Uu){c>>>=2,f-=2;break e}break;case 2:r.mode=l1;break;case 3:t.msg="invalid block type",r.mode=xe}c>>>=2,f-=2;break;case s1:for(c>>>=f&7,f-=f&7;f<32;){if(a===0)break e;a--,c+=n[o++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=xe;break}if(r.length=c&65535,c=0,f=0,r.mode=og,e===Uu)break e;case og:r.mode=a1;case a1:if(d=r.length,d){if(d>a&&(d=a),d>l&&(d=l),d===0)break e;i.set(n.subarray(o,o+d),s),a-=d,o+=d,l-=d,s+=d,r.length-=d;break}r.mode=On;break;case l1:for(;f<14;){if(a===0)break e;a--,c+=n[o++]<>>=5,f-=5,r.ndist=(c&31)+1,c>>>=5,f-=5,r.ncode=(c&15)+4,c>>>=4,f-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=xe;break}r.have=0,r.mode=c1;case c1:for(;r.have>>=3,f-=3}for(;r.have<19;)r.lens[ae[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,M={bits:r.lenbits},T=Bl(wD,r.lens,0,19,r.lencode,0,r.work,M),r.lenbits=M.bits,T){t.msg="invalid code lengths set",r.mode=xe;break}r.have=0,r.mode=f1;case f1:for(;r.have>>24,S=m>>>16&255,_=m&65535,!(k<=f);){if(a===0)break e;a--,c+=n[o++]<>>=k,f-=k,r.lens[r.have++]=_;else{if(_===16){for(I=k+2;f>>=k,f-=k,r.have===0){t.msg="invalid bit length repeat",r.mode=xe;break}x=r.lens[r.have-1],d=3+(c&3),c>>>=2,f-=2}else if(_===17){for(I=k+3;f>>=k,f-=k,x=0,d=3+(c&7),c>>>=3,f-=3}else{for(I=k+7;f>>=k,f-=k,x=0,d=11+(c&127),c>>>=7,f-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=xe;break}for(;d--;)r.lens[r.have++]=x}}if(r.mode===xe)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=xe;break}if(r.lenbits=9,M={bits:r.lenbits},T=Bl(U1,r.lens,0,r.nlen,r.lencode,0,r.work,M),r.lenbits=M.bits,T){t.msg="invalid literal/lengths set",r.mode=xe;break}if(r.distbits=6,r.distcode=r.distdyn,M={bits:r.distbits},T=Bl(H1,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,M),r.distbits=M.bits,T){t.msg="invalid distances set",r.mode=xe;break}if(r.mode=Hu,e===Uu)break e;case Hu:r.mode=Wu;case Wu:if(a>=6&&l>=258){t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=a,r.hold=c,r.bits=f,mD(t,h),s=t.next_out,i=t.output,l=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,c=r.hold,f=r.bits,r.mode===On&&(r.back=-1);break}for(r.back=0;m=r.lencode[c&(1<>>24,S=m>>>16&255,_=m&65535,!(k<=f);){if(a===0)break e;a--,c+=n[o++]<>w)],k=m>>>24,S=m>>>16&255,_=m&65535,!(w+k<=f);){if(a===0)break e;a--,c+=n[o++]<>>=w,f-=w,r.back+=w}if(c>>>=k,f-=k,r.back+=k,r.length=_,S===0){r.mode=m1;break}if(S&32){r.back=-1,r.mode=On;break}if(S&64){t.msg="invalid literal/length code",r.mode=xe;break}r.extra=S&15,r.mode=u1;case u1:if(r.extra){for(I=r.extra;f>>=r.extra,f-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=h1;case h1:for(;m=r.distcode[c&(1<>>24,S=m>>>16&255,_=m&65535,!(k<=f);){if(a===0)break e;a--,c+=n[o++]<>w)],k=m>>>24,S=m>>>16&255,_=m&65535,!(w+k<=f);){if(a===0)break e;a--,c+=n[o++]<>>=w,f-=w,r.back+=w}if(c>>>=k,f-=k,r.back+=k,S&64){t.msg="invalid distance code",r.mode=xe;break}r.offset=_,r.extra=S&15,r.mode=d1;case d1:if(r.extra){for(I=r.extra;f>>=r.extra,f-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=xe;break}r.mode=p1;case p1:if(l===0)break e;if(d=h-l,r.offset>d){if(d=r.offset-d,d>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=xe;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),b=r.window}else b=i,p=s-r.offset,d=r.length;d>l&&(d=l),l-=d,r.length-=d;do i[s++]=b[p++];while(--d);r.length===0&&(r.mode=Wu);break;case m1:if(l===0)break e;i[s++]=r.length,l--,r.mode=Wu;break;case sg:if(r.wrap){for(;f<32;){if(a===0)break e;a--,c|=n[o++]<{if(!t||!t.state)return cr;let e=t.state;return e.window&&(e.window=null),t.state=null,ko},ID=(t,e)=>{if(!t||!t.state)return cr;let r=t.state;return r.wrap&2?(r.head=e,e.done=!1,ko):cr},BD=(t,e)=>{let r=e.length,n,i,o;return!t||!t.state||(n=t.state,n.wrap!==0&&n.mode!==Xu)?cr:n.mode===Xu&&(i=1,i=Vl(i,e,r,0),i!==n.check)?W1:(o=Q1(t,e,r,r),o?(n.mode=G1,q1):(n.havedict=1,ko))},jD=J1,$D=Y1,zD=Z1,FD=DD,VD=X1,UD=PD,HD=LD,WD=ID,qD=BD,KD="pako inflate (from Nodeca project)",En={inflateReset:jD,inflateReset2:$D,inflateResetKeep:zD,inflateInit:FD,inflateInit2:VD,inflate:UD,inflateEnd:HD,inflateGetHeader:WD,inflateSetDictionary:qD,inflateInfo:KD};function GD(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var ZD=GD,eS=Object.prototype.toString,{Z_NO_FLUSH:JD,Z_FINISH:YD,Z_OK:Wl,Z_STREAM_END:cg,Z_NEED_DICT:fg,Z_STREAM_ERROR:XD,Z_DATA_ERROR:v1,Z_MEM_ERROR:QD}=vo;function Zl(t){this.options=th.assign({chunkSize:1024*64,windowBits:15,to:""},t||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new F1,this.strm.avail_out=0;let r=En.inflateInit2(this.strm,e.windowBits);if(r!==Wl)throw new Error(go[r]);if(this.header=new ZD,En.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Hl.string2buf(e.dictionary):eS.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=En.inflateSetDictionary(this.strm,e.dictionary),r!==Wl)))throw new Error(go[r])}Zl.prototype.push=function(t,e){let r=this.strm,n=this.options.chunkSize,i=this.options.dictionary,o,s,a;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?YD:JD,eS.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=En.inflate(r,s),o===fg&&i&&(o=En.inflateSetDictionary(r,i),o===Wl?o=En.inflate(r,s):o===v1&&(o=fg));r.avail_in>0&&o===cg&&r.state.wrap>0&&t[r.next_in]!==0;)En.inflateReset(r),o=En.inflate(r,s);switch(o){case XD:case v1:case fg:case QD:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(r.avail_out===0||o===cg))if(this.options.to==="string"){let l=Hl.utf8border(r.output,r.next_out),c=r.next_out-l,f=Hl.buf2string(r.output,l);r.next_out=c,r.avail_out=n-c,c&&r.output.set(r.output.subarray(l,l+c),0),this.onData(f)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(o===Wl&&a===0)){if(o===cg)return o=En.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(r.avail_in===0)break}}return!0};Zl.prototype.onData=function(t){this.chunks.push(t)};Zl.prototype.onEnd=function(t){t===Wl&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=th.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function vg(t,e){let r=new Zl(e);if(r.push(t),r.err)throw r.msg||go[r.err];return r.result}function eN(t,e){return e=e||{},e.raw=!0,vg(t,e)}var tN=Zl,rN=vg,nN=eN,iN=vg,oN=vo,sN={Inflate:tN,inflate:rN,inflateRaw:nN,ungzip:iN,constants:oN},{Deflate:aN,deflate:lN,deflateRaw:cN,gzip:fN}=dD,{Inflate:uN,inflate:hN,inflateRaw:dN,ungzip:pN}=sN,mN=aN,gN=lN,yN=cN,bN=fN,kN=uN,vN=hN,wN=dN,xN=pN,SN=vo,wg={Deflate:mN,deflate:gN,deflateRaw:yN,gzip:bN,Inflate:kN,inflate:vN,inflateRaw:wN,ungzip:xN,constants:SN};var on,xg=class{constructor(){E(this,on,new Map)}emit(e,...r){let n=g(this,on).get(e);if(!n?.all?.size)return!1;for(let i of n.all)i(...r),n.once.has(i)&&(n.all.delete(i),n.once.delete(i));return!1}on(e,r){return g(this,on).has(e)||g(this,on).set(e,{all:new Set,once:new Set}),g(this,on).get(e).all.add(r),this}once(e,r){g(this,on).has(e)||g(this,on).set(e,{all:new Set,once:new Set});let n=g(this,on).get(e);return n.all.add(r),n.once.add(r),this}};on=new WeakMap;var Sg=class{async get(e,r={}){let n=new Headers;for(let[o,s]of Object.entries(r?.headers??{})){let a=typeof s=="string"?[s]:s;for(let l of a)n.append(o,l)}let i=await fetch(e,{headers:n,redirect:"follow"});if(i.ok)return new Uint8Array(await i.arrayBuffer());throw new Error(`Status code ${i.status}: ${i.ok}`)}},_g=class{on(e,r){return e==="ready"&&r(),this}once(e,r){return e==="ready"&&r(),this}async close(){}},nh=class{states;constructor(){this.states=JSON.parse(localStorage.getItem(nh.LocalStorageKey)??"{}")}saveStates(){localStorage.setItem(nh.LocalStorageKey,JSON.stringify(this.states))}async chmod(e,r){}async getAllFiles(e){return[]}async mkdir(e,r){if(e=Y.ensureEndingSlash(e.toString()),this.states[e])throw new Error(`EEXIST: ${e}`);this.states[e]={type:"directory"},this.saveStates()}async readFile(e){e=e.toString();let r=this.states[e];if(r){if(r.type==="directory")throw new Error(`EISDIR: ${e}`)}else throw new Error(`ENOENT: ${e}`);return new Uint8Array((0,ih.decode)(r.content))}async showFile(e){throw new Error("showFile not supported on browser")}async stat(e){e=e.toString();let r=this.states[e];if(!r)throw new Error(`ENOENT: ${e}`);return{isDirectory:()=>r.type==="directory",isFile:()=>r.type==="file"}}async unlink(e){if(e=e.toString(),!this.states[e])throw new Error(`ENOENT: ${e}`);delete this.states[e],this.saveStates()}watch(e){return new _g}async writeFile(e,r,n){e=e.toString(),typeof r=="string"&&(r=new TextEncoder().encode(r)),r=(0,ih.encode)(r),this.states[e]={type:"file",content:r},this.saveStates()}},rh=nh;H(rh,"LocalStorageKey","spyglassmc-browser-fs");var Cg={archive:{decompressBall(t,e){throw new Error("decompressBall not supported on browser.")},async gunzip(t){return wg.inflate(t)},async gzip(t){return wg.gzip(t)}},crypto:{async getSha1(t){typeof t=="string"&&(t=new TextEncoder().encode(t));let e=await crypto.subtle.digest("SHA-1",t);return _N(new Uint8Array(e))}},downloader:new Sg,error:{isKind(t,e){return t instanceof Error&&t.message.startsWith(e)}},event:{EventEmitter:xg},fs:new rh};function _N(t){let e="";for(let r of t)e+=r.toString(16).padStart(2,"0");return e}Object.freeze(Cg);var Co={};yr(Co,{TypeDefSymbolData:()=>Vg,fileModule:()=>sS,module_:()=>aS,registerMcdocBinders:()=>Ug});var C5=Object.freeze({is(t){return t?.type==="mcdoc:module"}}),rS=Object.freeze({is(t){return Ya.is(t)||Ag.is(t)||So.is(t)||$g.is(t)||_o.is(t)||oc.is(t)||uh.is(t)}}),Ag=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),location:t.children.find(U.is),index:t.children.find(ki.is),target:t.children.find(sn.is),typeParams:t.children.find(lh.is)}},is(t){return t?.type==="mcdoc:dispatch_statement"}}),wt=Object.freeze({is(t){return t?.type==="mcdoc:literal"}}),ki=Object.freeze({destruct(t){return{parallelIndices:t.children.filter(CN.is)}},is(t){return t?.type==="mcdoc:index_body"}}),CN=Object.freeze({is(t){return Tg.is(t)||Jl.is(t)}}),Tg=Object.freeze({is(t){return wt.is(t)||fr.is(t)||et.is(t)||U.is(t)}}),fr=Object.freeze({is(t){return t?.type==="mcdoc:identifier"}}),Jl=Object.freeze({destruct(t){return{keys:t.children.filter(AN.is)}},is(t){return t?.type==="mcdoc:dynamic_index"}}),AN=Object.freeze({is(t){return wt.is(t)||fr.is(t)||et.is(t)}}),sn=Object.freeze({is(t){return TN.is(t)||ON.is(t)||Lg.is(t)||Dg.is(t)||Ng.is(t)||Pg.is(t)||Xl.is(t)||Ql.is(t)||So.is(t)||_o.is(t)||ec.is(t)||nc.is(t)||ic.is(t)}}),Og=Object.freeze({destruct(t){return{appendixes:t.children.filter(e=>ki.is(e)||Yl.is(e)),attributes:t.children.filter(Mn.is)}}}),Mn=Object.freeze({destruct(t){return{name:t.children.find(fr.is),value:t.children.find(nS.is)}},is(t){return t?.type==="mcdoc:attribute"}}),nS=Object.freeze({is(t){return sn.is(t)||Rg.is(t)}}),Rg=Object.freeze({destruct(t){return{positional:t.children.find(Eg.is),named:t.children.find(Mg.is)}},is(t){return t?.type==="mcdoc:attribute/tree"}}),Eg=Object.freeze({destruct(t){return{values:t.children.filter(nS.is)}},is(t){return t?.type==="mcdoc:attribute/tree/pos"}}),Mg=Object.freeze({destruct(t){let e={values:[]},r;for(let n of t.children)Ya.is(n)||(fr.is(n)||et.is(n)?r=n:r&&(e.values.push({key:r,value:n}),r=void 0));return e},is(t){return t?.type==="mcdoc:attribute/tree/named"}}),Yl=Object.freeze({destruct(t){return{args:t.children.filter(sn.is)}},is(t){return t?.type==="mcdoc:type_arg_block"}}),TN=Object.freeze({is(t){return t?.type==="mcdoc:type/any"}}),ON=Object.freeze({is(t){return t?.type==="mcdoc:type/boolean"}}),Us=Object.freeze({destruct(t){return oS(t)},is(t){return t?.type==="mcdoc:int_range"}}),Dg=Object.freeze({destruct(t){return{value:t.children.find(RN.is)}},is(t){return t?.type==="mcdoc:type/literal"}}),RN=Object.freeze({is(t){return wt.is(t)||xo.is(t)||et.is(t)}}),xo=Object.freeze({destruct(t){return{value:t.children.find(Sr.is),suffix:t.children.find(wt.is)}},is(t){return t?.type==="mcdoc:typed_number"}}),Ng=Object.freeze({destruct(t){return{numericKind:t.children.find(wt.is),valueRange:t.children.find(oh.is)||t.children.find(Us.is)}},is(t){return t?.type==="mcdoc:type/numeric_type"}}),Rr="<";function iS(t){let e=t&2?Rr:"",r=t&1?Rr:"";return`${e}..${r}`}function oS(t){let e,r,n;return t.children.length===1?(e=0,r=n=t.children[0]):t.children.length===3?(e=i(t.children[1]),r=t.children[0],n=t.children[2]):wt.is(t.children[0])?(e=i(t.children[0]),n=t.children[1]):(e=i(t.children[1]),r=t.children[0]),{kind:e,min:r,max:n};function i(o){let s=0;return o.value.startsWith(Rr)&&(s|=2),o.value.endsWith(Rr)&&(s|=1),s}}var oh=Object.freeze({destruct(t){return oS(t)},is(t){return t?.type==="mcdoc:float_range"}}),Pg=Object.freeze({destruct(t){let e,r,n=!1;for(let i of t.children)wt.is(i)&&i.value==="[]"?n=!0:Us.is(i)&&(n?e=i:r=i);return{arrayKind:t.children.find(wt.is),lengthRange:e,valueRange:r}},is(t){return t?.type==="mcdoc:type/primitive_array"}}),Xl=Object.freeze({destruct(t){return{item:t.children.find(sn.is),lengthRange:t.children.find(Us.is)}},is(t){return t?.type==="mcdoc:type/list"}}),Lg=Object.freeze({destruct(t){return{lengthRange:t.children.find(Us.is)}},is(t){return t?.type==="mcdoc:type/string"}}),Ql=Object.freeze({destruct(t){return{items:t.children.filter(sn.is)}},is(t){return t?.type==="mcdoc:type/tuple"}}),tS=new Set(["byte","short","int","long","float","double","string"]),So=Object.freeze({kinds:tS,destruct(t){return{block:t.children.find(sh.is),docComments:t.children.find(Hs.is),enumKind:e(t),identifier:t.children.find(fr.is),keyword:t.children.find(wt.is)};function e(r){for(let n of r.children.filter(wt.is))if(tS.has(n.value))return n.value}},is(t){return t?.type==="mcdoc:enum"}}),Hs=Object.freeze({asText(t){if(!t)return;let e=t.children.map(r=>r.comment);return e.every(r=>r.length===0||r.startsWith(" "))&&(e=e.map(r=>r.slice(1))),e.join(` +`)},is(t){return t?.type==="mcdoc:doc_comments"}}),sh=Object.freeze({destruct(t){return{fields:t.children.filter(ah.is)}},is(t){return t?.type==="mcdoc:enum/block"}}),ah=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),identifier:t.children.find(fr.is),value:t.children.find(EN.is)}},is(t){return t?.type==="mcdoc:enum/field"}}),EN=Object.freeze({is(t){return xo.is(t)||et.is(t)}}),A5=Object.freeze({is(t){return Mn.is(t)||Hs.is(t)}}),_o=Object.freeze({destruct(t){return{block:t.children.find(ch.is),docComments:t.children.find(Hs.is),identifier:t.children.find(fr.is),keyword:t.children.find(wt.is)}},is(t){return t?.type==="mcdoc:struct"}}),ec=Object.freeze({destruct(t){return{path:t.children.find(tc.is)}},is(t){return t?.type==="mcdoc:type/reference"}}),lh=Object.freeze({destruct(t){return{params:t.children.filter(Ig.is)}},is(t){return t?.type==="mcdoc:type_param_block"}}),Ig=Object.freeze({destruct(t){return{identifier:t.children.find(fr.is)}},is(t){return t?.type==="mcdoc:type_param"}}),tc=Object.freeze({destruct(t){let e=Za(t?.children,-1);return{children:t?.children??[],isAbsolute:t?.isAbsolute,lastIdentifier:fr.is(e)?e:void 0}},is(t){return t?.type==="mcdoc:path"}}),ch=Object.freeze({destruct(t){return{fields:t.children.filter(Bg.is)}},is(t){return t?.type==="mcdoc:struct/block"}}),Bg=Object.freeze({is(t){return Ws.is(t)||fh.is(t)}}),Ws=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),key:t.children.find(jg.is),type:t.children.find(sn.is),isOptional:t.isOptional}},is(t){return t?.type==="mcdoc:struct/field/pair"}}),jg=Object.freeze({is(t){return et.is(t)||fr.is(t)||rc.is(t)}}),rc=Object.freeze({destruct(t){return{type:t.children.find(sn.is)}},is(t){return t?.type==="mcdoc:struct/map_key"}}),fh=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),type:t.children.find(sn.is)}},is(t){return t?.type==="mcdoc:struct/field/spread"}}),nc=Object.freeze({destruct(t){return{location:t.children.find(U.is),index:t.children.find(ki.is)}},is(t){return t?.type==="mcdoc:type/dispatcher"}}),ic=Object.freeze({destruct(t){return{members:t.children.filter(sn.is)}},is(t){return t?.type==="mcdoc:type/union"}}),$g=Object.freeze({destruct(t){return{injection:t.children.find(MN.is)}},is(t){return t?.type==="mcdoc:injection"}}),MN=Object.freeze({is(t){return zg.is(t)||DN.is(t)}}),zg=Object.freeze({is(t){return t?.type==="mcdoc:injection/enum"}}),DN=Object.freeze({is(t){return t?.type==="mcdoc:injection/struct"}}),oc=Object.freeze({destruct(t){return{attributes:t.children.filter(Mn.is),docComments:t.children.find(Hs.is),identifier:t.children.find(fr.is),keyword:t.children.find(wt.is),typeParams:t.children.find(lh.is),rhs:t.children.find(sn.is)}},is(t){return t?.type==="mcdoc:type_alias"}}),uh=Object.freeze({destruct(t){return{binding:t.children.find(fr.is),path:t.children.find(tc.is)}},is(t){return t?.type==="mcdoc:use_statement"}});var NN=Object.freeze({is(t){return!!t&&typeof t=="object"&&typeof t.nextAnonymousIndex=="number"}}),Vg=Object.freeze({is(t){return!!t&&typeof t=="object"&&typeof t.typeDef=="object"}}),sS=ol.create(async(t,e)=>{let r=HN(e.doc.uri,e);if(!r){e.err.report(y("mcdoc.binder.out-of-root",P(e.doc.uri)),v.Beginning,0);return}let n={...e,moduleIdentifier:r};return aS(t,n)});async function aS(t,e){let r={nextAnonymousIndex:0};e.symbols.query({doc:e.doc,node:t},"mcdoc",e.moduleIdentifier).amend({data:{data:r}}),PN(t,e);for(let n of t.children)switch(n.type){case"mcdoc:dispatch_statement":await LN(n,e);break;case"mcdoc:enum":fS(n,e);break;case"mcdoc:injection":await jN(n,e);break;case"mcdoc:struct":await uS(n,e);break;case"mcdoc:type_alias":await zN(n,e);break;case"mcdoc:use_statement":await FN(n,e);break}}function PN(t,e){At(t,()=>!0,rS.is,c=>{switch(c.type){case"mcdoc:enum":r(c);break;case"mcdoc:struct":n(c);break;case"mcdoc:type_alias":i(c);break;case"mcdoc:use_statement":o(c);break}});function r(c){s("enum",c,So.destruct,f=>({typeDef:mS(f,e)}))}function n(c){s("struct",c,_o.destruct,f=>({typeDef:gS(f,e)}))}function i(c){s("type_alias",c,oc.destruct,f=>{let{attributes:u,rhs:h,typeParams:d}=oc.destruct(f);if(!h)return;let p={typeDef:an(h,e)};return d&&lS(c,d,p,e),p.typeDef=Hg(p.typeDef,u,e),p})}function o(c){let{binding:f,path:u}=uh.destruct(c);if(!u)return;let{lastIdentifier:h}=tc.destruct(u),d=f??h;d&&e.symbols.query({doc:e.doc,node:c},"mcdoc",`${e.moduleIdentifier}::${d.value}`).ifDeclared(p=>qs(e,p,d)).elseEnter({data:{subcategory:"use_statement_binding",visibility:1},usage:{type:"definition",node:d,fullRange:c}})}function s(c,f,u,h){let{docComments:d,identifier:p,keyword:b}=u(f),m=p?.value??l(f,e);e.symbols.query({doc:e.doc,node:f},"mcdoc",`${e.moduleIdentifier}::${m}`).ifDeclared(k=>qs(e,k,p??f)).elseEnter({data:{data:h(f),desc:Hs.asText(d),subcategory:c},usage:{type:"definition",node:p??b,fullRange:p&&f}})}function a(c,f){let u=f.symbols.query({doc:f.doc,node:c},"mcdoc",f.moduleIdentifier).getData(NN.is);if(!u)throw new Error(`No symbol data for module '${f.moduleIdentifier}'`);return u.nextAnonymousIndex++}function l(c,f){return``}}function lS(t,e,r,n){t.locals=Object.create(null),r.typeDef={kind:"template",child:r.typeDef,typeParams:[]};let{params:i}=lh.destruct(e);for(let o of i){let{identifier:s}=Ig.destruct(o);if(s.value){let a=`${n.moduleIdentifier}::${s.value}`;n.symbols.query({doc:n.doc,node:t},"mcdoc",a).ifDeclared(l=>qs(n,l,s)).elseEnter({data:{visibility:0},usage:{type:"declaration",node:s,fullRange:o}}),r.typeDef.typeParams.push({path:a})}}}async function LN(t,e){let{attributes:r,location:n,index:i,target:o,typeParams:s}=Ag.destruct(t);if(!(n&&i&&o))return;let a=U.toString(n,"full");e.symbols.query(e.doc,"mcdoc/dispatcher",a).enter({usage:{type:"reference",node:n,fullRange:t}});let{parallelIndices:l}=ki.destruct(i);if(l.length){let c={typeDef:an(o,e)};s&&lS(t,s,c,e),c.typeDef=Hg(c.typeDef,r,e);for(let f of l)Jl.is(f)||e.symbols.query(e.doc,"mcdoc/dispatcher",a,ac(f)).ifDeclared(u=>qs(e,u,f,{localeString:"mcdoc.binder.dispatcher-statement.duplicated-key"})).elseEnter({data:{data:c},usage:{type:"definition",node:f,fullRange:t}})}await vi(o,e)}async function vi(t,e){if(nc.is(t))await IN(t,e);else if(So.is(t))fS(t,e);else if(Xl.is(t)){let{item:n}=Xl.destruct(t);await vi(n,e)}else if(ec.is(t)){let{path:n}=ec.destruct(t);await cS(n,e)}else if(_o.is(t))await uS(t,e);else if(Ql.is(t)){let{items:n}=Ql.destruct(t);for(let i of n)await vi(i,e)}else if(ic.is(t)){let{members:n}=ic.destruct(t);for(let i of n)await vi(i,e)}let{appendixes:r}=Og.destruct(t);for(let n of r)if(Yl.is(n)){let{args:i}=Yl.destruct(n);for(let o of i)await vi(o,e)}}async function IN(t,e){let{index:r,location:n}=nc.destruct(t),i=U.toString(n,"full");e.symbols.query(e.doc,"mcdoc/dispatcher",i).enter({usage:{type:"reference",node:n,fullRange:t}});let{parallelIndices:o}=ki.destruct(r);for(let s of o)Jl.is(s)||e.symbols.query(e.doc,"mcdoc/dispatcher",i,ac(s)).enter({usage:{type:"reference",node:s,fullRange:t}})}async function cS(t,e){for(let{identifiers:r,node:n,indexRight:i}of hS(t,e,{reportErrors:!0}))if(r?.length){if(i===1){let o=hh(r),s=UN(o,e);if(!s){e.err.report(y("mcdoc.binder.path.unknown-module",P(o)),t,2);return}await e.ensureBindingStarted(s)}e.symbols.query({doc:e.doc,node:n},"mcdoc",hh(r)).ifDeclared((o,s)=>s.enter({usage:{type:"reference",node:n,fullRange:t,skipRenaming:wt.is(n)}})).else(()=>{i===0&&e.err.report(y("mcdoc.binder.path.unknown-identifier",P(Za(r,-1)),P(hh(r.slice(0,-1)))),t,2)})}}function fS(t,e){let{block:r,identifier:n,keyword:i}=So.destruct(t),o=n?.symbol??i.symbol;if(o?.subcategory!=="enum")return;let s=e.symbols.query({doc:e.doc,node:t},"mcdoc",...o.path);nr.assertDefined(s.symbol),BN(r,e,s)}function BN(t,e,r,n={}){let{fields:i}=sh.destruct(t);for(let o of i){let{identifier:s}=ah.destruct(o);r.member(s.value,a=>a.ifDeclared(l=>qs(e,l,s)).elseEnter({usage:{type:"definition",node:s,fullRange:o}}))}}async function jN(t,e){let{injection:r}=$g.destruct(t);zg.is(r)}async function uS(t,e){let{block:r,identifier:n,keyword:i}=_o.destruct(t),o=n?.symbol??i.symbol;if(o?.subcategory!=="struct")return;let s=e.symbols.query({doc:e.doc,node:t},"mcdoc",...o.path);nr.assertDefined(s.symbol),await $N(r,e,s)}async function $N(t,e,r,n={}){let{fields:i}=ch.destruct(t);for(let o of i)if(Ws.is(o)){let{key:s,type:a}=Ws.destruct(o);rc.is(s)||r.member(s.value,l=>l.ifDeclared(c=>qs(e,c,s)).elseEnter({usage:{type:"definition",node:s,fullRange:o}})),await vi(a,e)}else{let{type:s}=fh.destruct(o);await vi(s,e)}}async function zN(t,e){let{identifier:r,rhs:n,typeParams:i}=oc.destruct(t);r?.value&&n&&await vi(n,e)}async function FN(t,e){let{path:r}=uh.destruct(t);if(r)return cS(r,e)}function Ug(t){t.registerBinder("mcdoc:module",sS)}function qs(t,e,r,n={localeString:"mcdoc.binder.duplicated-declaration"}){t.err.report(y(n.localeString,P(e.identifier)),r,2,{related:[{location:Le.getDeclaredLocation(e),message:y(`${n.localeString}.related`,P(e.identifier))}]})}function*hS(t,e,r={}){let{children:n,isAbsolute:i}=tc.destruct(t),o=i?[]:e.moduleIdentifier.slice(2).split("::");for(let[s,a]of n.entries()){switch(a.type){case"mcdoc:identifier":o.push(a.value);break;case"mcdoc:literal":if(o.length===0){r.reportErrors&&e.err.report(y("mcdoc.binder.path.super-from-root"),a);return}o.pop();break;default:nr.assertNever(a)}yield{identifiers:o,node:a,index:s,indexRight:n.length-1-s}}}function VN(t,e,r={}){return Za([...hS(t,e,r)],-1)?.identifiers}function UN(t,e){return e.symbols.global.mcdoc?.[t]?.definition?.[0]?.uri}function HN(t,e){return Object.values(e.symbols.global.mcdoc??{}).find(r=>r.subcategory==="module"&&r.definition?.some(n=>n.uri===t))?.identifier}function hh(t){return t?`::${t.join("::")}`:void 0}function an(t,e){switch(t.type){case"mcdoc:enum":return mS(t,e);case"mcdoc:struct":return gS(t,e);case"mcdoc:type/any":return oP(t,e);case"mcdoc:type/boolean":return sP(t,e);case"mcdoc:type/dispatcher":return aP(t,e);case"mcdoc:type/list":return lP(t,e);case"mcdoc:type/literal":return cP(t,e);case"mcdoc:type/numeric_type":return hP(t,e);case"mcdoc:type/primitive_array":return dP(t,e);case"mcdoc:type/string":return pP(t,e);case"mcdoc:type/reference":return mP(t,e);case"mcdoc:type/tuple":return gP(t,e);case"mcdoc:type/union":return yP(t,e);default:return nr.assertNever(t)}}function Vt(t,e,r,n={}){let{attributes:i,appendixes:o}=Og.destruct(t),s=e;for(let a of o)if(ki.is(a)){if(n.skipFirstIndexBody){n.skipFirstIndexBody=!1;continue}s={kind:"indexed",child:s,parallelIndices:pS(a,r)}}else s={kind:"concrete",child:s,typeArgs:JN(a,r)};return s=Hg(s,i,r),s}function Hg(t,e,r){for(let n of e)t={kind:"attributed",attribute:dS(n,r),child:t};return t}function Wg(t,e){return WN(t.map(r=>dS(r,e)))}function WN(t){return t.length?t:void 0}function dS(t,e){let{name:r,value:n}=Mn.destruct(t);return{name:r.value,value:n&&Fg(n,e)}}function Fg(t,e){return t.type==="mcdoc:attribute/tree"?{kind:"tree",values:qN(t,e)}:an(t,e)}function qN(t,e){let r={},{named:n,positional:i}=Rg.destruct(t);if(i){let{values:o}=Eg.destruct(i);for(let[s,a]of o.entries())r[s]=Fg(a,e)}if(n){let{values:o}=Mg.destruct(n);for(let{key:s,value:a}of o)r[s.value]=Fg(a,e)}return r}function pS(t,e){let{parallelIndices:r}=ki.destruct(t);return r.map(n=>KN(n,e))}function KN(t,e){return Tg.is(t)?GN(t,e):ZN(t,e)}function GN(t,e){return{kind:"static",value:ac(t)}}function ZN(t,e){let{keys:r}=Jl.destruct(t);return{kind:"dynamic",accessor:r.map(ac)}}function JN(t,e){let{args:r}=Yl.destruct(t);return r.map(n=>an(n,e))}function mS(t,e){let{block:r,enumKind:n,identifier:i}=So.destruct(t),o=i?.symbol??t.symbol;return o&&Vg.is(o.data)&&o.data.typeDef.kind==="enum"?o.data.typeDef:Vt(t,{kind:"enum",enumKind:n,values:YN(r,e)},e)}function YN(t,e){let{fields:r}=sh.destruct(t);return r.map(n=>XN(n,e))}function XN(t,e){let{attributes:r,identifier:n,value:i}=ah.destruct(t);return{attributes:Wg(r,e),identifier:n.value,value:QN(i,e)}}function QN(t,e){if(xo.is(t)){let{value:r}=xo.destruct(t);return r.value}return t.value}function gS(t,e){let{block:r,identifier:n}=_o.destruct(t),i=n?.symbol??t.symbol;return i&&Vg.is(i.data)&&i.data.typeDef.kind==="struct"?i.data.typeDef:Vt(t,{kind:"struct",fields:eP(r,e)},e)}function eP(t,e){let{fields:r}=ch.destruct(t);return r.map(n=>tP(n,e))}function tP(t,e){return Ws.is(t)?rP(t,e):iP(t,e)}function rP(t,e){let{attributes:r,key:n,type:i,isOptional:o}=Ws.destruct(t);return{kind:"pair",attributes:Wg(r,e),key:nP(n,e),type:an(i,e),optional:o}}function nP(t,e){if(rc.is(t)){let{type:r}=rc.destruct(t);return an(r,e)}else return ac(t)}function iP(t,e){let{attributes:r,type:n}=fh.destruct(t);return{kind:"spread",attributes:Wg(r,e),type:an(n,e)}}function oP(t,e){return Vt(t,{kind:"any"},e)}function sP(t,e){return Vt(t,{kind:"boolean"},e)}function aP(t,e){let{index:r,location:n}=nc.destruct(t);return Vt(t,{kind:"dispatcher",parallelIndices:pS(r,e),registry:U.toString(n,"full")},e,{skipFirstIndexBody:!0})}function lP(t,e){let{item:r,lengthRange:n}=Xl.destruct(t);return Vt(t,{kind:"list",item:an(r,e),lengthRange:sc(n,e)},e)}function sc(t,e){if(!t)return;let{kind:r,min:n,max:i}=oh.is(t)?oh.destruct(t):Us.destruct(t);return{kind:r,min:n?.value,max:i?.value}}function cP(t,e){let{value:r}=Dg.destruct(t);return Vt(t,{kind:"literal",value:fP(r,e)},e)}function fP(t,e){if(wt.is(t))return{kind:"boolean",value:t.value==="true"};if(xo.is(t)){let{suffix:r,value:n}=xo.destruct(t);return{kind:"number",value:n.value,suffix:uP(r,e)}}else return{kind:"string",value:t.value}}function uP(t,e){return t?.value?.toLowerCase()}function hP(t,e){let{numericKind:r,valueRange:n}=Ng.destruct(t);return Vt(t,{kind:r.value,valueRange:sc(n,e)},e)}function dP(t,e){let{arrayKind:r,lengthRange:n,valueRange:i}=Pg.destruct(t);return Vt(t,{kind:`${r.value}_array`,lengthRange:sc(n,e),valueRange:sc(i,e)},e)}function pP(t,e){let{lengthRange:r}=Lg.destruct(t);return Vt(t,{kind:"string",lengthRange:sc(r,e)},e)}function mP(t,e){let{path:r}=ec.destruct(t);return Vt(t,{kind:"reference",path:hh(VN(r,e))},e)}function gP(t,e){let{items:r}=Ql.destruct(t);return Vt(t,{kind:"tuple",items:r.map(n=>an(n,e))},e)}function yP(t,e){let{members:r}=ic.destruct(t);return Vt(t,{kind:"union",members:r.map(n=>an(n,e))},e)}function ac(t){return U.is(t)?U.toString(t,"short"):t.value}var bP=t=>[Te.create(t,"variable")],kP=t=>[Te.create(t,t.colorTokenType??"literal")];function yS(t){t.registerColorizer("mcdoc:literal",kP),t.registerColorizer("mcdoc:identifier",bP)}var kS=Object.freeze(["fallback","none","unknown"]),L5=Object.freeze({kind:"union",members:[]});var vP=Object.freeze(["b","s","l","f","d"]),vS=Object.freeze([...vP,"B","S","L","F","D"]),Kg=Object.freeze(["byte","short","int","long"]),ph=Object.freeze(["float","double"]),I5=Object.freeze([...Kg,...ph]),Gg=Object.freeze(["byte","int","long"]),B5=Object.freeze(Gg.map(t=>`${t}_array`)),dh;(function(t){function e(r){let n=o=>{if(!o)return"";let{kind:s,min:a,max:l}=o;return a===l?` @ ${a}`:` @ ${a??""}${iS(s)}${l??""}`},i=o=>{let s=[];for(let a of Ue.toArray(o))a===void 0?s.push("()"):s.push(a.kind==="static"?`[${a.value}]`:`[[${a.accessor.map(l=>typeof l=="string"?l:l.keyword).join(".")}]]`);return`[${s.join(", ")}]`};if(r===void 0)return"";switch(r.kind){case"any":case"boolean":return r.kind;case"attributed":return`#[${r.attribute.name}${r.attribute.value?"=":""}] ${e(r.child)}`;case"byte":return`byte${n(r.valueRange)}`;case"byte_array":return`byte${n(r.valueRange)}[]${n(r.lengthRange)}`;case"concrete":return`${e(r.child)}${r.typeArgs.length?`<${r.typeArgs.map(e).join(", ")}>`:""}`;case"dispatcher":return`${r.registry??"spyglass:unknown"}[${i(r.parallelIndices)}]`;case"double":return`double${n(r.valueRange)}`;case"enum":return"";case"float":return`float${n(r.valueRange)}`;case"indexed":return`${e(r.child)}${i(r.parallelIndices)}`;case"int":return`int${n(r.valueRange)}`;case"int_array":return`int${n(r.valueRange)}[]${n(r.lengthRange)}`;case"list":return`[${e(r.item)}]${n(r.lengthRange)}`;case"literal":return`${r.value}`;case"long":return`long${n(r.valueRange)}`;case"long_array":return`long${n(r.valueRange)}[]${n(r.lengthRange)}`;case"reference":return r.path??"";case"short":return`short${n(r.valueRange)}`;case"string":return`string${n(r.lengthRange)}`;case"struct":return"";case"template":return`${e(r.child)}${r.typeParams.length?`<${r.typeParams.map(o=>`?${o.path}`).join(", ")}>`:""}`;case"tuple":return`[${r.items.map(o=>e(o)).join(",")}${r.items.length===1?",":""}]`;case"union":return`(${r.members.map(e).join(" | ")})`;case"unsafe":return"unsafe";default:return nr.assertNever(r)}}t.toString=e})(dh||(dh={}));var nt;(function(t){t[t.Nah=0]="Nah",t[t.Assignable=1]="Assignable",t[t.StrictlyAssignable=3]="StrictlyAssignable"})(nt||(nt={}));var lc=(t,e)=>{if(!e)return!0;if(!t)return!1;let{min:r,max:n}=t,{min:i,max:o}=e;return(i===void 0||r!==void 0&&r>=i)&&(o===void 0||n!==void 0&&n<=o)},Gs=t=>{let e=new Set,r=n=>{for(let i of e){if((Ks(n,i)&nt.StrictlyAssignable)===nt.StrictlyAssignable)return;(Ks(i,n)&nt.StrictlyAssignable)===nt.StrictlyAssignable&&e.delete(i)}e.add(n)};for(let n of t.members)n.kind==="union"?Gs(n).members.forEach(r):r(n);return{kind:"union",members:[...e]}};var wP=t=>(t=Gs(t),t.members.length===1?t.members[0]:t),cc=t=>({kind:"list",item:qg(t.item),...t.lengthRange?{lengthRange:{...t.lengthRange}}:{}}),qg=t=>(t.kind==="union"?t=wP(t):t.kind==="list"&&(t=cc(t)),t),Ks=(t,e,r=[])=>{let n=s=>s?nt.StrictlyAssignable:nt.Nah,i=s=>s?nt.Assignable:nt.Nah,o;return t=qg(t),e=qg(e),t.kind==="any"||t.kind==="reference"||e.kind==="reference"?o=nt.Assignable:e.kind==="any"?o=nt.StrictlyAssignable:t.kind==="union"?o=i(t.members.every(s=>Ks(s,e,r))):e.kind==="union"?o=i(e.members.some(s=>Ks(t,s))):t.kind==="boolean"?o=n(e.kind==="boolean"||e.kind==="byte"):t.kind==="byte"?e.kind==="boolean"?o=Ks(t,{kind:"byte",valueRange:{kind:0,min:0,max:1}},r):e.kind==="byte"?o=n(lc(t.valueRange,e.valueRange)):e.kind==="enum"?o=i(!e.enumKind||e.enumKind==="byte"):o=nt.Nah:t.kind==="byte_array"||t.kind==="int_array"||t.kind==="long_array"?o=n(e.kind===t.kind&&lc(t.lengthRange,e.lengthRange)&&lc(t.valueRange,e.valueRange)):t.kind==="struct"||t.kind==="dispatcher"?o=i(e.kind==="struct"||e.kind==="dispatcher"):t.kind==="enum"?o=i((e.kind==="byte"||e.kind==="float"||e.kind==="double"||e.kind==="int"||e.kind==="long"||e.kind==="short"||e.kind==="string")&&(!t.enumKind||t.enumKind===e.kind)):t.kind==="float"||t.kind==="double"||t.kind==="int"||t.kind==="long"||t.kind==="short"?e.kind===t.kind?o=n(lc(t.valueRange,e.valueRange)):e.kind==="enum"?o=i(!e.enumKind||e.enumKind===t.kind):o=nt.Nah:t.kind==="list"?e.kind==="list"&&lc(t.lengthRange,e.lengthRange)?o=Ks(t.item,e.item,r):o=nt.Nah:t.kind==="string"?e.kind==="string"?o=nt.StrictlyAssignable:o=i(e.kind==="enum"&&(!e.enumKind||e.enumKind==="string")):o=nt.Nah,o||r.push(y("mcdoc.checker.type-not-assignable",P(dh.toString(t)),P(dh.toString(e)))),o};var OS=Is(Rl({singleLinePrefixes:new Set(["//"])}),(t,e)=>!e.slice(t).startsWith("///"),y("mcdoc.parser.syntax.doc-comment-unexpected"));function RS(t=!1){return(e,r)=>{let n=[];for(e.skipWhitespace();e.canRead()&&e.peek(2)==="//"&&(!t||e.peek(3)!=="///");){let i=OS(e,r);n.push(i),e.skipWhitespace()}return n}}function z(t,e=!1){return(r,n)=>{r.skipWhitespace();let i=be(t,RS(e))(r,n);return r.skipWhitespace(),i}}function Mr(t,e=!1){return Ls(t,RS(e))}function Er(t,e){return(r,n)=>{let i={type:"mcdoc:literal",range:v.create(r),value:"",colorTokenType:e?.colorTokenType};return i.value=r.readIf(o=>e?.allowedChars?.has(o)??(e?.specialChars?.has(o)||/[a-z]/i.test(o))),i.range.end=r.cursor,Ue.toArray(t).every(o=>o!==i.value)&&n.err.report(y("expected-got",vn(t),P(i.value)),i),i}}function Et(t,e={colorTokenType:"keyword"}){return(r,n)=>{let i=Er(t,e)(r,n);return Ue.toArray(t).includes(i.value)?i:V}}function Q(t){return(e,r)=>{e.skipWhitespace(),e.trySkip(t)||r.err.report(y("expected-got",P(t),P(e.peek())),e)}}function fe(t){return(e,r)=>{if(e.skipWhitespace(),!e.trySkip(t))return V}}function Zg(t){return Is(Ee(t),e=>e.namespace!==void 0,y("mcdoc.parser.resource-location.colon-expected",P(q.NamespacePathSep)))}var xP=Object.freeze(["\0","","","","","","","\x07","\b"," ",` +`,"\v","\f","\r","","","\x7F"]),Zs=Tn(pt({escapable:{characters:["b","f","n","r","t","\\",'"'],unicode:!0},quotes:['"']}),...xP),ur=(t,e)=>{let r=/^[\p{L}\p{Nl}]$/u,n=/^[\p{L}\p{Nl}\u200C\u200D\p{Mn}\p{Mc}\p{Nd}\p{Pc}]$/u,i=new Set(["any","boolean","byte","double","enum","false","float","int","long","short","string","struct","super","true"]),o={type:"mcdoc:identifier",range:v.create(t),options:{category:"mcdoc"},value:""},s=t.innerCursor;if(r.test(t.peek()))for(t.skip();n.test(t.peek());)t.skip();else e.err.report(y("expected",y("mcdoc.node.identifier")),t);return o.value=t.string.slice(s,t.innerCursor),o.range.end=t.cursor,i.has(o.value)&&e.err.report(y("mcdoc.parser.identifier.reserved-word",P(o.value)),o),o};function Jg(t){let e=ne([{prefix:"%",parser:Er(["%key","%parent"],{specialChars:new Set(["%"])})},{prefix:'"',parser:Zs},{parser:ur}]),r=se("mcdoc:dynamic_index",z([Q("["),e,Ls(be([fe("."),e])),Q("]")])),n=ne([{prefix:"%",parser:Er(kS.map(i=>`%${i}`),{specialChars:new Set(["%"])})},{prefix:'"',parser:Zs},{prefix:"[",parser:t?.noDynamic?Is(r,()=>!1,y("mcdoc.parser.index-body.dynamic-index-not-allowed")):r},{parser:ar([Zg({category:"mcdoc/dispatcher",accessType:t?.accessType}),ur])}]);return se("mcdoc:index_body",z([Q("["),n,Mr(z([fe(","),oe(n)])),ke(fe(",")),Q("]")]))}var wS=ne([{prefix:"super",parser:Er("super")},{parser:ur}]),gh=(t,e)=>{let r;return t.trySkip("::")&&(r=!0),J(be([wS,Ls(be([fe("::"),wS]))]),n=>({type:"mcdoc:path",children:n.children,range:n.range,isAbsolute:r}))(t,e)},xS=se("mcdoc:attribute/tree/pos",z([{get:()=>mh},Mr(z([fe(","),{get:()=>oe(mh)}],!0),!0)],!0)),SS=z([ne([{prefix:'"',parser:Zs},{parser:ur}]),ne([{prefix:"=",parser:z([Q("="),{get:()=>mh}],!0)},{parser:{get:()=>Yg}}])],!0),_S=se("mcdoc:attribute/tree/named",z([SS,Mr(z([fe(","),oe(SS)],!0),!0)],!0)),SP=ar([z([_S,ke(fe(","))]),z([xS,Q(","),_S,ke(fe(","))]),z([xS,ke(fe(","))])]),_P=Object.freeze({"(":")","[":"]","{":"}"}),Yg=(t,e)=>{let r=t.trySkip("(")?"(":t.trySkip("[")?"[":t.trySkip("{")?"{":void 0;if(!r)return V;let n=SP(t,e),i={type:"mcdoc:attribute/tree",range:n.range,children:n.children,delim:r};return t.trySkip(_P[r]),i},mh=ne([{predicate:t=>["(","[","{"].includes(t.peek()),parser:Yg},{parser:{get:()=>Rt}}]),CP=se("mcdoc:attribute",z([fe("#["),ur,ne([{prefix:"=",parser:z([Q("="),mh,Q("]")],!0)},{predicate:t=>["(","[","{"].includes(t.peek()),parser:z([Yg,Q("]")],!0)},{parser:Q("]")}])],!0)),yh=Ls(CP),CS=se("mcdoc:type_param",z([ur])),AP=se("mcdoc:type_param_block",z([Q("<"),ne([{prefix:">",parser:Q(">")},{parser:z([CS,Mr(z([fe(","),oe(CS)])),ke(fe(",")),Q(">")])}])])),Xg=()=>{},ES=ne([{prefix:"<",parser:AP},{parser:Xg}]),TP=se("mcdoc:dispatch_statement",z([yh,Et("dispatch"),Zg({category:"mcdoc/dispatcher",accessType:1}),Jg({noDynamic:!0}),ES,Er("to"),{get:()=>Rt}],!0)),OP=Rl({singleLinePrefixes:new Set(["///"]),includesEol:!0}),RP=se("mcdoc:doc_comments",Ls(OP,t=>(t.skipWhitespace(),[]))),uc=z([ke(oe(RP)),yh]),MS=Er(["byte","short","int","long","string","float","double"],{colorTokenType:"type"}),DS=en({pattern:/^[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)?|[0-9]*\.[0-9]+(?:[eE][-+]?[0-9]+)?)$/}),NS=se("mcdoc:typed_number",be([DS,ke(Et(vS,{colorTokenType:"keyword"}))])),EP=ne([{prefix:'"',parser:Zs},{parser:NS}]),AS=se("mcdoc:enum/field",z([uc,ur,Q("="),EP],!0)),PS=se("mcdoc:enum/block",z([Q("{"),ne([{prefix:"}",parser:Q("}")},{parser:z([AS,Mr(z([fe(","),oe(AS)],!0),!0),ke(fe(",")),Q("}")],!0)}])],!0)),LS=se("mcdoc:enum",z([uc,Et("enum"),Q("("),MS,Q(")"),ke(Ol(ur)),PS],!0)),MP=se("mcdoc:struct/map_key",z([Q("["),{get:()=>Rt},Q("]")],!0)),DP=ne([{prefix:'"',parser:Zs},{prefix:"[",parser:MP},{parser:ur}]),NP=(t,e)=>{let r,n=z([uc,DP],!0)(t,e);t.trySkip("?")&&(r=!0);let i=z([Q(":"),{get:()=>Rt}],!0)(t,e);return{type:"mcdoc:struct/field/pair",children:[...n.children,...i.children],range:v.span(n,i),isOptional:r}},PP=se("mcdoc:struct/field/spread",z([yh,fe("..."),{get:()=>Rt}],!0)),TS=ar([PP,NP]),IS=se("mcdoc:struct/block",z([Q("{"),ne([{prefix:"}",parser:Q("}")},{parser:z([TS,Mr(z([fe(","),oe(TS)],!0),!0),ke(fe(",")),Q("}")],!0)}])],!0)),BS=se("mcdoc:struct",z([uc,Et("struct"),ke(oe(ur)),IS],!0)),LP=se("mcdoc:injection/enum",z([Er("enum"),Q("("),MS,Q(")"),gh,PS])),IP=se("mcdoc:injection/struct",z([Er("struct"),gh,IS])),BP=se("mcdoc:injection",z([Et("inject"),ne([{prefix:"enum",parser:LP},{parser:IP}])])),jP=se("mcdoc:type_alias",z([uc,Et("type"),ur,ES,Q("="),{get:()=>Rt}],!0)),$P=se("mcdoc:use_statement",z([Et("use"),gh,ne([{prefix:"as",parser:z([Er("as"),ur])},{parser:Xg}])],!0)),zP=ar([OS,TP,LS,BP,BS,jP,$P]),jS=se("mcdoc:module",Mr(zP,!0)),FP=se("mcdoc:type_arg_block",z([fe("<"),ne([{prefix:">",parser:Q(">")},{parser:z([{get:()=>Rt},Mr(z([fe(","),{get:()=>oe(Rt)}],!0),!0),ke(fe(",")),Q(">")],!0)}])]));function Dr(t,e){return se(t,z([yh,e,Mr(ne([{prefix:"<",parser:FP},{parser:Ol(Jg())}]))],!0))}var VP=Dr("mcdoc:type/any",Et("any",{colorTokenType:"type"})),UP=Dr("mcdoc:type/boolean",Et("boolean",{colorTokenType:"type"})),HP=Ar({pattern:/^(?:0|[-+]?[1-9][0-9]*)$/});function $S(t,e){let r=i=>i.tryPeek("..")||i.tryPeek(`${Rr}..`),n=Er(["..",`..${Rr}`,`${Rr}..`,`${Rr}..${Rr}`],{allowedChars:new Set([".",Rr])});return se(t,ne([{predicate:r,parser:be([n,e])},{parser:be([Tn(e,".."),ne([{predicate:r,parser:be([n,ke(oe(e))])},{parser:Xg}])])}]))}var WP=$S("mcdoc:int_range",HP),fc=ke((t,e)=>t.trySkip("@")?(t.skipWhitespace(),WP(t,e)):V),qP=Dr("mcdoc:type/string",z([Et("string",{colorTokenType:"type"}),fc])),KP=Dr("mcdoc:type/literal",ne([{predicate:t=>t.tryPeek("false")||t.tryPeek("true"),parser:Et(["false","true"],{colorTokenType:"type"})},{prefix:'"',parser:oe(Zs)},{parser:Ol(NS)}])),GP=$S("mcdoc:float_range",DS),ZP=ke((t,e)=>t.trySkip("@")?(t.skipWhitespace(),GP(t,e)):V),JP=Dr("mcdoc:type/numeric_type",ne([{predicate:t=>ph.some(e=>t.tryPeek(e)),parser:z([Et(ph,{colorTokenType:"type"}),ZP])},{parser:z([Et(Kg,{colorTokenType:"type"}),fc])}])),YP=Dr("mcdoc:type/primitive_array",z([Er(Gg),fc,Et("[]",{allowedChars:new Set(["[","]"]),colorTokenType:"type"}),fc])),XP=Dr("mcdoc:type/list",z([fe("["),{get:()=>Rt},Q("]"),fc],!0)),QP=Dr("mcdoc:type/tuple",z([fe("["),{get:()=>Rt},fe(","),ne([{prefix:"]",parser:Q("]")},{parser:z([{get:()=>Rt},Mr(z([fe(","),{get:()=>oe(Rt)}],!0),!0),ke(fe(",")),Q("]")],!0)}])],!0)),eL=Dr("mcdoc:type/dispatcher",z([Ol(Zg({category:"mcdoc/dispatcher"})),Jg()])),tL=Dr("mcdoc:type/union",z([fe("("),ne([{prefix:")",parser:Q(")")},{parser:z([{get:()=>Rt},Mr(z([fe("|"),{get:()=>oe(Rt)}],!0),!0),ke(fe("|")),Q(")")],!0)}])])),rL=Dr("mcdoc:type/reference",z([gh])),Rt=ar([VP,UP,eL,LS,XP,KP,JP,YP,qP,BS,QP,tL,rL]);function zS(t){return`::${t.join("::")}`}var Js=".mcdoc",FS="mcdoc/",VS=(t,e)=>{let r=[];for(let n of t){if(!n.endsWith(Js))continue;let i=Y.getRel(n,e.roots);i&&(i=i.slice(0,-Js.length).replace(/(^|\/)mod$/,""),r.push([n,i]))}r.every(([n,i])=>i.startsWith(FS))&&(r=r.map(([n,i])=>[n,i.slice(FS.length)]));for(let[n,i]of r)e.symbols.query(n,"mcdoc",zS(i.split("/"))).ifKnown(()=>{}).elseEnter({data:{subcategory:"module"},usage:{type:"definition"}})},US=(t,e,r)=>t.endsWith(Js)&&!e.endsWith(Js)?-1:!t.endsWith(Js)&&e.endsWith(Js)?1:r(t,e);var HS=({meta:t})=>{t.registerLanguage("mcdoc",{extensions:[".mcdoc"],parser:jS}),t.registerUriBinder(VS),t.setUriSorter(US),Ug(t),yS(t)};function WS(t){t.registerColorizer("nbt:byte",Ie.number),t.registerColorizer("nbt:short",Ie.number),t.registerColorizer("nbt:int",Ie.number),t.registerColorizer("nbt:long",Ie.number),t.registerColorizer("nbt:float",Ie.number),t.registerColorizer("nbt:double",Ie.number)}var ln={};yr(ln,{byteArray:()=>ty,compound:()=>wi,entry:()=>xi,intArray:()=>ry,list:()=>ey,longArray:()=>ny,path:()=>iy,primitive:()=>Ao,string:()=>Qg});function hr(t){return y(`nbt.node.${t.replace(/^nbt:/,"")}`)}var wi=(t,e)=>se("nbt:compound",Tr({start:"{",pair:{key:oe(pt({...ui,colorTokenType:"property"})),sep:":",value:xi,end:",",trailingEnd:!1},end:"}"}))(t,e);var KS=(2-2**-23)*2**127,oL=[{pattern:/^[-+]?(?:0|[1-9][0-9]*)b$/i,type:"nbt:byte",hasSuffix:!0,group:2,min:-128,max:127},{pattern:/^[-+]?(?:0|[1-9][0-9]*)s$/i,type:"nbt:short",hasSuffix:!0,group:2,min:-32768,max:32767},{pattern:/^[-+]?(?:0|[1-9][0-9]*)$/,type:"nbt:int",hasSuffix:!1,group:2,min:-2147483648,max:2147483647},{pattern:/^[-+]?(?:0|[1-9][0-9]*)l$/i,type:"nbt:long",hasSuffix:!0,group:3,min:-9223372036854775808n,max:9223372036854775807n},{pattern:/^[-+]?(?:[0-9]+\.?|[0-9]*\.[0-9]+)(?:e[-+]?[0-9]+)?f$/i,type:"nbt:float",hasSuffix:!0,group:1,min:-KS,max:KS},{pattern:/^[-+]?(?:[0-9]+\.|[0-9]*\.[0-9]+)(?:e[-+]?[0-9]+)?$/i,type:"nbt:double",hasSuffix:!1,group:1,min:-Number.MAX_VALUE,max:Number.MAX_VALUE},{pattern:/^[-+]?(?:[0-9]+\.?|[0-9]*\.[0-9]+)(?:e[-+]?[0-9]+)?d$/i,type:"nbt:double",hasSuffix:!0,group:1,min:-Number.MAX_VALUE,max:Number.MAX_VALUE},{pattern:/^true$/i,type:"nbt:byte",value:1,group:0},{pattern:/^false$/i,type:"nbt:byte",value:0,group:0}],Qg=ho,Ao=(t,e)=>{if(Ce.isBrigadierQuote(t.peek()))return Qg(t,e);let{result:r,updateSrcAndCtx:n}=Ft(Qg,t,e);for(let i of oL)if(i.pattern.test(r.value)){if(i.group===0){let f={type:"nbt:byte",range:r.range,value:i.value};return n(),f}let o=!1,s=()=>o=!0,a=i.group===2?Ar({pattern:/./,min:i.min,max:i.max,onOutOfRange:s}):i.group===3?El({pattern:/./,min:i.min,max:i.max,onOutOfRange:s}):en({pattern:/./,min:i.min,max:i.max,onOutOfRange:s}),{result:l,updateSrcAndCtx:c}=Ft(a,t,e);if(o){e.err.report(y("nbt.parser.number.out-of-range",hr(i.type),y("nbt.node.string"),i.min,i.max),r,2);break}return c(),i.hasSuffix&&(t.skip(),l.range.end++),{...l,type:i.type}}return n(),r};var xi=(t,e)=>oe(ne([{predicate:r=>r.tryPeek("[B;"),parser:ty},{predicate:r=>r.tryPeek("[I;"),parser:ry},{predicate:r=>r.tryPeek("[L;"),parser:ny},{predicate:r=>r.tryPeek("["),parser:ey},{predicate:r=>r.tryPeek("{"),parser:wi},{parser:Ao}]))(t,e);var ey=(t,e)=>{let n=fi({start:"[",value:xi,sep:",",trailingSep:!1,end:"]"})(t,e);if(n.type="nbt:list",n.valueType=n.children[0]?.value?.type,n.valueType)for(let{value:i}of n.children)i&&i.type!==n.valueType&&e.err.report(y("expected-got",hr(n.valueType),hr(i.type)),i);return n},ty=(t,e)=>{let n=fi({start:"[B;",value:Ao,sep:",",trailingSep:!1,end:"]"})(t,e);n.type="nbt:byte_array";for(let{value:i}of n.children)i&&i.type!=="nbt:byte"&&e.err.report(y("expected-got",y("nbt.node.byte"),hr(i.type)),i);return n},ry=(t,e)=>{let n=fi({start:"[I;",value:Ao,sep:",",trailingSep:!1,end:"]"})(t,e);n.type="nbt:int_array";for(let{value:i}of n.children)i&&i.type!=="nbt:int"&&e.err.report(y("expected-got",y("nbt.node.int"),hr(i.type)),i);return n},ny=(t,e)=>{let n=fi({start:"[L;",value:Ao,sep:",",trailingSep:!1,end:"]"})(t,e);n.type="nbt:long_array";for(let{value:i}of n.children)i&&i.type!=="nbt:long"&&e.err.report(y("expected-got",y("nbt.node.long"),hr(i.type)),i);return n};var iy=(t,e)=>{let r={type:"nbt:path",children:[],range:v.create(t)},n=["filter","key"],i=GS(t),o;for(;o!==t.cursor&&(n.includes(i)||e.err.report(y("expected-got",vn(n.map(ZS),!1,"or"),ZS(i)),t),i!=="end");)o=t.cursor,n=cL[i](r.children,t,e),i=GS(t);return r.range.end=t.cursor,r},sL=(t,e,r)=>(t.push(wi(e,r)),e.trySkip(".")?["key"]:["end"]),aL=(t,e,r)=>{let n={type:"nbt:path/index",children:void 0,range:v.create(e)};if(!e.trySkip("["))throw new Error(`NBT path index parser called at illegal position: \u201C${e.peek()}\u201D at ${e.cursor}`);e.skipSpace();let i=e.peek();return i==="{"?n.children=[wi(e,r)]:i!=="]"&&(n.children=[Ar({pattern:/^-?\d+$/})(e,r)]),e.skipSpace(),e.trySkip("]")||r.err.report(y("expected-got",P("]"),P(e.peek())),e),n.range.end=e.cursor,t.push(n),e.trySkip(".")?["index","key"]:["end","index"]},lL=(t,e,r)=>{let n=pt({colorTokenType:"property",escapable:{},quotes:['"'],unquotable:{blockList:new Set([` +`,"\r"," "," ",'"',"[","]",".","{","}"])}})(e,r);return t.push(n),e.trySkip(".")?["index","key"]:["end","filter","index"]};function GS(t){switch(t.peek()){case"":case" ":case` +`:case"\r":return"end";case"{":return"filter";case"[":return"index";default:return"key"}}function ZS(t){return y(`nbt.node.path.${t}`)}var cL={filter:sL,index:aL,key:lL};var it={};yr(it,{blockStates:()=>vy,compound:()=>n_,definition:()=>r_,enum_:()=>dL,fieldValue:()=>dc,index:()=>t_,path:()=>pL});var JS;(function(t){function e(r){return oy.is(r)||Nr.is(r)||my.is(r)}t.is=e})(JS||(JS={}));var oy;(function(t){function e(r){return sy.is(r)||et.is(r)}t.is=e})(oy||(oy={}));var sy;(function(t){function e(r){return ay.is(r)||hy.is(r)}t.is=e})(sy||(sy={}));var ay;(function(t){function e(r){return ly.is(r)||cy.is(r)||fy.is(r)||uy.is(r)}t.is=e})(ay||(ay={}));var ly;(function(t){function e(r){return r?.type==="nbt:byte"}t.is=e})(ly||(ly={}));var cy;(function(t){function e(r){return r?.type==="nbt:short"}t.is=e})(cy||(cy={}));var fy;(function(t){function e(r){return r?.type==="nbt:int"}t.is=e})(fy||(fy={}));var uy;(function(t){function e(r){return r?.type==="nbt:long"}t.is=e})(uy||(uy={}));var hy;(function(t){function e(r){return dy.is(r)||py.is(r)}t.is=e})(hy||(hy={}));var dy;(function(t){function e(r){return r?.type==="nbt:float"}t.is=e})(dy||(dy={}));var py;(function(t){function e(r){return r?.type==="nbt:double"}t.is=e})(py||(py={}));var Nr;(function(t){function e(r){return r?.type==="nbt:compound"}t.is=e})(Nr||(Nr={}));var my;(function(t){function e(r){return hc.is(r)||gy.is(r)}t.is=e})(my||(my={}));var hc;(function(t){function e(r){return r?.type==="nbt:list"}t.is=e})(hc||(hc={}));var gy;(function(t){function e(r){return yy.is(r)||by.is(r)||ky.is(r)}t.is=e})(gy||(gy={}));var yy;(function(t){function e(r){return r?.type==="nbt:byte_array"}t.is=e})(yy||(yy={}));var by;(function(t){function e(r){return r?.type==="nbt:int_array"}t.is=e})(by||(by={}));var ky;(function(t){function e(r){return r?.type==="nbt:long_array"}t.is=e})(ky||(ky={}));var Ys;(function(t){function e(r){return r?.type==="nbt:path"}t.is=e})(Ys||(Ys={}));var YS;(function(t){function e(r){return r?.type==="nbt:path/index"}t.is=e})(YS||(YS={}));var fL={"minecraft:brain_coral_fan":["minecraft:brain_coral_fan","minecraft:brain_coral_wall_fan"],"minecraft:bubble_coral_fan":["minecraft:bubble_coral_fan","minecraft:bubble_coral_wall_fan"],"minecraft:fire_coral_fan":["minecraft:fire_coral_fan","minecraft:fire_coral_wall_fan"],"minecraft:horn_coral_fan":["minecraft:horn_coral_fan","minecraft:horn_coral_wall_fan"],"minecraft:tube_coral_fan":["minecraft:tube_coral_fan","minecraft:tube_coral_wall_fan"],"minecraft:creeper_head":["minecraft:creeper_head","minecraft:creeper_wall_head"],"minecraft:dragon_head":["minecraft:dragon_head","minecraft:dragon_wall_head"],"minecraft:player_head":["minecraft:player_head","minecraft:player_wall_head"],"minecraft:skeleton_skull":["minecraft:skeleton_skull","minecraft:skeleton_wall_skull"],"minecraft:wither_skeleton_skull":["minecraft:wither_skeleton_skull","minecraft:wither_skeleton_wall_skull"],"minecraft:dead_brain_coral_fan":["minecraft:dead_brain_coral_fan","minecraft:dead_brain_coral_wall_fan"],"minecraft:dead_bubble_coral_fan":["minecraft:dead_bubble_coral_fan","minecraft:dead_bubble_coral_wall_fan"],"minecraft:dead_fire_coral_fan":["minecraft:dead_fire_coral_fan","minecraft:dead_fire_coral_wall_fan"],"minecraft:dead_horn_coral_fan":["minecraft:dead_horn_coral_fan","minecraft:dead_horn_coral_wall_fan"],"minecraft:dead_tube_coral_fan":["minecraft:dead_tube_coral_fan","minecraft:dead_tube_coral_wall_fan"],"minecraft:torch":["minecraft:torch","minecraft:wall_torch"],"minecraft:soul_torch":["minecraft:soul_torch","minecraft:soul_wall_torch"],"minecraft:redstone_torch":["minecraft:redstone_torch","minecraft:redstone_wall_torch"],"minecraft:beetroot_seeds":["minecraft:beetroots"],"minecraft:carrot":["minecraft:carrots"],"minecraft:cocoa_beans":["minecraft:cocoa"],"minecraft:glow_berries":["minecraft:cave_vines"],"minecraft:melon_seeds":["minecraft:melon_stem"],"minecraft:potato":["minecraft:potatoes"],"minecraft:pumpkin_seeds":["minecraft:pumpkin_stem"],"minecraft:redstone":["minecraft:redstone_wire"],"minecraft:string":["minecraft:tripwire"],"minecraft:sweat_berries":["minecraft:sweat_berry_bush"],"minecraft:wheat_seeds":["minecraft:wheat"]};function XS(t){return fL[t]}function QS(t){if(t==="minecraft:armor_stand")return t;let e=t.match(/^minecraft:([a-z0-9_]+)_spawn_egg$/);if(e)return`minecraft:${e[1]}`}var uL={"::minecraft::block::banner::Banner.CustomName":"mcfunction:component","::minecraft::block::brewingstand::BrewingStand.CustomName":"mcfunction:component","::minecraft::block::commandblock::CommandBlock.Command":"mcfunction:command","::minecraft::block::commandblock::CommandBlock.CustomName":"mcfunction:component","::minecraft::block::container::ContainerBase.CustomName":"mcfunction:component","::minecraft::block::enchantingtable::EnchantingTable.CustomName":"mcfunction:component","::minecraft::block::furnace::Furnace.CustomName":"mcfunction:component","::minecraft::block::hopper::Hopper.CustomName":"mcfunction:component","::minecraft::block::sign::Sign.Text1":"mcfunction:component","::minecraft::block::sign::Sign.Text2":"mcfunction:component","::minecraft::block::sign::Sign.Text3":"mcfunction:component","::minecraft::block::sign::Sign.Text4":"mcfunction:component","::minecraft::entity::effectcloud::EffectCloud.Particle":"mcfunction:particle","::minecraft::entity::minecart::CommandMinecart.Command":"mcfunction:command","::minecraft::entity::mob::LivingEntity.Team":"mcfunction:team","::minecraft::entity::EntityBase.Tags[]":"mcfunction:tag","::minecraft::item::blockitem::BlockItem.CanPlaceOn[]":"mcfunction:block_predicate","::minecraft::item::book::WrittenBook.pages[]":"mcfunction:component","::minecraft::item::ItemBase.CanDestroy[]":"mcfunction:block_predicate"};function e_(t){return uL[t]}function t_(t,e,r={}){switch(t){case"custom:blockitemstates":let n=XS(e);return n?vy(n,r):tt.noop;case"custom:blockstates":return vy([e],r);case"custom:spawnitemtag":let i=QS(e);return i?t_("entity_type",i,r):tt.noop;default:let o=hL(t);return o?(s,a)=>{r_(o,r)(s,a)}:tt.noop}}function hL(t){switch(t){case"block":return"::java::server::world::block::BlockEntity";case"entity_type":return"::java::server::world::entity::AnyEntity";case"item":return"::java::server::world::item::AnyItem";default:return}}function r_(t,e={}){return(r,n)=>{let o=n.symbols.query(n.doc,"mcdoc",t).getData(Co.TypeDefSymbolData.is)?.typeDef;if(o)switch(o.kind){case"struct":n_(o,e)(r,n);break;default:n.logger.error(`[nbt.checker.definition] Expected a struct type, but got ${o.kind}`)}}}function vy(t,e={}){return(r,n)=>{let i=Ga("block",t,n);for(let{key:o,value:s}of r.children)if(!(!o||!s)){if(s.type==="nbt:byte"&&(n.src.slice(s.range).toLowerCase()==="false"||n.src.slice(s.range).toLowerCase()==="true")){n.err.report(y("nbt.checker.block-states.fake-boolean"),s,2);continue}else if(s.type!=="string"&&s.type!=="nbt:int"){n.err.report(y("nbt.checker.block-states.unexpected-value-type"),s,2);continue}if(Object.keys(i).includes(o.value)){let a=i[o.value];a.includes(s.value.toString())||n.err.report(y("expected-got",a,P(s.value.toString())),s,2)}else n.err.report(y("nbt.checker.block-states.unknown-state",P(o.value),t),o,2)}}}function n_(t,e={}){return(r,n)=>{for(let{key:i,value:o}of r.children){if(!i||!o)continue;let s=i.value,a=t.fields.find(l=>l.kind==="pair"&&l.key===s);a?dc(a.type,e)(o,n):e.allowUnknownKey||n.err.report(y("unknown-key",P(s)),i,2)}}}function dL(t,e={}){return t?(r,n)=>{}:tt.noop}function pL(t,e){return(r,n)=>{}}function dc(t,e){let r=(i,{kind:o,min:s=-1/0,max:a=1/0})=>{let l=(c,f,u)=>u?c{if(t.kind!=="any"&&t.kind!=="dispatcher"&&t.kind!=="enum"&&t.kind!=="literal"&&t.kind!=="reference"&&t.kind!=="union"&&t.kind!=="attributed"&&t.kind!=="unsafe"&&t.kind!=="concrete"&&t.kind!=="indexed"&&t.kind!=="template"&&i.type!==n[t.kind]){o.err.report(y("expected",hr(n[t.kind])),i,2);return}switch(t.kind){case"boolean":i=i,i.value!==0&&i.value!==1&&o.err.report(y("nbt.checker.boolean.out-of-range",P("0b"),P("1b")),i,2);break;case"byte_array":case"int_array":case"long_array":if(i=i,t.lengthRange&&!r(i.children.length,t.lengthRange)&&o.err.report(y("expected",y("nbt.checker.collection.length-between",hr(i.type),t.lengthRange.min??"-\u221E",t.lengthRange.max??"+\u221E")),i,2),t.valueRange)for(let{value:l}of i.children)l&&!r(Number(l.value),t.valueRange)&&o.err.report(y("number.between",t.valueRange.min??"-\u221E",t.valueRange.max??"+\u221E"),i,2);break;case"byte":case"short":case"int":case"long":case"float":case"double":i=i,t.valueRange&&!r(Number(i.value),t.valueRange)&&o.err.report(y("number.between",t.valueRange.min??"-\u221E",t.valueRange.max??"+\u221E"),i,2);break;case"dispatcher":i=i;break;case"list":i=i,t=cc(t),t.lengthRange&&!r(i.children.length,t.lengthRange)&&o.err.report(y("expected",y("nbt.checker.collection.length-between",hr(i.type),t.lengthRange.min??"-\u221E",t.lengthRange.max??"+\u221E")),i,2);for(let{value:l}of i.children)l&&dc(t.item,e)(l,o);break;case"string":i=i;let s="",a=i;if(uu.is(i.parent)&&hc.is(i.parent.parent)&&(s="[]",a=i.parent.parent),kn.is(a.parent)){let l=a.parent.key?.symbol?.parentSymbol?.path.join("::"),c=a.parent.key?.value,f=`${l}.${c}${s}`,u=e_(f);if(u)try{let h=o.meta.getParser(u),d=uo(h,i.value,i.valueMap,o);d!==V&&(i.children=[d],d.parent=i)}catch(h){o.logger.error("[nbt.checker.fieldValue#string]",h)}}break;case"reference":i=i;break;case"union":t=Gs(t),t.members.length===0?o.err.report(y("nbt.checker.compound.field.union-empty-members"),kn.is(i.parent)?i.parent.key??i.parent:i,2):tt.any(t.members.map(l=>dc(l,e)))(i,o);break;case"attributed":dc(t.child,e)(i,o);break}}}var i_=({meta:t})=>{t.registerLanguage("nbt",{extensions:[".snbt"],parser:xi}),t.registerParser("nbt:entry",xi),t.registerParser("nbt:compound",wi),t.registerParser("nbt:path",iy),WS(t)};var ot;(function(t){function e(r,n){return Math.sign(Number(r.slice(2))-Number(n.slice(2)))}t.cmp=e})(ot||(ot={}));var xy={5:/^1\.15.*$/,6:/^1\.16.*$/,7:/^1\.17.*$/,8:/^1\.18(\.1)?$/,9:/^1\.18.*$/,10:/^1\.19(\.[1-3])?$/,12:/^1\.19.*$/,15:/^1\.20(\.1)?$/,18:/^1\.20\.2$/,26:/^1\.20\.[3-4]$/,41:/^1\.20\.[5-6]$/},kh;(function(t){function e(r){let n=r?.pack?.pack_format?.toString();if(!n)throw new Error("\u201Cpack.pack_format\u201D undefined");if(!Object.keys(xy).includes(n))throw new Error(`Unknown pack_format \u201C${n}\u201D`)}t.assert=e})(kh||(kh={}));function o_(t,{packMcmeta:e,versions:r}){function n(i){i<0&&(i=0);let o=r[i];return{id:o.id,name:o.name,release:o.release_target??"1.99",isLatest:i===0}}if(r.length===0)throw new Error("mcmeta version list is empty");if(t=t.toLowerCase(),r=r.sort((i,o)=>o.data_version-i.data_version),t==="auto"){if(e){let i=xy[e.pack.pack_format];if(i)return n(r.findIndex(o=>i.test(o.release_target)))}return n(0)}else{if(t==="latest release")return n(r.findIndex(i=>i.type==="release"));if(t==="latest snapshot")return n(r.findIndex(i=>i.type==="snapshot"))}return n(r.findIndex(i=>t===i.id.toLowerCase()||t===i.name.toLowerCase()))}var mL={fastly:"https://fastly.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}",github:"https://raw.githubusercontent.com/${user}/${repo}/${tag}/${path}",jsdelivr:"https://cdn.jsdelivr.net/gh/${user}/${repo}@${tag}/${path}"};function s_(t,e,r){let n=e?"summary":`${t}-summary`;function i(o){let a=(mL[r.toLowerCase()]??r).replace(/\${user}/g,"misode").replace(/\${repo}/g,"mcmeta").replace(/\${tag}/g,n).replace(/\${path}/g,o);if(!Ew.is(a))throw new Error(`Expected a remote URI from data source template but got ${a}`);return a}return{blocks:i("blocks/data.json.gz"),commands:i("commands/data.json.gz"),registries:i("registries/data.json.gz")}}function a_(t){let e="mcmeta://summary/registries.json";function r(i,o,s){let a=`${i[0].toUpperCase()}${i.slice(1)}`;for(let[l,[c,f]]of Object.entries(o)){let u=e;s.query(u,i,q.lengthen(l)).onEach(Object.entries(c),([h,d],p)=>{let b=f[h];p.member(`${u}#${a}_states`,h,m=>{m.enter({data:{subcategory:"state"},usage:{type:"declaration"}}).onEach(d,k=>{m.member(k,S=>{S.enter({data:{subcategory:"state_value"},usage:{type:"declaration"}}),k===b&&m.amend({data:{relations:{default:{category:i,path:S.path}}}})})})})})}}function n(i,o){function s(a){return hs.includes(a)||Gi.includes(a)}for(let[a,l]of Object.entries(i))if(s(a))for(let c of l)o.query(e,a,q.lengthen(c)).enter({usage:{type:"declaration"}})}return i=>{n(t.registries,i),r("block",t.blocks,i),r("fluid",t.fluids,i)}}var l_={flowing_lava:[{falling:["false","true"],level:["1","2","3","4","5","6","7","8"]},{falling:"false",level:"1"}],flowing_water:[{falling:["false","true"],level:["1","2","3","4","5","6","7","8"]},{falling:"false",level:"1"}],lava:[{falling:["false","true"]},{falling:"false"}],water:[{falling:["false","true"]},{falling:"false"}]};var vh=15e3;async function c_(t,e){return e.download({id:"mc-je/versions.json.gz",uri:"https://raw.githubusercontent.com/misode/mcmeta/summary/versions/data.json.gz",transformer:r=>ym(t,r),cache:Sy("misode","mcmeta","refs/heads/summary"),ttl:vh})}async function f_(t,e,r,n,i,o,s={}){let a=gL({defaultBranch:"summary",getTag:m=>`${m}-summary`,isLatest:i,version:n}),l=s_(n,i,o),c;async function f(m,k){if(k)try{let S=await Y.readJson(t,k.path);return k.replace?S:Ka(m,S)}catch(S){r.error(`[je] [mcmeta-overrides] Failed loading customized mcmeta summary file \u201C${k.path}\u201D`,S)}return m}let u=async(m,k)=>{let S={},_=await e.download({id:`mc-je/${n}/${m}.json.gz`,uri:l[m],transformer:w=>ym(t,w),cache:Sy("misode","mcmeta",a),ttl:vh},S);return c||=S.checksum,f(_,k)},[h,d,p,b]=[await u("blocks",s.blocks),await u("commands",s.commands),await f(l_,s.fluids),await u("registries",s.registries)];return{blocks:h,commands:d,fluids:p,registries:b,checksum:c}}function gL({defaultBranch:t,getTag:e,isLatest:r,version:n}){return r?`refs/heads/${t}`:`refs/tags/${e(n)}`}var u_={headers:{Accept:"application/vnd.github.v3+json","User-Agent":"SpyglassMC"}};function Sy(t,e,r){return{checksumExtension:".commit-sha",checksumJob:{uri:`https://api.github.com/repos/${t}/${e}/git/${r}`,transformer:n=>{let i=JSON.parse(ir(n));if(Array.isArray(i))return i[0].object.sha;if(i.message===void 0)return i.object.sha;throw new Error(i.message)},options:u_,ttl:vh}}}async function h_(t){let e="SpyglassMC",r="vanilla-mcdoc",n="refs/heads/main",i={};return await t.download({id:"mc-je/vanilla-mcdoc.tar.gz",uri:`https://api.github.com/repos/${e}/${r}/tarball/${n}`,transformer:o=>o,cache:Sy(e,r,n),options:u_,ttl:vh},i),{info:{startDepth:1},uri:i.cacheUri}}var bL=(()=>{let t=new Set(["block","fluid","function","game_event","item","worldgen/block_placer_type","worldgen/surface_builder"]),e=new Map([["advancements",{category:"advancement",extname:".json"}],["dimension",{category:"dimension",extname:".json",since:"1.16"}],["dimension_type",{category:"dimension_type",extname:".json",since:"1.16"}],["functions",{category:"function",extname:".mcfunction"}],["item_modifiers",{category:"item_modifier",extname:".json",since:"1.17"}],["loot_tables",{category:"loot_table",extname:".json"}],["predicates",{category:"predicate",extname:".json"}],["recipes",{category:"recipe",extname:".json"}],["tags/blocks",{category:"tag/block",extname:".json"}],["tags/entity_types",{category:"tag/entity_type",extname:".json"}],["tags/fluids",{category:"tag/fluid",extname:".json"}],["tags/functions",{category:"tag/function",extname:".json"}],["tags/game_events",{category:"tag/game_event",extname:".json",since:"1.17"}],["tags/items",{category:"tag/item",extname:".json"}],["worldgen/biome",{category:"worldgen/biome",extname:".json",since:"1.16"}],["worldgen/configured_carver",{category:"worldgen/configured_carver",extname:".json",since:"1.16"}],["worldgen/configured_feature",{category:"worldgen/configured_feature",extname:".json",since:"1.16"}],["worldgen/configured_structure_feature",{category:"worldgen/configured_structure_feature",extname:".json",since:"1.16"}],["worldgen/configured_surface_builder",{category:"worldgen/configured_surface_builder",extname:".json",since:"1.16",until:"1.17"}],["worldgen/density_function",{category:"worldgen/density_function",extname:".json",since:"1.18"}],["worldgen/noise",{category:"worldgen/noise",extname:".json",since:"1.18"}],["worldgen/noise_settings",{category:"worldgen/noise_settings",extname:".json",since:"1.16"}],["worldgen/placed_feature",{category:"worldgen/placed_feature",extname:".json",since:"1.18"}],["worldgen/processor_list",{category:"worldgen/processor_list",extname:".json",since:"1.16"}],["worldgen/template_pool",{category:"worldgen/template_pool",extname:".json",since:"1.16"}]]);for(let r of Rm)t.has(r)||e.set(`tags/${r}`,{category:`tag/${r}`,extname:".json",since:"1.18"});return e})();function*kL(t,e){yield*Y.getRels(t,e);let r=t.split("/");for(let n=r.length-2;n>=0;n--)r[n]==="data"&&(yield r.slice(n).join("/"))}function _y(t,e){let r=/^data\/([^\/]+)\/((?:tags\/|worldgen\/)?[a-z_]+)\/(.*)(\.(?:mcfunction|json))$/,n=kL(t,e.roots);for(let i of n){let o=i.match(r);if(!o)continue;let s=bL.get(o[2]);if(!s||s.extname!==o[4])continue;let a=e.project.loadedVersion;if(!(!a||!vL(a,s.since,s.until)))return{category:s.category,namespace:o[1],identifier:o[3]}}}var d_=(t,e)=>{for(let r of t){let n=_y(r,e);n&&e.symbols.query(r,n.category,`${n.namespace}:${n.identifier}`).enter({usage:{type:"definition"}})}};function vL(t,e,r){return!(e&&ot.cmp(t,e)<0||r&&ot.cmp(r,t)<0)}var wL=t=>[Te.create(t,"literal")],xL=t=>[Te.create(t,"literal")],SL=(t,e)=>{let r=[];for(let n of t.children)if(n.key&&r.push(Te.create(n.key,"property")),n.value){let i=e.meta.getColorizer(n.value.type);r.push(...i(n.value,e))}return r};function p_(t){t.registerColorizer("json:boolean",wL),t.registerColorizer("json:null",xL),t.registerColorizer("json:number",Ie.number),t.registerColorizer("json:object",SL),t.registerColorizer("json:string",Ie.string)}var mc={};yr(mc,{JsonStringOptions:()=>wh,array:()=>Ty,entry:()=>Si,json:()=>b_,number:()=>Cy,object:()=>Ay,string:()=>pc});var g_=(t,e)=>{let r=t.cursor;return t.trySkip("false")?{type:"json:boolean",range:v.create(r,t),value:!1}:t.trySkip("true")?{type:"json:boolean",range:v.create(r,t),value:!0}:V};var y_=(t,e)=>{let r=t.cursor;return t.trySkip("null")?{type:"json:null",range:v.create(r,t)}:V};var Cy=(t,e)=>{let n=en({pattern:/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?$/})(t,e);return n.type="json:number",n};var wh={escapable:{characters:["b","f","n","r","t"],unicode:!0},quotes:['"']},pc=(t,e)=>{let n=pt(wh)(t,e);return n.type="json:string",n};var Ay=(t,e)=>se("json:object",Tr({start:"{",pair:{key:pc,sep:":",value:Si,end:",",trailingEnd:!1},end:"}"}))(t,e);var _L=new Set(["0","1","2","3","4","5","6","7","8","9","-"]);function b_(t=!1){return(e,r)=>{let n=ne([{predicate:i=>i.tryPeek("["),parser:Ty},{predicate:i=>i.tryPeek("false")||i.tryPeek("true"),parser:g_},{predicate:i=>i.tryPeek("null"),parser:y_},{predicate:i=>_L.has(i.peek()),parser:Cy},{predicate:i=>i.tryPeek("{"),parser:Ay},{parser:pc}])(e,r);return t&&r.err.dump(),n}}var Si=b_(!0);var Ty=(t,e)=>{let n=fi({start:"[",value:Si,sep:",",trailingSep:!1,end:"]"})(t,e);return n.type="json:array",n};var xh;(function(t){function e(n){return Pr.is(n)||Oo.is(n)||dr.is(n)||Xs.is(n)||gc.is(n)||Ey.is(n)}t.is=e;function r(n){return t.is(n)||Oy.is(n)||Ry.is(n)}t.isRelated=r})(xh||(xh={}));var To;(function(t){function e(i){return i.type==="json:array"}t.isArray=e;function r(i){return i.type==="json:object"}t.isObject=r;function n(i){return i.type==="json:string"}t.isString=n})(To||(To={}));var Pr;(function(t){function e(n){return n?.type==="json:object"}t.is=e;function r(n){return{type:"json:object",range:v.get(n),children:[]}}t.mock=r})(Pr||(Pr={}));var Oy;(function(t){function e(r){return r.type==="pair"}t.is=e})(Oy||(Oy={}));var Oo;(function(t){function e(n){return n?.type==="json:array"}t.is=e;function r(n){return{type:"json:array",range:v.get(n),children:[]}}t.mock=r})(Oo||(Oo={}));var Ry;(function(t){function e(r){return r.type==="item"}t.is=e})(Ry||(Ry={}));var Sh;(function(t){function e(r){return r.type==="json:string"}t.is=e})(Sh||(Sh={}));var dr;(function(t){function e(n){return n?.type==="json:string"}t.is=e;function r(n){return{...et.mock(n,wh),type:"json:string"}}t.mock=r})(dr||(dr={}));var Xs;(function(t){function e(r){return r.type==="json:number"}t.is=e})(Xs||(Xs={}));var gc;(function(t){function e(r){return r.type==="json:boolean"}t.is=e})(gc||(gc={}));var Ey;(function(t){function e(r){return r.type==="json:null"}t.is=e})(Ey||(Ey={}));var k_=[` +`,":",'"'],My={"json:object":"{$1}","json:array":"[$1]","json:string":'"$1"',"json:boolean":"${1|false,true|}","json:number":"${1:0}"},CL=(t,e)=>re.dispatch(t,e),AL=re.record({key:(t,e,r,n,i,o)=>t.expectation?bc(t.expectation.filter(To.isObject).flatMap(s=>EL(n,t,s,r,i,o,e?.key?.value))):[],value:(t,e,r)=>e.value&&!v.isEmpty(e.value)?re.dispatch(e.value,r):t.expectation?bc(t.expectation.filter(To.isObject).filter(n=>n.fields).map(n=>n.fields.find(i=>i.key===e.key?.value)).flatMap(n=>v_(r.offset,n.value,r))):[]}),TL=(t,e)=>{let r=Iw(t.children,e.offset,(i,o)=>i.sep?v.compareOffset(v.translate(i,0,-1),o,!0):v.compareOffset(i.range,o,!0)),n=r>=0?t.children[r]:void 0;return n?.value?re.dispatch(n.value,e):t.expectation&&v.contains(v.translate(t,1,-1),e.offset,!0)?bc(t.expectation.filter(To.isArray).filter(i=>i.items).flatMap(i=>v_(e.offset,i.items,e))):[]},OL=t=>["false","true"].map(e=>yc(t,e)),RL=(t,e)=>t.children?.length?re.string(t,e):t.expectation?bc(t.expectation.filter(To.isString).flatMap(r=>Dy(t,r,e))):[];function EL(t,e,r,n,i,o,s){return r.fields?r.fields.filter(a=>a.key===s||!e.children.find(l=>a.key===l.key?.value)).map(a=>ML(t,a,i,o)):r.keys?r.keys.flatMap(a=>Dy(t,a,n).map(l=>({...l,...i?{insertText:`${l.insertText}: ${o?",":""}`}:{}}))):[]}function ML(t,e,r,n){let i=e.value?.[0]?My[e.value[0].type]:"";return pe.create(e.key,t,{kind:10,detail:e.value?.map(o=>o.typedoc).join(" | "),sortText:`${e.deprecated?2:e.opt?1:0}${e.key}`,deprecated:e.deprecated,filterText:`"${e.key}"`,insertText:`"${e.key}"${r?`: ${i}`:""}${n?",":""}`})}function v_(t,e,r){return bc(e.flatMap(n=>{switch(n.type){case"json:object":case"json:array":return[yc(t,My[n.type])];case"json:string":return Dy(r.offset,n,r);case"json:boolean":return["false","true"].map(i=>yc(t,i));case"json:number":return[yc(t,"0")]}}))}function Dy(t,e,r){return Array.isArray(e.pool)?e.pool.map(n=>pe.create(n,t,{kind:12,filterText:`"${n}"`,insertText:`"${n}"`})):[yc(t,My[e.type])]}function yc(t,e){return pe.create(e.replace("$1",""),t,{kind:12,insertText:e})}function bc(t){let e=[],r=new Set;return t.forEach(n=>{r.has(n.label)||(r.add(n.label),e.push(n))}),e}function w_(t){t.registerCompleter("json:entry",CL),t.registerCompleter("json:array",TL),t.registerCompleter("json:boolean",OL),t.registerCompleter("json:object",AL),t.registerCompleter("json:string",RL)}var DL=(t,e)=>t.children.length===0?"[]":`[ +${t.children.map(n=>{let i=n.value&&e.meta.getFormatter(n.value.type)(n.value,zm(e));return`${e.indent(1)}${i??""}`}).join(`, `)} -${e.indent()}]`,EL=(t,e)=>t.children.length===0?"{}":`{ -${t.children.map(n=>{let i=n.key&&Xr.string(n.key,e),o=n.value&&e.meta.getFormatter(n.value.type)(n.value,Bm(e));return`${e.indent(1)}${i??""}: ${o??""}`}).join(`, +${e.indent()}]`,NL=(t,e)=>t.children.length===0?"{}":`{ +${t.children.map(n=>{let i=n.key&&Xr.string(n.key,e),o=n.value&&e.meta.getFormatter(n.value.type)(n.value,zm(e));return`${e.indent(1)}${i??""}: ${o??""}`}).join(`, `)} -${e.indent()}}`;function v_(t){t.registerFormatter("json:array",RL),t.registerFormatter("json:boolean",Xr.boolean),t.registerFormatter("json:null",()=>"null"),t.registerFormatter("json:number",Xr.float),t.registerFormatter("json:object",EL),t.registerFormatter("json:string",Xr.string)}function _i(t,e){t.expectation=[{type:"json:boolean",typedoc:"Boolean"}],gc.is(t)||e.err.report(y("expected",y("boolean")),t)}function x_(t){return(e,r)=>t()(e,r)}function Ey(t,e){return(r,n)=>{e(r,{...n,context:t})}}function ML(t,e,r){let n={...r,err:new ut,symbols:r.symbols.clone()};t(e,n);let i=e.expectation;return Qe.undoChanges(e),{totalErrorSpan:n.err.errors.map(s=>s.range.end-s.range.start).reduce((s,a)=>s+a,0),maxSeverity:Math.max(...n.err.errors.map(s=>s.severity)),expectation:i,updateNodeAndCtx:()=>{r.err.absorb(n.err),Qe.redoChanges(e),n.symbols.applyDelayedEdits()}}}function Qs(t=[]){return(e,r)=>{if(t.length===0)return;let n=t.map(s=>ML(s,e,r)).sort((s,a)=>s.maxSeverity-a.maxSeverity||s.totalErrorSpan-a.totalErrorSpan),i=n.filter(s=>s.expectation?.map(a=>a.type).includes(e.type)),o=n.filter(s=>s.expectation).flatMap(s=>s.expectation);if(i.length===0){let s=o.map(a=>y(a.type.slice(5)));r.err.report(y("expected",vn(s,!1)),e)}else i[0].updateNodeAndCtx();e.expectation=o}}function kc(t,e){let r=Qe.create({type:"json:null",range:v.create(0)}),n={...e,err:new ut,depth:(e.depth??0)+1};return t(r,n),r.expectation}function vc(t){return(e,r)=>{e.expectation=[{type:"json:array",typedoc:"Array"}],(!r.depth||r.depth<=0)&&(e.expectation[0].items=kc(t,r)),Oo.is(e)?e.children.filter(n=>n.value).forEach(n=>t(n.value,r)):r.err.report(y("expected",y("array")),e)}}var _h=t=>(e,r)=>(n,i)=>{let o="Number"+(e===void 0&&r===void 0?"":`(${e??"-\u221E"}, ${r??"+\u221E"})`);n.expectation=[{type:"json:number",typedoc:o}],!Xs.is(n)||t==="integer"&&!Number.isInteger(n.value)?i.err.report(y("expected",y(t)),n):e!==void 0&&r!==void 0&&(n.valuer)?i.err.report(y("expected",y("number.between",e,r)),n):e!==void 0&&n.value=",e)),n):r!==void 0&&n.value>r&&i.err.report(y("expected",y("number.<=",r)),n)},S_=_h("integer")(void 0,void 0),xV=_h("float")(void 0,void 0),DL=_h("integer"),SV=_h("float");function Et(t){return t?.checker!==void 0}function __(t,e,r={}){return(n,i)=>{if(n.expectation=[{type:"json:object",typedoc:"Object"}],!i.depth||i.depth<=0)if(Array.isArray(t)&&e){let o=t.map(s=>[s,e(s,i)]).filter(([s,a])=>a!==void 0);n.expectation[0].fields=o.map(([s,a])=>({key:s,value:kc(Et(a)?a.checker:a,i),...Et(a)&&(a.opt||a.deprecated)?{opt:!0}:{},...Et(a)&&a.deprecated?{deprecated:!0}:{}}))}else typeof t=="function"&&e&&(n.expectation[0].keys=kc(t,i)?.filter(Sh.is));if(!Pr.is(n))i.err.report(y("expected",y("object")),n);else if(Array.isArray(t)&&e){let o=n.children.map(s=>s.key?.value);t.forEach(s=>{let a=e(s,i);!a||Et(a)&&(a.opt||a.deprecated)||o.includes(s)||i.err.report(y("json.checker.property.missing",P(s)),v.create(n.range.start,n.range.start+1))}),n.children.filter(s=>s.key).forEach(s=>{let a=s.key.value,l=e(a,i);if(!l||!t.includes(a)){r.allowUnknownProperties||i.err.report(y("json.checker.property.unknown",P(a)),s.key,2);return}Et(l)&&l.deprecated&&i.err.report(y("json.checker.property.deprecated",P(a)),s.key,0,{deprecated:!0});let c=i.context+(Et(l)&&l.context?`.${l.context}`:""),f=y(`json.doc.${c}`),u=s.value!==void 0?s.value:{type:"json:null",range:v.create(0)},h=Et(l)?l.checker:l;try{h(u,{...i,context:`${c}.${a}`})}catch(b){let m=i.doc.positionAt(s.range.start);i.logger.error(`Checking "${a}" at ${m.line}:${m.character} in "${i.doc.uri}"`,b)}let d=Et(l)?l.def:void 0,p=u.expectation?.map(b=>b.typedoc).join(" | ");s.key.hover=`\`\`\`typescript +${e.indent()}}`;function S_(t){t.registerFormatter("json:array",DL),t.registerFormatter("json:boolean",Xr.boolean),t.registerFormatter("json:null",()=>"null"),t.registerFormatter("json:number",Xr.float),t.registerFormatter("json:object",NL),t.registerFormatter("json:string",Xr.string)}function _i(t,e){t.expectation=[{type:"json:boolean",typedoc:"Boolean"}],gc.is(t)||e.err.report(y("expected",y("boolean")),t)}function C_(t){return(e,r)=>t()(e,r)}function Ny(t,e){return(r,n)=>{e(r,{...n,context:t})}}function PL(t,e,r){let n={...r,err:new ht,symbols:r.symbols.clone()};t(e,n);let i=e.expectation;return Qe.undoChanges(e),{totalErrorSpan:n.err.errors.map(s=>s.range.end-s.range.start).reduce((s,a)=>s+a,0),maxSeverity:Math.max(...n.err.errors.map(s=>s.severity)),expectation:i,updateNodeAndCtx:()=>{r.err.absorb(n.err),Qe.redoChanges(e),n.symbols.applyDelayedEdits()}}}function Qs(t=[]){return(e,r)=>{if(t.length===0)return;let n=t.map(s=>PL(s,e,r)).sort((s,a)=>s.maxSeverity-a.maxSeverity||s.totalErrorSpan-a.totalErrorSpan),i=n.filter(s=>s.expectation?.map(a=>a.type).includes(e.type)),o=n.filter(s=>s.expectation).flatMap(s=>s.expectation);if(i.length===0){let s=o.map(a=>y(a.type.slice(5)));r.err.report(y("expected",vn(s,!1)),e)}else i[0].updateNodeAndCtx();e.expectation=o}}function kc(t,e){let r=Qe.create({type:"json:null",range:v.create(0)}),n={...e,err:new ht,depth:(e.depth??0)+1};return t(r,n),r.expectation}function vc(t){return(e,r)=>{e.expectation=[{type:"json:array",typedoc:"Array"}],(!r.depth||r.depth<=0)&&(e.expectation[0].items=kc(t,r)),Oo.is(e)?e.children.filter(n=>n.value).forEach(n=>t(n.value,r)):r.err.report(y("expected",y("array")),e)}}var _h=t=>(e,r)=>(n,i)=>{let o="Number"+(e===void 0&&r===void 0?"":`(${e??"-\u221E"}, ${r??"+\u221E"})`);n.expectation=[{type:"json:number",typedoc:o}],!Xs.is(n)||t==="integer"&&!Number.isInteger(n.value)?i.err.report(y("expected",y(t)),n):e!==void 0&&r!==void 0&&(n.valuer)?i.err.report(y("expected",y("number.between",e,r)),n):e!==void 0&&n.value=",e)),n):r!==void 0&&n.value>r&&i.err.report(y("expected",y("number.<=",r)),n)},A_=_h("integer")(void 0,void 0),CV=_h("float")(void 0,void 0),LL=_h("integer"),AV=_h("float");function Mt(t){return t?.checker!==void 0}function T_(t,e,r={}){return(n,i)=>{if(n.expectation=[{type:"json:object",typedoc:"Object"}],!i.depth||i.depth<=0)if(Array.isArray(t)&&e){let o=t.map(s=>[s,e(s,i)]).filter(([s,a])=>a!==void 0);n.expectation[0].fields=o.map(([s,a])=>({key:s,value:kc(Mt(a)?a.checker:a,i),...Mt(a)&&(a.opt||a.deprecated)?{opt:!0}:{},...Mt(a)&&a.deprecated?{deprecated:!0}:{}}))}else typeof t=="function"&&e&&(n.expectation[0].keys=kc(t,i)?.filter(Sh.is));if(!Pr.is(n))i.err.report(y("expected",y("object")),n);else if(Array.isArray(t)&&e){let o=n.children.map(s=>s.key?.value);t.forEach(s=>{let a=e(s,i);!a||Mt(a)&&(a.opt||a.deprecated)||o.includes(s)||i.err.report(y("json.checker.property.missing",P(s)),v.create(n.range.start,n.range.start+1))}),n.children.filter(s=>s.key).forEach(s=>{let a=s.key.value,l=e(a,i);if(!l||!t.includes(a)){r.allowUnknownProperties||i.err.report(y("json.checker.property.unknown",P(a)),s.key,2);return}Mt(l)&&l.deprecated&&i.err.report(y("json.checker.property.deprecated",P(a)),s.key,0,{deprecated:!0});let c=i.context+(Mt(l)&&l.context?`.${l.context}`:""),f=y(`json.doc.${c}`),u=s.value!==void 0?s.value:{type:"json:null",range:v.create(0)},h=Mt(l)?l.checker:l;try{h(u,{...i,context:`${c}.${a}`})}catch(b){let m=i.doc.positionAt(s.range.start);i.logger.error(`Checking "${a}" at ${m.line}:${m.character} in "${i.doc.uri}"`,b)}let d=Mt(l)?l.def:void 0,p=u.expectation?.map(b=>b.typedoc).join(" | ");s.key.hover=`\`\`\`typescript ${c}.${a}: ${p} \`\`\`${f||d!==void 0?` ****** `:""}${f}${d!==void 0?` -\`@default\` ${JSON.stringify(d)}`:""}`})}else typeof t=="function"&&e&&n.children.filter(o=>o.key).forEach(o=>{if(t(o.key,i),o.value!==void 0){let s=e(o.key.value,i);s&&(Et(s)?s.checker:s)(o.value,i)}})}}function Dn(t,e){return __(Object.keys(t),r=>t[r],e)}function le(t,e){if(t!==void 0)return Et(t)?{...t,opt:!0,def:e}:{checker:t,opt:!0,def:e}}function C_(t){if(t!==void 0)return Et(t)?{...t,deprecated:!0}:{checker:t,deprecated:!0}}function Ch(t,e){return(r,n)=>{if(!Pr.is(r))n.err.report(y("expected",y("object")),r);else if(e){let i=r.children.findIndex(a=>a.key?.value===t),o=r.children[i],s=o?.value?.type==="json:string"?o.value.value:void 0;e(s,r.children,n)(r,n)}else t(r.children,n)(r,n)}}function My(t,e){if(t===void 0)return{};let r=e[q.shorten(t)];return r===void 0?{}:(Object.keys(r).forEach(n=>{let i=r[n];i!==void 0&&(r[n]={checker:Et(i)?i.checker:i,opt:Et(i)?i.opt:void 0,deprecated:Et(i)?i.deprecated:void 0,context:q.shorten(t)})}),r)}function A_(t,e){let r=e?.find(n=>n.key?.value===t);return r?.value?.type==="json:string"?r.value.value:void 0}function Dy(t,e,r){let n=new Set(Pr.is(t)?t.children.map(s=>s.key?.value):[]),i=Object.keys(r).find(s=>n.has(s));if(i===void 0)return e.err.report(y("json.checker.property.missing",Object.keys(r)),v.create(t.range.start,t.range.start+1)),Object.fromEntries(Object.entries(r).map(([s,a])=>[s,le(typeof a=="function"?Qs():a[s]??Qs())]));let o=r[i];return typeof o=="function"?o():o}function wc(t,e=!1){return wt(t,Re(typeof t=="string"?{category:t,allowTag:e}:{pool:t.map(q.lengthen)}),tt.resourceLocation)}function ea(t){return typeof t=="string"?wt(t,Bs(t)):wt(t,Oe(...t))}function wt(t,e,r,n){return(i,o)=>{if(i.expectation=[{type:"json:string",typedoc:NL(t),...n}],!dr.is(i))o.err.report(y("expected",y("string")),i);else if(e){let s=uo(Zn.resolve(e),i.value,i.valueMap,o);s!==V&&(i.children=[s],s.parent=i,r&&Zn.resolve(r)(s,o))}else r&&Zn.resolve(r)(i,o)}}function NL(t){return t?typeof t=="string"?`String("${t}")`:t.slice(0,10).map(e=>`"${e}"`).join(" | ")+(t.length>10?" | ...":""):"String"}var Ee=wt();var T_=({meta:t})=>{t.registerLanguage("json",{extensions:[".json",".mcmeta"],triggerCharacters:g_,parser:Si}),t.registerParser("json:entry",Si),u_(t),b_(t),v_(t)};var O_=new Map([["advancement","::java::data::advancement::Advancement"],["dimension","::java::data::worldgen::dimension::Dimension"],["dimension_type","::java::data::worldgen::dimension::DimensionType"],["item_modifier","::java::data::item_modifier::ItemModifier"],["loot_table","::java::data::loot::LootTable"],["predicate","::java::data::predicate::Predicate"],["recipe","::java::data::recipe::Recipe"],["worldgen/biome","::java::data::worldgen::biome::Biome"],["worldgen/configured_carver","::java::data::worldgen::carver::ConfiguredCarver"],["worldgen/configured_surface_builder","::java::data::worldgen::surface_builder::ConfiguredSurfaceBuilder"],["worldgen/configured_feature","::java::data::feature::ConfiguredFeature"],["worldgen/configured_structure_feature","::java::data::worldgen::structure::Structure"],["worldgen/density_function","::java::data::worldgen::density_function::DensityFunction"],["worldgen/noise","::java::data::worldgen::dimension::biome_source::NoiseParameters"],["worldgen/noise_settings","::java::data::worldgen::noise_settings::NoiseGeneratorSettings"],["worldgen/processor_list","::java::data::worldgen::processor_list::ProcessorList"],["worldgen/template_pool","::java::data::worldgen::template_pool::TemplatePool"]]),ta=(t,e)=>{let r=wy(e.doc.uri,e);if(r&&O_.has(r.category)){let n=O_.get(r.category);return R_(n)(t,e)}else if(!r?.category.startsWith("tag/"))return e.doc.uri.endsWith("/pack.mcmeta")?R_("::java::Pack")(t,e):void 0};function E_(t){t.registerChecker("json:array",ta),t.registerChecker("json:boolean",ta),t.registerChecker("json:null",ta),t.registerChecker("json:number",ta),t.registerChecker("json:object",ta),t.registerChecker("json:string",ta)}function R_(t){return(e,r)=>{let i=r.symbols.query(r.doc,"mcdoc",t).getData(Co.TypeDefSymbolData.is)?.typeDef;if(i)switch(i.kind){case"struct":M_(i)(e,r);break;default:r.logger.error(`[json.checker.definition] Expected a struct type, but got ${i.kind}`)}}}function M_(t){return(e,r)=>{if(Pr.is(e))for(let{key:n,value:i}of e.children){if(!n||!i)continue;let o=n.value,s=t.fields.find(a=>a.kind==="pair"&&a.key===o);s?Th(s.type)(i,r):r.err.report(y("unknown-key",P(o)),n,2)}}}function Th(t){let e=(n,{kind:i,min:o=-1/0,max:s=1/0})=>{let a=(l,c,f)=>f?l{if(t.kind!=="any"&&t.kind!=="dispatcher"&&t.kind!=="enum"&&t.kind!=="literal"&&t.kind!=="reference"&&t.kind!=="union"&&t.kind!=="attributed"&&t.kind!=="unsafe"&&t.kind!=="concrete"&&t.kind!=="indexed"&&t.kind!=="template"&&n.type!==r[t.kind]){i.err.report(y("expected",Ah(r[t.kind])),n,2);return}switch(t.kind){case"boolean":break;case"byte_array":case"int_array":case"long_array":if(n=n,t.lengthRange&&!e(n.children.length,t.lengthRange)&&i.err.report(y("expected",y("json.checker.array.length-between",Ah(n.type),t.lengthRange.min??"-\u221E",t.lengthRange.max??"+\u221E")),n,2),t.valueRange)for(let{value:o}of n.children)o?.type!=="json:number"?i.err.report(y("expected",Ah("json:number")),n,2):o&&!e(Number(o.value),t.valueRange)&&i.err.report(y("number.between",t.valueRange.min??"-\u221E",t.valueRange.max??"+\u221E"),n,2);break;case"byte":case"short":case"int":case"long":case"float":case"double":n=n,t.valueRange&&!e(Number(n.value),t.valueRange)&&i.err.report(y("number.between",t.valueRange.min??"-\u221E",t.valueRange.max??"+\u221E"),n,2);break;case"dispatcher":n=n;break;case"list":n=n,t=cc(t),t.lengthRange&&!e(n.children.length,t.lengthRange)&&i.err.report(y("expected",y("json.checker.collection.length-between",Ah(n.type),t.lengthRange.min??"-\u221E",t.lengthRange.max??"+\u221E")),n,2);for(let{value:o}of n.children)o&&Th(t.item)(o,i);break;case"struct":n=n,M_(t)(n,i);break;case"string":break;case"reference":break;case"union":t=Gs(t),t.members.length===0?i.err.report(y("json.checker.object.field.union-empty-members"),kn.is(n.parent)?n.parent.key??n.parent:n,2):tt.any(t.members.map(o=>Th(o)))(n,i);break;case"attributed":Th(t.child)(n,i);break}}}function Ah(t){let e=`json.node.${t.replace(/^json:/,"")}`;return y(e)}var N_=t=>{T_(t),E_(t.meta)};function L_(t){t.registerColorizer("mcfunction:command_macro",LL),t.registerColorizer("mcfunction:command_child/literal",Ie.literal),t.registerColorizer("mcfunction:command_child/trailing",Ie.error)}var LL=(t,e)=>[Ce.create(t,"string")];var Nh={};yr(Nh,{command:()=>$_,entry:()=>IL});var Oh;(function(t){function e(n){return n.type==="mcfunction:command"}t.is=e;function r(n){return{type:"mcfunction:command",range:v.get(n),children:[]}}t.mock=r})(Oh||(Oh={}));var j_=Object.freeze({is(t){return t?.type==="mcfunction:command_macro"}}),Rh;(function(t){function e(r){return r.type==="mcfunction:command_child"}t.is=e})(Rh||(Rh={}));var B_;(function(t){function e(r){return r?.type==="mcfunction:command_child/literal"}t.is=e})(B_||(B_={}));var Eh;(function(t){function e(r){return r?.type==="mcfunction:entry"}t.is=e})(Eh||(Eh={}));var Sc,Mh=class{constructor(){E(this,Sc,new Map);if(Mh._instance)throw new Error("Use the `instance` static property to get an instance.")}register(e,r,n){g(this,Sc).set(e,n?Ka(r,n):r)}get(e){let r=g(this,Sc).get(e);if(!r)throw new Error(`No command tree exist for version \u201C${e}\u201D`);return r}static get instance(){return this._instance??(this._instance=new Mh)}},pr=Mh;Sc=new WeakMap,H(pr,"_instance");function Ny(t,e){return e.reduce((r,n)=>r?.children?.[n],t)}function Ro(t,e,r){return t?.redirect?{treeNode:Ny(e,t.redirect),path:[...t.redirect]}:t&&!t.children&&!t.executable?{treeNode:e,path:[]}:{treeNode:t,path:r}}function Dh(t){let e={literalTreeNodes:[],argumentTreeNodes:[]};for(let r of Object.entries(t))r[1].type==="literal"?e.literalTreeNodes.push(r):r[1].type==="argument"&&e.argumentTreeNodes.push(r);return e}function IL(t,e){return(r,n)=>{let i=pr.instance.get(t),o=Ke.findChild(r,n.offset,!0);return Ya.is(o)||j_.is(o)?[]:$_(i,e)(o??Oh.mock(n.offset),n)}}function $_(t,e){return(r,n)=>{let i=Ke.findChildIndex(r,n.offset,!0),o=r.children[i]?.children[0];if(o)return re.dispatch(o,n);let s=Ke.findLastChild(r,n.offset);if(!s)return Object.keys(t.children??{}).map(u=>pe.create(u,n.offset,{kind:14}));let a=s.path,{treeNode:l}=Ro(Ny(t,a),t);if(!l?.children)return[];let{literalTreeNodes:c,argumentTreeNodes:f}=Dh(l.children);return[...c.map(([u])=>pe.create(u,n.offset,{kind:14})),...f.flatMap(([u,h])=>Ue.toArray(e(h,n.offset)).flatMap(d=>re.dispatch(d,n)))]}}function z_(t,e){let r=e.parser.slice(e.parser.indexOf(":")+1);return`<${t}: ${r}>`}var _c=(t,e)=>{let r=t.cursor,n=t.readSpace();return n!==" "&&e.err.report(y("expected",y("mcfunction.parser.sep",P(" "))),v.create(r,t)),n};function F_(t,e=!1){let r={pool:t,colorTokenType:e?"keyword":"literal"};return(n,i)=>{let o=n.cursor,s=n.readUntil(" ","\r",` -`);if(!s.length)return V;let a={type:"mcfunction:command_child/literal",range:v.create(o,n),options:r,value:s};return t.includes(s)||i.err.report(y("expected",t),a),a}}function Ph(t,e){return(r,n)=>{let i={type:"mcfunction:command",range:v.create(r),children:[]},o=r.cursor;if(r.trySkip("/")&&(i.slash=v.create(o,r.cursor)),BL(i.children,r,n,[],t,t,e),r.canReadInLine()){let s=$L(r,n);i.children.push({type:"mcfunction:command_child",range:s.range,children:[s],path:[]})}return i.range.end=r.cursor,i}}function BL(t,e,r,n,i,o,s){function a(c,f){let{treeNode:u,path:h}=Ro(f,i,c);c=h;let d=u?.children;if(!d)return!1;let{literalTreeNodes:p,argumentTreeNodes:b}=Dh(d),m=b.map(([R,x])=>({name:R,parser:s(x)??jL(x)})),k=p.length?F_(p.map(([R,x])=>R),u.type==="root"):void 0,S=[...k?[k]:[],...m.map(R=>R.parser)],_={index:0},C=(S.length>1?ar(S,_):S[0])(e,r);if(C!==V){let R=m[_.index-(k?1:0)]?.name??C.value,x=[...c,R];t.push({type:"mcfunction:command_child",range:C.range,children:[C],path:x});let T=d[R];if(!T)return!1;let O=T.permission??2;if(r.config.env.permissionLevel{let n=e.cursor,i=e.readUntilLineEnd(),o=v.create(n,e);return r.err.report(y("mcfunction.parser.unknown-parser",P(t.parser)),o,0),{type:"mcfunction:command_child/unknown",range:o,value:i}}}var $L=(t,e)=>{let r=t.cursor,n=t.readUntilLineEnd(),i=v.create(r,t);return e.err.report(y("mcfunction.parser.trailing",P(n)),i),{type:"mcfunction:command_child/trailing",range:i,value:n}};function zL(t,e){return e?`[${t}]`:t}function Py(t,e=!1){return Object.entries(t).map(([n,i])=>zL(Ly(n,i),e))}function FL(t){let e=Py(t);return e.length>5?`${e.slice(0,3).join("|")}|...|${e.slice(-2).join("|")}`:e.join("|")}function Ly(t,e){return e.type==="argument"?z_(t,e):t}function V_(t,e){return(r,n)=>{let i={type:"mcfunction:entry",range:v.create(r),children:[]};for(;r.skipWhitespace().canReadInLine();){let o;if(r.peek()==="#")o=VL(r,n);else if(r.peek()==="$"){let s=r.cursor;r.skipLine(),o={type:"mcfunction:command_macro",range:v.create(s,r)}}else o=Ph(pr.instance.get(t),e)(r,n);i.children.push(o),r.nextLine()}return i.range.end=r.cursor,i}}var VL=Rl({singleLinePrefixes:new Set(["#"])});var U_=({meta:t})=>{L_(t),t.registerCompleter("mcfunction:command_child/literal",re.literal)};function UL(t,e,r){return r.symbols.query(r.doc,t,q.lengthen(e)).symbol?.definition?.map(n=>n.uri)??[]}function Eo(t,e,r){let n=o=>dr.is(o)?o.value:o.children.find(s=>s.key?.value==="id").value.value;return[...UL(t,e,r).reduce((o,s)=>o,new Set)]}function H_(){let t=/^[0-9a-f]{1,6}$/i,e=(r,n)=>{let i=0,o=r.cursor;if(r.trySkip("#")){let s=r.readRemaining();s.match(t)?i=parseInt(s,16):n.err.report(y("expected",y("json.checker.string.hex-color")),v.create(o,r))}else{let s=r.readRemaining();ht.NamedColors.has(s)?i=ht.NamedColors.get(s):n.err.report(y("expected",ht.ColorNames),v.create(o,r))}return ht.fromCompositeInt(i)};return(r,n)=>{if(r.expectation=[{type:"json:string",typedoc:'String("Color")',pool:ht.ColorNames}],!dr.is(r))n.err.report(y("expected",y("string")),r);else{let i=uo(e,r.value,r.valueMap,n);i!==V&&(r.color={value:i,format:[Bt.HexRGB],range:{start:r.range.start+1,end:r.range.end-1}})}}}function Iy(t){return HL(t)?WL(t):qL(t)}function HL(t){return typeof t.definition=="string"}function WL({definition:t}){return(e,r)=>{if(!r.ensureBindingStarted){Ee(e,r);return}let n=r.meta.getParserLazily("nbt:compound"),i=it.definition(t);wt("nbt",n,i)(e,r)}}function qL(t){return(e,r)=>{let n=W_(t,r);if(!r.ensureBindingStarted){Ee(e,r);return}let i=r.meta.getParser("nbt:compound"),o=it.index(t.registry,n);wt("nbt",i,o)(e,r)}}function Lh(t){return(e,r)=>{let n=W_(t,r);if(!r.ensureBindingStarted){Ee(e,r);return}let i=r.meta.getParser("nbt:path"),o=it.path(t.registry,n);wt("nbt_path",i,o)(e,r)}}function W_({registry:t,id:e,idOrTag:r,ids:n,tag:i},o){return r&&(r.startsWith("#")?i=r.slice(1):e=r),i&&(t==="block"||t==="item"||t==="entity_type")?n=Eo(`tag/${t}`,i,o):e&&(n=[e]),n?.map(q.lengthen)}var ZU=wt("recipe_group",Bs("recipe_group"));var KL=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,By=wt(void 0,void 0,(t,e)=>{t.value.match(KL)||e.err.report(y("expected",y("uuid")),t)});function GL(t){return t.project.loadedVersion}function jy(t,e){return Vt.cmp(GL(t),e)}function ra(t,e,r,n){if(typeof e=="string"){let i=jy(t,e)>=0;return r===void 0?r:Array.isArray(r)?i?r:[]:i?r:void 0}else{let i=jy(t,r)<0;return e===void 0?e:Array.isArray(e)?i?e:n??[]:i?e:n??void 0}}function Ih(t,e,r){return jy(t,e)<0?r:C_(r)}var ZL=["key.jump","key.sneak","key.sprint","key.left","key.right","key.back","key.forward","key.attack","key.pickItem","key.use","key.drop","key.hotbar.1","key.hotbar.2","key.hotbar.3","key.hotbar.4","key.hotbar.5","key.hotbar.6","key.hotbar.7","key.hotbar.8","key.hotbar.9","key.inventory","key.swapOffhand","key.loadToolbarActivator","key.saveToolbarActivator","key.playerlist","key.chat","key.command","key.socialInteractions","key.advancements","key.spectatorOutlines","key.screenshot","key.smoothCamera","key.fullscreen","key.togglePerspective"],JL=Ey("text_component",(t,e)=>Dn({...Dy(t,e,{text:{text:Ee},translate:{translate:Ee,with:le(vc(cn),[])},selector:{selector:Ee,separator:le(ra(e,"1.17",cn))},score:{score:Dn({name:Ee,objective:Ee,value:le(Ee)})},keybind:{keybind:ea(ZL)},nbt:()=>({nbt:Ee,...Dy(t,e,{block:{block:Ee,nbt:Lh({registry:"block"})},entity:{entity:Ee,nbt:Lh({registry:"entity_type"})},storage:{storage:wc("storage"),nbt:Lh({registry:"storage"})}}),interpret:le(_i,!1),separator:le(ra(e,"1.17",cn))})}),color:le(H_()),font:le(Ee),bold:le(_i),italic:le(_i),underlined:le(_i),strikethrough:le(_i),obfuscated:le(_i),insertion:le(Ee),clickEvent:le(Ch("action",r=>Dn({action:ea(["open_url","open_file","run_command","suggest_command","change_page","copy_to_clipboard"]),value:Ee,...My(r,{run_command:{value:wt("command",e.meta.getParserLazily("mcfunction:command"),e.meta.getChecker("mcfunction:command"))},change_page:{value:wt("number",Ar({pattern:/\d+/,min:0}))}})}))),hoverEvent:le(Ch("action",(r,n,i)=>Dn({action:ea(["show_text","show_item","show_entity"]),...My(r,{show_text:{value:Ih(i,"1.16",cn),contents:le(ra(i,"1.16",cn))},show_item:{value:Ih(i,"1.16",Iy({definition:"::minecraft::util::invitem::InventoryItem"})),contents:le(ra(i,"1.16",Ch(o=>Dn({id:wc("item"),count:le(S_),tag:le(Iy({registry:"item",id:A_("id",o)}))}))))},show_entity:{value:Ih(i,"1.16",Dn({name:le(Ee),type:le(wc("entity_type")),id:le(By)})),contents:le(ra(i,"1.16",Dn({name:le(cn),type:le(wc("entity_type")),id:le(By)})))}})}))),extra:le(vc(cn))})(t,e)),cn=Ey("text_component",Qs([Ee,JL,vc(x_(()=>cn))]));var Bh;(function(t){function e(r){return r.type==="mcfunction:block/states"}t.is=e})(Bh||(Bh={}));var Lr;(function(t){function e(n){return n?.type==="mcfunction:block"}t.is=e;function r(n,i){let o=U.mock(n,{category:"block",allowTag:i});return{type:"mcfunction:block",range:v.get(n),children:[o],id:o}}t.mock=r})(Lr||(Lr={}));var jh;(function(t){function e(n){return{type:"mcfunction:coordinate",range:v.get(n),notation:"",value:0}}t.mock=e;function r(n){let i=n.value%360;return i>=180?i-360:i<-180?i+360:i}t.toDegree=r})(jh||(jh={}));var $h;(function(t){function e(r){return r.type==="mcfunction:entity_selector/arguments"}t.is=e})($h||($h={}));var K_=["a","e","p","r","s"],q_;(function(t){function e(r){return K_.includes(r)}t.is=e})(q_||(q_={}));var Ac=K_.map(t=>`@${t}`),na;(function(t){function e(r){return Ac.includes(r)}t.is=e})(na||(na={}));var Ir;(function(t){function e(i){return i?.type==="mcfunction:entity_selector"}t.is=e;function r(i){let o=Ne.mock(i,{pool:Ac,colorTokenType:"keyword"});return{type:"mcfunction:entity_selector",range:v.get(i),children:[o],variable:"e"}}t.mock=r,t.ArgumentKeys=new Set(["advancements","distance","gamemode","level","limit","name","nbt","predicate","scores","sort","tag","team","type","x","y","z","dx","dy","dz","x_rotation","y_rotation"]);function n(i,o,s){let a=c=>!!o.children.find(f=>f.key?.value===c),l=c=>!!o.children.find(f=>f.key?.value===c&&!f.value?.inverted);switch(s){case"advancements":case"distance":case"level":case"scores":case"x":case"y":case"z":case"dx":case"dy":case"dz":case"x_rotation":case"y_rotation":return a(s)?1:0;case"gamemode":case"name":case"team":return l(s)?1:0;case"limit":case"sort":return i.currentEntity?2:a(s)?1:0;case"type":return i.typeLimited?a(s)?1:2:0}return 0}t.canKeyExist=n})(Ir||(Ir={}));var ia;(function(t){function e(r){return r?.type==="mcfunction:entity"}t.is=e})(ia||(ia={}));var Ci;(function(t){function e(n){return n?.type==="mcfunction:item"}t.is=e;function r(n,i){let o=U.mock(n,{category:"item",allowTag:i});return{type:"mcfunction:item",range:v.get(n),children:[o],id:o}}t.mock=r})(Ci||(Ci={}));var zh;(function(t){function e(r){return{type:"mcfunction:int_range",range:v.get(r),children:[],value:[void 0,void 0]}}t.mock=e})(zh||(zh={}));var Ai;(function(t){t.SimpleValues=["air","armor","deathCount","dummy","food","health","level","playerKillCount","totalKillCount","trigger","xp"],t.ComplexCategories=new Map([["broken","item"],["crafted","item"],["custom","custom_stat"],["dropped","item"],["killed","entity_type"],["killed_by","entity_type"],["mined","block"],["picked_up","item"],["used","item"]]),t.ComplexSep=":";function e(r){return{type:"mcfunction:objective_criteria",range:v.get(r)}}t.mock=e})(Ai||(Ai={}));var Mo;(function(t){let e=new Set(["block","block_marker","dust","dust_color_transition","falling_dust","item","sculk_charge","shriek","vibration"]);function r(o){return e.has(o)}t.isSpecialType=r;function n(o){return o?.type==="mcfunction:particle"}t.is=n;function i(o){let s=U.mock(o,{category:"particle_type"});return{type:"mcfunction:particle",range:v.get(o),children:[s],id:s}}t.mock=i})(Mo||(Mo={}));var Fh;(function(t){function e(r){let n=or.mock(r,{category:"score_holder"});return{type:"mcfunction:score_holder",range:v.get(r),children:[n],fakeName:n}}t.mock=e})(Fh||(Fh={}));var Vh;(function(t){t.UnitToTicks=new Map([["",1],["t",1],["s",20],["d",24e3]]),t.Units=[...t.UnitToTicks.keys()]})(Vh||(Vh={}));var Ut;(function(t){function e(r,n){return{type:"mcfunction:vector",range:v.get(r),children:[],options:n,system:0}}t.mock=e})(Ut||(Ut={}));var YL=(t,e)=>{t.slash&&t.parent&&Eh.is(t.parent)&&e.err.report(y("unexpected-leading-slash"),t.slash),G_(t.children,0,e)},Ht=(t,e)=>t[e]?.path[t[e].path.length-1],Wt=(t,e)=>t[e]?.children[0],G_=(t,e,r)=>{for(let{children:[n]}of t)Lr.is(n)?Z_(n,r):ia.is(n)?J_(n,r):Ci.is(n)?Y_(n,r):Mo.is(n)?X_(n,r):xh.is(n)&&cn(n,{...r,context:""});if(Ht(t,e)==="data")if(Ht(t,e+1)==="get")Uh(t,e+2,r);else if(Ht(t,e+1)==="merge")XL(t,e+2,r);else if(Ht(t,e+1)==="modify"){Uh(t,e+2,r);let n=Wt(t,e+4)}else Ht(t,e+1)==="remove"&&Uh(t,e+2,r);else if(Ht(t,e)==="execute"){for(let n=e+1;n{t.nbt&&it.index("block",U.toString(t.id,"full"))(t.nbt,e)},J_=(t,e)=>{let r=t.selector?.arguments?.children.find(o=>o.key?.value==="nbt");if(!r)return;let n=$y(t,e),i=r.value;it.index("entity_type",n)(i,e)},Y_=(t,e)=>{t.nbt&&it.index("item",U.toString(t.id,"full"))(t.nbt,e)},X_=(t,e)=>{tt.dispatchSync(t,e)},XL=(t,e,r)=>{switch(Ht(t,e)){case"block":{let i=Wt(t,e+2);Nr.is(i)&&it.index("block",void 0)(i,r);break}case"entity":{let i=Wt(t,e+1),o=Wt(t,e+2);if(ia.is(i)&&Nr.is(o)){let s=$y(i,r);it.index("entity_type",s)(o,r)}break}case"storage":{let i=Wt(t,e+1),o=Wt(t,e+2);U.is(i)&&Nr.is(o)&&it.index("storage",U.toString(i,"full"))(o,r);break}}},Uh=(t,e,r)=>{switch(Ht(t,e)){case"block":{let i=Wt(t,e+2);Ys.is(i)&&it.path("block",void 0)(i,r);break}case"entity":{let i=Wt(t,e+1),o=Wt(t,e+2);if(ia.is(i)&&Ys.is(o)){let s=$y(i,r);it.path("entity_type",s)(o,r)}break}case"storage":{let i=Wt(t,e+1),o=Wt(t,e+2);U.is(i)&&Ys.is(o)&&it.path("storage",U.toString(i,"full"))(o,r);break}}},QL=(t,e,r)=>{let n=Wt(t,e),i=Wt(t,e+2);U.is(n)&&Nr.is(i)&&it.index("entity_type",U.toString(n,"full"))(i,r)},$y=(t,e)=>{if(t.playerName!==void 0||t.selector?.playersOnly)return["minecraft:player"];if(t.selector){let r=t.selector.arguments;if(!r)return;let n=[];for(let i of r.children){if(i.key?.value!=="type")continue;let o=i.value;if(!o||o.inverted)continue;let s=U.toString(o.value,"full",!0);if(s.startsWith(q.TagPrefix)){let a=Eo("tag/entity_type",s.slice(1),e);n=n.filter(l=>a.includes(l))}else n=[s]}return n}};function Q_(t){t.registerChecker("mcfunction:command",YL),t.registerChecker("mcfunction:block",Z_),t.registerChecker("mcfunction:entity",J_),t.registerChecker("mcfunction:item",Y_),t.registerChecker("mcfunction:particle",X_)}var eI=t=>[Ce.create(t,"type")],tI=t=>[Ce.create(t,"vector")];function tC(t){t.registerColorizer("mcfunction:coordinate",Ie.number),t.registerColorizer("mcfunction:vector",tI),t.registerColorizer("mcfunction:objective_criteria",eI)}var Hh=[...ht.ColorNames,"reset"],Wh=["feet","eyes"],Tc=["adventure","survival","creative","spectator"],qh=[...[...Array(54).keys()].map(t=>`container.${t}`),...[...Array(27).keys()].map(t=>`enderchest.${t}`),...[...Array(15).keys()].map(t=>`horse.${t}`),...[...Array(9).keys()].map(t=>`hotbar.${t}`),...[...Array(27).keys()].map(t=>`inventory.${t}`),...[...Array(8).keys()].map(t=>`villager.${t}`),"armor.chest","armor.feet","armor.head","armor.legs","horse.armor","horse.chest","horse.saddle","weapon","weapon.mainhand","weapon.offhand"],Kh=["=","+=","-=","*=","/=","%=","<",">","><"],Gh=["belowName","list","sidebar",...ht.ColorNames.map(t=>`sidebar.team.${t}`)],Zh=["x","xy","xz","xyz","xzy","y","yx","yz","yxz","yzx","z","zx","zy","zxy","zyx"];var nC=(t,e)=>{let r=t;switch(r.parser){case"brigadier:bool":return fu.mock(e);case"brigadier:double":case"brigadier:float":case"brigadier:integer":case"brigadier:long":case"minecraft:float_range":case"minecraft:message":case"minecraft:time":case"minecraft:uuid":return[];case"brigadier:string":return r.properties.type==="phrase"?et.mock(e,ui):[];case"minecraft:angle":return jh.mock(e);case"minecraft:block_pos":return Ut.mock(e,{dimension:3,integersOnly:!0});case"minecraft:block_predicate":return Lr.mock(e,!0);case"minecraft:block_state":return Lr.mock(e,!1);case"minecraft:color":return Ne.mock(e,{pool:Hh});case"minecraft:column_pos":return Ut.mock(e,{dimension:2,integersOnly:!0});case"minecraft:component":return[Oo.mock(e),Pr.mock(e),dr.mock(e)];case"minecraft:dimension":return U.mock(e,{category:"dimension"});case"minecraft:entity":case"minecraft:game_profile":return Ir.mock(e);case"minecraft:entity_anchor":return Ne.mock(e,{pool:Wh});case"minecraft:entity_summon":return U.mock(e,{category:"entity_type"});case"minecraft:function":return U.mock(e,{category:"function"});case"minecraft:gamemode":return Ne.mock(e,{pool:Tc});case"minecraft:int_range":return zh.mock(e);case"minecraft:item_enchantment":return U.mock(e,{category:"enchantment"});case"minecraft:item_predicate":return Ci.mock(e,!0);case"minecraft:item_slot":return Ne.mock(e,{pool:qh});case"minecraft:item_stack":return Ci.mock(e,!1);case"minecraft:mob_effect":return U.mock(e,{category:"mob_effect"});case"minecraft:objective":return or.mock(e,{category:"objective"});case"minecraft:objective_criteria":return Ai.mock(e);case"minecraft:operation":return Ne.mock(e,{pool:Kh,colorTokenType:"operator"});case"minecraft:particle":return Mo.mock(e);case"minecraft:resource":case"minecraft:resource_or_tag":return U.mock(e,{category:q.shorten(r.properties.registry),allowTag:r.parser==="minecraft:resource_or_tag"});case"minecraft:resource_location":return U.mock(e,r.properties??{pool:[],allowUnknown:!0});case"minecraft:rotation":return Ut.mock(e,{dimension:2,noLocal:!0});case"minecraft:scoreboard_slot":return Ne.mock(e,{pool:Gh});case"minecraft:score_holder":return Fh.mock(e);case"minecraft:swizzle":return Ne.mock(e,{pool:Zh});case"minecraft:team":return or.mock(e,{category:"team"});case"minecraft:vec2":return Ut.mock(e,{dimension:2,integersOnly:!0});case"minecraft:vec3":return Ut.mock(e,{dimension:3});case"spyglassmc:tag":return or.mock(e,{category:"tag"});case"minecraft:nbt_compound_tag":case"minecraft:nbt_path":case"minecraft:nbt_tag":default:return[]}},rI=(t,e)=>{let r=[];return v.contains(t.id,e.offset,!0)&&r.push(...re.resourceLocation(t.id,e)),t.states&&v.contains(v.translate(t.states,1,-1),e.offset,!0)&&r.push(...nI(t.states,e)),r},nI=(t,e)=>{if(!Lr.is(t.parent))return[];let r=t.parent.id,n=U.toString(r,"full"),i=r.isTag?Eo("tag/block",n,e):[n],o=Ga("block",i,e);return re.record({key:(s,a,l,c,f,u,h)=>Object.keys(o).filter(d=>a?.key?.value===d||!h.some(p=>p.value===d)).map(d=>pe.create(d,c,{kind:10,detail:y("mcfunction.completer.block.states.default-value",P(o[d][0])),insertText:new al().literal(d).if(f,p=>p.literal("=").placeholder(...o[d])).if(u,p=>p.literal(",")).build()})),value:(s,a,l)=>a.key&&o[a.key.value]?o[a.key.value].map(c=>pe.create(c,a.value??l.offset,{kind:12})):[]})(t,e)},iI=(t,e)=>[pe.create("~",t)],oI=(t,e)=>{let r=[];return v.contains(t.id,e.offset,!0)&&r.push(...re.resourceLocation(t.id,e)),r},sI=(t,e)=>{let r=Ai.SimpleValues.map(n=>pe.create(n,t));return(!t.children?.[0]||v.contains(t.children[0],e.offset,!0))&&r.push(...re.resourceLocation(t.children?.[0]??U.mock(t,{category:"stat_type",namespacePathSep:"."}),e)),t.children?.[1]&&v.contains(t.children[1],e.offset,!0)&&r.push(...re.resourceLocation(t.children[1],e)),r},aI=(t,e)=>{let r=Ke.findChild(t,e.offset,!0);if(r)return re.dispatch(r,e);let n=U.toString(t.id,"short"),i={block:[Lr.mock(e.offset,!1)],block_marker:[Lr.mock(e.offset,!1)],dust:[Ut.mock(e.offset,{dimension:3}),Sr.mock(e.offset)],dust_color_transition:[Ut.mock(e.offset,{dimension:3}),Sr.mock(e.offset),Ut.mock(e.offset,{dimension:3})],falling_dust:[Lr.mock(e.offset,!1)],item:[Ci.mock(e.offset,!1)],sculk_charge:[Sr.mock(e.offset)],shriek:[Ki.mock(e.offset)],vibration:[Ut.mock(e.offset,{dimension:3}),Ut.mock(e.offset,{dimension:3}),Ki.mock(e.offset)]};if(Mo.isSpecialType(n)){let o=t.children?.slice(1).filter(a=>a.range.end{let r;return t.selector&&v.contains(t.selector,e.offset,!0)?(r=zy(t.selector,e),v.contains(t.children[0],e.offset,!0)&&r.push(...re.symbol(or.mock(t,{category:"score_holder"}),e))):(r=re.symbol(t.fakeName??or.mock(t,{category:"score_holder"}),e),r.push(...zy(Ir.mock(t),e))),r},zy=(t,e)=>v.contains(t.children[0],e.offset,!0)?re.literal(t.children[0],e):t.arguments&&v.contains(v.translate(t.arguments,1,-1),e.offset,!0)?iC(t.arguments,e):[],iC=(t,e)=>{let r=t.parent;return Ir.is(r)?re.record({key:(n,i,o,s,a,l)=>[...Ir.ArgumentKeys].filter(c=>Ir.canKeyExist(r,n,c)===0).map(c=>pe.create(c,s,{kind:10,insertText:new al().literal(c).if(a,f=>f.literal("=").placeholder()).if(l,f=>f.literal(",")).build()})),value:(n,i,o)=>i.value?re.dispatch(i.value,o):[]})(t,e):[]},cI=(t,e)=>[pe.create("-2147483648..2147483647",t,{kind:21})],fI=(t,e)=>{let r=(i,o)=>pe.create(new Array(t.options.dimension).fill(i).join(" "),t,{sortText:o}),n=[];return n.push(r("~","a")),t.options.noLocal||n.push(r("^","b")),n.push(r("0.0","c")),n};function oC(t){t.registerCompleter("mcfunction:block",rI),t.registerCompleter("mcfunction:coordinate",iI),t.registerCompleter("mcfunction:entity_selector",zy),t.registerCompleter("mcfunction:entity_selector/arguments",iC),t.registerCompleter("mcfunction:int_range",cI),t.registerCompleter("mcfunction:item",oI),t.registerCompleter("mcfunction:objective_criteria",sI),t.registerCompleter("mcfunction:particle",aI),t.registerCompleter("mcfunction:score_holder",lI),t.registerCompleter("mcfunction:vector",fI)}var aC=(t,e)=>{if(t.children[0]?.type!=="mcfunction:entry")return[];let r=[];return Ct(t,n=>!0,Rh.is,n=>{let i=n,o=e.config.env.feature.inlayHint;(o===!0||typeof o=="object"&&o.enabledNodes.includes(i.children[0].type))&&r.push({offset:i.range.start,text:`${i.path[i.path.length-1]}:`})}),r};var cC=/^-?\d+$/,fC=/^-?(?:\d+\.?\d*|\.\d+)$/,uC=Number.MAX_VALUE,uI=-uC,hC=(2-2**-23)*2**127,hI=-hC,dI=2**31-1,pI=-(2**31),dC=9223372036854775807n,mI=-9223372036854775808n,gI=40,yI=16,bI=16;function kI(t){let e=t.project.loadedVersion;return!e||Vt.cmp(e,"1.18")<0}var Vy=t=>{let e=t,r=n=>oe(Tn(n,"\r",` -`));switch(e.parser){case"brigadier:bool":return r($u);case"brigadier:double":return r(Yh(e.properties?.min,e.properties?.max));case"brigadier:float":return r(aa(e.properties?.min,e.properties?.max));case"brigadier:integer":return r(la(e.properties?.min,e.properties?.max));case"brigadier:long":return r(vI(e.properties?.min,e.properties?.max));case"brigadier:string":switch(e.properties.type){case"word":return r(vC);case"phrase":return r(ho);case"greedy":default:return r(mC)}case"minecraft:angle":return r(Is(Fy(),n=>n.notation!=="^",y("mcfunction.parser.vector.local-disallowed")));case"minecraft:block_pos":return r(oa({dimension:3,integersOnly:!0}));case"minecraft:block_predicate":return r(Uy);case"minecraft:block_state":return r(Jh);case"minecraft:color":return r(J(Oe(...Hh),n=>({...n,color:ht.NamedColors.has(n.value)?ht.fromCompositeInt(ht.NamedColors.get(n.value)):void 0})));case"minecraft:column_pos":return r(oa({dimension:2,integersOnly:!0}));case"minecraft:component":return r(Hy);case"minecraft:dimension":return r(Re({category:"dimension"}));case"minecraft:entity":return r(lC(e.properties.amount,e.properties.type));case"minecraft:entity_anchor":return r(Oe(...Wh));case"minecraft:entity_summon":return r(Re({category:"entity_type"}));case"minecraft:float_range":return r(sa("float"));case"minecraft:function":return r(Re({category:"function",allowTag:!0}));case"minecraft:gamemode":return r(Oe(...Tc));case"minecraft:game_profile":return r(lC("multiple","players"));case"minecraft:int_range":return r(sa("integer"));case"minecraft:item_enchantment":return r(Re({category:"enchantment"}));case"minecraft:item_predicate":return r(wI);case"minecraft:item_slot":return r(Oe(...qh));case"minecraft:item_stack":return r(yC);case"minecraft:message":return r(xI);case"minecraft:mob_effect":return r(Re({category:"mob_effect"}));case"minecraft:nbt_compound_tag":return r(ln.compound);case"minecraft:nbt_path":return r(ln.path);case"minecraft:nbt_tag":return r(ln.entry);case"minecraft:objective":return r(kC(el.is(e.properties?.usageType)?e.properties?.usageType:void 0));case"minecraft:objective_criteria":return r(AI);case"minecraft:operation":return r(Oe({pool:Kh,colorTokenType:"operator"}));case"minecraft:particle":return r(Wy);case"minecraft:resource":case"minecraft:resource_or_tag":return r(Re({category:q.shorten(e.properties.registry),allowTag:e.parser==="minecraft:resource_or_tag"}));case"minecraft:resource_location":return r(Re(e.properties??{pool:[],allowUnknown:!0}));case"minecraft:rotation":return r(oa({dimension:2,noLocal:!0}));case"minecraft:score_holder":return r(CI(e.properties.amount));case"minecraft:scoreboard_slot":return r(Oe(...Gh));case"minecraft:swizzle":return r(Oe(...Zh));case"minecraft:team":return r(Qh(el.is(e.properties?.usageType)?e.properties?.usageType:void 0));case"minecraft:time":return r(TI);case"minecraft:uuid":return r(wC);case"minecraft:vec2":return r(oa({dimension:2,noLocal:!0}));case"minecraft:vec3":return r(oa({dimension:3}));case"spyglassmc:tag":return r(Xh());default:return}};function pC(t){return J(be([Re({category:"block",allowTag:t}),ke(J(oe(Tr({start:"[",pair:{key:dt({...ui,colorTokenType:"property"}),sep:"=",value:ho,end:",",trailingEnd:!0},end:"]"})),e=>({...e,type:"mcfunction:block/states"}))),ke(oe(ln.compound))]),e=>({type:"mcfunction:block",range:e.range,children:e.children,id:e.children.find(U.is),states:e.children.find(Bh.is),nbt:e.children.find(Nr.is)}))}var Jh=pC(!1),Uy=pC(!0),Hy=mc.json();function Yh(t=uI,e=uC){return en({pattern:fC,min:t,max:e})}function aa(t=hI,e=hC){return en({pattern:fC,min:t,max:e})}function la(t=pI,e=dI){return Ar({pattern:cC,min:t,max:e})}function vI(t,e){return El({pattern:cC,min:BigInt(t??mI),max:BigInt(e??dC)})}function Fy(t=!1){return(e,r)=>{let n={type:"mcfunction:coordinate",notation:"",range:v.create(e),value:0};if(e.trySkip("^")?n.notation="^":e.trySkip("~")&&(n.notation="~"),e.canReadInLine()&&e.peek()!==" "||n.notation===""){let i=(t&&n.notation===""?la:Yh)()(e,r);n.value=Number(i.value)}return n.range.end=e.cursor,n}}function lC(t,e){return J(ne([{predicate:r=>na.is(r.peek(2)),parser:qy()},{parser:ar([Gy(ho,bI,"mcfunction.parser.entity-selector.player-name.too-long"),wC])}]),(r,n,i)=>{let o={type:"mcfunction:entity",range:r.range,children:[r]};return et.is(r)?o.playerName=r:Ir.is(r)?o.selector=r:o.uuid=r,t==="single"&&o.selector&&!o.selector.single&&i.err.report(y("mcfunction.parser.entity-selector.multiple-disallowed"),o),e==="players"&&(o.uuid||o.selector&&!o.selector.playersOnly&&!o.selector.currentEntity)&&i.err.report(y("mcfunction.parser.entity-selector.entities-disallowed"),o),o})}var mC=dt({unquotable:{blockList:new Set([` -`,"\r"])}});function gC(t){return J(be([Re({category:"item",allowTag:t}),ke(oe(ln.compound))]),e=>({type:"mcfunction:item",range:e.range,children:e.children,id:e.children.find(U.is),nbt:e.children.find(Nr.is)}))}var yC=gC(!1),wI=gC(!0),xI=(t,e)=>{let r={type:"mcfunction:message",range:v.create(t),children:[]};for(;t.canReadInLine();)na.is(t.peek(2))?r.children.push(qy()(t,e)):r.children.push(Tn(mC,...Ac)(t,e));return r},Wy=(()=>{let t=J(_c,()=>[]),e=oa({dimension:3}),r=J(e,i=>({...i,color:i.children.length===3?{value:ht.fromDecRGB(i.children[0].value,i.children[1].value,i.children[2].value),format:[Bt.DecRGB]}:void 0})),n={block:Jh,block_marker:Jh,dust:be([r,aa()],t),dust_color_transition:be([r,aa(),r],t),falling_dust:Jh,item:yC,sculk_charge:aa(),shriek:la(),vibration:be([e,la()],t)};return J(be([Re({category:"particle_type"}),{get:i=>n[U.toString(i.children[0],"short")]}],t),i=>({type:"mcfunction:particle",range:i.range,children:i.children,id:i.children.find(U.is)}))})();function sa(t,e,r,n){let i=t==="float"?aa(e,r):la(e,r),o=oe(Tn(i,"..")),s=oe(Oe({pool:[".."],colorTokenType:"keyword"})),a=oe(i);return J(ar([be([o]),be([o,s]),be([s,a]),be([o,s,a])]),(l,c,f)=>{let u=t==="float"?l.children.filter(Sr.is):l.children.filter(Ki.is),h=l.children.find(Ne.is),d={type:t==="float"?"mcfunction:float_range":"mcfunction:int_range",range:l.range,children:l.children,value:h?u.length===2?[u[0].value,u[1].value]:v.endsBefore(u[0].range,h.range.start)?[u[0].value,void 0]:[void 0,u[0].value]:[u[0].value,u[0].value]};return!n&&d.value[0]!==void 0&&d.value[1]!==void 0&&d.value[0]>d.value[1]&&f.err.report(y("mcfunction.parser.range.min>max",d.value[0],d.value[1]),l),d})}function qy(){let t,e,r,n,i,o,s;return J(be([oe(Oe({pool:Ac,colorTokenType:"keyword"})),{get:a=>{let l=Ne.is(a.children?.[0])?a.children[0].value:void 0;e=l?l==="@s":void 0,n=l?l==="@p"||l==="@a"||l==="@r":void 0,i=l==="@e"?["Entity::isAlive"]:void 0,o=l?l==="@p"||l==="@r"||l==="@s":void 0,s=n;function c(f){return J(be([ke(oe(Oe({pool:["!"],colorTokenType:"keyword"}))),u=>{u.skipSpace()},f]),u=>({type:"mcfunction:entity_selector/arguments/value/invertable",range:u.range,children:u.children,inverted:!!u.children.find(d=>Ne.is(d)&&d.value==="!"),value:u.children.find(d=>!Ne.is(d)||d.value!=="!")}))}return ke(J(oe(Tr({start:"[",pair:{key:dt({...ui,value:{parser:Oe({pool:[...Ir.ArgumentKeys],colorTokenType:"property"}),type:"literal"}}),sep:"=",value:{get:(f,u)=>{let h=p=>!!f.children.find(b=>b.key?.value===p),d=p=>!!f.children.find(b=>b.key?.value===p&&!b.value?.inverted);switch(u?.value){case"advancements":return J(Tr({start:"{",pair:{key:Re({category:"advancement"}),sep:"=",value:ne([{predicate:p=>p.peek()==="{",parser:J(Tr({start:"{",pair:{key:vC,sep:"=",value:$u,end:",",trailingEnd:!0},end:"}"}),p=>({...p,type:"mcfunction:entity_selector/arguments/advancements/criteria"}))},{parser:$u}]),end:",",trailingEnd:!0},end:"}"}),(p,b,m)=>(h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),{...p,type:"mcfunction:entity_selector/arguments/advancements"}));case"distance":return J(sa("float",0),(p,b,m)=>(r=!0,t??=!n&&p.value[1]!==void 0,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"gamemode":return J(c(dt({unquotable:Ml,value:{type:"literal",parser:Oe(...Tc)}})),(p,b,m)=>(n=!0,(p.inverted?d(u.value):h(u.value))&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"limit":return J(la(0),(p,b,m)=>(o=p.value<=1,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),e&&m.err.report(y("mcfunction.parser.entity-selector.arguments.not-applicable",P(u.value)),u),p));case"level":return J(sa("integer",0),(p,b,m)=>(n=!0,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"name":return J(c(ho),(p,b,m)=>((p.inverted?d(u.value):h(u.value))&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"nbt":return c(ln.compound);case"predicate":return c(Re({category:"predicate"}));case"scores":return J(Tr({start:"{",pair:{key:kC("reference",["[","=",",","]","{","}"]),sep:"=",value:sa("integer"),end:",",trailingEnd:!0},end:"}"}),(p,b,m)=>(h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),{...p,type:"mcfunction:entity_selector/arguments/scores"}));case"sort":return J(dt({unquotable:Ml,value:{type:"literal",parser:Oe("arbitrary","furthest","nearest","random")}}),(p,b,m)=>(h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),e&&m.err.report(y("mcfunction.parser.entity-selector.arguments.not-applicable",P(u.value)),u),p));case"tag":return c(Xh(["[","=",",","]","{","}"]));case"team":return J(c(Qh("reference",["[","=",",","]","{","}"])),(p,b,m)=>((p.inverted?d(u.value):h(u.value))&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"type":return J(c(Re({category:"entity_type",allowTag:!0})),(p,b,m)=>(s?h(u.value)?m.err.report(y("duplicate-key",P(u.value)),u):m.err.report(y("mcfunction.parser.entity-selector.arguments.not-applicable",P(u.value)),u):!p.inverted&&!p.value.isTag&&(s=!0,U.toString(p.value,"short")==="player"&&(n=!0)),p));case"x":case"y":case"z":return J(Yh(),(p,b,m)=>(r=!0,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"dx":case"dy":case"dz":return J(Yh(),(p,b,m)=>(r=!0,t=!n,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"x_rotation":case"y_rotation":return J(sa("float",void 0,void 0,!0),(p,b,m)=>(h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case void 0:return()=>V;default:return(p,b)=>(b.err.report(y("mcfunction.parser.entity-selector.arguments.unknown",P(u.value)),u),V)}}},end:",",trailingEnd:!0},end:"]"})),f=>({...f,type:"mcfunction:entity_selector/arguments"})))}}]),a=>{let l={type:"mcfunction:entity_selector",range:a.range,children:a.children,variable:a.children.find(Ne.is).value.slice(1),arguments:a.children.find($h.is),chunkLimited:t,currentEntity:e,dimensionLimited:r,playersOnly:n,predicates:i,single:o,typeLimited:s};return l.hover=SI(l),l})}function SI(t){let e=new Map([[0,"\u{1F922}"],[1,"\u{1F605}"],[2,"Good"],[3,"Great"],[4,"\u{1F60C}\u{1F44C}"]]),r;if(t.currentEntity)r=`**Performance**: ${e.get(4)} +\`@default\` ${JSON.stringify(d)}`:""}`})}else typeof t=="function"&&e&&n.children.filter(o=>o.key).forEach(o=>{if(t(o.key,i),o.value!==void 0){let s=e(o.key.value,i);s&&(Mt(s)?s.checker:s)(o.value,i)}})}}function Dn(t,e){return T_(Object.keys(t),r=>t[r],e)}function le(t,e){if(t!==void 0)return Mt(t)?{...t,opt:!0,def:e}:{checker:t,opt:!0,def:e}}function O_(t){if(t!==void 0)return Mt(t)?{...t,deprecated:!0}:{checker:t,deprecated:!0}}function Ch(t,e){return(r,n)=>{if(!Pr.is(r))n.err.report(y("expected",y("object")),r);else if(e){let i=r.children.findIndex(a=>a.key?.value===t),o=r.children[i],s=o?.value?.type==="json:string"?o.value.value:void 0;e(s,r.children,n)(r,n)}else t(r.children,n)(r,n)}}function Py(t,e){if(t===void 0)return{};let r=e[q.shorten(t)];return r===void 0?{}:(Object.keys(r).forEach(n=>{let i=r[n];i!==void 0&&(r[n]={checker:Mt(i)?i.checker:i,opt:Mt(i)?i.opt:void 0,deprecated:Mt(i)?i.deprecated:void 0,context:q.shorten(t)})}),r)}function R_(t,e){let r=e?.find(n=>n.key?.value===t);return r?.value?.type==="json:string"?r.value.value:void 0}function Ly(t,e,r){let n=new Set(Pr.is(t)?t.children.map(s=>s.key?.value):[]),i=Object.keys(r).find(s=>n.has(s));if(i===void 0)return e.err.report(y("json.checker.property.missing",Object.keys(r)),v.create(t.range.start,t.range.start+1)),Object.fromEntries(Object.entries(r).map(([s,a])=>[s,le(typeof a=="function"?Qs():a[s]??Qs())]));let o=r[i];return typeof o=="function"?o():o}function wc(t,e=!1){return xt(t,Ee(typeof t=="string"?{category:t,allowTag:e}:{pool:t.map(q.lengthen)}),tt.resourceLocation)}function ea(t){return typeof t=="string"?xt(t,Bs(t)):xt(t,we(...t))}function xt(t,e,r,n){return(i,o)=>{if(i.expectation=[{type:"json:string",typedoc:IL(t),...n}],!dr.is(i))o.err.report(y("expected",y("string")),i);else if(e){let s=uo(Zn.resolve(e),i.value,i.valueMap,o);s!==V&&(i.children=[s],s.parent=i,r&&Zn.resolve(r)(s,o))}else r&&Zn.resolve(r)(i,o)}}function IL(t){return t?typeof t=="string"?`String("${t}")`:t.slice(0,10).map(e=>`"${e}"`).join(" | ")+(t.length>10?" | ...":""):"String"}var Me=xt();var E_=({meta:t})=>{t.registerLanguage("json",{extensions:[".json",".mcmeta"],triggerCharacters:k_,parser:Si}),t.registerParser("json:entry",Si),p_(t),w_(t),S_(t)};var M_=new Map([["advancement","::java::data::advancement::Advancement"],["dimension","::java::data::worldgen::dimension::Dimension"],["dimension_type","::java::data::worldgen::dimension::DimensionType"],["item_modifier","::java::data::item_modifier::ItemModifier"],["loot_table","::java::data::loot::LootTable"],["predicate","::java::data::predicate::Predicate"],["recipe","::java::data::recipe::Recipe"],["worldgen/biome","::java::data::worldgen::biome::Biome"],["worldgen/configured_carver","::java::data::worldgen::carver::ConfiguredCarver"],["worldgen/configured_surface_builder","::java::data::worldgen::surface_builder::ConfiguredSurfaceBuilder"],["worldgen/configured_feature","::java::data::feature::ConfiguredFeature"],["worldgen/configured_structure_feature","::java::data::worldgen::structure::Structure"],["worldgen/density_function","::java::data::worldgen::density_function::DensityFunction"],["worldgen/noise","::java::data::worldgen::dimension::biome_source::NoiseParameters"],["worldgen/noise_settings","::java::data::worldgen::noise_settings::NoiseGeneratorSettings"],["worldgen/processor_list","::java::data::worldgen::processor_list::ProcessorList"],["worldgen/template_pool","::java::data::worldgen::template_pool::TemplatePool"]]),ta=(t,e)=>{let r=_y(e.doc.uri,e);if(r&&M_.has(r.category)){let n=M_.get(r.category);return D_(n)(t,e)}else if(!r?.category.startsWith("tag/"))return e.doc.uri.endsWith("/pack.mcmeta")?D_("::java::Pack")(t,e):void 0};function N_(t){t.registerChecker("json:array",ta),t.registerChecker("json:boolean",ta),t.registerChecker("json:null",ta),t.registerChecker("json:number",ta),t.registerChecker("json:object",ta),t.registerChecker("json:string",ta)}function D_(t){return(e,r)=>{let i=r.symbols.query(r.doc,"mcdoc",t).getData(Co.TypeDefSymbolData.is)?.typeDef;if(i)switch(i.kind){case"struct":P_(i)(e,r);break;default:r.logger.error(`[json.checker.definition] Expected a struct type, but got ${i.kind}`)}}}function P_(t){return(e,r)=>{if(Pr.is(e))for(let{key:n,value:i}of e.children){if(!n||!i)continue;let o=n.value,s=t.fields.find(a=>a.kind==="pair"&&a.key===o);s?Th(s.type)(i,r):r.err.report(y("unknown-key",P(o)),n,2)}}}function Th(t){let e=(n,{kind:i,min:o=-1/0,max:s=1/0})=>{let a=(l,c,f)=>f?l{if(t.kind!=="any"&&t.kind!=="dispatcher"&&t.kind!=="enum"&&t.kind!=="literal"&&t.kind!=="reference"&&t.kind!=="union"&&t.kind!=="attributed"&&t.kind!=="unsafe"&&t.kind!=="concrete"&&t.kind!=="indexed"&&t.kind!=="template"&&n.type!==r[t.kind]){i.err.report(y("expected",Ah(r[t.kind])),n,2);return}switch(t.kind){case"boolean":break;case"byte_array":case"int_array":case"long_array":if(n=n,t.lengthRange&&!e(n.children.length,t.lengthRange)&&i.err.report(y("expected",y("json.checker.array.length-between",Ah(n.type),t.lengthRange.min??"-\u221E",t.lengthRange.max??"+\u221E")),n,2),t.valueRange)for(let{value:o}of n.children)o?.type!=="json:number"?i.err.report(y("expected",Ah("json:number")),n,2):o&&!e(Number(o.value),t.valueRange)&&i.err.report(y("number.between",t.valueRange.min??"-\u221E",t.valueRange.max??"+\u221E"),n,2);break;case"byte":case"short":case"int":case"long":case"float":case"double":n=n,t.valueRange&&!e(Number(n.value),t.valueRange)&&i.err.report(y("number.between",t.valueRange.min??"-\u221E",t.valueRange.max??"+\u221E"),n,2);break;case"dispatcher":n=n;break;case"list":n=n,t=cc(t),t.lengthRange&&!e(n.children.length,t.lengthRange)&&i.err.report(y("expected",y("json.checker.collection.length-between",Ah(n.type),t.lengthRange.min??"-\u221E",t.lengthRange.max??"+\u221E")),n,2);for(let{value:o}of n.children)o&&Th(t.item)(o,i);break;case"struct":n=n,P_(t)(n,i);break;case"string":break;case"reference":break;case"union":t=Gs(t),t.members.length===0?i.err.report(y("json.checker.object.field.union-empty-members"),kn.is(n.parent)?n.parent.key??n.parent:n,2):tt.any(t.members.map(o=>Th(o)))(n,i);break;case"attributed":Th(t.child)(n,i);break}}}function Ah(t){let e=`json.node.${t.replace(/^json:/,"")}`;return y(e)}var I_=t=>{E_(t),N_(t.meta)};function j_(t){t.registerColorizer("mcfunction:command_macro",jL),t.registerColorizer("mcfunction:command_child/literal",Ie.literal),t.registerColorizer("mcfunction:command_child/trailing",Ie.error)}var jL=(t,e)=>[Te.create(t,"string")];var Nh={};yr(Nh,{command:()=>V_,entry:()=>$L});var Oh;(function(t){function e(n){return n.type==="mcfunction:command"}t.is=e;function r(n){return{type:"mcfunction:command",range:v.get(n),children:[]}}t.mock=r})(Oh||(Oh={}));var F_=Object.freeze({is(t){return t?.type==="mcfunction:command_macro"}}),Rh;(function(t){function e(r){return r.type==="mcfunction:command_child"}t.is=e})(Rh||(Rh={}));var z_;(function(t){function e(r){return r?.type==="mcfunction:command_child/literal"}t.is=e})(z_||(z_={}));var Eh;(function(t){function e(r){return r?.type==="mcfunction:entry"}t.is=e})(Eh||(Eh={}));var Sc,Mh=class{constructor(){E(this,Sc,new Map);if(Mh._instance)throw new Error("Use the `instance` static property to get an instance.")}register(e,r,n){g(this,Sc).set(e,n?Ka(r,n):r)}get(e){let r=g(this,Sc).get(e);if(!r)throw new Error(`No command tree exist for version \u201C${e}\u201D`);return r}static get instance(){return this._instance??(this._instance=new Mh)}},pr=Mh;Sc=new WeakMap,H(pr,"_instance");function Iy(t,e){return e.reduce((r,n)=>r?.children?.[n],t)}function Ro(t,e,r){return t?.redirect?{treeNode:Iy(e,t.redirect),path:[...t.redirect]}:t&&!t.children&&!t.executable?{treeNode:e,path:[]}:{treeNode:t,path:r}}function Dh(t){let e={literalTreeNodes:[],argumentTreeNodes:[]};for(let r of Object.entries(t))r[1].type==="literal"?e.literalTreeNodes.push(r):r[1].type==="argument"&&e.argumentTreeNodes.push(r);return e}function $L(t,e){return(r,n)=>{let i=pr.instance.get(t),o=Ke.findChild(r,n.offset,!0);return Ya.is(o)||F_.is(o)?[]:V_(i,e)(o??Oh.mock(n.offset),n)}}function V_(t,e){return(r,n)=>{let i=Ke.findChildIndex(r,n.offset,!0),o=r.children[i]?.children[0];if(o)return re.dispatch(o,n);let s=Ke.findLastChild(r,n.offset);if(!s)return Object.keys(t.children??{}).map(u=>pe.create(u,n.offset,{kind:14}));let a=s.path,{treeNode:l}=Ro(Iy(t,a),t);if(!l?.children)return[];let{literalTreeNodes:c,argumentTreeNodes:f}=Dh(l.children);return[...c.map(([u])=>pe.create(u,n.offset,{kind:14})),...f.flatMap(([u,h])=>Ue.toArray(e(h,n.offset)).flatMap(d=>re.dispatch(d,n)))]}}function U_(t,e){let r=e.parser.slice(e.parser.indexOf(":")+1);return`<${t}: ${r}>`}var _c=(t,e)=>{let r=t.cursor,n=t.readSpace();return n!==" "&&e.err.report(y("expected",y("mcfunction.parser.sep",P(" "))),v.create(r,t)),n};function H_(t,e=!1){let r={pool:t,colorTokenType:e?"keyword":"literal"};return(n,i)=>{let o=n.cursor,s=n.readUntil(" ","\r",` +`);if(!s.length)return V;let a={type:"mcfunction:command_child/literal",range:v.create(o,n),options:r,value:s};return t.includes(s)||i.err.report(y("expected",t),a),a}}function Ph(t,e){return(r,n)=>{let i={type:"mcfunction:command",range:v.create(r),children:[]},o=r.cursor;if(r.trySkip("/")&&(i.slash=v.create(o,r.cursor)),zL(i.children,r,n,[],t,t,e),r.canReadInLine()){let s=VL(r,n);i.children.push({type:"mcfunction:command_child",range:s.range,children:[s],path:[]})}return i.range.end=r.cursor,i}}function zL(t,e,r,n,i,o,s){function a(c,f){let{treeNode:u,path:h}=Ro(f,i,c);c=h;let d=u?.children;if(!d)return!1;let{literalTreeNodes:p,argumentTreeNodes:b}=Dh(d),m=b.map(([R,x])=>({name:R,parser:s(x)??FL(x)})),k=p.length?H_(p.map(([R,x])=>R),u.type==="root"):void 0,S=[...k?[k]:[],...m.map(R=>R.parser)],_={index:0},C=(S.length>1?ar(S,_):S[0])(e,r);if(C!==V){let R=m[_.index-(k?1:0)]?.name??C.value,x=[...c,R];t.push({type:"mcfunction:command_child",range:C.range,children:[C],path:x});let T=d[R];if(!T)return!1;let O=T.permission??2;if(r.config.env.permissionLevel{let n=e.cursor,i=e.readUntilLineEnd(),o=v.create(n,e);return r.err.report(y("mcfunction.parser.unknown-parser",P(t.parser)),o,0),{type:"mcfunction:command_child/unknown",range:o,value:i}}}var VL=(t,e)=>{let r=t.cursor,n=t.readUntilLineEnd(),i=v.create(r,t);return e.err.report(y("mcfunction.parser.trailing",P(n)),i),{type:"mcfunction:command_child/trailing",range:i,value:n}};function UL(t,e){return e?`[${t}]`:t}function By(t,e=!1){return Object.entries(t).map(([n,i])=>UL(jy(n,i),e))}function HL(t){let e=By(t);return e.length>5?`${e.slice(0,3).join("|")}|...|${e.slice(-2).join("|")}`:e.join("|")}function jy(t,e){return e.type==="argument"?U_(t,e):t}function W_(t,e){return(r,n)=>{let i={type:"mcfunction:entry",range:v.create(r),children:[]};for(;r.skipWhitespace().canReadInLine();){let o;if(r.peek()==="#")o=WL(r,n);else if(r.peek()==="$"){let s=r.cursor;r.skipLine(),o={type:"mcfunction:command_macro",range:v.create(s,r)}}else o=Ph(pr.instance.get(t),e)(r,n);i.children.push(o),r.nextLine()}return i.range.end=r.cursor,i}}var WL=Rl({singleLinePrefixes:new Set(["#"])});var q_=({meta:t})=>{j_(t),t.registerCompleter("mcfunction:command_child/literal",re.literal)};function qL(t,e,r){return r.symbols.query(r.doc,t,q.lengthen(e)).symbol?.definition?.map(n=>n.uri)??[]}function Eo(t,e,r){let n=o=>dr.is(o)?o.value:o.children.find(s=>s.key?.value==="id").value.value;return[...qL(t,e,r).reduce((o,s)=>o,new Set)]}function K_(){let t=/^[0-9a-f]{1,6}$/i,e=(r,n)=>{let i=0,o=r.cursor;if(r.trySkip("#")){let s=r.readRemaining();s.match(t)?i=parseInt(s,16):n.err.report(y("expected",y("json.checker.string.hex-color")),v.create(o,r))}else{let s=r.readRemaining();dt.NamedColors.has(s)?i=dt.NamedColors.get(s):n.err.report(y("expected",dt.ColorNames),v.create(o,r))}return dt.fromCompositeInt(i)};return(r,n)=>{if(r.expectation=[{type:"json:string",typedoc:'String("Color")',pool:dt.ColorNames}],!dr.is(r))n.err.report(y("expected",y("string")),r);else{let i=uo(e,r.value,r.valueMap,n);i!==V&&(r.color={value:i,format:[jt.HexRGB],range:{start:r.range.start+1,end:r.range.end-1}})}}}function $y(t){return KL(t)?GL(t):ZL(t)}function KL(t){return typeof t.definition=="string"}function GL({definition:t}){return(e,r)=>{if(!r.ensureBindingStarted){Me(e,r);return}let n=r.meta.getParserLazily("nbt:compound"),i=it.definition(t);xt("nbt",n,i)(e,r)}}function ZL(t){return(e,r)=>{let n=G_(t,r);if(!r.ensureBindingStarted){Me(e,r);return}let i=r.meta.getParser("nbt:compound"),o=it.index(t.registry,n);xt("nbt",i,o)(e,r)}}function Lh(t){return(e,r)=>{let n=G_(t,r);if(!r.ensureBindingStarted){Me(e,r);return}let i=r.meta.getParser("nbt:path"),o=it.path(t.registry,n);xt("nbt_path",i,o)(e,r)}}function G_({registry:t,id:e,idOrTag:r,ids:n,tag:i},o){return r&&(r.startsWith("#")?i=r.slice(1):e=r),i&&(t==="block"||t==="item"||t==="entity_type")?n=Eo(`tag/${t}`,i,o):e&&(n=[e]),n?.map(q.lengthen)}var XU=xt("recipe_group",Bs("recipe_group"));var JL=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,zy=xt(void 0,void 0,(t,e)=>{t.value.match(JL)||e.err.report(y("expected",y("uuid")),t)});function YL(t){return t.project.loadedVersion}function Fy(t,e){return ot.cmp(YL(t),e)}function ra(t,e,r,n){if(typeof e=="string"){let i=Fy(t,e)>=0;return r===void 0?r:Array.isArray(r)?i?r:[]:i?r:void 0}else{let i=Fy(t,r)<0;return e===void 0?e:Array.isArray(e)?i?e:n??[]:i?e:n??void 0}}function Ih(t,e,r){return Fy(t,e)<0?r:O_(r)}var XL=["key.jump","key.sneak","key.sprint","key.left","key.right","key.back","key.forward","key.attack","key.pickItem","key.use","key.drop","key.hotbar.1","key.hotbar.2","key.hotbar.3","key.hotbar.4","key.hotbar.5","key.hotbar.6","key.hotbar.7","key.hotbar.8","key.hotbar.9","key.inventory","key.swapOffhand","key.loadToolbarActivator","key.saveToolbarActivator","key.playerlist","key.chat","key.command","key.socialInteractions","key.advancements","key.spectatorOutlines","key.screenshot","key.smoothCamera","key.fullscreen","key.togglePerspective"],QL=Ny("text_component",(t,e)=>Dn({...Ly(t,e,{text:{text:Me},translate:{translate:Me,with:le(vc(cn),[])},selector:{selector:Me,separator:le(ra(e,"1.17",cn))},score:{score:Dn({name:Me,objective:Me,value:le(Me)})},keybind:{keybind:ea(XL)},nbt:()=>({nbt:Me,...Ly(t,e,{block:{block:Me,nbt:Lh({registry:"block"})},entity:{entity:Me,nbt:Lh({registry:"entity_type"})},storage:{storage:wc("storage"),nbt:Lh({registry:"storage"})}}),interpret:le(_i,!1),separator:le(ra(e,"1.17",cn))})}),color:le(K_()),font:le(Me),bold:le(_i),italic:le(_i),underlined:le(_i),strikethrough:le(_i),obfuscated:le(_i),insertion:le(Me),clickEvent:le(Ch("action",r=>Dn({action:ea(["open_url","open_file","run_command","suggest_command","change_page","copy_to_clipboard"]),value:Me,...Py(r,{run_command:{value:xt("command",e.meta.getParserLazily("mcfunction:command"),e.meta.getChecker("mcfunction:command"))},change_page:{value:xt("number",Ar({pattern:/\d+/,min:0}))}})}))),hoverEvent:le(Ch("action",(r,n,i)=>Dn({action:ea(["show_text","show_item","show_entity"]),...Py(r,{show_text:{value:Ih(i,"1.16",cn),contents:le(ra(i,"1.16",cn))},show_item:{value:Ih(i,"1.16",$y({definition:"::minecraft::util::invitem::InventoryItem"})),contents:le(ra(i,"1.16",Ch(o=>Dn({id:wc("item"),count:le(A_),tag:le($y({registry:"item",id:R_("id",o)}))}))))},show_entity:{value:Ih(i,"1.16",Dn({name:le(Me),type:le(wc("entity_type")),id:le(zy)})),contents:le(ra(i,"1.16",Dn({name:le(cn),type:le(wc("entity_type")),id:le(zy)})))}})}))),extra:le(vc(cn))})(t,e)),cn=Ny("text_component",Qs([Me,QL,vc(C_(()=>cn))]));var Bh;(function(t){function e(r){return r.type==="mcfunction:block/states"}t.is=e})(Bh||(Bh={}));var Lr;(function(t){function e(n){return n?.type==="mcfunction:block"}t.is=e;function r(n,i){let o=U.mock(n,{category:"block",allowTag:i});return{type:"mcfunction:block",range:v.get(n),children:[o],id:o}}t.mock=r})(Lr||(Lr={}));var jh;(function(t){function e(n){return{type:"mcfunction:coordinate",range:v.get(n),notation:"",value:0}}t.mock=e;function r(n){let i=n.value%360;return i>=180?i-360:i<-180?i+360:i}t.toDegree=r})(jh||(jh={}));var $h;(function(t){function e(r){return r.type==="mcfunction:entity_selector/arguments"}t.is=e})($h||($h={}));var J_=["a","e","p","r","s"],Z_;(function(t){function e(r){return J_.includes(r)}t.is=e})(Z_||(Z_={}));var Ac=J_.map(t=>`@${t}`),na;(function(t){function e(r){return Ac.includes(r)}t.is=e})(na||(na={}));var Ir;(function(t){function e(i){return i?.type==="mcfunction:entity_selector"}t.is=e;function r(i){let o=Ae.mock(i,{pool:Ac,colorTokenType:"keyword"});return{type:"mcfunction:entity_selector",range:v.get(i),children:[o],variable:"e"}}t.mock=r,t.ArgumentKeys=new Set(["advancements","distance","gamemode","level","limit","name","nbt","predicate","scores","sort","tag","team","type","x","y","z","dx","dy","dz","x_rotation","y_rotation"]);function n(i,o,s){let a=c=>!!o.children.find(f=>f.key?.value===c),l=c=>!!o.children.find(f=>f.key?.value===c&&!f.value?.inverted);switch(s){case"advancements":case"distance":case"level":case"scores":case"x":case"y":case"z":case"dx":case"dy":case"dz":case"x_rotation":case"y_rotation":return a(s)?1:0;case"gamemode":case"name":case"team":return l(s)?1:0;case"limit":case"sort":return i.currentEntity?2:a(s)?1:0;case"type":return i.typeLimited?a(s)?1:2:0}return 0}t.canKeyExist=n})(Ir||(Ir={}));var ia;(function(t){function e(r){return r?.type==="mcfunction:entity"}t.is=e})(ia||(ia={}));var Ci;(function(t){function e(n){return n?.type==="mcfunction:item"}t.is=e;function r(n,i){let o=U.mock(n,{category:"item",allowTag:i});return{type:"mcfunction:item",range:v.get(n),children:[o],id:o}}t.mock=r})(Ci||(Ci={}));var zh;(function(t){function e(r){return{type:"mcfunction:int_range",range:v.get(r),children:[],value:[void 0,void 0]}}t.mock=e})(zh||(zh={}));var Ai;(function(t){t.SimpleValues=["air","armor","deathCount","dummy","food","health","level","playerKillCount","totalKillCount","trigger","xp"],t.ComplexCategories=new Map([["broken","item"],["crafted","item"],["custom","custom_stat"],["dropped","item"],["killed","entity_type"],["killed_by","entity_type"],["mined","block"],["picked_up","item"],["used","item"]]),t.ComplexSep=":";function e(r){return{type:"mcfunction:objective_criteria",range:v.get(r)}}t.mock=e})(Ai||(Ai={}));var Mo;(function(t){let e=new Set(["block","block_marker","dust","dust_color_transition","falling_dust","item","sculk_charge","shriek","vibration"]);function r(o){return e.has(o)}t.isSpecialType=r;function n(o){return o?.type==="mcfunction:particle"}t.is=n;function i(o){let s=U.mock(o,{category:"particle_type"});return{type:"mcfunction:particle",range:v.get(o),children:[s],id:s}}t.mock=i})(Mo||(Mo={}));var Fh;(function(t){function e(r){let n=or.mock(r,{category:"score_holder"});return{type:"mcfunction:score_holder",range:v.get(r),children:[n],fakeName:n}}t.mock=e})(Fh||(Fh={}));var Vh;(function(t){t.UnitToTicks=new Map([["",1],["t",1],["s",20],["d",24e3]]),t.Units=[...t.UnitToTicks.keys()]})(Vh||(Vh={}));var Ut;(function(t){function e(r,n){return{type:"mcfunction:vector",range:v.get(r),children:[],options:n,system:0}}t.mock=e})(Ut||(Ut={}));var eI=(t,e)=>{t.slash&&t.parent&&Eh.is(t.parent)&&e.err.report(y("unexpected-leading-slash"),t.slash),Y_(t.children,0,e)},Ht=(t,e)=>t[e]?.path[t[e].path.length-1],Wt=(t,e)=>t[e]?.children[0],Y_=(t,e,r)=>{for(let{children:[n]}of t)Lr.is(n)?X_(n,r):ia.is(n)?Q_(n,r):Ci.is(n)?eC(n,r):Mo.is(n)?tC(n,r):xh.is(n)&&cn(n,{...r,context:""});if(Ht(t,e)==="data")if(Ht(t,e+1)==="get")Uh(t,e+2,r);else if(Ht(t,e+1)==="merge")tI(t,e+2,r);else if(Ht(t,e+1)==="modify"){Uh(t,e+2,r);let n=Wt(t,e+4)}else Ht(t,e+1)==="remove"&&Uh(t,e+2,r);else if(Ht(t,e)==="execute"){for(let n=e+1;n{t.nbt&&it.index("block",U.toString(t.id,"full"))(t.nbt,e)},Q_=(t,e)=>{let r=t.selector?.arguments?.children.find(o=>o.key?.value==="nbt");if(!r)return;let n=Vy(t,e),i=r.value;it.index("entity_type",n)(i,e)},eC=(t,e)=>{t.nbt&&it.index("item",U.toString(t.id,"full"))(t.nbt,e)},tC=(t,e)=>{tt.dispatchSync(t,e)},tI=(t,e,r)=>{switch(Ht(t,e)){case"block":{let i=Wt(t,e+2);Nr.is(i)&&it.index("block",void 0)(i,r);break}case"entity":{let i=Wt(t,e+1),o=Wt(t,e+2);if(ia.is(i)&&Nr.is(o)){let s=Vy(i,r);it.index("entity_type",s)(o,r)}break}case"storage":{let i=Wt(t,e+1),o=Wt(t,e+2);U.is(i)&&Nr.is(o)&&it.index("storage",U.toString(i,"full"))(o,r);break}}},Uh=(t,e,r)=>{switch(Ht(t,e)){case"block":{let i=Wt(t,e+2);Ys.is(i)&&it.path("block",void 0)(i,r);break}case"entity":{let i=Wt(t,e+1),o=Wt(t,e+2);if(ia.is(i)&&Ys.is(o)){let s=Vy(i,r);it.path("entity_type",s)(o,r)}break}case"storage":{let i=Wt(t,e+1),o=Wt(t,e+2);U.is(i)&&Ys.is(o)&&it.path("storage",U.toString(i,"full"))(o,r);break}}},rI=(t,e,r)=>{let n=Wt(t,e),i=Wt(t,e+2);U.is(n)&&Nr.is(i)&&it.index("entity_type",U.toString(n,"full"))(i,r)},Vy=(t,e)=>{if(t.playerName!==void 0||t.selector?.playersOnly)return["minecraft:player"];if(t.selector){let r=t.selector.arguments;if(!r)return;let n=[];for(let i of r.children){if(i.key?.value!=="type")continue;let o=i.value;if(!o||o.inverted)continue;let s=U.toString(o.value,"full",!0);if(s.startsWith(q.TagPrefix)){let a=Eo("tag/entity_type",s.slice(1),e);n=n.filter(l=>a.includes(l))}else n=[s]}return n}};function rC(t){t.registerChecker("mcfunction:command",eI),t.registerChecker("mcfunction:block",X_),t.registerChecker("mcfunction:entity",Q_),t.registerChecker("mcfunction:item",eC),t.registerChecker("mcfunction:particle",tC)}var nI=t=>[Te.create(t,"type")],iI=t=>[Te.create(t,"vector")];function iC(t){t.registerColorizer("mcfunction:coordinate",Ie.number),t.registerColorizer("mcfunction:vector",iI),t.registerColorizer("mcfunction:objective_criteria",nI)}var Hh=[...dt.ColorNames,"reset"],Wh=["feet","eyes"],Tc=["adventure","survival","creative","spectator"],qh=[...[...Array(54).keys()].map(t=>`container.${t}`),...[...Array(27).keys()].map(t=>`enderchest.${t}`),...[...Array(15).keys()].map(t=>`horse.${t}`),...[...Array(9).keys()].map(t=>`hotbar.${t}`),...[...Array(27).keys()].map(t=>`inventory.${t}`),...[...Array(8).keys()].map(t=>`villager.${t}`),"armor.chest","armor.feet","armor.head","armor.legs","horse.armor","horse.chest","horse.saddle","weapon","weapon.mainhand","weapon.offhand"],Kh=["=","+=","-=","*=","/=","%=","<",">","><"],Gh=["belowName","list","sidebar",...dt.ColorNames.map(t=>`sidebar.team.${t}`)],Zh=["x","xy","xz","xyz","xzy","y","yx","yz","yxz","yzx","z","zx","zy","zxy","zyx"],Jh=["motion_blocking","motion_blocking_no_leaves","ocean_floor","ocean_floor_wg","world_surface","world_surface_wg"],Yh=["none","clockwise_90","180","counterclockwise_90"],Xh=["none","left_right","front_back"];var sC=(t,e)=>{let r=t;switch(r.parser){case"brigadier:bool":return fu.mock(e);case"brigadier:double":case"brigadier:float":case"brigadier:integer":case"brigadier:long":case"minecraft:float_range":case"minecraft:message":case"minecraft:time":case"minecraft:uuid":return[];case"brigadier:string":return r.properties.type==="phrase"?et.mock(e,ui):[];case"minecraft:angle":return jh.mock(e);case"minecraft:block_pos":return Ut.mock(e,{dimension:3,integersOnly:!0});case"minecraft:block_predicate":return Lr.mock(e,!0);case"minecraft:block_state":return Lr.mock(e,!1);case"minecraft:color":return Ae.mock(e,{pool:Hh});case"minecraft:column_pos":return Ut.mock(e,{dimension:2,integersOnly:!0});case"minecraft:component":return[Oo.mock(e),Pr.mock(e),dr.mock(e)];case"minecraft:dimension":return U.mock(e,{category:"dimension"});case"minecraft:entity":case"minecraft:game_profile":return Ir.mock(e);case"minecraft:heightmap":return Ae.mock(e,{pool:Jh});case"minecraft:entity_anchor":return Ae.mock(e,{pool:Wh});case"minecraft:entity_summon":return U.mock(e,{category:"entity_type"});case"minecraft:function":return U.mock(e,{category:"function"});case"minecraft:gamemode":return Ae.mock(e,{pool:Tc});case"minecraft:int_range":return zh.mock(e);case"minecraft:item_enchantment":return U.mock(e,{category:"enchantment"});case"minecraft:item_predicate":return Ci.mock(e,!0);case"minecraft:item_slot":return Ae.mock(e,{pool:qh});case"minecraft:item_stack":return Ci.mock(e,!1);case"minecraft:mob_effect":return U.mock(e,{category:"mob_effect"});case"minecraft:objective":return or.mock(e,{category:"objective"});case"minecraft:objective_criteria":return Ai.mock(e);case"minecraft:operation":return Ae.mock(e,{pool:Kh,colorTokenType:"operator"});case"minecraft:particle":return Mo.mock(e);case"minecraft:resource":case"minecraft:resource_key":case"minecraft:resource_or_tag":return U.mock(e,{category:q.shorten(r.properties.registry),allowTag:r.parser==="minecraft:resource_or_tag"});case"minecraft:resource_location":return U.mock(e,r.properties??{pool:[],allowUnknown:!0});case"minecraft:rotation":return Ut.mock(e,{dimension:2,noLocal:!0});case"minecraft:scoreboard_slot":return Ae.mock(e,{pool:Gh});case"minecraft:score_holder":return Fh.mock(e);case"minecraft:swizzle":return Ae.mock(e,{pool:Zh});case"minecraft:team":return or.mock(e,{category:"team"});case"minecraft:template_mirror":return Ae.mock(e,{pool:Xh});case"minecraft:template_rotation":return Ae.mock(e,{pool:Yh});case"minecraft:vec2":return Ut.mock(e,{dimension:2,integersOnly:!0});case"minecraft:vec3":return Ut.mock(e,{dimension:3});case"spyglassmc:tag":return or.mock(e,{category:"tag"});case"minecraft:nbt_compound_tag":case"minecraft:nbt_path":case"minecraft:nbt_tag":default:return[]}},oI=(t,e)=>{let r=[];return v.contains(t.id,e.offset,!0)&&r.push(...re.resourceLocation(t.id,e)),t.states&&v.contains(v.translate(t.states,1,-1),e.offset,!0)&&r.push(...sI(t.states,e)),r},sI=(t,e)=>{if(!Lr.is(t.parent))return[];let r=t.parent.id,n=U.toString(r,"full"),i=r.isTag?Eo("tag/block",n,e):[n],o=Ga("block",i,e);return re.record({key:(s,a,l,c,f,u,h)=>Object.keys(o).filter(d=>a?.key?.value===d||!h.some(p=>p.value===d)).map(d=>pe.create(d,c,{kind:10,detail:y("mcfunction.completer.block.states.default-value",P(o[d][0])),insertText:new al().literal(d).if(f,p=>p.literal("=").placeholder(...o[d])).if(u,p=>p.literal(",")).build()})),value:(s,a,l)=>a.key&&o[a.key.value]?o[a.key.value].map(c=>pe.create(c,a.value??l.offset,{kind:12})):[]})(t,e)},aI=(t,e)=>[pe.create("~",t)],lI=(t,e)=>{let r=[];return v.contains(t.id,e.offset,!0)&&r.push(...re.resourceLocation(t.id,e)),r},cI=(t,e)=>{let r=Ai.SimpleValues.map(n=>pe.create(n,t));return(!t.children?.[0]||v.contains(t.children[0],e.offset,!0))&&r.push(...re.resourceLocation(t.children?.[0]??U.mock(t,{category:"stat_type",namespacePathSep:"."}),e)),t.children?.[1]&&v.contains(t.children[1],e.offset,!0)&&r.push(...re.resourceLocation(t.children[1],e)),r},fI=(t,e)=>{let r=Ke.findChild(t,e.offset,!0);if(r)return re.dispatch(r,e);let n=U.toString(t.id,"short"),i={block:[Lr.mock(e.offset,!1)],block_marker:[Lr.mock(e.offset,!1)],dust:[Ut.mock(e.offset,{dimension:3}),Sr.mock(e.offset)],dust_color_transition:[Ut.mock(e.offset,{dimension:3}),Sr.mock(e.offset),Ut.mock(e.offset,{dimension:3})],falling_dust:[Lr.mock(e.offset,!1)],item:[Ci.mock(e.offset,!1)],sculk_charge:[Sr.mock(e.offset)],shriek:[Ki.mock(e.offset)],vibration:[Ut.mock(e.offset,{dimension:3}),Ut.mock(e.offset,{dimension:3}),Ki.mock(e.offset)]};if(Mo.isSpecialType(n)){let o=t.children?.slice(1).filter(a=>a.range.end{let r;return t.selector&&v.contains(t.selector,e.offset,!0)?(r=Uy(t.selector,e),v.contains(t.children[0],e.offset,!0)&&r.push(...re.symbol(or.mock(t,{category:"score_holder"}),e))):(r=re.symbol(t.fakeName??or.mock(t,{category:"score_holder"}),e),r.push(...Uy(Ir.mock(t),e))),r},Uy=(t,e)=>v.contains(t.children[0],e.offset,!0)?re.literal(t.children[0],e):t.arguments&&v.contains(v.translate(t.arguments,1,-1),e.offset,!0)?aC(t.arguments,e):[],aC=(t,e)=>{let r=t.parent;return Ir.is(r)?re.record({key:(n,i,o,s,a,l)=>[...Ir.ArgumentKeys].filter(c=>Ir.canKeyExist(r,n,c)===0).map(c=>pe.create(c,s,{kind:10,insertText:new al().literal(c).if(a,f=>f.literal("=").placeholder()).if(l,f=>f.literal(",")).build()})),value:(n,i,o)=>i.value?re.dispatch(i.value,o):[]})(t,e):[]},hI=(t,e)=>[pe.create("-2147483648..2147483647",t,{kind:21})],dI=(t,e)=>{let r=(i,o)=>pe.create(new Array(t.options.dimension).fill(i).join(" "),t,{sortText:o}),n=[];return n.push(r("~","a")),t.options.noLocal||n.push(r("^","b")),n.push(r("0.0","c")),n};function lC(t){t.registerCompleter("mcfunction:block",oI),t.registerCompleter("mcfunction:coordinate",aI),t.registerCompleter("mcfunction:entity_selector",Uy),t.registerCompleter("mcfunction:entity_selector/arguments",aC),t.registerCompleter("mcfunction:int_range",hI),t.registerCompleter("mcfunction:item",lI),t.registerCompleter("mcfunction:objective_criteria",cI),t.registerCompleter("mcfunction:particle",fI),t.registerCompleter("mcfunction:score_holder",uI),t.registerCompleter("mcfunction:vector",dI)}var fC=(t,e)=>{if(t.children[0]?.type!=="mcfunction:entry")return[];let r=[];return At(t,n=>!0,Rh.is,n=>{let i=n,o=e.config.env.feature.inlayHint;(o===!0||typeof o=="object"&&o.enabledNodes.includes(i.children[0].type))&&r.push({offset:i.range.start,text:`${i.path[i.path.length-1]}:`})}),r};var hC=/^-?\d+$/,dC=/^-?(?:\d+\.?\d*|\.\d+)$/,pC=Number.MAX_VALUE,pI=-pC,mC=(2-2**-23)*2**127,mI=-mC,gI=2**31-1,yI=-(2**31),gC=9223372036854775807n,bI=-9223372036854775808n,kI=40,vI=16,wI=16;function xI(t){let e=t.project.loadedVersion;return!e||ot.cmp(e,"1.18")<0}var Wy=t=>{let e=t,r=n=>oe(Tn(n,"\r",` +`));switch(e.parser){case"brigadier:bool":return r($u);case"brigadier:double":return r(ed(e.properties?.min,e.properties?.max));case"brigadier:float":return r(aa(e.properties?.min,e.properties?.max));case"brigadier:integer":return r(la(e.properties?.min,e.properties?.max));case"brigadier:long":return r(SI(e.properties?.min,e.properties?.max));case"brigadier:string":switch(e.properties.type){case"word":return r(SC);case"phrase":return r(ho);case"greedy":default:return r(bC)}case"minecraft:angle":return r(Is(Hy(),n=>n.notation!=="^",y("mcfunction.parser.vector.local-disallowed")));case"minecraft:block_pos":return r(oa({dimension:3,integersOnly:!0}));case"minecraft:block_predicate":return r(qy);case"minecraft:block_state":return r(Qh);case"minecraft:color":return r(J(we(...Hh),n=>({...n,color:dt.NamedColors.has(n.value)?dt.fromCompositeInt(dt.NamedColors.get(n.value)):void 0})));case"minecraft:column_pos":return r(oa({dimension:2,integersOnly:!0}));case"minecraft:component":return r(Ky);case"minecraft:dimension":return r(Ee({category:"dimension"}));case"minecraft:entity":return r(uC(e.properties.amount,e.properties.type));case"minecraft:entity_anchor":return r(we(...Wh));case"minecraft:entity_summon":return r(Ee({category:"entity_type"}));case"minecraft:float_range":return r(sa("float"));case"minecraft:function":return r(Ee({category:"function",allowTag:!0}));case"minecraft:gamemode":return r(we(...Tc));case"minecraft:game_profile":return r(uC("multiple","players"));case"minecraft:heightmap":return r(we(...Jh));case"minecraft:int_range":return r(sa("integer"));case"minecraft:item_enchantment":return r(Ee({category:"enchantment"}));case"minecraft:item_predicate":return r(_I);case"minecraft:item_slot":return r(we(...qh));case"minecraft:item_stack":return r(vC);case"minecraft:message":return r(CI);case"minecraft:mob_effect":return r(Ee({category:"mob_effect"}));case"minecraft:nbt_compound_tag":return r(ln.compound);case"minecraft:nbt_path":return r(ln.path);case"minecraft:nbt_tag":return r(ln.entry);case"minecraft:objective":return r(xC(el.is(e.properties?.usageType)?e.properties?.usageType:void 0));case"minecraft:objective_criteria":return r(RI);case"minecraft:operation":return r(we({pool:Kh,colorTokenType:"operator"}));case"minecraft:particle":return r(Gy);case"minecraft:resource":case"minecraft:resource_key":case"minecraft:resource_or_tag":return r(Ee({category:q.shorten(e.properties.registry),allowTag:e.parser==="minecraft:resource_or_tag"}));case"minecraft:resource_location":return r(Ee(e.properties??{pool:[],allowUnknown:!0}));case"minecraft:rotation":return r(oa({dimension:2,noLocal:!0}));case"minecraft:score_holder":return r(OI(e.properties.amount));case"minecraft:scoreboard_slot":return r(we(...Gh));case"minecraft:swizzle":return r(we(...Zh));case"minecraft:team":return r(rd(el.is(e.properties?.usageType)?e.properties?.usageType:void 0));case"minecraft:template_mirror":return r(we(...Xh));case"minecraft:template_rotation":return r(we(...Yh));case"minecraft:time":return r(EI);case"minecraft:uuid":return r(_C);case"minecraft:vec2":return r(oa({dimension:2,noLocal:!0}));case"minecraft:vec3":return r(oa({dimension:3}));case"spyglassmc:tag":return r(td());default:return}};function yC(t){return J(be([Ee({category:"block",allowTag:t}),ke(J(oe(Tr({start:"[",pair:{key:pt({...ui,colorTokenType:"property"}),sep:"=",value:ho,end:",",trailingEnd:!0},end:"]"})),e=>({...e,type:"mcfunction:block/states"}))),ke(oe(ln.compound))]),e=>({type:"mcfunction:block",range:e.range,children:e.children,id:e.children.find(U.is),states:e.children.find(Bh.is),nbt:e.children.find(Nr.is)}))}var Qh=yC(!1),qy=yC(!0),Ky=mc.json();function ed(t=pI,e=pC){return en({pattern:dC,min:t,max:e})}function aa(t=mI,e=mC){return en({pattern:dC,min:t,max:e})}function la(t=yI,e=gI){return Ar({pattern:hC,min:t,max:e})}function SI(t,e){return El({pattern:hC,min:BigInt(t??bI),max:BigInt(e??gC)})}function Hy(t=!1){return(e,r)=>{let n={type:"mcfunction:coordinate",notation:"",range:v.create(e),value:0};if(e.trySkip("^")?n.notation="^":e.trySkip("~")&&(n.notation="~"),e.canReadInLine()&&e.peek()!==" "||n.notation===""){let i=(t&&n.notation===""?la:ed)()(e,r);n.value=Number(i.value)}return n.range.end=e.cursor,n}}function uC(t,e){return J(ne([{predicate:r=>na.is(r.peek(2)),parser:Zy()},{parser:ar([Yy(ho,wI,"mcfunction.parser.entity-selector.player-name.too-long"),_C])}]),(r,n,i)=>{let o={type:"mcfunction:entity",range:r.range,children:[r]};return et.is(r)?o.playerName=r:Ir.is(r)?o.selector=r:o.uuid=r,t==="single"&&o.selector&&!o.selector.single&&i.err.report(y("mcfunction.parser.entity-selector.multiple-disallowed"),o),e==="players"&&(o.uuid||o.selector&&!o.selector.playersOnly&&!o.selector.currentEntity)&&i.err.report(y("mcfunction.parser.entity-selector.entities-disallowed"),o),o})}var bC=pt({unquotable:{blockList:new Set([` +`,"\r"])}});function kC(t){return J(be([Ee({category:"item",allowTag:t}),ke(oe(ln.compound))]),e=>({type:"mcfunction:item",range:e.range,children:e.children,id:e.children.find(U.is),nbt:e.children.find(Nr.is)}))}var vC=kC(!1),_I=kC(!0),CI=(t,e)=>{let r={type:"mcfunction:message",range:v.create(t),children:[]};for(;t.canReadInLine();)na.is(t.peek(2))?r.children.push(Zy()(t,e)):r.children.push(Tn(bC,...Ac)(t,e));return r},Gy=(()=>{let t=J(_c,()=>[]),e=oa({dimension:3}),r=J(e,i=>({...i,color:i.children.length===3?{value:dt.fromDecRGB(i.children[0].value,i.children[1].value,i.children[2].value),format:[jt.DecRGB]}:void 0})),n={block:Qh,block_marker:Qh,dust:be([r,aa()],t),dust_color_transition:be([r,aa(),r],t),falling_dust:Qh,item:vC,sculk_charge:aa(),shriek:la(),vibration:be([e,la()],t)};return J(be([Ee({category:"particle_type"}),{get:i=>n[U.toString(i.children[0],"short")]}],t),i=>({type:"mcfunction:particle",range:i.range,children:i.children,id:i.children.find(U.is)}))})();function sa(t,e,r,n){let i=t==="float"?aa(e,r):la(e,r),o=oe(Tn(i,"..")),s=oe(we({pool:[".."],colorTokenType:"keyword"})),a=oe(i);return J(ar([be([o]),be([o,s]),be([s,a]),be([o,s,a])]),(l,c,f)=>{let u=t==="float"?l.children.filter(Sr.is):l.children.filter(Ki.is),h=l.children.find(Ae.is),d={type:t==="float"?"mcfunction:float_range":"mcfunction:int_range",range:l.range,children:l.children,value:h?u.length===2?[u[0].value,u[1].value]:v.endsBefore(u[0].range,h.range.start)?[u[0].value,void 0]:[void 0,u[0].value]:[u[0].value,u[0].value]};return!n&&d.value[0]!==void 0&&d.value[1]!==void 0&&d.value[0]>d.value[1]&&f.err.report(y("mcfunction.parser.range.min>max",d.value[0],d.value[1]),l),d})}function Zy(){let t,e,r,n,i,o,s;return J(be([oe(we({pool:Ac,colorTokenType:"keyword"})),{get:a=>{let l=Ae.is(a.children?.[0])?a.children[0].value:void 0;e=l?l==="@s":void 0,n=l?l==="@p"||l==="@a"||l==="@r":void 0,i=l==="@e"?["Entity::isAlive"]:void 0,o=l?l==="@p"||l==="@r"||l==="@s":void 0,s=n;function c(f){return J(be([ke(oe(we({pool:["!"],colorTokenType:"keyword"}))),u=>{u.skipSpace()},f]),u=>({type:"mcfunction:entity_selector/arguments/value/invertable",range:u.range,children:u.children,inverted:!!u.children.find(d=>Ae.is(d)&&d.value==="!"),value:u.children.find(d=>!Ae.is(d)||d.value!=="!")}))}return ke(J(oe(Tr({start:"[",pair:{key:pt({...ui,value:{parser:we({pool:[...Ir.ArgumentKeys],colorTokenType:"property"}),type:"literal"}}),sep:"=",value:{get:(f,u)=>{let h=p=>!!f.children.find(b=>b.key?.value===p),d=p=>!!f.children.find(b=>b.key?.value===p&&!b.value?.inverted);switch(u?.value){case"advancements":return J(Tr({start:"{",pair:{key:Ee({category:"advancement"}),sep:"=",value:ne([{predicate:p=>p.peek()==="{",parser:J(Tr({start:"{",pair:{key:SC,sep:"=",value:$u,end:",",trailingEnd:!0},end:"}"}),p=>({...p,type:"mcfunction:entity_selector/arguments/advancements/criteria"}))},{parser:$u}]),end:",",trailingEnd:!0},end:"}"}),(p,b,m)=>(h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),{...p,type:"mcfunction:entity_selector/arguments/advancements"}));case"distance":return J(sa("float",0),(p,b,m)=>(r=!0,t??=!n&&p.value[1]!==void 0,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"gamemode":return J(c(pt({unquotable:Ml,value:{type:"literal",parser:we(...Tc)}})),(p,b,m)=>(n=!0,(p.inverted?d(u.value):h(u.value))&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"limit":return J(la(0),(p,b,m)=>(o=p.value<=1,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),e&&m.err.report(y("mcfunction.parser.entity-selector.arguments.not-applicable",P(u.value)),u),p));case"level":return J(sa("integer",0),(p,b,m)=>(n=!0,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"name":return J(c(ho),(p,b,m)=>((p.inverted?d(u.value):h(u.value))&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"nbt":return c(ln.compound);case"predicate":return c(Ee({category:"predicate"}));case"scores":return J(Tr({start:"{",pair:{key:xC("reference",["[","=",",","]","{","}"]),sep:"=",value:sa("integer"),end:",",trailingEnd:!0},end:"}"}),(p,b,m)=>(h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),{...p,type:"mcfunction:entity_selector/arguments/scores"}));case"sort":return J(pt({unquotable:Ml,value:{type:"literal",parser:we("arbitrary","furthest","nearest","random")}}),(p,b,m)=>(h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),e&&m.err.report(y("mcfunction.parser.entity-selector.arguments.not-applicable",P(u.value)),u),p));case"tag":return c(td(["[","=",",","]","{","}"]));case"team":return J(c(rd("reference",["[","=",",","]","{","}"])),(p,b,m)=>((p.inverted?d(u.value):h(u.value))&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"type":return J(c(Ee({category:"entity_type",allowTag:!0})),(p,b,m)=>(s?h(u.value)?m.err.report(y("duplicate-key",P(u.value)),u):m.err.report(y("mcfunction.parser.entity-selector.arguments.not-applicable",P(u.value)),u):!p.inverted&&!p.value.isTag&&(s=!0,U.toString(p.value,"short")==="player"&&(n=!0)),p));case"x":case"y":case"z":return J(ed(),(p,b,m)=>(r=!0,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"dx":case"dy":case"dz":return J(ed(),(p,b,m)=>(r=!0,t=!n,h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case"x_rotation":case"y_rotation":return J(sa("float",void 0,void 0,!0),(p,b,m)=>(h(u.value)&&m.err.report(y("duplicate-key",P(u.value)),u),p));case void 0:return()=>V;default:return(p,b)=>(b.err.report(y("mcfunction.parser.entity-selector.arguments.unknown",P(u.value)),u),V)}}},end:",",trailingEnd:!0},end:"]"})),f=>({...f,type:"mcfunction:entity_selector/arguments"})))}}]),a=>{let l={type:"mcfunction:entity_selector",range:a.range,children:a.children,variable:a.children.find(Ae.is).value.slice(1),arguments:a.children.find($h.is),chunkLimited:t,currentEntity:e,dimensionLimited:r,playersOnly:n,predicates:i,single:o,typeLimited:s};return l.hover=AI(l),l})}function AI(t){let e=new Map([[0,"\u{1F922}"],[1,"\u{1F605}"],[2,"Good"],[3,"Great"],[4,"\u{1F60C}\u{1F44C}"]]),r;if(t.currentEntity)r=`**Performance**: ${e.get(4)} - \`currentEntity\`: \`${t.currentEntity}\``;else{let n=[t.chunkLimited,t.dimensionLimited,t.playersOnly,t.typeLimited].filter(i=>i).length;r=`**Performance**: ${e.get(n)} - \`chunkLimited\`: \`${!!t.chunkLimited}\` - \`dimensionLimited\`: \`${!!t.dimensionLimited}\` @@ -70,8 +70,8 @@ ${c}.${a}: ${p} ------ **Predicates**: ${t.predicates.map(n=>`- \`${n}\``).join(` -`)}`),r}var _I=Gy(bC("score_holder"),gI,"mcfunction.parser.score_holder.fake-name.too-long");function CI(t){return J(ne([{predicate:e=>na.is(e.peek(2)),parser:qy()},{parser:_I}]),(e,r,n)=>{let i={type:"mcfunction:score_holder",range:e.range,children:[e]};return or.is(e)?i.fakeName=e:i.selector=e,t==="single"&&i.selector&&!i.selector.single&&n.err.report(y("mcfunction.parser.entity-selector.multiple-disallowed"),i),i})}function bC(t,e=[]){return Tn(Bs(t),Bw,e)}function kC(t,e=[]){return Gy(Ky({category:"objective",usageType:t},e),yI,"mcfunction.parser.objective.too-long")}var AI=J(ar([be([Tn(Re({category:"stat_type",namespacePathSep:"."}),":"),oe(Oe(":")),{get:t=>{if(U.is(t.children[0])){let e=Ai.ComplexCategories.get(U.toString(t.children[0],"short"));if(e)return Re({category:e,namespacePathSep:"."})}return Re({pool:[],allowUnknown:!0,namespacePathSep:"."})}}]),Oe(...Ai.SimpleValues)]),t=>{let e={type:"mcfunction:objective_criteria",range:t.range};return Ne.is(t)?e.simpleValue=t.value:e.children=t.children.filter(U.is),e});function Xh(t=[]){return Ky("tag",t)}function Qh(t,e=[]){return Ky({category:"team",usageType:t},e)}function Ky(t,e){return RI(bC(t,e))}var TI=J(be([aa(0,void 0),ke(oe(Oe(...Vh.Units)))]),t=>{let e=t.children.find(Sr.is),r=t.children.find(Ne.is);return{type:"mcfunction:time",range:t.range,children:t.children,value:e.value,unit:r?.value}}),vC=dt({unquotable:Ml}),OI=/^[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+$/i,wC=(t,e)=>{let r={type:"mcfunction:uuid",range:v.create(t),bits:[0n,0n]},n=t.readUntil(" ","\r",` -`,"\r"),i=!1;if(n.match(OI))try{let o=n.split("-").map(s=>BigInt(`0x${s}`));o.every(s=>s<=dC)&&(i=!0,r.bits[0]=BigInt.asIntN(64,o[0]<<32n|o[1]<<16n|o[2]),r.bits[1]=BigInt.asIntN(64,o[3]<<48n|o[4]))}catch{}return r.range.end=t.cursor,i||e.err.report(y("mcfunction.parser.uuid.invalid"),r),r};function Gy(t,e,r){return(n,i)=>kI(i)?J(t,(o,s,a)=>(o.value.length>e&&a.err.report(y(r,e),o),o))(n,i):t(n,i)}function RI(t){return J(t,(e,r,n)=>(e.value.match(Mx)||n.err.report(y("parser.string.illegal-brigadier",P(e.value)),e),e))}function oa(t){return(e,r)=>{let n={type:"mcfunction:vector",range:v.create(e),children:[],options:t,system:0};e.peek()==="^"&&(n.system=1);for(let i=0;i0&&_c(e,r);let o=(t.integersOnly,Fy(t.integersOnly)(e,r));n.children.push(o),n.system===1!=(o.notation==="^")&&r.err.report(y("mcfunction.parser.vector.mixed"),o)}return t.noLocal&&n.system===1&&r.err.report(y("mcfunction.parser.vector.local-disallowed"),n),n.range.end=e.cursor,n}}function SC(t){let e=pr.instance.get(t);return(r,n)=>{if(r.children[0]?.type!=="mcfunction:entry")return;let i=EI(r,n.offset),o=i?i.children:[],s=MI(e,o);if(s.length===0)return;let a=0;for(let c of o)if(n.offset>c.range.end)a+=1;else break;if(a>=s[0].length)return;let l={activeSignature:0,signatures:[]};return l.signatures=s.map(c=>{let f=c[a],u=a+1[...r,i]):r.length?[r]:[]}function OC(t){return{children:{advancement:{children:{grant:_C,revoke:_C}},...Vt.cmp(t,"1.16")>=0?{attribute:{children:{target:{children:{attribute:{properties:{category:"attribute"},children:{modifier:{children:{add:{children:{uuid:{properties:{category:"attribute_modifier_uuid",usageType:"definition"}}}},remove:{children:{uuid:{properties:{category:"attribute_modifier_uuid"}}}},value:{children:{get:{children:{uuid:{properties:{category:"attribute_modifier_uuid"}}}}}}}}}}}}}}}:{},ban:{permission:3},"ban-ip":{permission:3},banlist:{permission:3},bossbar:{children:{add:{children:{id:{properties:{category:"bossbar",usageType:"definition"}}}},get:{children:{id:{properties:{category:"bossbar"}}}},remove:{children:{id:{properties:{category:"bossbar"}}}},set:{children:{id:{properties:{category:"bossbar",accessType:1}}}}}},data:{children:{get:ed,merge:RC,modify:{children:{block:{children:{targetPos:{children:{targetPath:Zy}}}},entity:{children:{target:{children:{targetPath:Zy}}}},storage:{children:{target:{properties:{category:"storage",accessType:1},children:{targetPath:Zy}}}}}},remove:ed}},debug:{permission:3},deop:{permission:3},execute:{children:{if:CC,store:{children:{result:AC,success:AC}},unless:CC}},...Vt.cmp(t,"1.17")>=0?{item:{children:{replace:{children:{block:{children:{pos:{children:{slot:{children:{from:{children:{block:{children:{source:{children:{sourceSlot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}},entity:{children:{source:{children:{sourceSlot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}}}}}}}}}},entity:{children:{targets:{children:{slot:{children:{from:{children:{block:{children:{source:{children:{sourceSlot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}},entity:{children:{source:{children:{sourceSlot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}}}}}}}}}}}},modify:{children:{block:{children:{pos:{children:{slot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}},entity:{children:{targets:{children:{slot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}}}}}}}:{},help:{permission:0},kick:{permission:3},list:{permission:0},...Vt.cmp(t,"1.16")>=0?{locatebiome:{children:{biome:{properties:{category:"worldgen/biome"}}}}}:{},loot:{children:{give:{children:{players:Do}},insert:{children:{targetPos:Do}},replace:{children:{block:{children:{targetPos:{children:{slot:{children:{...Do.children,count:Do}}}}}},entity:{children:{entities:{children:{slot:{children:{...Do.children,count:Do}}}}}}}},spawn:{children:{targetPos:Do}}}},me:{permission:0},msg:{permission:0},op:{permission:3},pardon:{permission:3},"pardon-ip":{permission:3},playsound:mr,publish:{permission:4},recipe:{children:{give:TC,take:TC}},"save-all":{permission:4},"save-off":{permission:4},"save-on":{permission:4},scoreboard:{children:{objectives:{children:{add:{children:{objective:{parser:"minecraft:objective",properties:{usageType:"definition"}}}}}},players:{children:{add:Rc,operation:Rc,remove:Rc,reset:Rc,set:Rc}}}},setidletimeout:{permission:3},stop:{permission:4},stopsound:{children:{targets:{children:{"*":mr,ambient:mr,block:mr,hostile:mr,master:mr,music:mr,neutral:mr,player:mr,record:mr,voice:mr,weather:mr}}}},tag:{children:{targets:{children:{add:{children:{name:{parser:"spyglassmc:tag"}}},remove:{children:{name:{parser:"spyglassmc:tag"}}}}}}},team:{children:{add:{children:{team:{parser:"minecraft:team",properties:{usageType:"definition"}}}}}},teammsg:{permission:0},teleport:{children:{destination:void 0,targets:{executable:!0}}},tell:{permission:0},tm:{permission:0},trigger:{permission:0,children:{objective:{properties:{category:"objective",accessType:1}}}},w:{permission:0},whitelist:{permission:3}}}}var _C=Object.freeze({children:{targets:{children:{from:{children:{advancement:{properties:{category:"advancement"}}}},only:{children:{advancement:{properties:{category:"advancement"}}}},through:{children:{advancement:{properties:{category:"advancement"}}}},until:{children:{advancement:{properties:{category:"advancement"}}}}}}}}),ed=Object.freeze({children:{storage:{children:{source:{properties:{category:"storage"}}}}}}),RC=Object.freeze({children:{storage:{children:{target:{properties:{category:"storage",accessType:1}}}}}}),Oc=Object.freeze({children:{from:ed}}),Zy=Object.freeze({children:{append:Oc,insert:{children:{index:Oc}},merge:Oc,prepend:Oc,set:Oc}}),CC=Object.freeze({children:{data:ed,predicate:{children:{predicate:{properties:{category:"predicate"}}}}}}),AC=Object.freeze({children:{...RC.children,bossbar:{children:{id:{properties:{category:"bossbar",accessType:1}}}}}}),Do=Object.freeze({children:{fish:{children:{loot_table:{properties:{category:"loot_table"}}}},loot:{children:{loot_table:{properties:{category:"loot_table"}}}}}}),Rc=Object.freeze({children:{targets:{children:{objective:{properties:{accessType:1}}}}}}),TC=Object.freeze({children:{targets:{children:{recipe:{properties:{category:"recipe"}}}}}}),mr=Object.freeze({children:{sound:{properties:{category:"sound_event"}}}});var EC=(t,e,r)=>{let{meta:n}=t;U_(t),pr.instance.register(r,e,OC(r)),n.registerLanguage("mcfunction",{extensions:[".mcfunction"],parser:V_(r,Vy),completer:Nh.entry(r,nC),triggerCharacters:[" ","[","=","!",",","{",":","/",".",'"',"'"]}),n.registerParser("mcfunction:block_predicate",Uy),n.registerParser("mcfunction:component",Hy),n.registerParser("mcfunction:particle",Wy),n.registerParser("mcfunction:tag",Xh()),n.registerParser("mcfunction:team",Qh()),n.registerParser("mcfunction:command",Ph(pr.instance.get(r),Vy)),Q_(n),tC(n),oC(n),n.registerInlayHintProvider(aC),n.registerSignatureHelpProvider(SC(r))};var DC=async t=>{let{config:e,downloader:r,externals:n,logger:i,meta:o,projectRoot:s}=t;async function a(){let p,b=`${s}pack.mcmeta`;try{let m=await Y.readJson(n,b);kh.assert(m),p=m}catch(m){n.error.isKind(m,"ENOENT")||i.error(`[je.initialize] Failed loading pack.mcmeta \u201C${b}\u201D`,m)}return p}o.registerUriBinder(f_);let l=await s_(t.externals,t.downloader);if(!l){t.logger.error("[je-initialize] Failed loading game version list. Expect everything to be broken.");return}let c=await a(),{release:f,id:u,isLatest:h}=r_(e.env.gameVersion,{packMcmeta:c,versions:l});o.registerDependencyProvider("@vanilla-mcdoc",()=>c_(r));let d=await a_(t.externals,r,i,u,h,e.env.dataSource,e.env.mcmetaSummaryOverrides);if(!d.blocks||!d.commands||!d.fluids||!d.registries){t.logger.error("[je-initialize] Failed loading mcmeta summaries. Expect everything to be broken.");return}return o.registerSymbolRegistrar("mcmeta-summary",{checksum:d.checksum,registrar:i_(d)}),o.registerLinter("nameOfNbtKey",{configValidator:ni.configValidator.nameConvention,linter:ni.nameConvention("value"),nodePredicate:p=>!p.symbol&&p.parent?.parent?.type==="nbt:compound"&&kn.is(p.parent)&&p.type==="string"&&p.parent.key===p||!p.symbol&&p.parent?.type==="nbt:path"&&p.type==="string"||Pg.is(p.parent)&&Lg.is(p)&&!p.symbol?.path[0]?.startsWith("::minecraft")}),N_(t),EC(t,d.commands,f),t_(t),{loadedVersion:f}};var td=document.getElementById("language"),NI=document.getElementById("editor-container"),Ti=document.getElementById("uri"),NC="execute as @a run say hello world",PC=()=>td.selectedOptions[0]?.dataset?.language??td.value,LC=t=>IC.state.sliceDoc(0),Jy=0,fn=new ju({logger:console,profilers:new si(console,["cache#load","cache#save","project#init","project#ready"]),project:{cacheRoot:"file:///.cache/",defaultConfig:to.merge(Dm,{env:{dependencies:[]}}),externals:xg,initializers:[FS,DC],projectRoot:"file:///root/"}});await fn.project.ready();await fn.project.onDidOpen(Ti.value,PC(),0,NC);var PI=B.updateListener.of(t=>{if(!t.docChanged)return;let e=LC(t.state);fn.project.onDidChange(Ti.value,[{text:e}],++Jy).catch(r=>console.error("[onChange]",r))});async function LI(t){let e=await fn.project.ensureClientManagedChecked(Ti.value);if(!e)return null;let r=fn.complete(e.node,e.doc,t.pos);return r.length?{from:r[0].range.start,to:r[0].range.end,options:r.map(n=>({label:n.label,detail:n.detail,info:n.documentation}))}:null}var II=ce.define({create(){return $.none},update(t,e){let r=fn.project.getClientManaged(Ti.value);if(!r)return t;let{node:n}=r;t=$.none;for(let i of fs.getErrors(n))t=t.update({add:[BI(i).range(i.range.start,i.range.end===i.range.start?i.range.start+1:i.range.end)]});return t},provide:t=>B.decorations.from(t)}),BI=t=>$.mark({attributes:{"data-diagnostic-message":t.message},class:`spyglassmc-diagnostic spyglassmc-diagnostic-${t.severity}`}),jI=B.baseTheme({".spyglassmc-diagnostic::before":{content:"attr(data-diagnostic-message)",display:"none",position:"absolute",transform:"translateY(-100%)",border:"1px solid black","background-color":"wheat",opacity:"90%","white-space":"break-spaces",overflow:"hidden",height:"fit-content",width:"fit-content","max-height":"4em","max-width":"60em"},".spyglassmc-diagnostic:hover::before":{display:"block"},".spyglassmc-diagnostic-0":{textDecoration:"underline 1.5px darkgray"},".spyglassmc-diagnostic-1":{textDecoration:"underline 1.5px lightblue"},".spyglassmc-diagnostic-2":{textDecoration:"underline 1.5px orange"},".spyglassmc-diagnostic-3":{textDecoration:"underline 1.5px red"}}),$I=ce.define({create(){return $.none},update(t,e){let r=fn.project.getClientManaged(Ti.value);if(!r)return t;let{node:n,doc:i}=r,o=fn.colorize(n,i);t=$.none;for(let s of o)s.range.start!==s.range.end&&(t=t.update({add:[zI(s).range(s.range.start,s.range.end)]}));return t},provide:t=>B.decorations.from(t)}),zI=t=>$.mark({class:`spyglassmc-color-token-${t.type} ${t.modifiers?.map(e=>`spyglassmc-color-token-modifier-${e}`).join()??""}`}),FI=B.baseTheme({".spyglassmc-color-token-comment":{color:"#008000"},".spyglassmc-color-token-enum":{color:"#0070C1"},".spyglassmc-color-token-enumMember":{color:"#0070C1"},".spyglassmc-color-token-function":{color:"#795E26"},".spyglassmc-color-token-keyword":{color:"#AF00DB"},".spyglassmc-color-token-modifier":{color:"#001080"},".spyglassmc-color-token-number":{color:"#098658"},".spyglassmc-color-token-operator":{color:"#AF00DB"},".spyglassmc-color-token-property":{color:"#001080"},".spyglassmc-color-token-string":{color:"#A31515"},".spyglassmc-color-token-struct":{color:"#001080"},".spyglassmc-color-token-type":{color:"#267F99"},".spyglassmc-color-token-variable":{color:"#001080"},".spyglassmc-color-token-error":{color:"#FF0000"},".spyglassmc-color-token-literal":{color:"#0000FF"},".spyglassmc-color-token-resourceLocation":{color:"#795E26"},".spyglassmc-color-token-vector":{color:"#098658"}}),VI=B.theme({"&":{maxHeight:"40em"},".cm-gutter,.cm-content":{height:"40em"},".cm-scroller":{overflow:"auto"}}),IC=new B({parent:NI,state:G.create({doc:NC,extensions:[Aw,Ii.of([lw]),If({override:[LI]}),PI,II,jI,$I,FI,VI]})});td.onchange=async()=>{fn.project.onDidClose(Ti.value),Ti.value=`file:///root/foo.${td.value}`,Jy=0,await fn.project.onDidOpen(Ti.value,PC(),Jy,LC(IC.state))}; +`)}`),r}var TI=Yy(wC("score_holder"),kI,"mcfunction.parser.score_holder.fake-name.too-long");function OI(t){return J(ne([{predicate:e=>na.is(e.peek(2)),parser:Zy()},{parser:TI}]),(e,r,n)=>{let i={type:"mcfunction:score_holder",range:e.range,children:[e]};return or.is(e)?i.fakeName=e:i.selector=e,t==="single"&&i.selector&&!i.selector.single&&n.err.report(y("mcfunction.parser.entity-selector.multiple-disallowed"),i),i})}function wC(t,e=[]){return Tn(Bs(t),zw,e)}function xC(t,e=[]){return Yy(Jy({category:"objective",usageType:t},e),vI,"mcfunction.parser.objective.too-long")}var RI=J(ar([be([Tn(Ee({category:"stat_type",namespacePathSep:"."}),":"),oe(we(":")),{get:t=>{if(U.is(t.children[0])){let e=Ai.ComplexCategories.get(U.toString(t.children[0],"short"));if(e)return Ee({category:e,namespacePathSep:"."})}return Ee({pool:[],allowUnknown:!0,namespacePathSep:"."})}}]),we(...Ai.SimpleValues)]),t=>{let e={type:"mcfunction:objective_criteria",range:t.range};return Ae.is(t)?e.simpleValue=t.value:e.children=t.children.filter(U.is),e});function td(t=[]){return Jy("tag",t)}function rd(t,e=[]){return Jy({category:"team",usageType:t},e)}function Jy(t,e){return DI(wC(t,e))}var EI=J(be([aa(0,void 0),ke(oe(we(...Vh.Units)))]),t=>{let e=t.children.find(Sr.is),r=t.children.find(Ae.is);return{type:"mcfunction:time",range:t.range,children:t.children,value:e.value,unit:r?.value}}),SC=pt({unquotable:Ml}),MI=/^[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+$/i,_C=(t,e)=>{let r={type:"mcfunction:uuid",range:v.create(t),bits:[0n,0n]},n=t.readUntil(" ","\r",` +`,"\r"),i=!1;if(n.match(MI))try{let o=n.split("-").map(s=>BigInt(`0x${s}`));o.every(s=>s<=gC)&&(i=!0,r.bits[0]=BigInt.asIntN(64,o[0]<<32n|o[1]<<16n|o[2]),r.bits[1]=BigInt.asIntN(64,o[3]<<48n|o[4]))}catch{}return r.range.end=t.cursor,i||e.err.report(y("mcfunction.parser.uuid.invalid"),r),r};function Yy(t,e,r){return(n,i)=>xI(i)?J(t,(o,s,a)=>(o.value.length>e&&a.err.report(y(r,e),o),o))(n,i):t(n,i)}function DI(t){return J(t,(e,r,n)=>(e.value.match(Px)||n.err.report(y("parser.string.illegal-brigadier",P(e.value)),e),e))}function oa(t){return(e,r)=>{let n={type:"mcfunction:vector",range:v.create(e),children:[],options:t,system:0};e.peek()==="^"&&(n.system=1);for(let i=0;i0&&_c(e,r);let o=(t.integersOnly,Hy(t.integersOnly)(e,r));n.children.push(o),n.system===1!=(o.notation==="^")&&r.err.report(y("mcfunction.parser.vector.mixed"),o)}return t.noLocal&&n.system===1&&r.err.report(y("mcfunction.parser.vector.local-disallowed"),n),n.range.end=e.cursor,n}}function AC(t){let e=pr.instance.get(t);return(r,n)=>{if(r.children[0]?.type!=="mcfunction:entry")return;let i=NI(r,n.offset),o=i?i.children:[],s=PI(e,o);if(s.length===0)return;let a=0;for(let c of o)if(n.offset>c.range.end)a+=1;else break;if(a>=s[0].length)return;let l={activeSignature:0,signatures:[]};return l.signatures=s.map(c=>{let f=c[a],u=a+1[...r,i]):r.length?[r]:[]}function MC(t){return{children:{advancement:{children:{grant:TC,revoke:TC}},...ot.cmp(t,"1.16")>=0?{attribute:{children:{target:{children:{attribute:{properties:{category:"attribute"},children:{modifier:{children:{add:{children:{uuid:{properties:{category:"attribute_modifier_uuid",usageType:"definition"}}}},remove:{children:{uuid:{properties:{category:"attribute_modifier_uuid"}}}},value:{children:{get:{children:{uuid:{properties:{category:"attribute_modifier_uuid"}}}}}}}}}}}}}}}:{},ban:{permission:3},"ban-ip":{permission:3},banlist:{permission:3},bossbar:{children:{add:{children:{id:{properties:{category:"bossbar",usageType:"definition"}}}},get:{children:{id:{properties:{category:"bossbar"}}}},remove:{children:{id:{properties:{category:"bossbar"}}}},set:{children:{id:{properties:{category:"bossbar",accessType:1}}}}}},data:{children:{get:nd,merge:DC,modify:{children:{block:{children:{targetPos:{children:{targetPath:Xy}}}},entity:{children:{target:{children:{targetPath:Xy}}}},storage:{children:{target:{properties:{category:"storage",accessType:1},children:{targetPath:Xy}}}}}},remove:nd}},debug:{permission:3},deop:{permission:3},execute:{children:{if:OC,store:{children:{result:RC,success:RC}},unless:OC}},...ot.cmp(t,"1.17")>=0?{item:{children:{replace:{children:{block:{children:{pos:{children:{slot:{children:{from:{children:{block:{children:{source:{children:{sourceSlot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}},entity:{children:{source:{children:{sourceSlot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}}}}}}}}}},entity:{children:{targets:{children:{slot:{children:{from:{children:{block:{children:{source:{children:{sourceSlot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}},entity:{children:{source:{children:{sourceSlot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}}}}}}}}}}}},modify:{children:{block:{children:{pos:{children:{slot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}},entity:{children:{targets:{children:{slot:{children:{modifier:{properties:{category:"item_modifier"}}}}}}}}}}}}}:{},help:{permission:0},...ot.cmp(t,"1.18")>=0?{jfr:{permission:4}}:{},kick:{permission:3},list:{permission:0},...ot.cmp(t,"1.16")>=0?{locatebiome:{children:{biome:{properties:{category:"worldgen/biome"}}}}}:{},loot:{children:{give:{children:{players:Do}},insert:{children:{targetPos:Do}},replace:{children:{block:{children:{targetPos:{children:{slot:{children:{...Do.children,count:Do}}}}}},entity:{children:{entities:{children:{slot:{children:{...Do.children,count:Do}}}}}}}},spawn:{children:{targetPos:Do}}}},me:{permission:0},msg:{permission:0},op:{permission:3},pardon:{permission:3},"pardon-ip":{permission:3},...ot.cmp(t,"1.17")>=0?{perf:{permission:4}}:{},...ot.cmp(t,"1.19")>=0?{place:{children:{template:{children:{template:{properties:{category:"structure"}}}}}}}:{},playsound:mr,publish:{permission:4},recipe:{children:{give:EC,take:EC}},"save-all":{permission:4},"save-off":{permission:4},"save-on":{permission:4},scoreboard:{children:{objectives:{children:{add:{children:{objective:{parser:"minecraft:objective",properties:{usageType:"definition"}}}}}},players:{children:{add:Rc,operation:Rc,remove:Rc,reset:Rc,set:Rc}}}},setidletimeout:{permission:3},stop:{permission:4},stopsound:{children:{targets:{children:{"*":mr,ambient:mr,block:mr,hostile:mr,master:mr,music:mr,neutral:mr,player:mr,record:mr,voice:mr,weather:mr}}}},tag:{children:{targets:{children:{add:{children:{name:{parser:"spyglassmc:tag"}}},remove:{children:{name:{parser:"spyglassmc:tag"}}}}}}},team:{children:{add:{children:{team:{parser:"minecraft:team",properties:{usageType:"definition"}}}}}},teammsg:{permission:0},teleport:{children:{destination:void 0,targets:{executable:!0}}},tell:{permission:0},...ot.cmp(t,"1.20.2")>=0?{tick:{permission:3}}:{},tm:{permission:0},trigger:{permission:0,children:{objective:{properties:{category:"objective",accessType:1}}}},w:{permission:0},whitelist:{permission:3}}}}var TC=Object.freeze({children:{targets:{children:{from:{children:{advancement:{properties:{category:"advancement"}}}},only:{children:{advancement:{properties:{category:"advancement"}}}},through:{children:{advancement:{properties:{category:"advancement"}}}},until:{children:{advancement:{properties:{category:"advancement"}}}}}}}}),nd=Object.freeze({children:{storage:{children:{source:{properties:{category:"storage"}}}}}}),DC=Object.freeze({children:{storage:{children:{target:{properties:{category:"storage",accessType:1}}}}}}),Oc=Object.freeze({children:{from:nd}}),Xy=Object.freeze({children:{append:Oc,insert:{children:{index:Oc}},merge:Oc,prepend:Oc,set:Oc}}),OC=Object.freeze({children:{data:nd,predicate:{children:{predicate:{properties:{category:"predicate"}}}}}}),RC=Object.freeze({children:{...DC.children,bossbar:{children:{id:{properties:{category:"bossbar",accessType:1}}}}}}),Do=Object.freeze({children:{fish:{children:{loot_table:{properties:{category:"loot_table"}}}},loot:{children:{loot_table:{properties:{category:"loot_table"}}}}}}),Rc=Object.freeze({children:{targets:{children:{objective:{properties:{accessType:1}}}}}}),EC=Object.freeze({children:{targets:{children:{recipe:{properties:{category:"recipe"}}}}}}),mr=Object.freeze({children:{sound:{properties:{category:"sound_event"}}}});var NC=(t,e,r)=>{let{meta:n}=t;q_(t),pr.instance.register(r,e,MC(r)),n.registerLanguage("mcfunction",{extensions:[".mcfunction"],parser:W_(r,Wy),completer:Nh.entry(r,sC),triggerCharacters:[" ","[","=","!",",","{",":","/",".",'"',"'"]}),n.registerParser("mcfunction:block_predicate",qy),n.registerParser("mcfunction:component",Ky),n.registerParser("mcfunction:particle",Gy),n.registerParser("mcfunction:tag",td()),n.registerParser("mcfunction:team",rd()),n.registerParser("mcfunction:command",Ph(pr.instance.get(r),Wy)),rC(n),iC(n),lC(n),n.registerInlayHintProvider(fC),n.registerSignatureHelpProvider(AC(r))};var LC=async t=>{let{config:e,downloader:r,externals:n,logger:i,meta:o,projectRoot:s}=t;async function a(){let p,b=`${s}pack.mcmeta`;try{let m=await Y.readJson(n,b);kh.assert(m),p=m}catch(m){n.error.isKind(m,"ENOENT")||i.error(`[je.initialize] Failed loading pack.mcmeta \u201C${b}\u201D`,m)}return p}o.registerUriBinder(d_);let l=await c_(t.externals,t.downloader);if(!l){t.logger.error("[je-initialize] Failed loading game version list. Expect everything to be broken.");return}let c=await a(),{release:f,id:u,isLatest:h}=o_(e.env.gameVersion,{packMcmeta:c,versions:l});o.registerDependencyProvider("@vanilla-mcdoc",()=>h_(r));let d=await f_(t.externals,r,i,u,h,e.env.dataSource,e.env.mcmetaSummaryOverrides);if(!d.blocks||!d.commands||!d.fluids||!d.registries){t.logger.error("[je-initialize] Failed loading mcmeta summaries. Expect everything to be broken.");return}return o.registerSymbolRegistrar("mcmeta-summary",{checksum:d.checksum,registrar:a_(d)}),o.registerLinter("nameOfNbtKey",{configValidator:ni.configValidator.nameConvention,linter:ni.nameConvention("value"),nodePredicate:p=>!p.symbol&&p.parent?.parent?.type==="nbt:compound"&&kn.is(p.parent)&&p.type==="string"&&p.parent.key===p||!p.symbol&&p.parent?.type==="nbt:path"&&p.type==="string"||Bg.is(p.parent)&&jg.is(p)&&!p.symbol?.path[0]?.startsWith("::minecraft")}),I_(t),NC(t,d.commands,f),i_(t),{loadedVersion:f}};var id=document.getElementById("language"),II=document.getElementById("editor-container"),Ti=document.getElementById("uri"),IC="execute as @a run say hello world",BC=()=>id.selectedOptions[0]?.dataset?.language??id.value,jC=t=>$C.state.sliceDoc(0),Qy=0,fn=new ju({logger:console,profilers:new si(console,["cache#load","cache#save","project#init","project#ready"]),project:{cacheRoot:"file:///.cache/",defaultConfig:to.merge(Lm,{env:{dependencies:[]}}),externals:Cg,initializers:[HS,LC],projectRoot:"file:///root/"}});await fn.project.ready();await fn.project.onDidOpen(Ti.value,BC(),0,IC);var BI=B.updateListener.of(t=>{if(!t.docChanged)return;let e=jC(t.state);fn.project.onDidChange(Ti.value,[{text:e}],++Qy).catch(r=>console.error("[onChange]",r))});async function jI(t){let e=await fn.project.ensureClientManagedChecked(Ti.value);if(!e)return null;let r=fn.complete(e.node,e.doc,t.pos);return r.length?{from:r[0].range.start,to:r[0].range.end,options:r.map(n=>({label:n.label,detail:n.detail,info:n.documentation}))}:null}var $I=ce.define({create(){return $.none},update(t,e){let r=fn.project.getClientManaged(Ti.value);if(!r)return t;let{node:n}=r;t=$.none;for(let i of fs.getErrors(n))t=t.update({add:[zI(i).range(i.range.start,i.range.end===i.range.start?i.range.start+1:i.range.end)]});return t},provide:t=>B.decorations.from(t)}),zI=t=>$.mark({attributes:{"data-diagnostic-message":t.message},class:`spyglassmc-diagnostic spyglassmc-diagnostic-${t.severity}`}),FI=B.baseTheme({".spyglassmc-diagnostic::before":{content:"attr(data-diagnostic-message)",display:"none",position:"absolute",transform:"translateY(-100%)",border:"1px solid black","background-color":"wheat",opacity:"90%","white-space":"break-spaces",overflow:"hidden",height:"fit-content",width:"fit-content","max-height":"4em","max-width":"60em"},".spyglassmc-diagnostic:hover::before":{display:"block"},".spyglassmc-diagnostic-0":{textDecoration:"underline 1.5px darkgray"},".spyglassmc-diagnostic-1":{textDecoration:"underline 1.5px lightblue"},".spyglassmc-diagnostic-2":{textDecoration:"underline 1.5px orange"},".spyglassmc-diagnostic-3":{textDecoration:"underline 1.5px red"}}),VI=ce.define({create(){return $.none},update(t,e){let r=fn.project.getClientManaged(Ti.value);if(!r)return t;let{node:n,doc:i}=r,o=fn.colorize(n,i);t=$.none;for(let s of o)s.range.start!==s.range.end&&(t=t.update({add:[UI(s).range(s.range.start,s.range.end)]}));return t},provide:t=>B.decorations.from(t)}),UI=t=>$.mark({class:`spyglassmc-color-token-${t.type} ${t.modifiers?.map(e=>`spyglassmc-color-token-modifier-${e}`).join()??""}`}),HI=B.baseTheme({".spyglassmc-color-token-comment":{color:"#008000"},".spyglassmc-color-token-enum":{color:"#0070C1"},".spyglassmc-color-token-enumMember":{color:"#0070C1"},".spyglassmc-color-token-function":{color:"#795E26"},".spyglassmc-color-token-keyword":{color:"#AF00DB"},".spyglassmc-color-token-modifier":{color:"#001080"},".spyglassmc-color-token-number":{color:"#098658"},".spyglassmc-color-token-operator":{color:"#AF00DB"},".spyglassmc-color-token-property":{color:"#001080"},".spyglassmc-color-token-string":{color:"#A31515"},".spyglassmc-color-token-struct":{color:"#001080"},".spyglassmc-color-token-type":{color:"#267F99"},".spyglassmc-color-token-variable":{color:"#001080"},".spyglassmc-color-token-error":{color:"#FF0000"},".spyglassmc-color-token-literal":{color:"#0000FF"},".spyglassmc-color-token-resourceLocation":{color:"#795E26"},".spyglassmc-color-token-vector":{color:"#098658"}}),WI=B.theme({"&":{maxHeight:"40em"},".cm-gutter,.cm-content":{height:"40em"},".cm-scroller":{overflow:"auto"}}),$C=new B({parent:II,state:G.create({doc:IC,extensions:[Rw,Ii.of([uw]),If({override:[jI]}),BI,$I,FI,VI,HI,WI]})});id.onchange=async()=>{fn.project.onDidClose(Ti.value),Ti.value=`file:///root/foo.${id.value}`,Qy=0,await fn.project.onDidOpen(Ti.value,BC(),Qy,jC($C.state))}; /*! Bundled license information: pako/dist/pako.esm.mjs: