mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-04-22 21:05:46 +00:00
528 lines
No EOL
527 KiB
JavaScript
528 lines
No EOL
527 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,38360,(e,t,r)=>{var a={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ả:"A",Ạ:"A",Ẩ:"A",Ẫ:"A",Ậ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ẻ:"E",Ẽ:"E",Ẹ:"E",Ể:"E",Ễ:"E",Ệ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ỉ:"I",Ị:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ỏ:"O",Ọ:"O",Ổ:"O",Ỗ:"O",Ộ:"O",Ờ:"O",Ở:"O",Ỡ:"O",Ớ:"O",Ợ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ủ:"U",Ụ:"U",Ử:"U",Ữ:"U",Ự:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ả:"a",ạ:"a",ẩ:"a",ẫ:"a",ậ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ẻ:"e",ẽ:"e",ẹ:"e",ể:"e",ễ:"e",ệ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ỉ:"i",ị:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",ố:"o",ṍ:"o",ṓ:"o",ȏ:"o",ỏ:"o",ọ:"o",ổ:"o",ỗ:"o",ộ:"o",ờ:"o",ở:"o",ỡ:"o",ớ:"o",ợ:"o",ù:"u",ú:"u",û:"u",ü:"u",ủ:"u",ụ:"u",ử:"u",ữ:"u",ự:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",C̆:"C",c̆:"c",Ď:"D",ď:"d",Đ:"D",đ:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",Ǵ:"G",ĝ:"g",ǵ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ħ:"H",ħ:"h",Ḫ:"H",ḫ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",ı:"i",IJ:"IJ",ij:"ij",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ḱ:"K",ḱ:"k",K̆:"K",k̆:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ŀ:"L",ŀ:"l",Ł:"l",ł:"l",Ḿ:"M",ḿ:"m",M̆:"M",m̆:"m",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",ʼn:"n",N̆:"N",n̆:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Œ:"OE",œ:"oe",P̆:"P",p̆:"p",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",R̆:"R",r̆:"r",Ȓ:"R",ȓ:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",Ș:"S",ș:"s",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",ț:"t",Ț:"T",Ť:"T",ť:"t",Ŧ:"T",ŧ:"t",T̆:"T",t̆:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ȗ:"U",ȗ:"u",V̆:"V",v̆:"v",Ŵ:"W",ŵ:"w",Ẃ:"W",ẃ:"w",X̆:"X",x̆:"x",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Y̆:"Y",y̆:"y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",ſ:"s",ƒ:"f",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ứ:"U",ứ:"u",Ṹ:"U",ṹ:"u",Ǻ:"A",ǻ:"a",Ǽ:"AE",ǽ:"ae",Ǿ:"O",ǿ:"o",Þ:"TH",þ:"th",Ṕ:"P",ṕ:"p",Ṥ:"S",ṥ:"s",X́:"X",x́:"x",Ѓ:"Г",ѓ:"г",Ќ:"К",ќ:"к",A̋:"A",a̋:"a",E̋:"E",e̋:"e",I̋:"I",i̋:"i",Ǹ:"N",ǹ:"n",Ồ:"O",ồ:"o",Ṑ:"O",ṑ:"o",Ừ:"U",ừ:"u",Ẁ:"W",ẁ:"w",Ỳ:"Y",ỳ:"y",Ȁ:"A",ȁ:"a",Ȅ:"E",ȅ:"e",Ȉ:"I",ȉ:"i",Ȍ:"O",ȍ:"o",Ȑ:"R",ȑ:"r",Ȕ:"U",ȕ:"u",B̌:"B",b̌:"b",Č̣:"C",č̣:"c",Ê̌:"E",ê̌:"e",F̌:"F",f̌:"f",Ǧ:"G",ǧ:"g",Ȟ:"H",ȟ:"h",J̌:"J",ǰ:"j",Ǩ:"K",ǩ:"k",M̌:"M",m̌:"m",P̌:"P",p̌:"p",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z",й:"и",Й:"И",ё:"е",Ё:"Е"},n=Object.keys(a).join("|"),i=RegExp(n,"g"),o=RegExp(n,"");function s(e){return a[e]}var l=function(e){return e.replace(i,s)};t.exports=l,t.exports.has=function(e){return!!e.match(o)},t.exports.remove=l},29402,(e,t,r)=>{var a,n,i,o,s="__lodash_hash_undefined__",l=1/0,u="[object Arguments]",c="[object Array]",d="[object Boolean]",f="[object Date]",h="[object Error]",m="[object Function]",p="[object Map]",g="[object Number]",v="[object Object]",y="[object Promise]",A="[object RegExp]",F="[object Set]",b="[object String]",C="[object Symbol]",B="[object WeakMap]",S="[object ArrayBuffer]",x="[object DataView]",E=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,M=/^\w*$/,D=/^\./,k=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,w=/\\(\\)?/g,I=/^\[object .+?Constructor\]$/,T=/^(?:0|[1-9]\d*)$/,R={};R["[object Float32Array]"]=R["[object Float64Array]"]=R["[object Int8Array]"]=R["[object Int16Array]"]=R["[object Int32Array]"]=R["[object Uint8Array]"]=R["[object Uint8ClampedArray]"]=R["[object Uint16Array]"]=R["[object Uint32Array]"]=!0,R[u]=R[c]=R[S]=R[d]=R[x]=R[f]=R[h]=R[m]=R[p]=R[g]=R[v]=R[A]=R[F]=R[b]=R[B]=!1;var P=e.g&&e.g.Object===Object&&e.g,G="object"==typeof self&&self&&self.Object===Object&&self,L=P||G||Function("return this")(),j=r&&!r.nodeType&&r,_=j&&t&&!t.nodeType&&t,O=_&&_.exports===j&&P.process,U=function(){try{return O&&O.binding("util")}catch(e){}}(),H=U&&U.isTypedArray;function N(e,t){for(var r=-1,a=e?e.length:0,n=Array(a);++r<a;)n[r]=t(e[r],r,e);return n}function J(e){return function(t){return e(t)}}function K(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function V(e){var t=-1,r=Array(e.size);return e.forEach(function(e,a){r[++t]=[a,e]}),r}function z(e){var t=-1,r=Array(e.size);return e.forEach(function(e){r[++t]=e}),r}var q=Array.prototype,Q=Function.prototype,W=Object.prototype,X=L["__core-js_shared__"],Y=(n=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Z=Q.toString,$=W.hasOwnProperty,ee=W.toString,et=RegExp("^"+Z.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),er=L.Symbol,ea=L.Uint8Array,en=W.propertyIsEnumerable,ei=q.splice,eo=(i=Object.keys,o=Object,function(e){return i(o(e))}),es=eG(L,"DataView"),el=eG(L,"Map"),eu=eG(L,"Promise"),ec=eG(L,"Set"),ed=eG(L,"WeakMap"),ef=eG(Object,"create"),eh=eN(es),em=eN(el),ep=eN(eu),eg=eN(ec),ev=eN(ed),ey=er?er.prototype:void 0,eA=ey?ey.valueOf:void 0,eF=ey?ey.toString:void 0;function eb(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}function eC(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}function eB(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}function eS(e){var t=-1,r=e?e.length:0;for(this.__data__=new eB;++t<r;)this.add(e[t])}function ex(e){this.__data__=new eC(e)}function eE(e,t){for(var r=e.length;r--;)if(eK(e[r][0],t))return r;return -1}eb.prototype.clear=function(){this.__data__=ef?ef(null):{}},eb.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},eb.prototype.get=function(e){var t=this.__data__;if(ef){var r=t[e];return r===s?void 0:r}return $.call(t,e)?t[e]:void 0},eb.prototype.has=function(e){var t=this.__data__;return ef?void 0!==t[e]:$.call(t,e)},eb.prototype.set=function(e,t){return this.__data__[e]=ef&&void 0===t?s:t,this},eC.prototype.clear=function(){this.__data__=[]},eC.prototype.delete=function(e){var t=this.__data__,r=eE(t,e);return!(r<0)&&(r==t.length-1?t.pop():ei.call(t,r,1),!0)},eC.prototype.get=function(e){var t=this.__data__,r=eE(t,e);return r<0?void 0:t[r][1]},eC.prototype.has=function(e){return eE(this.__data__,e)>-1},eC.prototype.set=function(e,t){var r=this.__data__,a=eE(r,e);return a<0?r.push([e,t]):r[a][1]=t,this},eB.prototype.clear=function(){this.__data__={hash:new eb,map:new(el||eC),string:new eb}},eB.prototype.delete=function(e){return eP(this,e).delete(e)},eB.prototype.get=function(e){return eP(this,e).get(e)},eB.prototype.has=function(e){return eP(this,e).has(e)},eB.prototype.set=function(e,t){return eP(this,e).set(e,t),this},eS.prototype.add=eS.prototype.push=function(e){return this.__data__.set(e,s),this},eS.prototype.has=function(e){return this.__data__.has(e)},ex.prototype.clear=function(){this.__data__=new eC},ex.prototype.delete=function(e){return this.__data__.delete(e)},ex.prototype.get=function(e){return this.__data__.get(e)},ex.prototype.has=function(e){return this.__data__.has(e)},ex.prototype.set=function(e,t){var r=this.__data__;if(r instanceof eC){var a=r.__data__;if(!el||a.length<199)return a.push([e,t]),this;r=this.__data__=new eB(a)}return r.set(e,t),this};var eM=(a=function(e,t){return e&&eD(e,t,e0)},function(e,t){if(null==e)return e;if(!eq(e))return a(e,t);for(var r=e.length,n=-1,i=Object(e);++n<r&&!1!==t(i[n],n,i););return e}),eD=function(e,t,r){for(var a=-1,n=Object(e),i=r(e),o=i.length;o--;){var s=i[++a];if(!1===t(n[s],s,n))break}return e};function ek(e,t){var r;t=e_(t,e)?[t]:ez(r=t)?r:eU(r);for(var a=0,n=t.length;null!=e&&a<n;)e=e[eH(t[a++])];return a&&a==n?e:void 0}function ew(e,t){return null!=e&&t in Object(e)}function eI(e,t,r,a,n){return e===t||(null!=e&&null!=t&&(eX(e)||eY(t))?function(e,t,r,a,n,i){var o=ez(e),s=ez(t),l=c,m=c;o||(l=(l=eL(e))==u?v:l),s||(m=(m=eL(t))==u?v:m);var y=l==v&&!K(e),B=m==v&&!K(t),E=l==m;if(E&&!y)return i||(i=new ex),o||e$(e)?eR(e,t,r,a,n,i):function(e,t,r,a,n,i,o){switch(r){case x:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case S:if(e.byteLength!=t.byteLength||!a(new ea(e),new ea(t)))break;return!0;case d:case f:case g:return eK(+e,+t);case h:return e.name==t.name&&e.message==t.message;case A:case b:return e==t+"";case p:var s=V;case F:var l=2&i;if(s||(s=z),e.size!=t.size&&!l)break;var u=o.get(e);if(u)return u==t;i|=1,o.set(e,t);var c=eR(s(e),s(t),a,n,i,o);return o.delete(e),c;case C:if(eA)return eA.call(e)==eA.call(t)}return!1}(e,t,l,r,a,n,i);if(!(2&n)){var M=y&&$.call(e,"__wrapped__"),D=B&&$.call(t,"__wrapped__");if(M||D){var k=M?e.value():e,w=D?t.value():t;return i||(i=new ex),r(k,w,a,n,i)}}return!!E&&(i||(i=new ex),function(e,t,r,a,n,i){var o=2&n,s=e0(e),l=s.length;if(l!=e0(t).length&&!o)return!1;for(var u=l;u--;){var c=s[u];if(!(o?c in t:$.call(t,c)))return!1}var d=i.get(e);if(d&&i.get(t))return d==t;var f=!0;i.set(e,t),i.set(t,e);for(var h=o;++u<l;){var m=e[c=s[u]],p=t[c];if(a)var g=o?a(p,m,c,t,e,i):a(m,p,c,e,t,i);if(!(void 0===g?m===p||r(m,p,a,n,i):g)){f=!1;break}h||(h="constructor"==c)}if(f&&!h){var v=e.constructor,y=t.constructor;v!=y&&"constructor"in e&&"constructor"in t&&!("function"==typeof v&&v instanceof v&&"function"==typeof y&&y instanceof y)&&(f=!1)}return i.delete(e),i.delete(t),f}(e,t,r,a,n,i))}(e,t,eI,r,a,n):e!=e&&t!=t)}function eT(e){var t,r,a,n;return"function"==typeof e?e:null==e?e1:"object"==typeof e?ez(e)?(t=e[0],r=e[1],e_(t)&&function(e){return e==e&&!eX(e)}(r)?eO(eH(t),r):function(e){var a,n,i,o,s,l=(a=e,n=t,void 0===(i=null==a?void 0:ek(a,n))?void 0:i);return void 0===l&&l===r?(o=e,s=t,null!=o&&function(e,t,r){t=e_(t,e)?[t]:ez(a=t)?a:eU(a);for(var a,n,i=-1,o=t.length;++i<o;){var s=eH(t[i]);if(!(n=null!=e&&r(e,s)))break;e=e[s]}if(n)return n;var o=e?e.length:0;return!!o&&eW(o)&&ej(s,o)&&(ez(e)||eV(e))}(o,s,ew)):eI(r,l,void 0,3)}):1==(n=function(e){for(var t=e0(e),r=t.length;r--;){var a=t[r],n=e[a];t[r]=[a,n,function(e){return e==e&&!eX(e)}(n)]}return t}(a=e)).length&&n[0][2]?eO(n[0][0],n[0][1]):function(e){return e===a||function(e,t,r,a){var n=r.length,i=n;if(null==e)return!i;for(e=Object(e);n--;){var o=r[n];if((0,o[2])?o[1]!==e[o[0]]:!(o[0]in e))return!1}for(;++n<i;){var s=(o=r[n])[0],l=e[s],u=o[1];if(0,o[2]){if(void 0===l&&!(s in e))return!1}else{var c,d=new ex;if(!(void 0===c?eI(u,l,void 0,3,d):c))return!1}}return!0}(e,0,n)}:function(e){var t;return e_(e)?(t=eH(e),function(e){return null==e?void 0:e[t]}):function(t){return ek(t,e)}}(e)}function eR(e,t,r,a,n,i){var o=2&n,s=e.length,l=t.length;if(s!=l&&!(o&&l>s))return!1;var u=i.get(e);if(u&&i.get(t))return u==t;var c=-1,d=!0,f=1&n?new eS:void 0;for(i.set(e,t),i.set(t,e);++c<s;){var h=e[c],m=t[c];if(a)var p=o?a(m,h,c,t,e,i):a(h,m,c,e,t,i);if(void 0!==p){if(p)continue;d=!1;break}if(f){if(!function(e,t){for(var r=-1,a=e?e.length:0;++r<a;)if(t(e[r],r,e))return!0;return!1}(t,function(e,t){if(!f.has(t)&&(h===e||r(h,e,a,n,i)))return f.add(t)})){d=!1;break}}else if(!(h===m||r(h,m,a,n,i))){d=!1;break}}return i.delete(e),i.delete(t),d}function eP(e,t){var r,a,n=e.__data__;return("string"==(a=typeof(r=t))||"number"==a||"symbol"==a||"boolean"==a?"__proto__"!==r:null===r)?n["string"==typeof t?"string":"hash"]:n.map}function eG(e,t){var r,a=null==e?void 0:e[t];return!(!eX(a)||(r=a,Y&&Y in r))&&(eQ(a)||K(a)?et:I).test(eN(a))?a:void 0}var eL=function(e){return ee.call(e)};function ej(e,t){return!!(t=null==t?0x1fffffffffffff:t)&&("number"==typeof e||T.test(e))&&e>-1&&e%1==0&&e<t}function e_(e,t){if(ez(e))return!1;var r=typeof e;return!!("number"==r||"symbol"==r||"boolean"==r||null==e||eZ(e))||M.test(e)||!E.test(e)||null!=t&&e in Object(t)}function eO(e,t){return function(r){return null!=r&&r[e]===t&&(void 0!==t||e in Object(r))}}(es&&eL(new es(new ArrayBuffer(1)))!=x||el&&eL(new el)!=p||eu&&eL(eu.resolve())!=y||ec&&eL(new ec)!=F||ed&&eL(new ed)!=B)&&(eL=function(e){var t=ee.call(e),r=t==v?e.constructor:void 0,a=r?eN(r):void 0;if(a)switch(a){case eh:return x;case em:return p;case ep:return y;case eg:return F;case ev:return B}return t});var eU=eJ(function(e){e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(eZ(e))return eF?eF.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}(t);var t,r=[];return D.test(e)&&r.push(""),e.replace(k,function(e,t,a,n){r.push(a?n.replace(w,"$1"):t||e)}),r});function eH(e){if("string"==typeof e||eZ(e))return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}function eN(e){if(null!=e){try{return Z.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function eJ(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw TypeError("Expected a function");var r=function(){var a=arguments,n=t?t.apply(this,a):a[0],i=r.cache;if(i.has(n))return i.get(n);var o=e.apply(this,a);return r.cache=i.set(n,o),o};return r.cache=new(eJ.Cache||eB),r}function eK(e,t){return e===t||e!=e&&t!=t}function eV(e){var t;return eY(t=e)&&eq(t)&&$.call(e,"callee")&&(!en.call(e,"callee")||ee.call(e)==u)}eJ.Cache=eB;var ez=Array.isArray;function eq(e){return null!=e&&eW(e.length)&&!eQ(e)}function eQ(e){var t=eX(e)?ee.call(e):"";return t==m||"[object GeneratorFunction]"==t}function eW(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=0x1fffffffffffff}function eX(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function eY(e){return!!e&&"object"==typeof e}function eZ(e){return"symbol"==typeof e||eY(e)&&ee.call(e)==C}var e$=H?J(H):function(e){return eY(e)&&eW(e.length)&&!!R[ee.call(e)]};function e0(e){return eq(e)?function(e,t){var r=ez(e)||eV(e)?function(e,t){for(var r=-1,a=Array(e);++r<e;)a[r]=t(r);return a}(e.length,String):[],a=r.length,n=!!a;for(var i in e)$.call(e,i)&&!(n&&("length"==i||ej(i,a)))&&r.push(i);return r}(e):function(e){if(r=(t=e)&&t.constructor,t!==("function"==typeof r&&r.prototype||W))return eo(e);var t,r,a=[];for(var n in Object(e))$.call(e,n)&&"constructor"!=n&&a.push(n);return a}(e)}function e1(e){return e}t.exports=function(e,t,r,a){return null==e?[]:(ez(t)||(t=null==t?[]:[t]),ez(r=a?void 0:r)||(r=null==r?[]:[r]),function(e,t,r){var a,n,i,o=-1;t=N(t.length?t:[e1],J(eT));var s=(a=function(e,r,a){return{criteria:N(t,function(t){return t(e)}),index:++o,value:e}},n=-1,i=eq(e)?Array(e.length):[],eM(e,function(e,t,r){i[++n]=a(e,t,r)}),i),l=s.length;for(s.sort(function(e,t){return function(e,t,r){for(var a=-1,n=e.criteria,i=t.criteria,o=n.length,s=r.length;++a<o;){var l=function(e,t){if(e!==t){var r=void 0!==e,a=null===e,n=e==e,i=eZ(e),o=void 0!==t,s=null===t,l=t==t,u=eZ(t);if(!s&&!u&&!i&&e>t||i&&o&&l&&!s&&!u||a&&o&&l||!r&&l||!n)return 1;if(!a&&!i&&!u&&e<t||u&&r&&n&&!a&&!i||s&&r&&n||!o&&n||!l)return -1}return 0}(n[a],i[a]);if(l){if(a>=s)return l;return l*("desc"==r[a]?-1:1)}}return e.index-t.index}(e,t,r)});l--;)s[l]=s[l].value;return s}(e,t,r))}},76775,(e,t,r)=>{function a(e,t,r,a){return Math.round(e/r)+" "+a+(t>=1.5*r?"s":"")}t.exports=function(e,t){t=t||{};var r,n,i,o,s=typeof e;if("string"===s&&e.length>0){var l=e;if(!((l=String(l)).length>100)){var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(u){var c=parseFloat(u[1]);switch((u[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*c;case"weeks":case"week":case"w":return 6048e5*c;case"days":case"day":case"d":return 864e5*c;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*c;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*c;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:break}}}return}if("number"===s&&isFinite(e)){return t.long?(n=Math.abs(r=e))>=864e5?a(r,n,864e5,"day"):n>=36e5?a(r,n,36e5,"hour"):n>=6e4?a(r,n,6e4,"minute"):n>=1e3?a(r,n,1e3,"second"):r+" ms":(o=Math.abs(i=e))>=864e5?Math.round(i/864e5)+"d":o>=36e5?Math.round(i/36e5)+"h":o>=6e4?Math.round(i/6e4)+"m":o>=1e3?Math.round(i/1e3)+"s":i+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},7003,(e,t,r)=>{t.exports=function(t){function r(e){let t,n,i,o=null;function s(...e){if(!s.enabled)return;let a=Number(new Date);s.diff=a-(t||a),s.prev=t,s.curr=a,t=a,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let n=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,a)=>{if("%%"===t)return"%";n++;let i=r.formatters[a];if("function"==typeof i){let r=e[n];t=i.call(s,r),e.splice(n,1),n--}return t}),r.formatArgs.call(s,e),(s.log||r.log).apply(s,e)}return s.namespace=e,s.useColors=r.useColors(),s.color=r.selectColor(e),s.extend=a,s.destroy=r.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==r.namespaces&&(n=r.namespaces,i=r.enabled(e)),i),set:e=>{o=e}}),"function"==typeof r.init&&r.init(s),s}function a(e,t){let a=r(this.namespace+(void 0===t?":":t)+e);return a.log=this.log,a}function n(e,t){let r=0,a=0,n=-1,i=0;for(;r<e.length;)if(a<t.length&&(t[a]===e[r]||"*"===t[a]))"*"===t[a]?(n=a,i=r):r++,a++;else{if(-1===n)return!1;a=n+1,r=++i}for(;a<t.length&&"*"===t[a];)a++;return a===t.length}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){let e=[...r.names,...r.skips.map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){for(let t of(r.save(e),r.namespaces=e,r.names=[],r.skips=[],("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean)))"-"===t[0]?r.skips.push(t.slice(1)):r.names.push(t)},r.enabled=function(e){for(let t of r.skips)if(n(e,t))return!1;for(let t of r.names)if(n(e,t))return!0;return!1},r.humanize=e.r(76775),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(e=>{r[e]=t[e]}),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return r.colors[Math.abs(t)%r.colors.length]},r.enable(r.load()),r}},48450,(e,t,r)=>{let a;var n=e.i(47167);r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;let r="color: "+this.color;e.splice(1,0,r,"color: inherit");let a=0,n=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(a++,"%c"===e&&(n=a))}),e.splice(n,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")||r.storage.getItem("DEBUG")}catch(e){}return!e&&void 0!==n.default&&"env"in n.default&&(e=n.default.env.DEBUG),e},r.useColors=function(){let e;return"undefined"!=typeof window&&!!window.process&&("renderer"===window.process.type||!!window.process.__nwjs)||!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},r.storage=function(){try{return localStorage}catch(e){}}(),a=!1,r.destroy=()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))},r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e.r(7003)(r);let{formatters:i}=t.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},81405,(e,t,r)=>{var a;e.e,(a=function(){function e(e){return n.appendChild(e.dom),e}function t(e){for(var t=0;t<n.children.length;t++)n.children[t].style.display=t===e?"block":"none";r=e}var r=0,n=document.createElement("div");n.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",n.addEventListener("click",function(e){e.preventDefault(),t(++r%n.children.length)},!1);var i=(performance||Date).now(),o=i,s=0,l=e(new a.Panel("FPS","#0ff","#002")),u=e(new a.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=e(new a.Panel("MB","#f08","#201"));return t(0),{REVISION:16,dom:n,addPanel:e,showPanel:t,begin:function(){i=(performance||Date).now()},end:function(){s++;var e=(performance||Date).now();if(u.update(e-i,200),e>o+1e3&&(l.update(1e3*s/(e-o),100),o=e,s=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){i=this.end()},domElement:n,setMode:t}}).Panel=function(e,t,r){var a=1/0,n=0,i=Math.round,o=i(window.devicePixelRatio||1),s=80*o,l=48*o,u=3*o,c=2*o,d=3*o,f=15*o,h=74*o,m=30*o,p=document.createElement("canvas");p.width=s,p.height=l,p.style.cssText="width:80px;height:48px";var g=p.getContext("2d");return g.font="bold "+9*o+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=r,g.fillRect(0,0,s,l),g.fillStyle=t,g.fillText(e,u,c),g.fillRect(d,f,h,m),g.fillStyle=r,g.globalAlpha=.9,g.fillRect(d,f,h,m),{dom:p,update:function(l,v){a=Math.min(a,l),n=Math.max(n,l),g.fillStyle=r,g.globalAlpha=1,g.fillRect(0,0,s,f),g.fillStyle=t,g.fillText(i(l)+" "+e+" ("+i(a)+"-"+i(n)+")",u,c),g.drawImage(p,d+o,f,h-o,m,d,f,h-o,m),g.fillRect(d+h-o,f,o,m),g.fillStyle=r,g.globalAlpha=.9,g.fillRect(d+h-o,f,o,i((1-l/v)*m))}}},t.exports=a},75840,e=>{e.v({Bar:"PlayerHUD-module__-E1Scq__Bar",BarFill:"PlayerHUD-module__-E1Scq__BarFill",ChatWindow:"PlayerHUD-module__-E1Scq__ChatWindow",EnergyBar:"PlayerHUD-module__-E1Scq__EnergyBar PlayerHUD-module__-E1Scq__Bar",HealthBar:"PlayerHUD-module__-E1Scq__HealthBar PlayerHUD-module__-E1Scq__Bar",PlayerHUD:"PlayerHUD-module__-E1Scq__PlayerHUD"})},31713,e=>{"use strict";let t;var r,a,n=e.i(43476),i=e.i(932),o=e.i(71645),s=e.i(91037),l=e.i(8560),u=e.i(90072);e.s(["ACESFilmicToneMapping",()=>u.ACESFilmicToneMapping,"AddEquation",()=>u.AddEquation,"AddOperation",()=>u.AddOperation,"AdditiveAnimationBlendMode",()=>u.AdditiveAnimationBlendMode,"AdditiveBlending",()=>u.AdditiveBlending,"AgXToneMapping",()=>u.AgXToneMapping,"AlphaFormat",()=>u.AlphaFormat,"AlwaysCompare",()=>u.AlwaysCompare,"AlwaysDepth",()=>u.AlwaysDepth,"AlwaysStencilFunc",()=>u.AlwaysStencilFunc,"AmbientLight",()=>u.AmbientLight,"AnimationAction",()=>u.AnimationAction,"AnimationClip",()=>u.AnimationClip,"AnimationLoader",()=>u.AnimationLoader,"AnimationMixer",()=>u.AnimationMixer,"AnimationObjectGroup",()=>u.AnimationObjectGroup,"AnimationUtils",()=>u.AnimationUtils,"ArcCurve",()=>u.ArcCurve,"ArrayCamera",()=>u.ArrayCamera,"ArrowHelper",()=>u.ArrowHelper,"AttachedBindMode",()=>u.AttachedBindMode,"Audio",()=>u.Audio,"AudioAnalyser",()=>u.AudioAnalyser,"AudioContext",()=>u.AudioContext,"AudioListener",()=>u.AudioListener,"AudioLoader",()=>u.AudioLoader,"AxesHelper",()=>u.AxesHelper,"BackSide",()=>u.BackSide,"BasicDepthPacking",()=>u.BasicDepthPacking,"BasicShadowMap",()=>u.BasicShadowMap,"BatchedMesh",()=>u.BatchedMesh,"Bone",()=>u.Bone,"BooleanKeyframeTrack",()=>u.BooleanKeyframeTrack,"Box2",()=>u.Box2,"Box3",()=>u.Box3,"Box3Helper",()=>u.Box3Helper,"BoxGeometry",()=>u.BoxGeometry,"BoxHelper",()=>u.BoxHelper,"BufferAttribute",()=>u.BufferAttribute,"BufferGeometry",()=>u.BufferGeometry,"BufferGeometryLoader",()=>u.BufferGeometryLoader,"ByteType",()=>u.ByteType,"Cache",()=>u.Cache,"Camera",()=>u.Camera,"CameraHelper",()=>u.CameraHelper,"CanvasTexture",()=>u.CanvasTexture,"CapsuleGeometry",()=>u.CapsuleGeometry,"CatmullRomCurve3",()=>u.CatmullRomCurve3,"CineonToneMapping",()=>u.CineonToneMapping,"CircleGeometry",()=>u.CircleGeometry,"ClampToEdgeWrapping",()=>u.ClampToEdgeWrapping,"Clock",()=>u.Clock,"Color",()=>u.Color,"ColorKeyframeTrack",()=>u.ColorKeyframeTrack,"ColorManagement",()=>u.ColorManagement,"CompressedArrayTexture",()=>u.CompressedArrayTexture,"CompressedCubeTexture",()=>u.CompressedCubeTexture,"CompressedTexture",()=>u.CompressedTexture,"CompressedTextureLoader",()=>u.CompressedTextureLoader,"ConeGeometry",()=>u.ConeGeometry,"ConstantAlphaFactor",()=>u.ConstantAlphaFactor,"ConstantColorFactor",()=>u.ConstantColorFactor,"Controls",()=>u.Controls,"CubeCamera",()=>u.CubeCamera,"CubeDepthTexture",()=>u.CubeDepthTexture,"CubeReflectionMapping",()=>u.CubeReflectionMapping,"CubeRefractionMapping",()=>u.CubeRefractionMapping,"CubeTexture",()=>u.CubeTexture,"CubeTextureLoader",()=>u.CubeTextureLoader,"CubeUVReflectionMapping",()=>u.CubeUVReflectionMapping,"CubicBezierCurve",()=>u.CubicBezierCurve,"CubicBezierCurve3",()=>u.CubicBezierCurve3,"CubicInterpolant",()=>u.CubicInterpolant,"CullFaceBack",()=>u.CullFaceBack,"CullFaceFront",()=>u.CullFaceFront,"CullFaceFrontBack",()=>u.CullFaceFrontBack,"CullFaceNone",()=>u.CullFaceNone,"Curve",()=>u.Curve,"CurvePath",()=>u.CurvePath,"CustomBlending",()=>u.CustomBlending,"CustomToneMapping",()=>u.CustomToneMapping,"CylinderGeometry",()=>u.CylinderGeometry,"Cylindrical",()=>u.Cylindrical,"Data3DTexture",()=>u.Data3DTexture,"DataArrayTexture",()=>u.DataArrayTexture,"DataTexture",()=>u.DataTexture,"DataTextureLoader",()=>u.DataTextureLoader,"DataUtils",()=>u.DataUtils,"DecrementStencilOp",()=>u.DecrementStencilOp,"DecrementWrapStencilOp",()=>u.DecrementWrapStencilOp,"DefaultLoadingManager",()=>u.DefaultLoadingManager,"DepthFormat",()=>u.DepthFormat,"DepthStencilFormat",()=>u.DepthStencilFormat,"DepthTexture",()=>u.DepthTexture,"DetachedBindMode",()=>u.DetachedBindMode,"DirectionalLight",()=>u.DirectionalLight,"DirectionalLightHelper",()=>u.DirectionalLightHelper,"DiscreteInterpolant",()=>u.DiscreteInterpolant,"DodecahedronGeometry",()=>u.DodecahedronGeometry,"DoubleSide",()=>u.DoubleSide,"DstAlphaFactor",()=>u.DstAlphaFactor,"DstColorFactor",()=>u.DstColorFactor,"DynamicCopyUsage",()=>u.DynamicCopyUsage,"DynamicDrawUsage",()=>u.DynamicDrawUsage,"DynamicReadUsage",()=>u.DynamicReadUsage,"EdgesGeometry",()=>u.EdgesGeometry,"EllipseCurve",()=>u.EllipseCurve,"EqualCompare",()=>u.EqualCompare,"EqualDepth",()=>u.EqualDepth,"EqualStencilFunc",()=>u.EqualStencilFunc,"EquirectangularReflectionMapping",()=>u.EquirectangularReflectionMapping,"EquirectangularRefractionMapping",()=>u.EquirectangularRefractionMapping,"Euler",()=>u.Euler,"EventDispatcher",()=>u.EventDispatcher,"ExternalTexture",()=>u.ExternalTexture,"ExtrudeGeometry",()=>u.ExtrudeGeometry,"FileLoader",()=>u.FileLoader,"Float16BufferAttribute",()=>u.Float16BufferAttribute,"Float32BufferAttribute",()=>u.Float32BufferAttribute,"FloatType",()=>u.FloatType,"Fog",()=>u.Fog,"FogExp2",()=>u.FogExp2,"FramebufferTexture",()=>u.FramebufferTexture,"FrontSide",()=>u.FrontSide,"Frustum",()=>u.Frustum,"FrustumArray",()=>u.FrustumArray,"GLBufferAttribute",()=>u.GLBufferAttribute,"GLSL1",()=>u.GLSL1,"GLSL3",()=>u.GLSL3,"GreaterCompare",()=>u.GreaterCompare,"GreaterDepth",()=>u.GreaterDepth,"GreaterEqualCompare",()=>u.GreaterEqualCompare,"GreaterEqualDepth",()=>u.GreaterEqualDepth,"GreaterEqualStencilFunc",()=>u.GreaterEqualStencilFunc,"GreaterStencilFunc",()=>u.GreaterStencilFunc,"GridHelper",()=>u.GridHelper,"Group",()=>u.Group,"HalfFloatType",()=>u.HalfFloatType,"HemisphereLight",()=>u.HemisphereLight,"HemisphereLightHelper",()=>u.HemisphereLightHelper,"IcosahedronGeometry",()=>u.IcosahedronGeometry,"ImageBitmapLoader",()=>u.ImageBitmapLoader,"ImageLoader",()=>u.ImageLoader,"ImageUtils",()=>u.ImageUtils,"IncrementStencilOp",()=>u.IncrementStencilOp,"IncrementWrapStencilOp",()=>u.IncrementWrapStencilOp,"InstancedBufferAttribute",()=>u.InstancedBufferAttribute,"InstancedBufferGeometry",()=>u.InstancedBufferGeometry,"InstancedInterleavedBuffer",()=>u.InstancedInterleavedBuffer,"InstancedMesh",()=>u.InstancedMesh,"Int16BufferAttribute",()=>u.Int16BufferAttribute,"Int32BufferAttribute",()=>u.Int32BufferAttribute,"Int8BufferAttribute",()=>u.Int8BufferAttribute,"IntType",()=>u.IntType,"InterleavedBuffer",()=>u.InterleavedBuffer,"InterleavedBufferAttribute",()=>u.InterleavedBufferAttribute,"Interpolant",()=>u.Interpolant,"InterpolateDiscrete",()=>u.InterpolateDiscrete,"InterpolateLinear",()=>u.InterpolateLinear,"InterpolateSmooth",()=>u.InterpolateSmooth,"InterpolationSamplingMode",()=>u.InterpolationSamplingMode,"InterpolationSamplingType",()=>u.InterpolationSamplingType,"InvertStencilOp",()=>u.InvertStencilOp,"KeepStencilOp",()=>u.KeepStencilOp,"KeyframeTrack",()=>u.KeyframeTrack,"LOD",()=>u.LOD,"LatheGeometry",()=>u.LatheGeometry,"Layers",()=>u.Layers,"LessCompare",()=>u.LessCompare,"LessDepth",()=>u.LessDepth,"LessEqualCompare",()=>u.LessEqualCompare,"LessEqualDepth",()=>u.LessEqualDepth,"LessEqualStencilFunc",()=>u.LessEqualStencilFunc,"LessStencilFunc",()=>u.LessStencilFunc,"Light",()=>u.Light,"LightProbe",()=>u.LightProbe,"Line",()=>u.Line,"Line3",()=>u.Line3,"LineBasicMaterial",()=>u.LineBasicMaterial,"LineCurve",()=>u.LineCurve,"LineCurve3",()=>u.LineCurve3,"LineDashedMaterial",()=>u.LineDashedMaterial,"LineLoop",()=>u.LineLoop,"LineSegments",()=>u.LineSegments,"LinearFilter",()=>u.LinearFilter,"LinearInterpolant",()=>u.LinearInterpolant,"LinearMipMapLinearFilter",()=>u.LinearMipMapLinearFilter,"LinearMipMapNearestFilter",()=>u.LinearMipMapNearestFilter,"LinearMipmapLinearFilter",()=>u.LinearMipmapLinearFilter,"LinearMipmapNearestFilter",()=>u.LinearMipmapNearestFilter,"LinearSRGBColorSpace",()=>u.LinearSRGBColorSpace,"LinearToneMapping",()=>u.LinearToneMapping,"LinearTransfer",()=>u.LinearTransfer,"Loader",()=>u.Loader,"LoaderUtils",()=>u.LoaderUtils,"LoadingManager",()=>u.LoadingManager,"LoopOnce",()=>u.LoopOnce,"LoopPingPong",()=>u.LoopPingPong,"LoopRepeat",()=>u.LoopRepeat,"MOUSE",()=>u.MOUSE,"Material",()=>u.Material,"MaterialLoader",()=>u.MaterialLoader,"MathUtils",()=>u.MathUtils,"Matrix2",()=>u.Matrix2,"Matrix3",()=>u.Matrix3,"Matrix4",()=>u.Matrix4,"MaxEquation",()=>u.MaxEquation,"Mesh",()=>u.Mesh,"MeshBasicMaterial",()=>u.MeshBasicMaterial,"MeshDepthMaterial",()=>u.MeshDepthMaterial,"MeshDistanceMaterial",()=>u.MeshDistanceMaterial,"MeshLambertMaterial",()=>u.MeshLambertMaterial,"MeshMatcapMaterial",()=>u.MeshMatcapMaterial,"MeshNormalMaterial",()=>u.MeshNormalMaterial,"MeshPhongMaterial",()=>u.MeshPhongMaterial,"MeshPhysicalMaterial",()=>u.MeshPhysicalMaterial,"MeshStandardMaterial",()=>u.MeshStandardMaterial,"MeshToonMaterial",()=>u.MeshToonMaterial,"MinEquation",()=>u.MinEquation,"MirroredRepeatWrapping",()=>u.MirroredRepeatWrapping,"MixOperation",()=>u.MixOperation,"MultiplyBlending",()=>u.MultiplyBlending,"MultiplyOperation",()=>u.MultiplyOperation,"NearestFilter",()=>u.NearestFilter,"NearestMipMapLinearFilter",()=>u.NearestMipMapLinearFilter,"NearestMipMapNearestFilter",()=>u.NearestMipMapNearestFilter,"NearestMipmapLinearFilter",()=>u.NearestMipmapLinearFilter,"NearestMipmapNearestFilter",()=>u.NearestMipmapNearestFilter,"NeutralToneMapping",()=>u.NeutralToneMapping,"NeverCompare",()=>u.NeverCompare,"NeverDepth",()=>u.NeverDepth,"NeverStencilFunc",()=>u.NeverStencilFunc,"NoBlending",()=>u.NoBlending,"NoColorSpace",()=>u.NoColorSpace,"NoNormalPacking",()=>u.NoNormalPacking,"NoToneMapping",()=>u.NoToneMapping,"NormalAnimationBlendMode",()=>u.NormalAnimationBlendMode,"NormalBlending",()=>u.NormalBlending,"NormalGAPacking",()=>u.NormalGAPacking,"NormalRGPacking",()=>u.NormalRGPacking,"NotEqualCompare",()=>u.NotEqualCompare,"NotEqualDepth",()=>u.NotEqualDepth,"NotEqualStencilFunc",()=>u.NotEqualStencilFunc,"NumberKeyframeTrack",()=>u.NumberKeyframeTrack,"Object3D",()=>u.Object3D,"ObjectLoader",()=>u.ObjectLoader,"ObjectSpaceNormalMap",()=>u.ObjectSpaceNormalMap,"OctahedronGeometry",()=>u.OctahedronGeometry,"OneFactor",()=>u.OneFactor,"OneMinusConstantAlphaFactor",()=>u.OneMinusConstantAlphaFactor,"OneMinusConstantColorFactor",()=>u.OneMinusConstantColorFactor,"OneMinusDstAlphaFactor",()=>u.OneMinusDstAlphaFactor,"OneMinusDstColorFactor",()=>u.OneMinusDstColorFactor,"OneMinusSrcAlphaFactor",()=>u.OneMinusSrcAlphaFactor,"OneMinusSrcColorFactor",()=>u.OneMinusSrcColorFactor,"OrthographicCamera",()=>u.OrthographicCamera,"PCFShadowMap",()=>u.PCFShadowMap,"PCFSoftShadowMap",()=>u.PCFSoftShadowMap,"PMREMGenerator",()=>l.PMREMGenerator,"Path",()=>u.Path,"PerspectiveCamera",()=>u.PerspectiveCamera,"Plane",()=>u.Plane,"PlaneGeometry",()=>u.PlaneGeometry,"PlaneHelper",()=>u.PlaneHelper,"PointLight",()=>u.PointLight,"PointLightHelper",()=>u.PointLightHelper,"Points",()=>u.Points,"PointsMaterial",()=>u.PointsMaterial,"PolarGridHelper",()=>u.PolarGridHelper,"PolyhedronGeometry",()=>u.PolyhedronGeometry,"PositionalAudio",()=>u.PositionalAudio,"PropertyBinding",()=>u.PropertyBinding,"PropertyMixer",()=>u.PropertyMixer,"QuadraticBezierCurve",()=>u.QuadraticBezierCurve,"QuadraticBezierCurve3",()=>u.QuadraticBezierCurve3,"Quaternion",()=>u.Quaternion,"QuaternionKeyframeTrack",()=>u.QuaternionKeyframeTrack,"QuaternionLinearInterpolant",()=>u.QuaternionLinearInterpolant,"R11_EAC_Format",()=>u.R11_EAC_Format,"RED_GREEN_RGTC2_Format",()=>u.RED_GREEN_RGTC2_Format,"RED_RGTC1_Format",()=>u.RED_RGTC1_Format,"REVISION",()=>u.REVISION,"RG11_EAC_Format",()=>u.RG11_EAC_Format,"RGBADepthPacking",()=>u.RGBADepthPacking,"RGBAFormat",()=>u.RGBAFormat,"RGBAIntegerFormat",()=>u.RGBAIntegerFormat,"RGBA_ASTC_10x10_Format",()=>u.RGBA_ASTC_10x10_Format,"RGBA_ASTC_10x5_Format",()=>u.RGBA_ASTC_10x5_Format,"RGBA_ASTC_10x6_Format",()=>u.RGBA_ASTC_10x6_Format,"RGBA_ASTC_10x8_Format",()=>u.RGBA_ASTC_10x8_Format,"RGBA_ASTC_12x10_Format",()=>u.RGBA_ASTC_12x10_Format,"RGBA_ASTC_12x12_Format",()=>u.RGBA_ASTC_12x12_Format,"RGBA_ASTC_4x4_Format",()=>u.RGBA_ASTC_4x4_Format,"RGBA_ASTC_5x4_Format",()=>u.RGBA_ASTC_5x4_Format,"RGBA_ASTC_5x5_Format",()=>u.RGBA_ASTC_5x5_Format,"RGBA_ASTC_6x5_Format",()=>u.RGBA_ASTC_6x5_Format,"RGBA_ASTC_6x6_Format",()=>u.RGBA_ASTC_6x6_Format,"RGBA_ASTC_8x5_Format",()=>u.RGBA_ASTC_8x5_Format,"RGBA_ASTC_8x6_Format",()=>u.RGBA_ASTC_8x6_Format,"RGBA_ASTC_8x8_Format",()=>u.RGBA_ASTC_8x8_Format,"RGBA_BPTC_Format",()=>u.RGBA_BPTC_Format,"RGBA_ETC2_EAC_Format",()=>u.RGBA_ETC2_EAC_Format,"RGBA_PVRTC_2BPPV1_Format",()=>u.RGBA_PVRTC_2BPPV1_Format,"RGBA_PVRTC_4BPPV1_Format",()=>u.RGBA_PVRTC_4BPPV1_Format,"RGBA_S3TC_DXT1_Format",()=>u.RGBA_S3TC_DXT1_Format,"RGBA_S3TC_DXT3_Format",()=>u.RGBA_S3TC_DXT3_Format,"RGBA_S3TC_DXT5_Format",()=>u.RGBA_S3TC_DXT5_Format,"RGBDepthPacking",()=>u.RGBDepthPacking,"RGBFormat",()=>u.RGBFormat,"RGBIntegerFormat",()=>u.RGBIntegerFormat,"RGB_BPTC_SIGNED_Format",()=>u.RGB_BPTC_SIGNED_Format,"RGB_BPTC_UNSIGNED_Format",()=>u.RGB_BPTC_UNSIGNED_Format,"RGB_ETC1_Format",()=>u.RGB_ETC1_Format,"RGB_ETC2_Format",()=>u.RGB_ETC2_Format,"RGB_PVRTC_2BPPV1_Format",()=>u.RGB_PVRTC_2BPPV1_Format,"RGB_PVRTC_4BPPV1_Format",()=>u.RGB_PVRTC_4BPPV1_Format,"RGB_S3TC_DXT1_Format",()=>u.RGB_S3TC_DXT1_Format,"RGDepthPacking",()=>u.RGDepthPacking,"RGFormat",()=>u.RGFormat,"RGIntegerFormat",()=>u.RGIntegerFormat,"RawShaderMaterial",()=>u.RawShaderMaterial,"Ray",()=>u.Ray,"Raycaster",()=>u.Raycaster,"RectAreaLight",()=>u.RectAreaLight,"RedFormat",()=>u.RedFormat,"RedIntegerFormat",()=>u.RedIntegerFormat,"ReinhardToneMapping",()=>u.ReinhardToneMapping,"RenderTarget",()=>u.RenderTarget,"RenderTarget3D",()=>u.RenderTarget3D,"RepeatWrapping",()=>u.RepeatWrapping,"ReplaceStencilOp",()=>u.ReplaceStencilOp,"ReverseSubtractEquation",()=>u.ReverseSubtractEquation,"RingGeometry",()=>u.RingGeometry,"SIGNED_R11_EAC_Format",()=>u.SIGNED_R11_EAC_Format,"SIGNED_RED_GREEN_RGTC2_Format",()=>u.SIGNED_RED_GREEN_RGTC2_Format,"SIGNED_RED_RGTC1_Format",()=>u.SIGNED_RED_RGTC1_Format,"SIGNED_RG11_EAC_Format",()=>u.SIGNED_RG11_EAC_Format,"SRGBColorSpace",()=>u.SRGBColorSpace,"SRGBTransfer",()=>u.SRGBTransfer,"Scene",()=>u.Scene,"ShaderChunk",()=>l.ShaderChunk,"ShaderLib",()=>l.ShaderLib,"ShaderMaterial",()=>u.ShaderMaterial,"ShadowMaterial",()=>u.ShadowMaterial,"Shape",()=>u.Shape,"ShapeGeometry",()=>u.ShapeGeometry,"ShapePath",()=>u.ShapePath,"ShapeUtils",()=>u.ShapeUtils,"ShortType",()=>u.ShortType,"Skeleton",()=>u.Skeleton,"SkeletonHelper",()=>u.SkeletonHelper,"SkinnedMesh",()=>u.SkinnedMesh,"Source",()=>u.Source,"Sphere",()=>u.Sphere,"SphereGeometry",()=>u.SphereGeometry,"Spherical",()=>u.Spherical,"SphericalHarmonics3",()=>u.SphericalHarmonics3,"SplineCurve",()=>u.SplineCurve,"SpotLight",()=>u.SpotLight,"SpotLightHelper",()=>u.SpotLightHelper,"Sprite",()=>u.Sprite,"SpriteMaterial",()=>u.SpriteMaterial,"SrcAlphaFactor",()=>u.SrcAlphaFactor,"SrcAlphaSaturateFactor",()=>u.SrcAlphaSaturateFactor,"SrcColorFactor",()=>u.SrcColorFactor,"StaticCopyUsage",()=>u.StaticCopyUsage,"StaticDrawUsage",()=>u.StaticDrawUsage,"StaticReadUsage",()=>u.StaticReadUsage,"StereoCamera",()=>u.StereoCamera,"StreamCopyUsage",()=>u.StreamCopyUsage,"StreamDrawUsage",()=>u.StreamDrawUsage,"StreamReadUsage",()=>u.StreamReadUsage,"StringKeyframeTrack",()=>u.StringKeyframeTrack,"SubtractEquation",()=>u.SubtractEquation,"SubtractiveBlending",()=>u.SubtractiveBlending,"TOUCH",()=>u.TOUCH,"TangentSpaceNormalMap",()=>u.TangentSpaceNormalMap,"TetrahedronGeometry",()=>u.TetrahedronGeometry,"Texture",()=>u.Texture,"TextureLoader",()=>u.TextureLoader,"TextureUtils",()=>u.TextureUtils,"Timer",()=>u.Timer,"TimestampQuery",()=>u.TimestampQuery,"TorusGeometry",()=>u.TorusGeometry,"TorusKnotGeometry",()=>u.TorusKnotGeometry,"Triangle",()=>u.Triangle,"TriangleFanDrawMode",()=>u.TriangleFanDrawMode,"TriangleStripDrawMode",()=>u.TriangleStripDrawMode,"TrianglesDrawMode",()=>u.TrianglesDrawMode,"TubeGeometry",()=>u.TubeGeometry,"UVMapping",()=>u.UVMapping,"Uint16BufferAttribute",()=>u.Uint16BufferAttribute,"Uint32BufferAttribute",()=>u.Uint32BufferAttribute,"Uint8BufferAttribute",()=>u.Uint8BufferAttribute,"Uint8ClampedBufferAttribute",()=>u.Uint8ClampedBufferAttribute,"Uniform",()=>u.Uniform,"UniformsGroup",()=>u.UniformsGroup,"UniformsLib",()=>l.UniformsLib,"UniformsUtils",()=>u.UniformsUtils,"UnsignedByteType",()=>u.UnsignedByteType,"UnsignedInt101111Type",()=>u.UnsignedInt101111Type,"UnsignedInt248Type",()=>u.UnsignedInt248Type,"UnsignedInt5999Type",()=>u.UnsignedInt5999Type,"UnsignedIntType",()=>u.UnsignedIntType,"UnsignedShort4444Type",()=>u.UnsignedShort4444Type,"UnsignedShort5551Type",()=>u.UnsignedShort5551Type,"UnsignedShortType",()=>u.UnsignedShortType,"VSMShadowMap",()=>u.VSMShadowMap,"Vector2",()=>u.Vector2,"Vector3",()=>u.Vector3,"Vector4",()=>u.Vector4,"VectorKeyframeTrack",()=>u.VectorKeyframeTrack,"VideoFrameTexture",()=>u.VideoFrameTexture,"VideoTexture",()=>u.VideoTexture,"WebGL3DRenderTarget",()=>u.WebGL3DRenderTarget,"WebGLArrayRenderTarget",()=>u.WebGLArrayRenderTarget,"WebGLCoordinateSystem",()=>u.WebGLCoordinateSystem,"WebGLCubeRenderTarget",()=>u.WebGLCubeRenderTarget,"WebGLRenderTarget",()=>u.WebGLRenderTarget,"WebGLRenderer",()=>l.WebGLRenderer,"WebGLUtils",()=>l.WebGLUtils,"WebGPUCoordinateSystem",()=>u.WebGPUCoordinateSystem,"WebXRController",()=>u.WebXRController,"WireframeGeometry",()=>u.WireframeGeometry,"WrapAroundEnding",()=>u.WrapAroundEnding,"ZeroCurvatureEnding",()=>u.ZeroCurvatureEnding,"ZeroFactor",()=>u.ZeroFactor,"ZeroSlopeEnding",()=>u.ZeroSlopeEnding,"ZeroStencilOp",()=>u.ZeroStencilOp,"createCanvasElement",()=>u.createCanvasElement,"error",()=>u.error,"getConsoleFunction",()=>u.getConsoleFunction,"log",()=>u.log,"setConsoleFunction",()=>u.setConsoleFunction,"warn",()=>u.warn,"warnOnce",()=>u.warnOnce],32009);var c=e.i(32009);function d(e,t){let r;return(...a)=>{window.clearTimeout(r),r=window.setTimeout(()=>e(...a),t)}}let f=["x","y","top","bottom","left","right","width","height"];var h=e.i(46791);function m({ref:e,children:t,fallback:r,resize:a,style:i,gl:l,events:u=s.f,eventSource:h,eventPrefix:m,shadows:p,linear:g,flat:v,legacy:y,orthographic:A,frameloop:F,dpr:b,performance:C,raycaster:B,camera:S,scene:x,onPointerMissed:E,onCreated:M,...D}){o.useMemo(()=>(0,s.e)(c),[]);let k=(0,s.u)(),[w,I]=function({debounce:e,scroll:t,polyfill:r,offsetSize:a}={debounce:0,scroll:!1,offsetSize:!1}){var n,i,s;let l=r||("undefined"==typeof window?class{}:window.ResizeObserver);if(!l)throw Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");let[u,c]=(0,o.useState)({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),h=(0,o.useRef)({element:null,scrollContainers:null,resizeObserver:null,lastBounds:u,orientationHandler:null}),m=e?"number"==typeof e?e:e.scroll:null,p=e?"number"==typeof e?e:e.resize:null,g=(0,o.useRef)(!1);(0,o.useEffect)(()=>(g.current=!0,()=>void(g.current=!1)));let[v,y,A]=(0,o.useMemo)(()=>{let e=()=>{let e,t;if(!h.current.element)return;let{left:r,top:n,width:i,height:o,bottom:s,right:l,x:u,y:d}=h.current.element.getBoundingClientRect(),m={left:r,top:n,width:i,height:o,bottom:s,right:l,x:u,y:d};h.current.element instanceof HTMLElement&&a&&(m.height=h.current.element.offsetHeight,m.width=h.current.element.offsetWidth),Object.freeze(m),g.current&&(e=h.current.lastBounds,t=m,!f.every(r=>e[r]===t[r]))&&c(h.current.lastBounds=m)};return[e,p?d(e,p):e,m?d(e,m):e]},[c,a,m,p]);function F(){h.current.scrollContainers&&(h.current.scrollContainers.forEach(e=>e.removeEventListener("scroll",A,!0)),h.current.scrollContainers=null),h.current.resizeObserver&&(h.current.resizeObserver.disconnect(),h.current.resizeObserver=null),h.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",h.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",h.current.orientationHandler))}function b(){h.current.element&&(h.current.resizeObserver=new l(A),h.current.resizeObserver.observe(h.current.element),t&&h.current.scrollContainers&&h.current.scrollContainers.forEach(e=>e.addEventListener("scroll",A,{capture:!0,passive:!0})),h.current.orientationHandler=()=>{A()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",h.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",h.current.orientationHandler))}return n=A,i=!!t,(0,o.useEffect)(()=>{if(i)return window.addEventListener("scroll",n,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",n,!0)},[n,i]),s=y,(0,o.useEffect)(()=>(window.addEventListener("resize",s),()=>void window.removeEventListener("resize",s)),[s]),(0,o.useEffect)(()=>{F(),b()},[t,A,y]),(0,o.useEffect)(()=>F,[]),[e=>{e&&e!==h.current.element&&(F(),h.current.element=e,h.current.scrollContainers=function e(t){let r=[];if(!t||t===document.body)return r;let{overflow:a,overflowX:n,overflowY:i}=window.getComputedStyle(t);return[a,n,i].some(e=>"auto"===e||"scroll"===e)&&r.push(t),[...r,...e(t.parentElement)]}(e),b())},u,v]}({scroll:!0,debounce:{scroll:50,resize:0},...a}),T=o.useRef(null),R=o.useRef(null);o.useImperativeHandle(e,()=>T.current);let P=(0,s.a)(E),[G,L]=o.useState(!1),[j,_]=o.useState(!1);if(G)throw G;if(j)throw j;let O=o.useRef(null);(0,s.b)(()=>{let e=T.current;I.width>0&&I.height>0&&e&&(O.current||(O.current=(0,s.c)(e)),async function(){await O.current.configure({gl:l,scene:x,events:u,shadows:p,linear:g,flat:v,legacy:y,orthographic:A,frameloop:F,dpr:b,performance:C,raycaster:B,camera:S,size:I,onPointerMissed:(...e)=>null==P.current?void 0:P.current(...e),onCreated:e=>{null==e.events.connect||e.events.connect(h?(0,s.i)(h)?h.current:h:R.current),m&&e.setEvents({compute:(e,t)=>{let r=e[m+"X"],a=e[m+"Y"];t.pointer.set(r/t.size.width*2-1,-(2*(a/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),null==M||M(e)}}),O.current.render((0,n.jsx)(k,{children:(0,n.jsx)(s.E,{set:_,children:(0,n.jsx)(o.Suspense,{fallback:(0,n.jsx)(s.B,{set:L}),children:null!=t?t:null})})}))}())}),o.useEffect(()=>{let e=T.current;if(e)return()=>(0,s.d)(e)},[]);let U=h?"none":"auto";return(0,n.jsx)("div",{ref:R,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:U,...i},...D,children:(0,n.jsx)("div",{ref:w,style:{width:"100%",height:"100%"},children:(0,n.jsx)("canvas",{ref:T,style:{display:"block"},children:r})})})}function p(e){return(0,n.jsx)(h.FiberProvider,{children:(0,n.jsx)(m,{...e})})}e.i(39695),e.i(98133),e.i(95087);var g=e.i(66027),v=e.i(54970),y=e.i(12979),A=e.i(49774),F=e.i(73949),b=e.i(62395),C=e.i(75567),B=e.i(47071);let S={value:!0},x=`
|
||
vec3 terrainLinearToSRGB(vec3 linear) {
|
||
vec3 higher = pow(linear, vec3(1.0/2.4)) * 1.055 - 0.055;
|
||
vec3 lower = linear * 12.92;
|
||
return mix(lower, higher, step(vec3(0.0031308), linear));
|
||
}
|
||
|
||
vec3 terrainSRGBToLinear(vec3 srgb) {
|
||
vec3 higher = pow((srgb + 0.055) / 1.055, vec3(2.4));
|
||
vec3 lower = srgb / 12.92;
|
||
return mix(lower, higher, step(vec3(0.04045), srgb));
|
||
}
|
||
|
||
// Debug grid overlay using screen-space derivatives for sharp, anti-aliased lines
|
||
// Returns 1.0 on grid lines, 0.0 elsewhere
|
||
float terrainDebugGrid(vec2 uv, float gridSize, float lineWidth) {
|
||
vec2 scaledUV = uv * gridSize;
|
||
vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV);
|
||
float line = min(grid.x, grid.y);
|
||
return 1.0 - min(line / lineWidth, 1.0);
|
||
}
|
||
`;var E=e.i(79123),M=e.i(47021),D=e.i(48066);let k={0:32,1:32,2:32,3:32,4:32,5:32};function w({displacementMap:e,visibilityMask:t,textureNames:r,alphaTextures:a,detailTextureName:i,lightmap:s}){let{debugMode:l}=(0,E.useDebug)(),c=(0,B.useTexture)(r.map(e=>(0,y.terrainTextureToUrl)(e)),e=>{e.forEach(e=>(0,C.setupTexture)(e))}),d=i?(0,y.textureToUrl)(i):null,f=(0,B.useTexture)(d??y.FALLBACK_TEXTURE_URL,e=>{(0,C.setupTexture)(e)}),h=(0,o.useCallback)(e=>{!function({shader:e,baseTextures:t,alphaTextures:r,visibilityMask:a,tiling:n,detailTexture:i=null,lightmap:o=null}){e.uniforms.sunLightPointsDown=S;let s=t.length;if(t.forEach((t,r)=>{e.uniforms[`albedo${r}`]={value:t}}),r.forEach((t,r)=>{e.uniforms[`mask${r}`]={value:t}}),a&&(e.uniforms.visibilityMask={value:a}),t.forEach((t,r)=>{e.uniforms[`tiling${r}`]={value:n[r]??32}}),o&&(e.uniforms.terrainLightmap={value:o}),i&&(e.uniforms.detailTexture={value:i},e.uniforms.detailTiling={value:64},e.uniforms.detailFadeDistance={value:150},e.vertexShader=e.vertexShader.replace("#include <common>",`#include <common>
|
||
varying vec3 vTerrainWorldPos;`),e.vertexShader=e.vertexShader.replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
|
||
vTerrainWorldPos = (modelMatrix * vec4(transformed, 1.0)).xyz;`)),e.fragmentShader=`
|
||
uniform sampler2D albedo0;
|
||
uniform sampler2D albedo1;
|
||
uniform sampler2D albedo2;
|
||
uniform sampler2D albedo3;
|
||
uniform sampler2D albedo4;
|
||
uniform sampler2D albedo5;
|
||
uniform sampler2D mask0;
|
||
uniform sampler2D mask1;
|
||
uniform sampler2D mask2;
|
||
uniform sampler2D mask3;
|
||
uniform sampler2D mask4;
|
||
uniform sampler2D mask5;
|
||
uniform float tiling0;
|
||
uniform float tiling1;
|
||
uniform float tiling2;
|
||
uniform float tiling3;
|
||
uniform float tiling4;
|
||
uniform float tiling5;
|
||
${a?"uniform sampler2D visibilityMask;":""}
|
||
${o?"uniform sampler2D terrainLightmap;":""}
|
||
uniform bool sunLightPointsDown;
|
||
${i?`uniform sampler2D detailTexture;
|
||
uniform float detailTiling;
|
||
uniform float detailFadeDistance;
|
||
varying vec3 vTerrainWorldPos;`:""}
|
||
|
||
${x}
|
||
|
||
// Global variable to store shadow factor from RE_Direct for use in output calculation
|
||
float terrainShadowFactor = 1.0;
|
||
`+e.fragmentShader,a){let t="#include <clipping_planes_fragment>";e.fragmentShader=e.fragmentShader.replace(t,`${t}
|
||
// Early discard for invisible areas (before fog/lighting)
|
||
float visibility = texture2D(visibilityMask, vMapUv).r;
|
||
if (visibility < 0.5) {
|
||
discard;
|
||
}
|
||
`)}e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>",`
|
||
// Sample base albedo layers (sRGB textures auto-decoded to linear by Three.js)
|
||
vec2 baseUv = vMapUv;
|
||
vec3 c0 = texture2D(albedo0, baseUv * vec2(tiling0)).rgb;
|
||
${s>1?"vec3 c1 = texture2D(albedo1, baseUv * vec2(tiling1)).rgb;":""}
|
||
${s>2?"vec3 c2 = texture2D(albedo2, baseUv * vec2(tiling2)).rgb;":""}
|
||
${s>3?"vec3 c3 = texture2D(albedo3, baseUv * vec2(tiling3)).rgb;":""}
|
||
${s>4?"vec3 c4 = texture2D(albedo4, baseUv * vec2(tiling4)).rgb;":""}
|
||
${s>5?"vec3 c5 = texture2D(albedo5, baseUv * vec2(tiling5)).rgb;":""}
|
||
|
||
// Sample alpha masks for all layers (use R channel)
|
||
// Add +0.5 texel offset: Torque samples alpha at grid corners (integer indices),
|
||
// but GPU linear filtering samples at texel centers. This offset aligns them.
|
||
vec2 alphaUv = baseUv + vec2(0.5 / 256.0);
|
||
float a0 = texture2D(mask0, alphaUv).r;
|
||
${s>1?"float a1 = texture2D(mask1, alphaUv).r;":""}
|
||
${s>2?"float a2 = texture2D(mask2, alphaUv).r;":""}
|
||
${s>3?"float a3 = texture2D(mask3, alphaUv).r;":""}
|
||
${s>4?"float a4 = texture2D(mask4, alphaUv).r;":""}
|
||
${s>5?"float a5 = texture2D(mask5, alphaUv).r;":""}
|
||
|
||
// Torque-style additive weighted blending (blender.cc):
|
||
// result = tex0 * alpha0 + tex1 * alpha1 + tex2 * alpha2 + ...
|
||
// Each layer's alpha map defines its contribution weight.
|
||
vec3 blended = c0 * a0;
|
||
${s>1?"blended += c1 * a1;":""}
|
||
${s>2?"blended += c2 * a2;":""}
|
||
${s>3?"blended += c3 * a3;":""}
|
||
${s>4?"blended += c4 * a4;":""}
|
||
${s>5?"blended += c5 * a5;":""}
|
||
|
||
// Assign to diffuseColor before lighting
|
||
vec3 textureColor = blended;
|
||
|
||
${i?`// Detail texture blending (Torque-style multiplicative blend)
|
||
// Sample detail texture at high frequency tiling
|
||
vec3 detailColor = texture2D(detailTexture, baseUv * detailTiling).rgb;
|
||
|
||
// Calculate distance-based fade factor using world positions
|
||
// Torque: distFactor = (zeroDetailDistance - distance) / zeroDetailDistance
|
||
float distToCamera = distance(vTerrainWorldPos, cameraPosition);
|
||
float detailFade = clamp(1.0 - distToCamera / detailFadeDistance, 0.0, 1.0);
|
||
|
||
// Torque blending: dst * lerp(1.0, detailTexel, fadeFactor)
|
||
// Detail textures are authored with bright values (~0.8 mean), not 0.5 gray
|
||
// Direct multiplication adds subtle darkening for surface detail
|
||
textureColor *= mix(vec3(1.0), detailColor, detailFade);`:""}
|
||
|
||
// Store blended texture in diffuseColor (still in linear space here)
|
||
// We'll convert to sRGB in the output calculation
|
||
diffuseColor.rgb = textureColor;
|
||
`),o&&(e.fragmentShader=e.fragmentShader.replace("#include <lights_lambert_pars_fragment>",`#include <lights_lambert_pars_fragment>
|
||
|
||
// Override RE_Direct to extract shadow factor for Torque-style gamma-space lighting
|
||
#undef RE_Direct
|
||
void RE_Direct_TerrainShadow( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
||
// Torque lighting (terrLighting.cc): if light points up, terrain gets only ambient
|
||
// This prevents shadow acne from light hitting terrain backfaces
|
||
if (!sunLightPointsDown) {
|
||
terrainShadowFactor = 0.0;
|
||
return;
|
||
}
|
||
// directLight.color = sunColor * shadowFactor (shadow already applied by Three.js)
|
||
// Extract shadow factor by comparing to original sun color
|
||
#if ( NUM_DIR_LIGHTS > 0 )
|
||
vec3 originalSunColor = directionalLights[0].color;
|
||
float sunMax = max(max(originalSunColor.r, originalSunColor.g), originalSunColor.b);
|
||
float shadowedMax = max(max(directLight.color.r, directLight.color.g), directLight.color.b);
|
||
terrainShadowFactor = clamp(shadowedMax / max(sunMax, 0.001), 0.0, 1.0);
|
||
#endif
|
||
// Don't add to reflectedLight - we'll compute lighting in gamma space at output
|
||
}
|
||
#define RE_Direct RE_Direct_TerrainShadow
|
||
|
||
`),e.fragmentShader=e.fragmentShader.replace("#include <lights_fragment_begin>",`#include <lights_fragment_begin>
|
||
// Clear indirect diffuse - we'll compute ambient in gamma space
|
||
#if defined( RE_IndirectDiffuse )
|
||
irradiance = vec3(0.0);
|
||
#endif
|
||
`),e.fragmentShader=e.fragmentShader.replace("#include <lights_fragment_end>",`#include <lights_fragment_end>
|
||
// Clear Three.js lighting - we compute everything in gamma space
|
||
reflectedLight.directDiffuse = vec3(0.0);
|
||
reflectedLight.indirectDiffuse = vec3(0.0);
|
||
`)),e.fragmentShader=e.fragmentShader.replace("#include <opaque_fragment>",`// Torque-style terrain lighting: output = clamp(lighting \xd7 texture, 0, 1) in sRGB space
|
||
{
|
||
// Get texture in sRGB space (undo Three.js linear decode)
|
||
vec3 textureSRGB = terrainLinearToSRGB(diffuseColor.rgb);
|
||
|
||
${o?`
|
||
// Sample terrain lightmap for smooth NdotL
|
||
vec2 lightmapUv = vMapUv + vec2(0.5 / 512.0);
|
||
float lightmapNdotL = texture2D(terrainLightmap, lightmapUv).r;
|
||
|
||
// Get sun and ambient colors from Three.js lights (these ARE sRGB values from mission file)
|
||
// Three.js interprets them as linear, but the numerical values are preserved
|
||
#if ( NUM_DIR_LIGHTS > 0 )
|
||
vec3 sunColorSRGB = directionalLights[0].color;
|
||
#else
|
||
vec3 sunColorSRGB = vec3(0.7);
|
||
#endif
|
||
vec3 ambientColorSRGB = ambientLightColor;
|
||
|
||
// Torque formula (terrLighting.cc:471-483):
|
||
// lighting = ambient + NdotL * shadowFactor * sunColor
|
||
// Clamp lighting to [0,1] before multiplying by texture
|
||
vec3 lightingSRGB = clamp(ambientColorSRGB + lightmapNdotL * terrainShadowFactor * sunColorSRGB, 0.0, 1.0);
|
||
`:`
|
||
// No lightmap - use simple ambient lighting
|
||
vec3 lightingSRGB = ambientLightColor;
|
||
`}
|
||
|
||
// Torque formula: output = clamp(lighting \xd7 texture, 0, 1) in sRGB/gamma space
|
||
vec3 resultSRGB = clamp(lightingSRGB * textureSRGB, 0.0, 1.0);
|
||
|
||
// Convert back to linear for Three.js output pipeline
|
||
outgoingLight = terrainSRGBToLinear(resultSRGB) + totalEmissiveRadiance;
|
||
}
|
||
#include <opaque_fragment>`),e.fragmentShader=e.fragmentShader.replace("#include <tonemapping_fragment>",`#if DEBUG_MODE
|
||
// Debug mode: overlay green grid matching terrain grid squares (256x256)
|
||
float gridIntensity = terrainDebugGrid(vMapUv, 256.0, 1.5);
|
||
vec3 gridColor = vec3(0.0, 0.8, 0.4); // Green
|
||
gl_FragColor.rgb = mix(gl_FragColor.rgb, gridColor, gridIntensity * 0.1);
|
||
#endif
|
||
|
||
#include <tonemapping_fragment>`)}({shader:e,baseTextures:c,alphaTextures:a,visibilityMask:t,tiling:k,detailTexture:d?f:null,lightmap:s}),(0,M.injectCustomFog)(e,D.globalFogUniforms)},[c,a,t,f,d,s]),m=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=m.current;e&&(e.defines??={},e.defines.DEBUG_MODE=+!!l,e.needsUpdate=!0)},[l]);let p=`${d?"detail":"nodetail"}-${s?"lightmap":"nolightmap"}`;return(0,n.jsx)("meshLambertMaterial",{ref:m,map:e,depthWrite:!0,side:u.FrontSide,defines:{DEBUG_MODE:+!!l},onBeforeCompile:h},p)}function I(e){let t,r,a=(0,i.c)(8),{displacementMap:s,visibilityMask:l,textureNames:u,alphaTextures:c,detailTextureName:d,lightmap:f}=e;return a[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)("meshLambertMaterial",{color:"rgb(0, 109, 56)",wireframe:!0}),a[0]=t):t=a[0],a[1]!==c||a[2]!==d||a[3]!==s||a[4]!==f||a[5]!==u||a[6]!==l?(r=(0,n.jsx)(o.Suspense,{fallback:t,children:(0,n.jsx)(w,{displacementMap:s,visibilityMask:l,textureNames:u,alphaTextures:c,detailTextureName:d,lightmap:f})}),a[1]=c,a[2]=d,a[3]=s,a[4]=f,a[5]=u,a[6]=l,a[7]=r):r=a[7],r}let T=(0,o.memo)(function(e){let t,r,a,o=(0,i.c)(15),{tileX:s,tileZ:l,blockSize:u,basePosition:c,textureNames:d,geometry:f,displacementMap:h,visibilityMask:m,alphaTextures:p,detailTextureName:g,lightmap:v,visible:y}=e,A=void 0===y||y,F=u/2,b=c.x+s*u+F,C=c.z+l*u+F;o[0]!==b||o[1]!==C?(t=[b,0,C],o[0]=b,o[1]=C,o[2]=t):t=o[2];let B=t;return o[3]!==p||o[4]!==g||o[5]!==h||o[6]!==v||o[7]!==d||o[8]!==m?(r=(0,n.jsx)(I,{displacementMap:h,visibilityMask:m,textureNames:d,alphaTextures:p,detailTextureName:g,lightmap:v}),o[3]=p,o[4]=g,o[5]=h,o[6]=v,o[7]=d,o[8]=m,o[9]=r):r=o[9],o[10]!==f||o[11]!==B||o[12]!==r||o[13]!==A?(a=(0,n.jsx)("mesh",{position:B,geometry:f,castShadow:!0,receiveShadow:!0,visible:A,children:r}),o[10]=f,o[11]=B,o[12]=r,o[13]=A,o[14]=a):a=o[14],a});e.i(13876);var R=e.i(58647);function P(e){return(0,R.useRuntimeObjectByName)(e)}function G(e){let t=new Uint8Array(65536);for(let r of(t.fill(255),e)){let e=255&r,a=r>>8&255,n=r>>16,i=256*a;for(let r=0;r<n;r++){let a=i+e+r;a<t.length&&(t[a]=0)}}let r=new u.DataTexture(t,256,256,u.RedFormat,u.UnsignedByteType);return r.colorSpace=u.NoColorSpace,r.wrapS=r.wrapT=u.ClampToEdgeWrapping,r.magFilter=u.NearestFilter,r.minFilter=u.NearestFilter,r.needsUpdate=!0,r}let L=(0,o.memo)(function(e){let t,r,a,s,l,c,d,f,h,m,p,v,C,B,S,x,E,M,D,k,w,I=(0,i.c)(69),{object:R}=e;I[0]!==R?(t=(0,b.getProperty)(R,"terrainFile"),I[0]=R,I[1]=t):t=I[1];let L=t;I[2]!==R?(r=(0,b.getInt)(R,"squareSize")??8,I[2]=R,I[3]=r):r=I[3];let N=r;I[4]!==R?(a=(0,b.getProperty)(R,"detailTexture"),I[4]=R,I[5]=a):a=I[5];let J=a,K=256*N,V=function(){let e,t=(0,i.c)(2),r=P("Sky");if(!r)return 600;let a=(0,b.getFloat)(r,"high_visibleDistance");return null!=a&&a>0?a:(t[0]!==r?(e=(0,b.getFloat)(r,"visibleDistance")??600,t[0]=r,t[1]=e):e=t[1],e)}(),z=(0,F.useThree)(j),q=-(128*N);I[6]!==q?(s={x:q,z:q},I[6]=q,I[7]=s):s=I[7];let Q=s;if(I[8]!==R){let e=(0,b.getProperty)(R,"emptySquares");l=e?e.split(" ").map(_):[],I[8]=R,I[9]=l}else l=I[9];let W=l,{data:X}=((w=(0,i.c)(2))[0]!==L?(k={queryKey:["terrain",L],queryFn:()=>(0,y.loadTerrain)(L)},w[0]=L,w[1]=k):k=w[1],(0,g.useQuery)(k));e:{let e;if(!X){c=null;break e}let t=256*N;I[10]!==t||I[11]!==N||I[12]!==X.heightMap?(!function(e,t,r){let a=e.attributes.position,n=e.attributes.uv,i=e.attributes.normal,o=a.array,s=n.array,l=i.array,u=a.count,c=(e,r)=>(e=Math.max(0,Math.min(255,e)),t[256*(r=Math.max(0,Math.min(255,r)))+e]/65535*2048),d=(e,r)=>{let a=Math.floor(e=Math.max(0,Math.min(255,e))),n=Math.floor(r=Math.max(0,Math.min(255,r))),i=Math.min(a+1,255),o=Math.min(n+1,255),s=e-a,l=r-n;return(t[256*n+a]/65535*2048*(1-s)+t[256*n+i]/65535*2048*s)*(1-l)+(t[256*o+a]/65535*2048*(1-s)+t[256*o+i]/65535*2048*s)*l};for(let e=0;e<u;e++){let t=s[2*e],a=s[2*e+1],n=c(255&Math.floor(256*t),255&Math.floor(256*a));o[3*e+1]=n;let i=255*t,u=255*a,f=d(i-1,u),h=d(i+1,u),m=(d(i,u+1)-d(i,u-1))/2,p=r,g=(h-f)/2,v=Math.sqrt(m*m+p*p+g*g);v>0?(m/=v,p/=v,g/=v):(m=0,p=1,g=0),l[3*e]=m,l[3*e+1]=p,l[3*e+2]=g}a.needsUpdate=!0,i.needsUpdate=!0}(e=function(e,t){let r=new u.BufferGeometry,a=new Float32Array(198147),n=new Float32Array(198147),i=new Float32Array(132098),o=new Uint32Array(393216),s=0,l=e/256;for(let t=0;t<=256;t++)for(let r=0;r<=256;r++){let o=257*t+r;a[3*o]=r*l-e/2,a[3*o+1]=e/2-t*l,a[3*o+2]=0,n[3*o]=0,n[3*o+1]=0,n[3*o+2]=1,i[2*o]=r/256,i[2*o+1]=1-t/256}for(let e=0;e<256;e++)for(let t=0;t<256;t++){let r=257*e+t,a=r+1,n=(e+1)*257+t,i=n+1;((t^e)&1)==0?(o[s++]=r,o[s++]=n,o[s++]=i,o[s++]=r,o[s++]=i,o[s++]=a):(o[s++]=r,o[s++]=n,o[s++]=a,o[s++]=a,o[s++]=n,o[s++]=i)}return r.setIndex(new u.BufferAttribute(o,1)),r.setAttribute("position",new u.Float32BufferAttribute(a,3)),r.setAttribute("normal",new u.Float32BufferAttribute(n,3)),r.setAttribute("uv",new u.Float32BufferAttribute(i,2)),r.rotateX(-Math.PI/2),r.rotateY(-Math.PI/2),r}(t,0),X.heightMap,N),I[10]=t,I[11]=N,I[12]=X.heightMap,I[13]=e):e=I[13],c=e}let Y=c,Z=P("Sun");t:{let e,t;if(!Z){let e;I[14]===Symbol.for("react.memo_cache_sentinel")?(e=new u.Vector3(.57735,-.57735,.57735),I[14]=e):e=I[14],d=e;break t}I[15]!==Z?(e=((0,b.getProperty)(Z,"direction")??"0.57735 0.57735 -0.57735").split(" ").map(O),I[15]=Z,I[16]=e):e=I[16];let[r,a,n]=e,i=Math.sqrt(r*r+n*n+a*a),o=r/i,s=n/i,l=a/i;I[17]!==s||I[18]!==l||I[19]!==o?(t=new u.Vector3(o,s,l),I[17]=s,I[18]=l,I[19]=o,I[20]=t):t=I[20],d=t}let $=d;r:{let e;if(!X){f=null;break r}I[21]!==N||I[22]!==$||I[23]!==X.heightMap?(e=function(e,t,r){let a=(t,r)=>{let a=Math.max(0,Math.min(255,t)),n=Math.max(0,Math.min(255,r)),i=Math.floor(a),o=Math.floor(n),s=Math.min(i+1,255),l=Math.min(o+1,255),u=a-i,c=n-o;return((e[256*o+i]/65535*(1-u)+e[256*o+s]/65535*u)*(1-c)+(e[256*l+i]/65535*(1-u)+e[256*l+s]/65535*u)*c)*2048},n=new u.Vector3(-t.x,-t.y,-t.z).normalize(),i=new Uint8Array(262144);for(let e=0;e<512;e++)for(let t=0;t<512;t++){let o=t/2+.25,s=e/2+.25,l=a(o,s),u=a(o-.5,s),c=a(o+.5,s),d=a(o,s-.5),f=-((a(o,s+.5)-d)/1),h=-((c-u)/1),m=Math.sqrt(f*f+r*r+h*h),p=Math.max(0,f/m*n.x+r/m*n.y+h/m*n.z),g=1;p>0&&(g=function(e,t,r,a,n,i){let o=a.z/n,s=a.x/n,l=a.y,u=Math.sqrt(o*o+s*s);if(u<1e-4)return 1;let c=.5/u,d=o*c,f=s*c,h=l*c,m=e,p=t,g=r+.1;for(let e=0;e<768&&(m+=d,p+=f,g+=h,!(m<0)&&!(m>=256)&&!(p<0)&&!(p>=256)&&!(g>2048));e++)if(g<i(m,p))return 0;return 1}(o,s,l,n,r,a)),i[512*e+t]=Math.floor(p*g*255)}let o=new u.DataTexture(i,512,512,u.RedFormat,u.UnsignedByteType);return o.colorSpace=u.NoColorSpace,o.generateMipmaps=!0,o.wrapS=u.ClampToEdgeWrapping,o.wrapT=u.ClampToEdgeWrapping,o.magFilter=u.LinearFilter,o.minFilter=u.LinearFilter,o.needsUpdate=!0,o}(X.heightMap,$,N),I[21]=N,I[22]=$,I[23]=X.heightMap,I[24]=e):e=I[24],f=e}let ee=f;a:{let e;if(!X){h=null;break a}if(I[25]!==X.heightMap){let t=function(e){let t=new Float32Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r]/65535;return t}(X.heightMap);(e=new u.DataTexture(t,256,256,u.RedFormat,u.FloatType)).colorSpace=u.NoColorSpace,e.generateMipmaps=!1,e.wrapS=u.RepeatWrapping,e.wrapT=u.RepeatWrapping,e.needsUpdate=!0,I[25]=X.heightMap,I[26]=e}else e=I[26];h=e}let et=h;I[27]!==W?(m=G(W),I[27]=W,I[28]=m):m=I[28];let er=m;I[29]===Symbol.for("react.memo_cache_sentinel")?(p=G([]),I[29]=p):p=I[29];let ea=p;n:{let e;if(!X){v=null;break n}I[30]!==X.alphaMaps?(e=X.alphaMaps.map(U),I[30]=X.alphaMaps,I[31]=e):e=I[31],v=e}let en=v,ei=2*Math.ceil(V/K)+1,eo=ei*ei-1;I[32]!==eo?(C=Array.from({length:eo},H),I[32]=eo,I[33]=C):C=I[33];let es=C;I[34]!==eo?(B=()=>Array(eo).fill(null),I[34]=eo,I[35]=B):B=I[35];let[el,eu]=(0,o.useState)(B);I[36]===Symbol.for("react.memo_cache_sentinel")?(S={xStart:0,xEnd:0,zStart:0,zEnd:0},I[36]=S):S=I[36];let ec=(0,o.useRef)(S);return(I[37]!==Q.x||I[38]!==Q.z||I[39]!==K||I[40]!==z.position.x||I[41]!==z.position.z||I[42]!==eo||I[43]!==V?(x=()=>{let e=z.position.x-Q.x,t=z.position.z-Q.z,r=Math.floor((e-V)/K),a=Math.ceil((e+V)/K),n=Math.floor((t-V)/K),i=Math.ceil((t+V)/K),o=ec.current;if(r===o.xStart&&a===o.xEnd&&n===o.zStart&&i===o.zEnd)return;o.xStart=r,o.xEnd=a,o.zStart=n,o.zEnd=i;let s=[];for(let e=r;e<a;e++)for(let t=n;t<i;t++)(0!==e||0!==t)&&s.push({tileX:e,tileZ:t});for(;s.length<eo;)s.push(null);eu(s)},I[37]=Q.x,I[38]=Q.z,I[39]=K,I[40]=z.position.x,I[41]=z.position.z,I[42]=eo,I[43]=V,I[44]=x):x=I[44],(0,A.useFrame)(x),X&&Y&&et&&en)?(I[45]!==Q||I[46]!==K||I[47]!==J||I[48]!==er||I[49]!==en||I[50]!==et||I[51]!==Y||I[52]!==X.textureNames||I[53]!==ee?(E=(0,n.jsx)(T,{tileX:0,tileZ:0,blockSize:K,basePosition:Q,textureNames:X.textureNames,geometry:Y,displacementMap:et,visibilityMask:er,alphaTextures:en,detailTextureName:J,lightmap:ee}),I[45]=Q,I[46]=K,I[47]=J,I[48]=er,I[49]=en,I[50]=et,I[51]=Y,I[52]=X.textureNames,I[53]=ee,I[54]=E):E=I[54],I[55]!==Q||I[56]!==K||I[57]!==J||I[58]!==es||I[59]!==en||I[60]!==et||I[61]!==Y||I[62]!==X.textureNames||I[63]!==ee||I[64]!==el?(M=es.map(e=>{let t=el[e];return(0,n.jsx)(T,{tileX:t?.tileX??0,tileZ:t?.tileZ??0,blockSize:K,basePosition:Q,textureNames:X.textureNames,geometry:Y,displacementMap:et,visibilityMask:ea,alphaTextures:en,detailTextureName:J,lightmap:ee,visible:null!==t},e)}),I[55]=Q,I[56]=K,I[57]=J,I[58]=es,I[59]=en,I[60]=et,I[61]=Y,I[62]=X.textureNames,I[63]=ee,I[64]=el,I[65]=M):M=I[65],I[66]!==E||I[67]!==M?(D=(0,n.jsxs)(n.Fragment,{children:[E,M]}),I[66]=E,I[67]=M,I[68]=D):D=I[68],D):null});function j(e){return e.camera}function _(e){return parseInt(e,10)}function O(e){return parseFloat(e)}function U(e){return(0,C.setupMask)(e)}function H(e,t){return t}let N=(0,o.createContext)(null);function J(){return(0,o.useContext)(N)}function K(e){return(0,n.jsx)(t6,{objectId:e},e)}var V=o;let z=(0,V.createContext)(null),q={didCatch:!1,error:null};class Q extends V.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=q}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;null!==t&&(this.props.onReset?.({args:e,reason:"imperative-api"}),this.setState(q))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:r}=this.state,{resetKeys:a}=this.props;r&&null!==t.error&&function(e=[],t=[]){return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,a)&&(this.props.onReset?.({next:a,prev:e.resetKeys,reason:"keys"}),this.setState(q))}render(){let{children:e,fallbackRender:t,FallbackComponent:r,fallback:a}=this.props,{didCatch:n,error:i}=this.state,o=e;if(n){let e={error:i,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)o=t(e);else if(r)o=(0,V.createElement)(r,e);else if(void 0!==a)o=a;else throw i}return(0,V.createElement)(z.Provider,{value:{didCatch:n,error:i,resetErrorBoundary:this.resetErrorBoundary}},o)}}var W=e.i(31067),X=u;function Y(e,t){if(t===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t!==u.TriangleFanDrawMode&&t!==u.TriangleStripDrawMode)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e;{let r=e.getIndex();if(null===r){let t=[],a=e.getAttribute("position");if(void 0===a)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<a.count;e++)t.push(e);e.setIndex(t),r=e.getIndex()}let a=r.count-2,n=[];if(r)if(t===u.TriangleFanDrawMode)for(let e=1;e<=a;e++)n.push(r.getX(0)),n.push(r.getX(e)),n.push(r.getX(e+1));else for(let e=0;e<a;e++)e%2==0?(n.push(r.getX(e)),n.push(r.getX(e+1)),n.push(r.getX(e+2))):(n.push(r.getX(e+2)),n.push(r.getX(e+1)),n.push(r.getX(e)));n.length/3!==a&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let i=e.clone();return i.setIndex(n),i.clearGroups(),i}}let Z=parseInt(u.REVISION.replace(/\D+/g,""));function $(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);let t="";for(let r=0,a=e.length;r<a;r++)t+=String.fromCharCode(e[r]);try{return decodeURIComponent(escape(t))}catch(e){return t}}let ee="srgb",et="srgb-linear";class er extends X.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new el(e)}),this.register(function(e){return new eu(e)}),this.register(function(e){return new ey(e)}),this.register(function(e){return new eA(e)}),this.register(function(e){return new eF(e)}),this.register(function(e){return new ed(e)}),this.register(function(e){return new ef(e)}),this.register(function(e){return new eh(e)}),this.register(function(e){return new em(e)}),this.register(function(e){return new es(e)}),this.register(function(e){return new ep(e)}),this.register(function(e){return new ec(e)}),this.register(function(e){return new ev(e)}),this.register(function(e){return new eg(e)}),this.register(function(e){return new ei(e)}),this.register(function(e){return new eb(e)}),this.register(function(e){return new eC(e)})}load(e,t,r,a){let n,i=this;if(""!==this.resourcePath)n=this.resourcePath;else if(""!==this.path){let t=X.LoaderUtils.extractUrlBase(e);n=X.LoaderUtils.resolveURL(t,this.path)}else n=X.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){a?a(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new X.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(r){try{i.parse(r,n,function(r){t(r),i.manager.itemEnd(e)},o)}catch(e){o(e)}},r,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return -1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return -1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,a){let n,i={},o={};if("string"==typeof e)n=JSON.parse(e);else if(e instanceof ArrayBuffer)if($(new Uint8Array(e.slice(0,4)))===eB){try{i[en.KHR_BINARY_GLTF]=new eS(e)}catch(e){a&&a(e);return}n=JSON.parse(i[en.KHR_BINARY_GLTF].content)}else n=JSON.parse($(new Uint8Array(e)));else n=e;if(void 0===n.asset||n.asset.version[0]<2){a&&a(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let s=new eK(n,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});s.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](s);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[t.name]=t,i[t.name]=!0}if(n.extensionsUsed)for(let e=0;e<n.extensionsUsed.length;++e){let t=n.extensionsUsed[e],r=n.extensionsRequired||[];switch(t){case en.KHR_MATERIALS_UNLIT:i[t]=new eo;break;case en.KHR_DRACO_MESH_COMPRESSION:i[t]=new ex(n,this.dracoLoader);break;case en.KHR_TEXTURE_TRANSFORM:i[t]=new eE;break;case en.KHR_MESH_QUANTIZATION:i[t]=new eM;break;default:r.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}s.setExtensions(i),s.setPlugins(o),s.parse(r,a)}parseAsync(e,t){let r=this;return new Promise(function(a,n){r.parse(e,t,a,n)})}}function ea(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let en={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ei{constructor(e){this.parser=e,this.name=en.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let r=0,a=t.length;r<a;r++){let a=t[r];a.extensions&&a.extensions[this.name]&&void 0!==a.extensions[this.name].light&&e._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(e){let t,r=this.parser,a="light:"+e,n=r.cache.get(a);if(n)return n;let i=r.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],s=new X.Color(0xffffff);void 0!==o.color&&s.setRGB(o.color[0],o.color[1],o.color[2],et);let l=void 0!==o.range?o.range:0;switch(o.type){case"directional":(t=new X.DirectionalLight(s)).target.position.set(0,0,-1),t.add(t.target);break;case"point":(t=new X.PointLight(s)).distance=l;break;case"spot":(t=new X.SpotLight(s)).distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,t.angle=o.spot.outerConeAngle,t.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,t.target.position.set(0,0,-1),t.add(t.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return t.position.set(0,0,0),t.decay=2,eU(t,o),void 0!==o.intensity&&(t.intensity=o.intensity),t.name=r.createUniqueName(o.name||"light_"+e),n=Promise.resolve(t),r.cache.add(a,n),n}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){let t=this,r=this.parser,a=r.json.nodes[e],n=(a.extensions&&a.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then(function(e){return r._getNodeRef(t.cache,n,e)})}}class eo{constructor(){this.name=en.KHR_MATERIALS_UNLIT}getMaterialType(){return X.MeshBasicMaterial}extendParams(e,t,r){let a=[];e.color=new X.Color(1,1,1),e.opacity=1;let n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){let t=n.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],et),e.opacity=t[3]}void 0!==n.baseColorTexture&&a.push(r.assignTexture(e,"map",n.baseColorTexture,ee))}return Promise.all(a)}}class es{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let a=r.extensions[this.name].emissiveStrength;return void 0!==a&&(t.emissiveIntensity=a),Promise.resolve()}}class el{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,a=r.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();let n=[],i=a.extensions[this.name];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&n.push(r.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&n.push(r.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(n.push(r.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){let e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new X.Vector2(e,e)}return Promise.all(n)}}class eu{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_DISPERSION}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let a=r.extensions[this.name];return t.dispersion=void 0!==a.dispersion?a.dispersion:0,Promise.resolve()}}class ec{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,a=r.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();let n=[],i=a.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&n.push(r.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&n.push(r.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(n)}}class ed{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_SHEEN}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,a=r.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();let n=[];t.sheenColor=new X.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;let i=a.extensions[this.name];if(void 0!==i.sheenColorFactor){let e=i.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],et)}return void 0!==i.sheenRoughnessFactor&&(t.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&n.push(r.assignTexture(t,"sheenColorMap",i.sheenColorTexture,ee)),void 0!==i.sheenRoughnessTexture&&n.push(r.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(n)}}class ef{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,a=r.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();let n=[],i=a.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&n.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(n)}}class eh{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_VOLUME}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,a=r.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();let n=[],i=a.extensions[this.name];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&n.push(r.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;let o=i.attenuationColor||[1,1,1];return t.attenuationColor=new X.Color().setRGB(o[0],o[1],o[2],et),Promise.all(n)}}class em{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_IOR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let a=r.extensions[this.name];return t.ior=void 0!==a.ior?a.ior:1.5,Promise.resolve()}}class ep{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_SPECULAR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,a=r.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();let n=[],i=a.extensions[this.name];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&n.push(r.assignTexture(t,"specularIntensityMap",i.specularTexture));let o=i.specularColorFactor||[1,1,1];return t.specularColor=new X.Color().setRGB(o[0],o[1],o[2],et),void 0!==i.specularColorTexture&&n.push(r.assignTexture(t,"specularColorMap",i.specularColorTexture,ee)),Promise.all(n)}}class eg{constructor(e){this.parser=e,this.name=en.EXT_MATERIALS_BUMP}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,a=r.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();let n=[],i=a.extensions[this.name];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&n.push(r.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(n)}}class ev{constructor(e){this.parser=e,this.name=en.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?X.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,a=r.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();let n=[],i=a.extensions[this.name];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&n.push(r.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(n)}}class ey{constructor(e){this.parser=e,this.name=en.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,r=t.json,a=r.textures[e];if(!a.extensions||!a.extensions[this.name])return null;let n=a.extensions[this.name],i=t.options.ktx2Loader;if(!i)if(!(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0))return null;else throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return t.loadTextureImage(e,n.source,i)}}class eA{constructor(e){this.parser=e,this.name=en.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,a=r.json,n=a.textures[e];if(!n.extensions||!n.extensions[t])return null;let i=n.extensions[t],o=a.images[i.source],s=r.textureLoader;if(o.uri){let e=r.options.manager.getHandler(o.uri);null!==e&&(s=e)}return this.detectSupport().then(function(n){if(n)return r.loadTextureImage(e,i.source,s);if(a.extensionsRequired&&a.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class eF{constructor(e){this.parser=e,this.name=en.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,a=r.json,n=a.textures[e];if(!n.extensions||!n.extensions[t])return null;let i=n.extensions[t],o=a.images[i.source],s=r.textureLoader;if(o.uri){let e=r.options.manager.getHandler(o.uri);null!==e&&(s=e)}return this.detectSupport().then(function(n){if(n)return r.loadTextureImage(e,i.source,s);if(a.extensionsRequired&&a.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class eb{constructor(e){this.name=en.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,r=t.bufferViews[e];if(!r.extensions||!r.extensions[this.name])return null;{let e=r.extensions[this.name],a=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported)if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;else throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return a.then(function(t){let r=e.byteOffset||0,a=e.byteLength||0,i=e.count,o=e.byteStride,s=new Uint8Array(t,r,a);return n.decodeGltfBufferAsync?n.decodeGltfBufferAsync(i,o,s,e.mode,e.filter).then(function(e){return e.buffer}):n.ready.then(function(){let t=new ArrayBuffer(i*o);return n.decodeGltfBuffer(new Uint8Array(t),i,o,s,e.mode,e.filter),t})})}}}class eC{constructor(e){this.name=en.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;for(let e of t.meshes[r.mesh].primitives)if(e.mode!==eI.TRIANGLES&&e.mode!==eI.TRIANGLE_STRIP&&e.mode!==eI.TRIANGLE_FAN&&void 0!==e.mode)return null;let a=r.extensions[this.name].attributes,n=[],i={};for(let e in a)n.push(this.parser.getDependency("accessor",a[e]).then(t=>(i[e]=t,i[e])));return n.length<1?null:(n.push(this.parser.createNodeMesh(e)),Promise.all(n).then(e=>{let t=e.pop(),r=t.isGroup?t.children:[t],a=e[0].count,n=[];for(let e of r){let t=new X.Matrix4,r=new X.Vector3,o=new X.Quaternion,s=new X.Vector3(1,1,1),l=new X.InstancedMesh(e.geometry,e.material,a);for(let e=0;e<a;e++)i.TRANSLATION&&r.fromBufferAttribute(i.TRANSLATION,e),i.ROTATION&&o.fromBufferAttribute(i.ROTATION,e),i.SCALE&&s.fromBufferAttribute(i.SCALE,e),l.setMatrixAt(e,t.compose(r,o,s));for(let t in i)if("_COLOR_0"===t){let e=i[t];l.instanceColor=new X.InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,i[t]);X.Object3D.prototype.copy.call(l,e),this.parser.assignFinalMaterial(l),n.push(l)}return t.isGroup?(t.clear(),t.add(...n),t):n[0]}))}}let eB="glTF";class eS{constructor(e){this.name=en.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:$(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==eB)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,a=new DataView(e,12);let n=0;for(;n<r;){const t=a.getUint32(n,!0);n+=4;const r=a.getUint32(n,!0);if(n+=4,0x4e4f534a===r){const r=new Uint8Array(e,12+n,t);this.content=$(r)}else if(5130562===r){const r=12+n;this.body=e.slice(r,r+t)}n+=t}if(null===this.content)throw Error("THREE.GLTFLoader: JSON content not found.")}}class ex{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=en.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let r=this.json,a=this.dracoLoader,n=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},s={},l={};for(let e in i)o[eL[e]||e.toLowerCase()]=i[e];for(let t in e.attributes){let a=eL[t]||t.toLowerCase();if(void 0!==i[t]){let n=r.accessors[e.attributes[t]],i=eT[n.componentType];l[a]=i.name,s[a]=!0===n.normalized}}return t.getDependency("bufferView",n).then(function(e){return new Promise(function(t,r){a.decodeDracoFile(e,function(e){for(let t in e.attributes){let r=e.attributes[t],a=s[t];void 0!==a&&(r.normalized=a)}t(e)},o,l,et,r)})})}}class eE{constructor(){this.name=en.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(void 0===t.texCoord||t.texCoord===e.channel)&&void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class eM{constructor(){this.name=en.KHR_MESH_QUANTIZATION}}class eD extends X.Interpolant{constructor(e,t,r,a){super(e,t,r,a)}copySampleValue_(e){let t=this.resultBuffer,r=this.sampleValues,a=this.valueSize,n=e*a*3+a;for(let e=0;e!==a;e++)t[e]=r[n+e];return t}interpolate_(e,t,r,a){let n=this.resultBuffer,i=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,u=a-t,c=(r-t)/u,d=c*c,f=d*c,h=e*l,m=h-l,p=-2*f+3*d,g=f-d,v=1-p,y=g-d+c;for(let e=0;e!==o;e++){let t=i[m+e+o],r=i[m+e+s]*u,a=i[h+e+o],l=i[h+e]*u;n[e]=v*t+y*r+p*a+g*l}return n}}let ek=new X.Quaternion;class ew extends eD{interpolate_(e,t,r,a){let n=super.interpolate_(e,t,r,a);return ek.fromArray(n).normalize().toArray(n),n}}let eI={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},eT={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},eR={9728:X.NearestFilter,9729:X.LinearFilter,9984:X.NearestMipmapNearestFilter,9985:X.LinearMipmapNearestFilter,9986:X.NearestMipmapLinearFilter,9987:X.LinearMipmapLinearFilter},eP={33071:X.ClampToEdgeWrapping,33648:X.MirroredRepeatWrapping,10497:X.RepeatWrapping},eG={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eL={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Z>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ej={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},e_={CUBICSPLINE:void 0,LINEAR:X.InterpolateLinear,STEP:X.InterpolateDiscrete};function eO(e,t,r){for(let a in r.extensions)void 0===e[a]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[a]=r.extensions[a])}function eU(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function eH(e){let t="",r=Object.keys(e).sort();for(let a=0,n=r.length;a<n;a++)t+=r[a]+":"+e[r[a]]+";";return t}function eN(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}let eJ=new X.Matrix4;class eK{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ea,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,a=!1,n=-1;"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),n=(a=navigator.userAgent.indexOf("Firefox")>-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||r||a&&n<98?this.textureLoader=new X.TextureLoader(this.options.manager):this.textureLoader=new X.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new X.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let r=this,a=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(t){let i={scene:t[0][a.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:a.asset,parser:r,userData:{}};return eO(n,i,a),eU(i,a),Promise.all(r._invokeAll(function(e){return e.afterRoot&&e.afterRoot(i)})).then(function(){for(let e of i.scenes)e.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let r=0,a=t.length;r<a;r++){let a=t[r].joints;for(let t=0,r=a.length;t<r;t++)e[a[t]].isBone=!0}for(let t=0,a=e.length;t<a;t++){let a=e[t];void 0!==a.mesh&&(this._addNodeRef(this.meshCache,a.mesh),void 0!==a.skin&&(r[a.mesh].isSkinnedMesh=!0)),void 0!==a.camera&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;let a=r.clone(),n=(e,t)=>{let r=this.associations.get(e);for(let[a,i]of(null!=r&&this.associations.set(t,r),e.children.entries()))n(i,t.children[a])};return n(r,a),a.name+="_instance_"+e.uses[t]++,a}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){let a=e(t[r]);if(a)return a}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let r=[];for(let a=0;a<t.length;a++){let n=e(t[a]);n&&r.push(n)}return r}getDependency(e,t){let r=e+":"+t,a=this.cache.get(r);if(!a){switch(e){case"scene":a=this.loadScene(t);break;case"node":a=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":a=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":a=this.loadAccessor(t);break;case"bufferView":a=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":a=this.loadBuffer(t);break;case"material":a=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":a=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":a=this.loadSkin(t);break;case"animation":a=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":a=this.loadCamera(t);break;default:if(!(a=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)})))throw Error("Unknown type: "+e)}this.cache.add(r,a)}return a}getDependencies(e){let t=this.cache.get(e);if(!t){let r=this;t=Promise.all((this.json[e+("mesh"===e?"es":"s")]||[]).map(function(t,a){return r.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[en.KHR_BINARY_GLTF].body);let a=this.options;return new Promise(function(e,n){r.load(X.LoaderUtils.resolveURL(t.uri,a.path),e,void 0,function(){n(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){let r=t.byteLength||0,a=t.byteOffset||0;return e.slice(a,a+r)})}loadAccessor(e){let t=this,r=this.json,a=this.json.accessors[e];if(void 0===a.bufferView&&void 0===a.sparse){let e=eG[a.type],t=eT[a.componentType],r=!0===a.normalized,n=new t(a.count*e);return Promise.resolve(new X.BufferAttribute(n,e,r))}let n=[];return void 0!==a.bufferView?n.push(this.getDependency("bufferView",a.bufferView)):n.push(null),void 0!==a.sparse&&(n.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(n).then(function(e){let n,i,o=e[0],s=eG[a.type],l=eT[a.componentType],u=l.BYTES_PER_ELEMENT,c=u*s,d=a.byteOffset||0,f=void 0!==a.bufferView?r.bufferViews[a.bufferView].byteStride:void 0,h=!0===a.normalized;if(f&&f!==c){let e=Math.floor(d/f),r="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+e+":"+a.count,c=t.cache.get(r);c||(n=new l(o,e*f,a.count*f/u),c=new X.InterleavedBuffer(n,f/u),t.cache.add(r,c)),i=new X.InterleavedBufferAttribute(c,s,d%f/u,h)}else n=null===o?new l(a.count*s):new l(o,d,a.count*s),i=new X.BufferAttribute(n,s,h);if(void 0!==a.sparse){let t=eG.SCALAR,r=eT[a.sparse.indices.componentType],n=a.sparse.indices.byteOffset||0,u=a.sparse.values.byteOffset||0,c=new r(e[1],n,a.sparse.count*t),d=new l(e[2],u,a.sparse.count*s);null!==o&&(i=new X.BufferAttribute(i.array.slice(),i.itemSize,i.normalized));for(let e=0,t=c.length;e<t;e++){let t=c[e];if(i.setX(t,d[e*s]),s>=2&&i.setY(t,d[e*s+1]),s>=3&&i.setZ(t,d[e*s+2]),s>=4&&i.setW(t,d[e*s+3]),s>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return i})}loadTexture(e){let t=this.json,r=this.options,a=t.textures[e].source,n=t.images[a],i=this.textureLoader;if(n.uri){let e=r.manager.getHandler(n.uri);null!==e&&(i=e)}return this.loadTextureImage(e,a,i)}loadTextureImage(e,t,r){let a=this,n=this.json,i=n.textures[e],o=n.images[t],s=(o.uri||o.bufferView)+":"+i.sampler;if(this.textureCache[s])return this.textureCache[s];let l=this.loadImageSource(t,r).then(function(t){t.flipY=!1,t.name=i.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);let r=(n.samplers||{})[i.sampler]||{};return t.magFilter=eR[r.magFilter]||X.LinearFilter,t.minFilter=eR[r.minFilter]||X.LinearMipmapLinearFilter,t.wrapS=eP[r.wrapS]||X.RepeatWrapping,t.wrapT=eP[r.wrapT]||X.RepeatWrapping,a.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=l,l}loadImageSource(e,t){let r=this.json,a=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let n=r.images[e],i=self.URL||self.webkitURL,o=n.uri||"",s=!1;if(void 0!==n.bufferView)o=this.getDependency("bufferView",n.bufferView).then(function(e){s=!0;let t=new Blob([e],{type:n.mimeType});return o=i.createObjectURL(t)});else if(void 0===n.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(e){return new Promise(function(r,n){let i=r;!0===t.isImageBitmapLoader&&(i=function(e){let t=new X.Texture(e);t.needsUpdate=!0,r(t)}),t.load(X.LoaderUtils.resolveURL(e,a.path),i,void 0,n)})}).then(function(e){var t;return!0===s&&i.revokeObjectURL(o),eU(e,n),e.userData.mimeType=n.mimeType||((t=n.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e});return this.sourceCache[e]=l,l}assignTexture(e,t,r,a){let n=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(void 0!==r.texCoord&&r.texCoord>0&&((i=i.clone()).channel=r.texCoord),n.extensions[en.KHR_TEXTURE_TRANSFORM]){let e=void 0!==r.extensions?r.extensions[en.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=n.associations.get(i);i=n.extensions[en.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),n.associations.set(i,t)}}return void 0!==a&&("number"==typeof a&&(a=3001===a?ee:et),"colorSpace"in i?i.colorSpace=a:i.encoding=a===ee?3001:3e3),e[t]=i,i})}assignFinalMaterial(e){let t=e.geometry,r=e.material,a=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,i=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new X.PointsMaterial,X.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){let e="LineBasicMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new X.LineBasicMaterial,X.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,this.cache.add(e,t)),r=t}if(a||n||i){let e="ClonedMaterial:"+r.uuid+":";a&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),i&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),n&&(t.vertexColors=!0),i&&(t.flatShading=!0),a&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}e.material=r}getMaterialType(){return X.MeshStandardMaterial}loadMaterial(e){let t,r=this,a=this.json,n=this.extensions,i=a.materials[e],o={},s=i.extensions||{},l=[];if(s[en.KHR_MATERIALS_UNLIT]){let e=n[en.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),l.push(e.extendParams(o,i,r))}else{let a=i.pbrMetallicRoughness||{};if(o.color=new X.Color(1,1,1),o.opacity=1,Array.isArray(a.baseColorFactor)){let e=a.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],et),o.opacity=e[3]}void 0!==a.baseColorTexture&&l.push(r.assignTexture(o,"map",a.baseColorTexture,ee)),o.metalness=void 0!==a.metallicFactor?a.metallicFactor:1,o.roughness=void 0!==a.roughnessFactor?a.roughnessFactor:1,void 0!==a.metallicRoughnessTexture&&(l.push(r.assignTexture(o,"metalnessMap",a.metallicRoughnessTexture)),l.push(r.assignTexture(o,"roughnessMap",a.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}!0===i.doubleSided&&(o.side=X.DoubleSide);let u=i.alphaMode||"OPAQUE";if("BLEND"===u?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===u&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&t!==X.MeshBasicMaterial&&(l.push(r.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new X.Vector2(1,1),void 0!==i.normalTexture.scale)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&t!==X.MeshBasicMaterial&&(l.push(r.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&t!==X.MeshBasicMaterial){let e=i.emissiveFactor;o.emissive=new X.Color().setRGB(e[0],e[1],e[2],et)}return void 0!==i.emissiveTexture&&t!==X.MeshBasicMaterial&&l.push(r.assignTexture(o,"emissiveMap",i.emissiveTexture,ee)),Promise.all(l).then(function(){let a=new t(o);return i.name&&(a.name=i.name),eU(a,i),r.associations.set(a,{materials:e}),i.extensions&&eO(n,a,i),a})}createUniqueName(e){let t=X.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,r=this.extensions,a=this.primitiveCache,n=[];for(let i=0,o=e.length;i<o;i++){let o=e[i],s=function(e){let t,r=e.extensions&&e.extensions[en.KHR_DRACO_MESH_COMPRESSION];if(t=r?"draco:"+r.bufferView+":"+r.indices+":"+eH(r.attributes):e.indices+":"+eH(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,a=e.targets.length;r<a;r++)t+=":"+eH(e.targets[r]);return t}(o),l=a[s];if(l)n.push(l.promise);else{let e;e=o.extensions&&o.extensions[en.KHR_DRACO_MESH_COMPRESSION]?function(e){return r[en.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(r){return eV(r,e,t)})}(o):eV(new X.BufferGeometry,o,t),a[s]={primitive:o,promise:e},n.push(e)}}return Promise.all(n)}loadMesh(e){let t=this,r=this.json,a=this.extensions,n=r.meshes[e],i=n.primitives,o=[];for(let e=0,t=i.length;e<t;e++){var s;let t=void 0===i[e].material?(void 0===(s=this.cache).DefaultMaterial&&(s.DefaultMaterial=new X.MeshStandardMaterial({color:0xffffff,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:X.FrontSide})),s.DefaultMaterial):this.getDependency("material",i[e].material);o.push(t)}return o.push(t.loadGeometries(i)),Promise.all(o).then(function(r){let o=r.slice(0,r.length-1),s=r[r.length-1],l=[];for(let r=0,u=s.length;r<u;r++){let u,c=s[r],d=i[r],f=o[r];if(d.mode===eI.TRIANGLES||d.mode===eI.TRIANGLE_STRIP||d.mode===eI.TRIANGLE_FAN||void 0===d.mode)!0===(u=!0===n.isSkinnedMesh?new X.SkinnedMesh(c,f):new X.Mesh(c,f)).isSkinnedMesh&&u.normalizeSkinWeights(),d.mode===eI.TRIANGLE_STRIP?u.geometry=Y(u.geometry,X.TriangleStripDrawMode):d.mode===eI.TRIANGLE_FAN&&(u.geometry=Y(u.geometry,X.TriangleFanDrawMode));else if(d.mode===eI.LINES)u=new X.LineSegments(c,f);else if(d.mode===eI.LINE_STRIP)u=new X.Line(c,f);else if(d.mode===eI.LINE_LOOP)u=new X.LineLoop(c,f);else if(d.mode===eI.POINTS)u=new X.Points(c,f);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);Object.keys(u.geometry.morphAttributes).length>0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,a=t.weights.length;r<a;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){let r=t.extras.targetNames;if(e.morphTargetInfluences.length===r.length){e.morphTargetDictionary={};for(let t=0,a=r.length;t<a;t++)e.morphTargetDictionary[r[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}(u,n),u.name=t.createUniqueName(n.name||"mesh_"+e),eU(u,n),d.extensions&&eO(a,u,d),t.assignFinalMaterial(u),l.push(u)}for(let r=0,a=l.length;r<a;r++)t.associations.set(l[r],{meshes:e,primitives:r});if(1===l.length)return n.extensions&&eO(a,l[0],n),l[0];let u=new X.Group;n.extensions&&eO(a,u,n),t.associations.set(u,{meshes:e});for(let e=0,t=l.length;e<t;e++)u.add(l[e]);return u})}loadCamera(e){let t,r=this.json.cameras[e],a=r[r.type];return a?("perspective"===r.type?t=new X.PerspectiveCamera(X.MathUtils.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):"orthographic"===r.type&&(t=new X.OrthographicCamera(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),eU(t,r),Promise.resolve(t)):void console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){let t=this.json.skins[e],r=[];for(let e=0,a=t.joints.length;e<a;e++)r.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(e){let r=e.pop(),a=[],n=[];for(let i=0,o=e.length;i<o;i++){let o=e[i];if(o){a.push(o);let e=new X.Matrix4;null!==r&&e.fromArray(r.array,16*i),n.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[i])}return new X.Skeleton(a,n)})}loadAnimation(e){let t=this.json,r=this,a=t.animations[e],n=a.name?a.name:"animation_"+e,i=[],o=[],s=[],l=[],u=[];for(let e=0,t=a.channels.length;e<t;e++){let t=a.channels[e],r=a.samplers[t.sampler],n=t.target,c=n.node,d=void 0!==a.parameters?a.parameters[r.input]:r.input,f=void 0!==a.parameters?a.parameters[r.output]:r.output;void 0!==n.node&&(i.push(this.getDependency("node",c)),o.push(this.getDependency("accessor",d)),s.push(this.getDependency("accessor",f)),l.push(r),u.push(n))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(s),Promise.all(l),Promise.all(u)]).then(function(e){let t=e[0],a=e[1],i=e[2],o=e[3],s=e[4],l=[];for(let e=0,n=t.length;e<n;e++){let n=t[e],u=a[e],c=i[e],d=o[e],f=s[e];if(void 0===n)continue;n.updateMatrix&&n.updateMatrix();let h=r._createAnimationTracks(n,u,c,d,f);if(h)for(let e=0;e<h.length;e++)l.push(h[e])}return new X.AnimationClip(n,void 0,l)})}createNodeMesh(e){let t=this.json,r=this,a=t.nodes[e];return void 0===a.mesh?null:r.getDependency("mesh",a.mesh).then(function(e){let t=r._getNodeRef(r.meshCache,a.mesh,e);return void 0!==a.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,r=a.weights.length;t<r;t++)e.morphTargetInfluences[t]=a.weights[t]}),t})}loadNode(e){let t=this.json.nodes[e],r=this._loadNodeShallow(e),a=[],n=t.children||[];for(let e=0,t=n.length;e<t;e++)a.push(this.getDependency("node",n[e]));let i=void 0===t.skin?Promise.resolve(null):this.getDependency("skin",t.skin);return Promise.all([r,Promise.all(a),i]).then(function(e){let t=e[0],r=e[1],a=e[2];null!==a&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(a,eJ)});for(let e=0,a=r.length;e<a;e++)t.add(r[e]);return t})}_loadNodeShallow(e){let t=this.json,r=this.extensions,a=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];let n=t.nodes[e],i=n.name?a.createUniqueName(n.name):"",o=[],s=a._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),void 0!==n.camera&&o.push(a.getDependency("camera",n.camera).then(function(e){return a._getNodeRef(a.cameraCache,n.camera,e)})),a._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if((o=!0===n.isBone?new X.Bone:t.length>1?new X.Group:1===t.length?t[0]:new X.Object3D)!==t[0])for(let e=0,r=t.length;e<r;e++)o.add(t[e]);if(n.name&&(o.userData.name=n.name,o.name=i),eU(o,n),n.extensions&&eO(r,o,n),void 0!==n.matrix){let e=new X.Matrix4;e.fromArray(n.matrix),o.applyMatrix4(e)}else void 0!==n.translation&&o.position.fromArray(n.translation),void 0!==n.rotation&&o.quaternion.fromArray(n.rotation),void 0!==n.scale&&o.scale.fromArray(n.scale);return a.associations.has(o)||a.associations.set(o,{}),a.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,r=this.json.scenes[e],a=this,n=new X.Group;r.name&&(n.name=a.createUniqueName(r.name)),eU(n,r),r.extensions&&eO(t,n,r);let i=r.nodes||[],o=[];for(let e=0,t=i.length;e<t;e++)o.push(a.getDependency("node",i[e]));return Promise.all(o).then(function(e){for(let t=0,r=e.length;t<r;t++)n.add(e[t]);return a.associations=(e=>{let t=new Map;for(let[e,r]of a.associations)(e instanceof X.Material||e instanceof X.Texture)&&t.set(e,r);return e.traverse(e=>{let r=a.associations.get(e);null!=r&&t.set(e,r)}),t})(n),n})}_createAnimationTracks(e,t,r,a,n){let i,o=[],s=e.name?e.name:e.uuid,l=[];switch(ej[n.path]===ej.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(s),ej[n.path]){case ej.weights:i=X.NumberKeyframeTrack;break;case ej.rotation:i=X.QuaternionKeyframeTrack;break;case ej.position:case ej.scale:i=X.VectorKeyframeTrack;break;default:i=1===r.itemSize?X.NumberKeyframeTrack:X.VectorKeyframeTrack}let u=void 0!==a.interpolation?e_[a.interpolation]:X.InterpolateLinear,c=this._getArrayFromAccessor(r);for(let e=0,r=l.length;e<r;e++){let r=new i(l[e]+"."+ej[n.path],t.array,c,u);"CUBICSPLINE"===a.interpolation&&this._createCubicSplineTrackInterpolant(r),o.push(r)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=eN(t.constructor),r=new Float32Array(t.length);for(let a=0,n=t.length;a<n;a++)r[a]=t[a]*e;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof X.QuaternionKeyframeTrack?ew:eD)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function eV(e,t,r){let a=t.attributes,n=[];for(let t in a){let i=eL[t]||t.toLowerCase();i in e.attributes||n.push(function(t,a){return r.getDependency("accessor",t).then(function(t){e.setAttribute(a,t)})}(a[t],i))}if(void 0!==t.indices&&!e.index){let a=r.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});n.push(a)}return eU(e,t),!function(e,t,r){let a=t.attributes,n=new X.Box3;if(void 0===a.POSITION)return;{let e=r.json.accessors[a.POSITION],t=e.min,i=e.max;if(void 0===t||void 0===i)return console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(n.set(new X.Vector3(t[0],t[1],t[2]),new X.Vector3(i[0],i[1],i[2])),e.normalized){let t=eN(eT[e.componentType]);n.min.multiplyScalar(t),n.max.multiplyScalar(t)}}let i=t.targets;if(void 0!==i){let e=new X.Vector3,t=new X.Vector3;for(let a=0,n=i.length;a<n;a++){let n=i[a];if(void 0!==n.POSITION){let a=r.json.accessors[n.POSITION],i=a.min,o=a.max;if(void 0!==i&&void 0!==o){if(t.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),a.normalized){let e=eN(eT[a.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(e)}e.boundingBox=n;let o=new X.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,e.boundingSphere=o}(e,t,r),Promise.all(n).then(function(){return void 0!==t.targets?function(e,t,r){let a=!1,n=!1,i=!1;for(let e=0,r=t.length;e<r;e++){let r=t[e];if(void 0!==r.POSITION&&(a=!0),void 0!==r.NORMAL&&(n=!0),void 0!==r.COLOR_0&&(i=!0),a&&n&&i)break}if(!a&&!n&&!i)return Promise.resolve(e);let o=[],s=[],l=[];for(let u=0,c=t.length;u<c;u++){let c=t[u];if(a){let t=void 0!==c.POSITION?r.getDependency("accessor",c.POSITION):e.attributes.position;o.push(t)}if(n){let t=void 0!==c.NORMAL?r.getDependency("accessor",c.NORMAL):e.attributes.normal;s.push(t)}if(i){let t=void 0!==c.COLOR_0?r.getDependency("accessor",c.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(l)]).then(function(t){let r=t[0],o=t[1],s=t[2];return a&&(e.morphAttributes.position=r),n&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}(e,t.targets,r):e})}var ez=u;let eq=new WeakMap;class eQ extends ez.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,r,a){let n=new ez.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,e=>{let r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,r).then(t).catch(a)},r,a)}decodeDracoFile(e,t,r,a){let n={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:a||this.defaultAttributeTypes,useUniqueIDs:!!r};this.decodeGeometry(e,n).then(t)}decodeGeometry(e,t){let r;for(let e in t.attributeTypes){let r=t.attributeTypes[e];void 0!==r.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=r.name)}let a=JSON.stringify(t);if(eq.has(e)){let t=eq.get(e);if(t.key===a)return t.promise;if(0===e.byteLength)throw Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n=this.workerNextTaskID++,i=e.byteLength,o=this._getWorker(n,i).then(a=>(r=a,new Promise((a,i)=>{r._callbacks[n]={resolve:a,reject:i},r.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return o.catch(()=>!0).then(()=>{r&&n&&this._releaseTask(r,n)}),eq.set(e,{key:a,promise:o}),o}_createGeometry(e){let t=new ez.BufferGeometry;e.index&&t.setIndex(new ez.BufferAttribute(e.index.array,1));for(let r=0;r<e.attributes.length;r++){let a=e.attributes[r],n=a.name,i=a.array,o=a.itemSize;t.setAttribute(n,new ez.BufferAttribute(i,o))}return t}_loadLibrary(e,t){let r=new ez.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((t,a)=>{r.load(e,t,void 0,a)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{let r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let a=eW.toString(),n=["/* draco decoder */",r,"\n/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){let r=t.data;switch(r.type){case"decode":e._callbacks[r.id].resolve(r);break;case"error":e._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort(function(e,t){return e._taskLoad>t._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function eW(){let e,t;onmessage=function(r){let a=r.data;switch(a.type){case"init":e=a.decoderConfig,t=new Promise(function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)});break;case"decode":let n=a.buffer,i=a.taskConfig;t.then(e=>{let t=e.draco,r=new t.Decoder,o=new t.DecoderBuffer;o.Init(new Int8Array(n),n.byteLength);try{let e=function(e,t,r,a){var n,i,o;let s,l,u,c,d,f,h=a.attributeIDs,m=a.attributeTypes,p=t.GetEncodedGeometryType(r);if(p===e.TRIANGULAR_MESH)d=new e.Mesh,f=t.DecodeBufferToMesh(r,d);else if(p===e.POINT_CLOUD)d=new e.PointCloud,f=t.DecodeBufferToPointCloud(r,d);else throw Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||0===d.ptr)throw Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let g={index:null,attributes:[]};for(let r in h){let n,i,o=self[m[r]];if(a.useUniqueIDs)i=h[r],n=t.GetAttributeByUniqueId(d,i);else{if(-1===(i=t.GetAttributeId(d,e[h[r]])))continue;n=t.GetAttribute(d,i)}g.attributes.push(function(e,t,r,a,n,i){let o=i.num_components(),s=r.num_points()*o,l=s*n.BYTES_PER_ELEMENT,u=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,n),c=e._malloc(l);t.GetAttributeDataArrayForAllPoints(r,i,u,l,c);let d=new n(e.HEAPF32.buffer,c,s).slice();return e._free(c),{name:a,array:d,itemSize:o}}(e,t,d,r,o,n))}return p===e.TRIANGULAR_MESH&&(n=e,i=t,o=d,s=3*o.num_faces(),l=4*s,u=n._malloc(l),i.GetTrianglesUInt32Array(o,l,u),c=new Uint32Array(n.HEAPF32.buffer,u,s).slice(),n._free(u),g.index={array:c,itemSize:1}),e.destroy(d),g}(t,r,o,i),n=e.attributes.map(e=>e.array.buffer);e.index&&n.push(e.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:e},n)}catch(e){console.error(e),self.postMessage({type:"error",id:a.id,error:e.message})}finally{t.destroy(o),t.destroy(r)}})}}}var eX=e.i(971);let eY=function(e){let t=new Map,r=new Map,a=e.clone();return function e(t,r,a){a(t,r);for(let n=0;n<t.children.length;n++)e(t.children[n],r.children[n],a)}(e,a,function(e,a){t.set(a,e),r.set(e,a)}),a.traverse(function(e){if(!e.isSkinnedMesh)return;let a=t.get(e),n=a.skeleton.bones;e.skeleton=a.skeleton.clone(),e.bindMatrix.copy(a.bindMatrix),e.skeleton.bones=n.map(function(e){return r.get(e)}),e.bind(e.skeleton,e.bindMatrix)}),a},eZ=o.forwardRef(({isChild:e=!1,object:t,children:r,deep:a,castShadow:n,receiveShadow:i,inject:s,keys:l,...c},d)=>{let f={keys:l,deep:a,inject:s,castShadow:n,receiveShadow:i};if(Array.isArray(t=o.useMemo(()=>{if(!1===e&&!Array.isArray(t)){let e=!1;if(t.traverse(t=>{t.isSkinnedMesh&&(e=!0)}),e)return eY(t)}return t},[t,e])))return o.createElement("group",(0,W.default)({},c,{ref:d}),t.map(e=>o.createElement(eZ,(0,W.default)({key:e.uuid,object:e},f))),r);let{children:h,...m}=function(e,{keys:t=["near","far","color","distance","decay","penumbra","angle","intensity","skeleton","visible","castShadow","receiveShadow","morphTargetDictionary","morphTargetInfluences","name","geometry","material","position","rotation","scale","up","userData","bindMode","bindMatrix","bindMatrixInverse","skeleton"],deep:r,inject:a,castShadow:n,receiveShadow:i}){let s={};for(let r of t)s[r]=e[r];return r&&(s.geometry&&"materialsOnly"!==r&&(s.geometry=s.geometry.clone()),s.material&&"geometriesOnly"!==r&&(s.material=s.material.clone())),a&&(s="function"==typeof a?{...s,children:a(e)}:o.isValidElement(a)?{...s,children:a}:{...s,...a}),e instanceof u.Mesh&&(n&&(s.castShadow=!0),i&&(s.receiveShadow=!0)),s}(t,f),p=t.type[0].toLowerCase()+t.type.slice(1);return o.createElement(p,(0,W.default)({},m,c,{ref:d}),t.children.map(e=>"Bone"===e.type?o.createElement("primitive",(0,W.default)({key:e.uuid,object:e},f)):o.createElement(eZ,(0,W.default)({key:e.uuid,object:e},f,{isChild:!0}))),r,h)}),e$=null,e0="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function e1(e=!0,r=!0,a){return n=>{a&&a(n),e&&(e$||(e$=new eQ),e$.setDecoderPath("string"==typeof e?e:e0),n.setDRACOLoader(e$)),r&&n.setMeshoptDecoder((()=>{let e;if(t)return t;let r=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),a=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if("object"!=typeof WebAssembly)return{supported:!1};let n="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB";WebAssembly.validate(r)&&(n="B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB");let i=WebAssembly.instantiate(function(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r){let a=e.charCodeAt(r);t[r]=a>96?a-71:a>64?a-65:a>47?a+4:a>46?63:62}let r=0;for(let n=0;n<e.length;++n)t[r++]=t[n]<60?a[t[n]]:(t[n]-60)*64+t[++n];return t.buffer.slice(0,r)}(n),{}).then(t=>{(e=t.instance).exports.__wasm_call_ctors()});function o(t,r,a,n,i,o){let s=e.exports.sbrk,l=a+3&-4,u=s(l*n),c=s(i.length),d=new Uint8Array(e.exports.memory.buffer);d.set(i,c);let f=t(u,a,n,c,i.length);if(0===f&&o&&o(u,l,n),r.set(d.subarray(u,u+a*n)),s(u-s(0)),0!==f)throw Error(`Malformed buffer data: ${f}`)}let s={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},l={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return t={ready:i,supported:!0,decodeVertexBuffer(t,r,a,n,i){o(e.exports.meshopt_decodeVertexBuffer,t,r,a,n,e.exports[s[i]])},decodeIndexBuffer(t,r,a,n){o(e.exports.meshopt_decodeIndexBuffer,t,r,a,n)},decodeIndexSequence(t,r,a,n){o(e.exports.meshopt_decodeIndexSequence,t,r,a,n)},decodeGltfBuffer(t,r,a,n,i,u){o(e.exports[l[i]],t,r,a,n,e.exports[s[u]])}}})())}}let e2=(e,t,r,a)=>(0,eX.useLoader)(er,e,e1(t,r,a));e2.preload=(e,t,r,a)=>eX.useLoader.preload(er,e,e1(t,r,a)),e2.clear=e=>eX.useLoader.clear(er,e),e2.setDecoderPath=e=>{e0=e};var e3=e.i(89887);let e9=`
|
||
vec3 interiorLinearToSRGB(vec3 linear) {
|
||
vec3 higher = pow(linear, vec3(1.0/2.4)) * 1.055 - 0.055;
|
||
vec3 lower = linear * 12.92;
|
||
return mix(lower, higher, step(vec3(0.0031308), linear));
|
||
}
|
||
|
||
vec3 interiorSRGBToLinear(vec3 srgb) {
|
||
vec3 higher = pow((srgb + 0.055) / 1.055, vec3(2.4));
|
||
vec3 lower = srgb / 12.92;
|
||
return mix(lower, higher, step(vec3(0.04045), srgb));
|
||
}
|
||
|
||
// Debug grid overlay function using screen-space derivatives for sharp, anti-aliased lines
|
||
// Returns 1.0 on grid lines, 0.0 elsewhere
|
||
float debugGrid(vec2 uv, float gridSize, float lineWidth) {
|
||
vec2 scaledUV = uv * gridSize;
|
||
vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV);
|
||
float line = min(grid.x, grid.y);
|
||
return 1.0 - min(line / lineWidth, 1.0);
|
||
}
|
||
`;function e5({materialName:e,material:t,lightMap:r}){let a=(0,E.useDebug)(),i=a?.debugMode??!1,s=(0,y.textureToUrl)(e),l=(0,B.useTexture)(s,e=>(0,C.setupTexture)(e)),c=new Set(t?.userData?.flag_names??[]).has("SelfIlluminating"),d=new Set(t?.userData?.surface_flag_names??[]).has("SurfaceOutsideVisible"),f=(0,o.useCallback)(e=>{let t;(0,M.injectCustomFog)(e,D.globalFogUniforms),t=d??!1,e.uniforms.useSceneLighting={value:t},e.uniforms.interiorDebugColor={value:t?new u.Vector3(0,.4,1):new u.Vector3(1,.2,0)},e.fragmentShader=e.fragmentShader.replace("#include <common>",`#include <common>
|
||
${e9}
|
||
uniform bool useSceneLighting;
|
||
uniform vec3 interiorDebugColor;
|
||
`),e.fragmentShader=e.fragmentShader.replace("#include <lights_fragment_maps>",`// Lightmap handled in custom output calculation
|
||
#ifdef USE_LIGHTMAP
|
||
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
||
#endif`),e.fragmentShader=e.fragmentShader.replace("#include <opaque_fragment>",`// Torque-style lighting: output = clamp(lighting \xd7 texture, 0, 1) in sRGB space
|
||
// Get texture in sRGB space (undo Three.js linear decode)
|
||
vec3 textureSRGB = interiorLinearToSRGB(diffuseColor.rgb);
|
||
|
||
// Compute lighting in sRGB space
|
||
vec3 lightingSRGB = vec3(0.0);
|
||
|
||
if (useSceneLighting) {
|
||
// Three.js computed: reflectedLight = lighting \xd7 texture_linear / PI
|
||
// Extract pure lighting: lighting = reflectedLight \xd7 PI / texture_linear
|
||
vec3 totalLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
||
vec3 safeTexLinear = max(diffuseColor.rgb, vec3(0.001));
|
||
vec3 extractedLighting = totalLight * PI / safeTexLinear;
|
||
// NOTE: extractedLighting is ALREADY sRGB values because mission sun/ambient colors
|
||
// are sRGB values (Torque used them directly in gamma space). Three.js treats them
|
||
// as linear but the numerical values are the same. DO NOT convert to sRGB here!
|
||
// IMPORTANT: Torque clamps scene lighting to [0,1] BEFORE adding to lightmap
|
||
// (sceneLighting.cc line 1785: tmp.clamp())
|
||
lightingSRGB = clamp(extractedLighting, 0.0, 1.0);
|
||
}
|
||
|
||
// Add lightmap contribution (for BOTH outside and inside surfaces)
|
||
// In Torque, scene lighting is ADDED to lightmaps for outside surfaces at mission load
|
||
// (stored in .ml files). Inside surfaces only have base lightmap. Both need lightmap here.
|
||
#ifdef USE_LIGHTMAP
|
||
// Lightmap is stored as linear in Three.js (decoded from sRGB texture), convert back
|
||
lightingSRGB += interiorLinearToSRGB(lightMapTexel.rgb);
|
||
#endif
|
||
// Torque clamps the sum to [0,1] per channel (sceneLighting.cc lines 1817-1827)
|
||
lightingSRGB = clamp(lightingSRGB, 0.0, 1.0);
|
||
|
||
// Torque formula: output = clamp(lighting \xd7 texture, 0, 1) in sRGB/gamma space
|
||
vec3 resultSRGB = clamp(lightingSRGB * textureSRGB, 0.0, 1.0);
|
||
|
||
// Convert back to linear for Three.js output pipeline
|
||
vec3 resultLinear = interiorSRGBToLinear(resultSRGB);
|
||
|
||
// Reassign outgoingLight before opaque_fragment consumes it
|
||
outgoingLight = resultLinear + totalEmissiveRadiance;
|
||
|
||
#include <opaque_fragment>`),e.fragmentShader=e.fragmentShader.replace("#include <tonemapping_fragment>",`// Debug mode: overlay colored grid on top of normal rendering
|
||
// Blue grid = SurfaceOutsideVisible (receives scene ambient light)
|
||
// Red grid = inside surface (no scene ambient light)
|
||
#if DEBUG_MODE && defined(USE_MAP)
|
||
// gridSize=4 creates 4x4 grid per UV tile, lineWidth=1.5 is ~1.5 pixels wide
|
||
float gridIntensity = debugGrid(vMapUv, 4.0, 1.5);
|
||
gl_FragColor.rgb = mix(gl_FragColor.rgb, interiorDebugColor, gridIntensity * 0.1);
|
||
#endif
|
||
|
||
#include <tonemapping_fragment>`)},[d]),h=(0,o.useRef)(null),m=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=h.current??m.current;e&&(e.defines??={},e.defines.DEBUG_MODE=+!!i,e.needsUpdate=!0)},[i]);let p={DEBUG_MODE:+!!i},g=`${d}`;return c?(0,n.jsx)("meshBasicMaterial",{ref:h,map:l,toneMapped:!1,defines:p,onBeforeCompile:f},g):(0,n.jsx)("meshLambertMaterial",{ref:m,map:l,lightMap:r,toneMapped:!1,defines:p,onBeforeCompile:f},g)}function e8(e){if(!e)return null;let t=e.emissiveMap;return t&&(t.colorSpace=u.SRGBColorSpace),t??null}function e4(e){let t,r,a,s=(0,i.c)(13),{node:l}=e;e:{let e,r;if(!l.material){let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],s[0]=e):e=s[0],t=e;break e}if(Array.isArray(l.material)){let e;s[1]!==l.material?(e=l.material.map(e6),s[1]=l.material,s[2]=e):e=s[2],t=e;break e}s[3]!==l.material?(e=e8(l.material),s[3]=l.material,s[4]=e):e=s[4],s[5]!==e?(r=[e],s[5]=e,s[6]=r):r=s[6],t=r}let u=t;return s[7]!==u||s[8]!==l.material?(r=l.material?(0,n.jsx)(o.Suspense,{fallback:(0,n.jsx)("meshStandardMaterial",{color:"yellow",wireframe:!0}),children:Array.isArray(l.material)?l.material.map((e,t)=>(0,n.jsx)(e5,{materialName:e.userData.resource_path,material:e,lightMap:u[t]},t)):(0,n.jsx)(e5,{materialName:l.material.userData.resource_path,material:l.material,lightMap:u[0]})}):null,s[7]=u,s[8]=l.material,s[9]=r):r=s[9],s[10]!==l.geometry||s[11]!==r?(a=(0,n.jsx)("mesh",{geometry:l.geometry,castShadow:!0,receiveShadow:!0,children:r}),s[10]=l.geometry,s[11]=r,s[12]=a):a=s[12],a}function e6(e){return e8(e)}let e7=(0,o.memo)(function(e){let t,r,a,o,s,l,u=(0,i.c)(10),{object:c,interiorFile:d}=e,{nodes:f}=((l=(0,i.c)(2))[0]!==d?(s=(0,y.interiorToUrl)(d),l[0]=d,l[1]=s):s=l[1],e2(s)),h=(0,E.useDebug)(),m=h?.debugMode??!1;return u[0]===Symbol.for("react.memo_cache_sentinel")?(t=[0,-Math.PI/2,0],u[0]=t):t=u[0],u[1]!==f?(r=Object.entries(f).filter(ta).map(tn),u[1]=f,u[2]=r):r=u[2],u[3]!==m||u[4]!==d||u[5]!==c?(a=m?(0,n.jsxs)(e3.FloatingLabel,{children:[c._id,": ",d]}):null,u[3]=m,u[4]=d,u[5]=c,u[6]=a):a=u[6],u[7]!==r||u[8]!==a?(o=(0,n.jsxs)("group",{rotation:t,children:[r,a]}),u[7]=r,u[8]=a,u[9]=o):o=u[9],o});function te(e){let t,r,a,o,s=(0,i.c)(9),{color:l,label:u}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)("boxGeometry",{args:[10,10,10]}),s[0]=t):t=s[0],s[1]!==l?(r=(0,n.jsx)("meshStandardMaterial",{color:l,wireframe:!0}),s[1]=l,s[2]=r):r=s[2],s[3]!==l||s[4]!==u?(a=u?(0,n.jsx)(e3.FloatingLabel,{color:l,children:u}):null,s[3]=l,s[4]=u,s[5]=a):a=s[5],s[6]!==r||s[7]!==a?(o=(0,n.jsxs)("mesh",{children:[t,r,a]}),s[6]=r,s[7]=a,s[8]=o):o=s[8],o}function tt(e){let t,r=(0,i.c)(3),{label:a}=e,o=(0,E.useDebug)(),s=o?.debugMode??!1;return r[0]!==s||r[1]!==a?(t=s?(0,n.jsx)(te,{color:"red",label:a}):null,r[0]=s,r[1]=a,r[2]=t):t=r[2],t}let tr=(0,o.memo)(function(e){let t,r,a,s,l,u,c,d,f,h=(0,i.c)(22),{object:m}=e;h[0]!==m?(t=(0,b.getProperty)(m,"interiorFile"),h[0]=m,h[1]=t):t=h[1];let p=t;h[2]!==m?(r=(0,b.getPosition)(m),h[2]=m,h[3]=r):r=h[3];let g=r;h[4]!==m?(a=(0,b.getScale)(m),h[4]=m,h[5]=a):a=h[5];let v=a;h[6]!==m?(s=(0,b.getRotation)(m),h[6]=m,h[7]=s):s=h[7];let y=s,A=`${m._id}: ${p}`;return h[8]!==A?(l=(0,n.jsx)(tt,{label:A}),h[8]=A,h[9]=l):l=h[9],h[10]===Symbol.for("react.memo_cache_sentinel")?(u=(0,n.jsx)(te,{color:"orange"}),h[10]=u):u=h[10],h[11]!==p||h[12]!==m?(c=(0,n.jsx)(o.Suspense,{fallback:u,children:(0,n.jsx)(e7,{object:m,interiorFile:p})}),h[11]=p,h[12]=m,h[13]=c):c=h[13],h[14]!==l||h[15]!==c?(d=(0,n.jsx)(Q,{fallback:l,children:c}),h[14]=l,h[15]=c,h[16]=d):d=h[16],h[17]!==g||h[18]!==y||h[19]!==v||h[20]!==d?(f=(0,n.jsx)("group",{position:g,quaternion:y,scale:v,children:d}),h[17]=g,h[18]=y,h[19]=v,h[20]=d,h[21]=f):f=h[21],f});function ta(e){let[,t]=e;return t.isMesh}function tn(e){let[t,r]=e;return(0,n.jsx)(e4,{node:r},t)}function ti(e,{path:t}){let[r]=(0,eX.useLoader)(u.CubeTextureLoader,[e],e=>e.setPath(t));return r}ti.preload=(e,{path:t})=>eX.useLoader.preload(u.CubeTextureLoader,[e],e=>e.setPath(t));let to=()=>{};function ts(e){return e.wrapS=u.RepeatWrapping,e.wrapT=u.RepeatWrapping,e.minFilter=u.LinearFilter,e.magFilter=u.LinearFilter,e.colorSpace=u.NoColorSpace,e.needsUpdate=!0,e}let tl=`
|
||
attribute float alpha;
|
||
|
||
uniform vec2 uvOffset;
|
||
|
||
varying vec2 vUv;
|
||
varying float vAlpha;
|
||
|
||
void main() {
|
||
// Apply UV offset for scrolling
|
||
vUv = uv + uvOffset;
|
||
vAlpha = alpha;
|
||
|
||
vec4 pos = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||
// Set depth to far plane so clouds are always visible and behind other geometry
|
||
gl_Position = pos.xyww;
|
||
}
|
||
`,tu=`
|
||
uniform sampler2D cloudTexture;
|
||
uniform float debugMode;
|
||
uniform int layerIndex;
|
||
|
||
varying vec2 vUv;
|
||
varying float vAlpha;
|
||
|
||
// Debug grid using screen-space derivatives for sharp, anti-aliased lines
|
||
float debugGrid(vec2 uv, float gridSize, float lineWidth) {
|
||
vec2 scaledUV = uv * gridSize;
|
||
vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV);
|
||
float line = min(grid.x, grid.y);
|
||
return 1.0 - min(line / lineWidth, 1.0);
|
||
}
|
||
|
||
void main() {
|
||
vec4 texColor = texture2D(cloudTexture, vUv);
|
||
|
||
// Tribes 2 uses GL_MODULATE: final = texture \xd7 vertex color
|
||
// Vertex color is white with varying alpha, so:
|
||
// Final RGB = Texture RGB \xd7 1.0 = Texture RGB
|
||
// Final Alpha = Texture Alpha \xd7 Vertex Alpha
|
||
float finalAlpha = texColor.a * vAlpha;
|
||
vec3 color = texColor.rgb;
|
||
|
||
// Debug mode: overlay R/G/B grid for layers 0/1/2
|
||
if (debugMode > 0.5) {
|
||
float gridIntensity = debugGrid(vUv, 4.0, 1.5);
|
||
vec3 gridColor;
|
||
if (layerIndex == 0) {
|
||
gridColor = vec3(1.0, 0.0, 0.0); // Red
|
||
} else if (layerIndex == 1) {
|
||
gridColor = vec3(0.0, 1.0, 0.0); // Green
|
||
} else {
|
||
gridColor = vec3(0.0, 0.0, 1.0); // Blue
|
||
}
|
||
color = mix(color, gridColor, gridIntensity * 0.5);
|
||
}
|
||
|
||
// Output clouds with texture color and combined alpha
|
||
gl_FragColor = vec4(color, finalAlpha);
|
||
}
|
||
`;function tc({textureUrl:e,radius:t,heightPercent:r,speed:a,windDirection:i,layerIndex:s}){let{debugMode:l}=(0,E.useDebug)(),{animationEnabled:c}=(0,E.useSettings)(),d=(0,o.useRef)(null),f=(0,B.useTexture)(e,ts),h=(0,o.useMemo)(()=>{let e=r-.05;return function(e,t,r,a){var n;let i,o,s,l,c,d,f,h,m,p,g,v,y,A,F,b,C,B=new u.BufferGeometry,S=new Float32Array(75),x=new Float32Array(50),E=[.05,.05,.05,.05,.05,.05,r,r,r,.05,.05,r,t,r,.05,.05,r,r,r,.05,.05,.05,.05,.05,.05],M=2*e/4;for(let t=0;t<5;t++)for(let r=0;r<5;r++){let a=5*t+r,n=-e+r*M,i=e-t*M,o=e*E[a];S[3*a]=n,S[3*a+1]=o,S[3*a+2]=i,x[2*a]=r,x[2*a+1]=t}n=S,i=e=>({x:n[3*e],y:n[3*e+1],z:n[3*e+2]}),o=(e,t,r,a)=>{n[3*e]=t,n[3*e+1]=r,n[3*e+2]=a},s=i(1),l=i(3),c=i(5),d=i(6),f=i(8),h=i(9),m=i(15),p=i(16),g=i(18),v=i(19),y=i(21),A=i(23),F=c.x+(s.x-c.x)*.5,b=c.y+(s.y-c.y)*.5,C=c.z+(s.z-c.z)*.5,o(0,d.x+(F-d.x)*2,d.y+(b-d.y)*2,d.z+(C-d.z)*2),F=h.x+(l.x-h.x)*.5,b=h.y+(l.y-h.y)*.5,C=h.z+(l.z-h.z)*.5,o(4,f.x+(F-f.x)*2,f.y+(b-f.y)*2,f.z+(C-f.z)*2),F=y.x+(m.x-y.x)*.5,b=y.y+(m.y-y.y)*.5,C=y.z+(m.z-y.z)*.5,o(20,p.x+(F-p.x)*2,p.y+(b-p.y)*2,p.z+(C-p.z)*2),F=A.x+(v.x-A.x)*.5,b=A.y+(v.y-A.y)*.5,C=A.z+(v.z-A.z)*.5,o(24,g.x+(F-g.x)*2,g.y+(b-g.y)*2,g.z+(C-g.z)*2);let D=function(e,t){let r=new Float32Array(25);for(let a=0;a<25;a++){let n=e[3*a],i=e[3*a+2],o=1.3-Math.sqrt(n*n+i*i)/t;o<.4?o=0:o>.8&&(o=1),r[a]=o}return r}(S,e),k=[];for(let e=0;e<4;e++)for(let t=0;t<4;t++){let r=5*e+t,a=r+1,n=r+5,i=n+1;k.push(r,n,i),k.push(r,i,a)}return B.setIndex(k),B.setAttribute("position",new u.Float32BufferAttribute(S,3)),B.setAttribute("uv",new u.Float32BufferAttribute(x,2)),B.setAttribute("alpha",new u.Float32BufferAttribute(D,1)),B.computeBoundingSphere(),B}(t,r,e,0)},[t,r]);(0,o.useEffect)(()=>()=>{h.dispose()},[h]);let m=(0,o.useMemo)(()=>new u.ShaderMaterial({uniforms:{cloudTexture:{value:f},uvOffset:{value:new u.Vector2(0,0)},debugMode:{value:+!!l},layerIndex:{value:s}},vertexShader:tl,fragmentShader:tu,transparent:!0,depthWrite:!1,side:u.DoubleSide}),[f,l,s]);return(0,o.useEffect)(()=>()=>{m.dispose()},[m]),(0,A.useFrame)(c?(e,t)=>{let r=1e3*t/32;d.current??=new u.Vector2(0,0),d.current.x+=i.x*a*r,d.current.y+=i.y*a*r,d.current.x-=Math.floor(d.current.x),d.current.y-=Math.floor(d.current.y),m.uniforms.uvOffset.value.copy(d.current)}:to),(0,n.jsx)("mesh",{geometry:h,frustumCulled:!1,renderOrder:10,children:(0,n.jsx)("primitive",{object:m,attach:"material"})})}function td(e){var t;let r,a,s,l,c,d,f,h,m,p,v,F,C,B,S,x,E,M,D,k=(0,i.c)(37),{object:w}=e;k[0]!==w?(r=(0,b.getProperty)(w,"materialList"),k[0]=w,k[1]=r):r=k[1];let{data:I}=(t=r,(M=(0,i.c)(7))[0]!==t?(S=["detailMapList",t],x=()=>(0,y.loadDetailMapList)(t),M[0]=t,M[1]=S,M[2]=x):(S=M[1],x=M[2]),D=!!t,M[3]!==S||M[4]!==x||M[5]!==D?(E={queryKey:S,queryFn:x,enabled:D},M[3]=S,M[4]=x,M[5]=D,M[6]=E):E=M[6],(0,g.useQuery)(E));k[2]!==w?(a=(0,b.getFloat)(w,"visibleDistance")??500,k[2]=w,k[3]=a):a=k[3];let T=.95*a;k[4]!==w?(s=(0,b.getFloat)(w,"cloudSpeed1")??1e-4,k[4]=w,k[5]=s):s=k[5],k[6]!==w?(l=(0,b.getFloat)(w,"cloudSpeed2")??2e-4,k[6]=w,k[7]=l):l=k[7],k[8]!==w?(c=(0,b.getFloat)(w,"cloudSpeed3")??3e-4,k[8]=w,k[9]=c):c=k[9],k[10]!==s||k[11]!==l||k[12]!==c?(d=[s,l,c],k[10]=s,k[11]=l,k[12]=c,k[13]=d):d=k[13];let R=d;k[14]!==w?(f=(0,b.getFloat)(w,"cloudHeightPer1")??.35,k[14]=w,k[15]=f):f=k[15],k[16]!==w?(h=(0,b.getFloat)(w,"cloudHeightPer2")??.25,k[16]=w,k[17]=h):h=k[17],k[18]!==w?(m=(0,b.getFloat)(w,"cloudHeightPer3")??.2,k[18]=w,k[19]=m):m=k[19],k[20]!==f||k[21]!==h||k[22]!==m?(p=[f,h,m],k[20]=f,k[21]=h,k[22]=m,k[23]=p):p=k[23];let P=p;if(k[24]!==w){e:{let e,t=(0,b.getProperty)(w,"windVelocity");if(t){let[e,r]=t.split(" ").map(tf);if(0!==e||0!==r){v=new u.Vector2(r,-e).normalize();break e}}k[26]===Symbol.for("react.memo_cache_sentinel")?(e=new u.Vector2(1,0),k[26]=e):e=k[26],v=e}k[24]=w,k[25]=v}else v=k[25];let G=v;t:{let e;if(!I){let e;k[27]===Symbol.for("react.memo_cache_sentinel")?(e=[],k[27]=e):e=k[27],F=e;break t}if(k[28]!==P||k[29]!==R||k[30]!==I){e=[];for(let t=0;t<3;t++){let r=I[7+t];r&&e.push({texture:r,height:P[t],speed:R[t]})}k[28]=P,k[29]=R,k[30]=I,k[31]=e}else e=k[31];F=e}let L=F,j=(0,o.useRef)(null);return(k[32]===Symbol.for("react.memo_cache_sentinel")?(C=e=>{let{camera:t}=e;j.current&&j.current.position.copy(t.position)},k[32]=C):C=k[32],(0,A.useFrame)(C),L&&0!==L.length)?(k[33]!==L||k[34]!==T||k[35]!==G?(B=(0,n.jsx)("group",{ref:j,children:L.map((e,t)=>{let r=(0,y.textureToUrl)(e.texture);return(0,n.jsx)(o.Suspense,{fallback:null,children:(0,n.jsx)(tc,{textureUrl:r,radius:T,heightPercent:e.height,speed:e.speed,windDirection:G,layerIndex:t})},t)})}),k[33]=L,k[34]=T,k[35]=G,k[36]=B):B=k[36],B):null}function tf(e){return parseFloat(e)}let th=!1;function tm(e){if(!e)return;let[t,r,a]=e.split(" ").map(e=>parseFloat(e));return[new u.Color().setRGB(t,r,a),new u.Color().setRGB(t,r,a).convertSRGBToLinear()]}function tp({skyBoxFiles:e,fogColor:t,fogState:r}){let{camera:a}=(0,F.useThree)(),i=ti(e,{path:""}),s=!!t,l=(0,o.useMemo)(()=>a.projectionMatrixInverse,[a]),c=(0,o.useMemo)(()=>r?(0,D.packFogVolumeData)(r.fogVolumes):new Float32Array(12),[r]),d=(0,o.useRef)({skybox:{value:i},fogColor:{value:t??new u.Color(0,0,0)},enableFog:{value:s},inverseProjectionMatrix:{value:l},cameraMatrixWorld:{value:a.matrixWorld},cameraHeight:D.globalFogUniforms.cameraHeight,fogVolumeData:{value:c},horizonFogHeight:{value:.18}}),f=(0,o.useMemo)(()=>{if(!r)return .18;let e=.95*r.visibleDistance/Math.sqrt(3);return 60/Math.sqrt(e*e+3600)},[r]);return(0,o.useEffect)(()=>{d.current.skybox.value=i,d.current.fogColor.value=t??new u.Color(0,0,0),d.current.enableFog.value=s,d.current.fogVolumeData.value=c,d.current.horizonFogHeight.value=f},[i,t,s,c,f]),(0,n.jsxs)("mesh",{renderOrder:-1e3,frustumCulled:!1,children:[(0,n.jsxs)("bufferGeometry",{children:[(0,n.jsx)("bufferAttribute",{attach:"attributes-position",array:new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),count:3,itemSize:3}),(0,n.jsx)("bufferAttribute",{attach:"attributes-uv",array:new Float32Array([0,0,2,0,0,2]),count:3,itemSize:2})]}),(0,n.jsx)("shaderMaterial",{uniforms:d.current,vertexShader:`
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = vec4(position.xy, 0.9999, 1.0);
|
||
}
|
||
`,fragmentShader:`
|
||
uniform samplerCube skybox;
|
||
uniform vec3 fogColor;
|
||
uniform bool enableFog;
|
||
uniform mat4 inverseProjectionMatrix;
|
||
uniform mat4 cameraMatrixWorld;
|
||
uniform float cameraHeight;
|
||
uniform float fogVolumeData[12];
|
||
uniform float horizonFogHeight;
|
||
|
||
varying vec2 vUv;
|
||
|
||
// Convert linear to sRGB for display
|
||
// shaderMaterial does NOT get automatic linear->sRGB output conversion
|
||
// Use proper sRGB transfer function (not simplified gamma 2.2) to match Three.js
|
||
vec3 linearToSRGB(vec3 linear) {
|
||
vec3 low = linear * 12.92;
|
||
vec3 high = 1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055;
|
||
return mix(low, high, step(vec3(0.0031308), linear));
|
||
}
|
||
|
||
void main() {
|
||
vec2 ndc = vUv * 2.0 - 1.0;
|
||
vec4 viewPos = inverseProjectionMatrix * vec4(ndc, 1.0, 1.0);
|
||
viewPos.xyz /= viewPos.w;
|
||
vec3 direction = normalize((cameraMatrixWorld * vec4(viewPos.xyz, 0.0)).xyz);
|
||
direction = vec3(direction.z, direction.y, -direction.x);
|
||
// Sample skybox - Three.js CubeTexture with SRGBColorSpace auto-converts to linear
|
||
vec4 skyColor = textureCube(skybox, direction);
|
||
vec3 finalColor;
|
||
|
||
if (enableFog) {
|
||
vec3 effectiveFogColor = fogColor;
|
||
|
||
// Calculate how much fog volume the ray passes through
|
||
// For skybox at "infinite" distance, the relevant height is how much
|
||
// of the volume is above/below camera depending on view direction
|
||
float volumeFogInfluence = 0.0;
|
||
|
||
for (int i = 0; i < 3; i++) {
|
||
int offset = i * 4;
|
||
float volVisDist = fogVolumeData[offset + 0];
|
||
float volMinH = fogVolumeData[offset + 1];
|
||
float volMaxH = fogVolumeData[offset + 2];
|
||
float volPct = fogVolumeData[offset + 3];
|
||
|
||
if (volVisDist <= 0.0) continue;
|
||
|
||
// Check if camera is inside this volume
|
||
if (cameraHeight >= volMinH && cameraHeight <= volMaxH) {
|
||
// Camera is inside the fog volume
|
||
// Looking horizontally or up at shallow angles means ray travels
|
||
// through more fog before exiting the volume
|
||
float heightAboveCamera = volMaxH - cameraHeight;
|
||
float heightBelowCamera = cameraHeight - volMinH;
|
||
float volumeHeight = volMaxH - volMinH;
|
||
|
||
// For horizontal rays (direction.y ≈ 0), maximum fog influence
|
||
// For rays going up steeply, less fog (exits volume quickly)
|
||
// For rays going down, more fog (travels through volume below)
|
||
float rayInfluence;
|
||
if (direction.y >= 0.0) {
|
||
// Looking up: influence based on how steep we're looking
|
||
// Shallow angles = long path through fog = high influence
|
||
rayInfluence = 1.0 - smoothstep(0.0, 0.3, direction.y);
|
||
} else {
|
||
// Looking down: always high fog (into the volume)
|
||
rayInfluence = 1.0;
|
||
}
|
||
|
||
// Scale by percentage and volume depth factor
|
||
volumeFogInfluence += rayInfluence * volPct;
|
||
}
|
||
}
|
||
|
||
// Base fog factor from view direction (for haze at horizon)
|
||
// In Torque, the fog "bans" (bands) are rendered as geometry from
|
||
// height 0 (HORIZON) to height 60 (OFFSET_HEIGHT) on the skybox.
|
||
// The skybox corner is at mSkyBoxPt.x = mRadius / sqrt(3).
|
||
//
|
||
// horizonFogHeight is the direction.y value where the fog band ends:
|
||
// horizonFogHeight = 60 / sqrt(skyBoxPt.x^2 + 60^2)
|
||
//
|
||
// For Firestorm (visDist=600): mRadius=570, skyBoxPt.x=329, horizonFogHeight≈0.18
|
||
//
|
||
// Torque renders the fog bands as geometry with linear vertex alpha
|
||
// interpolation. We use a squared curve (t^2) to create a gentler
|
||
// falloff at the top of the gradient, matching Tribes 2's appearance.
|
||
float baseFogFactor;
|
||
if (direction.y <= 0.0) {
|
||
// Looking at or below horizon: full fog
|
||
baseFogFactor = 1.0;
|
||
} else if (direction.y >= horizonFogHeight) {
|
||
// Above fog band: no fog
|
||
baseFogFactor = 0.0;
|
||
} else {
|
||
// Within fog band: squared curve for gentler falloff at top
|
||
float t = direction.y / horizonFogHeight;
|
||
baseFogFactor = (1.0 - t) * (1.0 - t);
|
||
}
|
||
|
||
// Combine base fog with volume fog influence
|
||
// When inside a volume, increase fog intensity
|
||
float finalFogFactor = min(1.0, baseFogFactor + volumeFogInfluence * 0.5);
|
||
|
||
finalColor = mix(skyColor.rgb, effectiveFogColor, finalFogFactor);
|
||
} else {
|
||
finalColor = skyColor.rgb;
|
||
}
|
||
// Convert linear result to sRGB for display
|
||
gl_FragColor = vec4(linearToSRGB(finalColor), 1.0);
|
||
}
|
||
`,depthWrite:!1,depthTest:!1})]})}function tg(e){let t,r,a,o,s=(0,i.c)(6),{materialList:l,fogColor:u,fogState:c}=e,{data:d}=((o=(0,i.c)(2))[0]!==l?(a={queryKey:["detailMapList",l],queryFn:()=>(0,y.loadDetailMapList)(l)},o[0]=l,o[1]=a):a=o[1],(0,g.useQuery)(a));s[0]!==d?(t=d?[(0,y.textureToUrl)(d[1]),(0,y.textureToUrl)(d[3]),(0,y.textureToUrl)(d[4]),(0,y.textureToUrl)(d[5]),(0,y.textureToUrl)(d[0]),(0,y.textureToUrl)(d[2])]:null,s[0]=d,s[1]=t):t=s[1];let f=t;return f?(s[2]!==u||s[3]!==c||s[4]!==f?(r=(0,n.jsx)(tp,{skyBoxFiles:f,fogColor:u,fogState:c}),s[2]=u,s[3]=c,s[4]=f,s[5]=r):r=s[5],r):null}function tv({skyColor:e,fogColor:t,fogState:r}){let{camera:a}=(0,F.useThree)(),i=!!t,s=(0,o.useMemo)(()=>a.projectionMatrixInverse,[a]),l=(0,o.useMemo)(()=>r?(0,D.packFogVolumeData)(r.fogVolumes):new Float32Array(12),[r]),c=(0,o.useMemo)(()=>{if(!r)return .18;let e=.95*r.visibleDistance/Math.sqrt(3);return 60/Math.sqrt(e*e+3600)},[r]),d=(0,o.useRef)({skyColor:{value:e},fogColor:{value:t??new u.Color(0,0,0)},enableFog:{value:i},inverseProjectionMatrix:{value:s},cameraMatrixWorld:{value:a.matrixWorld},cameraHeight:D.globalFogUniforms.cameraHeight,fogVolumeData:{value:l},horizonFogHeight:{value:c}});return(0,o.useEffect)(()=>{d.current.skyColor.value=e,d.current.fogColor.value=t??new u.Color(0,0,0),d.current.enableFog.value=i,d.current.fogVolumeData.value=l,d.current.horizonFogHeight.value=c},[e,t,i,l,c]),(0,n.jsxs)("mesh",{renderOrder:-1e3,frustumCulled:!1,children:[(0,n.jsxs)("bufferGeometry",{children:[(0,n.jsx)("bufferAttribute",{attach:"attributes-position",array:new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),count:3,itemSize:3}),(0,n.jsx)("bufferAttribute",{attach:"attributes-uv",array:new Float32Array([0,0,2,0,0,2]),count:3,itemSize:2})]}),(0,n.jsx)("shaderMaterial",{uniforms:d.current,vertexShader:`
|
||
varying vec2 vUv;
|
||
|
||
void main() {
|
||
vUv = uv;
|
||
gl_Position = vec4(position.xy, 0.9999, 1.0);
|
||
}
|
||
`,fragmentShader:`
|
||
uniform vec3 skyColor;
|
||
uniform vec3 fogColor;
|
||
uniform bool enableFog;
|
||
uniform mat4 inverseProjectionMatrix;
|
||
uniform mat4 cameraMatrixWorld;
|
||
uniform float cameraHeight;
|
||
uniform float fogVolumeData[12];
|
||
uniform float horizonFogHeight;
|
||
|
||
varying vec2 vUv;
|
||
|
||
// Convert linear to sRGB for display
|
||
vec3 linearToSRGB(vec3 linear) {
|
||
vec3 low = linear * 12.92;
|
||
vec3 high = 1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055;
|
||
return mix(low, high, step(vec3(0.0031308), linear));
|
||
}
|
||
|
||
void main() {
|
||
vec2 ndc = vUv * 2.0 - 1.0;
|
||
vec4 viewPos = inverseProjectionMatrix * vec4(ndc, 1.0, 1.0);
|
||
viewPos.xyz /= viewPos.w;
|
||
vec3 direction = normalize((cameraMatrixWorld * vec4(viewPos.xyz, 0.0)).xyz);
|
||
direction = vec3(direction.z, direction.y, -direction.x);
|
||
|
||
vec3 finalColor;
|
||
|
||
if (enableFog) {
|
||
// Calculate volume fog influence (same logic as SkyBoxTexture)
|
||
float volumeFogInfluence = 0.0;
|
||
|
||
for (int i = 0; i < 3; i++) {
|
||
int offset = i * 4;
|
||
float volVisDist = fogVolumeData[offset + 0];
|
||
float volMinH = fogVolumeData[offset + 1];
|
||
float volMaxH = fogVolumeData[offset + 2];
|
||
float volPct = fogVolumeData[offset + 3];
|
||
|
||
if (volVisDist <= 0.0) continue;
|
||
|
||
if (cameraHeight >= volMinH && cameraHeight <= volMaxH) {
|
||
float rayInfluence;
|
||
if (direction.y >= 0.0) {
|
||
rayInfluence = 1.0 - smoothstep(0.0, 0.3, direction.y);
|
||
} else {
|
||
rayInfluence = 1.0;
|
||
}
|
||
volumeFogInfluence += rayInfluence * volPct;
|
||
}
|
||
}
|
||
|
||
// Base fog factor from view direction
|
||
float baseFogFactor;
|
||
if (direction.y <= 0.0) {
|
||
baseFogFactor = 1.0;
|
||
} else if (direction.y >= horizonFogHeight) {
|
||
baseFogFactor = 0.0;
|
||
} else {
|
||
float t = direction.y / horizonFogHeight;
|
||
baseFogFactor = (1.0 - t) * (1.0 - t);
|
||
}
|
||
|
||
// Combine base fog with volume fog influence
|
||
float finalFogFactor = min(1.0, baseFogFactor + volumeFogInfluence * 0.5);
|
||
|
||
finalColor = mix(skyColor, fogColor, finalFogFactor);
|
||
} else {
|
||
finalColor = skyColor;
|
||
}
|
||
|
||
gl_FragColor = vec4(linearToSRGB(finalColor), 1.0);
|
||
}
|
||
`,depthWrite:!1,depthTest:!1})]})}function ty(e,t){let{fogDistance:r,visibleDistance:a}=e;return[r,a]}function tA({fogState:e,enabled:t}){let{scene:r,camera:a}=(0,F.useThree)(),n=(0,o.useRef)(null),i=(0,o.useMemo)(()=>(0,D.packFogVolumeData)(e.fogVolumes),[e.fogVolumes]);return(0,o.useEffect)(()=>{th||((0,M.installCustomFogShader)(),th=!0)},[]),(0,o.useEffect)(()=>{(0,D.resetGlobalFogUniforms)();let[t,o]=ty(e,a.position.y),s=new u.Fog(e.fogColor,t,o);return r.fog=s,n.current=s,(0,D.updateGlobalFogUniforms)(a.position.y,i),()=>{r.fog=null,n.current=null,(0,D.resetGlobalFogUniforms)()}},[r,a,e,i]),(0,o.useEffect)(()=>{let r=n.current;if(r)if(t){let[t,n]=ty(e,a.position.y);r.near=t,r.far=n}else r.near=1e10,r.far=1e10},[t,e,a.position.y]),(0,A.useFrame)(()=>{let r=n.current;if(!r)return;let o=a.position.y;if((0,D.updateGlobalFogUniforms)(o,i,t),t){let[t,a]=ty(e,o);r.near=t,r.far=a,r.color.copy(e.fogColor)}}),null}function tF(e){return parseFloat(e)}function tb(e){return parseFloat(e)}function tC(e){return parseFloat(e)}function tB(e){let t=new Set;return e.bones.forEach((e,r)=>{e.name.match(/^Hulk/i)&&t.add(r)}),t}function tS(e,t){if(0===t.size||!e.attributes.skinIndex)return e;let r=e.attributes.skinIndex,a=e.attributes.skinWeight,n=e.index,i=Array(r.count).fill(!1);for(let e=0;e<r.count;e++)for(let n=0;n<4;n++){let o=r.array[4*e+n];if(a.array[4*e+n]>.01&&t.has(o)){i[e]=!0;break}}if(n){let t=[],r=n.array;for(let e=0;e<r.length;e+=3){let a=r[e],n=r[e+1],o=r[e+2];i[a]||i[n]||i[o]||t.push(a,n,o)}let a=e.clone();return a.setIndex(t),a}return e}let tx=/borg|xorg|porg|dorg|plant|tree|bush|fern|vine|grass|leaf|flower|frond|palm|foliage/i;function tE(e){return tx.test(e)}let tM=(0,o.createContext)(null);function tD(){let e=(0,o.useContext)(tM);if(!e)throw Error("useShapeInfo must be used within ShapeInfoProvider");return e}function tk(e){let t,r,a,o=(0,i.c)(10),{children:s,object:l,shapeName:u,type:c}=e;o[0]!==u?(t=tE(u),o[0]=u,o[1]=t):t=o[1];let d=t;o[2]!==d||o[3]!==l||o[4]!==u||o[5]!==c?(r={object:l,shapeName:u,type:c,isOrganic:d},o[2]=d,o[3]=l,o[4]=u,o[5]=c,o[6]=r):r=o[6];let f=r;return o[7]!==s||o[8]!==f?(a=(0,n.jsx)(tM.Provider,{value:f,children:s}),o[7]=s,o[8]=f,o[9]=a):a=o[9],a}e.i(47167);var tw=e.i(69230),tI=e.i(69637),tT=e.i(54440);let tR=(0,o.createContext)(null);function tP({children:e}){let t=(0,o.useRef)(void 0),r=(0,o.useRef)(0),a=(0,o.useRef)(0);(0,A.useFrame)((e,n)=>{for(r.current+=n;r.current>=.03125;)if(r.current-=.03125,a.current++,t.current)for(let e of t.current)e(a.current)});let i=(0,o.useCallback)(e=>(t.current??=new Set,t.current.add(e),()=>{t.current.delete(e)}),[]),s=(0,o.useCallback)(()=>a.current,[]),l=(0,o.useMemo)(()=>({subscribe:i,getTick:s}),[i,s]);return(0,n.jsx)(tR.Provider,{value:l,children:e})}let tG=new Map;function tL(e){e.onBeforeCompile=t=>{(0,M.injectCustomFog)(t,D.globalFogUniforms),e instanceof u.MeshLambertMaterial&&(t.uniforms.shapeDirectionalFactor={value:1},t.uniforms.shapeAmbientFactor={value:1.5},t.fragmentShader=t.fragmentShader.replace("#include <common>",`#include <common>
|
||
uniform float shapeDirectionalFactor;
|
||
uniform float shapeAmbientFactor;
|
||
`),t.fragmentShader=t.fragmentShader.replace("#include <lights_fragment_end>",`#include <lights_fragment_end>
|
||
// Apply shape-specific lighting multipliers
|
||
reflectedLight.directDiffuse *= shapeDirectionalFactor;
|
||
reflectedLight.indirectDiffuse *= shapeAmbientFactor;
|
||
`))}}function tj(e,t,r,a,n=1,i=!1){let o=r.has("Translucent"),s=r.has("Additive"),l=r.has("SelfIlluminating"),c=n<1||i;if(l){let e=s||o||c,r=new u.MeshBasicMaterial({map:t,side:2,transparent:e,depthWrite:!e,alphaTest:0,fog:!0,...c&&{opacity:n},...s&&{blending:u.AdditiveBlending}});return tL(r),r}if(a||o){let e={map:t,transparent:c,alphaTest:.5*!c,...c&&{opacity:n,depthWrite:!1},reflectivity:0},r=new u.MeshLambertMaterial({...e,side:1,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),a=new u.MeshLambertMaterial({...e,side:0});return tL(r),tL(a),[r,a]}let d=new u.MeshLambertMaterial({map:t,side:2,reflectivity:0,...c&&{transparent:!0,opacity:n,depthWrite:!1}});return tL(d),d}function t_(e){let t,r=(0,i.c)(2);return r[0]!==e?(t=(0,y.shapeToUrl)(e),r[0]=e,r[1]=t):t=r[1],e2(t)}let tO=(0,o.memo)(function(e){let t,r,a,s,l,c,d=(0,i.c)(37),{material:f,shapeName:h,geometry:m,backGeometry:p,castShadow:g,receiveShadow:v,vis:A,animated:F}=e,b=void 0!==g&&g,C=void 0!==v&&v,S=void 0===A?1:A,x=void 0!==F&&F,M=f.userData.resource_path;d[0]!==f.userData.flag_names?(t=f.userData.flag_names??[],d[0]=f.userData.flag_names,d[1]=t):t=d[1],d[2]!==t?(r=new Set(t),d[2]=t,d[3]=r):r=d[3];let D=r,k=function(e){let t,r,a,n,s=(0,i.c)(14),{animationEnabled:l}=(0,E.useSettings)();s[0]!==e?(t={queryKey:["ifl",e],queryFn:()=>(0,y.loadImageFrameList)(e)},s[0]=e,s[1]=t):t=s[1];let{data:c}=(m=t,(0,tI.useBaseQuery)({...m,enabled:!0,suspense:!0,throwOnError:tT.defaultThrowOnError,placeholderData:void 0},tw.QueryObserver,void 0));if(s[2]!==c||s[3]!==e){let t;s[5]!==e?(t=t=>(0,y.iflTextureToUrl)(t.name,e),s[5]=e,s[6]=t):t=s[6],r=c.map(t),s[2]=c,s[3]=e,s[4]=r}else r=s[4];let d=r,f=(0,B.useTexture)(d);if(s[7]!==c||s[8]!==e||s[9]!==f){let t;if(!(a=tG.get(e))){let t,r,n,i,o,s,l,c,d;r=(t=f[0].image).width,n=t.height,o=Math.ceil(Math.sqrt(i=f.length)),s=Math.ceil(i/o),(l=document.createElement("canvas")).width=r*o,l.height=n*s,c=l.getContext("2d"),f.forEach((e,t)=>{let a=Math.floor(t/o);c.drawImage(e.image,t%o*r,a*n)}),(d=new u.CanvasTexture(l)).colorSpace=u.SRGBColorSpace,d.generateMipmaps=!1,d.minFilter=u.NearestFilter,d.magFilter=u.NearestFilter,d.wrapS=u.ClampToEdgeWrapping,d.wrapT=u.ClampToEdgeWrapping,d.repeat.set(1/o,1/s),a={texture:d,columns:o,rows:s,frameCount:i,frameStartTicks:[],totalTicks:0,lastFrame:-1},tG.set(e,a)}t=0,(p=a).frameStartTicks=c.map(e=>{let r=t;return t+=e.frameCount,r}),p.totalTicks=t,s[7]=c,s[8]=e,s[9]=f,s[10]=a}else a=s[10];let h=a;s[11]!==l||s[12]!==h?(n=e=>{let t=l?function(e,t){if(0===e.totalTicks)return 0;let r=t%e.totalTicks,{frameStartTicks:a}=e;for(let e=a.length-1;e>=0;e--)if(r>=a[e])return e;return 0}(h,e):0;!function(e,t){if(t===e.lastFrame)return;e.lastFrame=t;let r=t%e.columns,a=e.rows-1-Math.floor(t/e.columns);e.texture.offset.set(r/e.columns,a/e.rows)}(h,t)},s[11]=l,s[12]=h,s[13]=n):n=s[13];var m,p,g=n;let v=(0,o.useContext)(tR);if(!v)throw Error("useTick must be used within a TickProvider");let A=(0,o.useRef)(g);return A.current=g,(0,o.useEffect)(()=>v.subscribe(e=>A.current(e)),[v]),h.texture}(`textures/${M}.ifl`);d[4]!==h?(a=h&&tE(h),d[4]=h,d[5]=a):a=d[5];let w=a;d[6]!==x||d[7]!==D||d[8]!==w||d[9]!==f||d[10]!==k||d[11]!==S?(s=tj(f,k,D,w,S,x),d[6]=x,d[7]=D,d[8]=w,d[9]=f,d[10]=k,d[11]=S,d[12]=s):s=d[12];let I=s;if(Array.isArray(I)){let e,t,r,a,i,o=p||m;return d[13]!==I[0]?(e=(0,n.jsx)("primitive",{object:I[0],attach:"material"}),d[13]=I[0],d[14]=e):e=d[14],d[15]!==b||d[16]!==C||d[17]!==e||d[18]!==o?(t=(0,n.jsx)("mesh",{geometry:o,castShadow:b,receiveShadow:C,children:e}),d[15]=b,d[16]=C,d[17]=e,d[18]=o,d[19]=t):t=d[19],d[20]!==I[1]?(r=(0,n.jsx)("primitive",{object:I[1],attach:"material"}),d[20]=I[1],d[21]=r):r=d[21],d[22]!==b||d[23]!==m||d[24]!==C||d[25]!==r?(a=(0,n.jsx)("mesh",{geometry:m,castShadow:b,receiveShadow:C,children:r}),d[22]=b,d[23]=m,d[24]=C,d[25]=r,d[26]=a):a=d[26],d[27]!==t||d[28]!==a?(i=(0,n.jsxs)(n.Fragment,{children:[t,a]}),d[27]=t,d[28]=a,d[29]=i):i=d[29],i}return d[30]!==I?(l=(0,n.jsx)("primitive",{object:I,attach:"material"}),d[30]=I,d[31]=l):l=d[31],d[32]!==b||d[33]!==m||d[34]!==C||d[35]!==l?(c=(0,n.jsx)("mesh",{geometry:m,castShadow:b,receiveShadow:C,children:l}),d[32]=b,d[33]=m,d[34]=C,d[35]=l,d[36]=c):c=d[36],c}),tU=(0,o.memo)(function(e){let t,r,a,o,s,l,u,c,d=(0,i.c)(42),{material:f,shapeName:h,geometry:m,backGeometry:p,castShadow:g,receiveShadow:v,vis:A,animated:F}=e,b=void 0!==g&&g,S=void 0!==v&&v,x=void 0===A?1:A,E=void 0!==F&&F,M=f.userData.resource_path;d[0]!==f.userData.flag_names?(t=f.userData.flag_names??[],d[0]=f.userData.flag_names,d[1]=t):t=d[1],d[2]!==t?(r=new Set(t),d[2]=t,d[3]=r):r=d[3];let D=r;M||console.warn(`No resource_path was found on "${h}" - rendering fallback.`),d[4]!==M?(a=M?(0,y.textureToUrl)(M):y.FALLBACK_TEXTURE_URL,d[4]=M,d[5]=a):a=d[5];let k=a;d[6]!==h?(o=h&&tE(h),d[6]=h,d[7]=o):o=d[7];let w=o,I=D.has("Translucent");d[8]!==w||d[9]!==I?(s=e=>w||I?(0,C.setupTexture)(e,{disableMipmaps:!0}):(0,C.setupTexture)(e),d[8]=w,d[9]=I,d[10]=s):s=d[10];let T=(0,B.useTexture)(k,s);d[11]!==E||d[12]!==D||d[13]!==w||d[14]!==f||d[15]!==T||d[16]!==x?(l=tj(f,T,D,w,x,E),d[11]=E,d[12]=D,d[13]=w,d[14]=f,d[15]=T,d[16]=x,d[17]=l):l=d[17];let R=l;if(Array.isArray(R)){let e,t,r,a,i,o=p||m;return d[18]!==R[0]?(e=(0,n.jsx)("primitive",{object:R[0],attach:"material"}),d[18]=R[0],d[19]=e):e=d[19],d[20]!==b||d[21]!==S||d[22]!==o||d[23]!==e?(t=(0,n.jsx)("mesh",{geometry:o,castShadow:b,receiveShadow:S,children:e}),d[20]=b,d[21]=S,d[22]=o,d[23]=e,d[24]=t):t=d[24],d[25]!==R[1]?(r=(0,n.jsx)("primitive",{object:R[1],attach:"material"}),d[25]=R[1],d[26]=r):r=d[26],d[27]!==b||d[28]!==m||d[29]!==S||d[30]!==r?(a=(0,n.jsx)("mesh",{geometry:m,castShadow:b,receiveShadow:S,children:r}),d[27]=b,d[28]=m,d[29]=S,d[30]=r,d[31]=a):a=d[31],d[32]!==t||d[33]!==a?(i=(0,n.jsxs)(n.Fragment,{children:[t,a]}),d[32]=t,d[33]=a,d[34]=i):i=d[34],i}return d[35]!==R?(u=(0,n.jsx)("primitive",{object:R,attach:"material"}),d[35]=R,d[36]=u):u=d[36],d[37]!==b||d[38]!==m||d[39]!==S||d[40]!==u?(c=(0,n.jsx)("mesh",{geometry:m,castShadow:b,receiveShadow:S,children:u}),d[37]=b,d[38]=m,d[39]=S,d[40]=u,d[41]=c):c=d[41],c}),tH=(0,o.memo)(function(e){let t=(0,i.c)(18),{material:r,shapeName:a,geometry:o,backGeometry:s,castShadow:l,receiveShadow:u,vis:c,animated:d}=e,f=void 0!==l&&l,h=void 0!==u&&u,m=void 0===c?1:c,p=void 0!==d&&d,g=new Set(r.userData.flag_names??[]).has("IflMaterial"),v=r.userData.resource_path;if(g&&v){let e;return t[0]!==p||t[1]!==s||t[2]!==f||t[3]!==o||t[4]!==r||t[5]!==h||t[6]!==a||t[7]!==m?(e=(0,n.jsx)(tO,{material:r,shapeName:a,geometry:o,backGeometry:s,castShadow:f,receiveShadow:h,vis:m,animated:p}),t[0]=p,t[1]=s,t[2]=f,t[3]=o,t[4]=r,t[5]=h,t[6]=a,t[7]=m,t[8]=e):e=t[8],e}if(!r.name)return null;{let e;return t[9]!==p||t[10]!==s||t[11]!==f||t[12]!==o||t[13]!==r||t[14]!==h||t[15]!==a||t[16]!==m?(e=(0,n.jsx)(tU,{material:r,shapeName:a,geometry:o,backGeometry:s,castShadow:f,receiveShadow:h,vis:m,animated:p}),t[9]=p,t[10]=s,t[11]=f,t[12]=o,t[13]=r,t[14]=h,t[15]=a,t[16]=m,t[17]=e):e=t[17],e}});function tN(e){let t,r,a,o,s=(0,i.c)(9),{color:l,label:u}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)("boxGeometry",{args:[10,10,10]}),s[0]=t):t=s[0],s[1]!==l?(r=(0,n.jsx)("meshStandardMaterial",{color:l,wireframe:!0}),s[1]=l,s[2]=r):r=s[2],s[3]!==l||s[4]!==u?(a=u?(0,n.jsx)(e3.FloatingLabel,{color:l,children:u}):null,s[3]=l,s[4]=u,s[5]=a):a=s[5],s[6]!==r||s[7]!==a?(o=(0,n.jsxs)("mesh",{children:[t,r,a]}),s[6]=r,s[7]=a,s[8]=o):o=s[8],o}function tJ(e){let t,r=(0,i.c)(4),{color:a,label:o}=e,{debugMode:s}=(0,E.useDebug)();return r[0]!==a||r[1]!==s||r[2]!==o?(t=s?(0,n.jsx)(tN,{color:a,label:o}):null,r[0]=a,r[1]=s,r[2]=o,r[3]=t):t=r[3],t}let tK=new Set(["octahedron.dts"]);function tV(e){let t,r,a,o,s=(0,i.c)(6),{label:l}=e,{debugMode:u}=(0,E.useDebug)();return u?(s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)("icosahedronGeometry",{args:[1,1]}),r=(0,n.jsx)("meshBasicMaterial",{color:"cyan",wireframe:!0}),s[0]=t,s[1]=r):(t=s[0],r=s[1]),s[2]!==l?(a=l?(0,n.jsx)(e3.FloatingLabel,{color:"cyan",children:l}):null,s[2]=l,s[3]=a):a=s[3],s[4]!==a?(o=(0,n.jsxs)("mesh",{children:[t,r,a]}),s[4]=a,s[5]=o):o=s[5],o):null}function tz(e){let t,r,a,s,l,u=(0,i.c)(15),{loadingColor:c,children:d}=e,f=void 0===c?"yellow":c,{object:h,shapeName:m}=tD();if(!m){let e,t=`${h._id}: <missing>`;return u[0]!==t?(e=(0,n.jsx)(tJ,{color:"orange",label:t}),u[0]=t,u[1]=e):e=u[1],e}if(tK.has(m.toLowerCase())){let e,t=`${h._id}: ${m}`;return u[2]!==t?(e=(0,n.jsx)(tV,{label:t}),u[2]=t,u[3]=e):e=u[3],e}let p=`${h._id}: ${m}`;return u[4]!==p?(t=(0,n.jsx)(tJ,{color:"red",label:p}),u[4]=p,u[5]=t):t=u[5],u[6]!==f?(r=(0,n.jsx)(tN,{color:f}),u[6]=f,u[7]=r):r=u[7],u[8]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsx)(tW,{}),u[8]=a):a=u[8],u[9]!==d||u[10]!==r?(s=(0,n.jsxs)(o.Suspense,{fallback:r,children:[a,d]}),u[9]=d,u[10]=r,u[11]=s):s=u[11],u[12]!==t||u[13]!==s?(l=(0,n.jsx)(Q,{fallback:t,children:s}),u[12]=t,u[13]=s,u[14]=l):l=u[14],l}function tq(e){return null!=e&&"ambient"===(e.vis_sequence??"").toLowerCase()&&Array.isArray(e.vis_keyframes)&&e.vis_keyframes.length>1&&(e.vis_duration??0)>0}function tQ(e){let t,r,a=(0,i.c)(7),{keyframes:s,duration:l,cyclic:u,children:c}=e,d=(0,o.useRef)(null),{animationEnabled:f}=(0,E.useSettings)();return a[0]!==f||a[1]!==u||a[2]!==l||a[3]!==s?(t=()=>{let e=d.current;if(!e)return;if(!f)return void e.traverse(e=>{if(e.isMesh){let t=e.material;t&&!Array.isArray(t)&&(t.opacity=s[0])}});let t=performance.now()/1e3,r=u?t%l/l:Math.min(t/l,1),a=s.length,n=r*a,i=Math.floor(n)%a,o=n-Math.floor(n),c=s[i]+(s[(i+1)%a]-s[i])*o;e.traverse(e=>{if(e.isMesh){let t=e.material;t&&!Array.isArray(t)&&(t.opacity=c)}})},a[0]=f,a[1]=u,a[2]=l,a[3]=s,a[4]=t):t=a[4],(0,A.useFrame)(t),a[5]!==c?(r=(0,n.jsx)("group",{ref:d,children:c}),a[5]=c,a[6]=r):r=a[6],r}let tW=(0,o.memo)(function(){let e,t,r,a,s,l,u=(0,i.c)(19),{object:c,shapeName:d,isOrganic:f}=tD(),{debugMode:h}=(0,E.useDebug)(),{nodes:m}=t_(d);if(u[0]!==m){e:{let t,r=Object.values(m).filter(tX);if(r.length>0){e=tB(r[0].skeleton);break e}u[2]===Symbol.for("react.memo_cache_sentinel")?(t=new Set,u[2]=t):t=u[2],e=t}u[0]=m,u[1]=e}else e=u[1];let p=e;u[3]!==p||u[4]!==f||u[5]!==m?(t=Object.entries(m).filter(tY).map(e=>{let[,t]=e,r=tS(t.geometry,p),a=null;if(r){(r=r.clone()).computeVertexNormals();let e=r.attributes.position,t=r.attributes.normal,n=e.array,i=t.array,o=new Map;for(let t=0;t<e.count;t++){let e=`${n[3*t].toFixed(4)},${n[3*t+1].toFixed(4)},${n[3*t+2].toFixed(4)}`;o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let e of o.values())if(e.length>1){let t=0,r=0,a=0;for(let n of e)t+=i[3*n],r+=i[3*n+1],a+=i[3*n+2];let n=Math.sqrt(t*t+r*r+a*a);for(let o of(n>0&&(t/=n,r/=n,a/=n),e))i[3*o]=t,i[3*o+1]=r,i[3*o+2]=a}if(t.needsUpdate=!0,f){let e=(a=r.clone()).attributes.normal,t=e.array;for(let e=0;e<t.length;e++)t[e]=-t[e];e.needsUpdate=!0}}let n=t.userData?.vis??1,i=tq(t.userData)?{keyframes:t.userData.vis_keyframes,duration:t.userData.vis_duration,cyclic:!!t.userData.vis_cyclic}:void 0;return{node:t,geometry:r,backGeometry:a,vis:n,visAnim:i}}),u[3]=p,u[4]=f,u[5]=m,u[6]=t):t=u[6];let g=t,v=!f;return u[7]===Symbol.for("react.memo_cache_sentinel")?(r=[0,Math.PI/2,0],u[7]=r):r=u[7],u[8]!==v||u[9]!==g||u[10]!==d?(a=g.map(e=>{let{node:t,geometry:r,backGeometry:a,vis:i,visAnim:s}=e,l=!!s,u=(0,n.jsx)("mesh",{geometry:r,children:(0,n.jsx)("meshStandardMaterial",{color:"gray",wireframe:!0})}),c=t.material?Array.isArray(t.material)?t.material.map((e,t)=>(0,n.jsx)(tH,{material:e,shapeName:d,geometry:r,backGeometry:a,castShadow:v,receiveShadow:v,vis:i,animated:l},t)):(0,n.jsx)(tH,{material:t.material,shapeName:d,geometry:r,backGeometry:a,castShadow:v,receiveShadow:v,vis:i,animated:l}):null;return s?(0,n.jsx)(tQ,{keyframes:s.keyframes,duration:s.duration,cyclic:s.cyclic,children:(0,n.jsx)(o.Suspense,{fallback:u,children:c})},t.id):(0,n.jsx)(o.Suspense,{fallback:u,children:c},t.id)}),u[8]=v,u[9]=g,u[10]=d,u[11]=a):a=u[11],u[12]!==h||u[13]!==c||u[14]!==d?(s=h?(0,n.jsxs)(e3.FloatingLabel,{children:[c._id,": ",d]}):null,u[12]=h,u[13]=c,u[14]=d,u[15]=s):s=u[15],u[16]!==a||u[17]!==s?(l=(0,n.jsxs)("group",{rotation:r,children:[a,s]}),u[16]=a,u[17]=s,u[18]=l):l=u[18],l});function tX(e){return e.skeleton}function tY(e){let[,t]=e;return t.material&&"Unassigned"!==t.material.name&&!t.name.match(/^Hulk/i)&&((t.userData?.vis??1)>.01||tq(t.userData))}var tZ=e.i(6112);let t$={1:"Storm",2:"Inferno"},t0=(0,o.createContext)(null);function t1(){let e=(0,o.useContext)(t0);if(!e)throw Error("useCameras must be used within CamerasProvider");return e}function t2({children:e}){let{camera:t}=(0,F.useThree)(),[r,a]=(0,o.useState)(-1),[i,s]=(0,o.useState)({}),[l,c]=(0,o.useState)(()=>({initialized:!1,position:null,quarternion:null})),d=(0,o.useCallback)(e=>{s(t=>({...t,[e.id]:e}))},[]),f=(0,o.useCallback)(e=>{s(t=>{let{[e.id]:r,...a}=t;return a})},[]),h=Object.keys(i).length,m=(0,o.useCallback)(e=>{if(e>=0&&e<h){a(e);let r=Object.keys(i)[e],n=i[r];t.position.copy(n.position);let o=new u.Quaternion().setFromAxisAngle(new u.Vector3(0,1,0),-Math.PI/2);t.quaternion.copy(n.rotation).multiply(o)}},[t,h,i]),p=(0,o.useCallback)(()=>{m(h?(r+1)%h:-1)},[h,r,m]);(0,o.useEffect)(()=>{let e=()=>{let e=window.location.hash;if(e.startsWith("#c")){let[t,r]=e.slice(2).split("~"),a=t.split(",").map(e=>parseFloat(e)),n=r.split(",").map(e=>parseFloat(e));c({initialized:!0,position:new u.Vector3(...a),quarternion:new u.Quaternion(...n)})}else c({initialized:!0,position:null,quarternion:null})};return window.addEventListener("hashchange",e),e(),()=>{window.removeEventListener("hashchange",e)}},[]),(0,o.useEffect)(()=>{l.initialized&&l.position&&(t.position.copy(l.position),l.quarternion&&t.quaternion.copy(l.quarternion))},[t,l]),(0,o.useEffect)(()=>{l.initialized&&!l.position&&h>0&&-1===r&&m(0)},[h,m,r,l]);let g=(0,o.useMemo)(()=>({registerCamera:d,unregisterCamera:f,nextCamera:p,setCameraIndex:m,cameraCount:h}),[d,f,p,m,h]);return 0===h&&-1!==r&&a(-1),(0,n.jsx)(t0.Provider,{value:g,children:e})}let t3=(0,o.createContext)(null),t9=t3.Provider,t5=(0,o.lazy)(()=>e.A(61921).then(e=>({default:e.AudioEmitter}))),t8={AudioEmitter:function(e){let t,r=(0,i.c)(3),{audioEnabled:a}=(0,E.useSettings)();return r[0]!==a||r[1]!==e?(t=a?(0,n.jsx)(t5,{...e}):null,r[0]=a,r[1]=e,r[2]=t):t=r[2],t},Camera:function(e){let t,r,a,n,s,l=(0,i.c)(14),{object:c}=e,{registerCamera:d,unregisterCamera:f}=t1(),h=(0,o.useId)();l[0]!==c?(t=(0,b.getProperty)(c,"dataBlock"),l[0]=c,l[1]=t):t=l[1];let m=t;l[2]!==c?(r=(0,b.getPosition)(c),l[2]=c,l[3]=r):r=l[3];let p=r;l[4]!==c?(a=(0,b.getRotation)(c),l[4]=c,l[5]=a):a=l[5];let g=a;return l[6]!==m||l[7]!==h||l[8]!==p||l[9]!==g||l[10]!==d||l[11]!==f?(n=()=>{if("Observer"===m){let e={id:h,position:new u.Vector3(...p),rotation:g};return d(e),()=>{f(e)}}},s=[h,m,d,f,p,g],l[6]=m,l[7]=h,l[8]=p,l[9]=g,l[10]=d,l[11]=f,l[12]=n,l[13]=s):(n=l[12],s=l[13]),(0,o.useEffect)(n,s),null},ForceFieldBare:(0,o.lazy)(()=>e.A(25147).then(e=>({default:e.ForceFieldBare}))),InteriorInstance:tr,Item:function(e){let t,r,a,s,l,u,c,d,f,h,m,p,g=(0,i.c)(32),{object:v}=e,y=J();g[0]!==v?(t=(0,b.getProperty)(v,"dataBlock")??"",g[0]=v,g[1]=t):t=g[1];let F=t,C=(0,tZ.useDatablock)(F);g[2]!==C||g[3]!==v?(r=function(e){if("string"==typeof e){let t=e.toLowerCase();return"0"!==t&&"false"!==t&&""!==t}return!!e}((0,b.getProperty)(v,"rotate")??(0,b.getProperty)(C,"rotate")),g[2]=C,g[3]=v,g[4]=r):r=g[4];let B=r;g[5]!==v?(a=(0,b.getPosition)(v),g[5]=v,g[6]=a):a=g[6];let S=a;g[7]!==v?(s=(0,b.getScale)(v),g[7]=v,g[8]=s):s=g[8];let x=s;g[9]!==v?(l=(0,b.getRotation)(v),g[9]=v,g[10]=l):l=g[10];let M=l,{animationEnabled:D}=(0,E.useSettings)(),k=(0,o.useRef)(null);g[11]!==D||g[12]!==B?(u=()=>{if(!k.current||!B||!D)return;let e=performance.now()/1e3;k.current.rotation.y=e/3*Math.PI*2},g[11]=D,g[12]=B,g[13]=u):u=g[13],(0,A.useFrame)(u),g[14]!==C?(c=(0,b.getProperty)(C,"shapeFile"),g[14]=C,g[15]=c):c=g[15];let w=c;w||console.error(`<Item> missing shape for datablock: ${F}`);let I=F?.toLowerCase()==="flag",T=y?.team??null,R=T&&T>0?t$[T]:null,P=I&&R?`${R} Flag`:null;return g[16]!==M||g[17]!==B?(d=!B&&{quaternion:M},g[16]=M,g[17]=B,g[18]=d):d=g[18],g[19]!==P?(f=P?(0,n.jsx)(e3.FloatingLabel,{opacity:.6,children:P}):null,g[19]=P,g[20]=f):f=g[20],g[21]!==f?(h=(0,n.jsx)(tz,{loadingColor:"pink",children:f}),g[21]=f,g[22]=h):h=g[22],g[23]!==S||g[24]!==x||g[25]!==h||g[26]!==d?(m=(0,n.jsx)("group",{ref:k,position:S,...d,scale:x,children:h}),g[23]=S,g[24]=x,g[25]=h,g[26]=d,g[27]=m):m=g[27],g[28]!==v||g[29]!==w||g[30]!==m?(p=(0,n.jsx)(tk,{type:"Item",object:v,shapeName:w,children:m}),g[28]=v,g[29]=w,g[30]=m,g[31]=p):p=g[31],p},SimGroup:function(e){let t,r,a,o,s=(0,i.c)(17),{object:l}=e,u=(0,R.useRuntimeObjectById)(l._id)??l,c=J();s[0]!==u._children?(t=u._children??[],s[0]=u._children,s[1]=t):t=s[1];let d=(0,R.useRuntimeChildIds)(u._id,t),f=null,h=!1;if(c&&c.hasTeams){if(h=!0,null!=c.team)f=c.team;else if(u._name){let e;if(s[2]!==u._name){let t;s[4]===Symbol.for("react.memo_cache_sentinel")?(t=/^team(\d+)$/i,s[4]=t):t=s[4],e=u._name.match(t),s[2]=u._name,s[3]=e}else e=s[3];let t=e;t&&(f=parseInt(t[1],10))}}else if(u._name){let e;s[5]!==u._name?(e=u._name.toLowerCase(),s[5]=u._name,s[6]=e):e=s[6],h="teams"===e}s[7]!==h||s[8]!==u||s[9]!==c||s[10]!==f?(r={object:u,parent:c,hasTeams:h,team:f},s[7]=h,s[8]=u,s[9]=c,s[10]=f,s[11]=r):r=s[11];let m=r;return s[12]!==d?(a=d.map(K),s[12]=d,s[13]=a):a=s[13],s[14]!==m||s[15]!==a?(o=(0,n.jsx)(N.Provider,{value:m,children:a}),s[14]=m,s[15]=a,s[16]=o):o=s[16],o},Sky:function({object:e}){let{fogEnabled:t,highQualityFog:r}=(0,E.useSettings)(),a=(0,b.getProperty)(e,"materialList"),i=(0,o.useMemo)(()=>tm((0,b.getProperty)(e,"SkySolidColor")),[e]),s=(0,b.getInt)(e,"useSkyTextures")??1,l=(0,o.useMemo)(()=>(function(e,t=!0){let r=(0,b.getFloat)(e,"fogDistance")??0,a=(0,b.getFloat)(e,"visibleDistance")??1e3,n=(0,b.getFloat)(e,"high_fogDistance"),i=(0,b.getFloat)(e,"high_visibleDistance"),o=t&&null!=n&&n>0?n:r,s=t&&null!=i&&i>0?i:a,l=function(e){if(!e)return new u.Color(.5,.5,.5);let[t,r,a]=e.split(" ").map(e=>parseFloat(e));return new u.Color().setRGB(t,r,a).convertSRGBToLinear()}((0,b.getProperty)(e,"fogColor")),c=[];for(let t=1;t<=3;t++){let r=function(e,t=1){if(!e)return null;let r=e.split(" ").map(e=>parseFloat(e));if(r.length<3)return null;let[a,n,i]=r;return a<=0||i<=n?null:{visibleDistance:a,minHeight:n,maxHeight:i,percentage:Math.max(0,Math.min(1,t))}}((0,b.getProperty)(e,`fogVolume${t}`),1);r&&c.push(r)}let d=c.reduce((e,t)=>Math.max(e,t.maxHeight),0);return{fogDistance:o,visibleDistance:s,fogColor:l,fogVolumes:c,fogLine:d,enabled:s>o}})(e,r),[e,r]),c=(0,o.useMemo)(()=>tm((0,b.getProperty)(e,"fogColor")),[e]),d=i||c,f=l.enabled&&t,h=l.fogColor,{scene:m,gl:p}=(0,F.useThree)();(0,o.useEffect)(()=>{if(f){let e=h.clone();m.background=e,p.setClearColor(e)}else if(d){let e=d[0].clone();m.background=e,p.setClearColor(e)}else m.background=null;return()=>{m.background=null}},[m,p,f,h,d]);let g=i?.[1];return(0,n.jsxs)(n.Fragment,{children:[a&&s?(0,n.jsx)(o.Suspense,{fallback:null,children:(0,n.jsx)(tg,{materialList:a,fogColor:f?h:void 0,fogState:f?l:void 0},a)}):g?(0,n.jsx)(tv,{skyColor:g,fogColor:f?h:void 0,fogState:f?l:void 0}):null,(0,n.jsx)(o.Suspense,{children:(0,n.jsx)(td,{object:e})}),l.enabled?(0,n.jsx)(tA,{fogState:l,enabled:t}):null]})},StaticShape:function(e){let t,r,a,o,s,l,u,c,d=(0,i.c)(19),{object:f}=e;d[0]!==f?(t=(0,b.getProperty)(f,"dataBlock")??"",d[0]=f,d[1]=t):t=d[1];let h=t,m=(0,tZ.useDatablock)(h);d[2]!==f?(r=(0,b.getPosition)(f),d[2]=f,d[3]=r):r=d[3];let p=r;d[4]!==f?(a=(0,b.getRotation)(f),d[4]=f,d[5]=a):a=d[5];let g=a;d[6]!==f?(o=(0,b.getScale)(f),d[6]=f,d[7]=o):o=d[7];let v=o;d[8]!==m?(s=(0,b.getProperty)(m,"shapeFile"),d[8]=m,d[9]=s):s=d[9];let y=s;return y||console.error(`<StaticShape> missing shape for datablock: ${h}`),d[10]===Symbol.for("react.memo_cache_sentinel")?(l=(0,n.jsx)(tz,{}),d[10]=l):l=d[10],d[11]!==p||d[12]!==g||d[13]!==v?(u=(0,n.jsx)("group",{position:p,quaternion:g,scale:v,children:l}),d[11]=p,d[12]=g,d[13]=v,d[14]=u):u=d[14],d[15]!==f||d[16]!==y||d[17]!==u?(c=(0,n.jsx)(tk,{type:"StaticShape",object:f,shapeName:y,children:u}),d[15]=f,d[16]=y,d[17]=u,d[18]=c):c=d[18],c},Sun:function(e){let t,r,a,s,l,c,d,f,h,m,p=(0,i.c)(25),{object:g}=e;p[0]!==g?(t=((0,b.getProperty)(g,"direction")??"0.57735 0.57735 -0.57735").split(" ").map(tC),p[0]=g,p[1]=t):t=p[1];let[v,y,A]=t,F=Math.sqrt(v*v+A*A+y*y),C=v/F,B=A/F,x=y/F;p[2]!==C||p[3]!==B||p[4]!==x?(r=new u.Vector3(C,B,x),p[2]=C,p[3]=B,p[4]=x,p[5]=r):r=p[5];let E=r,M=-(5e3*E.x),D=-(5e3*E.y),k=-(5e3*E.z);p[6]!==M||p[7]!==D||p[8]!==k?(a=new u.Vector3(M,D,k),p[6]=M,p[7]=D,p[8]=k,p[9]=a):a=p[9];let w=a;if(p[10]!==g){let[e,t,r]=((0,b.getProperty)(g,"color")??"0.7 0.7 0.7 1").split(" ").map(tb);s=new u.Color(e,t,r),p[10]=g,p[11]=s}else s=p[11];let I=s;if(p[12]!==g){let[e,t,r]=((0,b.getProperty)(g,"ambient")??"0.5 0.5 0.5 1").split(" ").map(tF);l=new u.Color(e,t,r),p[12]=g,p[13]=l}else l=p[13];let T=l,R=E.y<0;return p[14]!==R?(c=()=>{S.value=R},d=[R],p[14]=R,p[15]=c,p[16]=d):(c=p[15],d=p[16]),(0,o.useEffect)(c,d),p[17]!==I||p[18]!==w?(f=(0,n.jsx)("directionalLight",{position:w,color:I,intensity:1,castShadow:!0,"shadow-mapSize-width":8192,"shadow-mapSize-height":8192,"shadow-camera-left":-4096,"shadow-camera-right":4096,"shadow-camera-top":4096,"shadow-camera-bottom":-4096,"shadow-camera-near":100,"shadow-camera-far":12e3,"shadow-bias":-1e-5,"shadow-normalBias":.4,"shadow-radius":2}),p[17]=I,p[18]=w,p[19]=f):f=p[19],p[20]!==T?(h=(0,n.jsx)("ambientLight",{color:T,intensity:1}),p[20]=T,p[21]=h):h=p[21],p[22]!==f||p[23]!==h?(m=(0,n.jsxs)(n.Fragment,{children:[f,h]}),p[22]=f,p[23]=h,p[24]=m):m=p[24],m},TerrainBlock:L,TSStatic:function(e){let t,r,a,o,s,l,u,c=(0,i.c)(17),{object:d}=e;c[0]!==d?(t=(0,b.getProperty)(d,"shapeName"),c[0]=d,c[1]=t):t=c[1];let f=t;c[2]!==d?(r=(0,b.getPosition)(d),c[2]=d,c[3]=r):r=c[3];let h=r;c[4]!==d?(a=(0,b.getRotation)(d),c[4]=d,c[5]=a):a=c[5];let m=a;c[6]!==d?(o=(0,b.getScale)(d),c[6]=d,c[7]=o):o=c[7];let p=o;return f||console.error("<TSStatic> missing shapeName for object",d),c[8]===Symbol.for("react.memo_cache_sentinel")?(s=(0,n.jsx)(tz,{}),c[8]=s):s=c[8],c[9]!==h||c[10]!==m||c[11]!==p?(l=(0,n.jsx)("group",{position:h,quaternion:m,scale:p,children:s}),c[9]=h,c[10]=m,c[11]=p,c[12]=l):l=c[12],c[13]!==d||c[14]!==f||c[15]!==l?(u=(0,n.jsx)(tk,{type:"TSStatic",object:d,shapeName:f,children:l}),c[13]=d,c[14]=f,c[15]=l,c[16]=u):u=c[16],u},Turret:function(e){let t,r,a,o,s,l,u,c,d,f,h,m=(0,i.c)(27),{object:p}=e;m[0]!==p?(t=(0,b.getProperty)(p,"dataBlock")??"",m[0]=p,m[1]=t):t=m[1];let g=t;m[2]!==p?(r=(0,b.getProperty)(p,"initialBarrel"),m[2]=p,m[3]=r):r=m[3];let v=r,y=(0,tZ.useDatablock)(g),A=(0,tZ.useDatablock)(v);m[4]!==p?(a=(0,b.getPosition)(p),m[4]=p,m[5]=a):a=m[5];let F=a;m[6]!==p?(o=(0,b.getRotation)(p),m[6]=p,m[7]=o):o=m[7];let C=o;m[8]!==p?(s=(0,b.getScale)(p),m[8]=p,m[9]=s):s=m[9];let B=s;m[10]!==y?(l=(0,b.getProperty)(y,"shapeFile"),m[10]=y,m[11]=l):l=m[11];let S=l;m[12]!==A?(u=(0,b.getProperty)(A,"shapeFile"),m[12]=A,m[13]=u):u=m[13];let x=u;return S||console.error(`<Turret> missing shape for datablock: ${g}`),v&&!x&&console.error(`<Turret> missing shape for barrel datablock: ${v}`),m[14]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)(tz,{}),m[14]=c):c=m[14],m[15]!==x||m[16]!==p?(d=x?(0,n.jsx)(tk,{type:"Turret",object:p,shapeName:x,children:(0,n.jsx)("group",{position:[0,1.5,0],children:(0,n.jsx)(tz,{})})}):null,m[15]=x,m[16]=p,m[17]=d):d=m[17],m[18]!==F||m[19]!==C||m[20]!==B||m[21]!==d?(f=(0,n.jsxs)("group",{position:F,quaternion:C,scale:B,children:[c,d]}),m[18]=F,m[19]=C,m[20]=B,m[21]=d,m[22]=f):f=m[22],m[23]!==p||m[24]!==S||m[25]!==f?(h=(0,n.jsx)(tk,{type:"Turret",object:p,shapeName:S,children:f}),m[23]=p,m[24]=S,m[25]=f,m[26]=h):h=m[26],h},WaterBlock:(0,o.lazy)(()=>e.A(18599).then(e=>({default:e.WaterBlock}))),WayPoint:function(e){let t,r,a,o=(0,i.c)(7),{object:s}=e;o[0]!==s?(t=(0,b.getPosition)(s),o[0]=s,o[1]=t):t=o[1];let l=t;o[2]!==s?(r=(0,b.getProperty)(s,"name"),o[2]=s,o[3]=r):r=o[3];let u=r;return o[4]!==u||o[5]!==l?(a=u?(0,n.jsx)(e3.FloatingLabel,{position:l,opacity:.6,children:u}):null,o[4]=u,o[5]=l,o[6]=a):a=o[6],a}},t4=new Set(["ForceFieldBare","Item","StaticShape","Turret"]);function t6(e){let t,r,a,s=(0,i.c)(13),{object:l,objectId:u}=e,c=(0,R.useRuntimeObjectById)(u??l?._id)??l,{missionType:d}=(0,o.useContext)(t3),f=(0,R.useEngineSelector)(t7);e:{let e,r;if(!c){t=!1;break e}s[0]!==c?(e=new Set(((0,b.getProperty)(c,"missionTypesList")??"").toLowerCase().split(/\s+/).filter(Boolean)),s[0]=c,s[1]=e):e=s[1];let a=e;s[2]!==d||s[3]!==a?(r=!a.size||a.has(d.toLowerCase()),s[2]=d,s[3]=a,s[4]=r):r=s[4],t=r}let h=t;if(!c)return null;let m=t8[c._className];s[5]!==f||s[6]!==c._className?(r=f&&t4.has(c._className),s[5]=f,s[6]=c._className,s[7]=r):r=s[7];let p=r;return s[8]!==m||s[9]!==p||s[10]!==c||s[11]!==h?(a=h&&m?(0,n.jsx)(o.Suspense,{children:!p&&(0,n.jsx)(m,{object:c})}):null,s[8]=m,s[9]=p,s[10]=c,s[11]=h,s[12]=a):a=s[12],a}function t7(e){return null!=e.playback.recording}let re=(0,o.createContext)(null);function rt(e){let t,r,a=(0,i.c)(5),{runtime:o,children:s}=e;return a[0]!==s?(t=(0,n.jsx)(tP,{children:s}),a[0]=s,a[1]=t):t=a[1],a[2]!==o||a[3]!==t?(r=(0,n.jsx)(re.Provider,{value:o,children:t}),a[2]=o,a[3]=t,a[4]=r):r=a[4],r}var rr=e.i(86608),ra=e.i(38433),rn=e.i(33870),ri=e.i(91996);let ro=async e=>{let t;try{t=(0,y.getUrlForPath)(e)}catch(t){return console.warn(`Script not in manifest: ${e} (${t})`),null}try{let r=await fetch(t);if(!r.ok)return console.error(`Script fetch failed: ${e} (${r.status})`),null;return await r.text()}catch(t){return console.error(`Script fetch error: ${e}`),console.error(t),null}},rs=(0,rn.createScriptCache)(),rl={findFiles:e=>{let t=(0,v.default)(e,{nocase:!0});return(0,ri.getResourceList)().filter(e=>t(e)).map(e=>{let[,t]=(0,ri.getSourceAndPath)(e);return t})},isFile:e=>null!=(0,ri.getResourceMap)()[(0,ri.getResourceKey)(e)]};function ru(e){"batch.flushed"===e.type&&R.engineStore.getState().applyRuntimeBatch(e.events,{tick:e.tick})}function rc(e){e instanceof Error&&"AbortError"===e.name||console.error("Mission runtime failed to become ready:",e)}let rd=(0,o.memo)(function(e){let t,r,a,s,l,u,c,d,f=(0,i.c)(17),{name:h,missionType:m,onLoadingChange:p}=e,{data:v}=((d=(0,i.c)(2))[0]!==h?(c={queryKey:["parsedMission",h],queryFn:()=>(0,y.loadMission)(h)},d[0]=h,d[1]=c):c=d[1],(0,g.useQuery)(c)),{missionGroup:A,runtime:F,progress:b}=function(e,t,r){let a,n,s,l=(0,i.c)(6);l[0]===Symbol.for("react.memo_cache_sentinel")?(a={missionGroup:void 0,runtime:void 0,progress:0},l[0]=a):a=l[0];let[u,c]=(0,o.useState)(a);return l[1]!==e||l[2]!==t||l[3]!==r?(n=()=>{if(!r)return;let a=new AbortController,n=!1,i=null,o=(0,ra.createProgressTracker)(),s=()=>{c(e=>({...e,progress:o.progress}))};o.on("update",s);let{runtime:l,ready:u}=(0,rr.runServer)({missionName:e,missionType:t,runtimeOptions:{loadScript:ro,fileSystem:rl,cache:rs,signal:a.signal,progress:o,ignoreScripts:["scripts/admin.cs","scripts/ai.cs","scripts/aiBotProfiles.cs","scripts/aiBountyGame.cs","scripts/aiChat.cs","scripts/aiCnH.cs","scripts/aiCTF.cs","scripts/aiDeathMatch.cs","scripts/aiDebug.cs","scripts/aiDefaultTasks.cs","scripts/aiDnD.cs","scripts/aiHumanTasks.cs","scripts/aiHunters.cs","scripts/aiInventory.cs","scripts/aiObjectiveBuilder.cs","scripts/aiObjectives.cs","scripts/aiRabbit.cs","scripts/aiSiege.cs","scripts/aiTDM.cs","scripts/aiTeamHunters.cs","scripts/deathMessages.cs","scripts/graphBuild.cs","scripts/navGraph.cs","scripts/serverTasks.cs","scripts/spdialog.cs"]}});return u.then(()=>{n||a.signal.aborted||(R.engineStore.getState().setRuntime(l),c({missionGroup:l.getObjectByName("MissionGroup"),runtime:l,progress:1}))}).catch(rc),i=l.subscribeRuntimeEvents(ru),R.engineStore.getState().setRuntime(l),()=>{n=!0,o.off("update",s),a.abort(),i?.(),R.engineStore.getState().clearRuntime(),l.destroy()}},s=[e,t,r],l[1]=e,l[2]=t,l[3]=r,l[4]=n,l[5]=s):(n=l[4],s=l[5]),(0,o.useEffect)(n,s),u}(h,m,v),C=!v||!A||!F;f[0]!==A||f[1]!==m||f[2]!==v?(t={metadata:v,missionType:m,missionGroup:A},f[0]=A,f[1]=m,f[2]=v,f[3]=t):t=f[3];let B=t;return(f[4]!==C||f[5]!==p||f[6]!==b?(r=()=>{p?.(C,b)},a=[C,b,p],f[4]=C,f[5]=p,f[6]=b,f[7]=r,f[8]=a):(r=f[7],a=f[8]),(0,o.useEffect)(r,a),C)?null:(f[9]!==A?(s=(0,n.jsx)(t6,{object:A}),f[9]=A,f[10]=s):s=f[10],f[11]!==F||f[12]!==s?(l=(0,n.jsx)(rt,{runtime:F,children:s}),f[11]=F,f[12]=s,f[13]=l):l=f[13],f[14]!==B||f[15]!==l?(u=(0,n.jsx)(t9,{value:B,children:l}),f[14]=B,f[15]=l,f[16]=u):u=f[16],u)});var rf=e.i(19273),rh=e.i(86491),rm=e.i(40143),rp=e.i(15823),rg=class extends rp.Subscribable{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){let a=t.queryKey,n=t.queryHash??(0,rf.hashQueryKeyByOptions)(a,t),i=this.get(n);return i||(i=new rh.Query({client:e,queryKey:a,queryHash:n,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(a)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){rm.notifyManager.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>(0,rf.matchQuery)(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>(0,rf.matchQuery)(e,t)):t}notify(e){rm.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){rm.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){rm.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},rv=e.i(88587),ry=e.i(36553),rA=class extends rv.Removable{#t;#r;#a;#n;constructor(e){super(),this.#t=e.client,this.mutationId=e.mutationId,this.#a=e.mutationCache,this.#r=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#r.includes(e)||(this.#r.push(e),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#r=this.#r.filter(t=>t!==e),this.scheduleGc(),this.#a.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#r.length||("pending"===this.state.status?this.scheduleGc():this.#a.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#n=(0,ry.createRetryer)({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#i({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#a.canRun(this)});let a="pending"===this.state.status,n=!this.#n.canStart();try{if(a)t();else{this.#i({type:"pending",variables:e,isPaused:n}),await this.#a.config.onMutate?.(e,this,r);let t=await this.options.onMutate?.(e,r);t!==this.state.context&&this.#i({type:"pending",context:t,variables:e,isPaused:n})}let i=await this.#n.start();return await this.#a.config.onSuccess?.(i,e,this.state.context,this,r),await this.options.onSuccess?.(i,e,this.state.context,r),await this.#a.config.onSettled?.(i,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(i,null,e,this.state.context,r),this.#i({type:"success",data:i}),i}catch(t){try{await this.#a.config.onError?.(t,e,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,r)}catch(e){Promise.reject(e)}try{await this.#a.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,r)}catch(e){Promise.reject(e)}throw this.#i({type:"error",error:t}),t}finally{this.#a.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),rm.notifyManager.batch(()=>{this.#r.forEach(t=>{t.onMutationUpdate(e)}),this.#a.notify({mutation:this,type:"updated",action:e})})}},rF=rp,rb=class extends rF.Subscribable{constructor(e={}){super(),this.config=e,this.#o=new Set,this.#s=new Map,this.#l=0}#o;#s;#l;build(e,t,r){let a=new rA({client:e,mutationCache:this,mutationId:++this.#l,options:e.defaultMutationOptions(t),state:r});return this.add(a),a}add(e){this.#o.add(e);let t=rC(e);if("string"==typeof t){let r=this.#s.get(t);r?r.push(e):this.#s.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#o.delete(e)){let t=rC(e);if("string"==typeof t){let r=this.#s.get(t);if(r)if(r.length>1){let t=r.indexOf(e);-1!==t&&r.splice(t,1)}else r[0]===e&&this.#s.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=rC(e);if("string"!=typeof t)return!0;{let r=this.#s.get(t),a=r?.find(e=>"pending"===e.state.status);return!a||a===e}}runNext(e){let t=rC(e);if("string"!=typeof t)return Promise.resolve();{let r=this.#s.get(t)?.find(t=>t!==e&&t.state.isPaused);return r?.continue()??Promise.resolve()}}clear(){rm.notifyManager.batch(()=>{this.#o.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#o.clear(),this.#s.clear()})}getAll(){return Array.from(this.#o)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>(0,rf.matchMutation)(t,e))}findAll(e={}){return this.getAll().filter(t=>(0,rf.matchMutation)(e,t))}notify(e){rm.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return rm.notifyManager.batch(()=>Promise.all(e.map(e=>e.continue().catch(rf.noop))))}};function rC(e){return e.options.scope?.id}var rB=e.i(75555),rS=e.i(14448);function rx(e){return{onFetch:(t,r)=>{let a=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},l=0,u=async()=>{let r=!1,u=(0,rf.ensureQueryFn)(t.options,t.fetchOptions),c=async(e,a,n)=>{let i;if(r)return Promise.reject();if(null==a&&e.pages.length)return Promise.resolve(e);let o=(i={client:t.client,queryKey:t.queryKey,pageParam:a,direction:n?"backward":"forward",meta:t.options.meta},(0,rf.addConsumeAwareSignal)(i,()=>t.signal,()=>r=!0),i),s=await u(o),{maxPages:l}=t.options,c=n?rf.addToStart:rf.addToEnd;return{pages:c(e.pages,s,l),pageParams:c(e.pageParams,a,l)}};if(n&&i.length){let e="backward"===n,t={pages:i,pageParams:o},r=(e?function(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}:rE)(a,t);s=await c(t,r,e)}else{let t=e??i.length;do{let e=0===l?o[0]??a.initialPageParam:rE(a,s);if(l>0&&null==e)break;s=await c(s,e),l++}while(l<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=u}}}function rE(e,{pages:t,pageParams:r}){let a=t.length-1;return t.length>0?e.getNextPageParam(t[a],t,r[a],r):void 0}var rM=class{#u;#a;#c;#d;#f;#h;#m;#p;constructor(e={}){this.#u=e.queryCache||new rg,this.#a=e.mutationCache||new rb,this.#c=e.defaultOptions||{},this.#d=new Map,this.#f=new Map,this.#h=0}mount(){this.#h++,1===this.#h&&(this.#m=rB.focusManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#u.onFocus())}),this.#p=rS.onlineManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#u.onOnline())}))}unmount(){this.#h--,0===this.#h&&(this.#m?.(),this.#m=void 0,this.#p?.(),this.#p=void 0)}isFetching(e){return this.#u.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#a.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#u.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=this.#u.build(this,t),a=r.state.data;return void 0===a?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime((0,rf.resolveStaleTime)(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(a))}getQueriesData(e){return this.#u.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,r){let a=this.defaultQueryOptions({queryKey:e}),n=this.#u.get(a.queryHash),i=n?.state.data,o=(0,rf.functionalUpdate)(t,i);if(void 0!==o)return this.#u.build(this,a).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return rm.notifyManager.batch(()=>this.#u.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#u.get(t.queryHash)?.state}removeQueries(e){let t=this.#u;rm.notifyManager.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let r=this.#u;return rm.notifyManager.batch(()=>(r.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:!0,...t};return Promise.all(rm.notifyManager.batch(()=>this.#u.findAll(e).map(e=>e.cancel(r)))).then(rf.noop).catch(rf.noop)}invalidateQueries(e,t={}){return rm.notifyManager.batch(()=>(this.#u.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??!0};return Promise.all(rm.notifyManager.batch(()=>this.#u.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,r);return r.throwOnError||(t=t.catch(rf.noop)),"paused"===e.state.fetchStatus?Promise.resolve():t}))).then(rf.noop)}fetchQuery(e){let t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);let r=this.#u.build(this,t);return r.isStaleByTime((0,rf.resolveStaleTime)(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(rf.noop).catch(rf.noop)}fetchInfiniteQuery(e){return e.behavior=rx(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(rf.noop).catch(rf.noop)}ensureInfiniteQueryData(e){return e.behavior=rx(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return rS.onlineManager.isOnline()?this.#a.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#u}getMutationCache(){return this.#a}getDefaultOptions(){return this.#c}setDefaultOptions(e){this.#c=e}setQueryDefaults(e,t){this.#d.set((0,rf.hashKey)(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#d.values()],r={};return t.forEach(t=>{(0,rf.partialMatchKey)(e,t.queryKey)&&Object.assign(r,t.defaultOptions)}),r}setMutationDefaults(e,t){this.#f.set((0,rf.hashKey)(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#f.values()],r={};return t.forEach(t=>{(0,rf.partialMatchKey)(e,t.mutationKey)&&Object.assign(r,t.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#c.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=(0,rf.hashQueryKeyByOptions)(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===rf.skipToken&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#c.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#u.clear(),this.#a.clear()}},rD=e.i(12598),rk=e.i(8155);let rw=e=>{let t=(0,rk.createStore)(e),r=e=>(function(e,t=e=>e){let r=o.default.useSyncExternalStore(e.subscribe,o.default.useCallback(()=>t(e.getState()),[e,t]),o.default.useCallback(()=>t(e.getInitialState()),[e,t]));return o.default.useDebugValue(r),r})(t,e);return Object.assign(r,t),r};var rI=e.i(79473);let rT=o.createContext(null);function rR({map:e,children:t,onChange:r,domElement:a}){let n=e.map(e=>e.name+e.keys).join("-"),i=o.useMemo(()=>{let t;return(t=(0,rI.subscribeWithSelector)(()=>e.reduce((e,t)=>({...e,[t.name]:!1}),{})))?rw(t):rw},[n]),s=o.useMemo(()=>[i.subscribe,i.getState,i],[n]),l=i.setState;return o.useEffect(()=>{let t=e.map(({name:e,keys:t,up:a})=>({keys:t,up:a,fn:t=>{l({[e]:t}),r&&r(e,t,s[1]())}})).reduce((e,{keys:t,fn:r,up:a=!0})=>(t.forEach(t=>e[t]={fn:r,pressed:!1,up:a}),e),{}),n=({key:e,code:r})=>{let a=t[e]||t[r];if(!a)return;let{fn:n,pressed:i,up:o}=a;a.pressed=!0,(o||!i)&&n(!0)},i=({key:e,code:r})=>{let a=t[e]||t[r];if(!a)return;let{fn:n,up:i}=a;a.pressed=!1,i&&n(!1)},o=a||window;return o.addEventListener("keydown",n,{passive:!0}),o.addEventListener("keyup",i,{passive:!0}),()=>{o.removeEventListener("keydown",n),o.removeEventListener("keyup",i)}},[a,n]),o.createElement(rT.Provider,{value:s,children:t})}function rP(e){let[t,r,a]=o.useContext(rT);return e?a(e):[t,r]}var rG=Object.defineProperty;class rL{constructor(){((e,t,r)=>{let a;return(a="symbol"!=typeof t?t+"":t)in e?rG(e,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[a]=r})(this,"_listeners")}addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let r=this._listeners;return void 0!==r[e]&&-1!==r[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let r=this._listeners[e];if(void 0!==r){let e=r.indexOf(t);-1!==e&&r.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let r=t.slice(0);for(let t=0,a=r.length;t<a;t++)r[t].call(this,e);e.target=null}}}var rj=Object.defineProperty,r_=(e,t,r)=>{let a;return(a="symbol"!=typeof t?t+"":t)in e?rj(e,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[a]=r,r};let rO=new u.Euler(0,0,0,"YXZ"),rU=new u.Vector3,rH={type:"change"},rN={type:"lock"},rJ={type:"unlock"},rK=Math.PI/2;class rV extends rL{constructor(e,t){super(),r_(this,"camera"),r_(this,"domElement"),r_(this,"isLocked"),r_(this,"minPolarAngle"),r_(this,"maxPolarAngle"),r_(this,"pointerSpeed"),r_(this,"onMouseMove",e=>{this.domElement&&!1!==this.isLocked&&(rO.setFromQuaternion(this.camera.quaternion),rO.y-=.002*e.movementX*this.pointerSpeed,rO.x-=.002*e.movementY*this.pointerSpeed,rO.x=Math.max(rK-this.maxPolarAngle,Math.min(rK-this.minPolarAngle,rO.x)),this.camera.quaternion.setFromEuler(rO),this.dispatchEvent(rH))}),r_(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(rN),this.isLocked=!0):(this.dispatchEvent(rJ),this.isLocked=!1))}),r_(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),r_(this,"connect",e=>{this.domElement=e||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),r_(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),r_(this,"dispose",()=>{this.disconnect()}),r_(this,"getObject",()=>this.camera),r_(this,"direction",new u.Vector3(0,0,-1)),r_(this,"getDirection",e=>e.copy(this.direction).applyQuaternion(this.camera.quaternion)),r_(this,"moveForward",e=>{rU.setFromMatrixColumn(this.camera.matrix,0),rU.crossVectors(this.camera.up,rU),this.camera.position.addScaledVector(rU,e)}),r_(this,"moveRight",e=>{rU.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(rU,e)}),r_(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),r_(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}(a={}).forward="forward",a.backward="backward",a.left="left",a.right="right",a.up="up",a.down="down",a.lookUp="lookUp",a.lookDown="lookDown",a.lookLeft="lookLeft",a.lookRight="lookRight",a.camera1="camera1",a.camera2="camera2",a.camera3="camera3",a.camera4="camera4",a.camera5="camera5",a.camera6="camera6",a.camera7="camera7",a.camera8="camera8",a.camera9="camera9";let rz=Math.PI/2-.01;function rq(){let e,t,r,a,n,s,l,c,d,f,h,m,p,g=(0,i.c)(26),{speedMultiplier:v,setSpeedMultiplier:y}=(0,E.useControls)(),[b,C]=rP(),{camera:B,gl:S}=(0,F.useThree)(),{nextCamera:x,setCameraIndex:M,cameraCount:D}=t1(),k=(0,o.useRef)(null);g[0]===Symbol.for("react.memo_cache_sentinel")?(e=new u.Vector3,g[0]=e):e=g[0];let w=(0,o.useRef)(e);g[1]===Symbol.for("react.memo_cache_sentinel")?(t=new u.Vector3,g[1]=t):t=g[1];let I=(0,o.useRef)(t);g[2]===Symbol.for("react.memo_cache_sentinel")?(r=new u.Vector3,g[2]=r):r=g[2];let T=(0,o.useRef)(r);g[3]===Symbol.for("react.memo_cache_sentinel")?(a=new u.Euler(0,0,0,"YXZ"),g[3]=a):a=g[3];let R=(0,o.useRef)(a);return g[4]!==B||g[5]!==S.domElement?(n=()=>{let e=new rV(B,S.domElement);return k.current=e,()=>{e.dispose()}},s=[B,S.domElement],g[4]=B,g[5]=S.domElement,g[6]=n,g[7]=s):(n=g[6],s=g[7]),(0,o.useEffect)(n,s),g[8]!==B||g[9]!==S.domElement||g[10]!==x?(l=()=>{let e=S.domElement,t=new u.Euler(0,0,0,"YXZ"),r=!1,a=!1,n=0,i=0,o=t=>{k.current?.isLocked||t.target===e&&(r=!0,a=!1,n=t.clientX,i=t.clientY)},s=e=>{!r||!a&&3>Math.abs(e.clientX-n)&&3>Math.abs(e.clientY-i)||(a=!0,t.setFromQuaternion(B.quaternion,"YXZ"),t.y=t.y-.003*e.movementX,t.x=t.x-.003*e.movementY,t.x=Math.max(-rz,Math.min(rz,t.x)),B.quaternion.setFromEuler(t))},l=()=>{r=!1},c=t=>{let r=k.current;!r||r.isLocked?x():t.target!==e||a||r.lock()};return e.addEventListener("mousedown",o),document.addEventListener("mousemove",s),document.addEventListener("mouseup",l),document.addEventListener("click",c),()=>{e.removeEventListener("mousedown",o),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",l),document.removeEventListener("click",c)}},c=[B,S.domElement,x],g[8]=B,g[9]=S.domElement,g[10]=x,g[11]=l,g[12]=c):(l=g[11],c=g[12]),(0,o.useEffect)(l,c),g[13]!==D||g[14]!==M||g[15]!==b?(d=()=>{let e=["camera1","camera2","camera3","camera4","camera5","camera6","camera7","camera8","camera9"];return b(t=>{for(let r=0;r<e.length;r++)if(t[e[r]]&&r<D){M(r);break}})},f=[b,M,D],g[13]=D,g[14]=M,g[15]=b,g[16]=d,g[17]=f):(d=g[16],f=g[17]),(0,o.useEffect)(d,f),g[18]!==S.domElement||g[19]!==y?(h=()=>{let e=e=>{e.preventDefault();let t=e.deltaY>0?-1:1,r=Math.max(.05,Math.min(.5,Math.abs(.01*e.deltaY)))*t;y(e=>Math.max(.1,Math.min(5,Math.round((e+r)*20)/20)))},t=S.domElement;return t.addEventListener("wheel",e,{passive:!1}),()=>{t.removeEventListener("wheel",e)}},m=[S.domElement,y],g[18]=S.domElement,g[19]=y,g[20]=h,g[21]=m):(h=g[20],m=g[21]),(0,o.useEffect)(h,m),g[22]!==B||g[23]!==C||g[24]!==v?(p=(e,t)=>{let{forward:r,backward:a,left:n,right:i,up:o,down:s,lookUp:l,lookDown:u,lookLeft:c,lookRight:d}=C();if((l||u||c||d)&&(R.current.setFromQuaternion(B.quaternion,"YXZ"),c&&(R.current.y=R.current.y+ +t),d&&(R.current.y=R.current.y-t),l&&(R.current.x=R.current.x+ +t),u&&(R.current.x=R.current.x-t),R.current.x=Math.max(-rz,Math.min(rz,R.current.x)),B.quaternion.setFromEuler(R.current)),!r&&!a&&!n&&!i&&!o&&!s)return;let f=80*v;B.getWorldDirection(w.current),w.current.normalize(),I.current.crossVectors(B.up,w.current).normalize(),T.current.set(0,0,0),r&&T.current.add(w.current),a&&T.current.sub(w.current),n&&T.current.add(I.current),i&&T.current.sub(I.current),o&&(T.current.y=T.current.y+1),s&&(T.current.y=T.current.y-1),T.current.lengthSq()>0&&(T.current.normalize().multiplyScalar(f*t),B.position.add(T.current))},g[22]=B,g[23]=C,g[24]=v,g[25]=p):p=g[25],(0,A.useFrame)(p),null}let rQ=[{name:"forward",keys:["KeyW"]},{name:"backward",keys:["KeyS"]},{name:"left",keys:["KeyA"]},{name:"right",keys:["KeyD"]},{name:"up",keys:["Space"]},{name:"down",keys:["ShiftLeft","ShiftRight"]},{name:"lookUp",keys:["ArrowUp"]},{name:"lookDown",keys:["ArrowDown"]},{name:"lookLeft",keys:["ArrowLeft"]},{name:"lookRight",keys:["ArrowRight"]},{name:"camera1",keys:["Digit1"]},{name:"camera2",keys:["Digit2"]},{name:"camera3",keys:["Digit3"]},{name:"camera4",keys:["Digit4"]},{name:"camera5",keys:["Digit5"]},{name:"camera6",keys:["Digit6"]},{name:"camera7",keys:["Digit7"]},{name:"camera8",keys:["Digit8"]},{name:"camera9",keys:["Digit9"]}];function rW(){let e,t,r=(0,i.c)(2);return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],r[0]=e):e=r[0],(0,o.useEffect)(rX,e),r[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)(rq,{}),r[1]=t):t=r[1],t}function rX(){return window.addEventListener("keydown",rY,{capture:!0}),window.addEventListener("keyup",rY,{capture:!0}),()=>{window.removeEventListener("keydown",rY,{capture:!0}),window.removeEventListener("keyup",rY,{capture:!0})}}function rY(e){(e.metaKey||e.ctrlKey)&&"k"===e.key||e.metaKey&&e.stopImmediatePropagation()}function rZ(e){let t,r=(0,i.c)(2),{children:a}=e;return r[0]!==a?(t=(0,n.jsx)(n.Fragment,{children:a}),r[0]=a,r[1]=t):t=r[1],t}function r$(){return(0,R.useEngineSelector)(r0)}function r0(e){return e.playback.recording}function r1(){return(0,R.useEngineSelector)(r2)}function r2(e){return"playing"===e.playback.status}function r3(){return(0,R.useEngineSelector)(r9)}function r9(e){return e.playback.timeMs/1e3}function r5(e){return e.playback.durationMs/1e3}function r8(e){return e.playback.rate}function r4(){let e,t,r,a,n,o,s=(0,i.c)(17),l=r$(),u=(0,R.useEngineSelector)(at),c=(0,R.useEngineSelector)(ae),d=(0,R.useEngineSelector)(r7),f=(0,R.useEngineSelector)(r6);s[0]!==u?(e=e=>{u(e)},s[0]=u,s[1]=e):e=s[1];let h=e;s[2]!==l||s[3]!==c?(t=()=>{(!(l?.isMetadataOnly||l?.isPartial)||l.streamingPlayback)&&c("playing")},s[2]=l,s[3]=c,s[4]=t):t=s[4];let m=t;s[5]!==c?(r=()=>{c("paused")},s[5]=c,s[6]=r):r=s[6];let p=r;s[7]!==d?(a=e=>{d(1e3*e)},s[7]=d,s[8]=a):a=s[8];let g=a;s[9]!==f?(n=e=>{f(e)},s[9]=f,s[10]=n):n=s[10];let v=n;return s[11]!==p||s[12]!==m||s[13]!==g||s[14]!==h||s[15]!==v?(o={setRecording:h,play:m,pause:p,seek:g,setSpeed:v},s[11]=p,s[12]=m,s[13]=g,s[14]=h,s[15]=v,s[16]=o):o=s[16],o}function r6(e){return e.setPlaybackRate}function r7(e){return e.setPlaybackTime}function ae(e){return e.setPlaybackStatus}function at(e){return e.setDemoRecording}function ar(){let e,t,r,a,o,s,l,u,c,d,f,h,m,p,g,v,y,A,F,b,C,B,S,x,E=(0,i.c)(51),M=r$(),D=rP(af),k=rP(ad),w=rP(ac),I=rP(au),T=rP(al),R=rP(as),P=rP(ao),G=rP(ai),L=rP(an),j=rP(aa);return M?null:(E[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:"KeyboardOverlay-spacer"}),E[0]=e):e=E[0],E[1]!==D?(t=(0,n.jsx)("div",{className:"KeyboardOverlay-key","data-pressed":D,children:"W"}),E[1]=D,E[2]=t):t=E[2],E[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)("div",{className:"KeyboardOverlay-spacer"}),E[3]=r):r=E[3],E[4]!==t?(a=(0,n.jsxs)("div",{className:"KeyboardOverlay-row",children:[e,t,r]}),E[4]=t,E[5]=a):a=E[5],E[6]!==w?(o=(0,n.jsx)("div",{className:"KeyboardOverlay-key","data-pressed":w,children:"A"}),E[6]=w,E[7]=o):o=E[7],E[8]!==k?(s=(0,n.jsx)("div",{className:"KeyboardOverlay-key","data-pressed":k,children:"S"}),E[8]=k,E[9]=s):s=E[9],E[10]!==I?(l=(0,n.jsx)("div",{className:"KeyboardOverlay-key","data-pressed":I,children:"D"}),E[10]=I,E[11]=l):l=E[11],E[12]!==o||E[13]!==s||E[14]!==l?(u=(0,n.jsxs)("div",{className:"KeyboardOverlay-row",children:[o,s,l]}),E[12]=o,E[13]=s,E[14]=l,E[15]=u):u=E[15],E[16]!==a||E[17]!==u?(c=(0,n.jsxs)("div",{className:"KeyboardOverlay-column",children:[a,u]}),E[16]=a,E[17]=u,E[18]=c):c=E[18],E[19]===Symbol.for("react.memo_cache_sentinel")?(d=(0,n.jsx)("span",{className:"KeyboardOverlay-arrow",children:"↑"}),E[19]=d):d=E[19],E[20]!==T?(f=(0,n.jsx)("div",{className:"KeyboardOverlay-row",children:(0,n.jsxs)("div",{className:"KeyboardOverlay-key","data-pressed":T,children:[d," Space"]})}),E[20]=T,E[21]=f):f=E[21],E[22]===Symbol.for("react.memo_cache_sentinel")?(h=(0,n.jsx)("span",{className:"KeyboardOverlay-arrow",children:"↓"}),E[22]=h):h=E[22],E[23]!==R?(m=(0,n.jsx)("div",{className:"KeyboardOverlay-row",children:(0,n.jsxs)("div",{className:"KeyboardOverlay-key","data-pressed":R,children:[h," Shift"]})}),E[23]=R,E[24]=m):m=E[24],E[25]!==f||E[26]!==m?(p=(0,n.jsxs)("div",{className:"KeyboardOverlay-column",children:[f,m]}),E[25]=f,E[26]=m,E[27]=p):p=E[27],E[28]===Symbol.for("react.memo_cache_sentinel")?(g=(0,n.jsx)("div",{className:"KeyboardOverlay-spacer"}),E[28]=g):g=E[28],E[29]!==P?(v=(0,n.jsx)("div",{className:"KeyboardOverlay-key","data-pressed":P,children:"↑"}),E[29]=P,E[30]=v):v=E[30],E[31]===Symbol.for("react.memo_cache_sentinel")?(y=(0,n.jsx)("div",{className:"KeyboardOverlay-spacer"}),E[31]=y):y=E[31],E[32]!==v?(A=(0,n.jsxs)("div",{className:"KeyboardOverlay-row",children:[g,v,y]}),E[32]=v,E[33]=A):A=E[33],E[34]!==L?(F=(0,n.jsx)("div",{className:"KeyboardOverlay-key","data-pressed":L,children:"←"}),E[34]=L,E[35]=F):F=E[35],E[36]!==G?(b=(0,n.jsx)("div",{className:"KeyboardOverlay-key","data-pressed":G,children:"↓"}),E[36]=G,E[37]=b):b=E[37],E[38]!==j?(C=(0,n.jsx)("div",{className:"KeyboardOverlay-key","data-pressed":j,children:"→"}),E[38]=j,E[39]=C):C=E[39],E[40]!==F||E[41]!==b||E[42]!==C?(B=(0,n.jsxs)("div",{className:"KeyboardOverlay-row",children:[F,b,C]}),E[40]=F,E[41]=b,E[42]=C,E[43]=B):B=E[43],E[44]!==A||E[45]!==B?(S=(0,n.jsxs)("div",{className:"KeyboardOverlay-column",children:[A,B]}),E[44]=A,E[45]=B,E[46]=S):S=E[46],E[47]!==p||E[48]!==S||E[49]!==c?(x=(0,n.jsxs)("div",{className:"KeyboardOverlay",children:[c,p,S]}),E[47]=p,E[48]=S,E[49]=c,E[50]=x):x=E[50],x)}function aa(e){return e.lookRight}function an(e){return e.lookLeft}function ai(e){return e.lookDown}function ao(e){return e.lookUp}function as(e){return e.down}function al(e){return e.up}function au(e){return e.right}function ac(e){return e.left}function ad(e){return e.backward}function af(e){return e.forward}let ah=Math.PI/2-.01;function am({joystickState:t,joystickZone:r,lookJoystickState:a,lookJoystickZone:i}){let{touchMode:s}=(0,E.useControls)();(0,o.useEffect)(()=>{let a=r.current;if(!a)return;let n=null,i=!1;return e.A(84968).then(e=>{i||((n=e.default.create({zone:a,mode:"static",position:{left:"70px",bottom:"70px"},size:120,restOpacity:.9})).on("move",(e,r)=>{t.current.angle=r.angle.radian,t.current.force=Math.min(1,r.force)}),n.on("end",()=>{t.current.force=0}))}),()=>{i=!0,n?.destroy()}},[t,r,s]),(0,o.useEffect)(()=>{if("dualStick"!==s)return;let t=i.current;if(!t)return;let r=null,n=!1;return e.A(84968).then(e=>{n||((r=e.default.create({zone:t,mode:"static",position:{right:"70px",bottom:"70px"},size:120,restOpacity:.9})).on("move",(e,t)=>{a.current.angle=t.angle.radian,a.current.force=Math.min(1,t.force)}),r.on("end",()=>{a.current.force=0}))}),()=>{n=!0,r?.destroy()}},[s,a,i]);let l=()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()};return"dualStick"===s?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{ref:r,className:"TouchJoystick TouchJoystick--left",onContextMenu:e=>e.preventDefault(),onTouchStart:l}),(0,n.jsx)("div",{ref:i,className:"TouchJoystick TouchJoystick--right",onContextMenu:e=>e.preventDefault(),onTouchStart:l})]}):(0,n.jsx)("div",{ref:r,className:"TouchJoystick",onContextMenu:e=>e.preventDefault(),onTouchStart:l})}function ap(e){let t,r,a,n,s,l,c,d,f,h,m=(0,i.c)(25),{joystickState:p,joystickZone:g,lookJoystickState:v}=e,{speedMultiplier:y,touchMode:b}=(0,E.useControls)(),{camera:C,gl:B}=(0,F.useThree)();m[0]===Symbol.for("react.memo_cache_sentinel")?(t=new u.Euler(0,0,0,"YXZ"),m[0]=t):t=m[0];let S=(0,o.useRef)(t),x=(0,o.useRef)(null);m[1]===Symbol.for("react.memo_cache_sentinel")?(r={x:0,y:0},m[1]=r):r=m[1];let M=(0,o.useRef)(r);m[2]===Symbol.for("react.memo_cache_sentinel")?(a=new u.Vector3,m[2]=a):a=m[2];let D=(0,o.useRef)(a);m[3]===Symbol.for("react.memo_cache_sentinel")?(n=new u.Vector3,m[3]=n):n=m[3];let k=(0,o.useRef)(n);m[4]===Symbol.for("react.memo_cache_sentinel")?(s=new u.Vector3,m[4]=s):s=m[4];let w=(0,o.useRef)(s);return m[5]!==C.quaternion?(l=()=>{S.current.setFromQuaternion(C.quaternion,"YXZ")},m[5]=C.quaternion,m[6]=l):l=m[6],m[7]!==C?(c=[C],m[7]=C,m[8]=c):c=m[8],(0,o.useEffect)(l,c),m[9]!==C.quaternion||m[10]!==B.domElement||m[11]!==g||m[12]!==b?(d=()=>{if("moveLookStick"!==b)return;let e=B.domElement,t=e=>{let t=g.current;if(!t)return!1;let r=t.getBoundingClientRect();return e.clientX>=r.left&&e.clientX<=r.right&&e.clientY>=r.top&&e.clientY<=r.bottom},r=e=>{if(null===x.current)for(let r=0;r<e.changedTouches.length;r++){let a=e.changedTouches[r];if(!t(a)){x.current=a.identifier,M.current={x:a.clientX,y:a.clientY};break}}},a=e=>{if(null!==x.current)for(let t=0;t<e.changedTouches.length;t++){let r=e.changedTouches[t];if(r.identifier===x.current){let e=r.clientX-M.current.x,t=r.clientY-M.current.y;M.current={x:r.clientX,y:r.clientY},S.current.setFromQuaternion(C.quaternion,"YXZ"),S.current.y=S.current.y-.004*e,S.current.x=S.current.x-.004*t,S.current.x=Math.max(-ah,Math.min(ah,S.current.x)),C.quaternion.setFromEuler(S.current);break}}},n=e=>{for(let t=0;t<e.changedTouches.length;t++)if(e.changedTouches[t].identifier===x.current){x.current=null;break}};return e.addEventListener("touchstart",r,{passive:!0}),e.addEventListener("touchmove",a,{passive:!0}),e.addEventListener("touchend",n,{passive:!0}),e.addEventListener("touchcancel",n,{passive:!0}),()=>{e.removeEventListener("touchstart",r),e.removeEventListener("touchmove",a),e.removeEventListener("touchend",n),e.removeEventListener("touchcancel",n),x.current=null}},m[9]=C.quaternion,m[10]=B.domElement,m[11]=g,m[12]=b,m[13]=d):d=m[13],m[14]!==C||m[15]!==B.domElement||m[16]!==g||m[17]!==b?(f=[C,B.domElement,g,b],m[14]=C,m[15]=B.domElement,m[16]=g,m[17]=b,m[18]=f):f=m[18],(0,o.useEffect)(d,f),m[19]!==C||m[20]!==p.current||m[21]!==v||m[22]!==y||m[23]!==b?(h=(e,t)=>{let{force:r,angle:a}=p.current;if("dualStick"===b){let e=v.current;if(e.force>.15){let r=(e.force-.15)/.85,a=Math.cos(e.angle),n=Math.sin(e.angle);S.current.setFromQuaternion(C.quaternion,"YXZ"),S.current.y=S.current.y-a*r*2.5*t,S.current.x=S.current.x+n*r*2.5*t,S.current.x=Math.max(-ah,Math.min(ah,S.current.x)),C.quaternion.setFromEuler(S.current)}if(r>.08){let e=80*y*((r-.08)/.92),n=Math.cos(a),i=Math.sin(a);C.getWorldDirection(D.current),D.current.normalize(),k.current.crossVectors(C.up,D.current).normalize(),w.current.set(0,0,0).addScaledVector(D.current,i).addScaledVector(k.current,-n),w.current.lengthSq()>0&&(w.current.normalize().multiplyScalar(e*t),C.position.add(w.current))}}else if("moveLookStick"===b&&r>0){let e=80*y*.5;if(C.getWorldDirection(D.current),D.current.normalize(),w.current.copy(D.current).multiplyScalar(e*t),C.position.add(w.current),r>=.15){let e=Math.cos(a),n=Math.sin(a),i=(r-.15)/.85;S.current.setFromQuaternion(C.quaternion,"YXZ"),S.current.y=S.current.y-e*i*1.25*t,S.current.x=S.current.x+n*i*1.25*t,S.current.x=Math.max(-ah,Math.min(ah,S.current.x)),C.quaternion.setFromEuler(S.current)}}},m[19]=C,m[20]=p.current,m[21]=v,m[22]=y,m[23]=b,m[24]=h):h=m[24],(0,A.useFrame)(h),null}var ag="undefined"!=typeof window&&!!(null==(r=window.document)?void 0:r.createElement);function av(e){return e?"self"in e?e.document:e.ownerDocument||document:document}function ay(e){return e?"self"in e?e.self:av(e).defaultView||window:self}function aA(e,t=!1){let{activeElement:r}=av(e);if(!(null==r?void 0:r.nodeName))return null;if(ab(r)&&r.contentDocument)return aA(r.contentDocument.body,t);if(t){let e=r.getAttribute("aria-activedescendant");if(e){let t=av(r).getElementById(e);if(t)return t}}return r}function aF(e,t){return e===t||e.contains(t)}function ab(e){return"IFRAME"===e.tagName}function aC(e){let t=e.tagName.toLowerCase();return"button"===t||"input"===t&&!!e.type&&-1!==aB.indexOf(e.type)}var aB=["button","color","file","image","reset","submit"];function aS(e){return"function"==typeof e.checkVisibility?e.checkVisibility():e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0}function ax(e){try{let t=e instanceof HTMLInputElement&&null!==e.selectionStart,r="TEXTAREA"===e.tagName;return t||r||!1}catch(e){return!1}}function aE(e){return e.isContentEditable||ax(e)}function aM(e){let t=0,r=0;if(ax(e))t=e.selectionStart||0,r=e.selectionEnd||0;else if(e.isContentEditable){let a=av(e).getSelection();if((null==a?void 0:a.rangeCount)&&a.anchorNode&&aF(e,a.anchorNode)&&a.focusNode&&aF(e,a.focusNode)){let n=a.getRangeAt(0),i=n.cloneRange();i.selectNodeContents(e),i.setEnd(n.startContainer,n.startOffset),t=i.toString().length,i.setEnd(n.endContainer,n.endOffset),r=i.toString().length}}return{start:t,end:r}}function aD(e,t){let r=null==e?void 0:e.getAttribute("role");return r&&-1!==["dialog","menu","listbox","tree","grid"].indexOf(r)?r:t}function ak(e){if(!e)return null;let t=e=>"auto"===e||"scroll"===e;if(e.clientHeight&&e.scrollHeight>e.clientHeight){let{overflowY:r}=getComputedStyle(e);if(t(r))return e}else if(e.clientWidth&&e.scrollWidth>e.clientWidth){let{overflowX:r}=getComputedStyle(e);if(t(r))return e}return ak(e.parentElement)||document.scrollingElement||document.body}function aw(e,...t){/text|search|password|tel|url/i.test(e.type)&&e.setSelectionRange(...t)}function aI(e,t){return t&&e.item(t)||null}var aT=Symbol("FOCUS_SILENTLY");function aR(e,t,r){if(!t||t===r)return!1;let a=e.item(t.id);return!!a&&(!r||a.element!==r)}function aP(){}function aG(e,t){return"function"==typeof Object.hasOwn?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t)}function aL(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}function aj(e){return e}function a_(e,t){if(!e){if("string"!=typeof t)throw Error("Invariant failed");throw Error(t)}}function aO(e,...t){let r="function"==typeof e?e(...t):e;return null!=r&&!r}function aU(e){return e.disabled||!0===e["aria-disabled"]||"true"===e["aria-disabled"]}function aH(e){let t={};for(let r in e)void 0!==e[r]&&(t[r]=e[r]);return t}function aN(...e){for(let t of e)if(void 0!==t)return t}function aJ(e,t){"function"==typeof e?e(t):e&&(e.current=t)}function aK(){return ag&&!!navigator.maxTouchPoints}function aV(){return!!ag&&/mac|iphone|ipad|ipod/i.test(navigator.platform)}function az(){return ag&&aV()&&/apple/i.test(navigator.vendor)}function aq(e){return!!(e.currentTarget&&!aF(e.currentTarget,e.target))}function aQ(e){return e.target===e.currentTarget}function aW(e,t){let r=new FocusEvent("blur",t),a=e.dispatchEvent(r),n={...t,bubbles:!0};return e.dispatchEvent(new FocusEvent("focusout",n)),a}function aX(e,t){let r=new MouseEvent("click",t);return e.dispatchEvent(r)}function aY(e,t){let r=t||e.currentTarget,a=e.relatedTarget;return!a||!aF(r,a)}function aZ(e,t,r,a){let n=(e=>{if(a){let t=setTimeout(e,a);return()=>clearTimeout(t)}let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)})(()=>{e.removeEventListener(t,i,!0),r()}),i=()=>{n(),r()};return e.addEventListener(t,i,{once:!0,capture:!0}),n}function a$(e,t,r,a=window){let n=[];try{for(let i of(a.document.addEventListener(e,t,r),Array.from(a.frames)))n.push(a$(e,t,r,i))}catch(e){}return()=>{try{a.document.removeEventListener(e,t,r)}catch(e){}for(let e of n)e()}}var a0={...o},a1=a0.useId;a0.useDeferredValue;var a2=a0.useInsertionEffect,a3=ag?o.useLayoutEffect:o.useEffect;function a9(e){let t=(0,o.useRef)(()=>{throw Error("Cannot call an event handler while rendering.")});return a2?a2(()=>{t.current=e}):t.current=e,(0,o.useCallback)((...e)=>{var r;return null==(r=t.current)?void 0:r.call(t,...e)},[])}function a5(...e){return(0,o.useMemo)(()=>{if(e.some(Boolean))return t=>{for(let r of e)aJ(r,t)}},e)}function a8(e){if(a1){let t=a1();return e||t}let[t,r]=(0,o.useState)(e);return a3(()=>{if(e||t)return;let a=Math.random().toString(36).slice(2,8);r(`id-${a}`)},[e,t]),e||t}function a4(e,t){let r=(0,o.useRef)(!1);(0,o.useEffect)(()=>{if(r.current)return e();r.current=!0},t),(0,o.useEffect)(()=>()=>{r.current=!1},[])}function a6(){return(0,o.useReducer)(()=>[],[])}function a7(e){return a9("function"==typeof e?e:()=>e)}function ne(e,t,r=[]){let a=(0,o.useCallback)(r=>(e.wrapElement&&(r=e.wrapElement(r)),t(r)),[...r,e.wrapElement]);return{...e,wrapElement:a}}function nt(e=!1,t){let[r,a]=(0,o.useState)(null);return{portalRef:a5(a,t),portalNode:r,domReady:!e||r}}var nr=!1,na=!1,nn=0,ni=0;function no(e){let t,r;t=e.movementX||e.screenX-nn,r=e.movementY||e.screenY-ni,nn=e.screenX,ni=e.screenY,(t||r||0)&&(na=!0)}function ns(){na=!1}function nl(e){let t=o.forwardRef((t,r)=>e({...t,ref:r}));return t.displayName=e.displayName||e.name,t}function nu(e,t){return o.memo(e,t)}function nc(e,t){let r,{wrapElement:a,render:i,...s}=t,l=a5(t.ref,i&&(0,o.isValidElement)(i)&&("ref"in i.props||"ref"in i)?({...i.props}).ref||i.ref:null);if(o.isValidElement(i)){let e={...i.props,ref:l};r=o.cloneElement(i,function(e,t){let r={...e};for(let a in t){if(!aG(t,a))continue;if("className"===a){let a="className";r[a]=e[a]?`${e[a]} ${t[a]}`:t[a];continue}if("style"===a){let a="style";r[a]=e[a]?{...e[a],...t[a]}:t[a];continue}let n=t[a];if("function"==typeof n&&a.startsWith("on")){let t=e[a];if("function"==typeof t){r[a]=(...e)=>{n(...e),t(...e)};continue}}r[a]=n}return r}(s,e))}else r=i?i(s):(0,n.jsx)(e,{...s});return a?a(r):r}function nd(e){let t=(t={})=>e(t);return t.displayName=e.name,t}function nf(e=[],t=[]){let r=o.createContext(void 0),a=o.createContext(void 0),i=()=>o.useContext(r),s=t=>e.reduceRight((e,r)=>(0,n.jsx)(r,{...t,children:e}),(0,n.jsx)(r.Provider,{...t}));return{context:r,scopedContext:a,useContext:i,useScopedContext:(e=!1)=>{let t=o.useContext(a),r=i();return e?t:t||r},useProviderContext:()=>{let e=o.useContext(a),t=i();if(!e||e!==t)return t},ContextProvider:s,ScopedContextProvider:e=>(0,n.jsx)(s,{...e,children:t.reduceRight((t,r)=>(0,n.jsx)(r,{...e,children:t}),(0,n.jsx)(a.Provider,{...e}))})}}var nh=nf(),nm=nh.useContext;nh.useScopedContext,nh.useProviderContext;var np=nf([nh.ContextProvider],[nh.ScopedContextProvider]),ng=np.useContext;np.useScopedContext;var nv=np.useProviderContext,ny=np.ContextProvider,nA=np.ScopedContextProvider,nF=(0,o.createContext)(void 0),nb=(0,o.createContext)(void 0),nC=(0,o.createContext)(!0),nB="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";function nS(e){return!(!e.matches(nB)||!aS(e)||e.closest("[inert]"))}function nx(e){if(!nS(e)||0>Number.parseInt(e.getAttribute("tabindex")||"0",10))return!1;if(!("form"in e)||!e.form||e.checked||"radio"!==e.type)return!0;let t=e.form.elements.namedItem(e.name);if(!t||!("length"in t))return!0;let r=aA(e);return!r||r===e||!("form"in r)||r.form!==e.form||r.name!==e.name}function nE(e,t){let r=Array.from(e.querySelectorAll(nB));t&&r.unshift(e);let a=r.filter(nS);return a.forEach((e,t)=>{if(ab(e)&&e.contentDocument){let r=e.contentDocument.body;a.splice(t,1,...nE(r))}}),a}function nM(e,t,r){let a=Array.from(e.querySelectorAll(nB)),n=a.filter(nx);return(t&&nx(e)&&n.unshift(e),n.forEach((e,t)=>{if(ab(e)&&e.contentDocument){let a=nM(e.contentDocument.body,!1,r);n.splice(t,1,...a)}}),!n.length&&r)?a:n}function nD(e,t){var r;let a,n,i,o;return r=document.body,a=aA(r),i=(n=nE(r,!1)).indexOf(a),(o=n.slice(i+1)).find(nx)||(e?n.find(nx):null)||(t?o[0]:null)||null}function nk(e,t){var r;let a,n,i,o;return r=document.body,a=aA(r),i=(n=nE(r,!1).reverse()).indexOf(a),(o=n.slice(i+1)).find(nx)||(e?n.find(nx):null)||(t?o[0]:null)||null}function nw(e){let t=aA(e);if(!t)return!1;if(t===e)return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&r===e.id}function nI(e){let t=aA(e);if(!t)return!1;if(aF(e,t))return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&"id"in e&&(r===e.id||!!e.querySelector(`#${CSS.escape(r)}`))}function nT(e){!nI(e)&&nS(e)&&e.focus()}var nR=az(),nP=["text","search","url","tel","email","password","number","date","month","week","time","datetime","datetime-local"],nG=Symbol("safariFocusAncestor");function nL(e){return"input"===e.tagName.toLowerCase()&&!!e.type&&("radio"===e.type||"checkbox"===e.type)}function nj(e,t){return a9(r=>{null==e||e(r),!r.defaultPrevented&&t&&(r.stopPropagation(),r.preventDefault())})}var n_=!1,nO=!0;function nU(e){let t=e.target;t&&"hasAttribute"in t&&!t.hasAttribute("data-focus-visible")&&(nO=!1)}function nH(e){e.metaKey||e.ctrlKey||e.altKey||(nO=!0)}var nN=nd(function({focusable:e=!0,accessibleWhenDisabled:t,autoFocus:r,onFocusVisible:a,...n}){var i,s,l,u,c;let d=(0,o.useRef)(null);(0,o.useEffect)(()=>{!e||n_||(a$("mousedown",nU,!0),a$("keydown",nH,!0),n_=!0)},[e]),nR&&(0,o.useEffect)(()=>{if(!e)return;let t=d.current;if(!t||!nL(t))return;let r="labels"in t?t.labels:null;if(!r)return;let a=()=>queueMicrotask(()=>t.focus());for(let e of r)e.addEventListener("mouseup",a);return()=>{for(let e of r)e.removeEventListener("mouseup",a)}},[e]);let f=e&&aU(n),h=!!f&&!t,[m,p]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&h&&m&&p(!1)},[e,h,m]),(0,o.useEffect)(()=>{if(!e||!m)return;let t=d.current;if(!t||"undefined"==typeof IntersectionObserver)return;let r=new IntersectionObserver(()=>{nS(t)||p(!1)});return r.observe(t),()=>r.disconnect()},[e,m]);let g=nj(n.onKeyPressCapture,f),v=nj(n.onMouseDownCapture,f),y=nj(n.onClickCapture,f),A=n.onMouseDown,F=a9(t=>{if(null==A||A(t),t.defaultPrevented||!e)return;let r=t.currentTarget;if(!nR||aq(t)||!aC(r)&&!nL(r))return;let a=!1,n=()=>{a=!0};r.addEventListener("focusin",n,{capture:!0,once:!0});let i=function(e){for(;e&&!nS(e);)e=e.closest(nB);return e||null}(r.parentElement);i&&(i[nG]=!0),aZ(r,"mouseup",()=>{r.removeEventListener("focusin",n,!0),i&&(i[nG]=!1),a||nT(r)})}),b=(t,r)=>{if(r&&(t.currentTarget=r),!e)return;let n=t.currentTarget;n&&nw(n)&&(null==a||a(t),t.defaultPrevented||(n.dataset.focusVisible="true",p(!0)))},C=n.onKeyDownCapture,B=a9(t=>{if(null==C||C(t),t.defaultPrevented||!e||m||t.metaKey||t.altKey||t.ctrlKey||!aQ(t))return;let r=t.currentTarget;aZ(r,"focusout",()=>b(t,r))}),S=n.onFocusCapture,x=a9(t=>{if(null==S||S(t),t.defaultPrevented||!e)return;if(!aQ(t))return void p(!1);let r=t.currentTarget;nO||function(e){let{tagName:t,readOnly:r,type:a}=e;return"TEXTAREA"===t&&!r||"SELECT"===t&&!r||("INPUT"!==t||r?!!e.isContentEditable||"combobox"===e.getAttribute("role")&&!!e.dataset.name:nP.includes(a))}(t.target)?aZ(t.target,"focusout",()=>b(t,r)):p(!1)}),E=n.onBlur,M=a9(t=>{null==E||E(t),!e||aY(t)&&(t.currentTarget.removeAttribute("data-focus-visible"),p(!1))}),D=(0,o.useContext)(nC),k=a9(t=>{e&&r&&t&&D&&queueMicrotask(()=>{nw(t)||nS(t)&&t.focus()})}),w=function(e,t){let r=e=>{if("string"==typeof e)return e},[a,n]=(0,o.useState)(()=>r(void 0));return a3(()=>{let t=e&&"current"in e?e.current:e;n((null==t?void 0:t.tagName.toLowerCase())||r(void 0))},[e,void 0]),a}(d),I=e&&(!w||"button"===w||"summary"===w||"input"===w||"select"===w||"textarea"===w||"a"===w),T=e&&(!w||"button"===w||"input"===w||"select"===w||"textarea"===w),R=n.style,P=(0,o.useMemo)(()=>h?{pointerEvents:"none",...R}:R,[h,R]);return n={"data-focus-visible":e&&m||void 0,"data-autofocus":r||void 0,"aria-disabled":f||void 0,...n,ref:a5(d,k,n.ref),style:P,tabIndex:(i=e,s=h,l=I,u=T,c=n.tabIndex,i?s?l&&!u?-1:void 0:l?c:c||0:c),disabled:!!T&&!!h||void 0,contentEditable:f?void 0:n.contentEditable,onKeyPressCapture:g,onClickCapture:y,onMouseDownCapture:v,onMouseDown:F,onKeyDownCapture:B,onFocusCapture:x,onBlur:M},aH(n)});function nJ(e){let t=[];for(let r of e)t.push(...r);return t}function nK(e){return e.slice().reverse()}function nV(e,t,r){return a9(a=>{var n;let i,o;if(null==t||t(a),a.defaultPrevented||a.isPropagationStopped()||!aQ(a)||"Shift"===a.key||"Control"===a.key||"Alt"===a.key||"Meta"===a.key||(!(i=a.target)||ax(i))&&1===a.key.length&&!a.ctrlKey&&!a.metaKey)return;let s=e.getState(),l=null==(n=aI(e,s.activeId))?void 0:n.element;if(!l)return;let{view:u,...c}=a;l!==(null==r?void 0:r.current)&&l.focus(),o=new KeyboardEvent(a.type,c),l.dispatchEvent(o)||a.preventDefault(),a.currentTarget.contains(l)&&a.stopPropagation()})}nl(function(e){return nc("div",nN(e))});var nz=nd(function({store:e,composite:t=!0,focusOnMove:r=t,moveOnKeyPress:a=!0,...i}){let s=nv();a_(e=e||s,!1);let l=(0,o.useRef)(null),u=(0,o.useRef)(null),c=function(e){let[t,r]=(0,o.useState)(!1),a=(0,o.useCallback)(()=>r(!0),[]),n=e.useState(t=>aI(e,t.activeId));return(0,o.useEffect)(()=>{let e=null==n?void 0:n.element;!t||e&&(r(!1),e.focus({preventScroll:!0}))},[n,t]),a}(e),d=e.useState("moves"),[,f]=function(e){let[t,r]=(0,o.useState)(null);return a3(()=>{if(null==t||!e)return;let r=null;return e(e=>(r=e,t)),()=>{e(r)}},[t,e]),[t,r]}(t?e.setBaseElement:null);(0,o.useEffect)(()=>{var a;if(!e||!d||!t||!r)return;let{activeId:n}=e.getState(),i=null==(a=aI(e,n))?void 0:a.element;i&&("scrollIntoView"in i?(i.focus({preventScroll:!0}),i.scrollIntoView({block:"nearest",inline:"nearest",...void 0})):i.focus())},[e,d,t,r]),a3(()=>{if(!e||!d||!t)return;let{baseElement:r,activeId:a}=e.getState();if(null!==a||!r)return;let n=u.current;u.current=null,n&&aW(n,{relatedTarget:r}),nw(r)||r.focus()},[e,d,t]);let h=e.useState("activeId"),m=e.useState("virtualFocus");a3(()=>{var r;if(!e||!t||!m)return;let a=u.current;if(u.current=null,!a)return;let n=(null==(r=aI(e,h))?void 0:r.element)||aA(a);n!==a&&aW(a,{relatedTarget:n})},[e,h,m,t]);let p=nV(e,i.onKeyDownCapture,u),g=nV(e,i.onKeyUpCapture,u),v=i.onFocusCapture,y=a9(t=>{var r;let a;if(null==v||v(t),t.defaultPrevented||!e)return;let{virtualFocus:n}=e.getState();if(!n)return;let i=t.relatedTarget,o=(a=(r=t.currentTarget)[aT],delete r[aT],a);aQ(t)&&o&&(t.stopPropagation(),u.current=i)}),A=i.onFocus,F=a9(r=>{if(null==A||A(r),r.defaultPrevented||!t||!e)return;let{relatedTarget:a}=r,{virtualFocus:n}=e.getState();n?aQ(r)&&!aR(e,a)&&queueMicrotask(c):aQ(r)&&e.setActiveId(null)}),b=i.onBlurCapture,C=a9(t=>{var r;if(null==b||b(t),t.defaultPrevented||!e)return;let{virtualFocus:a,activeId:n}=e.getState();if(!a)return;let i=null==(r=aI(e,n))?void 0:r.element,o=t.relatedTarget,s=aR(e,o),l=u.current;u.current=null,aQ(t)&&s?(o===i?l&&l!==o&&aW(l,t):i?aW(i,t):l&&aW(l,t),t.stopPropagation()):!aR(e,t.target)&&i&&aW(i,t)}),B=i.onKeyDown,S=a7(a),x=a9(t=>{var r;if(null==B||B(t),t.nativeEvent.isComposing||t.defaultPrevented||!e||!aQ(t))return;let{orientation:a,renderedItems:n,activeId:i}=e.getState(),o=aI(e,i);if(null==(r=null==o?void 0:o.element)?void 0:r.isConnected)return;let s="horizontal"!==a,l="vertical"!==a,u=n.some(e=>!!e.rowId);if(("ArrowLeft"===t.key||"ArrowRight"===t.key||"Home"===t.key||"End"===t.key)&&ax(t.currentTarget))return;let c={ArrowUp:(u||s)&&(()=>{if(u){let e=nJ(nK(function(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}(n))).find(e=>!e.disabled);return null==e?void 0:e.id}return null==e?void 0:e.last()}),ArrowRight:(u||l)&&e.first,ArrowDown:(u||s)&&e.first,ArrowLeft:(u||l)&&e.last,Home:e.first,End:e.last,PageUp:e.first,PageDown:e.last}[t.key];if(c){let r=c();if(void 0!==r){if(!S(t))return;t.preventDefault(),e.move(r)}}});return i=ne(i,t=>(0,n.jsx)(ny,{value:e,children:t}),[e]),i={"aria-activedescendant":e.useState(r=>{var a;if(e&&t&&r.virtualFocus)return null==(a=aI(e,r.activeId))?void 0:a.id}),...i,ref:a5(l,f,i.ref),onKeyDownCapture:p,onKeyUpCapture:g,onFocusCapture:y,onFocus:F,onBlurCapture:C,onKeyDown:x},i=nN({focusable:e.useState(e=>t&&(e.virtualFocus||null===e.activeId)),...i})});nl(function(e){return nc("div",nz(e))});var nq=nf();nq.useContext,nq.useScopedContext;var nQ=nq.useProviderContext,nW=nf([nq.ContextProvider],[nq.ScopedContextProvider]);nW.useContext,nW.useScopedContext;var nX=nW.useProviderContext,nY=nW.ContextProvider,nZ=nW.ScopedContextProvider,n$=(0,o.createContext)(void 0),n0=(0,o.createContext)(void 0),n1=nf([nY],[nZ]);n1.useContext,n1.useScopedContext;var n2=n1.useProviderContext,n3=n1.ContextProvider,n9=n1.ScopedContextProvider,n5=nd(function({store:e,...t}){let r=n2();return e=e||r,t={...t,ref:a5(null==e?void 0:e.setAnchorElement,t.ref)}});nl(function(e){return nc("div",n5(e))});var n8=(0,o.createContext)(void 0),n4=nf([n3,ny],[n9,nA]),n6=n4.useContext,n7=n4.useScopedContext,ie=n4.useProviderContext,it=n4.ContextProvider,ir=n4.ScopedContextProvider,ia=(0,o.createContext)(void 0),ii=(0,o.createContext)(!1);function io(e,t){let r=e.__unstableInternals;return a_(r,"Invalid store"),r[t]}function is(e,...t){let r=e,a=r,n=Symbol(),i=aP,o=new Set,s=new Set,l=new Set,u=new Set,c=new Set,d=new WeakMap,f=new WeakMap,h=(e,t,r=u)=>(r.add(t),f.set(t,e),()=>{var e;null==(e=d.get(t))||e(),d.delete(t),f.delete(t),r.delete(t)}),m=(e,i,o=!1)=>{var l,h;if(!aG(r,e))return;let m=(h=r[e],"function"==typeof i?i("function"==typeof h?h():h):i);if(m===r[e])return;if(!o)for(let r of t)null==(l=null==r?void 0:r.setState)||l.call(r,e,m);let p=r;r={...r,[e]:m};let g=Symbol();n=g,s.add(e);let v=(t,a,n)=>{var i;let o=f.get(t);(!o||o.some(t=>n?n.has(t):t===e))&&(null==(i=d.get(t))||i(),d.set(t,t(r,a)))};for(let e of u)v(e,p);queueMicrotask(()=>{if(n!==g)return;let e=r;for(let e of c)v(e,a,s);a=e,s.clear()})},p={getState:()=>r,setState:m,__unstableInternals:{setup:e=>(l.add(e),()=>l.delete(e)),init:()=>{let e=o.size,a=Symbol();o.add(a);let n=()=>{o.delete(a),o.size||i()};if(e)return n;let s=Object.keys(r).map(e=>aL(...t.map(t=>{var r;let a=null==(r=null==t?void 0:t.getState)?void 0:r.call(t);if(a&&aG(a,e))return id(t,[e],t=>{m(e,t[e],!0)})}))),u=[];for(let e of l)u.push(e());return i=aL(...s,...u,...t.map(iu)),n},subscribe:(e,t)=>h(e,t),sync:(e,t)=>(d.set(t,t(r,r)),h(e,t)),batch:(e,t)=>(d.set(t,t(r,a)),h(e,t,c)),pick:e=>is(function(e,t){let r={};for(let a of t)aG(e,a)&&(r[a]=e[a]);return r}(r,e),p),omit:e=>is(function(e,t){let r={...e};for(let e of t)aG(r,e)&&delete r[e];return r}(r,e),p)}};return p}function il(e,...t){if(e)return io(e,"setup")(...t)}function iu(e,...t){if(e)return io(e,"init")(...t)}function ic(e,...t){if(e)return io(e,"subscribe")(...t)}function id(e,...t){if(e)return io(e,"sync")(...t)}function ih(e,...t){if(e)return io(e,"batch")(...t)}function im(e,...t){if(e)return io(e,"omit")(...t)}function ip(...e){var t;let r={};for(let a of e){let e=null==(t=null==a?void 0:a.getState)?void 0:t.call(a);e&&Object.assign(r,e)}let a=is(r,...e);return Object.assign({},...e,a)}function ig(e,t){}function iv(e,t,r){if(!r)return!1;let a=e.find(e=>!e.disabled&&e.value);return(null==a?void 0:a.value)===t}function iy(e,t){return!!t&&null!=e&&(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),t.length>e.length&&0===t.toLowerCase().indexOf(e.toLowerCase()))}var iA=nd(function({store:e,focusable:t=!0,autoSelect:r=!1,getAutoSelectId:a,setValueOnChange:n,showMinLength:i=0,showOnChange:s,showOnMouseDown:l,showOnClick:u=l,showOnKeyDown:c,showOnKeyPress:d=c,blurActiveItemOnClick:f,setValueOnClick:h=!0,moveOnKeyPress:m=!0,autoComplete:p="list",...g}){var v;let y,A=ie();a_(e=e||A,!1);let F=(0,o.useRef)(null),[b,C]=a6(),B=(0,o.useRef)(!1),S=(0,o.useRef)(!1),x=e.useState(e=>e.virtualFocus&&r),E="inline"===p||"both"===p,[M,D]=(0,o.useState)(E);v=[E],y=(0,o.useRef)(!1),a3(()=>{if(y.current)return(()=>{E&&D(!0)})();y.current=!0},v),a3(()=>()=>{y.current=!1},[]);let k=e.useState("value"),w=(0,o.useRef)();(0,o.useEffect)(()=>id(e,["selectedValue","activeId"],(e,t)=>{w.current=t.selectedValue}),[]);let I=e.useState(e=>{var t;if(E&&M){if(e.activeValue&&Array.isArray(e.selectedValue)&&(e.selectedValue.includes(e.activeValue)||(null==(t=w.current)?void 0:t.includes(e.activeValue))))return;return e.activeValue}}),T=e.useState("renderedItems"),R=e.useState("open"),P=e.useState("contentElement"),G=(0,o.useMemo)(()=>{if(!E||!M)return k;if(iv(T,I,x)){if(iy(k,I)){let e=(null==I?void 0:I.slice(k.length))||"";return k+e}return k}return I||k},[E,M,T,I,x,k]);(0,o.useEffect)(()=>{let e=F.current;if(!e)return;let t=()=>D(!0);return e.addEventListener("combobox-item-move",t),()=>{e.removeEventListener("combobox-item-move",t)}},[]),(0,o.useEffect)(()=>{if(!E||!M||!I||!iv(T,I,x)||!iy(k,I))return;let e=aP;return queueMicrotask(()=>{let t=F.current;if(!t)return;let{start:r,end:a}=aM(t),n=k.length,i=I.length;aw(t,n,i),e=()=>{if(!nw(t))return;let{start:e,end:o}=aM(t);e!==n||o===i&&aw(t,r,a)}}),()=>e()},[b,E,M,I,T,x,k]);let L=(0,o.useRef)(null),j=a9(a),_=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!R||!P)return;let t=ak(P);if(!t)return;L.current=t;let r=()=>{B.current=!1},a=()=>{if(!e||!B.current)return;let{activeId:t}=e.getState();null===t||t!==_.current&&(B.current=!1)},n={passive:!0,capture:!0};return t.addEventListener("wheel",r,n),t.addEventListener("touchmove",r,n),t.addEventListener("scroll",a,n),()=>{t.removeEventListener("wheel",r,!0),t.removeEventListener("touchmove",r,!0),t.removeEventListener("scroll",a,!0)}},[R,P,e]),a3(()=>{!k||S.current||(B.current=!0)},[k]),a3(()=>{"always"!==x&&R||(B.current=R)},[x,R]);let O=e.useState("resetValueOnSelect");a4(()=>{var t,r;let a=B.current;if(!e||!R||!a&&!O)return;let{baseElement:n,contentElement:i,activeId:o}=e.getState();if(!n||nw(n)){if(null==i?void 0:i.hasAttribute("data-placing")){let e=new MutationObserver(C);return e.observe(i,{attributeFilter:["data-placing"]}),()=>e.disconnect()}if(x&&a){let r,a=j(T),n=void 0!==a?a:null!=(t=null==(r=T.find(e=>{var t;return!e.disabled&&(null==(t=e.element)?void 0:t.getAttribute("role"))!=="tab"}))?void 0:r.id)?t:e.first();_.current=n,e.move(null!=n?n:null)}else{let t=null==(r=e.item(o||e.first()))?void 0:r.element;t&&"scrollIntoView"in t&&t.scrollIntoView({block:"nearest",inline:"nearest"})}}},[e,R,b,k,x,O,j,T]),(0,o.useEffect)(()=>{if(!E)return;let t=F.current;if(!t)return;let r=[t,P].filter(e=>!!e),a=t=>{r.every(e=>aY(t,e))&&(null==e||e.setValue(G))};for(let e of r)e.addEventListener("focusout",a);return()=>{for(let e of r)e.removeEventListener("focusout",a)}},[E,P,e,G]);let U=e=>e.currentTarget.value.length>=i,H=g.onChange,N=a7(null!=s?s:U),J=a7(null!=n?n:!e.tag),K=a9(t=>{if(null==H||H(t),t.defaultPrevented||!e)return;let r=t.currentTarget,{value:a,selectionStart:n,selectionEnd:i}=r,o=t.nativeEvent;if(B.current=!0,"input"===o.type&&(o.isComposing&&(B.current=!1,S.current=!0),E)){let e="insertText"===o.inputType||"insertCompositionText"===o.inputType,t=n===a.length;D(e&&t)}if(J(t)){let t=a===e.getState().value;e.setValue(a),queueMicrotask(()=>{aw(r,n,i)}),E&&x&&t&&C()}N(t)&&e.show(),x&&B.current||e.setActiveId(null)}),V=g.onCompositionEnd,z=a9(e=>{B.current=!0,S.current=!1,null==V||V(e),e.defaultPrevented||x&&C()}),q=g.onMouseDown,Q=a7(null!=f?f:()=>!!(null==e?void 0:e.getState().includesBaseElement)),W=a7(h),X=a7(null!=u?u:U),Y=a9(t=>{null==q||q(t),t.defaultPrevented||t.button||t.ctrlKey||e&&(Q(t)&&e.setActiveId(null),W(t)&&e.setValue(G),X(t)&&aZ(t.currentTarget,"mouseup",e.show))}),Z=g.onKeyDown,$=a7(null!=d?d:U),ee=a9(t=>{if(null==Z||Z(t),t.repeat||(B.current=!1),t.defaultPrevented||t.ctrlKey||t.altKey||t.shiftKey||t.metaKey||!e)return;let{open:r}=e.getState();!r&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&$(t)&&(t.preventDefault(),e.show())}),et=g.onBlur,er=a9(e=>{if(B.current=!1,null==et||et(e),e.defaultPrevented)return}),ea=a8(g.id),en=e.useState(e=>null===e.activeId);return g={id:ea,role:"combobox","aria-autocomplete":"inline"===p||"list"===p||"both"===p||"none"===p?p:void 0,"aria-haspopup":aD(P,"listbox"),"aria-expanded":R,"aria-controls":null==P?void 0:P.id,"data-active-item":en||void 0,value:G,...g,ref:a5(F,g.ref),onChange:K,onCompositionEnd:z,onMouseDown:Y,onKeyDown:ee,onBlur:er},g=nz({store:e,focusable:t,...g,moveOnKeyPress:e=>!aO(m,e)&&(E&&D(!0),!0)}),{autoComplete:"off",...g=n5({store:e,...g})}}),iF=nl(function(e){return nc("input",iA(e))});function ib(e){let t=e.relatedTarget;return(null==t?void 0:t.nodeType)===Node.ELEMENT_NODE?t:null}var iC=Symbol("composite-hover"),iB=nd(function({store:e,focusOnHover:t=!0,blurOnHoverEnd:r=!!t,...a}){let n=ng();a_(e=e||n,!1);let i=((0,o.useEffect)(()=>{nr||(a$("mousemove",no,!0),a$("mousedown",ns,!0),a$("mouseup",ns,!0),a$("keydown",ns,!0),a$("scroll",ns,!0),nr=!0)},[]),a9(()=>na)),s=a.onMouseMove,l=a7(t),u=a9(t=>{if((null==s||s(t),!t.defaultPrevented&&i())&&l(t)){if(!nI(t.currentTarget)){let t=null==e?void 0:e.getState().baseElement;t&&!nw(t)&&t.focus()}null==e||e.setActiveId(t.currentTarget.id)}}),c=a.onMouseLeave,d=a7(r),f=a9(t=>{var r;let a;null==c||c(t),!t.defaultPrevented&&i()&&((a=ib(t))&&aF(t.currentTarget,a)||function(e){let t=ib(e);if(!t)return!1;do{if(aG(t,iC)&&t[iC])return!0;t=t.parentElement}while(t)return!1}(t)||!l(t)||d(t)&&(null==e||e.setActiveId(null),null==(r=null==e?void 0:e.getState().baseElement)||r.focus()))}),h=(0,o.useCallback)(e=>{e&&(e[iC]=!0)},[]);return aH(a={...a,ref:a5(h,a.ref),onMouseMove:u,onMouseLeave:f})});nu(nl(function(e){return nc("div",iB(e))}));var iS=nd(function({store:e,shouldRegisterItem:t=!0,getItem:r=aj,element:a,...n}){let i=nm();e=e||i;let s=a8(n.id),l=(0,o.useRef)(a);return(0,o.useEffect)(()=>{let a=l.current;if(!s||!a||!t)return;let n=r({id:s,element:a});return null==e?void 0:e.renderItem(n)},[s,t,r,e]),aH(n={...n,ref:a5(l,n.ref)})});function ix(e){if(!e.isTrusted)return!1;let t=e.currentTarget;return"Enter"===e.key?aC(t)||"SUMMARY"===t.tagName||"A"===t.tagName:" "===e.key&&(aC(t)||"SUMMARY"===t.tagName||"INPUT"===t.tagName||"SELECT"===t.tagName)}nl(function(e){return nc("div",iS(e))});var iE=Symbol("command"),iM=nd(function({clickOnEnter:e=!0,clickOnSpace:t=!0,...r}){let a,n,i=(0,o.useRef)(null),[s,l]=(0,o.useState)(!1);(0,o.useEffect)(()=>{i.current&&l(aC(i.current))},[]);let[u,c]=(0,o.useState)(!1),d=(0,o.useRef)(!1),f=aU(r),[h,m]=(a=r.onLoadedMetadataCapture,n=(0,o.useMemo)(()=>Object.assign(()=>{},{...a,[iE]:!0}),[a,iE,!0]),[null==a?void 0:a[iE],{onLoadedMetadataCapture:n}]),p=r.onKeyDown,g=a9(r=>{null==p||p(r);let a=r.currentTarget;if(r.defaultPrevented||h||f||!aQ(r)||ax(a)||a.isContentEditable)return;let n=e&&"Enter"===r.key,i=t&&" "===r.key,o="Enter"===r.key&&!e,s=" "===r.key&&!t;if(o||s)return void r.preventDefault();if(n||i){let e=ix(r);if(n){if(!e){r.preventDefault();let{view:e,...t}=r,n=()=>aX(a,t);ag&&/firefox\//i.test(navigator.userAgent)?aZ(a,"keyup",n):queueMicrotask(n)}}else i&&(d.current=!0,e||(r.preventDefault(),c(!0)))}}),v=r.onKeyUp,y=a9(e=>{if(null==v||v(e),e.defaultPrevented||h||f||e.metaKey)return;let r=t&&" "===e.key;if(d.current&&r&&(d.current=!1,!ix(e))){e.preventDefault(),c(!1);let t=e.currentTarget,{view:r,...a}=e;queueMicrotask(()=>aX(t,a))}});return nN(r={"data-active":u||void 0,type:s?"button":void 0,...m,...r,ref:a5(i,r.ref),onKeyDown:g,onKeyUp:y})});nl(function(e){return nc("button",iM(e))});var{useSyncExternalStore:iD}=e.i(2239).default,ik=()=>()=>{};function iw(e,t=aj){let r=o.useCallback(t=>e?ic(e,null,t):ik(),[e]),a=()=>{let r="string"==typeof t?t:null,a="function"==typeof t?t:null,n=null==e?void 0:e.getState();return a?a(n):n&&r&&aG(n,r)?n[r]:void 0};return iD(r,a,a)}function iI(e,t){let r=o.useRef({}),a=o.useCallback(t=>e?ic(e,null,t):ik(),[e]),n=()=>{let a=null==e?void 0:e.getState(),n=!1,i=r.current;for(let e in t){let r=t[e];if("function"==typeof r){let t=r(a);t!==i[e]&&(i[e]=t,n=!0)}if("string"==typeof r){if(!a||!aG(a,r))continue;let t=a[r];t!==i[e]&&(i[e]=t,n=!0)}}return n&&(r.current={...i}),r.current};return iD(a,n,n)}function iT(e,t,r,a){var n;let i,s=aG(t,r)?t[r]:void 0,l=(n={value:s,setValue:a?t[a]:void 0},i=(0,o.useRef)(n),a3(()=>{i.current=n}),i);a3(()=>id(e,[r],(e,t)=>{let{value:a,setValue:n}=l.current;n&&e[r]!==t[r]&&e[r]!==a&&n(e[r])}),[e,r]),a3(()=>{if(void 0!==s)return e.setState(r,s),ih(e,[r],()=>{void 0!==s&&e.setState(r,s)})})}function iR(e,t){let[r,a]=o.useState(()=>e(t));a3(()=>iu(r),[r]);let n=o.useCallback(e=>iw(r,e),[r]);return[o.useMemo(()=>({...r,useState:n}),[r,n]),a9(()=>{a(r=>e({...t,...r.getState()}))})]}function iP(e,t,r,a=!1){var n;let i,o;if(!t||!r)return;let{renderedItems:s}=t.getState(),l=ak(e);if(!l)return;let u=function(e,t=!1){let r=e.clientHeight,{top:a}=e.getBoundingClientRect(),n=1.5*Math.max(.875*r,r-40),i=t?r-n+a:n+a;return"HTML"===e.tagName?i+e.scrollTop:i}(l,a);for(let e=0;e<s.length;e+=1){let s=i;if(!(i=r(e)))break;if(i===s)continue;let l=null==(n=aI(t,i))?void 0:n.element;if(!l)continue;let c=function(e,t=!1){let{top:r}=e.getBoundingClientRect();return t?r+e.clientHeight:r}(l,a)-u,d=Math.abs(c);if(a&&c<=0||!a&&c>=0){void 0!==o&&o<d&&(i=s);break}o=d}return i}var iG=nd(function({store:e,rowId:t,preventScrollOnKeyDown:r=!1,moveOnKeyPress:a=!0,tabbable:i=!1,getItem:s,"aria-setsize":l,"aria-posinset":u,...c}){let d=ng();e=e||d;let f=a8(c.id),h=(0,o.useRef)(null),m=(0,o.useContext)(nb),p=aU(c)&&!c.accessibleWhenDisabled,{rowId:g,baseElement:v,isActiveItem:y,ariaSetSize:A,ariaPosInSet:F,isTabbable:b}=iI(e,{rowId:e=>t||(e&&(null==m?void 0:m.baseElement)&&m.baseElement===e.baseElement?m.id:void 0),baseElement:e=>(null==e?void 0:e.baseElement)||void 0,isActiveItem:e=>!!e&&e.activeId===f,ariaSetSize:e=>null!=l?l:e&&(null==m?void 0:m.ariaSetSize)&&m.baseElement===e.baseElement?m.ariaSetSize:void 0,ariaPosInSet(e){if(null!=u)return u;if(!e||!(null==m?void 0:m.ariaPosInSet)||m.baseElement!==e.baseElement)return;let t=e.renderedItems.filter(e=>e.rowId===g);return m.ariaPosInSet+t.findIndex(e=>e.id===f)},isTabbable(t){if(!(null==t?void 0:t.renderedItems.length))return!0;if(t.virtualFocus)return!1;if(i)return!0;if(null===t.activeId)return!1;let r=null==e?void 0:e.item(t.activeId);return null!=r&&!!r.disabled||null==r||!r.element||t.activeId===f}}),C=(0,o.useCallback)(e=>{var t;let r={...e,id:f||e.id,rowId:g,disabled:!!p,children:null==(t=e.element)?void 0:t.textContent};return s?s(r):r},[f,g,p,s]),B=c.onFocus,S=(0,o.useRef)(!1),x=a9(t=>{var r,a;if(null==B||B(t),t.defaultPrevented||aq(t)||!f||!e||(r=e,!aQ(t)&&aR(r,t.target)))return;let{virtualFocus:n,baseElement:i}=e.getState();e.setActiveId(f),aE(t.currentTarget)&&function(e,t=!1){if(ax(e))e.setSelectionRange(t?e.value.length:0,e.value.length);else if(e.isContentEditable){let r=av(e).getSelection();null==r||r.selectAllChildren(e),t&&(null==r||r.collapseToEnd())}}(t.currentTarget),!n||!aQ(t)||!aE(a=t.currentTarget)&&("INPUT"!==a.tagName||aC(a))&&(null==i?void 0:i.isConnected)&&((az()&&t.currentTarget.hasAttribute("data-autofocus")&&t.currentTarget.scrollIntoView({block:"nearest",inline:"nearest"}),S.current=!0,t.relatedTarget===i||aR(e,t.relatedTarget))?(i[aT]=!0,i.focus({preventScroll:!0})):i.focus())}),E=c.onBlurCapture,M=a9(t=>{if(null==E||E(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState();(null==r?void 0:r.virtualFocus)&&S.current&&(S.current=!1,t.preventDefault(),t.stopPropagation())}),D=c.onKeyDown,k=a7(r),w=a7(a),I=a9(t=>{if(null==D||D(t),t.defaultPrevented||!aQ(t)||!e)return;let{currentTarget:r}=t,a=e.getState(),n=e.item(f),i=!!(null==n?void 0:n.rowId),o="horizontal"!==a.orientation,s="vertical"!==a.orientation,l=()=>!(!i&&!s&&a.baseElement&&ax(a.baseElement)),u={ArrowUp:(i||o)&&e.up,ArrowRight:(i||s)&&e.next,ArrowDown:(i||o)&&e.down,ArrowLeft:(i||s)&&e.previous,Home:()=>{if(l())return!i||t.ctrlKey?null==e?void 0:e.first():null==e?void 0:e.previous(-1)},End:()=>{if(l())return!i||t.ctrlKey?null==e?void 0:e.last():null==e?void 0:e.next(-1)},PageUp:()=>iP(r,e,null==e?void 0:e.up,!0),PageDown:()=>iP(r,e,null==e?void 0:e.down)}[t.key];if(u){if(aE(r)){let e=aM(r),a=s&&"ArrowLeft"===t.key,n=s&&"ArrowRight"===t.key,i=o&&"ArrowUp"===t.key,l=o&&"ArrowDown"===t.key;if(n||l){let{length:t}=function(e){if(ax(e))return e.value;if(e.isContentEditable){let t=av(e).createRange();return t.selectNodeContents(e),t.toString()}return""}(r);if(e.end!==t)return}else if((a||i)&&0!==e.start)return}let a=u();if(k(t)||void 0!==a){if(!w(t))return;t.preventDefault(),e.move(a)}}}),T=(0,o.useMemo)(()=>({id:f,baseElement:v}),[f,v]);return c={id:f,"data-active-item":y||void 0,...c=ne(c,e=>(0,n.jsx)(nF.Provider,{value:T,children:e}),[T]),ref:a5(h,c.ref),tabIndex:b?c.tabIndex:-1,onFocus:x,onBlurCapture:M,onKeyDown:I},c=iM(c),aH({...c=iS({store:e,...c,getItem:C,shouldRegisterItem:!!f&&c.shouldRegisterItem}),"aria-setsize":A,"aria-posinset":F})});nu(nl(function(e){return nc("button",iG(e))}));var iL=nd(function({store:e,value:t,hideOnClick:r,setValueOnClick:a,selectValueOnClick:i=!0,resetValueOnSelect:s,focusOnHover:l=!1,moveOnKeyPress:u=!0,getItem:c,...d}){var f,h;let m=n7();a_(e=e||m,!1);let{resetValueOnSelectState:p,multiSelectable:g,selected:v}=iI(e,{resetValueOnSelectState:"resetValueOnSelect",multiSelectable:e=>Array.isArray(e.selectedValue),selected:e=>(function(e,t){if(null!=t)return null!=e&&(Array.isArray(e)?e.includes(t):e===t)})(e.selectedValue,t)}),y=(0,o.useCallback)(e=>{let r={...e,value:t};return c?c(r):r},[t,c]);a=null!=a?a:!g,r=null!=r?r:null!=t&&!g;let A=d.onClick,F=a7(a),b=a7(i),C=a7(null!=(f=null!=s?s:p)?f:g),B=a7(r),S=a9(r=>{null==A||A(r),r.defaultPrevented||function(e){let t=e.currentTarget;if(!t)return!1;let r=t.tagName.toLowerCase();return!!e.altKey&&("a"===r||"button"===r&&"submit"===t.type||"input"===r&&"submit"===t.type)}(r)||!function(e){let t=e.currentTarget;if(!t)return!1;let r=aV();if(r&&!e.metaKey||!r&&!e.ctrlKey)return!1;let a=t.tagName.toLowerCase();return"a"===a||"button"===a&&"submit"===t.type||"input"===a&&"submit"===t.type}(r)&&(null!=t&&(b(r)&&(C(r)&&(null==e||e.resetValue()),null==e||e.setSelectedValue(e=>Array.isArray(e)?e.includes(t)?e.filter(e=>e!==t):[...e,t]:t)),F(r)&&(null==e||e.setValue(t))),B(r)&&(null==e||e.hide()))}),x=d.onKeyDown,E=a9(t=>{if(null==x||x(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState().baseElement;!r||nw(r)||(1===t.key.length||"Backspace"===t.key||"Delete"===t.key)&&(queueMicrotask(()=>r.focus()),ax(r)&&(null==e||e.setValue(r.value)))});g&&null!=v&&(d={"aria-selected":v,...d}),d=ne(d,e=>(0,n.jsx)(ia.Provider,{value:t,children:(0,n.jsx)(ii.Provider,{value:null!=v&&v,children:e})}),[t,v]),d={role:null!=(h=({menu:"menuitem",listbox:"option",tree:"treeitem"})[(0,o.useContext)(n8)])?h:"option",children:t,...d,onClick:S,onKeyDown:E};let M=a7(u);return d=iG({store:e,...d,getItem:y,moveOnKeyPress:t=>{if(!M(t))return!1;let r=new Event("combobox-item-move"),a=null==e?void 0:e.getState().baseElement;return null==a||a.dispatchEvent(r),!0}}),d=iB({store:e,focusOnHover:l,...d})}),ij=nu(nl(function(e){return nc("div",iL(e))})),i_=e.i(74080);function iO(e,t){let r=setTimeout(t,e);return()=>clearTimeout(r)}function iU(...e){return e.join(", ").split(", ").reduce((e,t)=>{let r=t.endsWith("ms")?1:1e3,a=Number.parseFloat(t||"0s")*r;return a>e?a:e},0)}function iH(e,t,r){return!r&&!1!==t&&(!e||!!t)}var iN=nd(function({store:e,alwaysVisible:t,...r}){let a=nQ();a_(e=e||a,!1);let i=(0,o.useRef)(null),s=a8(r.id),[l,u]=(0,o.useState)(null),c=e.useState("open"),d=e.useState("mounted"),f=e.useState("animated"),h=e.useState("contentElement"),m=iw(e.disclosure,"contentElement");a3(()=>{i.current&&(null==e||e.setContentElement(i.current))},[e]),a3(()=>{let t;return null==e||e.setState("animated",e=>(t=e,!0)),()=>{void 0!==t&&(null==e||e.setState("animated",t))}},[e]),a3(()=>{if(f){var e;let t;return(null==h?void 0:h.isConnected)?(e=()=>{u(c?"enter":d?"leave":null)},t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)}),()=>cancelAnimationFrame(t)):void u(null)}},[f,h,c,d]),a3(()=>{if(!e||!f||!l||!h)return;let t=()=>null==e?void 0:e.setState("animating",!1),r=()=>(0,i_.flushSync)(t);if("leave"===l&&c||"enter"===l&&!c)return;if("number"==typeof f)return iO(f,r);let{transitionDuration:a,animationDuration:n,transitionDelay:i,animationDelay:o}=getComputedStyle(h),{transitionDuration:s="0",animationDuration:u="0",transitionDelay:d="0",animationDelay:p="0"}=m?getComputedStyle(m):{},g=iU(i,o,d,p)+iU(a,n,s,u);if(!g){"enter"===l&&e.setState("animated",!1),t();return}return iO(Math.max(g-1e3/60,0),r)},[e,f,h,m,c,l]);let p=iH(d,(r=ne(r,t=>(0,n.jsx)(nZ,{value:e,children:t}),[e])).hidden,t),g=r.style,v=(0,o.useMemo)(()=>p?{...g,display:"none"}:g,[p,g]);return aH(r={id:s,"data-open":c||void 0,"data-enter":"enter"===l||void 0,"data-leave":"leave"===l||void 0,hidden:p,...r,ref:a5(s?e.setContentElement:null,i,r.ref),style:v})}),iJ=nl(function(e){return nc("div",iN(e))});nl(function({unmountOnHide:e,...t}){let r=nQ();return!1===iw(t.store||r,t=>!e||(null==t?void 0:t.mounted))?null:(0,n.jsx)(iJ,{...t})});var iK=nd(function({store:e,alwaysVisible:t,...r}){let a=n7(!0),i=n6(),s=!!(e=e||i)&&e===a;a_(e,!1);let l=(0,o.useRef)(null),u=a8(r.id),c=e.useState("mounted"),d=iH(c,r.hidden,t),f=d?{...r.style,display:"none"}:r.style,h=e.useState(e=>Array.isArray(e.selectedValue)),m=function(e,t,r){let a=function(e){let[t]=(0,o.useState)(e);return t}(r),[n,i]=(0,o.useState)(a);return(0,o.useEffect)(()=>{let r=e&&"current"in e?e.current:e;if(!r)return;let n=()=>{let e=r.getAttribute(t);i(null==e?a:e)},o=new MutationObserver(n);return o.observe(r,{attributeFilter:[t]}),n(),()=>o.disconnect()},[e,t,a]),n}(l,"role",r.role),p="listbox"===m||"tree"===m||"grid"===m,[g,v]=(0,o.useState)(!1),y=e.useState("contentElement");a3(()=>{if(!c)return;let e=l.current;if(!e||y!==e)return;let t=()=>{v(!!e.querySelector("[role='listbox']"))},r=new MutationObserver(t);return r.observe(e,{subtree:!0,childList:!0,attributeFilter:["role"]}),t(),()=>r.disconnect()},[c,y]),g||(r={role:"listbox","aria-multiselectable":p&&h||void 0,...r}),r=ne(r,t=>(0,n.jsx)(ir,{value:e,children:(0,n.jsx)(n8.Provider,{value:m,children:t})}),[e,m]);let A=!u||a&&s?null:e.setContentElement;return aH(r={id:u,hidden:d,...r,ref:a5(A,l,r.ref),style:f})}),iV=nl(function(e){return nc("div",iK(e))}),iz=(0,o.createContext)(null),iq=nd(function(e){return{...e,style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px",...e.style}}});nl(function(e){return nc("span",iq(e))});var iQ=nd(function(e){return iq(e={"data-focus-trap":"",tabIndex:0,"aria-hidden":!0,...e,style:{position:"fixed",top:0,left:0,...e.style}})}),iW=nl(function(e){return nc("span",iQ(e))});function iX(e){queueMicrotask(()=>{null==e||e.focus()})}var iY=nd(function({preserveTabOrder:e,preserveTabOrderAnchor:t,portalElement:r,portalRef:a,portal:i=!0,...s}){let l=(0,o.useRef)(null),u=a5(l,s.ref),c=(0,o.useContext)(iz),[d,f]=(0,o.useState)(null),[h,m]=(0,o.useState)(null),p=(0,o.useRef)(null),g=(0,o.useRef)(null),v=(0,o.useRef)(null),y=(0,o.useRef)(null);return a3(()=>{let e=l.current;if(!e||!i)return void f(null);let t=r?"function"==typeof r?r(e):r:av(e).createElement("div");if(!t)return void f(null);let n=t.isConnected;if(n||(c||av(e).body).appendChild(t),t.id||(t.id=e.id?`portal/${e.id}`:function(e="id"){return`${e?`${e}-`:""}${Math.random().toString(36).slice(2,8)}`}()),f(t),aJ(a,t),!n)return()=>{t.remove(),aJ(a,null)}},[i,r,c,a]),a3(()=>{if(!i||!e||!t)return;let r=av(t).createElement("span");return r.style.position="fixed",t.insertAdjacentElement("afterend",r),m(r),()=>{r.remove(),m(null)}},[i,e,t]),(0,o.useEffect)(()=>{if(!d||!e)return;let t=0,r=e=>{if(!aY(e))return;let r="focusin"===e.type;if(cancelAnimationFrame(t),r){let e=d.querySelectorAll("[data-tabindex]"),t=e=>{let t=e.getAttribute("data-tabindex");e.removeAttribute("data-tabindex"),t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")};for(let r of(d.hasAttribute("data-tabindex")&&t(d),e))t(r);return}t=requestAnimationFrame(()=>{for(let e of nM(d,!0))!function(e){var t;let r=null!=(t=e.getAttribute("tabindex"))?t:"";e.setAttribute("data-tabindex",r),e.setAttribute("tabindex","-1")}(e)})};return d.addEventListener("focusin",r,!0),d.addEventListener("focusout",r,!0),()=>{cancelAnimationFrame(t),d.removeEventListener("focusin",r,!0),d.removeEventListener("focusout",r,!0)}},[d,e]),s={...s=ne(s,t=>{if(t=(0,n.jsx)(iz.Provider,{value:d||c,children:t}),!i)return t;if(!d)return(0,n.jsx)("span",{ref:u,id:s.id,style:{position:"fixed"},hidden:!0});t=(0,n.jsxs)(n.Fragment,{children:[e&&d&&(0,n.jsx)(iW,{ref:g,"data-focus-trap":s.id,className:"__focus-trap-inner-before",onFocus:e=>{aY(e,d)?iX(nD()):iX(p.current)}}),t,e&&d&&(0,n.jsx)(iW,{ref:v,"data-focus-trap":s.id,className:"__focus-trap-inner-after",onFocus:e=>{aY(e,d)?iX(nk()):iX(y.current)}})]}),d&&(t=(0,i_.createPortal)(t,d));let r=(0,n.jsxs)(n.Fragment,{children:[e&&d&&(0,n.jsx)(iW,{ref:p,"data-focus-trap":s.id,className:"__focus-trap-outer-before",onFocus:e=>{e.relatedTarget!==y.current&&aY(e,d)?iX(g.current):iX(nk())}}),e&&(0,n.jsx)("span",{"aria-owns":null==d?void 0:d.id,style:{position:"fixed"}}),e&&d&&(0,n.jsx)(iW,{ref:y,"data-focus-trap":s.id,className:"__focus-trap-outer-after",onFocus:e=>{if(aY(e,d))iX(v.current);else{let e=nD();if(e===g.current)return void requestAnimationFrame(()=>{var e;return null==(e=nD())?void 0:e.focus()});iX(e)}}})]});return h&&e&&(r=(0,i_.createPortal)(r,h)),(0,n.jsxs)(n.Fragment,{children:[r,t]})},[d,c,i,s.id,e,h]),ref:u}});nl(function(e){return nc("div",iY(e))});var iZ=(0,o.createContext)(0);function i$({level:e,children:t}){let r=(0,o.useContext)(iZ),a=Math.max(Math.min(e||r+1,6),1);return(0,n.jsx)(iZ.Provider,{value:a,children:t})}var i0=nd(function({autoFocusOnShow:e=!0,...t}){return ne(t,t=>(0,n.jsx)(nC.Provider,{value:e,children:t}),[e])});nl(function(e){return nc("div",i0(e))});var i1=new WeakMap;function i2(e,t,r){i1.has(e)||i1.set(e,new Map);let a=i1.get(e),n=a.get(t);if(!n)return a.set(t,r()),()=>{var e;null==(e=a.get(t))||e(),a.delete(t)};let i=r(),o=()=>{i(),n(),a.delete(t)};return a.set(t,o),()=>{a.get(t)===o&&(i(),a.set(t,n))}}function i3(e,t,r){return i2(e,t,()=>{let a=e.getAttribute(t);return e.setAttribute(t,r),()=>{null==a?e.removeAttribute(t):e.setAttribute(t,a)}})}function i9(e,t,r){return i2(e,t,()=>{let a=t in e,n=e[t];return e[t]=r,()=>{a?e[t]=n:delete e[t]}})}function i5(e,t){return e?i2(e,"style",()=>{let r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}):()=>{}}var i8=["SCRIPT","STYLE"];function i4(e){return`__ariakit-dialog-snapshot-${e}`}function i6(e,t,r,a){for(let n of t){if(!(null==n?void 0:n.isConnected))continue;let i=t.some(e=>!!e&&e!==n&&e.contains(n)),o=av(n),s=n;for(;n.parentElement&&n!==o.body;){if(null==a||a(n.parentElement,s),!i)for(let a of n.parentElement.children)(function(e,t,r){return!i8.includes(t.tagName)&&!!function(e,t){let r=av(t),a=i4(e);if(!r.body[a])return!0;for(;;){if(t===r.body)return!1;if(t[a])return!0;if(!t.parentElement)return!1;t=t.parentElement}}(e,t)&&!r.some(e=>e&&aF(t,e))})(e,a,t)&&r(a,s);n=n.parentElement}}}function i7(e,...t){if(!e)return!1;let r=e.getAttribute("data-backdrop");return null!=r&&(""===r||"true"===r||!t.length||t.some(e=>r===e))}function oe(e="",t=!1){return`__ariakit-dialog-${t?"ancestor":"outside"}${e?`-${e}`:""}`}function ot(e,t=""){return aL(i9(e,oe("",!0),!0),i9(e,oe(t,!0),!0))}function or(e,t){if(e[oe(t,!0)])return!0;let r=oe(t);for(;;){if(e[r])return!0;if(!e.parentElement)return!1;e=e.parentElement}}function oa(e,t){let r=[],a=t.map(e=>null==e?void 0:e.id);return i6(e,t,t=>{i7(t,...a)||r.unshift(function(e,t=""){return aL(i9(e,oe(),!0),i9(e,oe(t),!0))}(t,e))},(t,a)=>{a.hasAttribute("data-dialog")&&a.id!==e||r.unshift(ot(t,e))}),()=>{for(let e of r)e()}}function on({store:e,type:t,listener:r,capture:a,domReady:n}){let i=a9(r),s=iw(e,"open"),l=(0,o.useRef)(!1);a3(()=>{if(!s||!n)return;let{contentElement:t}=e.getState();if(!t)return;let r=()=>{l.current=!0};return t.addEventListener("focusin",r,!0),()=>t.removeEventListener("focusin",r,!0)},[e,s,n]),(0,o.useEffect)(()=>{if(s)return a$(t,t=>{let{contentElement:r,disclosureElement:a}=e.getState(),n=t.target;!r||!n||!(!("HTML"===n.tagName||aF(av(n).body,n))||aF(r,n)||function(e,t){if(!e)return!1;if(aF(e,t))return!0;let r=t.getAttribute("aria-activedescendant");if(r){let t=av(e).getElementById(r);if(t)return aF(e,t)}return!1}(a,n)||n.hasAttribute("data-focus-trap")||function(e,t){if(!("clientY"in e))return!1;let r=t.getBoundingClientRect();return 0!==r.width&&0!==r.height&&r.top<=e.clientY&&e.clientY<=r.top+r.height&&r.left<=e.clientX&&e.clientX<=r.left+r.width}(t,r))&&(!l.current||or(n,r.id))&&(n&&n[nG]||i(t))},a)},[s,a])}function oi(e,t){return"function"==typeof e?e(t):!!e}var oo=(0,o.createContext)({});function os(){return"inert"in HTMLElement.prototype}function ol(e,t){if(!("style"in e))return aP;if(os())return i9(e,"inert",!0);let r=nM(e,!0).map(e=>{if(null==t?void 0:t.some(t=>t&&aF(t,e)))return aP;let r=i2(e,"focus",()=>(e.focus=aP,()=>{delete e.focus}));return aL(i3(e,"tabindex","-1"),r)});return aL(...r,i3(e,"aria-hidden","true"),i5(e,{pointerEvents:"none",userSelect:"none",cursor:"default"}))}function ou(e={}){let t=ip(e.store,im(e.disclosure,["contentElement","disclosureElement"]));ig(e,t);let r=null==t?void 0:t.getState(),a=aN(e.open,null==r?void 0:r.open,e.defaultOpen,!1),n=aN(e.animated,null==r?void 0:r.animated,!1),i=is({open:a,animated:n,animating:!!n&&a,mounted:a,contentElement:aN(null==r?void 0:r.contentElement,null),disclosureElement:aN(null==r?void 0:r.disclosureElement,null)},t);return il(i,()=>id(i,["animated","animating"],e=>{e.animated||i.setState("animating",!1)})),il(i,()=>ic(i,["open"],()=>{i.getState().animated&&i.setState("animating",!0)})),il(i,()=>id(i,["open","animating"],e=>{i.setState("mounted",e.open||e.animating)})),{...i,disclosure:e.disclosure,setOpen:e=>i.setState("open",e),show:()=>i.setState("open",!0),hide:()=>i.setState("open",!1),toggle:()=>i.setState("open",e=>!e),stopAnimation:()=>i.setState("animating",!1),setContentElement:e=>i.setState("contentElement",e),setDisclosureElement:e=>i.setState("disclosureElement",e)}}function oc(e,t,r){return a4(t,[r.store,r.disclosure]),iT(e,r,"open","setOpen"),iT(e,r,"mounted","setMounted"),iT(e,r,"animated"),Object.assign(e,{disclosure:r.disclosure})}nd(function(e){return e});var od=nl(function(e){return nc("div",e)});function of({store:e,backdrop:t,alwaysVisible:r,hidden:a}){let i=(0,o.useRef)(null),s=function(e={}){let[t,r]=iR(ou,e);return oc(t,r,e)}({disclosure:e}),l=iw(e,"contentElement");(0,o.useEffect)(()=>{let e=i.current;!e||l&&(e.style.zIndex=getComputedStyle(l).zIndex)},[l]),a3(()=>{let e=null==l?void 0:l.id;if(!e)return;let t=i.current;if(t)return ot(t,e)},[l]);let u=iN({ref:i,store:s,role:"presentation","data-backdrop":(null==l?void 0:l.id)||"",alwaysVisible:r,hidden:null!=a?a:void 0,style:{position:"fixed",top:0,right:0,bottom:0,left:0}});if(!t)return null;if((0,o.isValidElement)(t))return(0,n.jsx)(od,{...u,render:t});let c="boolean"!=typeof t?t:"div";return(0,n.jsx)(od,{...u,render:(0,n.jsx)(c,{})})}function oh(e={}){return ou(e)}Object.assign(od,["a","button","details","dialog","div","form","h1","h2","h3","h4","h5","h6","header","img","input","label","li","nav","ol","p","section","select","span","summary","textarea","ul","svg"].reduce((e,t)=>(e[t]=nl(function(e){return nc(t,e)}),e),{}));var om=az();function op(e,t=!1){if(!e)return null;let r="current"in e?e.current:e;return r?t?nS(r)?r:null:r:null}var og=nd(function({store:e,open:t,onClose:r,focusable:a=!0,modal:i=!0,portal:s=!!i,backdrop:l=!!i,hideOnEscape:u=!0,hideOnInteractOutside:c=!0,getPersistentElements:d,preventBodyScroll:f=!!i,autoFocusOnShow:h=!0,autoFocusOnHide:m=!0,initialFocus:p,finalFocus:g,unmountOnHide:v,unstable_treeSnapshotKey:y,...A}){var F;let b,C,B,S=nX(),x=(0,o.useRef)(null),E=function(e={}){let[t,r]=iR(oh,e);return oc(t,r,e)}({store:e||S,open:t,setOpen(e){if(e)return;let t=x.current;if(!t)return;let a=new Event("close",{bubbles:!1,cancelable:!0});r&&t.addEventListener("close",r,{once:!0}),t.dispatchEvent(a),a.defaultPrevented&&E.setOpen(!0)}}),{portalRef:M,domReady:D}=nt(s,A.portalRef),k=A.preserveTabOrder,w=iw(E,e=>k&&!i&&e.mounted),I=a8(A.id),T=iw(E,"open"),R=iw(E,"mounted"),P=iw(E,"contentElement"),G=iH(R,A.hidden,A.alwaysVisible);b=function({attribute:e,contentId:t,contentElement:r,enabled:a}){let[n,i]=a6(),s=(0,o.useCallback)(()=>{if(!a||!r)return!1;let{body:n}=av(r),i=n.getAttribute(e);return!i||i===t},[n,a,r,e,t]);return(0,o.useEffect)(()=>{if(!a||!t||!r)return;let{body:n}=av(r);if(s())return n.setAttribute(e,t),()=>n.removeAttribute(e);let o=new MutationObserver(()=>(0,i_.flushSync)(i));return o.observe(n,{attributeFilter:[e]}),()=>o.disconnect()},[n,a,t,r,s,e]),s}({attribute:"data-dialog-prevent-body-scroll",contentElement:P,contentId:I,enabled:f&&!G}),(0,o.useEffect)(()=>{var e,t;if(!b()||!P)return;let r=av(P),a=ay(P),{documentElement:n,body:i}=r,o=n.style.getPropertyValue("--scrollbar-width"),s=o?Number.parseInt(o,10):a.innerWidth-n.clientWidth,l=Math.round(n.getBoundingClientRect().left)+n.scrollLeft?"paddingLeft":"paddingRight",u=aV()&&!(ag&&navigator.platform.startsWith("Mac")&&!aK());return aL((e="--scrollbar-width",t=`${s}px`,n?i2(n,e,()=>{let r=n.style.getPropertyValue(e);return n.style.setProperty(e,t),()=>{r?n.style.setProperty(e,r):n.style.removeProperty(e)}}):()=>{}),u?(()=>{var e,t;let{scrollX:r,scrollY:n,visualViewport:o}=a,u=null!=(e=null==o?void 0:o.offsetLeft)?e:0,c=null!=(t=null==o?void 0:o.offsetTop)?t:0,d=i5(i,{position:"fixed",overflow:"hidden",top:`${-(n-Math.floor(c))}px`,left:`${-(r-Math.floor(u))}px`,right:"0",[l]:`${s}px`});return()=>{d(),a.scrollTo({left:r,top:n,behavior:"instant"})}})():i5(i,{overflow:"hidden",[l]:`${s}px`}))},[b,P]),F=iw(E,"open"),C=(0,o.useRef)(),(0,o.useEffect)(()=>{if(!F){C.current=null;return}return a$("mousedown",e=>{C.current=e.target},!0)},[F]),on({...B={store:E,domReady:D,capture:!0},type:"click",listener:e=>{let{contentElement:t}=E.getState(),r=C.current;r&&aS(r)&&or(r,null==t?void 0:t.id)&&oi(c,e)&&E.hide()}}),on({...B,type:"focusin",listener:e=>{let{contentElement:t}=E.getState();!t||e.target===av(t)||oi(c,e)&&E.hide()}}),on({...B,type:"contextmenu",listener:e=>{oi(c,e)&&E.hide()}});let{wrapElement:L,nestedDialogs:j}=function(e){let t=(0,o.useContext)(oo),[r,a]=(0,o.useState)([]),i=(0,o.useCallback)(e=>{var r;return a(t=>[...t,e]),aL(null==(r=t.add)?void 0:r.call(t,e),()=>{a(t=>t.filter(t=>t!==e))})},[t]);a3(()=>id(e,["open","contentElement"],r=>{var a;if(r.open&&r.contentElement)return null==(a=t.add)?void 0:a.call(t,e)}),[e,t]);let s=(0,o.useMemo)(()=>({store:e,add:i}),[e,i]);return{wrapElement:(0,o.useCallback)(e=>(0,n.jsx)(oo.Provider,{value:s,children:e}),[s]),nestedDialogs:r}}(E);A=ne(A,L,[L]),a3(()=>{if(!T)return;let e=x.current,t=aA(e,!0);!t||"BODY"===t.tagName||e&&aF(e,t)||E.setDisclosureElement(t)},[E,T]),om&&(0,o.useEffect)(()=>{if(!R)return;let{disclosureElement:e}=E.getState();if(!e||!aC(e))return;let t=()=>{let t=!1,r=()=>{t=!0};e.addEventListener("focusin",r,{capture:!0,once:!0}),aZ(e,"mouseup",()=>{e.removeEventListener("focusin",r,!0),t||nT(e)})};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},[E,R]),(0,o.useEffect)(()=>{if(!R||!D)return;let e=x.current;if(!e)return;let t=ay(e),r=t.visualViewport||t,a=()=>{var r,a;let n=null!=(a=null==(r=t.visualViewport)?void 0:r.height)?a:t.innerHeight;e.style.setProperty("--dialog-viewport-height",`${n}px`)};return a(),r.addEventListener("resize",a),()=>{r.removeEventListener("resize",a)}},[R,D]),(0,o.useEffect)(()=>{if(!i||!R||!D)return;let e=x.current;if(e&&!e.querySelector("[data-dialog-dismiss]")){var t;let r;return t=E.hide,(r=av(e).createElement("button")).type="button",r.tabIndex=-1,r.textContent="Dismiss popup",Object.assign(r.style,{border:"0px",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0px",position:"absolute",whiteSpace:"nowrap",width:"1px"}),r.addEventListener("click",t),e.prepend(r),()=>{r.removeEventListener("click",t),r.remove()}}},[E,i,R,D]),a3(()=>{if(!os()||T||!R||!D)return;let e=x.current;if(e)return ol(e)},[T,R,D]);let _=T&&D;a3(()=>{if(I&&_)return function(e,t){let{body:r}=av(t[0]),a=[];return i6(e,t,t=>{a.push(i9(t,i4(e),!0))}),aL(i9(r,i4(e),!0),()=>{for(let e of a)e()})}(I,[x.current])},[I,_,y]);let O=a9(d);a3(()=>{if(!I||!_)return;let{disclosureElement:e}=E.getState(),t=[x.current,...O()||[],...j.map(e=>e.getState().contentElement)];if(i){let e,r;return aL(oa(I,t),(e=[],r=t.map(e=>null==e?void 0:e.id),i6(I,t,a=>{i7(a,...r)||!function(e,...t){if(!e)return!1;let r=e.getAttribute("data-focus-trap");return null!=r&&(!t.length||""!==r&&t.some(e=>r===e))}(a,...r)&&e.unshift(ol(a,t))},r=>{!r.hasAttribute("role")||t.some(e=>e&&aF(e,r))||e.unshift(i3(r,"role","none"))}),()=>{for(let t of e)t()}))}return oa(I,[e,...t])},[I,E,_,O,j,i,y]);let U=!!h,H=a7(h),[N,J]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(!T||!U||!D||!(null==P?void 0:P.isConnected))return;let e=op(p,!0)||P.querySelector("[data-autofocus=true],[autofocus]")||function(e,t,r){let[a]=nM(e,t,r);return a||null}(P,!0,s&&w)||P,t=nS(e);H(t?e:null)&&(J(!0),queueMicrotask(()=>{e.focus(),!om||t&&e.scrollIntoView({block:"nearest",inline:"nearest"})}))},[T,U,D,P,p,s,w,H]);let K=!!m,V=a7(m),[z,q]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(T)return q(!0),()=>q(!1)},[T]);let Q=(0,o.useCallback)((e,t=!0)=>{let r,{disclosureElement:a}=E.getState();if(!(!(r=aA())||e&&aF(e,r))&&nS(r))return;let n=op(g)||a;if(null==n?void 0:n.id){let e=av(n),t=`[aria-activedescendant="${n.id}"]`,r=e.querySelector(t);r&&(n=r)}if(n&&!nS(n)){let e=n.closest("[data-dialog]");if(null==e?void 0:e.id){let t=av(e),r=`[aria-controls~="${e.id}"]`,a=t.querySelector(r);a&&(n=a)}}let i=n&&nS(n);!i&&t?requestAnimationFrame(()=>Q(e,!1)):!V(i?n:null)||i&&(null==n||n.focus({preventScroll:!0}))},[E,g,V]),W=(0,o.useRef)(!1);a3(()=>{if(T||!z||!K)return;let e=x.current;W.current=!0,Q(e)},[T,z,D,K,Q]),(0,o.useEffect)(()=>{if(!z||!K)return;let e=x.current;return()=>{if(W.current){W.current=!1;return}Q(e)}},[z,K,Q]);let X=a7(u);(0,o.useEffect)(()=>{if(D&&R)return a$("keydown",e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=x.current;if(!t||or(t))return;let r=e.target;if(!r)return;let{disclosureElement:a}=E.getState();!("BODY"===r.tagName||aF(t,r)||!a||aF(a,r))||X(e)&&E.hide()},!0)},[E,D,R,X]);let Y=(A=ne(A,e=>(0,n.jsx)(i$,{level:i?1:void 0,children:e}),[i])).hidden,Z=A.alwaysVisible;A=ne(A,e=>l?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(of,{store:E,backdrop:l,hidden:Y,alwaysVisible:Z}),e]}):e,[E,l,Y,Z]);let[$,ee]=(0,o.useState)(),[et,er]=(0,o.useState)();return A=i0({...A={id:I,"data-dialog":"",role:"dialog",tabIndex:a?-1:void 0,"aria-labelledby":$,"aria-describedby":et,...A=ne(A,e=>(0,n.jsx)(nZ,{value:E,children:(0,n.jsx)(n$.Provider,{value:ee,children:(0,n.jsx)(n0.Provider,{value:er,children:e})})}),[E]),ref:a5(x,A.ref)},autoFocusOnShow:N}),A=iY({portal:s,...A=nN({...A=iN({store:E,...A}),focusable:a}),portalRef:M,preserveTabOrder:w})});function ov(e,t=nX){return nl(function(r){let a=t();return iw(r.store||a,e=>!r.unmountOnHide||(null==e?void 0:e.mounted)||!!r.open)?(0,n.jsx)(e,{...r}):null})}ov(nl(function(e){return nc("div",og(e))}),nX);let oy=Math.min,oA=Math.max,oF=Math.round,ob=Math.floor,oC=e=>({x:e,y:e}),oB={left:"right",right:"left",bottom:"top",top:"bottom"},oS={start:"end",end:"start"};function ox(e,t){return"function"==typeof e?e(t):e}function oE(e){return e.split("-")[0]}function oM(e){return e.split("-")[1]}function oD(e){return"x"===e?"y":"x"}function ok(e){return"y"===e?"height":"width"}let ow=new Set(["top","bottom"]);function oI(e){return ow.has(oE(e))?"y":"x"}function oT(e){return e.replace(/start|end/g,e=>oS[e])}let oR=["left","right"],oP=["right","left"],oG=["top","bottom"],oL=["bottom","top"];function oj(e){return e.replace(/left|right|bottom|top/g,e=>oB[e])}function o_(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function oO(e){let{x:t,y:r,width:a,height:n}=e;return{width:a,height:n,top:r,left:t,right:t+a,bottom:r+n,x:t,y:r}}function oU(e,t,r){let a,{reference:n,floating:i}=e,o=oI(t),s=oD(oI(t)),l=ok(s),u=oE(t),c="y"===o,d=n.x+n.width/2-i.width/2,f=n.y+n.height/2-i.height/2,h=n[l]/2-i[l]/2;switch(u){case"top":a={x:d,y:n.y-i.height};break;case"bottom":a={x:d,y:n.y+n.height};break;case"right":a={x:n.x+n.width,y:f};break;case"left":a={x:n.x-i.width,y:f};break;default:a={x:n.x,y:n.y}}switch(oM(t)){case"start":a[s]-=h*(r&&c?-1:1);break;case"end":a[s]+=h*(r&&c?-1:1)}return a}let oH=async(e,t,r)=>{let{placement:a="bottom",strategy:n="absolute",middleware:i=[],platform:o}=r,s=i.filter(Boolean),l=await (null==o.isRTL?void 0:o.isRTL(t)),u=await o.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=oU(u,a,l),f=a,h={},m=0;for(let r=0;r<s.length;r++){let{name:i,fn:p}=s[r],{x:g,y:v,data:y,reset:A}=await p({x:c,y:d,initialPlacement:a,placement:f,strategy:n,middlewareData:h,rects:u,platform:o,elements:{reference:e,floating:t}});c=null!=g?g:c,d=null!=v?v:d,h={...h,[i]:{...h[i],...y}},A&&m<=50&&(m++,"object"==typeof A&&(A.placement&&(f=A.placement),A.rects&&(u=!0===A.rects?await o.getElementRects({reference:e,floating:t,strategy:n}):A.rects),{x:c,y:d}=oU(u,f,l)),r=-1)}return{x:c,y:d,placement:f,strategy:n,middlewareData:h}};async function oN(e,t){var r;void 0===t&&(t={});let{x:a,y:n,platform:i,rects:o,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=ox(t,e),m=o_(h),p=s[f?"floating"===d?"reference":"floating":d],g=oO(await i.getClippingRect({element:null==(r=await (null==i.isElement?void 0:i.isElement(p)))||r?p:p.contextElement||await (null==i.getDocumentElement?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),v="floating"===d?{x:a,y:n,width:o.floating.width,height:o.floating.height}:o.reference,y=await (null==i.getOffsetParent?void 0:i.getOffsetParent(s.floating)),A=await (null==i.isElement?void 0:i.isElement(y))&&await (null==i.getScale?void 0:i.getScale(y))||{x:1,y:1},F=oO(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:v,offsetParent:y,strategy:l}):v);return{top:(g.top-F.top+m.top)/A.y,bottom:(F.bottom-g.bottom+m.bottom)/A.y,left:(g.left-F.left+m.left)/A.x,right:(F.right-g.right+m.right)/A.x}}let oJ=new Set(["left","top"]);async function oK(e,t){let{placement:r,platform:a,elements:n}=e,i=await (null==a.isRTL?void 0:a.isRTL(n.floating)),o=oE(r),s=oM(r),l="y"===oI(r),u=oJ.has(o)?-1:1,c=i&&l?-1:1,d=ox(t,e),{mainAxis:f,crossAxis:h,alignmentAxis:m}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&"number"==typeof m&&(h="end"===s?-1*m:m),l?{x:h*c,y:f*u}:{x:f*u,y:h*c}}function oV(){return"undefined"!=typeof window}function oz(e){return oW(e)?(e.nodeName||"").toLowerCase():"#document"}function oq(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function oQ(e){var t;return null==(t=(oW(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function oW(e){return!!oV()&&(e instanceof Node||e instanceof oq(e).Node)}function oX(e){return!!oV()&&(e instanceof Element||e instanceof oq(e).Element)}function oY(e){return!!oV()&&(e instanceof HTMLElement||e instanceof oq(e).HTMLElement)}function oZ(e){return!!oV()&&"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof oq(e).ShadowRoot)}let o$=new Set(["inline","contents"]);function o0(e){let{overflow:t,overflowX:r,overflowY:a,display:n}=st(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+r)&&!o$.has(n)}let o1=new Set(["table","td","th"]),o2=[":popover-open",":modal"];function o3(e){return o2.some(t=>{try{return e.matches(t)}catch(e){return!1}})}let o9=["transform","translate","scale","rotate","perspective"],o5=["transform","translate","scale","rotate","perspective","filter"],o8=["paint","layout","strict","content"];function o4(e){let t=o6(),r=oX(e)?st(e):e;return o9.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||o5.some(e=>(r.willChange||"").includes(e))||o8.some(e=>(r.contain||"").includes(e))}function o6(){return"undefined"!=typeof CSS&&!!CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")}let o7=new Set(["html","body","#document"]);function se(e){return o7.has(oz(e))}function st(e){return oq(e).getComputedStyle(e)}function sr(e){return oX(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sa(e){if("html"===oz(e))return e;let t=e.assignedSlot||e.parentNode||oZ(e)&&e.host||oQ(e);return oZ(t)?t.host:t}function sn(e,t,r){var a;void 0===t&&(t=[]),void 0===r&&(r=!0);let n=function e(t){let r=sa(t);return se(r)?t.ownerDocument?t.ownerDocument.body:t.body:oY(r)&&o0(r)?r:e(r)}(e),i=n===(null==(a=e.ownerDocument)?void 0:a.body),o=oq(n);if(i){let e=si(o);return t.concat(o,o.visualViewport||[],o0(n)?n:[],e&&r?sn(e):[])}return t.concat(n,sn(n,[],r))}function si(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function so(e){let t=st(e),r=parseFloat(t.width)||0,a=parseFloat(t.height)||0,n=oY(e),i=n?e.offsetWidth:r,o=n?e.offsetHeight:a,s=oF(r)!==i||oF(a)!==o;return s&&(r=i,a=o),{width:r,height:a,$:s}}function ss(e){return oX(e)?e:e.contextElement}function sl(e){let t=ss(e);if(!oY(t))return oC(1);let r=t.getBoundingClientRect(),{width:a,height:n,$:i}=so(t),o=(i?oF(r.width):r.width)/a,s=(i?oF(r.height):r.height)/n;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}let su=oC(0);function sc(e){let t=oq(e);return o6()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:su}function sd(e,t,r,a){var n;void 0===t&&(t=!1),void 0===r&&(r=!1);let i=e.getBoundingClientRect(),o=ss(e),s=oC(1);t&&(a?oX(a)&&(s=sl(a)):s=sl(e));let l=(void 0===(n=r)&&(n=!1),a&&(!n||a===oq(o))&&n)?sc(o):oC(0),u=(i.left+l.x)/s.x,c=(i.top+l.y)/s.y,d=i.width/s.x,f=i.height/s.y;if(o){let e=oq(o),t=a&&oX(a)?oq(a):a,r=e,n=si(r);for(;n&&a&&t!==r;){let e=sl(n),t=n.getBoundingClientRect(),a=st(n),i=t.left+(n.clientLeft+parseFloat(a.paddingLeft))*e.x,o=t.top+(n.clientTop+parseFloat(a.paddingTop))*e.y;u*=e.x,c*=e.y,d*=e.x,f*=e.y,u+=i,c+=o,n=si(r=oq(n))}}return oO({width:d,height:f,x:u,y:c})}function sf(e,t){let r=sr(e).scrollLeft;return t?t.left+r:sd(oQ(e)).left+r}function sh(e,t){let r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-sf(e,r),y:r.top+t.scrollTop}}let sm=new Set(["absolute","fixed"]);function sp(e,t,r){var a;let n;if("viewport"===t)n=function(e,t){let r=oq(e),a=oQ(e),n=r.visualViewport,i=a.clientWidth,o=a.clientHeight,s=0,l=0;if(n){i=n.width,o=n.height;let e=o6();(!e||e&&"fixed"===t)&&(s=n.offsetLeft,l=n.offsetTop)}let u=sf(a);if(u<=0){let e=a.ownerDocument,t=e.body,r=getComputedStyle(t),n="CSS1Compat"===e.compatMode&&parseFloat(r.marginLeft)+parseFloat(r.marginRight)||0,o=Math.abs(a.clientWidth-t.clientWidth-n);o<=25&&(i-=o)}else u<=25&&(i+=u);return{width:i,height:o,x:s,y:l}}(e,r);else if("document"===t){let t,r,i,o,s,l,u;a=oQ(e),t=oQ(a),r=sr(a),i=a.ownerDocument.body,o=oA(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),s=oA(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),l=-r.scrollLeft+sf(a),u=-r.scrollTop,"rtl"===st(i).direction&&(l+=oA(t.clientWidth,i.clientWidth)-o),n={width:o,height:s,x:l,y:u}}else if(oX(t)){let e,a,i,o,s,l;a=(e=sd(t,!0,"fixed"===r)).top+t.clientTop,i=e.left+t.clientLeft,o=oY(t)?sl(t):oC(1),s=t.clientWidth*o.x,l=t.clientHeight*o.y,n={width:s,height:l,x:i*o.x,y:a*o.y}}else{let r=sc(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return oO(n)}function sg(e){return"static"===st(e).position}function sv(e,t){if(!oY(e)||"fixed"===st(e).position)return null;if(t)return t(e);let r=e.offsetParent;return oQ(e)===r&&(r=r.ownerDocument.body),r}function sy(e,t){var r;let a=oq(e);if(o3(e))return a;if(!oY(e)){let t=sa(e);for(;t&&!se(t);){if(oX(t)&&!sg(t))return t;t=sa(t)}return a}let n=sv(e,t);for(;n&&(r=n,o1.has(oz(r)))&&sg(n);)n=sv(n,t);return n&&se(n)&&sg(n)&&!o4(n)?a:n||function(e){let t=sa(e);for(;oY(t)&&!se(t);){if(o4(t))return t;if(o3(t))break;t=sa(t)}return null}(e)||a}let sA=async function(e){let t=this.getOffsetParent||sy,r=this.getDimensions,a=await r(e.floating);return{reference:function(e,t,r){let a=oY(t),n=oQ(t),i="fixed"===r,o=sd(e,!0,i,t),s={scrollLeft:0,scrollTop:0},l=oC(0);if(a||!a&&!i)if(("body"!==oz(t)||o0(n))&&(s=sr(t)),a){let e=sd(t,!0,i,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else n&&(l.x=sf(n));i&&!a&&n&&(l.x=sf(n));let u=!n||a||i?oC(0):sh(n,s);return{x:o.left+s.scrollLeft-l.x-u.x,y:o.top+s.scrollTop-l.y-u.y,width:o.width,height:o.height}}(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}},sF={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:r,offsetParent:a,strategy:n}=e,i="fixed"===n,o=oQ(a),s=!!t&&o3(t.floating);if(a===o||s&&i)return r;let l={scrollLeft:0,scrollTop:0},u=oC(1),c=oC(0),d=oY(a);if((d||!d&&!i)&&(("body"!==oz(a)||o0(o))&&(l=sr(a)),oY(a))){let e=sd(a);u=sl(a),c.x=e.x+a.clientLeft,c.y=e.y+a.clientTop}let f=!o||d||i?oC(0):sh(o,l);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:r.y*u.y-l.scrollTop*u.y+c.y+f.y}},getDocumentElement:oQ,getClippingRect:function(e){let{element:t,boundary:r,rootBoundary:a,strategy:n}=e,i=[..."clippingAncestors"===r?o3(t)?[]:function(e,t){let r=t.get(e);if(r)return r;let a=sn(e,[],!1).filter(e=>oX(e)&&"body"!==oz(e)),n=null,i="fixed"===st(e).position,o=i?sa(e):e;for(;oX(o)&&!se(o);){let t=st(o),r=o4(o);r||"fixed"!==t.position||(n=null),(i?!r&&!n:!r&&"static"===t.position&&!!n&&sm.has(n.position)||o0(o)&&!r&&function e(t,r){let a=sa(t);return!(a===r||!oX(a)||se(a))&&("fixed"===st(a).position||e(a,r))}(e,o))?a=a.filter(e=>e!==o):n=t,o=sa(o)}return t.set(e,a),a}(t,this._c):[].concat(r),a],o=i[0],s=i.reduce((e,r)=>{let a=sp(t,r,n);return e.top=oA(a.top,e.top),e.right=oy(a.right,e.right),e.bottom=oy(a.bottom,e.bottom),e.left=oA(a.left,e.left),e},sp(t,o,n));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:sy,getElementRects:sA,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:t,height:r}=so(e);return{width:t,height:r}},getScale:sl,isElement:oX,isRTL:function(e){return"rtl"===st(e).direction}};function sb(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function sC(e=0,t=0,r=0,a=0){if("function"==typeof DOMRect)return new DOMRect(e,t,r,a);let n={x:e,y:t,width:r,height:a,top:t,right:e+r,bottom:t+a,left:e};return{...n,toJSON:()=>n}}function sB(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}function sS(e){let t=window.devicePixelRatio||1;return Math.round(e*t)/t}var sx=nd(function({store:e,modal:t=!1,portal:r=!!t,preserveTabOrder:a=!0,autoFocusOnShow:i=!0,wrapperProps:s,fixed:l=!1,flip:u=!0,shift:c=0,slide:d=!0,overlap:f=!1,sameWidth:h=!1,fitViewport:m=!1,gutter:p,arrowPadding:g=4,overflowPadding:v=8,getAnchorRect:y,updatePosition:A,...F}){let b=n2();a_(e=e||b,!1);let C=e.useState("arrowElement"),B=e.useState("anchorElement"),S=e.useState("disclosureElement"),x=e.useState("popoverElement"),E=e.useState("contentElement"),M=e.useState("placement"),D=e.useState("mounted"),k=e.useState("rendered"),w=(0,o.useRef)(null),[I,T]=(0,o.useState)(!1),{portalRef:R,domReady:P}=nt(r,F.portalRef),G=a9(y),L=a9(A),j=!!A;a3(()=>{if(!(null==x?void 0:x.isConnected))return;x.style.setProperty("--popover-overflow-padding",`${v}px`);let t={contextElement:B||void 0,getBoundingClientRect:()=>{let e=null==G?void 0:G(B);return e||!B?function(e){if(!e)return sC();let{x:t,y:r,width:a,height:n}=e;return sC(t,r,a,n)}(e):B.getBoundingClientRect()}},r=async()=>{var r,a,n,i,o;let s,y,A;if(!D)return;C||(w.current=w.current||document.createElement("div"));let F=C||w.current,b=[(r={gutter:p,shift:c},void 0===(a=({placement:e})=>{var t;let a=((null==F?void 0:F.clientHeight)||0)/2,n="number"==typeof r.gutter?r.gutter+a:null!=(t=r.gutter)?t:a;return{crossAxis:e.split("-")[1]?void 0:r.shift,mainAxis:n,alignmentAxis:r.shift}})&&(a=0),{name:"offset",options:a,async fn(e){var t,r;let{x:n,y:i,placement:o,middlewareData:s}=e,l=await oK(e,a);return o===(null==(t=s.offset)?void 0:t.placement)&&null!=(r=s.arrow)&&r.alignmentOffset?{}:{x:n+l.x,y:i+l.y,data:{...l,placement:o}}}}),function(e){var t;if(!1===e.flip)return;let r="string"==typeof e.flip?e.flip.split(" "):void 0;return a_(!r||r.every(sB),!1),{name:"flip",options:t={padding:e.overflowPadding,fallbackPlacements:r},async fn(e){var r,a,n,i,o,s,l,u;let c,d,f,{placement:h,middlewareData:m,rects:p,initialPlacement:g,platform:v,elements:y}=e,{mainAxis:A=!0,crossAxis:F=!0,fallbackPlacements:b,fallbackStrategy:C="bestFit",fallbackAxisSideDirection:B="none",flipAlignment:S=!0,...x}=ox(t,e);if(null!=(r=m.arrow)&&r.alignmentOffset)return{};let E=oE(h),M=oI(g),D=oE(g)===g,k=await (null==v.isRTL?void 0:v.isRTL(y.floating)),w=b||(D||!S?[oj(g)]:(c=oj(g),[oT(g),c,oT(c)])),I="none"!==B;!b&&I&&w.push(...(d=oM(g),f=function(e,t,r){switch(e){case"top":case"bottom":if(r)return t?oP:oR;return t?oR:oP;case"left":case"right":return t?oG:oL;default:return[]}}(oE(g),"start"===B,k),d&&(f=f.map(e=>e+"-"+d),S&&(f=f.concat(f.map(oT)))),f));let T=[g,...w],R=await oN(e,x),P=[],G=(null==(a=m.flip)?void 0:a.overflows)||[];if(A&&P.push(R[E]),F){let e,t,r,a,n=(s=h,l=p,void 0===(u=k)&&(u=!1),e=oM(s),r=ok(t=oD(oI(s))),a="x"===t?e===(u?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[r]>l.floating[r]&&(a=oj(a)),[a,oj(a)]);P.push(R[n[0]],R[n[1]])}if(G=[...G,{placement:h,overflows:P}],!P.every(e=>e<=0)){let e=((null==(n=m.flip)?void 0:n.index)||0)+1,t=T[e];if(t&&("alignment"!==F||M===oI(t)||G.every(e=>oI(e.placement)!==M||e.overflows[0]>0)))return{data:{index:e,overflows:G},reset:{placement:t}};let r=null==(i=G.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:i.placement;if(!r)switch(C){case"bestFit":{let e=null==(o=G.filter(e=>{if(I){let t=oI(e.placement);return t===M||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:o[0];e&&(r=e);break}case"initialPlacement":r=g}if(h!==r)return{reset:{placement:r}}}return{}}}}({flip:u,overflowPadding:v}),function(e){if(e.slide||e.overlap){var t,r;return{name:"shift",options:r={mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:(void 0===t&&(t={}),{options:t,fn(e){let{x:r,y:a,placement:n,rects:i,middlewareData:o}=e,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=ox(t,e),c={x:r,y:a},d=oI(n),f=oD(d),h=c[f],m=c[d],p=ox(s,e),g="number"==typeof p?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(l){let e="y"===f?"height":"width",t=i.reference[f]-i.floating[e]+g.mainAxis,r=i.reference[f]+i.reference[e]-g.mainAxis;h<t?h=t:h>r&&(h=r)}if(u){var v,y;let e="y"===f?"width":"height",t=oJ.has(oE(n)),r=i.reference[d]-i.floating[e]+(t&&(null==(v=o.offset)?void 0:v[d])||0)+(t?0:g.crossAxis),a=i.reference[d]+i.reference[e]+(t?0:(null==(y=o.offset)?void 0:y[d])||0)-(t?g.crossAxis:0);m<r?m=r:m>a&&(m=a)}return{[f]:h,[d]:m}}})},async fn(e){let{x:t,y:a,placement:n}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:s={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...l}=ox(r,e),u={x:t,y:a},c=await oN(e,l),d=oI(oE(n)),f=oD(d),h=u[f],m=u[d];if(i){let e="y"===f?"top":"left",t="y"===f?"bottom":"right",r=h+c[e],a=h-c[t];h=oA(r,oy(h,a))}if(o){let e="y"===d?"top":"left",t="y"===d?"bottom":"right",r=m+c[e],a=m-c[t];m=oA(r,oy(m,a))}let p=s.fn({...e,[f]:h,[d]:m});return{...p,data:{x:p.x-t,y:p.y-a,enabled:{[f]:i,[d]:o}}}}}}}({slide:d,shift:c,overlap:f,overflowPadding:v}),function(e,t){if(e){let r;return{name:"arrow",options:r={element:e,padding:t.arrowPadding},async fn(e){let{x:t,y:a,placement:n,rects:i,platform:o,elements:s,middlewareData:l}=e,{element:u,padding:c=0}=ox(r,e)||{};if(null==u)return{};let d=o_(c),f={x:t,y:a},h=oD(oI(n)),m=ok(h),p=await o.getDimensions(u),g="y"===h,v=g?"clientHeight":"clientWidth",y=i.reference[m]+i.reference[h]-f[h]-i.floating[m],A=f[h]-i.reference[h],F=await (null==o.getOffsetParent?void 0:o.getOffsetParent(u)),b=F?F[v]:0;b&&await (null==o.isElement?void 0:o.isElement(F))||(b=s.floating[v]||i.floating[m]);let C=b/2-p[m]/2-1,B=oy(d[g?"top":"left"],C),S=oy(d[g?"bottom":"right"],C),x=b-p[m]-S,E=b/2-p[m]/2+(y/2-A/2),M=oA(B,oy(E,x)),D=!l.arrow&&null!=oM(n)&&E!==M&&i.reference[m]/2-(E<B?B:S)-p[m]/2<0,k=D?E<B?E-B:E-x:0;return{[h]:f[h]+k,data:{[h]:M,centerOffset:E-M-k,...D&&{alignmentOffset:k}},reset:D}}}}}(F,{arrowPadding:g}),{name:"size",options:i={padding:(n={sameWidth:h,fitViewport:m,overflowPadding:v}).overflowPadding,apply({elements:e,availableWidth:t,availableHeight:r,rects:a}){let i=e.floating,o=Math.round(a.reference.width);t=Math.floor(t),r=Math.floor(r),i.style.setProperty("--popover-anchor-width",`${o}px`),i.style.setProperty("--popover-available-width",`${t}px`),i.style.setProperty("--popover-available-height",`${r}px`),n.sameWidth&&(i.style.width=`${o}px`),n.fitViewport&&(i.style.maxWidth=`${t}px`,i.style.maxHeight=`${r}px`)}},async fn(e){var t,r;let a,n,{placement:o,rects:s,platform:l,elements:u}=e,{apply:c=()=>{},...d}=ox(i,e),f=await oN(e,d),h=oE(o),m=oM(o),p="y"===oI(o),{width:g,height:v}=s.floating;"top"===h||"bottom"===h?(a=h,n=m===(await (null==l.isRTL?void 0:l.isRTL(u.floating))?"start":"end")?"left":"right"):(n=h,a="end"===m?"top":"bottom");let y=v-f.top-f.bottom,A=g-f.left-f.right,F=oy(v-f[a],y),b=oy(g-f[n],A),C=!e.middlewareData.shift,B=F,S=b;if(null!=(t=e.middlewareData.shift)&&t.enabled.x&&(S=A),null!=(r=e.middlewareData.shift)&&r.enabled.y&&(B=y),C&&!m){let e=oA(f.left,0),t=oA(f.right,0),r=oA(f.top,0),a=oA(f.bottom,0);p?S=g-2*(0!==e||0!==t?e+t:oA(f.left,f.right)):B=v-2*(0!==r||0!==a?r+a:oA(f.top,f.bottom))}await c({...e,availableWidth:S,availableHeight:B});let x=await l.getDimensions(u.floating);return g!==x.width||v!==x.height?{reset:{rects:!0}}:{}}}],B=await (o={placement:M,strategy:l?"fixed":"absolute",middleware:b},s=new Map,A={...(y={platform:sF,...o}).platform,_c:s},oH(t,x,{...y,platform:A}));null==e||e.setState("currentPlacement",B.placement),T(!0);let S=sS(B.x),E=sS(B.y);if(Object.assign(x.style,{top:"0",left:"0",transform:`translate3d(${S}px,${E}px,0)`}),F&&B.middlewareData.arrow){let{x:e,y:t}=B.middlewareData.arrow,r=B.placement.split("-")[0],a=F.clientWidth/2,n=F.clientHeight/2,i=null!=e?e+a:-a,o=null!=t?t+n:-n;x.style.setProperty("--popover-transform-origin",{top:`${i}px calc(100% + ${n}px)`,bottom:`${i}px ${-n}px`,left:`calc(100% + ${a}px) ${o}px`,right:`${-a}px ${o}px`}[r]),Object.assign(F.style,{left:null!=e?`${e}px`:"",top:null!=t?`${t}px`:"",[r]:"100%"})}},a=function(e,t,r,a){let n;void 0===a&&(a={});let{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:u=!1}=a,c=ss(e),d=i||o?[...c?sn(c):[],...sn(t)]:[];d.forEach(e=>{i&&e.addEventListener("scroll",r,{passive:!0}),o&&e.addEventListener("resize",r)});let f=c&&l?function(e,t){let r,a=null,n=oQ(e);function i(){var e;clearTimeout(r),null==(e=a)||e.disconnect(),a=null}return!function o(s,l){void 0===s&&(s=!1),void 0===l&&(l=1),i();let u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:h}=u;if(s||t(),!f||!h)return;let m={rootMargin:-ob(d)+"px "+-ob(n.clientWidth-(c+f))+"px "+-ob(n.clientHeight-(d+h))+"px "+-ob(c)+"px",threshold:oA(0,oy(1,l))||1},p=!0;function g(t){let a=t[0].intersectionRatio;if(a!==l){if(!p)return o();a?o(!1,a):r=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==a||sb(u,e.getBoundingClientRect())||o(),p=!1}try{a=new IntersectionObserver(g,{...m,root:n.ownerDocument})}catch(e){a=new IntersectionObserver(g,m)}a.observe(e)}(!0),i}(c,r):null,h=-1,m=null;s&&(m=new ResizeObserver(e=>{let[a]=e;a&&a.target===c&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(t)})),r()}),c&&!u&&m.observe(c),m.observe(t));let p=u?sd(e):null;return u&&function t(){let a=sd(e);p&&!sb(p,a)&&r(),p=a,n=requestAnimationFrame(t)}(),r(),()=>{var e;d.forEach(e=>{i&&e.removeEventListener("scroll",r),o&&e.removeEventListener("resize",r)}),null==f||f(),null==(e=m)||e.disconnect(),m=null,u&&cancelAnimationFrame(n)}}(t,x,async()=>{j?(await L({updatePosition:r}),T(!0)):await r()},{elementResize:"function"==typeof ResizeObserver});return()=>{T(!1),a()}},[e,k,x,C,B,x,M,D,P,l,u,c,d,f,h,m,p,g,v,G,j,L]),a3(()=>{if(!D||!P||!(null==x?void 0:x.isConnected)||!(null==E?void 0:E.isConnected))return;let e=()=>{x.style.zIndex=getComputedStyle(E).zIndex};e();let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[D,P,x,E]);let _=l?"fixed":"absolute";return F=ne(F,t=>(0,n.jsx)("div",{...s,style:{position:_,top:0,left:0,width:"max-content",...null==s?void 0:s.style},ref:null==e?void 0:e.setPopoverElement,children:t}),[e,_,s]),F={"data-placing":!I||void 0,...F=ne(F,t=>(0,n.jsx)(n9,{value:e,children:t}),[e]),style:{position:"relative",...F.style}},F=og({store:e,modal:t,portal:r,preserveTabOrder:a,preserveTabOrderAnchor:S||B,autoFocusOnShow:I&&i,...F,portalRef:R})});ov(nl(function(e){return nc("div",sx(e))}),n2);var sE=nd(function({store:e,modal:t,tabIndex:r,alwaysVisible:a,autoFocusOnHide:n=!0,hideOnInteractOutside:i=!0,...s}){let l=ie();a_(e=e||l,!1);let u=e.useState("baseElement"),c=(0,o.useRef)(!1),d=iw(e.tag,e=>null==e?void 0:e.renderedItems.length);return s=iK({store:e,alwaysVisible:a,...s}),s=sx({store:e,modal:t,alwaysVisible:a,backdrop:!1,autoFocusOnShow:!1,finalFocus:u,preserveTabOrderAnchor:null,unstable_treeSnapshotKey:d,...s,getPersistentElements(){var r;let a=(null==(r=s.getPersistentElements)?void 0:r.call(s))||[];if(!t||!e)return a;let{contentElement:n,baseElement:i}=e.getState();if(!i)return a;let o=av(i),l=[];if((null==n?void 0:n.id)&&l.push(`[aria-controls~="${n.id}"]`),(null==i?void 0:i.id)&&l.push(`[aria-controls~="${i.id}"]`),!l.length)return[...a,i];let u=l.join(",");return[...a,...o.querySelectorAll(u)]},autoFocusOnHide:e=>!aO(n,e)&&(!c.current||(c.current=!1,!1)),hideOnInteractOutside(t){var r,a;let n=null==e?void 0:e.getState(),o=null==(r=null==n?void 0:n.contentElement)?void 0:r.id,s=null==(a=null==n?void 0:n.baseElement)?void 0:a.id;if(function(e,...t){if(!e)return!1;if("id"in e){let r=t.filter(Boolean).map(e=>`[aria-controls~="${e}"]`).join(", ");return!!r&&e.matches(r)}return!1}(t.target,o,s))return!1;let l="function"==typeof i?i(t):i;return l&&(c.current="click"===t.type),l}})}),sM=ov(nl(function(e){return nc("div",sE(e))}),ie);(0,o.createContext)(null),(0,o.createContext)(null);var sD=nf([ny],[nA]),sk=sD.useContext;sD.useScopedContext,sD.useProviderContext,sD.ContextProvider,sD.ScopedContextProvider;var sw={id:null};function sI(e,t){return e.find(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function sT(e,t){return e.filter(e=>e.rowId===t)}function sR(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}function sP(e){let t=0;for(let{length:r}of e)r>t&&(t=r);return t}var sG=az()&&aK();function sL({tag:e,...t}={}){let r=ip(t.store,function(e,...t){if(e)return io(e,"pick")(...t)}(e,["value","rtl"]));ig(t,r);let a=null==e?void 0:e.getState(),n=null==r?void 0:r.getState(),i=aN(t.activeId,null==n?void 0:n.activeId,t.defaultActiveId,null),o=function(e={}){var t;let r=null==(t=e.store)?void 0:t.getState(),a=function(e={}){var t,r;ig(e,e.store);let a=null==(t=e.store)?void 0:t.getState(),n=aN(e.items,null==a?void 0:a.items,e.defaultItems,[]),i=new Map(n.map(e=>[e.id,e])),o={items:n,renderedItems:aN(null==a?void 0:a.renderedItems,[])},s=null==(r=e.store)?void 0:r.__unstablePrivateStore,l=is({items:n,renderedItems:o.renderedItems},s),u=is(o,e.store),c=e=>{var t;let r,a,n=(t=e=>e.element,r=e.map((e,t)=>[t,e]),a=!1,(r.sort(([e,r],[n,i])=>{var o;let s=t(r),l=t(i);return s!==l&&s&&l?(o=s,l.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING)?(e>n&&(a=!0),-1):(e<n&&(a=!0),1):0}),a)?r.map(([e,t])=>t):e);l.setState("renderedItems",n),u.setState("renderedItems",n)};il(u,()=>iu(l)),il(l,()=>ih(l,["items"],e=>{u.setState("items",e.items)})),il(l,()=>ih(l,["renderedItems"],e=>{let t=!0,r=requestAnimationFrame(()=>{let{renderedItems:t}=u.getState();e.renderedItems!==t&&c(e.renderedItems)});if("function"!=typeof IntersectionObserver)return()=>cancelAnimationFrame(r);let a=new IntersectionObserver(()=>{if(t){t=!1;return}cancelAnimationFrame(r),r=requestAnimationFrame(()=>c(e.renderedItems))},{root:function(e){var t;let r=e.find(e=>!!e.element),a=[...e].reverse().find(e=>!!e.element),n=null==(t=null==r?void 0:r.element)?void 0:t.parentElement;for(;n&&(null==a?void 0:a.element);){let e=n;if(a&&e.contains(a.element))return n;n=n.parentElement}return av(n).body}(e.renderedItems)});for(let t of e.renderedItems)t.element&&a.observe(t.element);return()=>{cancelAnimationFrame(r),a.disconnect()}}));let d=(e,t,r=!1)=>{let a;return t(t=>{let r=t.findIndex(({id:t})=>t===e.id),n=t.slice();if(-1!==r){let o={...a=t[r],...e};n[r]=o,i.set(e.id,o)}else n.push(e),i.set(e.id,e);return n}),()=>{t(t=>{if(!a)return r&&i.delete(e.id),t.filter(({id:t})=>t!==e.id);let n=t.findIndex(({id:t})=>t===e.id);if(-1===n)return t;let o=t.slice();return o[n]=a,i.set(e.id,a),o})}},f=e=>d(e,e=>l.setState("items",e),!0);return{...u,registerItem:f,renderItem:e=>aL(f(e),d(e,e=>l.setState("renderedItems",e))),item:e=>{if(!e)return null;let t=i.get(e);if(!t){let{items:r}=l.getState();(t=r.find(t=>t.id===e))&&i.set(e,t)}return t||null},__unstablePrivateStore:l}}(e),n=aN(e.activeId,null==r?void 0:r.activeId,e.defaultActiveId),i=is({...a.getState(),id:aN(e.id,null==r?void 0:r.id,`id-${Math.random().toString(36).slice(2,8)}`),activeId:n,baseElement:aN(null==r?void 0:r.baseElement,null),includesBaseElement:aN(e.includesBaseElement,null==r?void 0:r.includesBaseElement,null===n),moves:aN(null==r?void 0:r.moves,0),orientation:aN(e.orientation,null==r?void 0:r.orientation,"both"),rtl:aN(e.rtl,null==r?void 0:r.rtl,!1),virtualFocus:aN(e.virtualFocus,null==r?void 0:r.virtualFocus,!1),focusLoop:aN(e.focusLoop,null==r?void 0:r.focusLoop,!1),focusWrap:aN(e.focusWrap,null==r?void 0:r.focusWrap,!1),focusShift:aN(e.focusShift,null==r?void 0:r.focusShift,!1)},a,e.store);il(i,()=>id(i,["renderedItems","activeId"],e=>{i.setState("activeId",t=>{var r;return void 0!==t?t:null==(r=sI(e.renderedItems))?void 0:r.id})}));let o=(e="next",t={})=>{var r,a;let n=i.getState(),{skip:o=0,activeId:s=n.activeId,focusShift:l=n.focusShift,focusLoop:u=n.focusLoop,focusWrap:c=n.focusWrap,includesBaseElement:d=n.includesBaseElement,renderedItems:f=n.renderedItems,rtl:h=n.rtl}=t,m="up"===e||"down"===e,p="next"===e||"down"===e,g=m?nJ(function(e,t,r){let a=sP(e);for(let n of e)for(let e=0;e<a;e+=1){let a=n[e];if(!a||r&&a.disabled){let a=0===e&&r?sI(n):n[e-1];n[e]=a&&t!==a.id&&r?a:{id:"__EMPTY_ITEM__",disabled:!0,rowId:null==a?void 0:a.rowId}}}return e}(sR(f),s,l&&!o)):f;if(g=(p?h&&!m:!h||m)?nK(g):g,g=m?function(e){let t=sR(e),r=sP(t),a=[];for(let e=0;e<r;e+=1)for(let r of t){let t=r[e];t&&a.push({...t,rowId:t.rowId?`${e}`:void 0})}return a}(g):g,null==s)return null==(r=sI(g))?void 0:r.id;let v=g.find(e=>e.id===s);if(!v)return null==(a=sI(g))?void 0:a.id;let y=g.some(e=>e.rowId),A=g.indexOf(v),F=g.slice(A+1),b=sT(F,v.rowId);if(o){let e=b.filter(e=>s?!e.disabled&&e.id!==s:!e.disabled),t=e.slice(o)[0]||e[e.length-1];return null==t?void 0:t.id}let C=u&&(m?"horizontal"!==u:"vertical"!==u),B=y&&c&&(m?"horizontal"!==c:"vertical"!==c),S=p?(!y||m)&&C&&d:!!m&&d;if(C){let e=sI(function(e,t,r=!1){let a=e.findIndex(e=>e.id===t);return[...e.slice(a+1),...r?[sw]:[],...e.slice(0,a)]}(B&&!S?g:sT(g,v.rowId),s,S),s);return null==e?void 0:e.id}if(B){let e=sI(S?b:F,s);return S?(null==e?void 0:e.id)||null:null==e?void 0:e.id}let x=sI(b,s);return!x&&S?null:null==x?void 0:x.id};return{...a,...i,setBaseElement:e=>i.setState("baseElement",e),setActiveId:e=>i.setState("activeId",e),move:e=>{void 0!==e&&(i.setState("activeId",e),i.setState("moves",e=>e+1))},first:()=>{var e;return null==(e=sI(i.getState().renderedItems))?void 0:e.id},last:()=>{var e;return null==(e=sI(nK(i.getState().renderedItems)))?void 0:e.id},next:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),o("next",e)),previous:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),o("previous",e)),down:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),o("down",e)),up:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),o("up",e))}}({...t,activeId:i,includesBaseElement:aN(t.includesBaseElement,null==n?void 0:n.includesBaseElement,!0),orientation:aN(t.orientation,null==n?void 0:n.orientation,"vertical"),focusLoop:aN(t.focusLoop,null==n?void 0:n.focusLoop,!0),focusWrap:aN(t.focusWrap,null==n?void 0:n.focusWrap,!0),virtualFocus:aN(t.virtualFocus,null==n?void 0:n.virtualFocus,!0)}),s=function({popover:e,...t}={}){let r=ip(t.store,im(e,["arrowElement","anchorElement","contentElement","popoverElement","disclosureElement"]));ig(t,r);let a=null==r?void 0:r.getState(),n=oh({...t,store:r}),i=aN(t.placement,null==a?void 0:a.placement,"bottom"),o=is({...n.getState(),placement:i,currentPlacement:i,anchorElement:aN(null==a?void 0:a.anchorElement,null),popoverElement:aN(null==a?void 0:a.popoverElement,null),arrowElement:aN(null==a?void 0:a.arrowElement,null),rendered:Symbol("rendered")},n,r);return{...n,...o,setAnchorElement:e=>o.setState("anchorElement",e),setPopoverElement:e=>o.setState("popoverElement",e),setArrowElement:e=>o.setState("arrowElement",e),render:()=>o.setState("rendered",Symbol("rendered"))}}({...t,placement:aN(t.placement,null==n?void 0:n.placement,"bottom-start")}),l=aN(t.value,null==n?void 0:n.value,t.defaultValue,""),u=aN(t.selectedValue,null==n?void 0:n.selectedValue,null==a?void 0:a.values,t.defaultSelectedValue,""),c=Array.isArray(u),d={...o.getState(),...s.getState(),value:l,selectedValue:u,resetValueOnSelect:aN(t.resetValueOnSelect,null==n?void 0:n.resetValueOnSelect,c),resetValueOnHide:aN(t.resetValueOnHide,null==n?void 0:n.resetValueOnHide,c&&!e),activeValue:null==n?void 0:n.activeValue},f=is(d,o,s,r);return sG&&il(f,()=>id(f,["virtualFocus"],()=>{f.setState("virtualFocus",!1)})),il(f,()=>{if(e)return aL(id(f,["selectedValue"],t=>{Array.isArray(t.selectedValue)&&e.setValues(t.selectedValue)}),id(e,["values"],e=>{f.setState("selectedValue",e.values)}))}),il(f,()=>id(f,["resetValueOnHide","mounted"],e=>{!e.resetValueOnHide||e.mounted||f.setState("value",l)})),il(f,()=>id(f,["open"],e=>{e.open||(f.setState("activeId",i),f.setState("moves",0))})),il(f,()=>id(f,["moves","activeId"],(e,t)=>{e.moves===t.moves&&f.setState("activeValue",void 0)})),il(f,()=>ih(f,["moves","renderedItems"],(e,t)=>{if(e.moves===t.moves)return;let{activeId:r}=f.getState(),a=o.item(r);f.setState("activeValue",null==a?void 0:a.value)})),{...s,...o,...f,tag:e,setValue:e=>f.setState("value",e),resetValue:()=>f.setState("value",d.value),setSelectedValue:e=>f.setState("selectedValue",e)}}function sj(e={}){var t,r,a,n,i,o,s,l;let u;t=e,u=sk();let[c,d]=iR(sL,e={id:a8((r=t={...t,tag:void 0!==t.tag?t.tag:u}).id),...r});return a4(d,[(a=e).tag]),iT(c,a,"value","setValue"),iT(c,a,"selectedValue","setSelectedValue"),iT(c,a,"resetValueOnHide"),iT(c,a,"resetValueOnSelect"),Object.assign((o=c,a4(s=d,[(l=a).popover]),iT(o,l,"placement"),n=oc(o,s,l),i=n,a4(d,[a.store]),iT(i,a,"items","setItems"),iT(n=i,a,"activeId","setActiveId"),iT(n,a,"includesBaseElement"),iT(n,a,"virtualFocus"),iT(n,a,"orientation"),iT(n,a,"rtl"),iT(n,a,"focusLoop"),iT(n,a,"focusWrap"),iT(n,a,"focusShift"),n),{tag:a.tag})}function s_(e={}){let t=sj(e);return(0,n.jsx)(it,{value:t,children:e.children})}var sO=(0,o.createContext)(void 0),sU=nd(function(e){let[t,r]=(0,o.useState)();return aH(e={role:"group","aria-labelledby":t,...e=ne(e,e=>(0,n.jsx)(sO.Provider,{value:r,children:e}),[])})});nl(function(e){return nc("div",sU(e))});var sH=nd(function({store:e,...t}){return sU(t)});nl(function(e){return nc("div",sH(e))});var sN=nd(function({store:e,...t}){let r=n7();return a_(e=e||r,!1),"grid"===aD(e.useState("contentElement"))&&(t={role:"rowgroup",...t}),t=sH({store:e,...t})}),sJ=nl(function(e){return nc("div",sN(e))}),sK=nd(function(e){let t=(0,o.useContext)(sO),r=a8(e.id);return a3(()=>(null==t||t(r),()=>null==t?void 0:t(void 0)),[t,r]),aH(e={id:r,"aria-hidden":!0,...e})});nl(function(e){return nc("div",sK(e))});var sV=nd(function({store:e,...t}){return sK(t)});nl(function(e){return nc("div",sV(e))});var sz=nd(function(e){return sV(e)}),sq=nl(function(e){return nc("div",sz(e))}),sQ=e.i(38360);let sW={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},sX=(e,t)=>String(e.rankedValue).localeCompare(String(t.rankedValue));function sY(e,t,r={}){let{keys:a,threshold:n=sW.MATCHES,baseSort:i=sX,sorter:o=e=>e.sort((e,t)=>(function(e,t,r){let{rank:a,keyIndex:n}=e,{rank:i,keyIndex:o}=t;return a!==i?a>i?-1:1:n===o?r(e,t):n<o?-1:1})(e,t,i))}=r;return o(e.reduce(function(e,i,o){var s,l,u,c;let d=(s=i,l=a,u=t,c=r,l?(function(e,t){let r=[];for(let n=0,i=t.length;n<i;n++){var a;let i=t[n],o="string"==typeof(a=i)?s0:{...s0,...a},s=function(e,t){let r;if("object"==typeof t&&(t=t.key),"function"==typeof t)r=t(e);else if(null==e)r=null;else if(Object.hasOwnProperty.call(e,t))r=e[t];else{if(t.includes("."))return function(e,t){let r=e.split("."),a=[t];for(let e=0,t=r.length;e<t;e++){let t=r[e],n=[];for(let e=0,r=a.length;e<r;e++){let r=a[e];if(null!=r)if(Object.hasOwnProperty.call(r,t)){let e=r[t];null!=e&&n.push(e)}else"*"===t&&(n=n.concat(r))}a=n}return Array.isArray(a[0])?[].concat(...a):a}(t,e);r=null}return null==r?[]:Array.isArray(r)?r:[String(r)]}(e,i);for(let e=0,t=s.length;e<t;e++)r.push({itemValue:s[e],attributes:o})}return r})(s,l).reduce(({rank:e,rankedValue:t,keyIndex:r,keyThreshold:a},{itemValue:n,attributes:i},o)=>{let s=sZ(n,u,c),l=t,{minRanking:d,maxRanking:f,threshold:h}=i;return s<d&&s>=sW.MATCHES?s=d:s>f&&(s=f),s>e&&(e=s,r=o,a=h,l=n),{rankedValue:l,rank:e,keyIndex:r,keyThreshold:a}},{rankedValue:s,rank:sW.NO_MATCH,keyIndex:-1,keyThreshold:c.threshold}):{rankedValue:s,rank:sZ(s,u,c),keyIndex:-1,keyThreshold:c.threshold}),{rank:f,keyThreshold:h=n}=d;return f>=h&&e.push({...d,item:i,index:o}),e},[])).map(({item:e})=>e)}function sZ(e,t,r){if(e=s$(e,r),(t=s$(t,r)).length>e.length)return sW.NO_MATCH;if(e===t)return sW.CASE_SENSITIVE_EQUAL;let a=function*(e,t){let r=-1;for(;(r=e.indexOf(t,r+1))>-1;)yield r;return -1}(e=e.toLowerCase(),t=t.toLowerCase()),n=a.next(),i=n.value;if(e.length===t.length&&0===i)return sW.EQUAL;if(0===i)return sW.STARTS_WITH;let o=n;for(;!o.done;){if(o.value>0&&" "===e[o.value-1])return sW.WORD_STARTS_WITH;o=a.next()}return i>0?sW.CONTAINS:1===t.length?sW.NO_MATCH:(function(e){let t="",r=" ";for(let a=0;a<e.length;a++){let n=e.charAt(a),i=" "===n||"-"===n;" "!==r&&"-"!==r||i||(t+=n),r=n}return t})(e).includes(t)?sW.ACRONYM:function(e,t){var r;let a,n=0,i=0;function o(e,t,r){for(let a=r,i=t.length;a<i;a++)if(t[a]===e)return n+=1,a+1;return -1}let s=o(t[0],e,0);if(s<0)return sW.NO_MATCH;i=s;for(let r=1,a=t.length;r<a;r++)if(!((i=o(t[r],e,i))>-1))return sW.NO_MATCH;return r=i-s,a=n/t.length,sW.MATCHES+1/r*a}(e,t)}function s$(e,{keepDiacritics:t}){return e=`${e}`,t||(e=(0,sQ.default)(e)),e}sY.rankings=sW;let s0={maxRanking:1/0,minRanking:-1/0};var s1=e.i(29402);let s2=new Set(["SkiFree","SkiFree_Daily","SkiFree_Randomizer"]),s3={"missions.vl2":"Official","TR2final105-client.vl2":"Team Rabbit 2","z_mappacks/CTF/Classic_maps_v1.vl2":"Classic","z_mappacks/CTF/DynamixFinalPack.vl2":"Official","z_mappacks/CTF/KryMapPack_b3EDIT.vl2":"KryMapPack","z_mappacks/CTF/S5maps.vl2":"S5","z_mappacks/CTF/S8maps.vl2":"S8","z_mappacks/CTF/TWL-MapPack.vl2":"TWL","z_mappacks/CTF/TWL-MapPackEDIT.vl2":"TWL","z_mappacks/CTF/TWL2-MapPack.vl2":"TWL2","z_mappacks/CTF/TWL2-MapPackEDIT.vl2":"TWL2","z_mappacks/TWL_T2arenaOfficialMaps.vl2":"Arena","z_mappacks/xPack2.vl2":"xPack2","z_mappacks/z_DMP2-V0.6.vl2":"DMP2 (Discord Map Pack)","z_mappacks/zDMP-4.7.3DX.vl2":"DMP (Discord Map Pack)","z_mappacks/zDMP-4.7.3DX-ServerOnly.vl2":"DMP (Discord Map Pack)"},s9={"z_mappacks/DM":"DM","z_mappacks/LCTF":"LCTF","z_mappacks/Lak":"LakRabbit"},s5=(0,ri.getMissionList)().filter(e=>!s2.has(e)).map(e=>{let t,r=(0,ri.getMissionInfo)(e),[a]=(0,ri.getSourceAndPath)(r.resourcePath),n=(t=a.match(/^(.*)(\/[^/]+)$/))?t[1]:"",i=s3[a]??s9[n]??null;return{resourcePath:r.resourcePath,missionName:e,displayName:r.displayName,sourcePath:a,groupName:i,missionTypes:r.missionTypes}}),s8=new Map(s5.map(e=>[e.missionName,e])),s4=function(e){let t=new Map;for(let r of e){let e=t.get(r.groupName)??[];e.push(r),t.set(r.groupName,e)}return t.forEach((e,r)=>{t.set(r,(0,s1.default)(e,[e=>(e.displayName||e.missionName).toLowerCase()],["asc"]))}),(0,s1.default)(Array.from(t.entries()),[([e])=>"Official"===e?0:null==e?2:1,([e])=>e?e.toLowerCase():""],["asc","asc"])}(s5),s6="undefined"!=typeof navigator&&/Mac|iPhone|iPad|iPod/.test(navigator.platform);function s7(e){let t,r,a,o,s,l=(0,i.c)(12),{mission:u}=e,c=u.displayName||u.missionName;return l[0]!==c?(t=(0,n.jsx)("span",{className:"MissionSelect-itemName",children:c}),l[0]=c,l[1]=t):t=l[1],l[2]!==u.missionTypes?(r=u.missionTypes.length>0&&(0,n.jsx)("span",{className:"MissionSelect-itemTypes",children:u.missionTypes.map(le)}),l[2]=u.missionTypes,l[3]=r):r=l[3],l[4]!==t||l[5]!==r?(a=(0,n.jsxs)("span",{className:"MissionSelect-itemHeader",children:[t,r]}),l[4]=t,l[5]=r,l[6]=a):a=l[6],l[7]!==u.missionName?(o=(0,n.jsx)("span",{className:"MissionSelect-itemMissionName",children:u.missionName}),l[7]=u.missionName,l[8]=o):o=l[8],l[9]!==a||l[10]!==o?(s=(0,n.jsxs)(n.Fragment,{children:[a,o]}),l[9]=a,l[10]=o,l[11]=s):s=l[11],s}function le(e){return(0,n.jsx)("span",{className:"MissionSelect-itemType","data-mission-type":e,children:e},e)}function lt(e){let t,r,a,s,l,u,c,d,f,h,m,p,g,v,y,A,F,b=(0,i.c)(44),{value:C,missionType:B,onChange:S,disabled:x}=e,[E,M]=(0,o.useState)(""),D=(0,o.useRef)(null),k=(0,o.useRef)(B);b[0]===Symbol.for("react.memo_cache_sentinel")?(t=e=>{(0,o.startTransition)(()=>M(e))},b[0]=t):t=b[0];let w=sj({resetValueOnHide:!0,selectedValue:C,setSelectedValue:e=>{if(e){let t=k.current,r=(0,ri.getMissionInfo)(e).missionTypes;t&&r.includes(t)||(t=r[0]),S({missionName:e,missionType:t}),D.current?.blur()}},setValue:t});b[1]!==w?(r=()=>{let e=e=>{"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),D.current?.focus(),w.show())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},a=[w],b[1]=w,b[2]=r,b[3]=a):(r=b[2],a=b[3]),(0,o.useEffect)(r,a),b[4]!==C?(s=s8.get(C),b[4]=C,b[5]=s):s=b[5];let I=s;e:{let e,t;if(!E){let e;b[6]===Symbol.for("react.memo_cache_sentinel")?(e={type:"grouped",groups:s4},b[6]=e):e=b[6],l=e;break e}b[7]!==E?(e=sY(s5,E,{keys:["displayName","missionName","missionTypes","groupName"]}),b[7]=E,b[8]=e):e=b[8];let r=e;b[9]!==r?(t={type:"flat",missions:r},b[9]=r,b[10]=t):t=b[10],l=t}let T=l,R=I?I.displayName||I.missionName:C,P="flat"===T.type?0===T.missions.length:0===T.groups.length,G=e=>(0,n.jsx)(ij,{value:e.missionName,className:"MissionSelect-item",focusOnHover:!0,onClick:t=>{if(t.target&&t.target instanceof HTMLElement){let r=t.target.dataset.missionType;r?(k.current=r,e.missionName===C&&S({missionName:e.missionName,missionType:r})):k.current=null}else k.current=null},children:(0,n.jsx)(s7,{mission:e})},e.missionName);b[11]!==w?(u=()=>{try{document.exitPointerLock()}catch{}w.show()},c=e=>{"Escape"!==e.key||w.getState().open||D.current?.blur()},b[11]=w,b[12]=u,b[13]=c):(u=b[12],c=b[13]),b[14]!==x||b[15]!==R||b[16]!==u||b[17]!==c?(d=(0,n.jsx)(iF,{ref:D,autoSelect:!0,disabled:x,placeholder:R,className:"MissionSelect-input",onFocus:u,onKeyDown:c}),b[14]=x,b[15]=R,b[16]=u,b[17]=c,b[18]=d):d=b[18],b[19]!==R?(f=(0,n.jsx)("span",{className:"MissionSelect-selectedName",children:R}),b[19]=R,b[20]=f):f=b[20],b[21]!==B?(h=B&&(0,n.jsx)("span",{className:"MissionSelect-itemType","data-mission-type":B,children:B}),b[21]=B,b[22]=h):h=b[22],b[23]!==h||b[24]!==f?(m=(0,n.jsxs)("div",{className:"MissionSelect-selectedValue",children:[f,h]}),b[23]=h,b[24]=f,b[25]=m):m=b[25],b[26]===Symbol.for("react.memo_cache_sentinel")?(p=(0,n.jsx)("kbd",{className:"MissionSelect-shortcut",children:s6?"⌘K":"^K"}),b[26]=p):p=b[26],b[27]!==m||b[28]!==d?(g=(0,n.jsxs)("div",{className:"MissionSelect-inputWrapper",children:[d,m,p]}),b[27]=m,b[28]=d,b[29]=g):g=b[29];let L="flat"===T.type?T.missions.map(G):T.groups.map(e=>{let[t,r]=e;return t?(0,n.jsxs)(sJ,{className:"MissionSelect-group",children:[(0,n.jsx)(sq,{className:"MissionSelect-groupLabel",children:t}),r.map(G)]},t):(0,n.jsx)(o.Fragment,{children:r.map(G)},"ungrouped")});return b[30]!==P?(v=P&&(0,n.jsx)("div",{className:"MissionSelect-noResults",children:"No missions found"}),b[30]=P,b[31]=v):v=b[31],b[32]!==iV||b[33]!==L||b[34]!==v?(y=(0,n.jsxs)(iV,{className:"MissionSelect-list",children:[L,v]}),b[32]=iV,b[33]=L,b[34]=v,b[35]=y):y=b[35],b[36]!==sM||b[37]!==y?(A=(0,n.jsx)(sM,{gutter:4,fitViewport:!0,autoFocusOnHide:!1,className:"MissionSelect-popover",children:y}),b[36]=sM,b[37]=y,b[38]=A):A=b[38],b[39]!==s_||b[40]!==w||b[41]!==g||b[42]!==A?(F=(0,n.jsxs)(s_,{store:w,children:[g,A]}),b[39]=s_,b[40]=w,b[41]=g,b[42]=A,b[43]=F):F=b[43],F}var lr=e.i(11152),la=e.i(40141);function ln(e){return(0,la.GenIcon)({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M192 0c-41.8 0-77.4 26.7-90.5 64L64 64C28.7 64 0 92.7 0 128L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64l-37.5 0C269.4 26.7 233.8 0 192 0zm0 64a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM305 273L177 401c-9.4 9.4-24.6 9.4-33.9 0L79 337c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L271 239c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"},child:[]}]})(e)}function li(e){let t,r,a,s,l,u=(0,i.c)(11),{cameraRef:c,missionName:d,missionType:f}=e,{fogEnabled:h}=(0,E.useSettings)(),[m,p]=(0,o.useState)(!1),g=(0,o.useRef)(null);u[0]!==c||u[1]!==h||u[2]!==d||u[3]!==f?(t=async()=>{clearTimeout(g.current);let e=c.current;if(!e)return;let t=function({position:e,quaternion:t}){let r=e=>parseFloat(e.toFixed(3)),a=`${r(e.x)},${r(e.y)},${r(e.z)}`,n=`${r(t.x)},${r(t.y)},${r(t.z)},${r(t.w)}`;return`#c${a}~${n}`}(e),r=new URLSearchParams;r.set("mission",`${d}~${f}`),r.set("fog",h.toString());let a=`${window.location.pathname}?${r}${t}`,n=`${window.location.origin}${a}`;window.history.replaceState(null,"",a);try{await navigator.clipboard.writeText(n),p(!0),g.current=setTimeout(()=>{p(!1)},1100)}catch(e){console.error(e)}},u[0]=c,u[1]=h,u[2]=d,u[3]=f,u[4]=t):t=u[4];let v=t,y=m?"true":"false";return u[5]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)(lr.FaMapPin,{className:"MapPin"}),a=(0,n.jsx)(ln,{className:"ClipboardCheck"}),s=(0,n.jsx)("span",{className:"ButtonLabel",children:" Copy coordinates URL"}),u[5]=r,u[6]=a,u[7]=s):(r=u[5],a=u[6],s=u[7]),u[8]!==v||u[9]!==y?(l=(0,n.jsxs)("button",{type:"button",className:"IconButton LabelledButton CopyCoordinatesButton","aria-label":"Copy coordinates URL",title:"Copy coordinates URL",onClick:v,"data-copied":y,id:"copyCoordinatesButton",children:[r,a,s]}),u[8]=v,u[9]=y,u[10]=l):l=u[10],l}function lo(e){return(0,la.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M21 3H3c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5a2 2 0 0 0-2-2zm0 14H3V5h18v12zm-5-6-7 4V7z"},child:[]}]})(e)}var ls={},ll=function(e,t,r,a,n){var i=new Worker(ls[t]||(ls[t]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return i.onmessage=function(e){var t=e.data,r=t.$e$;if(r){var a=Error(r[0]);a.code=r[1],a.stack=r[2],n(a,null)}else n(null,t)},i.postMessage(r,a),i},lu=Uint8Array,lc=Uint16Array,ld=Int32Array,lf=new lu([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,0,0,0]),lh=new lu([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,0,0]),lm=new lu([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lp=function(e,t){for(var r=new lc(31),a=0;a<31;++a)r[a]=t+=1<<e[a-1];for(var n=new ld(r[30]),a=1;a<30;++a)for(var i=r[a];i<r[a+1];++i)n[i]=i-r[a]<<5|a;return{b:r,r:n}},lg=lp(lf,2),lv=lg.b,ly=lg.r;lv[28]=258,ly[258]=28;for(var lA=lp(lh,0),lF=lA.b,lb=lA.r,lC=new lc(32768),lB=0;lB<32768;++lB){var lS=(43690&lB)>>1|(21845&lB)<<1;lS=(61680&(lS=(52428&lS)>>2|(13107&lS)<<2))>>4|(3855&lS)<<4,lC[lB]=((65280&lS)>>8|(255&lS)<<8)>>1}for(var lx=function(e,t,r){for(var a,n=e.length,i=0,o=new lc(t);i<n;++i)e[i]&&++o[e[i]-1];var s=new lc(t);for(i=1;i<t;++i)s[i]=s[i-1]+o[i-1]<<1;if(r){a=new lc(1<<t);var l=15-t;for(i=0;i<n;++i)if(e[i])for(var u=i<<4|e[i],c=t-e[i],d=s[e[i]-1]++<<c,f=d|(1<<c)-1;d<=f;++d)a[lC[d]>>l]=u}else for(i=0,a=new lc(n);i<n;++i)e[i]&&(a[i]=lC[s[e[i]-1]++]>>15-e[i]);return a},lE=new lu(288),lB=0;lB<144;++lB)lE[lB]=8;for(var lB=144;lB<256;++lB)lE[lB]=9;for(var lB=256;lB<280;++lB)lE[lB]=7;for(var lB=280;lB<288;++lB)lE[lB]=8;for(var lM=new lu(32),lB=0;lB<32;++lB)lM[lB]=5;var lD=lx(lE,9,0),lk=lx(lE,9,1),lw=lx(lM,5,0),lI=lx(lM,5,1),lT=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},lR=function(e,t,r){var a=t/8|0;return(e[a]|e[a+1]<<8)>>(7&t)&r},lP=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},lG=function(e){return(e+7)/8|0},lL=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new lu(e.subarray(t,r))},lj=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],l_=function(e,t,r){var a=Error(t||lj[e]);if(a.code=e,Error.captureStackTrace&&Error.captureStackTrace(a,l_),!r)throw a;return a},lO=function(e,t,r,a){var n=e.length,i=a?a.length:0;if(!n||t.f&&!t.l)return r||new lu(0);var o=!r,s=o||2!=t.i,l=t.i;o&&(r=new lu(3*n));var u=function(e){var t=r.length;if(e>t){var a=new lu(Math.max(2*t,e));a.set(r),r=a}},c=t.f||0,d=t.p||0,f=t.b||0,h=t.l,m=t.d,p=t.m,g=t.n,v=8*n;do{if(!h){c=lR(e,d,1);var y=lR(e,d+1,3);if(d+=3,y)if(1==y)h=lk,m=lI,p=9,g=5;else if(2==y){var A=lR(e,d,31)+257,F=lR(e,d+10,15)+4,b=A+lR(e,d+5,31)+1;d+=14;for(var C=new lu(b),B=new lu(19),S=0;S<F;++S)B[lm[S]]=lR(e,d+3*S,7);d+=3*F;for(var x=lT(B),E=(1<<x)-1,M=lx(B,x,1),S=0;S<b;){var D=M[lR(e,d,E)];d+=15&D;var k=D>>4;if(k<16)C[S++]=k;else{var w=0,I=0;for(16==k?(I=3+lR(e,d,3),d+=2,w=C[S-1]):17==k?(I=3+lR(e,d,7),d+=3):18==k&&(I=11+lR(e,d,127),d+=7);I--;)C[S++]=w}}var T=C.subarray(0,A),R=C.subarray(A);p=lT(T),g=lT(R),h=lx(T,p,1),m=lx(R,g,1)}else l_(1);else{var k=lG(d)+4,P=e[k-4]|e[k-3]<<8,G=k+P;if(G>n){l&&l_(0);break}s&&u(f+P),r.set(e.subarray(k,G),f),t.b=f+=P,t.p=d=8*G,t.f=c;continue}if(d>v){l&&l_(0);break}}s&&u(f+131072);for(var L=(1<<p)-1,j=(1<<g)-1,_=d;;_=d){var w=h[lP(e,d)&L],O=w>>4;if((d+=15&w)>v){l&&l_(0);break}if(w||l_(2),O<256)r[f++]=O;else if(256==O){_=d,h=null;break}else{var U=O-254;if(O>264){var S=O-257,H=lf[S];U=lR(e,d,(1<<H)-1)+lv[S],d+=H}var N=m[lP(e,d)&j],J=N>>4;N||l_(3),d+=15&N;var R=lF[J];if(J>3){var H=lh[J];R+=lP(e,d)&(1<<H)-1,d+=H}if(d>v){l&&l_(0);break}s&&u(f+131072);var K=f+U;if(f<R){var V=i-R,z=Math.min(R,K);for(V+f<0&&l_(3);f<z;++f)r[f]=a[V+f]}for(;f<K;++f)r[f]=r[f-R]}}t.l=h,t.p=_,t.b=f,t.f=c,h&&(c=1,t.m=p,t.d=m,t.n=g)}while(!c)return f!=r.length&&o?lL(r,0,f):r.subarray(0,f)},lU=function(e,t,r){r<<=7&t;var a=t/8|0;e[a]|=r,e[a+1]|=r>>8},lH=function(e,t,r){r<<=7&t;var a=t/8|0;e[a]|=r,e[a+1]|=r>>8,e[a+2]|=r>>16},lN=function(e,t){for(var r=[],a=0;a<e.length;++a)e[a]&&r.push({s:a,f:e[a]});var n=r.length,i=r.slice();if(!n)return{t:lW,l:0};if(1==n){var o=new lu(r[0].s+1);return o[r[0].s]=1,{t:o,l:1}}r.sort(function(e,t){return e.f-t.f}),r.push({s:-1,f:25001});var s=r[0],l=r[1],u=0,c=1,d=2;for(r[0]={s:-1,f:s.f+l.f,l:s,r:l};c!=n-1;)s=r[r[u].f<r[d].f?u++:d++],l=r[u!=c&&r[u].f<r[d].f?u++:d++],r[c++]={s:-1,f:s.f+l.f,l:s,r:l};for(var f=i[0].s,a=1;a<n;++a)i[a].s>f&&(f=i[a].s);var h=new lc(f+1),m=lJ(r[c-1],h,0);if(m>t){var a=0,p=0,g=m-t,v=1<<g;for(i.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});a<n;++a){var y=i[a].s;if(h[y]>t)p+=v-(1<<m-h[y]),h[y]=t;else break}for(p>>=g;p>0;){var A=i[a].s;h[A]<t?p-=1<<t-h[A]++-1:++a}for(;a>=0&&p;--a){var F=i[a].s;h[F]==t&&(--h[F],++p)}m=t}return{t:new lu(h),l:m}},lJ=function(e,t,r){return -1==e.s?Math.max(lJ(e.l,t,r+1),lJ(e.r,t,r+1)):t[e.s]=r},lK=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new lc(++t),a=0,n=e[0],i=1,o=function(e){r[a++]=e},s=1;s<=t;++s)if(e[s]==n&&s!=t)++i;else{if(!n&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(n),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(n);i=1,n=e[s]}return{c:r.subarray(0,a),n:t}},lV=function(e,t){for(var r=0,a=0;a<t.length;++a)r+=e[a]*t[a];return r},lz=function(e,t,r){var a=r.length,n=lG(t+2);e[n]=255&a,e[n+1]=a>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var i=0;i<a;++i)e[n+i+4]=r[i];return(n+4+a)*8},lq=function(e,t,r,a,n,i,o,s,l,u,c){lU(t,c++,r),++n[256];for(var d,f,h,m,p=lN(n,15),g=p.t,v=p.l,y=lN(i,15),A=y.t,F=y.l,b=lK(g),C=b.c,B=b.n,S=lK(A),x=S.c,E=S.n,M=new lc(19),D=0;D<C.length;++D)++M[31&C[D]];for(var D=0;D<x.length;++D)++M[31&x[D]];for(var k=lN(M,7),w=k.t,I=k.l,T=19;T>4&&!w[lm[T-1]];--T);var R=u+5<<3,P=lV(n,lE)+lV(i,lM)+o,G=lV(n,g)+lV(i,A)+o+14+3*T+lV(M,w)+2*M[16]+3*M[17]+7*M[18];if(l>=0&&R<=P&&R<=G)return lz(t,c,e.subarray(l,l+u));if(lU(t,c,1+(G<P)),c+=2,G<P){d=lx(g,v,0),f=g,h=lx(A,F,0),m=A;var L=lx(w,I,0);lU(t,c,B-257),lU(t,c+5,E-1),lU(t,c+10,T-4),c+=14;for(var D=0;D<T;++D)lU(t,c+3*D,w[lm[D]]);c+=3*T;for(var j=[C,x],_=0;_<2;++_)for(var O=j[_],D=0;D<O.length;++D){var U=31&O[D];lU(t,c,L[U]),c+=w[U],U>15&&(lU(t,c,O[D]>>5&127),c+=O[D]>>12)}}else d=lD,f=lE,h=lw,m=lM;for(var D=0;D<s;++D){var H=a[D];if(H>255){var U=H>>18&31;lH(t,c,d[U+257]),c+=f[U+257],U>7&&(lU(t,c,H>>23&31),c+=lf[U]);var N=31&H;lH(t,c,h[N]),c+=m[N],N>3&&(lH(t,c,H>>5&8191),c+=lh[N])}else lH(t,c,d[H]),c+=f[H]}return lH(t,c,d[256]),c+f[256]},lQ=new ld([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),lW=new lu(0),lX=function(e,t,r,a,n,i){var o=i.z||e.length,s=new lu(a+o+5*(1+Math.ceil(o/7e3))+n),l=s.subarray(a,s.length-n),u=i.l,c=7&(i.r||0);if(t){c&&(l[0]=i.r>>3);for(var d=lQ[t-1],f=d>>13,h=8191&d,m=(1<<r)-1,p=i.p||new lc(32768),g=i.h||new lc(m+1),v=Math.ceil(r/3),y=2*v,A=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&m},F=new ld(25e3),b=new lc(288),C=new lc(32),B=0,S=0,x=i.i||0,E=0,M=i.w||0,D=0;x+2<o;++x){var k=A(x),w=32767&x,I=g[k];if(p[w]=I,g[k]=w,M<=x){var T=o-x;if((B>7e3||E>24576)&&(T>423||!u)){c=lq(e,l,0,F,b,C,S,E,D,x-D,c),E=B=S=0,D=x;for(var R=0;R<286;++R)b[R]=0;for(var R=0;R<30;++R)C[R]=0}var P=2,G=0,L=h,j=w-I&32767;if(T>2&&k==A(x-j))for(var _=Math.min(f,T)-1,O=Math.min(32767,x),U=Math.min(258,T);j<=O&&--L&&w!=I;){if(e[x+P]==e[x+P-j]){for(var H=0;H<U&&e[x+H]==e[x+H-j];++H);if(H>P){if(P=H,G=j,H>_)break;for(var N=Math.min(j,H-2),J=0,R=0;R<N;++R){var K=x-j+R&32767,V=p[K],z=K-V&32767;z>J&&(J=z,I=K)}}}I=p[w=I],j+=w-I&32767}if(G){F[E++]=0x10000000|ly[P]<<18|lb[G];var q=31&ly[P],Q=31&lb[G];S+=lf[q]+lh[Q],++b[257+q],++C[Q],M=x+P,++B}else F[E++]=e[x],++b[e[x]]}}for(x=Math.max(x,M);x<o;++x)F[E++]=e[x],++b[e[x]];c=lq(e,l,u,F,b,C,S,E,D,x-D,c),u||(i.r=7&c|l[c/8|0]<<3,c-=7,i.h=g,i.p=p,i.i=x,i.w=M)}else{for(var x=i.w||0;x<o+u;x+=65535){var W=x+65535;W>=o&&(l[c/8|0]=u,W=o),c=lz(l,c+1,e.subarray(x,W))}i.i=o}return lL(s,0,a+lG(c)+n)},lY=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var r=t,a=9;--a;)r=(1&r&&-0x12477ce0)^r>>>1;e[t]=r}return e}(),lZ=function(){var e=-1;return{p:function(t){for(var r=e,a=0;a<t.length;++a)r=lY[255&r^t[a]]^r>>>8;e=r},d:function(){return~e}}},l$=function(){var e=1,t=0;return{p:function(r){for(var a=e,n=t,i=0|r.length,o=0;o!=i;){for(var s=Math.min(o+2655,i);o<s;++o)n+=a+=r[o];a=(65535&a)+15*(a>>16),n=(65535&n)+15*(n>>16)}e=a,t=n},d:function(){return e%=65521,t%=65521,(255&e)<<24|(65280&e)<<8|(255&t)<<8|t>>8}}},l0=function(e,t,r,a,n){if(!n&&(n={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),o=new lu(i.length+e.length);o.set(i),o.set(e,i.length),e=o,n.w=i.length}return lX(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,r,a,n)},l1=function(e,t){var r={};for(var a in e)r[a]=e[a];for(var a in t)r[a]=t[a];return r},l2=function(e,t,r){for(var a=e(),n=e.toString(),i=n.slice(n.indexOf("[")+1,n.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<a.length;++o){var s=a[o],l=i[o];if("function"==typeof s){t+=";"+l+"=";var u=s.toString();if(s.prototype)if(-1!=u.indexOf("[native code]")){var c=u.indexOf(" ",8)+1;t+=u.slice(c,u.indexOf("(",c))}else for(var d in t+=u,s.prototype)t+=";"+l+".prototype."+d+"="+s.prototype[d].toString();else t+=u}else r[l]=s}return t},l3=[],l9=function(e){var t=[];for(var r in e)e[r].buffer&&t.push((e[r]=new e[r].constructor(e[r])).buffer);return t},l5=function(e,t,r,a){if(!l3[r]){for(var n="",i={},o=e.length-1,s=0;s<o;++s)n=l2(e[s],n,i);l3[r]={c:l2(e[o],n,i),e:i}}var l=l1({},l3[r].e);return ll(l3[r].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",r,l,l9(l),a)},l8=function(){return[lu,lc,ld,lf,lh,lm,lv,lF,lk,lI,lC,lj,lx,lT,lR,lP,lG,lL,l_,lO,ub,ue,ut]},l4=function(){return[lu,lc,ld,lf,lh,lm,ly,lb,lD,lE,lw,lM,lC,lQ,lW,lx,lU,lH,lN,lJ,lK,lV,lz,lq,lG,lL,lX,l0,uy,ue]},l6=function(){return[uc,ud]},l7=function(){return[um]},ue=function(e){return postMessage(e,[e.buffer])},ut=function(e){return e&&{out:e.size&&new lu(e.size),dictionary:e.dictionary}},ur=function(e,t,r,a,n,i){var o=l5(r,a,n,function(e,t){o.terminate(),i(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},ua=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){t.data.length?(e.push(t.data[0],t.data[1]),postMessage([t.data[0].length])):e.flush()}},un=function(e,t,r,a,n,i,o){var s,l=l5(e,a,n,function(e,r){e?(l.terminate(),t.ondata.call(t,e)):Array.isArray(r)?1==r.length?(t.queuedSize-=r[0],t.ondrain&&t.ondrain(r[0])):(r[1]&&l.terminate(),t.ondata.call(t,e,r[0],r[1])):o(r)});l.postMessage(r),t.queuedSize=0,t.push=function(e,r){t.ondata||l_(5),s&&t.ondata(l_(4,0,1),null,!!r),t.queuedSize+=e.length,l.postMessage([e,s=r],[e.buffer])},t.terminate=function(){l.terminate()},i&&(t.flush=function(){l.postMessage([])})},ui=function(e,t){return e[t]|e[t+1]<<8},uo=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},us=function(e,t){return uo(e,t)+0x100000000*uo(e,t+4)},ul=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},uu=function(e,t){var r=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:2*(9==t.level),e[9]=3,0!=t.mtime&&ul(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),r){e[3]=8;for(var a=0;a<=r.length;++a)e[a+10]=r.charCodeAt(a)}},uc=function(e){(31!=e[0]||139!=e[1]||8!=e[2])&&l_(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=(e[10]|e[11]<<8)+2);for(var a=(t>>3&1)+(t>>4&1);a>0;a-=!e[r++]);return r+(2&t)},ud=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},uf=function(e){return 10+(e.filename?e.filename.length+1:0)},uh=function(e,t){var r=t.level;if(e[0]=120,e[1]=(0==r?0:r<6?1:9==r?3:2)<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var a=l$();a.p(t.dictionary),ul(e,2,a.d())}},um=function(e,t){return((15&e[0])!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&l_(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&l_(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function up(e,t){return"function"==typeof e&&(t=e,e={}),this.ondata=t,e}var ug=function(){function e(e,t){if("function"==typeof e&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new lu(98304),this.o.dictionary){var r=this.o.dictionary.subarray(-32768);this.b.set(r,32768-r.length),this.s.i=32768-r.length}}return e.prototype.p=function(e,t){this.ondata(l0(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||l_(5),this.s.l&&l_(4);var r=e.length+this.s.z;if(r>this.b.length){if(r>2*this.b.length-32768){var a=new lu(-32768&r);a.set(this.b.subarray(0,this.s.z)),this.b=a}var n=this.b.length-this.s.z;this.b.set(e.subarray(0,n),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(n),32768),this.s.z=e.length-n+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=1&t,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},e.prototype.flush=function(){this.ondata||l_(5),this.s.l&&l_(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},e}(),uv=function(e,t){un([l4,function(){return[ua,ug]}],this,up.call(this,e,t),function(e){onmessage=ua(new ug(e.data))},6,1)};function uy(e,t){return l0(e,t||{},0,0)}var uA=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var r=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new lu(32768),this.p=new lu(0),r&&this.o.set(r)}return e.prototype.e=function(e){if(this.ondata||l_(5),this.d&&l_(4),this.p.length){if(e.length){var t=new lu(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,r=lO(this.p,this.s,this.o);this.ondata(lL(r,t,this.s.b),this.d),this.o=lL(r,this.s.b-32768),this.s.b=this.o.length,this.p=lL(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),uF=function(e,t){un([l8,function(){return[ua,uA]}],this,up.call(this,e,t),function(e){onmessage=ua(new uA(e.data))},7,0)};function ub(e,t){return lO(e,{i:2},t&&t.out,t&&t.dictionary)}(function(){function e(e,t){this.c=lZ(),this.l=0,this.v=1,ug.call(this,e,t)}e.prototype.push=function(e,t){this.c.p(e),this.l+=e.length,ug.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var r=l0(e,this.o,this.v&&uf(this.o),t&&8,this.s);this.v&&(uu(r,this.o),this.v=0),t&&(ul(r,r.length-8,this.c.d()),ul(r,r.length-4,this.l)),this.ondata(r,t)},e.prototype.flush=function(){ug.prototype.flush.call(this)}})();var uC=function(){function e(e,t){this.v=1,this.r=0,uA.call(this,e,t)}return e.prototype.push=function(e,t){if(uA.prototype.e.call(this,e),this.r+=e.length,this.v){var r=this.p.subarray(this.v-1),a=r.length>3?uc(r):4;if(a>r.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-r.length);this.p=r.subarray(a),this.v=0}uA.prototype.c.call(this,t),!this.s.f||this.s.l||t||(this.v=lG(this.s.p)+9,this.s={i:0},this.o=new lu(0),this.push(new lu(0),t))},e}(),uB=function(e,t){var r=this;un([l8,l6,function(){return[ua,uA,uC]}],this,up.call(this,e,t),function(e){var t=new uC(e.data);t.onmember=function(e){return postMessage(e)},onmessage=ua(t)},9,0,function(e){return r.onmember&&r.onmember(e)})},uS=(function(){function e(e,t){this.c=l$(),this.v=1,ug.call(this,e,t)}e.prototype.push=function(e,t){this.c.p(e),ug.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var r=l0(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(uh(r,this.o),this.v=0),t&&ul(r,r.length-4,this.c.d()),this.ondata(r,t)},e.prototype.flush=function(){ug.prototype.flush.call(this)}}(),function(){function e(e,t){uA.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(uA.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(um(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&l_(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),uA.prototype.c.call(this,t)},e}()),ux=function(e,t){un([l8,l7,function(){return[ua,uA,uS]}],this,up.call(this,e,t),function(e){onmessage=ua(new uS(e.data))},11,0)},uE=function(){function e(e,t){this.o=up.call(this,e,t)||{},this.G=uC,this.I=uA,this.Z=uS}return e.prototype.i=function(){var e=this;this.s.ondata=function(t,r){e.ondata(t,r)}},e.prototype.push=function(e,t){if(this.ondata||l_(5),this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var r=new lu(this.p.length+e.length);r.set(this.p),r.set(e,this.p.length)}else this.p=e;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):(15&this.p[0])!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,t),this.p=null)}},e}();function uM(e,t){uE.call(this,e,t),this.queuedSize=0,this.G=uB,this.I=uF,this.Z=ux}uM.prototype.i=function(){var e=this;this.s.ondata=function(t,r,a){e.ondata(t,r,a)},this.s.ondrain=function(t){e.queuedSize-=t,e.ondrain&&e.ondrain(t)}},uM.prototype.push=function(e,t){this.queuedSize+=e.length,uE.prototype.push.call(this,e,t)};var uD="undefined"!=typeof TextEncoder&&new TextEncoder,uk="undefined"!=typeof TextDecoder&&new TextDecoder,uw=0;try{uk.decode(lW,{stream:!0}),uw=1}catch(e){}var uI=function(e){for(var t="",r=0;;){var a=e[r++],n=(a>127)+(a>223)+(a>239);if(r+n>e.length)return{s:t,r:lL(e,r-1)};n?3==n?t+=String.fromCharCode(55296|(a=((15&a)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536)>>10,56320|1023&a):1&n?t+=String.fromCharCode((31&a)<<6|63&e[r++]):t+=String.fromCharCode((15&a)<<12|(63&e[r++])<<6|63&e[r++]):t+=String.fromCharCode(a)}};function uT(e,t){if(t){for(var r=new lu(e.length),a=0;a<e.length;++a)r[a]=e.charCodeAt(a);return r}if(uD)return uD.encode(e);for(var n=e.length,i=new lu(e.length+(e.length>>1)),o=0,s=function(e){i[o++]=e},a=0;a<n;++a){if(o+5>i.length){var l=new lu(o+8+(n-a<<1));l.set(i),i=l}var u=e.charCodeAt(a);u<128||t?s(u):(u<2048?s(192|u>>6):(u>55295&&u<57344?(s(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++a))>>18),s(128|u>>12&63)):s(224|u>>12),s(128|u>>6&63)),s(128|63&u))}return lL(i,0,o)}(function(e){this.ondata=e,uw?this.t=new TextDecoder:this.p=lW}).prototype.push=function(e,t){if(this.ondata||l_(5),t=!!t,this.t){this.ondata(this.t.decode(e,{stream:!0}),t),t&&(this.t.decode().length&&l_(8),this.t=null);return}this.p||l_(4);var r=new lu(this.p.length+e.length);r.set(this.p),r.set(e,this.p.length);var a=uI(r),n=a.s,i=a.r;t?(i.length&&l_(8),this.p=null):this.p=i,this.ondata(n,t)},(function(e){this.ondata=e}).prototype.push=function(e,t){this.ondata||l_(5),this.d&&l_(4),this.ondata(uT(e),this.d=t||!1)};var uR=function(e){return 1==e?3:e<6?2:+(9==e)},uP=function(e,t){for(;1!=ui(e,t);t+=4+ui(e,t+2));return[us(e,t+12),us(e,t+4),us(e,t+20)]},uG=function(e){var t=0;if(e)for(var r in e){var a=e[r].length;a>65535&&l_(9),t+=a+4}return t},uL=function(e,t,r,a,n,i,o,s){var l=a.length,u=r.extra,c=s&&s.length,d=uG(u);ul(e,t,null!=o?0x2014b50:0x4034b50),t+=4,null!=o&&(e[t++]=20,e[t++]=r.os),e[t]=20,t+=2,e[t++]=r.flag<<1|(i<0&&8),e[t++]=n&&8,e[t++]=255&r.compression,e[t++]=r.compression>>8;var f=new Date(null==r.mtime?Date.now():r.mtime),h=f.getFullYear()-1980;if((h<0||h>119)&&l_(10),ul(e,t,h<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,-1!=i&&(ul(e,t,r.crc),ul(e,t+4,i<0?-i-2:i),ul(e,t+8,r.size)),ul(e,t+12,l),ul(e,t+14,d),t+=16,null!=o&&(ul(e,t,c),ul(e,t+6,r.attrs),ul(e,t+10,o),t+=14),e.set(a,t),t+=l,d)for(var m in u){var p=u[m],g=p.length;ul(e,t,+m),ul(e,t+2,g),e.set(p,t+4),t+=4+g}return c&&(e.set(s,t),t+=c),t},uj=function(e,t,r,a,n){ul(e,t,0x6054b50),ul(e,t+8,r),ul(e,t+10,r),ul(e,t+12,a),ul(e,t+16,n)},u_=function(){function e(e){this.filename=e,this.c=lZ(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){this.ondata||l_(5),this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();function uO(e,t){var r=this;t||(t={}),u_.call(this,e),this.d=new ug(t,function(e,t){r.ondata(null,e,t)}),this.compression=8,this.flag=uR(t.level)}function uU(e,t){var r=this;t||(t={}),u_.call(this,e),this.d=new uv(t,function(e,t,a){r.ondata(e,t,a)}),this.compression=8,this.flag=uR(t.level),this.terminate=this.d.terminate}function uH(e){this.ondata=e,this.u=[],this.d=1}uO.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},uO.prototype.push=function(e,t){u_.prototype.push.call(this,e,t)},uU.prototype.process=function(e,t){this.d.push(e,t)},uU.prototype.push=function(e,t){u_.prototype.push.call(this,e,t)},uH.prototype.add=function(e){var t=this;if(this.ondata||l_(5),2&this.d)this.ondata(l_(4+(1&this.d)*8,0,1),null,!1);else{var r=uT(e.filename),a=r.length,n=e.comment,i=n&&uT(n),o=a!=e.filename.length||i&&n.length!=i.length,s=a+uG(e.extra)+30;a>65535&&this.ondata(l_(11,0,1),null,!1);var l=new lu(s);uL(l,0,e,r,o,-1);var u=[l],c=function(){for(var e=0,r=u;e<r.length;e++){var a=r[e];t.ondata(null,a,!1)}u=[]},d=this.d;this.d=0;var f=this.u.length,h=l1(e,{f:r,u:o,o:i,t:function(){e.terminate&&e.terminate()},r:function(){if(c(),d){var e=t.u[f+1];e?e.r():t.d=1}d=1}}),m=0;e.ondata=function(r,a,n){if(r)t.ondata(r,a,n),t.terminate();else if(m+=a.length,u.push(a),n){var i=new lu(16);ul(i,0,0x8074b50),ul(i,4,e.crc),ul(i,8,m),ul(i,12,e.size),u.push(i),h.c=m,h.b=s+m+16,h.crc=e.crc,h.size=e.size,d&&h.r(),d=1}else d&&c()},this.u.push(h)}},uH.prototype.end=function(){var e=this;2&this.d?this.ondata(l_(4+(1&this.d)*8,0,1),null,!0):(this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3)},uH.prototype.e=function(){for(var e=0,t=0,r=0,a=0,n=this.u;a<n.length;a++){var i=n[a];r+=46+i.f.length+uG(i.extra)+(i.o?i.o.length:0)}for(var o=new lu(r+22),s=0,l=this.u;s<l.length;s++){var i=l[s];uL(o,e,i,i.f,i.u,-i.c-2,t,i.o),e+=46+i.f.length+uG(i.extra)+(i.o?i.o.length:0),t+=i.b}uj(o,e,this.u.length,r,t),this.ondata(null,o,!0),this.d=2},uH.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++)t[e].t();this.d=2};var uN=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}();function uJ(){var e=this;this.i=new uA(function(t,r){e.ondata(null,t,r)})}function uK(e,t){var r=this;t<32e4?this.i=new uA(function(e,t){r.ondata(null,e,t)}):(this.i=new uF(function(e,t,a){r.ondata(e,t,a)}),this.terminate=this.i.terminate)}function uV(e){this.onfile=e,this.k=[],this.o={0:uN},this.p=lW}uJ.prototype.push=function(e,t){try{this.i.push(e,t)}catch(e){this.ondata(e,null,t)}},uJ.compression=8,uK.prototype.push=function(e,t){this.i.terminate&&(e=lL(e,0)),this.i.push(e,t)},uK.compression=8,uV.prototype.push=function(e,t){var r=this;if(this.onfile||l_(5),this.p||l_(4),this.c>0){var a=Math.min(this.c,e.length),n=e.subarray(0,a);if(this.c-=a,this.d?this.d.push(n,!this.c):this.k[0].push(n),(e=e.subarray(a)).length)return this.push(e,t)}else{var i=0,o=0,s=void 0,l=void 0;this.p.length?e.length?((l=new lu(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var u=l.length,c=this.c,d=c&&this.d,f=this;o<u-4&&"break"!==function(){var e=uo(l,o);if(0x4034b50==e){i=1,s=o,f.d=null,f.c=0;var t=ui(l,o+6),a=ui(l,o+8),n=8&t,d=ui(l,o+26),h=ui(l,o+28);if(u>o+30+d+h){var m,p,g=[];f.k.unshift(g),i=2;var v=uo(l,o+18),y=uo(l,o+22),A=function(e,t){if(t){for(var r="",a=0;a<e.length;a+=16384)r+=String.fromCharCode.apply(null,e.subarray(a,a+16384));return r}if(uk)return uk.decode(e);var n=uI(e),i=n.s,r=n.r;return r.length&&l_(8),i}(l.subarray(o+30,o+=30+d),!(2048&t));0xffffffff==v?(v=(m=n?[-2]:uP(l,o))[0],y=m[1]):n&&(v=-1),o+=h,f.c=v;var F={name:A,compression:a,start:function(){if(F.ondata||l_(5),v){var e=r.o[a];e||F.ondata(l_(14,"unknown compression type "+a,1),null,!1),(p=v<0?new e(A):new e(A,v,y)).ondata=function(e,t,r){F.ondata(e,t,r)};for(var t=0;t<g.length;t++){var n=g[t];p.push(n,!1)}r.k[0]==g&&r.c?r.d=p:p.push(lW,!0)}else F.ondata(null,lW,!0)},terminate:function(){p&&p.terminate&&p.terminate()}};v>=0&&(F.size=v,F.originalSize=y),f.onfile(F)}return"break"}if(c){if(0x8074b50==e)return s=o+=12+(-2==c&&8),i=3,f.c=0,"break";else if(0x2014b50==e)return s=o-=4,i=3,f.c=0,"break"}}();++o);if(this.p=lW,c<0){var h=i?l.subarray(0,s-12-(-2==c&&8)-(0x8074b50==uo(l,s-16)&&4)):l.subarray(0,o);d?d.push(h,!!i):this.k[+(2==i)].push(h)}if(2&i)return this.push(l.subarray(o),t);this.p=l.subarray(o)}t&&(this.c&&l_(13),this.p=null)},uV.prototype.register=function(e){this.o[e.compression]=e},"function"==typeof queueMicrotask&&queueMicrotask;var uz=e.i(48450);let uq=[0,0,0,0,0,0,0,0,0,329,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2809,68,0,27,0,58,3,62,4,7,0,0,15,65,554,3,394,404,189,117,30,51,27,15,34,32,80,1,142,3,142,39,0,144,125,44,122,275,70,135,61,127,8,12,113,246,122,36,185,1,149,309,335,12,11,14,54,151,0,0,2,0,0,211,0,2090,344,736,993,2872,701,605,646,1552,328,305,1240,735,1533,1713,562,3,1775,1149,1469,979,407,553,59,279,31,0,0,0,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];function uQ(e){return e.node?e.node.pop:e.leaf.pop}let uW=new class{nodes=[];leaves=[];tablesBuilt=!1;buildTables(){if(this.tablesBuilt)return;this.tablesBuilt=!0,this.leaves=[];for(let t=0;t<256;t++){var e;this.leaves.push({pop:uq[t]+ +((e=t)>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)+1,symbol:t,numBits:0,code:0})}this.nodes=[{pop:0,index0:0,index1:0}];let t=256,r=[];for(let e=0;e<256;e++)r.push({node:null,leaf:this.leaves[e]});for(;1!==t;){let e=0xfffffffe,a=0xffffffff,n=-1,i=-1;for(let o=0;o<t;o++){let t=uQ(r[o]);t<e?(a=e,i=n,e=t,n=o):t<a&&(a=t,i=o)}let o={pop:uQ(r[n])+uQ(r[i]),index0:this.determineIndex(r[n]),index1:this.determineIndex(r[i])};this.nodes.push(o);let s=n<i?n:i,l=n>i?n:i;r[s]={node:o,leaf:null},l!==t-1&&(r[l]=r[t-1]),t--}this.nodes[0]=r[0].node,this.generateCodes(0,0,0)}determineIndex(e){return null!==e.leaf?-(this.leaves.indexOf(e.leaf)+1):this.nodes.indexOf(e.node)}generateCodes(e,t,r){if(t<0){let a=this.leaves[-(t+1)];a.code=e,a.numBits=r}else{let a=this.nodes[t];this.generateCodes(e,a.index0,r+1),this.generateCodes(e|1<<r,a.index1,r+1)}}readHuffBuffer(e){if(this.tablesBuilt||this.buildTables(),e.readFlag()){let t=e.readInt(8),r=[];for(let a=0;a<t;a++){let t=0;for(;;)if(t>=0)t=e.readFlag()?this.nodes[t].index1:this.nodes[t].index0;else{r.push(this.leaves[-(t+1)].symbol);break}}return String.fromCharCode(...r)}{let t=e.readInt(8);return String.fromCharCode(...e.readBytes(t))}}};class uX{data;bitNum;maxReadBitNum;error;stringBuffer=null;constructor(e,t=0){this.data=e,this.bitNum=t,this.maxReadBitNum=e.length<<3,this.error=!1}getCurPos(){return this.bitNum}setCurPos(e){this.bitNum=e}getBytePosition(){return this.bitNum+7>>3}isError(){return this.error}isFull(){return this.bitNum>this.maxReadBitNum}getRemainingBits(){return this.maxReadBitNum-this.bitNum}getMaxPos(){return this.maxReadBitNum}readFlag(){if(this.bitNum>=this.maxReadBitNum)return this.error=!0,!1;let e=1<<(7&this.bitNum),t=(this.data[this.bitNum>>3]&e)!=0;return this.bitNum++,t}readInt(e){if(0===e)return 0;if(this.bitNum+e>this.maxReadBitNum)return this.error=!0,0;let t=this.bitNum>>3,r=7&this.bitNum;if(this.bitNum+=e,e+r<=32){let a=0,n=e+r+7>>3;for(let e=0;e<n&&t+e<this.data.length;e++)a|=this.data[t+e]<<8*e;return(a>>>=r,32===e)?a>>>0:a&(1<<e)-1}let a=0,n=e+r+7>>3;for(let e=0;e<n&&t+e<this.data.length;e++)a+=this.data[t+e]*2**(8*e);return(a=Math.floor(a/2**r),32===e)?a>>>0:a&(1<<e)-1}readSignedInt(e){return this.readFlag()?-this.readInt(e-1):this.readInt(e-1)}readFloat(e){return this.readInt(e)/((1<<e)-1)}readSignedFloat(e){return 2*this.readInt(e)/((1<<e)-1)-1}readRangedU32(e,t){let r=Math.ceil(Math.log2(t-e+1))||1;return this.readInt(r)+e}readBitsBuffer(e){if(0===e)return new Uint8Array(0);let t=e+7>>3,r=new Uint8Array(t),a=this.bitNum>>3,n=7&this.bitNum,i=8-n;if(0===n)r.set(this.data.subarray(a,a+t));else{let e=this.data[a];for(let o=0;o<t;o++){let t=a+o+1<this.data.length?this.data[a+o+1]:0;r[o]=(e>>n|t<<i)&255,e=t}}let o=7&e;return 0!==o&&(r[t-1]&=(1<<o)-1),this.bitNum+=e,r}readBytes(e){return Array.from(this.readBitsBuffer(8*e))}readU8(){return this.readInt(8)}readU16(){return this.readInt(16)}readU32(){return this.readInt(32)}readS32(){return 0|this.readU32()}static f32Buf=new ArrayBuffer(4);static f32View=new DataView(uX.f32Buf);static f32U8=new Uint8Array(uX.f32Buf);readF32(){if(this.bitNum+32>this.maxReadBitNum)return this.error=!0,0;let e=this.bitNum>>3,t=7&this.bitNum,r=uX.f32U8;if(0===t)r[0]=this.data[e],r[1]=this.data[e+1],r[2]=this.data[e+2],r[3]=this.data[e+3];else{let a=8-t;for(let n=0;n<4;n++){let i=this.data[e+n],o=e+n+1<this.data.length?this.data[e+n+1]:0;r[n]=(i>>t|o<<a)&255}}return this.bitNum+=32,uX.f32View.getFloat32(0,!0)}readBool(){return 0!==this.readU8()}readNormalVector(e){let t=this.readSignedFloat(e+1)*Math.PI,r=this.readSignedFloat(e)*(Math.PI/2);return{x:Math.sin(t)*Math.cos(r),y:Math.cos(t)*Math.cos(r),z:Math.sin(r)}}readAffineTransform(){let e={x:this.readF32(),y:this.readF32(),z:this.readF32()},t=this.readF32(),r=this.readF32(),a=this.readF32(),n=Math.sqrt(Math.max(0,1-(t*t+r*r+a*a)));return this.readFlag()&&(n=-n),{position:e,rotation:{x:t,y:r,z:a,w:n}}}readString(){if(null!==this.stringBuffer&&this.readFlag()){let e=this.readInt(8),t=uW.readHuffBuffer(this),r=this.stringBuffer.substring(0,e)+t;return this.stringBuffer=r,r}let e=uW.readHuffBuffer(this);return null!==this.stringBuffer&&(this.stringBuffer=e),e}setStringBuffer(e){this.stringBuffer=e?"":null}skipBits(e){this.bitNum+=e}readPoint3F(){return{x:this.readF32(),y:this.readF32(),z:this.readF32()}}readCompressedPoint(e,t=.01){let r=this.readInt(2);if(3===r)return{x:this.readF32(),y:this.readF32(),z:this.readF32()};let a=[16,18,20][r],n=this.readSignedInt(a),i=this.readSignedInt(a),o=this.readSignedInt(a);return{x:e.x+n*t,y:e.y+i*t,z:e.z+o*t}}readMatrixF(){let e=Array(16);for(let t=0;t<16;t++)e[t]=this.readF32();return{elements:e,position:{x:e[12],y:e[13],z:e[14]}}}unpackNetString(){switch(this.readInt(2)){case 0:default:return"";case 1:return this.readString();case 2:{let e=this.readInt(10);return`\x01${e}`}case 3:{let e,t=this.readFlag();return e=this.readFlag()?this.readInt(7):this.readFlag()?this.readInt(15):this.readInt(31),t&&(e=-e),String(e)}}}savePos(){return this.bitNum}restorePos(e){this.bitNum=e,this.error=!1}getBuffer(){return this.data}}let uY=["AudioDescription","AudioEnvironment","AudioProfile","AudioSampleEnvironment","BombProjectileData","CameraData","CannedChatItem","CommanderIconData","DebrisData","DecalData","ELFProjectileData","EffectProfile","EnergyProjectileData","ExplosionData","FireballAtmosphereData","FlareProjectileData","FlyingVehicleData","ForceFieldBareData","GameBaseData","GrenadeProjectileData","HoverVehicleData","ItemData","JetEffectData","LightningData","LinearFlareProjectileData","LinearProjectileData","MissionMarkerData","ParticleData","ParticleEmissionDummyData","ParticleEmitterData","PlayerData","PrecipitationData","ProjectileData","RepairProjectileData","RunningLightData","SeekerProjectileData","SensorData","ShapeBaseData","ShapeBaseImageData","ShockLanceProjectileData","ShockwaveData","SimDataBlock","SniperProjectileData","SplashData","StaticShapeData","StationFXPersonalData","StationFXVehicleData","TSShapeConstructor","TargetProjectileData","TracerProjectileData","TriggerData","TurretData","TurretImageData","WheeledVehicleData"],uZ=["AIObjective","AudioEmitter","BeaconObject","BombProjectile","Camera","Debris","ELFProjectile","EnergyProjectile","FireballAtmosphere","FlareProjectile","FlyingVehicle","ForceFieldBare","GameBase","GrenadeProjectile","HoverVehicle","InteriorInstance","Item","Lightning","LinearFlareProjectile","LinearProjectile","Marker","MissionArea","MissionMarker","ParticleEmissionDummy","PhysicalZone","Player","Precipitation","Projectile","RepairProjectile","ScopeAlwaysShape","SeekerProjectile","ShapeBase","ShockLanceProjectile","Shockwave","SimpleNetObject","Sky","SniperProjectile","SpawnSphere","Splash","StaticShape","StationFXPersonal","StationFXVehicle","Sun","TSStatic","TargetProjectile","TerrainBlock","TracerProjectile","Trigger","Turret","VehicleBlocker","WaterBlock","WayPoint","WheeledVehicle"],u$=["CRCChallengeEvent","CRCChallengeResponseEvent","FogChallengeEvent","GhostAlwaysObjectEvent","GhostingMessageEvent","GravityEvent","LightningStrikeEvent","NetStringEvent","PathManagerEvent","RemoteCommandEvent","RemoveClientTargetTypeEvent","ResetClientTargetsEvent","SensorGroupColorEvent","SetMissionCRCEvent","SetObjectActiveImageEvent","SetSensorGroupEvent","SetServerTargetEvent","Sim2DAudioEvent","Sim3DAudioEvent","SimDataBlockEvent","SimTargetAudioEvent","SimVoiceStreamEvent","SimpleMessageEvent","TargetFreeEvent","TargetInfoEvent","TargetToEvent"],u0=(0,uz.default)("t2-demo-parser:ghosts");class u1{registry;ghostTracker;compressionPoint={x:0,y:0,z:0};controlParserByGhostIndex=new Map;dataBlockDataMap;lastSeqRecvdAtSend=Array(32).fill(0);lastSeqRecvd=0;highestAckedSeq=0;lastSendSeq=0;recvAckMask=0;connectSequence=0;lastRecvAckAck=0;connectionEstablished=!1;nextRecvEventSeq=0;pendingGuaranteedEvents=[];controlObjectParsed=0;controlObjectFailed=0;eventsParsed=0;eventsFailed=0;ghostCreatesParsed=0;ghostUpdatesParsed=0;ghostDeletes=0;ghostsFailed=0;ghostsTrackerDiverged=0;packetsParsed=0;protocolRejected=0;protocolNoDispatch=0;constructor(e,t,r){this.registry=e,this.ghostTracker=t,this.dataBlockDataMap=r?.dataBlockDataMap,r?.connectionProtocolState&&this.setConnectionProtocolState(r.connectionProtocolState),"number"==typeof r?.nextRecvEventSeq&&(this.nextRecvEventSeq=r.nextRecvEventSeq>>>0)}getCompressionPoint(){return this.compressionPoint}getConnectionContext(){let e=this.dataBlockDataMap;return{compressionPoint:this.compressionPoint,ghostTracker:this.ghostTracker,getDataBlockParser:e=>this.registry.getDataBlockParser(e),getDataBlockData:e?t=>e.get(t):void 0,getGhostParser:e=>this.registry.getGhostParser(e)}}setNextRecvEventSeq(e){this.nextRecvEventSeq=e>>>0}setConnectionProtocolState(e){for(this.lastSeqRecvdAtSend=e.lastSeqRecvdAtSend.slice(0,32);this.lastSeqRecvdAtSend.length<32;)this.lastSeqRecvdAtSend.push(0);this.lastSeqRecvd=e.lastSeqRecvd>>>0,this.highestAckedSeq=e.highestAckedSeq>>>0,this.lastSendSeq=e.lastSendSeq>>>0,this.recvAckMask=e.ackMask>>>0,this.connectSequence=e.connectSequence>>>0,this.lastRecvAckAck=e.lastRecvAckAck>>>0,this.connectionEstablished=e.connectionEstablished}onSendPacketTrigger(){this.lastSendSeq=this.lastSendSeq+1>>>0,this.lastSeqRecvdAtSend[31&this.lastSendSeq]=this.lastSeqRecvd>>>0}applyProtocolHeader(e){if(e.connectSeqBit!==(1&this.connectSequence)||e.ackByteCount>4||e.packetType>2)return{accepted:!1,dispatchData:!1};let t=(e.seqNumber|0xfffffe00&this.lastSeqRecvd)>>>0;if(t<this.lastSeqRecvd&&(t=t+512>>>0),this.lastSeqRecvd+31<t)return{accepted:!1,dispatchData:!1};let r=(e.highestAck|0xfffffe00&this.highestAckedSeq)>>>0;if(r<this.highestAckedSeq&&(r=r+512>>>0),this.lastSendSeq<r)return{accepted:!1,dispatchData:!1};let a=t-this.lastSeqRecvd&31;this.recvAckMask=this.recvAckMask<<a>>>0,0===e.packetType&&(this.recvAckMask=(1|this.recvAckMask)>>>0);for(let t=this.highestAckedSeq+1;t<=r;t++)(e.ackMask&1<<(r-t&31))!=0&&(this.lastRecvAckAck=this.lastSeqRecvdAtSend[31&t]>>>0);t-this.lastRecvAckAck>32&&(this.lastRecvAckAck=t-32),this.highestAckedSeq=r;let n=this.lastSeqRecvd!==t&&0===e.packetType;return this.lastSeqRecvd=t,{accepted:!0,dispatchData:n}}parsePacket(e){let t=new uX(e),r=this.readDnetHeader(t),a=this.applyProtocolHeader(r);if(this.packetsParsed++,!a.accepted)return this.protocolRejected++,{dnetHeader:r,rateInfo:{},gameState:this.emptyGameState(),events:[],ghosts:[]};if(!a.dispatchData)return this.protocolNoDispatch++,{dnetHeader:r,rateInfo:{},gameState:this.emptyGameState(),events:[],ghosts:[]};let n=this.readRateInfo(t);t.setStringBuffer(!0);let i=this.readGameState(t),o=void 0===i.controlObjectDataStart||void 0!==i.controlObjectData,s=o?this.readEvents(t):[],l=s[s.length-1],u=!l||l.dataBitsEnd!==l.dataBitsStart,c=o&&u?t.getCurPos():void 0,d=o&&u?this.readGhosts(t,r.seqNumber):[];return t.setStringBuffer(!1),{dnetHeader:r,rateInfo:n,gameState:i,events:s,ghosts:d,ghostSectionStart:c}}readDnetHeader(e){let t=e.readFlag(),r=e.readInt(1),a=e.readInt(9),n=e.readInt(9),i=e.readInt(2),o=e.readInt(3),s=o>0?e.readInt(8*o):0;return{gameFlag:t,connectSeqBit:r,seqNumber:a,highestAck:n,packetType:i,ackByteCount:o,ackMask:s}}readRateInfo(e){let t={};return e.readFlag()&&(t.updateDelay=e.readInt(10),t.packetSize=e.readInt(10)),e.readFlag()&&(t.maxUpdateDelay=e.readInt(10),t.maxPacketSize=e.readInt(10)),t}readGameState(e){let t,r,a,n,i,o,s,l,u,c,d,f,h,m,p,g=e.readInt(32);e.readFlag()&&(e.readFlag()&&(t=e.readFloat(7)),e.readFlag()&&(r=1.5*e.readFloat(7))),e.readFlag()&&(a=e.readFlag(),n=e.readFlag()),e.readFlag()&&((i=e.readFlag())&&(o={x:e.readF32(),y:e.readF32(),z:e.readF32()}),1===(s=e.readRangedU32(0,2))?e.readFlag()&&(l=e.readRangedU32(0,1023)):2===s&&(u={x:e.readF32(),y:e.readF32(),z:e.readF32()}));let v=e.readFlag(),y=e.readFlag();if(e.readFlag())if(e.readFlag()){let p=e.readInt(10);c=p,d=e.getCurPos();let A=e.savePos(),F=this.ghostTracker.getGhost(p),b=F?this.registry.getGhostParser(F.classId):void 0,C=this.controlParserByGhostIndex.get(p),B=this.registry.getGhostParser(25),S=this.registry.getGhostParser(4),x=[],E=new Set,M=e=>{!e?.readPacketData||E.has(e.name)||(E.add(e.name),x.push(e))};M(b),M(C),M(B),M(S);let D=!1;for(let t of x){e.restorePos(A);try{let r=this.getConnectionContext(),a=t.readPacketData(e,r);if(e.getCurPos()-d<=0||e.isError())continue;h=a,f=e.getCurPos(),this.controlParserByGhostIndex.set(p,t),r.compressionPoint!==this.compressionPoint&&(this.compressionPoint=r.compressionPoint,m=this.compressionPoint),this.controlObjectParsed++,D=!0;break}catch{}}if(!D)return e.restorePos(A),f=d,this.controlObjectFailed++,{lastMoveAck:g,damageFlash:t,whiteOut:r,selfLocked:a,selfHomed:n,seekerTracking:i,seekerTrackingPos:o,seekerMode:s,seekerObjectGhostIndex:l,targetPos:u,pinged:v,jammed:y,controlObjectGhostIndex:c,controlObjectDataStart:d,controlObjectDataEnd:f,controlObjectData:h,targetVisibility:[]}}else m={x:e.readF32(),y:e.readF32(),z:e.readF32()},this.compressionPoint=m;let A=[];for(;e.readFlag();)A.push({index:e.readInt(4),mask:e.readInt(32)});return e.readFlag()&&(p=e.readInt(8)),{lastMoveAck:g,damageFlash:t,whiteOut:r,selfLocked:a,selfHomed:n,seekerTracking:i,seekerTrackingPos:o,seekerMode:s,seekerObjectGhostIndex:l,targetPos:u,pinged:v,jammed:y,controlObjectGhostIndex:c,controlObjectDataStart:d,controlObjectDataEnd:f,controlObjectData:h,compressionPoint:m,targetVisibility:A.length>0?A:void 0,cameraFov:p}}readEvents(e){let t=[],r=!0,a=-2;for(;;){let n,i,o,s=e.readFlag();if(r&&!s){if(r=!1,!e.readFlag()){this.dispatchGuaranteedEvents(t);break}}else if(r||s){if(!s)break}else{this.dispatchGuaranteedEvents(t);break}!r&&(a=n=e.readFlag()?a+1&127:e.readInt(7),(i=n|0xffffff80&this.nextRecvEventSeq)<this.nextRecvEventSeq&&(i+=128));let l=e.readInt(6)+255,u=e.getCurPos(),c=this.registry.getEventParser(l);if(c)try{let t=this.getConnectionContext();o=c.unpack(e,t),this.eventsParsed++}catch{this.eventsFailed++,t.push({classId:l,guaranteed:!r,sequenceNumber:n,absoluteSequenceNumber:i,dataBitsStart:u,dataBitsEnd:u});break}else{t.push({classId:l,guaranteed:!r,sequenceNumber:n,absoluteSequenceNumber:i,dataBitsStart:u,dataBitsEnd:u});break}let d={classId:l,guaranteed:!r,sequenceNumber:n,absoluteSequenceNumber:i,dataBitsStart:u,dataBitsEnd:e.getCurPos(),parsedData:o};r?(t.push(d),o&&this.applyEventSideEffects(o)):void 0!==i&&this.enqueueGuaranteedEvent(i,d)}return t}enqueueGuaranteedEvent(e,t){let r=0;for(;r<this.pendingGuaranteedEvents.length&&this.pendingGuaranteedEvents[r].absoluteSequenceNumber<e;)r++;this.pendingGuaranteedEvents.splice(r,0,{absoluteSequenceNumber:e,event:t})}dispatchGuaranteedEvents(e){for(;this.pendingGuaranteedEvents.length>0&&this.pendingGuaranteedEvents[0].absoluteSequenceNumber===this.nextRecvEventSeq;){let t=this.pendingGuaranteedEvents.shift();if(!t)break;this.nextRecvEventSeq=this.nextRecvEventSeq+1>>>0,e.push(t.event),t.event.parsedData&&this.applyEventSideEffects(t.event.parsedData)}}applyEventSideEffects(e){let t=e.type;if("GhostingMessageEvent"===t){let t=e.message;"number"==typeof t&&2===t&&this.ghostTracker.clear();return}if("GhostAlwaysObjectEvent"===t){let t=e.ghostIndex,r=e.classId;if("number"==typeof t&&"number"==typeof r){let e=this.registry.getGhostParser(r);this.ghostTracker.createGhost(t,r,e?.name??`unknown_${r}`)}}"SimDataBlockEvent"===t&&this.dataBlockDataMap&&e.dataBlockData&&"number"==typeof e.objectId&&this.dataBlockDataMap.set(e.objectId,e.dataBlockData)}readGhosts(e,t){let r=[];if(!e.readFlag())return r;let a=e.readInt(3)+3;for(;e.readFlag();){let n;if(e.isError())break;let i=e.readInt(a);if(e.isError())break;if(e.readFlag()){this.ghostTracker.deleteGhost(i),this.ghostDeletes++,r.push({index:i,type:"delete",updateBitsStart:e.getCurPos(),updateBitsEnd:e.getCurPos()});continue}let o=!this.ghostTracker.hasGhost(i);n=o?e.readInt(7)+0:this.ghostTracker.getGhost(i)?.classId;let s=e.getCurPos(),l=void 0!==n?this.registry.getGhostParser(n):void 0;if(o&&!l){this.ghostsTrackerDiverged++,u0("DIVERGED pkt=%d seq=%d idx=%d classId=%d bit=%d/%d trackerSize=%d (server sent UPDATE for ghost not in our tracker; 7-bit classId is actually update data)",this.packetsParsed,t,i,n,s,e.getMaxPos(),this.ghostTracker.size()),r.push({index:i,type:"create",classId:n,updateBitsStart:s,updateBitsEnd:s});break}let u=!1;if(l)try{let t=this.getConnectionContext();t.currentGhostIndex=i;let a=l.unpackUpdate(e,o,t),c=e.getCurPos();o&&void 0!==n?(this.ghostTracker.createGhost(i,n,l.name),this.ghostCreatesParsed++):this.ghostUpdatesParsed++,r.push({index:i,type:o?"create":"update",classId:n,updateBitsStart:s,updateBitsEnd:c,parsedData:a}),u=!0}catch(c){this.ghostsFailed++;let a=o?"create":"update",u=c instanceof Error?c.message:String(c);u0("FAIL pkt=%d seq=%d #%d idx=%d op=%s classId=%d parser=%s bit=%d/%d trackerSize=%d err=%s",this.packetsParsed,t,r.length,i,a,n,l.name,s,e.getMaxPos(),this.ghostTracker.size(),u)}if(!u){u0("STOP pkt=%d seq=%d idx=%d op=%s classId=%d parser=%s bit=%d/%d",this.packetsParsed,t,i,o?"create":"update",n,l?.name??"NONE",s,e.getMaxPos()),r.push({index:i,type:o?"create":"update",classId:n,updateBitsStart:s,updateBitsEnd:s});break}}return r}emptyGameState(){return{lastMoveAck:0,pinged:!1,jammed:!1}}}class u2{eventParsers=new Map;ghostParsers=new Map;dataBlockParsers=new Map;eventCatalog=new Map;ghostCatalog=new Map;dataBlockCatalog=new Map;catalogEvent(e){this.eventCatalog.set(e.name,e)}catalogGhost(e){this.ghostCatalog.set(e.name,e)}catalogDataBlock(e){this.dataBlockCatalog.set(e.name,e)}bindDeterministicDataBlocks(e,t){let r=0,a=[];for(let n=0;n<e.length;n++){let i=e[n],o=this.dataBlockCatalog.get(i);o?(this.dataBlockParsers.set(t+n,o),r++):a.push(i)}return{bound:r,missing:a}}bindDeterministicEvents(e,t){let r=0,a=[];for(let n=0;n<e.length;n++){let i=e[n],o=this.eventCatalog.get(i);o?(this.eventParsers.set(t+n,o),r++):a.push(i)}return{bound:r,missing:a}}bindDeterministicGhosts(e,t){let r=0,a=[];for(let n=0;n<e.length;n++){let i=e[n],o=this.ghostCatalog.get(i);o?(this.ghostParsers.set(t+n,o),r++):a.push(i)}return{bound:r,missing:a}}getEventParser(e){return this.eventParsers.get(e)}getGhostParser(e){return this.ghostParsers.get(e)}getDataBlockParser(e){return this.dataBlockParsers.get(e)}getGhostCatalog(){return this.ghostCatalog}getEventBindings(){let e=new Map;for(let[t,r]of this.eventParsers)e.set(t,r.name);return e}getGhostBindings(){let e=new Map;for(let[t,r]of this.ghostParsers)e.set(t,r.name);return e}}class u3{ghosts=new Map;getGhost(e){return this.ghosts.get(e)}hasGhost(e){return this.ghosts.has(e)}createGhost(e,t,r){let a={classId:t,className:r,state:{}};return this.ghosts.set(e,a),a}deleteGhost(e){this.ghosts.delete(e)}getAllGhosts(){return this.ghosts}size(){return this.ghosts.size}clear(){this.ghosts.clear()}}function u9(e){let t=e.readFlag()?e.readInt(16):0,r=e.readFlag()?e.readInt(16):0,a=e.readFlag()?e.readInt(16):0,n=e.readInt(6),i=e.readInt(6),o=e.readInt(6),s=e.readFlag(),l=[];for(let t=0;t<6;t++)l.push(e.readFlag());return{pyaw:t,ppitch:r,proll:a,px:n,py:i,pz:o,freeLook:s,trigger:l}}function u5(e){return e.readInt(11)}function u8(e,t,r){let a={};return e.readFlag()&&(a.dataBlockId=u5(e)),e.readFlag()&&(a.targetId=e.readFlag()?e.readInt(9):-1),a}function u4(e,t,r){let a=u8(e,t,r);if(!e.readFlag())return a;if(e.readFlag()&&(a.damageLevel=e.readFloat(6),a.damageState=e.readInt(2),a.blowApart=e.readFlag(),a.damageDir=e.readNormalVector(8)),e.readFlag()){let t=[];for(let r=0;r<4;r++)if(e.readFlag()){let a=e.readFlag(),n={index:r,playing:a};a&&(n.profileId=u5(e)),t.push(n)}t.length>0&&(a.sounds=t)}if(e.readFlag()){let t=[];for(let r=0;r<4;r++)e.readFlag()&&t.push({index:r,sequence:e.readInt(5),state:e.readInt(2),forward:e.readFlag(),atEnd:e.readFlag()});t.length>0&&(a.threads=t)}let n=!1;if(e.readFlag()){let r=[];for(let a=0;a<8;a++)if(e.readFlag()){let i={index:a};e.readFlag()?i.dataBlockId=u5(e):i.dataBlockId=0,e.readFlag()&&(e.readFlag()?i.skinTagIndex=e.readInt(10):i.skinName=e.readString(),n=!0),i.wet=e.readFlag(),i.ammo=e.readFlag(),i.loaded=e.readFlag(),i.target=e.readFlag(),i.triggerDown=e.readFlag(),i.fireCount=e.readInt(3),t&&(i.imageExtraFlag=e.readFlag()),r.push(i)}r.length>0&&(a.images=r)}if(e.readFlag()){if(e.readFlag()){a.stateAEnabled=e.readFlag(),a.stateB=e.readFlag();let t=e.readFlag();a.hasInvulnerability=t,t?(a.invulnerabilityVisual=e.readFlag(),a.invulnerabilityTicks=e.readU32()):a.binaryCloak=e.readFlag()}if(e.readFlag())if(e.readFlag()){let t=e.readFlag();a.stateBMode=t,t?a.energyPackOn=!0:a.energyPackOn=!1}else a.shieldNormal=e.readNormalVector(8),a.energyPercent=e.readFloat(5);e.readFlag()&&(a.stateValue1=e.readU32(),a.stateValue2=e.readU32())}return n&&(a.imageSkinDirty=!0),e.readFlag()&&(e.readFlag()?(a.mountObject=e.readInt(10),a.mountNode=e.readInt(5)):a.mountObject=-1),a}function u6(e,t,r){let a=u4(e,t,r);if(e.readFlag()&&(a.impactSound=e.readInt(3)),e.readFlag()&&(a.action=e.readInt(8),a.actionHoldAtEnd=e.readFlag(),a.actionAtEnd=e.readFlag(),a.actionFirstPerson=e.readFlag(),!a.actionAtEnd&&e.readFlag()&&(a.actionAnimPos=e.readSignedFloat(6))),e.readFlag()&&(a.armAction=e.readInt(8)),e.readFlag())return a;if(e.readFlag()){if(a.actionState=e.readInt(3),e.readFlag()&&(a.recoverTicks=e.readInt(7)),a.moveFlag0=e.readFlag(),a.moveFlag1=e.readFlag(),a.position=e.readCompressedPoint(r.compressionPoint),e.readFlag()){let t=e.readInt(13)/32,r=e.readNormalVector(10);a.velocity={x:r.x*t,y:r.y*t,z:r.z*t}}else a.velocity={x:0,y:0,z:0};a.headX=e.readSignedFloat(6),a.headZ=e.readSignedFloat(6),a.rotationZ=2*e.readFloat(7)*Math.PI,a.move=u9(e),a.allowWarp=e.readFlag()}return a.energy=e.readFloat(5),a}function u7(e,t){let r={};if(r.energyLevel=e.readF32(),r.rechargeRate=e.readF32(),r.actionState=e.readInt(3),e.readFlag()&&(r.recoverTicks=e.readInt(7)),e.readFlag()&&(r.jumpDelay=e.readInt(7)),e.readFlag()){let a={x:e.readF32(),y:e.readF32(),z:e.readF32()};r.position=a,t.compressionPoint=a,r.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},r.jumpSurfaceLastContact=e.readInt(4)}if(r.headX=e.readF32(),r.headZ=e.readF32(),r.rotationZ=e.readF32(),e.readFlag()){let a=e.readInt(10);r.controlObjectGhost=a;let n=t.ghostTracker.getGhost(a),i=n?t.getGhostParser?.(n.classId):void 0;if(i?.readPacketData){let n=t.currentGhostIndex;t.currentGhostIndex=a,r.controlObjectData=i.readPacketData(e,t),t.currentGhostIndex=n}}return r.disableMove=e.readFlag(),r.pilot=e.readFlag(),r}function ce(e,t,r){let a=u4(e,t,r);return(a.jetting=e.readFlag(),e.readFlag())?a._controlledEarlyReturn=!0:(a.steeringYaw=e.readFloat(9),a.steeringPitch=e.readFloat(9),a.move=u9(e),a.frozen=e.readFlag(),e.readFlag()&&(a.position=e.readCompressedPoint(r.compressionPoint),a.angPosition={x:e.readF32(),y:e.readF32(),z:e.readF32(),w:e.readF32()},a.linMomentum=e.readPoint3F(),a.angMomentum=e.readPoint3F()),e.readFlag()&&(a.energy=e.readFloat(8))),a}function ct(e,t){let r={};r.energyLevel=e.readF32(),r.rechargeRate=e.readF32(),r.steering={x:e.readF32(),y:e.readF32()};let a={x:e.readF32(),y:e.readF32(),z:e.readF32()};return r.linPosition=a,r.angPosition={x:e.readF32(),y:e.readF32(),z:e.readF32(),w:e.readF32()},r.linMomentum=e.readPoint3F(),r.angMomentum=e.readPoint3F(),r.disableMove=e.readFlag(),r.frozen=e.readFlag(),t.compressionPoint=a,r}function cr(e,t){let r=ct(e,t);r.braking=e.readFlag();let a=4,n=t.currentGhostIndex;if(void 0!==n){let e=cK.get(n);void 0!==e&&(a=e)}let i=[];for(let t=0;t<a;t++)i.push({avel:e.readF32(),Dy:e.readF32(),Dx:e.readF32()});return r.wheels=i,r}function ca(e,t,r){let a=ce(e,t,r);return e.readFlag()||(a.createHeightOn=e.readFlag(),a.thrustDirection=e.readInt(3)),a}function cn(e,t,r){let a=ce(e,t,r);return a.thrustDirection=e.readInt(3),a}function ci(e,t,r){let a=u4(e,t,r);if(e.readFlag()&&(a.rotate=e.readFlag(),a.isStatic=e.readFlag(),a.collideable=e.readFlag(),e.readFlag()&&(a.scale=e.readPoint3F())),e.readFlag()&&(a.collisionObject=e.readInt(10)),e.readFlag()&&(a.rotation={zSign:e.readFlag()?-1:1,angle:e.readF32()}),e.readFlag()){a.position=e.readPoint3F();let t=e.readFlag();a.atRest=t,t||(a.velocity=e.readPoint3F()),a.warp=e.readFlag()}return a}function co(e,t,r){let a=u4(e,t,r);return e.readFlag()&&(a.transform=e.readAffineTransform(),a.position=a.transform.position,a.scale=e.readPoint3F()),a.powered=e.readFlag(),a}function cs(e,t,r){return co(e,t,r)}function cl(e,t,r){return{position:e.readPoint3F()}}function cu(e,t,r){return{message:e.readString()}}function cc(e,t,r){let a=co(e,t,r);return e.readFlag()&&(a.beaconType=e.readInt(2)),a}function cd(e,t,r){let a=u4(e,t,r);return e.readFlag()&&(a.transform=e.readAffineTransform(),a.position=a.transform.position,a.scale=e.readPoint3F()),a}function cf(e,t,r){let a=u8(e,t,r);a.value0=e.readF32(),a.value1=e.readF32(),a.value2=e.readF32(),a.value3=e.readF32(),a.value4=e.readF32(),a.value5=e.readF32(),a.bool0=e.readBool(),a.bool1=e.readBool(),a.bool2=e.readBool(),a.bool3=e.readBool(),a.value6=e.readF32(),a.value7=e.readF32(),a.value8=e.readF32(),a.value9=e.readF32(),a.value10=e.readF32(),a.value11=e.readF32(),a.bool4=e.readBool(),a.bool5=e.readBool(),a.value12=e.readF32(),a.value13=e.readF32(),a.value14=e.readF32(),a.bool6=e.readBool(),a.string0=e.readString(),a.string1=e.readString();let n=[];for(let t=0;t<2;t++)n.push(e.readFlag()?u5(e):-1);return a.objectRefs=n,a.objectRef2=e.readFlag()?u5(e):-1,a}function ch(e,t,r){return u8(e,t,r)}function cm(e,t,r){let a={};return(e.readFlag()&&(a.dataBlockId=u5(e)),e.readFlag()&&(a.targetId=e.readFlag()?e.readInt(9):-1),e.readFlag())?(a.position={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.currTick=e.readInt(12),e.readFlag()&&(a.resetFlag=!0),e.readFlag()&&(a.explodePoint={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.explodeNormal={x:e.readF32(),y:e.readF32(),z:e.readF32()}),e.readFlag()?(a.sourceObject=e.readInt(11),a.sourceSlot=e.readInt(3)):(a.sourceObject=-1,a.sourceSlot=-1),e.readFlag()?a.vehicleObject=e.readInt(11):a.vehicleObject=0,a):(e.readFlag()&&(a.position={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()}),e.readFlag()&&(a.endPoint={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.endNormal={x:e.readF32(),y:e.readF32(),z:e.readF32()}),a)}function cp(e,t,r){let a=u8(e,t,r);return e.readFlag()?(a.position=e.readPoint3F(),a.velocity=e.readPoint3F(),a.currTick=e.readRangedU32(0,4095),a.quickSplash=e.readFlag(),e.readFlag()&&(a.explodePoint=e.readPoint3F(),a.explodeNormal=e.readPoint3F()),e.readFlag()&&(a.sourceObject=e.readRangedU32(0,1024),a.sourceSlot=e.readRangedU32(0,7)),e.readFlag()&&(a.vehicleObject=e.readRangedU32(0,1024))):(e.readFlag()&&(a.position=e.readPoint3F(),a.velocity=e.readPoint3F()),e.readFlag()&&(a.explodePoint=e.readPoint3F(),a.explodeNormal=e.readPoint3F())),a}function cg(e,t,r){let a=u8(e,t,r);return e.readFlag()?(a.position={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.orientation={x:e.readF32(),y:e.readF32(),z:e.readF32()},e.readFlag()?(a.sourceObject=e.readInt(11),a.sourceSlot=e.readInt(3)):(a.sourceObject=-1,a.sourceSlot=-1),e.readFlag()?e.readFlag()?(a.targetGhost=e.readInt(11),a.targetMode=0):(a.targetDirection={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.targetMode=1):a.targetMode=2,a.timeoutReset=e.readFlag(),a):(e.readFlag()?(a.retargetPos={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.retargetDir={x:e.readF32(),y:e.readF32(),z:e.readF32()}):(a.position={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},e.readFlag()?e.readFlag()?(a.targetGhost=e.readInt(11),a.targetMode=0):(a.targetDirection={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.targetMode=1):a.targetMode=2),a)}function cv(e,t,r){let a=co(e,t,r);return e.readFlag()&&(a.capacitorEnergy=e.readFloat(8)),e.readFlag()||e.readFlag()&&(a.phi=e.readFloat(10),a.theta=e.readFloat(10),a.activationLevel=e.readFloat(8)),a}function cy(e,t,r){let a={};return e.readFlag()?(a.crc=e.readU32(),a.interiorFile=e.readString(),a.showTerrainInside=e.readFlag(),a.transform=e.readMatrixF(),a.scale=e.readPoint3F(),a.alarmState=e.readFlag(),a.skinBase=e.readString(),e.readFlag()&&(a.audioProfileId=u5(e)),e.readFlag()&&(a.audioEnvironmentId=u5(e))):(e.readFlag()&&(a.transform=e.readMatrixF(),a.scale=e.readPoint3F()),a.alarmState=e.readFlag(),e.readFlag()&&(a.skinBase=e.readString()),e.readFlag()&&(e.readFlag()&&(a.audioProfileId=u5(e)),e.readFlag()&&(a.audioEnvironmentId=u5(e)))),a}function cA(e,t,r){let a=u4(e,t,r);return e.readFlag()||e.readFlag()&&(a.posX=e.readF32(),a.posY=e.readF32(),a.posZ=e.readF32(),a.fovOrDist=e.readF32(),a.orbitParam=e.readF32()),a}function cF(e,t){let r={};r.energyLevel=e.readF32(),r.rechargeRate=e.readF32();let a={x:e.readF32(),y:e.readF32(),z:e.readF32()};r.position=a,r.rotX=e.readF32(),r.rotZ=e.readF32();let n=e.readInt(3);return r.cameraMode=n,(3===n||4===n)&&(r.minOrbitDist=e.readF32(),r.maxOrbitDist=e.readF32(),r.curOrbitDist=e.readF32(),3===n&&(r.observingClientObject=e.readFlag(),r.orbitObjectGhostIndex=e.readInt(10)),4===n&&(r.orbitPoint=e.readCompressedPoint(t.compressionPoint,.01))),t.compressionPoint=a,r}function cb(e,t,r){let a=u8(e,t,r);return e.readFlag()?e.readFlag()?(a.hidden=!0,a.explodePosition=e.readCompressedPoint(r.compressionPoint),a.explodeNormal=e.readNormalVector(14),a.endedWithDecal=e.readFlag()):(a.position=e.readCompressedPoint(r.compressionPoint),a.direction=e.readNormalVector(14),a.currTick=e.readRangedU32(0,511),e.readFlag()&&(a.sourceObject=e.readInt(10),a.sourceSlot=e.readRangedU32(0,7),e.readFlag()&&(a.excessVel=e.readRangedU32(0,255),a.excessDir=e.readNormalVector(7))),e.readFlag()&&(a.vehicleObject=e.readInt(10))):(a.explodePosition=e.readCompressedPoint(r.compressionPoint),a.explodeNormal=e.readNormalVector(14),a.endedWithDecal=e.readFlag()),a}function cC(e,t,r){let a=u8(e,t,r);return e.readFlag()&&e.readFlag()&&(a.sourceObject=e.readRangedU32(0,1024),a.sourceSlot=e.readRangedU32(0,7),a.targetObject=e.readRangedU32(0,1024)),a}function cB(e,t,r){let a=u8(e,t,r);return e.readFlag()&&e.readFlag()&&(a.sourceObject=e.readRangedU32(0,1024),a.sourceSlot=e.readRangedU32(0,7),a.repairingObject=e.readRangedU32(0,1024)),a}function cS(e,t,r){let a=u8(e,t,r);return e.readFlag()?(a.initialPosition=e.readPoint3F(),a.endPos=e.readPoint3F(),a.truncated=e.readFlag(),e.readFlag()&&(a.sourceObject=e.readRangedU32(0,1024),a.sourceSlot=e.readRangedU32(0,7),a.clientOwned=e.readFlag())):(e.readFlag()?(a.sourceObject=e.readRangedU32(0,1024),a.sourceSlot=e.readRangedU32(0,7),a.clientOwned=e.readFlag()):a.initialPosition=e.readPoint3F(),a.endPos=e.readPoint3F(),a.truncated=e.readFlag()),a}function cx(e,t,r){let a=cd(e,t,r);return e.readFlag()&&(a.name=e.readString()),e.readFlag()&&(a.teamId=e.readS32()),e.readFlag()&&(a.hidden=e.readFlag()),a}function cE(e,t,r){let a=cd(e,t,r);return e.readFlag()&&(a.radius=e.readF32(),a.sphereWeight=e.readF32(),a.indoorWeight=e.readF32(),a.outdoorWeight=e.readF32()),a}function cM(e,t,r){let a=u8(e,t,r);if(e.readFlag()?(a.transform=e.readAffineTransform(),a.scale=e.readPoint3F()):e.readFlag()&&(a.transform=e.readAffineTransform(),a.scale=e.readPoint3F()),e.readFlag()){let t=e.readInt(2);a.state=t,3===t?a.position=0:0===t||(a.position=e.readU32())}return a}function cD(e,t,r){let a={};return a.transform=e.readMatrixF(),a.scale=e.readPoint3F(),a.shapeName=e.readString(),a}function ck(e,t,r){let a={};if(e.readFlag()){a.crc=e.readU32(),a.terrFileName=e.readString(),a.detailTextureName=e.readString(),a.squareSize=e.readU32();let t=e.readU32(),r=[];for(let a=0;a<t;a++)r.push(e.readU32());a.emptySquareRunCount=t}else if(e.readFlag()){let t=e.readU32(),r=[];for(let a=0;a<t;a++)r.push(e.readU32());a.emptySquareRunCount=t}return a}function cw(e,t,r){let a={};if(e.readFlag()){let t=[];for(let r=0;r<5;r++)t.push(e.readString());a.textures=t}if(e.readFlag()){let t=[];for(let r=0;r<19;r++)t.push(e.readF32());a.direction={x:t[0],y:t[1],z:t[2]},a.color={r:t[3],g:t[4],b:t[5],a:t[6]},a.ambient={r:t[7],g:t[8],b:t[9],a:t[10]},a.extraLightProps=t.slice(11)}return a}function cI(e,t,r){let a={};if(e.readFlag()){a.materialList=e.readString(),a.fogColor={r:e.readF32(),g:e.readF32(),b:e.readF32()};let t=e.readU32();if(t>64)throw Error(`Invalid Sky fogVolumeCount: ${t}`);a.fogVolumeCount=t,a.useSkyTextures=e.readBool(),a.renderBottomTexture=e.readBool(),a.skySolidColor={r:e.readF32(),g:e.readF32(),b:e.readF32()},a.windEffectPrecipitation=e.readBool();let r=[];for(let a=0;a<t;a++)r.push({visibleDistance:e.readF32(),minHeight:e.readF32(),maxHeight:e.readF32(),color:{r:e.readF32(),g:e.readF32(),b:e.readF32()}});a.fogVolumes=r;let n=[];for(let t=0;t<3;t++)n.push({texture:e.readString(),heightPercent:e.readF32(),speed:e.readF32()});a.cloudLayers=n,a.windVelocity=e.readPoint3F(),a.stormCurrent=e.readF32(),e.readFlag()&&(a.stormInit={startPct:e.readF32(),duration:e.readF32(),indexOrMode:e.readF32(),startTime:e.readF32(),targetPct:e.readF32()})}return e.readFlag()&&(a.stormCloudsOn=e.readBool()),e.readFlag()&&(a.stormFogOn=e.readBool()),e.readFlag()&&(a.visibleDistance=e.readF32(),a.fogDistance=e.readF32()),e.readFlag()&&(a.stormType=e.readF32(),a.stormMagnitude=e.readF32()),e.readFlag()&&(a.stormTimeline={startPct:e.readF32(),duration:e.readF32(),indexOrMode:e.readF32()}),e.readFlag()&&(a.stormCloudProfile={enabled:e.readF32(),value0:e.readF32(),value1:e.readF32(),value2:e.readF32()}),e.readFlag()&&(a.windVelocity=e.readPoint3F()),a}function cT(e,t,r){let a=u8(e,t,r);return e.readFlag()&&(a.position=e.readPoint3F(),a.scale=e.readPoint3F(),a.strikeWidth=e.readF32(),a.chanceToHitTarget=e.readF32(),a.strikeRadius=e.readF32(),a.boltStartRadius=e.readF32(),a.color={r:e.readF32(),g:e.readF32(),b:e.readF32()},a.fadeColor={r:e.readF32(),g:e.readF32(),b:e.readF32()},a.useFog=0!==e.readInt(8),a.strikesPerMinute=e.readF32()),a}function cR(e,t,r){let a={};a.transform=e.readAffineTransform(),a.scale=e.readPoint3F(),a.surfaceName=e.readString(),a.envMapName=e.readString();let n=[];for(let t=0;t<2;t++)n.push(e.readString());return a.submergeNames=n,a.liquidType=e.readS32(),a.density=e.readF32(),a.viscosity=e.readF32(),a.waveMagnitude=e.readF32(),a.surfaceOpacity=e.readF32(),a.envMapIntensity=e.readF32(),a.removeWetEdges=0!==e.readInt(8),e.readFlag()&&(a.audioEnvironmentId=u5(e)),a}function cP(e,t,r){let a={};return e.readFlag()&&(a.area={x:e.readS32(),y:e.readS32(),w:e.readS32(),h:e.readS32()},a.flightCeiling=e.readF32(),a.flightCeilingRange=e.readF32()),a}function cG(e,t,r){let a=u8(e,t,r);return e.readFlag()&&(a.position=e.readPoint3F()),a}function cL(e,t,r){let a=u8(e,t,r);return e.readFlag()&&(a.position=e.readPoint3F(),a.normal=e.readPoint3F()),a}function cj(e,t,r){let a=u8(e,t,r);return e.readFlag()&&(a.dropRadius=e.readF32(),a.dropsPerMinute=e.readF32(),a.maxDropAngle=e.readF32(),a.minDropAngle=e.readF32(),a.startVelocity=e.readF32(),a.dropHeight=e.readF32(),a.dropDir=e.readPoint3F()),a}function c_(e,t,r){let a={};return a.transform=e.readMatrixF(),a.boundsMin=e.readPoint3F(),a.boundsMax=e.readPoint3F(),a}function cO(e,t,r){let a=u8(e,t,r);return a.transform=e.readMatrixF(),a.scale=e.readPoint3F(),e.readFlag()&&(a.emitterDatablockId=u5(e)),a}function cU(e,t,r){let a=u8(e,t,r);if(e.readFlag()){a.percentage=e.readF32();let t=e.readS32();if(a.colorCount=t,t<0||t>3)throw Error(`Invalid precipitation colorCount: ${t}`);let r=[];for(let a=0;a<t;a++)r.push({r:e.readInt(8)/255,g:e.readInt(8)/255,b:e.readInt(8)/255,a:e.readInt(8)/255});a.colors=r,a.offsetSpeed=e.readF32(),a.minVelocity=e.readF32(),a.maxVelocity=e.readF32(),a.maxDrops=e.readS32(),a.maxRadius=e.readF32(),e.readFlag()&&(a.stormLastTime=e.readF32(),a.stormTime=e.readF32(),a.stormEndPercentage=e.readF32())}return e.readFlag()&&(a.stormPrecipitationOn=e.readBool()),e.readFlag()&&(a.stormTime=e.readF32(),a.stormEndPercentage=e.readF32()),e.readFlag()&&(a.percentageUpdate=e.readF32()),a}function cH(e,t,r){let a=u8(e,t,r);return e.readFlag()?(a.energyPercentage=e.readFloat(7),a.initialPosition=e.readPoint3F(),a.endPos=e.readPoint3F(),a.truncated=e.readFlag(),a.hitWater=e.readFlag(),e.readFlag()&&(a.sourceObject=e.readRangedU32(0,1024),a.sourceSlot=e.readRangedU32(0,7),a.clientOwned=e.readFlag())):(e.readFlag()?(a.sourceObject=e.readRangedU32(0,1024),a.sourceSlot=e.readRangedU32(0,7),a.clientOwned=e.readFlag()):a.initialPosition=e.readPoint3F(),a.endPos=e.readPoint3F(),a.truncated=e.readFlag()),a}function cN(e,t,r){let a=u8(e,t,r);return e.readFlag()&&(a.targetObject=e.readRangedU32(0,1024)),e.readFlag()&&(a.start=e.readPoint3F(),a.end=e.readPoint3F(),a.hitObject=e.readFlag(),e.readFlag()&&(a.sourceObject=e.readRangedU32(0,1024),a.sourceSlot=e.readRangedU32(0,7))),a}let cJ=new Map,cK=new Map;function cV(e,t,r){let a=ce(e,t,r);if(a.braking=e.readFlag(),e.readFlag()){let t=4,n=a.dataBlockId,i=r.currentGhostIndex;if(void 0!==n){let e=cJ.get(n);if(void 0!==e)t=e;else if(r.getDataBlockData){let e=r.getDataBlockData(n);e&&(t=function(e){if(!e)return 6;let t=e.toLowerCase();return t.includes("mpb")||t.includes("mpbase"),6}(e.shapeName),cJ.set(n,t))}void 0!==i&&cK.set(i,t)}else if(void 0!==i){let e=cK.get(i);void 0!==e&&(t=e)}let o=[];for(let r=0;r<t;r++)o.push({avel:e.readF32(),dy:e.readF32(),dx:e.readF32()});a.wheels=o}return a}function cz(e,t,r){return{tickPeriodMS:e.readU32()}}function cq(e,t,r){let a={};if(e.readFlag()){a.transform=e.readMatrixF(),a.scale=e.readPoint3F();let t=e.readU32();if(t>Math.floor(e.getRemainingBits()/96))throw Error(`Invalid physicalZone point count: ${t}`);let r=[];for(let a=0;a<t;a++)r.push(e.readPoint3F());a.points=r;let n=e.readU32();if(n>Math.floor(e.getRemainingBits()/128))throw Error(`Invalid physicalZone plane count: ${n}`);let i=[];for(let t=0;t<n;t++)i.push({x:e.readF32(),y:e.readF32(),z:e.readF32(),d:e.readF32()});a.planes=i;let o=e.readU32();if(o>Math.floor(e.getRemainingBits()/128))throw Error(`Invalid physicalZone edge count: ${o}`);let s=[];for(let t=0;t<o;t++)s.push({face0:e.readU32(),face1:e.readU32(),vertex0:e.readU32(),vertex1:e.readU32()});a.edges=s,a.velocityMod=e.readF32(),a.gravityMod=e.readF32(),a.appliedForce=e.readPoint3F(),a.active=e.readFlag()}else a.active=e.readFlag();return a}function cQ(e,t,r){let a={};return a.initialUpdate=e.readFlag(),e.readFlag()&&(a.transform=e.readAffineTransform()),e.readFlag()&&e.readFlag()&&(a.audioProfileId=u5(e)),e.readFlag()&&e.readFlag()&&(a.audioDescriptionId=u5(e)),e.readFlag()&&(a.filename=e.readString()),e.readFlag()&&(a.useProfileDescription=e.readFlag()),e.readFlag()&&(a.volume=e.readF32()),e.readFlag()&&(a.isLooping=e.readFlag()),e.readFlag()&&(a.is3D=e.readFlag()),e.readFlag()&&(a.minDistance=e.readF32()),e.readFlag()&&(a.maxDistance=e.readF32()),e.readFlag()&&(a.coneInsideAngle=e.readF32()),e.readFlag()&&(a.coneOutsideAngle=e.readF32()),e.readFlag()&&(a.coneOutsideVolume=e.readF32()),e.readFlag()&&(a.coneVector=e.readPoint3F()),e.readFlag()&&(a.loopCount=e.readF32()),e.readFlag()&&(a.minLoopGap=e.readF32()),e.readFlag()&&(a.maxLoopGap=e.readF32()),e.readFlag()&&(a.audioType=e.readF32()),e.readFlag()&&(a.outsideAmbient=e.readFlag()),a}function cW(e,t,r){let a=u8(e,t,r);return e.readFlag()&&e.readFlag()&&(a.stationObject=e.readRangedU32(0,1024)),a}function cX(e,t,r){let a=u4(e,t,r);return e.readFlag()&&(a.transform=e.readAffineTransform(),a.scale=e.readPoint3F()),a.unknownFlag=e.readFlag(),a}function cY(e,t){if(!e.readFlag())return{type:"SimDataBlockEvent",mProcess:!1};let r=e.readInt(11)+0,a=e.readInt(7)+128,n=e.readInt(11),i=e.readInt(12),o={type:"SimDataBlockEvent",mProcess:!0};o.objectId=r,o.classId=a,o.index=n,o.total=i,o._payloadBitPos=e.getCurPos();let s=t.getDataBlockParser?.(a);if(s)try{o.dataBlockData=s.unpackData(e),o.dataBlockClassName=s.name}catch{o._needsClassParser=!0}else o._needsClassParser=!0;return o}function cZ(e,t){let r=e.readInt(10),a=e.readFlag(),n=a?e.readString():void 0;return{type:"NetStringEvent",id:r,hasValue:a,value:n}}function c$(e,t){return{type:"Sim2DAudioEvent",profileId:e.readInt(11)+3}}function c0(e,t){let r,a=e.readInt(11)+3;if(e.readFlag()){let t=e.readFloat(8),a=e.readFloat(8),n=e.readFloat(8),i=Math.sqrt(Math.max(0,1-(t*t+a*a+n*n)));e.readFlag()&&(i=-i),r={x:t,y:a,z:n,w:i}}return{type:"Sim3DAudioEvent",profileId:a,rotation:r,position:e.readCompressedPoint(t.compressionPoint,.5)}}function c1(e,t){return{type:"SetSensorGroupEvent",sensorGroup:e.readInt(5)}}function c2(e,t){let r={type:"SetServerTargetEvent"};return e.readFlag()&&(r.targetId=e.readInt(9)),r.targetPos={x:e.readF32(),y:e.readF32(),z:e.readF32()},r}function c3(e,t){let r={type:"TargetToEvent"};return e.readFlag()&&(r.targetId=e.readInt(9)),e.readFlag()&&(r.targetPos={x:e.readF32(),y:e.readF32(),z:e.readF32()}),r.assign=e.readFlag(),r}function c9(e,t){return{type:"SetObjectActiveImageEvent",objectId:e.readRangedU32(0,1023),imageSlot:e.readRangedU32(0,8)}}function c5(e,t){return{type:"SetMissionCRCEvent",crc:e.readU32()}}function c8(e,t){let r=e.readInt(5),a=[];for(let t=0;t<r;t++)a.push(e.unpackNetString());return{type:"RemoteCommandEvent",argc:r,argv:a,funcName:a[0]??"",args:a.slice(1)}}function c4(e,t){let r={type:"TargetInfoEvent"};return r.targetId=e.readInt(9),e.readFlag()&&(r.nameTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(r.skinTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(r.skinPrefTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(r.voiceTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(r.typeTag=e.readFlag()?e.readInt(10):1024),e.readFlag()&&(r.sensorGroup=e.readInt(5)),e.readFlag()&&(r.dataBlockId=e.readFlag()?e.readInt(11):-2),e.readFlag()&&(r.renderFlags=e.readInt(9)),e.readFlag()&&(r.voicePitch=1.5*e.readFloat(7)+.5),r}function c6(e,t){return{type:"TargetFreeEvent",targetId:e.readInt(9)}}function c7(e,t){let r={type:"SimTargetAudioEvent"};return r.targetId=e.readInt(9),r.fileTag=e.readInt(12),r.descriptionId=e.readRangedU32(3,1026),e.readFlag()&&(r.position=e.readCompressedPoint(t.compressionPoint,.5)),r.updateSound=e.readFlag(),r}function de(e,t){let r={type:"SensorGroupColorEvent"};r.sensorGroup=e.readInt(5);let a=e.readU32();r.updateMask=a;let n=[];for(let t=0;t<32;t++)1<<t&a&&(e.readFlag()?n.push({index:t,r:e.readU8(),g:e.readU8(),b:e.readU8(),a:e.readU8()}):n.push({index:t,default:!0}));return r.colors=n,r}function dt(e,t){return{type:"ResetClientTargetsEvent",clientTargetsOnly:e.readFlag()}}function dr(e,t){return{type:"RemoveClientTargetTypeEvent",targetType:e.readRangedU32(0,3)}}function da(e,t){let r={type:"SimVoiceStreamEvent"};r.streamId=e.readInt(5),r.sequence=e.readInt(6),r.codecId=e.readInt(2),r.clientId=e.readU8(),0===r.sequence&&(r.objectId=e.readInt(10)),e.readFlag()?r.size=e.readInt(5):r.size=16;let a=r.size;return a>0&&(r.audioData=e.readBitsBuffer(8*a)),r}function dn(e,t){return{type:"GhostingMessageEvent",sequence:e.readU32(),message:e.readInt(3),ghostCount:e.readInt(11)}}function di(e,t){let r={type:"GhostAlwaysObjectEvent"};r.ghostIndex=e.readInt(10);let a=e.readFlag();if(r._hasObjectData=a,a){let a=e.readInt(7);r.classId=a;let n=t.getGhostParser?.(a);if(!n)throw Error(`No ghost parser for GhostAlwaysObjectEvent classId=${a}`);r.objectData=n.unpackUpdate(e,!0,t)}return r}function ds(e,t){let r={type:"PathManagerEvent"};if(e.readFlag()){r.messageType="NewPaths";let t=e.readU32(),a=[];for(let r=0;r<t&&r<256;r++){let t=e.readU32(),r=e.readU32(),n=[];for(let t=0;t<r&&t<1024;t++)n.push({position:e.readPoint3F(),msToNext:e.readU32()});a.push({totalTime:t,points:n})}r.paths=a}else{r.messageType="ModifyPath",r.modifiedPath=e.readU32();let t=e.readU32(),a=e.readU32(),n=[];for(let t=0;t<a&&t<1024;t++)n.push({position:e.readPoint3F(),msToNext:e.readU32()});r.path={totalTime:t,points:n}}return r}function dl(e,t){let r={type:"LightningStrikeEvent"};return e.readFlag()&&(r.sourceGhost=e.readInt(11),r.startX=e.readFloat(10),r.startY=e.readFloat(10),e.readFlag()&&(r.targetGhost=e.readInt(11))),r}function du(e,t){let r=e.readRangedU32(0,63),a=e.readBitsBuffer(8*r);return{type:"FileChunkEvent",chunkLen:r,chunkData:a}}function dc(e,t){return{type:"DownloadMessageEvent",value:e.readU32(),message:e.readInt(3)}}function dd(e,t){let r=e.readRangedU32(0,31),a=[];for(let t=0;t<r;t++)a.push(e.readString());return{type:"FileDownloadRequestEvent",fileNames:a}}function df(e,t){return{type:"SimpleMessageEvent",message:e.readString()}}function dh(e,t){return{type:"CRCChallengeEvent",crcValue:e.readU32(),field1:e.readU32(),field2:e.readU32(),flag:e.readFlag()}}function dm(e,t){return{type:"CRCChallengeResponseEvent",crcValue:e.readU32(),field1:e.readU32(),field2:e.readU32()}}function dp(e,t){return{type:"GravityEvent",gravity:e.readF32()}}function dg(e,t){return{type:"FogChallengeEvent"}}function dv(e){return e.readFlag()?e.readInt(11):null}function dy(e,t,r){return e.readRangedU32(0,r-t)+t}function dA(e){return{r:e.readInt(8)/255,g:e.readInt(8)/255,b:e.readInt(8)/255,a:e.readInt(8)/255}}function dF(e){return 0!==e.readInt(8)}function db(e,t,r,a){return t+e.readInt(a)/((1<<a)-1)*(r-t)}function dC(e){let t={};e.readFlag()&&(t.crc=e.readU32()),t.shapeName=e.readString(),e.readFlag()&&(t.mass=e.readF32()),e.readFlag()&&(t.drag=e.readF32()),e.readFlag()&&(t.density=e.readF32()),e.readFlag()&&(t.maxEnergy=e.readF32()),e.readFlag()&&(t.cameraMaxDist=e.readF32()),e.readFlag()&&(t.cameraMinDist=e.readF32()),e.readFlag()&&(t.cameraDefaultFov=e.readF32()),e.readFlag()&&(t.cameraMinFov=e.readF32()),e.readFlag()&&(t.cameraMaxFov=e.readF32()),t.debrisShapeName=e.readString(),e.readFlag()&&(t.sensorRadius=e.readInt(10),t.sensorColor={r:e.readInt(8),g:e.readInt(8),b:e.readInt(8),a:e.readInt(8)}),e.readFlag()&&(t.heat=e.readF32()),t.cmdCategory=e.readString(),t.cmdMiniIconName=e.readString(),t.canControl=e.readFlag(),t.canObserve=e.readFlag(),t.observeThroughObject=e.readFlag(),t.firstPersonOnly=e.readFlag(),t.isInvincible=e.readFlag(),t.renderWhenDestroyed=e.readFlag(),t.debris=dv(e),t.explosion=dv(e),t.underwaterExplosion=dv(e),t.debrisEmitter=dv(e),t.inheritEnergyFromMount=e.readFlag(),t.useEyePoint=e.readFlag(),t.emap=e.readFlag(),t.shieldEffectLifetimeMS=e.readU32(),e.readFlag()&&(t.shieldEffectScale={x:e.readF32(),y:e.readF32(),z:e.readF32()});let r=[];for(let t=0;t<8;t++){if(!e.readFlag())continue;let t={};t.friendlyName=e.readString(),e.readFlag()&&(t.enemyName=e.readString()),t.renderCenter=e.readFlag(),t.renderModulated=e.readFlag(),t.renderAlways=e.readFlag(),t.renderDistance=e.readFlag(),t.renderName=e.readFlag(),r.push(t)}return r.length>0&&(t.hudImages=r),t}function dB(e){let t={};e.readFlag()&&(t.crc=e.readU32()),t.shapeName=e.readString(),t.mountPoint=e.readU32(),e.readFlag()||(t.offset=e.readAffineTransform()),t.firstPerson=e.readFlag(),t.mass=e.readF32(),t.usesEnergy=e.readFlag(),t.minEnergy=e.readF32(),t.hasFlash=e.readFlag(),t.projectile=dv(e),t.muzzleFlash=dv(e),t.isSeeker=e.readFlag(),t.isSeeker&&(t.seekerRadius=e.readF32(),t.maxSeekAngle=e.readF32(),t.seekerLockTime=e.readF32(),t.seekerFreeTime=e.readF32(),t.isTargetLockRequired=e.readFlag(),t.maxLockRange=e.readF32()),t.cloakable=e.readFlag(),t.lightType=e.readRangedU32(0,3),0!==t.lightType&&(t.lightRadius=e.readF32(),t.lightTime=e.readS32(),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7)}),t.shellExitDir={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.shellExitVariance=e.readF32(),t.shellVelocity=e.readF32(),t.casing=dv(e),t.accuFire=e.readFlag();let r=[];for(let t=0;t<31;t++){if(!e.readFlag())continue;let t={};t.name=e.readString(),t.transitionOnAmmo=e.readInt(5),t.transitionOnNoAmmo=e.readInt(5),t.transitionOnTarget=e.readInt(5),t.transitionOnNoTarget=e.readInt(5),t.transitionOnWet=e.readInt(5),t.transitionOnNotWet=e.readInt(5),t.transitionOnTriggerUp=e.readInt(5),t.transitionOnTriggerDown=e.readInt(5),t.transitionOnTimeout=e.readInt(5),t.transitionGeneric0In=e.readInt(5),t.transitionGeneric0Out=e.readInt(5),e.readFlag()&&(t.timeoutValue=e.readF32()),t.waitForTimeout=e.readFlag(),t.fire=e.readFlag(),t.ejectShell=e.readFlag(),t.scaleAnimation=e.readFlag(),t.direction=e.readFlag(),t.reload=e.readFlag(),e.readFlag()&&(t.energyDrain=e.readF32()),t.loaded=e.readInt(3),t.spin=e.readInt(3),t.recoil=e.readInt(3),e.readFlag()&&(t.sequence=e.readSignedInt(16)),e.readFlag()&&(t.sequenceVis=e.readSignedInt(16)),t.flashSequence=e.readFlag(),t.ignoreLoadedForReady=e.readFlag(),t.emitter=dv(e),null!==t.emitter&&(t.emitterTime=e.readF32(),t.emitterNode=e.readS32()),t.sound=dv(e),r.push(t)}return t.states=r,t}function dS(e){let t=dC(e);t.renderFirstPerson=e.readFlag(),t.minLookAngle=e.readF32(),t.maxLookAngle=e.readF32(),t.maxFreelookAngle=e.readF32(),t.maxTimeScale=e.readF32(),t.maxStepHeight=e.readF32(),t.runForce=e.readF32(),t.runEnergyDrain=e.readF32(),t.minRunEnergy=e.readF32(),t.maxForwardSpeed=e.readF32(),t.maxBackwardSpeed=e.readF32(),t.maxSideSpeed=e.readF32(),t.maxUnderwaterForwardSpeed=e.readF32(),t.maxUnderwaterBackwardSpeed=e.readF32(),t.maxUnderwaterSideSpeedRef=dv(e),e.readFlag()&&(t.runSurfaceAngleRef=e.readInt(11)),t.runSurfaceAngle=e.readF32(),t.recoverDelay=e.readF32(),t.recoverRunForceScale=e.readF32(),t.jumpForce=e.readF32(),t.jumpEnergyDrain=e.readF32(),t.minJumpEnergy=e.readF32(),t.minJumpSpeed=e.readF32(),t.maxJumpSpeed=e.readF32(),t.jumpSurfaceAngle=e.readF32(),t.minJetEnergy=e.readF32(),t.splashVelocity=e.readF32(),t.splashAngle=e.readF32(),t.splashFreqMod=e.readF32(),t.splashVelEpsilon=e.readF32(),t.bubbleEmitTime=e.readF32(),t.medSplashSoundVel=e.readF32(),t.hardSplashSoundVel=e.readF32(),t.exitSplashSoundVel=e.readF32(),t.jumpDelay=e.readInt(7),t.horizMaxSpeed=e.readF32(),t.horizResistSpeed=e.readF32(),t.horizResistFactor=e.readF32(),t.upMaxSpeed=e.readF32(),t.upResistSpeed=e.readF32(),t.upResistFactor=e.readF32(),t.jetEnergyDrain=e.readF32(),t.canJet=e.readF32(),t.maxJetHorizontalPercentage=e.readF32(),t.maxJetForwardSpeed=e.readF32(),t.jetForce=e.readF32(),t.minJetSpeed=e.readF32(),t.maxDamage=e.readF32(),t.minImpactDamageSpeed=e.readF32(),t.impactDamageScale=e.readF32(),t.footSplashHeight=e.readF32();let r=[];for(let t=0;t<32;t++)e.readFlag()?r.push(e.readInt(11)):r.push(null);t.sounds=r,t.boxSize={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.footPuffEmitter=dv(e),t.footPuffNumParts=e.readF32(),t.footPuffRadius=e.readF32(),t.decalData=dv(e),t.decalOffset=e.readF32(),t.dustEmitter=dv(e),t.splash=dv(e);let a=[];for(let t=0;t<3;t++)a.push(dv(e));return t.splashEmitters=a,t.groundImpactMinSpeed=e.readF32(),t.groundImpactShakeFreq={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.groundImpactShakeAmp={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.groundImpactShakeDuration=e.readF32(),t.groundImpactShakeFalloff=e.readF32(),t.boundingRadius=e.readF32(),t.moveBubbleSize=e.readF32(),t}function dx(e){let t=dC(e);t.bodyRestitution=e.readF32(),t.bodyFriction=e.readF32();let r=[];for(let t=0;t<2;t++)r.push(dv(e));t.impactSounds=r,t.minImpactSpeed=e.readF32(),t.softImpactSpeed=e.readF32(),t.hardImpactSpeed=e.readF32(),t.minRollSpeed=e.readF32(),t.maxSteeringAngle=e.readF32(),t.maxDrag=e.readF32(),t.minDrag=e.readF32(),t.cameraOffset=e.readF32(),t.cameraLag=e.readF32(),t.jetForce=e.readF32(),t.jetEnergyDrain=e.readF32(),t.minJetEnergy=e.readF32(),t.integration=e.readF32(),t.collisionTol=e.readF32(),t.massCenter=e.readF32(),t.exitSplashSoundVelocity=e.readF32(),t.softSplashSoundVelocity=e.readF32(),t.mediumSplashSoundVelocity=e.readF32(),t.hardSplashSoundVelocity=e.readF32();let a=[];for(let t=0;t<5;t++)a.push(dv(e));t.waterSounds=a,t.dustEmitter=dv(e);let n=[];for(let t=0;t<3;t++)n.push(dv(e));t.damageEmitters=n;let i=[];for(let t=0;t<2;t++)i.push(dv(e));return t.splashEmitters=i,t.damageEmitterOffset0={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.damageEmitterOffset1={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.damageLevelTolerance0=e.readF32(),t.damageLevelTolerance1=e.readF32(),t.splashFreqMod=e.readF32(),t.splashVelEpsilon=e.readF32(),t.collDamageThresholdVel=e.readF32(),t.collDamageMultiplier=e.readF32(),t}function dE(e){let t=dx(e);t.jetActivateSound=dv(e),t.jetDeactivateSound=dv(e);let r=[];for(let t=0;t<4;t++)r.push(dv(e));return t.jetEmitters=r,t.maneuveringForce=e.readF32(),t.horizontalSurfaceForce=e.readF32(),t.verticalSurfaceForce=e.readF32(),t.autoInputDamping=e.readF32(),t.steeringForce=e.readF32(),t.steeringRollForce=e.readF32(),t.rollForce=e.readF32(),t.autoAngularForce=e.readF32(),t.rotationalDrag=e.readF32(),t.maxAutoSpeed=e.readF32(),t.autoLinearForce=e.readF32(),t.hoverHeight=e.readF32(),t.createHoverHeight=e.readF32(),t.minTrailSpeed=e.readF32(),t.vertThrustMultiple=e.readF32(),t.maxForwardSpeed=e.readF32(),t}function dM(e){let t=dx(e);t.dragForce=e.readF32(),t.mainThrustForce=e.readF32(),t.reverseThrustForce=e.readF32(),t.strafeThrustForce=e.readF32(),t.turboFactor=e.readF32(),t.stabLenMin=e.readF32(),t.stabLenMax=e.readF32(),t.stabSpringConstant=e.readF32(),t.stabDampingConstant=e.readF32(),t.gyroDrag=e.readF32(),t.normalForce=e.readF32(),t.restorativeForce=e.readF32(),t.steeringForce=e.readF32(),t.rollForce=e.readF32(),t.pitchForce=e.readF32(),t.floatingThrustFactor=e.readF32(),t.brakingForce=e.readF32(),t.dustTrailOffset={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.dustTrailFreqMod=e.readF32(),t.triggerTrailHeight=e.readF32(),t.floatSound=dv(e),t.thrustSound=dv(e),t.turboSound=dv(e);let r=[];for(let t=0;t<3;t++)r.push(dv(e));return t.jetEmitters=r,t.dustTrailEmitter=dv(e),t.mainThrustEmitterFactor=e.readF32(),t.strafeThrustEmitterFactor=e.readF32(),t.reverseThrustEmitterFactor=e.readF32(),t}function dD(e){let t=dx(e);return t.tireRadius=e.readF32(),t.tireStaticFriction=e.readF32(),t.tireKineticFriction=e.readF32(),t.tireRestitution=e.readF32(),t.tireLateralForce=e.readF32(),t.tireLateralDamping=e.readF32(),t.tireLateralRelaxation=e.readF32(),t.tireLongitudinalForce=e.readF32(),t.tireLongitudinalDamping=e.readF32(),t.tireEmitter=dv(e),t.jetSound=dv(e),t.engineSound=dv(e),t.squealSound=dv(e),t.wadeSound=dv(e),t.spring=e.readF32(),t.springDamping=e.readF32(),t.springLength=e.readF32(),t.brakeTorque=e.readF32(),t.engineTorque=e.readF32(),t.engineBrake=e.readF32(),t.maxWheelSpeed=e.readF32(),t.steeringAngle=e.readF32(),t.steeringReturn=e.readF32(),t.steeringDamping=e.readF32(),t.powerSteeringFactor=e.readF32(),t}function dk(e){let t=dC(e);return t.noIndividualDamage=e.readFlag(),t.dynamicTypeField=e.readS32(),t}function dw(e){let t=dk(e);return t.thetaMin=e.readF32(),t.thetaMax=e.readF32(),t.thetaNull=e.readF32(),t.neverUpdateControl=e.readFlag(),t.primaryAxis=e.readRangedU32(0,3),t.maxCapacitorEnergy=e.readF32(),t.capacitorRechargeRate=e.readF32(),t}function dI(e){let t=dB(e);return t.activationMS=e.readInt(8),t.deactivateDelayMS=e.readInt(8),t.degPerSecTheta=e.readRangedU32(0,1080),t.degPerSecPhi=e.readRangedU32(0,1080),t.dontFireInsideDamageRadius=e.readFlag(),t.damageRadius=e.readF32(),t.useCapacitor=e.readFlag(),t}function dT(e){let t=dC(e);return t.friction=e.readFloat(10),t.elasticity=e.readFloat(10),t.sticky=e.readFlag(),e.readFlag()&&(t.gravityMod=e.readFloat(10)),e.readFlag()&&(t.maxVelocity=e.readF32()),e.readFlag()&&(t.lightType=e.readInt(2),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7)},t.lightTime=e.readS32(),t.lightRadius=e.readF32(),t.lightOnlyStatic=e.readFlag()),t}function dR(e){let t={};t.projectileShapeName=e.readString(),t.faceViewerLinkTime=e.readS32(),t.lifetime=e.readS32(),t.faceViewer=e.readFlag(),e.readFlag()&&(t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()}),t.activateEmitter=dv(e),t.maintainEmitter=dv(e),t.activateSound=dv(e),t.maintainSound=dv(e),t.explosion=dv(e),t.splash=dv(e),t.bounceExplosion=dv(e),t.bounceSound=dv(e),t.underwaterExplosion=dv(e);let r=[];for(let t=0;t<6;t++)r.push(dv(e));return t.decals=r,e.readFlag()&&(t.lightRadius=e.readFloat(8),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7)}),e.readFlag()&&(t.underwaterLightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7)}),t.explodeOnWaterImpact=dF(e),t.depthTolerance=e.readF32(),t}function dP(e){let t=dR(e);return t.dryVelocity=e.readF32(),t.wetVelocity=e.readF32(),t.fizzleTime=e.readU32(),t.fizzleType=e.readU32(),t.hardRetarget=e.readFlag(),t.inheritedVelocityScale=e.readRangedU32(0,90),t.lifetimeMS=e.readRangedU32(0,90),t.collideWithOwnerTimeMS=e.readU32(),t.proximityRadius=e.readU32(),t.tracerProjectile=e.readFlag(),t}function dG(e){let t=dR(e);return t.grenadeElasticity=e.readS32(),t.grenadeFriction=e.readF32(),t.dragCoefficient=e.readF32(),t.windCoefficient=e.readF32(),t.gravityMod=e.readF32(),t.muzzleVelocity=e.readF32(),t.drag=e.readF32(),t.lifetimeMS=e.readS32(),t}function dL(e){let t=dR(e);return t.lifetimeMS=e.readS32(),t.muzzleVelocity=e.readF32(),t.turningSpeed=e.readF32(),t.proximityRadius=e.readF32(),t.terrainAvoidanceSpeed=e.readF32(),t.terrainScanAhead=e.readF32(),t.terrainHeightFail=e.readF32(),t.terrainAvoidanceRadius=e.readF32(),t.flareDistance=e.readF32(),t.flareAngle=e.readF32(),t.useFlechette=dF(e),t.maxVelocity=e.readF32(),t.acceleration=e.readF32(),t.flechetteDelayMs=e.readS32(),t.exhaustTimeMs=e.readS32(),t.exhaustNodeName=e.readString(),t.casingShapeName=e.readString(),t.casingDebris=dv(e),t.puffEmitter=dv(e),t.exhaustEmitter=dv(e),t}function dj(e){let t=dR(e);t.maxRifleRange=e.readF32(),t.rifleHeadMultiplier=e.readF32(),t.beamColor=dA(e),t.fadeTime=e.readF32(),t.startBeamWidth=e.readF32(),t.endBeamWidth=e.readF32(),t.pulseBeamWidth=e.readF32(),t.beamFlareAngle=e.readF32(),t.minFlareSize=e.readF32(),t.maxFlareSize=e.readF32(),t.pulseSpeed=e.readF32(),t.pulseLength=e.readF32(),t.lightColor=dA(e),t.lightRadius=e.readF32();let r=[];for(let t=0;t<12;t++)r.push(e.readString());return t.textures=r,t}function d_(e){let t=dR(e);t.zapDuration=e.readF32(),t.boltLength=e.readF32(),t.numParts=e.readF32(),t.lightningFreq=e.readF32(),t.lightningDensity=e.readF32(),t.lightningAmp=e.readF32(),t.lightningWidth=e.readF32(),t.shockwave=dv(e);let r=[],a=[],n=[],i=[];for(let t=0;t<2;t++)r.push(e.readF32()),a.push(e.readF32()),n.push(e.readF32()),i.push(e.readF32());t.startWidth=r,t.endWidth=a,t.boltSpeed=n,t.texWrap=i;let o=[];for(let t=0;t<4;t++)o.push(e.readString());return t.textures=o,t.emitter=dv(e),t}function dO(e){let t=dR(e);return t.beamRange=e.readF32(),t.beamDrainRate=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=e.readF32(),t.startWidth=e.readF32(),t.endWidth=e.readF32(),t.mainBeamTexture=e.readString(),t.innerBeamTexture=e.readString(),t.flareTexture=e.readString(),t.hitEmitter=dv(e),t}function dU(e){let t=dR(e);return t.beamRange=e.readF32(),t.beamRepairRate=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=e.readF32(),t.startWidth=e.readF32(),t.endWidth=e.readF32(),t.startBeamWidth=e.readF32(),t.endBeamWidth=e.readF32(),t.mainBeamTexture=e.readString(),t.innerBeamTexture=e.readString(),t}function dH(e){let t=dR(e);t.maxRifleRange=e.readF32(),t.beamColor=dA(e),t.startBeamWidth=e.readF32(),t.pulseBeamWidth=e.readF32(),t.beamFlareAngle=e.readF32(),t.minFlareSize=e.readF32(),t.maxFlareSize=e.readF32(),t.pulseSpeed=e.readF32(),t.pulseLength=e.readF32();let r=[];for(let t=0;t<4;t++)r.push(e.readString());return t.textures=r,t}function dN(e){let t=dP(e);return t.tracerLength=e.readF32(),t.tracerAlpha=e.readF32(),t.tracerMinPixels=e.readF32(),t.crossViewFraction=dF(e),t.tracerColor=dA(e),t.tracerWidth=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=dF(e),t.textureName0=e.readString(),t.textureName1=e.readString(),t}function dJ(e){let t=dG(e);return t.energyDrainPerSecond=e.readF32(),t.energyMinDrain=e.readF32(),t.beamWidth=e.readF32(),t.beamRange=e.readF32(),t.numSegments=e.readF32(),t.texRepeat=e.readF32(),t.beamFlareAngle=e.readF32(),t.beamTexture=e.readString(),t.flareTexture=e.readString(),t}function dK(e){let t=dP(e);return t.numFlares=e.readF32(),t.flareColor=dA(e),t.flareTexture=e.readString(),t.smokeTexture=e.readString(),t.size=e.readF32(),t.flareModTexture=e.readF32(),t.smokeSize=e.readF32(),t}function dV(e){let t=dG(e);return t.smokeDist=e.readF32(),t.noSmoke=e.readF32(),t.boomTime=e.readF32(),t.casingDist=e.readF32(),t.smokeCushion=e.readF32(),t.noSmokeCounter=e.readF32(),t.smokeTexture=e.readString(),t.bombTexture=e.readString(),t}function dz(e){let t=dG(e);return t.size=e.readF32(),t.useLensFlare=dF(e),t.flareTexture=e.readString(),t.lensFlareTexture=e.readString(),t}function dq(e){let t={};t.dtsFileName=e.readString(),t.soundProfile=dv(e),t.particleEmitter=dv(e),t.particleDensity=e.readInt(14),t.particleRadius=e.readF32(),t.faceViewer=e.readFlag(),e.readFlag()&&(t.explosionScale={x:e.readInt(16),y:e.readInt(16),z:e.readInt(16)}),t.playSpeed=e.readInt(14),t.debrisThetaMin=e.readRangedU32(0,180),t.debrisThetaMax=e.readRangedU32(0,180),t.debrisPhiMin=e.readRangedU32(0,360),t.debrisPhiMax=e.readRangedU32(0,360),t.debrisMinVelocity=e.readRangedU32(0,1e3),t.debrisMaxVelocity=e.readRangedU32(0,1e3),t.debrisNum=e.readInt(14),t.debrisVariance=e.readRangedU32(0,1e4),t.delayMS=e.readInt(16),t.delayVariance=e.readInt(16),t.lifetimeMS=e.readInt(16),t.lifetimeVariance=e.readInt(16),t.offset=e.readF32(),t.shakeCamera=e.readFlag(),t.hasLight=e.readFlag(),t.camShakeFreq={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.camShakeAmp={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.camShakeDuration=e.readF32(),t.camShakeRadius=e.readF32(),t.camShakeFalloff=e.readF32(),t.shockwave=dv(e),t.debris=dv(e);let r=[];for(let t=0;t<4;t++)r.push(dv(e));t.emitters=r;let a=[];for(let t=0;t<5;t++)a.push(dv(e));t.subExplosions=a;let n=e.readRangedU32(0,4),i=[];for(let t=0;t<n;t++)i.push(e.readFloat(8));t.times=i;let o=[];for(let t=0;t<n;t++)o.push({x:e.readRangedU32(0,16e3),y:e.readRangedU32(0,16e3),z:e.readRangedU32(0,16e3)});return t.sizes=o,t}function dQ(e){let t={};return t.elasticity=e.readF32(),t.friction=e.readF32(),t.numBounces=e.readS32(),t.bounceVariance=e.readS32(),t.minSpinSpeed=e.readF32(),t.maxSpinSpeed=e.readF32(),t.render2D=dF(e),t.explodeOnMaxBounce=dF(e),t.staticOnMaxBounce=dF(e),t.snapOnMaxBounce=dF(e),t.lifetime=e.readF32(),t.lifetimeVariance=e.readF32(),t.minSpinSpeed_dup=e.readF32(),t.maxSpinSpeed_dup=e.readF32(),t.velocity=e.readF32(),t.velocityVariance=e.readF32(),t.useRadiusMass=dF(e),t.fade=dF(e),t.baseRadius=e.readF32(),t.gravModifier=e.readF32(),t.terminalVelocity=e.readF32(),t.ignoreWater=dF(e),t.shapeFileName=e.readString(),t.skinName=e.readString(),t.emitter0=dv(e),t.emitter1=dv(e),t.explosion=dv(e),t}function dW(e){let t={};t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.delayMS=e.readS32(),t.delayVariance=e.readS32(),t.lifetimeMS=e.readS32(),t.lifetimeVariance=e.readS32(),t.width=e.readF32(),t.numSegments=e.readS32(),t.velocity=e.readF32(),t.height=e.readF32(),t.acceleration=e.readF32(),t.texWrap=e.readF32(),t.texFactor=e.readF32(),t.ejectionFreq=e.readF32(),t.ejectionAngle=e.readF32(),t.ringLifetime=e.readF32(),t.startRadius=e.readF32(),t.explosion=dv(e);let r=[];for(let t=0;t<3;t++)r.push(dv(e));t.emitters=r;let a=[];for(let t=0;t<4;t++)a.push(dA(e));t.colors=a;let n=[];for(let t=0;t<4;t++)n.push(e.readF32());return t.times=n,t.textureName=e.readString(),t.foamTexture=e.readString(),t}function dX(e){let t={};t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.delayMS=e.readS32(),t.delayVariance=e.readS32(),t.lifetimeMS=e.readS32(),t.lifetimeVariance=e.readS32(),t.width=e.readF32(),t.numSegments=e.readS32(),t.velocity=e.readF32(),t.height=e.readF32(),t.verticalCurve=e.readF32(),t.acceleration=e.readF32(),t.texWrap=e.readF32(),t.texFactor=e.readF32(),t.is2D=dF(e),t.orientToNormal=dF(e),t.mapToTerrain=dF(e),t.renderBottom=dF(e),t.renderSquare=dF(e);let r=[];for(let t=0;t<3;t++)r.push(dv(e));t.emitters=r;let a=[];for(let t=0;t<4;t++)a.push(dA(e));t.colors=a;let n=[];for(let t=0;t<4;t++)n.push(e.readF32());return t.times=n,t.textureName=e.readString(),t.mapToTexture=e.readString(),t}function dY(e){let t={};t.ejectionPeriodMS=e.readInt(10),t.periodVarianceMS=e.readInt(10),t.ejectionVelocity=e.readInt(16),t.velocityVariance=e.readInt(14),e.readFlag()&&(t.ejectionOffset=e.readInt(16)),t.thetaMin=e.readRangedU32(0,180),t.thetaMax=e.readRangedU32(0,180),e.readFlag()&&(t.phiReferenceVel=e.readRangedU32(0,360)),e.readFlag()&&(t.phiVariance=e.readRangedU32(0,360)),t.overrideAdvances=e.readFlag(),t.orientParticles=e.readFlag(),t.orientOnVelocity=e.readFlag(),t.lifetimeMS=e.readInt(10),t.lifetimeVarianceMS=e.readInt(10),t.useEmitterSizes=e.readFlag(),t.useEmitterColors=e.readFlag();let r=e.readU32(),a=[];for(let t=0;t<r&&t<16;t++)a.push(dv(e));return t.particles=a,t}function dZ(e){let t={};t.dragCoefficient=e.readFloat(10),e.readFlag()&&(t.windCoefficient=e.readF32()),t.gravityCoefficient=e.readSignedFloat(12),t.inheritedVelFactor=e.readFloat(9),e.readFlag()&&(t.constantAcceleration=e.readF32()),t.lifetimeMS=e.readInt(10),t.lifetimeVarianceMS=e.readInt(10),e.readFlag()&&(t.spinSpeed=e.readF32()),e.readFlag()&&(t.spinRandomMin=e.readInt(11),t.spinRandomMax=e.readInt(11)),t.useInvAlpha=e.readFlag();let r=e.readInt(2)+1,a=[];for(let t=0;t<r;t++)a.push({r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7),size:e.readFloat(14),time:e.readFloat(8)});t.keys=a;let n=e.readInt(6),i=[];for(let t=0;t<n&&t<50;t++)i.push(e.readString());return t.textures=i,t}function d$(e){let t={};return t.volume=e.readFloat(6),t.isLooping=e.readFlag(),t.isLooping&&(t.loopCount=e.readS32(),t.minLoopGap=e.readS32(),t.maxLoopGap=e.readS32()),t.is3D=e.readFlag(),t.is3D&&(t.referenceDistance=e.readF32(),t.maxDistance=e.readF32(),t.coneInsideAngle=e.readInt(9),t.coneOutsideAngle=e.readInt(9),t.coneOutsideVolume=e.readFloat(6),t.coneVector=e.readNormalVector(8),t.environmentLevel=e.readF32()),t.type=e.readInt(3),t}function d0(e){let t={};return t.description=dv(e),t.environment=dv(e),t.sampleEnvironment=dv(e),t.filename=e.readString(),t}function d1(e){let t={};return t.useRoom=e.readFlag(),t.useRoom?t.room=e.readRangedU32(0,26):(t.roomHF=dy(e,-1e4,0),t.reflections=dy(e,-1e4,1e4),t.reverb=dy(e,-1e4,2e3),t.roomRolloffFactor=db(e,.1,10,8),t.decayTime=db(e,.1,20,8),t.decayHFRatio=db(e,.1,20,8),t.reflectionsDelay=db(e,0,.3,9),t.reverbDelay=db(e,0,.1,7),t.roomVolume=dy(e,-1e4,0),t.effectVolume=db(e,0,1,9),t.damping=db(e,0,2,10),t.environmentSize=db(e,1,100,8),t.environmentDiffusion=db(e,0,1,10),t.flags=e.readInt(6)),t.effectVolumeHF=db(e,0,1,8),t}function d2(e){let t={};return t.direct=dy(e,-1e4,1e3),t.directHF=dy(e,-1e4,0),t.room=dy(e,-1e4,1e3),t.roomHF=dy(e,-1e4,0),t.obstruction=db(e,0,1,9),t.obstructionLFRatio=db(e,0,1,8),t.occlusion=db(e,0,1,9),t.occlusionLFRatio=db(e,0,1,8),t.occlusionRoomRatio=db(e,0,10,9),t.roomRolloff=db(e,0,10,9),t.airAbsorption=db(e,0,10,9),t.outsideVolumeHF=dy(e,-1e4,0),t.flags=e.readInt(3),t}function d3(e){return{sizeX:e.readF32(),sizeY:e.readF32(),textureName:e.readString()}}function d9(e){return dC(e)}function d5(e){return{}}function d8(e){return{tickPeriodMS:e.readS32()}}function d4(e){let t={};return t.fadeMS=e.readS32(),t.baseTranslucency=e.readF32(),t.powerOffTranslucency=e.readF32(),t.fadeInOnly=e.readFlag(),t.triggerEnable=e.readFlag(),t.color1=dA(e),t.color2=dA(e),t.banRadius=e.readF32(),t.speed=e.readF32(),t.maxSpeed=e.readF32(),t.attackMS=e.readF32(),t.decayMS=e.readF32(),t.texture0=e.readString(),t.texture1=e.readString(),t.texture2=e.readString(),t.texture3=e.readString(),t.texture4=e.readString(),t}function d6(e){return{timeMultiple:e.readF32()}}function d7(e){let t=["baseImage","activeImage","inactiveImage","selectImage","hilightImage"],r={};for(let a=0;a<5;a++)r[t[a]]=e.readString();return r}function fe(e){let t={};return t.soundProfile=dv(e),t.numDrops=e.readS32(),t.maxSize=e.readF32(),t.materialList=e.readString(),t.sizeX=e.readF32(),t.sizeY=e.readF32(),t.movingBoxPer=e.readF32(),t.divHeightVal=e.readF32(),t.sizeBigBox=e.readF32(),t.topBoxSpeed=e.readF32(),t.frontBoxSpeed=e.readF32(),t.topBoxDrawPer=e.readF32(),t.bottomDrawHeight=e.readF32(),t.skipIfPer=e.readF32(),t.bottomSpeedPer=e.readF32(),t.frontSpeedPer=e.readF32(),t.frontRadiusPer=e.readF32(),t}function ft(e){return{emitter:dv(e)}}function fr(e){let t={},r=[];for(let t=0;t<8;t++)r.push(dv(e));t.strikeSounds=r;let a=[];for(let t=0;t<8;t++)a.push(e.readString());return t.strikeTextures=a,t.thunderSound=dv(e),t}function fa(e){let t={};t.glowTopHeight=e.readF32(),t.glowBottomHeight=e.readF32(),t.glowTopRadius=e.readF32(),t.glowBottomRadius=e.readF32(),t.numGlowSegments=e.readF32(),t.glowFadeTime=e.readF32(),t.armLightDelay=e.readF32(),t.armLightLifetime=e.readF32(),t.armLightFadeTime=e.readF32(),t.lifetime=e.readF32(),t.numArcSegments=e.readF32(),t.sphereColor=dA(e),t.spherePhiSegments=e.readF32(),t.sphereThetaSegments=e.readF32(),t.sphereRadius=e.readF32(),t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.glowTexture=e.readString();for(let r=0;r<4;r++)t[`padTexture${r}0`]=e.readString(),t[`padTexture${r}1`]=e.readString();return t.lightStartColor=e.readString(),t.lightEndColor=e.readString(),t}function fn(e){let t={};return t.glowTopRadius=e.readF32(),t.glowBottomRadius=e.readF32(),t.glowTopHeight=e.readF32(),t.glowBottomHeight=e.readF32(),t.numGlowSegments=e.readF32(),t.numGlowPanels=e.readF32(),t.topAlpha=e.readF32(),t.bottomAlpha=e.readF32(),t.glowSpeed=e.readF32(),t.scrollSpeed=e.readF32(),t.glowTexture=e.readString(),t.padTexture=e.readString(),t.lightStartColor=e.readString(),t.lightEndColor=e.readString(),t}function fi(e){return{chatText:e.readString()}}function fo(e){return dC(e)}function fs(e){return{}}function fl(e){return{}}function fu(e){let t={};t.shape=e.readString();let r=e.readInt(7),a=[];for(let t=0;t<r&&t<128;t++)a.push(e.readString());return t.sequences=a,t}function fc(e){let t={};return t.minDistance=e.readF32(),t.maxDistance=e.readF32(),t.audioScale=e.readF32(),t.directional=dF(e),t.effectName=e.readString(),t}function fd(e){let t={};return t.coolColor=dA(e),t.hotColor=dA(e),t.activateTime=e.readF32(),t.deactivateTime=e.readF32(),t.length=e.readF32(),t.width=e.readF32(),t.speed=e.readF32(),t.stretch=e.readF32(),t.yOffset=e.readF32(),e.readFlag()&&(t.texture=e.readString()),t}function ff(e){let t={};return t.radius=e.readF32(),t.color=dA(e),t.type=e.readF32(),t.length=e.readF32(),t.nodeName=e.readString(),t.direction={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.offset={x:e.readF32(),y:e.readF32(),z:e.readF32()},e.readFlag()&&(t.texture=e.readString()),t}let fh=(0,uz.default)("t2-demo-parser"),fm=(0,uz.default)("t2-demo-parser:initial"),fp=(0,uz.default)("t2-demo-parser:blocks");class fg{buffer;view;offset;registry;ghostTracker;packetParser;_loaded=!1;_header;_initialBlock;_decompressedData;_decompressedView;_blockStreamOffset=0;_blockCount;_blockCursor=0;constructor(e){this.buffer=e,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.offset=0,this.registry=new u2,this.ghostTracker=new u3,function(e){e.catalogEvent({name:"SimDataBlockEvent",unpack:cY}),e.catalogEvent({name:"NetStringEvent",unpack:cZ}),e.catalogEvent({name:"Sim2DAudioEvent",unpack:c$}),e.catalogEvent({name:"Sim3DAudioEvent",unpack:c0}),e.catalogEvent({name:"SetSensorGroupEvent",unpack:c1}),e.catalogEvent({name:"SetServerTargetEvent",unpack:c2}),e.catalogEvent({name:"TargetToEvent",unpack:c3}),e.catalogEvent({name:"SetObjectActiveImageEvent",unpack:c9}),e.catalogEvent({name:"SetMissionCRCEvent",unpack:c5}),e.catalogEvent({name:"RemoteCommandEvent",unpack:c8}),e.catalogEvent({name:"TargetInfoEvent",unpack:c4}),e.catalogEvent({name:"TargetFreeEvent",unpack:c6}),e.catalogEvent({name:"SimTargetAudioEvent",unpack:c7}),e.catalogEvent({name:"SensorGroupColorEvent",unpack:de}),e.catalogEvent({name:"ResetClientTargetsEvent",unpack:dt}),e.catalogEvent({name:"RemoveClientTargetTypeEvent",unpack:dr}),e.catalogEvent({name:"SimVoiceStreamEvent",unpack:da}),e.catalogEvent({name:"GhostingMessageEvent",unpack:dn}),e.catalogEvent({name:"GhostAlwaysObjectEvent",unpack:di}),e.catalogEvent({name:"PathManagerEvent",unpack:ds}),e.catalogEvent({name:"LightningStrikeEvent",unpack:dl}),e.catalogEvent({name:"FileChunkEvent",unpack:du}),e.catalogEvent({name:"DownloadMessageEvent",unpack:dc}),e.catalogEvent({name:"FileDownloadRequestEvent",unpack:dd}),e.catalogEvent({name:"SimpleMessageEvent",unpack:df}),e.catalogEvent({name:"CRCChallengeEvent",unpack:dh}),e.catalogEvent({name:"CRCChallengeResponseEvent",unpack:dm}),e.catalogEvent({name:"GravityEvent",unpack:dp}),e.catalogEvent({name:"FogChallengeEvent",unpack:dg})}(this.registry),function(e){e.catalogGhost({name:"AIObjective",unpackUpdate:cX}),e.catalogGhost({name:"BeaconObject",unpackUpdate:cc}),e.catalogGhost({name:"BombProjectile",unpackUpdate:cm}),e.catalogGhost({name:"Player",unpackUpdate:u6,readPacketData:u7}),e.catalogGhost({name:"Debris",unpackUpdate:cf}),e.catalogGhost({name:"GameBase",unpackUpdate:u8}),e.catalogGhost({name:"ShapeBase",unpackUpdate:u4,readPacketData:ct}),e.catalogGhost({name:"Vehicle",unpackUpdate:ce,readPacketData:ct}),e.catalogGhost({name:"FlyingVehicle",unpackUpdate:ca,readPacketData:ct}),e.catalogGhost({name:"HoverVehicle",unpackUpdate:cn,readPacketData:ct}),e.catalogGhost({name:"Item",unpackUpdate:ci}),e.catalogGhost({name:"Marker",unpackUpdate:cl}),e.catalogGhost({name:"MissionMarker",unpackUpdate:cd}),e.catalogGhost({name:"StaticShape",unpackUpdate:co}),e.catalogGhost({name:"Projectile",unpackUpdate:ch}),e.catalogGhost({name:"ScopeAlwaysShape",unpackUpdate:cs}),e.catalogGhost({name:"GrenadeProjectile",unpackUpdate:cp}),e.catalogGhost({name:"SimpleNetObject",unpackUpdate:cu}),e.catalogGhost({name:"SeekerProjectile",unpackUpdate:cg}),e.catalogGhost({name:"Turret",unpackUpdate:cv}),e.catalogGhost({name:"InteriorInstance",unpackUpdate:cy}),e.catalogGhost({name:"Camera",unpackUpdate:cA,readPacketData:cF}),e.catalogGhost({name:"LinearProjectile",unpackUpdate:cb}),e.catalogGhost({name:"ELFProjectile",unpackUpdate:cC}),e.catalogGhost({name:"RepairProjectile",unpackUpdate:cB}),e.catalogGhost({name:"TargetProjectile",unpackUpdate:cS}),e.catalogGhost({name:"TracerProjectile",unpackUpdate:cb}),e.catalogGhost({name:"WayPoint",unpackUpdate:cx}),e.catalogGhost({name:"SpawnSphere",unpackUpdate:cE}),e.catalogGhost({name:"ForceFieldBare",unpackUpdate:cM}),e.catalogGhost({name:"TSStatic",unpackUpdate:cD}),e.catalogGhost({name:"TerrainBlock",unpackUpdate:ck}),e.catalogGhost({name:"Sun",unpackUpdate:cw}),e.catalogGhost({name:"Sky",unpackUpdate:cI}),e.catalogGhost({name:"Lightning",unpackUpdate:cT}),e.catalogGhost({name:"WaterBlock",unpackUpdate:cR}),e.catalogGhost({name:"MissionArea",unpackUpdate:cP}),e.catalogGhost({name:"Splash",unpackUpdate:cG}),e.catalogGhost({name:"Shockwave",unpackUpdate:cL}),e.catalogGhost({name:"FireballAtmosphere",unpackUpdate:cj}),e.catalogGhost({name:"VehicleBlocker",unpackUpdate:c_}),e.catalogGhost({name:"ParticleEmissionDummy",unpackUpdate:cO}),e.catalogGhost({name:"Precipitation",unpackUpdate:cU}),e.catalogGhost({name:"EnergyProjectile",unpackUpdate:cp}),e.catalogGhost({name:"FlareProjectile",unpackUpdate:cp}),e.catalogGhost({name:"LinearFlareProjectile",unpackUpdate:cb}),e.catalogGhost({name:"SniperProjectile",unpackUpdate:cH}),e.catalogGhost({name:"ShockLanceProjectile",unpackUpdate:cN}),e.catalogGhost({name:"WheeledVehicle",unpackUpdate:cV,readPacketData:cr}),e.catalogGhost({name:"Trigger",unpackUpdate:cz}),e.catalogGhost({name:"PhysicalZone",unpackUpdate:cq}),e.catalogGhost({name:"AudioEmitter",unpackUpdate:cQ}),e.catalogGhost({name:"StationFXPersonal",unpackUpdate:cW}),e.catalogGhost({name:"StationFXVehicle",unpackUpdate:cW})}(this.registry),function(e){e.catalogDataBlock({name:"ShapeBaseData",unpackData:dC}),e.catalogDataBlock({name:"ShapeBaseImageData",unpackData:dB}),e.catalogDataBlock({name:"PlayerData",unpackData:dS}),e.catalogDataBlock({name:"VehicleData",unpackData:dx}),e.catalogDataBlock({name:"FlyingVehicleData",unpackData:dE}),e.catalogDataBlock({name:"HoverVehicleData",unpackData:dM}),e.catalogDataBlock({name:"WheeledVehicleData",unpackData:dD}),e.catalogDataBlock({name:"StaticShapeData",unpackData:dk}),e.catalogDataBlock({name:"TurretData",unpackData:dw}),e.catalogDataBlock({name:"TurretImageData",unpackData:dI}),e.catalogDataBlock({name:"ItemData",unpackData:dT}),e.catalogDataBlock({name:"ProjectileData",unpackData:dR}),e.catalogDataBlock({name:"LinearProjectileData",unpackData:dP}),e.catalogDataBlock({name:"GrenadeProjectileData",unpackData:dG}),e.catalogDataBlock({name:"SeekerProjectileData",unpackData:dL}),e.catalogDataBlock({name:"SniperProjectileData",unpackData:dj}),e.catalogDataBlock({name:"ShockLanceProjectileData",unpackData:d_}),e.catalogDataBlock({name:"ELFProjectileData",unpackData:dO}),e.catalogDataBlock({name:"RepairProjectileData",unpackData:dU}),e.catalogDataBlock({name:"TargetProjectileData",unpackData:dH}),e.catalogDataBlock({name:"TracerProjectileData",unpackData:dN}),e.catalogDataBlock({name:"EnergyProjectileData",unpackData:dJ}),e.catalogDataBlock({name:"LinearFlareProjectileData",unpackData:dK}),e.catalogDataBlock({name:"BombProjectileData",unpackData:dV}),e.catalogDataBlock({name:"FlareProjectileData",unpackData:dz}),e.catalogDataBlock({name:"ExplosionData",unpackData:dq}),e.catalogDataBlock({name:"DebrisData",unpackData:dQ}),e.catalogDataBlock({name:"SplashData",unpackData:dW}),e.catalogDataBlock({name:"ShockwaveData",unpackData:dX}),e.catalogDataBlock({name:"ParticleEmitterData",unpackData:dY}),e.catalogDataBlock({name:"ParticleData",unpackData:dZ}),e.catalogDataBlock({name:"AudioDescription",unpackData:d$}),e.catalogDataBlock({name:"AudioProfile",unpackData:d0}),e.catalogDataBlock({name:"AudioEnvironment",unpackData:d1}),e.catalogDataBlock({name:"AudioSampleEnvironment",unpackData:d2}),e.catalogDataBlock({name:"DecalData",unpackData:d3}),e.catalogDataBlock({name:"CameraData",unpackData:d9}),e.catalogDataBlock({name:"SensorData",unpackData:d5}),e.catalogDataBlock({name:"TriggerData",unpackData:d8}),e.catalogDataBlock({name:"ForceFieldBareData",unpackData:d4}),e.catalogDataBlock({name:"ParticleEmissionDummyData",unpackData:d6}),e.catalogDataBlock({name:"CommanderIconData",unpackData:d7}),e.catalogDataBlock({name:"PrecipitationData",unpackData:fe}),e.catalogDataBlock({name:"FireballAtmosphereData",unpackData:ft}),e.catalogDataBlock({name:"LightningData",unpackData:fr}),e.catalogDataBlock({name:"StationFXVehicleData",unpackData:fa}),e.catalogDataBlock({name:"StationFXPersonalData",unpackData:fn}),e.catalogDataBlock({name:"CannedChatItem",unpackData:fi}),e.catalogDataBlock({name:"MissionMarkerData",unpackData:fo}),e.catalogDataBlock({name:"GameBaseData",unpackData:fs}),e.catalogDataBlock({name:"SimDataBlock",unpackData:fl}),e.catalogDataBlock({name:"TSShapeConstructor",unpackData:fu}),e.catalogDataBlock({name:"EffectProfile",unpackData:fc}),e.catalogDataBlock({name:"JetEffectData",unpackData:fd}),e.catalogDataBlock({name:"RunningLightData",unpackData:ff})}(this.registry);const{bound:t,missing:r}=this.registry.bindDeterministicDataBlocks(uY,128);r.length>0&&fh("DataBlock binding: %d/%d bound, missing parsers: %s",t,uY.length,r.join(", "));const{bound:a,missing:n}=this.registry.bindDeterministicGhosts(uZ,0);n.length>0&&fh("Ghost binding: %d/%d bound, missing parsers: %s",a,uZ.length,n.join(", "));const{bound:i,missing:o}=this.registry.bindDeterministicEvents(u$,255);o.length>0&&fh("Event binding: %d/%d bound, missing parsers: %s",i,u$.length,o.join(", ")),this.packetParser=new u1(this.registry,this.ghostTracker)}getRegistry(){return this.registry}getGhostTracker(){return this.ghostTracker}getPacketParser(){return this.packetParser}get loaded(){return this._loaded}get header(){if(!this._loaded)throw Error("must call load() first");return this._header}get initialBlock(){if(!this._loaded)throw Error("must call load() first");return this._initialBlock}get blockCount(){if(!this._loaded)throw Error("must call load() first");if(void 0===this._blockCount){let e=this._decompressedData,t=this._decompressedView,r=0,a=0;for(;a+2<=e.length;){let n=4095&t.getUint16(a,!0);if((a+=2+n)>e.length)break;r++}this._blockCount=r}return this._blockCount}get blockCursor(){if(!this._loaded)throw Error("must call load() first");return this._blockCursor}async load(){if(this._loaded)return{header:this._header,initialBlock:this._initialBlock};let e=this.readHeader();fh('header: "%s" version=0x%s length=%dms (%smin) initialBlockSize=%d',e.identString,e.protocolVersion.toString(16),e.demoLengthMs,(e.demoLengthMs/1e3/60).toFixed(1),e.initialBlockSize);let t=this.buffer.subarray(this.offset,this.offset+e.initialBlockSize),r=this.readInitialBlock(t);this.offset+=e.initialBlockSize;let a=this.buffer.subarray(this.offset);fh("compressed block stream: %d bytes",a.length);let n=await new Promise((e,t)=>{var r,n;r=(r,a)=>{r?t(r):e(a)},n||(n=r,r={}),"function"!=typeof n&&l_(7),ur(a,r,[l8],function(e){return ue(ub(e.data[0],ut(e.data[1])))},1,n)});return fh("decompressed block stream: %d bytes",n.length),this._decompressedData=n,this._decompressedView=new DataView(n.buffer,n.byteOffset,n.byteLength),this.setupPacketParser(r),this._header=e,this._initialBlock=r,this._blockStreamOffset=0,this._blockCursor=0,this._loaded=!0,{header:e,initialBlock:r}}nextBlock(){if(!this._loaded)throw Error("must call load() first");let e=this._decompressedData,t=this._decompressedView,r=this._blockStreamOffset;if(r+2>e.length)return;let a=t.getUint16(r,!0),n=a>>12,i=4095&a;if(r+2+i>e.length)return void fp("block %d: size %d would exceed decompressed data (offset=%d remaining=%d), stopping",this._blockCursor,i,r+2,e.length-r-2);let o=e.subarray(r+2,r+2+i);this._blockStreamOffset=r+2+i;let s={index:this._blockCursor,type:n,size:i,data:o};if(this._blockCursor++,0===n)try{s.parsed=this.packetParser.parsePacket(o)}catch{}else if(1===n)this.packetParser.onSendPacketTrigger();else if(2===n&&64===i)try{s.parsed=this.readRawMove(o)}catch{}else if(3===n&&8===i)try{s.parsed=this.readInfoBlock(o)}catch{}return s}reset(){if(!this._loaded)throw Error("must call load() first");this._blockStreamOffset=0,this._blockCursor=0,this._blockCount=void 0,this.setupPacketParser(this._initialBlock)}processBlocks(e){if(!this._loaded)throw Error("must call load() first");let t=0;for(let r=0;r<e&&this.nextBlock();r++)t++;return t}setupPacketParser(e){let t=new Map;for(let[r,a]of e.dataBlocks)t.set(r,a.data);let r=new u3;for(let t of e.initialGhosts){if("create"!==t.type||void 0===t.classId)continue;let e=this.registry.getGhostParser(t.classId);r.createGhost(t.index,t.classId,e?.name??`unknown_${t.classId}`)}let a=new u1(this.registry,r,{dataBlockDataMap:t,connectionProtocolState:e.connectionState,nextRecvEventSeq:e.nextRecvEventSeq});this.ghostTracker=r,this.packetParser=a}async parseFullDemo(){let e,{header:t,initialBlock:r}=await this.load(),a=[];for(;e=this.nextBlock();)a.push(e);return{header:t,initialBlock:r,blocks:a}}readHeader(){let e=this.view.getUint8(this.offset);this.offset+=1;let t=new TextDecoder("ascii").decode(this.buffer.subarray(this.offset,this.offset+e));this.offset+=e;let r=this.view.getUint32(this.offset,!0);this.offset+=4;let a=this.view.getUint32(this.offset,!0);this.offset+=4;let n=this.view.getUint32(this.offset,!0);return this.offset+=4,{identString:t,protocolVersion:r,demoLengthMs:a,initialBlockSize:n}}readInitialBlock(e){let t,r,a=new uX(e),n=new Map;for(let e=0;e<1024;e++)a.readFlag()&&n.set(e,a.readString());fm("after tagged strings bit=%d count=%d",a.getCurPos(),n.size);let i=a.readU32(),o=[],s=new Map,l=0;for(;a.readFlag();){if(l++,!a.readFlag())continue;let e=a.readInt(11),t=a.readInt(7)+128,r=a.readInt(11),n=a.readInt(12),i=a.getCurPos();o.push({objectId:e,classId:t,index:r,total:n,dataBitsStart:i});let u=this.registry.getDataBlockParser(t);if(u){let r=u.unpackData(a);s.set(e,{classId:t,className:u.name,objectId:e,data:r})}else{let e=t>=128&&t<128+uY.length?uY[t-128]:`unknown(${t})`;throw Error(`No parser for DataBlock classId ${t} (${e}) at bit ${i}`)}}fh("all %d/%d DataBlocks parsed (%d payloads), bit position after DataBlocks: %d",l,i,s.size,a.getCurPos());let u=a.readU8(),c=[];for(let e=0;e<6;e++)c.push(a.readU32());let d=[];for(let e=0;e<16;e++)d.push(a.readU32());let f=a.readU32(),h=[];for(let e=0;e<f;e++)h.push(this.readScoreEntry(a));fm("after score entries bit=%d scoreCount=%d",a.getCurPos(),f);let m=this.readDemoValues(a);fm("after demo values bit=%d demoValues=%d",a.getCurPos(),m.length);let{sensorGroupColors:p,targets:g}=this.readComplexTargetManager(a);fm("after complex target manager bit=%d targets=%d sensorGroupColors=%d",a.getCurPos(),g.length,p.length);let v=this.readConnectionProtocol(a);fm("after connection protocol bit=%d lastRecv=%d highestAck=%d lastSend=%d connected=%s",a.getCurPos(),v.lastSeqRecvd,v.highestAckedSeq,v.lastSendSeq,v.connectionEstablished);let y=a.readF32(),A=a.readF32();fm("after RTT/loss bit=%d rtt=%d loss=%d",a.getCurPos(),y,A);let F=this.readPathManager(a);fm("after path manager bit=%d entries=%d",a.getCurPos(),F.length);let b=a.readU32();fm("after notify count bit=%d notifyCount=%d",a.getCurPos(),b);let C=8*a.getBuffer().length,B=new u3,S=this.ghostTracker;this.ghostTracker=B;let x=[],E=0,M=0,D=[],k=-1,w="",I=0;try{fm("phase2 start bit=%d remaining=%d",a.getCurPos(),C-a.getCurPos()),({nextRecvEventSeq:E,events:x}=this.readEventStartBlock(a)),fm("after initial events bit=%d count=%d",a.getCurPos(),x.length);let e=this.readGhostStartBlock(a,s);if(M=e.ghostingSequence,D=e.ghosts,fm("after initial ghosts bit=%d count=%d seq=%d",a.getCurPos(),D.length,M),k=a.readS32(),fm("after control ghost index bit=%d control=%d",a.getCurPos(),k),-1!==k){let e=B.getGhost(k);if(e){let r=this.registry.getGhostParser(e.classId);r?.readPacketData&&(t=r.readPacketData(a,{compressionPoint:{x:0,y:0,z:0},ghostTracker:B}),fm("after control readPacketData bit=%d parser=%s",a.getCurPos(),r.name))}}w=a.readString(),I=a.readU32(),a.setCurPos(a.getCurPos()+7>>3<<3),this.readSimpleTargetManager(a),this.readSimpleTargetManager(a),fm('after sequential tail bit=%d mission="%s" CRC=0x%s',a.getCurPos(),w,I.toString(16))}catch(e){r=e instanceof Error?e.message:String(e)}finally{this.ghostTracker=S}let T=C-a.getCurPos(),R=w.length>0?w.split("").filter(e=>{let t=e.charCodeAt(0);return t>=32&&t<=126}).length/w.length:1,P=w.length>0&&R>=.8&&void 0===r;return fh('initial block: events=%d ghosts=%d ghostingSeq=%d controlObj=%d mission="%s" CRC=0x%s valid=%s%s',x.length,D.length,M,k,w,I.toString(16),P,r?` error=${r}`:""),{taggedStrings:n,dataBlockHeaders:o,dataBlockCount:l,dataBlocks:s,demoSetting:u,connectionFields:c,stateArray:d,scoreEntries:h,demoValues:m,sensorGroupColors:p,targetEntries:g,connectionState:v,roundTripTime:y,packetLoss:A,pathManager:F,notifyCount:b,nextRecvEventSeq:E,ghostingSequence:M,initialGhosts:D,initialEvents:x,controlObjectGhostIndex:k,controlObjectData:t,missionName:w,missionCRC:I,phase2TrailingBits:T,phase2Valid:P,phase2Error:r}}readScoreEntry(e){let t=e.readFlag()?e.readInt(16):0,r=e.readFlag()?e.readInt(16):0,a=e.readFlag()?e.readInt(16):0,n=e.readInt(6),i=e.readInt(6),o=e.readInt(6),s=e.readFlag(),l=[];for(let t=0;t<6;t++)l.push(e.readFlag());return{clientId:t,teamId:r,score:a,field0:n,field1:i,field2:o,isBot:s,triggerFlags:l}}readDemoValues(e){let t=[];for(;e.readFlag();)t.push(e.readString());return t}readComplexTargetManager(e){e.readU8(),e.readU8(),e.readU8(),e.readU8();let t=[];for(let r=0;r<32;r++)for(let a=0;a<32;a++)e.readFlag()&&t.push({group:r,targetGroup:a,r:e.readU8(),g:e.readU8(),b:e.readU8(),a:e.readU8()});let r=[];for(let t=0;t<512;t++){if(!e.readFlag())continue;let a={targetId:t,sensorGroup:0,targetData:0,damageLevel:0};e.readFlag()&&(a.sensorData=e.readU32()),e.readFlag()&&(a.voiceMapData=e.readU32()),e.readFlag()&&(a.name=e.readString()),e.readFlag()&&(a.skin=e.readString()),e.readFlag()&&(a.skinPref=e.readString()),e.readFlag()&&(a.voice=e.readString()),e.readFlag()&&(a.typeDescription=e.readString()),a.sensorGroup=e.readInt(5),a.targetData=e.readInt(9),t>=32&&e.readFlag()&&(a.dataBlockRef=e.readInt(11)),a.damageLevel=e.readFloat(7),r.push(a)}return{sensorGroupColors:t,targets:r}}readPathManager(e){let t=[],r=e.readU32();for(let a=0;a<r;a++){let r=e.readU32(),a=e.readU32(),n=[];for(let t=0;t<a;t++)n.push({field0:e.readU32(),field1:e.readU32(),field2:e.readU32(),auxField:e.readU32()});t.push({entryId:r,records:n})}return t}readSimpleTargetManager(e){e.readU8(),e.readU32(),e.readU32(),e.readU32(),e.readU32()}readConnectionProtocol(e){let t=[];for(let r=0;r<32;r++)t.push(e.readU32());let r=e.readU32(),a=e.readU32(),n=e.readU32(),i=e.readU32(),o=e.readU32();return{lastSeqRecvdAtSend:t,lastSeqRecvd:r,highestAckedSeq:a,lastSendSeq:n,ackMask:i,connectSequence:o,lastRecvAckAck:e.readU32(),connectionEstablished:e.readBool()}}readEventStartBlock(e){let t=e.readU32(),r=[];for(fm("event block: nextRecvEventSeq=%d bit=%d",t,e.getCurPos());e.readFlag();){let t,a=e.readInt(6)+255,n=e.getCurPos(),i=this.registry.getEventParser(a);if(i)try{let r={compressionPoint:{x:0,y:0,z:0},ghostTracker:this.ghostTracker,getDataBlockParser:e=>this.registry.getDataBlockParser(e)};t=i.unpack(e,r)}catch{r.push({classId:a,guaranteed:!0,dataBitsStart:n,dataBitsEnd:n});break}else{r.push({classId:a,guaranteed:!0,dataBitsStart:n,dataBitsEnd:n});break}r.push({classId:a,guaranteed:!0,dataBitsStart:n,dataBitsEnd:e.getCurPos(),parsedData:t}),fm(" event classId=%d bits=%d",a,e.getCurPos()-n)}return{nextRecvEventSeq:t,events:r}}readGhostStartBlock(e,t){let r=e.readU32(),a=[];fm("ghost block: seq=%d bit=%d",r,e.getCurPos());let n=this.registry.getGhostCatalog(),i=8*e.getBuffer().length,o=new Map;for(let[e,r]of t)o.set(e,r.data);for(;e.readFlag()&&!e.isError();){let r=e.readInt(10),s=e.readInt(7)+0,l=e.getCurPos(),u=[],c=new Set,{entry:d}=this.identifyGhostViaDataBlock(e,t,n),f=this.registry.getGhostParser(s);f&&(u.push({entry:f,method:"registry"}),c.add(f)),d&&!c.has(d)&&(u.push({entry:d,method:"datablock"}),c.add(d));let h={getDataBlockData:e=>o.get(e),getDataBlockParser:e=>this.registry.getDataBlockParser(e)},m=!1;for(let{entry:t,method:n}of u){let o="registry"===n,u=this.tryGhostParser(e,t,l,i,!1,h,o);if(!1!==u){this.ghostTracker.createGhost(r,s,t.name),fm(" ghost idx=%d classId=%d parser=%s bits=%d via=%s",r,s,t.name,e.getCurPos()-l,n),a.push({index:r,type:"create",classId:s,updateBitsStart:l,updateBitsEnd:e.getCurPos(),parsedData:u}),m=!0;break}}if(!m){fm(" ghost idx=%d classId=%d NO PARSER (stopping at bit=%d, remaining=%d)",r,s,l,i-l);break}}return fm("ghost loop ended at bit=%d remaining=%d count=%d",e.getCurPos(),i-e.getCurPos(),a.length),{ghostingSequence:r,ghosts:a}}tryGhostParser(e,t,r,a,n=!1,i,o=!1){let s=e.savePos();n||fm(" try %s: startBit=%d",t.name,r);try{let l=t.unpackUpdate(e,!0,{compressionPoint:{x:0,y:0,z:0},ghostTracker:this.ghostTracker,...i}),u=e.getCurPos()-r,c=a-e.getCurPos();if(e.isError()||!o&&u<3)return n||fm(" reject %s: bits=%d isError=%s",t.name,u,e.isError()),e.restorePos(s),!1;if(c>1e3){let r=e.getCurPos(),a=e.readFlag();if(e.setCurPos(r),!a)return n||fm(" reject %s: bits=%d misaligned (remaining=%d)",t.name,u,c),e.restorePos(s),!1}return l??{}}catch(r){return n||fm(" reject %s: error at bit=%d: %s",t.name,e.getCurPos(),r instanceof Error?r.message:String(r)),e.restorePos(s),!1}}identifyGhostViaDataBlock(e,t,r){let a;if(!t)return{entry:void 0,dbFlag:!1};let n=e.savePos(),i=!1;try{if(i=e.readFlag()){let n=e.readInt(11),i=t.get(n);if(i){let e=i.className.replace(/Data$/,"");(a=r.get(e))||fm(" identifyGhostViaDataBlock: dbId=%d className=%s ghostName=%s (no ghost parser)",n,i.className,e)}else fm(" identifyGhostViaDataBlock: dbId=%d (no DataBlock found)",n)}else fm(" identifyGhostViaDataBlock: DataBlock flag=0")}catch{}return e.restorePos(n),{entry:a,dbFlag:i}}readRawMove(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),r=t.getInt32(0,!0),a=t.getInt32(4,!0),n=t.getInt32(8,!0),i=t.getUint32(12,!0),o=t.getUint32(16,!0),s=t.getUint32(20,!0),l=t.getFloat32(24,!0),u=t.getFloat32(28,!0),c=t.getFloat32(32,!0),d=t.getFloat32(36,!0),f=t.getFloat32(40,!0),h=t.getFloat32(44,!0),m=t.getUint32(48,!0),p=t.getUint32(52,!0),g=0!==e[56],v=[];for(let t=0;t<6;t++)v.push(0!==e[57+t]);return{px:r,py:a,pz:n,pyaw:i,ppitch:o,proll:s,x:l,y:u,z:c,yaw:d,pitch:f,roll:h,id:m,sendCount:p,freeLook:g,trigger:v}}readInfoBlock(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{value1:t.getUint32(0,!0),value2:t.getFloat32(4,!0)}}}let fv=Object.freeze({r:0,g:255,b:0}),fy=Object.freeze({r:255,g:0,b:0}),fA=new Set(["FlyingVehicle","HoverVehicle","WheeledVehicle"]),fF=new Set(["BombProjectile","EnergyProjectile","FlareProjectile","GrenadeProjectile","LinearFlareProjectile","LinearProjectile","Projectile","SeekerProjectile","TracerProjectile"]),fb=new Set(["LinearProjectile","TracerProjectile","LinearFlareProjectile","Projectile"]),fC=new Set(["GrenadeProjectile","EnergyProjectile","FlareProjectile","BombProjectile"]),fB=new Set(["SeekerProjectile"]),fS=new Set(["StaticShape","ScopeAlwaysShape","Turret","BeaconObject","ForceFieldBare"]),fx=new Set(["TSStatic","InteriorInstance","TerrainBlock","Sky","Sun","MissionArea","PhysicalZone","MissionMarker","SpawnSphere","VehicleBlocker","Camera"]),fE=.494*Math.PI,fM=new u.Matrix4,fD=new u.Quaternion;function fk(e){return null!=e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}function fw(e,t,r){return e<t?t:e>r?r:e}function fI(e){let t=-e/2;return[0,Math.sin(t),0,Math.cos(t)]}function fT(e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.z)||!Number.isFinite(e.w))return null;let t=-e.y,r=-e.z,a=-e.x,n=e.w,i=t*t+r*r+a*a+n*n;if(i<=1e-12)return null;let o=1/Math.sqrt(i);return[t*o,r*o,a*o,n*o]}function fR(e){let t="";for(let r=0;r<e.length;r++)e.charCodeAt(r)>=32&&(t+=e[r]);return t}function fP(e){return"Player"===e?"Player":fA.has(e)?"Vehicle":"Item"===e?"Item":fF.has(e)?"Projectile":fS.has(e)?"Deployable":"Ghost"}function fG(e,t){return"Player"===e?`player_${t}`:fA.has(e)?`vehicle_${t}`:"Item"===e?`item_${t}`:fF.has(e)?`projectile_${t}`:fS.has(e)?`deployable_${t}`:`ghost_${t}`}function fL(e){return!!e&&"object"==typeof e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z&&"number"==typeof e.w}function fj(e){return!!e&&"object"==typeof e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z}function f_(e){if(e){for(let t of[e.shapeName,e.projectileShapeName,e.shapeFileName,e.shapeFile,e.model])if("string"==typeof t&&t.length>0)return t}}function fO(e,t){if(e)for(let r of t){let t=e[r];if("number"==typeof t&&Number.isFinite(t))return t}}function fU(e,t){if(e)for(let r of t){let t=e[r];if("string"==typeof t&&t.length>0)return t}}function fH(e){return e?"number"==typeof e.cameraMode?"camera":"number"==typeof e.rotationZ?"player":null:null}class fN{parser;initialBlock;registry;netStrings=new Map;targetNames=new Map;targetTeams=new Map;sensorGroupColors=new Map;state;constructor(e){this.parser=e,this.registry=e.getRegistry();const t=e.initialBlock;this.initialBlock={dataBlocks:t.dataBlocks,initialGhosts:t.initialGhosts,controlObjectGhostIndex:t.controlObjectGhostIndex,controlObjectData:t.controlObjectData,targetEntries:t.targetEntries,sensorGroupColors:t.sensorGroupColors,taggedStrings:t.taggedStrings},this.state={moveTicks:0,moveYawAccum:0,movePitchAccum:0,yawOffset:0,pitchOffset:0,lastAbsYaw:0,lastAbsPitch:0,lastControlType:"player",isPiloting:!1,lastOrbitDistance:void 0,exhausted:!1,latestFov:100,latestControl:{ghostIndex:t.controlObjectGhostIndex,data:t.controlObjectData,position:fk(t.controlObjectData?.position)?t.controlObjectData?.position:void 0},camera:null,entitiesById:new Map,entityIdByGhostIndex:new Map,lastStatus:{health:1,energy:1},nextExplosionId:0,playerSensorGroup:0},this.reset()}reset(){for(let[e,t]of(this.parser.reset(),this.netStrings.clear(),this.targetNames.clear(),this.targetTeams.clear(),this.sensorGroupColors.clear(),this.state.entitiesById.clear(),this.state.entityIdByGhostIndex.clear(),this.initialBlock.taggedStrings))this.netStrings.set(e,t);for(let e of this.initialBlock.targetEntries)e.name&&this.targetNames.set(e.targetId,fR(e.name)),this.targetTeams.set(e.targetId,e.sensorGroup);for(let e of this.initialBlock.sensorGroupColors){let t=this.sensorGroupColors.get(e.group);t||(t=new Map,this.sensorGroupColors.set(e.group,t)),t.set(e.targetGroup,{r:e.r,g:e.g,b:e.b})}if(this.state.playerSensorGroup=0,this.state.moveTicks=0,this.state.moveYawAccum=0,this.state.movePitchAccum=0,this.state.yawOffset=0,this.state.pitchOffset=0,this.state.lastAbsYaw=0,this.state.lastAbsPitch=0,this.state.lastControlType=fH(this.initialBlock.controlObjectData)??"player",this.state.isPiloting="player"===this.state.lastControlType&&!!(this.initialBlock.controlObjectData?.pilot||this.initialBlock.controlObjectData?.controlObjectGhost!=null),this.state.lastCameraMode="camera"===this.state.lastControlType&&"number"==typeof this.initialBlock.controlObjectData?.cameraMode?this.initialBlock.controlObjectData.cameraMode:void 0,this.state.lastOrbitGhostIndex="camera"===this.state.lastControlType&&"number"==typeof this.initialBlock.controlObjectData?.orbitObjectGhostIndex?this.initialBlock.controlObjectData.orbitObjectGhostIndex:void 0,"camera"===this.state.lastControlType){let e=this.initialBlock.controlObjectData?.minOrbitDist,t=this.initialBlock.controlObjectData?.maxOrbitDist,r=this.initialBlock.controlObjectData?.curOrbitDist;"number"==typeof e&&"number"==typeof t&&Number.isFinite(e)&&Number.isFinite(t)?this.state.lastOrbitDistance=Math.max(0,t-e):"number"==typeof r&&Number.isFinite(r)?this.state.lastOrbitDistance=Math.max(0,r):this.state.lastOrbitDistance=void 0}else this.state.lastOrbitDistance=void 0;let e=this.getAbsoluteRotation(this.initialBlock.controlObjectData);for(let t of(e&&(this.state.lastAbsYaw=e.yaw,this.state.lastAbsPitch=e.pitch,this.state.yawOffset=e.yaw,this.state.pitchOffset=e.pitch),this.state.exhausted=!1,this.state.latestFov=100,this.state.latestControl={ghostIndex:this.initialBlock.controlObjectGhostIndex,data:this.initialBlock.controlObjectData,position:fk(this.initialBlock.controlObjectData?.position)?this.initialBlock.controlObjectData?.position:void 0},this.state.controlPlayerGhostId="player"===this.state.lastControlType&&this.initialBlock.controlObjectGhostIndex>=0?`player_${this.initialBlock.controlObjectGhostIndex}`:void 0,this.state.camera=null,this.state.lastStatus={health:1,energy:1},this.state.nextExplosionId=0,this.initialBlock.initialGhosts)){if("create"!==t.type||null==t.classId)continue;let e=this.registry.getGhostParser(t.classId)?.name??`ghost_${t.classId}`,r=fG(e,t.index),a={id:r,ghostIndex:t.index,className:e,spawnTick:0,type:fP(e),rotation:[0,0,0,1]};this.applyGhostData(a,t.parsedData),this.state.entitiesById.set(r,a),this.state.entityIdByGhostIndex.set(t.index,r)}this.updateCameraAndHud()}getSnapshot(){return this.buildSnapshot()}getEffectShapes(){let e=new Set;for(let[,t]of this.initialBlock.dataBlocks){let r=t.data?.explosion;if(null==r)continue;let a=this.getDataBlockData(r),n=a?.dtsFileName;n&&e.add(n)}return[...e]}stepToTime(e,t=1/0){let r=Math.floor(1e3*(Number.isFinite(e)?Math.max(0,e):0)/32);r<this.state.moveTicks&&this.reset();let a=0;for(;!this.state.exhausted&&this.state.moveTicks<r&&a<t&&this.stepOneMoveTick();)a+=1;return this.buildSnapshot()}stepOneMoveTick(){for(;;){let e=this.parser.nextBlock();if(!e)return this.state.exhausted=!0,!1;if(this.handleBlock(e),2===e.type)return this.state.moveTicks+=1,this.advanceProjectiles(),this.removeExpiredExplosions(),this.updateCameraAndHud(),!0}}handleBlock(e){if(0===e.type&&this.isPacketData(e.parsed)){let t=e.parsed,r=t.gameState.controlObjectData,a=this.state.latestControl,n="number"==typeof t.gameState.controlObjectGhostIndex?t.gameState.controlObjectGhostIndex:a.ghostIndex,i=t.gameState.compressionPoint,o=fk(r?.position)?r?.position:fk(i)?i:a.position;if(this.state.latestControl={ghostIndex:n,data:r,position:o},n!==a.ghostIndex){let e=this.state.entityIdByGhostIndex.get(n),t=e?this.state.entitiesById.get(e):void 0;t?.sensorGroup!=null&&t.sensorGroup>0&&(this.state.playerSensorGroup=t.sensorGroup)}if(r){let e=fH(r);if(e&&(this.state.lastControlType=e),"player"===this.state.lastControlType)this.state.isPiloting=!!(r.pilot||null!=r.controlObjectGhost);else if(this.state.isPiloting=!1,"number"==typeof r.cameraMode)if(this.state.lastCameraMode=r.cameraMode,3===r.cameraMode){"number"==typeof r.orbitObjectGhostIndex&&(this.state.lastOrbitGhostIndex=r.orbitObjectGhostIndex);let e=r.minOrbitDist,t=r.maxOrbitDist,a=r.curOrbitDist;"number"==typeof e&&"number"==typeof t&&Number.isFinite(e)&&Number.isFinite(t)?this.state.lastOrbitDistance=Math.max(0,t-e):"number"==typeof a&&Number.isFinite(a)&&(this.state.lastOrbitDistance=Math.max(0,a))}else this.state.lastOrbitGhostIndex=void 0,this.state.lastOrbitDistance=void 0}for(let e of t.events){let t=this.registry.getEventParser(e.classId)?.name;if("NetStringEvent"===t&&e.parsedData){let t=e.parsedData.id,r=e.parsedData.value;null!=t&&"string"==typeof r&&this.netStrings.set(t,r);continue}if("TargetInfoEvent"===t&&e.parsedData){let t=e.parsedData.targetId,r=e.parsedData.nameTag;if(null!=t&&null!=r){let e=this.netStrings.get(r);e&&this.targetNames.set(t,fR(e))}let a=e.parsedData.sensorGroup;null!=t&&null!=a&&this.targetTeams.set(t,a)}else if("SetSensorGroupEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup;null!=t&&(this.state.playerSensorGroup=t)}else if("SensorGroupColorEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup,r=e.parsedData.colors;if(r){let e=this.sensorGroupColors.get(t);for(let a of(e||(e=new Map,this.sensorGroupColors.set(t,e)),r))a.default?e.delete(a.index):e.set(a.index,{r:a.r??0,g:a.g??0,b:a.b??0})}}}for(let e of t.ghosts)this.applyPacketGhost(e);return}if(3===e.type&&this.isInfoData(e.parsed)){Number.isFinite(e.parsed.value2)&&(this.state.latestFov=e.parsed.value2);return}2===e.type&&this.isMoveData(e.parsed)&&(this.state.moveYawAccum+=e.parsed.yaw??0,this.state.movePitchAccum+=e.parsed.pitch??0)}applyPacketGhost(e){let t=e.index,r=this.state.entityIdByGhostIndex.get(t);if("delete"===e.type){r&&(this.state.entitiesById.delete(r),this.state.entityIdByGhostIndex.delete(t));return}let a=this.resolveGhostClassName(t,e.classId);if(!a)return;let n=fG(a,t);r&&r!==n&&this.state.entitiesById.delete(r);let i=this.state.entitiesById.get(n);i||(i={id:n,ghostIndex:t,className:a,spawnTick:this.state.moveTicks,type:fP(a),rotation:[0,0,0,1]},this.state.entitiesById.set(n,i)),i.ghostIndex=t,i.className=a,i.type=fP(a),this.state.entityIdByGhostIndex.set(t,n),this.applyGhostData(i,e.parsedData)}resolveGhostClassName(e,t){if("number"==typeof t){let e=this.registry.getGhostParser(t)?.name;if(e)return e}let r=this.state.entityIdByGhostIndex.get(e);if(r){let e=this.state.entitiesById.get(r);if(e?.className)return e.className}let a=this.parser.getGhostTracker().getGhost(e);if(a?.className)return a.className}resolveEntityIdForGhostIndex(e){let t=this.state.entityIdByGhostIndex.get(e);if(t)return t;let r=this.parser.getGhostTracker().getGhost(e);if(r)return fG(r.className,e)}getDataBlockData(e){let t=this.initialBlock.dataBlocks.get(e);if(t?.data)return t.data;let r=this.parser.getPacketParser();return r.dataBlockDataMap?.get(e)}resolveExplosionInfo(e){let t=this.getDataBlockData(e),r=t?.explosion;if(null==r)return;let a=this.getDataBlockData(r);if(!a)return;let n=a.dtsFileName;if(!n)return;let i=a.lifetimeMS??31;return{shape:n,faceViewer:!1!==a.faceViewer&&0!==a.faceViewer,lifetimeTicks:i}}applyGhostData(e,t){if(!t)return;let r=t.dataBlockId;if(null!=r){e.dataBlockId=r;let t=this.getDataBlockData(r),a=f_(t);if(e.visual=function(e,t){if(!t)return;let r=fU(t,["tracerTex0","textureName0","texture0"])??"";if(!("TracerProjectile"===e||r.length>0&&null!=fO(t,["tracerLength"]))||!r)return;let a=fU(t,["tracerTex1","textureName1","texture1"]),n=fO(t,["tracerLength"])??10,i=fO(t,["tracerWidth"]),o=fO(t,["tracerAlpha"]),s=null!=i&&(null!=fO(t,["crossViewAng"])||i<=.7)?i:o??i??.5,l=fO(t,["crossViewAng","crossViewFraction"])??("number"==typeof t.tracerWidth&&t.tracerWidth>.7?t.tracerWidth:.98);return{kind:"tracer",texture:r,crossTexture:a,tracerLength:n,tracerWidth:s,crossViewAng:l,crossSize:fO(t,["crossSize","muzzleVelocity"])??.45,renderCross:function(e,t){if(e)for(let r of t){let t=e[r];if("boolean"==typeof t)return t}}(t,["renderCross","proximityRadius"])??!0}}(e.className,t)??function(e,t){if(t){if("LinearFlareProjectile"===e){let e=fU(t,["smokeTexture","flareTexture"]);if(!e)return;let r=t.flareColor,a=fO(t,["size"])??.5;return{kind:"sprite",texture:e,color:r?{r:r.r,g:r.g,b:r.b}:{r:1,g:1,b:1},size:a}}if("FlareProjectile"===e){let e=fU(t,["flareTexture"]);if(!e)return;return{kind:"sprite",texture:e,color:{r:1,g:.9,b:.5},size:fO(t,["size"])??4}}}}(e.className,t),"string"==typeof a&&(e.shapeHint=a,e.dataBlock=a),"Player"===e.type&&"number"==typeof t?.maxEnergy&&(e.maxEnergy=t.maxEnergy),"Projectile"===e.type&&(fb.has(e.className)?e.projectilePhysics="linear":fC.has(e.className)?(e.projectilePhysics="ballistic",e.gravityMod=fO(t,["gravityMod"])??1):fB.has(e.className)&&(e.projectilePhysics="seeker")),"Projectile"===e.type&&!e.explosionShape){let t=this.resolveExplosionInfo(r);t&&(e.explosionShape=t.shape,e.faceViewer=t.faceViewer,e.explosionLifetimeTicks=t.lifetimeTicks)}}if("Player"===e.type){let r=t.images;if(Array.isArray(r)&&r.length>0){let t=r[0];if(t?.dataBlockId&&t.dataBlockId>0){let r=this.getDataBlockData(t.dataBlockId),a=f_(r);if(a){let t=r?.mountPoint;(null==t||t<=0)&&!/pack_/i.test(a)&&(e.weaponShape=a)}}}}let a=fk(t.position)?t.position:fk(t.initialPosition)?t.initialPosition:fk(t.explodePosition)?t.explodePosition:fk(t.endPoint)?t.endPoint:fk(t.transform?.position)?t.transform.position:void 0;a&&(e.position=[a.x,a.y,a.z]);let n=fj(t.direction)?t.direction:void 0;if(n&&(e.direction=[n.x,n.y,n.z]),"Player"===e.type&&"number"==typeof t.rotationZ)e.rotation=fI(t.rotationZ);else if(fL(t.angPosition)){let r=fT(t.angPosition);r&&(e.rotation=r)}else if(fL(t.transform?.rotation)){let r=fT(t.transform.rotation);r&&(e.rotation=r)}else if("Item"===e.type&&"number"==typeof t.rotation?.angle){let r=t.rotation;e.rotation=fI((r.zSign??1)*r.angle)}else if("Projectile"===e.type){let r=t.velocity??t.direction??(fk(t.initialPosition)&&fk(t.endPos)?{x:t.endPos.x-t.initialPosition.x,y:t.endPos.y-t.initialPosition.y,z:t.endPos.z-t.initialPosition.z}:void 0);fj(r)&&(0!==r.x||0!==r.y)&&(e.rotation=fI(Math.atan2(r.x,r.y)))}if(fj(t.velocity)&&(e.velocity=[t.velocity.x,t.velocity.y,t.velocity.z],e.direction||(e.direction=[t.velocity.x,t.velocity.y,t.velocity.z])),e.projectilePhysics){if("linear"===e.projectilePhysics){let r=fO(null!=e.dataBlockId?this.getDataBlockData(e.dataBlockId):void 0,["dryVelocity","muzzleVelocity","bulletVelocity"])??80,a=e.direction??[0,1,0],n=a[0]*r,i=a[1]*r,o=a[2]*r,s=t.excessVel,l=t.excessDir;"number"==typeof s&&s>0&&fj(l)&&(n+=l.x*s,i+=l.y*s,o+=l.z*s),e.simulatedVelocity=[n,i,o]}else e.velocity&&(e.simulatedVelocity=[e.velocity[0],e.velocity[1],e.velocity[2]]);let r=t.currTick;if("number"==typeof r&&r>0&&e.simulatedVelocity&&e.position){let t=.032*r,a=e.simulatedVelocity;if(e.position[0]+=a[0]*t,e.position[1]+=a[1]*t,e.position[2]+=a[2]*t,"ballistic"===e.projectilePhysics){let r=9.81*(e.gravityMod??1);e.position[2]-=.5*r*t*t,a[2]-=r*t}}}let i=fk(t.explodePosition)?t.explodePosition:fk(t.explodePoint)?t.explodePoint:void 0;if("Projectile"===e.type&&!e.hasExploded&&i&&e.explosionShape){e.hasExploded=!0;let t=`fx_${this.state.nextExplosionId++}`,r=e.explosionLifetimeTicks??31,a={id:t,ghostIndex:-1,className:"Explosion",spawnTick:this.state.moveTicks,type:"Explosion",dataBlock:e.explosionShape,position:[i.x,i.y,i.z],rotation:[0,0,0,1],isExplosion:!0,faceViewer:!1!==e.faceViewer,expiryTick:this.state.moveTicks+r};this.state.entitiesById.set(t,a),e.position=void 0,e.simulatedVelocity=void 0}if("number"==typeof t.damageLevel&&(e.health=fw(1-t.damageLevel,0,1)),"number"==typeof t.energy&&(e.energy=fw(t.energy,0,1)),"number"==typeof t.targetId){e.targetId=t.targetId;let r=this.targetNames.get(t.targetId);r&&(e.playerName=r);let a=this.targetTeams.get(t.targetId);null!=a&&(e.sensorGroup=a,e.ghostIndex===this.state.latestControl.ghostIndex&&"player"===this.state.lastControlType&&(this.state.playerSensorGroup=a))}}advanceProjectiles(){for(let e of this.state.entitiesById.values()){if(!e.simulatedVelocity||!e.position)continue;let t=e.simulatedVelocity,r=e.position;if("ballistic"===e.projectilePhysics){let r=9.81*(e.gravityMod??1);t[2]-=.032*r}r[0]+=.032*t[0],r[1]+=.032*t[1],r[2]+=.032*t[2],(0!==t[0]||0!==t[1])&&(e.rotation=fI(Math.atan2(t[0],t[1])))}}removeExpiredExplosions(){for(let[e,t]of this.state.entitiesById)t.isExplosion&&null!=t.expiryTick&&this.state.moveTicks>=t.expiryTick&&this.state.entitiesById.delete(e)}updateCameraAndHud(){let e=this.state.latestControl,t=.032*this.state.moveTicks,r=e.data,a=this.state.lastControlType;if(e.position){var n,i;let o,s,l,u,c=this.getAbsoluteRotation(r),d=!this.state.isPiloting&&"player"===a,f=d?this.state.moveYawAccum+this.state.yawOffset:this.state.lastAbsYaw,h=d?this.state.movePitchAccum+this.state.pitchOffset:this.state.lastAbsPitch,m=f,p=h;if(c?(m=c.yaw,p=c.pitch,this.state.lastAbsYaw=m,this.state.lastAbsPitch=p,this.state.yawOffset=m-this.state.moveYawAccum,this.state.pitchOffset=p-this.state.movePitchAccum):d?(this.state.lastAbsYaw=m,this.state.lastAbsPitch=p):(m=this.state.lastAbsYaw,p=this.state.lastAbsPitch),this.state.camera={time:t,position:[e.position.x,e.position.y,e.position.z],rotation:(n=m,o=Math.sin(i=fw(p,-fE,fE)),s=Math.cos(i),l=Math.sin(n),u=Math.cos(n),fM.set(-l,u*o,-u*s,0,0,s,o,0,u,l*o,-l*s,0,0,0,0,1),fD.setFromRotationMatrix(fM),[fD.x,fD.y,fD.z,fD.w]),fov:this.state.latestFov,mode:"observer",yaw:m,pitch:p},"camera"===a)if(("number"==typeof r?.cameraMode?r.cameraMode:this.state.lastCameraMode)===3){this.state.camera.mode="third-person","number"==typeof this.state.lastOrbitDistance&&(this.state.camera.orbitDistance=this.state.lastOrbitDistance);let e="number"==typeof r?.orbitObjectGhostIndex?r.orbitObjectGhostIndex:this.state.lastOrbitGhostIndex;"number"==typeof e&&e>=0&&(this.state.camera.orbitTargetId=this.resolveEntityIdForGhostIndex(e))}else this.state.camera.mode="observer";else this.state.camera.mode="first-person",e.ghostIndex>=0&&(this.state.controlPlayerGhostId=`player_${e.ghostIndex}`),this.state.controlPlayerGhostId&&(this.state.camera.controlEntityId=this.state.controlPlayerGhostId);if("player"===a&&!this.state.isPiloting&&this.state.controlPlayerGhostId&&e.position){let t=this.state.entitiesById.get(this.state.controlPlayerGhostId);t&&(t.position=[e.position.x,e.position.y,e.position.z],t.rotation=fI(m))}}else this.state.camera&&(this.state.camera={...this.state.camera,time:t,fov:this.state.latestFov});let o={health:1,energy:1};if(this.state.camera?.mode==="first-person"){let e=this.state.controlPlayerGhostId,t=e?this.state.entitiesById.get(e):void 0;o.health=t?.health??1;let a=r?.energyLevel;if("number"==typeof a){let e=t?.maxEnergy??60;e>0&&(o.energy=fw(a/e,0,1))}else o.energy=t?.energy??1}else if(this.state.camera?.mode==="third-person"&&this.state.camera.orbitTargetId){let e=this.state.entitiesById.get(this.state.camera.orbitTargetId);o.health=e?.health??1,o.energy=e?.energy??1}this.state.lastStatus=o}buildSnapshot(){let e=[];for(let t of this.state.entitiesById.values())(t.spawnTick>0||!fx.has(t.className))&&e.push({id:t.id,type:t.type,visual:t.visual,direction:t.direction,ghostIndex:t.ghostIndex,className:t.className,dataBlockId:t.dataBlockId,shapeHint:t.shapeHint,dataBlock:t.dataBlock,weaponShape:t.weaponShape,playerName:t.playerName,iffColor:"Player"===t.type&&null!=t.sensorGroup?this.resolveIffColor(t.sensorGroup):void 0,position:t.position?[...t.position]:void 0,rotation:t.rotation?[...t.rotation]:void 0,velocity:t.velocity,health:t.health,energy:t.energy,faceViewer:t.faceViewer});return{timeSec:.032*this.state.moveTicks,exhausted:this.state.exhausted,camera:this.state.camera,entities:e,controlPlayerGhostId:this.state.controlPlayerGhostId,status:this.state.lastStatus}}resolveIffColor(e){if(0===this.state.playerSensorGroup)return;let t=this.sensorGroupColors.get(this.state.playerSensorGroup);if(t){let r=t.get(e);if(r)return r}return e===this.state.playerSensorGroup?fv:0!==e?fy:void 0}getAbsoluteRotation(e){return e?"number"==typeof e.rotationZ&&"number"==typeof e.headX?{yaw:e.rotationZ,pitch:e.headX}:"number"==typeof e.rotZ&&"number"==typeof e.rotX?{yaw:e.rotZ,pitch:e.rotX}:null:null}isPacketData(e){return!!e&&"object"==typeof e&&"gameState"in e&&"events"in e&&"ghosts"in e}isMoveData(e){return!!e&&"object"==typeof e&&"yaw"in e}isInfoData(e){return!!e&&"object"==typeof e&&"value2"in e&&"number"==typeof e.value2}}async function fJ(e){let t=new fg(new Uint8Array(e)),{header:r,initialBlock:a}=await t.load(),{missionName:n,gameType:i}=function(e){let t=null,r=null;for(let a=0;a<e.length;a++){if("readplayerinfo"!==e[a])continue;let n=e[a+1];if(n){if(n.startsWith("2 ")){let e=n.split(" ");e[4]&&(t=e[4]);continue}if(n.startsWith("3 ")){let e=n.split(" ");e[2]&&(r=e[2])}}}return{missionName:t,gameType:r}}(a.demoValues);return{duration:r.demoLengthMs/1e3,missionName:n??a.missionName??null,gameType:i,entities:[],cameraModes:[],isMetadataOnly:!0,isPartial:!0,streamingPlayback:new fN(t)}}function fK(){let e,t,r,a,s,l,u,c,d=(0,i.c)(20),f=r$(),{setRecording:h}=r4(),m=(0,o.useRef)(null),p=(0,o.useRef)(0);d[0]!==f||d[1]!==h?(e=()=>{if(f){p.current=p.current+1,h(null);return}m.current?.click()},d[0]=f,d[1]=h,d[2]=e):e=d[2];let g=e;d[3]!==h?(t=async e=>{let t=e.target.files?.[0];if(t){e.target.value="";try{let e=await t.arrayBuffer(),r=p.current+1;p.current=r;let a=await fJ(e);if(p.current!==r)return;h(a)}catch(e){console.error("Failed to load demo:",e)}}},d[3]=h,d[4]=t):t=d[4];let v=t;d[5]===Symbol.for("react.memo_cache_sentinel")?(r={display:"none"},d[5]=r):r=d[5],d[6]!==v?(a=(0,n.jsx)("input",{ref:m,type:"file",accept:".rec",style:r,onChange:v}),d[6]=v,d[7]=a):a=d[7];let y=f?"Unload demo":"Load demo (.rec)",A=f?"Unload demo":"Load demo (.rec)",F=f?"true":void 0;d[8]===Symbol.for("react.memo_cache_sentinel")?(s=(0,n.jsx)(lo,{className:"DemoIcon"}),d[8]=s):s=d[8];let b=f?"Unload demo":"Demo";return d[9]!==b?(l=(0,n.jsx)("span",{className:"ButtonLabel",children:b}),d[9]=b,d[10]=l):l=d[10],d[11]!==g||d[12]!==y||d[13]!==A||d[14]!==F||d[15]!==l?(u=(0,n.jsxs)("button",{type:"button",className:"IconButton LabelledButton","aria-label":y,title:A,onClick:g,"data-active":F,children:[s,l]}),d[11]=g,d[12]=y,d[13]=A,d[14]=F,d[15]=l,d[16]=u):u=d[16],d[17]!==u||d[18]!==a?(c=(0,n.jsxs)(n.Fragment,{children:[a,u]}),d[17]=u,d[18]=a,d[19]=c):c=d[19],c}function fV(e){return(0,la.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12.01",y2:"8"},child:[]}]})(e)}function fz(e){return(0,la.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(e)}function fq(e){let t,r,a,s,l,u,c,d,f,h,m,p,g,v,y,A,F,b,C,B,S,x,M,D,k,w,I,T,R,P,G,L,j,_,O,U,H,N,J,K,V,z,q,Q,W,X=(0,i.c)(103),{missionName:Y,missionType:Z,onChangeMission:$,onOpenMapInfo:ee,cameraRef:et,isTouch:er}=e,{fogEnabled:ea,setFogEnabled:en,fov:ei,setFov:eo,audioEnabled:es,setAudioEnabled:el,animationEnabled:eu,setAnimationEnabled:ec}=(0,E.useSettings)(),{speedMultiplier:ed,setSpeedMultiplier:ef,touchMode:eh,setTouchMode:em}=(0,E.useControls)(),{debugMode:ep,setDebugMode:eg}=(0,E.useDebug)(),ev=null!=r$(),[ey,eA]=(0,o.useState)(!1),eF=(0,o.useRef)(null),eb=(0,o.useRef)(null),eC=(0,o.useRef)(null);X[0]!==ey?(t=()=>{ey&&eF.current?.focus()},r=[ey],X[0]=ey,X[1]=t,X[2]=r):(t=X[1],r=X[2]),(0,o.useEffect)(t,r),X[3]===Symbol.for("react.memo_cache_sentinel")?(a=e=>{let t=e.relatedTarget;t&&eC.current?.contains(t)||eA(!1)},X[3]=a):a=X[3];let eB=a;X[4]===Symbol.for("react.memo_cache_sentinel")?(s=e=>{"Escape"===e.key&&(eA(!1),eb.current?.focus())},X[4]=s):s=X[4];let eS=s;return X[5]!==ev||X[6]!==Y||X[7]!==Z||X[8]!==$?(l=(0,n.jsx)(lt,{value:Y,missionType:Z,onChange:$,disabled:ev}),X[5]=ev,X[6]=Y,X[7]=Z,X[8]=$,X[9]=l):l=X[9],X[10]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{eA(fQ)},X[10]=u):u=X[10],X[11]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)(fz,{}),X[11]=c):c=X[11],X[12]!==ey?(d=(0,n.jsx)("button",{ref:eb,className:"IconButton Controls-toggle",onClick:u,"aria-expanded":ey,"aria-controls":"settingsPanel","aria-label":"Settings",children:c}),X[12]=ey,X[13]=d):d=X[13],X[14]!==et||X[15]!==Y||X[16]!==Z?(f=(0,n.jsx)(li,{cameraRef:et,missionName:Y,missionType:Z}),X[14]=et,X[15]=Y,X[16]=Z,X[17]=f):f=X[17],X[18]===Symbol.for("react.memo_cache_sentinel")?(h=(0,n.jsx)(fK,{}),X[18]=h):h=X[18],X[19]===Symbol.for("react.memo_cache_sentinel")?(m=(0,n.jsx)(fV,{}),p=(0,n.jsx)("span",{className:"ButtonLabel",children:"Show map info"}),X[19]=m,X[20]=p):(m=X[19],p=X[20]),X[21]!==ee?(g=(0,n.jsxs)("button",{type:"button",className:"IconButton LabelledButton MapInfoButton","aria-label":"Show map info",onClick:ee,children:[m,p]}),X[21]=ee,X[22]=g):g=X[22],X[23]!==g||X[24]!==f?(v=(0,n.jsxs)("div",{className:"Controls-group",children:[f,h,g]}),X[23]=g,X[24]=f,X[25]=v):v=X[25],X[26]!==en?(y=e=>{en(e.target.checked)},X[26]=en,X[27]=y):y=X[27],X[28]!==ea||X[29]!==y?(A=(0,n.jsx)("input",{id:"fogInput",type:"checkbox",checked:ea,onChange:y}),X[28]=ea,X[29]=y,X[30]=A):A=X[30],X[31]===Symbol.for("react.memo_cache_sentinel")?(F=(0,n.jsx)("label",{htmlFor:"fogInput",children:"Fog?"}),X[31]=F):F=X[31],X[32]!==A?(b=(0,n.jsxs)("div",{className:"CheckboxField",children:[A,F]}),X[32]=A,X[33]=b):b=X[33],X[34]!==el?(C=e=>{el(e.target.checked)},X[34]=el,X[35]=C):C=X[35],X[36]!==es||X[37]!==C?(B=(0,n.jsx)("input",{id:"audioInput",type:"checkbox",checked:es,onChange:C}),X[36]=es,X[37]=C,X[38]=B):B=X[38],X[39]===Symbol.for("react.memo_cache_sentinel")?(S=(0,n.jsx)("label",{htmlFor:"audioInput",children:"Audio?"}),X[39]=S):S=X[39],X[40]!==B?(x=(0,n.jsxs)("div",{className:"CheckboxField",children:[B,S]}),X[40]=B,X[41]=x):x=X[41],X[42]!==b||X[43]!==x?(M=(0,n.jsxs)("div",{className:"Controls-group",children:[b,x]}),X[42]=b,X[43]=x,X[44]=M):M=X[44],X[45]!==ec?(D=e=>{ec(e.target.checked)},X[45]=ec,X[46]=D):D=X[46],X[47]!==eu||X[48]!==D?(k=(0,n.jsx)("input",{id:"animationInput",type:"checkbox",checked:eu,onChange:D}),X[47]=eu,X[48]=D,X[49]=k):k=X[49],X[50]===Symbol.for("react.memo_cache_sentinel")?(w=(0,n.jsx)("label",{htmlFor:"animationInput",children:"Animation?"}),X[50]=w):w=X[50],X[51]!==k?(I=(0,n.jsxs)("div",{className:"CheckboxField",children:[k,w]}),X[51]=k,X[52]=I):I=X[52],X[53]!==eg?(T=e=>{eg(e.target.checked)},X[53]=eg,X[54]=T):T=X[54],X[55]!==ep||X[56]!==T?(R=(0,n.jsx)("input",{id:"debugInput",type:"checkbox",checked:ep,onChange:T}),X[55]=ep,X[56]=T,X[57]=R):R=X[57],X[58]===Symbol.for("react.memo_cache_sentinel")?(P=(0,n.jsx)("label",{htmlFor:"debugInput",children:"Debug?"}),X[58]=P):P=X[58],X[59]!==R?(G=(0,n.jsxs)("div",{className:"CheckboxField",children:[R,P]}),X[59]=R,X[60]=G):G=X[60],X[61]!==I||X[62]!==G?(L=(0,n.jsxs)("div",{className:"Controls-group",children:[I,G]}),X[61]=I,X[62]=G,X[63]=L):L=X[63],X[64]===Symbol.for("react.memo_cache_sentinel")?(j=(0,n.jsx)("label",{htmlFor:"fovInput",children:"FOV"}),X[64]=j):j=X[64],X[65]!==eo?(_=e=>eo(parseInt(e.target.value)),X[65]=eo,X[66]=_):_=X[66],X[67]!==ei||X[68]!==ev||X[69]!==_?(O=(0,n.jsx)("input",{id:"fovInput",type:"range",min:75,max:120,step:5,value:ei,disabled:ev,onChange:_}),X[67]=ei,X[68]=ev,X[69]=_,X[70]=O):O=X[70],X[71]!==ei?(U=(0,n.jsx)("output",{htmlFor:"fovInput",children:ei}),X[71]=ei,X[72]=U):U=X[72],X[73]!==O||X[74]!==U?(H=(0,n.jsxs)("div",{className:"Field",children:[j,O,U]}),X[73]=O,X[74]=U,X[75]=H):H=X[75],X[76]===Symbol.for("react.memo_cache_sentinel")?(N=(0,n.jsx)("label",{htmlFor:"speedInput",children:"Speed"}),X[76]=N):N=X[76],X[77]!==ef?(J=e=>ef(parseFloat(e.target.value)),X[77]=ef,X[78]=J):J=X[78],X[79]!==ev||X[80]!==ed||X[81]!==J?(K=(0,n.jsxs)("div",{className:"Field",children:[N,(0,n.jsx)("input",{id:"speedInput",type:"range",min:.1,max:5,step:.05,value:ed,disabled:ev,onChange:J})]}),X[79]=ev,X[80]=ed,X[81]=J,X[82]=K):K=X[82],X[83]!==H||X[84]!==K?(V=(0,n.jsxs)("div",{className:"Controls-group",children:[H,K]}),X[83]=H,X[84]=K,X[85]=V):V=X[85],X[86]!==er||X[87]!==em||X[88]!==eh?(z=er&&(0,n.jsx)("div",{className:"Controls-group",children:(0,n.jsxs)("div",{className:"Field",children:[(0,n.jsx)("label",{htmlFor:"touchModeInput",children:"Joystick:"})," ",(0,n.jsxs)("select",{id:"touchModeInput",value:eh,onChange:e=>em(e.target.value),children:[(0,n.jsx)("option",{value:"dualStick",children:"Dual Stick"}),(0,n.jsx)("option",{value:"moveLookStick",children:"Single Stick"})]})]})}),X[86]=er,X[87]=em,X[88]=eh,X[89]=z):z=X[89],X[90]!==ey||X[91]!==v||X[92]!==M||X[93]!==L||X[94]!==V||X[95]!==z?(q=(0,n.jsxs)("div",{className:"Controls-dropdown",ref:eF,id:"settingsPanel",tabIndex:-1,onKeyDown:eS,onBlur:eB,"data-open":ey,children:[v,M,L,V,z]}),X[90]=ey,X[91]=v,X[92]=M,X[93]=L,X[94]=V,X[95]=z,X[96]=q):q=X[96],X[97]!==q||X[98]!==d?(Q=(0,n.jsxs)("div",{ref:eC,children:[d,q]}),X[97]=q,X[98]=d,X[99]=Q):Q=X[99],X[100]!==Q||X[101]!==l?(W=(0,n.jsxs)("div",{id:"controls",onKeyDown:fY,onPointerDown:fX,onClick:fW,children:[l,Q]}),X[100]=Q,X[101]=l,X[102]=W):W=X[102],W}function fQ(e){return!e}function fW(e){return e.stopPropagation()}function fX(e){return e.stopPropagation()}function fY(e){return e.stopPropagation()}let fZ=()=>null,f$=o.forwardRef(({envMap:e,resolution:t=256,frames:r=1/0,makeDefault:a,children:n,...i},s)=>{let l=(0,F.useThree)(({set:e})=>e),c=(0,F.useThree)(({camera:e})=>e),d=(0,F.useThree)(({size:e})=>e),f=o.useRef(null);o.useImperativeHandle(s,()=>f.current,[]);let h=o.useRef(null),m=function(e,t,r){let a=(0,F.useThree)(e=>e.size),n=(0,F.useThree)(e=>e.viewport),i="number"==typeof e?e:a.width*n.dpr,s=a.height*n.dpr,l=("number"==typeof e?void 0:e)||{},{samples:c=0,depth:d,...f}=l,h=null!=d?d:l.depthBuffer,m=o.useMemo(()=>{let e=new u.WebGLRenderTarget(i,s,{minFilter:u.LinearFilter,magFilter:u.LinearFilter,type:u.HalfFloatType,...f});return h&&(e.depthTexture=new u.DepthTexture(i,s,u.FloatType)),e.samples=c,e},[]);return o.useLayoutEffect(()=>{m.setSize(i,s),c&&(m.samples=c)},[c,m,i,s]),o.useEffect(()=>()=>m.dispose(),[]),m}(t);o.useLayoutEffect(()=>{i.manual||(f.current.aspect=d.width/d.height)},[d,i]),o.useLayoutEffect(()=>{f.current.updateProjectionMatrix()});let p=0,g=null,v="function"==typeof n;return(0,A.useFrame)(t=>{v&&(r===1/0||p<r)&&(h.current.visible=!1,t.gl.setRenderTarget(m),g=t.scene.background,e&&(t.scene.background=e),t.gl.render(t.scene,f.current),t.scene.background=g,t.gl.setRenderTarget(null),h.current.visible=!0,p++)}),o.useLayoutEffect(()=>{if(a)return l(()=>({camera:f.current})),()=>l(()=>({camera:c}))},[f,a,l]),o.createElement(o.Fragment,null,o.createElement("perspectiveCamera",(0,W.default)({ref:f},i),!v&&n),o.createElement("group",{ref:h},v&&n(m.texture)))});function f0(){let e,t,r=(0,i.c)(3),{fov:a}=(0,E.useSettings)();return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=[0,256,0],r[0]=e):e=r[0],r[1]!==a?(t=(0,n.jsx)(f$,{makeDefault:!0,position:e,fov:a}),r[1]=a,r[2]=t):t=r[2],t}var f1=e.i(51434),f2=e.i(81405);function f3(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}function f9({showPanel:e=0,className:t,parent:r}){let a=function(e,t=[],r){let[a,n]=o.useState();return o.useLayoutEffect(()=>{let t=e();return n(t),f3(void 0,t),()=>f3(void 0,null)},t),a}(()=>new f2.default,[]);return o.useEffect(()=>{if(a){let n=r&&r.current||document.body;a.showPanel(e),null==n||n.appendChild(a.dom);let i=(null!=t?t:"").split(" ").filter(e=>e);i.length&&a.dom.classList.add(...i);let o=(0,s.j)(()=>a.begin()),l=(0,s.k)(()=>a.end());return()=>{i.length&&a.dom.classList.remove(...i),null==n||n.removeChild(a.dom),o(),l()}}},[r,a,t,e]),null}var f5=e.i(60099);function f8(){let e,t,r=(0,i.c)(3),{debugMode:a}=(0,E.useDebug)(),s=(0,o.useRef)(null);return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{let e=s.current;e&&e.setColors("rgb(153, 255, 0)","rgb(0, 153, 255)","rgb(255, 153, 0)")},r[0]=e):e=r[0],(0,o.useEffect)(e),r[1]!==a?(t=a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(f9,{className:"StatsPanel"}),(0,n.jsx)("axesHelper",{ref:s,args:[70],renderOrder:999,children:(0,n.jsx)("lineBasicMaterial",{depthTest:!1,depthWrite:!1,fog:!1,vertexColors:!0})}),(0,n.jsx)(f5.Html,{position:[80,0,0],center:!0,children:(0,n.jsx)("span",{className:"AxisLabel","data-axis":"y",children:"Y"})}),(0,n.jsx)(f5.Html,{position:[0,80,0],center:!0,children:(0,n.jsx)("span",{className:"AxisLabel","data-axis":"z",children:"Z"})}),(0,n.jsx)(f5.Html,{position:[0,0,80],center:!0,children:(0,n.jsx)("span",{className:"AxisLabel","data-axis":"x",children:"X"})})]}):null,r[1]=a,r[2]=t):t=r[2],t}var f4=o;let f6=new u.Vector3,f7=new u.Quaternion,he=new u.Quaternion,ht=new u.Quaternion,hr=new u.Vector3,ha=new u.Vector3,hn=new u.Vector3,hi=new u.Vector3,ho=new u.Raycaster,hs=new u.Vector3,hl=new u.Vector3,hu=new u.Vector3,hc=new u.Vector3,hd=new u.Vector3,hf=new u.Vector3,hh=new u.Vector3,hm=new u.Vector3,hp=new u.Matrix4,hg=new u.Vector3(0,1,0),hv=new u.Quaternion().setFromAxisAngle(new u.Vector3(0,1,0),Math.PI/2),hy=hv.clone().invert();function hA(e,t){return 180*(2*Math.atan(Math.tan(Math.max(.01,Math.min(179.99,e))*Math.PI/180/2)/(Number.isFinite(t)&&t>1e-6?t:4/3)))/Math.PI}function hF(e){e.wrapS=u.ClampToEdgeWrapping,e.wrapT=u.ClampToEdgeWrapping,e.minFilter=u.LinearFilter,e.magFilter=u.LinearFilter,e.colorSpace=u.NoColorSpace,e.flipY=!1,e.needsUpdate=!0}function hb(e,t){return t.set(e[1],e[2],e[0])}function hC(e,t){if(0===e.length)return null;if(t<=e[0].time)return e[0];if(t>=e[e.length-1].time)return e[e.length-1];let r=0,a=e.length-1;for(;a-r>1;){let n=r+a>>1;e[n].time<=t?r=n:a=n}return e[r]}function hB(e,t,r){let a=e.clone(!0),n=t.find(e=>"Root"===e.name);if(n){let e=new u.AnimationMixer(a);e.clipAction(n).play(),e.setTime(0)}a.updateMatrixWorld(!0);let i=null,o=null;return(a.traverse(e=>{i||e.name!==r||(i=new u.Vector3,o=new u.Quaternion,e.getWorldPosition(i),e.getWorldQuaternion(o))}),i&&o)?{position:i,quaternion:o}:null}let hS=new u.TextureLoader;function hx(e,t){let r=e.userData?.resource_path,a=new Set(e.userData?.flag_names??[]);if(!r){let t=new u.MeshLambertMaterial({color:e.color,side:2,reflectivity:0});return tL(t),t}let n=(0,y.textureToUrl)(r),i=hS.load(n);(0,C.setupTexture)(i);let o=tj(e,i,a,!1,t);return Array.isArray(o)?o[1]:o}function hE(e){let t=null;e.traverse(e=>{!t&&e.skeleton&&(t=e.skeleton)});let r=t?tB(t):new Set;e.traverse(e=>{if(!e.isMesh)return;if(e.name.match(/^Hulk/i)||e.material?.name==="Unassigned"||(e.userData?.vis??1)<.01){e.visible=!1;return}if(e.geometry){let t=tS(e.geometry,r);!function(e){e.computeVertexNormals();let t=e.attributes.position,r=e.attributes.normal;if(!t||!r)return;let a=t.array,n=r.array,i=new Map;for(let e=0;e<t.count;e++){let t=`${a[3*e].toFixed(4)},${a[3*e+1].toFixed(4)},${a[3*e+2].toFixed(4)}`;i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let e of i.values())if(e.length>1){let t=0,r=0,a=0;for(let i of e)t+=n[3*i],r+=n[3*i+1],a+=n[3*i+2];let i=Math.sqrt(t*t+r*r+a*a);for(let o of(i>0&&(t/=i,r/=i,a/=i),e))n[3*o]=t,n[3*o+1]=r,n[3*o+2]=a}r.needsUpdate=!0}(t=t.clone()),e.geometry=t}let t=e.userData?.vis??1;Array.isArray(e.material)?e.material=e.material.map(e=>hx(e,t)):e.material&&(e.material=hx(e.material,t))})}function hM({recording:e}){let{gl:t,scene:r}=(0,F.useThree)(),a=(0,R.useEngineStoreApi)(),n=(0,f4.useRef)(null),i=(0,f4.useRef)(0);return(0,f4.useEffect)(()=>{a.getState().recordPlaybackDiagnosticEvent({kind:"recording.loaded",meta:{missionName:e.missionName??null,gameType:e.gameType??null,isMetadataOnly:!!e.isMetadataOnly,isPartial:!!e.isPartial,hasStreamingPlayback:!!e.streamingPlayback,durationSec:Number(e.duration.toFixed(3))}})},[a]),(0,f4.useEffect)(()=>{let e=t.domElement;if(!e)return;let r=()=>{try{let e=t.getContext();if(e&&"function"==typeof e.isContextLost)return!!e.isContextLost()}catch{}},n=e=>{e.preventDefault();let t=a.getState();t.setWebglContextLost(!0),t.recordPlaybackDiagnosticEvent({kind:"webgl.context.lost",message:"Renderer emitted webglcontextlost",meta:{contextLost:r()}}),console.error("[demo diagnostics] WebGL context lost")},i=()=>{let e=a.getState();e.setWebglContextLost(!1),e.recordPlaybackDiagnosticEvent({kind:"webgl.context.restored",message:"Renderer emitted webglcontextrestored",meta:{contextLost:r()}}),console.warn("[demo diagnostics] WebGL context restored")},o=e=>{a.getState().recordPlaybackDiagnosticEvent({kind:"webgl.context.creation_error",message:e.statusMessage??"Context creation error",meta:{contextLost:r()}}),console.error("[demo diagnostics] WebGL context creation error",e.statusMessage??"")};return e.addEventListener("webglcontextlost",n,!1),e.addEventListener("webglcontextrestored",i,!1),e.addEventListener("webglcontextcreationerror",o,!1),()=>{e.removeEventListener("webglcontextlost",n,!1),e.removeEventListener("webglcontextrestored",i,!1),e.removeEventListener("webglcontextcreationerror",o,!1)}},[a,t]),(0,f4.useEffect)(()=>{let e=()=>{let e,o,{sceneObjects:s,visibleSceneObjects:l}=(e=0,o=0,r.traverse(t=>{e+=1,t.visible&&(o+=1)}),{sceneObjects:e,visibleSceneObjects:o}),u=Array.isArray(t.info.programs)?t.info.programs.length:0,c=performance.memory,d={t:Date.now(),geometries:t.info.memory.geometries,textures:t.info.memory.textures,programs:u,renderCalls:t.info.render.calls,renderTriangles:t.info.render.triangles,renderPoints:t.info.render.points,renderLines:t.info.render.lines,sceneObjects:s,visibleSceneObjects:l,jsHeapUsed:c?.usedJSHeapSize,jsHeapTotal:c?.totalJSHeapSize,jsHeapLimit:c?.jsHeapSizeLimit};a.getState().appendRendererSample(d);let f=n.current;if(n.current={geometries:d.geometries,textures:d.textures,programs:d.programs,sceneObjects:d.sceneObjects,visibleSceneObjects:d.visibleSceneObjects},!f)return;let h=d.t,m=d.geometries-f.geometries,p=d.textures-f.textures,g=d.programs-f.programs,v=d.sceneObjects-f.sceneObjects;h-i.current>=5e3&&(m>=200||p>=100||g>=20||v>=400)&&(i.current=h,a.getState().recordPlaybackDiagnosticEvent({kind:"renderer.resource.spike",message:"Detected large one-second renderer resource increase",meta:{geometryDelta:m,textureDelta:p,programDelta:g,sceneObjectDelta:v,geometries:d.geometries,textures:d.textures,programs:d.programs,sceneObjects:d.sceneObjects}}))};e();let o=window.setInterval(e,1e3);return()=>{window.clearInterval(o)}},[a,t,r]),null}function hD(){let e=(0,R.useEngineStoreApi)(),t=r$(),r=(0,f4.useRef)(null);return(r.current||(r.current=hj("DemoPlayback")),(0,f4.useEffect)(()=>{hT+=1;let a=Date.now();return e.getState().recordPlaybackDiagnosticEvent({kind:"component.lifecycle",message:"DemoPlayback mounted",meta:{component:"DemoPlayback",phase:"mount",instanceId:r.current,mountCount:hT,unmountCount:hR,recordingMissionName:t?.missionName??null,recordingDurationSec:t?Number(t.duration.toFixed(3)):null,ts:a}}),console.info("[demo diagnostics] DemoPlayback mounted",{instanceId:r.current,mountCount:hT,unmountCount:hR,recordingMissionName:t?.missionName??null,mountedAt:a}),()=>{hR+=1;let a=Date.now();e.getState().recordPlaybackDiagnosticEvent({kind:"component.lifecycle",message:"DemoPlayback unmounted",meta:{component:"DemoPlayback",phase:"unmount",instanceId:r.current,mountCount:hT,unmountCount:hR,recordingMissionName:t?.missionName??null,ts:a}}),console.info("[demo diagnostics] DemoPlayback unmounted",{instanceId:r.current,mountCount:hT,unmountCount:hR,recordingMissionName:t?.missionName??null,unmountedAt:a})}},[e]),t)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(hM,{recording:t}),t.isMetadataOnly||t.isPartial?(0,n.jsx)(h_,{recording:t}):(0,n.jsx)(hk,{recording:t})]}):null}function hk(e){let t,r,a,o,s,l,c,d,f,h,m,p,g,v,y=(0,i.c)(38),{recording:F}=e,b=(0,R.useEngineStoreApi)(),C=(0,f4.useRef)(null),B=(0,f4.useRef)(null),S=(0,f4.useRef)(0);y[0]===Symbol.for("react.memo_cache_sentinel")?(t=new u.Vector3(0,2.1,0),y[0]=t):t=y[0];let x=(0,f4.useRef)(t);e:{let e,t,a;if(!F){let e;y[1]===Symbol.for("react.memo_cache_sentinel")?(e={cameraEntity:null,otherEntities:[]},y[1]=e):e=y[1],r=e;break e}y[2]!==F.entities?(e=F.entities.find(hI)??null,y[2]=F.entities,y[3]=e):e=y[3];let n=e;y[4]!==F.entities?(t=F.entities.filter(hw),y[4]=F.entities,y[5]=t):t=y[5];let i=t;y[6]!==n||y[7]!==i?(a={cameraEntity:n,otherEntities:i},y[6]=n,y[7]=i,y[8]=a):a=y[8],r=a}let{cameraEntity:E,otherEntities:M}=r;if(y[9]!==M){for(let e of(a=new Map,M))a.set(String(e.id),function(e){let{keyframes:t}=e,r=String(e.id),a=new Float32Array(t.length),n=new Float32Array(3*t.length),i=new Float32Array(4*t.length);for(let e=0;e<t.length;e++){let r=t[e];a[e]=r.time,n[3*e]=r.position[1],n[3*e+1]=r.position[2],n[3*e+2]=r.position[0];let[o,s,l,u]=r.rotation;i[4*e]=o,i[4*e+1]=s,i[4*e+2]=l,i[4*e+3]=u}let o=[new u.VectorKeyframeTrack(`${r}.position`,a,n),new u.QuaternionKeyframeTrack(`${r}.quaternion`,a,i)];return new u.AnimationClip(r,-1,o)}(e));y[9]=M,y[10]=a}else a=y[10];let D=a;if(y[11]!==M){for(let e of(o=new Map,M))o.set(String(e.id),{spawn:e.spawnTime??0,despawn:e.despawnTime});y[11]=M,y[12]=o}else o=y[12];let k=o;if(y[13]!==M||y[14]!==F){t:{let e;if(!F){s=null;break t}if(y[16]!==M){for(let t of(e=new Map,M))t.dataBlock&&e.set(String(t.id),t.dataBlock);y[16]=M,y[17]=e}else e=y[17];for(let t of F.cameraModes)if("first-person"===t.mode&&t.controlEntityId){s=e.get(t.controlEntityId)??null;break t}s=null}y[13]=M,y[14]=F,y[15]=s}else s=y[15];let w=s;return y[18]!==D?(l=()=>{let e=C.current;if(!e||0===D.size){B.current=null;return}let t=new u.AnimationMixer(e);for(let[,e]of(B.current=t,D)){let r=t.clipAction(e);r.setLoop(u.LoopOnce,1),r.clampWhenFinished=!0,r.play()}return t.setTime(0),t.timeScale=0,()=>{t.stopAllAction(),B.current=null}},c=[D],y[18]=D,y[19]=l,y[20]=c):(l=y[19],c=y[20]),(0,f4.useEffect)(l,c),y[21]!==b?(d=()=>{S.current=b.getState().playback.timeMs/1e3,B.current&&B.current.setTime(S.current)},f=[b],y[21]=b,y[22]=d,y[23]=f):(d=y[22],f=y[23]),(0,f4.useEffect)(d,f),y[24]!==E||y[25]!==b||y[26]!==k||y[27]!==F?(h=(e,t)=>{let r=e.camera,a=b.getState(),n=a.playback,i=B.current,o=n.status,s=n.rate,l=n.timeMs/1e3;if(Math.abs(l-S.current)>5e-4&&(S.current=l,i&&i.setTime(l)),"playing"===o&&F){let e=t*s;S.current=S.current+e,S.current>=F.duration&&(S.current=F.duration,a.setPlaybackStatus("paused")),i&&(i.timeScale=1,i.update(e))}else i&&(i.timeScale=0);if(E&&E.keyframes.length>0){let e=function(e,t,r,a){let{keyframes:n}=e;if(0===n.length)return;if(t<=n[0].time){let e=n[0];return r.set(e.position[1],e.position[2],e.position[0]),a.set(...e.rotation),e.fov}if(t>=n[n.length-1].time){let e=n[n.length-1];return r.set(e.position[1],e.position[2],e.position[0]),a.set(...e.rotation),e.fov}let i=0,o=n.length-1;for(;o-i>1;){let e=i+o>>1;n[e].time<=t?i=e:o=e}let s=n[i],l=n[o],u=(t-s.time)/(l.time-s.time);return r.set(s.position[1],s.position[2],s.position[0]),f6.set(l.position[1],l.position[2],l.position[0]),r.lerp(f6,u),a.set(...s.rotation),f7.set(...l.rotation),a.slerp(f7,u),s.fov??l.fov}(E,S.current,r.position,r.quaternion);if("number"==typeof e&&Number.isFinite(e)&&"isPerspectiveCamera"in r&&r.isPerspectiveCamera){let t=hA(e,r.aspect);Math.abs(r.fov-t)>.01&&(r.fov=t,r.updateProjectionMatrix())}}let u=F?function(e,t){if(0===e.length||t<e[0].time)return null;if(t>=e[e.length-1].time)return e[e.length-1];let r=0,a=e.length-1;for(;a-r>1;){let n=r+a>>1;e[n].time<=t?r=n:a=n}return e[r]}(F.cameraModes,S.current):null;if(u?.mode==="first-person"&&C.current){let e=C.current.children.find(e=>e.name===u.controlEntityId);e?(f6.copy(x.current).applyQuaternion(e.quaternion),r.position.add(f6)):r.position.y=r.position.y+x.current.y}C.current&&k.size>0&&function(e,t,r){for(let a of e.children){let e=t.get(a.name);e&&(a.visible=r>=e.spawn&&(null==e.despawn||r<e.despawn))}}(C.current,k,S.current);let c=1e3*S.current;Math.abs(c-n.timeMs)>.5&&a.setPlaybackTime(c)},y[24]=E,y[25]=b,y[26]=k,y[27]=F,y[28]=h):h=y[28],(0,A.useFrame)(h),y[29]!==M?(m=M.map(e=>(0,n.jsx)(hz,{entity:e,timeRef:S},e.id)),y[29]=M,y[30]=m):m=y[30],y[31]!==m?(p=(0,n.jsx)("group",{ref:C,children:m}),y[31]=m,y[32]=p):p=y[32],y[33]!==w?(g=w&&(0,n.jsx)(f4.Suspense,{fallback:null,children:(0,n.jsx)(hY,{shapeName:w,eyeOffsetRef:x})}),y[33]=w,y[34]=g):g=y[34],y[35]!==p||y[36]!==g?(v=(0,n.jsxs)(tP,{children:[p,g]}),y[35]=p,y[36]=g,y[37]=v):v=y[37],v}function hw(e){return"Camera"!==e.type}function hI(e){return"Camera"===e.type}let hT=0,hR=0,hP=0,hG=0,hL=0;function hj(e){return hL+=1,`${e}-${hL}`}function h_({recording:e}){let t=(0,R.useEngineStoreApi)(),r=(0,f4.useRef)(null);r.current||(r.current=hj("StreamingDemoPlayback"));let a=(0,f4.useRef)(null),i=(0,f4.useRef)(0),o=(0,f4.useRef)(0),s=(0,f4.useRef)(null),l=(0,f4.useRef)(null),c=(0,f4.useRef)(new u.Vector3(0,2.1,0)),d=(0,f4.useRef)(e.streamingPlayback??null),f=(0,f4.useRef)(null),h=(0,f4.useRef)(""),m=(0,f4.useRef)(new Map),p=(0,f4.useRef)(0),g=(0,f4.useRef)(!1),[v,F]=(0,f4.useState)([]),[b,C]=(0,f4.useState)(null);(0,f4.useEffect)(()=>{hP+=1;let a=Date.now();return t.getState().recordPlaybackDiagnosticEvent({kind:"component.lifecycle",message:"StreamingDemoPlayback mounted",meta:{component:"StreamingDemoPlayback",phase:"mount",instanceId:r.current,mountCount:hP,unmountCount:hG,recordingMissionName:e.missionName??null,recordingDurationSec:Number(e.duration.toFixed(3)),ts:a}}),console.info("[demo diagnostics] StreamingDemoPlayback mounted",{instanceId:r.current,mountCount:hP,unmountCount:hG,recordingMissionName:e.missionName??null,mountedAt:a}),()=>{hG+=1;let a=Date.now();t.getState().recordPlaybackDiagnosticEvent({kind:"component.lifecycle",message:"StreamingDemoPlayback unmounted",meta:{component:"StreamingDemoPlayback",phase:"unmount",instanceId:r.current,mountCount:hP,unmountCount:hG,recordingMissionName:e.missionName??null,ts:a}}),console.info("[demo diagnostics] StreamingDemoPlayback unmounted",{instanceId:r.current,mountCount:hP,unmountCount:hG,recordingMissionName:e.missionName??null,unmountedAt:a})}},[t]);let B=(0,f4.useCallback)(e=>{let r=m.current.size,a=function(e){let t=[];for(let r of e.entities){let e=r.visual?.kind==="tracer"?`tracer:${r.visual.texture}:${r.visual.crossTexture??""}:${r.visual.tracerLength}:${r.visual.tracerWidth}:${r.visual.crossViewAng}:${r.visual.crossSize}:${+!!r.visual.renderCross}`:r.visual?.kind==="sprite"?`sprite:${r.visual.texture}:${r.visual.color.r}:${r.visual.color.g}:${r.visual.color.b}:${r.visual.size}`:"";t.push(`${r.id}|${r.type}|${r.dataBlock??""}|${r.weaponShape??""}|${r.playerName??""}|${r.className??""}|${r.ghostIndex??""}|${r.dataBlockId??""}|${r.shapeHint??""}|${r.faceViewer?"fv":""}|${e}`)}return t.sort(),t.join(";")}(e),n=h.current!==a,i=new Map;for(let t of e.entities){var o,s,l,u,c,d,f,g,v;let r=m.current.get(t.id);r&&r.type===t.type&&r.dataBlock===t.dataBlock&&r.weaponShape===t.weaponShape&&r.className===t.className&&r.ghostIndex===t.ghostIndex&&r.dataBlockId===t.dataBlockId&&r.shapeHint===t.shapeHint||(o=t.id,s=t.type,l=t.dataBlock,u=t.visual,c=t.direction,d=t.weaponShape,f=t.playerName,g=t.className,v=t.ghostIndex,r={id:o,type:s,dataBlock:l,visual:u,direction:c,weaponShape:d,playerName:f,className:g,ghostIndex:v,dataBlockId:t.dataBlockId,shapeHint:t.shapeHint,keyframes:[{time:0,position:[0,0,0],rotation:[0,0,0,1]}]}),r.playerName=t.playerName,r.iffColor=t.iffColor,r.dataBlock=t.dataBlock,r.visual=t.visual,r.direction=t.direction,r.weaponShape=t.weaponShape,r.className=t.className,r.ghostIndex=t.ghostIndex,r.dataBlockId=t.dataBlockId,r.shapeHint=t.shapeHint,0===r.keyframes.length&&r.keyframes.push({time:e.timeSec,position:t.position??[0,0,0],rotation:t.rotation??[0,0,0,1]});let a=r.keyframes[0];a.time=e.timeSec,t.position&&(a.position=t.position),t.rotation&&(a.rotation=t.rotation),a.velocity=t.velocity,a.health=t.health,a.energy=t.energy,i.set(t.id,r)}if(m.current=i,n){h.current=a,F(Array.from(i.values()));let n=Date.now();n-p.current>=500&&(p.current=n,t.getState().recordPlaybackDiagnosticEvent({kind:"stream.entities.rebuild",message:"Renderable demo entity list was rebuilt",meta:{previousEntityCount:r,nextEntityCount:i.size,snapshotTimeSec:Number(e.timeSec.toFixed(3))}}))}let y=null;if(e.camera?.mode==="first-person"&&e.camera.controlEntityId){let t=i.get(e.camera.controlEntityId);t?.dataBlock&&(y=t.dataBlock)}C(e=>e===y?e:y)},[t]);return(0,f4.useEffect)(()=>{d.current=e.streamingPlayback??null,m.current=new Map,h.current="",f.current=null,i.current=0,o.current=0,s.current=null,l.current=null,g.current=!1;let r=d.current;if(!r)return void t.getState().setPlaybackStreamSnapshot(null);for(let e of(r.reset(),r.getEffectShapes()))e2.preload((0,y.shapeToUrl)(e));let a=r.getSnapshot();return i.current=a.timeSec,o.current=a.timeSec,s.current=a,l.current=a,B(a),t.getState().setPlaybackStreamSnapshot(a),f.current=a,()=>{t.getState().setPlaybackStreamSnapshot(null)}},[e,t,B]),(0,A.useFrame)((e,r)=>{let n=d.current;if(!n)return;let u=t.getState(),h=u.playback,m="playing"===h.status,p=h.timeMs/1e3,v=!m&&Math.abs(p-o.current)>5e-4,y=m&&Math.abs(p-i.current)>.05,A=v||y;A&&(o.current=p),m&&(o.current+=r*h.rate);let F=Math.max(1,Math.ceil(1e3*r*Math.max(h.rate,.01)/32)+2),b=o.current+.032,C=n.stepToTime(b,m&&!A?F:1/0),S=l.current;!S||C.timeSec<S.timeSec||C.timeSec-S.timeSec>.048?(s.current=C,l.current=C):C.timeSec!==S.timeSec&&(s.current=S,l.current=C);let x=l.current??C,E=s.current??x,M=x.timeSec-.032,D=Math.max(0,Math.min(1,(o.current-M)/.032));i.current=o.current,C.exhausted&&m&&(o.current=Math.min(o.current,C.timeSec)),B(x);let k=f.current;k&&x.timeSec===k.timeSec&&x.exhausted===k.exhausted&&x.status.health===k.status.health&&x.status.energy===k.status.energy&&x.camera?.mode===k.camera?.mode&&x.camera?.controlEntityId===k.camera?.controlEntityId&&x.camera?.orbitTargetId===k.camera?.orbitTargetId||(f.current=x,u.setPlaybackStreamSnapshot(x));let w=x.camera,I=w&&E.camera&&E.camera.mode===w.mode&&E.camera.controlEntityId===w.controlEntityId&&E.camera.orbitTargetId===w.orbitTargetId?E.camera:null;if(w){if(I){let t=I.position[0],r=I.position[1],a=I.position[2],n=w.position[0],i=w.position[1],o=w.position[2];e.camera.position.set(r+(i-r)*D,a+(o-a)*D,t+(n-t)*D),he.set(...I.rotation),ht.set(...w.rotation),he.slerp(ht,D),e.camera.quaternion.copy(he)}else e.camera.position.set(w.position[1],w.position[2],w.position[0]),e.camera.quaternion.set(...w.rotation);if(Number.isFinite(w.fov)&&"isPerspectiveCamera"in e.camera&&e.camera.isPerspectiveCamera){let t=e.camera,r=hA(I&&Number.isFinite(I.fov)?I.fov+(w.fov-I.fov)*D:w.fov,t.aspect);Math.abs(t.fov-r)>.01&&(t.fov=r,t.updateProjectionMatrix())}}let T=new Map(x.entities.map(e=>[e.id,e])),R=new Map(E.entities.map(e=>[e.id,e])),P=a.current;if(P)for(let t of P.children){let r=T.get(t.name);if(!r?.position){t.visible=!1;continue}t.visible=!0;let a=R.get(t.name);if(a?.position){let e=a.position[0],n=a.position[1],i=a.position[2],o=r.position[0],s=r.position[1],l=r.position[2],u=e+(o-e)*D,c=n+(s-n)*D,d=i+(l-i)*D;t.position.set(c,d,u)}else t.position.set(r.position[1],r.position[2],r.position[0]);r.faceViewer?t.quaternion.copy(e.camera.quaternion):r.visual?.kind==="tracer"?t.quaternion.identity():r.rotation&&(a?.rotation?(he.set(...a.rotation),ht.set(...r.rotation),he.slerp(ht,D),t.quaternion.copy(he)):t.quaternion.set(...r.rotation))}let G=w?.mode;if("third-person"===G&&P&&w?.orbitTargetId){let t=P.children.find(e=>e.name===w.orbitTargetId);if(t){let r=T.get(w.orbitTargetId);ha.copy(t.position),r?.type==="Player"&&(ha.y+=1);let a=!1;if("number"==typeof w.yaw&&"number"==typeof w.pitch){let e=Math.sin(w.pitch),t=Math.cos(w.pitch),r=Math.sin(w.yaw),n=Math.cos(w.yaw);hr.set(-t,-r*e,-n*e),a=hr.lengthSq()>1e-8}if(a||(hr.copy(e.camera.position).sub(ha),a=hr.lengthSq()>1e-8),a){hr.normalize();let t=Math.max(.1,w.orbitDistance??4);for(let r of(hn.copy(ha).addScaledVector(hr,t),ho.near=.001,ho.far=2.5*t,ho.camera=e.camera,ho.set(ha,hr),ho.intersectObjects(e.scene.children,!0))){if(r.distance<=1e-4||function(e,t){let r=e;for(;r;){if(r.name===t)return!0;r=r.parent}return!1}(r.object,w.orbitTargetId))continue;if(!r.face)break;hi.copy(r.face.normal).transformDirection(r.object.matrixWorld);let e=-hr.dot(hi);if(e>.01){let a=r.distance-.05/e;a>t&&(a=t),a<0&&(a=0),hn.copy(ha).addScaledVector(hr,a)}break}e.camera.position.copy(hn),e.camera.lookAt(ha)}}}if("first-person"===G&&P&&w?.controlEntityId){let t=P.children.find(e=>e.name===w.controlEntityId);t?(f6.copy(c.current).applyQuaternion(t.quaternion),e.camera.position.add(f6)):e.camera.position.y+=c.current.y}m&&C.exhausted?(g.current||(g.current=!0,u.recordPlaybackDiagnosticEvent({kind:"stream.exhausted",message:"Streaming playback reached end-of-stream while playing",meta:{streamTimeSec:Number(C.timeSec.toFixed(3)),requestedPlaybackSec:Number(o.current.toFixed(3))}})),u.setPlaybackStatus("paused")):C.exhausted||(g.current=!1);let L=1e3*o.current;Math.abs(L-h.timeMs)>.5&&u.setPlaybackTime(L)}),(0,n.jsxs)(tP,{children:[(0,n.jsx)("group",{ref:a,children:v.map(e=>(0,n.jsx)(hz,{entity:e,timeRef:i},e.id))}),b&&(0,n.jsx)(f4.Suspense,{fallback:null,children:(0,n.jsx)(hY,{shapeName:b,eyeOffsetRef:c})})]})}function hO(e){let t,r,a,o,s,l=(0,i.c)(18),{entity:u,timeRef:c}=e,{camera:d}=(0,F.useThree)(),f=(0,f4.useRef)(null),h=(0,f4.useRef)(null),m=(0,f4.useRef)(null),[p,g]=(0,f4.useState)(!0);e:{if(u.playerName){t=u.playerName;break e}if("string"==typeof u.id){let e;if(l[0]!==u.id){let t;l[2]===Symbol.for("react.memo_cache_sentinel")?(t=/^player_/,l[2]=t):t=l[2],e=u.id.replace(t,"Player "),l[0]=u.id,l[1]=e}else e=l[1];t=e;break e}t=`Player ${u.id}`}let v=t;l[3]!==u.keyframes?(r=u.keyframes.some(hU),l[3]=u.keyframes,l[4]=r):r=l[4];let y=r;return l[5]!==d||l[6]!==u.iffColor||l[7]!==u.keyframes||l[8]!==y||l[9]!==p||l[10]!==c?(a=()=>{let e=f.current;if(!e)return;e.getWorldPosition(f6);let t=d.position.distanceTo(f6),r=t<150;if(p!==r&&g(r),r){if(h.current){let e=Math.max(0,Math.min(1,1-t/150));h.current.style.opacity=e.toString()}if(m.current&&y){let e=hC(u.keyframes,c.current),t=e?.health??1;m.current.style.width=`${Math.max(0,Math.min(100,100*t))}%`,m.current.style.background=u.iffColor?`rgb(${u.iffColor.r}, ${u.iffColor.g}, ${u.iffColor.b})`:""}}},l[5]=d,l[6]=u.iffColor,l[7]=u.keyframes,l[8]=y,l[9]=p,l[10]=c,l[11]=a):a=l[11],(0,A.useFrame)(a),l[12]!==v||l[13]!==y||l[14]!==p?(o=p&&(0,n.jsx)(f5.Html,{position:[0,2.8,0],center:!0,children:(0,n.jsxs)("div",{ref:h,className:"PlayerNameplate",children:[(0,n.jsx)("div",{className:"PlayerNameplate-name",children:v}),y&&(0,n.jsx)("div",{className:"PlayerNameplate-healthBar",children:(0,n.jsx)("div",{ref:m,className:"PlayerNameplate-healthFill"})})]})}),l[12]=v,l[13]=y,l[14]=p,l[15]=o):o=l[15],l[16]!==o?(s=(0,n.jsx)("group",{ref:f,children:o}),l[16]=o,l[17]=s):s=l[17],s}function hU(e){return null!=e.health}function hH(e){let t,r,a,o,s,l=(0,i.c)(14),{visual:c}=e;l[0]!==c.texture?(t=(0,y.textureToUrl)(c.texture),l[0]=c.texture,l[1]=t):t=l[1];let d=t,f=(0,B.useTexture)(d,hN),h=Array.isArray(f)?f[0]:f;l[2]!==c.color.b||l[3]!==c.color.g||l[4]!==c.color.r?(r=new u.Color().setRGB(c.color.r,c.color.g,c.color.b,u.SRGBColorSpace),l[2]=c.color.b,l[3]=c.color.g,l[4]=c.color.r,l[5]=r):r=l[5];let m=r;return l[6]!==c.size?(a=[c.size,c.size,1],l[6]=c.size,l[7]=a):a=l[7],l[8]!==m||l[9]!==h?(o=(0,n.jsx)("spriteMaterial",{map:h,color:m,transparent:!0,blending:u.AdditiveBlending,depthWrite:!1,toneMapped:!1}),l[8]=m,l[9]=h,l[10]=o):o=l[10],l[11]!==a||l[12]!==o?(s=(0,n.jsx)("sprite",{scale:a,children:o}),l[11]=a,l[12]=o,l[13]=s):s=l[13],s}function hN(e){hF(Array.isArray(e)?e[0]:e)}function hJ(e){let t,r,a,o,s,l,c,d,f,h,m,p,g=(0,i.c)(28),{entity:v,visual:F}=e,b=(0,f4.useRef)(null),C=(0,f4.useRef)(null),S=(0,f4.useRef)(null);g[0]===Symbol.for("react.memo_cache_sentinel")?(t=new u.Quaternion,g[0]=t):t=g[0];let x=(0,f4.useRef)(t);g[1]!==F.texture?(r=(0,y.textureToUrl)(F.texture),g[1]=F.texture,g[2]=r):r=g[2];let E=F.crossTexture??F.texture;g[3]!==E?(a=(0,y.textureToUrl)(E),g[3]=E,g[4]=a):a=g[4],g[5]!==r||g[6]!==a?(o=[r,a],g[5]=r,g[6]=a,g[7]=o):o=g[7];let M=o,D=(0,B.useTexture)(M,hK);g[8]!==D?(s=Array.isArray(D)?D:[D,D],g[8]=D,g[9]=s):s=g[9];let[k,w]=s;return g[10]!==v||g[11]!==F.crossSize||g[12]!==F.crossViewAng||g[13]!==F.renderCross||g[14]!==F.tracerLength||g[15]!==F.tracerWidth?(l=e=>{var t;let{camera:r}=e,a=b.current,n=C.current;if(!a||!n)return;let i=v.keyframes[0],o=i?.position,s=v.direction??i?.velocity;if(!o||!s||(hb(s,hs),1e-8>hs.lengthSq())){a.visible=!1,S.current&&(S.current.visible=!1);return}hs.normalize(),a.visible=!0,hb(o,hf),hl.copy(hf).sub(r.position),hu.crossVectors(hl,hs),1e-8>hu.lengthSq()&&(hu.crossVectors(hg,hs),1e-8>hu.lengthSq()&&hu.set(1,0,0)),hu.normalize().multiplyScalar(F.tracerWidth);let l=.5*F.tracerLength;hc.copy(hs).multiplyScalar(-l),hd.copy(hs).multiplyScalar(l);let u=n.array;u[0]=hc.x+hu.x,u[1]=hc.y+hu.y,u[2]=hc.z+hu.z,u[3]=hc.x-hu.x,u[4]=hc.y-hu.y,u[5]=hc.z-hu.z,u[6]=hd.x-hu.x,u[7]=hd.y-hu.y,u[8]=hd.z-hu.z,u[9]=hd.x+hu.x,u[10]=hd.y+hu.y,u[11]=hd.z+hu.z,n.needsUpdate=!0;let c=S.current;if(!c)return;if(!F.renderCross){c.visible=!1;return}hl.normalize();let d=hs.dot(hl);if(d>-F.crossViewAng&&d<F.crossViewAng){c.visible=!1;return}c.visible=!0,t=x.current,hh.crossVectors(hs,hg),1e-8>hh.lengthSq()&&hh.set(-1,0,0),hh.normalize(),hm.crossVectors(hh,hs).normalize(),hp.set(hh.x,hs.x,hm.x,0,hh.y,hs.y,hm.y,0,hh.z,hs.z,hm.z,0,0,0,0,1),t.setFromRotationMatrix(hp),c.quaternion.copy(x.current),c.scale.setScalar(F.crossSize)},g[10]=v,g[11]=F.crossSize,g[12]=F.crossViewAng,g[13]=F.renderCross,g[14]=F.tracerLength,g[15]=F.tracerWidth,g[16]=l):l=g[16],(0,A.useFrame)(l),g[17]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)("bufferAttribute",{ref:C,attach:"attributes-position",args:[new Float32Array(12),3]}),g[17]=c):c=g[17],g[18]===Symbol.for("react.memo_cache_sentinel")?(d=(0,n.jsx)("bufferAttribute",{attach:"attributes-uv",args:[new Float32Array([0,0,0,1,1,1,1,0]),2]}),g[18]=d):d=g[18],g[19]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsxs)("bufferGeometry",{children:[c,d,(0,n.jsx)("bufferAttribute",{attach:"index",args:[new Uint16Array([0,1,2,0,2,3]),1]})]}),g[19]=f):f=g[19],g[20]!==k?(h=(0,n.jsxs)("mesh",{ref:b,children:[f,(0,n.jsx)("meshBasicMaterial",{map:k,transparent:!0,blending:u.AdditiveBlending,side:u.DoubleSide,depthWrite:!1,toneMapped:!1})]}),g[20]=k,g[21]=h):h=g[21],g[22]!==w||g[23]!==F.renderCross?(m=F.renderCross?(0,n.jsxs)("mesh",{ref:S,children:[(0,n.jsxs)("bufferGeometry",{children:[(0,n.jsx)("bufferAttribute",{attach:"attributes-position",args:[new Float32Array([-.5,0,-.5,.5,0,-.5,.5,0,.5,-.5,0,.5]),3]}),(0,n.jsx)("bufferAttribute",{attach:"attributes-uv",args:[new Float32Array([0,0,0,1,1,1,1,0]),2]}),(0,n.jsx)("bufferAttribute",{attach:"index",args:[new Uint16Array([0,1,2,0,2,3]),1]})]}),(0,n.jsx)("meshBasicMaterial",{map:w,transparent:!0,blending:u.AdditiveBlending,side:u.DoubleSide,depthWrite:!1,toneMapped:!1})]}):null,g[22]=w,g[23]=F.renderCross,g[24]=m):m=g[24],g[25]!==h||g[26]!==m?(p=(0,n.jsxs)(n.Fragment,{children:[h,m]}),g[25]=h,g[26]=m,g[27]=p):p=g[27],p}function hK(e){for(let t of Array.isArray(e)?e:[e])hF(t)}function hV(e){let t,r,a=(0,i.c)(9),{entity:o}=e,s=String(o.id);a[0]!==o.className||a[1]!==o.dataBlockId||a[2]!==o.ghostIndex||a[3]!==o.shapeHint||a[4]!==o.type||a[5]!==s?((t=[]).push(`${s} (${o.type})`),o.className&&t.push(`class ${o.className}`),"number"==typeof o.ghostIndex&&t.push(`ghost ${o.ghostIndex}`),"number"==typeof o.dataBlockId&&t.push(`db ${o.dataBlockId}`),t.push(o.shapeHint?`shapeHint ${o.shapeHint}`:"shapeHint <none resolved>"),a[0]=o.className,a[1]=o.dataBlockId,a[2]=o.ghostIndex,a[3]=o.shapeHint,a[4]=o.type,a[5]=s,a[6]=t):t=a[6];let l=t.join(" | ");return a[7]!==l?(r=(0,n.jsx)(e3.FloatingLabel,{color:"#ff6688",children:l}),a[7]=l,a[8]=r):r=a[8],r}function hz(e){let t,r,a,o,s,l,u,c,d=(0,i.c)(77),{entity:f,timeRef:h}=e,m=(0,E.useDebug)(),p=m?.debugMode??!1,g=String(f.id);if(f.visual?.kind==="tracer"){let e,t,r,a,i;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e={demoVisualKind:"tracer"},d[0]=e):e=d[0],d[1]!==f?(t=(0,n.jsx)(f4.Suspense,{fallback:null,children:(0,n.jsx)(hJ,{entity:f,visual:f.visual})}),d[1]=f,d[2]=t):t=d[2],d[3]!==p||d[4]!==f?(r=p?(0,n.jsx)(hV,{entity:f}):null,d[3]=p,d[4]=f,d[5]=r):r=d[5],d[6]!==t||d[7]!==r?(a=(0,n.jsxs)("group",{name:"model",userData:e,children:[t,r]}),d[6]=t,d[7]=r,d[8]=a):a=d[8],d[9]!==g||d[10]!==a?(i=(0,n.jsx)("group",{name:g,children:a}),d[9]=g,d[10]=a,d[11]=i):i=d[11],i}if(f.visual?.kind==="sprite"){let e,t,r,a,i;return d[12]===Symbol.for("react.memo_cache_sentinel")?(e={demoVisualKind:"sprite"},d[12]=e):e=d[12],d[13]!==f.visual?(t=(0,n.jsx)(f4.Suspense,{fallback:null,children:(0,n.jsx)(hH,{visual:f.visual})}),d[13]=f.visual,d[14]=t):t=d[14],d[15]!==p||d[16]!==f?(r=p?(0,n.jsx)(hV,{entity:f}):null,d[15]=p,d[16]=f,d[17]=r):r=d[17],d[18]!==t||d[19]!==r?(a=(0,n.jsxs)("group",{name:"model",userData:e,children:[t,r]}),d[18]=t,d[19]=r,d[20]=a):a=d[20],d[21]!==g||d[22]!==a?(i=(0,n.jsx)("group",{name:g,children:a}),d[21]=g,d[22]=a,d[23]=i):i=d[23],i}if(!f.dataBlock){let e,t,r,a,i,o;return d[24]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("sphereGeometry",{args:[.3,6,4]}),d[24]=e):e=d[24],d[25]!==f.type?(t=h$(f.type),d[25]=f.type,d[26]=t):t=d[26],d[27]!==t?(r=(0,n.jsxs)("mesh",{children:[e,(0,n.jsx)("meshBasicMaterial",{color:t,wireframe:!0})]}),d[27]=t,d[28]=r):r=d[28],d[29]!==p||d[30]!==f?(a=p?(0,n.jsx)(hV,{entity:f}):null,d[29]=p,d[30]=f,d[31]=a):a=d[31],d[32]!==r||d[33]!==a?(i=(0,n.jsxs)("group",{name:"model",children:[r,a]}),d[32]=r,d[33]=a,d[34]=i):i=d[34],d[35]!==g||d[36]!==i?(o=(0,n.jsx)("group",{name:g,children:i}),d[35]=g,d[36]=i,d[37]=o):o=d[37],o}d[38]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)("sphereGeometry",{args:[.5,8,6]}),d[38]=t):t=d[38],d[39]!==f.type?(r=h$(f.type),d[39]=f.type,d[40]=r):r=d[40],d[41]!==r?(a=(0,n.jsxs)("mesh",{children:[t,(0,n.jsx)("meshBasicMaterial",{color:r,wireframe:!0})]}),d[41]=r,d[42]=a):a=d[42];let v=a;if("Player"===f.type){let e,t,r,a,i,o;return d[43]!==f||d[44]!==h?(e=(0,n.jsx)(hq,{entity:f,timeRef:h}),d[43]=f,d[44]=h,d[45]=e):e=d[45],d[46]!==v||d[47]!==e?(t=(0,n.jsx)(f4.Suspense,{fallback:v,children:e}),d[46]=v,d[47]=e,d[48]=t):t=d[48],d[49]!==v||d[50]!==t?(r=(0,n.jsx)(hZ,{fallback:v,children:t}),d[49]=v,d[50]=t,d[51]=r):r=d[51],d[52]!==f||d[53]!==h?(a=(0,n.jsx)(hO,{entity:f,timeRef:h}),d[52]=f,d[53]=h,d[54]=a):a=d[54],d[55]!==r||d[56]!==a?(i=(0,n.jsxs)("group",{name:"model",children:[r,a]}),d[55]=r,d[56]=a,d[57]=i):i=d[57],d[58]!==g||d[59]!==i?(o=(0,n.jsx)("group",{name:g,children:i}),d[58]=g,d[59]=i,d[60]=o):o=d[60],o}return d[61]!==f.dataBlock||d[62]!==f.id?(o=(0,n.jsx)(hW,{shapeName:f.dataBlock,entityId:f.id}),d[61]=f.dataBlock,d[62]=f.id,d[63]=o):o=d[63],d[64]!==v||d[65]!==o?(s=(0,n.jsx)(f4.Suspense,{fallback:v,children:o}),d[64]=v,d[65]=o,d[66]=s):s=d[66],d[67]!==v||d[68]!==s?(l=(0,n.jsx)("group",{name:"model",children:(0,n.jsx)(hZ,{fallback:v,children:s})}),d[67]=v,d[68]=s,d[69]=l):l=d[69],d[70]!==f.dataBlock||d[71]!==f.weaponShape?(u=f.weaponShape&&(0,n.jsx)("group",{name:"weapon",children:(0,n.jsx)(hZ,{fallback:null,children:(0,n.jsx)(f4.Suspense,{fallback:null,children:(0,n.jsx)(hX,{shapeName:f.weaponShape,playerShapeName:f.dataBlock})})})}),d[70]=f.dataBlock,d[71]=f.weaponShape,d[72]=u):u=d[72],d[73]!==g||d[74]!==l||d[75]!==u?(c=(0,n.jsxs)("group",{name:g,children:[l,u]}),d[73]=g,d[74]=l,d[75]=u,d[76]=c):c=d[76],c}function hq(e){let t,r,a,o,s,l,c,d,f,h,m,p,g,v=(0,i.c)(28),{entity:y,timeRef:F}=e,b=(0,R.useEngineStoreApi)(),C=t_(y.dataBlock);if(v[0]!==C.scene){var B;let e,n,i;B=C.scene,e=new Map,n=new Map,i=B.clone(),function e(t,r,a){a(t,r);for(let n=0;n<t.children.length;n++)e(t.children[n],r.children[n],a)}(B,i,function(t,r){e.set(r,t),n.set(t,r)}),i.traverse(function(t){if(!t.isSkinnedMesh)return;let r=e.get(t),a=r.skeleton.bones;t.skeleton=r.skeleton.clone(),t.bindMatrix.copy(r.bindMatrix),t.skeleton.bones=a.map(function(e){return n.get(e)}),t.bind(t.skeleton,t.bindMatrix)}),hE(a=i),r=new u.AnimationMixer(a),t=null,a.traverse(e=>{t||"Mount0"!==e.name||(t=e)}),v[0]=C.scene,v[1]=t,v[2]=r,v[3]=a}else t=v[1],r=v[2],a=v[3];v[4]!==t||v[5]!==r||v[6]!==a?(o={clonedScene:a,mixer:r,mount0:t},v[4]=t,v[5]=r,v[6]=a,v[7]=o):o=v[7];let{clonedScene:S,mixer:x,mount0:E}=o;v[8]===Symbol.for("react.memo_cache_sentinel")?(s=new Map,v[8]=s):s=v[8];let M=(0,f4.useRef)(s);v[9]===Symbol.for("react.memo_cache_sentinel")?(l={name:"Root",timeScale:1},v[9]=l):l=v[9];let D=(0,f4.useRef)(l);return v[10]!==C.animations||v[11]!==x?(c=()=>{let e=new Map;for(let t of C.animations){let r=x.clipAction(t);e.set(t.name.toLowerCase(),r)}M.current=e;let t=e.get("root");return t&&t.play(),D.current={name:"Root",timeScale:1},x.update(0),()=>{x.stopAllAction(),M.current=new Map}},d=[x,C.animations],v[10]=C.animations,v[11]=x,v[12]=c,v[13]=d):(c=v[12],d=v[13]),(0,f4.useEffect)(c,d),v[14]!==b||v[15]!==y.keyframes||v[16]!==x||v[17]!==F?(f=(e,t)=>{let r=b.getState().playback,a="playing"===r.status,n=F.current,i=hC(y.keyframes,n),o=function(e,t){if(!e)return{animation:"Root",timeScale:1};let[r,a,n]=e;if(n<-10)return{animation:"Fall",timeScale:1};let i=-2*Math.atan2(t[1],t[3]),o=Math.cos(i),s=Math.sin(i),l=r*o+a*s,u=-r*s+a*o,c=-u,d=-l,f=Math.max(u,c,d,l);return f<.1?{animation:"Root",timeScale:1}:f===u?{animation:"Forward",timeScale:1}:f===c?{animation:"Back",timeScale:1}:f===d?{animation:"Side",timeScale:1}:{animation:"Side",timeScale:-1}}(i?.velocity,i?.rotation??[0,0,0,1]),s=D.current;if(o.animation!==s.name||o.timeScale!==s.timeScale){let e=M.current,t=e.get(s.name.toLowerCase()),r=e.get(o.animation.toLowerCase());r&&(a&&t&&t!==r?(t.fadeOut(.25),r.reset().fadeIn(.25).play()):(t&&t!==r&&t.stop(),r.reset().play()),r.timeScale=o.timeScale,D.current={name:o.animation,timeScale:o.timeScale})}a?x.update(t*r.rate):x.update(0)},v[14]=b,v[15]=y.keyframes,v[16]=x,v[17]=F,v[18]=f):f=v[18],(0,A.useFrame)(f),v[19]===Symbol.for("react.memo_cache_sentinel")?(h=[0,Math.PI/2,0],v[19]=h):h=v[19],v[20]!==S?(m=(0,n.jsx)("group",{rotation:h,children:(0,n.jsx)("primitive",{object:S})}),v[20]=S,v[21]=m):m=v[21],v[22]!==y.weaponShape||v[23]!==E?(p=y.weaponShape&&E&&(0,n.jsx)(hZ,{fallback:null,children:(0,n.jsx)(f4.Suspense,{fallback:null,children:(0,n.jsx)(hQ,{weaponShape:y.weaponShape,mount0:E})})}),v[22]=y.weaponShape,v[23]=E,v[24]=p):p=v[24],v[25]!==m||v[26]!==p?(g=(0,n.jsxs)(n.Fragment,{children:[m,p]}),v[25]=m,v[26]=p,v[27]=g):g=v[27],g}function hQ(e){let t,r,a=(0,i.c)(7),{weaponShape:n,mount0:o}=e,s=t_(n);return a[0]!==o||a[1]!==s.animations||a[2]!==s.scene?(t=()=>{let e=s.scene.clone(!0);hE(e);let t=hB(s.scene,s.animations,"Mountpoint");if(t){let r=t.quaternion.clone().invert(),a=t.position.clone().negate().applyQuaternion(r);e.position.copy(a),e.quaternion.copy(r)}return o.add(e),()=>{o.remove(e)}},a[0]=o,a[1]=s.animations,a[2]=s.scene,a[3]=t):t=a[3],a[4]!==o||a[5]!==s?(r=[s,o],a[4]=o,a[5]=s,a[6]=r):r=a[6],(0,f4.useEffect)(t,r),null}function hW(e){let t,r,a,o=(0,i.c)(6),{shapeName:s,entityId:l}=e,u="number"==typeof l?l:0;o[0]!==u?(t={_class:"player",_className:"Player",_id:u},o[0]=u,o[1]=t):t=o[1];let c=t;return o[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,n.jsx)(tz,{loadingColor:"#00ff88"}),o[2]=r):r=o[2],o[3]!==s||o[4]!==c?(a=(0,n.jsx)(tk,{object:c,shapeName:s,type:"StaticShape",children:r}),o[3]=s,o[4]=c,o[5]=a):a=o[5],a}function hX(e){let t,r,a,o,s,l=(0,i.c)(16),{shapeName:u,playerShapeName:c}=e,d=t_(c),f=t_(u);if(l[0]!==d.animations||l[1]!==d.scene||l[2]!==f){e:{let e,r,a,n=hB(d.scene,d.animations,"Mount0");if(!n){let e;l[4]===Symbol.for("react.memo_cache_sentinel")?(e={position:void 0,quaternion:void 0},l[4]=e):e=l[4],t=e;break e}let i=hB(f.scene,f.animations,"Mountpoint");if(i){let t=i.quaternion.clone().invert(),a=i.position.clone().negate().applyQuaternion(t);r=n.quaternion.clone().multiply(t),e=a.clone().applyQuaternion(n.quaternion).add(n.position)}else e=n.position.clone(),r=n.quaternion.clone();let o=e.applyQuaternion(hv),s=hv.clone().multiply(r).multiply(hy);l[5]!==o||l[6]!==s?(a={position:o,quaternion:s},l[5]=o,l[6]=s,l[7]=a):a=l[7],t=a}l[0]=d.animations,l[1]=d.scene,l[2]=f,l[3]=t}else t=l[3];let h=t;l[8]===Symbol.for("react.memo_cache_sentinel")?(r={_class:"weapon",_className:"Weapon",_id:0},l[8]=r):r=l[8];let m=r;return l[9]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsx)(tz,{loadingColor:"#4488ff"}),l[9]=a):a=l[9],l[10]!==h.position||l[11]!==h.quaternion?(o=(0,n.jsx)("group",{position:h.position,quaternion:h.quaternion,children:a}),l[10]=h.position,l[11]=h.quaternion,l[12]=o):o=l[12],l[13]!==u||l[14]!==o?(s=(0,n.jsx)(tk,{object:m,shapeName:u,type:"Item",children:o}),l[13]=u,l[14]=o,l[15]=s):s=l[15],s}function hY(e){let t,r,a=(0,i.c)(7),{shapeName:n,eyeOffsetRef:o}=e,s=t_(n);return a[0]!==o||a[1]!==s.animations||a[2]!==s.scene?(t=()=>{let e=hB(s.scene,s.animations,"Eye");e?o.current.set(e.position.z,e.position.y,-e.position.x):o.current.set(0,2.1,0)},a[0]=o,a[1]=s.animations,a[2]=s.scene,a[3]=t):t=a[3],a[4]!==o||a[5]!==s?(r=[s,o],a[4]=o,a[5]=s,a[6]=r):r=a[6],(0,f4.useEffect)(t,r),null}class hZ extends f4.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.warn("[demo] Shape load failed:",e.message,t.componentStack)}render(){return this.state.hasError?this.props.fallback:this.props.children}}function h$(e){switch(e.toLowerCase()){case"player":return"#00ff88";case"vehicle":return"#ff8800";case"projectile":return"#ff0044";case"deployable":return"#ffcc00";default:return"#8888ff"}}var h0=e.i(30064);let h1=[.25,.5,1,2,4];function h2(e){let t=Math.floor(e/60),r=Math.floor(e%60);return`${t}:${r.toString().padStart(2,"0")}`}function h3(){let e,t,r,a,o,s,l,u,c,d,f,h,m,p,g,v,y,A,F,b,C=(0,i.c)(55),B=r$(),S=r1(),x=r3(),E=(0,R.useEngineSelector)(r5),M=(0,R.useEngineSelector)(r8),{play:D,pause:k,seek:w,setSpeed:I}=r4(),T=(0,R.useEngineStoreApi)(),P=(0,R.useEngineSelector)(mr),G=(0,R.useEngineSelector)(mt),L=(0,R.useEngineSelector)(me),j=(0,R.useEngineSelector)(h7),_=(0,R.useEngineSelector)(h6);C[0]!==w?(e=e=>{w(parseFloat(e.target.value))},C[0]=w,C[1]=e):e=C[1];let O=e;C[2]!==I?(t=e=>{I(parseFloat(e.target.value))},C[2]=I,C[3]=t):t=C[3];let U=t;C[4]!==T?(r=()=>{let e=T.getState(),t=(0,h0.buildSerializableDiagnosticsSnapshot)(e),r=(0,h0.buildSerializableDiagnosticsJson)(e);console.log("[demo diagnostics dump]",t),console.log("[demo diagnostics dump json]",r)},C[4]=T,C[5]=r):r=C[5];let H=r;C[6]!==T?(a=()=>{T.getState().clearPlaybackDiagnostics(),console.info("[demo diagnostics] Cleared playback diagnostics")},C[6]=T,C[7]=a):a=C[7];let N=a;if(!B)return null;let J=S?k:D,K=S?"Pause":"Play",V=S?"❚❚":"▶";C[8]!==J||C[9]!==K||C[10]!==V?(o=(0,n.jsx)("button",{className:"DemoControls-playPause",onClick:J,"aria-label":K,children:V}),C[8]=J,C[9]=K,C[10]=V,C[11]=o):o=C[11],C[12]!==x?(s=h2(x),C[12]=x,C[13]=s):s=C[13],C[14]!==E?(l=h2(E),C[14]=E,C[15]=l):l=C[15];let z=`${s} / ${l}`;C[16]!==z?(u=(0,n.jsx)("span",{className:"DemoControls-time",children:z}),C[16]=z,C[17]=u):u=C[17],C[18]!==x||C[19]!==E||C[20]!==O?(c=(0,n.jsx)("input",{className:"DemoControls-seek",type:"range",min:0,max:E,step:.01,value:x,onChange:O}),C[18]=x,C[19]=E,C[20]=O,C[21]=c):c=C[21],C[22]===Symbol.for("react.memo_cache_sentinel")?(d=h1.map(h9),C[22]=d):d=C[22],C[23]!==U||C[24]!==M?(f=(0,n.jsx)("select",{className:"DemoControls-speed",value:M,onChange:U,children:d}),C[23]=U,C[24]=M,C[25]=f):f=C[25];let q=P?"true":void 0,Q=P?"WebGL context: LOST":"WebGL context: ok";if(C[26]!==Q?(h=(0,n.jsx)("div",{className:"DemoDiagnosticsPanel-status",children:Q}),C[26]=Q,C[27]=h):h=C[27],C[28]!==L){var W;m=(0,n.jsx)("div",{className:"DemoDiagnosticsPanel-metrics",children:L?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{children:["geom ",L.geometries," tex"," ",L.textures," prog"," ",L.programs]}),(0,n.jsxs)("span",{children:["draw ",L.renderCalls," tri"," ",L.renderTriangles]}),(0,n.jsxs)("span",{children:["scene ",L.visibleSceneObjects,"/",L.sceneObjects]}),(0,n.jsxs)("span",{children:["heap ",Number.isFinite(W=L.jsHeapUsed)&&null!=W?W<1024?`${Math.round(W)} B`:W<1048576?`${(W/1024).toFixed(1)} KB`:W<0x40000000?`${(W/1048576).toFixed(1)} MB`:`${(W/0x40000000).toFixed(2)} GB`:"n/a"]})]}):(0,n.jsx)("span",{children:"No renderer samples yet"})}),C[28]=L,C[29]=m}else m=C[29];return C[30]!==j||C[31]!==G?(p=(0,n.jsxs)("span",{children:["samples ",G," events ",j]}),C[30]=j,C[31]=G,C[32]=p):p=C[32],C[33]!==_?(g=_?(0,n.jsxs)("span",{title:_.message,children:["last event: ",_.kind]}):(0,n.jsx)("span",{children:"last event: none"}),C[33]=_,C[34]=g):g=C[34],C[35]!==H?(v=(0,n.jsx)("button",{type:"button",onClick:H,children:"Dump"}),C[35]=H,C[36]=v):v=C[36],C[37]!==N?(y=(0,n.jsx)("button",{type:"button",onClick:N,children:"Clear"}),C[37]=N,C[38]=y):y=C[38],C[39]!==p||C[40]!==g||C[41]!==v||C[42]!==y?(A=(0,n.jsxs)("div",{className:"DemoDiagnosticsPanel-footer",children:[p,g,v,y]}),C[39]=p,C[40]=g,C[41]=v,C[42]=y,C[43]=A):A=C[43],C[44]!==q||C[45]!==h||C[46]!==m||C[47]!==A?(F=(0,n.jsxs)("div",{className:"DemoDiagnosticsPanel","data-context-lost":q,children:[h,m,A]}),C[44]=q,C[45]=h,C[46]=m,C[47]=A,C[48]=F):F=C[48],C[49]!==u||C[50]!==c||C[51]!==f||C[52]!==F||C[53]!==o?(b=(0,n.jsxs)("div",{className:"DemoControls",onKeyDown:h4,onPointerDown:h8,onClick:h5,children:[o,u,c,f,F]}),C[49]=u,C[50]=c,C[51]=f,C[52]=F,C[53]=o,C[54]=b):b=C[54],b}function h9(e){return(0,n.jsxs)("option",{value:e,children:[e,"x"]},e)}function h5(e){return e.stopPropagation()}function h8(e){return e.stopPropagation()}function h4(e){return e.stopPropagation()}function h6(e){let t=e.diagnostics.playbackEvents;return t.length>0?t[t.length-1]:null}function h7(e){return e.diagnostics.playbackEvents.length}function me(e){let t=e.diagnostics.rendererSamples;return t.length>0?t[t.length-1]:null}function mt(e){return e.diagnostics.rendererSamples.length}function mr(e){return e.diagnostics.webglContextLost}var ma=e.i(75840);function mn(e,t){if(0===e.length)return{health:1,energy:1};let r=0,a=e.length-1;if(t<=e[0].time)return{health:e[0].health??1,energy:e[0].energy??1};if(t>=e[a].time)return{health:e[a].health??1,energy:e[a].energy??1};for(;a-r>1;){let n=r+a>>1;e[n].time<=t?r=n:a=n}return{health:e[r].health??1,energy:e[r].energy??1}}function mi(e){let t,r=(0,i.c)(2),{value:a}=e,o=Math.max(0,Math.min(100,100*a)),s=`${o}%`;return r[0]!==s?(t=(0,n.jsx)("div",{className:ma.default.HealthBar,children:(0,n.jsx)("div",{className:ma.default.BarFill,style:{width:s}})}),r[0]=s,r[1]=t):t=r[1],t}function mo(e){let t,r=(0,i.c)(2),{value:a}=e,o=Math.max(0,Math.min(100,100*a)),s=`${o}%`;return r[0]!==s?(t=(0,n.jsx)("div",{className:ma.default.EnergyBar,children:(0,n.jsx)("div",{className:ma.default.BarFill,style:{width:s}})}),r[0]=s,r[1]=t):t=r[1],t}function ms(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:ma.default.ChatWindow}),t[0]=e):e=t[0],e}function ml(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:ma.default.WeaponSlots}),t[0]=e):e=t[0],e}function mu(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:ma.default.ToolBelt}),t[0]=e):e=t[0],e}function mc(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:ma.default.Reticle}),t[0]=e):e=t[0],e}function md(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:ma.default.TeamStats}),t[0]=e):e=t[0],e}function mf(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("div",{className:ma.default.Compass}),t[0]=e):e=t[0],e}function mh(){let e,t,r,a,o,s,l,u,c,d,f,h,m=(0,i.c)(44),p=r$(),g=r3(),v=(0,R.useEngineSelector)(mm);if(m[0]!==p){e:{let t=new Map;if(!p){e=t;break e}for(let e of p.entities)t.set(e.id,e);e=t}m[0]=p,m[1]=e}else e=m[1];let y=e;if(!p)return null;if(p.isMetadataOnly||p.isPartial){let e,t,r,a,i,o,s,l,u,c=v?.status;return c?(m[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)(ms,{}),t=(0,n.jsx)(mf,{}),m[2]=e,m[3]=t):(e=m[2],t=m[3]),m[4]!==c.health?(r=(0,n.jsx)(mi,{value:c.health}),m[4]=c.health,m[5]=r):r=m[5],m[6]!==c.energy?(a=(0,n.jsx)(mo,{value:c.energy}),m[6]=c.energy,m[7]=a):a=m[7],m[8]===Symbol.for("react.memo_cache_sentinel")?(i=(0,n.jsx)(md,{}),o=(0,n.jsx)(mc,{}),s=(0,n.jsx)(mu,{}),l=(0,n.jsx)(ml,{}),m[8]=i,m[9]=o,m[10]=s,m[11]=l):(i=m[8],o=m[9],s=m[10],l=m[11]),m[12]!==r||m[13]!==a?(u=(0,n.jsxs)("div",{className:ma.default.PlayerHUD,children:[e,t,r,a,i,o,s,l]}),m[12]=r,m[13]=a,m[14]=u):u=m[14],u):null}m[15]!==g||m[16]!==p.cameraModes?(t=function(e,t){if(0===e.length||t<e[0].time)return null;if(t>=e[e.length-1].time)return e[e.length-1];let r=0,a=e.length-1;for(;a-r>1;){let n=r+a>>1;e[n].time<=t?r=n:a=n}return e[r]}(p.cameraModes,g),m[15]=g,m[16]=p.cameraModes,m[17]=t):t=m[17];let A=t;m[18]===Symbol.for("react.memo_cache_sentinel")?(r={health:1,energy:1},m[18]=r):r=m[18];let F=r;if(A?.mode==="first-person"){let e,t,r;if(m[19]!==g||m[20]!==y||m[21]!==p.controlPlayerGhostId){let r=p.controlPlayerGhostId?y.get(p.controlPlayerGhostId):void 0,a=y.get("recording_player");e=r?mn(r.keyframes,g):void 0,t=a?mn(a.keyframes,g):void 0,m[19]=g,m[20]=y,m[21]=p.controlPlayerGhostId,m[22]=e,m[23]=t}else e=m[22],t=m[23];let a=t,n=e?.health??1,i=a?.energy??e?.energy??1;m[24]!==n||m[25]!==i?(r={health:n,energy:i},m[24]=n,m[25]=i,m[26]=r):r=m[26],F=r}else if(A?.mode==="third-person"&&A.orbitTargetId)if(m[27]!==g||m[28]!==y||m[29]!==A.orbitTargetId){let e=y.get(A.orbitTargetId);e&&(F=mn(e.keyframes,g)),m[27]=g,m[28]=y,m[29]=A.orbitTargetId,m[30]=F}else F=m[30];return m[31]===Symbol.for("react.memo_cache_sentinel")?(a=(0,n.jsx)(ms,{}),o=(0,n.jsx)(mf,{}),m[31]=a,m[32]=o):(a=m[31],o=m[32]),m[33]!==F.health?(s=(0,n.jsx)(mi,{value:F.health}),m[33]=F.health,m[34]=s):s=m[34],m[35]!==F.energy?(l=(0,n.jsx)(mo,{value:F.energy}),m[35]=F.energy,m[36]=l):l=m[36],m[37]===Symbol.for("react.memo_cache_sentinel")?(c=(0,n.jsx)(md,{}),d=(0,n.jsx)(mc,{}),f=(0,n.jsx)(mu,{}),u=(0,n.jsx)(ml,{}),m[37]=u,m[38]=c,m[39]=d,m[40]=f):(u=m[37],c=m[38],d=m[39],f=m[40]),m[41]!==s||m[42]!==l?(h=(0,n.jsxs)("div",{className:ma.default.PlayerHUD,children:[a,o,s,l,c,d,f,u]}),m[41]=s,m[42]=l,m[43]=h):h=m[43],h}function mm(e){return e.playback.streamSnapshot}var mp=e.i(50361),mg=e.i(24540);function mv(e,t,r){try{return e(t)}catch(e){return(0,mg.l)("[nuqs] Error while parsing value `%s`: %O"+(r?" (for key `%s`)":""),t,e,r),null}}function my(e){function t(t){if(void 0===t)return null;let r="";if(Array.isArray(t)){if(void 0===t[0])return null;r=t[0]}return"string"==typeof t&&(r=t),mv(e.parse,r)}return{type:"single",eq:(e,t)=>e===t,...e,parseServerSide:t,withDefault(e){return{...this,defaultValue:e,parseServerSide:r=>t(r)??e}},withOptions(e){return{...this,...e}}}}my({parse:e=>e,serialize:String}),my({parse:e=>{let t=parseInt(e);return t==t?t:null},serialize:e=>""+Math.round(e)}),my({parse:e=>{let t=parseInt(e);return t==t?t-1:null},serialize:e=>""+Math.round(e+1)}),my({parse:e=>{let t=parseInt(e,16);return t==t?t:null},serialize:e=>{let t=Math.round(e).toString(16);return(1&t.length?"0":"")+t}}),my({parse:e=>{let t=parseFloat(e);return t==t?t:null},serialize:String});let mA=my({parse:e=>"true"===e.toLowerCase(),serialize:String});function mF(e,t){return e.valueOf()===t.valueOf()}my({parse:e=>{let t=parseInt(e);return t==t?new Date(t):null},serialize:e=>""+e.valueOf(),eq:mF}),my({parse:e=>{let t=new Date(e);return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString(),eq:mF}),my({parse:e=>{let t=new Date(e.slice(0,10));return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString().slice(0,10),eq:mF});let mb=(0,mp.r)(),mC={};function mB(e,t,r,a,n,i){let o=!1,s=Object.entries(e).reduce((e,[s,l])=>{var u;let c=t?.[s]??s,d=a[c],f="multi"===l.type?[]:null,h=void 0===d?("multi"===l.type?r?.getAll(c):r?.get(c))??f:d;return n&&i&&((u=n[c]??f)===h||null!==u&&null!==h&&"string"!=typeof u&&"string"!=typeof h&&u.length===h.length&&u.every((e,t)=>e===h[t]))?e[s]=i[s]??null:(o=!0,e[s]=((0,mp.i)(h)?null:mv(l.parse,h,c))??null,n&&(n[c]=h)),e},{});if(!o){let t=Object.keys(e),r=Object.keys(i??{});o=t.length!==r.length||t.some(e=>!r.includes(e))}return{state:s,hasChanged:o}}function mS(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,e[r]??t[r]??null]))}function mx(e,t={}){let{parse:r,type:a,serialize:n,eq:i,defaultValue:s,...l}=t,[{[e]:u},c]=function(e,t={}){let r=(0,o.useId)(),a=(0,mg.i)(),n=(0,mg.a)(),{history:i="replace",scroll:s=a?.scroll??!1,shallow:l=a?.shallow??!0,throttleMs:u=mp.s.timeMs,limitUrlUpdates:c=a?.limitUrlUpdates,clearOnDefault:d=a?.clearOnDefault??!0,startTransition:f,urlKeys:h=mC}=t,m=Object.keys(e).join(","),p=(0,o.useMemo)(()=>Object.fromEntries(Object.keys(e).map(e=>[e,h[e]??e])),[m,JSON.stringify(h)]),g=(0,mg.r)(Object.values(p)),v=g.searchParams,y=(0,o.useRef)({}),A=(0,o.useMemo)(()=>Object.fromEntries(Object.keys(e).map(t=>[t,e[t].defaultValue??null])),[Object.values(e).map(({defaultValue:e})=>e).join(",")]),F=mp.t.useQueuedQueries(Object.values(p)),[b,C]=(0,o.useState)(()=>mB(e,h,v??new URLSearchParams,F).state),B=(0,o.useRef)(b);if((0,mg.c)("[nuq+ %s `%s`] render - state: %O, iSP: %s",r,m,b,v),Object.keys(y.current).join("&")!==Object.values(p).join("&")){let{state:t,hasChanged:a}=mB(e,h,v,F,y.current,B.current);a&&((0,mg.c)("[nuq+ %s `%s`] State changed: %O",r,m,{state:t,initialSearchParams:v,queuedQueries:F,queryRef:y.current,stateRef:B.current}),B.current=t,C(t)),y.current=Object.fromEntries(Object.entries(p).map(([t,r])=>[r,e[t]?.type==="multi"?v?.getAll(r):v?.get(r)??null]))}(0,o.useEffect)(()=>{let{state:t,hasChanged:a}=mB(e,h,v,F,y.current,B.current);a&&((0,mg.c)("[nuq+ %s `%s`] State changed: %O",r,m,{state:t,initialSearchParams:v,queuedQueries:F,queryRef:y.current,stateRef:B.current}),B.current=t,C(t))},[Object.values(p).map(e=>`${e}=${v?.getAll(e)}`).join("&"),JSON.stringify(F)]),(0,o.useEffect)(()=>{let t=Object.keys(e).reduce((t,a)=>(t[a]=({state:t,query:n})=>{C(i=>{let{defaultValue:o}=e[a],s=p[a],l=t??o??null;return Object.is(i[a]??o??null,l)?((0,mg.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). no change, skipping, resolved: %O",r,m,s,t,o,B.current),i):(B.current={...B.current,[a]:l},y.current[s]=n,(0,mg.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). updateInternalState, resolved: %O",r,m,s,t,o,B.current),B.current)})},t),{});for(let a of Object.keys(e)){let e=p[a];(0,mg.c)("[nuq+ %s `%s`] Subscribing to sync for `%s`",r,e,m),mb.on(e,t[a])}return()=>{for(let a of Object.keys(e)){let e=p[a];(0,mg.c)("[nuq+ %s `%s`] Unsubscribing to sync for `%s`",r,e,m),mb.off(e,t[a])}}},[m,p]);let S=(0,o.useCallback)((t,a={})=>{let o,h=Object.fromEntries(Object.keys(e).map(e=>[e,null])),v="function"==typeof t?t(mS(B.current,A))??h:t??h;(0,mg.c)("[nuq+ %s `%s`] setState: %O",r,m,v);let y=0,F=!1,b=[];for(let[t,r]of Object.entries(v)){let h=e[t],m=p[t];if(!h||void 0===r)continue;(a.clearOnDefault??h.clearOnDefault??d)&&null!==r&&void 0!==h.defaultValue&&(h.eq??((e,t)=>e===t))(r,h.defaultValue)&&(r=null);let v=null===r?null:(h.serialize??String)(r);mb.emit(m,{state:r,query:v});let A={key:m,query:v,options:{history:a.history??h.history??i,shallow:a.shallow??h.shallow??l,scroll:a.scroll??h.scroll??s,startTransition:a.startTransition??h.startTransition??f}};if(a?.limitUrlUpdates?.method==="debounce"||c?.method==="debounce"||h.limitUrlUpdates?.method==="debounce"){!0===A.options.shallow&&console.warn((0,mg.s)(422));let e=a?.limitUrlUpdates?.timeMs??c?.timeMs??h.limitUrlUpdates?.timeMs??mp.s.timeMs,t=mp.t.push(A,e,g,n);y<e&&(o=t,y=e)}else{let e=a?.limitUrlUpdates?.timeMs??h?.limitUrlUpdates?.timeMs??c?.timeMs??a.throttleMs??h.throttleMs??u;b.push(mp.t.abort(m)),mp.n.push(A,e),F=!0}}let C=b.reduce((e,t)=>t(e),F?mp.n.flush(g,n):mp.n.getPendingPromise(g));return o??C},[m,i,l,s,u,c?.method,c?.timeMs,f,p,g.updateUrl,g.getSearchParamsSnapshot,g.rateLimitFactor,n,A]);return[(0,o.useMemo)(()=>mS(b,A),[b,A]),S]}({[e]:{parse:r??(e=>e),type:a,serialize:n,eq:i,defaultValue:s}},l);return[u,(0,o.useCallback)((t,r={})=>c(r=>({[e]:"function"==typeof t?t(r[e]):t}),r),[e,c])]}let mE=(0,o.lazy)(()=>e.A(59197).then(e=>({default:e.MapInfoDialog}))),mM=new rM,mD={toneMapping:u.NoToneMapping,outputColorSpace:u.SRGBColorSpace},mk=my({parse(e){let[t,r]=e.split("~"),a=r,n=(0,ri.getMissionInfo)(t).missionTypes;return r&&n.includes(r)||(a=n[0]),{missionName:t,missionType:a}},serialize:({missionName:e,missionType:t})=>1===(0,ri.getMissionInfo)(e).missionTypes.length?e:`${e}~${t}`,eq:(e,t)=>e.missionName===t.missionName&&e.missionType===t.missionType}).withDefault({missionName:"RiverDance",missionType:"CTF"});function mw(){let e,t,r,a,s,l,[c,d]=mx("mission",mk),f=(0,R.useEngineStoreApi)(),[h,m]=mx("fog",mA),g=(0,o.useCallback)(()=>{m(null)},[m]),v=(0,o.useRef)(c);v.current=c;let y=(0,o.useCallback)(e=>{let t=v.current,r=function(e=0){let t=Error().stack;if(!t)return null;let r=t.split("\n").map(e=>e.trim()).filter(Boolean).slice(1+e,9+e);return r.length>0?r.join(" <= "):null}(1);f.getState().recordPlaybackDiagnosticEvent({kind:"mission.change.requested",message:"changeMission invoked",meta:{previousMissionName:t.missionName,previousMissionType:t.missionType??null,nextMissionName:e.missionName,nextMissionType:e.missionType??null,stack:r??"unavailable"}}),console.info("[mission trace] changeMission",{previousMission:t,nextMission:e,stack:r}),window.location.hash="",g(),d(e)},[f,d,g]),A=(r=(0,i.c)(2),a=(0,o.useRef)(null),r[0]===Symbol.for("react.memo_cache_sentinel")?(e=e=>{let t=window.matchMedia("(pointer: coarse)");return t.addEventListener("change",e),a.current=t,()=>{t.removeEventListener("change",e)}},r[0]=e):e=r[0],s=e,r[1]===Symbol.for("react.memo_cache_sentinel")?(t=()=>a.current?.matches??null,r[1]=t):t=r[1],l=t,(0,o.useSyncExternalStore)(s,l,fZ)),{missionName:F,missionType:b}=c,[C,B]=(0,o.useState)(!1),[S,x]=(0,o.useState)(0),[M,D]=(0,o.useState)(!0),k=S<1;(0,o.useEffect)(()=>{if(k)D(!0);else{let e=setTimeout(()=>D(!1),500);return()=>clearTimeout(e)}},[k]),(0,o.useEffect)(()=>(window.setMissionName=e=>{let t=(0,ri.getMissionInfo)(e).missionTypes;y({missionName:e,missionType:t[0]})},window.getMissionList=ri.getMissionList,window.getMissionInfo=ri.getMissionInfo,()=>{delete window.setMissionName,delete window.getMissionList,delete window.getMissionInfo}),[y]),(0,o.useEffect)(()=>{let e=e=>{if("KeyI"!==e.code||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||B(!0)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let w=(0,o.useCallback)((e,t=0)=>{x(t)},[]),I=(0,o.useRef)(null),T=(0,o.useRef)({angle:0,force:0}),P=(0,o.useRef)(null),G=(0,o.useRef)({angle:0,force:0}),L=(0,o.useRef)(null);return(0,n.jsx)(rD.QueryClientProvider,{client:mM,children:(0,n.jsx)("main",{children:(0,n.jsx)(rZ,{children:(0,n.jsx)(E.SettingsProvider,{fogEnabledOverride:h,onClearFogEnabledOverride:g,children:(0,n.jsxs)(rR,{map:rQ,children:[(0,n.jsxs)("div",{id:"canvasContainer",children:[M&&(0,n.jsxs)("div",{id:"loadingIndicator","data-complete":!k,children:[(0,n.jsx)("div",{className:"LoadingSpinner"}),(0,n.jsx)("div",{className:"LoadingProgress",children:(0,n.jsx)("div",{className:"LoadingProgress-bar",style:{width:`${100*S}%`}})}),(0,n.jsxs)("div",{className:"LoadingProgress-text",children:[Math.round(100*S),"%"]})]}),(0,n.jsx)(p,{frameloop:"always",gl:mD,shadows:{type:u.PCFShadowMap},onCreated:e=>{I.current=e.camera},children:(0,n.jsx)(t2,{children:(0,n.jsxs)(f1.AudioProvider,{children:[(0,n.jsx)(rd,{name:F,missionType:b,onLoadingChange:w},`${F}~${b}`),(0,n.jsx)(f0,{}),(0,n.jsx)(f8,{}),(0,n.jsx)(hD,{}),(0,n.jsx)(mR,{isTouch:A,joystickStateRef:T,joystickZoneRef:P,lookJoystickStateRef:G,lookJoystickZoneRef:L})]})})})]}),(0,n.jsx)(mh,{}),A&&(0,n.jsx)(am,{joystickState:T,joystickZone:P,lookJoystickState:G,lookJoystickZone:L}),!1===A&&(0,n.jsx)(ar,{}),(0,n.jsx)(fq,{missionName:F,missionType:b,onChangeMission:y,onOpenMapInfo:()=>B(!0),cameraRef:I,isTouch:A}),C&&(0,n.jsx)(o.Suspense,{fallback:null,children:(0,n.jsx)(mE,{open:C,onClose:()=>B(!1),missionName:F,missionType:b??""})}),(0,n.jsx)(mT,{changeMission:y,currentMission:c}),(0,n.jsx)(h3,{}),(0,n.jsx)(mP,{})]})})})})})}let mI={"Capture the Flag":"CTF","Capture and Hold":"CnH",Deathmatch:"DM","Team Deathmatch":"TDM",Siege:"Siege",Bounty:"Bounty",Rabbit:"Rabbit"};function mT(e){let t,r,a=(0,i.c)(5),{changeMission:n,currentMission:s}=e,l=r$();return a[0]!==n||a[1]!==s||a[2]!==l?(t=()=>{if(!l?.missionName)return;let e=(0,ri.findMissionByDemoName)(l.missionName);if(!e)return void console.warn(`Demo mission "${l.missionName}" not found in manifest`);let t=(0,ri.getMissionInfo)(e),r=l.gameType?mI[l.gameType]:void 0,a=r&&t.missionTypes.includes(r)?r:t.missionTypes[0];(s.missionName!==e||s.missionType!==a)&&n({missionName:e,missionType:a})},r=[l,n,s],a[0]=n,a[1]=s,a[2]=l,a[3]=t,a[4]=r):(t=a[3],r=a[4]),(0,o.useEffect)(t,r),null}function mR(e){let t,r=(0,i.c)(6),{isTouch:a,joystickStateRef:o,joystickZoneRef:s,lookJoystickStateRef:l,lookJoystickZoneRef:u}=e;if(r1()||null===a)return null;if(a){let e;return r[0]!==o||r[1]!==s||r[2]!==l||r[3]!==u?(e=(0,n.jsx)(ap,{joystickState:o,joystickZone:s,lookJoystickState:l,lookJoystickZone:u}),r[0]=o,r[1]=s,r[2]=l,r[3]=u,r[4]=e):e=r[4],e}return r[5]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)(rW,{}),r[5]=t):t=r[5],t}function mP(){let e,t,r=(0,i.c)(4),{setRecording:a}=r4(),n=(0,R.useEngineStoreApi)();return r[0]!==n||r[1]!==a?(e=()=>(window.loadDemoRecording=a,window.getDemoDiagnostics=()=>(0,h0.buildSerializableDiagnosticsSnapshot)(n.getState()),window.getDemoDiagnosticsJson=()=>(0,h0.buildSerializableDiagnosticsJson)(n.getState()),window.clearDemoDiagnostics=()=>{n.getState().clearPlaybackDiagnostics()},mG),t=[n,a],r[0]=n,r[1]=a,r[2]=e,r[3]=t):(e=r[2],t=r[3]),(0,o.useEffect)(e,t),null}function mG(){delete window.loadDemoRecording,delete window.getDemoDiagnostics,delete window.getDemoDiagnosticsJson,delete window.clearDemoDiagnostics}function mL(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)(o.Suspense,{children:(0,n.jsx)(mw,{})}),t[0]=e):e=t[0],e}e.s(["default",()=>mL],31713)}]); |