>>=v,p-=v),p<15&&(m+=k[r++]<>>24,m>>>=v,p-=v,v=g>>>16&255,!(16&v)){if(0==(64&v)){g=f[(65535&g)+(m&(1<s){e.msg="invalid distance too far back",S.mode=30;break e}if(m>>>=v,p-=v,v=i-n,N>v){if(v=N-v,v>l&&S.sane){e.msg="invalid distance too far back",S.mode=30;break e}if(O=0,w=_,0===d){if(O+=c-v,v2;)x[i++]=w[O++],x[i++]=w[O++],x[i++]=w[O++],y-=3;y&&(x[i++]=w[O++],y>1&&(x[i++]=w[O++]))}else{O=i-N;do{x[i++]=x[O++],x[i++]=x[O++],x[i++]=x[O++],y-=3}while(y>2);y&&(x[i++]=x[O++],y>1&&(x[i++]=x[O++]))}break}}break}}while(r>3,r-=y,p-=y<<3,m&=(1<{const c=s.bits;let l,d,_,m,p,u,f=0,h=0,b=0,g=0,v=0,y=0,N=0,O=0,w=0,k=0,x=null,S=0;const j=new Uint16Array(16),M=new Uint16Array(16);let P,A,L,C=null,B=0;for(f=0;f<=15;f++)j[f]=0;for(h=0;h=1&&0===j[g];g--);if(v>g&&(v=g),0===g)return i[n++]=20971520,i[n++]=20971520,s.bits=1,0;for(b=1;b0&&(0===e||1!==g))return-1;for(M[1]=0,f=1;f<15;f++)M[f+1]=M[f]+j[f];for(h=0;h852||2===e&&w>592)return 1;for(;;){P=f-N,a[h]u?(A=C[B+a[h]],L=x[S+a[h]]):(A=96,L=0),l=1<>N)+d]=P<<24|A<<16|L|0}while(0!==d);for(l=1<>=1;if(0!==l?(k&=l-1,k+=l):k=0,h++,0==--j[f]){if(f===g)break;f=t[r+a[h]]}if(f>v&&(k&m)!==_){for(0===N&&(N=v),p+=b,y=f-N,O=1<852||2===e&&w>592)return 1;_=k&m,i[_]=v<<24|y<<16|p-n|0}}return 0!==k&&(i[p+k]=f-N<<24|64<<16|0),s.bits=v,0};const{Z_FINISH:yo,Z_BLOCK:No,Z_TREES:Oo,Z_OK:wo,Z_STREAM_END:ko,Z_NEED_DICT:xo,Z_STREAM_ERROR:So,Z_DATA_ERROR:jo,Z_MEM_ERROR:Mo,Z_BUF_ERROR:Po,Z_DEFLATED:Ao}=or,Lo=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Co(){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}const Bo=e=>{if(!e||!e.state)return So;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,wo},zo=e=>{if(!e||!e.state)return So;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Bo(e)},To=(e,t)=>{let r;if(!e||!e.state)return So;const o=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?So:(null!==o.window&&o.wbits!==t&&(o.window=null),o.wrap=r,o.wbits=t,zo(e))},Io=(e,t)=>{if(!e)return So;const r=new Co;e.state=r,r.window=null;const o=To(e,t);return o!==wo&&(e.state=null),o};let Ro,Do,Eo=!0;const Fo=e=>{if(Eo){Ro=new Int32Array(512),Do=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(vo(1,e.lens,0,288,Ro,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;vo(2,e.lens,0,32,Do,0,e.work,{bits:5}),Eo=!1}e.lencode=Ro,e.lenbits=9,e.distcode=Do,e.distbits=5},$o=(e,t,r,o)=>{let i;const n=e.state;return null===n.window&&(n.wsize=1<=n.wsize?(n.window.set(t.subarray(r-n.wsize,r),0),n.wnext=0,n.whave=n.wsize):(i=n.wsize-n.wnext,i>o&&(i=o),n.window.set(t.subarray(r-o,r-o+i),n.wnext),(o-=i)?(n.window.set(t.subarray(r-o,r),0),n.wnext=o,n.whave=n.wsize):(n.wnext+=i,n.wnext===n.wsize&&(n.wnext=0),n.whaveIo(e,15),inflateInit2:Io,inflate:(e,t)=>{let r,o,i,n,a,s,c,l,d,_,m,p,u,f,h,b,g,v,y,N,O,w,k=0;const x=new Uint8Array(4);let S,j;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return So;r=e.state,12===r.mode&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,n=e.next_in,o=e.input,s=e.avail_in,l=r.hold,d=r.bits,_=s,m=c,w=wo;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,l+=o[n++]<>>8&255,r.check=tr(r.check,x,2,0),l=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&l)!==Ao){e.msg="unknown compression method",r.mode=30;break}if(l>>>=4,d-=4,O=8+(15&l),0===r.wbits)r.wbits=O;else if(O>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(x[0]=255&l,x[1]=l>>>8&255,r.check=tr(r.check,x,2,0)),l=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,l+=o[n++]<>>8&255,x[2]=l>>>16&255,x[3]=l>>>24&255,r.check=tr(r.check,x,4,0)),l=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,l+=o[n++]<>8),512&r.flags&&(x[0]=255&l,x[1]=l>>>8&255,r.check=tr(r.check,x,2,0)),l=0,d=0,r.mode=5;case 5:if(1024&r.flags){for(;d<16;){if(0===s)break e;s--,l+=o[n++]<>>8&255,r.check=tr(r.check,x,2,0)),l=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(p=r.length,p>s&&(p=s),p&&(r.head&&(O=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(o.subarray(n,n+p),O)),512&r.flags&&(r.check=tr(r.check,o,p,n)),s-=p,n+=p,r.length-=p),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;p=0;do{O=o[n+p++],r.head&&O&&r.length<65536&&(r.head.name+=String.fromCharCode(O))}while(O&&p>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;d<32;){if(0===s)break e;s--,l+=o[n++]<>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,l+=o[n++]<>>=1,d-=1,3&l){case 0:r.mode=14;break;case 1:if(Fo(r),r.mode=20,t===Oo){l>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}l>>>=2,d-=2;break;case 14:for(l>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,l+=o[n++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&l,l=0,d=0,r.mode=15,t===Oo)break e;case 15:r.mode=16;case 16:if(p=r.length,p){if(p>s&&(p=s),p>c&&(p=c),0===p)break e;i.set(o.subarray(n,n+p),a),s-=p,n+=p,c-=p,a+=p,r.length-=p;break}r.mode=12;break;case 17:for(;d<14;){if(0===s)break e;s--,l+=o[n++]<>>=5,d-=5,r.ndist=1+(31&l),l>>>=5,d-=5,r.ncode=4+(15&l),l>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,d-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},w=vo(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,w){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>24,b=k>>>16&255,g=65535&k,!(h<=d);){if(0===s)break e;s--,l+=o[n++]<>>=h,d-=h,r.lens[r.have++]=g;else{if(16===g){for(j=h+2;d>>=h,d-=h,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}O=r.lens[r.have-1],p=3+(3&l),l>>>=2,d-=2}else if(17===g){for(j=h+3;d>>=h,d-=h,O=0,p=3+(7&l),l>>>=3,d-=3}else{for(j=h+7;d>>=h,d-=h,O=0,p=11+(127&l),l>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;p--;)r.lens[r.have++]=O}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},w=vo(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,w){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},w=vo(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,w){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Oo)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=n,e.avail_in=s,r.hold=l,r.bits=d,uo(e,m),a=e.next_out,i=e.output,c=e.avail_out,n=e.next_in,o=e.input,s=e.avail_in,l=r.hold,d=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;k=r.lencode[l&(1<>>24,b=k>>>16&255,g=65535&k,!(h<=d);){if(0===s)break e;s--,l+=o[n++]<>v)],h=k>>>24,b=k>>>16&255,g=65535&k,!(v+h<=d);){if(0===s)break e;s--,l+=o[n++]<>>=v,d-=v,r.back+=v}if(l>>>=h,d-=h,r.back+=h,r.length=g,0===b){r.mode=26;break}if(32&b){r.back=-1,r.mode=12;break}if(64&b){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&b,r.mode=22;case 22:if(r.extra){for(j=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;k=r.distcode[l&(1<>>24,b=k>>>16&255,g=65535&k,!(h<=d);){if(0===s)break e;s--,l+=o[n++]<>v)],h=k>>>24,b=k>>>16&255,g=65535&k,!(v+h<=d);){if(0===s)break e;s--,l+=o[n++]<>>=v,d-=v,r.back+=v}if(l>>>=h,d-=h,r.back+=h,64&b){e.msg="invalid distance code",r.mode=30;break}r.offset=g,r.extra=15&b,r.mode=24;case 24:if(r.extra){for(j=r.extra;d>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===c)break e;if(p=m-c,r.offset>p){if(p=r.offset-p,p>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p>r.wnext?(p-=r.wnext,u=r.wsize-p):u=r.wnext-p,p>r.length&&(p=r.length),f=r.window}else f=i,u=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=f[u++]}while(--p);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,l|=o[n++]<{if(!e||!e.state)return So;let t=e.state;return t.window&&(t.window=null),e.state=null,wo},inflateGetHeader:(e,t)=>{if(!e||!e.state)return So;const r=e.state;return 0==(2&r.wrap)?So:(r.head=t,t.done=!1,wo)},inflateSetDictionary:(e,t)=>{const r=t.length;let o,i,n;return e&&e.state?(o=e.state,0!==o.wrap&&11!==o.mode?So:11===o.mode&&(i=1,i=Qt(i,t,r,0),i!==o.check)?jo:(n=$o(e,t,r,r),n?(o.mode=31,Mo):(o.havedict=1,wo))):So},inflateInfo:"pako inflate (from Nodeca project)"};var Uo=function(){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};const Ho=Object.prototype.toString,{Z_NO_FLUSH:Zo,Z_FINISH:Wo,Z_OK:Go,Z_STREAM_END:Vo,Z_NEED_DICT:Xo,Z_STREAM_ERROR:Yo,Z_DATA_ERROR:Jo,Z_MEM_ERROR:Ko}=or;function Qo(e){this.options=Vr({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new to,this.strm.avail_out=0;let r=qo.inflateInit2(this.strm,t.windowBits);if(r!==Go)throw new Error(rr[r]);if(this.header=new Uo,qo.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Kr(t.dictionary):"[object ArrayBuffer]"===Ho.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=qo.inflateSetDictionary(this.strm,t.dictionary),r!==Go)))throw new Error(rr[r])}var ei,ti;Qo.prototype.push=function(e,t){const r=this.strm,o=this.options.chunkSize,i=this.options.dictionary;let n,a,s;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Wo:Zo,"[object ArrayBuffer]"===Ho.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(o),r.next_out=0,r.avail_out=o),n=qo.inflate(r,a),n===Xo&&i&&(n=qo.inflateSetDictionary(r,i),n===Go?n=qo.inflate(r,a):n===Jo&&(n=Xo));r.avail_in>0&&n===Vo&&r.state.wrap>0&&0!==e[r.next_in];)qo.inflateReset(r),n=qo.inflate(r,a);switch(n){case Yo:case Jo:case Xo:case Ko:return this.onEnd(n),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||n===Vo))if("string"===this.options.to){let e=eo(r.output,r.next_out),t=r.next_out-e,i=Qr(r.output,e);r.next_out=t,r.avail_out=o-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(n!==Go||0!==s){if(n===Vo)return n=qo.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},Qo.prototype.onData=function(e){this.chunks.push(e)},Qo.prototype.onEnd=function(e){e===Go&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Xr(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},(ti=ei||(ei={})).UP="up",ti.DOWN="down",ti.NORTH="north",ti.EAST="east",ti.SOUTH="south",ti.WEST="west";const ri={[ei.UP]:[0,1,0],[ei.DOWN]:[0,-1,0],[ei.NORTH]:[0,0,-1],[ei.EAST]:[1,0,0],[ei.SOUTH]:[0,0,1],[ei.WEST]:[-1,0,0]};var oi,ii,ni,ai,si,ci,li,di,_i,mi,pi,ui,fi;function hi(e,t,r){if(!e[t])throw new Error(`Missing ${t} tag`);if(e[t].type!==r)throw new Error(`Expected ${t} to be of type ${r}, but found ${e[t].type}`);return e[t].value}!function(e){e.ALL=[e.UP,e.DOWN,e.NORTH,e.EAST,e.SOUTH,e.WEST],e.normal=function(e){return ri[e]}}(ei||(ei={})),function(e){e.create=function(e,t,r){return[e,t,r]},e.offset=function(e,t,r,o){return[e[0]+t,e[1]+r,e[2]+o]},e.towards=function(t,r){return e.offset(t,...ei.normal(r))}}(oi||(oi={}));class bi{constructor(e,t={}){this.name=e,this.properties=t}getName(){return this.name}getProperties(){return this.properties}getProperty(e){return this.properties[e]}isFluid(){return"minecraft:water"===this.name||"minecraft:lava"===this.name}equals(e){return this.name===e.name&&Object.keys(this.properties).every((t=>e.properties[t]===this.properties[t]))}toString(){return 0===Object.keys(this.properties).length?this.name:`${this.name}[${Object.entries(this.properties).map((([e,t])=>e+"="+t)).join(",")}]`}static fromNbt(e){const t=hi(e.value,"Name","string"),r=function(e,t){try{return e()}catch(r){return t}}((()=>hi(e.value,"Properties","compound")),{}),o=Object.keys(r).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:hi(r,t,"string")})),{});return new bi(t,o)}static fromJson(e){var t,r;const o=null!==(t=ni.readObject(e))&&void 0!==t?t:{},i=null!==(r=ni.readString(o.Name))&&void 0!==r?r:"minecraft:stone",n=ni.readMap(o.Properties,(e=>{var t;return null!==(t=ni.readString(e))&&void 0!==t?t:""}));return new bi(i,n)}}bi.AIR=new bi("minecraft:air");class gi{constructor(e){this.minY=e,this.storage=Array(gi.SIZE),this.palette=[bi.AIR]}get minBlockY(){return this.minY<<4}index(e,t,r){return(e<<8)+(t<<4)+r}getBlockState(e,t,r){var o;const i=this.storage[this.index(e,t,r)];return null!==(o=this.palette[i])&&void 0!==o?o:bi.AIR}setBlockState(e,t,r,o){let i=this.palette.findIndex((e=>e.equals(o)));-1===i&&(i=this.palette.length,this.palette.push(o)),this.storage[this.index(e,t,r)]=i}}gi.WIDTH=16,gi.SIZE=gi.WIDTH*gi.WIDTH*gi.WIDTH;class vi{constructor(e,t,r){this.minY=e,this.height=t,this.pos=r,this.sections=Array(this.sectionsCount).fill(null)}get maxY(){return this.minY+this.height}get minSection(){return this.minY>>4}get maxSection(){return 1+(this.maxY-1>>4)}get sectionsCount(){return this.maxSection-this.minSection}getSectionIndex(e){return(e>>4)-this.minSection}getBlockState(e){var t;const[r,o,i]=e,n=this.sections[this.getSectionIndex(o)];return null!==(t=null==n?void 0:n.getBlockState(15&r,15&o,15&i))&&void 0!==t?t:bi.AIR}setBlockState(e,t){const[r,o,i]=e,n=this.getSectionIndex(o);let a=this.sections[n];if(null===a){if(t.equals(bi.AIR))return;a=this.getOrCreateSection(n)}a.setBlockState(15&r,15&o,15&i,t)}getOrCreateSection(e){return null==this.sections[e]&&(this.sections[e]=new gi(this.minSection+e)),this.sections[e]}}function yi(e){return e*e}function Ni(e,t,r){return t+e*(r-t)}function Oi(e,t,r,o,i,n){return Ni(t,Ni(e,r,o),Ni(e,i,n))}function wi(e,t,r){return r<0?e:r>1?t:Ni(r,e,t)}function ki(e){return e*e*e*(e*(6*e-15)+10)}!function(e){e.create=function(e,t){return[e,t]},e.fromBlockPos=function(e){return[e[0]>>4,e[2]>>4]},e.fromLong=function(e){return[4294967295&Number(e),Number(e>>BigInt(32))]},e.minBlockX=function(e){return e[0]<<4},e.minBlockZ=function(e){return e[1]<<4},e.maxBlockX=function(e){return e[0]<<19},e.maxBlockZ=function(e){return e[1]<<19}}(ii||(ii={})),function(e){function t(e){return"object"==typeof e&&null!==e?e:void 0}e.readNumber=function(e){return"number"==typeof e?e:void 0},e.readInt=function(e){return"number"==typeof e?Math.floor(e):void 0},e.readString=function(e){return"string"==typeof e?e:void 0},e.readBoolean=function(e){return"boolean"==typeof e?e:void 0},e.readObject=t,e.readArray=function(e,t){if(Array.isArray(e))return e.map((e=>t(e)))},e.readMap=function(e,r){var o;const i=null!==(o=t(e))&&void 0!==o?o:{};return Object.fromEntries(Object.entries(i).map((([e,t])=>[e,r(t)])))},e.compose=function(e,t,r){const o=t(e);return o?r(o):void 0}}(ni||(ni={}));class xi{constructor(e){this.xo=256*e.nextDouble(),this.yo=256*e.nextDouble(),this.zo=256*e.nextDouble(),this.p=Array(256);for(let t=0;t<256;t+=1)this.p[t]=t;for(let t=0;t<256;t+=1){const r=e.nextInt(256-t),o=this.p[t];this.p[t]=this.p[t+r],this.p[t+r]=o}}sample2D(e,t){let r,o,i;const n=(e+t)*xi.F2,a=Math.floor(e+n),s=e-(a-(r=(a+(o=Math.floor(t+n)))*xi.G2));let c,l;s>(i=t-(o-r))?(c=1,l=0):(c=0,l=1);const d=s-c+xi.G2,_=i-l+xi.G2,m=s-1+2*xi.G2,p=i-1+2*xi.G2,u=255&a,f=255&o,h=this.P(u+this.P(f))%12,b=this.P(u+c+this.P(f+l))%12,g=this.P(u+1+this.P(f+1))%12;return 70*(this.getCornerNoise3D(h,s,i,0,.5)+this.getCornerNoise3D(b,d,_,0,.5)+this.getCornerNoise3D(g,m,p,0,.5))}sample(e,t,r){const o=.3333333333333333*(e+t+r),i=Math.floor(e+o),n=Math.floor(t+o),a=Math.floor(r+o),s=.16666666666666666*(i+n+a),c=e-(i-s),l=t-(n-s),d=r-(a-s);let _,m,p,u,f,h;c>=l?l>=d?(_=1,m=0,p=0,u=1,f=1,h=0):c>=d?(_=1,m=0,p=0,u=1,f=0,h=1):(_=0,m=0,p=1,u=1,f=0,h=1):l127?t-256:t;for(let t=0;t<256;t+=1){const r=e.nextInt(256-t),o=this.p[t];this.p[t]=this.p[t+r],this.p[t+r]=o}}sample(e,t,r,o=0,i=0){const n=e+this.xo,a=t+this.yo,s=r+this.zo,c=Math.floor(n),l=Math.floor(a),d=Math.floor(s),_=n-c,m=a-l,p=s-d;let u=0;if(0!==o){const e=i>=0&&i=0;o-=1)o0&&(s=this.maxLimitNoise.getOctaveNoise(m))&&(_+=s.sample(p,u,f,a,t*a)/l),l/=2}return wi(d/512,_/512,c)}}class Pi{constructor(e,{firstOctave:t,amplitudes:r}){this.first=new ji(e,t,r),this.second=new ji(e,t,r);let o=1/0,i=-1/0;for(let a=0;a{var t;return null!==(t=ni.readNumber(e))&&void 0!==t?t:0})))&&void 0!==o?o:[]}};class Ai{constructor(e){this.seed=BigInt(0),this.setSeed(e)}fork(){return new Ai(this.nextLong())}setSeed(e){this.seed=e^Ai.MULTIPLIER&Ai.MODULUS_MASK}advance(){this.seed=this.seed*Ai.MULTIPLIER+Ai.INCREMENT&Ai.MODULUS_MASK}consume(e){for(let t=0;t>BigInt(Ai.MODULUS_BITS-e));return t>2147483647?t-4294967296:t}nextInt(e){if(void 0===e)return this.next(32);if(0==(e&e-1))return Number(BigInt(e)*BigInt(this.next(31))>>BigInt(31));let t,r;for(;(t=this.next(31))-(r=t%e)+(e-1)<0;);return r}nextLong(){return(BigInt(this.next(32))<0;){const t=Math.floor(o/2),i=e+t;r(i)?o=t:(e=i+1,o-=t+1)}return e}(0,this.locations.length,(e=>tt:t.apply.bind(t)),this.derivatives.push(r),this}}(si||(si={})).rotate=function(e,t,r){let{up:o,down:i,north:n,east:a,south:s,west:c}=e;switch(r){case 90:[n,a,s,c]=[a,s,c,n];break;case 180:[n,a,s,c]=[s,c,n,a];break;case 270:[n,a,s,c]=[c,n,a,s]}switch(t){case 90:[o,n,i,s]=[n,i,s,o];break;case 180:[o,n,i,s]=[i,s,o,n];break;case 270:[o,n,i,s]=[s,o,n,i]}return{up:o,down:i,north:n,east:a,south:s,west:c}},function(e){function t(e,t){return"number"==typeof e?new r(e,null!=t?t:e):e}e.target=function(e,t,r,o,n,a){return new i(e,t,r,o,n,a)},e.parameters=function(e,r,i,n,a,s,c){return new o(t(e),t(r),t(i),t(n),t(a),t(s),c)},e.param=t;class r{constructor(e,t){this.min=e,this.max=t}distance(e){const t=("number"==typeof e?e:e.min)-this.max,r=this.min-("number"==typeof e?e:e.max);return t>0?t:Math.max(r,0)}union(e){return new r(Math.min(this.min,e.min),Math.max(this.max,e.max))}static fromJson(e){var t;if("number"==typeof e)return new r(e,e);const[o,i]=null!==(t=ni.readArray(e,(e=>ni.readNumber(e))))&&void 0!==t?t:[];return new r(null!=o?o:0,null!=i?i:0)}}e.Param=r;class o{constructor(e,t,r,o,i,n,a){this.temperature=e,this.humidity=t,this.continentalness=r,this.erosion=o,this.depth=i,this.weirdness=n,this.offset=a}fittness(e){return yi(this.temperature.distance(e.temperature))+yi(this.humidity.distance(e.humidity))+yi(this.continentalness.distance(e.continentalness))+yi(this.erosion.distance(e.erosion))+yi(this.depth.distance(e.depth))+yi(this.weirdness.distance(e.weirdness))+yi(this.offset-e.offset)}space(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,new r(this.offset,this.offset)]}static fromJson(e){var t,i;const n=null!==(t=ni.readObject(e))&&void 0!==t?t:{};return new o(r.fromJson(n.temperature),r.fromJson(n.humidity),r.fromJson(n.continentalness),r.fromJson(n.erosion),r.fromJson(n.depth),r.fromJson(n.weirdness),null!==(i=ni.readInt(n.offset))&&void 0!==i?i:0)}}e.ParamPoint=o;class i{constructor(e,t,r,o,i,n){this.temperature=e,this.humidity=t,this.continentalness=r,this.erosion=o,this.depth=i,this.weirdness=n}get offset(){return 0}toArray(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,this.offset]}}e.TargetPoint=i,e.Parameters=class{constructor(e){this.things=e,this.index=new n(e)}find(e){return this.index.search(e,((e,t)=>e.distance(t)))}};class n{constructor(e){this.root=n.build(e.map((([e,t])=>new c(e,t))))}static build(e){if(1===e.length)return e[0];if(e.length<=n.CHILDREN_PER_NODE){const t=e.map((e=>{let t=0;for(let r=0;r<7;r+=1){const o=e.space[r];t+=Math.abs((o.min+o.max)/2)}return{key:t,node:e}})).sort(((e,t)=>e.key-t.key)).map((({node:e})=>e));return new s(t)}let t=1/0,r=-1,o=[];for(let i=0;i<7;++i){n.sort(e,i,!1),o=n.bucketize(e);let a=0;for(const e of o)a+=n.area(e.space);t>a&&(t=a,r=i)}return e=n.sort(e,r,!1),o=n.bucketize(e),o=n.sort(o,r,!0),new s(o.map((e=>n.build(e.children))))}static sort(e,t,r){return e.map((e=>{const o=e.space[t],i=(o.min+o.max)/2;return{key:r?Math.abs(i):i,node:e}})).sort(((e,t)=>e.key-t.key)).map((({node:e})=>e))}static bucketize(e){const t=[];let r=[];const o=Math.pow(10,Math.floor(Math.log(e.length-.01)/Math.log(10)));for(const i of e)r.push(i),r.lengthnew r(1/0,-1/0)));for(const r of e)t=[...Array(7)].map(((e,o)=>t[o].union(r.space[o])));return t}search(e,t){let r=1/0,o=null;for(const i of this.children){const n=t(i,e);if(r<=n)continue;const a=i.search(e,t),s=i==a?n:t(a,e);r<=s||(r=s,o=a)}return o}}e.RSubTree=s;class c extends a{constructor(e,t){super(e.space()),this.thing=t}search(){return this}}e.RLeaf=c}(ci||(ci={}));class Bi{constructor(e){this.biome=e}getBiome(){return this.biome}static fromJson(e){var t,r;const o=null!==(t=ni.readObject(e))&&void 0!==t?t:{},i=null!==(r=ni.readString(o.biome))&&void 0!==r?r:"minecraft:the_void";return new Bi(i)}}class zi{constructor(e){this.parameters=e}getBiome(e,t,r,o){const i=o(e,t,r);return this.parameters.find(i)}static fromJson(e){var t,r;const o=null!==(t=ni.readObject(e))&&void 0!==t?t:{},i=(null!==(r=ni.readArray(o.biomes,(e=>{var t,r,o;return r=null!==(t=ni.readObject(e))&&void 0!==t?t:{},{biome:null!==(o=ni.readString(r.biome))&&void 0!==o?o:"minecraft:the_void",parameters:ci.ParamPoint.fromJson(r.parameters)}})))&&void 0!==r?r:[]).map((e=>[e.parameters,()=>e.biome]));return new zi(new ci.Parameters(i))}}!function(e){function t(e){return l.apply(e)+.015}function r(e){return d.apply(e)}function o(e){return _.apply(e)}function i(e){return 3*-(Math.abs(Math.abs(e)-.6666667)-.33333334)}e.offset=t,e.factor=r,e.peaks=o,e.peaksAndValleys=i,e.point=function(e,t,r){return{continents:e,erosion:t,weirdness:r,ridges:i(r)}},e.nearWater=function(e,t){return!(e<-.2)&&(e<-.05||Math.abs(t)<.15)},e.shape=function(e,i){return{offset:t(e),factor:r(e),peaks:o(e),nearWater:i}};const n=p("beachSpline",-.15,-.05,0,0,.1,0,-.03,!1,!1),a=p("lowSpline",-.1,-.1,.03,.1,.1,.01,-.03,!1,!1),s=p("midSpline",-.1,-.1,.03,.1,.7,.01,-.03,!0,!0),c=p("highSpline",-.05,.3,.03,.1,1,.01,.01,!0,!0),l=new Ci("offsetSampler",(e=>e.continents)).addPoint(-1.1,.044).addPoint(-1.02,-.2222).addPoint(-.51,-.2222).addPoint(-.44,-.12).addPoint(-.18,-.12).addPoint(-.16,n).addPoint(-.15,n).addPoint(-.1,a).addPoint(.25,s).addPoint(1,c),d=new Ci("Factor-Continents",(e=>e.continents)).addPoint(-.19,505).addPoint(-.15,m("erosionCoast",800,!0,"ridgeCoast-OldMountains")).addPoint(-.1,m("erosionInland",700,!0,"ridgeInland-OldMountains")).addPoint(.03,m("erosionMidInland",650,!0,"ridgeMidInland-OldMountains")).addPoint(.06,m("erosionFarInland",600,!1,"ridgeFarInland-OldMountains")),_=new Ci("Peaks",(e=>e.continents)).addPoint(.1,0).addPoint(.2,new Ci("Peaks-erosion",(e=>e.erosion)).addPoint(-.8,new Ci("Peaks-erosion-ridges",(e=>e.ridges)).addPoint(-1,0).addPoint(.2,0).addPoint(1,new Ci("Peaks-erosion-ridges-weirdness",(e=>e.weirdness)).addPoint(-.01,80).addPoint(.01,20))).addPoint(-.4,0));function m(e,t,r,o){const i=new Ci(e,(e=>e.erosion)).addPoint(-.6,t).addPoint(-.5,342).addPoint(-.35,t).addPoint(-.25,t).addPoint(-.1,342).addPoint(.03,t);if(r){const e=new Ci("weirdnessShattered",(e=>e.weirdness)).addPoint(0,t).addPoint(.1,80),r=new Ci("ridgesShattered",(e=>e.ridges)).addPoint(-.9,t).addPoint(-.69,e);i.addPoint(.35,t).addPoint(.45,r).addPoint(.55,r).addPoint(.62,t)}else{const e=new Ci(o,(e=>e.ridges)).addPoint(-.7,t).addPoint(-.15,175),r=new Ci(o,(e=>e.ridges)).addPoint(.45,t).addPoint(.7,200);i.addPoint(.05,r).addPoint(.4,r).addPoint(.45,e).addPoint(.55,e).addPoint(.58,t)}return i}function p(e,t,r,o,i,n,a,s,c,l){const d=u(Ni(n,.6,1.5),l),_=u(Ni(n,.6,1),l),m=u(n,l),p=b(e+"-widePlateau",t-.15,.5*n,Ni(.5,.5,.5)*n,.5*n,.6*n,.5),f=b(e+"-narrowPlateau",t,a*n,o*n,.5*n,.6*n,.5),h=b(e+"-plains",t,a,a,o,i,.5),g=b(e+"-plainsFarInland",t,a,a,o,i,.5),v=new Ci(e,(e=>e.ridges)).addPoint(-1,t).addPoint(-.4,h).addPoint(0,i+.07),y=b(e+"-swamps",-.02,s,s,o,i,0),N=new Ci(e,(e=>e.erosion)).addPoint(-.85,d).addPoint(-.7,_).addPoint(-.4,m).addPoint(-.35,p).addPoint(-.1,f).addPoint(.2,h);return c&&N.addPoint(.4,g).addPoint(.45,v).addPoint(.55,v).addPoint(.58,g),N.addPoint(.7,y),N}function u(e,t){const r=new Ci(`M-spline for continentalness: ${e} ${t}`,(e=>e.ridges)),o=f(-1,e,-.7),i=f(1,e,-.7),n=.5*(1-(a=e))/(.46082947*(1-.5*(1-a)))-1.17;var a;if(-.65e.ridges)).addPoint(-1,t,s).addPoint(-.4,r,Math.min(s,c)).addPoint(0,o,c).addPoint(.4,i,2*(i-o)).addPoint(1,n,.7*(n-i))}}(li||(li={}));class Ti{constructor(e,t,r,o,i,n){this.cellCountY=t,this.cellCountZ=r,this.cellMinY=i,this.filler=n,this.noise000=0,this.noise001=0,this.noise100=0,this.noise101=0,this.noise010=0,this.noise011=0,this.noise110=0,this.noise111=0,this.valueXZ00=0,this.valueXZ10=0,this.valueXZ01=0,this.valueXZ11=0,this.valueZ0=0,this.valueZ1=0,this.minCellX=o[0]*e,this.minCellZ=o[1]*r,this.slice0=Ti.allocateSlice(t,r),this.slice1=Ti.allocateSlice(t,r)}static allocateSlice(e,t){const r=Array(t+1);for(let o=0;o>2,a=r*this.cellWidth>>2,{offset:s,factor:c,peaks:l}=this.getTerrainShape(n,a),d=684.412*this.settings.sampling.xzScale,_=684.412*this.settings.sampling.yScale,m=d/this.settings.sampling.xzFactor,p=_/this.settings.sampling.yFactor;for(let u=0;u<=i;u+=1){const i=u+o,n=this.blendedNoise.sample(t,i,r,d,_,m,p),a=this.samplePeakNoise(l,t*this.cellHeight,r*this.cellHeight)/128,f=this.computeInitialDensity(i*this.cellHeight,s,c,0,a)+n;e[u]=this.applySlide(f,i)}}samplePeakNoise(e,t,r){if(0===e)return 0;const o=3e3/this.cellWidth,i=this.mountainPeakNoise.sample(t*o,0,r*o);return i>0?e*i:e/2*i}computeInitialDensity(e,t,r,o,i){const n=(Ii.computeDimensionDensity(this.settings.densityFactor,this.settings.densityOffset,e,o)+t+i)*r;return n*(n>0?4:1)}applySlide(e,t){const r=t-Math.floor(this.settings.minY/this.cellHeight);if(this.settings.topSlide.size>0){const t=(this.cellCountY-r-this.settings.topSlide.offset)/this.settings.topSlide.size;e=wi(this.settings.topSlide.target,e,t)}if(this.settings.bottomSlide.size>0){const t=(r-this.settings.bottomSlide.offset)/this.settings.bottomSlide.size;e=wi(this.settings.bottomSlide.target,e,t)}return e}static computeDimensionDensity(e,t,r,o=0){return e*(1-r/128+o)+t}}class Ri{constructor(e,t,r,o){this.seed=e,this.biomeSource=t,this.settings=r,this.cellHeight=r.noise.ySize<<2,this.cellWidth=r.noise.xzSize<<2,this.cellCountXZ=Math.floor(16/this.cellWidth),this.cellCountY=Math.floor(r.noise.height/this.cellHeight),this.sampler=new Ii(this.cellWidth,this.cellHeight,this.cellCountY,t,r.noise,r.octaves,e,o)}fill(e){const t=Math.max(e.minY,this.settings.noise.minY),r=Math.min(e.maxY,this.settings.noise.minY+this.settings.noise.height),o=Math.floor(t/this.cellHeight),i=Math.floor((r-t)/this.cellHeight),n=ii.minBlockX(e.pos),a=ii.minBlockZ(e.pos),s=new Ti(this.cellCountXZ,i,this.cellCountXZ,e.pos,o,this.sampler.fillNoiseColumn.bind(this.sampler)),c=Array(s);c.forEach((e=>e.initializeForFirstCellX()));for(let l=0;le.advanceCellX(l)));for(let t=0;t=0;d-=1){c.forEach((e=>e.selectCellYZ(d,t)));for(let i=this.cellHeight-1;i>=0;i-=1){const _=(o+d)*this.cellHeight+i,m=15&_,p=e.getSectionIndex(_);e.getSectionIndex(r.minBlockY)!==p&&(r=e.getOrCreateSection(p));const u=i/this.cellHeight;c.forEach((e=>e.updateForY(u)));for(let e=0;ee.updateForX(d)));for(let e=0;ee.swapSlices()))}}baseState(e,t,r,o){return(o=(o=function(e,t,r){return Math.max(t,Math.min(r,e))}(o/200,-1,1))/2-o*o*o/24)>0?this.settings.defaultBlock:t