(function(u,Mt){typeof exports=="object"&&typeof module<"u"?Mt(exports):typeof define=="function"&&define.amd?define(["exports"],Mt):(u=typeof globalThis<"u"?globalThis:u||self,Mt(u.deepslate={}))})(this,function(u){"use strict";var hu=Object.defineProperty;var fu=(u,Mt,Se)=>Mt in u?hu(u,Mt,{enumerable:!0,configurable:!0,writable:!0,value:Se}):u[Mt]=Se;var _=(u,Mt,Se)=>(fu(u,typeof Mt!="symbol"?Mt+"":Mt,Se),Se);function Mt(n){var t=n.slice(0,2);return t.length===2&&t[0]===31&&t[1]===139}function Se(n){const t=n.slice(0,2);return t.length===2&&t[0]===120&&(t[1]===1||t[1]===94||t[1]===156||t[2]===218)}function ia(n){const t=n.slice(0,8),e=new DataView(t.buffer,t.byteOffset),r=e.getUint32(0,!0),i=e.getUint32(4,!0);if(t.length===8&&r>0&&r<100&&i===n.byteLength-8)return r}function sa(n){var t=[],e,r;for(e=0;e>6),t.push(128|r&63)):r<65536?(t.push(224|r>>12),t.push(128|r>>6&63),t.push(128|r&63)):(t.push(240|r>>18&7),t.push(128|r>>12&63),t.push(128|r>>6&63),t.push(128|r&63));return t}function aa(n){var t=[],e;for(e=0;e=e)return;let r=this.buffer.byteLength;for(;rthis.buffer.byteLength&&s.fill(0,this.buffer.byteLength,this.offset),this.buffer=i,this.view=new DataView(i),this.array=s}writeNumber(t,e,r){this.accommodate(e),this.view[t](this.offset,r,this.littleEndian),this.offset+=e}writeBytes(t){this.accommodate(t.length),this.array.set(t,this.offset),this.offset+=t.length}writeString(t){const e=sa(t);this.writeShort(e.length),this.writeBytes(e)}getData(){return this.accommodate(0),this.array.slice(0,this.offset)}}u.Json=void 0,(n=>{function t(h){return typeof h=="number"?h:void 0}n.readNumber=t;function e(h){return typeof h=="number"?Math.floor(h):void 0}n.readInt=e;function r(h){return typeof h=="string"?h:void 0}n.readString=r;function i(h){return typeof h=="boolean"?h:void 0}n.readBoolean=i;function s(h){return typeof h=="object"&&h!==null&&!Array.isArray(h)?h:void 0}n.readObject=s;function a(h,d){if(!!Array.isArray(h))return d?h.map(f=>d(f)):h}n.readArray=a;function o(h,d){if(!!Array.isArray(h))return[0,1].map(f=>d(h[f]))}n.readPair=o;function m(h,d){var w;const f=(w=s(h))!=null?w:{};return Object.fromEntries(Object.entries(f).map(([v,g])=>[v,d(g)]))}n.readMap=m;function c(h,d,f){const w=d(h);return w?f(w):void 0}n.compose=c;function l(h,d){return typeof h!="string"?d[0]:d.includes(h)?h:d[0]}n.readEnum=l})(u.Json||(u.Json={})),u.Color=void 0,(n=>{function t(i){const s=u.Json.readNumber(i);if(s)return r(s);const a=u.Json.readArray(i,o=>{var m;return(m=u.Json.readNumber(o))!=null?m:0});if(!(a===void 0||a.length!==3))return a}n.fromJson=t;function e(i){if(i.isNumber())return r(i.getAsNumber());if(!i.isListOrArray())return;const s=i.getItems();if(!(s.length<3))return s.map(a=>a.getAsNumber())}n.fromNbt=e;function r(i){const s=i>>16&255,a=i>>8&255,o=i&255;return[s/255,a/255,o/255]}n.intToRgb=r})(u.Color||(u.Color={}));class Et{constructor(t){_(this,"source");_(this,"cursor");this.source=t,this.cursor=0}get remainingLength(){return this.source.length-this.cursor}get totalLength(){return this.source.length}getRead(t=0){return this.source.substring(t,this.cursor)}getRemaining(){return this.source.substring(this.cursor)}canRead(t=1){return this.cursor+t<=this.source.length}peek(t=0){return this.source.charAt(this.cursor+t)}read(){return this.source.charAt(this.cursor++)}skip(){this.cursor+=1}skipWhitespace(){for(;this.canRead()&&Et.isWhitespace(this.peek());)this.skip()}expect(t,e=!1){if(e&&this.skipWhitespace(),!this.canRead()||this.peek()!==t)throw this.createError(`Expected '${t}'`);this.skip()}readInt(){const t=this.cursor;for(;this.canRead()&&Et.isAllowedInNumber(this.peek());)this.skip();const e=this.getRead(t);if(e.length===0)throw this.createError("Expected integer");try{const r=Number(e);if(isNaN(r)||!Number.isInteger(r))throw new Error;return r}catch{throw this.cursor=t,this.createError(`Invalid integer '${e}'`)}}readFloat(){const t=this.cursor;for(;this.canRead()&&Et.isAllowedInNumber(this.peek());)this.skip();const e=this.getRead(t);if(e.length===0)throw this.createError("Expected float");try{const r=Number(e);if(isNaN(r))throw new Error;return r}catch{throw this.cursor=t,this.createError(`Invalid float '${e}'`)}}readUnquotedString(){const t=this.cursor;for(;this.canRead()&&Et.isAllowedInUnquotedString(this.peek());)this.skip();return this.getRead(t)}readQuotedString(){if(!this.canRead())return"";const t=this.peek();if(!Et.isQuotedStringStart(t))throw this.createError("Expected quote to start a string");return this.skip(),this.readStringUntil(t)}readString(){if(!this.canRead())return"";const t=this.peek();return Et.isQuotedStringStart(t)?(this.skip(),this.readStringUntil(t)):this.readUnquotedString()}readStringUntil(t){const e=[];let r=!1;for(;this.canRead();){const i=this.read();if(r)if(i===t||i==="\\")e.push(i),r=!1;else throw this.cursor-=1,this.createError(`Invalid escape sequence '${i}' in quoted string`);else if(i==="\\")r=!0;else{if(i===t)return e.join("");e.push(i)}}throw this.createError("Unclosed quoted string")}readBoolean(){const t=this.cursor,e=this.readUnquotedString();if(e.length===0)throw this.createError("Expected bool");if(e==="true")return!0;if(e==="false")return!1;throw this.cursor=t,this.createError(`Invalid bool, expected true or false but found '${e}'`)}static isAllowedInNumber(t){return t>="0"&&t<="9"||t==="."||t==="-"}static isAllowedInUnquotedString(t){return t>="0"&&t<="9"||t>="A"&&t<="Z"||t>="a"&&t<="z"||t==="_"||t==="-"||t==="."||t==="+"}static isQuotedStringStart(t){return t==="'"||t==='"'}static isWhitespace(t){return t===" "||t===" "||t===` `||t==="\r"}createError(t){const e=Math.min(this.source.length,this.cursor),r=(e>10?"...":"")+this.source.substring(Math.max(0,e-10),e);return new Error(`${t} at position ${this.cursor}: ${r}<--[HERE]`)}}function sn(n){let t=null;return()=>(t==null&&(t=n()),t)}function Ee(n,t,e){const r=n.get(t);if(r!==void 0)return r;const i=e(t);return n.set(t,i),i}function wr(n,t,e,r){const i=n.get(t),s=i!=null?i:e;return r(s,t),n.set(t,s),s}/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */const oa=4,ui=0,hi=1,ca=2;function Ge(n){let t=n.length;for(;--t>=0;)n[t]=0}const la=0,fi=1,ua=2,ha=3,fa=258,pr=29,an=256,on=an+1+pr,Ve=30,vr=19,di=2*on+1,Ie=15,_r=16,da=7,br=256,mi=16,gi=17,wi=18,yr=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]),Jn=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]),ma=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),pi=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ga=512,Xt=new Array((on+2)*2);Ge(Xt);const cn=new Array(Ve*2);Ge(cn);const ln=new Array(ga);Ge(ln);const un=new Array(fa-ha+1);Ge(un);const Sr=new Array(pr);Ge(Sr);const zn=new Array(Ve);Ge(zn);function Er(n,t,e,r,i){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=r,this.max_length=i,this.has_stree=n&&n.length}let vi,_i,bi;function Ir(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}const yi=n=>n<256?ln[n]:ln[256+(n>>>7)],hn=(n,t)=>{n.pending_buf[n.pending++]=t&255,n.pending_buf[n.pending++]=t>>>8&255},It=(n,t,e)=>{n.bi_valid>_r-e?(n.bi_buf|=t<>_r-n.bi_valid,n.bi_valid+=e-_r):(n.bi_buf|=t<{It(n,e[t*2],e[t*2+1])},Si=(n,t)=>{let e=0;do e|=n&1,n>>>=1,e<<=1;while(--t>0);return e>>>1},wa=n=>{n.bi_valid===16?(hn(n,n.bi_buf),n.bi_buf=0,n.bi_valid=0):n.bi_valid>=8&&(n.pending_buf[n.pending++]=n.bi_buf&255,n.bi_buf>>=8,n.bi_valid-=8)},pa=(n,t)=>{const e=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,m=t.stat_desc.max_length;let c,l,h,d,f,w,v=0;for(d=0;d<=Ie;d++)n.bl_count[d]=0;for(e[n.heap[n.heap_max]*2+1]=0,c=n.heap_max+1;cm&&(d=m,v++),e[l*2+1]=d,!(l>r)&&(n.bl_count[d]++,f=0,l>=o&&(f=a[l-o]),w=e[l*2],n.opt_len+=w*(d+f),s&&(n.static_len+=w*(i[l*2+1]+f)));if(v!==0){do{for(d=m-1;n.bl_count[d]===0;)d--;n.bl_count[d]--,n.bl_count[d+1]+=2,n.bl_count[m]--,v-=2}while(v>0);for(d=m;d!==0;d--)for(l=n.bl_count[d];l!==0;)h=n.heap[--c],!(h>r)&&(e[h*2+1]!==d&&(n.opt_len+=(d-e[h*2+1])*e[h*2],e[h*2+1]=d),l--)}},Ei=(n,t,e)=>{const r=new Array(Ie+1);let i=0,s,a;for(s=1;s<=Ie;s++)r[s]=i=i+e[s-1]<<1;for(a=0;a<=t;a++){let o=n[a*2+1];o!==0&&(n[a*2]=Si(r[o]++,o))}},va=()=>{let n,t,e,r,i;const s=new Array(Ie+1);for(e=0,r=0;r>=7;r{let t;for(t=0;t{n.bi_valid>8?hn(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0},_a=(n,t,e,r)=>{ki(n),r&&(hn(n,e),hn(n,~e)),n.pending_buf.set(n.window.subarray(t,t+e),n.pending),n.pending+=e},Ai=(n,t,e,r)=>{const i=t*2,s=e*2;return n[i]{const r=n.heap[e];let i=e<<1;for(;i<=n.heap_len&&(i{let r,i,s=0,a,o;if(n.last_lit!==0)do r=n.pending_buf[n.d_buf+s*2]<<8|n.pending_buf[n.d_buf+s*2+1],i=n.pending_buf[n.l_buf+s],s++,r===0?Ht(n,i,t):(a=un[i],Ht(n,a+an+1,t),o=yr[a],o!==0&&(i-=Sr[a],It(n,i,o)),r--,a=yi(r),Ht(n,a,e),o=Jn[a],o!==0&&(r-=zn[a],It(n,r,o)));while(s{const e=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems;let a,o,m=-1,c;for(n.heap_len=0,n.heap_max=di,a=0;a>1;a>=1;a--)kr(n,e,a);c=s;do a=n.heap[1],n.heap[1]=n.heap[n.heap_len--],kr(n,e,1),o=n.heap[1],n.heap[--n.heap_max]=a,n.heap[--n.heap_max]=o,e[c*2]=e[a*2]+e[o*2],n.depth[c]=(n.depth[a]>=n.depth[o]?n.depth[a]:n.depth[o])+1,e[a*2+1]=e[o*2+1]=c,n.heap[1]=c++,kr(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],pa(n,t),Ei(e,m,n.bl_count)},xi=(n,t,e)=>{let r,i=-1,s,a=t[0*2+1],o=0,m=7,c=4;for(a===0&&(m=138,c=3),t[(e+1)*2+1]=65535,r=0;r<=e;r++)s=a,a=t[(r+1)*2+1],!(++o{let r,i=-1,s,a=t[0*2+1],o=0,m=7,c=4;for(a===0&&(m=138,c=3),r=0;r<=e;r++)if(s=a,a=t[(r+1)*2+1],!(++o{let t;for(xi(n,n.dyn_ltree,n.l_desc.max_code),xi(n,n.dyn_dtree,n.d_desc.max_code),Ar(n,n.bl_desc),t=vr-1;t>=3&&n.bl_tree[pi[t]*2+1]===0;t--);return n.opt_len+=3*(t+1)+5+5+4,t},ya=(n,t,e,r)=>{let i;for(It(n,t-257,5),It(n,e-1,5),It(n,r-4,4),i=0;i{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&n.dyn_ltree[e*2]!==0)return ui;if(n.dyn_ltree[9*2]!==0||n.dyn_ltree[10*2]!==0||n.dyn_ltree[13*2]!==0)return hi;for(e=32;e{Ni||(va(),Ni=!0),n.l_desc=new Ir(n.dyn_ltree,vi),n.d_desc=new Ir(n.dyn_dtree,_i),n.bl_desc=new Ir(n.bl_tree,bi),n.bi_buf=0,n.bi_valid=0,Ii(n)},Ci=(n,t,e,r)=>{It(n,(la<<1)+(r?1:0),3),_a(n,t,e,!0)},Ia=n=>{It(n,fi<<1,3),Ht(n,br,Xt),wa(n)},ka=(n,t,e,r)=>{let i,s,a=0;n.level>0?(n.strm.data_type===ca&&(n.strm.data_type=Sa(n)),Ar(n,n.l_desc),Ar(n,n.d_desc),a=ba(n),i=n.opt_len+3+7>>>3,s=n.static_len+3+7>>>3,s<=i&&(i=s)):i=s=e+5,e+4<=i&&t!==-1?Ci(n,t,e,r):n.strategy===oa||s===i?(It(n,(fi<<1)+(r?1:0),3),Mi(n,Xt,cn)):(It(n,(ua<<1)+(r?1:0),3),ya(n,n.l_desc.max_code+1,n.d_desc.max_code+1,a+1),Mi(n,n.dyn_ltree,n.dyn_dtree)),Ii(n),r&&ki(n)},Aa=(n,t,e)=>(n.pending_buf[n.d_buf+n.last_lit*2]=t>>>8&255,n.pending_buf[n.d_buf+n.last_lit*2+1]=t&255,n.pending_buf[n.l_buf+n.last_lit]=e&255,n.last_lit++,t===0?n.dyn_ltree[e*2]++:(n.matches++,t--,n.dyn_ltree[(un[e]+an+1)*2]++,n.dyn_dtree[yi(t)*2]++),n.last_lit===n.lit_bufsize-1);var Ma=Ea,xa=Ci,Ra=ka,Na=Aa,Ca=Ia,Ba={_tr_init:Ma,_tr_stored_block:xa,_tr_flush_block:Ra,_tr_tally:Na,_tr_align:Ca},fn=(n,t,e,r)=>{let i=n&65535|0,s=n>>>16&65535|0,a=0;for(;e!==0;){a=e>2e3?2e3:e,e-=a;do i=i+t[r++]|0,s=s+i|0;while(--a);i%=65521,s%=65521}return i|s<<16|0};const Ta=()=>{let n,t=[];for(var e=0;e<256;e++){n=e;for(var r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t},La=new Uint32Array(Ta());var dt=(n,t,e,r)=>{const i=La,s=r+e;n^=-1;for(let a=r;a>>8^i[(n^t[a])&255];return n^-1},ke={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"},Ae={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};const{_tr_init:Pa,_tr_stored_block:Oa,_tr_flush_block:Ja,_tr_tally:oe,_tr_align:za}=Ba,{Z_NO_FLUSH:Me,Z_PARTIAL_FLUSH:Da,Z_FULL_FLUSH:Fa,Z_FINISH:ce,Z_BLOCK:Bi,Z_OK:Zt,Z_STREAM_END:Ti,Z_STREAM_ERROR:Nt,Z_DATA_ERROR:Ua,Z_BUF_ERROR:Mr,Z_DEFAULT_COMPRESSION:Ha,Z_FILTERED:Za,Z_HUFFMAN_ONLY:Dn,Z_RLE:Ga,Z_FIXED:Va,Z_DEFAULT_STRATEGY:$a,Z_UNKNOWN:Ya,Z_DEFLATED:Fn}=Ae,qa=9,Wa=15,Xa=8,ja=29,xr=256+1+ja,Ka=30,Qa=19,to=2*xr+1,eo=15,K=3,le=258,zt=le+K+1,no=32,Un=42,Rr=69,Hn=73,Zn=91,Gn=103,xe=113,dn=666,ht=1,mn=2,Re=3,$e=4,ro=3,ue=(n,t)=>(n.msg=ke[t],t),Li=n=>(n<<1)-(n>4?9:0),he=n=>{let t=n.length;for(;--t>=0;)n[t]=0};let fe=(n,t,e)=>(t<{const t=n.state;let e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(n.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},gt=(n,t)=>{Ja(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,de(n.strm)},tt=(n,t)=>{n.pending_buf[n.pending++]=t},gn=(n,t)=>{n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=t&255},io=(n,t,e,r)=>{let i=n.avail_in;return i>r&&(i=r),i===0?0:(n.avail_in-=i,t.set(n.input.subarray(n.next_in,n.next_in+i),e),n.state.wrap===1?n.adler=fn(n.adler,t,i,e):n.state.wrap===2&&(n.adler=dt(n.adler,t,i,e)),n.next_in+=i,n.total_in+=i,i)},Pi=(n,t)=>{let e=n.max_chain_length,r=n.strstart,i,s,a=n.prev_length,o=n.nice_match;const m=n.strstart>n.w_size-zt?n.strstart-(n.w_size-zt):0,c=n.window,l=n.w_mask,h=n.prev,d=n.strstart+le;let f=c[r+a-1],w=c[r+a];n.prev_length>=n.good_match&&(e>>=2),o>n.lookahead&&(o=n.lookahead);do if(i=t,!(c[i+a]!==w||c[i+a-1]!==f||c[i]!==c[r]||c[++i]!==c[r+1])){r+=2,i++;do;while(c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&ra){if(n.match_start=t,a=s,s>=o)break;f=c[r+a-1],w=c[r+a]}}while((t=h[t&l])>m&&--e!==0);return a<=n.lookahead?a:n.lookahead},Ne=n=>{const t=n.w_size;let e,r,i,s,a;do{if(s=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-zt)){n.window.set(n.window.subarray(t,t+t),0),n.match_start-=t,n.strstart-=t,n.block_start-=t,r=n.hash_size,e=r;do i=n.head[--e],n.head[e]=i>=t?i-t:0;while(--r);r=t,e=r;do i=n.prev[--e],n.prev[e]=i>=t?i-t:0;while(--r);s+=t}if(n.strm.avail_in===0)break;if(r=io(n.strm,n.window,n.strstart+n.lookahead,s),n.lookahead+=r,n.lookahead+n.insert>=K)for(a=n.strstart-n.insert,n.ins_h=n.window[a],n.ins_h=fe(n,n.ins_h,n.window[a+1]);n.insert&&(n.ins_h=fe(n,n.ins_h,n.window[a+K-1]),n.prev[a&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=a,a++,n.insert--,!(n.lookahead+n.insert{let e=65535;for(e>n.pending_buf_size-5&&(e=n.pending_buf_size-5);;){if(n.lookahead<=1){if(Ne(n),n.lookahead===0&&t===Me)return ht;if(n.lookahead===0)break}n.strstart+=n.lookahead,n.lookahead=0;const r=n.block_start+e;if((n.strstart===0||n.strstart>=r)&&(n.lookahead=n.strstart-r,n.strstart=r,gt(n,!1),n.strm.avail_out===0)||n.strstart-n.block_start>=n.w_size-zt&&(gt(n,!1),n.strm.avail_out===0))return ht}return n.insert=0,t===ce?(gt(n,!0),n.strm.avail_out===0?Re:$e):(n.strstart>n.block_start&&(gt(n,!1),n.strm.avail_out===0),ht)},Nr=(n,t)=>{let e,r;for(;;){if(n.lookahead=K&&(n.ins_h=fe(n,n.ins_h,n.window[n.strstart+K-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),e!==0&&n.strstart-e<=n.w_size-zt&&(n.match_length=Pi(n,e)),n.match_length>=K)if(r=oe(n,n.strstart-n.match_start,n.match_length-K),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=K){n.match_length--;do n.strstart++,n.ins_h=fe(n,n.ins_h,n.window[n.strstart+K-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart;while(--n.match_length!==0);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=fe(n,n.ins_h,n.window[n.strstart+1]);else r=oe(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(r&&(gt(n,!1),n.strm.avail_out===0))return ht}return n.insert=n.strstart{let e,r,i;for(;;){if(n.lookahead=K&&(n.ins_h=fe(n,n.ins_h,n.window[n.strstart+K-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=K-1,e!==0&&n.prev_length4096)&&(n.match_length=K-1)),n.prev_length>=K&&n.match_length<=n.prev_length){i=n.strstart+n.lookahead-K,r=oe(n,n.strstart-1-n.prev_match,n.prev_length-K),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=i&&(n.ins_h=fe(n,n.ins_h,n.window[n.strstart+K-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart);while(--n.prev_length!==0);if(n.match_available=0,n.match_length=K-1,n.strstart++,r&&(gt(n,!1),n.strm.avail_out===0))return ht}else if(n.match_available){if(r=oe(n,0,n.window[n.strstart-1]),r&>(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return ht}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(r=oe(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart{let e,r,i,s;const a=n.window;for(;;){if(n.lookahead<=le){if(Ne(n),n.lookahead<=le&&t===Me)return ht;if(n.lookahead===0)break}if(n.match_length=0,n.lookahead>=K&&n.strstart>0&&(i=n.strstart-1,r=a[i],r===a[++i]&&r===a[++i]&&r===a[++i])){s=n.strstart+le;do;while(r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&in.lookahead&&(n.match_length=n.lookahead)}if(n.match_length>=K?(e=oe(n,1,n.match_length-K),n.lookahead-=n.match_length,n.strstart+=n.match_length,n.match_length=0):(e=oe(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++),e&&(gt(n,!1),n.strm.avail_out===0))return ht}return n.insert=0,t===ce?(gt(n,!0),n.strm.avail_out===0?Re:$e):n.last_lit&&(gt(n,!1),n.strm.avail_out===0)?ht:mn},oo=(n,t)=>{let e;for(;;){if(n.lookahead===0&&(Ne(n),n.lookahead===0)){if(t===Me)return ht;break}if(n.match_length=0,e=oe(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++,e&&(gt(n,!1),n.strm.avail_out===0))return ht}return n.insert=0,t===ce?(gt(n,!0),n.strm.avail_out===0?Re:$e):n.last_lit&&(gt(n,!1),n.strm.avail_out===0)?ht:mn};function Gt(n,t,e,r,i){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=r,this.func=i}const wn=[new Gt(0,0,0,0,so),new Gt(4,4,8,4,Nr),new Gt(4,5,16,8,Nr),new Gt(4,6,32,32,Nr),new Gt(4,4,16,16,Ye),new Gt(8,16,32,32,Ye),new Gt(8,16,128,128,Ye),new Gt(8,32,128,256,Ye),new Gt(32,128,258,1024,Ye),new Gt(32,258,258,4096,Ye)],co=n=>{n.window_size=2*n.w_size,he(n.head),n.max_lazy_match=wn[n.level].max_lazy,n.good_match=wn[n.level].good_length,n.nice_match=wn[n.level].nice_length,n.max_chain_length=wn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=K-1,n.match_available=0,n.ins_h=0};function lo(){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=Fn,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(to*2),this.dyn_dtree=new Uint16Array((2*Ka+1)*2),this.bl_tree=new Uint16Array((2*Qa+1)*2),he(this.dyn_ltree),he(this.dyn_dtree),he(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(eo+1),this.heap=new Uint16Array(2*xr+1),he(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*xr+1),he(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}const Oi=n=>{if(!n||!n.state)return ue(n,Nt);n.total_in=n.total_out=0,n.data_type=Ya;const t=n.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Un:xe,n.adler=t.wrap===2?0:1,t.last_flush=Me,Pa(t),Zt},Ji=n=>{const t=Oi(n);return t===Zt&&co(n.state),t},uo=(n,t)=>!n||!n.state||n.state.wrap!==2?Nt:(n.state.gzhead=t,Zt),zi=(n,t,e,r,i,s)=>{if(!n)return Nt;let a=1;if(t===Ha&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),i<1||i>qa||e!==Fn||r<8||r>15||t<0||t>9||s<0||s>Va)return ue(n,Nt);r===8&&(r=9);const o=new lo;return n.state=o,o.strm=n,o.wrap=a,o.gzhead=null,o.w_bits=r,o.w_size=1<zi(n,t,Fn,Wa,Xa,$a),fo=(n,t)=>{let e,r;if(!n||!n.state||t>Bi||t<0)return n?ue(n,Nt):Nt;const i=n.state;if(!n.output||!n.input&&n.avail_in!==0||i.status===dn&&t!==ce)return ue(n,n.avail_out===0?Mr:Nt);i.strm=n;const s=i.last_flush;if(i.last_flush=t,i.status===Un)if(i.wrap===2)n.adler=0,tt(i,31),tt(i,139),tt(i,8),i.gzhead?(tt(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)),tt(i,i.gzhead.time&255),tt(i,i.gzhead.time>>8&255),tt(i,i.gzhead.time>>16&255),tt(i,i.gzhead.time>>24&255),tt(i,i.level===9?2:i.strategy>=Dn||i.level<2?4:0),tt(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(tt(i,i.gzhead.extra.length&255),tt(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(n.adler=dt(n.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Rr):(tt(i,0),tt(i,0),tt(i,0),tt(i,0),tt(i,0),tt(i,i.level===9?2:i.strategy>=Dn||i.level<2?4:0),tt(i,ro),i.status=xe);else{let a=Fn+(i.w_bits-8<<4)<<8,o=-1;i.strategy>=Dn||i.level<2?o=0:i.level<6?o=1:i.level===6?o=2:o=3,a|=o<<6,i.strstart!==0&&(a|=no),a+=31-a%31,i.status=xe,gn(i,a),i.strstart!==0&&(gn(i,n.adler>>>16),gn(i,n.adler&65535)),n.adler=1}if(i.status===Rr)if(i.gzhead.extra){for(e=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>e&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),de(n),e=i.pending,i.pending===i.pending_buf_size));)tt(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>e&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Hn)}else i.status=Hn;if(i.status===Hn)if(i.gzhead.name){e=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>e&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),de(n),e=i.pending,i.pending===i.pending_buf_size)){r=1;break}i.gzindexe&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),r===0&&(i.gzindex=0,i.status=Zn)}else i.status=Zn;if(i.status===Zn)if(i.gzhead.comment){e=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>e&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),de(n),e=i.pending,i.pending===i.pending_buf_size)){r=1;break}i.gzindexe&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),r===0&&(i.status=Gn)}else i.status=Gn;if(i.status===Gn&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&de(n),i.pending+2<=i.pending_buf_size&&(tt(i,n.adler&255),tt(i,n.adler>>8&255),n.adler=0,i.status=xe)):i.status=xe),i.pending!==0){if(de(n),n.avail_out===0)return i.last_flush=-1,Zt}else if(n.avail_in===0&&Li(t)<=Li(s)&&t!==ce)return ue(n,Mr);if(i.status===dn&&n.avail_in!==0)return ue(n,Mr);if(n.avail_in!==0||i.lookahead!==0||t!==Me&&i.status!==dn){let a=i.strategy===Dn?oo(i,t):i.strategy===Ga?ao(i,t):wn[i.level].func(i,t);if((a===Re||a===$e)&&(i.status=dn),a===ht||a===Re)return n.avail_out===0&&(i.last_flush=-1),Zt;if(a===mn&&(t===Da?za(i):t!==Bi&&(Oa(i,0,0,!1),t===Fa&&(he(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),de(n),n.avail_out===0))return i.last_flush=-1,Zt}return t!==ce?Zt:i.wrap<=0?Ti:(i.wrap===2?(tt(i,n.adler&255),tt(i,n.adler>>8&255),tt(i,n.adler>>16&255),tt(i,n.adler>>24&255),tt(i,n.total_in&255),tt(i,n.total_in>>8&255),tt(i,n.total_in>>16&255),tt(i,n.total_in>>24&255)):(gn(i,n.adler>>>16),gn(i,n.adler&65535)),de(n),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?Zt:Ti)},mo=n=>{if(!n||!n.state)return Nt;const t=n.state.status;return t!==Un&&t!==Rr&&t!==Hn&&t!==Zn&&t!==Gn&&t!==xe&&t!==dn?ue(n,Nt):(n.state=null,t===xe?ue(n,Ua):Zt)},go=(n,t)=>{let e=t.length;if(!n||!n.state)return Nt;const r=n.state,i=r.wrap;if(i===2||i===1&&r.status!==Un||r.lookahead)return Nt;if(i===1&&(n.adler=fn(n.adler,t,e,0)),r.wrap=0,e>=r.w_size){i===0&&(he(r.head),r.strstart=0,r.block_start=0,r.insert=0);let m=new Uint8Array(r.w_size);m.set(t.subarray(e-r.w_size,e),0),t=m,e=r.w_size}const s=n.avail_in,a=n.next_in,o=n.input;for(n.avail_in=e,n.next_in=0,n.input=t,Ne(r);r.lookahead>=K;){let m=r.strstart,c=r.lookahead-(K-1);do r.ins_h=fe(r,r.ins_h,r.window[m+K-1]),r.prev[m&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=m,m++;while(--c);r.strstart=m,r.lookahead=K-1,Ne(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=K-1,r.match_available=0,n.next_in=a,n.input=o,n.avail_in=s,r.wrap=i,Zt};var wo=ho,po=zi,vo=Ji,_o=Oi,bo=uo,yo=fo,So=mo,Eo=go,Io="pako deflate (from Nodeca project)",pn={deflateInit:wo,deflateInit2:po,deflateReset:vo,deflateResetKeep:_o,deflateSetHeader:bo,deflate:yo,deflateEnd:So,deflateSetDictionary:Eo,deflateInfo:Io};const ko=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);var Ao=function(n){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(!!e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const r in e)ko(e,r)&&(n[r]=e[r])}}return n},Mo=n=>{let t=0;for(let r=0,i=n.length;r=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;vn[254]=vn[254]=1;var xo=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let t,e,r,i,s,a=n.length,o=0;for(i=0;i>>6,t[s++]=128|e&63):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|e&63):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|e&63);return t};const Ro=(n,t)=>{if(t<65534&&n.subarray&&Di)return String.fromCharCode.apply(null,n.length===t?n:n.subarray(0,t));let e="";for(let r=0;r{const e=t||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,t));let r,i;const s=new Array(e*2);for(i=0,r=0;r4){s[i++]=65533,r+=o-1;continue}for(a&=o===2?31:o===3?15:7;o>1&&r1){s[i++]=65533;continue}a<65536?s[i++]=a:(a-=65536,s[i++]=55296|a>>10&1023,s[i++]=56320|a&1023)}return Ro(s,i)},Co=(n,t)=>{t=t||n.length,t>n.length&&(t=n.length);let e=t-1;for(;e>=0&&(n[e]&192)===128;)e--;return e<0||e===0?t:e+vn[n[e]]>t?e:t},_n={string2buf:xo,buf2string:No,utf8border:Co};function Bo(){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 Fi=Bo;const Ui=Object.prototype.toString,{Z_NO_FLUSH:To,Z_SYNC_FLUSH:Lo,Z_FULL_FLUSH:Po,Z_FINISH:Oo,Z_OK:$n,Z_STREAM_END:Jo,Z_DEFAULT_COMPRESSION:zo,Z_DEFAULT_STRATEGY:Do,Z_DEFLATED:Fo}=Ae;function bn(n){this.options=Vn.assign({level:zo,method:Fo,chunkSize:16384,windowBits:15,memLevel:8,strategy:Do},n||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Fi,this.strm.avail_out=0;let e=pn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==$n)throw new Error(ke[e]);if(t.header&&pn.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=_n.string2buf(t.dictionary):Ui.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,e=pn.deflateSetDictionary(this.strm,r),e!==$n)throw new Error(ke[e]);this._dict_set=!0}}bn.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize;let i,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?Oo:To,typeof n=="string"?e.input=_n.string2buf(n):Ui.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),(s===Lo||s===Po)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(i=pn.deflate(e,s),i===Jo)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),i=pn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===$n;if(e.avail_out===0){this.onData(e.output);continue}if(s>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0},bn.prototype.onData=function(n){this.chunks.push(n)},bn.prototype.onEnd=function(n){n===$n&&(this.result=Vn.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Cr(n,t){const e=new bn(t);if(e.push(n,!0),e.err)throw e.msg||ke[e.err];return e.result}function Uo(n,t){return t=t||{},t.raw=!0,Cr(n,t)}function Ho(n,t){return t=t||{},t.gzip=!0,Cr(n,t)}var Zo=bn,Go=Cr,Vo=Uo,$o=Ho,Yo=Ae,qo={Deflate:Zo,deflate:Go,deflateRaw:Vo,gzip:$o,constants:Yo};const Yn=30,Wo=12;var Xo=function(t,e){let r,i,s,a,o,m,c,l,h,d,f,w,v,g,p,S,E,y,R,k,I,x,N,A;const C=t.state;r=t.next_in,N=t.input,i=r+(t.avail_in-5),s=t.next_out,A=t.output,a=s-(e-t.avail_out),o=s+(t.avail_out-257),m=C.dmax,c=C.wsize,l=C.whave,h=C.wnext,d=C.window,f=C.hold,w=C.bits,v=C.lencode,g=C.distcode,p=(1<>>24,f>>>=y,w-=y,y=E>>>16&255,y===0)A[s++]=E&65535;else if(y&16){R=E&65535,y&=15,y&&(w>>=y,w-=y),w<15&&(f+=N[r++]<>>24,f>>>=y,w-=y,y=E>>>16&255,y&16){if(k=E&65535,y&=15,wm){t.msg="invalid distance too far back",C.mode=Yn;break t}if(f>>>=y,w-=y,y=s-a,k>y){if(y=k-y,y>l&&C.sane){t.msg="invalid distance too far back",C.mode=Yn;break t}if(I=0,x=d,h===0){if(I+=c-y,y2;)A[s++]=x[I++],A[s++]=x[I++],A[s++]=x[I++],R-=3;R&&(A[s++]=x[I++],R>1&&(A[s++]=x[I++]))}else{I=s-k;do A[s++]=A[I++],A[s++]=A[I++],A[s++]=A[I++],R-=3;while(R>2);R&&(A[s++]=A[I++],R>1&&(A[s++]=A[I++]))}}else if((y&64)===0){E=g[(E&65535)+(f&(1<>3,r-=R,w-=R<<3,f&=(1<{const m=o.bits;let c=0,l=0,h=0,d=0,f=0,w=0,v=0,g=0,p=0,S=0,E,y,R,k,I,x=null,N=0,A;const C=new Uint16Array(qe+1),L=new Uint16Array(qe+1);let F=null,U=0,Y,T,J;for(c=0;c<=qe;c++)C[c]=0;for(l=0;l=1&&C[d]===0;d--);if(f>d&&(f=d),d===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,o.bits=1,0;for(h=1;h0&&(n===Gi||d!==1))return-1;for(L[1]=0,c=1;cHi||n===Vi&&p>Zi)return 1;for(;;){Y=c-v,a[l]A?(T=F[U+a[l]],J=x[N+a[l]]):(T=32+64,J=0),E=1<>v)+y]=Y<<24|T<<16|J|0;while(y!==0);for(E=1<>=1;if(E!==0?(S&=E-1,S+=E):S=0,l++,--C[c]===0){if(c===d)break;c=t[e+a[l]]}if(c>f&&(S&k)!==R){for(v===0&&(v=f),I+=h,w=c-v,g=1<Hi||n===Vi&&p>Zi)return 1;R=S&k,i[R]=f<<24|w<<16|I-s|0}}return S!==0&&(i[I+S]=c-v<<24|64<<16|0),o.bits=f,0};const ec=0,$i=1,Yi=2,{Z_FINISH:qi,Z_BLOCK:nc,Z_TREES:qn,Z_OK:Ce,Z_STREAM_END:rc,Z_NEED_DICT:ic,Z_STREAM_ERROR:Ct,Z_DATA_ERROR:Wi,Z_MEM_ERROR:Xi,Z_BUF_ERROR:sc,Z_DEFLATED:ji}=Ae,Ki=1,Qi=2,ts=3,es=4,ns=5,rs=6,is=7,ss=8,as=9,os=10,Wn=11,jt=12,Tr=13,cs=14,Lr=15,ls=16,us=17,hs=18,fs=19,Xn=20,jn=21,ds=22,ms=23,gs=24,ws=25,ps=26,Pr=27,vs=28,_s=29,st=30,bs=31,ac=32,oc=852,cc=592,lc=15,ys=n=>(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<24);function uc(){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 Ss=n=>{if(!n||!n.state)return Ct;const t=n.state;return n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=t.wrap&1),t.mode=Ki,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(oc),t.distcode=t.distdyn=new Int32Array(cc),t.sane=1,t.back=-1,Ce},Es=n=>{if(!n||!n.state)return Ct;const t=n.state;return t.wsize=0,t.whave=0,t.wnext=0,Ss(n)},Is=(n,t)=>{let e;if(!n||!n.state)return Ct;const r=n.state;return t<0?(e=0,t=-t):(e=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15)?Ct:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,Es(n))},ks=(n,t)=>{if(!n)return Ct;const e=new uc;n.state=e,e.window=null;const r=Is(n,t);return r!==Ce&&(n.state=null),r},hc=n=>ks(n,lc);let As=!0,Or,Jr;const fc=n=>{if(As){Or=new Int32Array(512),Jr=new Int32Array(32);let t=0;for(;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(yn($i,n.lens,0,288,Or,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;yn(Yi,n.lens,0,32,Jr,0,n.work,{bits:5}),As=!1}n.lencode=Or,n.lenbits=9,n.distcode=Jr,n.distbits=5},Ms=(n,t,e,r)=>{let i;const s=n.state;return s.window===null&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(e-r,e-r+i),s.wnext),r-=i,r?(s.window.set(t.subarray(e-r,e),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave{let e,r,i,s,a,o,m,c,l,h,d,f,w,v,g=0,p,S,E,y,R,k,I,x;const N=new Uint8Array(4);let A,C;const L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!n||!n.state||!n.output||!n.input&&n.avail_in!==0)return Ct;e=n.state,e.mode===jt&&(e.mode=Tr),a=n.next_out,i=n.output,m=n.avail_out,s=n.next_in,r=n.input,o=n.avail_in,c=e.hold,l=e.bits,h=o,d=m,x=Ce;t:for(;;)switch(e.mode){case Ki:if(e.wrap===0){e.mode=Tr;break}for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>>8&255,e.check=dt(e.check,N,2,0),c=0,l=0,e.mode=Qi;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((c&255)<<8)+(c>>8))%31){n.msg="incorrect header check",e.mode=st;break}if((c&15)!==ji){n.msg="unknown compression method",e.mode=st;break}if(c>>>=4,l-=4,I=(c&15)+8,e.wbits===0)e.wbits=I;else if(I>e.wbits){n.msg="invalid window size",e.mode=st;break}e.dmax=1<>8&1),e.flags&512&&(N[0]=c&255,N[1]=c>>>8&255,e.check=dt(e.check,N,2,0)),c=0,l=0,e.mode=ts;case ts:for(;l<32;){if(o===0)break t;o--,c+=r[s++]<>>8&255,N[2]=c>>>16&255,N[3]=c>>>24&255,e.check=dt(e.check,N,4,0)),c=0,l=0,e.mode=es;case es:for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>8),e.flags&512&&(N[0]=c&255,N[1]=c>>>8&255,e.check=dt(e.check,N,2,0)),c=0,l=0,e.mode=ns;case ns:if(e.flags&1024){for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>>8&255,e.check=dt(e.check,N,2,0)),c=0,l=0}else e.head&&(e.head.extra=null);e.mode=rs;case rs:if(e.flags&1024&&(f=e.length,f>o&&(f=o),f&&(e.head&&(I=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(s,s+f),I)),e.flags&512&&(e.check=dt(e.check,r,f,s)),o-=f,s+=f,e.length-=f),e.length))break t;e.length=0,e.mode=is;case is:if(e.flags&2048){if(o===0)break t;f=0;do I=r[s+f++],e.head&&I&&e.length<65536&&(e.head.name+=String.fromCharCode(I));while(I&&f>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=jt;break;case os:for(;l<32;){if(o===0)break t;o--,c+=r[s++]<>>=l&7,l-=l&7,e.mode=Pr;break}for(;l<3;){if(o===0)break t;o--,c+=r[s++]<>>=1,l-=1,c&3){case 0:e.mode=cs;break;case 1:if(fc(e),e.mode=Xn,t===qn){c>>>=2,l-=2;break t}break;case 2:e.mode=us;break;case 3:n.msg="invalid block type",e.mode=st}c>>>=2,l-=2;break;case cs:for(c>>>=l&7,l-=l&7;l<32;){if(o===0)break t;o--,c+=r[s++]<>>16^65535)){n.msg="invalid stored block lengths",e.mode=st;break}if(e.length=c&65535,c=0,l=0,e.mode=Lr,t===qn)break t;case Lr:e.mode=ls;case ls:if(f=e.length,f){if(f>o&&(f=o),f>m&&(f=m),f===0)break t;i.set(r.subarray(s,s+f),a),o-=f,s+=f,m-=f,a+=f,e.length-=f;break}e.mode=jt;break;case us:for(;l<14;){if(o===0)break t;o--,c+=r[s++]<>>=5,l-=5,e.ndist=(c&31)+1,c>>>=5,l-=5,e.ncode=(c&15)+4,c>>>=4,l-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=st;break}e.have=0,e.mode=hs;case hs:for(;e.have>>=3,l-=3}for(;e.have<19;)e.lens[L[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,A={bits:e.lenbits},x=yn(ec,e.lens,0,19,e.lencode,0,e.work,A),e.lenbits=A.bits,x){n.msg="invalid code lengths set",e.mode=st;break}e.have=0,e.mode=fs;case fs:for(;e.have>>24,S=g>>>16&255,E=g&65535,!(p<=l);){if(o===0)break t;o--,c+=r[s++]<>>=p,l-=p,e.lens[e.have++]=E;else{if(E===16){for(C=p+2;l>>=p,l-=p,e.have===0){n.msg="invalid bit length repeat",e.mode=st;break}I=e.lens[e.have-1],f=3+(c&3),c>>>=2,l-=2}else if(E===17){for(C=p+3;l>>=p,l-=p,I=0,f=3+(c&7),c>>>=3,l-=3}else{for(C=p+7;l>>=p,l-=p,I=0,f=11+(c&127),c>>>=7,l-=7}if(e.have+f>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=st;break}for(;f--;)e.lens[e.have++]=I}}if(e.mode===st)break;if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=st;break}if(e.lenbits=9,A={bits:e.lenbits},x=yn($i,e.lens,0,e.nlen,e.lencode,0,e.work,A),e.lenbits=A.bits,x){n.msg="invalid literal/lengths set",e.mode=st;break}if(e.distbits=6,e.distcode=e.distdyn,A={bits:e.distbits},x=yn(Yi,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,A),e.distbits=A.bits,x){n.msg="invalid distances set",e.mode=st;break}if(e.mode=Xn,t===qn)break t;case Xn:e.mode=jn;case jn:if(o>=6&&m>=258){n.next_out=a,n.avail_out=m,n.next_in=s,n.avail_in=o,e.hold=c,e.bits=l,Xo(n,d),a=n.next_out,i=n.output,m=n.avail_out,s=n.next_in,r=n.input,o=n.avail_in,c=e.hold,l=e.bits,e.mode===jt&&(e.back=-1);break}for(e.back=0;g=e.lencode[c&(1<>>24,S=g>>>16&255,E=g&65535,!(p<=l);){if(o===0)break t;o--,c+=r[s++]<>y)],p=g>>>24,S=g>>>16&255,E=g&65535,!(y+p<=l);){if(o===0)break t;o--,c+=r[s++]<>>=y,l-=y,e.back+=y}if(c>>>=p,l-=p,e.back+=p,e.length=E,S===0){e.mode=ps;break}if(S&32){e.back=-1,e.mode=jt;break}if(S&64){n.msg="invalid literal/length code",e.mode=st;break}e.extra=S&15,e.mode=ds;case ds:if(e.extra){for(C=e.extra;l>>=e.extra,l-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=ms;case ms:for(;g=e.distcode[c&(1<>>24,S=g>>>16&255,E=g&65535,!(p<=l);){if(o===0)break t;o--,c+=r[s++]<>y)],p=g>>>24,S=g>>>16&255,E=g&65535,!(y+p<=l);){if(o===0)break t;o--,c+=r[s++]<>>=y,l-=y,e.back+=y}if(c>>>=p,l-=p,e.back+=p,S&64){n.msg="invalid distance code",e.mode=st;break}e.offset=E,e.extra=S&15,e.mode=gs;case gs:if(e.extra){for(C=e.extra;l>>=e.extra,l-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=st;break}e.mode=ws;case ws:if(m===0)break t;if(f=d-m,e.offset>f){if(f=e.offset-f,f>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=st;break}f>e.wnext?(f-=e.wnext,w=e.wsize-f):w=e.wnext-f,f>e.length&&(f=e.length),v=e.window}else v=i,w=a-e.offset,f=e.length;f>m&&(f=m),m-=f,e.length-=f;do i[a++]=v[w++];while(--f);e.length===0&&(e.mode=jn);break;case ps:if(m===0)break t;i[a++]=e.length,m--,e.mode=jn;break;case Pr:if(e.wrap){for(;l<32;){if(o===0)break t;o--,c|=r[s++]<{if(!n||!n.state)return Ct;let t=n.state;return t.window&&(t.window=null),n.state=null,Ce},gc=(n,t)=>{if(!n||!n.state)return Ct;const e=n.state;return(e.wrap&2)===0?Ct:(e.head=t,t.done=!1,Ce)},wc=(n,t)=>{const e=t.length;let r,i,s;return!n||!n.state||(r=n.state,r.wrap!==0&&r.mode!==Wn)?Ct:r.mode===Wn&&(i=1,i=fn(i,t,e,0),i!==r.check)?Wi:(s=Ms(n,t,e,e),s?(r.mode=bs,Xi):(r.havedict=1,Ce))};var pc=Es,vc=Is,_c=Ss,bc=hc,yc=ks,Sc=dc,Ec=mc,Ic=gc,kc=wc,Ac="pako inflate (from Nodeca project)",Kt={inflateReset:pc,inflateReset2:vc,inflateResetKeep:_c,inflateInit:bc,inflateInit2:yc,inflate:Sc,inflateEnd:Ec,inflateGetHeader:Ic,inflateSetDictionary:kc,inflateInfo:Ac};function Mc(){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 xc=Mc;const xs=Object.prototype.toString,{Z_NO_FLUSH:Rc,Z_FINISH:Nc,Z_OK:Sn,Z_STREAM_END:zr,Z_NEED_DICT:Dr,Z_STREAM_ERROR:Cc,Z_DATA_ERROR:Rs,Z_MEM_ERROR:Bc}=Ae;function En(n){this.options=Vn.assign({chunkSize:1024*64,windowBits:15,to:""},n||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(n&&n.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Fi,this.strm.avail_out=0;let e=Kt.inflateInit2(this.strm,t.windowBits);if(e!==Sn)throw new Error(ke[e]);if(this.header=new xc,Kt.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=_n.string2buf(t.dictionary):xs.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=Kt.inflateSetDictionary(this.strm,t.dictionary),e!==Sn)))throw new Error(ke[e])}En.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?Nc:Rc,xs.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),s=Kt.inflate(e,a),s===Dr&&i&&(s=Kt.inflateSetDictionary(e,i),s===Sn?s=Kt.inflate(e,a):s===Rs&&(s=Dr));e.avail_in>0&&s===zr&&e.state.wrap>0&&n[e.next_in]!==0;)Kt.inflateReset(e),s=Kt.inflate(e,a);switch(s){case Cc:case Rs:case Dr:case Bc:return this.onEnd(s),this.ended=!0,!1}if(o=e.avail_out,e.next_out&&(e.avail_out===0||s===zr))if(this.options.to==="string"){let m=_n.utf8border(e.output,e.next_out),c=e.next_out-m,l=_n.buf2string(e.output,m);e.next_out=c,e.avail_out=r-c,c&&e.output.set(e.output.subarray(m,m+c),0),this.onData(l)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(s===Sn&&o===0)){if(s===zr)return s=Kt.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0},En.prototype.onData=function(n){this.chunks.push(n)},En.prototype.onEnd=function(n){n===Sn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Vn.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Fr(n,t){const e=new En(t);if(e.push(n),e.err)throw e.msg||ke[e.err];return e.result}function Tc(n,t){return t=t||{},t.raw=!0,Fr(n,t)}var Lc=En,Pc=Fr,Oc=Tc,Jc=Fr,zc=Ae,Dc={Inflate:Lc,inflate:Pc,inflateRaw:Oc,ungzip:Jc,constants:zc};const{Deflate:Fc,deflate:Uc,deflateRaw:Hc,gzip:Zc}=qo,{Inflate:Gc,inflate:Vc,inflateRaw:$c,ungzip:Yc}=Dc;var qc=Fc,Wc=Uc,Xc=Hc,jc=Zc,Kc=Gc,Qc=Vc,tl=$c,el=Yc,nl=Ae,Ur={Deflate:qc,deflate:Wc,deflateRaw:Xc,gzip:jc,Inflate:Kc,inflate:Qc,inflateRaw:tl,ungzip:el,constants:nl},D=(n=>(n[n.End=0]="End",n[n.Byte=1]="Byte",n[n.Short=2]="Short",n[n.Int=3]="Int",n[n.Long=4]="Long",n[n.Float=5]="Float",n[n.Double=6]="Double",n[n.ByteArray=7]="ByteArray",n[n.String=8]="String",n[n.List=9]="List",n[n.Compound=10]="Compound",n[n.IntArray=11]="IntArray",n[n.LongArray=12]="LongArray",n))(D||{});const mr=class{static register(t,e){const r=e.create().getId();if(r!==t)throw new Error(`Registered factory ${D[r]} does not match type ${D[t]}`);mr.FACTORIES.set(t,e)}isEnd(){return this.getId()===D.End}isByte(){return this.getId()===D.Byte}isShort(){return this.getId()===D.Short}isInt(){return this.getId()===D.Int}isLong(){return this.getId()===D.Long}isFloat(){return this.getId()===D.Float}isDouble(){return this.getId()===D.Double}isByteArray(){return this.getId()===D.ByteArray}isString(){return this.getId()===D.String}isList(){return this.getId()===D.List}isCompound(){return this.getId()===D.Compound}isIntArray(){return this.getId()===D.IntArray}isLongArray(){return this.getId()===D.LongArray}isNumber(){return this.isByte()||this.isShort()||this.isInt()||this.isLong()||this.isFloat()||this.isDouble()}isArray(){return this.isByteArray()||this.isIntArray()||this.isLongArray()}isListOrArray(){return this.isList()||this.isArray()}getAsNumber(){return 0}getAsString(){return""}toJsonWithId(){return{type:this.getId(),value:this.toJson()}}static getFactory(t){const e=this.FACTORIES.get(t);if(!e)throw new Error(`Invalid tag id ${t}`);return e}static create(t){return this.getFactory(t).create()}static fromString(t){const e=typeof t=="string"?new Et(t):t;return this.getFactory(D.Compound).fromString(e)}static fromJson(t,e=D.Compound){return this.getFactory(e).fromJson(t)}static fromJsonWithId(t){var i,s,a;const e=(i=u.Json.readObject(t))!=null?i:{},r=(s=u.Json.readInt(e.type))!=null?s:0;return mr.fromJson((a=e.value)!=null?a:{},r)}static fromBytes(t,e=D.Compound){return this.getFactory(e).fromBytes(t)}};let et=mr;_(et,"FACTORIES",new Map);const Ue=class extends et{constructor(e){super();_(this,"value");this.value=typeof e=="number"?e:e?1:0}getId(){return D.Byte}equals(e){return e.isByte()&&this.value===e.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()+"b"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(e){e.writeByte(this.value)}static create(){return Ue.ZERO}static fromJson(e){var r;return new Ue((r=u.Json.readInt(e))!=null?r:0)}static fromBytes(e){const r=e.readByte();return new Ue(r)}};let Bt=Ue;_(Bt,"ZERO",new Ue(0)),_(Bt,"ONE",new Ue(1)),et.register(D.Byte,Bt);class In extends et{constructor(e){super();_(this,"items");this.items=e}getItems(){return this.items.slice(0)}getAsTuple(e,r){return[...Array(e)].map((i,s)=>r(this.items[s]))}get(e){if(e=Math.floor(e),!(e<0||e>=this.items.length))return this.items[e]}get length(){return this.items.length}map(e){return this.items.map(e)}filter(e){return this.items.filter(e)}forEach(e){this.items.forEach(e)}set(e,r){this.items[e]=r}add(e){this.items.push(e)}insert(e,r){this.items.splice(e,0,r)}delete(e){this.items.splice(e,1)}clear(){this.items=[]}}class me extends In{constructor(t){super(Array.from(t!=null?t:[],e=>typeof e=="number"?new Bt(e):e))}getId(){return D.ByteArray}equals(t){return t.isByteArray()&&this.length===t.length&&this.items.every((e,r)=>e.equals(t.items[r]))}getType(){return D.Byte}toString(){return"[B;"+this.items.map(e=>e.getAsNumber().toFixed()+"B").join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsNumber())}toJson(){return this.items.map(t=>t.getAsNumber())}toBytes(t){t.writeInt(this.items.length),t.writeBytes(this.items.map(e=>e.getAsNumber()))}static create(){return new me([])}static fromJson(t){var r;const e=(r=u.Json.readArray(t,i=>{var s;return(s=u.Json.readNumber(i))!=null?s:0}))!=null?r:[];return new me(e)}static fromBytes(t){const e=t.readInt(),r=t.readBytes(e);return new me(r)}}et.register(D.ByteArray,me);class Be extends et{constructor(e){super();_(this,"value");this.value=e}getId(){return D.Float}equals(e){return e.isFloat()&&this.value===e.value}getAsNumber(){return this.value}toString(){return this.value.toString()+"f"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(e){e.writeFloat(this.value)}static create(){return new Be(0)}static fromJson(e){var r;return new Be((r=u.Json.readNumber(e))!=null?r:0)}static fromBytes(e){const r=e.readFloat();return new Be(r)}}et.register(D.Float,Be);class Dt extends et{constructor(e){super();_(this,"value");this.value=e}getId(){return D.Int}equals(e){return e.isInt()&&this.value===e.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(e){e.writeInt(this.value)}static create(){return new Dt(0)}static fromJson(e){var r;return new Dt((r=u.Json.readInt(e))!=null?r:0)}static fromBytes(e){const r=e.readInt();return new Dt(r)}}et.register(D.Int,Dt);class ge extends In{constructor(t){super(Array.from(t!=null?t:[],e=>typeof e=="number"?new Dt(e):e))}getId(){return D.IntArray}equals(t){return t.isIntArray()&&this.length===t.length&&this.items.every((e,r)=>e.equals(t.items[r]))}getType(){return D.Int}get length(){return this.items.length}toString(){return"[I;"+this.items.map(e=>e.getAsNumber().toFixed()).join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsNumber())}toJson(){return this.items.map(t=>t.getAsNumber())}toBytes(t){t.writeInt(this.items.length);for(const e of this.items)t.writeInt(e.getAsNumber())}static create(){return new ge}static fromJson(t){var r;const e=(r=u.Json.readArray(t,i=>{var s;return(s=u.Json.readNumber(i))!=null?s:0}))!=null?r:[];return new ge(e)}static fromBytes(t){const e=t.readInt(),r=[];for(let i=0;inew e(i)))}getId(){return D.List}equals(e){return e.isList()&&this.type===e.type&&this.length===e.length&&this.items.every((r,i)=>r.equals(e.items[i]))}getType(){return this.type}getNumber(e){const r=this.get(e);return r!=null&&r.isNumber()?r.getAsNumber():0}getString(e){const r=this.get(e);return r!=null&&r.isString()?r.getAsString():""}getList(e,r){const i=this.get(e);return(i==null?void 0:i.isList())&&i.getType()===r?i:Tt.create()}getCompound(e){const r=this.get(e);return r!=null&&r.isCompound()?r:mt.create()}set(e,r){this.updateType(r),super.set(e,r)}add(e){this.updateType(e),super.add(e)}insert(e,r){this.updateType(r),super.insert(e,r)}updateType(e){if(e.getId()!==D.End){if(this.type===D.End)this.type=e.getId();else if(this.type!==e.getId())throw new Error(`Trying to add tag of type ${D[e.getId()]} to list of ${D[this.type]}`)}}clear(){super.clear(),this.type=D.End}toString(){return"["+this.items.map(e=>e.toString()).join(",")+"]"}toPrettyString(e=" ",r=0){if(this.length===0)return"[]";const i=e.repeat(r),s=e.repeat(r+1);return`[ `+this.map(a=>s+a.toPrettyString(e,r+1)).join(`, `)+` `+i+"]"}toSimplifiedJson(){return this.map(e=>e.toSimplifiedJson())}toJson(){return{type:this.type,items:this.items.map(e=>e.toJson())}}toBytes(e){this.items.length===0?this.type=D.End:this.type=this.items[0].getId(),e.writeByte(this.type),e.writeInt(this.items.length);for(const r of this.items)r.toBytes(e)}static create(){return new Tt}static fromJson(e){var a,o,m;const r=(a=u.Json.readObject(e))!=null?a:{},i=(o=u.Json.readNumber(r.type))!=null?o:D.Compound,s=((m=u.Json.readArray(r.items))!=null?m:[]).flatMap(c=>c!==void 0?[et.fromJson(c,i)]:[]);return new Tt(s,i)}static fromBytes(e){const r=e.readByte(),i=e.readInt();if(r===D.End&&i>0)throw new Error(`Missing type on ListTag but length is ${i}`);const s=[];for(let a=0;atypeof r=="number"?r:0):[0,0])}static fromBytes(e){const r=e.readInt(),i=e.readInt();return new ft([r,i])}};let Te=ft;_(Te,"dataview",new DataView(new Uint8Array(8).buffer)),et.register(D.Long,Te);class we extends In{constructor(t){super(Array.from(t!=null?t:[],e=>typeof e=="bigint"||Array.isArray(e)?new Te(e):e))}getId(){return D.LongArray}equals(t){return t.isLongArray()&&this.length===t.length&&this.items.every((e,r)=>e.equals(t.items[r]))}getType(){return D.Long}get length(){return this.items.length}toString(){return"[I;"+this.items.map(e=>e.toString()).join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsPair())}toJson(){return this.items.map(t=>t.getAsPair())}toBytes(t){t.writeInt(this.items.length);for(const e of this.items){const[r,i]=e.getAsPair();t.writeInt(r),t.writeInt(i)}}static create(){return new we}static fromJson(t){var r;const e=(r=u.Json.readArray(t,i=>{var s;return(s=u.Json.readPair(i,a=>{var o;return(o=u.Json.readNumber(a))!=null?o:0}))!=null?s:[0,0]}))!=null?r:[];return new we(e)}static fromBytes(t){const e=t.readInt(),r=[];for(let i=0;i{const t=new RegExp("^[-+]?(?:[0-9]+[.]|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?$","i"),e=new RegExp("^[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?d$","i"),r=new RegExp("^[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?f$","i"),i=new RegExp("^[-+]?(?:0|[1-9][0-9]*)b$","i"),s=new RegExp("^[-+]?(?:0|[1-9][0-9]*)l$","i"),a=new RegExp("^[-+]?(?:0|[1-9][0-9]*)s$","i"),o=new RegExp("^[-+]?(?:0|[1-9][0-9]*)$","i");function m(f){if(f.skipWhitespace(),!f.canRead())throw f.createError("Expected value");const w=f.peek();if(w==="{")return c(f);if(w==="[")if(f.canRead(3)&&!Et.isQuotedStringStart(f.peek(1))&&f.peek(2)===";"){f.expect("[",!0);const v=f.cursor,g=f.read();if(f.skip(),f.skipWhitespace(),f.canRead()){if(g==="B")return h(f,me,D.ByteArray,D.Byte);if(g==="L")return h(f,we,D.LongArray,D.Long);if(g==="I")return h(f,ge,D.IntArray,D.Int);throw f.cursor=v,f.createError(`Invalid array type '${g}'`)}else throw f.createError("Expected value")}else return l(f);else{f.skipWhitespace();const v=f.cursor;if(Et.isQuotedStringStart(f.peek()))return new vt(f.readQuotedString());{const g=f.readUnquotedString();if(g.length===0)throw f.cursor=v,f.createError("Expected value");try{if(r.test(g)){const p=Number(g.substring(0,g.length-1));return new Be(p)}else if(i.test(g)){const p=Number(g.substring(0,g.length-1));return new Bt(Math.floor(p))}else if(s.test(g)){const p=BigInt(g.substring(0,g.length-1));return new Te(p)}else if(a.test(g)){const p=Number(g.substring(0,g.length-1));return new Le(Math.floor(p))}else if(o.test(g)){const p=Number(g);return new Dt(Math.floor(p))}else if(e.test(g)){const p=Number(g.substring(0,g.length-1));return new te(p)}else if(t.test(g)){const p=Number(g);return new te(p)}else{if(g.toLowerCase()==="true")return Bt.ONE;if(g.toLowerCase()==="false")return Bt.ZERO}}catch{}return g.length===0?vt.EMPTY:new vt(g)}}}n.readTag=m;function c(f){f.expect("{",!0);const w=new Map;for(f.skipWhitespace();f.canRead()&&f.peek()!=="}";){const v=f.cursor;if(f.skipWhitespace(),!f.canRead())throw f.createError("Expected key");const g=f.readString();if(g.length===0)throw f.cursor=v,f.createError("Expected key");f.expect(":",!0);const p=m(f);if(w.set(g,p),!d(f))break;if(!f.canRead())throw f.createError("Expected key")}return f.expect("}",!0),new mt(w)}function l(f){if(f.expect("[",!0),f.skipWhitespace(),!f.canRead())throw f.createError("Expected value");const w=[];let v=D.End;for(;f.peek()!=="]";){const g=f.cursor,p=m(f),S=p.getId();if(v===D.End)v=S;else if(S!==v)throw f.cursor=g,f.createError(`Can't insert ${D[S]} into list of ${D[v]}`);if(w.push(p),!d(f))break;if(!f.canRead())throw f.createError("Expected value")}return f.expect("]",!0),new Tt(w,v)}function h(f,w,v,g){const p=[];for(;f.peek()!=="]";){const S=m(f);if(S.getId()!==g)throw f.createError(`Can't insert ${D[S.getId()]} into ${D[v]}`);if(p.push(S.isLong()?S.getAsPair():S.getAsNumber()),!d(f))break;if(!f.canRead())throw f.createError("Expected value")}return f.expect("]"),new w(p)}function d(f){return f.skipWhitespace(),f.canRead()&&f.peek()===","?(f.skip(),f.skipWhitespace(),!0):!1}})(Kn||(Kn={}));class mt extends et{constructor(e){super();_(this,"properties");this.properties=e!=null?e:new Map}getId(){return D.Compound}equals(e){return e.isCompound()&&this.size===e.size&&[...this.properties.entries()].every(([r,i])=>{const s=e.properties.get(r);return s!==void 0&&i.equals(s)})}has(e){return this.properties.has(e)}hasNumber(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.isNumber())!=null?i:!1}hasString(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.isString())!=null?i:!1}hasList(e,r,i){var a;const s=this.get(e);return(a=(s==null?void 0:s.isList())&&(r===void 0||s.getType()===r)&&(i===void 0||s.length===i))!=null?a:!1}hasCompound(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.isCompound())!=null?i:!1}get(e){return this.properties.get(e)}getString(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.getAsString())!=null?i:""}getNumber(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.getAsNumber())!=null?i:0}getBoolean(e){return this.getNumber(e)!==0}getList(e,r){const i=this.get(e);return(i==null?void 0:i.isList())&&(r===void 0||i.getType()===r)?i:Tt.create()}getCompound(e){const r=this.get(e);return r!=null&&r.isCompound()?r:mt.create()}getByteArray(e){const r=this.get(e);return r!=null&&r.isByteArray()?r:me.create()}getIntArray(e){const r=this.get(e);return r!=null&&r.isIntArray()?r:ge.create()}getLongArray(e){const r=this.get(e);return r!=null&&r.isLongArray()?r:we.create()}keys(){return this.properties.keys()}get size(){return this.properties.size}map(e){return Object.fromEntries([...this.properties.entries()].map(([r,i])=>e(r,i,this)))}forEach(e){[...this.properties.entries()].forEach(([r,i])=>e(r,i,this))}set(e,r){return this.properties.set(e,r),this}delete(e){return this.properties.delete(e)}clear(){return this.properties.clear(),this}toString(){const e=[];for(const[r,i]of this.properties.entries()){const s=r.split("").some(a=>!Et.isAllowedInUnquotedString(a));e.push((s?JSON.stringify(r):r)+":"+i.toString())}return"{"+e.join(",")+"}"}toPrettyString(e=" ",r=0){if(this.size===0)return"{}";const i=e.repeat(r),s=e.repeat(r+1),a=[];for(const[o,m]of this.properties.entries()){const c=o.split("").some(l=>!Et.isAllowedInUnquotedString(l));a.push((c?JSON.stringify(o):o)+": "+m.toPrettyString(e,r+1))}return`{ `+a.map(o=>s+o).join(`, `)+` `+i+"}"}toSimplifiedJson(){return this.map((e,r)=>[e,r.toSimplifiedJson()])}toJson(){return this.map((e,r)=>[e,{type:r.getId(),value:r.toJson()}])}toBytes(e){for(const[r,i]of this.properties.entries()){const s=i.getId();e.writeByte(s),e.writeString(r),i.toBytes(e)}e.writeByte(D.End)}static create(){return new mt}static fromString(e){return Kn.readTag(e)}static fromJson(e){const r=u.Json.readMap(e,i=>{var c;const{type:s,value:a}=(c=u.Json.readObject(i))!=null?c:{},o=u.Json.readNumber(s);return et.fromJson(a!=null?a:{},o)});return new mt(new Map(Object.entries(r)))}static fromBytes(e){const r=new Map;for(;;){const i=e.readByte();if(i===D.End)break;const s=e.readString(),a=et.fromBytes(e,i);r.set(s,a)}return new mt(r)}}et.register(D.Compound,mt);const be=class{constructor(t,e,r,i,s){this.name=t,this.root=e,this.compression=r,this.littleEndian=i,this.bedrockHeader=s}writeNamedTag(t){t.writeByte(D.Compound),t.writeString(this.name),this.root.toBytes(t)}write(){const t=this.littleEndian===!0||this.bedrockHeader!==void 0,e=new li({littleEndian:t,offset:this.bedrockHeader&&8});if(this.writeNamedTag(e),this.bedrockHeader!==void 0){const i=e.offset;e.offset=0,e.writeInt(this.bedrockHeader),e.writeInt(i-8),e.offset=i}const r=e.getData();return this.compression==="gzip"?Ur.gzip(r):this.compression==="zlib"?Ur.deflate(r):r}static readNamedTag(t){if(t.readByte()!==D.Compound)throw new Error("Top tag should be a compound");return{name:t.readString(),root:mt.fromBytes(t)}}static create(t={}){var o,m,c;const e=(o=t.name)!=null?o:be.DEFAULT_NAME,r=mt.create(),i=(m=t.compression)!=null?m:"none",s=typeof t.bedrockHeader=="boolean"?be.DEFAULT_BEDROCK_HEADER:t.bedrockHeader,a=(c=t.littleEndian)!=null?c:t.bedrockHeader!==void 0;return new be(e,r,i,a,s)}static read(t,e={}){var d;const r=typeof e.bedrockHeader=="number"?e.bedrockHeader:e.bedrockHeader?ia(t):void 0,i=e.compression==="gzip"||!r&&e.compression===void 0&&Mt(t),s=e.compression==="zlib"||!r&&e.compression===void 0&&Se(t),a=s||i?Ur.inflate(t):t,o=e.littleEndian||r!==void 0,m=i?"gzip":s?"zlib":"none",c=new ci(a,{littleEndian:o,offset:r&&8}),{name:l,root:h}=be.readNamedTag(c);return new be((d=e.name)!=null?d:l,h,m,o,r)}toJson(){var t;return{name:this.name,root:this.root.toJson(),compression:this.compression,littleEndian:this.littleEndian,bedrockHeader:(t=this.bedrockHeader)!=null?t:null}}static fromJson(t){var m,c,l,h,d;const e=(m=u.Json.readObject(t))!=null?m:{},r=(c=u.Json.readString(e.name))!=null?c:"",i=mt.fromJson((l=e.root)!=null?l:{}),s=(h=u.Json.readString(e.compression))!=null?h:"none",a=(d=u.Json.readBoolean(e.littleEndian))!=null?d:!1,o=u.Json.readNumber(e.bedrockHeader);return new be(r,i,s,a,o)}};let Vt=be;_(Vt,"DEFAULT_NAME",""),_(Vt,"DEFAULT_BEDROCK_HEADER",4);class Qt{constructor(t,e,r,i,s){_(this,"file");_(this,"dirty");this.x=t,this.z=e,this.compression=r,this.timestamp=i,this.raw=s,this.dirty=!1}getCompression(){switch(this.compression){case 1:return"gzip";case 2:return"zlib";case 3:return"none";default:throw new Error(`Invalid compression mode ${this.compression}`)}}setCompression(t){switch(t){case"gzip":this.compression=1;break;case"zlib":this.compression=2;break;case"none":this.compression=3;break;default:throw new Error(`Invalid compression mode ${t}`)}}getFile(){return this.file===void 0&&(this.file=Vt.read(this.raw,{compression:this.getCompression()})),this.file}getRoot(){return this.getFile().root}setRoot(t){this.file===void 0&&(this.file=Vt.create({compression:this.getCompression()})),this.file.root=t,this.markDirty()}markDirty(){this.dirty=!0}getRaw(){if(this.file===void 0||this.dirty===!1)return this.raw;this.file.compression=this.getCompression();const t=this.file.write();return this.raw=t,this.dirty=!1,t}toJson(){return{x:this.x,z:this.z,compression:this.compression,timestamp:this.timestamp,size:this.raw.byteLength}}toRef(t){return new Qt.Ref(this.x,this.z,this.compression,this.timestamp,this.raw.byteLength,t)}static create(t,e,r,i){const s=new Qt(t,e,0,i!=null?i:0,r.write());return s.setCompression(r.compression),s}static fromJson(t,e){var c,l,h,d,f,w;const r=(c=u.Json.readObject(t))!=null?c:{},i=(l=u.Json.readInt(r.x))!=null?l:0,s=(h=u.Json.readInt(r.z))!=null?h:0,a=(d=u.Json.readNumber(r.compression))!=null?d:2,o=(f=u.Json.readInt(r.timestamp))!=null?f:0,m=(w=u.Json.readInt(r.size))!=null?w:0;return new Qt.Ref(i,s,a,o,m,e)}}(n=>{class t{constructor(r,i,s,a,o,m){_(this,"file");this.x=r,this.z=i,this.compression=s,this.timestamp=a,this.size=o,this.resolver=m}getFile(){if(this.file instanceof Vt)return this.file}getRoot(){if(this.file instanceof Vt)return this.file.root}async getFileAsync(){return this.file?this.file:(this.file=(async()=>{const r=await this.resolver(this.x,this.z);return this.file=r,r})(),this.file)}async getRootAsync(){return(await this.getFileAsync()).root}isResolved(){return this.file instanceof Vt}}n.Ref=t})(Qt||(Qt={}));class Ns{constructor(t){_(this,"chunks");this.chunks=Array(32*32).fill(void 0);for(const e of t){const r=pe.getIndex(e.x,e.z);this.chunks[r]=e}}getChunkPositions(){return this.chunks.flatMap(t=>t?[[t.x,t.z]]:[])}getChunk(t){if(!(t<0||t>=32*32))return this.chunks[t]}findChunk(t,e){return this.getChunk(pe.getIndex(t,e))}getFirstChunk(){return this.chunks.filter(t=>t!==void 0)[0]}filter(t){return this.chunks.filter(e=>e!==void 0&&t(e))}map(t){return this.chunks.flatMap(e=>e!==void 0?[t(e)]:[])}}class pe extends Ns{constructor(t){super(t)}write(){let t=0;for(const s of this.chunks)s!==void 0&&(t+=Math.ceil(s.getRaw().length/4096));const e=new Uint8Array(8192+t*4096),r=new DataView(e.buffer);let i=2;for(const s of this.chunks){if(s===void 0)continue;const a=s.getRaw(),o=4*((s.x&31)+(s.z&31)*32),m=Math.ceil(a.length/4096);r.setInt8(o,i>>16),r.setInt16(o+1,i&65535),r.setInt8(o+3,m),r.setInt32(o+4096,s.timestamp);const c=i*4096;r.setInt32(c,a.length+1),r.setInt8(c+4,s.compression),e.set(a,c+5),i+=m}return e}static read(t){const e=[];for(let r=0;r<32;r+=1)for(let i=0;i<32;i+=1){const s=4*((r&31)+(i&31)*32);if(t[s+3]===0)continue;const o=(t[s]<<16)+(t[s+1]<<8)+t[s+2],m=(t[s+4096]<<24)+(t[s+4097]<<16)+(t[s+4098]<<8)+t[s+4099],c=o*4096,l=(t[c]<<24)+(t[c+1]<<16)+(t[c+2]<<8)+t[c+3],h=t[c+4],d=t.slice(c+5,c+4+l);e.push(new Qt(r,i,h,m,d))}return new pe(e)}static getIndex(t,e){return(t&31)+(e&31)*32}toJson(){return{chunks:this.map(t=>t.toJson())}}static fromJson(t,e){var a,o;const r=(a=u.Json.readObject(t))!=null?a:{},s=((o=u.Json.readArray(r.chunks))!=null?o:[]).flatMap(m=>m!==void 0?[Qt.fromJson(m,e)]:[]);return new pe.Ref(s)}}(n=>{class t extends Ns{}n.Ref=t})(pe||(pe={}));class te extends et{constructor(e){super();_(this,"value");this.value=e}getId(){return D.Double}equals(e){return e.isDouble()&&this.value===e.value}getAsNumber(){return this.value}toString(){return Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(e){e.writeDouble(this.value)}static create(){return new te(0)}static fromJson(e){var r;return new te((r=u.Json.readNumber(e))!=null?r:0)}static fromBytes(e){const r=e.readDouble();return new te(r)}}et.register(D.Double,te);const tn=class extends et{constructor(){super()}getId(){return D.End}equals(t){return t.isEnd()}toString(){return"END"}toPrettyString(){return this.toString()}toSimplifiedJson(){return null}toJson(){return null}toBytes(){}static create(){return tn.INSTANCE}static fromJson(){return tn.INSTANCE}static fromBytes(){return tn.INSTANCE}};let kn=tn;_(kn,"INSTANCE",new tn),et.register(D.End,kn);function Hr(n){return typeof n=="string"?new vt(n):typeof n=="number"?Number.isInteger(n)?new Dt(n):new te(n):typeof n=="boolean"?new Bt(n):Array.isArray(n)?new Tt(n.map(Hr)):typeof n=="object"&&n!==null?new mt(new Map(Object.entries(n!=null?n:{}).map(([t,e])=>[t,Hr(e)]))):new Bt(0)}u.Direction=(n=>(n.UP="up",n.DOWN="down",n.NORTH="north",n.EAST="east",n.SOUTH="south",n.WEST="west",n))(u.Direction||{});const rl={up:[0,1,0],down:[0,-1,0],north:[0,0,-1],east:[1,0,0],south:[0,0,1],west:[-1,0,0]};(n=>{n.ALL=["up","down","north","east","south","west"];function t(e){return rl[e]}n.normal=t})(u.Direction||(u.Direction={})),u.BlockPos=void 0,(n=>{function t(h,d,f){return[h,d,f]}n.create=t,n.ZERO=n.create(0,0,0);function e(h,d,f,w){return[h[0]+d,h[1]+f,h[2]+w]}n.offset=e;function r(h,d){return[h[0]-d[0],h[1]-d[1],h[2]-d[2]]}n.subtract=r;function i(h,d){return[h[0]+d[0],h[1]+d[1],h[2]+d[2]]}n.add=i;function s(h,d){return n.offset(h,...u.Direction.normal(d))}n.towards=s;function a(h,d){return h===d?!0:h[0]===d[0]&&h[1]===d[1]&&h[2]===d[2]}n.equals=a;function o(h){return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]}n.magnitude=o;function m(h){return new Tt(h.map(d=>new Dt(d)))}n.toNbt=m;function c(h){return h.getAsTuple(3,d=>d!=null&&d.isInt()?d.getAsNumber():0)}n.fromNbt=c;function l(h){var f;const d=(f=u.Json.readArray(h,w=>{var v;return(v=u.Json.readInt(w))!=null?v:0}))!=null?f:[0,0,0];return t(d[0],d[1],d[2])}n.fromJson=l})(u.BlockPos||(u.BlockPos={}));const ae=class{constructor(t,e){this.namespace=t,this.path=e}is(t){return this.equals(ae.parse(t))}equals(t){return this===t?!0:t instanceof ae?this.namespace===t.namespace&&this.path===t.path:!1}toString(){return this.namespace+ae.SEPARATOR+this.path}withPrefix(t){return new ae(this.namespace,t+this.path)}static create(t){return new ae(this.DEFAULT_NAMESPACE,t)}static parse(t){const e=t.indexOf(this.SEPARATOR);if(e>=0){const r=e>=1?t.substring(0,e):this.DEFAULT_NAMESPACE,i=t.substring(e+1);return new ae(r,i)}return new ae(this.DEFAULT_NAMESPACE,t)}};let B=ae;_(B,"DEFAULT_NAMESPACE","minecraft"),_(B,"SEPARATOR",":");const yt=class{constructor(t,e={}){_(this,"name");this.properties=e,this.name=typeof t=="string"?B.parse(t):t}getName(){return this.name}getProperties(){return this.properties}getProperty(t){return this.properties[t]}isFluid(){return this.is(yt.WATER)||this.is(yt.LAVA)}isWaterlogged(){return this.is(yt.WATER)||this.is(yt.LAVA)||this.is("bubble_column")||this.is("kelp")||this.is("kelp_plant")||this.is("seagrass")||this.is("tall_seagrass")||this.properties.waterlogged==="true"}equals(t){return this.name.equals(t.name)?Object.keys(this.properties).every(e=>t.properties[e]===this.properties[e]):!1}is(t){return typeof t=="string"?this.name.equals(B.parse(t)):t instanceof B?this.name.equals(t):this.name.equals(t.name)}toString(){return Object.keys(this.properties).length===0?this.name.toString():`${this.name.toString()}[${Object.entries(this.properties).map(([t,e])=>t+"="+e).join(",")}]`}static parse(t){const e=t.indexOf("[");if(e===-1)return new yt(t);{const r=t.substring(0,e),i=t.substring(e+1,t.length-1).split(","),s=Object.fromEntries(i.map(a=>a.split("=")));return new yt(r,s)}}static fromNbt(t){const e=B.parse(t.getString("Name")),r=t.getCompound("Properties").map((i,s)=>[i,s.getAsString()]);return new yt(e,r)}static fromJson(t){var s,a;const e=(s=u.Json.readObject(t))!=null?s:{},r=B.parse((a=u.Json.readString(e.Name))!=null?a:yt.STONE.name.toString()),i=u.Json.readMap(e.Properties,o=>{var m;return(m=u.Json.readString(o))!=null?m:""});return new yt(r,i)}};let j=yt;_(j,"AIR",new yt(B.create("air"))),_(j,"STONE",new yt(B.create("stone"))),_(j,"WATER",new yt(B.create("water"),{level:"0"})),_(j,"LAVA",new yt(B.create("lava"),{level:"0"}));class Cs{constructor(t,e){_(this,"storage");_(this,"palette");this.size=t,this.defaultValue=e,this.storage=Array(t).fill(0),this.palette=[e]}index(t,e,r){return(t<<8)+(e<<4)+r}get(t,e,r){const i=this.storage[this.index(t,e,r)];return this.palette[i]}set(t,e,r,i){let s=this.palette.findIndex(a=>a.equals(i));s===-1&&(s=this.palette.length,this.palette.push(i)),this.storage[this.index(t,e,r)]=s}}const en=class{constructor(t){_(this,"states");this.minY=t,this.states=new Cs(en.SIZE,j.AIR)}get minBlockY(){return this.minY<<4}getBlockState(t,e,r){return this.states.get(t,e,r)}setBlockState(t,e,r,i){this.states.set(t,e,r,i)}};let We=en;_(We,"WIDTH",16),_(We,"SIZE",en.WIDTH*en.WIDTH*en.WIDTH);class il{constructor(t,e,r){_(this,"sections");this.minY=t,this.height=e,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(this.maxY-1>>4)+1}get sectionsCount(){return this.maxSection-this.minSection}getSectionIndex(t){return(t>>4)-this.minSection}getBlockState(t){var a;const[e,r,i]=t,s=this.sections[this.getSectionIndex(r)];return(a=s==null?void 0:s.getBlockState(e&15,r&15,i&15))!=null?a:j.AIR}setBlockState(t,e){const[r,i,s]=t,a=this.getSectionIndex(i);let o=this.sections[a];if(o===null){if(e.equals(j.AIR))return;o=this.getOrCreateSection(a)}o.setBlockState(r&15,i&15,s&15,e)}getOrCreateSection(t){return this.sections[t]==null&&(this.sections[t]=new We(this.minSection+t)),this.sections[t]}}u.ChunkPos=void 0,(n=>{function t(l,h){return[l,h]}n.create=t;function e(l){return[l[0]>>4,l[2]>>4]}n.fromBlockPos=e;function r(l){return[Number(l)&4294967295,Number(l>>BigInt(32))]}n.fromLong=r;function i(l){return s(l[0],l[1])}n.toLong=i;function s(l,h){return BigInt(l&4294967295)|BigInt(h&4294967295)<{function t(e){return{effect:B.parse(e.getString("id")),duration:e.getNumber("duration"),amplifier:e.getNumber("amplifier")}}n.fromNbt=t})(u.MobEffectInstance||(u.MobEffectInstance={}));const Ts=new Map([["minecraft:empty",[]],["minecraft:water",[]],["minecraft:mundane",[]],["minecraft:thick",[]],["minecraft:awkward",[]],["minecraft:night_vision",[{effect:B.create("night_vision"),duration:3600,amplifier:0}]],["minecraft:long_night_vision",[{effect:B.create("night_vision"),duration:9600,amplifier:0}]],["minecraft:invisibility",[{effect:B.create("invisibility"),duration:3600,amplifier:0}]],["minecraft:long_invisibility",[{effect:B.create("invisibility"),duration:9600,amplifier:0}]],["minecraft:leaping",[{effect:B.create("jump_boost"),duration:3600,amplifier:0}]],["minecraft:long_leaping",[{effect:B.create("jump_boost"),duration:9600,amplifier:0}]],["minecraft:strong_leaping",[{effect:B.create("jump_boost"),duration:1800,amplifier:1}]],["minecraft:fire_resistance",[{effect:B.create("fire_resistance"),duration:3600,amplifier:0}]],["minecraft:long_fire_resistance",[{effect:B.create("fire_resistance"),duration:9600,amplifier:0}]],["minecraft:swiftness",[{effect:B.create("speed"),duration:3600,amplifier:0}]],["minecraft:long_swiftness",[{effect:B.create("speed"),duration:9600,amplifier:0}]],["minecraft:strong_swiftness",[{effect:B.create("speed"),duration:1800,amplifier:1}]],["minecraft:slowness",[{effect:B.create("slowness"),duration:1800,amplifier:0}]],["minecraft:long_slowness",[{effect:B.create("slowness"),duration:4800,amplifier:0}]],["minecraft:strong_slowness",[{effect:B.create("slowness"),duration:400,amplifier:3}]],["minecraft:turtle_master",[{effect:B.create("slowness"),duration:400,amplifier:3},{effect:B.create("resistance"),duration:400,amplifier:2}]],["minecraft:long_turtle_master",[{effect:B.create("slowness"),duration:800,amplifier:3},{effect:B.create("resistance"),duration:800,amplifier:2}]],["minecraft:strong_turtle_master",[{effect:B.create("slowness"),duration:400,amplifier:5},{effect:B.create("resistance"),duration:400,amplifier:3}]],["minecraft:water_breathing",[{effect:B.create("water_breathing"),duration:3600,amplifier:0}]],["minecraft:long_water_breathing",[{effect:B.create("water_breathing"),duration:9600,amplifier:0}]],["minecraft:healing",[{effect:B.create("instant_health"),duration:1,amplifier:0}]],["minecraft:strong_healing",[{effect:B.create("instant_health"),duration:1,amplifier:1}]],["minecraft:harming",[{effect:B.create("instant_damage"),duration:1,amplifier:0}]],["minecraft:strong_harming",[{effect:B.create("instant_damage"),duration:1,amplifier:1}]],["minecraft:poison",[{effect:B.create("poison"),duration:900,amplifier:0}]],["minecraft:long_poison",[{effect:B.create("poison"),duration:1800,amplifier:0}]],["minecraft:strong_poison",[{effect:B.create("poison"),duration:432,amplifier:1}]],["minecraft:regeneration",[{effect:B.create("regeneration"),duration:900,amplifier:0}]],["minecraft:long_regeneration",[{effect:B.create("regeneration"),duration:1800,amplifier:0}]],["minecraft:strong_regeneration",[{effect:B.create("regeneration"),duration:450,amplifier:1}]],["minecraft:strength",[{effect:B.create("strength"),duration:3600,amplifier:0}]],["minecraft:long_strength",[{effect:B.create("strength"),duration:9600,amplifier:0}]],["minecraft:strong_strength",[{effect:B.create("strength"),duration:1800,amplifier:1}]],["minecraft:weakness",[{effect:B.create("weakness"),duration:1800,amplifier:0}]],["minecraft:long_weakness",[{effect:B.create("weakness"),duration:4800,amplifier:0}]],["minecraft:luck",[{effect:B.create("luck"),duration:6e3,amplifier:0}]],["minecraft:slow_falling",[{effect:B.create("slow_falling"),duration:1800,amplifier:0}]],["minecraft:long_slow_falling",[{effect:B.create("slow_falling"),duration:4800,amplifier:0}]],["minecraft:wind_charged",[{effect:B.create("wind_charged"),duration:3600,amplifier:0}]],["minecraft:weaving",[{effect:B.create("weaving"),duration:3600,amplifier:0}]],["minecraft:oozing",[{effect:B.create("oozing"),duration:3600,amplifier:0}]],["minecraft:infested",[{effect:B.create("infested"),duration:3600,amplifier:0}]]]);u.PotionContents=void 0,(n=>{function t(s){const a={};return s.isString()?a.potion=B.parse(s.getAsString()):s.isCompound()&&(s.hasString("potion")&&(a.potion=B.parse(s.getString("potion"))),s.hasNumber("custom_color")&&(a.customColor=s.getNumber("custom_color")),s.hasList("custom_effects")&&(a.customEffects=s.getList("custom_effects",D.Compound).map(u.MobEffectInstance.fromNbt))),a}n.fromNbt=t;function e(s){if(s.customColor)return u.Color.intToRgb(s.customColor);const a=r(s);return i(a)}n.getColor=e;function r(s){var o;const a=[];return s.potion&&a.push(...(o=Ts.get(s.potion.toString()))!=null?o:[]),s.customEffects&&a.push(...s.customEffects),a}n.getAllEffects=r;function i(s){let[a,o,m]=[0,0,0],c=0;for(const l of s){const h=Bs.get(l.effect.toString());if(h===void 0)continue;const d=u.Color.intToRgb(h),f=l.amplifier+1;a+=f*d[0],o+=f*d[1],m+=f*d[2],c+=f}return c===0?u.Color.intToRgb(-13083194):(a=a/c,o=o/c,m=m/c,[a,o,m])}})(u.PotionContents||(u.PotionContents={})),u.Holder=void 0,(n=>{function t(i,s){return a=>typeof a=="string"?r(i,B.parse(a)):e(s(a))}n.parser=t;function e(i,s){return{value:()=>i,key:()=>s}}n.direct=e;function r(i,s,a=!0){return a?{value:()=>i.getOrThrow(s),key:()=>s}:{value:()=>i.get(s),key:()=>s}}n.reference=r})(u.Holder||(u.Holder={}));class ve{constructor(t){this.entries=t}static parser(t,e){const r=e!=null?e:i=>{var s;return u.Holder.reference(t,B.parse((s=u.Json.readString(i))!=null?s:""))};return i=>{var s,a;return typeof i=="string"?i.startsWith("#")?u.Holder.reference(t.getTagRegistry(),B.parse(i.substring(1))):u.Holder.direct(new ve([])):u.Holder.direct((a=new ve((s=u.Json.readArray(i,r))!=null?s:[]))!=null?a:[])}}static fromJson(t,e,r){var o,m,c;const i=(o=u.Json.readObject(e))!=null?o:{},s=(m=u.Json.readBoolean(i.replace))!=null?m:!1,a=(c=u.Json.readArray(i.values,l=>{var f,w,v;var h=!0,d="";if(typeof l=="string")d=l;else{const g=(f=u.Json.readObject(l))!=null?f:{};h=(w=u.Json.readBoolean(g.required))!=null?w:!1,d=(v=u.Json.readString(g.id))!=null?v:""}return d.startsWith("#")?u.Holder.reference(t.getTagRegistry(),B.parse(d.substring(1)),h):u.Holder.reference(t,B.parse(d),h)}))!=null?c:[];return r&&!s&&t.getTagRegistry().has(r)&&(a==null||a.push(u.Holder.direct(t.getTagRegistry().get(r)))),new ve(a)}*getEntries(){for(const t of this.entries){const e=t.value();e!==void 0&&(e instanceof ve?yield*e.getEntries():yield t)}}}class $t{constructor(t,e,r=new Map){this.id=t,this.count=e,this.components=r}getComponent(t,e){var i;if(typeof t=="string"&&(t=B.parse(t)),this.components.has("!"+t.toString()))return;const r=this.components.get(t.toString());if(r)return r;if(e)return(i=e.getItemComponents(this.id))==null?void 0:i.get(t.toString())}hasComponent(t,e){var r;return typeof t=="string"&&(t=B.parse(t)),this.components.has("!"+t.toString())?!1:this.components.has(t.toString())?!0:e?(r=e.getItemComponents(this.id))==null?void 0:r.has(t.toString()):!1}clone(){const t=new Map(this.components);return new $t(this.id,this.count,t)}is(t){return typeof t=="string"?this.id.equals(B.parse(t)):t instanceof B?this.id.equals(t):this.id.equals(t.id)}equals(t){return this===t?!0:t instanceof $t?this.count===t.count&&this.isSameItemSameComponents(t):!1}isSameItemSameComponents(t){if(!this.id.equals(t.id)||this.components.size!==t.components.size)return!1;for(const[e,r]of this.components){const i=t.components.get(e);if(r.toString()!==(i==null?void 0:i.toString()))return!1}return!0}toString(){let t=this.id.toString();return this.components.size>0&&(t+=`[${[...this.components.entries()].map(([e,r])=>e.startsWith("!")?e:`${e}=${r.toString()}`).join(",")}]`),this.count>1&&(t+=` ${this.count}`),t}static fromString(t){const e=new Et(t);for(;e.canRead()&&e.peek()!=="[";)e.skip();const r=B.parse(e.getRead());if(!e.canRead())return new $t(r,1);const i=new Map;if(e.skip(),e.peek()==="]")return new $t(r,1,i);do{if(e.peek()==="!"){e.skip();const s=e.cursor;for(;e.canRead()&&e.peek()!=="]"&&e.peek()!==",";)e.skip();i.set("!"+B.parse(e.getRead(s)).toString(),new mt)}else{const s=e.cursor;for(;e.canRead()&&e.peek()!=="=";)e.skip();const a=B.parse(e.getRead(s)).toString();if(!e.canRead())break;e.skip();const o=Kn.readTag(e);i.set(a,o)}if(!e.canRead())break;if(e.peek()==="]")return new $t(r,1,i);if(e.peek()!==",")throw new Error("Expected , or ]");e.skip()}while(e.canRead());throw new Error("Missing closing ]")}toNbt(){const t=new mt().set("id",new vt(this.id.toString()));return this.count>1&&t.set("count",new Dt(this.count)),this.components.size>0&&t.set("components",new mt(this.components)),t}static fromNbt(t){const e=B.parse(t.getString("id")),r=t.hasNumber("count")?t.getNumber("count"):1,i=new Map(Object.entries(t.getCompound("components").map((s,a)=>s.startsWith("!")?["!"+B.parse(s).toString(),new mt]:[B.parse(s).toString(),a])));return new $t(e,r,i)}}const He=class{constructor(t,e){_(this,"storage",new Map);_(this,"builtin",new Map);_(this,"tags");this.key=t,this.parser=e}static createAndRegister(t,e){const r=new He(B.create(t),e);return He.REGISTRY.register(r.key,r),r}register(t,e,r){return this.storage.set(t.toString(),e),r&&this.builtin.set(t.toString(),e),u.Holder.reference(this,t)}delete(t){const e=this.storage.delete(t.toString());return this.builtin.delete(t.toString()),e}keys(){return[...this.storage.keys()].map(t=>B.parse(t))}has(t){return this.storage.has(t.toString())}get(t){var e=this.storage.get(t.toString());return e instanceof Function&&(e=e(),this.storage.set(t.toString(),e)),e}getOrThrow(t){const e=this.get(t);if(e===void 0)throw new Error(`Missing key in ${this.key.toString()}: ${t.toString()}`);return e}parse(t){if(!this.parser)throw new Error(`No parser exists for ${this.key.toString()}`);return this.parser(t)}clear(){this.storage.clear();for(const[t,e]of this.builtin.entries())this.storage.set(t,e);return this.tags&&this.tags.clear(),this}assign(t){if(!this.key.equals(t.key))throw new Error(`Cannot assign registry of type ${t.key.toString()} to registry of type ${this.key.toString()}`);for(const e of t.keys())this.storage.set(e.toString(),t.getOrThrow(e));return this}cloneEmpty(){return new He(this.key,this.parser)}forEach(t){for(const[e,r]of this.storage.entries())t(B.parse(e),r instanceof Function?r():r,this)}map(t){return[...this.storage.entries()].map(([e,r])=>t(B.parse(e),r instanceof Function?r():r,this))}getTagRegistry(){return this.tags===void 0&&(this.tags=new He(new B(this.key.namespace,`tags/${this.key.path}`))),this.tags}};let xt=He;_(xt,"REGISTRY",new He(B.create("root"))),u.Rotation=(n=>(n.NONE="none",n.CLOCKWISE_90="clockwise_90",n.CLOCKWISE_180="180",n.COUNTERCLOCKWISE_90="counterclockwise_90",n))(u.Rotation||{}),(n=>{function t(e){return["none","clockwise_90","180","counterclockwise_90"][e.nextInt(4)]}n.getRandom=t})(u.Rotation||(u.Rotation={}));const gr=class{constructor(t,e=[],r=[]){_(this,"blocksMap",[]);this.size=t,this.palette=e,this.blocks=r,r.forEach(i=>{if(!this.isInside(i.pos))throw new Error(`Found block at ${i.pos} which is outside the structure bounds ${this.size}`);this.blocksMap[i.pos[0]*t[1]*t[2]+i.pos[1]*t[2]+i.pos[2]]=i})}getSize(){return this.size}addBlock(t,e,r,i){if(!this.isInside(t))throw new Error(`Cannot add block at ${t} outside the structure bounds ${this.size}`);const s=new j(e,r);let a=this.palette.findIndex(o=>o.equals(s));return a===-1&&(a=this.palette.length,this.palette.push(s)),this.blocks.push({pos:t,state:a,nbt:i}),this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]]={pos:t,state:a,nbt:i},this}getBlocks(){return this.blocks.map(t=>this.toPlacedBlock(t))}getBlock(t){if(!this.isInside(t))return null;const e=this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]];return e?this.toPlacedBlock(e):null}toPlacedBlock(t){const e=this.palette[t.state];if(!e)throw new Error(`Block at ${t.pos.join(" ")} in structure references invalid palette index ${t.state}`);return{pos:t.pos,state:e,nbt:t.nbt}}isInside(t){return t[0]>=0&&t[0]=0&&t[1]=0&&t[2]j.fromNbt(s)),i=t.getList("blocks",D.Compound).map(s=>{const a=u.BlockPos.fromNbt(s.getList("pos")),o=s.getNumber("state"),m=s.getCompound("nbt");return{pos:a,state:o,nbt:m.size>0?m:void 0}});return new gr(e,r,i)}static transform(t,e,r){switch(e){case u.Rotation.COUNTERCLOCKWISE_90:return u.BlockPos.create(r[0]-r[2]+t[2],t[1],r[0]+r[2]-t[0]);case u.Rotation.CLOCKWISE_90:return u.BlockPos.create(r[0]+r[2]-t[2],t[1],r[2]-r[0]+t[0]);case u.Rotation.CLOCKWISE_180:return u.BlockPos.create(r[0]+r[0]-t[0],t[1],r[2]+r[2]-t[2]);default:return t}}};let ee=gr;_(ee,"REGISTRY",xt.createAndRegister("structures")),_(ee,"EMPTY",new gr(u.BlockPos.ZERO));const sl=-2147483648,al=2147483647,ol=-9223372036854776e3,cl=9223372036854776e3;function ne(n){return n*n}function _t(n,t,e){return Math.max(t,Math.min(e,n))}function Pe(n,t,e){return t+n*(e-t)}function Zr(n,t,e){return Math.fround(t+Math.fround(n*Math.fround(e-t)))}function Qn(n,t,e,r,i,s){return Pe(t,Pe(n,e,r),Pe(n,i,s))}function Ls(n,t,e,r,i,s,a,o,m,c,l){return Pe(e,Qn(n,t,r,i,s,a),Qn(n,t,o,m,c,l))}function An(n,t,e){return n===0?t():n===1?e():t()+n*(e()-t())}function Gr(n,t,e,r,i,s){return An(t,()=>An(n,e,r),()=>An(n,i,s))}function Ps(n,t,e,r,i,s,a,o,m,c,l){return An(e,()=>Gr(n,t,r,i,s,a),()=>Gr(n,t,o,m,c,l))}function tr(n,t,e){return e<0?n:e>1?t:Pe(e,n,t)}function Vr(n,t,e){return(n-t)/(e-t)}function er(n){return n*n*n*(n*(n*6-15)+10)}function Mn(n,t,e,r,i){return Pe(Vr(n,t,e),r,i)}function $r(n,t,e,r,i){return tr(r,i,Vr(n,t,e))}function Yt(n){return _t(Math.floor(n),sl,al)}function Os(n){return _t(Math.floor(n),ol,cl)}function Js(n,t,e){let r=t-n;for(;r>0;){const i=Math.floor(r/2),s=n+i;if(e(s)){r=i;continue}n=s+1,r-=i+1}return n}function Yr(n,t,e){let r=BigInt(n*3129871)^BigInt(e)*BigInt(116129781)^BigInt(t);return r=r*r*BigInt(42317861)+r*BigInt(11),r>>BigInt(16)}function nr(n,t,e,r,i,s,a,o){return BigInt(n)<>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>18,n|=n>>32,n+1}function rr(n,t,e){return n.nextInt(e-t+1)+t}function ir(n,t,e){return t>=e?t:n.nextInt(e-t+1)+t}function Ds(n,t){for(var e=n.length;e>1;e--){const r=t.nextInt(e),i=n[r];n[r]=n[e-1],n[e-1]=i}}u.MinMaxNumberFunction=void 0,(n=>{function t(e){return typeof e=="object"&&e!==null&&"minValue"in e&&"maxValue"in e}n.is=t})(u.MinMaxNumberFunction||(u.MinMaxNumberFunction={})),u.CubicSpline=void 0,(n=>{function t(i,s){var c,l,h,d;if(typeof i=="number")return new e(i);const a=(c=u.Json.readObject(i))!=null?c:{},o=new r(s(a.coordinate)),m=(l=u.Json.readArray(a.points,f=>{var w;return(w=u.Json.readObject(f))!=null?w:{}}))!=null?l:[];if(m.length===0)return new e(0);for(const f of m){const w=(h=u.Json.readNumber(f.location))!=null?h:0,v=t(f.value,s),g=(d=u.Json.readNumber(f.derivative))!=null?d:0;o.addPoint(w,v,g)}return o}n.fromJson=t;class e{constructor(s){this.value=s}compute(){return this.value}min(){return this.value}max(){return this.value}mapAll(){return this}calculateMinMax(){}}n.Constant=e;class r{constructor(s,a=[],o=[],m=[]){_(this,"calculatedMin",Number.NEGATIVE_INFINITY);_(this,"calculatedMax",Number.POSITIVE_INFINITY);this.coordinate=s,this.locations=a,this.values=o,this.derivatives=m}compute(s){const a=this.coordinate.compute(s),o=Js(0,this.locations.length,E=>aa.mapAll(s)),this.derivatives)}addPoint(s,a,o=0){return this.locations.push(Math.fround(s)),this.values.push(typeof a=="number"?new n.Constant(Math.fround(a)):a),this.derivatives.push(Math.fround(o)),this}calculateMinMax(){if(!u.MinMaxNumberFunction.is(this.coordinate))return;const s=this.locations.length-1;var a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;const m=this.coordinate.minValue(),c=this.coordinate.maxValue();for(const h of this.values)h.calculateMinMax();if(mthis.locations[s]){const h=r.linearExtend(c,this.locations,this.values[s].min(),this.derivatives,s),d=r.linearExtend(c,this.locations,this.values[s].max(),this.derivatives,s);a=Math.min(a,Math.min(h,d)),o=Math.max(o,Math.max(h,d))}for(const h of this.values)a=Math.min(a,h.min()),o=Math.max(o,h.max());for(var l=0;l>>32-r},rotr:function(e,r){return e<<32-r|e>>>r},endian:function(e){if(e.constructor==Number)return t.rotl(e,8)&16711935|t.rotl(e,24)&4278255360;for(var r=0;r0;e--)r.push(Math.floor(Math.random()*256));return r},bytesToWords:function(e){for(var r=[],i=0,s=0;i>>5]|=e[i]<<24-s%32;return r},wordsToBytes:function(e){for(var r=[],i=0;i>>5]>>>24-i%32&255);return r},bytesToHex:function(e){for(var r=[],i=0;i>>4).toString(16)),r.push((e[i]&15).toString(16));return r.join("")},hexToBytes:function(e){for(var r=[],i=0;i>>6*(3-a)&63)):r.push("=");return r.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var r=[],i=0,s=0;i>>6-s*2);return r}};Us.exports=t})();var Qr={utf8:{stringToBytes:function(n){return Qr.bin.stringToBytes(unescape(encodeURIComponent(n)))},bytesToString:function(n){return decodeURIComponent(escape(Qr.bin.bytesToString(n)))}},bin:{stringToBytes:function(n){for(var t=[],e=0;e * @license MIT */var Vl=function(n){return n!=null&&(Zs(n)||$l(n)||!!n._isBuffer)};function Zs(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function $l(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Zs(n.slice(0,0))}(function(){var n=Us.exports,t=Hs.utf8,e=Vl,r=Hs.bin,i=function(s,a){s.constructor==String?a&&a.encoding==="binary"?s=r.stringToBytes(s):s=t.stringToBytes(s):e(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var o=n.bytesToWords(s),m=s.length*8,c=1732584193,l=-271733879,h=-1732584194,d=271733878,f=0;f>>24)&16711935|(o[f]<<24|o[f]>>>8)&4278255360;o[m>>>5]|=128<>>9<<4)+14]=m;for(var w=i._ff,v=i._gg,g=i._hh,p=i._ii,f=0;f>>0,l=l+E>>>0,h=h+y>>>0,d=d+R>>>0}return n.endian([c,l,h,d])};i._ff=function(s,a,o,m,c,l,h){var d=s+(a&o|~a&m)+(c>>>0)+h;return(d<>>32-l)+a},i._gg=function(s,a,o,m,c,l,h){var d=s+(a&m|o&~m)+(c>>>0)+h;return(d<>>32-l)+a},i._hh=function(s,a,o,m,c,l,h){var d=s+(a^o^m)+(c>>>0)+h;return(d<>>32-l)+a},i._ii=function(s,a,o,m,c,l,h){var d=s+(o^(a|~m))+(c>>>0)+h;return(d<>>32-l)+a},i._blocksize=16,i._digestsize=16,Kr.exports=function(s,a){if(s==null)throw new Error("Illegal argument "+s);var o=n.wordsToBytes(i(s,a));return a&&a.asBytes?o:a&&a.asString?r.bytesToString(o):n.bytesToHex(o)}})();const Rt=class{constructor(t){_(this,"seed",BigInt(0));this.setSeed(t)}static fromLargeFeatureSeed(t,e,r){const i=new Rt(t),s=i.nextLong(),a=i.nextLong(),o=BigInt(e)*s^BigInt(r)*a^t;return i.setSeed(o),i}static fromLargeFeatureWithSalt(t,e,r,i){const s=BigInt(e)*BigInt("341873128712")+BigInt(r)*BigInt("132897987541")+t+BigInt(i);return new Rt(s)}fork(){return new Rt(this.nextLong())}forkPositional(){return new Gs(this.nextLong())}setSeed(t){this.seed=(t^Rt.MULTIPLIER)&Rt.MODULUS_MASK}advance(){this.seed=this.seed*Rt.MULTIPLIER+Rt.INCREMENT&Rt.MODULUS_MASK}consume(t){for(let e=0;e>BigInt(Rt.MODULUS_BITS-t));return e>2147483647?e-4294967296:e}nextInt(t){if(t===void 0)return this.next(32);if((t&t-1)==0)return Number(BigInt(t)*BigInt(this.next(31))>>BigInt(31));let e,r;for(;(e=this.next(31))-(r=e%t)+(t-1)<0;);return r}nextLong(){return(BigInt(this.next(32))<>$.BIGINT_30)*$.STAFFORD_1&$.MAX_ULONG,t=(t^t>>$.BIGINT_27)*$.STAFFORD_2&$.MAX_ULONG,(t^t>>$.BIGINT_31)&$.MAX_ULONG}static upgradeSeedTo128bit(t){t<0&&(t+=$.POW2_60);const e=t^$.SILVER_RATIO_64,r=e+$.GOLDEN_RATIO_64&$.MAX_ULONG;return[$.mixStafford13(e),$.mixStafford13(r)]}static rotateLeft(t,e){return t<>$.BIGINT_64-e}setSeed(t){this.seed=$.upgradeSeedTo128bit(t)}fork(){return new $([this.next(),this.next()])}forkPositional(){return new Vs(this.next(),this.next())}next(){const t=this.seed[0];let e=this.seed[1];const r=$.rotateLeft(t+e&$.MAX_ULONG,$.BIGINT_17)+t&$.MAX_ULONG;return e^=t,this.seed=[$.rotateLeft(t,$.BIGINT_49)^e^e<<$.BIGINT_21&$.MAX_ULONG,$.rotateLeft(e,$.BIGINT_28)],r}nextLong(){let t=this.next();return t>$.POW2_63&&(t-=$.POW2_60),t}consume(t){let e=this.seed[0],r=this.seed[1];for(let i=0;i>BigInt(64-t)}nextInt(t){let e=this.next()&$.MAX_UINT;if(t){const r=BigInt(t);let i=e*r,s=i&$.MAX_UINT;if(s>$.BIGINT_32;return Number(a)}else{let r=Number(e);return r>=2147483648&&(r-=4294967296),r}}nextFloat(){return Number(this.nextBits(24))*$.FLOAT_MULTIPLIER}nextDouble(){return Number(this.nextBits(53))*$.DOUBLE_MULTIPLIER}parityConfigString(){return"seedLo: "+this.seed[0]+", seedHi: "+this.seed[1]}};let nt=$;_(nt,"SILVER_RATIO_64",BigInt("7640891576956012809")),_(nt,"GOLDEN_RATIO_64",BigInt("-7046029254386353131")),_(nt,"FLOAT_MULTIPLIER",1/Math.pow(2,24)),_(nt,"DOUBLE_MULTIPLIER",11102230246251565e-32),_(nt,"BIGINT_1",BigInt(1)),_(nt,"BIGINT_17",BigInt(17)),_(nt,"BIGINT_21",BigInt(21)),_(nt,"BIGINT_27",BigInt(27)),_(nt,"BIGINT_28",BigInt(28)),_(nt,"BIGINT_30",BigInt(30)),_(nt,"BIGINT_31",BigInt(31)),_(nt,"BIGINT_32",BigInt(32)),_(nt,"BIGINT_49",BigInt(49)),_(nt,"BIGINT_64",BigInt(64)),_(nt,"STAFFORD_1",BigInt("-4658895280553007687")),_(nt,"STAFFORD_2",BigInt("-7723592293110705685")),_(nt,"MAX_ULONG",BigInt("0xFFFFFFFFFFFFFFFF")),_(nt,"POW2_60",BigInt("0x10000000000000000")),_(nt,"POW2_63",BigInt("0x8000000000000000")),_(nt,"MAX_UINT",BigInt(4294967295));class Vs{constructor(t,e){this.seedLo=t,this.seedHi=e}at(t,e,r){const s=Yr(t,e,r)^this.seedLo;return new nt([s,this.seedHi])}fromHashOf(t){const e=Kr.exports(t,{asBytes:!0}),r=nr(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]),i=nr(e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]);return new nt([r^this.seedLo,i^this.seedHi])}seedKey(){return[this.seedLo,this.seedHi]}}const Wt=class{constructor(t){_(this,"p");_(this,"xo");_(this,"yo");_(this,"zo");this.xo=t.nextDouble()*256,this.yo=t.nextDouble()*256,this.zo=t.nextDouble()*256,this.p=Array(256);for(let e=0;e<256;e+=1)this.p[e]=e;for(let e=0;e<256;e+=1){const r=t.nextInt(256-e),i=this.p[e];this.p[e]=this.p[e+r],this.p[e+r]=i}}sample2D(t,e){const r=(t+e)*Wt.F2,i=Yt(t+r),s=Yt(e+r),a=(i+s)*Wt.G2,o=i-a,m=t-o;let c,l;const h=e-(s-a);m>h?(c=1,l=0):(c=0,l=1);const d=m-c+Wt.G2,f=h-l+Wt.G2,w=m-1+2*Wt.G2,v=h-1+2*Wt.G2,g=i&255,p=s&255,S=this.P(g+this.P(p))%12,E=this.P(g+c+this.P(p+l))%12,y=this.P(g+1+this.P(p+1))%12,R=this.getCornerNoise3D(S,m,h,0,.5),k=this.getCornerNoise3D(E,d,f,0,.5),I=this.getCornerNoise3D(y,w,v,0,.5);return 70*(R+k+I)}sample(t,e,r){const i=(t+e+r)*.3333333333333333,s=Yt(t+i),a=Yt(e+i),o=Yt(r+i),m=(s+a+o)*.16666666666666666,c=t-(s-m),l=e-(a-m),h=r-(o-m);let d,f,w,v,g,p;c>=l?l>=h?(d=1,f=0,w=0,v=1,g=1,p=0):c>=h?(d=1,f=0,w=0,v=1,g=0,p=1):(d=0,f=0,w=1,v=1,g=0,p=1):l127?e-256:e;for(let e=0;e<256;e+=1){const r=t.nextInt(256-e),i=this.p[e];this.p[e]=this.p[e+r],this.p[e+r]=i}}sample(t,e,r,i=0,s=0){const a=t+this.xo,o=e+this.yo,m=r+this.zo,c=Yt(a),l=Yt(o),h=Yt(m),d=a-c,f=o-l,w=m-h;let v=0;if(i!==0){const g=s>=0&&s=0;s-=1)s0&&(d=this.maxLimitNoise.getOctaveNoise(p))&&(g+=d.sample(S,E,y,R,s*w)/w),w/=2}return tr(v/512,g/512,f)/128}}const Tn=class{constructor(t,{firstOctave:e,amplitudes:r}){_(this,"valueFactor");_(this,"first");_(this,"second");_(this,"maxValue");this.first=new pt(t,e,r),this.second=new pt(t,e,r);let i=1/0,s=-1/0;for(let o=0;o{function t(r,i){return{firstOctave:r,amplitudes:i}}n.create=t;function e(r){var s,a,o;const i=(s=u.Json.readObject(r))!=null?s:{};return{firstOctave:(a=u.Json.readInt(i.firstOctave))!=null?a:0,amplitudes:(o=u.Json.readArray(i.amplitudes,m=>{var c;return(c=u.Json.readNumber(m))!=null?c:0}))!=null?o:[]}}n.fromJson=e})(u.NoiseParameters||(u.NoiseParameters={}));class Yl{constructor(t,e){_(this,"noiseLevels");_(this,"highestFreqInputFactor");_(this,"highestFreqValueFactor");const r=e[e.length-1],s=-e[0]+r+1,a=new Set(e),o=new wt(t);this.noiseLevels=Array(s),r>=0&&r=0&&a.has(r-m)?this.noiseLevels[m]=new wt(t):t.consume(262);if(r>0)throw new Error("Positive octaves are not allowed");this.highestFreqInputFactor=Math.pow(2,r),this.highestFreqValueFactor=1/(Math.pow(2,s)-1)}sample(t,e,r){let i=0,s=this.highestFreqInputFactor,a=this.highestFreqValueFactor;for(let o=0;o{const t=n/15,e=t*.6+(t>0?.4:.3),r=_t(t*t*.7-.5,0,1),i=_t(t*t*.6-.7,0,1);return[e,r,i]},qs=n=>[n/8,1-n/32,n*64],Oe={large_fern:()=>se,tall_grass:()=>se,grass_block:()=>se,fern:()=>se,grass:()=>se,short_grass:()=>se,potted_fern:()=>se,pink_petals:()=>se,spruce_leaves:()=>ql,birch_leaves:()=>Wl,oak_leaves:()=>Xe,jungle_leaves:()=>Xe,acacia_leaves:()=>Xe,dark_oak_leaves:()=>Xe,vine:()=>Xe,mangrove_leaves:()=>Xe,water:()=>or,bubble_column:()=>or,cauldron:()=>or,water_cauldron:()=>or,redstone_wire:n=>{var t;return jl(parseInt((t=n.power)!=null?t:"0"))},sugar_cane:()=>se,attached_melon_stem:()=>Ys,attached_pumpkin_stem:()=>Ys,melon_stem:n=>{var t;return qs(parseInt((t=n.age)!=null?t:"0"))},pumpkin_stem:n=>{var t;return qs(parseInt((t=n.age)!=null?t:"0"))},lily_pad:()=>Xl};u.Cull=void 0,(n=>{function t(r,i,s){let{up:a,down:o,north:m,east:c,south:l,west:h}=r;switch(s){case 90:[m,c,l,h]=[c,l,h,m];break;case 180:[m,c,l,h]=[l,h,m,c];break;case 270:[m,c,l,h]=[h,m,c,l]}switch(i){case 90:[a,m,o,l]=[m,o,l,a];break;case 180:[a,m,o,l]=[o,l,a,m];break;case 270:[a,m,o,l]=[l,a,m,o]}return{up:a,down:o,north:m,east:c,south:l,west:h}}n.rotate=t;function e(){return Object.create(null)}n.none=e})(u.Cull||(u.Cull={}));const Ut=class{constructor(t,e,r,i,s){this.pos=t,this.color=e,this.texture=r,this.normal=i,this.blockPos=s}transform(t){return Ut.VEC[0]=this.pos.x,Ut.VEC[1]=this.pos.y,Ut.VEC[2]=this.pos.z,Zl(Ut.VEC,Ut.VEC,t),this.pos=new q(Ut.VEC[0],Ut.VEC[1],Ut.VEC[2]),this}static fromPos(t){return new Ut(t,[0,0,0],[0,0],void 0,void 0)}};let Pt=Ut;_(Pt,"VEC",jr());class cr{constructor(t,e){this.v1=t,this.v2=e}vertices(){return[this.v1,this.v2]}forEach(t){return t(this.v1),t(this.v2),this}transform(t){return this.forEach(e=>e.transform(t)),this}setColor(t){return this.forEach(e=>e.color=t),this}toString(){return`Line(${this.v1.pos.toString()}, ${this.v2.pos.toString()})`}static fromPoints(t,e){return new cr(Pt.fromPos(t),Pt.fromPos(e))}}class it{constructor(t=[],e=[]){_(this,"posBuffer");_(this,"colorBuffer");_(this,"textureBuffer");_(this,"normalBuffer");_(this,"blockPosBuffer");_(this,"indexBuffer");_(this,"linePosBuffer");_(this,"lineColorBuffer");this.quads=t,this.lines=e}clear(){return this.quads=[],this.lines=[],this}isEmpty(){return this.quads.length===0&&this.lines.length===0}quadVertices(){return this.quads.length*4}quadIndices(){return this.quads.length*6}lineVertices(){return this.lines.length*2}merge(t){return this.quads=this.quads.concat(t.quads),this.lines=this.lines.concat(t.lines),this}addLine(t,e,r,i,s,a,o){const m=new cr(Pt.fromPos(new q(t,e,r)),Pt.fromPos(new q(i,s,a))).setColor(o);return this.lines.push(m),this}addLineCube(t,e,r,i,s,a,o){return this.addLine(t,e,r,t,e,a,o),this.addLine(i,e,r,i,e,a,o),this.addLine(t,e,r,i,e,r,o),this.addLine(t,e,a,i,e,a,o),this.addLine(t,e,r,t,s,r,o),this.addLine(i,e,r,i,s,r,o),this.addLine(t,e,a,t,s,a,o),this.addLine(i,e,a,i,s,a,o),this.addLine(t,s,r,t,s,a,o),this.addLine(i,s,r,i,s,a,o),this.addLine(t,s,r,i,s,r,o),this.addLine(t,s,a,i,s,a,o),this}transform(t){for(const e of this.quads)e.transform(t);return this}computeNormals(){for(const t of this.quads){const e=t.normal();t.forEach(r=>r.normal=e)}}rebuild(t,e){const r=(s,a,o)=>{var m;if(s||(s=(m=t.createBuffer())!=null?m:void 0),!s)throw new Error("Cannot create new buffer");return t.bindBuffer(a,s),t.bufferData(a,o,t.DYNAMIC_DRAW),s},i=(s,a,o)=>{if(s.length===0){a&&t.deleteBuffer(a);return}const m=s.flatMap(c=>c.vertices().flatMap(l=>{const h=o(l);if(!h)throw new Error("Missing vertex component");return h}));return r(a,t.ARRAY_BUFFER,new Float32Array(m))};return e.pos&&(this.posBuffer=i(this.quads,this.posBuffer,s=>s.pos.components()),this.linePosBuffer=i(this.lines,this.linePosBuffer,s=>s.pos.components())),e.color&&(this.colorBuffer=i(this.quads,this.colorBuffer,s=>s.color),this.lineColorBuffer=i(this.lines,this.lineColorBuffer,s=>s.color)),e.texture&&(this.textureBuffer=i(this.quads,this.textureBuffer,s=>s.texture)),e.normal&&(this.normalBuffer=i(this.quads,this.normalBuffer,s=>{var a;return(a=s.normal)==null?void 0:a.components()})),e.blockPos&&(this.blockPosBuffer=i(this.quads,this.blockPosBuffer,s=>{var a;return(a=s.blockPos)==null?void 0:a.components()})),this.quads.length===0?(this.indexBuffer&&t.deleteBuffer(this.indexBuffer),this.indexBuffer=void 0):this.indexBuffer=r(this.indexBuffer,t.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.quads.flatMap((s,a)=>[4*a,4*a+1,4*a+2,a*4,4*a+2,4*a+3],!0))),this}}class ei{constructor(t,e){this.variants=t,this.multipart=e}getModelVariants(t){if(this.variants){const e=Object.keys(this.variants).filter(i=>this.matchesVariant(i,t));if(e.length===0)return[];const r=this.variants[e[0]];return[Array.isArray(r)?r[0]:r]}else if(this.multipart)return this.multipart.filter(r=>r.when?this.matchesCase(r.when,t):!0).map(r=>Array.isArray(r.apply)?r.apply[0]:r.apply);return[]}getMesh(t,e,r,i,s){var c,l,h,d,f;const a=this.getModelVariants(e),o=new it;for(const w of a){const v=u.Cull.rotate(s,(c=w.x)!=null?c:0,(l=w.y)!=null?l:0),g=i.getBlockModel(B.parse(w.model));if(!g)throw new Error(`Cannot find block model ${w.model}`);const p=t?(h=Oe[t.path])==null?void 0:h.call(Oe,e):void 0,S=g.getMesh(r,v,p);if(w.x||w.y){const E=rt();X(E,E,[8,8,8]),bt(E,E,-Wr((d=w.y)!=null?d:0)),xn(E,E,-Wr((f=w.x)!=null?f:0)),X(E,E,[-8,-8,-8]),S.transform(E)}o.merge(S)}const m=rt();return Lt(m,m,[.0625,.0625,.0625]),o.transform(m)}matchesVariant(t,e){return t.split(",").every(r=>{const[i,s]=r.split("=");return e[i]===s})}matchesCase(t,e){if(Array.isArray(t.OR))return t.OR.some(i=>this.matchesCase(i,e));const r=t;return Object.keys(r).every(i=>r[i].split("|").includes(e[i]))}static fromJson(t){return new ei(t.variants,t.multipart)}}class qt{constructor(t,e,r,i){this.v1=t,this.v2=e,this.v3=r,this.v4=i}vertices(){return[this.v1,this.v2,this.v3,this.v4]}forEach(t){return t(this.v1),t(this.v2),t(this.v3),t(this.v4),this}transform(t){return this.forEach(e=>e.transform(t)),this}normal(){const t=this.v2.pos.sub(this.v1.pos),e=this.v3.pos.sub(this.v1.pos);return t.cross(e).normalize()}reverse(){return[this.v1,this.v2,this.v3,this.v4]=[this.v4,this.v3,this.v2,this.v1],this}setColor(t){return this.forEach(e=>e.color=t),this}setTexture(t){return this.v1.texture=[t[0],t[1]],this.v2.texture=[t[2],t[3]],this.v3.texture=[t[4],t[5]],this.v4.texture=[t[6],t[7]],this}toString(){return`Quad(${this.v1.pos.toString()}, ${this.v2.pos.toString()}, ${this.v3.pos.toString()}, ${this.v4.pos.toString()})`}static fromPoints(t,e,r,i){return new qt(Pt.fromPos(t),Pt.fromPos(e),Pt.fromPos(r),Pt.fromPos(i))}}const Kl={0:[0,3,2,3,2,1,0,1],90:[2,3,2,1,0,1,0,3],180:[2,1,0,1,0,3,2,3],270:[0,1,0,3,2,3,2,1]},Ql={x:[1,0,0],y:[0,1,0],z:[0,0,1]},je=1.41421356237,tu={x:[1,je,je],y:[je,1,je],z:[je,je,1]},nn=class{constructor(t,e,r,i,s){_(this,"generationMarker",!1);_(this,"uvEpsilon",1/16);this.parent=t,this.textures=e,this.elements=r,this.display=i,this.guiLight=s}getDisplayTransform(t){var i;const e=(i=this.display)==null?void 0:i[t],r=rt();return X(r,r,[8,8,8]),e!=null&&e.translation&&X(r,r,e.translation),e!=null&&e.rotation&&(xn(r,r,e.rotation[0]*Math.PI/180),bt(r,r,e.rotation[1]*Math.PI/180),Fs(r,r,-e.rotation[2]*Math.PI/180)),e!=null&&e.scale&&Lt(r,r,e.scale),X(r,r,[-8,-8,-8]),r}getMesh(t,e,r){var a;const i=new it,s=o=>r===void 0?[1,1,1]:o===void 0||o<0?[1,1,1]:typeof r=="function"?r(o):r;for(const o of(a=this.elements)!=null?a:[])i.merge(this.getElementMesh(o,t,e,s));return i}getElementMesh(t,e,r,i){var w,v,g,p,S,E,y,R,k,I,x,N;const s=new it,[a,o,m]=t.from,[c,l,h]=t.to,d=(A,C,L)=>{var Z,Q,kt,At,St,ut,lt,H,O;const F=qt.fromPoints(new q(L[0],L[1],L[2]),new q(L[3],L[4],L[5]),new q(L[6],L[7],L[8]),new q(L[9],L[10],L[11])),U=i(A.tintindex);F.setColor(U);const[Y,T,J,G]=e.getTextureUV(this.getTexture(A.texture)),V=(J-Y)/16,M=(G-T)/16,b=V*this.uvEpsilon,P=M*this.uvEpsilon;C[0]=((Q=(Z=A.uv)==null?void 0:Z[0])!=null?Q:C[0])*V+b,C[1]=((At=(kt=A.uv)==null?void 0:kt[1])!=null?At:C[1])*M+P,C[2]=((ut=(St=A.uv)==null?void 0:St[2])!=null?ut:C[2])*V-b,C[3]=((H=(lt=A.uv)==null?void 0:lt[3])!=null?H:C[3])*M-P;const z=Kl[(O=A.rotation)!=null?O:0];F.setTexture([Y+C[z[0]],T+C[z[1]],Y+C[z[2]],T+C[z[3]],Y+C[z[4]],T+C[z[5]],Y+C[z[6]],T+C[z[7]]]),s.quads.push(F)};((v=(w=t.faces)==null?void 0:w.up)==null?void 0:v.texture)&&(!t.faces.up.cullface||!r[t.faces.up.cullface])&&d(t.faces.up,[a,16-h,c,16-m],[a,l,h,c,l,h,c,l,m,a,l,m]),((p=(g=t.faces)==null?void 0:g.down)==null?void 0:p.texture)&&(!t.faces.down.cullface||!r[t.faces.down.cullface])&&d(t.faces.down,[16-h,16-c,16-m,16-a],[a,o,m,c,o,m,c,o,h,a,o,h]),((E=(S=t.faces)==null?void 0:S.south)==null?void 0:E.texture)&&(!t.faces.south.cullface||!r[t.faces.south.cullface])&&d(t.faces.south,[a,16-l,c,16-o],[a,o,h,c,o,h,c,l,h,a,l,h]),((R=(y=t.faces)==null?void 0:y.north)==null?void 0:R.texture)&&(!t.faces.north.cullface||!r[t.faces.north.cullface])&&d(t.faces.north,[16-c,16-l,16-a,16-o],[c,o,m,a,o,m,a,l,m,c,l,m]),((I=(k=t.faces)==null?void 0:k.east)==null?void 0:I.texture)&&(!t.faces.east.cullface||!r[t.faces.east.cullface])&&d(t.faces.east,[16-h,16-l,16-m,16-o],[c,o,h,c,o,m,c,l,m,c,l,h]),((N=(x=t.faces)==null?void 0:x.west)==null?void 0:N.texture)&&(!t.faces.west.cullface||!r[t.faces.west.cullface])&&d(t.faces.west,[m,16-l,h,16-o],[a,o,m,a,o,h,a,l,h,a,l,m]);const f=rt();if(t.rotation){const A=Ul(...t.rotation.origin);X(f,f,A),Nl(f,f,Wr(t.rotation.angle),Ql[t.rotation.axis]),t.rotation.rescale&&Lt(f,f,tu[t.rotation.axis]),Hl(A,A),X(f,f,A)}return s.transform(f)}getTexture(t){var e,r;for(;t.startsWith("#");)t=(r=(e=this.textures)==null?void 0:e[t.slice(1)])!=null?r:"";return B.parse(t)}withUvEpsilon(t){return this.uvEpsilon=t,this}flatten(t){var r,i,s,a;if(!this.parent)return;if(this.parent.equals(nn.BUILTIN_GENERATED)){this.generationMarker=!0;return}const e=this.getParent(t);if(!e){console.warn(`parent ${this.parent} does not exist!`),this.parent=void 0;return}if(e.flatten(t),this.elements||(this.elements=e.elements),this.textures||(this.textures={}),Object.keys((r=e.textures)!=null?r:{}).forEach(o=>{this.textures[o]||(this.textures[o]=e.textures[o])}),this.display||(this.display={}),Object.keys((i=e.display)!=null?i:{}).forEach(o=>{var c;const m=o;this.display[m]?Object.keys((c=e.display[m])!=null?c:{}).forEach(l=>{const h=l;this.display[m][h]||(this.display[m][h]=e.display[m][h])}):this.display[m]=e.display[m]}),this.guiLight||(this.guiLight=e.guiLight),e.generationMarker&&(this.generationMarker=!0),this.generationMarker&&((a=(s=this.elements)==null?void 0:s.length)!=null?a:0)===0)for(let o=0;o{function t(T){return J=>new ot(void 0,{0:T.withPrefix("entity/chest/").toString()},[{from:[1,0,1],to:[15,10,15],faces:{north:{uv:[10.5,8.25,14,10.75],rotation:180,texture:"#0"},east:{uv:[7,8.25,10.5,10.75],rotation:180,texture:"#0"},south:{uv:[3.5,8.25,7,10.75],rotation:180,texture:"#0"},west:{uv:[0,8.25,3.5,10.75],rotation:180,texture:"#0"},up:{uv:[7,4.75,10.5,8.25],texture:"#0"},down:{uv:[3.5,4.75,7,8.25],texture:"#0"}}},{from:[1,10,1],to:[15,14,15],faces:{north:{uv:[10.5,3.75,14,4.75],rotation:180,texture:"#0"},east:{uv:[7,3.75,10.5,4.75],rotation:180,texture:"#0"},south:{uv:[3.5,3.75,7,4.75],rotation:180,texture:"#0"},west:{uv:[0,3.75,3.5,4.75],rotation:180,texture:"#0"},up:{uv:[7,0,10.5,3.5],texture:"#0"},down:{uv:[3.5,0,7,3.5],texture:"#0"}}},{from:[7,7,0],to:[9,11,2],faces:{north:{uv:[.25,.25,.75,1.25],rotation:180,texture:"#0"},east:{uv:[0,.25,.25,1.25],rotation:180,texture:"#0"},south:{uv:[1,.25,1.5,1.25],rotation:180,texture:"#0"},west:{uv:[.75,.25,1,1.25],rotation:180,texture:"#0"},up:{uv:[.25,0,.75,.25],rotation:180,texture:"#0"},down:{uv:[.75,0,1.25,.25],rotation:180,texture:"#0"}}}]).getMesh(J,u.Cull.none())}n.chestRenderer=t;function e(T){return new ot(void 0,{0:"entity/decorated_pot/decorated_pot_side",1:"entity/decorated_pot/decorated_pot_base"},[{from:[1,0,1],to:[15,16,15],faces:{north:{uv:[1,0,15,16],texture:"#0"},east:{uv:[1,0,15,16],texture:"#0"},south:{uv:[1,0,15,16],texture:"#0"},west:{uv:[1,0,15,16],texture:"#0"},up:{uv:[0,6.5,7,13.5],texture:"#1"},down:{uv:[7,6.5,14,13.5],texture:"#1"}}},{from:[5,16,5],to:[11,17,11],faces:{north:{uv:[0,5.5,3,6],texture:"#1"},east:{uv:[3,5.5,6,6],texture:"#1"},south:{uv:[6,5.5,9,6],texture:"#1"},west:{uv:[9,5.5,12,6],texture:"#1"}}},{from:[4,17,4],to:[12,20,12],faces:{north:{uv:[0,4,4,5.5],texture:"#1"},east:{uv:[4,4,8,5.5],texture:"#1"},south:{uv:[8,4,12,5.5],texture:"#1"},west:{uv:[12,4,16,5.5],texture:"#1"},up:{uv:[4,0,8,4],texture:"#1"},down:{uv:[8,0,12,4],texture:"#1"}}}]).getMesh(T,u.Cull.none())}n.decoratedPotRenderer=e;function r(T){return new ot(void 0,{0:"entity/shield_base_nopattern"},[{from:[-6,-11,-2],to:[6,11,-1],faces:{north:{uv:[3.5,.25,6.5,5.75],texture:"#0"},east:{uv:[3.25,.25,3.5,5.75],texture:"#0"},south:{uv:[.25,.25,3.25,5.75],texture:"#0"},west:{uv:[0,.25,.25,5.75],texture:"#0"},up:{uv:[.25,0,3.25,.25],texture:"#0"},down:{uv:[3.25,0,6.25,.25],texture:"#0"}}}]).getMesh(T,u.Cull.none())}n.shieldRenderer=r;function i(T,J){return G=>new ot(void 0,{0:T.withPrefix("entity/").toString()},[{from:[4,0,4],to:[12,8,12],faces:{north:{uv:[6,2*J,8,4*J],texture:"#0"},east:{uv:[2,2*J,0,4*J],texture:"#0"},south:{uv:[2,2*J,4,4*J],texture:"#0"},west:{uv:[6,2*J,4,4*J],texture:"#0"},up:{uv:[2,0*J,4,2*J],texture:"#0"},down:{uv:[4,0*J,6,2*J],texture:"#0"}}}]).getMesh(G,u.Cull.none())}n.headRenderer=i;function s(T=B.create("enderdragon/dragon")){return J=>{const G=rt();return X(G,G,[8,8,8]),Lt(G,G,[.75,.75,.75]),bt(G,G,Math.PI),X(G,G,[-8,-11.2,-8]),new ot(void 0,{0:T.withPrefix("entity/").toString()},[{from:[2,4,-16],to:[14,9,0],faces:{north:{uv:[12,3.75,12.75,4.0625],texture:"#0"},east:{uv:[11,3.75,12,4.0625],texture:"#0"},south:{uv:[13.75,3.75,14.5,4.0625],texture:"#0"},west:{uv:[12.75,3.75,13.75,4.0625],texture:"#0"},up:{uv:[12.75,3.75,12,2.75],texture:"#0"},down:{uv:[13.5,2.75,12.75,3.75],texture:"#0"}}},{from:[0,0,-2],to:[16,16,14],faces:{north:{uv:[8,2.875,9,3.875],texture:"#0"},east:{uv:[7,2.875,8,3.875],texture:"#0"},south:{uv:[10,2.875,11,3.875],texture:"#0"},west:{uv:[9,2.875,10,3.875],texture:"#0"},up:{uv:[9,2.875,8,1.875],texture:"#0"},down:{uv:[10,1.875,9,2.875],texture:"#0"}}},{from:[2,0,-16],to:[14,4,0],rotation:{angle:-.2*180/Math.PI,axis:"x",origin:[8,4,-2]},faces:{north:{uv:[12,5.0625,12.75,5.3125],texture:"#0"},east:{uv:[11,5.0625,12,5.3125],texture:"#0"},south:{uv:[13.75,5.0625,14.5,5.3125],texture:"#0"},west:{uv:[12.75,5.0625,13.75,5.3125],texture:"#0"},up:{uv:[12.75,5.0625,12,4.0625],texture:"#0"},down:{uv:[13.5,4.0625,12.75,5.0625],texture:"#0"}}},{from:[3,16,4],to:[5,20,10],faces:{north:{uv:[.375,.375,.5,.625],texture:"#0"},east:{uv:[0,.375,.375,.625],texture:"#0"},south:{uv:[.875,.375,1,.625],texture:"#0"},west:{uv:[.5,.375,.875,.625],texture:"#0"},up:{uv:[.5,.375,.375,0],texture:"#0"},down:{uv:[.625,0,.5,.375],texture:"#0"}}},{from:[11,16,4],to:[13,20,10],faces:{north:{uv:[.375,.375,.5,.625],texture:"#0"},east:{uv:[0,.375,.375,.625],texture:"#0"},south:{uv:[.875,.375,1,.625],texture:"#0"},west:{uv:[.5,.375,.875,.625],texture:"#0"},up:{uv:[.5,.375,.375,0],texture:"#0"},down:{uv:[.625,0,.5,.375],texture:"#0"}}},{from:[3,9,-14],to:[5,11,-10],faces:{north:{uv:[7.25,.25,7.375,.375],texture:"#0"},east:{uv:[7,.25,7.25,.375],texture:"#0"},south:{uv:[7.625,.25,7.75,.375],texture:"#0"},west:{uv:[7.375,.25,7.625,.375],texture:"#0"},up:{uv:[7.375,.25,7.25,0],texture:"#0"},down:{uv:[7.5,0,7.375,.25],texture:"#0"}}},{from:[11,9,-14],to:[13,11,-10],faces:{north:{uv:[7.25,.25,7.375,.375],texture:"#0"},east:{uv:[7,.25,7.25,.375],texture:"#0"},south:{uv:[7.625,.25,7.75,.375],texture:"#0"},west:{uv:[7.375,.25,7.625,.375],texture:"#0"},up:{uv:[7.375,.25,7.25,0],texture:"#0"},down:{uv:[7.5,0,7.375,.25],texture:"#0"}}}]).withUvEpsilon(1/256).getMesh(J,u.Cull.none()).transform(G)}}n.dragonHeadRenderer=s;function a(T=B.create("piglin/piglin")){return J=>new ot(void 0,{0:T.withPrefix("entity/").toString()},[{from:[3,0,4],to:[13,8,12],faces:{north:{uv:[6.5,2,9,4],texture:"#0"},east:{uv:[2,2,0,4],texture:"#0"},south:{uv:[2,2,4.5,4],texture:"#0"},west:{uv:[6.5,2,4.5,4],texture:"#0"},up:{uv:[2,0,4.5,2],texture:"#0"},down:{uv:[4.5,0,7,2],texture:"#0"}}},{from:[6,0,12],to:[10,4,13],faces:{north:{uv:[9.25,.5,10.25,1.5],texture:"#0"},east:{uv:[7.75,.5,8,1.5],texture:"#0"},south:{uv:[8,.5,9,1.5],texture:"#0"},west:{uv:[9,.5,9.25,1.5],texture:"#0"},up:{uv:[8,.25,9,.5],texture:"#0"},down:{uv:[9,.25,10,.5],texture:"#0"}}},{from:[5,0,12],to:[6,2,13],faces:{north:{uv:[1.25,.25,1.5,.75],texture:"#0"},east:{uv:[.5,.25,.75,.75],texture:"#0"},south:{uv:[.75,.25,1,.75],texture:"#0"},west:{uv:[1,.25,1.25,.75],texture:"#0"},up:{uv:[.75,0,1,.25],texture:"#0"},down:{uv:[1,0,1.25,.25],texture:"#0"}}},{from:[10,0,12],to:[11,2,13],faces:{north:{uv:[1.25,1.25,1.5,1.75],texture:"#0"},east:{uv:[.5,1.25,.75,1.75],texture:"#0"},south:{uv:[.75,1.25,1,1.75],texture:"#0"},west:{uv:[1,1.25,1.25,1.75],texture:"#0"},up:{uv:[.75,1,1,1.25],texture:"#0"},down:{uv:[1,1,1.25,1.25],texture:"#0"}}},{from:[2.5,1.5,6],to:[3.5,6.5,10],rotation:{angle:-30,axis:"z",origin:[3,7,8]},faces:{north:{uv:[12,2.5,12.25,3.75],texture:"#0"},east:{uv:[9.75,2.5,10.75,3.75],texture:"#0"},south:{uv:[10.75,2.5,11,3.75],texture:"#0"},west:{uv:[11,2.5,12,3.75],texture:"#0"},up:{uv:[10.75,1.5,11,2.5],texture:"#0"},down:{uv:[11,1.5,11.25,2.5],texture:"#0"}}},{from:[12.5,1.5,6],to:[13.5,6.5,10],rotation:{angle:30,axis:"z",origin:[13,7,8]},faces:{north:{uv:[15.25,2.5,15,3.75],texture:"#0"},east:{uv:[15,2.5,14,3.75],texture:"#0"},south:{uv:[14,2.5,13.75,3.75],texture:"#0"},west:{uv:[13.75,2.5,12.75,3.75],texture:"#0"},up:{uv:[14,1.5,13.75,2.5],texture:"#0"},down:{uv:[14.25,1.5,14,2.5],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}n.piglinHeadRenderer=a;function o(T){return J=>new ot(void 0,{0:T.withPrefix("entity/signs/").toString()},[{from:[-4,8,7],to:[20,20,9],faces:{north:{uv:[.5,1,6.5,7],texture:"#0"},east:{uv:[0,1,.5,7],texture:"#0"},south:{uv:[7,1,13,7],texture:"#0"},west:{uv:[6.5,1,7,7],texture:"#0"},up:{uv:[6.5,1,.5,0],texture:"#0"},down:{uv:[12.5,0,6.5,1],texture:"#0"}}},{from:[7,-6,7],to:[9,8,9],faces:{north:{uv:[.5,8,1,15],texture:"#0"},east:{uv:[0,8,.5,15],texture:"#0"},south:{uv:[1.5,8,2,15],texture:"#0"},west:{uv:[1,8,1.5,15],texture:"#0"},up:{uv:[1,8,.5,7],texture:"#0"},down:{uv:[1.5,7,1,8],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}n.signRenderer=o;function m(T){return J=>new ot(void 0,{0:T.withPrefix("entity/signs/").toString()},[{from:[-4,4,17],to:[20,16,19],faces:{north:{uv:[.5,1,6.5,7],texture:"#0"},east:{uv:[0,1,.5,7],texture:"#0"},south:{uv:[7,1,13,7],texture:"#0"},west:{uv:[6.5,1,7,7],texture:"#0"},up:{uv:[6.5,1,.5,0],texture:"#0"},down:{uv:[12.5,0,6.5,1],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}n.wallSignRenderer=m;function c(T){return(J,G)=>J?new ot(void 0,{0:T.withPrefix("entity/signs/hanging/").toString()},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[2,10,8],to:[14,16,8],faces:{north:{uv:[3.5,3,6.5,6],texture:"#0"},south:{uv:[3.5,3,6.5,6],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(G,u.Cull.none()):new ot(void 0,{0:T.withPrefix("entity/signs/hanging/").toString()},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[1.5,10,8],to:[4.5,16,8],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[3,10,6.5],to:[3,16,9.5],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}},{from:[11.5,10,8],to:[14.5,16,8],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[13,10,6.5],to:[13,16,9.5],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(G,u.Cull.none())}n.hangingSignRenderer=c;function l(T){return J=>new ot(void 0,{0:`entity/signs/hanging/${T}`},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[0,14,6],to:[16,16,10],faces:{north:{uv:[1,2,5,3],texture:"#0"},east:{uv:[0,2,1,3],texture:"#0"},south:{uv:[6,2,10,3],texture:"#0"},west:{uv:[5,2,6,3],texture:"#0"},up:{uv:[5,2,1,0],texture:"#0"},down:{uv:[9,0,5,2],texture:"#0"}}},{from:[1.5,10,8],to:[4.5,16,8],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[3,10,6.5],to:[3,16,9.5],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}},{from:[11.5,10,8],to:[14.5,16,8],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[13,10,6.5],to:[13,16,9.5],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}n.wallHangingSignRenderer=l;function h(T){return new ot(void 0,{0:"entity/conduit/base"},[{from:[5,5,5],to:[11,11,11],faces:{north:{uv:[3,6,6,12],texture:"#0"},east:{uv:[0,6,3,12],texture:"#0"},south:{uv:[9,6,12,12],texture:"#0"},west:{uv:[6,6,9,12],texture:"#0"},up:{uv:[6,6,3,0],texture:"#0"},down:{uv:[9,0,6,6],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(T,u.Cull.none())}n.conduitRenderer=h;function d(T){return J=>new ot(void 0,{0:T.withPrefix("entity/shulker/").toString()},[{from:[0,0,0],to:[16,8,16],faces:{north:{uv:[4,11,8,13],texture:"#0"},east:{uv:[0,11,4,13],texture:"#0"},south:{uv:[12,11,16,13],texture:"#0"},west:{uv:[8,11,12,13],texture:"#0"},up:{uv:[8,11,4,7],texture:"#0"},down:{uv:[12,7,8,11],texture:"#0"}}},{from:[0,4,0],to:[16,16,16],faces:{north:{uv:[4,4,8,7],texture:"#0"},east:{uv:[0,4,4,7],texture:"#0"},south:{uv:[12,4,16,7],texture:"#0"},west:{uv:[8,4,12,7],texture:"#0"},up:{uv:[8,4,4,0],texture:"#0"},down:{uv:[12,0,8,4],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}n.shulkerBoxRenderer=d;function f(T){return J=>new ot(void 0,{0:"entity/banner_base"},[{from:[-2,-8,9],to:[18,32,10],faces:{north:{uv:[.25,.25,5.25,10.25],texture:"#0"},east:{uv:[0,.25,.25,10.25],texture:"#0"},south:{uv:[5.5,.25,10.5,10.25],texture:"#0"},west:{uv:[5.25,.25,5.5,10.25],texture:"#0"},up:{uv:[5.25,.25,.25,0],texture:"#0"},down:{uv:[10.25,0,5.25,.25],texture:"#0"}}},{from:[7,-12,7],to:[9,30,9],faces:{north:{uv:[11.5,.5,12,11],texture:"#0"},east:{uv:[11,.5,11.5,11],texture:"#0"},south:{uv:[12.5,.5,13,11],texture:"#0"},west:{uv:[12,.5,12.5,11],texture:"#0"},up:{uv:[12,.5,11.5,0],texture:"#0"},down:{uv:[12.5,0,12,.5],texture:"#0"}}},{from:[-2,30,7],to:[18,32,9],faces:{north:{uv:[.5,11,5.5,11.5],texture:"#0"},east:{uv:[0,11,.5,11.5],texture:"#0"},south:{uv:[6,11,11,11.5],texture:"#0"},west:{uv:[5.5,11,6,11.5],texture:"#0"},up:{uv:[5.5,11,.5,10.5],texture:"#0"},down:{uv:[10.5,10.5,5.5,11],texture:"#0"}}}]).getMesh(J,u.Cull.none())}n.bannerRenderer=f;function w(T){return J=>new ot(void 0,{0:"entity/banner_base"},[{from:[-2,-8,-1.5],to:[18,32,-.5],faces:{north:{uv:[.25,.25,5.25,10.25],texture:"#0"},east:{uv:[0,.25,.25,10.25],texture:"#0"},south:{uv:[5.5,.25,10.5,10.25],texture:"#0"},west:{uv:[5.25,.25,5.5,10.25],texture:"#0"},up:{uv:[5.25,.25,.25,0],texture:"#0"},down:{uv:[10.25,0,5.25,.25],texture:"#0"}}},{from:[-2,30,-3.5],to:[18,32,-1.5],faces:{north:{uv:[.5,11,5.5,11.5],texture:"#0"},east:{uv:[0,11,.5,11.5],texture:"#0"},south:{uv:[6,11,11,11.5],texture:"#0"},west:{uv:[5.5,11,6,11.5],texture:"#0"},up:{uv:[5.5,11,.5,10.5],texture:"#0"},down:{uv:[10.5,10.5,5.5,11],texture:"#0"}}}]).getMesh(J,u.Cull.none())}n.wallBannerRenderer=w;function v(T){return new ot(void 0,{0:"entity/bell/bell_body"},[{from:[5,3,5],to:[11,10,11],faces:{north:{uv:[3,3,6,6.5],texture:"#0"},east:{uv:[0,3,3,6.5],texture:"#0"},south:{uv:[9,3,12,6.5],texture:"#0"},west:{uv:[6,3,9,6.5],texture:"#0"},up:{uv:[6,3,3,0],texture:"#0"},down:{uv:[9,0,6,3],texture:"#0"}}},{from:[4,10,4],to:[12,12,12],faces:{north:{uv:[4,10.5,8,11.5],texture:"#0"},east:{uv:[0,10.5,4,11.5],texture:"#0"},south:{uv:[12,10.5,16,11.5],texture:"#0"},west:{uv:[8,10.5,12,11.5],texture:"#0"},up:{uv:[8,10.5,4,6.5],texture:"#0"},down:{uv:[12,6.5,8,10.5],texture:"#0"}}}]).withUvEpsilon(1/64).getMesh(T,u.Cull.none())}n.bellRenderer=v;function g(T){return(J,G)=>J==="foot"?new ot(void 0,{0:T.withPrefix("entity/bed/").toString()},[{from:[0,3,0],to:[16,9,16],faces:{north:{uv:[5.5,5.5,9.5,7],rotation:180,texture:"#0"},east:{uv:[0,7,1.5,11],rotation:270,texture:"#0"},west:{uv:[5.5,7,7,11],rotation:90,texture:"#0"},up:{uv:[5.5,11,1.5,7],texture:"#0"},down:{uv:[11,7,7,11],texture:"#0"}}},{from:[0,0,0],to:[3,3,3],faces:{north:{uv:[12.5,5.25,13.25,6],texture:"#0"},east:{uv:[14.75,5.25,15.5,6],texture:"#0"},south:{uv:[14,5.25,14.75,6],texture:"#0"},west:{uv:[13.25,5.25,14,6],texture:"#0"},up:{uv:[13.25,4.5,14,5.25],texture:"#0"},down:{uv:[14,4.5,14.75,5.25],texture:"#0"}}},{from:[13,0,0],to:[16,3,3],faces:{north:{uv:[13.25,3.75,14,4.5],texture:"#0"},east:{uv:[12.5,3.75,13.25,4.5],texture:"#0"},south:{uv:[14.75,3.75,15.5,4.5],texture:"#0"},west:{uv:[14,3.75,14.75,4.5],texture:"#0"},up:{uv:[13.25,3,14,3.75],texture:"#0"},down:{uv:[14,3,14.75,3.75],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(G,u.Cull.none()):new ot(void 0,{0:T.withPrefix("entity/bed/").toString()},[{from:[0,3,0],to:[16,9,16],faces:{east:{uv:[0,1.5,1.5,5.5],rotation:270,texture:"#0"},south:{uv:[1.5,0,5.5,1.5],rotation:180,texture:"#0"},west:{uv:[5.5,1.5,7,5.5],rotation:90,texture:"#0"},up:{uv:[5.5,5.5,1.5,1.5],texture:"#0"},down:{uv:[11,1.5,7,5.5],texture:"#0"}}},{from:[0,0,13],to:[3,3,16],faces:{north:{uv:[14.75,.75,15.5,1.5],texture:"#0"},east:{uv:[14,.75,14.75,1.5],texture:"#0"},south:{uv:[13.25,.75,14,1.5],texture:"#0"},west:{uv:[12.5,.75,13.25,1.5],texture:"#0"},up:{uv:[13.25,0,14,.75],texture:"#0"},down:{uv:[14,0,14.75,.75],texture:"#0"}}},{from:[13,0,13],to:[16,3,16],faces:{north:{uv:[14,2.25,14.75,3],texture:"#0"},east:{uv:[13.25,2.25,14,3],texture:"#0"},south:{uv:[12.5,2.25,13.25,3],texture:"#0"},west:{uv:[14.75,2.25,15.5,3],texture:"#0"},up:{uv:[13.25,1.5,14,2.25],texture:"#0"},down:{uv:[14,1.5,14.75,2.25],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(G,u.Cull.none())}n.bedRenderer=g;function p(T,J,G=""){var V;return(V=T.getProperty(J))!=null?V:G}function S(T,J,G="0"){var V;return parseInt((V=T.getProperty(J))!=null?V:G)}const E=new Map(Object.entries({"minecraft:chest":n.chestRenderer(B.create("normal")),"minecraft:ender_chest":n.chestRenderer(B.create("ender")),"minecraft:trapped_chest":n.chestRenderer(B.create("trapped"))})),y=new Map(Object.entries({"minecraft:skeleton_skull":n.headRenderer(B.create("skeleton/skeleton"),2),"minecraft:wither_skeleton_skull":n.headRenderer(B.create("skeleton/wither_skeleton"),2),"minecraft:zombie_head":n.headRenderer(B.create("zombie/zombie"),1),"minecraft:creeper_head":n.headRenderer(B.create("creeper/creeper"),2),"minecraft:dragon_head":n.dragonHeadRenderer(),"minecraft:piglin_head":n.piglinHeadRenderer(),"minecraft:player_head":n.headRenderer(B.create("player/wide/steve"),1)})),R=["oak","spruce","birch","jungle","acacia","dark_oak","mangrove","cherry","bamboo","crimson","warped"],k=new Map(R.map(T=>[`minecraft:${T}_sign`,n.signRenderer(B.create(T))])),I=new Map(R.map(T=>[`minecraft:${T}_wall_sign`,n.wallSignRenderer(B.create(T))])),x=new Map(R.map(T=>[`minecraft:${T}_hanging_sign`,n.hangingSignRenderer(B.create(T))])),N=new Map(R.map(T=>[`minecraft:${T}_wall_hanging_sign`,n.wallHangingSignRenderer(T)])),A=["white","orange","magenta","light_blue","yellow","lime","pink","gray","light_gray","cyan","purple","blue","brown","green","red","black"],C=new Map(A.map(T=>[`minecraft:${T}_shulker_box`,n.shulkerBoxRenderer(B.create(`shulker_${T}`))])),L=new Map(A.map(T=>[`minecraft:${T}_bed`,n.bedRenderer(B.create(T))])),F=new Map(A.map(T=>[`minecraft:${T}_banner`,n.bannerRenderer(T)])),U=new Map(A.map(T=>[`minecraft:${T}_wall_banner`,n.wallBannerRenderer(T)]));function Y(T,J,G){const V=new it;T.is("water")&&V.merge(ni("water",S(T,"level"),J,G,0)),T.is("lava")&&V.merge(ni("lava",S(T,"level"),J,G));const M=E.get(T.getName().toString());if(M!==void 0){const H=p(T,"facing","south"),O=rt();X(O,O,[8,8,8]),bt(O,O,H==="west"?Math.PI/2:H==="south"?Math.PI:H==="east"?Math.PI*3/2:0),X(O,O,[-8,-8,-8]),V.merge(M(J).transform(O))}T.is("decorated_pot")&&V.merge(e(J));const b=y.get(T.getName().toString());if(b!==void 0){const H=S(T,"rotation")/16*Math.PI*2,O=rt();X(O,O,[8,8,8]),bt(O,O,H),X(O,O,[-8,-8,-8]),V.merge(b(J).transform(O))}const P=k.get(T.getName().toString());if(P!==void 0){const H=S(T,"rotation")/16*Math.PI*2,O=rt();X(O,O,[8,8,8]),bt(O,O,H),Lt(O,O,[2/3,2/3,2/3]),X(O,O,[-8,-8,-8]),V.merge(P(J).transform(O))}const z=I.get(T.getName().toString());if(z!==void 0){const H=p(T,"facing","south"),O=rt();X(O,O,[8,8,8]),bt(O,O,H==="west"?Math.PI/2:H==="south"?Math.PI:H==="east"?Math.PI*3/2:0),Lt(O,O,[2/3,2/3,2/3]),X(O,O,[-8,-8,-8]),V.merge(z(J).transform(O))}const Z=x.get(T.getName().toString());if(Z!==void 0){const H=p(T,"attached","false")==="true",O=S(T,"rotation")/16*Math.PI*2,ct=rt();X(ct,ct,[8,8,8]),bt(ct,ct,O),Lt(ct,ct,[2/3,2/3,2/3]),X(ct,ct,[-8,-8,-8]),V.merge(Z(H,J).transform(ct))}const Q=N.get(T.getName().toString());if(Q!==void 0){const H=p(T,"facing","south"),O=rt();X(O,O,[8,8,8]),bt(O,O,H==="west"?Math.PI/2:H==="south"?Math.PI:H==="east"?Math.PI*3/2:0),X(O,O,[-8,-8,-8]),V.merge(Q(J).transform(O))}T.is("conduit")&&V.merge(h(J));const kt=C.get(T.getName().toString());if(kt!==void 0){const H=p(T,"facing","up"),O=rt();X(O,O,[8,8,8]),H==="down"?xn(O,O,Math.PI):H!=="up"&&(bt(O,O,H==="east"?Math.PI/2:H==="north"?Math.PI:H==="west"?Math.PI*3/2:0),xn(O,O,Math.PI/2)),X(O,O,[-8,-8,-8]),V.merge(kt(J).transform(O))}if(T.is("bell")){const H=rt();X(H,H,[8,8,8]),Lt(H,H,[1,-1,-1]),X(H,H,[-8,-8,-8]),V.merge(v(J).transform(H))}const At=L.get(T.getName().toString());if(At!==void 0){const H=p(T,"part","head"),O=p(T,"facing","south"),ct=rt();X(ct,ct,[8,8,8]),bt(ct,ct,O==="east"?Math.PI/2:O==="north"?Math.PI:O==="west"?Math.PI*3/2:0),X(ct,ct,[-8,-8,-8]),V.merge(At(H,J).transform(ct))}const St=F.get(T.getName().toString());if(St!==void 0){const H=S(T,"rotation")/16*Math.PI*2,O=rt();X(O,O,[8,24,8]),bt(O,O,H),Lt(O,O,[2/3,2/3,2/3]),X(O,O,[-8,-24,-8]),V.merge(St(J).transform(O))}const ut=U.get(T.getName().toString());if(ut!==void 0){const H=p(T,"facing","south"),O=rt();X(O,O,[8,8,8]),bt(O,O,H==="east"?Math.PI/2:H==="north"?Math.PI:H==="west"?Math.PI*3/2:0),Lt(O,O,[2/3,2/3,2/3]),X(O,O,[-8,-23.2,-8]),V.merge(ut(J).transform(O))}!T.is("water")&&!T.is("lava")&&T.isWaterlogged()&&V.merge(ni("water",0,J,G,0));const lt=rt();return Lt(lt,lt,[.0625,.0625,.0625]),V.transform(lt)}n.getBlockMesh=Y})(u.SpecialRenderers||(u.SpecialRenderers={}));class Ws{constructor(t,e,r,i=16){_(this,"chunks",[]);_(this,"chunkSize");this.gl=t,this.structure=e,this.resources=r,this.chunkSize=typeof i=="number"?[i,i,i]:i,this.updateStructureBuffers()}setStructure(t){this.structure=t,this.updateStructureBuffers()}updateStructureBuffers(t){var e,r;if(!!this.structure){t?t.forEach(i=>{const s=this.getChunk(i);s.mesh.clear(),s.transparentMesh.clear()}):this.chunks.forEach(i=>i.forEach(s=>s.forEach(a=>{a.mesh.clear(),a.transparentMesh.clear()})));for(const i of this.structure.getBlocks()){const s=i.state.getName(),a=i.state.getProperties(),o=(e=this.resources.getDefaultBlockProperties(s))!=null?e:{};Object.entries(o).forEach(([l,h])=>{a[l]||(a[l]=h)});const m=[Math.floor(i.pos[0]/this.chunkSize[0]),Math.floor(i.pos[1]/this.chunkSize[1]),Math.floor(i.pos[2]/this.chunkSize[2])];if(t&&!t.some(l=>Gl(l,m)))continue;const c=this.getChunk(m);try{const l=this.resources.getBlockDefinition(s),h={up:this.needsCull(i,u.Direction.UP),down:this.needsCull(i,u.Direction.DOWN),west:this.needsCull(i,u.Direction.WEST),east:this.needsCull(i,u.Direction.EAST),north:this.needsCull(i,u.Direction.NORTH),south:this.needsCull(i,u.Direction.SOUTH)},d=new it;l&&d.merge(l.getMesh(s,a,this.resources,this.resources,h));const f=u.SpecialRenderers.getBlockMesh(i.state,this.resources,h);f.isEmpty()||d.merge(f),d.isEmpty()||(this.finishChunkMesh(d,i.pos),(r=this.resources.getBlockFlags(i.state.getName()))!=null&&r.semi_transparent?c.transparentMesh.merge(d):c.mesh.merge(d))}catch(l){console.error(`Error rendering block ${s}`,l)}}t?t.forEach(i=>{const s=this.getChunk(i);s.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0,blockPos:!0}),s.transparentMesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0,blockPos:!0})}):this.chunks.forEach(i=>i.forEach(s=>s.forEach(a=>{a.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0,blockPos:!0}),a.transparentMesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0,blockPos:!0})})))}}getMeshes(){const t=this.chunks.flatMap(e=>e.flatMap(r=>r.flatMap(i=>i!=null?i:[])));return t.flatMap(e=>e.mesh.isEmpty()?[]:e.mesh).concat(t.flatMap(e=>e.transparentMesh.isEmpty()?[]:e.transparentMesh))}needsCull(t,e){var s;const r=(s=this.structure.getBlock(u.BlockPos.towards(t.pos,e)))==null?void 0:s.state;if(!r)return!1;const i=this.resources.getBlockFlags(r.getName());return t.state.getName().equals(r.getName())&&(i==null?void 0:i.self_culling)?!0:i!=null&&i.opaque?!(e===u.Direction.UP&&t.state.isWaterlogged()):t.state.isWaterlogged()&&r.isWaterlogged()}finishChunkMesh(t,e){const r=rt();X(r,r,e),t.transform(r);for(const i of t.quads){const s=i.normal();i.forEach(a=>a.normal=s),i.forEach(a=>a.blockPos=new q(e[0],e[1],e[2]))}}getChunk(t){const e=Math.abs(t[0])*2+(t[0]<0?1:0),r=Math.abs(t[1])*2+(t[1]<0?1:0),i=Math.abs(t[2])*2+(t[2]<0?1:0);return this.chunks[e]||(this.chunks[e]=[]),this.chunks[e][r]||(this.chunks[e][r]=[]),this.chunks[e][r][i]||(this.chunks[e][r][i]={mesh:new it,transparentMesh:new it}),this.chunks[e][r][i]}}class Nn{constructor(t,e,r){_(this,"gl");_(this,"program");this.gl=t,this.program=this.initShaderProgram(e,r)}getProgram(){return this.program}initShaderProgram(t,e){const r=this.loadShader(this.gl.VERTEX_SHADER,t),i=this.loadShader(this.gl.FRAGMENT_SHADER,e),s=this.gl.createProgram();if(this.gl.attachShader(s,r),this.gl.attachShader(s,i),this.gl.linkProgram(s),!this.gl.getProgramParameter(s,this.gl.LINK_STATUS))throw new Error(`Unable to link shader program: ${this.gl.getProgramInfoLog(s)}`);return s}loadShader(t,e){const r=this.gl.createShader(t);if(this.gl.shaderSource(r,e),this.gl.compileShader(r),!this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS)){const i=new Error(`Compiling ${t===this.gl.VERTEX_SHADER?"vertex":"fragment"} shader: ${this.gl.getShaderInfoLog(r)}`);throw this.gl.deleteShader(r),i}return r}}const eu=` attribute vec4 vertPos; attribute vec2 texCoord; attribute vec3 vertColor; attribute vec3 normal; uniform mat4 mView; uniform mat4 mProj; varying highp vec2 vTexCoord; varying highp vec3 vTintColor; varying highp float vLighting; void main(void) { gl_Position = mProj * mView * vertPos; vTexCoord = texCoord; vTintColor = vertColor; vLighting = normal.y * 0.2 + abs(normal.z) * 0.1 + 0.8; } `,nu=` precision highp float; varying highp vec2 vTexCoord; varying highp vec3 vTintColor; varying highp float vLighting; uniform sampler2D sampler; void main(void) { vec4 texColor = texture2D(sampler, vTexCoord); if(texColor.a < 0.01) discard; gl_FragColor = vec4(texColor.xyz * vTintColor * vLighting, texColor.a); } `;class lr{constructor(t){_(this,"shaderProgram");_(this,"projMatrix");_(this,"activeShader");this.gl=t,this.shaderProgram=new Nn(t,eu,nu).getProgram(),this.activeShader=this.shaderProgram,this.projMatrix=this.getPerspective(),this.initialize()}setViewport(t,e,r,i){this.gl.viewport(t,e,r,i),this.projMatrix=this.getPerspective()}getPerspective(){const t=70*Math.PI/180,e=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,r=rt();return Tl(r,t,e,.1,500),r}initialize(){this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LEQUAL),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enable(this.gl.CULL_FACE),this.gl.cullFace(this.gl.BACK)}setShader(t){this.gl.useProgram(t),this.activeShader=t}setVertexAttr(t,e,r){if(r===void 0)throw new Error(`Expected buffer for ${t}`);const i=this.gl.getAttribLocation(this.activeShader,t);this.gl.bindBuffer(this.gl.ARRAY_BUFFER,r),this.gl.vertexAttribPointer(i,e,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(i)}setUniform(t,e){const r=this.gl.getUniformLocation(this.activeShader,t);this.gl.uniformMatrix4fv(r,!1,e)}setTexture(t){this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t)}createAtlasTexture(t){const e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),e}prepareDraw(t){this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix)}drawMesh(t,e){if(t.quadVertices()>0){if(e.pos&&this.setVertexAttr("vertPos",3,t.posBuffer),e.color&&this.setVertexAttr("vertColor",3,t.colorBuffer),e.texture&&this.setVertexAttr("texCoord",2,t.textureBuffer),e.normal&&this.setVertexAttr("normal",3,t.normalBuffer),e.blockPos&&this.setVertexAttr("blockPos",3,t.blockPosBuffer),!t.indexBuffer)throw new Error("Expected index buffer");this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t.indexBuffer),this.gl.drawElements(this.gl.TRIANGLES,t.quadIndices(),this.gl.UNSIGNED_SHORT,0)}t.lineVertices()>0&&(e.pos&&this.setVertexAttr("vertPos",3,t.linePosBuffer),e.color&&this.setVertexAttr("vertColor",3,t.lineColorBuffer),this.gl.drawArrays(this.gl.LINES,0,t.lineVertices()))}}class ur extends lr{constructor(e,r,i,s={}){super(e);_(this,"mesh");_(this,"atlasTexture");this.item=r,this.resources=i,this.updateMesh(s),this.atlasTexture=this.createAtlasTexture(this.resources.getTextureAtlas())}setItem(e,r={}){this.item=e,this.updateMesh(r)}updateMesh(e={}){this.mesh=ur.getItemMesh(this.item,this.resources,e),this.mesh.computeNormals(),this.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0})}static getItemMesh(e,r,i){var m;const s=(m=e.getComponent("item_model",r))==null?void 0:m.getAsString();if(s===void 0)return new it;const a=r.getItemModel(B.parse(s));if(!a)throw new Error(`Item model ${s} does not exist (defined by item ${e.toString()})`);return a.getMesh(e,r,i)}getPerspective(){const e=rt();return Ll(e,0,16,0,16,.1,500),e}drawItem(){const e=rt();X(e,e,[0,0,-32]),this.setShader(this.shaderProgram),this.setTexture(this.atlasTexture),this.prepareDraw(e),this.drawMesh(this.mesh,{pos:!0,color:!0,texture:!0,normal:!0})}}const Je=[0,0,0];u.ItemTint=void 0,(n=>{function t(l){var f,w,v,g,p,S,E,y,R,k,I,x;const h=(f=u.Json.readObject(l))!=null?f:{},d=(w=u.Json.readString(h.type))==null?void 0:w.replace(/^minecraft:/,"");switch(d){case"constant":return new e((v=u.Color.fromJson(h.value))!=null?v:Je);case"dye":return new r((g=u.Color.fromJson(h.default))!=null?g:Je);case"grass":return new i((p=u.Json.readNumber(h.temperature))!=null?p:0,(S=u.Json.readNumber(h.downfall))!=null?S:0);case"firework":return new s((E=u.Color.fromJson(h.default))!=null?E:Je);case"potion":return new a((y=u.Color.fromJson(h.default))!=null?y:Je);case"map_color":return new o((R=u.Color.fromJson(h.default))!=null?R:Je);case"custom_model_data":return new m((k=u.Json.readInt(h.index))!=null?k:0,(I=u.Color.fromJson(h.default))!=null?I:Je);case"team":return new c((x=u.Color.fromJson(h.default))!=null?x:Je);default:throw new Error(`Invalid item tint type ${d}`)}}n.fromJson=t;class e{constructor(h){this.value=h}getTint(h){return this.value}}n.Constant=e;class r{constructor(h){this.default_color=h}getTint(h,d){const f=h.getComponent("dyed_color",d);return f?f.isCompound()?u.Color.intToRgb(f.getNumber("rgb")):u.Color.intToRgb(f.getAsNumber()):this.default_color}}n.Dye=r;class i{constructor(h,d){this.temperature=h,this.downfall=d}getTint(h){return[124/255,189/255,107/255]}}n.Grass=i;class s{constructor(h){this.default_color=h}getTint(h,d){const f=h.getComponent("firework_explosion",d);if(!(f!=null&&f.isCompound()))return this.default_color;const w=f.get("colors");return!w||!w.isListOrArray()?this.default_color:(()=>{if(w.length===1)return u.Color.intToRgb(w.get(0).getAsNumber());let[g,p,S]=[0,0,0];for(const E of w.getItems())g+=(E.getAsNumber()&16711680)>>16,p+=(E.getAsNumber()&65280)>>8,S+=(E.getAsNumber()&255)>>0;return g/=w.length,p/=w.length,S/=w.length,[g/255,p/255,S/255]})()}}n.Firework=s;class a{constructor(h){this.default_color=h}getTint(h,d){const f=h.getComponent("potion_contents",d);if(!f)return this.default_color;const w=u.PotionContents.fromNbt(f);return u.PotionContents.getColor(w)}}n.Potion=a;class o{constructor(h){this.default_color=h}getTint(h,d){const f=h.getComponent("map_color",d);return f?u.Color.intToRgb(f.getAsNumber()):this.default_color}}n.MapColor=o;class m{constructor(h,d){this.index=h,this.default_color=d}getTint(h,d){var v;const f=h.getComponent("custom_model_data",d);if(!(f!=null&&f.isCompound()))return this.default_color;const w=f.getList("colors").get(this.index);return w?(v=u.Color.fromNbt(w))!=null?v:this.default_color:this.default_color}}n.CustomModelData=m;class c{constructor(h){this.default_color=h}getTint(h,d,f){var w;return(w=f.context_entity_team_color)!=null?w:this.default_color}}n.Team=c})(u.ItemTint||(u.ItemTint={}));var ri;(n=>{function t(f){var g,p,S,E,y,R,k,I,x,N,A,C,L;const w=(g=u.Json.readObject(f))!=null?g:{},v=(p=u.Json.readString(w.type))==null?void 0:p.replace(/^minecraft:/,"");switch(v){case"bed":return new e(B.parse((S=u.Json.readString(w.texture))!=null?S:""));case"banner":return new r((E=u.Json.readString(w.color))!=null?E:"");case"conduit":return new i;case"chest":return new s(B.parse((y=u.Json.readString(w.texture))!=null?y:""),(R=u.Json.readNumber(w.openness))!=null?R:0);case"head":return new a((k=u.Json.readString(w.kind))!=null?k:"",typeof w.texture=="string"?B.parse(w.texture):void 0,(I=u.Json.readNumber(w.animation))!=null?I:0);case"shulker_box":return new o(B.parse((x=u.Json.readString(w.texture))!=null?x:""),(N=u.Json.readNumber(w.openness))!=null?N:0,(A=u.Json.readString(w.orientation))!=null?A:"up");case"shield":return new m;case"trident":return new c;case"decorated_pot":return new l;case"standing_sign":return new h((C=u.Json.readString(w.wood_type))!=null?C:"",typeof w.texture=="string"?B.parse(w.texture):void 0);case"hanging_sign":return new d((L=u.Json.readString(w.wood_type))!=null?L:"",typeof w.texture=="string"?B.parse(w.texture):void 0);default:throw new Error(`Invalid item model type ${v}`)}}n.fromJson=t;class e{constructor(w){_(this,"renderer");this.renderer=u.SpecialRenderers.bedRenderer(w)}getMesh(w,v){const g=this.renderer("head",v),p=this.renderer("foot",v),S=rt();return X(S,S,[0,0,-16]),g.merge(p.transform(S))}}class r{constructor(w){_(this,"renderer");this.renderer=u.SpecialRenderers.bannerRenderer(w)}getMesh(w,v){return this.renderer(v)}}class i{getMesh(w,v){return u.SpecialRenderers.conduitRenderer(v)}}class s{constructor(w,v){_(this,"renderer");this.renderer=u.SpecialRenderers.chestRenderer(w)}getMesh(w,v){const g=rt();return X(g,g,[8,8,8]),bt(g,g,Math.PI),X(g,g,[-8,-8,-8]),this.renderer(v).transform(g)}}class a{constructor(w,v,g){_(this,"renderer");var p;this.renderer=((p={skeleton:()=>u.SpecialRenderers.headRenderer(v!=null?v:B.create("skeleton/skeleton"),2),wither_skeleton:()=>u.SpecialRenderers.headRenderer(v!=null?v:B.create("skeleton/wither_skeleton"),2),zombie:()=>u.SpecialRenderers.headRenderer(v!=null?v:B.create("zombie/zombie"),1),creeper:()=>u.SpecialRenderers.headRenderer(v!=null?v:B.create("creeper/creeper"),2),dragon:()=>u.SpecialRenderers.dragonHeadRenderer(v),piglin:()=>u.SpecialRenderers.piglinHeadRenderer(v),player:()=>u.SpecialRenderers.headRenderer(v!=null?v:B.create("player/wide/steve"),1)}[w])!=null?p:()=>()=>new it)()}getMesh(w,v){return this.renderer(v)}}class o{constructor(w,v,g){_(this,"renderer");this.renderer=u.SpecialRenderers.shulkerBoxRenderer(w)}getMesh(w,v){return this.renderer(v)}}class m{getMesh(w,v){const g=u.SpecialRenderers.shieldRenderer(v),p=rt();return X(p,p,[-3,1,0]),xn(p,p,-10*Math.PI/180),bt(p,p,-10*Math.PI/180),Fs(p,p,-5*Math.PI/180),g.transform(p)}}class c{getMesh(w,v){return new it}}class l{getMesh(w,v){return u.SpecialRenderers.decoratedPotRenderer(v)}}class h{constructor(w,v){_(this,"renderer");this.renderer=u.SpecialRenderers.signRenderer(v!=null?v:B.create(w))}getMesh(w,v){return this.renderer(v)}}class d{constructor(w,v){_(this,"renderer");this.renderer=u.SpecialRenderers.hangingSignRenderer(v!=null?v:B.create(w))}getMesh(w,v){return this.renderer(!1,v)}}})(ri||(ri={}));const Xs=new it;u.ItemModel=void 0,(n=>{function t(l){var f,w,v,g,p,S,E,y,R;const h=(f=u.Json.readObject(l))!=null?f:{},d=(w=u.Json.readString(h.type))==null?void 0:w.replace(/^minecraft:/,"");switch(d){case"empty":return new e;case"model":return new r(B.parse((v=u.Json.readString(h.model))!=null?v:""),(g=u.Json.readArray(h.tints,u.ItemTint.fromJson))!=null?g:[]);case"composite":return new i((p=u.Json.readArray(h.models,n.fromJson))!=null?p:[]);case"condition":return new s(s.propertyFromJson(h),n.fromJson(h.on_true),n.fromJson(h.on_false));case"select":return new a(a.propertyFromJson(h),new Map((S=u.Json.readArray(h.cases,k=>{var I;return(I=u.Json.readObject(k))!=null?I:{}}))==null?void 0:S.flatMap(k=>{var x;const I=n.fromJson(k.model);return Array.isArray(k.when)?k.when.map(N=>{var A;return[(A=u.Json.readString(N))!=null?A:"",I]}):[[(x=u.Json.readString(k.when))!=null?x:"",I]]})),h.fallback?n.fromJson(h.fallback):void 0);case"range_dispatch":return new o(o.propertyFromJson(h),(E=u.Json.readNumber(h.scale))!=null?E:1,(y=u.Json.readArray(h.entries,k=>{var x,N;const I=(x=u.Json.readObject(k))!=null?x:{};return{threshold:(N=u.Json.readNumber(I.threshold))!=null?N:0,model:n.fromJson(I.model)}}))!=null?y:[],h.fallback?n.fromJson(h.fallback):void 0);case"special":return new m(ri.fromJson(h.model),B.parse((R=u.Json.readString(h.base))!=null?R:""));case"bundle/selected_item":return new c;default:throw new Error(`Invalid item model type ${d}`)}}n.fromJson=t;class e{getMesh(h,d,f){return new it}}n.Empty=e;class r{constructor(h,d){this.modelId=h,this.tints=d}getMesh(h,d,f){var p;const w=d.getBlockModel(this.modelId);if(!w)throw new Error(`Model ${this.modelId} does not exist (trying to render ${h.toString()})`);const v=S=>Sw.merge(v.getMesh(h,d,f))),w}}n.Composite=i;class s{constructor(h,d,f){this.property=h,this.onTrue=d,this.onFalse=f}getMesh(h,d,f){return(this.property(h,d,f)?this.onTrue:this.onFalse).getMesh(h,d,f)}static propertyFromJson(h){var f,w,v,g,p;const d=(f=u.Json.readString(h.property))==null?void 0:f.replace(/^minecraft:/,"");switch(d){case"fishing_rod/cast":case"selected":case"carried":case"extended_view":return(k,I,x)=>{var N;return(N=x[d])!=null?N:!1};case"view_entity":return(k,I,x)=>{var N;return(N=x.context_entity_is_view_entity)!=null?N:!1};case"using_item":return(k,I,x)=>{var N;return((N=x.use_duration)!=null?N:-1)>=0};case"bundle/has_selected_item":return(k,I,x)=>{var N;return((N=x["bundle/selected_item"])!=null?N:-1)>=0};case"broken":return(k,I,x)=>{var C,L;const N=(C=k.getComponent("damage",I))==null?void 0:C.getAsNumber(),A=(L=k.getComponent("max_damage",I))==null?void 0:L.getAsNumber();return N!==void 0&&A!==void 0&&N>=A-1};case"damaged":return(k,I,x)=>{var C,L;const N=(C=k.getComponent("damage",I))==null?void 0:C.getAsNumber(),A=(L=k.getComponent("max_damage",I))==null?void 0:L.getAsNumber();return N!==void 0&&A!==void 0&&N>=1};case"has_component":const S=B.parse((w=u.Json.readString(h.component))!=null?w:""),E=(v=u.Json.readBoolean(h.ignore_default))!=null?v:!1;return(k,I,x)=>k.hasComponent(S,E?void 0:I);case"keybind_down":const y=(g=u.Json.readString(h.keybind))!=null?g:"";return(k,I,x)=>{var N,A;return(A=(N=x.keybind_down)==null?void 0:N.includes(y))!=null?A:!1};case"custom_model_data":const R=(p=u.Json.readInt(h.index))!=null?p:0;return(k,I,x)=>{const N=k.getComponent("custom_model_data",I);if(!(N!=null&&N.isCompound()))return!1;const A=N.getList("flags").getNumber(R);return A!==void 0&&A!==0};default:throw new Error(`Invalid condition property ${d}`)}}}n.Condition=s;class a{constructor(h,d,f){this.property=h,this.cases=d,this.fallback=f}getMesh(h,d,f){var v,g,p;const w=this.property(h,d,f);return(p=(g=(v=w!==null?this.cases.get(w):void 0)!=null?v:this.fallback)==null?void 0:g.getMesh(h,d,f))!=null?p:Xs}static propertyFromJson(h){var f,w,v;const d=(f=u.Json.readString(h.property))==null?void 0:f.replace(/^minecraft:/,"");switch(d){case"main_hand":return(E,y,R)=>{var k;return(k=R.main_hand)!=null?k:"right"};case"display_context":return(E,y,R)=>{var k;return(k=R.display_context)!=null?k:"gui"};case"context_dimension":return(E,y,R)=>{var k,I;return(I=(k=R.context_dimension)==null?void 0:k.toString())!=null?I:null};case"charge_type":const g=B.create("firework_rocket");return(E,y,R)=>{const k=E.getComponent("charged_projectiles",y);return!(k!=null&&k.isList())||k.length===0?"none":k.filter(I=>I.isCompound()?B.parse(I.getString("id")).equals(g):!1).length>0?"rocket":"arrow"};case"trim_material":return(E,y,R)=>{const k=E.getComponent("trim",y);return k!=null&&k.isCompound()?B.parse(k.getString("material")).toString():null};case"block_state":const p=(w=u.Json.readString(h.block_state_property))!=null?w:"";return(E,y,R)=>{const k=E.getComponent("block_state",y);return k!=null&&k.isCompound()?k.getString(p):null};case"local_time":return(E,y,R)=>"NOT IMPLEMENTED";case"context_entity_type":return(E,y,R)=>{var k,I;return(I=(k=R.context_entity_type)==null?void 0:k.toString())!=null?I:null};case"custom_model_data":const S=(v=u.Json.readInt(h.index))!=null?v:0;return(E,y,R)=>{const k=E.getComponent("custom_model_data",y);if(!(k!=null&&k.isCompound()))return null;const I=k.getList("strings");return I.length<=S?null:I.getString(S)};default:throw new Error(`Invalid select property ${d}`)}}}n.Select=a;class o{constructor(h,d,f,w){_(this,"entries");this.property=h,this.scale=d,this.fallback=w,this.entries=f.sort((v,g)=>v.threshold-g.threshold)}getMesh(h,d,f){var g;const w=this.property(h,d,f)*this.scale;let v=this.fallback;for(const p of this.entries)if(p.threshold<=w)v=p.model;else break;return(g=v==null?void 0:v.getMesh(h,d,f))!=null?g:Xs}static propertyFromJson(h){var f,w,v,g,p,S,E;const d=(f=u.Json.readString(h.property))==null?void 0:f.replace(/^minecraft:/,"");switch(d){case"bundle/fullness":let y=function(N,A){const C=N.getComponent("bundle_contents",A);return C!=null&&C.isListOrArray()?C.map(F=>F.isCompound()?$t.fromNbt(F):void 0).reduce((F,U)=>{var J,G;if(U===void 0)return F;if(U.hasComponent("bundle_contents",A))return F+y(U,A)+.0625;const Y=U.getComponent("bees",A);if((Y==null?void 0:Y.isListOrArray())&&Y.length>0)return F+1;const T=(G=(J=U.getComponent("max_stack_size",A))==null?void 0:J.getAsNumber())!=null?G:1;return F+U.count/T},0):0};return(N,A,C)=>y(N,A);case"damage":{const N=(w=u.Json.readBoolean(h.normalize))!=null?w:!0;return(A,C,L)=>{var Y,T,J,G;const F=(T=(Y=A.getComponent("max_damage",C))==null?void 0:Y.getAsNumber())!=null?T:0,U=_t((G=(J=A.getComponent("damage",C))==null?void 0:J.getAsNumber())!=null?G:0,0,F);return N?_t(U/F,0,1):_t(U,0,F)}}case"count":{const N=(v=u.Json.readBoolean(h.normalize))!=null?v:!0;return(A,C,L)=>{var U,Y;const F=(Y=(U=A.getComponent("max_stack_size",C))==null?void 0:U.getAsNumber())!=null?Y:1;return N?_t(A.count/F,0,1):_t(A.count,0,F)}}case"cooldown":return(N,A,C)=>{var U,Y,T;const L=N.getComponent("use_cooldown",A),F=L!=null&&L.isCompound()?B.parse((U=L.getString("cooldown_group"))!=null?U:N.id):N.id;return(T=(Y=C.cooldown_percentage)==null?void 0:Y[F.toString()])!=null?T:0};case"time":switch((g=u.Json.readString(h.source))!=null?g:"daytime"){case"moon_phase":return(N,A,C)=>{var L;return((L=C.game_time)!=null?L:0)/24e3%8/8};case"random":return(N,A,C)=>Math.random();default:return(N,A,C)=>{var Y;const F=((Y=C.game_time)!=null?Y:0)/24e3%1-.25,U=.5-Math.cos(F*Math.PI)/2;return(F*2+U)/3}}case"compass":return(N,A,C)=>{var L;return(L=C.compass_angle)!=null?L:0};case"crossbow/pull":return(N,A,C)=>{var L;return(L=C["crossbow/pull"])!=null?L:0};case"use_duration":const k=(p=u.Json.readBoolean(h.remaining))!=null?p:!0;return(N,A,C)=>{var L;return C.use_duration===void 0||C.use_duration<0?0:k?Math.max(((L=C.max_use_duration)!=null?L:0)-C.use_duration,0):C.use_duration};case"use_cycle":const I=(S=u.Json.readNumber(h.period))!=null?S:1;return(N,A,C)=>{var L,F;return C.use_duration===void 0||C.use_duration<0?0:Math.max(((L=C.max_use_duration)!=null?L:0)-((F=C.use_duration)!=null?F:0),0)%I};case"custom_model_data":const x=(E=u.Json.readInt(h.index))!=null?E:0;return(N,A,C)=>{const L=N.getComponent("custom_model_data",A);return L!=null&&L.isCompound()?L.getList("floats").getNumber(x):0};default:throw new Error(`Invalid select property ${d}`)}}}n.RangeDispatch=o;class m{constructor(h,d){this.specialModel=h,this.base=d}getMesh(h,d,f){var g;const w=this.specialModel.getMesh(h,d),v=d.getBlockModel(this.base);if(!v)throw new Error(`Base model ${this.base} does not exist (trying to render ${h.toString()})`);return w.transform(v.getDisplayTransform((g=f.display_context)!=null?g:"gui")),w}}n.Special=m;class c{getMesh(h,d,f){const w=f["bundle/selected_item"];if(w===void 0||w<0)return new it;const v=h.getComponent("bundle_contents",d);if(!(v!=null&&v.isListOrArray()))return new it;const g=v.get(w);if(g===void 0||!g.isCompound())return new it;const p=$t.fromNbt(g);return ur.getItemMesh(p,d,{...f,"bundle/selected_item":-1,selected:!1,carried:!1,use_duration:-1})}}n.BundleSelectedItem=c})(u.ItemModel||(u.ItemModel={}));const ru=` attribute vec4 vertPos; attribute vec3 blockPos; uniform mat4 mView; uniform mat4 mProj; varying highp vec3 vColor; void main(void) { gl_Position = mProj * mView * vertPos; vColor = blockPos / 256.0; } `,iu=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `,su=` attribute vec4 vertPos; attribute vec3 vertColor; uniform mat4 mView; uniform mat4 mProj; varying highp vec3 vColor; void main(void) { gl_Position = mProj * mView * vertPos; vColor = vertColor; } `,au=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `;class ou extends lr{constructor(e,r,i,s){var o,m;super(e);_(this,"gridShaderProgram");_(this,"colorShaderProgram");_(this,"gridMesh",new it);_(this,"outlineMesh",new it);_(this,"invisibleBlocksMesh",new it);_(this,"atlasTexture");_(this,"useInvisibleBlocks");_(this,"chunkBuilder");this.structure=r,this.resources=i;const a=(o=s==null?void 0:s.chunkSize)!=null?o:16;this.chunkBuilder=new Ws(e,r,i,a),s!=null&&s.facesPerBuffer&&console.warn("[deepslate renderer warning]: facesPerBuffer option has been removed in favor of chunkSize"),this.useInvisibleBlocks=(m=s==null?void 0:s.useInvisibleBlockBuffer)!=null?m:!0,this.gridShaderProgram=new Nn(e,su,au).getProgram(),this.colorShaderProgram=new Nn(e,ru,iu).getProgram(),this.gridMesh=this.getGridMesh(),this.outlineMesh=this.getOutlineMesh(),this.invisibleBlocksMesh=this.getInvisibleBlocksMesh(),this.atlasTexture=this.createAtlasTexture(this.resources.getTextureAtlas())}setStructure(e){this.structure=e,this.chunkBuilder.setStructure(e),this.gridMesh=this.getGridMesh(),this.invisibleBlocksMesh=this.getInvisibleBlocksMesh()}updateStructureBuffers(e){this.chunkBuilder.updateStructureBuffers(e)}getGridMesh(){const[e,r,i]=this.structure.getSize(),s=new it;s.addLine(0,0,0,e,0,0,[1,0,0]),s.addLine(0,0,0,0,0,i,[0,0,1]);const a=[.8,.8,.8];s.addLine(0,0,0,0,r,0,a),s.addLine(e,0,0,e,r,0,a),s.addLine(0,0,i,0,r,i,a),s.addLine(e,0,i,e,r,i,a),s.addLine(0,r,0,0,r,i,a),s.addLine(e,r,0,e,r,i,a),s.addLine(0,r,0,e,r,0,a),s.addLine(0,r,i,e,r,i,a);for(let o=1;o<=e;o+=1)s.addLine(o,0,0,o,0,i,a);for(let o=1;o<=i;o+=1)s.addLine(0,0,o,e,0,o,a);return s.rebuild(this.gl,{pos:!0,color:!0})}getOutlineMesh(){return new it().addLineCube(0,0,0,1,1,1,[1,1,1]).rebuild(this.gl,{pos:!0,color:!0})}getInvisibleBlocksMesh(){const e=new it;if(!this.useInvisibleBlocks)return e;const r=this.structure.getSize();for(let i=0;i{this.drawMesh(r,{pos:!0,color:!0,texture:!0,normal:!0})})}drawColoredStructure(e){this.setShader(this.colorShaderProgram),this.prepareDraw(e),this.chunkBuilder.getMeshes().forEach(r=>{this.drawMesh(r,{pos:!0,color:!0,normal:!0,blockPos:!0})})}drawOutline(e,r){this.setShader(this.gridShaderProgram);const i=rt();Al(i,e),X(i,i,r),this.prepareDraw(i),this.drawMesh(this.outlineMesh,{pos:!0,color:!0})}}class Cn{constructor(t,e){_(this,"part");if(this.img=t,this.idMap=e,!qr(t.width)||!qr(t.height))throw new Error(`Expected texture atlas dimensions to be powers of two, got ${t.width}x${t.height}.`);this.part=16/t.width}getTextureAtlas(){return this.img}getTextureUV(t){var e;return(e=this.idMap[t.toString()])!=null?e:[0,0,this.part,this.part]}static async fromBlobs(t){const e=Math.sqrt(Object.keys(t).length+1),r=zs(e),i=r*16,s=1/r,a=document.createElement("canvas");a.width=i,a.height=i;const o=a.getContext("2d");this.drawInvalidTexture(o);const m={};let c=1;return await Promise.all(Object.keys(t).map(async l=>{const h=c%r,d=Math.floor(c/r);c+=1,m[l]=[s*h,s*d,s*h+s,s*d+s];const f=await createImageBitmap(t[l]);o.drawImage(f,0,0,16,16,16*h,16*d,16,16)})),new Cn(o.getImageData(0,0,i,i),m)}static empty(){const t=document.createElement("canvas");t.width=16,t.height=16;const e=t.getContext("2d");return Cn.drawInvalidTexture(e),new Cn(e.getImageData(0,0,16,16),{})}static drawInvalidTexture(t){t.fillStyle="black",t.fillRect(0,0,16,16),t.fillStyle="magenta",t.fillRect(0,0,8,8),t.fillRect(8,8,8,8)}}const cu=` attribute vec4 vertPos; attribute vec3 vertColor; uniform mat4 mView; uniform mat4 mProj; varying highp vec3 vColor; void main(void) { gl_Position = mProj * mView * vertPos; vColor = vertColor; } `,lu=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `;class uu extends lr{constructor(e){super(e);_(this,"voxelShaderProgram");_(this,"voxels",[]);_(this,"quads",[]);_(this,"meshes",[]);this.voxelShaderProgram=new Nn(e,cu,lu).getProgram()}setVoxels(e){this.voxels=e,this.quads=this.getQuads(),this.meshes=this.getMeshes()}getQuads(){var i,s,a,o,m,c,l,h,d,f,w,v;const e=new Map;for(const g of this.voxels)wr(e,g.x,new Map,p=>{wr(p,g.y,new Set,S=>{S.add(g.z)})});const r=[];for(const g of this.voxels)(s=(i=e.get(g.x+1))==null?void 0:i.get(g.y))!=null&&s.has(g.z)||r.push(qt.fromPoints(new q(g.x+1,g.y,g.z),new q(g.x+1,g.y+1,g.z),new q(g.x+1,g.y+1,g.z+1),new q(g.x+1,g.y,g.z+1)).setColor(g.color)),(o=(a=e.get(g.x-1))==null?void 0:a.get(g.y))!=null&&o.has(g.z)||r.push(qt.fromPoints(new q(g.x,g.y,g.z+1),new q(g.x,g.y+1,g.z+1),new q(g.x,g.y+1,g.z),new q(g.x,g.y,g.z)).setColor(g.color)),(c=(m=e.get(g.x))==null?void 0:m.get(g.y+1))!=null&&c.has(g.z)||r.push(qt.fromPoints(new q(g.x,g.y+1,g.z+1),new q(g.x+1,g.y+1,g.z+1),new q(g.x+1,g.y+1,g.z),new q(g.x,g.y+1,g.z)).setColor(g.color)),(h=(l=e.get(g.x))==null?void 0:l.get(g.y-1))!=null&&h.has(g.z)||r.push(qt.fromPoints(new q(g.x,g.y,g.z),new q(g.x+1,g.y,g.z),new q(g.x+1,g.y,g.z+1),new q(g.x,g.y,g.z+1)).setColor(g.color)),(f=(d=e.get(g.x))==null?void 0:d.get(g.y))!=null&&f.has(g.z+1)||r.push(qt.fromPoints(new q(g.x,g.y,g.z+1),new q(g.x+1,g.y,g.z+1),new q(g.x+1,g.y+1,g.z+1),new q(g.x,g.y+1,g.z+1)).setColor(g.color)),(v=(w=e.get(g.x))==null?void 0:w.get(g.y))!=null&&v.has(g.z-1)||r.push(qt.fromPoints(new q(g.x,g.y+1,g.z),new q(g.x+1,g.y+1,g.z),new q(g.x+1,g.y,g.z),new q(g.x,g.y,g.z)).setColor(g.color));return console.debug(`Converted ${this.voxels.length} voxels into ${r.length} quads!`),r}getMeshes(){const e=[];let r=new it;for(const i of this.quads){const s=i.normal(),a=(s.y*.25+Math.abs(s.z)*.125+.75)/256;i.forEach(o=>o.color=[o.color[0]*a,o.color[1]*a,o.color[2]*a]),r.quads.push(i),r.quadVertices()>65e3&&(e.push(r),r=new it)}r.isEmpty()||e.push(r);for(const i of e)i.rebuild(this.gl,{pos:!0,color:!0});return e}draw(e){if(console.debug(`Drawing ${this.meshes.length} meshes...`),this.setShader(this.voxelShaderProgram),this.prepareDraw(e),this.meshes.length===0){this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);return}for(const r of this.meshes)this.drawMesh(r,{pos:!0,color:!0})}}u.NoiseRouter=void 0,(n=>{const t=o=>new W.HolderHolder(u.Holder.parser(u.WorldgenRegistries.DENSITY_FUNCTION,W.fromJson)(o));function e(o){var c;const m=(c=u.Json.readObject(o))!=null?c:{};return{barrier:t(m.barrier),fluidLevelFloodedness:t(m.fluid_level_floodedness),fluidLevelSpread:t(m.fluid_level_spread),lava:t(m.lava),temperature:t(m.temperature),vegetation:t(m.vegetation),continents:t(m.continents),erosion:t(m.erosion),depth:t(m.depth),ridges:t(m.ridges),initialDensityWithoutJaggedness:t(m.initial_density_without_jaggedness),finalDensity:t(m.final_density),veinToggle:t(m.vein_toggle),veinRidged:t(m.vein_ridged),veinGap:t(m.vein_gap)}}n.fromJson=e;function r(o){return{barrier:W.Constant.ZERO,fluidLevelFloodedness:W.Constant.ZERO,fluidLevelSpread:W.Constant.ZERO,lava:W.Constant.ZERO,temperature:W.Constant.ZERO,vegetation:W.Constant.ZERO,continents:W.Constant.ZERO,erosion:W.Constant.ZERO,depth:W.Constant.ZERO,ridges:W.Constant.ZERO,initialDensityWithoutJaggedness:W.Constant.ZERO,finalDensity:W.Constant.ZERO,veinToggle:W.Constant.ZERO,veinRidged:W.Constant.ZERO,veinGap:W.Constant.ZERO,...o}}n.create=r;function i(o,m){return{barrier:o.barrier.mapAll(m),fluidLevelFloodedness:o.fluidLevelFloodedness.mapAll(m),fluidLevelSpread:o.fluidLevelSpread.mapAll(m),lava:o.lava.mapAll(m),temperature:o.temperature.mapAll(m),vegetation:o.vegetation.mapAll(m),continents:o.continents.mapAll(m),erosion:o.erosion.mapAll(m),depth:o.depth.mapAll(m),ridges:o.ridges.mapAll(m),initialDensityWithoutJaggedness:o.initialDensityWithoutJaggedness.mapAll(m),finalDensity:o.finalDensity.mapAll(m),veinToggle:o.veinToggle.mapAll(m),veinRidged:o.veinRidged.mapAll(m),veinGap:o.veinGap.mapAll(m)}}n.mapAll=i;const s=new Map;function a(o,m){var f;const c=(f=m.key())==null?void 0:f.toString();if(!c)throw new Error("Cannot instantiate noise from direct holder");const l=o.seedKey(),h=s.get(c);if(h&&h[0]===l[0]&&h[1]===l[1])return h[2];const d=new ie(o.fromHashOf(c),m.value());return s.set(c,[l[0],l[1],d]),d}n.instantiate=a})(u.NoiseRouter||(u.NoiseRouter={})),u.NoiseSettings=void 0,(n=>{function t(o){var c,l,h,d,f;const m=(c=u.Json.readObject(o))!=null?c:{};return{minY:(l=u.Json.readInt(m.min_y))!=null?l:0,height:(h=u.Json.readInt(m.height))!=null?h:256,xzSize:(d=u.Json.readInt(m.size_horizontal))!=null?d:1,ySize:(f=u.Json.readInt(m.size_vertical))!=null?f:1}}n.fromJson=t;function e(o){return{minY:0,height:256,xzSize:1,ySize:1,...o}}n.create=e;function r(o){return o.ySize<<2}n.cellHeight=r;function i(o){return o.xzSize<<2}n.cellWidth=i;function s(o){return o.height/r(o)}n.cellCountY=s;function a(o){return Math.floor(o.minY/r(o))}n.minCellY=a})(u.NoiseSettings||(u.NoiseSettings={})),u.NoiseSlideSettings=void 0,(n=>{function t(r){var s,a,o,m;const i=(s=u.Json.readObject(r))!=null?s:{};return{target:(a=u.Json.readNumber(i.target))!=null?a:0,size:(o=u.Json.readInt(i.size))!=null?o:0,offset:(m=u.Json.readInt(i.offset))!=null?m:0}}n.fromJson=t;function e(r,i,s){if(r.size<=0)return i;const a=(s-r.offset)/r.size;return tr(r.target,i,a)}n.apply=e})(u.NoiseSlideSettings||(u.NoiseSlideSettings={})),u.VerticalAnchor=void 0,(n=>{function t(s){var o,m,c,l;const a=(o=u.Json.readObject(s))!=null?o:{};return a.absolute!==void 0?e((m=u.Json.readNumber(a.absolute))!=null?m:0):a.above_bottom!==void 0?r((c=u.Json.readNumber(a.above_bottom))!=null?c:0):a.below_top!==void 0?i((l=u.Json.readNumber(a.below_top))!=null?l:0):()=>0}n.fromJson=t;function e(s){return()=>s}n.absolute=e;function r(s){return a=>a.minY+s}n.aboveBottom=r;function i(s){return a=>a.minY+a.height-1-s}n.belowTop=i})(u.VerticalAnchor||(u.VerticalAnchor={}));class js{constructor(t,e,r){_(this,"surfaceNoise");_(this,"surfaceSecondaryNoise");_(this,"random");_(this,"positionalRandoms");this.rule=t,this.defaultBlock=e,this.random=nt.create(r).forkPositional(),this.surfaceNoise=u.NoiseRouter.instantiate(this.random,u.WorldgenRegistries.SURFACE_NOISE),this.surfaceSecondaryNoise=u.NoiseRouter.instantiate(this.random,u.WorldgenRegistries.SURFACE_SECONDARY_NOISE),this.positionalRandoms=new Map}buildSurface(t,e,r,i){const s=u.ChunkPos.minBlockX(t.pos),a=u.ChunkPos.minBlockZ(t.pos),o=new Ks(this,t,e,r,i),m=this.rule(o);for(let c=0;c<16;c+=1){const l=s+c;for(let h=0;h<1;h+=1){const d=a+h;o.updateXZ(l,d);let f=0,w=Number.MIN_SAFE_INTEGER,v=Number.MAX_SAFE_INTEGER;for(let g=t.maxY;g>=t.minY;g-=1){const p=u.BlockPos.create(l,g,d),S=t.getBlockState(p);if(S.equals(j.AIR)){f=0,w=Number.MIN_SAFE_INTEGER;continue}if(S.isFluid()){w===Number.MIN_SAFE_INTEGER&&(w=g+1);continue}if(v>=g){v=Number.MIN_SAFE_INTEGER;for(let R=g-1;R>=t.minY;R-=1){const k=t.getBlockState(u.BlockPos.create(l,R,d));if(k.equals(j.AIR)||k.isFluid()){v=R+1;break}}}f+=1;const E=g-v+1;if(!S.equals(this.defaultBlock))continue;o.updateY(f,E,w,g);const y=m(l,g,d);y&&t.setBlockState(p,y)}}}}getSurfaceDepth(t,e){const r=this.surfaceNoise.sample(t,0,e),i=this.random.at(t,0,e).nextDouble()*.25;return r*2.75+3+i}getSurfaceSecondary(t,e){return this.surfaceSecondaryNoise.sample(t,0,e)}getRandom(t){return Ee(this.positionalRandoms,t,()=>this.random.fromHashOf(t))}}class Ks{constructor(t,e,r,i,s){_(this,"blockX",0);_(this,"blockY",0);_(this,"blockZ",0);_(this,"stoneDepthAbove",0);_(this,"stoneDepthBelow",0);_(this,"surfaceDepth",0);_(this,"waterHeight",0);_(this,"biome",()=>"");_(this,"surfaceSecondary",()=>0);_(this,"minSurfaceLevel",()=>0);this.system=t,this.chunk=e,this.noiseChunk=r,this.context=i,this.getBiome=s}updateXZ(t,e){this.blockX=t,this.blockZ=e,this.surfaceDepth=this.system.getSurfaceDepth(t,e),this.surfaceSecondary=sn(()=>this.system.getSurfaceSecondary(t,e)),this.minSurfaceLevel=sn(()=>this.calculateMinSurfaceLevel(t,e))}updateY(t,e,r,i){this.blockY=i,this.stoneDepthAbove=t,this.stoneDepthBelow=e,this.waterHeight=r,this.biome=sn(()=>this.getBiome(u.BlockPos.create(this.blockX,this.blockY,this.blockZ)))}calculateMinSurfaceLevel(t,e){const r=t>>4,i=e>>4,s=this.noiseChunk.getPreliminarySurfaceLevel(r<<4,i<<4),a=this.noiseChunk.getPreliminarySurfaceLevel(r+1<<4,i<<4),o=this.noiseChunk.getPreliminarySurfaceLevel(r<<4,i+1<<4),m=this.noiseChunk.getPreliminarySurfaceLevel(r+1<<4,i+1<<4);return Math.floor(Qn((t&15)/16,(e&15)/16,s,a,o,m))+this.surfaceDepth-8}}u.SurfaceRule=void 0,(n=>{n.NOOP=()=>()=>{};function t(s){var m,c,l;const a=(m=u.Json.readObject(s))!=null?m:{};switch((c=u.Json.readString(a.type))==null?void 0:c.replace(/^minecraft:/,"")){case"block":return e(j.fromJson(a.result_state));case"sequence":return r((l=u.Json.readArray(a.sequence,n.fromJson))!=null?l:[]);case"condition":return i(u.SurfaceCondition.fromJson(a.if_true),n.fromJson(a.then_run))}return n.NOOP}n.fromJson=t;function e(s){return()=>()=>s}n.block=e;function r(s){return a=>{const o=s.map(m=>m(a));return(m,c,l)=>{for(const h of o){const d=h(m,c,l);if(d)return d}}}}n.sequence=r;function i(s,a){return o=>(m,c,l)=>{if(s(o))return a(o)(m,c,l)}}n.condition=i})(u.SurfaceRule||(u.SurfaceRule={})),u.SurfaceCondition=void 0,(n=>{n.FALSE=()=>!1,n.TRUE=()=>!0;function t(c){var d,f,w,v,g,p,S,E,y,R,k,I;const l=(d=u.Json.readObject(c))!=null?d:{};switch((f=u.Json.readString(l.type))==null?void 0:f.replace(/^minecraft:/,"")){case"above_preliminary_surface":return e();case"biome":return r((w=u.Json.readArray(l.biome_is,x=>{var N;return(N=u.Json.readString(x))!=null?N:""}))!=null?w:[]);case"not":return i(n.fromJson(l.invert));case"stone_depth":return s((v=u.Json.readInt(l.offset))!=null?v:0,(g=u.Json.readBoolean(l.add_surface_depth))!=null?g:!1,(p=u.Json.readInt(l.secondary_depth_range))!=null?p:0,u.Json.readString(l.surface_type)==="ceiling");case"vertical_gradient":return a((S=u.Json.readString(l.random_name))!=null?S:"",u.VerticalAnchor.fromJson(l.true_at_and_below),u.VerticalAnchor.fromJson(l.false_at_and_above));case"water":return o((E=u.Json.readInt(l.offset))!=null?E:0,(y=u.Json.readInt(l.surface_depth_multiplier))!=null?y:0,(R=u.Json.readBoolean(l.add_surface_depth))!=null?R:!1);case"y_above":return m(u.VerticalAnchor.fromJson(l.anchor),(k=u.Json.readInt(l.surface_depth_multiplier))!=null?k:0,(I=u.Json.readBoolean(l.add_surface_depth))!=null?I:!1)}return n.FALSE}n.fromJson=t;function e(){return c=>c.blockY>=c.minSurfaceLevel()}n.abovePreliminarySurface=e;function r(c){const l=new Set(c);return h=>l.has(h.biome())}n.biome=r;function i(c){return l=>!c(l)}n.not=i;function s(c,l,h,d){return f=>{const w=d?f.stoneDepthBelow:f.stoneDepthAbove,v=l?f.surfaceDepth:0,g=h===0?0:Mn(f.surfaceSecondary(),-1,1,0,h);return w<=1+c+v+g}}n.stoneDepth=s;function a(c,l,h){return d=>{const f=l(d.context),w=h(d.context);if(d.blockY<=f)return!0;if(d.blockY>=w)return!1;const v=d.system.getRandom(c),g=Mn(d.blockY,f,w,1,0);return v.nextFloat(){if(d.waterHeight===Number.MIN_SAFE_INTEGER)return!0;const f=h?d.stoneDepthAbove:0;return d.blockY+f>=d.waterHeight+c+d.surfaceDepth*l}}n.water=o;function m(c,l,h){return d=>{const f=h?d.stoneDepthAbove:0;return d.blockY+f>=c(d.context)+d.surfaceDepth*l}}n.yAbove=m})(u.SurfaceCondition||(u.SurfaceCondition={})),u.NoiseGeneratorSettings=void 0,(n=>{function t(r){var s,a,o,m,c,l;const i=(s=u.Json.readObject(r))!=null?s:{};return{surfaceRule:u.SurfaceRule.fromJson(i.surface_rule),noise:u.NoiseSettings.fromJson(i.noise),defaultBlock:j.fromJson(i.default_block),defaultFluid:j.fromJson(i.default_fluid),noiseRouter:u.NoiseRouter.fromJson(i.noise_router),seaLevel:(a=u.Json.readInt(i.sea_level))!=null?a:0,disableMobGeneration:(o=u.Json.readBoolean(i.disable_mob_generation))!=null?o:!1,aquifersEnabled:(m=u.Json.readBoolean(i.aquifers_enabled))!=null?m:!1,oreVeinsEnabled:(c=u.Json.readBoolean(i.ore_veins_enabled))!=null?c:!1,legacyRandomSource:(l=u.Json.readBoolean(i.legacy_random_source))!=null?l:!1}}n.fromJson=t;function e(r){return{surfaceRule:u.SurfaceRule.NOOP,noise:u.NoiseSettings.create({}),defaultBlock:j.STONE,defaultFluid:j.WATER,noiseRouter:u.NoiseRouter.create({}),seaLevel:0,disableMobGeneration:!1,aquifersEnabled:!1,oreVeinsEnabled:!1,legacyRandomSource:!1,...r}}n.create=e})(u.NoiseGeneratorSettings||(u.NoiseGeneratorSettings={})),u.WorldgenRegistries=void 0,(n=>{n.NOISE=xt.createAndRegister("worldgen/noise",u.NoiseParameters.fromJson),n.DENSITY_FUNCTION=xt.createAndRegister("worldgen/density_function",e=>W.fromJson(e)),n.NOISE_SETTINGS=xt.createAndRegister("worldgen/noise_settings",u.NoiseGeneratorSettings.fromJson),n.BIOME=xt.createAndRegister("worldgen/biome"),n.SURFACE_NOISE=t("surface",-6,[1,1,1]),n.SURFACE_SECONDARY_NOISE=t("surface_secondary",-6,[1,1,0,1]);function t(e,r,i){return n.NOISE.register(B.create(e),u.NoiseParameters.create(r,i),!0)}})(u.WorldgenRegistries||(u.WorldgenRegistries={}));class W{minValue(){return-this.maxValue()}mapAll(t){return t.map(this)}}(n=>{function t(V,M,b){return{x:V,y:M,z:b}}n.context=t;class e extends n{constructor(M){super(),this.input=M}compute(M){return this.transform(M,this.input.compute(M))}}const r=u.Holder.parser(u.WorldgenRegistries.NOISE,u.NoiseParameters.fromJson);function i(V,M=i){var z,Z,Q,kt,At,St,ut,lt,H,O,ct,rn,Pn,On,si,ai,oi,ea,na,ra;if(typeof V=="string")return new a(u.Holder.reference(u.WorldgenRegistries.DENSITY_FUNCTION,B.parse(V)));if(typeof V=="number")return new s(V);const b=(z=u.Json.readObject(V))!=null?z:{},P=(Z=u.Json.readString(b.type))==null?void 0:Z.replace(/^minecraft:/,"");switch(P){case"blend_alpha":return new o(1,0,1);case"blend_offset":return new o(0,-1/0,1/0);case"beardifier":return new o(0,-1/0,1/0);case"old_blended_noise":return new m((Q=u.Json.readNumber(b.xz_scale))!=null?Q:1,(kt=u.Json.readNumber(b.y_scale))!=null?kt:1,(At=u.Json.readNumber(b.xz_factor))!=null?At:80,(St=u.Json.readNumber(b.y_factor))!=null?St:160,(ut=u.Json.readNumber(b.smear_scale_multiplier))!=null?ut:8);case"flat_cache":return new l(M(b.argument));case"interpolated":return new w(M(b.argument));case"cache_2d":return new d(M(b.argument));case"cache_once":return new f(M(b.argument));case"cache_all_in_cell":return new h(M(b.argument));case"noise":return new v((lt=u.Json.readNumber(b.xz_scale))!=null?lt:1,(H=u.Json.readNumber(b.y_scale))!=null?H:1,r(b.noise));case"end_islands":return new g;case"weird_scaled_sampler":return new S(M(b.input),u.Json.readEnum(b.rarity_value_mapper,p),r(b.noise));case"shifted_noise":return new E(M(b.shift_x),M(b.shift_y),M(b.shift_z),(O=u.Json.readNumber(b.xz_scale))!=null?O:1,(ct=u.Json.readNumber(b.y_scale))!=null?ct:1,r(b.noise));case"range_choice":return new y(M(b.input),(rn=u.Json.readNumber(b.min_inclusive))!=null?rn:0,(Pn=u.Json.readNumber(b.max_exclusive))!=null?Pn:1,M(b.when_in_range),M(b.when_out_of_range));case"shift_a":return new k(r(b.argument));case"shift_b":return new I(r(b.argument));case"shift":return new x(r(b.argument));case"blend_density":return new N(M(b.argument));case"clamp":return new A(M(b.input),(On=u.Json.readNumber(b.min))!=null?On:0,(si=u.Json.readNumber(b.max))!=null?si:1);case"abs":case"square":case"cube":case"half_negative":case"quarter_negative":case"squeeze":return new C(P,M(b.argument));case"add":case"mul":case"min":case"max":return new F(u.Json.readEnum(P,L),M(b.argument1),M(b.argument2));case"spline":return new U(u.CubicSpline.fromJson(b.spline,M));case"constant":return new s((ai=u.Json.readNumber(b.argument))!=null?ai:0);case"y_clamped_gradient":return new Y((oi=u.Json.readInt(b.from_y))!=null?oi:-4064,(ea=u.Json.readInt(b.to_y))!=null?ea:4062,(na=u.Json.readNumber(b.from_value))!=null?na:-4064,(ra=u.Json.readNumber(b.to_value))!=null?ra:4062)}return s.ZERO}n.fromJson=i;const T=class extends n{constructor(M){super(),this.value=M}compute(){return this.value}minValue(){return this.value}maxValue(){return this.value}};let s=T;_(s,"ZERO",new T(0)),_(s,"ONE",new T(1)),n.Constant=s;class a extends n{constructor(M){super(),this.holder=M}compute(M){return this.holder.value().compute(M)}minValue(){return this.holder.value().minValue()}maxValue(){return this.holder.value().maxValue()}}n.HolderHolder=a;class o extends n.Constant{constructor(M,b,P){super(M),this.min=b,this.max=P}minValue(){return this.min}maxValue(){return this.max}}n.ConstantMinMax=o;class m extends n{constructor(M,b,P,z,Z,Q){super(),this.xzScale=M,this.yScale=b,this.xzFactor=P,this.yFactor=z,this.smearScaleMultiplier=Z,this.blendedNoise=Q}compute(M){var b,P;return(P=(b=this.blendedNoise)==null?void 0:b.sample(M.x,M.y,M.z))!=null?P:0}maxValue(){var M,b;return(b=(M=this.blendedNoise)==null?void 0:M.maxValue)!=null?b:0}}n.OldBlendedNoise=m;class c extends n{constructor(M){super(),this.wrapped=M}minValue(){return this.wrapped.minValue()}maxValue(){return this.wrapped.maxValue()}}class l extends c{constructor(b){super(b);_(this,"lastQuartX");_(this,"lastQuartZ");_(this,"lastValue",0)}compute(b){const P=b.x>>2,z=b.z>>2;return(this.lastQuartX!==P||this.lastQuartZ!==z)&&(this.lastValue=this.wrapped.compute(n.context(P<<2,0,z<<2)),this.lastQuartX=P,this.lastQuartZ=z),this.lastValue}mapAll(b){return b.map(new l(this.wrapped.mapAll(b)))}}n.FlatCache=l;class h extends c{constructor(M){super(M)}compute(M){return this.wrapped.compute(M)}mapAll(M){return M.map(new h(this.wrapped.mapAll(M)))}}n.CacheAllInCell=h;class d extends c{constructor(b){super(b);_(this,"lastBlockX");_(this,"lastBlockZ");_(this,"lastValue",0)}compute(b){const P=b.x,z=b.z;return(this.lastBlockX!==P||this.lastBlockZ!==z)&&(this.lastValue=this.wrapped.compute(b),this.lastBlockX=P,this.lastBlockZ=z),this.lastValue}mapAll(b){return b.map(new d(this.wrapped.mapAll(b)))}}n.Cache2D=d;class f extends c{constructor(b){super(b);_(this,"lastBlockX");_(this,"lastBlockY");_(this,"lastBlockZ");_(this,"lastValue",0)}compute(b){const P=b.x,z=b.y,Z=b.z;return(this.lastBlockX!==P||this.lastBlockY!==z||this.lastBlockZ!==Z)&&(this.lastValue=this.wrapped.compute(b),this.lastBlockX=P,this.lastBlockY=z,this.lastBlockZ=Z),this.lastValue}mapAll(b){return b.map(new f(this.wrapped.mapAll(b)))}}n.CacheOnce=f;class w extends c{constructor(b,P=4,z=4){super(b);_(this,"values");this.cellWidth=P,this.cellHeight=z,this.values=new Map}compute({x:b,y:P,z}){const Z=this.cellWidth,Q=this.cellHeight,kt=(b%Z+Z)%Z/Z,At=(P%Q+Q)%Q/Q,St=(z%Z+Z)%Z/Z,ut=Math.floor(b/Z)*Z,lt=Math.floor(P/Q)*Q,H=Math.floor(z/Z)*Z;return Ps(kt,At,St,()=>this.computeCorner(ut,lt,H),()=>this.computeCorner(ut+Z,lt,H),()=>this.computeCorner(ut,lt+Q,H),()=>this.computeCorner(ut+Z,lt+Q,H),()=>this.computeCorner(ut,lt,H+Z),()=>this.computeCorner(ut+Z,lt,H+Z),()=>this.computeCorner(ut,lt+Q,H+Z),()=>this.computeCorner(ut+Z,lt+Q,H+Z))}computeCorner(b,P,z){return Ee(this.values,`${b} ${P} ${z}`,()=>this.wrapped.compute(n.context(b,P,z)))}mapAll(b){return b.map(new w(this.wrapped.mapAll(b)))}withCellSize(b,P){return new w(this.wrapped,b,P)}}n.Interpolated=w;class v extends n{constructor(M,b,P,z){super(),this.xzScale=M,this.yScale=b,this.noiseData=P,this.noise=z}compute(M){var b,P;return(P=(b=this.noise)==null?void 0:b.sample(M.x*this.xzScale,M.y*this.yScale,M.z*this.xzScale))!=null?P:0}maxValue(){var M,b;return(b=(M=this.noise)==null?void 0:M.maxValue)!=null?b:2}}n.Noise=v;class g extends n{constructor(b){super();_(this,"islandNoise");const P=new at(b!=null?b:BigInt(0));P.consume(17292),this.islandNoise=new wt(P)}getHeightValue(b,P){const z=Math.floor(b/2),Z=Math.floor(P/2),Q=b%2,kt=P%2;let At=_t(100-Math.sqrt(b*b+P*P)*8,-100,80);for(let St=-12;St<=12;St+=1)for(let ut=-12;ut<=12;ut+=1){const lt=z+St,H=Z+ut;if(lt*lt+H*H<=4096||this.islandNoise.sample2D(lt,H)>=-.9)continue;const O=(Math.abs(lt)*3439+Math.abs(H)*147)%13+9,ct=Q+St*2,rn=kt+ut*2,Pn=100-Math.sqrt(ct*ct+rn*rn)*O,On=_t(Pn,-100,80);At=Math.max(At,On)}return At}compute({x:b,y:P,z}){return(this.getHeightValue(Math.floor(b/8),Math.floor(z/8))-8)/128}minValue(){return-.84375}maxValue(){return .5625}}n.EndIslands=g;const p=["type_1","type_2"],J=class extends e{constructor(b,P,z,Z){super(b);_(this,"mapper");this.rarityValueMapper=P,this.noiseData=z,this.noise=Z,this.mapper=J.ValueMapper[this.rarityValueMapper]}transform(b,P){if(!this.noise)return 0;const z=this.mapper(P);return z*Math.abs(this.noise.sample(b.x/z,b.y/z,b.z/z))}mapAll(b){return b.map(new J(this.input.mapAll(b),this.rarityValueMapper,this.noiseData,this.noise))}minValue(){return 0}maxValue(){return this.rarityValueMapper==="type_1"?2:3}static rarityValueMapper1(b){return b<-.5?.75:b<0?1:b<.5?1.5:2}static rarityValueMapper2(b){return b<-.75?.5:b<-.5?.75:b<.5?1:b<.75?2:3}};let S=J;_(S,"ValueMapper",{type_1:J.rarityValueMapper1,type_2:J.rarityValueMapper2}),n.WeirdScaledSampler=S;class E extends v{constructor(M,b,P,z,Z,Q,kt){super(z,Z,Q,kt),this.shiftX=M,this.shiftY=b,this.shiftZ=P}compute(M){var Z,Q;const b=M.x*this.xzScale+this.shiftX.compute(M),P=M.y*this.yScale+this.shiftY.compute(M),z=M.z*this.xzScale+this.shiftZ.compute(M);return(Q=(Z=this.noise)==null?void 0:Z.sample(b,P,z))!=null?Q:0}mapAll(M){return M.map(new E(this.shiftX.mapAll(M),this.shiftY.mapAll(M),this.shiftZ.mapAll(M),this.xzScale,this.yScale,this.noiseData,this.noise))}}n.ShiftedNoise=E;class y extends n{constructor(M,b,P,z,Z){super(),this.input=M,this.minInclusive=b,this.maxExclusive=P,this.whenInRange=z,this.whenOutOfRange=Z}compute(M){const b=this.input.compute(M);return this.minInclusive<=b&&bMath.abs(b),square:b=>b*b,cube:b=>b*b*b,half_negative:b=>b>0?b:b*.5,quarter_negative:b=>b>0?b:b*.25,squeeze:b=>{const P=_t(b,-1,1);return P/2-P*P*P/24}}),n.Mapped=C;const L=["add","mul","min","max"];class F extends n{constructor(M,b,P,z,Z){super(),this.type=M,this.argument1=b,this.argument2=P,this.min=z,this.max=Z}compute(M){const b=this.argument1.compute(M);switch(this.type){case"add":return b+this.argument2.compute(M);case"mul":return b===0?0:b*this.argument2.compute(M);case"min":return bthis.argument2.maxValue()?b:Math.max(b,this.argument2.compute(M))}}mapAll(M){return M.map(new F(this.type,this.argument1.mapAll(M),this.argument2.mapAll(M)))}minValue(){var M;return(M=this.min)!=null?M:-1/0}maxValue(){var M;return(M=this.max)!=null?M:1/0}withMinMax(){const M=this.argument1.minValue(),b=this.argument2.minValue(),P=this.argument1.maxValue(),z=this.argument2.maxValue();(this.type==="min"||this.type==="max")&&(M>=z||b>=P)&&console.warn(`Creating a ${this.type} function between two non-overlapping inputs`);let Z,Q;switch(this.type){case"add":Z=M+b,Q=P+z;break;case"mul":Z=M>0&&b>0?M*b||0:P<0&&z<0?P*z||0:Math.min(M*z||0,b*P||0),Q=M>0&&b>0?P*z||0:P<0&&z<0?M*b||0:Math.max(M*b||0,P*z||0);break;case"min":Z=Math.min(M,b),Q=Math.min(P,z);break;case"max":Z=Math.max(M,b),Q=Math.max(P,z);break}return new F(this.type,this.argument1,this.argument2,Z,Q)}}n.Ap2=F;class U extends n{constructor(M){super(),this.spline=M}compute(M){return this.spline.compute(M)}mapAll(M){const b=this.spline.mapAll(P=>P instanceof n?P.mapAll(M):P);return b.calculateMinMax(),M.map(new U(b))}minValue(){return this.spline.min()}maxValue(){return this.spline.max()}}n.Spline=U;class Y extends n{constructor(M,b,P,z){super(),this.fromY=M,this.toY=b,this.fromValue=P,this.toValue=z}compute(M){return $r(M.y,this.fromY,this.toY,this.fromValue,this.toValue)}minValue(){return Math.min(this.fromValue,this.toValue)}maxValue(){return Math.max(this.fromValue,this.toValue)}}n.YClampedGradient=Y})(W||(W={}));class Bn{constructor(t,e){this.level=t,this.type=e}at(t){return t{function t(e){return{compute({x:r,y:i,z:s},a){if(!(a>0))return e(r,i,s).at(i)}}}n.createDisabled=t})(u.Aquifer||(u.Aquifer={}));const Jt=class{constructor(t,e,r,i,s,a,o){_(this,"minGridX");_(this,"minGridY");_(this,"minGridZ");_(this,"gridSizeX");_(this,"gridSizeZ");_(this,"gridSize");_(this,"aquiferCache");_(this,"aquiferLocationCache");this.noiseChunk=t,this.router=r,this.random=i,this.globalFluidPicker=o,this.minGridX=this.gridX(u.ChunkPos.minBlockX(e))-1,this.gridSizeX=this.gridX(u.ChunkPos.maxBlockX(e))+1-this.minGridX+1,this.minGridY=this.gridY(s)-1,this.minGridZ=this.gridZ(u.ChunkPos.minBlockZ(e))-1,this.gridSizeZ=this.gridZ(u.ChunkPos.maxBlockZ(e))+1-this.minGridZ+1;const m=this.gridY(s+a)+1-this.minGridY+1;this.gridSize=this.gridSizeX*m*this.gridSizeZ,this.aquiferCache=Array(this.gridSize).fill(void 0),this.aquiferLocationCache=Array(this.gridSize).fill(u.BlockPos.ZERO)}compute({x:t,y:e,z:r},i){if(i<=0){if(this.globalFluidPicker(t,e,r).at(e).is(j.LAVA))return j.LAVA;{const s=this.gridX(t-5),a=this.gridY(e+1),o=this.gridZ(r-5);let m=Number.MAX_SAFE_INTEGER,c=Number.MAX_SAFE_INTEGER,l=Number.MAX_SAFE_INTEGER,h=u.BlockPos.ZERO,d=u.BlockPos.ZERO,f=u.BlockPos.ZERO;for(let R=0;R<=1;R+=1)for(let k=-1;k<=1;k+=1)for(let I=0;I<=1;I+=1){const x=this.getLocation(s+R,a+k,o+I),N=u.BlockPos.magnitude(x);m>=N?(f=d,d=h,h=x,l=c,c=m,m=N):c>=N?(f=d,d=x,l=c,c=N):l>=N&&(f=x,l=N)}const w=this.getStatus(h),v=this.getStatus(d),g=this.getStatus(f),p=Jt.similarity(m,c),S=Jt.similarity(m,l),E=Jt.similarity(c,l);let y;if(w.at(e).is(j.WATER)&&this.globalFluidPicker(t,e-1,r).at(e-1).is(j.LAVA))y=1;else if(p>-1){const R=sn(()=>this.router.barrier.compute(W.context(t,e*.5,r))),k=this.calculatePressure(e,w,v,R),I=this.calculatePressure(e,w,g,R),x=this.calculatePressure(e,v,g,R),N=Math.max(k,I*Math.max(0,S),x*Math.max(E));y=Math.max(0,2*Math.max(0,p)*N)}else y=0;if(i+y<=0)return w.at(e)}}}static similarity(t,e){return 1-Math.abs(e-t)/25}calculatePressure(t,e,r,i){const s=e.at(t),a=r.at(t);if(s.is(j.LAVA)&&a.is(j.WATER)||s.is(j.WATER)&&a.is(j.LAVA))return 1;const o=Math.abs(e.level-r.level);if(o===0)return 0;const m=(e.level+r.level)/2,c=t+.5-m,l=o/2-Math.abs(c),h=c>0?l>0?l/1.5:l/2.5:l>-3?(l+3)/3:(l+3)/10;return h<-2||h>2?h:h+i()}getStatus(t){const[e,r,i]=t,s=this.getIndex(this.gridX(e),this.gridY(r),this.gridZ(i)),a=this.aquiferCache[s];if(a!==void 0)return a;const o=this.computeStatus(e,r,i);return this.aquiferCache[s]=o,o}computeStatus(t,e,r){const i=this.globalFluidPicker(t,e,r);let s=Number.MAX_SAFE_INTEGER,a=!1;for(const[w,v]of Jt.SURFACE_SAMPLING){const g=t+(v<<4),p=r+(v<<4),S=this.noiseChunk.getPreliminarySurfaceLevel(g,p);s=Math.min(s,S);const E=w===0&&v===0;if(E&&e-12>S+8)return i;if(E||e+12>S+8){const y=this.globalFluidPicker(g,S+8,p);if(!y.at(S+8).is(j.AIR)){if(E)return y;a=!0}}}const o=a?$r(s+8-e,0,64,1,0):0,m=_t(this.router.fluidLevelFloodedness.compute(W.context(t,e*.67,r)),-1,1);if(m>Mn(o,1,0,-.3,.8))return i;if(m<=Mn(o,1,0,-.8,.4))return new Bn(Number.MIN_SAFE_INTEGER,i.type);const c=Math.floor(e/40),l=this.router.fluidLevelSpread.compute(W.context(Math.floor(t/16),c,Math.floor(r/16))),h=c*40+20+Math.floor(l/3)*3,d=Math.min(s,h),f=this.getFluidType(t,e,r,i.type,h);return new Bn(d,f)}getFluidType(t,e,r,i,s){if(s<=-10){const a=this.router.lava.compute(W.context(Math.floor(t/64),Math.floor(e/40),Math.floor(r/64)));if(Math.abs(a)>.3)return j.LAVA}return i}getLocation(t,e,r){const i=this.getIndex(t,e,r),s=this.aquiferLocationCache[i];if(u.BlockPos.equals(s,u.BlockPos.ZERO))return s;const a=this.random.at(t,e,r),o=u.BlockPos.create(t*Jt.X_SPACING+a.nextInt(10),e*Jt.Y_SPACING+a.nextInt(9),r*Jt.Z_SPACING+a.nextInt(10));return this.aquiferLocationCache[i]=o,o}getIndex(t,e,r){const i=t-this.minGridX,s=e-this.minGridY,a=r-this.minGridZ,o=(s*this.gridSizeZ+a)*this.gridSizeX+i;if(o<0||o>=this.gridSize)throw new Error(`Invalid aquifer index at ${t} ${e} ${r}: 0 <= ${o} < ${this.gridSize}`);return o}gridX(t){return Math.floor(t/Jt.X_SPACING)}gridY(t){return Math.floor(t/Jt.Y_SPACING)}gridZ(t){return Math.floor(t/Jt.Z_SPACING)}};let ze=Jt;_(ze,"X_SPACING",16),_(ze,"Y_SPACING",12),_(ze,"Z_SPACING",16),_(ze,"SURFACE_SAMPLING",[[-2,-1],[-1,-1],[0,-1],[1,-1],[-3,0],[-2,0],[-1,0],[0,0],[1,0],[-2,1],[-1,1],[0,1],[1,1]]),u.HeightProvider=void 0,(n=>{function t(m){var h,d,f;const c=(h=u.Json.readObject(m))!=null?h:{};switch((d=u.Json.readString(c.type))==null?void 0:d.replace(/^minecraft:/,"")){case void 0:return e(u.VerticalAnchor.fromJson(m));case"constant":return e(u.VerticalAnchor.fromJson(c.value));case"uniform":return r(u.VerticalAnchor.fromJson(c.min_inclusive),u.VerticalAnchor.fromJson(c.max_inclusive));case"biased_to_bottom":return i(u.VerticalAnchor.fromJson(c.min_inclusive),u.VerticalAnchor.fromJson(c.max_inclusive),u.Json.readInt(c.inner));case"very_biased_to_bottom":return s(u.VerticalAnchor.fromJson(c.min_inclusive),u.VerticalAnchor.fromJson(c.max_inclusive),u.Json.readInt(c.inner));case"trapezoid":return a(u.VerticalAnchor.fromJson(c.min_inclusive),u.VerticalAnchor.fromJson(c.max_inclusive),u.Json.readInt(c.plateau));case"weighted_list":return o((f=u.Json.readArray(c.distribution,w=>{var g,p;const v=(g=u.Json.readObject(w))!=null?g:{};return{weight:(p=u.Json.readInt(v.weight))!=null?p:1,data:t(v.data)}}))!=null?f:[])}return()=>0}n.fromJson=t;function e(m){return(c,l)=>m(l)}n.constant=e;function r(m,c){return(l,h)=>{const d=m(h),f=c(h);return d>f?d:l.nextInt(f-d+1)+d}}n.uniform=r;function i(m,c,l=1){return(h,d)=>{const f=m(d),w=c(d);if(w-f-l+1<=0)return f;{const v=h.nextInt(w-f-l+1);return h.nextInt(v+l)+f}}}n.biased_to_bottom=i;function s(m,c,l=1){return(h,d)=>{const f=m(d),w=c(d);if(w-f-l+1<=0)return f;{const v=ir(h,f+l,w),g=ir(h,f,v-1);return ir(h,f,g-1+l)}}}n.very_biased_to_bottom=s;function a(m,c,l=0){return(h,d)=>{const f=m(d),w=c(d);if(f>w)return f;{const v=w-f;if(l>=v)return rr(h,f,w);{const g=(v-l)/2,p=v-g;return f+rr(h,0,p)+rr(h,0,g)}}}}n.trapezoid=a;function o(m){const c=m.reduce((l,h,d)=>l+h.weight,0);return(l,h)=>{let d=l.nextInt(c);for(const f of m)if(d-=f.weight,d<=0)return f.data(l,h);return 0}}n.weighted_list=o})(u.HeightProvider||(u.HeightProvider={})),u.Heightmap=void 0,(n=>{function t(e){if(typeof e=="string"&&(e==="WORLD_SURFACE_WG"||e==="WORLD_SURFACE"||e==="OCEAN_FLOOR_WG"||e==="OCEAN_FLOOR"||e==="MOTION_BLOCKING"||e==="MOTION_BLOCKING_NO_LEAVES"))return e}n.fromJson=t})(u.Heightmap||(u.Heightmap={}));class ii{constructor(t,e,r,i,s,a,o,m,c){_(this,"cellWidth");_(this,"cellHeight");_(this,"firstCellX");_(this,"firstCellZ");_(this,"firstNoiseX");_(this,"firstNoiseZ");_(this,"noiseSizeXZ");_(this,"preliminarySurfaceLevel",new Map);_(this,"aquifer");_(this,"materialRule");_(this,"initialDensity");this.cellCountXZ=t,this.cellCountY=e,this.cellNoiseMinY=r,this.minX=s,this.minZ=a,this.settings=o,this.cellWidth=u.NoiseSettings.cellWidth(o),this.cellHeight=u.NoiseSettings.cellHeight(o),this.firstCellX=Math.floor(s/this.cellWidth),this.firstCellZ=Math.floor(a/this.cellWidth),this.firstNoiseX=s>>2,this.firstNoiseZ=a>>2,this.noiseSizeXZ=t*this.cellWidth>>2,this.aquifer=u.Aquifer.createDisabled(c);const l=i.router.finalDensity;this.materialRule=u.MaterialRule.fromList([h=>this.aquifer.compute(h,l.compute(h))]),this.initialDensity=i.router.initialDensityWithoutJaggedness}getFinalState(t,e,r){return this.materialRule({x:t,y:e,z:r})}getPreliminarySurfaceLevel(t,e){return Ee(this.preliminarySurfaceLevel,u.ChunkPos.asLong(t,e),()=>{const r=t<<2,i=e<<2;for(let s=this.settings.minY+this.settings.height;s>=this.settings.minY;s-=this.cellHeight)if(this.initialDensity.compute(W.context(r,s,i))>.390625)return s;return Number.MAX_SAFE_INTEGER})}}u.MaterialRule=void 0,(n=>{function t(e){return r=>{for(const i of e){const s=i(r);if(s)return s}}}n.fromList=t})(u.MaterialRule||(u.MaterialRule={}));class Qs{constructor(t,e){_(this,"noiseChunkCache");_(this,"globalFluidPicker");this.biomeSource=t,this.settings=e,this.noiseChunkCache=new Map;const r=new Bn(-54,j.LAVA),i=new Bn(e.seaLevel,e.defaultFluid);this.globalFluidPicker=(s,a,o)=>ao.equals(j.STONE):s=o=>!o.equals(j.AIR),(a=this.iterateNoiseColumn(i,t,e,void 0,s,j.STONE))!=null?a:this.settings.noise.minY}iterateNoiseColumn(t,e,r,i,s,a){var v,g;const o=this.settings.noise.minY,m=u.NoiseSettings.cellHeight(this.settings.noise),c=Math.floor(o/m),l=Math.floor(this.settings.noise.height/m);if(l<=0)return;const h=u.NoiseSettings.cellWidth(this.settings.noise),d=Math.floor(e/h),f=Math.floor(r/h),w=new ii(1,l,c,t,d,f,this.settings.noise,this.settings.aquifersEnabled,this.globalFluidPicker);for(let p=l-1;p>=0;p-=1)for(let S=m-1;S>=0;S-=1){const E=(c+p)*m+S,y=(g=(v=w.getFinalState(e,E,r))!=null?v:a)!=null?g:this.settings.defaultBlock;if(i!==void 0&&(i[E+o]=y),s!==void 0&&s(y))return E+1}}fill(t,e,r=!1){var w;const i=Math.max(e.minY,this.settings.noise.minY),s=Math.min(e.maxY,this.settings.noise.minY+this.settings.noise.height),a=u.NoiseSettings.cellWidth(this.settings.noise),o=u.NoiseSettings.cellHeight(this.settings.noise),m=Math.floor(16/a),c=Math.floor(i/o),l=Math.floor((s-i)/o),h=u.ChunkPos.minBlockX(e.pos),d=u.ChunkPos.minBlockZ(e.pos),f=this.getOrCreateNoiseChunk(t,e);for(let v=0;v=0;S-=1)for(let E=o-1;E>=0;E-=1){const y=(c+S)*o+E,R=y&15,k=e.getSectionIndex(y);e.getSectionIndex(p.minBlockY)!==k&&(p=e.getOrCreateSection(k));for(let I=0;Ir)}computeBiome(t,e,r,i){return this.biomeSource.getBiome(e,r,i,t.sampler)}getOrCreateNoiseChunk(t,e){return Ee(this.noiseChunkCache,u.ChunkPos.toLong(e.pos),()=>{const r=Math.max(e.minY,this.settings.noise.minY),i=Math.min(e.maxY,this.settings.noise.minY+this.settings.noise.height),s=u.NoiseSettings.cellWidth(this.settings.noise),a=u.NoiseSettings.cellHeight(this.settings.noise),o=Math.floor(16/s),m=Math.floor(r/a),c=Math.floor((i-r)/a),l=u.ChunkPos.minBlockX(e.pos),h=u.ChunkPos.minBlockZ(e.pos);return new ii(o,c,m,t,l,h,this.settings.noise,this.settings.aquifersEnabled,this.globalFluidPicker)})}}class hr{constructor(t,e){_(this,"n");if(this.shift=t,this.biomes=e,e.length===0)throw new Error("Cannot create checkerboard biome source without biomes");this.n=e.length}getBiome(t,e,r){const i=(((t>>this.shift)+(r>>this.shift))%this.n+this.n)%this.n;return B.parse(this.biomes[i].toString())}static fromJson(t){var s,a,o;const e=(s=u.Json.readObject(t))!=null?s:{},r=(a=u.Json.readInt(e.scale))!=null?a:2;let i;return typeof e.biomes=="string"?i=[B.parse(e.biomes)]:i=(o=u.Json.readArray(e.biomes,m=>{var c;return B.parse((c=u.Json.readString(m))!=null?c:"")}))!=null?o:[],new hr(r+2,i)}}class Ke{constructor(t){this.biome=t}getBiome(){return this.biome}static fromJson(t){var i,s;const e=(i=u.Json.readObject(t))!=null?i:{},r=B.parse((s=u.Json.readString(e.biome))!=null?s:"plains");return new Ke(r)}}u.Climate=void 0,(n=>{function e(v,g,p,S,E,y){return new o(v,g,p,S,E,y)}n.target=e;function r(v,g,p,S,E,y,R){return new a(i(v),i(g),i(p),i(S),i(E),i(y),R)}n.parameters=r;function i(v,g){return typeof v=="number"?new s(v,g!=null?g:v):v}n.param=i;class s{constructor(g,p){this.min=g,this.max=p}distance(g){const p=(typeof g=="number"?g:g.min)-this.max,S=this.min-(typeof g=="number"?g:g.max);return p>0?p:Math.max(S,0)}union(g){return new s(Math.min(this.min,g.min),Math.max(this.max,g.max))}static fromJson(g){var E;if(typeof g=="number")return new s(g,g);const[p,S]=(E=u.Json.readArray(g,y=>u.Json.readNumber(y)))!=null?E:[];return new s(p!=null?p:0,S!=null?S:0)}}n.Param=s;class a{constructor(g,p,S,E,y,R,k){this.temperature=g,this.humidity=p,this.continentalness=S,this.erosion=E,this.depth=y,this.weirdness=R,this.offset=k}fittness(g){return ne(this.temperature.distance(g.temperature))+ne(this.humidity.distance(g.humidity))+ne(this.continentalness.distance(g.continentalness))+ne(this.erosion.distance(g.erosion))+ne(this.depth.distance(g.depth))+ne(this.weirdness.distance(g.weirdness))+ne(this.offset-g.offset)}space(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,new s(this.offset,this.offset)]}static fromJson(g){var S,E;const p=(S=u.Json.readObject(g))!=null?S:{};return new a(s.fromJson(p.temperature),s.fromJson(p.humidity),s.fromJson(p.continentalness),s.fromJson(p.erosion),s.fromJson(p.depth),s.fromJson(p.weirdness),(E=u.Json.readNumber(p.offset))!=null?E:0)}}n.ParamPoint=a;class o{constructor(g,p,S,E,y,R){this.temperature=g,this.humidity=p,this.continentalness=S,this.erosion=E,this.depth=y,this.weirdness=R}get offset(){return 0}toArray(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,this.offset]}}n.TargetPoint=o;class m{constructor(g){_(this,"index");this.things=g,this.index=new l(g)}find(g){return this.index.search(g,(p,S)=>p.distance(S))}}n.Parameters=m;class c{constructor(g,p,S,E,y,R){this.temperature=g,this.humidity=p,this.continentalness=S,this.erosion=E,this.depth=y,this.weirdness=R}static fromRouter(g){return new n.Sampler(g.temperature,g.vegetation,g.continents,g.erosion,g.depth,g.ridges)}sample(g,p,S){const E=W.context(g<<2,p<<2,S<<2);return n.target(this.temperature.compute(E),this.humidity.compute(E),this.continentalness.compute(E),this.erosion.compute(E),this.depth.compute(E),this.weirdness.compute(E))}}n.Sampler=c;const w=class{constructor(g){_(this,"root");_(this,"last_leaf",null);if(g.length===0)throw new Error("At least one point is required to build search tree");this.root=w.build(g.map(([p,S])=>new f(p,S)))}static build(g){if(g.length===1)return g[0];if(g.length<=w.CHILDREN_PER_NODE){const y=g.map(R=>{let k=0;for(let I=0;I<7;I+=1){const x=R.space[I];k+=Math.abs((x.min+x.max)/2)}return{key:k,node:R}}).sort((R,k)=>R.key-k.key).map(({node:R})=>R);return new d(y)}let p=1/0,S=-1,E=[];for(let y=0;y<7;++y){g=w.sort(g,y,!1),E=w.bucketize(g);let R=0;for(const k of E)R+=w.area(k.space);p>R&&(p=R,S=y)}return g=w.sort(g,S,!1),E=w.bucketize(g),E=w.sort(E,S,!0),new d(E.map(y=>w.build(y.children)))}static sort(g,p,S){return g.map(E=>{const y=E.space[p],R=(y.min+y.max)/2;return{key:S?Math.abs(R):R,node:E}}).sort((E,y)=>E.key-y.key).map(({node:E})=>E)}static bucketize(g){const p=[];let S=[];const E=Math.pow(10,Math.floor(Math.log(g.length-.01)/Math.log(10)));for(const y of g)S.push(y),!(S.lengthnew s(1/0,-1/0));for(const S of g)p=[...Array(7)].map((E,y)=>p[y].union(S.space[y]));return p}search(g,p,S){let E=p?S(p,g):1/0,y=p;for(const R of this.children){const k=S(R,g);if(E<=k)continue;const I=R.search(g,y,S);if(I===null)continue;const x=R==I?k:S(I,g);if(x===0)return I;E<=x||(E=x,y=I)}return y}}n.RSubTree=d;class f extends h{constructor(g,p){super(g.space()),this.thing=p}search(){return this}}n.RLeaf=f})(u.Climate||(u.Climate={}));class fr{constructor(t){_(this,"parameters");this.parameters=new u.Climate.Parameters(t)}getBiome(t,e,r,i){const s=i.sample(t,e,r);return this.parameters.find(s)}static fromJson(t){var s,a;const e=(s=u.Json.readObject(t))!=null?s:{},i=((a=u.Json.readArray(e.biomes,o=>{var m;return(c=>{var l;return{biome:B.parse((l=u.Json.readString(c.biome))!=null?l:"plains"),parameters:u.Climate.ParamPoint.fromJson(c.parameters)}})((m=u.Json.readObject(o))!=null?m:{})}))!=null?a:[]).map(o=>[o.parameters,()=>o.biome]);return new fr(i)}}const ye=class{getBiome(t,e,r,i){const s=t<<2,a=e<<2,o=r<<2,m=s>>4,c=o>>4;if(m*m+c*c<=4096)return ye.END;const l=W.context((m*2+1)*8,a,(c*2+1)*8),h=i.erosion.compute(l);return h>.25?ye.HIGHLANDS:h>=-.0625?ye.MIDLANDS:h>=-.21875?ye.BARRENS:ye.ISLANDS}static fromJson(t){return new ye}};let _e=ye;_(_e,"END",B.create("the_end")),_(_e,"HIGHLANDS",B.create("end_highlands")),_(_e,"MIDLANDS",B.create("end_midlands")),_(_e,"ISLANDS",B.create("small_end_islands")),_(_e,"BARRENS",B.create("end_barrens")),u.BiomeSource=void 0,(n=>{function t(r){var a,o;const i=(a=u.Json.readObject(r))!=null?a:{};switch((o=u.Json.readString(i.type))==null?void 0:o.replace(/^minecraft:/,"")){case"fixed":return Ke.fromJson(r);case"checkerboard":return hr.fromJson(r);case"multi_noise":return fr.fromJson(r);case"the_end":return _e.fromJson(r);default:return new Ke(B.create("plains"))}}n.fromJson=t;function e(r,i,s,a,o,m,c,l,h=1,d=!1){if(r instanceof Ke)return m(r.getBiome())?d?{pos:u.BlockPos.create(i,s,a),biome:r.getBiome()}:{pos:u.BlockPos.create(i-o+c.nextInt(o*2+1),s,a-o+c.nextInt(o*2+1)),biome:r.getBiome()}:void 0;const f=i>>2,w=a>>2,v=o>>2,g=s>>2;for(var p=void 0,S=0,E=d?0:v,y=E;y<=v;y+=h)for(var R=-y;R<=y;R+=h){const I=Math.abs(R)===y;for(var k=-y;k<=y;k+=h){if(d&&!(Math.abs(k)===y)&&!I)continue;const x=f+k,N=w+R,A=r.getBiome(x,g,N,l);if(m(A)){if((p===void 0||c.nextInt(S+1)<=.5)&&(p={pos:u.BlockPos.create(x<<2,s,N<<2),biome:A},d))return p;S++}}}return p}n.findBiomeHorizontal=e})(u.BiomeSource||(u.BiomeSource={}));class ta{constructor(t,e){_(this,"noiseCache");_(this,"randomCache");_(this,"random");_(this,"aquiferRandom");_(this,"oreRandom");_(this,"surfaceSystem");_(this,"router");_(this,"sampler");this.seed=e,this.noiseCache=new Map,this.randomCache=new Map,this.random=(t.legacyRandomSource?new at(e):nt.create(e)).forkPositional(),this.aquiferRandom=this.random.fromHashOf(B.create("aquifer").toString()).forkPositional(),this.oreRandom=this.random.fromHashOf(B.create("ore").toString()).forkPositional(),this.surfaceSystem=new js(t.surfaceRule,t.defaultBlock,e),this.router=u.NoiseRouter.mapAll(t.noiseRouter,this.createVisitor(t.noise,t.legacyRandomSource)),this.sampler=u.Climate.Sampler.fromRouter(this.router)}createVisitor(t,e){const r=new Map,i=a=>{const o=a.key();if(o===void 0)throw new Error("Cannot create noise without key");if(e){if(o.equals(B.create("temperature")))return new ie(new at(this.seed+BigInt(0)),u.NoiseParameters.create(-7,[1,1]));if(o.equals(B.create("vegetation")))return new ie(new at(this.seed+BigInt(1)),u.NoiseParameters.create(-7,[1,1]));if(o.equals(B.create("offset")))return new ie(this.random.fromHashOf("offset"),u.NoiseParameters.create(0,[0]))}return this.getOrCreateNoise(o)},s={map:a=>{if(a instanceof W.HolderHolder){const o=a.holder.key();if(o!==void 0&&r.has(o.toString()))return r.get(o.toString());{const m=a.holder.value().mapAll(s);return o!==void 0&&r.set(o.toString(),m),m}}if(a instanceof W.Interpolated)return a.withCellSize(u.NoiseSettings.cellWidth(t),u.NoiseSettings.cellHeight(t));if(a instanceof W.ShiftedNoise)return new W.ShiftedNoise(a.shiftX,a.shiftY,a.shiftZ,a.xzScale,a.yScale,a.noiseData,i(a.noiseData));if(a instanceof W.Noise)return new W.Noise(a.xzScale,a.yScale,a.noiseData,i(a.noiseData));if(a instanceof W.ShiftNoise)return a.withNewNoise(i(a.noiseData));if(a instanceof W.WeirdScaledSampler)return new W.WeirdScaledSampler(a.input,a.rarityValueMapper,a.noiseData,i(a.noiseData));if(a instanceof W.OldBlendedNoise){const o=e?new at(this.seed+BigInt(0)):this.random.fromHashOf(B.create("terrain").toString());return new W.OldBlendedNoise(a.xzScale,a.yScale,a.xzFactor,a.yFactor,a.smearScaleMultiplier,new $s(o,a.xzScale,a.yScale,a.xzFactor,a.yFactor,a.smearScaleMultiplier))}return a instanceof W.EndIslands?new W.EndIslands(this.seed):a instanceof W.Mapped||a instanceof W.Ap2?a.withMinMax():a}};return s}getOrCreateNoise(t){const e=xt.REGISTRY.getOrThrow(B.create("worldgen/noise"));return Ee(this.noiseCache,t.toString(),r=>new ie(this.random.fromHashOf(r),e.getOrThrow(t)))}getOrCreateRandom(t){return Ee(this.randomCache,t.toString(),e=>this.random.fromHashOf(e).forkPositional())}}class Ft{static fromJson(t){var r,i,s,a;const e=(r=u.Json.readObject(t))!=null?r:{};switch((i=u.Json.readString(e.element_type))==null?void 0:i.replace(/^minecraft:/,"")){case"single_pool_element":case"legacy_single_pool_element":const o=B.parse((s=u.Json.readString(e.location))!=null?s:""),m={key:()=>o,value:()=>{var l;return(l=ee.REGISTRY.get(o))!=null?l:ee.EMPTY}};return new Ft.SinlgePoolElement(m);case"list_pool_element":const c=(a=u.Json.readArray("elements",Ft.fromJson))!=null?a:[];return new Ft.ListPoolElement(c);case"feature_pool_element":return new Ft.FeaturePoolElement;case"empty_pool_element":default:return new Ft.EmptyPoolElement}}}(n=>{class t extends n{getBoundingBox(o,m){throw new Error("Invalid call of EmptyPoolElement")}getShuffledJigsawBlocks(o,m){return[]}toString(){return"[Empty Pool Element]"}}n.EmptyPoolElement=t;class e extends n{constructor(){super();_(this,"defaultJigsawNBT");const m=new Map;m.set("name",new vt("minecraft:bottom")),m.set("final_state",new vt("minecraft:air")),m.set("pool",new vt("minecraft:empty")),m.set("target",new vt("minecraft:empty")),m.set("joint",new vt("rollable")),this.defaultJigsawNBT=new mt(m)}getBoundingBox(m,c){return[m,m]}getShuffledJigsawBlocks(m,c){return[{pos:[0,0,0],state:new j(B.create("jigsaw"),{orientation:"down_south"}),nbt:this.defaultJigsawNBT}]}toString(){return"[Feature Pool Element]"}}n.FeaturePoolElement=e;const s=class extends n{constructor(o){super(),this.template=o}getBoundingBox(o,m){const c=u.BlockPos.offset(this.template.value().getSize(),-1,-1,-1),l=o,h=u.BlockPos.add(ee.transform(c,m,u.BlockPos.ZERO),o),d=u.BlockPos.create(Math.min(l[0],h[0]),l[1],Math.min(l[2],h[2])),f=u.BlockPos.create(Math.max(l[0],h[0]),h[1],Math.max(l[2],h[2]));return[d,f]}getShuffledJigsawBlocks(o,m){const c=this.template.value().getBlocks().filter(l=>l.state.getName().equals(s.JIGSAW_ID));return c.forEach(l=>l.pos=ee.transform(l.pos,o,u.BlockPos.ZERO)),Ds(c,m),c}toString(){return`[Single Pool Element: ${this.template.key()}]`}};let r=s;_(r,"JIGSAW_ID",B.parse("jigsaw")),n.SinlgePoolElement=r;class i extends n{constructor(o){super(),this.elements=o}getBoundingBox(o,m){var c=void 0,l=void 0;for(const h of this.elements){const d=h.getBoundingBox(o,m);!c||!l?(c=d[0],l=d[1]):(c[0]=Math.min(c[0],d[0][0]),c[1]=Math.min(c[1],d[0][1]),c[2]=Math.min(c[2],d[0][2]),l[0]=Math.min(c[0],d[1][0]),l[1]=Math.min(c[1],d[1][1]),l[2]=Math.min(c[2],d[1][2]))}return[c,l]}getShuffledJigsawBlocks(o,m){return this.elements[0].getShuffledJigsawBlocks(o,m)}toString(){return`[List Pool Element: ${"; ".concat(...this.elements.map(o=>o.toString()))}]`}}n.ListPoolElement=i})(Ft||(Ft={}));const Ze=class{constructor(t,e){_(this,"totalWeight");this.rawTemplates=t,this.fallback=e,this.totalWeight=t.reduce((r,i)=>r+i.weight,0)}static fromJson(t){var s,a,o;const e=(s=u.Json.readObject(t))!=null?s:{},r=Ze.structurePoolParser((a=e.fallback)!=null?a:""),i=(o=u.Json.readArray(e.elements,m=>{var d,f;const c=(d=u.Json.readObject(m))!=null?d:{},l=Ft.fromJson(c.element),h=(f=u.Json.readInt(c.weight))!=null?f:1;return{element:l,weight:h}}))!=null?o:[];return new Ze(i,r)}getRandomTemplate(t){var e=t.nextInt(this.totalWeight);for(const r of this.rawTemplates)if(e-=r.weight,e<0)return r.element;return this.rawTemplates[this.rawTemplates.length-1].element}};let De=Ze;_(De,"REGISTRY",xt.createAndRegister("worldgen/template_pool",Ze.fromJson)),_(De,"structurePoolParser",u.Holder.parser(Ze.REGISTRY,Ze.fromJson));class dr{constructor(t){this.settings=t}onTopOfChunkCenter(t,e,r,i="WORLD_SURFACE_WG"){const s=(e<<4)+8,a=(r<<4)+8;return[s,t.chunkGenerator.getBaseHeight(s,a,i,t.randomState)-1,a]}getLowestY(t,e,r,i,s){return Math.min(t.chunkGenerator.getBaseHeight(e,r,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(e,r+s,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(e+i,r,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(e+i,r+s,"WORLD_SURFACE_WG",t.randomState)-1)}getLowestYIn5by5BoxOffset7Blocks(t,e,r,i){let s=5,a=5;i===u.Rotation.CLOCKWISE_90?s=-5:i===u.Rotation.CLOCKWISE_180?(s=-5,a=-5):i===u.Rotation.COUNTERCLOCKWISE_90&&(a=-5);const o=(e<<4)+7,m=(r<<4)+7;return u.BlockPos.create(o,this.getLowestY(t,o,m,s,a),m)}tryGenerate(t,e,r){const i=at.fromLargeFeatureSeed(r.seed,t,e),s=this.findGenerationPoint(t,e,i,r);if(s===void 0)return;const a=r.biomeSource.getBiome(s[0]>>2,s[1]>>2,s[2]>>2,r.randomState.sampler);return[...this.settings.validBiomes.getEntries()].findIndex(o=>{var m;return(m=o.key())==null?void 0:m.equals(a)})>=0?s:void 0}}(n=>{n.REGISTRY=xt.createAndRegister("worldgen/structure",i);class t{constructor(I){this.validBiomes=I}}n.StructureSettings=t;class e{constructor(I,x,N,A){_(this,"chunkGenerator");_(this,"randomState");this.seed=I,this.biomeSource=x,this.settings=N,this.levelHeight=A,this.randomState=new ta(N,I),this.chunkGenerator=new Qs(x,N)}}n.GenerationContext=e;const r=u.Holder.parser(De.REGISTRY,De.fromJson);function i(k){var C,L,F;const I=ve.parser(u.WorldgenRegistries.BIOME),x=(C=u.Json.readObject(k))!=null?C:{},N=I(x.biomes),A=new t(N.value());switch((L=u.Json.readString(x.type))==null?void 0:L.replace(/^minecraft:/,"")){case"buried_treasure":return new a(A);case"desert_pyramid":return new m(A);case"end_city":return new c(A);case"fortress":return new l(A);case"igloo":return new h(A);case"jigsaw":const U=u.HeightProvider.fromJson(x.start_height),Y=r(x.start_pool),T=u.Json.readString(x.start_jigsaw_name),J=T?B.parse(T):void 0,G=u.Heightmap.fromJson(x.project_start_to_heightmap),V=s.DimensionPadding.fromJson(x.dimension_padding);return new s(A,Y,U,G,J,V);case"jungle_temple":return new d(A);case"mineshaft":const M=u.Json.readString(x.mineshaft_type)==="mesa"?"mesa":"normal";return new f(A,M);case"nether_fossil":return new l(A);case"ocean_monument":return new v(A);case"ocean_ruin":return new g(A);case"ruined_portal":return new p(A);case"shipwreck":const b=(F=u.Json.readBoolean(x.is_beached))!=null?F:!1;return new S(A,b);case"stronghold":return new E(A);case"swamp_hut":return new y(A);case"woodland_mansion":return new R(A)}return new a(A)}n.fromJson=i;class s extends n{constructor(I,x,N,A,C,L){super(I),this.startingPoolHolder=x,this.startHeight=N,this.projectStartToHeightmap=A,this.startJigsawName=C,this.dimensionPadding=L}findGenerationPoint(I,x,N,A){var C=this.startHeight(N,A.settings.noise);const L=u.BlockPos.create(I<<4,C,x<<4),F=u.Rotation.getRandom(N),Y=this.startingPoolHolder.value().getRandomTemplate(N);if(!(Y instanceof Ft.EmptyPoolElement)){var T;if(this.startJigsawName){const z=s.getRandomNamedJigsaw(Y,this.startJigsawName,F,N);if(z===void 0)return;T=z}else T=u.BlockPos.ZERO;const J=u.BlockPos.subtract(L,T),G=Y.getBoundingBox(J,F),V=(G[1][0]+G[0][0])/2^0,M=(G[1][2]+G[0][2])/2^0;var C;return this.projectStartToHeightmap?C=L[1]+A.chunkGenerator.getBaseHeight(V,M,this.projectStartToHeightmap,A.randomState):C=J[1],G.forEach(z=>z[1]+=C-G[0][1]-1),s.isStartTooCloseToWorldHeightLimits(this.dimensionPadding,G,A.levelHeight)?void 0:u.BlockPos.create(V,C+T[1],M)}}static isStartTooCloseToWorldHeightLimits(I,x,N){if(I===s.DimensionPadding.ZERO)return!1;const A=N.minY+I.bottom,C=N.minY+N.height-I.top;return x[0][1]C}static getRandomNamedJigsaw(I,x,N,A){var L,F;const C=I.getShuffledJigsawBlocks(N,A);for(const U of C)if(B.parse((F=(L=U.nbt)==null?void 0:L.getString("name"))!=null?F:"minecraft:empty").equals(x))return U.pos}}n.JigsawStructure=s,(k=>{const x=class{constructor(A,C){this.top=A,this.bottom=C}static fromJson(A){var L,F,U;if(A===void 0)return x.ZERO;if(typeof A=="number")return new x(A,A);const C=(L=u.Json.readObject(A))!=null?L:{};return new x((F=u.Json.readInt(C.top))!=null?F:0,(U=u.Json.readInt(C.bottom))!=null?U:0)}};let I=x;_(I,"ZERO",new x(0,0)),k.DimensionPadding=I})(s=n.JigsawStructure||(n.JigsawStructure={}));class a extends n{findGenerationPoint(I,x,N,A){return this.onTopOfChunkCenter(A,I,x,"OCEAN_FLOOR_WG")}}n.BuriedTreasureStructure=a;class o extends n{constructor(I,x,N){super(I),this.width=x,this.depth=N}findGenerationPoint(I,x,N,A){if(!(this.getLowestY(A,I<<4,x<<4,this.width,this.depth)o+m.weight,0);for(;s.length>0;){let o=i.nextInt(a),m,c;for([m,c]of s.entries())if(o-=c.weight,o<0)break;const l=c.structure.value().tryGenerate(t,e,r);if(l!==void 0)return{id:c.structure.key(),pos:l};s.splice(m,1),a-=c.weight}}}};let Fe=Ln;_(Fe,"REGISTRY",xt.createAndRegister("worldgen/structure_set",Ln.fromJson)),(n=>{class t{constructor(r,i){this.structure=r,this.weight=i}static fromJson(r){var s,a,o;const i=(s=u.Json.readObject(r))!=null?s:{};return new t(u.Holder.reference(dr.REGISTRY,B.parse((a=u.Json.readString(i.structure))!=null?a:"minecraft:empty")),(o=u.Json.readInt(i.weight))!=null?o:1)}}n.StructureSelectionEntry=t})(Fe||(Fe={}));class Ot{constructor(t,e,r,i,s){this.locateOffset=t,this.frequencyReductionMethod=e,this.frequency=r,this.salt=i,this.exclusionZone=s}static fromJson(t){var c,l,h,d,f,w,v,g,p,S;const e=(c=u.Json.readObject(t))!=null?c:{},r=(l=u.Json.readString(e.type))==null?void 0:l.replace(/^minecraft:/,""),i=u.BlockPos.fromJson(e.locate_offset),s=Ot.FrequencyReducer.fromType((h=u.Json.readString(e.frequency_reduction_method))!=null?h:"default"),a=(d=u.Json.readNumber(e.frequency))!=null?d:1,o=(f=u.Json.readInt(e.salt))!=null?f:0,m="exclusion_zone"in e?Ot.ExclusionZone.fromJson(e.exclusion_zone):void 0;switch(r){case"random_spread":const E=(w=u.Json.readInt(e.spacing))!=null?w:1,y=(v=u.Json.readInt(e.separation))!=null?v:1,R=Ot.SpreadType.fromJson(e.spread_type);return new Ot.RandomSpreadStructurePlacement(i,s,a,o,m,E,y,R);case"concentric_rings":const k=(g=u.Json.readInt(e.distance))!=null?g:1,I=(p=u.Json.readInt(e.spread))!=null?p:1,x=(S=u.Json.readInt(e.count))!=null?S:1,N=ve.parser(u.WorldgenRegistries.BIOME)(e.preferred_biomes);return new Ot.ConcentricRingsStructurePlacement(i,s,a,o,m,k,I,x,N)}return new Ot.RandomSpreadStructurePlacement([0,0,0],Ot.FrequencyReducer.ProbabilityReducer,1,0,void 0,1,1,"linear")}isStructureChunk(t,e,r){return this.isPlacementChunk(t,e,r)?this.frequency<1&&!this.frequencyReductionMethod(t,this.salt,e,r,this.frequency)?!1:!(this.exclusionZone&&this.exclusionZone.isPlacementForbidden(t,e,r)):!1}prepare(t,e,r){}}(n=>{(s=>{function a(h){switch(h){case"legacy_type_1":return l;case"legacy_type_2":return c;case"legacy_type_3":return m;case"default":default:return o}}s.fromType=a;function o(h,d,f,w,v){return at.fromLargeFeatureWithSalt(h,d,f,w).nextFloat()>4,p=w>>4,S=new at(BigInt(g^p<<4)^h);return S.nextInt(),S.nextInt(Math.floor(1/v))===0}s.LegacyPillagerOutpostReducer=l})(n.FrequencyReducer||(n.FrequencyReducer={}));class t{constructor(a,o){this.otherSet=a,this.chunkCount=o}static fromJson(a){var m,c,l;const o=(m=u.Json.readObject(a))!=null?m:{};return new t(u.Holder.reference(Fe.REGISTRY,B.parse((c=u.Json.readString(o.other_set))!=null?c:"")),(l=u.Json.readInt(o.chunk_count))!=null?l:1)}isPlacementForbidden(a,o,m){const c=this.otherSet.value().placement;return c.getPotentialStructureChunks(a,o-this.chunkCount,m-this.chunkCount,o+this.chunkCount,m+this.chunkCount).findIndex(l=>Math.abs(l[0]-o)<=this.chunkCount&&Math.abs(l[1]-m)<=this.chunkCount&&c.isStructureChunk(a,l[0],l[1]))>=0}}n.ExclusionZone=t,(s=>{function a(o){var c;return((c=u.Json.readString(o))!=null?c:"linear")==="triangular"?"triangular":"linear"}s.fromJson=a})(n.SpreadType||(n.SpreadType={}));class e extends n{constructor(a,o,m,c,l,h,d,f){super(a,o,m,c,l),this.spacing=h,this.separation=d,this.spreadType=f}evaluateSpread(a,o){switch(this.spreadType){case"linear":return a.nextInt(o);case"triangular":return Math.floor((a.nextInt(o)+a.nextInt(o))/2)}}getPotentialStructureChunk(a,o,m){const c=Math.floor(o/this.spacing),l=Math.floor(m/this.spacing),h=at.fromLargeFeatureWithSalt(a,c,l,this.salt),d=this.spacing-this.separation,f=this.evaluateSpread(h,d),w=this.evaluateSpread(h,d);return[c*this.spacing+f,l*this.spacing+w]}isPlacementChunk(a,o,m){const[c,l]=this.getPotentialStructureChunk(a,o,m);return c===o&&l===m}getPotentialStructureChunks(a,o,m,c,l){const h=[];for(let d=Math.floor(o/this.spacing)*this.spacing;d<=c;d+=this.spacing)for(let f=Math.floor(m/this.spacing)*this.spacing;f<=l;f+=this.spacing)h.push(this.getPotentialStructureChunk(a,d,f));return h}}n.RandomSpreadStructurePlacement=e;const r=112;class i extends n{constructor(o,m,c,l,h,d,f,w,v){super(o,m,c,l,h);_(this,"positions");this.distance=d,this.spread=f,this.count=w,this.preferredBiomes=v}prepare(o,m,c){if(this.positions!==void 0||(this.positions=[],this.count===0))return;const l=new at(c);var h=l.nextDouble()*Math.PI*2,d=this.spread,f=0,w=0;const v=[...this.preferredBiomes.value().getEntries()].flatMap(p=>{var S;return(S=p.key())!=null?S:[]});for(var g=0;g{const x=u.BiomeSource.findBiomeHorizontal(o,y,0,R,r,N=>v.findIndex(A=>A.equals(N))>=0,k,m);return x?[x.pos[0]>>4,x.pos[2]>>4]:[S,E]};this.positions.push({center:[S,E],real:I}),h+=Math.PI*2/d,w++,w==d&&(f++,w=0,d+=2*d/(f+1),d=Math.min(d,this.count-g),h+=l.nextDouble()*Math.PI*2)}}isPlacementChunk(o,m,c){return this.positions===void 0?(console.warn("trying to access concentric rings placement before position calculation"),!1):this.getPotentialStructureChunks(o,m,c,m,c).findIndex(l=>l[0]===m&&l[1]===c)>=0}getPotentialStructureChunks(o,m,c,l,h){if(this.positions===void 0)return console.warn("trying to access concentric rings placement before position calculation"),[];const d=[];for(const f of this.positions)f.center[0]>4)||f.center[0]>l+(r>>4)||f.center[1]>4)||f.center[1]>h+(r>>4)||(f.real instanceof Function&&(f.real=f.real()),d.push(f.real));return d}}n.ConcentricRingsStructurePlacement=i})(Ot||(Ot={})),u.BlendedNoise=$s,u.BlockColors=Oe,u.BlockDefinition=ei,u.BlockModel=ot,u.BlockState=j,u.CheckerboardBiomeSource=hr,u.Chunk=il,u.ChunkBuilder=Ws,u.ChunkSection=We,u.DensityFunction=W,u.EFFECT_COLORS=Bs,u.FixedBiomeSource=Ke,u.FluidStatus=Bn,u.HolderSet=ve,u.Identifier=B,u.ImprovedNoise=ti,u.ItemRenderer=ur,u.ItemStack=$t,u.LegacyPositionalRandom=Gs,u.LegacyRandom=at,u.Line=cr,u.Matrix3=Rn,u.Matrix4=ar,u.Mesh=it,u.MultiNoiseBiomeSource=fr,u.NbtAbstractList=In,u.NbtByte=Bt,u.NbtByteArray=me,u.NbtChunk=Qt,u.NbtCompound=mt,u.NbtDouble=te,u.NbtEnd=kn,u.NbtFile=Vt,u.NbtFloat=Be,u.NbtInt=Dt,u.NbtIntArray=ge,u.NbtList=Tt,u.NbtLong=Te,u.NbtLongArray=we,u.NbtRegion=pe,u.NbtShort=Le,u.NbtString=vt,u.NbtTag=et,u.NbtType=D,u.NoiseAquifer=ze,u.NoiseChunk=ii,u.NoiseChunkGenerator=Qs,u.NormalNoise=ie,u.POTION_EFFECTS=Ts,u.PalettedContainer=Cs,u.PerlinNoise=pt,u.PerlinSimplexNoise=Yl,u.Quad=qt,u.RandomState=ta,u.RawDataInput=ci,u.RawDataOutput=li,u.Registry=xt,u.Renderer=lr,u.ShaderProgram=Nn,u.SimplexNoise=wt,u.StringReader=Et,u.Structure=ee,u.StructurePlacement=Ot,u.StructurePoolElement=Ft,u.StructureRenderer=ou,u.StructureSet=Fe,u.StructureTemplatePool=De,u.SurfaceContext=Ks,u.SurfaceSystem=js,u.TextureAtlas=Cn,u.Vector=q,u.Vertex=Pt,u.VoxelRenderer=uu,u.WorldgenStructure=dr,u.XoroshiroPositionalRandom=Vs,u.XoroshiroRandom=nt,u.binarySearch=Js,u.clamp=_t,u.clampedLerp=tr,u.clampedMap=$r,u.computeIfAbsent=Ee,u.floatLerp=Zr,u.getSeed=Yr,u.intFloor=Yt,u.inverseLerp=Vr,u.isPowerOfTwo=qr,u.jsonToNbt=Hr,u.lazy=sn,u.lazyLerp=An,u.lazyLerp2=Gr,u.lazyLerp3=Ps,u.lerp=Pe,u.lerp2=Qn,u.lerp3=Ls,u.longFloor=Os,u.longfromBytes=nr,u.map=Mn,u.mutateWithDefault=wr,u.nextInt=ir,u.randomBetweenInclusive=rr,u.shuffle=Ds,u.smoothstep=er,u.square=ne,u.upperPowerOfTwo=zs,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});