_virtual_cc-d248fb81.js 2.3 MB

123
  1. System.register([],(function(t,e){"use strict";return{execute:function(){function i(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,f(n.key),n)}}function n(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function r(){return(r=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,a(t,e)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,e,i){return(u=h()?Reflect.construct.bind():function(t,e,i){var n=[null];n.push.apply(n,e);var r=new(Function.bind.apply(t,n));return i&&a(r,i.prototype),r}).apply(null,arguments)}function l(t){var e="function"==typeof Map?new Map:void 0;return(l=function(t){if(null===t||(i=t,-1===Function.toString.call(i).indexOf("[native code]")))return t;var i;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return u(t,arguments,o(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,t)})(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function d(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return _(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function p(t,e,i,n,r){var s={};return Object.keys(n).forEach((function(t){s[t]=n[t]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,n){return n(t,e,i)||i}),s),r&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(r):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(t,e,s),s=null),s}function m(t,e){const i="undefined"==typeof window?global:window;return void 0===i[t]?i[t]=e:i[t]}t({$:ZF,E:function(){return 0},K:XF,N:qF,P:YF,W:function(t){return jF.test(t)},X:function(t){return WF.test(t)},Y:JF,Z:QF,_:d,aM:Nn,aO:an,aQ:en,aS:xn,aV:On,aY:Gn,a_:zn,au:x2,av:R2,ax:function(t,e){for(var i=t,n="";null!==i&&i!==e;)n=i.name+"/"+n,i=i.parent;return n.slice(0,-1)},ay:DQ,b0:fn,b5:Ci,b6:wi,b7:xi,b8:Ri,b9:Ii,bE:function(t){t>0&&(ut=t)},bI:pt,bJ:function(t){for(var e,i=d(t);!(e=i()).done;)mt(e.value)},bK:function(t){return _t||(_t="undefined"==typeof Proxy?{}:new Proxy(t,{get:function(t,e,i){return mt(e),Reflect.get(t,e,i)}})),_t},bL:yl,bM:vl,bP:pi,bQ:mi,b_:function(t){return t[eo]},ba:Bi,bb:Di,bc:Pi,bd:Oi,be:Mi,bf:Li,bg:Ni,bh:Fi,bi:ki,bj:Vi,bk:Gi,bl:Ui,bm:zi,bn:Hi,bo:Wi,bp:ji,bq:Qi,br:Zi,bx:pe,by:ge,bz:Se,c:ttt,c$:z,c1:Yu,c3:U,c4:F,c5:V,c6:k,c7:G,c8:X,c9:J,cA:Sh,cB:Fh,cN:no,cP:function(t,e,i){if(me(t,e),me(t,i),e===i)return t;var n=t[e];if(e<i)for(var r=e+1;r<=i;++r)t[r-1]=t[r];else for(var s=e;s!==i;--s)t[s]=t[s-1];return t[i]=n,t},cS:function(t,e,i){ai(We(t),e,i)},cT:ai,cW:Wo,cX:jo,c_:function(t,e){e.forEach((function(e){Object.getOwnPropertyNames(e.prototype).forEach((function(i){"constructor"!==i&&Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))}))}))},ca:Y,cb:$,cc:et,cd:it,ce:tt,cz:Dl,d0:function(t,e){return Ps(t,e,0)},d1:Ps,d2:function(t,e,i){for(var n=0,r=t.length-1,s=r>>>1;n<=r;s=n+r>>>1){var o=t[s];if(i(o,e)<0)r=s-1;else{if(!(i(o,e)>0))return s;n=s+1}}return~n},d3:function(){},d4:function(){},d5:me,d6:Fl,dC:aL,dd:hM,e5:Mp,e7:g8,fW:_pt,fX:dpt}),m("CC_WECHAT",!1),m("CC_BAIDU",!1),m("CC_XIAOMI",!1),m("CC_ALIPAY",!1),m("CC_BYTEDANCE",!1),m("CC_OPPO",!1),m("CC_VIVO",!1),m("CC_HUAWEI",!1),m("CC_COCOSPLAY",!1),m("CC_QTT",!1),m("CC_LINKSURE",!1);const g=!1;m("CC_EDITOR",!1);m("CC_PREVIEW",!1),m("CC_BUILD",!0),m("CC_TEST",!1),m("CC_DEBUG",!1),m("CC_DEV",!1),m("CC_MINIGAME",!1),m("CC_RUNTIME_BASED",!1),m("CC_SUPPORT_JIT",!0),m("CC_JSB",!1);var y="undefined"==typeof window?global:window,v=t("aJ",{_global:y});v.internal={};var S=t("aI","3.8.2");y.CocosEngine=v.ENGINE_VERSION=S,y.cc=v;var T=void 0!==globalThis.jsb&&void 0!==jsb.window?jsb.window:globalThis;function A(t){var e,i;return e=(t>65535)<<4,e|=i=((t>>>=e)>255)<<3,e|=i=((t>>>=i)>15)<<2,(e|=i=((t>>>=i)>3)<<1)|(t>>>=i)>>1}function b(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}function E(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}function C(t){return--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,1+(t|=t>>>16)}y.ccwindow=T;var w=new Array(256);!function(t){for(var e=0;e<256;++e){var i=e,n=e,r=7;for(i>>>=1;i;i>>>=1)n<<=1,n|=1&i,--r;t[e]=n<<r&255}}(w);var x=Object.freeze({__proto__:null,INT_BITS:32,INT_MAX:2147483647,INT_MIN:-2147483648,sign:function(t){return(t>0)-(t<0)},abs:function(t){var e=t>>31;return(t^e)-e},min:function(t,e){return e^(t^e)&-(t<e)},max:function(t,e){return t^(t^e)&-(t<e)},isPow2:function(t){return!(t&t-1||!t)},log2:A,log10:function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},popCount:b,countTrailingZeros:E,nextPow2:C,prevPow2:function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},parity:function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1},reverse:function(t){return w[255&t]<<24|w[t>>>8&255]<<16|w[t>>>16&255]<<8|w[t>>>24&255]},interleave2:function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},deinterleave2:function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},interleave3:function(t,e,i){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(i=1227133513&((i=3272356035&((i=251719695&((i=4278190335&((i&=1023)|i<<16))|i<<8))|i<<4))|i<<2))<<2},deinterleave3:function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},nextCombination:function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>E(t)+1}});t("aK",x);var R=T.document,I="https://github.com/cocos-creator/engine/blob/develop/EngineErrorMap.md",B=null,D=console.log.bind(console),P=D,O=D,M=function(t,e){if(!t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];console.log("ASSERT: "+N.apply(void 0,[e].concat(n)))}},L=D;function N(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return v.js.formatStr.apply(null,e)}function F(){return D.apply(void 0,arguments)}function k(){return P.apply(void 0,arguments)}function V(){return O.apply(void 0,arguments)}function G(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return M.apply(void 0,[t,e].concat(n))}function U(){return L.apply(void 0,arguments)}function z(t){if(D=P=O=M=L=function(){},t!==Q.NONE){if(t>Q.ERROR){var e=function(t){if(v.game.canvas){if(!B){var e=R.createElement("Div");e.setAttribute("id","logInfoDiv"),e.setAttribute("width","200"),e.setAttribute("height",v.game.canvas.height);var i=e.style;i.zIndex="99999",i.position="absolute",i.top=i.left="0",(B=R.createElement("textarea")).setAttribute("rows","20"),B.setAttribute("cols","30"),B.setAttribute("disabled","true");var n=B.style;n.backgroundColor="transparent",n.borderBottom="1px solid #cccccc",n.borderTopWidth=n.borderLeftWidth=n.borderRightWidth="0px",n.borderTopStyle=n.borderLeftStyle=n.borderRightStyle="none",n.padding="0px",n.margin="0px",e.appendChild(B),v.game.canvas.parentNode.appendChild(e)}B.value=B.value+t+"\r\n",B.scrollTop=B.scrollHeight}};O=function(){e("ERROR : "+N.apply(void 0,arguments))},M=function(t,i){if(!t){for(var n=arguments.length,r=new Array(n>2?n-2:0),s=2;s<n;s++)r[s-2]=arguments[s];e("ASSERT: "+N.apply(void 0,[i].concat(r)))}},t!==Q.ERROR_FOR_WEB_PAGE&&(P=function(){e("WARN : "+N.apply(void 0,arguments))}),t===Q.INFO_FOR_WEB_PAGE&&(D=function(){e(N.apply(void 0,arguments))})}else console&&(console.error||(console.error=console.log),console.warn||(console.warn=console.log),O=console.error.bind?console.error.bind(console):function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return console.error.apply(console,e)},M=function(t,e){if(!t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];var s=N.apply(void 0,[e].concat(n));throw new Error(s)}});if(t!==Q.ERROR&&(P=console.warn.bind?console.warn.bind(console):function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return console.warn.apply(console,e)}),t<=Q.INFO&&(D=console.log.bind?console.log.bind(console):function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return console.log.apply(console,e)}),t<=Q.VERBOSE&&"function"==typeof console.debug){var i=console.debug.bind(console);L=function(){return i.apply(void 0,arguments)}}}}function H(t){V(t.stack||t)}function W(t){return function(e){for(var i=t+" "+e+", please go to "+I+"#"+e+" to see details.",n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return 0===r.length?i:i+" Arguments: "+r.join(", ")}}var j=W("Log");function X(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];F(j.apply(void 0,[t].concat(i)))}var q=W("Warning");function Y(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];k(q.apply(void 0,[t].concat(i)))}var K=W("Error");function J(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];V(K.apply(void 0,[t].concat(i)))}var Q,Z=W("Assert");function $(t,e){if(!t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];G(!1,Z.apply(void 0,[e].concat(n)))}}function tt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return K.apply(void 0,[t].concat(i))}function et(){return!!v.profiler&&v.profiler.isShowingStats()}function it(t){v.profiler&&(t?v.profiler.showStats():v.profiler.hideStats())}t("cf",Q),function(t){t[t.NONE=0]="NONE",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.INFO_FOR_WEB_PAGE=5]="INFO_FOR_WEB_PAGE",t[t.WARN_FOR_WEB_PAGE=6]="WARN_FOR_WEB_PAGE",t[t.ERROR_FOR_WEB_PAGE=7]="ERROR_FOR_WEB_PAGE"}(Q||t("cf",Q={}));var nt,rt,st,ot,at,ht=Object.freeze({__proto__:null,log:F,warn:k,error:V,assert:G,debug:U,_resetDebugSetting:z,_throw:H,logID:X,warnID:Y,errorID:J,assertID:$,get DebugMode(){return Q},getError:tt,isDisplayStats:et,setDisplayStats:it}),ut=10;t("bF",nt),t("bG",rt),t("bH",st);var lt=0,ct=new Map;ot=function(t,e,i,n,r,s,o){var a=ct.get(s);a&&a.logTimes>a.count&&(r("'%s' is deprecated, please use '%s' instead. "+o,t+"."+e,i+"."+n),a.count++)},t("bF",nt=function(t,e,i){null!=t&&i.forEach((function(i){var n=lt++;ct.set(n,{id:n,count:0,logTimes:void 0!==i.logTimes?i.logTimes:ut});var r=null!=i.target?i.target:t,s=null!=i.newName?i.newName:i.name,o=null!=i.targetName?i.targetName:e,a=r===t,h=i.suggest?"("+i.suggest+")":"";if(null!=i.customFunction)t[i.name]=function(){var t;return ot(e,i.name,o,s,k,n,h),(t=i.customFunction).call.apply(t,[this].concat(Array.prototype.slice.call(arguments)))};else if(null!=i.customSetter||null!=i.customGetter){var u=null!=i.customSetter,l=null!=i.customGetter;u&&l?Object.defineProperty(t,i.name,{get:function(){return ot(e,i.name,o,s,k,n,h),i.customGetter.call(this)},set:function(t){ot(e,i.name,o,s,k,n,h),i.customSetter.call(this,t)},enumerable:!1}):u?Object.defineProperty(t,i.name,{set:function(t){ot(e,i.name,o,s,k,n,h),i.customSetter.call(this,t)},enumerable:!1}):l&&Object.defineProperty(t,i.name,{get:function(){return ot(e,i.name,o,s,k,n,h),i.customGetter.call(this)},enumerable:!1})}else Object.defineProperty(t,i.name,{get:function(){return ot(e,i.name,o,s,k,n,h),a?this[s]:r[s]},set:function(t){ot(e,i.name,o,s,k,n,h),a?this[s]=t:r[s]=t},enumerable:!1})}))}),at=function(t,e,i,n,r){var s=ct.get(n);s&&s.logTimes>s.count&&(i("'%s' has been removed. "+r,t+"."+e),s.count++)},t("bG",rt=function(t,e,i){null!=t&&i.forEach((function(i){var n=lt++;ct.set(n,{id:n,count:0,logTimes:void 0!==i.logTimes?i.logTimes:ut});var r=i.suggest?"("+i.suggest+")":"";Object.defineProperty(t,i.name,{get:function(){return at(e,i.name,V,n,r)},set:function(){at(e,i.name,V,n,r)},enumerable:!1})}))}),t("bH",st=function(){});var _t,dt,ft={};function pt(t){for(var e in t){var i=t[e];ft[e]=i}}function mt(t){var e=ft[t];if(e){var i=e.newName,n=e.since;e.removed?i?J(16003,t,n,i):J(16002,t,n):i?Y(16001,t,n,i):Y(16e3,t,n)}}var gt=function(){function t(t){this.id=void 0,this.prefix=void 0,this.id=0|998*Math.random(),this.prefix=t?t+".":""}return t.prototype.getNewId=function(){return this.prefix+(++this.id).toString()},t}();dt=gt,gt.global=new dt("global");var yt=new gt("TmpCId."),vt="undefined"==typeof Symbol?"__aliases__":Symbol("[[Aliases]]"),St="__cid__";function Tt(t){return"number"==typeof t||t instanceof Number}function At(t){return"string"==typeof t||t instanceof String}function bt(t){for(var e in t)return!1;return!0}var Et,Ct=(Et={value:void 0,enumerable:!1,writable:!1,configurable:!0},function(t,e,i,n,r){Et.value=i,Et.writable=n,Et.enumerable=r,Object.defineProperty(t,e,Et),Et.value=void 0}),wt=function(){var t={get:void 0,set:void 0,enumerable:!1};return function(e,i,n,r,s,o){void 0===s&&(s=!1),void 0===o&&(o=!1),"boolean"==typeof r&&(console.log("Set `setter` to boolean is deprecated. Please don not use like this again."),s=r,r=void 0),t.get=n,t.set=r,t.enumerable=s,t.configurable=o,Object.defineProperty(e,i,t),t.get=void 0,t.set=void 0}}(),xt=function(){var t={get:void 0,enumerable:!1,configurable:!1};return function(e,i,n,r,s){t.get=n,t.enumerable=r,t.configurable=s,Object.defineProperty(e,i,t),t.get=void 0}}(),Rt=function(){var t={set:void 0,enumerable:!1,configurable:!1};return function(e,i,n,r,s){t.set=n,t.enumerable=r,t.configurable=s,Object.defineProperty(e,i,t),t.set=void 0}}();function It(t){var e=Object.create(null);return t&&(e["."]=1,e["/"]=1,delete e["."],delete e["/"]),e}function Bt(t){if("function"==typeof t){var e=t.prototype;if(e&&e.hasOwnProperty("__classname__")&&e.__classname__)return e.__classname__;var i="";if(t.name&&(i=t.name),t.toString){var n,r=t.toString();(n="["===r.charAt(0)?/\[\w+\s*(\w+)\]/.exec(r):/function\s*(\w+)/.exec(r))&&2===n.length&&(i=n[1])}return"Object"!==i?i:""}return t&&t.constructor?Bt(t.constructor):""}function Dt(t,e,i,n){var r=/([^.]+)$/,s=r.exec(e)[0],o=r.exec(i)[0];function a(){return this[o]}n?wt(t,s,a,(function(t){this[o]=t})):xt(t,s,a)}function Pt(t,e,i,n){for(var r in i)Dt(t,e+"."+r,i[r],n)}var Ot=/(%d)|(%s)/,Mt=/%s/;function Lt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];if(0===arguments.length)return"";if(0===i.length)return""+t;var r="string"==typeof t&&Ot.test(t);if(r)for(var s,o=d(i);!(s=o()).done;){var a=s.value,h="number"==typeof a?Ot:Mt;if(h.test(t)){var u=""+a;t=t.replace(h,u)}else t+=" "+a}else for(var l,c=d(i);!(l=c()).done;){var _=l.value;t+=" "+_}return t}function Nt(){for(var t=arguments.length-1,e=new Array(t),i=0;i<t;++i)e[i]=arguments[i+1];return e}function Ft(t,e){for(;t;){var i=Object.getOwnPropertyDescriptor(t,e);if(i)return i;t=Object.getPrototypeOf(t)}return null}function kt(t,e,i){var n=Ft(e,t);n&&Object.defineProperty(i,t,n)}function Vt(t){t=t||{};for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];for(var r=0,s=i;r<s.length;r++){var o=s[r];if(o){if("object"!=typeof o){J(5402,o);continue}for(var a in o)a in t||kt(a,o,t)}}return t}function Gt(t){t=t||{};for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];for(var r=0,s=i;r<s.length;r++){var o=s[r];if(o){if("object"!=typeof o){J(5403,o);continue}for(var a in o)kt(a,o,t)}}return t}function Ut(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.prototype=Object.create(e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),t}function zt(t){var e=t.prototype,i=e&&Object.getPrototypeOf(e);return i&&i.constructor}function Ht(t,e){if(t&&e){if("function"!=typeof t)return!1;if("function"!=typeof e)return!1;if(t===e)return!0;for(;;){if(!(t=zt(t)))return!1;if(t===e)return!0}}return!1}function Wt(t){for(var e=0,i=Object.keys(t);e<i.length;e++)delete t[i[e]]}var jt=It(!0),Xt=It(!0);function qt(t,e,i){return function(n,r){if(r.prototype.hasOwnProperty(t)&&delete e[r.prototype[t]],Ct(r.prototype,t,n),n){var s=e[n];!i&&s&&s!==r?V("A Class already exists with the same "+t+' : "'+n+'".'):e[n]=r}}}var Yt=qt("__cid__",jt,!1),Kt=qt("__classname__",Xt,!0);function Jt(t,e){if(Kt(t,e),!e.prototype.hasOwnProperty(St)){var i=t||yt.getNewId();i&&Yt(i,e)}}function Qt(t,e){var i=Xt[e],n=jt[e],r=!0;if(i&&i!==t&&(V('"'+e+'" has already been set as name or alias of another class.'),r=!1),n&&n!==t&&(V('"'+e+'" has already been set as id or alias of another class.'),r=!1),r){var s=t[vt];s||(s=[],t[vt]=s),s.push(e),Xt[e]=t,jt[e]=t}}function Zt(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];for(var n=0,r=e;n<r.length;n++){var s=r[n],o=s.prototype,a=o.__cid__;a&&delete jt[a];var h=o.__classname__;h&&delete Xt[h];var u=o[vt];if(u)for(var l=0;l<u.length;++l){var c=u[l];delete Xt[c],delete jt[c]}}}function $t(t){return te(t)}function te(t){return jt[t]}function ee(t){return Xt[t]}function ie(t,e){return ne(t,e)}function ne(t,e){if(e=void 0===e||e,"function"==typeof t&&t.prototype.hasOwnProperty(St))return t.prototype.__cid__;if(t&&t.constructor){var i=t.constructor.prototype;if(i&&i.hasOwnProperty(St))return t.__cid__}return""}var re=function(){var t=e.prototype;function e(t,e){this.count=void 0,this._pool=void 0,this._cleanup=void 0;var i=void 0===e?t:e,n=void 0===e?null:t;this.count=0,this._pool=new Array(i),this._cleanup=n}return t.get=function(){return this._get()},t._get=function(){if(this.count>0){--this.count;var t=this._pool[this.count];return this._pool[this.count]=null,t}return null},t.put=function(t){var e=this._pool;if(this.count<e.length){if(this._cleanup&&!1===this._cleanup(t))return;e[this.count]=t,++this.count}},t.resize=function(t){t>=0&&(this._pool.length=t,this.count>t&&(this.count=t))},e}(),se=function(){function t(t){this.i=0,this.array=t}var e=t.prototype;return e.remove=function(t){var e=this.array.indexOf(t);e>=0&&this.removeAt(e)},e.removeAt=function(t){this.array.splice(t,1),t<=this.i&&--this.i},e.fastRemove=function(t){var e=this.array.indexOf(t);e>=0&&this.fastRemoveAt(e)},e.fastRemoveAt=function(t){var e=this.array;e[t]=e[e.length-1],--e.length,t<=this.i&&--this.i},e.push=function(t){this.array.push(t)},n(t,[{key:"length",get:function(){return this.array.length},set:function(t){this.array.length=t,this.i>=t&&(this.i=t-1)}}]),t}();function oe(t,e){t.splice(e,1)}function ae(t,e){var i=t.length;e<0||e>=i||(t[e]=t[i-1],t.length=i-1)}function he(t,e){var i=t.indexOf(e);return i>=0&&(oe(t,i),!0)}function ue(t,e){var i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],--t.length)}function le(t,e){var i=t.findIndex(e);if(i>=0){var n=t[i];return oe(t,i),n}}function ce(t,e){return t.indexOf(e)>=0}var _e=Object.freeze({__proto__:null,removeAt:oe,fastRemoveAt:ae,remove:he,fastRemove:ue,removeIf:le,verifyType:function(t,e){if(t&&t.length>0)for(var i,n=d(t);!(i=n()).done;)if(!(i.value instanceof e))return X(1300),!1;return!0},removeArray:function(t,e){for(var i=0,n=e.length;i<n;i++)he(t,e[i])},appendObjectsAt:function(t,e,i){return t.splice.apply(t,[i,0].concat(e)),t},contains:ce,copy:function(t){for(var e=t.length,i=new Array(e),n=0;n<e;n+=1)i[n]=t[n];return i},MutableForwardIterator:se}),de={IDGenerator:gt,Pool:re,array:_e,isNumber:Tt,isString:At,isEmptyObject:bt,getPropertyDescriptor:Ft,addon:Vt,mixin:Gt,extend:Ut,getSuper:zt,isChildClassOf:Ht,clear:Wt,value:Ct,getset:wt,get:xt,set:Rt,unregisterClass:Zt,getClassName:Bt,setClassName:Jt,setClassAlias:Qt,getClassByName:ee,getClassById:te,get _registeredClassNames(){return r({},Xt)},set _registeredClassNames(t){Wt(Xt),Object.assign(Xt,t)},get _registeredClassIds(){return r({},jt)},set _registeredClassIds(t){Wt(jt),Object.assign(jt,t)},_getClassId:ie,getClassId:ne,_setClassId:Yt,_getClassById:$t,obsolete:Dt,obsoletes:Pt,formatStr:Lt,shiftArguments:Nt,createMap:It};v.js=de;var fe=Object.freeze({__proto__:null,array:_e,js:de,IDGenerator:gt,Pool:re,isNumber:Tt,isString:At,isEmptyObject:bt,value:Ct,getset:wt,get:xt,set:Rt,createMap:It,getClassName:Bt,obsolete:Dt,obsoletes:Pt,formatStr:Lt,shiftArguments:Nt,getPropertyDescriptor:Ft,copyAllProperties:function(t,e,i){for(var n=Object.getOwnPropertyNames(t),r=0,s=n.length;r<s;++r){var o=n[r];-1===i.indexOf(o)&&kt(o,t,e)}},addon:Vt,mixin:Gt,extend:Ut,getSuper:zt,isChildClassOf:Ht,clear:Wt,_idToClass:jt,_nameToClass:Xt,_setClassId:Yt,setClassName:Jt,setClassAlias:Qt,unregisterClass:Zt,_getClassById:$t,getClassById:te,getClassByName:ee,_getClassId:ie,getClassId:ne});function pe(t){if("__bitmask__"in t)return t;Ct(t,"__bitmask__",null,!0);for(var e=-1,i=Object.keys(t),n=0;n<i.length;n++){var r=i[n],s=t[r];if(-1===s)s=++e,t[r]=s;else if("number"==typeof s)e=s;else if("string"==typeof s&&Number.isInteger(parseFloat(r)))continue;var o=""+s;r!==o&&Ct(t,o,r)}return t}function me(t,e){e>=0&&t.length,t.length}function ge(t){return"__enums__"in t?t:(Ct(t,"__enums__",null,!0),ge.update(t))}function ye(t){t.hasOwnProperty("__enums__")}function ve(t){ye(t);var e=t.__enums__||[];for(var i in e.length=0,t){var n=t[i];Number.isInteger(n)&&e.push({name:i,value:n})}return e.sort((function(t,e){return t.value-e.value})),t.__enums__=e,e}function Se(t){"__enums__"in t||Ct(t,"__enums__",null,!0)}t("bB",fe),pe.isBitMask=function(t){return t&&t.hasOwnProperty("__bitmask__")},pe.getList=function(t){return t.__bitmask__?t.__bitmask__:pe.update(t)},pe.update=function(t){Array.isArray(t.__bitmask__)||(t.__bitmask__=[]);var e=t.__bitmask__;for(var i in e.length=0,t){var n=t[i];Number.isInteger(n)&&e.push({name:i,value:n})}return e.sort((function(t,e){return t.value-e.value})),e},v.BitMask=pe,ge.update=function(t){for(var e=-1,i=Object.keys(t),n=0;n<i.length;n++){var r=i[n],s=t[r];if(-1===s)s=++e,t[r]=s;else if("number"==typeof s)e=s;else if("string"==typeof s&&Number.isInteger(parseFloat(r)))continue;var o=""+s;r!==o&&Ct(t,o,r)}return Array.isArray(t.__enums__)&&ve(t),t},ge||t("by",ge={}),ge.isEnum=function(t){return t&&t.hasOwnProperty("__enums__")},ge.getList=function(t){return ye(t),t.__enums__?t.__enums__:ve(t)},ge.sortList=function(t,e){ye(t),Array.isArray(t.__enums__)&&t.__enums__.sort(e)},v.Enum=ge;var Te,Ae=t("bA",function(){function t(){}var e=t.prototype;return e.clone=function(){return J(100,Bt(this)+".clone"),this},e.equals=function(){return!1},e.set=function(){J(100,Bt(this)+".set")},e.toString=function(){return""},t}());Jt("cc.ValueType",Ae),v.ValueType=Ae,function(t){t.PATH="path",t.ENGINE="engine",t.ASSETS="assets",t.SCRIPTING="scripting",t.PHYSICS="physics",t.RENDERING="rendering",t.LAUNCH="launch",t.SCREEN="screen",t.SPLASH_SCREEN="splashScreen",t.ANIMATION="animation",t.PROFILING="profiling",t.PLUGINS="plugins",t.XR="xr"}(Te||(Te={}));var be=t("cv",function(){function t(){this._settings={},this._override={}}var e=t.prototype;return e.init=function(t,e){var i=this;for(var n in void 0===t&&(t=""),void 0===e&&(e={}),e){var r=e[n];if(r)for(var s in r)this.overrideSettings(n,s,r[s])}return t?new Promise((function(e,n){var r=new XMLHttpRequest;r.open("GET",t),r.responseType="text",r.onload=function(){i._settings=JSON.parse(r.response),e()},r.onerror=function(){n(new Error("request settings failed!"))},r.send(null)})):Promise.resolve()},e.overrideSettings=function(t,e,i){t in this._override||(this._override[t]={}),this._override[t][e]=i},e.querySettings=function(t,e){if(t in this._override){var i=this._override[t];if(i&&e in i)return i[e]}if(t in this._settings){var n=this._settings[t];if(n&&e in n)return n[e]}return null},t}());be.Category=Te;var Ee=t("cw",new be);v.settings=Ee;var Ce=t("ci",{SUPPORT_TEXTURE_FORMATS:[".astc",".pkm",".pvr",".webp",".jpg",".jpeg",".bmp",".png"],KEY:{none:0,back:6,menu:18,backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pause:19,capslock:20,escape:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,select:41,insert:45,Delete:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,num0:96,num1:97,num2:98,num3:99,num4:100,num5:101,num6:102,num7:103,num8:104,num9:105,"*":106,"+":107,"-":109,numdel:110,"/":111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,";":186,semicolon:186,equal:187,"=":187,",":188,comma:188,dash:189,".":190,period:190,forwardslash:191,grave:192,"[":219,openbracket:219,backslash:220,"]":221,closebracket:221,quote:222,dpadLeft:1e3,dpadRight:1001,dpadUp:1003,dpadDown:1004,dpadCenter:1005},RAD:Math.PI/180,DEG:180/Math.PI,REPEAT_FOREVER:Number.MAX_VALUE-1,FLT_EPSILON:1.192092896e-7,ORIENTATION_PORTRAIT:1,ORIENTATION_LANDSCAPE:2,ORIENTATION_AUTO:3,ENABLE_TILEDMAP_CULLING:!0,TOUCH_TIMEOUT:5e3,ENABLE_TRANSPARENT_CANVAS:!1,ENABLE_WEBGL_ANTIALIAS:!0,ENABLE_FLOAT_OUTPUT:!1,CLEANUP_IMAGE_CACHE:!1,ENABLE_MULTI_TOUCH:!0,MAX_LABEL_CANVAS_POOL_SIZE:20,ENABLE_WEBGL_HIGHP_STRUCT_VALUES:!1,BATCHER2D_MEM_INCREMENT:144,CUSTOM_PIPELINE_NAME:"",init:function(){var t=Ee.querySettings(be.Category.ENGINE,"macros");if(t)for(var e in t)Ce[e]=t[e]}});v.macro=Ce;for(var we=/^(?:cc|dragonBones|sp|ccsg)\..+/,xe=new Array(123),Re=0;Re<123;++Re)xe[Re]=64;for(var Ie=0;Ie<64;++Ie)xe["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(Ie)]=Ie;var Be=xe;function De(t,e,i){function n(t,e,i,n){var r=Object.getOwnPropertyDescriptor(t,e);if(r)r.get&&(t[i]=r.get),r.set&&n&&(t[n]=r.set);else{var s=t[i];wt(t,e,s,t[n])}}for(var r,s=t.prototype,o=0;o<e.length;o++){var a=(r=e[o])[0].toUpperCase()+r.slice(1);n(s,r,"get"+a,"set"+a)}for(r in i){var h=i[r];n(s,r,h[0],h[1])}}function Pe(t,e,i,n){var r=t[e];r?Array.isArray(r)?n?(r.push(r[0]),r[0]=i):r.push(i):t[e]=n?[i,r]:[r,i]:t[e]=i}function Oe(t,e){if("function"==typeof t.contains)return t.contains(e);if("function"==typeof t.compareDocumentPosition)return!!(16&t.compareDocumentPosition(e));var i=e.parentNode;if(i)do{if(i===t)return!0;i=i.parentNode}while(null!==i);return!1}function Me(t){return"object"==typeof window&&"function"==typeof Node?t instanceof Node:!!t&&"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName}function Le(t,e,i){t&&function(t,e){for(var i,n=arguments.length,r=new Array(n>2?n-2:0),s=2;s<n;s++)r[s-2]=arguments[s];var o=performance.now(),a=requestAnimationFrame||window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(void 0===a||null!==(i=globalThis.__globalXR)&&void 0!==i&&i.isWebXR)return setTimeout.apply(void 0,[t,e].concat(r));var h=function i(){performance.now()-o<e?a(i):t.apply(void 0,r)};a(h)}((function(){t(e,i)}),0)}function Ne(t){return!(!t||t.constructor!==Object)&&bt(t)}function Fe(t,e,i){if(e>i){var n=e;e=i,i=n}return t<e?e:t<i?t:i}function ke(t){return t*Ce.RAD}function Ve(t){return t*Ce.DEG}v.misc={BUILTIN_CLASSID_RE:we,BASE64_VALUES:Be,propertyDefine:De,pushToMap:Pe,contains:Oe,isDomNode:Me,callInNextTick:Le,isPlainEmptyObj_DEV:Ne,clampf:Fe,degreesToRadians:ke,radiansToDegrees:Ve},t("bC",Object.freeze({__proto__:null,BUILTIN_CLASSID_RE:we,BASE64_VALUES:Be,propertyDefine:De,pushToMap:Pe,contains:Oe,isDomNode:Me,callInNextTick:Le,tryCatchFunctor_EDITOR:function(t){return Function("target","try {\n target."+t+"();\n}\ncatch (e) {\n cc._throw(e);\n}")},isPlainEmptyObj_DEV:Ne,clampf:Fe,degreesToRadians:ke,radiansToDegrees:Ve}));var Ge="$_$";function Ue(t,e){var i=e?Object.create(e):{};return Ct(t,"__attrs__",i),i}function ze(t){if("function"!=typeof t)return Ue(t,We(t.constructor));for(var e,i=v.Class.getInheritanceChain(t),n=i.length-1;n>=0;n--){var r=i[n];r.hasOwnProperty("__attrs__")&&r.__attrs__||Ue(r,(e=i[n+1])&&e.__attrs__)}return Ue(t,(e=i[0])&&e.__attrs__),t.__attrs__}function He(t,e){var i=We(t),n=e+Ge,r={};for(var s in i)s.startsWith(n)&&(r[s.slice(n.length)]=i[s]);return r}function We(t){return t.hasOwnProperty("__attrs__")&&t.__attrs__||ze(t)}function je(t,e,i,n){We(t)[e+Ge+i]=n}var Xe=function(){function t(t,e){this.name=void 0,this.default=void 0,this.name=t,this.default=e}return t.prototype.toString=function(){return this.name},t}(),qe=t("bS",new Xe("Integer",0));v.Integer=qe,v.CCInteger=qe;var Ye=t("bT",new Xe("Float",0));v.Float=Ye,v.CCFloat=Ye;var Ke=t("bU",new Xe("Boolean",!1));v.Boolean=Ke,v.CCBoolean=Ke;var Je=t("bV",new Xe("String",""));function Qe(t,e){return function(i,n){var r='"'+Bt(i)+"."+n+'"',s=He(i,n),o=s.type;if(o===qe||o===Ye?o="Number":o!==Je&&o!==Ke||(o=""+o),o===t){if(s.hasOwnProperty("default")){var a=s.default;if(void 0!==a&&!Array.isArray(a)&&!Ne(a)){var h=typeof a,u=t.toLowerCase();if(h===u)if("object"===u){if(!a||a instanceof s.ctor)return;Y(3605,r,Bt(s.ctor))}else"Number"!==t&&Y(3606,e,r,t);else{if("function"===h)return;t===Je.default&&null==a?Y(3607,r):Y(3611,e,r,h)}delete s.type}}}else Y(3604,r)}}v.String=Je,v.CCString=Je;var Ze=Object.freeze({__proto__:null,DELIMETER:Ge,createAttrsSingle:Ue,createAttrs:ze,attr:He,getClassAttrs:We,setClassAttr:je,PrimitiveType:Xe,CCInteger:qe,CCFloat:Ye,CCBoolean:Ke,CCString:Je,getTypeChecker_ET:Qe,getObjTypeChecker_ET:function(t){return function(e,i){Qe("Object","type")(e,i);var n=We(e)[i+Ge+"default"],r=v.Class.getDefault(n);if(!Array.isArray(r)&&Ht(t,v.ValueType)){var s=Bt(t),o=Lt('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.',Bt(e),i,s);n?F(o):Y(3612,o,s,Bt(e),i,s)}}}}),$e={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function ti(t,e,i,n){if(!t.get&&!t.set&&t.hasOwnProperty("default")){var r="_N$"+e;t.get=function(){return this[r]},t.set=function(t){var e=this[r];this[r]=t,i.call(this,e)};var s={};for(var o in n[r]=s,$e){var a=$e[o];t.hasOwnProperty(o)&&(s[o]=t[o],a.canUsedInGet||delete t[o])}}}function ei(t,e,i,n){if(Array.isArray(e)){if(!(e.length>0))return J(5508,i,n);t.type=e=e[0]}"function"==typeof e&&(e===String?t.type=v.String:e===Boolean?t.type=v.Boolean:e===Number&&(t.type=v.Float))}function ii(t,e,i){var n=t||void 0===e?{_short:!0}:{_short:!0,default:e};return i&&(n.type=i),n}function ni(t,e){if(!t||t.constructor!==Object){if(Array.isArray(t)&&t.length>0)return ii(e,[],t);if("function"==typeof t){var i=t;return ii(e,Ht(i,v.ValueType)?new i:null,i)}return t instanceof Xe?ii(e,void 0,t):ii(e,t)}return null}var ri,si=[];function oi(){return si[si.length-1]}function ai(t,e,i){t[e+"$_$type"]="Enum",t[e+"$_$enumList"]=ge.getList(i)}v._RF={push:function(t,e,i,n){void 0===i&&(i=e,e=""),si.push({uuid:e,script:i,module:t,exports:t.exports,beh:null,importMeta:n})},pop:function(){var t=si.pop(),e=t.module,i=e.exports;if(i===t.exports){for(var n in i)return;e.exports=i=t.cls}},peek:oi},function(t){t[t.STANDALONE=1]="STANDALONE",t[t.IMPLICIT_VISIBLE=2]="IMPLICIT_VISIBLE",t[t.IMPLICIT_SERIALIZABLE=4]="IMPLICIT_SERIALIZABLE"}(ri||(ri={}));var hi=Ge,ui="__ctors__",li=t("cU","Enum"),ci=t("cV","BitMask");function _i(t,e,i,n){!function(t,e){!function(t,e){t.indexOf(e)<0&&t.push(e)}(t.__props__,e)}(t,i),yi(t,n,e,i)}function di(t,e,i,n){var r=n.get;n.set,r&&(yi(t,n,e,i),je(t,i,"serializable",!1))}function fi(t){return"function"==typeof t?t():t}function pi(t){var e=t.name,i=t.extends,n=function(t,e,i){var n=v.Component,r=oi();if(r&&Ht(e,n)){if(Ht(r.cls,n))return J(3615),null;t=t||r.script}var s=function(t,e,i){var n=i.ctor;return Ct(n,ui,!0,!0),n.prototype,e&&(n.$super=e),Jt(t,n),n}(t,e,i);if(r)if(Ht(e,n)){var o=r.uuid;o&&Yt(o,s),r.cls=s}else Ht(r.cls,n)||(r.cls=s);return s}(e,i,t);e||(e=v.js.getClassName(n)),n._sealed=!0,i&&(i._sealed=!1),function(t,e,i,n){if(t.__props__=[],n&&n.__props__&&(t.__props__=n.__props__.slice()),i)for(var r in function(t,e){for(var i in t){var n=t[i],r=ni(n,!1);if(r&&(n=t[i]=r),n){var s=n.notify;s&&ti(n,i,s,t),"type"in n&&ei(n,n.type,e,i)}}}(i,e),i){var s=i[r];s.get||s.set?di(t,e,r,s):_i(t,e,r,s)}var o=We(t);t.__values__=t.__props__.filter((function(t){return!1!==o[t+"$_$serializable"]}))}(n,e,t.properties,i);var r=t.editor;return r&&Ht(i,v.Component)&&v.Component._registerEditorProps(n,r),n}function mi(t){var e;return null==t||null===(e=t.hasOwnProperty)||void 0===e?void 0:e.call(t,"__values__")}pi._isCCClass=function(t){var e;return null==t||null===(e=t.hasOwnProperty)||void 0===e?void 0:e.call(t,ui)},pi.fastDefine=function(t,e,i){Jt(t,e);for(var n=e.__props__=e.__values__=Object.keys(i),r=We(e),s=0;s<n.length;s++){var o=n[s];r[o+hi+"visible"]=!1,r[o+hi+"default"]=i[o]}},pi.Attr=Ze,pi.attr=He,pi.isCCClassOrFastDefined=mi,pi.getInheritanceChain=function(t){for(var e=[];t=zt(t);)t!==Object&&e.push(t);return e};var gi={Integer:"Number",Float:"Number",Boolean:"Boolean",String:"String"};function yi(t,e,i,n){var r=null,s="";function o(){return s=n+hi,r=We(t)}"type"in e&&void 0===e.type&&Y(3660,n,i);var a=e.type;a&&(gi[a]?(r||o())[s+"type"]=a:"Object"===a||("object"==typeof a?ge.isEnum(a)?ai(r||o(),n,a):pe.isBitMask(a)&&((r||o())[s+"type"]=ci,r[s+"bitmaskList"]=pe.getList(a)):"function"==typeof a&&((r||o())[s+"type"]="Object",r[s+"ctor"]=a))),"default"in e&&((r||o())[s+"default"]=e.default);var h,u=function(t,i){if(t in e){var n=e[t];typeof n===i&&((r||o())[s+t]=n)}};e.editorOnly&&((r||o())[s+"editorOnly"]=!0),e.__internalFlags&ri.STANDALONE?h=!0===e.serializable||0!=(e.__internalFlags&ri.IMPLICIT_SERIALIZABLE):!1===e.serializable&&(h=!1),void 0!==h&&((r||o())[s+"serializable"]=h),u("formerlySerializedAs","string");var l=e.range;l&&Array.isArray(l)&&l.length>=2&&((r||o())[s+"min"]=l[0],r[s+"max"]=l[1],l.length>2&&(r[s+"step"]=l[2])),u("min","number"),u("max","number"),u("step","number")}pi.isArray=function(t){return t=fi(t),Array.isArray(t)},pi.getDefault=fi,pi.escapeForJS=function(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},pi.IDENTIFIER_RE=/^[A-Za-z_$][0-9A-Za-z_$]*$/,pi.getNewValueTypeCode=function(t){for(var e=Bt(t),i=t.constructor,n="new "+e+"(",r=0;r<i.__props__.length;r++)n+=t[i.__props__[r]],r<i.__props__.length-1&&(n+=",");return n+")"},v.Class=pi;var vi=Math.PI/180,Si=180/Math.PI,Ti=Math.random,Ai=t("b2",.5*Math.PI),bi=t("b3",2*Math.PI),Ei=t("b4",1e-6);function Ci(t,e){return Math.abs(t-e)<=Ei*Math.max(1,Math.abs(t),Math.abs(e))}function wi(t,e,i){return i=i||Ei,Math.abs(t-e)<=i}function xi(t,e,i){if(e>i){var n=e;e=i,i=n}return t<e?e:t>i?i:t}function Ri(t){return t<0?0:t>1?1:t}function Ii(t,e,i){return t+(e-t)*i}function Bi(t){return t*vi}function Di(t){return t*Si}function Pi(){return Ti()}function Oi(t){Ti=t}function Mi(t,e){return Pi()*(e-t)+t}function Li(t,e){return Math.floor(Mi(t,e))}function Ni(t){return(t=(9301*t+49297)%233280)/233280}function Fi(t,e,i){return Ni(t)*(i-e)+e}function ki(t,e,i){return Math.floor(Fi(t,e,i))}function Vi(t){return C(t)}function Gi(t,e){return t-Math.floor(t/e)*e}function Ui(t,e){return t=Gi(t,2*e),e-Math.abs(t-e)}function zi(t,e,i){return(i-t)/(e-t)}function Hi(t){return Math.abs(t.x)>Math.abs(t.y)?Math.abs(t.x)>Math.abs(t.z)?t.x:t.z:Math.abs(t.y)>Math.abs(t.z)?t.y:t.z}function Wi(t,e){return Math.abs(t)>Math.abs(e)?t:e}function ji(t,e){e.forEach((function(e){Object.defineProperty(t,e,{enumerable:!0})}))}var Xi,qi,Yi,Ki=(Xi=new Float32Array(1),qi=new Int32Array(Xi.buffer),function(t){Xi[0]=t;var e=qi[0],i=e>>16&32768,n=2147483647&e,r=n-(112<<23)+4096>>13;return r=n<113<<23?0:r,r=n>=143<<23?31744:r,r=n>255<<23?32256:r,qi[0]=i|r,qi[0]}),Ji=function(){var t=new Float32Array(1),e=new Int32Array(t.buffer);return function(i){var n,r=32767&i,s=r<<13;return 31744!==s?(s+=112<<23,0===r?s=(1048575&s)>>1:32767===r&&(s=2147483647)):s=2139095040,n=(i>>15&1)<<31|s,e[0]=n,t[0]}}();function Qi(t){return Ki(t)}function Zi(t){return Ji(t)}var $i,tn=t("aP",function(t){function e(e,i,n,r){var s;return s=t.call(this)||this,"object"==typeof e?(s.x=e.x,s.y=e.y,s.z=e.z,s.w=e.w):(s.x=e||0,s.y=i||0,s.z=n||0,s.w=r||0),s}s(e,t),e.clone=function(t){return new e(t.x,t.y,t.z,t.w)},e.copy=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t},e.set=function(t,e,i,n,r){return t.x=e,t.y=i,t.z=n,t.w=r,t},e.fromColor=function(t,e){return t.x=e.r,t.y=e.g,t.z=e.b,t.w=e.a,t},e.angle=function(t,e){var i=t.y*e.z-t.z*e.y,n=t.z*e.x-t.x*e.z,r=t.x*e.y-t.y*e.x,s=t.x*e.x+t.y*e.y+t.z*e.z;return Math.atan2(Math.sqrt(i*i+n*n+r*r),s)},e.add=function(t,e,i){return t.x=e.x+i.x,t.y=e.y+i.y,t.z=e.z+i.z,t.w=e.w+i.w,t},e.subtract=function(t,e,i){return t.x=e.x-i.x,t.y=e.y-i.y,t.z=e.z-i.z,t.w=e.w-i.w,t},e.multiply=function(t,e,i){return t.x=e.x*i.x,t.y=e.y*i.y,t.z=e.z*i.z,t.w=e.w*i.w,t},e.divide=function(t,e,i){return t.x=e.x/i.x,t.y=e.y/i.y,t.z=e.z/i.z,t.w=e.w/i.w,t},e.ceil=function(t,e){return t.x=Math.ceil(e.x),t.y=Math.ceil(e.y),t.z=Math.ceil(e.z),t.w=Math.ceil(e.w),t},e.floor=function(t,e){return t.x=Math.floor(e.x),t.y=Math.floor(e.y),t.z=Math.floor(e.z),t.w=Math.floor(e.w),t},e.min=function(t,e,i){return t.x=Math.min(e.x,i.x),t.y=Math.min(e.y,i.y),t.z=Math.min(e.z,i.z),t.w=Math.min(e.w,i.w),t},e.max=function(t,e,i){return t.x=Math.max(e.x,i.x),t.y=Math.max(e.y,i.y),t.z=Math.max(e.z,i.z),t.w=Math.max(e.w,i.w),t},e.round=function(t,e){return t.x=Math.round(e.x),t.y=Math.round(e.y),t.z=Math.round(e.z),t.w=Math.round(e.w),t},e.multiplyScalar=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i,t},e.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t.z=e.z+i.z*n,t.w=e.w+i.w*n,t},e.distance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z,s=e.w-t.w;return Math.sqrt(i*i+n*n+r*r+s*s)},e.squaredDistance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z,s=e.w-t.w;return i*i+n*n+r*r+s*s},e.len=function(t){var e=t.x,i=t.y,n=t.z,r=t.w;return Math.sqrt(e*e+i*i+n*n+r*r)},e.lengthSqr=function(t){var e=t.x,i=t.y,n=t.z,r=t.w;return e*e+i*i+n*n+r*r},e.negate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=-e.w,t},e.inverse=function(t,e){return t.x=1/e.x,t.y=1/e.y,t.z=1/e.z,t.w=1/e.w,t},e.inverseSafe=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w;return Math.abs(i)<Ei?t.x=0:t.x=1/i,Math.abs(n)<Ei?t.y=0:t.y=1/n,Math.abs(r)<Ei?t.z=0:t.z=1/r,Math.abs(s)<Ei?t.w=0:t.w=1/s,t},e.normalize=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w,o=i*i+n*n+r*r+s*s;return o>0?(o=1/Math.sqrt(o),t.x=i*o,t.y=n*o,t.z=r*o,t.w=s*o):(t.x=0,t.y=0,t.z=0,t.w=0),t},e.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},e.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t.w=e.w+n*(i.w-e.w),t},e.scale=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i,t},e.random=function(t,e){e=e||1;var i=2*Pi()*Math.PI,n=2*Pi()-1,r=Math.sqrt(1-n*n);return t.x=r*Math.cos(i)*e,t.y=r*Math.sin(i)*e,t.z=n*e,t.w=0,t},e.transformMat4=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=e.w;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12*o,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13*o,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14*o,t.w=i.m03*n+i.m07*r+i.m11*s+i.m15*o,t},e.transformAffine=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=e.w;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12*o,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13*o,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14*o,t.w=e.w,t},e.transformQuat=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.x,a=i.y,h=i.z,u=i.w,l=u*n+a*s-h*r,c=u*r+h*n-o*s,_=u*s+o*r-a*n,d=-o*n-a*r-h*s;return t.x=l*u+d*-o+c*-h-_*-a,t.y=c*u+d*-a+_*-o-l*-h,t.z=_*u+d*-h+l*-a-c*-o,t.w=e.w,t},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t[i+3]=e.w,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t.w=e[i+3],t},e.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},e.equals=function(t,e,i){return void 0===i&&(i=Ei),!(Math.abs(t.x)===1/0||Math.abs(t.y)===1/0||Math.abs(t.z)===1/0||Math.abs(t.w)===1/0||Math.abs(e.x)===1/0||Math.abs(e.y)===1/0||Math.abs(e.z)===1/0||Math.abs(e.w)===1/0)&&Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(e.y))&&Math.abs(t.z-e.z)<=i*Math.max(1,Math.abs(t.z),Math.abs(e.z))&&Math.abs(t.w-e.w)<=i*Math.max(1,Math.abs(t.w),Math.abs(e.w))};var i=e.prototype;return i.clone=function(){return new e(this.x,this.y,this.z,this.w)},i.set=function(t,e,i,n){return"object"==typeof t?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},i.equals=function(t,e){return void 0===e&&(e=Ei),Math.abs(this.x-t.x)<=e*Math.max(1,Math.abs(this.x),Math.abs(t.x))&&Math.abs(this.y-t.y)<=e*Math.max(1,Math.abs(this.y),Math.abs(t.y))&&Math.abs(this.z-t.z)<=e*Math.max(1,Math.abs(this.z),Math.abs(t.z))&&Math.abs(this.w-t.w)<=e*Math.max(1,Math.abs(this.w),Math.abs(t.w))},i.equals4f=function(t,e,i,n,r){return void 0===r&&(r=Ei),Math.abs(this.x-t)<=r*Math.max(1,Math.abs(this.x),Math.abs(t))&&Math.abs(this.y-e)<=r*Math.max(1,Math.abs(this.y),Math.abs(e))&&Math.abs(this.z-i)<=r*Math.max(1,Math.abs(this.z),Math.abs(i))&&Math.abs(this.w-n)<=r*Math.max(1,Math.abs(this.w),Math.abs(n))},i.strictEquals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},i.strictEquals4f=function(t,e,i,n){return this.x===t&&this.y===e&&this.z===i&&this.w===n},i.lerp=function(t,e){var i=this.x,n=this.y,r=this.z,s=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=r+e*(t.z-r),this.w=s+e*(t.w-s),this},i.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+", "+this.w.toFixed(2)+")"},i.clampf=function(t,e){return this.x=xi(this.x,t.x,e.x),this.y=xi(this.y,t.y,e.y),this.z=xi(this.z,t.z,e.z),this.w=xi(this.w,t.w,e.w),this},i.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},i.add4f=function(t,e,i,n){return this.x+=t,this.y+=e,this.z+=i,this.w+=n,this},i.subtract=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},i.subtract4f=function(t,e,i,n){return this.x-=t,this.y-=e,this.z-=i,this.w-=n,this},i.multiplyScalar=function(t){return"object"==typeof t&&console.warn("should use Vec4.multiply for vector * vector operation"),this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.multiply=function(t){return"object"!=typeof t&&console.warn("should use Vec4.scale for vector * scalar operation"),this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this},i.multiply4f=function(t,e,i,n){return this.x*=t,this.y*=e,this.z*=i,this.w*=n,this},i.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this},i.divide4f=function(t,e,i,n){return this.x/=t,this.y/=e,this.z/=i,this.w/=n,this},i.negative=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},i.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},i.cross=function(t){var e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,o=t.z;return this.x=i*o-n*s,this.y=n*r-e*o,this.z=e*s-i*r,this},i.length=function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},i.lengthSqr=function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},i.normalize=function(){var t=this.x,e=this.y,i=this.z,n=this.w,r=t*t+e*e+i*i+n*n;return r>0&&(r=1/Math.sqrt(r),this.x=t*r,this.y=e*r,this.z=i*r,this.w=n*r),this},i.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.transformMat4=function(t){var e=this.x,i=this.y,n=this.z,r=this.w;return this.x=t.m00*e+t.m04*i+t.m08*n+t.m12*r,this.y=t.m01*e+t.m05*i+t.m09*n+t.m13*r,this.z=t.m02*e+t.m06*i+t.m10*n+t.m14*r,this.w=t.m03*e+t.m07*i+t.m11*n+t.m15*r,this},e}(Ae));function en(t,e,i,n){return new tn(t,e,i,n)}Yi=tn,tn.ZERO=Object.freeze(new Yi(0,0,0,0)),tn.ONE=Object.freeze(new Yi(1,1,1,1)),tn.NEG_ONE=Object.freeze(new Yi(-1,-1,-1,-1)),tn.UNIT_X=Object.freeze(new Yi(1,0,0,0)),tn.UNIT_Y=Object.freeze(new Yi(0,1,0,0)),tn.UNIT_Z=Object.freeze(new Yi(0,0,1,0)),tn.UNIT_W=Object.freeze(new Yi(0,0,0,1)),pi.fastDefine("cc.Vec4",tn,{x:0,y:0,z:0,w:0}),v.Vec4=tn,v.v4=en;var nn,rn,sn,on=t("aN",function(t){function e(e,i,n){var r;return r=t.call(this)||this,"object"==typeof e?(r.x=e.x,r.y=e.y,r.z=e.z):(r.x=e||0,r.y=i||0,r.z=n||0),r}s(e,t),e.zero=function(t){return t.x=0,t.y=0,t.z=0,t},e.clone=function(t){return new e(t.x,t.y,t.z)},e.copy=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t},e.set=function(t,e,i,n){return t.x=e,t.y=i,t.z=n,t},e.add=function(t,e,i){return t.x=e.x+i.x,t.y=e.y+i.y,t.z=e.z+i.z,t},e.subtract=function(t,e,i){return t.x=e.x-i.x,t.y=e.y-i.y,t.z=e.z-i.z,t},e.multiply=function(t,e,i){return t.x=e.x*i.x,t.y=e.y*i.y,t.z=e.z*i.z,t},e.divide=function(t,e,i){return t.x=e.x/i.x,t.y=e.y/i.y,t.z=e.z/i.z,t},e.ceil=function(t,e){return t.x=Math.ceil(e.x),t.y=Math.ceil(e.y),t.z=Math.ceil(e.z),t},e.floor=function(t,e){return t.x=Math.floor(e.x),t.y=Math.floor(e.y),t.z=Math.floor(e.z),t},e.min=function(t,e,i){return t.x=Math.min(e.x,i.x),t.y=Math.min(e.y,i.y),t.z=Math.min(e.z,i.z),t},e.max=function(t,e,i){return t.x=Math.max(e.x,i.x),t.y=Math.max(e.y,i.y),t.z=Math.max(e.z,i.z),t},e.round=function(t,e){return t.x=Math.round(e.x),t.y=Math.round(e.y),t.z=Math.round(e.z),t},e.multiplyScalar=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t},e.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t.z=e.z+i.z*n,t},e.distance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z;return Math.sqrt(i*i+n*n+r*r)},e.squaredDistance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z;return i*i+n*n+r*r},e.len=function(t){var e=t.x,i=t.y,n=t.z;return Math.sqrt(e*e+i*i+n*n)},e.lengthSqr=function(t){var e=t.x,i=t.y,n=t.z;return e*e+i*i+n*n},e.negate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t},e.invert=function(t,e){return t.x=1/e.x,t.y=1/e.y,t.z=1/e.z,t},e.invertSafe=function(t,e){var i=e.x,n=e.y,r=e.z;return Math.abs(i)<Ei?t.x=0:t.x=1/i,Math.abs(n)<Ei?t.y=0:t.y=1/n,Math.abs(r)<Ei?t.z=0:t.z=1/r,t},e.normalize=function(t,e){var i=e.x,n=e.y,r=e.z,s=i*i+n*n+r*r;return s>0?(s=1/Math.sqrt(s),t.x=i*s,t.y=n*s,t.z=r*s):(t.x=0,t.y=0,t.z=0),t},e.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},e.cross=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.x,a=i.y,h=i.z;return t.x=r*h-s*a,t.y=s*o-n*h,t.z=n*a-r*o,t},e.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t},e.random=function(t,e){e=e||1;var i=2*Pi()*Math.PI,n=2*Pi()-1,r=Math.sqrt(1-n*n);return t.x=r*Math.cos(i)*e,t.y=r*Math.sin(i)*e,t.z=n*e,t},e.transformMat4=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.m03*n+i.m07*r+i.m11*s+i.m15;return o=o?1/o:1,t.x=(i.m00*n+i.m04*r+i.m08*s+i.m12)*o,t.y=(i.m01*n+i.m05*r+i.m09*s+i.m13)*o,t.z=(i.m02*n+i.m06*r+i.m10*s+i.m14)*o,t},e.transformMat4Normal=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.m03*n+i.m07*r+i.m11*s;return o=o?1/o:1,t.x=(i.m00*n+i.m04*r+i.m08*s)*o,t.y=(i.m01*n+i.m05*r+i.m09*s)*o,t.z=(i.m02*n+i.m06*r+i.m10*s)*o,t},e.transformMat3=function(t,e,i){var n=e.x,r=e.y,s=e.z;return t.x=n*i.m00+r*i.m03+s*i.m06,t.y=n*i.m01+r*i.m04+s*i.m07,t.z=n*i.m02+r*i.m05+s*i.m08,t},e.transformAffine=function(t,e,i){var n=e.x,r=e.y,s=e.z;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14,t},e.transformQuat=function(t,e,i){var n=i.w*e.x+i.y*e.z-i.z*e.y,r=i.w*e.y+i.z*e.x-i.x*e.z,s=i.w*e.z+i.x*e.y-i.y*e.x,o=-i.x*e.x-i.y*e.y-i.z*e.z;return t.x=n*i.w+o*-i.x+r*-i.z-s*-i.y,t.y=r*i.w+o*-i.y+s*-i.x-n*-i.z,t.z=s*i.w+o*-i.z+n*-i.y-r*-i.x,t},e.transformRTS=function(t,e,i,n,r){var s=e.x*r.x,o=e.y*r.y,a=e.z*r.z,h=i.w*s+i.y*a-i.z*o,u=i.w*o+i.z*s-i.x*a,l=i.w*a+i.x*o-i.y*s,c=-i.x*s-i.y*o-i.z*a;return t.x=h*i.w+c*-i.x+u*-i.z-l*-i.y+n.x,t.y=u*i.w+c*-i.y+l*-i.x-h*-i.z+n.y,t.z=l*i.w+c*-i.z+h*-i.y-u*-i.x+n.z,t},e.transformInverseRTS=function(t,e,i,n,r){var s=e.x-n.x,o=e.y-n.y,a=e.z-n.z,h=i.w*s-i.y*a+i.z*o,u=i.w*o-i.z*s+i.x*a,l=i.w*a-i.x*o+i.y*s,c=i.x*s+i.y*o+i.z*a;return t.x=(h*i.w+c*i.x+u*i.z-l*i.y)/r.x,t.y=(u*i.w+c*i.y+l*i.x-h*i.z)/r.y,t.z=(l*i.w+c*i.z+h*i.y-u*i.x)/r.z,t},e.rotateX=function(t,e,i,n){var r=e.x-i.x,s=e.y-i.y,o=e.z-i.z,a=Math.cos(n),h=Math.sin(n),u=r,l=s*a-o*h,c=s*h+o*a;return t.x=u+i.x,t.y=l+i.y,t.z=c+i.z,t},e.rotateY=function(t,e,i,n){var r=e.x-i.x,s=e.y-i.y,o=e.z-i.z,a=Math.cos(n),h=Math.sin(n),u=o*h+r*a,l=s,c=o*a-r*h;return t.x=u+i.x,t.y=l+i.y,t.z=c+i.z,t},e.rotateZ=function(t,e,i,n){var r=e.x-i.x,s=e.y-i.y,o=e.z-i.z,a=Math.cos(n),h=Math.sin(n),u=r*a-s*h,l=r*h+s*a,c=o;return t.x=u+i.x,t.y=l+i.y,t.z=c+i.z,t},e.rotateN=function(t,e,i,n,r){var s=e.x-i.x,o=e.y-i.y,a=e.z-i.z,h=n.x,u=n.y,l=n.z,c=Math.cos(r),_=Math.sin(r),d=s*(h*h*(1-c)+c)+o*(h*u*(1-c)-h*_)+a*(h*l*(1-c)+u*_),f=s*(h*u*(1-c)+l*_)+o*(u*u*(1-c)+c)+a*(u*l*(1-c)-h*_),p=s*(h*l*(1-c)-u*_)+o*(u*l*(1-c)+h*_)+a*(l*l*(1-c)+c);return t.x=d+i.x,t.y=f+i.y,t.z=p+i.z,t},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t},e.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z},e.equals=function(t,e,i){void 0===i&&(i=Ei);var n=t.x,r=t.y,s=t.z,o=e.x,a=e.y,h=e.z;return Math.abs(n-o)<=i*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=i*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(s-h)<=i*Math.max(1,Math.abs(s),Math.abs(h))},e.angle=function(t,e){var i=t.x*t.x+t.y*t.y+t.z*t.z,n=e.x*e.x+e.y*e.y+e.z*e.z;if(0===i||0===n)return 0;var r=(t.x*e.x+t.y*e.y+t.z*e.z)/Math.sqrt(i*n);return r=xi(r,-1,1),Math.acos(r)},e.projectOnPlane=function(t,i,n){return e.subtract(t,i,e.project(t,i,n))},e.project=function(t,i,n){var r=e.lengthSqr(n);return r<1e-6?e.set(t,0,0,0):e.multiplyScalar(t,n,e.dot(i,n)/r)},e.moveTowards=function(t,e,i,n){var r=i.x-e.x,s=i.y-e.y,o=i.z-e.z,a=r*r+s*s+o*o;if(0===a||n>=0&&a<n*n)return t.x=i.x,t.y=i.y,t.z=i.z,t;var h=n/Math.sqrt(a);return t.x=e.x+r*h,t.y=e.y+s*h,t.z=e.z+o*h,t},e.generateOrthogonal=function(t,i){var n=i.x,r=i.y,s=i.z,o=Math.abs(n),a=Math.abs(r),h=Math.abs(s);return o<a&&o<h?e.set(t,0,s,-r):a<h?e.set(t,s,0,-n):e.set(t,r,-n,0),e.normalize(t,t)};var i=e.prototype;return i.clone=function(){return new e(this.x,this.y,this.z)},i.set=function(t,e,i){return"object"==typeof t?(this.x=t.x,this.y=t.y,this.z=t.z):(this.x=t||0,this.y=e||0,this.z=i||0),this},i.equals=function(t,e){return void 0===e&&(e=Ei),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&Math.abs(this.z-t.z)<=e},i.equals3f=function(t,e,i,n){return void 0===n&&(n=Ei),Math.abs(this.x-t)<=n&&Math.abs(this.y-e)<=n&&Math.abs(this.z-i)<=n},i.strictEquals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},i.strictEquals3f=function(t,e,i){return this.x===t&&this.y===e&&this.z===i},i.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+")"},i.lerp=function(t,e){return this.x+=e*(t.x-this.x),this.y+=e*(t.y-this.y),this.z+=e*(t.z-this.z),this},i.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},i.add3f=function(t,e,i){return this.x+=t,this.y+=e,this.z+=i,this},i.subtract=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},i.subtract3f=function(t,e,i){return this.x-=t,this.y-=e,this.z-=i,this},i.multiplyScalar=function(t){return"object"==typeof t&&console.warn("should use Vec3.multiply for vector * vector operation"),this.x*=t,this.y*=t,this.z*=t,this},i.multiply=function(t){return"object"!=typeof t&&console.warn("should use Vec3.scale for vector * scalar operation"),this.x*=t.x,this.y*=t.y,this.z*=t.z,this},i.multiply3f=function(t,e,i){return this.x*=t,this.y*=e,this.z*=i,this},i.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},i.divide3f=function(t,e,i){return this.x/=t,this.y/=e,this.z/=i,this},i.negative=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},i.clampf=function(t,e){return this.x=xi(this.x,t.x,e.x),this.y=xi(this.y,t.y,e.y),this.z=xi(this.z,t.z,e.z),this},i.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},i.cross=function(t){var e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,o=t.z;return this.x=i*o-n*s,this.y=n*r-e*o,this.z=e*s-i*r,this},i.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},i.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z},i.normalize=function(){var t=this.x,e=this.y,i=this.z,n=t*t+e*e+i*i;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},i.transformMat4=function(t){var e=this.x,i=this.y,n=this.z,r=t.m03*e+t.m07*i+t.m11*n+t.m15;return r=r?1/r:1,this.x=(t.m00*e+t.m04*i+t.m08*n+t.m12)*r,this.y=(t.m01*e+t.m05*i+t.m09*n+t.m13)*r,this.z=(t.m02*e+t.m06*i+t.m10*n+t.m14)*r,this},e}(Ae));function an(t,e,i){return new on(t,e,i)}$i=on,on.UNIT_X=Object.freeze(new $i(1,0,0)),on.UNIT_Y=Object.freeze(new $i(0,1,0)),on.UNIT_Z=Object.freeze(new $i(0,0,1)),on.RIGHT=Object.freeze(new $i(1,0,0)),on.UP=Object.freeze(new $i(0,1,0)),on.FORWARD=Object.freeze(new $i(0,0,-1)),on.ZERO=Object.freeze(new $i(0,0,0)),on.ONE=Object.freeze(new $i(1,1,1)),on.NEG_ONE=Object.freeze(new $i(-1,-1,-1)),on.slerp=(nn=new $i,rn=new $i,sn=new $i,function(t,e,i,n){var r=1e-5,s=$i.len(e),o=$i.len(i);if(s<r||o<r)return $i.lerp(t,e,i,n);var a=Ii(s,o,n),h=$i.dot(e,i)/(s*o);if(h>.99999)return $i.lerp(t,e,i,n);if(h<-.99999){var u=$i.multiplyScalar(nn,e,1/s),l=$i.generateOrthogonal(rn,u),c=Math.PI*n;return ln(sn,u,l,c),$i.multiplyScalar(t,sn,a),t}var _=h,d=Math.acos(_)*n,f=$i.multiplyScalar(nn,e,1/s),p=$i.multiplyScalar(rn,i,1/o);return $i.scaleAndAdd(sn,p,f,-_),$i.normalize(sn,sn),$i.multiplyScalar(sn,sn,Math.sin(d)),$i.scaleAndAdd(sn,sn,f,Math.cos(d)),$i.multiplyScalar(t,sn,a),t}),pi.fastDefine("cc.Vec3",on,{x:0,y:0,z:0}),v.Vec3=on;var hn,un,ln=(hn={x:0,y:0,z:0,w:0},function(t,e,i,n){var r=.5*n,s=Math.sin(r);return hn.x=s*i.x,hn.y=s*i.y,hn.z=s*i.z,hn.w=Math.cos(r),on.transformQuat(t,e,hn),t});v.v3=an;var cn,_n=1/255,dn=t("a$",function(t){function e(e,i,n,r){var s;return(s=t.call(this)||this)._val=0,"string"==typeof e?s.fromHEX(e):void 0!==i?s.set(e,i,n,r):s.set(e),s}s(e,t),e.clone=function(t){var i=new e;return t._val?i._val=t._val:i._val=(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r,i},e.copy=function(t,e){return t.r=e.r,t.g=e.g,t.b=e.b,t.a=e.a,t},e.set=function(t,e,i,n,r){return t.r=e,t.g=i,t.b=n,t.a=r,t},e.toVec4=function(t,e){return(e=void 0!==e?e:new tn).x=t.r*_n,e.y=t.g*_n,e.z=t.b*_n,e.w=t.a*_n,e},e.fromVec4=function(t,i){return(i=void 0===i?new e:i).r=Math.floor(t.x/_n),i.g=Math.floor(t.y/_n),i.b=Math.floor(t.z/_n),i.a=Math.floor(t.w/_n),i},e.fromHEX=function(t,e){var i;return"string"==typeof e?(6===(e="#"===e[0]?e.substring(1):e).length?e+="FF":3===e.length?e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+"FF":4===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),i=Number("0x"+e)):(e<16777216&&(e=255+(e<<8)),i=e),t.r=i>>>24,t.g=(16711680&i)>>>16,t.b=(65280&i)>>>8,t.a=255&i,t._val=(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r,t},e.add=function(t,e,i){return t.r=e.r+i.r,t.g=e.g+i.g,t.b=e.b+i.b,t.a=e.a+i.a,t},e.subtract=function(t,e,i){return t.r=e.r-i.r,t.g=e.g-i.g,t.b=e.b-i.b,t.a=e.a-i.a,t},e.multiply=function(t,e,i){return t.r=e.r*i.r,t.g=e.g*i.g,t.b=e.b*i.b,t.a=e.a*i.a,t},e.divide=function(t,e,i){return t.r=e.r/i.r,t.g=e.g/i.g,t.b=e.b/i.b,t.a=e.a/i.a,t},e.scale=function(t,e,i){return t.r=e.r*i,t.g=e.g*i,t.b=e.b*i,t.a=e.a*i,t},e.lerp=function(t,e,i,n){var r=e.r,s=e.g,o=e.b,a=e.a;return r+=(i.r-r)*n,s+=(i.g-s)*n,o+=(i.b-o)*n,a+=(i.a-a)*n,t._val=Math.floor((a<<24>>>0)+(o<<16)+(s<<8)+r),t},e.toArray=function(t,i,n){void 0===n&&(n=0);var r=i instanceof e||i.a>1?1/255:1;return t[n+0]=i.r*r,t[n+1]=i.g*r,t[n+2]=i.b*r,t[n+3]=i.a*r,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),e.r=255*t[i+0],e.g=255*t[i+1],e.b=255*t[i+2],e.a=255*t[i+3],e},e.fromUint32=function(t,e){return t._val=e,t},e.toUint32=function(t){return t._val},e.strictEquals=function(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a},e.equals=function(t,e,i){return void 0===i&&(i=Ei),!(Math.abs(t.r)===1/0||Math.abs(t.g)===1/0||Math.abs(t.b)===1/0||Math.abs(t.a)===1/0)&&Math.abs(t.r-e.r)<=i*Math.max(1,Math.abs(t.r),Math.abs(e.r))&&Math.abs(t.g-e.g)<=i*Math.max(1,Math.abs(t.g),Math.abs(e.g))&&Math.abs(t.b-e.b)<=i*Math.max(1,Math.abs(t.b),Math.abs(e.b))&&Math.abs(t.a-e.a)<=i*Math.max(1,Math.abs(t.a),Math.abs(e.a))},e.hex=function(t){return(255*t.r<<24|255*t.g<<16|255*t.b<<8|255*t.a)>>>0};var i=e.prototype;return i.clone=function(){var t=new e;return t._val=this._val,t},i.equals=function(t){return t&&this._val===t._val},i.lerp=function(t,e){var i=this.r,n=this.g,r=this.b,s=this.a;return i+=(t.r-i)*e,n+=(t.g-n)*e,r+=(t.b-r)*e,s+=(t.a-s)*e,this._val=Math.floor((s<<24>>>0)+(r<<16)+(n<<8)+i),this},i.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},i.toCSS=function(t){return void 0===t&&(t="rgba"),"rgba"===t?"rgba("+this.r+","+this.g+","+this.b+","+(this.a*_n).toFixed(2)+")":"rgb"===t?"rgb("+this.r+","+this.g+","+this.b+")":"#"+this.toHEX(t)},i.fromHEX=function(t){t=0===t.indexOf("#")?t.substring(1):t;var e=parseInt(t.substr(0,2),16)||0,i=parseInt(t.substr(2,2),16)||0,n=parseInt(t.substr(4,2),16)||0,r=parseInt(t.substr(6,2),16);return r=Number.isNaN(r)?255:r,this._val=(r<<24>>>0)+(n<<16)+(i<<8)+(0|e),this},i.toHEX=function(t){void 0===t&&(t="#rrggbb");var e="0",i=[(this.r<16?e:"")+this.r.toString(16),(this.g<16?e:"")+this.g.toString(16),(this.b<16?e:"")+this.b.toString(16)];return"#rgb"===t?(i[0]=i[0][0],i[1]=i[1][0],i[2]=i[2][0]):"#rrggbbaa"===t&&i.push((this.a<16?e:"")+this.a.toString(16)),i.join("")},i.toRGBValue=function(){return 16777215&this._val},i.fromHSV=function(t,e,i){var n=0,r=0,s=0;if(0===e)n=r=s=i;else if(0===i)n=r=s=0;else{1===t&&(t=0),t*=6;var o=Math.floor(t),a=t-o,h=i*(1-e),u=i*(1-e*a),l=i*(1-e*(1-a));switch(o){default:case 0:n=i,r=l,s=h;break;case 1:n=u,r=i,s=h;break;case 2:n=h,r=i,s=l;break;case 3:n=h,r=u,s=i;break;case 4:n=l,r=h,s=i;break;case 5:n=i,r=h,s=u}}return n*=255,r*=255,s*=255,this._val=(this.a<<24>>>0)+(s<<16)+(r<<8)+(0|n),this},i.toHSV=function(){var t=this.r*_n,e=this.g*_n,i=this.b*_n,n={h:0,s:0,v:0},r=Math.max(t,e,i),s=Math.min(t,e,i),o=0;return n.v=r,n.s=r?(r-s)/r:0,n.s?(o=r-s,n.h=t===r?(e-i)/o:e===r?2+(i-t)/o:4+(t-e)/o,n.h/=6,n.h<0&&(n.h+=1)):n.h=0,n},i.set=function(t,e,i,n){return"object"==typeof t?null!=t._val?this._val=t._val:(e=t.g||0,i=t.b||0,n="number"==typeof t.a?t.a:255,t=t.r||0,this._val=(n<<24>>>0)+(i<<16)+(e<<8)+(0|t)):(t=t||0,e=e||0,i=i||0,n="number"==typeof n?n:255,this._val=(n<<24>>>0)+(i<<16)+(e<<8)+(0|t)),this},i.multiply=function(t){var e=(255&this._val)*t.r>>8,i=(65280&this._val)*t.g>>8,n=(16711680&this._val)*t.b>>8,r=((4278190080&this._val)>>>8)*t.a;return this._val=4278190080&r|16711680&n|65280&i|255&e,this},i._set_r_unsafe=function(t){return this._val=(4294967040&this._val|t)>>>0,this},i._set_g_unsafe=function(t){return this._val=(4294902015&this._val|t<<8)>>>0,this},i._set_b_unsafe=function(t){return this._val=(4278255615&this._val|t<<16)>>>0,this},i._set_a_unsafe=function(t){return this._val=(16777215&this._val|t<<24)>>>0,this},n(e,[{key:"r",get:function(){return 255&this._val},set:function(t){t=~~xi(t,0,255),this._val=(4294967040&this._val|t)>>>0}},{key:"g",get:function(){return(65280&this._val)>>8},set:function(t){t=~~xi(t,0,255),this._val=(4294902015&this._val|t<<8)>>>0}},{key:"b",get:function(){return(16711680&this._val)>>16},set:function(t){t=~~xi(t,0,255),this._val=(4278255615&this._val|t<<16)>>>0}},{key:"a",get:function(){return(4278190080&this._val)>>>24},set:function(t){t=~~xi(t,0,255),this._val=(16777215&this._val|t<<24)>>>0}},{key:"x",get:function(){return this.r*_n},set:function(t){this.r=255*t}},{key:"y",get:function(){return this.g*_n},set:function(t){this.g=255*t}},{key:"z",get:function(){return this.b*_n},set:function(t){this.b=255*t}},{key:"w",get:function(){return this.a*_n},set:function(t){this.a=255*t}}]),e}(Ae));function fn(t,e,i,n){return new dn(t,e,i,n)}function pn(t){var e=t.clone();return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e}un=dn,dn.WHITE=Object.freeze(new un(255,255,255,255)),dn.GRAY=Object.freeze(new un(127,127,127,255)),dn.BLACK=Object.freeze(new un(0,0,0,255)),dn.TRANSPARENT=Object.freeze(new un(0,0,0,0)),dn.RED=Object.freeze(new un(255,0,0,255)),dn.GREEN=Object.freeze(new un(0,255,0,255)),dn.BLUE=Object.freeze(new un(0,0,255,255)),dn.CYAN=Object.freeze(new un(0,255,255,255)),dn.MAGENTA=Object.freeze(new un(255,0,255,255)),dn.YELLOW=Object.freeze(new un(255,255,0,255)),pi.fastDefine("cc.Color",dn,{r:0,g:0,b:0,a:255}),v.Color=dn,v.color=fn;var mn=t("aT",function(t){function e(e,i,n,r,s,o,a,h,u){var l;return void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=1),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=1),l=t.call(this)||this,"object"==typeof e?(l.m00=e.m00,l.m01=e.m01,l.m02=e.m02,l.m03=e.m03,l.m04=e.m04,l.m05=e.m05,l.m06=e.m06,l.m07=e.m07,l.m08=e.m08):(l.m00=e,l.m01=i,l.m02=n,l.m03=r,l.m04=s,l.m05=o,l.m06=a,l.m07=h,l.m08=u),l}s(e,t),e.clone=function(t){return new e(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05,t.m06,t.m07,t.m08)},e.copy=function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m04=e.m04,t.m05=e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t},e.set=function(t,e,i,n,r,s,o,a,h,u){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t.m04=s,t.m05=o,t.m06=a,t.m07=h,t.m08=u,t},e.identity=function(t){return t.m00=1,t.m01=0,t.m02=0,t.m03=0,t.m04=1,t.m05=0,t.m06=0,t.m07=0,t.m08=1,t},e.transpose=function(t,e){if(t===e){var i=e.m01,n=e.m02,r=e.m05;t.m01=e.m03,t.m02=e.m06,t.m03=i,t.m05=e.m07,t.m06=n,t.m07=r}else t.m00=e.m00,t.m01=e.m03,t.m02=e.m06,t.m03=e.m01,t.m04=e.m04,t.m05=e.m07,t.m06=e.m02,t.m07=e.m05,t.m08=e.m08;return t},e.invert=function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=l*o-a*u,_=-l*s+a*h,d=u*s-o*h,f=i*c+n*_+r*d;return 0===f?(t.m00=0,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=0,t.m06=0,t.m07=0,t.m08=0,t):(f=1/f,t.m00=c*f,t.m01=(-l*n+r*u)*f,t.m02=(a*n-r*o)*f,t.m03=_*f,t.m04=(l*i-r*h)*f,t.m05=(-a*i+r*s)*f,t.m06=d*f,t.m07=(-u*i+n*h)*f,t.m08=(o*i-n*s)*f,t)},e.determinant=function(t){var e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,o=t.m05,a=t.m06,h=t.m07,u=t.m08;return e*(u*s-o*h)+i*(-u*r+o*a)+n*(h*r-s*a)},e.multiply=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=i.m00,d=i.m01,f=i.m02,p=i.m03,m=i.m04,g=i.m05,y=i.m06,v=i.m07,S=i.m08;return t.m00=_*n+d*o+f*u,t.m01=_*r+d*a+f*l,t.m02=_*s+d*h+f*c,t.m03=p*n+m*o+g*u,t.m04=p*r+m*a+g*l,t.m05=p*s+m*h+g*c,t.m06=y*n+v*o+S*u,t.m07=y*r+v*a+S*l,t.m08=y*s+v*h+S*c,t},e.multiplyMat4=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=i.m00,d=i.m01,f=i.m02,p=i.m04,m=i.m05,g=i.m06,y=i.m08,v=i.m09,S=i.m10;return t.m00=_*n+d*o+f*u,t.m01=_*r+d*a+f*l,t.m02=_*s+d*h+f*c,t.m03=p*n+m*o+g*u,t.m04=p*r+m*a+g*l,t.m05=p*s+m*h+g*c,t.m06=y*n+v*o+S*u,t.m07=y*r+v*a+S*l,t.m08=y*s+v*h+S*c,t},e.transform=function(t,e,i){this.translate(t,e,i)},e.translate=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=i.x,d=i.y;return t.m00=n,t.m01=r,t.m02=s,t.m03=o,t.m04=a,t.m05=h,t.m06=_*n+d*o+u,t.m07=_*r+d*a+l,t.m08=_*s+d*h+c,t},e.scale=function(t,e,i){var n=i.x,r=i.y;return t.m00=n*e.m00,t.m01=n*e.m01,t.m02=n*e.m02,t.m03=r*e.m03,t.m04=r*e.m04,t.m05=r*e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t},e.rotate=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=Math.sin(i),d=Math.cos(i);return t.m00=d*n+_*o,t.m01=d*r+_*a,t.m02=d*s+_*h,t.m03=d*o-_*n,t.m04=d*a-_*r,t.m05=d*h-_*s,t.m06=u,t.m07=l,t.m08=c,t},e.fromMat4=function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m04,t.m04=e.m05,t.m05=e.m06,t.m06=e.m08,t.m07=e.m09,t.m08=e.m10,t},e.fromViewUp=function(t,i,n){return on.lengthSqr(i)<Ei*Ei?(e.identity(t),t):(n=n||on.UNIT_Y,on.normalize(yn,on.cross(yn,n,i)),on.lengthSqr(yn)<Ei*Ei?(e.identity(t),t):(on.cross(vn,i,yn),e.set(t,yn.x,yn.y,yn.z,vn.x,vn.y,vn.z,i.x,i.y,i.z),t))},e.fromTranslation=function(t,e){return t.m00=1,t.m01=0,t.m02=0,t.m03=0,t.m04=1,t.m05=0,t.m06=e.x,t.m07=e.y,t.m08=1,t},e.fromScaling=function(t,e){return t.m00=e.x,t.m01=0,t.m02=0,t.m03=0,t.m04=e.y,t.m05=0,t.m06=0,t.m07=0,t.m08=1,t},e.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t.m00=n,t.m01=i,t.m02=0,t.m03=-i,t.m04=n,t.m05=0,t.m06=0,t.m07=0,t.m08=1,t},e.fromQuat=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w,o=i+i,a=n+n,h=r+r,u=i*o,l=n*o,c=n*a,_=r*o,d=r*a,f=r*h,p=s*o,m=s*a,g=s*h;return t.m00=1-c-f,t.m03=l-g,t.m06=_+m,t.m01=l+g,t.m04=1-u-f,t.m07=d-p,t.m02=_-m,t.m05=d+p,t.m08=1-u-c,t},e.inverseTransposeMat4=function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=e.m09,_=e.m10,d=e.m11,f=e.m12,p=e.m13,m=e.m14,g=e.m15,y=i*a-n*o,v=i*h-r*o,S=i*u-s*o,T=n*h-r*a,A=n*u-s*a,b=r*u-s*h,E=l*p-c*f,C=l*m-_*f,w=l*g-d*f,x=c*m-_*p,R=c*g-d*p,I=_*g-d*m,B=y*I-v*R+S*x+T*w-A*C+b*E;return B?(B=1/B,t.m00=(a*I-h*R+u*x)*B,t.m01=(h*w-o*I-u*C)*B,t.m02=(o*R-a*w+u*E)*B,t.m03=(r*R-n*I-s*x)*B,t.m04=(i*I-r*w+s*C)*B,t.m05=(n*w-i*R-s*E)*B,t.m06=(p*b-m*A+g*T)*B,t.m07=(m*S-f*b-g*v)*B,t.m08=(f*A-p*S+g*y)*B,t):null},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.m00,t[i+1]=e.m01,t[i+2]=e.m02,t[i+3]=e.m03,t[i+4]=e.m04,t[i+5]=e.m05,t[i+6]=e.m06,t[i+7]=e.m07,t[i+8]=e.m08,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.m00=e[i+0],t.m01=e[i+1],t.m02=e[i+2],t.m03=e[i+3],t.m04=e[i+4],t.m05=e[i+5],t.m06=e[i+6],t.m07=e[i+7],t.m08=e[i+8],t},e.add=function(t,e,i){return t.m00=e.m00+i.m00,t.m01=e.m01+i.m01,t.m02=e.m02+i.m02,t.m03=e.m03+i.m03,t.m04=e.m04+i.m04,t.m05=e.m05+i.m05,t.m06=e.m06+i.m06,t.m07=e.m07+i.m07,t.m08=e.m08+i.m08,t},e.subtract=function(t,e,i){return t.m00=e.m00-i.m00,t.m01=e.m01-i.m01,t.m02=e.m02-i.m02,t.m03=e.m03-i.m03,t.m04=e.m04-i.m04,t.m05=e.m05-i.m05,t.m06=e.m06-i.m06,t.m07=e.m07-i.m07,t.m08=e.m08-i.m08,t},e.multiplyScalar=function(t,e,i){return t.m00=e.m00*i,t.m01=e.m01*i,t.m02=e.m02*i,t.m03=e.m03*i,t.m04=e.m04*i,t.m05=e.m05*i,t.m06=e.m06*i,t.m07=e.m07*i,t.m08=e.m08*i,t},e.multiplyScalarAndAdd=function(t,e,i,n){return t.m00=i.m00*n+e.m00,t.m01=i.m01*n+e.m01,t.m02=i.m02*n+e.m02,t.m03=i.m03*n+e.m03,t.m04=i.m04*n+e.m04,t.m05=i.m05*n+e.m05,t.m06=i.m06*n+e.m06,t.m07=i.m07*n+e.m07,t.m08=i.m08*n+e.m08,t},e.strictEquals=function(t,e){return t.m00===e.m00&&t.m01===e.m01&&t.m02===e.m02&&t.m03===e.m03&&t.m04===e.m04&&t.m05===e.m05&&t.m06===e.m06&&t.m07===e.m07&&t.m08===e.m08},e.equals=function(t,e,i){return void 0===i&&(i=Ei),Math.abs(t.m00-e.m00)<=i*Math.max(1,Math.abs(t.m00),Math.abs(e.m00))&&Math.abs(t.m01-e.m01)<=i*Math.max(1,Math.abs(t.m01),Math.abs(e.m01))&&Math.abs(t.m02-e.m02)<=i*Math.max(1,Math.abs(t.m02),Math.abs(e.m02))&&Math.abs(t.m03-e.m03)<=i*Math.max(1,Math.abs(t.m03),Math.abs(e.m03))&&Math.abs(t.m04-e.m04)<=i*Math.max(1,Math.abs(t.m04),Math.abs(e.m04))&&Math.abs(t.m05-e.m05)<=i*Math.max(1,Math.abs(t.m05),Math.abs(e.m05))&&Math.abs(t.m06-e.m06)<=i*Math.max(1,Math.abs(t.m06),Math.abs(e.m06))&&Math.abs(t.m07-e.m07)<=i*Math.max(1,Math.abs(t.m07),Math.abs(e.m07))&&Math.abs(t.m08-e.m08)<=i*Math.max(1,Math.abs(t.m08),Math.abs(e.m08))},e.toEuler=function(t,e){var i=t.m00,n=t.m01;t.m02;var r=t.m03,s=t.m04;t.m05;var o=t.m06,a=t.m07,h=t.m08;return a<.999?a>-.999?(e.x=Math.asin(-a),e.y=Math.atan2(o,h),e.z=Math.atan2(n,s),!0):(e.x=Ai,e.y=Math.atan2(r,i),e.z=0,!1):(e.x=-Ai,e.y=Math.atan2(-r,i),e.z=0,!1)};var i=e.prototype;return i.clone=function(){var t=this;return new e(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05,t.m06,t.m07,t.m08)},i.set=function(t,e,i,n,r,s,o,a,h){return void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=1),"object"==typeof t?(this.m00=t.m00,this.m01=t.m01,this.m02=t.m02,this.m03=t.m03,this.m04=t.m04,this.m05=t.m05,this.m06=t.m06,this.m07=t.m07,this.m08=t.m08):(this.m00=t,this.m01=e,this.m02=i,this.m03=n,this.m04=r,this.m05=s,this.m06=o,this.m07=a,this.m08=h),this},i.equals=function(t,e){return void 0===e&&(e=Ei),Math.abs(this.m00-t.m00)<=e*Math.max(1,Math.abs(this.m00),Math.abs(t.m00))&&Math.abs(this.m01-t.m01)<=e*Math.max(1,Math.abs(this.m01),Math.abs(t.m01))&&Math.abs(this.m02-t.m02)<=e*Math.max(1,Math.abs(this.m02),Math.abs(t.m02))&&Math.abs(this.m03-t.m03)<=e*Math.max(1,Math.abs(this.m03),Math.abs(t.m03))&&Math.abs(this.m04-t.m04)<=e*Math.max(1,Math.abs(this.m04),Math.abs(t.m04))&&Math.abs(this.m05-t.m05)<=e*Math.max(1,Math.abs(this.m05),Math.abs(t.m05))&&Math.abs(this.m06-t.m06)<=e*Math.max(1,Math.abs(this.m06),Math.abs(t.m06))&&Math.abs(this.m07-t.m07)<=e*Math.max(1,Math.abs(this.m07),Math.abs(t.m07))&&Math.abs(this.m08-t.m08)<=e*Math.max(1,Math.abs(this.m08),Math.abs(t.m08))},i.strictEquals=function(t){return this.m00===t.m00&&this.m01===t.m01&&this.m02===t.m02&&this.m03===t.m03&&this.m04===t.m04&&this.m05===t.m05&&this.m06===t.m06&&this.m07===t.m07&&this.m08===t.m08},i.toString=function(){var t=this;return"[\n"+t.m00+", "+t.m01+", "+t.m02+",\n"+t.m03+",\n"+t.m04+", "+t.m05+",\n"+t.m06+", "+t.m07+",\n"+t.m08+"\n]"},i.identity=function(){return this.m00=1,this.m01=0,this.m02=0,this.m03=0,this.m04=1,this.m05=0,this.m06=0,this.m07=0,this.m08=1,this},i.transpose=function(){var t=this.m01,e=this.m02,i=this.m05;return this.m01=this.m03,this.m02=this.m06,this.m03=t,this.m05=this.m07,this.m06=e,this.m07=i,this},i.invert=function(){var t=this.m00,e=this.m01,i=this.m02,n=this.m03,r=this.m04,s=this.m05,o=this.m06,a=this.m07,h=this.m08,u=h*r-s*a,l=-h*n+s*o,c=a*n-r*o,_=t*u+e*l+i*c;return 0===_?(this.set(0,0,0,0,0,0,0,0,0),this):(_=1/_,this.m00=u*_,this.m01=(-h*e+i*a)*_,this.m02=(s*e-i*r)*_,this.m03=l*_,this.m04=(h*t-i*o)*_,this.m05=(-s*t+i*n)*_,this.m06=c*_,this.m07=(-a*t+e*o)*_,this.m08=(r*t-e*n)*_,this)},i.determinant=function(){var t=this.m00,e=this.m01,i=this.m02,n=this.m03,r=this.m04,s=this.m05,o=this.m06,a=this.m07,h=this.m08;return t*(h*r-s*a)+e*(-h*n+s*o)+i*(a*n-r*o)},i.add=function(t){return this.m00+=t.m00,this.m01+=t.m01,this.m02+=t.m02,this.m03+=t.m03,this.m04+=t.m04,this.m05+=t.m05,this.m06+=t.m06,this.m07+=t.m07,this.m08+=t.m08,this},i.subtract=function(t){return this.m00-=t.m00,this.m01-=t.m01,this.m02-=t.m02,this.m03-=t.m03,this.m04-=t.m04,this.m05-=t.m05,this.m06-=t.m06,this.m07-=t.m07,this.m08-=t.m08,this},i.multiply=function(t){var e=this.m00,i=this.m01,n=this.m02,r=this.m03,s=this.m04,o=this.m05,a=this.m06,h=this.m07,u=this.m08,l=t.m00,c=t.m01,_=t.m02,d=t.m03,f=t.m04,p=t.m05,m=t.m06,g=t.m07,y=t.m08;return this.m00=l*e+c*r+_*a,this.m01=l*i+c*s+_*h,this.m02=l*n+c*o+_*u,this.m03=d*e+f*r+p*a,this.m04=d*i+f*s+p*h,this.m05=d*n+f*o+p*u,this.m06=m*e+g*r+y*a,this.m07=m*i+g*s+y*h,this.m08=m*n+g*o+y*u,this},i.multiplyScalar=function(t){return this.m00*=t,this.m01*=t,this.m02*=t,this.m03*=t,this.m04*=t,this.m05*=t,this.m06*=t,this.m07*=t,this.m08*=t,this},i.scale=function(t){var e=t.x,i=t.y;return this.m00=e*this.m00,this.m01=e*this.m01,this.m02=e*this.m02,this.m03=i*this.m03,this.m04=i*this.m04,this.m05=i*this.m05,this.m06=this.m06,this.m07=this.m07,this.m08=this.m08,this},i.rotate=function(t){var e=this.m00,i=this.m01,n=this.m02,r=this.m03,s=this.m04,o=this.m05,a=this.m06,h=this.m07,u=this.m08,l=Math.sin(t),c=Math.cos(t);return this.m00=c*e+l*r,this.m01=c*i+l*s,this.m02=c*n+l*o,this.m03=c*r-l*e,this.m04=c*s-l*i,this.m05=c*o-l*n,this.m06=a,this.m07=h,this.m08=u,this},i.fromQuat=function(t){var e=t.x,i=t.y,n=t.z,r=t.w,s=e+e,o=i+i,a=n+n,h=e*s,u=i*s,l=i*o,c=n*s,_=n*o,d=n*a,f=r*s,p=r*o,m=r*a;return this.m00=1-l-d,this.m03=u-m,this.m06=c+p,this.m01=u+m,this.m04=1-h-d,this.m07=_-f,this.m02=c-p,this.m05=_+f,this.m08=1-h-l,this},e}(Ae));cn=mn,mn.IDENTITY=Object.freeze(new cn);var gn,yn=new on,vn=new on;pi.fastDefine("cc.Mat3",mn,{m00:1,m01:0,m02:0,m03:0,m04:1,m05:0,m06:0,m07:0,m08:1}),v.Mat3=mn;var Sn=t("aR",function(t){function e(e,i,n,r){var s;return s=t.call(this)||this,"object"==typeof e?(s.x=e.x,s.y=e.y,s.z=e.z,s.w=e.w):(s.x=e||0,s.y=i||0,s.z=n||0,s.w=null!=r?r:1),s}s(e,t),e.clone=function(t){return new e(t.x,t.y,t.z,t.w)},e.copy=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t},e.set=function(t,e,i,n,r){return t.x=e,t.y=i,t.z=n,t.w=r,t},e.identity=function(t){return t.x=0,t.y=0,t.z=0,t.w=1,t},e.rotationTo=function(t,i,n){var r=on.dot(i,n);return r<-.999999?(on.cross(En,on.UNIT_X,i),En.length()<1e-6&&on.cross(En,on.UNIT_Y,i),on.normalize(En,En),e.fromAxisAngle(t,En,Math.PI),t):r>.999999?(t.x=0,t.y=0,t.z=0,t.w=1,t):(on.cross(En,i,n),t.x=En.x,t.y=En.y,t.z=En.z,t.w=1+r,e.normalize(t,t))},e.getAxisAngle=function(t,e){var i=2*Math.acos(e.w),n=Math.sin(i/2);return 0!==n?(t.x=e.x/n,t.y=e.y/n,t.z=e.z/n):(t.x=1,t.y=0,t.z=0),i},e.multiply=function(t,e,i){var n=e.x*i.w+e.w*i.x+e.y*i.z-e.z*i.y,r=e.y*i.w+e.w*i.y+e.z*i.x-e.x*i.z,s=e.z*i.w+e.w*i.z+e.x*i.y-e.y*i.x,o=e.w*i.w-e.x*i.x-e.y*i.y-e.z*i.z;return t.x=n,t.y=r,t.z=s,t.w=o,t},e.multiplyScalar=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i,t},e.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t.z=e.z+i.z*n,t.w=e.w+i.w*n,t},e.rotateX=function(t,e,i){i*=.5;var n=Math.sin(i),r=Math.cos(i),s=e.x,o=e.y,a=e.z,h=e.w;return t.x=s*r+h*n,t.y=o*r+a*n,t.z=a*r-o*n,t.w=h*r-s*n,t},e.rotateY=function(t,e,i){i*=.5;var n=Math.sin(i),r=Math.cos(i),s=e.x,o=e.y,a=e.z,h=e.w;return t.x=s*r-a*n,t.y=o*r+h*n,t.z=a*r+s*n,t.w=h*r-o*n,t},e.rotateZ=function(t,e,i){i*=.5;var n=Math.sin(i),r=Math.cos(i),s=e.x,o=e.y,a=e.z,h=e.w;return t.x=s*r+o*n,t.y=o*r-s*n,t.z=a*r+h*n,t.w=h*r-a*n,t},e.rotateAround=function(t,i,n,r){return e.invert(An,i),on.transformQuat(En,n,An),e.fromAxisAngle(An,En,r),e.multiply(t,i,An),t},e.rotateAroundLocal=function(t,i,n,r){return e.fromAxisAngle(An,n,r),e.multiply(t,i,An),t},e.calculateW=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=Math.sqrt(Math.abs(1-e.x*e.x-e.y*e.y-e.z*e.z)),t},e.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},e.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t.w=e.w+n*(i.w-e.w),t},e.slerp=function(t,e,i,n){var r=0,s=0,o=i.x,a=i.y,h=i.z,u=i.w,l=e.x*i.x+e.y*i.y+e.z*i.z+e.w*i.w;if(l<0&&(l=-l,o=-o,a=-a,h=-h,u=-u),1-l>1e-6){var c=Math.acos(l),_=Math.sin(c);r=Math.sin((1-n)*c)/_,s=Math.sin(n*c)/_}else r=1-n,s=n;return t.x=r*e.x+s*o,t.y=r*e.y+s*a,t.z=r*e.z+s*h,t.w=r*e.w+s*u,t},e.sqlerp=function(t,i,n,r,s,o){return e.slerp(An,i,s,o),e.slerp(bn,n,r,o),e.slerp(t,An,bn,2*o*(1-o)),t},e.invert=function(t,e){var i=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w,n=i?1/i:0;return t.x=-e.x*n,t.y=-e.y*n,t.z=-e.z*n,t.w=e.w*n,t},e.conjugate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w,t},e.len=function(t){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w)},e.lengthSqr=function(t){return t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},e.normalize=function(t,e){var i=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w;return i>0?(i=1/Math.sqrt(i),t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i):(t.x=0,t.y=0,t.z=0,t.w=0),t},e.fromAxes=function(t,i,n,r){return mn.set(Cn,i.x,i.y,i.z,n.x,n.y,n.z,r.x,r.y,r.z),e.normalize(t,e.fromMat3(t,Cn))},e.fromViewUp=function(t,i,n){return mn.fromViewUp(Cn,i,n),e.normalize(t,e.fromMat3(t,Cn))},e.fromAxisAngle=function(t,e,i){i*=.5;var n=Math.sin(i);return t.x=n*e.x,t.y=n*e.y,t.z=n*e.z,t.w=Math.cos(i),t},e.fromMat3=function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=i-o-l,_=o-i-l,d=l-i-o,f=0,p=i+o+l;c>p&&(p=c,f=1),_>p&&(p=_,f=2),d>p&&(p=d,f=3);var m=.5*Math.sqrt(p+1),g=.25/m;switch(f){case 0:t.w=m,t.x=(a-u)*g,t.y=(h-r)*g,t.z=(n-s)*g;break;case 1:t.w=(a-u)*g,t.x=m,t.y=(n+s)*g,t.z=(h+r)*g;break;case 2:t.w=(h-r)*g,t.x=(n+s)*g,t.y=m,t.z=(a+u)*g;break;case 3:t.w=(n-s)*g,t.x=(h+r)*g,t.y=(a+u)*g,t.z=m;break;default:t.w=1,t.x=0,t.y=0,t.z=0}return t},e.fromEuler=function(t,e,i,n){e*=wn,i*=wn,n*=wn;var r=Math.sin(e),s=Math.cos(e),o=Math.sin(i),a=Math.cos(i),h=Math.sin(n),u=Math.cos(n);return t.x=r*a*u+s*o*h,t.y=s*o*u+r*a*h,t.z=s*a*h-r*o*u,t.w=s*a*u-r*o*h,t},e.fromAngleZ=function(t,e){return e*=wn,t.x=t.y=0,t.z=Math.sin(e),t.w=Math.cos(e),t},e.toAxisX=function(t,e){var i=2*e.y,n=2*e.z;return t.x=1-i*e.y-n*e.z,t.y=i*e.x+n*e.w,t.z=n*e.x-i*e.w,t},e.toAxisY=function(t,e){var i=2*e.x,n=2*e.y,r=2*e.z;return t.x=n*e.x-r*e.w,t.y=1-i*e.x-r*e.z,t.z=r*e.y+i*e.w,t},e.toAxisZ=function(t,e){var i=2*e.x,n=2*e.y,r=2*e.z;return t.x=r*e.x+n*e.w,t.y=r*e.y-i*e.w,t.z=1-i*e.x-n*e.y,t},e.toEuler=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=e.w,a=0,h=0,u=0,l=n*r+s*o;if(l>.499999)a=0,h=Di(2*Math.atan2(n,o)),u=90;else if(l<-.499999)a=0,h=-Di(2*Math.atan2(n,o)),u=-90;else{var c=n*n,_=r*r,d=s*s;a=Di(Math.atan2(2*n*o-2*r*s,1-2*c-2*d)),h=Di(Math.atan2(2*r*o-2*n*s,1-2*_-2*d)),u=Di(Math.asin(2*l)),i&&(a=-180*Math.sign(a+1e-6)+a,h=-180*Math.sign(h+1e-6)+h,u=180*Math.sign(u+1e-6)-u)}return t.x=a,t.y=h,t.z=u,t},e.toEulerInYXZOrder=function(t,e){mn.fromQuat(Cn,e),mn.toEuler(Cn,t),t.x=Di(t.x),t.y=Di(t.y),t.z=Di(t.z)},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t[i+3]=e.w,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t.w=e[i+3],t},e.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},e.equals=function(t,e,i){return void 0===i&&(i=Ei),Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(e.y))&&Math.abs(t.z-e.z)<=i*Math.max(1,Math.abs(t.z),Math.abs(e.z))&&Math.abs(t.w-e.w)<=i*Math.max(1,Math.abs(t.w),Math.abs(e.w))},e.angle=function(t,i){var n=Math.min(Math.abs(e.dot(t,i)),1);return 2*Math.acos(n)},e.rotateTowards=function(t,i,n,r){var s=e.angle(i,n);if(0===s)return t.x=n.x,t.y=n.y,t.z=n.z,t.w=n.w,t;var o=Math.min(r/Di(s),1);return e.slerp(t,i,n,o)};var i=e.prototype;return i.clone=function(){return new e(this.x,this.y,this.z,this.w)},i.set=function(t,e,i,n){return"object"==typeof t?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=null!=n?n:1),this},i.equals=function(t,e){return void 0===e&&(e=Ei),Math.abs(this.x-t.x)<=e*Math.max(1,Math.abs(this.x),Math.abs(t.x))&&Math.abs(this.y-t.y)<=e*Math.max(1,Math.abs(this.y),Math.abs(t.y))&&Math.abs(this.z-t.z)<=e*Math.max(1,Math.abs(this.z),Math.abs(t.z))&&Math.abs(this.w-t.w)<=e*Math.max(1,Math.abs(this.w),Math.abs(t.w))},i.strictEquals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},i.getEulerAngles=function(t){return e.toEuler(t,this)},i.lerp=function(t,e){return this.x+=e*(t.x-this.x),this.y+=e*(t.y-this.y),this.z+=e*(t.z-this.z),this.w+=e*(t.w-this.w),this},i.slerp=function(t,i){return e.slerp(this,this,t,i)},i.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},i.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e}(Ae));gn=Sn,Sn.IDENTITY=Object.freeze(new gn);var Tn,An=new Sn,bn=new Sn,En=new on,Cn=new mn,wn=.5*Math.PI/180;function xn(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),new Sn(t,e,i,n)}pi.fastDefine("cc.Quat",Sn,{x:0,y:0,z:0,w:1}),v.Quat=Sn,v.quat=xn;var Rn=t("b1",Object.freeze([Object.freeze([1,0,0,1]),Object.freeze([0,1,-1,0]),Object.freeze([-1,0,0,-1]),Object.freeze([0,-1,1,0])])),In=t("aU",function(t){function e(e,i,n,r,s,o,a,h,u,l,c,_,d,f,p,m){var g;return void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=1),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=0),void 0===l&&(l=0),void 0===c&&(c=1),void 0===_&&(_=0),void 0===d&&(d=0),void 0===f&&(f=0),void 0===p&&(p=0),void 0===m&&(m=1),g=t.call(this)||this,"object"==typeof e?(g.m00=e.m00,g.m01=e.m01,g.m02=e.m02,g.m03=e.m03,g.m04=e.m04,g.m05=e.m05,g.m06=e.m06,g.m07=e.m07,g.m08=e.m08,g.m09=e.m09,g.m10=e.m10,g.m11=e.m11,g.m12=e.m12,g.m13=e.m13,g.m14=e.m14,g.m15=e.m15):(g.m00=e,g.m01=i,g.m02=n,g.m03=r,g.m04=s,g.m05=o,g.m06=a,g.m07=h,g.m08=u,g.m09=l,g.m10=c,g.m11=_,g.m12=d,g.m13=f,g.m14=p,g.m15=m),g}s(e,t),e.clone=function(t){return new e(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05,t.m06,t.m07,t.m08,t.m09,t.m10,t.m11,t.m12,t.m13,t.m14,t.m15)},e.copy=function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m04=e.m04,t.m05=e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t.m09=e.m09,t.m10=e.m10,t.m11=e.m11,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15,t},e.set=function(t,e,i,n,r,s,o,a,h,u,l,c,_,d,f,p,m){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t.m04=s,t.m05=o,t.m06=a,t.m07=h,t.m08=u,t.m09=l,t.m10=c,t.m11=_,t.m12=d,t.m13=f,t.m14=p,t.m15=m,t},e.identity=function(t){return t.m00=1,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=1,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=1,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.transpose=function(t,e){if(t===e){var i=e.m01,n=e.m02,r=e.m03,s=e.m06,o=e.m07,a=e.m11;t.m01=e.m04,t.m02=e.m08,t.m03=e.m12,t.m04=i,t.m06=e.m09,t.m07=e.m13,t.m08=n,t.m09=s,t.m11=e.m14,t.m12=r,t.m13=o,t.m14=a}else t.m00=e.m00,t.m01=e.m04,t.m02=e.m08,t.m03=e.m12,t.m04=e.m01,t.m05=e.m05,t.m06=e.m09,t.m07=e.m13,t.m08=e.m02,t.m09=e.m06,t.m10=e.m10,t.m11=e.m14,t.m12=e.m03,t.m13=e.m07,t.m14=e.m11,t.m15=e.m15;return t},e.invert=function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=e.m09,_=e.m10,d=e.m11,f=e.m12,p=e.m13,m=e.m14,g=e.m15,y=i*a-n*o,v=i*h-r*o,S=i*u-s*o,T=n*h-r*a,A=n*u-s*a,b=r*u-s*h,E=l*p-c*f,C=l*m-_*f,w=l*g-d*f,x=c*m-_*p,R=c*g-d*p,I=_*g-d*m,B=y*I-v*R+S*x+T*w-A*C+b*E;return 0===B?(t.m00=0,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=0,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=0,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=0,t):(B=1/B,t.m00=(a*I-h*R+u*x)*B,t.m01=(r*R-n*I-s*x)*B,t.m02=(p*b-m*A+g*T)*B,t.m03=(_*A-c*b-d*T)*B,t.m04=(h*w-o*I-u*C)*B,t.m05=(i*I-r*w+s*C)*B,t.m06=(m*S-f*b-g*v)*B,t.m07=(l*b-_*S+d*v)*B,t.m08=(o*R-a*w+u*E)*B,t.m09=(n*w-i*R-s*E)*B,t.m10=(f*A-p*S+g*y)*B,t.m11=(c*S-l*A-d*y)*B,t.m12=(a*C-o*x-h*E)*B,t.m13=(i*x-n*C+r*E)*B,t.m14=(p*v-f*T-m*y)*B,t.m15=(l*T-c*v+_*y)*B,t)},e.determinant=function(t){var e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,o=t.m05,a=t.m06,h=t.m07,u=t.m08,l=t.m09,c=t.m10,_=t.m11,d=t.m12,f=t.m13,p=t.m14,m=t.m15;return(e*o-i*s)*(c*m-_*p)-(e*a-n*s)*(l*m-_*f)+(e*h-r*s)*(l*p-c*f)+(i*a-n*o)*(u*m-_*d)-(i*h-r*o)*(u*p-c*d)+(n*h-r*a)*(u*f-l*d)},e.multiply=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=e.m09,d=e.m10,f=e.m11,p=e.m12,m=e.m13,g=e.m14,y=e.m15,v=i.m00,S=i.m01,T=i.m02,A=i.m03;return t.m00=v*n+S*a+T*c+A*p,t.m01=v*r+S*h+T*_+A*m,t.m02=v*s+S*u+T*d+A*g,t.m03=v*o+S*l+T*f+A*y,v=i.m04,S=i.m05,T=i.m06,A=i.m07,t.m04=v*n+S*a+T*c+A*p,t.m05=v*r+S*h+T*_+A*m,t.m06=v*s+S*u+T*d+A*g,t.m07=v*o+S*l+T*f+A*y,v=i.m08,S=i.m09,T=i.m10,A=i.m11,t.m08=v*n+S*a+T*c+A*p,t.m09=v*r+S*h+T*_+A*m,t.m10=v*s+S*u+T*d+A*g,t.m11=v*o+S*l+T*f+A*y,v=i.m12,S=i.m13,T=i.m14,A=i.m15,t.m12=v*n+S*a+T*c+A*p,t.m13=v*r+S*h+T*_+A*m,t.m14=v*s+S*u+T*d+A*g,t.m15=v*o+S*l+T*f+A*y,t},e.transform=function(t,e,i){var n=i.x,r=i.y,s=i.z;if(e===t)t.m12=e.m00*n+e.m04*r+e.m08*s+e.m12,t.m13=e.m01*n+e.m05*r+e.m09*s+e.m13,t.m14=e.m02*n+e.m06*r+e.m10*s+e.m14,t.m15=e.m03*n+e.m07*r+e.m11*s+e.m15;else{var o=e.m00,a=e.m01,h=e.m02,u=e.m03,l=e.m04,c=e.m05,_=e.m06,d=e.m07,f=e.m08,p=e.m09,m=e.m10,g=e.m11;t.m00=o,t.m01=a,t.m02=h,t.m03=u,t.m04=l,t.m05=c,t.m06=_,t.m07=d,t.m08=f,t.m09=p,t.m10=m,t.m11=g,t.m12=o*n+l*r+f*s+e.m12,t.m13=a*n+c*r+p*s+e.m13,t.m14=h*n+_*r+m*s+e.m14,t.m15=u*n+d*r+g*s+e.m15}return t},e.translate=function(t,e,i){return e===t?(t.m12+=i.x,t.m13+=i.y,t.m14+=i.z):(t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m04=e.m04,t.m05=e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t.m09=e.m09,t.m10=e.m10,t.m11=e.m11,t.m12=e.m12+i.x,t.m13=e.m13+i.y,t.m14=e.m14+i.z,t.m15=e.m15),t},e.scale=function(t,e,i){var n=i.x,r=i.y,s=i.z;return t.m00=e.m00*n,t.m01=e.m01*n,t.m02=e.m02*n,t.m03=e.m03*n,t.m04=e.m04*r,t.m05=e.m05*r,t.m06=e.m06*r,t.m07=e.m07*r,t.m08=e.m08*s,t.m09=e.m09*s,t.m10=e.m10*s,t.m11=e.m11*s,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15,t},e.rotate=function(t,e,i,n){var r=n.x,s=n.y,o=n.z,a=Math.sqrt(r*r+s*s+o*o);if(Math.abs(a)<Ei)return null;r*=a=1/a,s*=a,o*=a;var h=Math.sin(i),u=Math.cos(i),l=1-u,c=e.m00,_=e.m01,d=e.m02,f=e.m03,p=e.m04,m=e.m05,g=e.m06,y=e.m07,v=e.m08,S=e.m09,T=e.m10,A=e.m11,b=r*r*l+u,E=s*r*l+o*h,C=o*r*l-s*h,w=r*s*l-o*h,x=s*s*l+u,R=o*s*l+r*h,I=r*o*l+s*h,B=s*o*l-r*h,D=o*o*l+u;return t.m00=c*b+p*E+v*C,t.m01=_*b+m*E+S*C,t.m02=d*b+g*E+T*C,t.m03=f*b+y*E+A*C,t.m04=c*w+p*x+v*R,t.m05=_*w+m*x+S*R,t.m06=d*w+g*x+T*R,t.m07=f*w+y*x+A*R,t.m08=c*I+p*B+v*D,t.m09=_*I+m*B+S*D,t.m10=d*I+g*B+T*D,t.m11=f*I+y*B+A*D,e!==t&&(t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15),t},e.rotateX=function(t,e,i){var n=Math.sin(i),r=Math.cos(i),s=e.m04,o=e.m05,a=e.m06,h=e.m07,u=e.m08,l=e.m09,c=e.m10,_=e.m11;return e!==t&&(t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15),t.m04=s*r+u*n,t.m05=o*r+l*n,t.m06=a*r+c*n,t.m07=h*r+_*n,t.m08=u*r-s*n,t.m09=l*r-o*n,t.m10=c*r-a*n,t.m11=_*r-h*n,t},e.rotateY=function(t,e,i){var n=Math.sin(i),r=Math.cos(i),s=e.m00,o=e.m01,a=e.m02,h=e.m03,u=e.m08,l=e.m09,c=e.m10,_=e.m11;return e!==t&&(t.m04=e.m04,t.m05=e.m05,t.m06=e.m06,t.m07=e.m07,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15),t.m00=s*r-u*n,t.m01=o*r-l*n,t.m02=a*r-c*n,t.m03=h*r-_*n,t.m08=s*n+u*r,t.m09=o*n+l*r,t.m10=a*n+c*r,t.m11=h*n+_*r,t},e.rotateZ=function(t,e,i){var n=Math.sin(i),r=Math.cos(i),s=e.m00,o=e.m01,a=e.m02,h=e.m03,u=e.m04,l=e.m05,c=e.m06,_=e.m07;return e!==t&&(t.m08=e.m08,t.m09=e.m09,t.m10=e.m10,t.m11=e.m11,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15),t.m00=s*r+u*n,t.m01=o*r+l*n,t.m02=a*r+c*n,t.m03=h*r+_*n,t.m04=u*r-s*n,t.m05=l*r-o*n,t.m06=c*r-a*n,t.m07=_*r-h*n,t},e.fromTranslation=function(t,e){return t.m00=1,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=1,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=1,t.m11=0,t.m12=e.x,t.m13=e.y,t.m14=e.z,t.m15=1,t},e.fromScaling=function(t,e){return t.m00=e.x,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=e.y,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=e.z,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.fromRotation=function(t,e,i){var n=i.x,r=i.y,s=i.z,o=Math.sqrt(n*n+r*r+s*s);if(Math.abs(o)<Ei)return null;n*=o=1/o,r*=o,s*=o;var a=Math.sin(e),h=Math.cos(e),u=1-h;return t.m00=n*n*u+h,t.m01=r*n*u+s*a,t.m02=s*n*u-r*a,t.m03=0,t.m04=n*r*u-s*a,t.m05=r*r*u+h,t.m06=s*r*u+n*a,t.m07=0,t.m08=n*s*u+r*a,t.m09=r*s*u-n*a,t.m10=s*s*u+h,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.fromXRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t.m00=1,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=n,t.m06=i,t.m07=0,t.m08=0,t.m09=-i,t.m10=n,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.fromYRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t.m00=n,t.m01=0,t.m02=-i,t.m03=0,t.m04=0,t.m05=1,t.m06=0,t.m07=0,t.m08=i,t.m09=0,t.m10=n,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.fromZRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t.m00=n,t.m01=i,t.m02=0,t.m03=0,t.m04=-i,t.m05=n,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=1,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.fromRT=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=e.w,a=n+n,h=r+r,u=s+s,l=n*a,c=n*h,_=n*u,d=r*h,f=r*u,p=s*u,m=o*a,g=o*h,y=o*u;return t.m00=1-(d+p),t.m01=c+y,t.m02=_-g,t.m03=0,t.m04=c-y,t.m05=1-(l+p),t.m06=f+m,t.m07=0,t.m08=_+g,t.m09=f-m,t.m10=1-(l+d),t.m11=0,t.m12=i.x,t.m13=i.y,t.m14=i.z,t.m15=1,t},e.getTranslation=function(t,e){return t.x=e.m12,t.y=e.m13,t.z=e.m14,t},e.getScaling=function(t,e){var i=Pn.m00=e.m00,n=Pn.m01=e.m01,r=Pn.m02=e.m02,s=Pn.m03=e.m04,o=Pn.m04=e.m05,a=Pn.m05=e.m06,h=Pn.m06=e.m08,u=Pn.m07=e.m09,l=Pn.m08=e.m10;return t.x=Math.sqrt(i*i+n*n+r*r),t.y=Math.sqrt(s*s+o*o+a*a),t.z=Math.sqrt(h*h+u*u+l*l),mn.determinant(Pn)<0&&(t.x*=-1),t},e.getRotation=function(t,e){var i=e.m00+e.m05+e.m10,n=0;return i>0?(n=2*Math.sqrt(i+1),t.w=.25*n,t.x=(e.m06-e.m09)/n,t.y=(e.m08-e.m02)/n,t.z=(e.m01-e.m04)/n):e.m00>e.m05&&e.m00>e.m10?(n=2*Math.sqrt(1+e.m00-e.m05-e.m10),t.w=(e.m06-e.m09)/n,t.x=.25*n,t.y=(e.m01+e.m04)/n,t.z=(e.m08+e.m02)/n):e.m05>e.m10?(n=2*Math.sqrt(1+e.m05-e.m00-e.m10),t.w=(e.m08-e.m02)/n,t.x=(e.m01+e.m04)/n,t.y=.25*n,t.z=(e.m06+e.m09)/n):(n=2*Math.sqrt(1+e.m10-e.m00-e.m05),t.w=(e.m01-e.m04)/n,t.x=(e.m08+e.m02)/n,t.y=(e.m06+e.m09)/n,t.z=.25*n),t},e.toRTS=function(t,e,i,n){var r=on.set(Dn,t.m00,t.m01,t.m02).length(),s=on.set(Dn,t.m04,t.m05,t.m06).length(),o=on.set(Dn,t.m08,t.m09,t.m10).length();Pn.m00=t.m00/r,Pn.m01=t.m01/r,Pn.m02=t.m02/r,Pn.m03=t.m04/s,Pn.m04=t.m05/s,Pn.m05=t.m06/s,Pn.m06=t.m08/o,Pn.m07=t.m09/o,Pn.m08=t.m10/o;var a=mn.determinant(Pn);n&&(on.set(n,r,s,o),a<0&&(n.x*=-1)),i&&on.set(i,t.m12,t.m13,t.m14),e&&(a<0&&(Pn.m00*=-1,Pn.m01*=-1,Pn.m02*=-1),Sn.fromMat3(e,Pn))},e.toSRT=function(t,e,i,n){var r=on.set(Dn,t.m00,t.m01,t.m02).length(),s=on.set(Dn,t.m04,t.m05,t.m06).length(),o=on.set(Dn,t.m08,t.m09,t.m10).length();n&&(n.x=r,n.y=s,n.z=o),i&&on.set(i,t.m12,t.m13,t.m14),e&&(Pn.m00=t.m00/r,Pn.m01=t.m01/r,Pn.m02=t.m02/r,Pn.m03=t.m04/s,Pn.m04=t.m05/s,Pn.m05=t.m06/s,Pn.m06=t.m08/o,Pn.m07=t.m09/o,Pn.m08=t.m10/o,mn.determinant(Pn)<0&&(n&&(n.x*=-1),Pn.m00*=-1,Pn.m01*=-1,Pn.m02*=-1),Sn.fromMat3(e,Pn))},e.toEuler=function(t,e){return mn.set(Pn,t.m00,t.m01,t.m02,t.m04,t.m05,t.m06,t.m08,t.m09,t.m10),mn.toEuler(Pn,e)},e.fromRTS=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=e.w,h=r+r,u=s+s,l=o+o,c=r*h,_=r*u,d=r*l,f=s*u,p=s*l,m=o*l,g=a*h,y=a*u,v=a*l,S=n.x,T=n.y,A=n.z;return t.m00=(1-(f+m))*S,t.m01=(_+v)*S,t.m02=(d-y)*S,t.m03=0,t.m04=(_-v)*T,t.m05=(1-(c+m))*T,t.m06=(p+g)*T,t.m07=0,t.m08=(d+y)*A,t.m09=(p-g)*A,t.m10=(1-(c+f))*A,t.m11=0,t.m12=i.x,t.m13=i.y,t.m14=i.z,t.m15=1,t},e.fromSRT=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=e.w,h=r+r,u=s+s,l=o+o,c=r*h,_=r*u,d=r*l,f=s*u,p=s*l,m=o*l,g=a*h,y=a*u,v=a*l,S=n.x,T=n.y,A=n.z;return t.m00=(1-(f+m))*S,t.m01=(_+v)*S,t.m02=(d-y)*S,t.m03=0,t.m04=(_-v)*T,t.m05=(1-(c+m))*T,t.m06=(p+g)*T,t.m07=0,t.m08=(d+y)*A,t.m09=(p-g)*A,t.m10=(1-(c+f))*A,t.m11=0,t.m12=i.x,t.m13=i.y,t.m14=i.z,t.m15=1,t},e.fromRTSOrigin=function(t,e,i,n,r){var s=e.x,o=e.y,a=e.z,h=e.w,u=s+s,l=o+o,c=a+a,_=s*u,d=s*l,f=s*c,p=o*l,m=o*c,g=a*c,y=h*u,v=h*l,S=h*c,T=n.x,A=n.y,b=n.z,E=r.x,C=r.y,w=r.z;return t.m00=(1-(p+g))*T,t.m01=(d+S)*T,t.m02=(f-v)*T,t.m03=0,t.m04=(d-S)*A,t.m05=(1-(_+g))*A,t.m06=(m+y)*A,t.m07=0,t.m08=(f+v)*b,t.m09=(m-y)*b,t.m10=(1-(_+p))*b,t.m11=0,t.m12=i.x+E-(t.m00*E+t.m04*C+t.m08*w),t.m13=i.y+C-(t.m01*E+t.m05*C+t.m09*w),t.m14=i.z+w-(t.m02*E+t.m06*C+t.m10*w),t.m15=1,t},e.fromSRTOrigin=function(t,e,i,n,r){var s=e.x,o=e.y,a=e.z,h=e.w,u=s+s,l=o+o,c=a+a,_=s*u,d=s*l,f=s*c,p=o*l,m=o*c,g=a*c,y=h*u,v=h*l,S=h*c,T=n.x,A=n.y,b=n.z,E=r.x,C=r.y,w=r.z;return t.m00=(1-(p+g))*T,t.m01=(d+S)*T,t.m02=(f-v)*T,t.m03=0,t.m04=(d-S)*A,t.m05=(1-(_+g))*A,t.m06=(m+y)*A,t.m07=0,t.m08=(f+v)*b,t.m09=(m-y)*b,t.m10=(1-(_+p))*b,t.m11=0,t.m12=i.x+E-(t.m00*E+t.m04*C+t.m08*w),t.m13=i.y+C-(t.m01*E+t.m05*C+t.m09*w),t.m14=i.z+w-(t.m02*E+t.m06*C+t.m10*w),t.m15=1,t},e.fromQuat=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w,o=i+i,a=n+n,h=r+r,u=i*o,l=n*o,c=n*a,_=r*o,d=r*a,f=r*h,p=s*o,m=s*a,g=s*h;return t.m00=1-c-f,t.m01=l+g,t.m02=_-m,t.m03=0,t.m04=l-g,t.m05=1-u-f,t.m06=d+p,t.m07=0,t.m08=_+m,t.m09=d-p,t.m10=1-u-c,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.frustum=function(t,e,i,n,r,s,o){var a=1/(i-e),h=1/(r-n),u=1/(s-o);return t.m00=2*s*a,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=2*s*h,t.m06=0,t.m07=0,t.m08=(i+e)*a,t.m09=(r+n)*h,t.m10=(o+s)*u,t.m11=-1,t.m12=0,t.m13=0,t.m14=o*s*2*u,t.m15=0,t},e.perspective=function(t,e,i,n,r,s,o,a,h){void 0===s&&(s=!0),void 0===o&&(o=-1),void 0===a&&(a=1),void 0===h&&(h=0);var u=1/Math.tan(e/2),l=1/(n-r),c=s?u/i:u,_=(s?u:u*i)*a,d=Rn[h];return t.m00=c*d[0],t.m01=c*d[1],t.m02=0,t.m03=0,t.m04=_*d[2],t.m05=_*d[3],t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=(r-o*n)*l,t.m11=-1,t.m12=0,t.m13=0,t.m14=r*n*l*(1-o),t.m15=0,t},e.ortho=function(t,e,i,n,r,s,o,a,h,u){void 0===a&&(a=-1),void 0===h&&(h=1),void 0===u&&(u=0);var l=1/(e-i),c=1/(n-r)*h,_=1/(s-o),d=-2*l,f=-2*c,p=(e+i)*l,m=(r+n)*c,g=Rn[u];return t.m00=d*g[0],t.m01=d*g[1],t.m02=0,t.m03=0,t.m04=f*g[2],t.m05=f*g[3],t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=_*(1-a),t.m11=0,t.m12=p*g[0]+m*g[2],t.m13=p*g[1]+m*g[3],t.m14=(s-a*o)*_,t.m15=1,t},e.lookAt=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=n.x,h=n.y,u=n.z,l=r-i.x,c=s-i.y,_=o-i.z,d=1/Math.sqrt(l*l+c*c+_*_),f=h*(_*=d)-u*(c*=d),p=u*(l*=d)-a*_,m=a*c-h*l,g=c*(m*=d=1/Math.sqrt(f*f+p*p+m*m))-_*(p*=d),y=_*(f*=d)-l*m,v=l*p-c*f;return t.m00=f,t.m01=g,t.m02=l,t.m03=0,t.m04=p,t.m05=y,t.m06=c,t.m07=0,t.m08=m,t.m09=v,t.m10=_,t.m11=0,t.m12=-(f*r+p*s+m*o),t.m13=-(g*r+y*s+v*o),t.m14=-(l*r+c*s+_*o),t.m15=1,t},e.inverseTranspose=function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=e.m09,_=e.m10,d=e.m11,f=e.m12,p=e.m13,m=e.m14,g=e.m15,y=i*a-n*o,v=i*h-r*o,S=i*u-s*o,T=n*h-r*a,A=n*u-s*a,b=r*u-s*h,E=l*p-c*f,C=l*m-_*f,w=l*g-d*f,x=c*m-_*p,R=c*g-d*p,I=_*g-d*m,B=y*I-v*R+S*x+T*w-A*C+b*E;return B?(B=1/B,t.m00=(a*I-h*R+u*x)*B,t.m01=(h*w-o*I-u*C)*B,t.m02=(o*R-a*w+u*E)*B,t.m03=0,t.m04=(r*R-n*I-s*x)*B,t.m05=(i*I-r*w+s*C)*B,t.m06=(n*w-i*R-s*E)*B,t.m07=0,t.m08=(p*b-m*A+g*T)*B,t.m09=(m*S-f*b-g*v)*B,t.m10=(f*A-p*S+g*y)*B,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t):null},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.m00,t[i+1]=e.m01,t[i+2]=e.m02,t[i+3]=e.m03,t[i+4]=e.m04,t[i+5]=e.m05,t[i+6]=e.m06,t[i+7]=e.m07,t[i+8]=e.m08,t[i+9]=e.m09,t[i+10]=e.m10,t[i+11]=e.m11,t[i+12]=e.m12,t[i+13]=e.m13,t[i+14]=e.m14,t[i+15]=e.m15,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.m00=e[i+0],t.m01=e[i+1],t.m02=e[i+2],t.m03=e[i+3],t.m04=e[i+4],t.m05=e[i+5],t.m06=e[i+6],t.m07=e[i+7],t.m08=e[i+8],t.m09=e[i+9],t.m10=e[i+10],t.m11=e[i+11],t.m12=e[i+12],t.m13=e[i+13],t.m14=e[i+14],t.m15=e[i+15],t},e.add=function(t,e,i){return t.m00=e.m00+i.m00,t.m01=e.m01+i.m01,t.m02=e.m02+i.m02,t.m03=e.m03+i.m03,t.m04=e.m04+i.m04,t.m05=e.m05+i.m05,t.m06=e.m06+i.m06,t.m07=e.m07+i.m07,t.m08=e.m08+i.m08,t.m09=e.m09+i.m09,t.m10=e.m10+i.m10,t.m11=e.m11+i.m11,t.m12=e.m12+i.m12,t.m13=e.m13+i.m13,t.m14=e.m14+i.m14,t.m15=e.m15+i.m15,t},e.subtract=function(t,e,i){return t.m00=e.m00-i.m00,t.m01=e.m01-i.m01,t.m02=e.m02-i.m02,t.m03=e.m03-i.m03,t.m04=e.m04-i.m04,t.m05=e.m05-i.m05,t.m06=e.m06-i.m06,t.m07=e.m07-i.m07,t.m08=e.m08-i.m08,t.m09=e.m09-i.m09,t.m10=e.m10-i.m10,t.m11=e.m11-i.m11,t.m12=e.m12-i.m12,t.m13=e.m13-i.m13,t.m14=e.m14-i.m14,t.m15=e.m15-i.m15,t},e.multiplyScalar=function(t,e,i){return t.m00=e.m00*i,t.m01=e.m01*i,t.m02=e.m02*i,t.m03=e.m03*i,t.m04=e.m04*i,t.m05=e.m05*i,t.m06=e.m06*i,t.m07=e.m07*i,t.m08=e.m08*i,t.m09=e.m09*i,t.m10=e.m10*i,t.m11=e.m11*i,t.m12=e.m12*i,t.m13=e.m13*i,t.m14=e.m14*i,t.m15=e.m15*i,t},e.multiplyScalarAndAdd=function(t,e,i,n){return t.m00=e.m00+i.m00*n,t.m01=e.m01+i.m01*n,t.m02=e.m02+i.m02*n,t.m03=e.m03+i.m03*n,t.m04=e.m04+i.m04*n,t.m05=e.m05+i.m05*n,t.m06=e.m06+i.m06*n,t.m07=e.m07+i.m07*n,t.m08=e.m08+i.m08*n,t.m09=e.m09+i.m09*n,t.m10=e.m10+i.m10*n,t.m11=e.m11+i.m11*n,t.m12=e.m12+i.m12*n,t.m13=e.m13+i.m13*n,t.m14=e.m14+i.m14*n,t.m15=e.m15+i.m15*n,t},e.strictEquals=function(t,e){return t.m00===e.m00&&t.m01===e.m01&&t.m02===e.m02&&t.m03===e.m03&&t.m04===e.m04&&t.m05===e.m05&&t.m06===e.m06&&t.m07===e.m07&&t.m08===e.m08&&t.m09===e.m09&&t.m10===e.m10&&t.m11===e.m11&&t.m12===e.m12&&t.m13===e.m13&&t.m14===e.m14&&t.m15===e.m15},e.equals=function(t,e,i){return void 0===i&&(i=Ei),Math.abs(t.m00-e.m00)<=i*Math.max(1,Math.abs(t.m00),Math.abs(e.m00))&&Math.abs(t.m01-e.m01)<=i*Math.max(1,Math.abs(t.m01),Math.abs(e.m01))&&Math.abs(t.m02-e.m02)<=i*Math.max(1,Math.abs(t.m02),Math.abs(e.m02))&&Math.abs(t.m03-e.m03)<=i*Math.max(1,Math.abs(t.m03),Math.abs(e.m03))&&Math.abs(t.m04-e.m04)<=i*Math.max(1,Math.abs(t.m04),Math.abs(e.m04))&&Math.abs(t.m05-e.m05)<=i*Math.max(1,Math.abs(t.m05),Math.abs(e.m05))&&Math.abs(t.m06-e.m06)<=i*Math.max(1,Math.abs(t.m06),Math.abs(e.m06))&&Math.abs(t.m07-e.m07)<=i*Math.max(1,Math.abs(t.m07),Math.abs(e.m07))&&Math.abs(t.m08-e.m08)<=i*Math.max(1,Math.abs(t.m08),Math.abs(e.m08))&&Math.abs(t.m09-e.m09)<=i*Math.max(1,Math.abs(t.m09),Math.abs(e.m09))&&Math.abs(t.m10-e.m10)<=i*Math.max(1,Math.abs(t.m10),Math.abs(e.m10))&&Math.abs(t.m11-e.m11)<=i*Math.max(1,Math.abs(t.m11),Math.abs(e.m11))&&Math.abs(t.m12-e.m12)<=i*Math.max(1,Math.abs(t.m12),Math.abs(e.m12))&&Math.abs(t.m13-e.m13)<=i*Math.max(1,Math.abs(t.m13),Math.abs(e.m13))&&Math.abs(t.m14-e.m14)<=i*Math.max(1,Math.abs(t.m14),Math.abs(e.m14))&&Math.abs(t.m15-e.m15)<=i*Math.max(1,Math.abs(t.m15),Math.abs(e.m15))};var i=e.prototype;return i.clone=function(){return new e(this.m00,this.m01,this.m02,this.m03,this.m04,this.m05,this.m06,this.m07,this.m08,this.m09,this.m10,this.m11,this.m12,this.m13,this.m14,this.m15)},i.set=function(t,e,i,n,r,s,o,a,h,u,l,c,_,d,f,p){return void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=1),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=0),void 0===l&&(l=1),void 0===c&&(c=0),void 0===_&&(_=0),void 0===d&&(d=0),void 0===f&&(f=0),void 0===p&&(p=1),"object"==typeof t?(this.m01=t.m01,this.m02=t.m02,this.m03=t.m03,this.m04=t.m04,this.m05=t.m05,this.m06=t.m06,this.m07=t.m07,this.m08=t.m08,this.m09=t.m09,this.m10=t.m10,this.m11=t.m11,this.m12=t.m12,this.m13=t.m13,this.m14=t.m14,this.m15=t.m15,this.m00=t.m00):(this.m01=e,this.m02=i,this.m03=n,this.m04=r,this.m05=s,this.m06=o,this.m07=a,this.m08=h,this.m09=u,this.m10=l,this.m11=c,this.m12=_,this.m13=d,this.m14=f,this.m15=p,this.m00=t),this},i.equals=function(t,e){return void 0===e&&(e=Ei),!(Math.abs(this.m00)===1/0||Math.abs(this.m01)===1/0||Math.abs(this.m02)===1/0||Math.abs(this.m03)===1/0||Math.abs(this.m04)===1/0||Math.abs(this.m05)===1/0||Math.abs(this.m06)===1/0||Math.abs(this.m07)===1/0||Math.abs(this.m08)===1/0||Math.abs(this.m09)===1/0||Math.abs(this.m10)===1/0||Math.abs(this.m11)===1/0||Math.abs(this.m12)===1/0||Math.abs(this.m13)===1/0||Math.abs(this.m14)===1/0||Math.abs(this.m15)===1/0)&&Math.abs(this.m00-t.m00)<=e*Math.max(1,Math.abs(this.m00),Math.abs(t.m00))&&Math.abs(this.m01-t.m01)<=e*Math.max(1,Math.abs(this.m01),Math.abs(t.m01))&&Math.abs(this.m02-t.m02)<=e*Math.max(1,Math.abs(this.m02),Math.abs(t.m02))&&Math.abs(this.m03-t.m03)<=e*Math.max(1,Math.abs(this.m03),Math.abs(t.m03))&&Math.abs(this.m04-t.m04)<=e*Math.max(1,Math.abs(this.m04),Math.abs(t.m04))&&Math.abs(this.m05-t.m05)<=e*Math.max(1,Math.abs(this.m05),Math.abs(t.m05))&&Math.abs(this.m06-t.m06)<=e*Math.max(1,Math.abs(this.m06),Math.abs(t.m06))&&Math.abs(this.m07-t.m07)<=e*Math.max(1,Math.abs(this.m07),Math.abs(t.m07))&&Math.abs(this.m08-t.m08)<=e*Math.max(1,Math.abs(this.m08),Math.abs(t.m08))&&Math.abs(this.m09-t.m09)<=e*Math.max(1,Math.abs(this.m09),Math.abs(t.m09))&&Math.abs(this.m10-t.m10)<=e*Math.max(1,Math.abs(this.m10),Math.abs(t.m10))&&Math.abs(this.m11-t.m11)<=e*Math.max(1,Math.abs(this.m11),Math.abs(t.m11))&&Math.abs(this.m12-t.m12)<=e*Math.max(1,Math.abs(this.m12),Math.abs(t.m12))&&Math.abs(this.m13-t.m13)<=e*Math.max(1,Math.abs(this.m13),Math.abs(t.m13))&&Math.abs(this.m14-t.m14)<=e*Math.max(1,Math.abs(this.m14),Math.abs(t.m14))&&Math.abs(this.m15-t.m15)<=e*Math.max(1,Math.abs(this.m15),Math.abs(t.m15))},i.strictEquals=function(t){return this.m00===t.m00&&this.m01===t.m01&&this.m02===t.m02&&this.m03===t.m03&&this.m04===t.m04&&this.m05===t.m05&&this.m06===t.m06&&this.m07===t.m07&&this.m08===t.m08&&this.m09===t.m09&&this.m10===t.m10&&this.m11===t.m11&&this.m12===t.m12&&this.m13===t.m13&&this.m14===t.m14&&this.m15===t.m15},i.toString=function(){return"[\n"+this.m00+", "+this.m01+", "+this.m02+", "+this.m03+",\n"+this.m04+", "+this.m05+", "+this.m06+", "+this.m07+",\n"+this.m08+", "+this.m09+", "+this.m10+", "+this.m11+",\n"+this.m12+", "+this.m13+", "+this.m14+", "+this.m15+"\n]"},i.identity=function(){return this.m00=1,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=1,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=1,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},i.zero=function(){return this.m00=0,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=0,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=0,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=0,this},i.transpose=function(){var t=this.m01,e=this.m02,i=this.m03,n=this.m06,r=this.m07,s=this.m11;return this.m01=this.m04,this.m02=this.m08,this.m03=this.m12,this.m04=t,this.m06=this.m09,this.m07=this.m13,this.m08=e,this.m09=n,this.m11=this.m14,this.m12=i,this.m13=r,this.m14=s,this},i.invert=function(){var t=this.m00,e=this.m01,i=this.m02,n=this.m03,r=this.m04,s=this.m05,o=this.m06,a=this.m07,h=this.m08,u=this.m09,l=this.m10,c=this.m11,_=this.m12,d=this.m13,f=this.m14,p=this.m15,m=t*s-e*r,g=t*o-i*r,y=t*a-n*r,v=e*o-i*s,S=e*a-n*s,T=i*a-n*o,A=h*d-u*_,b=h*f-l*_,E=h*p-c*_,C=u*f-l*d,w=u*p-c*d,x=l*p-c*f,R=m*x-g*w+y*C+v*E-S*b+T*A;return 0===R?(this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),this):(R=1/R,this.m00=(s*x-o*w+a*C)*R,this.m01=(i*w-e*x-n*C)*R,this.m02=(d*T-f*S+p*v)*R,this.m03=(l*S-u*T-c*v)*R,this.m04=(o*E-r*x-a*b)*R,this.m05=(t*x-i*E+n*b)*R,this.m06=(f*y-_*T-p*g)*R,this.m07=(h*T-l*y+c*g)*R,this.m08=(r*w-s*E+a*A)*R,this.m09=(e*E-t*w-n*A)*R,this.m10=(_*S-d*y+p*m)*R,this.m11=(u*y-h*S-c*m)*R,this.m12=(s*b-r*C-o*A)*R,this.m13=(t*C-e*b+i*A)*R,this.m14=(d*g-_*v-f*m)*R,this.m15=(h*v-u*g+l*m)*R,this)},i.determinant=function(){var t=this.m00,e=this.m01,i=this.m02,n=this.m03,r=this.m04,s=this.m05,o=this.m06,a=this.m07,h=this.m08,u=this.m09,l=this.m10,c=this.m11,_=this.m12,d=this.m13,f=this.m14,p=this.m15;return(t*s-e*r)*(l*p-c*f)-(t*o-i*r)*(u*p-c*d)+(t*a-n*r)*(u*f-l*d)+(e*o-i*s)*(h*p-c*_)-(e*a-n*s)*(h*f-l*_)+(i*a-n*o)*(h*d-u*_)},i.add=function(t){return this.m00+=t.m00,this.m01+=t.m01,this.m02+=t.m02,this.m03+=t.m03,this.m04+=t.m04,this.m05+=t.m05,this.m06+=t.m06,this.m07+=t.m07,this.m08+=t.m08,this.m09+=t.m09,this.m10+=t.m10,this.m11+=t.m11,this.m12+=t.m12,this.m13+=t.m13,this.m14+=t.m14,this.m15+=t.m15,this},i.subtract=function(t){return this.m00-=t.m00,this.m01-=t.m01,this.m02-=t.m02,this.m03-=t.m03,this.m04-=t.m04,this.m05-=t.m05,this.m06-=t.m06,this.m07-=t.m07,this.m08-=t.m08,this.m09-=t.m09,this.m10-=t.m10,this.m11-=t.m11,this.m12-=t.m12,this.m13-=t.m13,this.m14-=t.m14,this.m15-=t.m15,this},i.multiply=function(t){var e=this.m00,i=this.m01,n=this.m02,r=this.m03,s=this.m04,o=this.m05,a=this.m06,h=this.m07,u=this.m08,l=this.m09,c=this.m10,_=this.m11,d=this.m12,f=this.m13,p=this.m14,m=this.m15,g=t.m00,y=t.m01,v=t.m02,S=t.m03;return this.m00=g*e+y*s+v*u+S*d,this.m01=g*i+y*o+v*l+S*f,this.m02=g*n+y*a+v*c+S*p,this.m03=g*r+y*h+v*_+S*m,g=t.m04,y=t.m05,v=t.m06,S=t.m07,this.m04=g*e+y*s+v*u+S*d,this.m05=g*i+y*o+v*l+S*f,this.m06=g*n+y*a+v*c+S*p,this.m07=g*r+y*h+v*_+S*m,g=t.m08,y=t.m09,v=t.m10,S=t.m11,this.m08=g*e+y*s+v*u+S*d,this.m09=g*i+y*o+v*l+S*f,this.m10=g*n+y*a+v*c+S*p,this.m11=g*r+y*h+v*_+S*m,g=t.m12,y=t.m13,v=t.m14,S=t.m15,this.m12=g*e+y*s+v*u+S*d,this.m13=g*i+y*o+v*l+S*f,this.m14=g*n+y*a+v*c+S*p,this.m15=g*r+y*h+v*_+S*m,this},i.multiplyScalar=function(t){return this.m00*=t,this.m01*=t,this.m02*=t,this.m03*=t,this.m04*=t,this.m05*=t,this.m06*=t,this.m07*=t,this.m08*=t,this.m09*=t,this.m10*=t,this.m11*=t,this.m12*=t,this.m13*=t,this.m14*=t,this.m15*=t,this},i.translate=function(t){return this.m12+=t.x,this.m13+=t.y,this.m14+=t.z,this},i.transform=function(t){var e=t.x,i=t.y,n=t.z,r=this.m00,s=this.m01,o=this.m02,a=this.m03,h=this.m04,u=this.m05,l=this.m06,c=this.m07,_=this.m08,d=this.m09,f=this.m10,p=this.m11;return this.m12=r*e+h*i+_*n+this.m12,this.m13=s*e+u*i+d*n+this.m13,this.m14=o*e+l*i+f*n+this.m14,this.m15=a*e+c*i+p*n+this.m15,this},i.scale=function(t){var e=t.x,i=t.y,n=t.z;return this.m00*=e,this.m01*=e,this.m02*=e,this.m03*=e,this.m04*=i,this.m05*=i,this.m06*=i,this.m07*=i,this.m08*=n,this.m09*=n,this.m10*=n,this.m11*=n,this},i.rotate=function(t,e){var i=e.x,n=e.y,r=e.z,s=Math.sqrt(i*i+n*n+r*r);if(Math.abs(s)<Ei)return null;i*=s=1/s,n*=s,r*=s;var o=Math.sin(t),a=Math.cos(t),h=1-a,u=this.m00,l=this.m01,c=this.m02,_=this.m03,d=this.m04,f=this.m05,p=this.m06,m=this.m07,g=this.m08,y=this.m09,v=this.m10,S=this.m11,T=i*i*h+a,A=n*i*h+r*o,b=r*i*h-n*o,E=i*n*h-r*o,C=n*n*h+a,w=r*n*h+i*o,x=i*r*h+n*o,R=n*r*h-i*o,I=r*r*h+a;return this.m00=u*T+d*A+g*b,this.m01=l*T+f*A+y*b,this.m02=c*T+p*A+v*b,this.m03=_*T+m*A+S*b,this.m04=u*E+d*C+g*w,this.m05=l*E+f*C+y*w,this.m06=c*E+p*C+v*w,this.m07=_*E+m*C+S*w,this.m08=u*x+d*R+g*I,this.m09=l*x+f*R+y*I,this.m10=c*x+p*R+v*I,this.m11=_*x+m*R+S*I,this},i.getTranslation=function(t){return t.x=this.m12,t.y=this.m13,t.z=this.m14,t},i.getScale=function(t){var e=Pn.m00=this.m00,i=Pn.m01=this.m01,n=Pn.m02=this.m02,r=Pn.m03=this.m04,s=Pn.m04=this.m05,o=Pn.m05=this.m06,a=Pn.m06=this.m08,h=Pn.m07=this.m09,u=Pn.m08=this.m10;return t.x=Math.sqrt(e*e+i*i+n*n),t.y=Math.sqrt(r*r+s*s+o*o),t.z=Math.sqrt(a*a+h*h+u*u),mn.determinant(Pn)<0&&(t.x*=-1),t},i.getRotation=function(t){var e=on.set(Dn,this.m00,this.m01,this.m02).length(),i=on.set(Dn,this.m04,this.m05,this.m06).length(),n=on.set(Dn,this.m08,this.m09,this.m10).length();return Pn.m00=this.m00/e,Pn.m01=this.m01/e,Pn.m02=this.m02/e,Pn.m03=this.m04/i,Pn.m04=this.m05/i,Pn.m05=this.m06/i,Pn.m06=this.m08/n,Pn.m07=this.m09/n,Pn.m08=this.m10/n,mn.determinant(Pn)<0&&(Pn.m00*=-1,Pn.m01*=-1,Pn.m02*=-1),Sn.fromMat3(t,Pn)},i.fromRTS=function(t,e,i){var n=t.x,r=t.y,s=t.z,o=t.w,a=n+n,h=r+r,u=s+s,l=n*a,c=n*h,_=n*u,d=r*h,f=r*u,p=s*u,m=o*a,g=o*h,y=o*u,v=i.x,S=i.y,T=i.z;return this.m00=(1-(d+p))*v,this.m01=(c+y)*v,this.m02=(_-g)*v,this.m03=0,this.m04=(c-y)*S,this.m05=(1-(l+p))*S,this.m06=(f+m)*S,this.m07=0,this.m08=(_+g)*T,this.m09=(f-m)*T,this.m10=(1-(l+d))*T,this.m11=0,this.m12=e.x,this.m13=e.y,this.m14=e.z,this.m15=1,this},i.fromSRT=function(t,e,i){var n=t.x,r=t.y,s=t.z,o=t.w,a=n+n,h=r+r,u=s+s,l=n*a,c=n*h,_=n*u,d=r*h,f=r*u,p=s*u,m=o*a,g=o*h,y=o*u,v=i.x,S=i.y,T=i.z;return this.m00=(1-(d+p))*v,this.m01=(c+y)*v,this.m02=(_-g)*v,this.m03=0,this.m04=(c-y)*S,this.m05=(1-(l+p))*S,this.m06=(f+m)*S,this.m07=0,this.m08=(_+g)*T,this.m09=(f-m)*T,this.m10=(1-(l+d))*T,this.m11=0,this.m12=e.x,this.m13=e.y,this.m14=e.z,this.m15=1,this},i.fromQuat=function(t){var e=t.x,i=t.y,n=t.z,r=t.w,s=e+e,o=i+i,a=n+n,h=e*s,u=i*s,l=i*o,c=n*s,_=n*o,d=n*a,f=r*s,p=r*o,m=r*a;return this.m00=1-l-d,this.m01=u+m,this.m02=c-p,this.m03=0,this.m04=u-m,this.m05=1-h-d,this.m06=_+f,this.m07=0,this.m08=c+p,this.m09=_-f,this.m10=1-h-l,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},e}(Ae));Tn=In,In.IDENTITY=Object.freeze(new Tn);var Bn,Dn=new on,Pn=new mn;function On(t,e,i,n,r,s,o,a,h,u,l,c,_,d,f,p){return new In(t,e,i,n,r,s,o,a,h,u,l,c,_,d,f,p)}pi.fastDefine("cc.Mat4",In,{m00:1,m01:0,m02:0,m03:0,m04:0,m05:1,m06:0,m07:0,m08:0,m09:0,m10:1,m11:0,m12:0,m13:0,m14:0,m15:1}),v.Mat4=In,v.mat4=On;var Mn,Ln=t("aL",function(t){function e(e,i){var n;return n=t.call(this)||this,"object"==typeof e?(n.x=e.x,n.y=e.y):(n.x=e||0,n.y=i||0),n}s(e,t),e.clone=function(t){return new e(t.x,t.y)},e.copy=function(t,e){return t.x=e.x,t.y=e.y,t},e.set=function(t,e,i){return t.x=e,t.y=i,t},e.add=function(t,e,i){return t.x=e.x+i.x,t.y=e.y+i.y,t},e.subtract=function(t,e,i){return t.x=e.x-i.x,t.y=e.y-i.y,t},e.multiply=function(t,e,i){return t.x=e.x*i.x,t.y=e.y*i.y,t},e.divide=function(t,e,i){return t.x=e.x/i.x,t.y=e.y/i.y,t},e.ceil=function(t,e){return t.x=Math.ceil(e.x),t.y=Math.ceil(e.y),t},e.floor=function(t,e){return t.x=Math.floor(e.x),t.y=Math.floor(e.y),t},e.min=function(t,e,i){return t.x=Math.min(e.x,i.x),t.y=Math.min(e.y,i.y),t},e.max=function(t,e,i){return t.x=Math.max(e.x,i.x),t.y=Math.max(e.y,i.y),t},e.round=function(t,e){return t.x=Math.round(e.x),t.y=Math.round(e.y),t},e.multiplyScalar=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t},e.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t},e.distance=function(t,e){var i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)},e.squaredDistance=function(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},e.len=function(t){var e=t.x,i=t.y;return Math.sqrt(e*e+i*i)},e.lengthSqr=function(t){var e=t.x,i=t.y;return e*e+i*i},e.negate=function(t,e){return t.x=-e.x,t.y=-e.y,t},e.inverse=function(t,e){return t.x=1/e.x,t.y=1/e.y,t},e.inverseSafe=function(t,e){var i=e.x,n=e.y;return Math.abs(i)<Ei?t.x=0:t.x=1/i,Math.abs(n)<Ei?t.y=0:t.y=1/n,t},e.normalize=function(t,e){var i=e.x,n=e.y,r=i*i+n*n;return r>0?(r=1/Math.sqrt(r),t.x=i*r,t.y=n*r):(t.x=0,t.y=0),t},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.cross=function(t,e,i){return t instanceof on?(t.x=t.y=0,t.z=e.x*i.y-e.y*i.x,t):t.x*e.y-t.y*e.x},e.lerp=function(t,e,i,n){var r=e.x,s=e.y;return t.x=r+n*(i.x-r),t.y=s+n*(i.y-s),t},e.random=function(t,e){e=e||1;var i=2*Pi()*Math.PI;return t.x=Math.cos(i)*e,t.y=Math.sin(i)*e,t},e.transformMat3=function(t,e,i){var n=e.x,r=e.y;return t.x=i.m00*n+i.m03*r+i.m06,t.y=i.m01*n+i.m04*r+i.m07,t},e.transformMat4=function(t,e,i){var n=e.x,r=e.y;return t.x=i.m00*n+i.m04*r+i.m12,t.y=i.m01*n+i.m05*r+i.m13,t},e.str=function(t){return"Vec2("+t.x+", "+t.y+")"},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t},e.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y},e.equals=function(t,e,i){return void 0===i&&(i=Ei),Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(e.y))},e.angle=function(t,e){var i=t.x*t.x+t.y*t.y,n=e.x*e.x+e.y*e.y;if(0===i||0===n)return 0;var r=(t.x*e.x+t.y*e.y)/Math.sqrt(i*n);return r=xi(r,-1,1),Math.acos(r)};var i=e.prototype;return i.clone=function(){return new e(this.x,this.y)},i.set=function(t,e){return"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t||0,this.y=e||0),this},i.equals=function(t,e){return void 0===e&&(e=Ei),Math.abs(this.x-t.x)<=e*Math.max(1,Math.abs(this.x),Math.abs(t.x))&&Math.abs(this.y-t.y)<=e*Math.max(1,Math.abs(this.y),Math.abs(t.y))},i.equals2f=function(t,e,i){return void 0===i&&(i=Ei),Math.abs(this.x-t)<=i*Math.max(1,Math.abs(this.x),Math.abs(t))&&Math.abs(this.y-e)<=i*Math.max(1,Math.abs(this.y),Math.abs(e))},i.strictEquals=function(t){return t&&this.x===t.x&&this.y===t.y},i.strictEquals2f=function(t,e){return this.x===t&&this.y===e},i.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+")"},i.lerp=function(t,e){var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},i.clampf=function(t,e){return this.x=xi(this.x,t.x,e.x),this.y=xi(this.y,t.y,e.y),this},i.add=function(t){return this.x+=t.x,this.y+=t.y,this},i.add2f=function(t,e){return this.x+=t,this.y+=e,this},i.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},i.subtract2f=function(t,e){return this.x-=t,this.y-=e,this},i.multiplyScalar=function(t){return"object"==typeof t&&console.warn("should use Vec2.multiply for vector * vector operation"),this.x*=t,this.y*=t,this},i.multiply=function(t){return"object"!=typeof t&&console.warn("should use Vec2.scale for vector * scalar operation"),this.x*=t.x,this.y*=t.y,this},i.multiply2f=function(t,e){return this.x*=t,this.y*=e,this},i.divide=function(t){return this.x/=t.x,this.y/=t.y,this},i.divide2f=function(t,e){return this.x/=t,this.y/=e,this},i.negative=function(){return this.x=-this.x,this.y=-this.y,this},i.dot=function(t){return this.x*t.x+this.y*t.y},i.cross=function(t){return this.x*t.y-this.y*t.x},i.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},i.lengthSqr=function(){return this.x*this.x+this.y*this.y},i.normalize=function(){var t=this.x,e=this.y,i=t*t+e*e;return i>0&&(i=1/Math.sqrt(i),this.x*=i,this.y*=i),this},i.angle=function(t){var e=this.lengthSqr(),i=t.lengthSqr();if(0===e||0===i)return 0;var n=this.dot(t)/Math.sqrt(e*i);return n=xi(n,-1,1),Math.acos(n)},i.signAngle=function(t){var e=this.cross(t),i=this.dot(t);return Math.atan2(e,i)},i.rotate=function(t){var e=this.x,i=this.y,n=Math.sin(t),r=Math.cos(t);return this.x=r*e-n*i,this.y=n*e+r*i,this},i.project=function(t){var e=this.dot(t)/t.dot(t);return this.x=t.x*e,this.y=t.y*e,this},i.transformMat4=function(t){var e=this.x,i=this.y;return this.x=t.m00*e+t.m04*i+t.m12,this.y=t.m01*e+t.m05*i+t.m13,this},e}(Ae));function Nn(t,e){return new Ln(t,e)}Bn=Ln,Ln.ZERO=Object.freeze(new Bn(0,0)),Ln.ONE=Object.freeze(new Bn(1,1)),Ln.NEG_ONE=Object.freeze(new Bn(-1,-1)),Ln.UNIT_X=Object.freeze(new Bn(1,0)),Ln.UNIT_Y=Object.freeze(new Bn(0,1)),pi.fastDefine("cc.Vec2",Ln,{x:0,y:0}),v.Vec2=Ln,v.v2=Nn,nt(Ln,"Vec2",[{name:"sub",newName:"subtract",target:Ln,targetName:"Vec2"},{name:"mul",newName:"multiply",target:Ln,targetName:"Vec2"},{name:"div",newName:"divide",target:Ln,targetName:"Vec2"},{name:"dist",newName:"distance",target:Ln,targetName:"Vec2"},{name:"sqrDist",newName:"squaredDistance",target:Ln,targetName:"Vec2"},{name:"mag",newName:"len",target:Ln,targetName:"Vec2"},{name:"sqrMag",newName:"lengthSqr",target:Ln,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:Ln,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:Ln,targetName:"Vec2"}]),nt(Ln.prototype,"Vec2",[{name:"mag",newName:"length",target:Ln.prototype,targetName:"Vec2"},{name:"magSqr",newName:"lengthSqr",target:Ln.prototype,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:Ln.prototype,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:Ln.prototype,targetName:"Vec2"}]),nt(on,"Vec3",[{name:"sub",newName:"subtract",target:on,targetName:"Vec3"},{name:"mul",newName:"multiply",target:on,targetName:"Vec3"},{name:"div",newName:"divide",target:on,targetName:"Vec3"},{name:"dist",newName:"distance",target:on,targetName:"Vec3"},{name:"sqrDist",newName:"squaredDistance",target:on,targetName:"Vec3"},{name:"mag",newName:"len",target:on,targetName:"Vec3"},{name:"sqrMag",newName:"lengthSqr",target:on,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:on,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:on,targetName:"Vec3"}]),nt(on.prototype,"Vec3",[{name:"mag",newName:"length",target:on.prototype,targetName:"Vec3"},{name:"magSqr",newName:"lengthSqr",target:on.prototype,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:on.prototype,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:on.prototype,targetName:"Vec3"}]),nt(tn,"Vec4",[{name:"sub",newName:"subtract",target:tn,targetName:"Vec4"},{name:"mul",newName:"multiply",target:tn,targetName:"Vec4"},{name:"div",newName:"divide",target:tn,targetName:"Vec4"},{name:"dist",newName:"distance",target:tn,targetName:"Vec4"},{name:"sqrDist",newName:"squaredDistance",target:tn,targetName:"Vec4"},{name:"mag",newName:"len",target:tn,targetName:"Vec4"},{name:"sqrMag",newName:"lengthSqr",target:tn,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:tn,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:tn,targetName:"Vec4"}]),nt(tn.prototype,"Vec4",[{name:"mag",newName:"length",target:tn.prototype,targetName:"Vec4"},{name:"magSqr",newName:"lengthSqr",target:tn.prototype,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:tn.prototype,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:tn.prototype,targetName:"Vec4"}]),nt(Sn,"Quat",[{name:"mag",newName:"len",target:Sn,targetName:"Quat"},{name:"mul",newName:"multiply",target:Sn,targetName:"Quat"},{name:"sqrMag",newName:"lengthSqr",target:Sn,targetName:"Quat"},{name:"scale",newName:"multiplyScalar",target:Sn,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Sn,targetName:"Quat"}]),nt(Sn.prototype,"Quat",[{name:"scale",newName:"multiplyScalar",target:Sn.prototype,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Sn.prototype,targetName:"Quat"}]),nt(dn,"Color",[{name:"sub",newName:"subtract",target:dn,targetName:"Color"},{name:"mul",newName:"multiply",target:dn,targetName:"Color"},{name:"div",newName:"divide",target:dn,targetName:"Color"},{name:"exactEquals",newName:"strictEquals",target:dn,targetName:"Color"},{name:"fromHex",newName:"fromHEX",customFunction:function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=e[1].toString(16);return v.Color.fromHEX(e[0],n)}}]),nt(mn,"Mat3",[{name:"sub",newName:"subtract",target:mn,targetName:"Mat3"},{name:"mul",newName:"multiply",target:mn,targetName:"Mat3"},{name:"exactEquals",newName:"strictEquals",target:mn,targetName:"Mat3"},{name:"transfrom",newName:"transform",target:mn,targetName:"Mat3"}]),nt(mn.prototype,"Mat3",[{name:"sub",newName:"subtract",target:mn.prototype,targetName:"Mat3"},{name:"mul",newName:"multiply",target:mn.prototype,targetName:"Mat3"},{name:"mulScalar",newName:"multiplyScalar",target:mn.prototype,targetName:"Mat3"},{name:"exactEquals",newName:"strictEquals",target:mn.prototype,targetName:"Mat3"}]),nt(In,"Mat4",[{name:"sub",newName:"subtract",target:In,targetName:"Mat4"},{name:"mul",newName:"multiply",target:In,targetName:"Mat4"},{name:"exactEquals",newName:"strictEquals",target:In,targetName:"Mat4"}]),nt(In.prototype,"Mat4",[{name:"sub",newName:"subtract",target:In.prototype,targetName:"Mat4"},{name:"mul",newName:"multiply",target:In.prototype,targetName:"Mat4"},{name:"mulScalar",newName:"multiplyScalar",target:In.prototype,targetName:"Mat4"},{name:"exactEquals",newName:"strictEquals",target:In.prototype,targetName:"Mat4"}]),function(t){t[t.VEC2=0]="VEC2",t[t.VEC3=1]="VEC3",t[t.VEC4=2]="VEC4",t[t.QUATERNION=3]="QUATERNION",t[t.MAT3=4]="MAT3",t[t.MAT4=5]="MAT4",t[t.SIZE=6]="SIZE",t[t.RECT=7]="RECT",t[t.COLOR=8]="COLOR"}(Mn||(Mn={}));var Fn,kn=t("aW",function(){function t(t,e,i,n,r,s){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s}return t.identity=function(){return new t},t.clone=function(e){return new t(e.a,e.b,e.c,e.d,e.tx,e.ty)},t.concat=function(t,e,i){var n=e.a,r=e.b,s=e.c,o=e.d,a=e.tx,h=e.ty;t.a=n*i.a+r*i.c,t.b=n*i.b+r*i.d,t.c=s*i.a+o*i.c,t.d=s*i.b+o*i.d,t.tx=a*i.a+h*i.c+i.tx,t.ty=a*i.b+h*i.d+i.ty},t.invert=function(t,e){var i=1/(e.a*e.d-e.b*e.c);t.a=i*e.d,t.b=-i*e.b,t.c=-i*e.c,t.d=i*e.a,t.tx=i*(e.c*e.ty-e.d*e.tx),t.ty=i*(e.b*e.tx-e.a*e.ty)},t.fromMat4=function(t,e){t.a=e.m00,t.b=e.m01,t.c=e.m04,t.d=e.m05,t.tx=e.m12,t.ty=e.m13},t.transformVec2=function(t,e,i,n){var r,s;n?(r=e,s=i):(n=i,r=e.x,s=e.y),t.x=n.a*r+n.c*s+n.tx,t.y=n.b*r+n.d*s+n.ty},t.transformSize=function(t,e,i){t.width=i.a*e.width+i.c*e.height,t.height=i.b*e.width+i.d*e.height},t.transformRect=function(t,e,i){var n=e.x+e.width,r=e.y+e.height,s=i.a*e.x+i.c*e.y+i.tx,o=i.b*e.x+i.d*e.y+i.ty,a=i.a*n+i.c*e.y+i.tx,h=i.b*n+i.d*e.y+i.ty,u=i.a*e.x+i.c*r+i.tx,l=i.b*e.x+i.d*r+i.ty,c=i.a*n+i.c*r+i.tx,_=i.b*n+i.d*r+i.ty,d=Math.min(s,a,u,c),f=Math.max(s,a,u,c),p=Math.min(o,h,l,_),m=Math.max(o,h,l,_);t.x=d,t.y=p,t.width=f-d,t.height=m-p},t.transformObb=function(t,e,i,n,r,s,o){void 0===o&&(o=!0);var a=s.a*r.x+s.c*r.y+s.tx,h=s.b*r.x+s.d*r.y+s.ty,u=s.a*r.width,l=s.b*r.width,c=s.c*r.height,_=s.d*r.height;o?(e.x=a,e.y=h,i.x=u+a,i.y=l+h,t.x=c+a,t.y=_+h,n.x=u+c+a,n.y=l+_+h):(t.x=a,t.y=h,n.x=u+a,n.y=l+h,e.x=c+a,e.y=_+h,i.x=u+c+a,i.y=l+_+h)},t}());v.AffineTransform=kn;var Vn=t("aX",function(t){function e(e,i){var n;return n=t.call(this)||this,"object"==typeof e?(n.width=e.width,n.height=e.height):(n.width=e||0,n.height=i||0),n}s(e,t),e.lerp=function(t,e,i,n){return t.width=e.width+(i.width-e.width)*n,t.height=e.height+(i.height-e.height)*n,t},e.equals=function(t,e){return t.width===e.width&&t.height===e.height};var i=e.prototype;return i.clone=function(){return new e(this.width,this.height)},i.set=function(t,e){return"object"==typeof t?(this.height=t.height,this.width=t.width):(this.width=t||0,this.height=e||0),this},i.equals=function(t){return this.width===t.width&&this.height===t.height},i.lerp=function(t,e){return this.width+=(t.width-this.width)*e,this.height+=(t.height-this.height)*e,this},i.toString=function(){return"("+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},n(e,[{key:"x",get:function(){return this.width},set:function(t){this.width=t}},{key:"y",get:function(){return this.height},set:function(t){this.height=t}}]),e}(Ae));function Gn(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),new Vn(t,e)}Fn=Vn,Vn.ZERO=Object.freeze(new Fn(0,0)),Vn.ONE=Object.freeze(new Fn(1,1)),pi.fastDefine("cc.Size",Vn,{width:0,height:0}),v.size=Gn,v.Size=Vn;var Un=t("aZ",function(t){function e(e,i,n,r){var s;return s=t.call(this)||this,"object"==typeof e?(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height):(s.x=e||0,s.y=i||0,s.width=n||0,s.height=r||0),s}s(e,t),e.fromMinMax=function(t,e,i){var n=Math.min(e.x,i.x),r=Math.min(e.y,i.y),s=Math.max(e.x,i.x),o=Math.max(e.y,i.y);return t.x=n,t.y=r,t.width=s-n,t.height=o-r,t},e.lerp=function(t,e,i,n){var r=e.x,s=e.y,o=e.width,a=e.height;return t.x=r+(i.x-r)*n,t.y=s+(i.y-s)*n,t.width=o+(i.width-o)*n,t.height=a+(i.height-a)*n,t},e.intersection=function(t,e,i){var n=e.x,r=e.y,s=e.x+e.width,o=e.y+e.height,a=i.x,h=i.y,u=i.x+i.width,l=i.y+i.height;return t.x=Math.max(n,a),t.y=Math.max(r,h),t.width=Math.min(s,u)-t.x,t.height=Math.min(o,l)-t.y,t},e.union=function(t,e,i){var n=e.x,r=e.y,s=e.width,o=e.height,a=i.x,h=i.y,u=i.width,l=i.height;return t.x=Math.min(n,a),t.y=Math.min(r,h),t.width=Math.max(n+s,a+u)-t.x,t.height=Math.max(r+o,h+l)-t.y,t},e.equals=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height};var i=e.prototype;return i.clone=function(){return new e(this.x,this.y,this.width,this.height)},i.set=function(t,e,i,n){return"object"==typeof t?(this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height):(this.x=t||0,this.y=e||0,this.width=i||0,this.height=n||0),this},i.equals=function(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},i.lerp=function(t,e){var i=this.x,n=this.y,r=this.width,s=this.height;return this.x=i+(t.x-i)*e,this.y=n+(t.y-n)*e,this.width=r+(t.width-r)*e,this.height=s+(t.height-s)*e,this},i.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},i.intersects=function(t){var e=this.x+this.width,i=this.y+this.height,n=t.x+t.width,r=t.y+t.height;return!(e<t.x||n<this.x||i<t.y||r<this.y)},i.contains=function(t){return this.x<=t.x&&this.x+this.width>=t.x&&this.y<=t.y&&this.y+this.height>=t.y},i.containsRect=function(t){return this.x<=t.x&&this.x+this.width>=t.x+t.width&&this.y<=t.y&&this.y+this.height>=t.y+t.height},i.transformMat4=function(t){var e=this.x,i=this.y,n=e+this.width,r=i+this.height,s=t.m00*e+t.m04*i+t.m12,o=t.m01*e+t.m05*i+t.m13,a=t.m00*n+t.m04*i+t.m12,h=t.m01*n+t.m05*i+t.m13,u=t.m00*e+t.m04*r+t.m12,l=t.m01*e+t.m05*r+t.m13,c=t.m00*n+t.m04*r+t.m12,_=t.m01*n+t.m05*r+t.m13,d=Math.min(s,a,u,c),f=Math.max(s,a,u,c),p=Math.min(o,h,l,_),m=Math.max(o,h,l,_);return this.x=d,this.y=p,this.width=f-d,this.height=m-p,this},i.transformMat4ToPoints=function(t,e,i,n,r){var s=this.x,o=this.y,a=s+this.width,h=o+this.height;e.x=t.m00*s+t.m04*o+t.m12,e.y=t.m01*s+t.m05*o+t.m13,r.x=t.m00*a+t.m04*o+t.m12,r.y=t.m01*a+t.m05*o+t.m13,i.x=t.m00*s+t.m04*h+t.m12,i.y=t.m01*s+t.m05*h+t.m13,n.x=t.m00*a+t.m04*h+t.m12,n.y=t.m01*a+t.m05*h+t.m13},n(e,[{key:"xMin",get:function(){return this.x},set:function(t){this.width+=this.x-t,this.x=t}},{key:"yMin",get:function(){return this.y},set:function(t){this.height+=this.y-t,this.y=t}},{key:"xMax",get:function(){return this.x+this.width},set:function(t){this.width=t-this.x}},{key:"yMax",get:function(){return this.y+this.height},set:function(t){this.height=t-this.y}},{key:"center",get:function(){return new Ln(this.x+.5*this.width,this.y+.5*this.height)},set:function(t){this.x=t.x-.5*this.width,this.y=t.y-.5*this.height}},{key:"origin",get:function(){return new Ln(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}},{key:"size",get:function(){return new Vn(this.width,this.height)},set:function(t){this.width=t.width,this.height=t.height}},{key:"z",get:function(){return this.width},set:function(t){this.width=t}},{key:"w",get:function(){return this.height},set:function(t){this.height=t}}]),e}(Ae));function zn(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),new Un(t,e,i,n)}pi.fastDefine("cc.Rect",Un,{x:0,y:0,width:0,height:0}),v.Rect=Un,v.rect=zn;var Hn=t("bs",Float64Array),Wn=t("bt",function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.createFloatArray=function(t){return new Hn(t)},n(e,[{key:"array",get:function(){return this._array}}]),e}(Ae)),jn=Object.freeze({__proto__:null,bits:x,Vec2:Ln,v2:Nn,Vec3:on,v3:an,Vec4:tn,v4:en,Quat:Sn,quat:xn,Mat3:mn,Mat4:In,mat4:On,AffineTransform:kn,Size:Vn,size:Gn,Rect:Un,rect:zn,Color:dn,color:fn,preTransforms:Rn,HALF_PI:Ai,TWO_PI:bi,EPSILON:Ei,equals:Ci,approx:wi,clamp:xi,clamp01:Ri,lerp:Ii,toRadian:Bi,toDegree:Di,random:Pi,setRandGenerator:Oi,randomRange:Mi,randomRangeInt:Li,pseudoRandom:Ni,pseudoRandomRange:Fi,pseudoRandomRangeInt:ki,nextPow2:Vi,repeat:Gi,pingPong:Ui,inverseLerp:zi,absMaxComponent:Hi,absMax:Wi,enumerableProps:ji,floatToHalf:Qi,halfToFloat:Zi,MATH_FLOAT_ARRAY:Hn,MathBase:Wn});t("aF",jn);var Xn=new on,qn=new on,Yn=new on,Kn=new on,Jn=new on,Qn=new on,Zn=new Array(3),$n=new Array(3);function tr(t,e){return on.dot(e.n,t)-e.d}function er(t,e,i){return on.copy(t,e),on.subtract(Jn,i.center,i.halfExtents),on.add(Qn,i.center,i.halfExtents),t.x=t.x<Jn.x?Jn.x:t.x,t.y=t.y<Jn.y?Jn.y:t.y,t.z=t.z<Jn.z?Jn.z:t.z,t.x=t.x>Qn.x?Qn.x:t.x,t.y=t.y>Qn.y?Qn.y:t.y,t.z=t.z>Qn.z?Qn.z:t.z,t}function ir(t,e,i){on.set(Xn,i.orientation.m00,i.orientation.m01,i.orientation.m02),on.set(qn,i.orientation.m03,i.orientation.m04,i.orientation.m05),on.set(Yn,i.orientation.m06,i.orientation.m07,i.orientation.m08),Zn[0]=Xn,Zn[1]=qn,Zn[2]=Yn,$n[0]=i.halfExtents.x,$n[1]=i.halfExtents.y,$n[2]=i.halfExtents.z,on.subtract(Kn,e,i.center),on.set(t,i.center.x,i.center.y,i.center.z);for(var n=0;n<3;n++){var r=on.dot(Kn,Zn[n]);r>$n[n]&&(r=$n[n]),r<-$n[n]&&(r=-$n[n]),t.x+=r*Zn[n].x,t.y+=r*Zn[n].y,t.z+=r*Zn[n].z}return t}var nr=Object.freeze({__proto__:null,point_plane:tr,pt_point_plane:function(t,e,i){var n=tr(e,i);return on.subtract(t,e,on.multiplyScalar(t,i.n,n))},pt_point_aabb:er,pt_point_obb:ir,pt_point_line:function(t,e,i,n){on.subtract(Xn,i,n);var r=Xn.clone(),s=on.lengthSqr(r);if(0===s)on.copy(t,i);else{on.subtract(Xn,e,i);var o=on.dot(Xn,r)/s;o<0?on.copy(t,i):o>1?on.copy(t,n):on.scaleAndAdd(t,i,r,o)}}}),rr={SHAPE_RAY:1,SHAPE_LINE:2,SHAPE_SPHERE:4,SHAPE_AABB:8,SHAPE_OBB:16,SHAPE_PLANE:32,SHAPE_TRIANGLE:64,SHAPE_FRUSTUM:128,SHAPE_FRUSTUM_ACCURATE:256,SHAPE_CAPSULE:512,SHAPE_SPLINE:1024},sr=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=-1),this.s=void 0,this.e=void 0,this._type=void 0,this._type=rr.SHAPE_LINE,this.s=new on(t,e,i),this.e=new on(n,r,s)}return t.create=function(e,i,n,r,s,o){return new t(e,i,n,r,s,o)},t.clone=function(e){return new t(e.s.x,e.s.y,e.s.z,e.e.x,e.e.y,e.e.z)},t.copy=function(t,e){return on.copy(t.s,e.s),on.copy(t.e,e.e),t},t.fromPoints=function(t,e,i){return on.copy(t.s,e),on.copy(t.e,i),t},t.set=function(t,e,i,n,r,s,o){return t.s.x=e,t.s.y=i,t.s.z=n,t.e.x=r,t.e.y=s,t.e.z=o,t},t.len=function(t){return on.distance(t.s,t.e)},t.prototype.length=function(){return on.distance(this.s,this.e)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),or=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=-1),this.o=void 0,this.d=void 0,this._type=void 0,this._type=rr.SHAPE_RAY,this.o=new on(t,e,i),this.d=new on(n,r,s)}return t.create=function(e,i,n,r,s,o){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=1),new t(e,i,n,r,s,o)},t.clone=function(e){return new t(e.o.x,e.o.y,e.o.z,e.d.x,e.d.y,e.d.z)},t.copy=function(t,e){return on.copy(t.o,e.o),on.copy(t.d,e.d),t},t.fromPoints=function(t,e,i){return on.copy(t.o,e),on.normalize(t.d,on.subtract(t.d,i,e)),t},t.set=function(t,e,i,n,r,s,o){return t.o.x=e,t.o.y=i,t.o.z=n,t.d.x=r,t.d.y=s,t.d.z=o,t},t.prototype.computeHit=function(t,e){on.normalize(t,this.d),on.scaleAndAdd(t,this.o,t,e)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),ar=new on,hr=new on,ur=new on,lr=new on;function cr(t){return Math.max(Math.max(t.x,t.y),t.z)}var _r,dr,fr,pr,mr,gr=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),this._center=new on(0,0,0),this._radius=0,this._type=void 0,this._type=rr.SHAPE_SPHERE,this._center=new on(t,e,i),this._radius=n}t.create=function(e,i,n,r){return new t(e,i,n,r)},t.clone=function(e){return new t(e.center.x,e.center.y,e.center.z,e.radius)},t.copy=function(t,e){return on.copy(t.center,e.center),t.radius=e.radius,t},t.fromPoints=function(t,e,i){return on.multiplyScalar(t.center,on.add(ar,e,i),.5),t.radius=.5*on.subtract(ar,i,e).length(),t},t.set=function(t,e,i,n,r){return t.center.x=e,t.center.y=i,t.center.z=n,t.radius=r,t};var e=t.prototype;return e.destroy=function(){},e.clone=function(){return t.clone(this)},e.copy=function(e){return t.copy(this,e)},e.getBoundary=function(t,e){on.set(t,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),on.set(e,this.center.x+this.radius,this.center.y+this.radius,this.center.z+this.radius)},e.transform=function(t,e,i,n,r){on.transformMat4(r.center,this.center,t),r.radius=this.radius*cr(n)},e.translateAndRotate=function(t,e,i){on.transformMat4(i.center,this.center,t)},e.setScale=function(t,e){e.radius=this.radius*cr(t)},e.mergePoint=function(t){this.radius<0&&(this.center.set(t),this.radius=0),on.subtract(hr,t,this.center);var e=hr.length();if(e>this.radius){var i=.5*(e-this.radius);this.radius+=i,on.multiplyScalar(hr,hr,i/e),on.add(this.center,this.center,hr)}},e.mergePoints=function(t){var e=t.length;if(!(e<1)){this.radius=-1;for(var i=0;i<e;i++)this.mergePoint(t[i])}},e.mergeAABB=function(t){t.getBoundary(ur,lr),this.mergePoint(ur),this.mergePoint(lr)},n(t,[{key:"center",get:function(){return this._center},set:function(t){this._center=t}},{key:"radius",get:function(){return this._radius},set:function(t){this._radius=t}},{key:"type",get:function(){return this._type}}]),t}(),yr=function(t,e){var i=on.dot(t.d,e.n);if(Math.abs(i)<Number.EPSILON)return 0;var n=-tr(t.o,e)/i;return n<0?0:n},vr=(_r=new on(0,0,0),dr=new on(0,0,0),fr=new on(0,0,0),pr=new on(0,0,0),mr=new on(0,0,0),function(t,e,i){on.subtract(_r,e.b,e.a),on.subtract(dr,e.c,e.a),on.cross(fr,t.d,dr);var n=on.dot(_r,fr);if(n<Number.EPSILON&&(!i||n>-Number.EPSILON))return 0;var r=1/n;on.subtract(pr,t.o,e.a);var s=on.dot(pr,fr)*r;if(s<0||s>1)return 0;on.cross(mr,pr,_r);var o=on.dot(t.d,mr)*r;if(o<0||s+o>1)return 0;var a=on.dot(dr,mr)*r;return a<0?0:a}),Sr=function(){var t=new on(0,0,0);return function(e,i){var n=i.radius,r=i.center,s=e.o,o=e.d,a=n*n;on.subtract(t,r,s);var h=t.lengthSqr(),u=on.dot(t,o),l=a-(h-u*u);if(l<0)return 0;var c=Math.sqrt(l),_=h<a?u+c:u-c;return _<0?0:_}}(),Tr=function(){var t=new on,e=new on;return function(i,n){return on.subtract(t,n.center,n.halfExtents),on.add(e,n.center,n.halfExtents),function(t,e,i){var n=t.o,r=t.d,s=1/r.x,o=1/r.y,a=1/r.z,h=(e.x-n.x)*s,u=(i.x-n.x)*s,l=(e.y-n.y)*o,c=(i.y-n.y)*o,_=(e.z-n.z)*a,d=(i.z-n.z)*a,f=Math.max(Math.max(Math.min(h,u),Math.min(l,c)),Math.min(_,d)),p=Math.min(Math.min(Math.max(h,u),Math.max(l,c)),Math.max(_,d));return p<0||f>p?0:f>0?f:p}(i,t,e)}}(),Ar=function(){var t=new on,e=new on,i=new on,n=new on,r=new on,s=new on,o=new on,a=new Array(3),h=new Array(3),u=new Array(3),l=new Array(6);return function(c,_){a[0]=_.halfExtents.x,a[1]=_.halfExtents.y,a[2]=_.halfExtents.z,t=_.center,e=c.o,i=c.d,on.set(n,_.orientation.m00,_.orientation.m01,_.orientation.m02),on.set(r,_.orientation.m03,_.orientation.m04,_.orientation.m05),on.set(s,_.orientation.m06,_.orientation.m07,_.orientation.m08),on.subtract(o,t,e),h[0]=on.dot(n,i),h[1]=on.dot(r,i),h[2]=on.dot(s,i),u[0]=on.dot(n,o),u[1]=on.dot(r,o),u[2]=on.dot(s,o);for(var d=0;d<3;++d){if(0===h[d]){if(-u[d]-a[d]>0||-u[d]+a[d]<0)return 0;h[d]=1e-7}l[2*d+0]=(u[d]+a[d])/h[d],l[2*d+1]=(u[d]-a[d])/h[d]}var f=Math.max(Math.max(Math.min(l[0],l[1]),Math.min(l[2],l[3])),Math.min(l[4],l[5])),p=Math.min(Math.min(Math.max(l[0],l[1]),Math.max(l[2],l[3])),Math.max(l[4],l[5]));return p<0||f>p?0:f>0?f:p}}(),br=function(){var t=new on,e=new on,i=new on,n=new on,r=new on,s=new on,o=new on,a=new gr;return function(h,u){var l=u.ellipseCenter0,c=u.ellipseCenter1,_=on.subtract(e,c,l);if(_.length()<Ei)return a.radius=u.radius,a.center.set(u.ellipseCenter0),as.raySphere(h,a);var d=h.o,f=on.subtract(i,d,l),p=on.normalize(t,h.d),m=on.cross(n,p,_),g=m.lengthSqr();if(0===g){a.radius=u.radius;var y=on.subtract(r,c,d);return f.lengthSqr()<y.lengthSqr()?a.center.set(l):a.center.set(c),as.raySphere(h,a)}var v=on.cross(r,f,_),S=_.lengthSqr(),T=2*on.dot(m,v),A=u.radius*u.radius,b=T*T-4*g*(v.lengthSqr()-A*S);if(b<0)return 0;var E=(-T-Math.sqrt(b))/(2*g);if(E<0){a.radius=u.radius;var C=on.subtract(s,c,d);return f.lengthSqr()<C.lengthSqr()?a.center.set(u.ellipseCenter0):a.center.set(u.ellipseCenter1),as.raySphere(h,a)}var w=on.scaleAndAdd(s,h.o,p,E),x=on.subtract(o,w,l),R=on.dot(x,_)/S;return R>=0&&R<=1?E:R<0?(a.radius=u.radius,a.center.set(u.ellipseCenter0),as.raySphere(h,a)):R>1?(a.radius=u.radius,a.center.set(u.ellipseCenter1),as.raySphere(h,a)):0}}(),Er=function(){var t=new on(0,0,0);return function(e,i){on.subtract(t,e.e,e.s);var n=-tr(e.s,i)/on.dot(t,i.n);return n<0||n>1?0:n}}(),Cr=function(){var t=new on(0,0,0),e=new on(0,0,0),i=new on(0,0,0),n=new on(0,0,0),r=new on(0,0,0),s=new on(0,0,0);return function(o,a,h){on.subtract(t,a.b,a.a),on.subtract(e,a.c,a.a),on.subtract(i,o.s,o.e),on.cross(r,t,e);var u=on.dot(i,r);if(u<=0)return 0;on.subtract(n,o.s,a.a);var l=on.dot(n,r);if(l<0||l>u)return 0;on.cross(s,i,n);var c=on.dot(e,s);if(c<0||c>u)return 0;var _=-on.dot(t,s);if(_<0||c+_>u)return 0;if(h){var d=1/u,f=1-(c*=d)-(_*=d);on.set(h,a.a.x*f+a.b.x*c+a.c.x*_,a.a.y*f+a.b.y*c+a.c.y*_,a.a.z*f+a.b.z*c+a.c.z*_)}return 1}}(),wr=new or;function Rr(t,e){wr.o.set(t.s),on.subtract(wr.d,t.e,t.s),wr.d.normalize();var i=Tr(wr,e);return i<=t.length()?i:0}function Ir(t,e){wr.o.set(t.s),on.subtract(wr.d,t.e,t.s),wr.d.normalize();var i=Ar(wr,e);return i<=t.length()?i:0}function Br(t,e){wr.o.set(t.s),on.subtract(wr.d,t.e,t.s),wr.d.normalize();var i=Sr(wr,e);return i<=t.length()?i:0}var Dr,Pr,Or,Mr,Lr=(Dr=new on,Pr=new on,Or=new on,Mr=new on,function(t,e){return on.subtract(Dr,t.center,t.halfExtents),on.add(Pr,t.center,t.halfExtents),on.subtract(Or,e.center,e.halfExtents),on.add(Mr,e.center,e.halfExtents),Dr.x<=Mr.x&&Pr.x>=Or.x&&Dr.y<=Mr.y&&Pr.y>=Or.y&&Dr.z<=Mr.z&&Pr.z>=Or.z});function Nr(t,e,i,n,r,s){on.set(s[0],t.x+i.x*e.x+n.x*e.y+r.x*e.z,t.y+i.y*e.x+n.y*e.y+r.y*e.z,t.z+i.z*e.x+n.z*e.y+r.z*e.z),on.set(s[1],t.x-i.x*e.x+n.x*e.y+r.x*e.z,t.y-i.y*e.x+n.y*e.y+r.y*e.z,t.z-i.z*e.x+n.z*e.y+r.z*e.z),on.set(s[2],t.x+i.x*e.x-n.x*e.y+r.x*e.z,t.y+i.y*e.x-n.y*e.y+r.y*e.z,t.z+i.z*e.x-n.z*e.y+r.z*e.z),on.set(s[3],t.x+i.x*e.x+n.x*e.y-r.x*e.z,t.y+i.y*e.x+n.y*e.y-r.y*e.z,t.z+i.z*e.x+n.z*e.y-r.z*e.z),on.set(s[4],t.x-i.x*e.x-n.x*e.y-r.x*e.z,t.y-i.y*e.x-n.y*e.y-r.y*e.z,t.z-i.z*e.x-n.z*e.y-r.z*e.z),on.set(s[5],t.x+i.x*e.x-n.x*e.y-r.x*e.z,t.y+i.y*e.x-n.y*e.y-r.y*e.z,t.z+i.z*e.x-n.z*e.y-r.z*e.z),on.set(s[6],t.x-i.x*e.x+n.x*e.y-r.x*e.z,t.y-i.y*e.x+n.y*e.y-r.y*e.z,t.z-i.z*e.x+n.z*e.y-r.z*e.z),on.set(s[7],t.x-i.x*e.x-n.x*e.y+r.x*e.z,t.y-i.y*e.x-n.y*e.y+r.y*e.z,t.z-i.z*e.x-n.z*e.y+r.z*e.z)}function Fr(t,e){for(var i=on.dot(e,t[0]),n=i,r=1;r<8;++r){var s=on.dot(e,t[r]);i=s<i?s:i,n=s>n?s:n}return[i,n]}var kr,Vr,Gr,Ur,zr,Hr=function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=new on(0,0,0);for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=new on(0,0,0),n[r]=new on(0,0,0);var s=new on,o=new on;return function(e,r){on.set(t[0],1,0,0),on.set(t[1],0,1,0),on.set(t[2],0,0,1),on.set(t[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),on.set(t[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),on.set(t[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var a=0;a<3;++a)on.cross(t[6+3*a],t[a],t[3]),on.cross(t[7+3*a],t[a],t[4]),on.cross(t[7+3*a],t[a],t[5]);on.subtract(s,e.center,e.halfExtents),on.add(o,e.center,e.halfExtents),function(t,e,i){on.set(i[0],t.x,e.y,e.z),on.set(i[1],t.x,e.y,t.z),on.set(i[2],t.x,t.y,e.z),on.set(i[3],t.x,t.y,t.z),on.set(i[4],e.x,e.y,e.z),on.set(i[5],e.x,e.y,t.z),on.set(i[6],e.x,t.y,e.z),on.set(i[7],e.x,t.y,t.z)}(s,o,i),Nr(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var h=0;h<15;++h){var u=Fr(i,t[h]),l=Fr(n,t[h]);if(l[0]>u[1]||u[0]>l[1])return 0}return 1}}(),Wr=function(t,e){var i=t.halfExtents.x*Math.abs(e.n.x)+t.halfExtents.y*Math.abs(e.n.y)+t.halfExtents.z*Math.abs(e.n.z),n=on.dot(e.n,t.center);return n+i<e.d?-1:n-i>e.d?0:1},jr=function(t,e){for(var i=0;i<e.planes.length;i++)if(-1===Wr(t,e.planes[i]))return 0;return 1},Xr=function(){for(var t=new Array(8),e=0,i=0,n=0;n<t.length;n++)t[n]=new on(0,0,0);return function(n,r){for(var s=0,o=!1,a=0;a<r.planes.length;a++){if(-1===(s=Wr(n,r.planes[a])))return 0;1===s&&(o=!0)}if(!o)return 1;for(var h=0;h<r.vertices.length;h++)on.subtract(t[h],r.vertices[h],n.center);e=0,i=0;for(var u=0;u<r.vertices.length;u++)t[u].x>n.halfExtents.x?e++:t[u].x<-n.halfExtents.x&&i++;if(e===r.vertices.length||i===r.vertices.length)return 0;e=0,i=0;for(var l=0;l<r.vertices.length;l++)t[l].y>n.halfExtents.y?e++:t[l].y<-n.halfExtents.y&&i++;if(e===r.vertices.length||i===r.vertices.length)return 0;e=0,i=0;for(var c=0;c<r.vertices.length;c++)t[c].z>n.halfExtents.z?e++:t[c].z<-n.halfExtents.z&&i++;return e===r.vertices.length||i===r.vertices.length?0:1}}(),qr=(kr=new on(0,0,0),Vr=new mn,function(t,e){return on.subtract(kr,e,t.center),on.transformMat3(kr,kr,mn.transpose(Vr,t.orientation)),i=kr,n=t.halfExtents,Math.abs(i.x)<n.x&&Math.abs(i.y)<n.y&&Math.abs(i.z)<n.z;var i,n}),Yr=(Gr=function(t,e,i,n){return Math.abs(t.x*e+t.y*i+t.z*n)},function(t,e){var i=t.halfExtents.x*Gr(e.n,t.orientation.m00,t.orientation.m01,t.orientation.m02)+t.halfExtents.y*Gr(e.n,t.orientation.m03,t.orientation.m04,t.orientation.m05)+t.halfExtents.z*Gr(e.n,t.orientation.m06,t.orientation.m07,t.orientation.m08),n=on.dot(e.n,t.center);return n+i<e.d?-1:n-i>e.d?0:1}),Kr=function(t,e){for(var i=0;i<e.planes.length;i++)if(-1===Yr(t,e.planes[i]))return 0;return 1},Jr=function(){for(var t=new Array(8),e=0,i=0,n=0,r=0;r<t.length;r++)t[r]=new on(0,0,0);var s=function(t,e,i,n){return t.x*e+t.y*i+t.z*n};return function(r,o){for(var a=0,h=!1,u=0;u<o.planes.length;u++){if(-1===(a=Yr(r,o.planes[u])))return 0;1===a&&(h=!0)}if(!h)return 1;for(var l=0;l<o.vertices.length;l++)on.subtract(t[l],o.vertices[l],r.center);i=0,n=0;for(var c=0;c<o.vertices.length;c++)(e=s(t[c],r.orientation.m00,r.orientation.m01,r.orientation.m02))>r.halfExtents.x?i++:e<-r.halfExtents.x&&n++;if(i===o.vertices.length||n===o.vertices.length)return 0;i=0,n=0;for(var _=0;_<o.vertices.length;_++)(e=s(t[_],r.orientation.m03,r.orientation.m04,r.orientation.m05))>r.halfExtents.y?i++:e<-r.halfExtents.y&&n++;if(i===o.vertices.length||n===o.vertices.length)return 0;i=0,n=0;for(var d=0;d<o.vertices.length;d++)(e=s(t[d],r.orientation.m06,r.orientation.m07,r.orientation.m08))>r.halfExtents.z?i++:e<-r.halfExtents.z&&n++;return i===o.vertices.length||n===o.vertices.length?0:1}}(),Qr=function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=new on(0,0,0);for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=new on(0,0,0),n[r]=new on(0,0,0);return function(e,r){on.set(t[0],e.orientation.m00,e.orientation.m01,e.orientation.m02),on.set(t[1],e.orientation.m03,e.orientation.m04,e.orientation.m05),on.set(t[2],e.orientation.m06,e.orientation.m07,e.orientation.m08),on.set(t[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),on.set(t[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),on.set(t[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var s=0;s<3;++s)on.cross(t[6+3*s],t[s],t[3]),on.cross(t[7+3*s],t[s],t[4]),on.cross(t[8+3*s],t[s],t[5]);Nr(e.center,e.halfExtents,t[0],t[1],t[2],i),Nr(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var o=0;o<15;++o){var a=Fr(i,t[o]),h=Fr(n,t[o]);if(h[0]>a[1]||a[0]>h[1])return 0}return 1}}(),Zr=function(){for(var t=new gr,e=new on,i=new on,n=new on,r=new Array(8),s=0;s<8;s++)r[s]=new on;for(var o=new Array(8),a=0;a<8;a++)o[a]=new on;return function(s,a){if(0===on.squaredDistance(a.ellipseCenter0,a.ellipseCenter1))return t.radius=a.radius,t.center.set(a.ellipseCenter0),as.sphereOBB(t,s);e.x=s.orientation.m00,e.y=s.orientation.m01,e.z=s.orientation.m02,i.x=s.orientation.m03,i.y=s.orientation.m04,i.z=s.orientation.m05,n.x=s.orientation.m06,n.y=s.orientation.m07,n.z=s.orientation.m08,Nr(s.center,s.halfExtents,e,i,n,r);var h=o,u=on.copy(h[0],e),l=on.copy(h[1],i),c=on.copy(h[2],n);on.subtract(h[3],a.center,s.center).normalize();var _=on.subtract(h[4],a.ellipseCenter0,a.ellipseCenter1);_.normalize(),on.cross(h[5],u,_),on.cross(h[6],l,_),on.cross(h[7],c,_);for(var d=0;d<8;++d){var f=Fr(r,h[d]),p=on.dot(h[d],a.ellipseCenter0),m=on.dot(h[d],a.ellipseCenter1),g=Math.max(p,m),y=Math.min(p,m)-a.radius,v=g+a.radius;if(y>f[1]||f[0]>v)return 0}return 1}}(),$r=function(t,e){var i=on.dot(e.n,t.center),n=t.radius*e.n.length();return i+n<e.d?-1:i-n>e.d?0:1},ts=function(t,e){for(var i=0;i<e.planes.length;i++)if(-1===$r(t,e.planes[i]))return 0;return 1},es=(Ur=new on(0,0,0),zr=[1,-1,1,-1,1,-1],function(t,e){for(var i=0;i<6;i++){var n=e.planes[i],r=t.radius,s=t.center,o=n.n,a=n.d,h=on.dot(o,s);if(h+r<a)return 0;if(!(h-r>a)){on.add(Ur,s,on.multiplyScalar(Ur,o,r));for(var u=0;u<6;u++)if(u!==i&&u!==i+zr[i]){var l=e.planes[u];if(on.dot(l.n,Ur)<l.d)return 0}}}return 1}),is=function(t,e){var i=t.radius+e.radius;return on.squaredDistance(t.center,e.center)<i*i},ns=function(){var t=new on;return function(e,i){return er(t,e.center,i),on.squaredDistance(e.center,t)<e.radius*e.radius}}(),rs=function(){var t=new on;return function(e,i){return ir(t,e.center,i),on.squaredDistance(e.center,t)<e.radius*e.radius}}(),ss=function(){var t=new on,e=new on;return function(i,n){var r=i.radius+n.radius,s=r*r,o=on.squaredDistance(n.ellipseCenter0,n.ellipseCenter1);if(0===o)return on.squaredDistance(i.center,n.center)<s;on.subtract(t,i.center,n.ellipseCenter0),on.subtract(e,n.ellipseCenter1,n.ellipseCenter0);var a=on.dot(t,e)/o;return a<0?on.squaredDistance(i.center,n.ellipseCenter0)<s:a>1?on.squaredDistance(i.center,n.ellipseCenter1)<s:(on.scaleAndAdd(t,n.ellipseCenter0,e,a),on.squaredDistance(i.center,t)<s)}}(),os=function(){var t=new on,e=new on,i=new on,n=new on,r=new on,s=new on;return function(o,a){var h,u,l=on.subtract(t,o.ellipseCenter1,o.ellipseCenter0),c=on.subtract(e,a.ellipseCenter1,a.ellipseCenter0),_=on.subtract(i,o.ellipseCenter0,a.ellipseCenter0),d=on.dot(l,l),f=on.dot(l,c),p=on.dot(c,c),m=on.dot(l,_),g=on.dot(c,_),y=d*p-f*f,v=y,S=y;y<Ei?(h=0,v=1,u=g,S=p):(u=d*g-f*m,(h=f*g-p*m)<0?(h=0,u=g,S=p):h>v&&(h=v,u=g+f,S=p)),u<0?(u=0,-m<0?h=0:-m>d?h=v:(h=-m,v=d)):u>S&&(u=S,-m+f<0?h=0:-m+f>d?h=v:(h=-m+f,v=d));var T=Math.abs(h)<Ei?0:h/v,A=Math.abs(u)<Ei?0:u/S,b=n;b.set(_),b.add(on.multiplyScalar(r,l,T)),b.subtract(on.multiplyScalar(s,c,A));var E=o.radius+a.radius;return b.lengthSqr()<E*E}}(),as={raySphere:Sr,rayAABB:Tr,rayOBB:Ar,rayPlane:yr,rayTriangle:vr,rayCapsule:br,raySubMesh:null,rayMesh:null,rayModel:null,lineSphere:Br,lineAABB:Rr,lineOBB:Ir,linePlane:Er,lineTriangle:Cr,sphereWithSphere:is,sphereAABB:ns,sphereOBB:rs,spherePlane:$r,sphereFrustum:ts,sphereFrustumAccurate:es,sphereCapsule:ss,aabbWithAABB:Lr,aabbWithOBB:Hr,aabbPlane:Wr,aabbFrustum:jr,aabbFrustumAccurate:Xr,obbWithOBB:Qr,obbPlane:Yr,obbFrustum:Kr,obbFrustumAccurate:Jr,obbPoint:qr,obbCapsule:Zr,aabbFrustumCompletelyInside:function(t,e){for(var i=0;i<e.planes.length;i++)if(0!==Wr(t,e.planes[i]))return 0;return 1},capsuleWithCapsule:os,resolve:function(t,e,i){void 0===i&&(i=null);var n=t._type,r=e._type,s=this[n|r];return n<r?s(t,e,i):s(e,t,i)}};as[rr.SHAPE_RAY|rr.SHAPE_SPHERE]=Sr,as[rr.SHAPE_RAY|rr.SHAPE_AABB]=Tr,as[rr.SHAPE_RAY|rr.SHAPE_OBB]=Ar,as[rr.SHAPE_RAY|rr.SHAPE_PLANE]=yr,as[rr.SHAPE_RAY|rr.SHAPE_TRIANGLE]=vr,as[rr.SHAPE_RAY|rr.SHAPE_CAPSULE]=br,as[rr.SHAPE_LINE|rr.SHAPE_SPHERE]=Br,as[rr.SHAPE_LINE|rr.SHAPE_AABB]=Rr,as[rr.SHAPE_LINE|rr.SHAPE_OBB]=Ir,as[rr.SHAPE_LINE|rr.SHAPE_PLANE]=Er,as[rr.SHAPE_LINE|rr.SHAPE_TRIANGLE]=Cr,as[rr.SHAPE_SPHERE]=is,as[rr.SHAPE_SPHERE|rr.SHAPE_AABB]=ns,as[rr.SHAPE_SPHERE|rr.SHAPE_OBB]=rs,as[rr.SHAPE_SPHERE|rr.SHAPE_PLANE]=$r,as[rr.SHAPE_SPHERE|rr.SHAPE_FRUSTUM]=ts,as[rr.SHAPE_SPHERE|rr.SHAPE_FRUSTUM_ACCURATE]=es,as[rr.SHAPE_SPHERE|rr.SHAPE_CAPSULE]=ss,as[rr.SHAPE_AABB]=Lr,as[rr.SHAPE_AABB|rr.SHAPE_OBB]=Hr,as[rr.SHAPE_AABB|rr.SHAPE_PLANE]=Wr,as[rr.SHAPE_AABB|rr.SHAPE_FRUSTUM]=jr,as[rr.SHAPE_AABB|rr.SHAPE_FRUSTUM_ACCURATE]=Xr,as[rr.SHAPE_OBB]=Qr,as[rr.SHAPE_OBB|rr.SHAPE_PLANE]=Yr,as[rr.SHAPE_OBB|rr.SHAPE_FRUSTUM]=Kr,as[rr.SHAPE_OBB|rr.SHAPE_FRUSTUM_ACCURATE]=Jr,as[rr.SHAPE_OBB|rr.SHAPE_CAPSULE]=Zr,as[rr.SHAPE_CAPSULE]=os,nt(sr.prototype,"line",[{name:"mag",newName:"len"},{name:"magnitude",newName:"len"}]),rt(as,"intersect",[{name:"line_quad"}]);var hs=new on(0,0,0),us=new on(0,0,0),ls=v.mat4(),cs=v.v4(),_s=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=0),this.n=void 0,this._type=rr.SHAPE_PLANE,this.n=new on(t,e,i),this.d=n}return t.create=function(e,i,n,r){return new t(e,i,n,r)},t.clone=function(e){return new t(e.n.x,e.n.y,e.n.z,e.d)},t.copy=function(t,e){return on.copy(t.n,e.n),t.d=e.d,t},t.fromPoints=function(t,e,i,n){return on.subtract(hs,i,e),on.subtract(us,n,e),on.normalize(t.n,on.cross(t.n,hs,us)),t.d=on.dot(t.n,e),t},t.set=function(t,e,i,n,r){return t.n.x=e,t.n.y=i,t.n.z=n,t.d=r,t},t.fromNormalAndPoint=function(t,e,i){return on.copy(t.n,e),t.d=on.dot(e,i),t},t.normalize=function(t,e){var i=e.n.length();return on.normalize(t.n,e.n),i>0&&(t.d=e.d/i),t},t.prototype.transform=function(t){In.invert(ls,t),In.transpose(ls,ls),tn.set(cs,this.n.x,this.n.y,this.n.z,-this.d),tn.transformMat4(cs,cs,ls),on.set(this.n,cs.x,cs.y,cs.z),this.d=-cs.w},n(t,[{key:"type",get:function(){return this._type}},{key:"x",get:function(){return this.n.x},set:function(t){this.n.x=t}},{key:"y",get:function(){return this.n.y},set:function(t){this.n.y=t}},{key:"z",get:function(){return this.n.z},set:function(t){this.n.z=t}},{key:"w",get:function(){return this.d},set:function(t){this.d=t}}]),t}(),ds=function(){function t(t,e,i,n,r,s,o,a,h){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=1),void 0===h&&(h=0),this.a=void 0,this.b=void 0,this.c=void 0,this._type=void 0,this._type=rr.SHAPE_TRIANGLE,this.a=new on(t,e,i),this.b=new on(n,r,s),this.c=new on(o,a,h)}return t.create=function(e,i,n,r,s,o,a,h,u){return void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=1),new t(e,i,n,r,s,o,a,h,u)},t.clone=function(e){return new t(e.a.x,e.a.y,e.a.z,e.b.x,e.b.y,e.b.z,e.c.x,e.c.y,e.c.z)},t.copy=function(t,e){return on.copy(t.a,e.a),on.copy(t.b,e.b),on.copy(t.c,e.c),t},t.fromPoints=function(t,e,i,n){return on.copy(t.a,e),on.copy(t.b,i),on.copy(t.c,n),t},t.set=function(t,e,i,n,r,s,o,a,h,u){return t.a.x=e,t.a.y=i,t.a.z=n,t.b.x=r,t.b.y=s,t.b.z=o,t.c.x=a,t.c.y=h,t.c.z=u,t},n(t,[{key:"type",get:function(){return this._type}}]),t}(),fs=new on,ps=new on,ms=new on,gs=new on,ys=new mn,vs=function(t,e,i){ys.m00=Math.abs(i.m00),ys.m01=Math.abs(i.m01),ys.m02=Math.abs(i.m02),ys.m03=Math.abs(i.m04),ys.m04=Math.abs(i.m05),ys.m05=Math.abs(i.m06),ys.m06=Math.abs(i.m08),ys.m07=Math.abs(i.m09),ys.m08=Math.abs(i.m10),on.transformMat3(t,e,ys)},Ss=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=1),void 0===s&&(s=1),this.center=void 0,this.halfExtents=void 0,this._type=void 0,this._type=rr.SHAPE_AABB,this.center=new on(t,e,i),this.halfExtents=new on(n,r,s)}t.create=function(e,i,n,r,s,o){return new t(e,i,n,r,s,o)},t.clone=function(e){return new t(e.center.x,e.center.y,e.center.z,e.halfExtents.x,e.halfExtents.y,e.halfExtents.z)},t.copy=function(t,e){return on.copy(t.center,e.center),on.copy(t.halfExtents,e.halfExtents),t},t.fromPoints=function(t,e,i){return on.add(fs,i,e),on.subtract(ps,i,e),on.multiplyScalar(t.center,fs,.5),on.multiplyScalar(t.halfExtents,ps,.5),t},t.set=function(t,e,i,n,r,s,o){return t.center.set(e,i,n),t.halfExtents.set(r,s,o),t},t.merge=function(e,i,n){return on.subtract(fs,i.center,i.halfExtents),on.subtract(ps,n.center,n.halfExtents),on.add(ms,i.center,i.halfExtents),on.add(gs,n.center,n.halfExtents),on.max(gs,ms,gs),on.min(ms,fs,ps),t.fromPoints(e,ms,gs)},t.toBoundingSphere=function(t,e){return t.center.set(e.center),t.radius=e.halfExtents.length(),t},t.transform=function(t,e,i){return on.transformMat4(t.center,e.center,i),vs(t.halfExtents,e.halfExtents,i),t};var e=t.prototype;return e.getBoundary=function(t,e){on.subtract(t,this.center,this.halfExtents),on.add(e,this.center,this.halfExtents)},e.transform=function(t,e,i,n,r){on.transformMat4(r.center,this.center,t),vs(r.halfExtents,this.halfExtents,t)},e.clone=function(){return t.clone(this)},e.copy=function(e){return t.copy(this,e)},e.mergePoint=function(t){this.getBoundary(fs,ps),t.x<fs.x&&(fs.x=t.x),t.y<fs.y&&(fs.y=t.y),t.z<fs.z&&(fs.z=t.z),t.x>ps.x&&(ps.x=t.x),t.y>ps.y&&(ps.y=t.y),t.z>ps.z&&(ps.z=t.z),on.add(ms,fs,ps),this.center.set(on.multiplyScalar(ms,ms,.5)),this.halfExtents.set(ps.x-ms.x,ps.y-ms.y,ps.z-ms.z)},e.mergePoints=function(t){if(!(t.length<1))for(var e=0;e<t.length;e++)this.mergePoint(t[e])},e.mergeFrustum=function(t){this.mergePoints(t.vertices)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),Ts=function(){function t(t,e,i){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=1),this._type=void 0,this.radius=void 0,this.halfHeight=void 0,this.axis=void 0,this.center=void 0,this.rotation=void 0,this.ellipseCenter0=void 0,this.ellipseCenter1=void 0,this._type=rr.SHAPE_CAPSULE,this.radius=t,this.halfHeight=e,this.axis=i,this.center=new on,this.rotation=new Sn,this.ellipseCenter0=new on(0,e,0),this.ellipseCenter1=new on(0,-e,0),this.updateCache()}var e=t.prototype;return e.transform=function(t,e,i,n,r){var s=n,o=Hi(s);r.radius=this.radius*Math.abs(o);var a=(this.halfHeight+this.radius)*Math.abs(s.y)-r.radius;a<0&&(a=0),r.halfHeight=a,on.transformMat4(r.center,this.center,t),Sn.multiply(r.rotation,this.rotation,i),r.updateCache()},e.updateCache=function(){this.updateLocalCenter(),on.transformQuat(this.ellipseCenter0,this.ellipseCenter0,this.rotation),on.transformQuat(this.ellipseCenter1,this.ellipseCenter1,this.rotation),this.ellipseCenter0.add(this.center),this.ellipseCenter1.add(this.center)},e.updateLocalCenter=function(){var t=this.halfHeight;switch(this.axis){case 0:this.ellipseCenter0.set(t,0,0),this.ellipseCenter1.set(-t,0,0);break;case 1:this.ellipseCenter0.set(0,t,0),this.ellipseCenter1.set(0,-t,0);break;case 2:this.ellipseCenter0.set(0,0,t),this.ellipseCenter1.set(0,0,-t)}},n(t,[{key:"type",get:function(){return this._type}}]),t}(),As=new Array(8);As[0]=new on(1,1,1),As[1]=new on(-1,1,1),As[2]=new on(-1,-1,1),As[3]=new on(1,-1,1),As[4]=new on(1,1,-1),As[5]=new on(-1,1,-1),As[6]=new on(-1,-1,-1),As[7]=new on(1,-1,-1);var bs,Es=new on,Cs=new on,ws=new on,xs=function(){e.createOrthographic=function(t,e,i,n,r,s){var o=e/2,a=i/2;on.set(ws,o,a,-n),on.transformMat4(t.vertices[0],ws,s),on.set(ws,-o,a,-n),on.transformMat4(t.vertices[1],ws,s),on.set(ws,-o,-a,-n),on.transformMat4(t.vertices[2],ws,s),on.set(ws,o,-a,-n),on.transformMat4(t.vertices[3],ws,s),on.set(ws,o,a,-r),on.transformMat4(t.vertices[4],ws,s),on.set(ws,-o,a,-r),on.transformMat4(t.vertices[5],ws,s),on.set(ws,-o,-a,-r),on.transformMat4(t.vertices[6],ws,s),on.set(ws,o,-a,-r),on.transformMat4(t.vertices[7],ws,s),t.updatePlanes()},e.createOrtho=function(t,i,n,r,s,o){return e.createOrthographic(t,i,n,r,s,o)},e.createPerspective=function(t,e,i,n,r,s){var o=Math.tan(.5*i),a=o*e;Es.set(n*a,n*o,n),Cs.set(r*a,r*o,r);var h=t.vertices;ws.set(Es.x,Es.y,-Es.z),on.transformMat4(h[0],ws,s),ws.set(-Es.x,Es.y,-Es.z),on.transformMat4(h[1],ws,s),ws.set(-Es.x,-Es.y,-Es.z),on.transformMat4(h[2],ws,s),ws.set(Es.x,-Es.y,-Es.z),on.transformMat4(h[3],ws,s),ws.set(Cs.x,Cs.y,-Cs.z),on.transformMat4(h[4],ws,s),ws.set(-Cs.x,Cs.y,-Cs.z),on.transformMat4(h[5],ws,s),ws.set(-Cs.x,-Cs.y,-Cs.z),on.transformMat4(h[6],ws,s),ws.set(Cs.x,-Cs.y,-Cs.z),on.transformMat4(h[7],ws,s),t.updatePlanes()},e.createFromAABB=function(t,e){var i=new on,n=new on;return on.subtract(i,e.center,e.halfExtents),on.add(n,e.center,e.halfExtents),t.vertices[0].set(n.x,n.y,-i.z),t.vertices[1].set(i.x,n.y,-i.z),t.vertices[2].set(i.x,i.y,-i.z),t.vertices[3].set(n.x,i.y,-i.z),t.vertices[4].set(n.x,n.y,-n.z),t.vertices[5].set(i.x,n.y,-n.z),t.vertices[6].set(i.x,i.y,-n.z),t.vertices[7].set(n.x,i.y,-n.z),t.updatePlanes(),t};var t=e.prototype;function e(){this.planes=void 0,this.vertices=void 0,this._type=void 0,this._type=rr.SHAPE_FRUSTUM,this.planes=new Array(6);for(var t=0;t<6;++t)this.planes[t]=_s.create(0,0,0,0);this.vertices=new Array(8);for(var e=0;e<8;++e)this.vertices[e]=new on}return t.split=function(t,i,n,r,s){return e.createPerspective(this,n,r,t,i,s)},e.create=function(){return new e},e.clone=function(t){return e.copy(new e,t)},e.copy=function(t,e){t._type=e.type;for(var i=0;i<6;++i)_s.copy(t.planes[i],e.planes[i]);for(var n=0;n<8;++n)on.copy(t.vertices[n],e.vertices[n]);return t},t.update=function(t,e){on.set(this.planes[0].n,t.m03+t.m00,t.m07+t.m04,t.m11+t.m08),this.planes[0].d=-(t.m15+t.m12),on.set(this.planes[1].n,t.m03-t.m00,t.m07-t.m04,t.m11-t.m08),this.planes[1].d=-(t.m15-t.m12),on.set(this.planes[2].n,t.m03+t.m01,t.m07+t.m05,t.m11+t.m09),this.planes[2].d=-(t.m15+t.m13),on.set(this.planes[3].n,t.m03-t.m01,t.m07-t.m05,t.m11-t.m09),this.planes[3].d=-(t.m15-t.m13),on.set(this.planes[4].n,t.m03+t.m02,t.m07+t.m06,t.m11+t.m10),this.planes[4].d=-(t.m15+t.m14),on.set(this.planes[5].n,t.m03-t.m02,t.m07-t.m06,t.m11-t.m10),this.planes[5].d=-(t.m15-t.m14);for(var i=0;i<6;i++){var n=this.planes[i],r=1/n.n.length();on.multiplyScalar(n.n,n.n,r),n.d*=r}for(var s=0;s<8;s++)on.transformMat4(this.vertices[s],As[s],e)},t.transform=function(t){for(var e=0;e<8;e++)on.transformMat4(this.vertices[e],this.vertices[e],t);this.updatePlanes()},t.zero=function(){for(var t=0;t<8;t++)this.vertices[t].set(0,0,0);for(var e=0;e<6;e++)_s.set(this.planes[e],0,0,0,0)},t.updatePlanes=function(){_s.fromPoints(this.planes[0],this.vertices[1],this.vertices[6],this.vertices[5]),_s.fromPoints(this.planes[1],this.vertices[3],this.vertices[4],this.vertices[7]),_s.fromPoints(this.planes[2],this.vertices[6],this.vertices[3],this.vertices[7]),_s.fromPoints(this.planes[3],this.vertices[0],this.vertices[5],this.vertices[4]),_s.fromPoints(this.planes[4],this.vertices[2],this.vertices[0],this.vertices[3]),_s.fromPoints(this.planes[5],this.vertices[7],this.vertices[5],this.vertices[6])},n(e,[{key:"accurate",set:function(t){this._type=t?rr.SHAPE_FRUSTUM_ACCURATE:rr.SHAPE_FRUSTUM}},{key:"type",get:function(){return this._type}}]),e}(),Rs=new on,Is=new on,Bs=new mn,Ds=function(){function t(t,e,i,n,r,s,o,a,h,u,l,c,_,d,f){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=1),void 0===s&&(s=1),void 0===o&&(o=1),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=0),void 0===l&&(l=1),void 0===c&&(c=0),void 0===_&&(_=0),void 0===d&&(d=0),void 0===f&&(f=1),this.center=void 0,this.halfExtents=void 0,this.orientation=void 0,this._type=void 0,this._type=rr.SHAPE_OBB,this.center=new on(t,e,i),this.halfExtents=new on(n,r,s),this.orientation=new mn(o,a,h,u,l,c,_,d,f)}t.create=function(e,i,n,r,s,o,a,h,u,l,c,_,d,f,p){return new t(e,i,n,r,s,o,a,h,u,l,c,_,d,f,p)},t.clone=function(e){return new t(e.center.x,e.center.y,e.center.z,e.halfExtents.x,e.halfExtents.y,e.halfExtents.z,e.orientation.m00,e.orientation.m01,e.orientation.m02,e.orientation.m03,e.orientation.m04,e.orientation.m05,e.orientation.m06,e.orientation.m07,e.orientation.m08)},t.copy=function(t,e){return on.copy(t.center,e.center),on.copy(t.halfExtents,e.halfExtents),mn.copy(t.orientation,e.orientation),t},t.fromPoints=function(t,e,i){return on.multiplyScalar(t.center,on.add(Rs,e,i),.5),on.multiplyScalar(t.halfExtents,on.subtract(Is,i,e),.5),mn.identity(t.orientation),t},t.set=function(t,e,i,n,r,s,o,a,h,u,l,c,_,d,f,p){return on.set(t.center,e,i,n),on.set(t.halfExtents,r,s,o),mn.set(t.orientation,a,h,u,l,c,_,d,f,p),t};var e=t.prototype;return e.getBoundary=function(t,e){!function(t,e,i){Bs.m00=Math.abs(i.m00),Bs.m01=Math.abs(i.m01),Bs.m02=Math.abs(i.m02),Bs.m03=Math.abs(i.m03),Bs.m04=Math.abs(i.m04),Bs.m05=Math.abs(i.m05),Bs.m06=Math.abs(i.m06),Bs.m07=Math.abs(i.m07),Bs.m08=Math.abs(i.m08),on.transformMat3(t,e,Bs)}(Rs,this.halfExtents,this.orientation),on.subtract(t,this.center,Rs),on.add(e,this.center,Rs)},e.transform=function(t,e,i,n,r){on.transformMat4(r.center,this.center,t),mn.fromQuat(r.orientation,i),on.multiply(r.halfExtents,this.halfExtents,n)},e.translateAndRotate=function(t,e,i){on.transformMat4(i.center,this.center,t),mn.fromQuat(i.orientation,e)},e.setScale=function(t,e){on.multiply(e.halfExtents,this.halfExtents,t)},n(t,[{key:"type",get:function(){return this._type}}]),t}();function Ps(t,e,i){void 0===i&&(i=1e-6);for(var n=0,r=t.length-1,s=r>>>1;n<=r;s=n+r>>>1){var o=t[s];if(o>e+i)r=s-1;else{if(!(o<e-i))return s;n=s+1}}return~n}bs=Symbol.iterator;var Os,Ms,Ls,Ns=function(){function t(){this._times=[],this._values=[]}var e=t.prototype;return e[bs]=function(){var t=this,e=0;return{next:function(){if(e>=t._times.length)return{done:!0,value:void 0};var i=[t._times[e],t._values[e]];return++e,{done:!1,value:i}}}},e.keyframes=function(){return this},e.times=function(){return this._times},e.values=function(){return this._values},e.getKeyframeTime=function(t){return this._times[t]},e.getKeyframeValue=function(t){return this._values[t]},e.addKeyFrame=function(t,e){return this._insertNewKeyframe(t,e)},e.removeKeyframe=function(t){this._times.splice(t,1),this._values.splice(t,1)},e.indexOfKeyframe=function(t){return Ps(this._times,t)},e.updateTime=function(t,e){var i=this._values[t];this.removeKeyframe(t),this._insertNewKeyframe(e,i)},e.assignSorted=function(t,e){if(void 0!==e)this.setKeyframes(t.slice(),e.slice());else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return t[1]})))}},e.clear=function(){this._times.length=0,this._values.length=0},e.searchKeyframe=function(t){return Ps(this._times,t)},e.setKeyframes=function(t,e){t.length,e.length,function(t){t.every((function(t,e,i){return 0===e||t>i[e-1]||wi(t,i[e-1],1e-6)}))}(t),this._times=t,this._values=e},e._insertNewKeyframe=function(t,e){var i=this._times,n=this._values,r=i.length,s=Ps(i,t);if(s>=0)return s;var o=~s;return 0===o?(i.unshift(t),n.unshift(e)):o===r?(i.push(t),n.push(e)):(i.splice(o-1,0,t),n.splice(o-1,0,e)),o},n(t,[{key:"keyFramesCount",get:function(){return this._times.length}},{key:"rangeMin",get:function(){return this._times[0]}},{key:"rangeMax",get:function(){return this._times[this._values.length-1]}}]),t}();function Fs(t){return t>-1e-9&&t<1e-9}function ks(t,e,i,n){return i.slice().reverse().reduce((function(i,n){return n(t,e,i)||i}),n)}pi.fastDefine("cc.KeyframeCurve",Ns,{_times:[],_values:[]}),t("cm",Os),function(t){t[t.LINEAR=0]="LINEAR",t[t.CONSTANT=1]="CONSTANT",t[t.CUBIC=2]="CUBIC"}(Os||t("cm",Os={})),t("cn",Ms),function(t){t[t.LINEAR=0]="LINEAR",t[t.CLAMP=1]="CLAMP",t[t.LOOP=2]="LOOP",t[t.PING_PONG=3]="PING_PONG"}(Ms||t("cn",Ms={})),t("co",Ls),function(t){t[t.NONE=0]="NONE",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.BOTH=3]="BOTH"}(Ls||t("co",Ls={}));var Vs=function(){},Gs=function(){return Vs},Us=zs((function(){}));function zs(t){return function(e){return"function"==typeof e?t(e):function(i){return t(i,e)}}}function Hs(t){return function(e){return function(i){!function(t,e,i){var n=js(t);if(n){var r=Xs(n,"proto");Xs(r,"editor")[e]=i}}(i,t,e)}}}var Ws="__ccclassCache__";function js(t){return Xs(t,Ws)}function Xs(t,e){return t[e]||(t[e]={})}var qs=zs((function(t,e){var i=zt(t);i===Object&&(i=null);var n={name:e,extends:i,ctor:t},r=t[Ws];if(r){var s=r.proto;s&&Gt(n,s),t[Ws]=void 0}return pi(n)})),Ys=Hs("requireComponent"),Ks=Hs("executionOrder"),Js=Us;function Qs(t,e,i){var n=null;function r(t,e,i){!function(t,e,i,n,r,s){var o,a=s&&"function"!=typeof s&&(s.get||s.set);r&&(o=ni(r,a));var h=Gt(e,o||r||{});a?(s.get&&(h.get=s.get),s.set&&(h.set=s.set)):to(t,h,i,n,s)}(function(t){return js(t.constructor)}(t),function(t,e){var i,n,r=Xs(js(t.constructor),"proto"),s=Xs(r,"properties");return null!==(n=s[i=e])&&void 0!==n?n:s[i]={}}(t,e),t.constructor,e,n,i)}return void 0===t?Qs({type:void 0}):void 0===e?(n=t,r):void r(t,e,i)}function Zs(t){var e;try{e=t()}catch(e){return t}return"object"!=typeof e||null===e?e:t}function $s(t,e,i){var n,r,s=js(t.constructor),o=Xs(s,"proto"),a=Xs(o,"properties"),h=null!==(r=a[n=e])&&void 0!==r?r:a[n]={};return h.__internalFlags|=ri.STANDALONE,i&&"function"!=typeof i&&(i.get||i.set)?(i.get&&(h.get=i.get),i.set&&(h.set=i.set)):to(s,h,t.constructor,e,i),h}function to(t,e,i,n,r){if(void 0!==r)"function"==typeof r?e.default=Zs(r):null===r||r.initializer&&(e.default=Zs(r.initializer));else{var s=t.default||(t.default=function(t){var e;try{e=new t}catch(t){return{}}return e}(i));s.hasOwnProperty(n)&&(e.default=s[n])}}var eo=Symbol("cc:SerializationMetadata"),io=t("cO",(function(t,e,i){so($s(t,e,i))}));function no(t){return function(e,i,n){var r=$s(e,i,n);r.formerlySerializedAs=t,so(r)}}var ro=function(t,e,i){var n=$s(t,e,i);n.editorOnly=!0,so(n)};function so(t){t.__internalFlags|=ri.IMPLICIT_SERIALIZABLE}var oo=Vs,ao=Us,ho=Gs,uo=Us,lo=Gs,co=Gs,_o=Gs,fo=t("cD",Vs),po=t("cF",Gs),mo=t("cG",Gs),go=t("cE",Gs),yo=t("cI",Gs),vo=t("cJ",Gs),So=t("cK",Vs),To=t("cH",Gs),Ao=t("cL",Vs),bo=xo(qe),Eo=xo(Ye),Co=xo(Ke),wo=xo(Je);function xo(t){return Qs({type:t})}var Ro=t("cM",(function(t,e,i){$s(t,e,i).override=!0})),Io=t("bX","__editorExtras__"),Bo=t("b$",(function(){})),Do=Object.freeze({__proto__:null,uniquelyReferenced:oo,ccclass:qs,property:Qs,requireComponent:Ys,executionOrder:Ks,disallowMultiple:Js,executeInEditMode:ao,menu:ho,playOnFocus:uo,inspector:lo,icon:co,help:_o,type:xo,integer:bo,float:Eo,boolean:Co,string:wo,editable:fo,tooltip:go,visible:po,displayName:mo,displayOrder:To,range:yo,rangeStep:vo,slide:So,disallowAnimation:Ao,override:Ro,formerlySerializedAs:no,serializable:io});t("bO",Do);var Po,Oo,Mo,Lo,No,Fo,ko,Vo,Go,Uo,zo=[],Ho=t("bR",function(){function t(t){void 0===t&&(t=""),this._objFlags=void 0,this._name=void 0,this._name=t,this._objFlags=0}t._deferredDestroy=function(){for(var t=zo.length,e=0;e<t;++e){var i=zo[e];1&i._objFlags||i._destroyImmediate()}t===zo.length?zo.length=0:zo.splice(0,t)};var e=t.prototype;return e.destroy=function(){return 1&this._objFlags?(Y(5e3),!1):!(4&this._objFlags||(this._objFlags|=4,zo.push(this),0))},e._destruct=function(){var t=this.constructor,e=t.__destruct__;e||(e=function(t,e){var i,n=t instanceof v.Node||t instanceof v.Component,r=n?"_id":null,s={};for(i in t)if(t.hasOwnProperty(i)){if(i===r)continue;switch(typeof t[i]){case"string":s[i]="";break;case"object":case"function":s[i]=null}}if(pi._isCCClass(e))for(var o=v.Class.Attr.getClassAttrs(e),a=e.__props__,h=0;h<a.length;h++){var u=""+(i=a[h]);if(u in o){if(n&&"_id"===i)continue;switch(typeof o[u]){case"string":s[i]="";break;case"object":case"function":s[i]=null;break;case"undefined":s[i]=void 0}}}var l="";for(i in s){var c;c=pi.IDENTIFIER_RE.test(i)?"o."+i+"=":"o["+pi.escapeForJS(i)+"]=";var _=s[i];""===_&&(_='""'),l+=c+_+";\n"}return Function("o",l)}(this,t),Ct(t,"__destruct__",e,!0)),e(this)},e._destroyImmediate=function(){var t;1&this._objFlags?J(5e3):(null===(t=this._onPreDestroy)||void 0===t||t.call(this),this._destruct(),this._objFlags|=1)},n(t,[{key:"name",get:function(){return this._name},set:function(t){this._name=t}},{key:"hideFlags",get:function(){return this._objFlags&t.Flags.AllHideMasks},set:function(e){var i=e&t.Flags.AllHideMasks;this._objFlags=this._objFlags&~t.Flags.AllHideMasks|i}},{key:"isValid",get:function(){return!(1&this._objFlags)}}]),t}());function Wo(t){return t instanceof Ho}function jo(t,e){return"object"==typeof t?!(!t||t._objFlags&(e?5:1)):void 0!==t}function Xo(t,e){return(e<<3)+t}function qo(t){return Ko[t]}function Yo(t){switch(t){case Go.Uint8:return Uint8Array;case Go.Uint16:return Uint16Array;case Go.Uint32:return Uint32Array;case Go.Int8:return Int8Array;case Go.Int16:return Int16Array;case Go.Int32:return Int32Array;case Go.Float32:return Float32Array;case Go.Float64:return Float64Array}}Ho.prototype._deserialize=null,pi.fastDefine("cc.Object",Ho,{_name:"",_objFlags:0}),Ct(Ho,"Flags",{Destroyed:1,DontSave:8,EditorOnly:16,Dirty:32,DontDestroy:64,PersistentMask:-4192741,Destroying:128,Deactivating:256,LockedInEditor:512,HideInHierarchy:1024,AllHideMasks:1560,IsPreloadStarted:8192,IsOnLoadStarted:32768,IsOnLoadCalled:16384,IsOnEnableCalled:2048,IsStartCalled:65536,IsEditorOnEnableCalled:4096,IsPositionLocked:1<<21,IsRotationLocked:1<<17,IsScaleLocked:1<<18,IsAnchorLocked:1<<19,IsSizeLocked:1<<20}),v.isValid=jo,v.Object=Ho,function(t){t[t.Uint8=0]="Uint8",t[t.Uint16=1]="Uint16",t[t.Uint32=2]="Uint32",t[t.Int8=3]="Int8",t[t.Int16=4]="Int16",t[t.Int32=5]="Int32",t[t.Float32=6]="Float32",t[t.Float64=7]="Float64"}(Go||(Go={})),function(t){t[t.Scalar=0]="Scalar",t[t.Vec2=1]="Vec2",t[t.Vec3=2]="Vec3",t[t.Vec4=3]="Vec4",t[t.Quat=4]="Quat",t[t.Mat4=5]="Mat4"}(Uo||(Uo={})),t("bW",qs("cc.CompactValueTypeArray")(((ko=function(){function t(){this._byteOffset=Mo&&Mo(),this._unitCount=Lo&&Lo(),this._unitElement=No&&No(),this._length=Fo&&Fo()}return t.lengthFor=function(t,e,i){return qo(e).requiredUnits*t.length*Yo(i).BYTES_PER_ELEMENT},t.compress=function(e,i,n,r,s,o){for(var a=qo(i),h=Yo(n),u=a.requiredUnits*e.length,l=new h(r,s,u),c=0;c<e.length;++c)a.compress(l,c,e[c]);var _=new t;return _._unitElement=Xo(n,i),_._byteOffset=o,_._unitCount=u,_._length=e.length,_},t.prototype.decompress=function(t){for(var e,i={storageUnit:7&(e=this._unitElement),elementType:e>>3},n=i.storageUnit,r=qo(i.elementType),s=new(Yo(n))(t,this._byteOffset,this._unitCount),o=new Array(this._length),a=0;a<this._length;++a)o[a]=r.decompress(s,a);return o},t}()).StorageUnit=Go,ko.ElementType=Uo,Mo=ks((Oo=ko).prototype,"_byteOffset",[io],(function(){return 0})),Lo=ks(Oo.prototype,"_unitCount",[io],(function(){return 0})),No=ks(Oo.prototype,"_unitElement",[io],(function(){return Xo(Go.Uint8,Uo.Scalar)})),Fo=ks(Oo.prototype,"_length",[io],(function(){return 0})),Po=Oo))||Po);var Ko=((Vo={})[Uo.Scalar]={requiredUnits:1,compress:function(t,e,i){t[e]=i},decompress:function(t,e){return t[e]}},Vo[Uo.Vec2]={requiredUnits:2,compress:function(t,e,i){t[2*e]=i.x,t[2*e+1]=i.y},decompress:function(t,e){return new on(t[2*e],t[2*e+1])}},Vo[Uo.Vec3]={requiredUnits:3,compress:function(t,e,i){t[3*e]=i.x,t[3*e+1]=i.y,t[3*e+2]=i.z},decompress:function(t,e){return new on(t[3*e],t[3*e+1],t[3*e+2])}},Vo[Uo.Vec4]={requiredUnits:4,compress:function(t,e,i){t[4*e]=i.x,t[4*e+1]=i.y,t[4*e+2]=i.z,t[4*e+3]=i.w},decompress:function(t,e){return new tn(t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}},Vo[Uo.Quat]={requiredUnits:4,compress:function(t,e,i){t[4*e]=i.x,t[4*e+1]=i.y,t[4*e+2]=i.z,t[4*e+3]=i.w},decompress:function(t,e){return new Sn(t[4*e],t[4*e+1],t[4*e+2],t[4*e+3])}},Vo[Uo.Mat4]={requiredUnits:16,compress:function(t,e,i){In.toArray(t,i,16*e)},decompress:function(t,e){return In.fromArray(new In,t,16*e)}},Vo),Jo=t("bZ",Symbol("[[Serialize]]")),Qo=t("bY",Symbol("[[Deserialize]]"));function Zo(){return 0}function $o(t){return t}function ta(t){return t*t}function ea(t){return t*(2-t)}function ia(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}function na(t){return t*t*t}function ra(t){return--t*t*t+1}function sa(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}function oa(t){return t*t*t*t}function aa(t){return 1- --t*t*t*t}function ha(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}function ua(t){return t*t*t*t*t}function la(t){return--t*t*t*t*t+1}function ca(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}function _a(t){return 1===t?1:1-Math.cos(t*Math.PI/2)}function da(t){return Math.sin(t*Math.PI/2)}function fa(t){return.5*(1-Math.cos(Math.PI*t))}function pa(t){return 0===t?0:Math.pow(1024,t-1)}function ma(t){return 1===t?1:1-Math.pow(2,-10*t)}function ga(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}function ya(t){return 1-Math.sqrt(1-t*t)}function va(t){return Math.sqrt(1- --t*t)}function Sa(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}function Ta(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),-i*Math.pow(2,10*(t-=1))*Math.sin(2*(t-e)*Math.PI/.4))}function Aa(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*t)*Math.sin(2*(t-e)*Math.PI/.4)+1)}function ba(t){var e,i=.1;return 0===t?0:1===t?1:(!i||i<1?(i=1,e=.1):e=.4*Math.asin(1/i)/(2*Math.PI),(t*=2)<1?i*Math.pow(2,10*(t-=1))*Math.sin(2*(t-e)*Math.PI/.4)*-.5:i*Math.pow(2,-10*(t-=1))*Math.sin(2*(t-e)*Math.PI/.4)*.5+1)}function Ea(t){if(1===t)return 1;var e=1.70158;return t*t*((e+1)*t-e)}function Ca(t){if(0===t)return 0;var e=1.70158;return--t*t*((e+1)*t+e)+1}function wa(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}function xa(t){return 1-Ra(1-t)}function Ra(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Ia(t){return t<.5?.5*xa(2*t):.5*Ra(2*t-1)+.5}function Ba(t){return t<=0?0:t>=1?1:t*t*(3-2*t)}function Da(t){return t<=0?0:t>=1?1:t*t*t*(t*(6*t-15)+10)}v._decorator=Do;var Pa=za(ta,ea),Oa=za(na,ra),Ma=za(oa,aa),La=za(ua,la),Na=za(_a,da),Fa=za(pa,ma),ka=za(ya,va),Va=za(Ta,Aa),Ga=za(Ea,Ca),Ua=za(xa,Ra);function za(t,e){return function(i){return i<.5?e(2*i)/2:t(2*i-1)/2+.5}}var Ha,Wa,ja=Object.freeze({__proto__:null,constant:Zo,linear:$o,quadIn:ta,quadOut:ea,quadInOut:ia,cubicIn:na,cubicOut:ra,cubicInOut:sa,quartIn:oa,quartOut:aa,quartInOut:ha,quintIn:ua,quintOut:la,quintInOut:ca,sineIn:_a,sineOut:da,sineInOut:fa,expoIn:pa,expoOut:ma,expoInOut:ga,circIn:ya,circOut:va,circInOut:Sa,elasticIn:Ta,elasticOut:Aa,elasticInOut:ba,backIn:Ea,backOut:Ca,backInOut:wa,bounceIn:xa,bounceOut:Ra,bounceInOut:Ia,smooth:Ba,fade:Da,quadOutIn:Pa,cubicOutIn:Oa,quartOutIn:Ma,quintOutIn:La,sineOutIn:Na,expoOutIn:Fa,circOutIn:ka,elasticOutIn:Va,backOutIn:Ga,bounceOutIn:Ua});t("cy",ja),t("cY",Wa),function(t){t[t.LINEAR=0]="LINEAR",t[t.CONSTANT=1]="CONSTANT",t[t.QUAD_IN=2]="QUAD_IN",t[t.QUAD_OUT=3]="QUAD_OUT",t[t.QUAD_IN_OUT=4]="QUAD_IN_OUT",t[t.QUAD_OUT_IN=5]="QUAD_OUT_IN",t[t.CUBIC_IN=6]="CUBIC_IN",t[t.CUBIC_OUT=7]="CUBIC_OUT",t[t.CUBIC_IN_OUT=8]="CUBIC_IN_OUT",t[t.CUBIC_OUT_IN=9]="CUBIC_OUT_IN",t[t.QUART_IN=10]="QUART_IN",t[t.QUART_OUT=11]="QUART_OUT",t[t.QUART_IN_OUT=12]="QUART_IN_OUT",t[t.QUART_OUT_IN=13]="QUART_OUT_IN",t[t.QUINT_IN=14]="QUINT_IN",t[t.QUINT_OUT=15]="QUINT_OUT",t[t.QUINT_IN_OUT=16]="QUINT_IN_OUT",t[t.QUINT_OUT_IN=17]="QUINT_OUT_IN",t[t.SINE_IN=18]="SINE_IN",t[t.SINE_OUT=19]="SINE_OUT",t[t.SINE_IN_OUT=20]="SINE_IN_OUT",t[t.SINE_OUT_IN=21]="SINE_OUT_IN",t[t.EXPO_IN=22]="EXPO_IN",t[t.EXPO_OUT=23]="EXPO_OUT",t[t.EXPO_IN_OUT=24]="EXPO_IN_OUT",t[t.EXPO_OUT_IN=25]="EXPO_OUT_IN",t[t.CIRC_IN=26]="CIRC_IN",t[t.CIRC_OUT=27]="CIRC_OUT",t[t.CIRC_IN_OUT=28]="CIRC_IN_OUT",t[t.CIRC_OUT_IN=29]="CIRC_OUT_IN",t[t.ELASTIC_IN=30]="ELASTIC_IN",t[t.ELASTIC_OUT=31]="ELASTIC_OUT",t[t.ELASTIC_IN_OUT=32]="ELASTIC_IN_OUT",t[t.ELASTIC_OUT_IN=33]="ELASTIC_OUT_IN",t[t.BACK_IN=34]="BACK_IN",t[t.BACK_OUT=35]="BACK_OUT",t[t.BACK_IN_OUT=36]="BACK_IN_OUT",t[t.BACK_OUT_IN=37]="BACK_OUT_IN",t[t.BOUNCE_IN=38]="BOUNCE_IN",t[t.BOUNCE_OUT=39]="BOUNCE_OUT",t[t.BOUNCE_IN_OUT=40]="BOUNCE_IN_OUT",t[t.BOUNCE_OUT_IN=41]="BOUNCE_OUT_IN",t[t.SMOOTH=42]="SMOOTH",t[t.FADE=43]="FADE"}(Wa||t("cY",Wa={}));var Xa,qa=((Ha={})[Wa.CONSTANT]=Zo,Ha[Wa.LINEAR]=$o,Ha[Wa.QUAD_IN]=ta,Ha[Wa.QUAD_OUT]=ea,Ha[Wa.QUAD_IN_OUT]=ia,Ha[Wa.QUAD_OUT_IN]=Pa,Ha[Wa.CUBIC_IN]=na,Ha[Wa.CUBIC_OUT]=ra,Ha[Wa.CUBIC_IN_OUT]=sa,Ha[Wa.CUBIC_OUT_IN]=Oa,Ha[Wa.QUART_IN]=oa,Ha[Wa.QUART_OUT]=aa,Ha[Wa.QUART_IN_OUT]=ha,Ha[Wa.QUART_OUT_IN]=Ma,Ha[Wa.QUINT_IN]=ua,Ha[Wa.QUINT_OUT]=la,Ha[Wa.QUINT_IN_OUT]=ca,Ha[Wa.QUINT_OUT_IN]=La,Ha[Wa.SINE_IN]=_a,Ha[Wa.SINE_OUT]=da,Ha[Wa.SINE_IN_OUT]=fa,Ha[Wa.SINE_OUT_IN]=Na,Ha[Wa.EXPO_IN]=pa,Ha[Wa.EXPO_OUT]=ma,Ha[Wa.EXPO_IN_OUT]=ga,Ha[Wa.EXPO_OUT_IN]=Fa,Ha[Wa.CIRC_IN]=ya,Ha[Wa.CIRC_OUT]=va,Ha[Wa.CIRC_IN_OUT]=Sa,Ha[Wa.CIRC_OUT_IN]=ka,Ha[Wa.ELASTIC_IN]=Ta,Ha[Wa.ELASTIC_OUT]=Aa,Ha[Wa.ELASTIC_IN_OUT]=ba,Ha[Wa.ELASTIC_OUT_IN]=Va,Ha[Wa.BACK_IN]=Ea,Ha[Wa.BACK_OUT]=Ca,Ha[Wa.BACK_IN_OUT]=wa,Ha[Wa.BACK_OUT_IN]=Ga,Ha[Wa.BOUNCE_IN]=xa,Ha[Wa.BOUNCE_OUT]=Ra,Ha[Wa.BOUNCE_IN_OUT]=Ia,Ha[Wa.BOUNCE_OUT_IN]=Ua,Ha[Wa.SMOOTH]=Ba,Ha[Wa.FADE]=Da,Ha);function Ya(t){return qa[t]}b(255),b(65280);var Ka,Ja,Qa,Za=Os.LINEAR<<0|Ls.NONE<<8|Wa.LINEAR<<16,$a=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).value=0,e.rightTangent=0,e.rightTangentWeight=0,e.leftTangent=0,e.leftTangentWeight=0,e._flags=Za,e}return s(e,t),n(e,[{key:"interpolationMode",get:function(){return(255&this._flags)>>0},set:function(t){this._flags&=-256,this._flags|=t<<0}},{key:"tangentWeightMode",get:function(){return(65280&this._flags)>>8},set:function(t){this._flags&=-65281,this._flags|=t<<8}},{key:"easingMethod",get:function(){return(16711680&this._flags)>>16},set:function(t){this._flags&=-16711681,this._flags|=t<<16}}]),e}(Bo);function th(t){var e=new $a;if("number"==typeof t)e.value=t;else{var i=t.interpolationMode,n=t.tangentWeightMode,r=t.value,s=t.rightTangent,o=t.rightTangentWeight,a=t.leftTangent,h=t.leftTangentWeight,u=t.easingMethod,l=t[Io];e.value=null!=r?r:e.value,e.rightTangent=null!=s?s:e.rightTangent,e.rightTangentWeight=null!=o?o:e.rightTangentWeight,e.leftTangent=null!=a?a:e.leftTangent,e.leftTangentWeight=null!=h?h:e.leftTangentWeight,e.interpolationMode=null!=i?i:e.interpolationMode,e.tangentWeightMode=null!=n?n:e.tangentWeightMode,e.easingMethod=null!=u?u:e.easingMethod,l&&(e[Io]=l)}return e}pi.fastDefine("cc.RealKeyframeValue",$a,((Xa={interpolationMode:Os.LINEAR,tangentWeightMode:Ls.NONE,value:0,rightTangent:0,rightTangentWeight:0,leftTangent:0,leftTangentWeight:0,easingMethod:Wa.LINEAR})[Io]=void 0,Xa)),pi.Attr.setClassAttr($a,Io,"editorOnly",!0),(Ka=$a,null!==(Qa=(Ja=Ka)[eo])&&void 0!==Qa?Qa:Ja[eo]={}).uniquelyReferenced=!0;var eh,ih=t("cl",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).preExtrapolation=Ms.CLAMP,e.postExtrapolation=Ms.CLAMP,e}s(e,t);var i=e.prototype;return i.evaluate=function(t){var e=this._times,i=this._values,n=e.length;if(0===n)return 0;var r=e[0],s=e[n-1];if(t<r){var o=this.preExtrapolation,a=i[0];if(o===Ms.CLAMP||n<2)return a.value;switch(o){case Ms.LINEAR:return yh(r,i[0].value,e[1],i[1].value,t);case Ms.LOOP:t=mh(t,r,s);break;case Ms.PING_PONG:t=gh(t,r,s);break;default:return a.value}}else if(t>s){var h=this.postExtrapolation,u=i[n-1];if(h===Ms.CLAMP||n<2)return u.value;switch(h){case Ms.LINEAR:return yh(s,u.value,e[n-2],i[n-2].value,t);case Ms.LOOP:t=mh(t,r,s);break;case Ms.PING_PONG:t=gh(t,r,s);break;default:return u.value}}var l=Ps(e,t);if(l>=0)return i[l].value;var c=~l,_=c-1,d=e[_],f=i[_],p=e[c];return function(t,e,i,n,r){var s=i-t;switch(e.interpolationMode){default:case Os.CONSTANT:return e.value;case Os.LINEAR:var o=e.easingMethod===Wa.LINEAR?r:Ya(e.easingMethod)(r);return Ii(e.value,n.value,o);case Os.CUBIC:var a=1/3,h=e.rightTangent,u=e.rightTangentWeight,l=0!=(e.tangentWeightMode&Ls.RIGHT),c=n.leftTangent,_=n.leftTangentWeight,d=0!=(n.tangentWeightMode&Ls.LEFT);if(l||d){var f=0;if(l)f=u;else{var p=s,m=s*h;f=Math.sqrt(p*p+m*m)*a}var g=Math.atan(h),y=Math.cos(g)*f+t,v=Math.sin(g)*f+e.value,S=0;if(d)S=_;else{var T=s,A=s*c;S=Math.sqrt(T*T+A*A)*a}var b=Math.atan(c),E=(y-t)/s,C=(-Math.cos(b)*S+i-t)/s,w=v,x=-Math.sin(b)*S+n.value,R=[0,0,0],I=function(t,e,i,n,r){var s=i/n,o=e/n,a=s*s,h=1/3*(-1/3*a+o),u=.5*(2/27*s*a-1/3*s*o+t/n),l=h*h*h,c=u*u+l,_=0;if(Fs(c)){if(Fs(u))return r[0]=0,1;var d=Math.cbrt(-u);return r[0]=2*d,r[1]=-d,2}if(c<0){var f=1/3*Math.acos(-u/Math.sqrt(-l)),p=2*Math.sqrt(-h);r[0]=p*Math.cos(f),r[1]=-p*Math.cos(f+Math.PI/3),r[2]=-p*Math.cos(f-Math.PI/3),_=3}else{var m=Math.sqrt(c),g=Math.cbrt(m-u),y=-Math.cbrt(m+u);r[0]=g+y,_=1}for(var v=1/3*s,S=0;S<_;++S)r[S]-=v;return _}(0-r,3*E,3*C-6*E,3*(E-C)+1,R),B=function(t,e,i){var n=i;if(1===e)n=t[0];else{n=-1/0;for(var r=0;r<e;++r){var s=t[r];s>=0&&s<=1&&s>n&&(n=s)}n===-1/0&&(n=0)}return n}(R,I,r);return vh(e.value,w,x,n.value,B)}var D=e.value+a*h*s,P=n.value-a*c*s;return vh(e.value,D,P,n.value,r)}}(d,f,p,i[c],(t-d)/(p-d))},i.addKeyFrame=function(e,i){return t.prototype.addKeyFrame.call(this,e,th(i))},i.assignSorted=function(t,e){if(void 0!==e)this.setKeyframes(t.slice(),e.map((function(t){return th(t)})));else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return th(t[1])})))}},i.isConstant=function(t){if(this._values.length<=1)return!0;var e=this._values[0].value;return this._values.every((function(i){return wi(i.value,e,t)}))},i[Jo]=function(t,e){if(e.toCCON){var i=this._times,n=this._values,r=i.length,s=new DataView(new ArrayBuffer(0+nh+nh+rh+sh*r+dh*r)),o=0;s.setUint8(o,this.preExtrapolation),o+=nh,s.setUint8(o,this.postExtrapolation),o+=nh,s.setUint32(o,r,!0),o+=rh,i.forEach((function(t,e){return s.setFloat32(o+sh*e,t,!0)})),o+=sh*r;for(var a,h=d(n);!(a=h()).done;){var u=a.value;o=fh(s,u,o)}var l=new Uint8Array(s.buffer,0,o);t.writeProperty("bytes",l);var c=n.map((function(t){return t[Io]}));c.some((function(t){return void 0!==t}))&&t.writeProperty("keyframeValueEditorExtras",c)}else t.writeThis()},i[Qo]=function(t,e){if(e.fromCCON){var i=t.readProperty("bytes"),n=new DataView(i.buffer,i.byteOffset,i.byteLength),r=0;this.preExtrapolation=n.getUint8(r),r+=nh,this.postExtrapolation=n.getUint8(r),r+=nh;var s=n.getUint32(r,!0);r+=rh;var o=Array.from({length:s},(function(t,e){return n.getFloat32(r+sh*e,!0)}));r+=sh*s;for(var a=new Array(s),h=0;h<s;++h){var u=th({});r=ph(n,u,r),a[h]=u}i.byteLength;var l=t.readProperty("keyframeValueEditorExtras");l&&(l.length,l.forEach((function(t,e){return a[e][Io]=t}))),this._times=o,this._values=a}else t.readThis()},e}(Ns));pi.fastDefine("cc.RealCurve",ih,{_times:[],_values:[],preExtrapolation:Ms.CLAMP,postExtrapolation:Ms.CLAMP}),function(t){t[t.VALUE=1]="VALUE",t[t.INTERPOLATION_MODE=2]="INTERPOLATION_MODE",t[t.TANGENT_WEIGHT_MODE=4]="TANGENT_WEIGHT_MODE",t[t.LEFT_TANGENT=8]="LEFT_TANGENT",t[t.LEFT_TANGENT_WEIGHT=16]="LEFT_TANGENT_WEIGHT",t[t.RIGHT_TANGENT=32]="RIGHT_TANGENT",t[t.RIGHT_TANGENT_WEIGHT=64]="RIGHT_TANGENT_WEIGHT"}(eh||(eh={}));var nh=1,rh=4,sh=4,oh=th({}),ah=oh.interpolationMode,hh=oh.tangentWeightMode,uh=oh.leftTangent,lh=oh.leftTangentWeight,ch=oh.rightTangent,_h=oh.rightTangentWeight,dh=26;function fh(t,e,i){var n=0,r=i,s=r;r+=4;var o=e.value,a=e.interpolationMode,h=e.tangentWeightMode,u=e.rightTangent,l=e.rightTangentWeight,c=e.leftTangent,_=e.leftTangentWeight,d=e.easingMethod;return t.setFloat32(r,o,!0),r+=4,a!==ah&&(n|=eh.INTERPOLATION_MODE,t.setUint8(r,a),r+=1),h!==hh&&(n|=eh.TANGENT_WEIGHT_MODE,t.setUint8(r,h),r+=1),c!==uh&&(n|=eh.LEFT_TANGENT,t.setFloat32(r,c,!0),r+=4),_!==lh&&(n|=eh.LEFT_TANGENT_WEIGHT,t.setFloat32(r,_,!0),r+=4),u!==ch&&(n|=eh.RIGHT_TANGENT,t.setFloat32(r,u,!0),r+=4),l!==_h&&(n|=eh.RIGHT_TANGENT_WEIGHT,t.setFloat32(r,l,!0),r+=4),n|=d<<8,t.setUint32(s,n,!0),r}function ph(t,e,i){var n=i,r=t.getUint32(n,!0);n+=4,e.value=t.getFloat32(n,!0),n+=4,r&eh.INTERPOLATION_MODE&&(e.interpolationMode=t.getUint8(n),n+=1),r&eh.TANGENT_WEIGHT_MODE&&(e.tangentWeightMode=t.getUint8(n),n+=1),r&eh.LEFT_TANGENT&&(e.leftTangent=t.getFloat32(n,!0),n+=4),r&eh.LEFT_TANGENT_WEIGHT&&(e.leftTangentWeight=t.getFloat32(n,!0),n+=4),r&eh.RIGHT_TANGENT&&(e.rightTangent=t.getFloat32(n,!0),n+=4),r&eh.RIGHT_TANGENT_WEIGHT&&(e.rightTangentWeight=t.getFloat32(n,!0),n+=4);var s=(65280&r)>>8;return e.easingMethod=s,n}function mh(t,e,i){return e+Gi(t-e,i-e)}function gh(t,e,i){return e+Ui(t-e,i-e)}function yh(t,e,i,n,r){return e+(n-e)/(i-t)*(r-t)}function vh(t,e,i,n,r){var s=1-r;return s*s*s*t+3*s*s*r*e+3*s*r*r*i+r*r*r*n}function Sh(t,e,i,n,r){var s=1-r;return s*(s*(t+(3*e-t)*r)+3*i*r*r)+n*r*r*r}v.bezier=Sh;var Th,Ah,bh,Eh,Ch,wh,xh,Rh,Ih,Bh,Dh=Math.cos,Ph=Math.acos,Oh=Math.max,Mh=2*Math.PI,Lh=Math.sqrt;function Nh(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}function Fh(t,e){var i=function(t,e){var i,n,r,s,o=e-0,a=e-t[0],h=3*o,u=3*a,l=3*(e-t[2]),c=1/(-o+u-l+(e-1)),_=1/3,d=(h-6*a+l)*c,f=d*_,p=(-h+u)*c,m=(3*p-d*d)*_,g=m*_,y=(2*d*d*d-9*d*p+o*c*27)/27,v=y/2,S=v*v+g*g*g;if(S<0){var T=-m*_,A=Lh(T*T*T),b=-y/(2*A),E=Ph(b<-1?-1:b>1?1:b),C=2*Nh(A);return n=C*Dh(E*_)-f,r=C*Dh((E+Mh)*_)-f,s=C*Dh((E+2*Mh)*_)-f,n>=0&&n<=1?r>=0&&r<=1?s>=0&&s<=1?Oh(n,r,s):Oh(n,r):s>=0&&s<=1?Oh(n,s):n:r>=0&&r<=1?s>=0&&s<=1?Oh(r,s):r:s}if(0===S)return r=-(i=v<0?Nh(-v):-Nh(v))-f,(n=2*i-f)>=0&&n<=1?r>=0&&r<=1?Oh(n,r):n:r;var w=Lh(S);return(i=Nh(-v+w))-Nh(v+w)-f}(t,e),n=t[1];return((1-i)*(n+(t[3]-n)*i)*3+i*i)*i}v.bezierByTime=Fh,t("cq",Bh),function(t){t[t.SLERP=0]="SLERP",t[t.CONSTANT=1]="CONSTANT"}(Bh||t("cq",Bh={}));var kh=qs("cc.QuatKeyframeValue")(Th=oo((Ah=function(t){var e=void 0===t?{}:t,i=e.value,n=e.interpolationMode,r=e.easingMethod;this.interpolationMode=bh&&bh(),this.value=Eh&&Eh(),this.easingMethod=Ch&&Ch(),this.value=i?Sn.clone(i):this.value,this.interpolationMode=null!=n?n:this.interpolationMode,this.easingMethod=null!=r?r:this.easingMethod},bh=ks(Ah.prototype,"interpolationMode",[io],(function(){return Bh.SLERP})),Eh=ks(Ah.prototype,"value",[io],(function(){return Sn.clone(Sn.IDENTITY)})),Ch=ks(Ah.prototype,"easingMethod",[io],(function(){return Wa.LINEAR})),Th=Ah))||Th)||Th;function Vh(t){return new kh(t)}var Gh,Uh=t("cp",qs("cc.QuatCurve")((xh=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).preExtrapolation=Rh&&Rh(),e.postExtrapolation=Ih&&Ih(),e}s(e,t);var i=e.prototype;return i.evaluate=function(t,e){var i;null!==(i=e)&&void 0!==i||(e=new Sn);var n=this._times,r=this._values,s=this.postExtrapolation,o=this.preExtrapolation,a=n.length;if(0===a)return e;var h=n[0],u=n[a-1];if(t<h){var l=r[0];switch(o){case Ms.LOOP:t=h+Gi(t-h,u-h);break;case Ms.PING_PONG:t=h+Ui(t-h,u-h);break;case Ms.CLAMP:default:return Sn.copy(e,l.value)}}else if(t>u){var c=r[a-1];switch(s){case Ms.LOOP:t=h+Gi(t-h,u-h);break;case Ms.PING_PONG:t=h+Ui(t-h,u-h);break;case Ms.CLAMP:default:return Sn.copy(e,c.value)}}var _=Ps(n,t);if(_>=0)return Sn.copy(e,r[_].value);var d=~_,f=d-1,p=n[f],m=r[f],g=n[d],y=r[d],v=(t-p)/(g-p);switch(m.interpolationMode){default:case Bh.CONSTANT:return Sn.copy(e,m.value);case Bh.SLERP:var S=m.easingMethod,T=S===Wa.LINEAR?v:Array.isArray(S)?Fh(S,v):Ya(S)(v);return Sn.slerp(e,m.value,y.value,T)}},i.addKeyFrame=function(e,i){var n=new kh(i);return t.prototype.addKeyFrame.call(this,e,n)},i.assignSorted=function(t,e){if(void 0!==e)this.setKeyframes(t.slice(),e.map((function(t){return Vh(t)})));else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return Vh(t[1])})))}},i[Jo]=function(t,e){if(e.toCCON){var i=this._times,n=this._values,r=!0;n.forEach((function(t,e,i){var n=i[0];r&&t.interpolationMode!==n.interpolationMode&&(r=!1)}));var s=i.length,o=qh*(r?1:s),a=n.reduce((function(t,e){var i=e.easingMethod;return t+(Array.isArray(i)?Yh+4*Jh:Yh)}),0),h=0,u=new DataView(new ArrayBuffer(h+=Hh+Wh+jh*s+4*Xh*s+a+o+0)),l=0,c=0;r&&(c|=Gh.INTERPOLATION_MODE),u.setUint32(l,c,!0),l+=Hh,u.setUint32(l,s,!0),l+=Wh,i.forEach((function(t,e){return u.setFloat32(l+jh*e,t,!0)})),l+=jh*s,n.forEach((function(t,e){var i=t.value,n=i.x,r=i.y,s=i.z,o=i.w,a=l+4*Xh*e;u.setFloat32(a+0*Xh,n,!0),u.setFloat32(a+1*Xh,r,!0),u.setFloat32(a+2*Xh,s,!0),u.setFloat32(a+3*Xh,o,!0)})),l+=4*Xh*s,n.forEach((function(t){var e=t.easingMethod;Array.isArray(e)?(u.setUint8(l,Kh),++l,u.setFloat32(l+0*Jh,e[0],!0),u.setFloat32(l+1*Jh,e[1],!0),u.setFloat32(l+2*Jh,e[2],!0),u.setFloat32(l+3*Jh,e[3],!0),l+=4*Jh):(u.setUint8(l,e),++l)}));var _=l;l+=o;var d=_;n.forEach((function(t){var e=t.interpolationMode;u.setUint8(d,e),r||(d+=qh)}));var f=new Uint8Array(u.buffer);t.writeProperty("bytes",f)}else t.writeThis()},i[Qo]=function(t,e){if(e.fromCCON){var i=t.readProperty("bytes"),n=new DataView(i.buffer,i.byteOffset,i.byteLength),r=0,s=n.getUint32(r,!0);r+=Hh;var o=s&Gh.INTERPOLATION_MODE,a=n.getUint32(r,!0);r+=Wh;var h=Array.from({length:a},(function(t,e){return n.getFloat32(r+jh*e,!0)})),u=r+=jh*a;r+=4*Xh*a;var l=Array.from({length:a},(function(t,e){var i=u+4*Xh*e,s=n.getFloat32(i+0*Xh,!0),o=n.getFloat32(i+1*Xh,!0),a=n.getFloat32(i+2*Xh,!0),h=n.getFloat32(i+3*Xh,!0),l=n.getUint8(r);++r;var c=Vh({value:{x:s,y:o,z:a,w:h}});return l!==Kh?c.easingMethod=l:(c.easingMethod=[n.getFloat32(r+0*Jh,!0),n.getFloat32(r+1*Jh,!0),n.getFloat32(r+2*Jh,!0),n.getFloat32(r+3*Jh,!0)],r+=4*Jh),c}));if(o){var c=n.getUint8(r);++r;for(var _=0;_<a;++_)l[_].interpolationMode=c}else{for(var d=0;d<a;++d){var f=n.getUint8(r+d);l[d].interpolationMode=f}r+=a}this._times=h,this._values=l}else t.readThis()},e}(Ns),Rh=ks(xh.prototype,"preExtrapolation",[io],(function(){return Ms.CLAMP})),Ih=ks(xh.prototype,"postExtrapolation",[io],(function(){return Ms.CLAMP})),wh=xh))||wh);!function(t){t[t.INTERPOLATION_MODE=1]="INTERPOLATION_MODE"}(Gh||(Gh={}));var zh,Hh=1,Wh=4,jh=4,Xh=4,qh=1,Yh=1,Kh=255,Jh=4,Qh=t("cr",qs("cc.ObjectCurve")(zh=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.evaluate=function(t){var e=this.searchKeyframe(t);if(e>=0)return this._values[e];var i=xi(~e-1,0,this._values.length-1);return this._values[i]},e}(Ns))||zh),Zh=ge({Blend:0,Fixed:1}),$h=t("cs",(function(){this.color=dn.WHITE.clone(),this.time=0}));pi.fastDefine("cc.ColorKey",$h,{color:dn.WHITE.clone(),time:0}),pi.Attr.setClassAttr($h,"color","visible",!0),pi.Attr.setClassAttr($h,"time","visible",!0);var tu=t("ct",(function(){this.alpha=1,this.time=0}));pi.fastDefine("cc.AlphaKey",tu,{alpha:1,time:0}),pi.Attr.setClassAttr(tu,"alpha","visible",!0),pi.Attr.setClassAttr(tu,"time","visible",!0);var eu=t("cu",function(){function t(){this.colorKeys=[],this.alphaKeys=[],this.mode=Zh.Blend}var e=t.prototype;return e.setKeys=function(t,e){this.colorKeys=t,this.alphaKeys=e},e.sortKeys=function(){this.colorKeys.length>1&&this.colorKeys.sort((function(t,e){return t.time-e.time})),this.alphaKeys.length>1&&this.alphaKeys.sort((function(t,e){return t.time-e.time}))},e.evaluate=function(t){return this.evaluateFast(new dn,t)},e.evaluateFast=function(t,e){return this.getRGB(t,e),t._set_a_unsafe(this.getAlpha(e)),t},e.randomColor=function(){return this.getRandomColor(new dn)},e.getRandomColor=function(t){var e=this.colorKeys[Math.trunc(Pi()*this.colorKeys.length)],i=this.alphaKeys[Math.trunc(Pi()*this.alphaKeys.length)];return t.set(e.color),t._set_a_unsafe(i.alpha),t},e.getRGB=function(t,e){var i=this.colorKeys,n=i.length;if(n>1){e=Gi(e,1+Ei);for(var r=1;r<n;++r){var s=i[r-1].time,o=i[r].time;if(e>=s&&e<o){if(this.mode===Zh.Fixed)return dn.copy(t,i[r].color),t;var a=(e-s)/(o-s);return dn.lerp(t,i[r-1].color,i[r].color,a),t}}var h=n-1;wi(e,i[h].time,Ei)?dn.copy(t,i[h].color):e<i[0].time?dn.lerp(t,dn.BLACK,i[0].color,e/i[0].time):e>i[h].time&&dn.lerp(t,i[h].color,dn.BLACK,(e-i[h].time)/(1-i[h].time))}else 1===n?dn.copy(t,i[0].color):dn.copy(t,dn.WHITE);return t},e.getAlpha=function(t){var e=this.alphaKeys,i=e.length;if(i>1){t=Gi(t,1+Ei);for(var n=1;n<i;++n){var r=e[n-1].time,s=e[n].time;if(t>=r&&t<s){if(this.mode===Zh.Fixed)return e[n].alpha;var o=(t-r)/(s-r);return Ii(e[n-1].alpha,e[n].alpha,o)}}var a=i-1;return wi(t,e[a].time,Ei)?e[a].alpha:t<e[0].time?Ii(0,e[0].alpha,t/e[0].time):t>e[a].time?Ii(e[a].alpha,0,(t-e[a].time)/(1-e[a].time)):255}return 1===i?e[0].alpha:255},t}());eu.Mode=Zh,pi.fastDefine("cc.Gradient",eu,{colorKeys:[],alphaKeys:[],mode:Zh.Blend}),pi.Attr.setClassAttr(eu,"colorKeys","visible",!0),pi.Attr.setClassAttr(eu,"alphaKeys","visible",!0),pi.Attr.setClassAttr(eu,"mode","visible",!0);var iu=function(){this.time=0,this.value=0,this.inTangent=0,this.outTangent=0};pi.fastDefine("cc.Keyframe",iu,{time:0,value:0,inTangent:0,outTangent:0});var nu=function(){function t(){this.index=void 0,this.time=void 0,this.endTime=void 0,this.coefficient=void 0,this.index=-1,this.time=0,this.endTime=0,this.coefficient=new Float32Array(4)}return t.prototype.evaluate=function(t){return ru(t-this.time,this.coefficient)},t}();function ru(t,e){return t*(t*(t*e[0]+e[1])+e[2])+e[3]}var su,ou,au=function(){function t(t){if(void 0===t&&(t=null),this._curve=void 0,this.cachedKey=void 0,t instanceof ih)this._curve=t;else{var e=new ih;this._curve=e,e.preExtrapolation=Ms.LOOP,e.postExtrapolation=Ms.CLAMP,t?e.assignSorted(t.map((function(t){return[t.time,{interpolationMode:Os.CUBIC,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}]}))):e.assignSorted([[0,{interpolationMode:Os.CUBIC,value:1}],[1,{interpolationMode:Os.CUBIC,value:1}]])}this.cachedKey=new nu}var e=t.prototype;return e.addKey=function(t){t?this._curve.addKeyFrame(t.time,{interpolationMode:Os.CUBIC,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}):this._curve.clear()},e.evaluate_slow=function(t){return this._curve.evaluate(t)},e.evaluate=function(t){var e=this.cachedKey,i=this._curve,n=i.keyFramesCount-1,r=t,s=t<0?i.preExtrapolation:i.postExtrapolation,o=i.getKeyframeTime(0),a=i.getKeyframeTime(n);switch(s){case Ms.LOOP:r=Gi(t-o,a-o)+o;break;case Ms.PING_PONG:r=Ui(t-o,a-o)+o;break;case Ms.CLAMP:default:r=xi(t,o,a)}if(r>=e.time&&r<e.endTime)return e.evaluate(r);var h=this.findIndex(e,r),u=Math.min(h+1,n);return this.calcOptimizedKey(e,h,u),e.evaluate(r)},e.calcOptimizedKey=function(t,e,i){var n=this._curve.getKeyframeTime(e),r=this._curve.getKeyframeTime(i),s=this._curve.getKeyframeValue(e),o=s.value,a=s.leftTangent,h=this._curve.getKeyframeValue(i),u=h.value,l=h.rightTangent;t.index=e,t.time=n,t.endTime=r;var c=r-n,_=u-o,d=1/(c*c),f=a*c,p=l*c;t.coefficient[0]=(f+p-_-_)*d/c,t.coefficient[1]=(_+_+_-f-f-p)*d,t.coefficient[2]=a,t.coefficient[3]=o},e.findIndex=function(t,e){var i=this._curve,n=i.keyFramesCount,r=t.index;if(-1!==r)if(e>i.getKeyframeTime(r))for(var s=0;s<3;s++){var o=r+s;if(o+1<n&&i.getKeyframeTime(o+1)>e)return o}else for(var a=0;a<3;a++){var h=r-a;if(h>=0&&i.getKeyframeTime(h-1)<=e)return h-1}for(var u,l=0,c=n;c-l>1;)u=Math.floor((l+c)/2),i.getKeyframeTime(u)>=e?c=u:l=u;return l},n(t,[{key:"_internalCurve",get:function(){return this._curve}},{key:"keyFrames",get:function(){return Array.from(this._curve.keyframes()).map((function(t){var e=t[0],i=t[1],n=new iu;return n.time=e,n.value=i.value,n.inTangent=i.leftTangent,n.outTangent=i.rightTangent,n}))},set:function(t){this._curve.assignSorted(t.map((function(t){return[t.time,{interpolationMode:Os.CUBIC,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}]})))}},{key:"preWrapMode",get:function(){return uu(this._curve.preExtrapolation)},set:function(t){this._curve.preExtrapolation=hu(t)}},{key:"postWrapMode",get:function(){return uu(this._curve.postExtrapolation)},set:function(t){this._curve.postExtrapolation=hu(t)}}]),t}();function hu(t){switch(t){default:case su.Default:case su.Normal:case su.Clamp:return Ms.CLAMP;case su.PingPong:return Ms.PING_PONG;case su.Loop:return Ms.LOOP}}function uu(t){switch(t){default:case Ms.LINEAR:case Ms.CLAMP:return su.Clamp;case Ms.PING_PONG:return su.PingPong;case Ms.LOOP:return su.Loop}}au.defaultKF=[{time:0,value:1,inTangent:0,outTangent:0},{time:1,value:1,inTangent:0,outTangent:0}],pi.fastDefine("cc.AnimationCurve",au,{_curve:null}),function(t){t[t.Default=0]="Default",t[t.Normal=1]="Normal",t[t.Loop=2]="Loop",t[t.ShouldWrap=4]="ShouldWrap",t[t.Clamp=8]="Clamp",t[t.PingPong=22]="PingPong",t[t.Reverse=36]="Reverse"}(su||(su={})),function(t){t[t.LINEAR=0]="LINEAR",t[t.BEZIER=1]="BEZIER",t[t.CATMULL_ROM=2]="CATMULL_ROM"}(ou||(ou={}));var lu,cu=4294967295,_u=new on,du=new on,fu=new on,pu=new on,mu=function(){function t(t,e){void 0===t&&(t=ou.CATMULL_ROM),void 0===e&&(e=[]),this._type=void 0,this._mode=ou.CATMULL_ROM,this._knots=[],this._type=rr.SHAPE_SPLINE,this._mode=t;for(var i=0;i<e.length;i++)this._knots[i]=new on(e[i])}t.create=function(e,i){return void 0===i&&(i=[]),new t(e,i)},t.clone=function(e){return new t(e.mode,e.knots)},t.copy=function(t,e){t._mode=e.mode,t._knots.length=0;for(var i=e.knots,n=i.length,r=0;r<n;r++)t._knots[r]=new on(i[r]);return t};var e=t.prototype;return e.setModeAndKnots=function(t,e){this._mode=t,this._knots.length=0;for(var i=0;i<e.length;i++)this._knots[i]=new on(e[i])},e.clearKnots=function(){this._knots.length=0},e.getKnotCount=function(){return this._knots.length},e.addKnot=function(t){this._knots.push(new on(t))},e.insertKnot=function(t,e){var i=new on(e);t>=this._knots.length?this._knots.push(i):this._knots.splice(t,0,i)},e.removeKnot=function(t){t>=0&&this._knots.length,this._knots.splice(t,1)},e.setKnot=function(t,e){t>=0&&this._knots.length,this._knots[t].set(e)},e.getKnot=function(t){return t>=0&&this._knots.length,this._knots[t]},e.getPoint=function(e,i){void 0===i&&(i=cu),e=xi(e,0,1);var n=this.getSegments();if(0===n)return new on(0,0,0);if(i===cu){var r=1/n;i=Math.floor(e/r),e=e%r/r}if(i>=n)return new on(this._knots[this._knots.length-1]);switch(this._mode){case ou.LINEAR:return t.calcLinear(this._knots[i],this._knots[i+1],e);case ou.BEZIER:return t.calcBezier(this._knots[4*i],this._knots[4*i+1],this._knots[4*i+2],this._knots[4*i+3],e);case ou.CATMULL_ROM:var s=i>0?this._knots[i-1]:this._knots[i],o=i+2<this._knots.length?this._knots[i+2]:this._knots[i+1];return t.calcCatmullRom(s,this._knots[i],this._knots[i+1],o,e);default:return new on(0,0,0)}},e.getPoints=function(t,e){if(void 0===e&&(e=cu),0===t)return[];if(1===t)return[this.getPoint(0,e)];for(var i=[],n=1/(t-1),r=0;r<t;r++){var s=r*n,o=this.getPoint(s,e);i.push(o)}return i},e.getSegments=function(){var t=this._knots.length;switch(this._mode){case ou.LINEAR:case ou.CATMULL_ROM:return t<2?(Y(14300),0):t-1;case ou.BEZIER:return t<4||t%4!=0?(Y(14301),0):t/4}},t.calcLinear=function(t,e,i){var n=new on;return on.multiplyScalar(_u,t,1-i),on.multiplyScalar(du,e,i),on.add(n,_u,du),n},t.calcBezier=function(t,e,i,n,r){var s=new on,o=1-r;return on.multiplyScalar(_u,t,o*o*o),on.multiplyScalar(du,e,3*r*o*o),on.multiplyScalar(fu,i,3*r*r*o),on.multiplyScalar(pu,n,r*r*r),on.add(_u,_u,du),on.add(fu,fu,pu),on.add(s,_u,fu),s},t.calcCatmullRom=function(t,e,i,n,r){var s=new on,o=r*r,a=o*r;return on.multiplyScalar(_u,t,-.5*a+o-.5*r),on.multiplyScalar(du,e,1.5*a-2.5*o+1),on.multiplyScalar(fu,i,-1.5*a+2*o+.5*r),on.multiplyScalar(pu,n,.5*a-.5*o),on.add(_u,_u,du),on.add(fu,fu,pu),on.add(s,_u,fu),s},n(t,[{key:"type",get:function(){return this._type}},{key:"mode",get:function(){return this._mode}},{key:"knots",get:function(){return this._knots}}]),t}();function gu(t,e){console.warn(t+" is deprecated, please use "+e+" instead.")}!function(t){t[t.ALL=0]="ALL",t[t.CLOSEST=1]="CLOSEST",t[t.ANY=2]="ANY"}(lu||(lu={})),nt(as,"intersect",[{name:"ray_aabb",newName:"rayAABB"},{name:"ray_plane",newName:"rayPlane"},{name:"ray_triangle",newName:"rayTriangle"},{name:"ray_sphere",newName:"raySphere"},{name:"ray_obb",newName:"rayOBB"},{name:"ray_capsule",newName:"rayCapsule"},{name:"ray_subMesh",newName:"raySubMesh"},{name:"ray_mesh",newName:"rayMesh"},{name:"ray_model",newName:"rayModel"},{name:"line_plane",newName:"linePlane"},{name:"line_triangle",newName:"lineTriangle"},{name:"line_aabb",newName:"lineAABB"},{name:"line_obb",newName:"lineOBB"},{name:"line_sphere",newName:"lineSphere"},{name:"aabb_aabb",newName:"aabbWithAABB"},{name:"aabb_obb",newName:"aabbWithOBB"},{name:"aabb_plane",newName:"aabbPlane"},{name:"aabb_frustum",newName:"aabbFrustum"},{name:"aabbFrustum_accurate",newName:"aabbFrustumAccurate"},{name:"obb_point",newName:"obbPoint"},{name:"obb_plane",newName:"obbPlane"},{name:"obb_frustum",newName:"obbFrustum"},{name:"obbFrustum_accurate",newName:"obbFrustumAccurate"},{name:"obb_obb",newName:"obbWithOBB"},{name:"obb_capsule",newName:"obbCapsule"},{name:"sphere_plane",newName:"spherePlane"},{name:"sphere_frustum",newName:"sphereFrustum"},{name:"sphereFrustum_accurate",newName:"sphereFrustumAccurate"},{name:"sphere_sphere",newName:"sphereWithSphere"},{name:"sphere_aabb",newName:"sphereAABB"},{name:"sphere_obb",newName:"sphereOBB"},{name:"sphere_capsule",newName:"sphereCapsule"},{name:"capsule_capsule",newName:"capsuleWithCapsule"}]);var yu=function(t){function e(){var e;return e=t.call(this)||this,gu("line","Line"),e}return s(e,t),e}(sr),vu=function(t){function e(){var e;return e=t.call(this)||this,gu("plane","Plane"),e}return s(e,t),e}(_s),Su=function(t){function e(){var e;return e=t.call(this)||this,gu("ray","Ray"),e}return s(e,t),e}(or),Tu=function(t){function e(){var e;return e=t.call(this)||this,gu("triangle","Triangle"),e}return s(e,t),e}(ds),Au=function(t){function e(){var e;return e=t.call(this)||this,gu("sphere","Sphere"),e}return s(e,t),e}(gr),bu=function(t){function e(){var e;return e=t.call(this)||this,gu("aabb","AABB"),e}return s(e,t),e}(Ss),Eu=function(t){function e(){var e;return e=t.call(this)||this,gu("obb","OBB"),e}return s(e,t),e}(Ds),Cu=function(t){function e(){var e;return e=t.call(this)||this,gu("capsule","Capsule"),e}return s(e,t),e}(Ts),wu=function(t){function e(){var e;return e=t.call(this)||this,gu("frustum","Frustum"),e}return s(e,t),e}(xs),xu=Object.freeze({__proto__:null,distance:nr,enums:rr,intersect:as,Line:sr,Plane:_s,Ray:or,Triangle:ds,Sphere:gr,AABB:Ss,OBB:Ds,Capsule:Ts,Frustum:xs,Keyframe:iu,AnimationCurve:au,get WrapModeMask(){return su},get SplineMode(){return ou},Spline:mu,constructLegacyCurveAndConvert:function(){var t=new ih;return t.assignSorted([[0,{interpolationMode:Os.CUBIC,value:1}],[1,{interpolationMode:Os.CUBIC,value:1}]]),t},OptimizedKey:nu,evalOptCurve:ru,get ERaycastMode(){return lu},line:yu,plane:vu,ray:Su,triangle:Tu,sphere:Au,aabb:bu,obb:Eu,capsule:Cu,frustum:wu});t("aH",xu);var Ru=function(){function t(){this._poolHandle=-1,Iu.addContainer(this)}return t.prototype.destroy=function(){Iu.removeContainer(this)},t}(),Iu=new(function(){function t(){this._pools=[],this._lastShrinkPassed=0,this.shrinkTimeSpan=5}var e=t.prototype;return e.addContainer=function(t){-1===t._poolHandle&&(t._poolHandle=this._pools.length,this._pools.push(t))},e.removeContainer=function(t){-1!==t._poolHandle&&(this._pools[this._pools.length-1]._poolHandle=t._poolHandle,ae(this._pools,t._poolHandle),t._poolHandle=-1)},e.tryShrink=function(){for(var t=0;t<this._pools.length;t++)this._pools[t].tryShrink()},e.update=function(t){this._lastShrinkPassed+=t,this._lastShrinkPassed>this.shrinkTimeSpan&&(this.tryShrink(),this._lastShrinkPassed-=this.shrinkTimeSpan)},t}()),Bu=t("bu",function(t){function e(e,i,n){var r;(r=t.call(this)||this)._ctor=void 0,r._elementsPerBatch=void 0,r._nextAvail=void 0,r._freePool=[],r._dtor=void 0,r._ctor=e,r._dtor=n||null,r._elementsPerBatch=Math.max(i,1),r._nextAvail=r._elementsPerBatch-1;for(var s=0;s<r._elementsPerBatch;++s)r._freePool.push(e());return r}s(e,t);var i=e.prototype;return i.alloc=function(){if(this._nextAvail<0){this._freePool.length=this._elementsPerBatch;for(var t=0;t<this._elementsPerBatch;t++)this._freePool[t]=this._ctor();this._nextAvail=this._elementsPerBatch-1}return this._freePool[this._nextAvail--]},i.free=function(t){this._freePool[++this._nextAvail]=t},i.freeArray=function(t){this._freePool.length=this._nextAvail+1,Array.prototype.push.apply(this._freePool,t),this._nextAvail+=t.length},i.tryShrink=function(){if(this._nextAvail>>1>this._elementsPerBatch){if(this._dtor)for(var t=this._nextAvail>>1;t<=this._nextAvail;t++)this._dtor(this._freePool[t]);this._freePool.length=this._nextAvail>>1,this._nextAvail=this._freePool.length-1}},i.destroy=function(){var e=arguments.length>0?arguments[0]:null;e&&Y(14100);var i=e||this._dtor;if(i)for(var n=0;n<=this._nextAvail;n++)i(this._freePool[n]);this._freePool.length=0,this._nextAvail=-1,t.prototype.destroy.call(this)},e}(Ru)),Du=t("bv",function(t){function e(e,i,n){var r;(r=t.call(this)||this)._fn=void 0,r._dtor=null,r._count=0,r._data=void 0,r._initSize=0,r._fn=e,r._dtor=n||null,r._data=new Array(i),r._initSize=i;for(var s=0;s<i;++s)r._data[s]=e();return r}s(e,t);var i=e.prototype;return i.reset=function(){this._count=0},i.resize=function(t){if(t>this._data.length)for(var e=this._data.length;e<t;++e)this._data[e]=this._fn()},i.add=function(){return this._count>=this._data.length&&this.resize(this._data.length<<1),this._data[this._count++]},i.destroy=function(){if(this._dtor)for(var e=0;e<this._data.length;e++)this._dtor(this._data[e]);this._data.length=0,this._count=0,t.prototype.destroy.call(this)},i.tryShrink=function(){if(this._data.length>>2>this._count){var t=Math.max(this._initSize,this._data.length>>1);if(this._dtor)for(var e=t;e<this._data.length;e++)this._dtor(this._data[e]);this._data.length=t}},i.removeAt=function(t){if(!(t>=this._count)){var e=this._count-1,i=this._data[t];this._data[t]=this._data[e],this._data[e]=i,this._count-=1}},n(e,[{key:"length",get:function(){return this._count}},{key:"data",get:function(){return this._data}}]),e}(Ru)),Pu=t("bw",function(t){function e(e,i){var n;return(n=t.call(this)||this).array=void 0,n.length=0,n._compareFn=void 0,n._initSize=0,n.array=new Array(e),n._initSize=e,n.length=0,n._compareFn=i,n}s(e,t);var i=e.prototype;return i.push=function(t){this.array[this.length++]=t},i.pop=function(){return this.array[--this.length]},i.get=function(t){return this.array[t]},i.clear=function(){this.length=0},i.destroy=function(){this.length=0,this.array.length=0,t.prototype.destroy.call(this)},i.tryShrink=function(){this.array.length>>2>this.length&&(this.array.length=Math.max(this._initSize,this.array.length>>1))},i.sort=function(){this.array.length=this.length,this.array.sort(this._compareFn)},i.concat=function(t){for(var e=0;e<t.length;++e)this.array[this.length++]=t[e]},i.fastRemove=function(t){if(!(t>=this.length||t<0)){var e=--this.length;this.array[t]=this.array[e]}},i.indexOf=function(t){for(var e=0,i=this.length;e<i;++e)if(this.array[e]===t)return e;return-1},e}(Ru));t("aG",Object.freeze({__proto__:null,Pool:Bu,RecyclePool:Du,CachedArray:Pu}));var Ou=t("cx",function(){function t(){this._id="",this._priority=0,this._executeInEditMode=!1}t.sortByPriority=function(t,e){return t._priority<e._priority?1:t._priority>e.priority?-1:0};var e=t.prototype;return e.init=function(){},e.update=function(){},e.postUpdate=function(){},e.destroy=function(){},n(t,[{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t}},{key:"id",get:function(){return this._id},set:function(t){this._id=t}}]),t}());Ou.Priority=ge({LOW:0,MEDIUM:100,HIGH:200,SCHEDULER:1<<31>>>0});var Mu=new gt("Scheduler"),Lu=function(){function t(t,e,i,n){this.target=void 0,this.priority=void 0,this.paused=void 0,this.markedForDeletion=void 0,this.target=t,this.priority=e,this.paused=i,this.markedForDeletion=n}return t.get=function(e,i,n,r){var s=t._listEntries.pop();return s?(s.target=e,s.priority=i,s.paused=n,s.markedForDeletion=r):s=new t(e,i,n,r),s},t.put=function(e){t._listEntries.length<20&&(e.target=null,t._listEntries.push(e))},t}();Lu._listEntries=[];var Nu=function(){function t(t,e,i,n){this.list=void 0,this.entry=void 0,this.target=void 0,this.callback=void 0,this.list=t,this.entry=e,this.target=i,this.callback=n}return t.get=function(e,i,n,r){var s=t._hashUpdateEntries.pop();return s?(s.list=e,s.entry=i,s.target=n,s.callback=r):s=new t(e,i,n,r),s},t.put=function(e){t._hashUpdateEntries.length<20&&(e.list=e.entry=e.target=e.callback=null,t._hashUpdateEntries.push(e))},t}();Nu._hashUpdateEntries=[];var Fu=function(){function t(t,e,i,n,r,s){this.timers=void 0,this.target=void 0,this.timerIndex=void 0,this.currentTimer=void 0,this.currentTimerSalvaged=void 0,this.paused=void 0,this.timers=t,this.target=e,this.timerIndex=i,this.currentTimer=n,this.currentTimerSalvaged=r,this.paused=s}return t.get=function(e,i,n,r,s,o){var a=t._hashTimerEntries.pop();return a?(a.timers=e,a.target=i,a.timerIndex=n,a.currentTimer=r,a.currentTimerSalvaged=s,a.paused=o):a=new t(e,i,n,r,s,o),a},t.put=function(e){t._hashTimerEntries.length<20&&(e.timers=e.target=e.currentTimer=null,t._hashTimerEntries.push(e))},t}();Fu._hashTimerEntries=[];var ku=function(){function t(){this._lock=void 0,this._scheduler=void 0,this._elapsed=void 0,this._runForever=void 0,this._useDelay=void 0,this._timesExecuted=void 0,this._repeat=void 0,this._delay=void 0,this._interval=void 0,this._target=void 0,this._callback=void 0,this._lock=!1,this._scheduler=null,this._elapsed=-1,this._runForever=!1,this._useDelay=!1,this._timesExecuted=0,this._repeat=0,this._delay=0,this._interval=0,this._target=null}t.get=function(){return t._timers.pop()||new t},t.put=function(e){t._timers.length<20&&!e._lock&&(e._scheduler=e._target=e._callback=null,t._timers.push(e))};var e=t.prototype;return e.initWithCallback=function(t,e,i,n,r,s){return this._lock=!1,this._scheduler=t,this._target=i,this._callback=e,this._elapsed=-1,this._interval=n,this._delay=s,this._useDelay=this._delay>0,this._repeat=r,this._runForever=this._repeat===v.macro.REPEAT_FOREVER,!0},e.getInterval=function(){return this._interval},e.setInterval=function(t){this._interval=t},e.update=function(t){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=t,this._runForever&&!this._useDelay?this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0):(this._useDelay?this._elapsed>=this._delay&&(this.trigger(),this._elapsed-=this._delay,this._timesExecuted+=1,this._useDelay=!1):this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0,this._timesExecuted+=1),this._callback&&!this._runForever&&this._timesExecuted>this._repeat&&this.cancel()))},e.getCallback=function(){return this._callback},e.trigger=function(){this._target&&this._callback&&(this._lock=!0,this._callback.call(this._target,this._elapsed),this._lock=!1)},e.cancel=function(){this._scheduler&&this._callback&&this._target&&this._scheduler.unschedule(this._callback,this._target)},t}();ku._timers=[];var Vu=t("ck",function(t){function e(){var e;return(e=t.call(this)||this)._timeScale=void 0,e._updatesNegList=void 0,e._updates0List=void 0,e._updatesPosList=void 0,e._hashForUpdates=void 0,e._hashForTimers=void 0,e._currentTarget=void 0,e._currentTargetSalvaged=void 0,e._updateHashLocked=void 0,e._arrayForTimers=void 0,e._timeScale=1,e._updatesNegList=[],e._updates0List=[],e._updatesPosList=[],e._hashForUpdates=It(!0),e._hashForTimers=It(!0),e._currentTarget=null,e._currentTargetSalvaged=!1,e._updateHashLocked=!1,e._arrayForTimers=[],e}s(e,t),e.enableForTarget=function(t){var e=!1;(t.uuid||t.id)&&(e=!0),e||(t.id=Mu.getNewId())};var i=e.prototype;return i.setTimeScale=function(t){this._timeScale=t},i.getTimeScale=function(){return this._timeScale},i.update=function(t){var e,i,n,r,s;for(this._updateHashLocked=!0,1!==this._timeScale&&(t*=this._timeScale),e=0,n=(i=this._updatesNegList).length;e<n;e++){var o,a;(r=i[e]).paused||r.markedForDeletion||!r.target||null===(o=(a=r.target).update)||void 0===o||o.call(a,t)}for(e=0,n=(i=this._updates0List).length;e<n;e++){var h,u;(r=i[e]).paused||r.markedForDeletion||!r.target||null===(h=(u=r.target).update)||void 0===h||h.call(u,t)}for(e=0,n=(i=this._updatesPosList).length;e<n;e++){var l,c;(r=i[e]).paused||r.markedForDeletion||!r.target||null===(l=(c=r.target).update)||void 0===l||l.call(c,t)}var _=this._arrayForTimers;for(e=0;e<_.length;e++){var d;if(s=_[e],this._currentTarget=s,this._currentTargetSalvaged=!1,!s.paused&&s.timers)for(s.timerIndex=0;s.timerIndex<s.timers.length;++s.timerIndex)s.currentTimer=s.timers[s.timerIndex],s.currentTimerSalvaged=!1,s.currentTimer.update(t),s.currentTimer=null;this._currentTargetSalvaged&&0===(null===(d=this._currentTarget.timers)||void 0===d?void 0:d.length)&&(this._removeHashElement(this._currentTarget),--e)}for(e=0,i=this._updatesNegList;e<i.length;)(r=i[e]).markedForDeletion?this._removeUpdateFromHash(r):e++;for(e=0,i=this._updates0List;e<i.length;)(r=i[e]).markedForDeletion?this._removeUpdateFromHash(r):e++;for(e=0,i=this._updatesPosList;e<i.length;)(r=i[e]).markedForDeletion?this._removeUpdateFromHash(r):e++;this._updateHashLocked=!1,this._currentTarget=null},i.schedule=function(t,e,i,n,r,s){var o,a,h,u;"function"!=typeof t?(Y(1514),h=e,u=t):(h=t,u=e),3!==arguments.length&&4!==arguments.length&&5!==arguments.length||(s=!!n,n=v.macro.REPEAT_FOREVER,r=0),$(Boolean(u),1502);var l=u.uuid||u.id;if(l){var c,_,d=this._hashForTimers[l];if(d?d.paused!==s&&Y(1511):(d=Fu.get(null,u,0,null,!1,Boolean(s)),this._arrayForTimers.push(d),this._hashForTimers[l]=d),null==d.timers)d.timers=[];else for(_=0;_<d.timers.length;++_)if((c=d.timers[_])&&h===c.getCallback())return X(1507,c.getInterval(),i),void c.setInterval(i);(c=ku.get()).initWithCallback(this,h,u,i,null!==(o=n)&&void 0!==o?o:0,null!==(a=r)&&void 0!==a?a:0),d.timers.push(c),this._currentTarget===d&&this._currentTargetSalvaged&&(this._currentTargetSalvaged=!1)}else J(1510)},i.scheduleUpdate=function(t,e,i){var n=t.uuid||t.id;if(n){var r=this._hashForUpdates[n];if(r&&r.entry){if(r.entry.priority===e)return r.entry.markedForDeletion=!1,void(r.entry.paused=i);if(this._updateHashLocked)return X(1506),r.entry.markedForDeletion=!1,void(r.entry.paused=i);this.unscheduleUpdate(t)}var s,o=Lu.get(t,e,i,!1);0===e?(s=this._updates0List,this._appendIn(s,o)):(s=e<0?this._updatesNegList:this._updatesPosList,this._priorityIn(s,o,e)),this._hashForUpdates[n]=Nu.get(s,o,t,null)}else J(1510)},i.unschedule=function(t,e){if(e&&t){var i=e.uuid||e.id;if(i){var n=this._hashForTimers[i];if(n){var r=n.timers;if(!r)return;for(var s=0,o=r.length;s<o;s++){var a=r[s];if(t===a.getCallback())return a!==n.currentTimer||n.currentTimerSalvaged||(n.currentTimerSalvaged=!0),r.splice(s,1),ku.put(a),n.timerIndex>=s&&n.timerIndex--,void(0===r.length&&(this._currentTarget===n?this._currentTargetSalvaged=!0:this._removeHashElement(n)))}}}else J(1510)}},i.unscheduleUpdate=function(t){if(t){var e=t.uuid||t.id;if(e){var i=this._hashForUpdates[e];null!=i&&i.entry&&(this._updateHashLocked?i.entry.markedForDeletion=!0:this._removeUpdateFromHash(i.entry))}else J(1510)}},i.unscheduleAllForTarget=function(t){if(t){var e=t.uuid||t.id;if(e){var i=this._hashForTimers[e];if(null!=i&&i.timers){var n=i.timers;i.currentTimer&&n.indexOf(i.currentTimer)>-1&&!i.currentTimerSalvaged&&(i.currentTimerSalvaged=!0);for(var r=0,s=n.length;r<s;r++)ku.put(n[r]);n.length=0,this._currentTarget===i?this._currentTargetSalvaged=!0:this._removeHashElement(i)}this.unscheduleUpdate(t)}else J(1510)}},i.unscheduleAll=function(){this.unscheduleAllWithMinPriority(Ou.Priority.SCHEDULER)},i.unscheduleAllWithMinPriority=function(t){var e,i,n,r=this._arrayForTimers;for(e=r.length-1;e>=0;e--)(i=r[e]).target&&this.unscheduleAllForTarget(i.target);var s=0;if(t<0)for(e=0;e<this._updatesNegList.length;){var o;s=this._updatesNegList.length,null!==(o=n=this._updatesNegList[e])&&void 0!==o&&o.target&&n.priority>=t&&this.unscheduleUpdate(n.target),s===this._updatesNegList.length&&e++}if(t<=0)for(e=0;e<this._updates0List.length;){var a;s=this._updates0List.length,null!==(a=n=this._updates0List[e])&&void 0!==a&&a.target&&this.unscheduleUpdate(n.target),s===this._updates0List.length&&e++}for(e=0;e<this._updatesPosList.length;){var h;s=this._updatesPosList.length,null!==(h=n=this._updatesPosList[e])&&void 0!==h&&h.target&&n.priority>=t&&this.unscheduleUpdate(n.target),s===this._updatesPosList.length&&e++}},i.isScheduled=function(t,e){$(Boolean(t),1508),$(Boolean(e),1509);var i=e.uuid||e.id;if(!i)return J(1510),!1;var n=this._hashForTimers[i];if(!n)return!1;if(null==n.timers)return!1;for(var r=n.timers,s=0;s<r.length;++s)if(t===r[s].getCallback())return!0;return!1},i.pauseAllTargets=function(){return this.pauseAllTargetsWithMinPriority(Ou.Priority.SCHEDULER)},i.pauseAllTargetsWithMinPriority=function(t){var e,i,n,r,s=[],o=this._arrayForTimers;for(i=0,n=o.length;i<n;i++){var a;null!==(a=e=o[i])&&void 0!==a&&a.target&&(e.paused=!0,s.push(e.target))}if(t<0)for(i=0;i<this._updatesNegList.length;i++){var h;null!==(h=r=this._updatesNegList[i])&&void 0!==h&&h.target&&r.priority>=t&&(r.paused=!0,s.push(r.target))}if(t<=0)for(i=0;i<this._updates0List.length;i++){var u;null!==(u=r=this._updates0List[i])&&void 0!==u&&u.target&&(r.paused=!0,s.push(r.target))}for(i=0;i<this._updatesPosList.length;i++){var l;null!==(l=r=this._updatesPosList[i])&&void 0!==l&&l.target&&r.priority>=t&&(r.paused=!0,s.push(r.target))}return s},i.resumeTargets=function(t){if(t)for(var e=0;e<t.length;e++)this.resumeTarget(t[e])},i.pauseTarget=function(t){$(Boolean(t),1503);var e=t.uuid||t.id;if(e){var i=this._hashForTimers[e];i&&(i.paused=!0);var n=this._hashForUpdates[e];null!=n&&n.entry&&(n.entry.paused=!0)}else J(1510)},i.resumeTarget=function(t){$(Boolean(t),1504);var e=t.uuid||t.id;if(e){var i=this._hashForTimers[e];i&&(i.paused=!1);var n=this._hashForUpdates[e];null!=n&&n.entry&&(n.entry.paused=!1)}else J(1510)},i.isTargetPaused=function(t){$(Boolean(t),1505);var e=t.uuid||t.id;if(!e)return J(1510),!1;var i=this._hashForTimers[e];if(i)return i.paused;var n=this._hashForUpdates[e];return!(null==n||!n.entry)&&n.entry.paused},i._removeHashElement=function(t){if(t.target){var e=t.target.uuid||t.target.id;if(void 0!==e){delete this._hashForTimers[e];for(var i=this._arrayForTimers,n=0,r=i.length;n<r;n++)if(i[n]===t){i.splice(n,1);break}Fu.put(t)}}},i._removeUpdateFromHash=function(t){if(t.target){var e=t.target.uuid||t.target.id;if(void 0!==e){var i=this._hashForUpdates[e];if(i){var n=i.list,r=i.entry;if(n)for(var s=0,o=n.length;s<o;s++)if(n[s]===r){n.splice(s,1);break}delete this._hashForUpdates[e],r&&Lu.put(r),Nu.put(i)}}}},i._priorityIn=function(t,e,i){for(var n=0;n<t.length;n++)if(i<t[n].priority)return void t.splice(n,0,e);t.push(e)},i._appendIn=function(t,e){t.push(e)},e}(Ou));Vu.ID="scheduler",v.Scheduler=Vu;var Gu={};nt(Gu,"vmath",[{name:"vec2",newName:"Vec2",target:jn,targetName:"math"},{name:"vec3",newName:"Vec3",target:jn,targetName:"math"},{name:"vec4",newName:"Vec4",target:jn,targetName:"math"},{name:"quat",newName:"Quat",target:jn,targetName:"math"},{name:"mat3",newName:"Mat3",target:jn,targetName:"math"},{name:"mat4",newName:"Mat4",target:jn,targetName:"math"},{name:"color4",newName:"Color",target:jn,targetName:"math"},{name:"rect",newName:"Rect",target:jn,targetName:"math"},{name:"approx",newName:"approx",target:jn,targetName:"math"},{name:"EPSILON",newName:"EPSILON",target:jn,targetName:"math"},{name:"equals",newName:"equals",target:jn,targetName:"math"},{name:"clamp",newName:"clamp",target:jn,targetName:"math"},{name:"clamp01",newName:"clamp01",target:jn,targetName:"math"},{name:"lerp",newName:"lerp",target:jn,targetName:"math"},{name:"toRadian",newName:"toRadian",target:jn,targetName:"math"},{name:"toDegree",newName:"toDegree",target:jn,targetName:"math"},{name:"random",newName:"random",target:jn,targetName:"math"},{name:"randomRange",newName:"randomRange",target:jn,targetName:"math"},{name:"randomRangeInt",newName:"randomRangeInt",target:jn,targetName:"math"},{name:"pseudoRandom",newName:"pseudoRandom",target:jn,targetName:"math"},{name:"pseudoRandomRangeInt",newName:"pseudoRandomRangeInt",target:jn,targetName:"math"},{name:"nextPow2",newName:"nextPow2",target:jn,targetName:"math"},{name:"repeat",newName:"repeat",target:jn,targetName:"math"},{name:"pingPong",newName:"pingPong",target:jn,targetName:"math"},{name:"inverseLerp",newName:"inverseLerp",target:jn,targetName:"math"}]),v.vmath=Gu,nt(Vu.prototype,"Scheduler.prototype",[{name:"enableForTarget",newName:"enableForTarget",target:Vu,targetName:"Scheduler"}]),nt(Vu,"Scheduler",[{name:"PRIORITY_SYSTEM",newName:"System.Priority.SCHEDULER",customGetter:function(){return Ou.Priority.SCHEDULER}}]),rt(Vu,"Scheduler",[{name:"PRIORITY_NON_SYSTEM",suggest:"Use enum` System.Priority` instead"}]),pt({replaceProperty:{since:"3.6.0",removed:!1},removeProperty:{since:"3.6.0",removed:!1},markAsWarning:{since:"3.6.0",removed:!1},setDefaultLogTimes:{since:"3.6.0",removed:!1}});var Uu=ae;function zu(){}var Hu=function(){function t(){this.callback=zu,this.target=void 0,this.once=!1}var e=t.prototype;return e.set=function(t,e,i){this.callback=t||zu,this.target=e,this.once=!!i},e.reset=function(){this.target=void 0,this.callback=zu,this.once=!1},e.check=function(){return!(Wo(this.target)&&!jo(this.target,!0))},t}(),Wu=new Bu((function(){return new Hu}),32),ju=function(){function t(){this.callbackInfos=[],this.isInvoking=!1,this.containCanceled=!1}var e=t.prototype;return e.removeByCallback=function(t){for(var e=0;e<this.callbackInfos.length;++e){var i=this.callbackInfos[e];i&&i.callback===t&&(i.reset(),Wu.free(i),Uu(this.callbackInfos,e),--e)}},e.removeByTarget=function(t){for(var e=0;e<this.callbackInfos.length;++e){var i=this.callbackInfos[e];i&&i.target===t&&(i.reset(),Wu.free(i),Uu(this.callbackInfos,e),--e)}},e.cancel=function(t){var e=this.callbackInfos[t];e&&(e.reset(),this.isInvoking?this.callbackInfos[t]=null:Uu(this.callbackInfos,t),Wu.free(e)),this.containCanceled=!0},e.cancelAll=function(){for(var t=0;t<this.callbackInfos.length;t++){var e=this.callbackInfos[t];e&&(e.reset(),Wu.free(e),this.callbackInfos[t]=null)}this.containCanceled=!0},e.purgeCanceled=function(){for(var t=this.callbackInfos.length-1;t>=0;--t)this.callbackInfos[t]||Uu(this.callbackInfos,t);this.containCanceled=!1},e.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1},t}(),Xu=new Bu((function(){return new ju}),16),qu=t("cZ",function(){function t(){this._callbackTable=It(!0),this._offCallback=void 0}var e=t.prototype;return e.on=function(t,e,i,n){if(!this.hasEventListener(t,e,i)){var r=this._callbackTable[t];r||(r=this._callbackTable[t]=Xu.alloc());var s=Wu.alloc();s.set(e,i,n),r.callbackInfos.push(s)}return e},e.hasEventListener=function(t,e,i){var n=this._callbackTable&&this._callbackTable[t];if(!n)return!1;var r=n.callbackInfos;if(!e){if(n.isInvoking){for(var s=0;s<r.length;++s)if(r[s])return!0;return!1}return r.length>0}for(var o=0;o<r.length;++o){var a=r[o];if(a&&a.check()&&a.callback===e&&a.target===i)return!0}return!1},e.removeAll=function(t){var e=typeof t;if("string"===e||"number"===e){var i=this._callbackTable&&this._callbackTable[t];i&&(i.isInvoking?i.cancelAll():(i.clear(),Xu.free(i),delete this._callbackTable[t]))}else if(t)for(var n in this._callbackTable){var r=this._callbackTable[n];if(r.isInvoking)for(var s=r.callbackInfos,o=0;o<s.length;++o){var a=s[o];a&&a.target===t&&r.cancel(o)}else r.removeByTarget(t)}},e.off=function(t,e,i){var n,r=this._callbackTable&&this._callbackTable[t];if(r){var s=r.callbackInfos;if(e)for(var o=0;o<s.length;++o){var a=s[o];if(a&&a.callback===e&&a.target===i){r.cancel(o);break}}else this.removeAll(t)}null===(n=this._offCallback)||void 0===n||n.call(this)},e.emit=function(t,e,i,n,r,s){var o=this._callbackTable&&this._callbackTable[t];if(o){var a=!o.isInvoking;o.isInvoking=!0;for(var h=o.callbackInfos,u=0,l=h.length;u<l;++u){var c=h[u];if(c){var _=c.callback,d=c.target;c.once&&this.off(t,_,d),c.check()?d?_.call(d,e,i,n,r,s):_(e,i,n,r,s):this.off(t,_,d)}}a&&(o.isInvoking=!1,o.containCanceled&&o.purgeCanceled())}},e.clear=function(){for(var t in this._callbackTable){var e=this._callbackTable[t];e&&(e.clear(),Xu.free(e),delete this._callbackTable[t])}},e._registerOffCallback=function(t){this._offCallback=t},t}());function Yu(t){for(var e=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._callbackTable=It(!0),e}s(e,t);var i=e.prototype;return i.once=function(t,e,i){return this.on(t,e,i,!0)},i.targetOff=function(t){this.removeAll(t)},e}(t),i=qu.prototype,n=Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i)),r=0;r<n.length;++r){var o=n[r];if(!(o in e.prototype)){var a=Object.getOwnPropertyDescriptor(i,o);a&&Object.defineProperty(e.prototype,o,a)}}return e}var Ku=t("c0",Yu((function(){})));v.EventTarget=Ku;var Ju,Qu,Zu,$u,tl,el,il=t("c2",function(){function t(){this._delegates=[]}var e=t.prototype;return e.add=function(t){this._delegates.includes(t)||this._delegates.push(t)},e.hasListener=function(t){return this._delegates.includes(t)},e.remove=function(t){ue(this._delegates,t)},e.dispatch=function(){for(var t=arguments,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return Promise.all(this._delegates.map((function(e){return e.apply(void 0,t)})).filter(Boolean))},t}());!function(t){t.UNKNOWN="unknown",t.WECHAT="wechat",t.ANDROID="androidbrowser",t.IE="ie",t.EDGE="edge",t.QQ="qqbrowser",t.MOBILE_QQ="mqqbrowser",t.UC="ucbrowser",t.UCBS="ucbs",t.BROWSER_360="360browser",t.BAIDU_APP="baiduboxapp",t.BAIDU="baidubrowser",t.MAXTHON="maxthon",t.OPERA="opera",t.OUPENG="oupeng",t.MIUI="miuibrowser",t.FIREFOX="firefox",t.SAFARI="safari",t.CHROME="chrome",t.LIEBAO="liebao",t.QZONE="qzone",t.SOUGOU="sogou",t.HUAWEI="huawei"}(Ju||(Ju={})),function(t){t.UNKNOWN="unknown",t.ENGLISH="en",t.CHINESE="zh",t.FRENCH="fr",t.ITALIAN="it",t.GERMAN="de",t.SPANISH="es",t.DUTCH="du",t.RUSSIAN="ru",t.KOREAN="ko",t.JAPANESE="ja",t.HUNGARIAN="hu",t.PORTUGUESE="pt",t.ARABIC="ar",t.NORWEGIAN="no",t.POLISH="pl",t.TURKISH="tr",t.UKRAINIAN="uk",t.ROMANIAN="ro",t.BULGARIAN="bg",t.HINDI="hi"}(Qu||(Qu={})),function(t){t[t.NONE=0]="NONE",t[t.LAN=1]="LAN",t[t.WWAN=2]="WWAN"}(Zu||(Zu={})),function(t){t.UNKNOWN="Unknown",t.IOS="iOS",t.ANDROID="Android",t.WINDOWS="Windows",t.LINUX="Linux",t.OSX="OS X",t.OHOS="OHOS",t.OPENHARMONY="OpenHarmony"}($u||($u={})),function(t){t.UNKNOWN="UNKNOWN",t.EDITOR_PAGE="EDITOR_PAGE",t.EDITOR_CORE="EDITOR_CORE",t.MOBILE_BROWSER="MOBILE_BROWSER",t.DESKTOP_BROWSER="DESKTOP_BROWSER",t.WIN32="WIN32",t.ANDROID="ANDROID",t.IOS="IOS",t.MACOS="MACOS",t.OHOS="OHOS",t.OPENHARMONY="OPENHARMONY",t.WECHAT_GAME="WECHAT_GAME",t.WECHAT_MINI_PROGRAM="WECHAT_MINI_PROGRAM",t.BAIDU_MINI_GAME="BAIDU_MINI_GAME",t.XIAOMI_QUICK_GAME="XIAOMI_QUICK_GAME",t.ALIPAY_MINI_GAME="ALIPAY_MINI_GAME",t.TAOBAO_CREATIVE_APP="TAOBAO_CREATIVE_APP",t.TAOBAO_MINI_GAME="TAOBAO_MINI_GAME",t.BYTEDANCE_MINI_GAME="BYTEDANCE_MINI_GAME",t.OPPO_MINI_GAME="OPPO_MINI_GAME",t.VIVO_MINI_GAME="VIVO_MINI_GAME",t.HUAWEI_QUICK_GAME="HUAWEI_QUICK_GAME",t.COCOSPLAY="COCOSPLAY",t.LINKSURE_MINI_GAME="LINKSURE_MINI_GAME",t.QTT_MINI_GAME="QTT_MINI_GAME"}(tl||(tl={})),function(t){t.WEBP="WEBP",t.IMAGE_BITMAP="IMAGE_BITMAP",t.WEB_VIEW="WEB_VIEW",t.VIDEO_PLAYER="VIDEO_PLAYER",t.SAFE_AREA="SAFE_AREA",t.HPE="HPE",t.INPUT_TOUCH="INPUT_TOUCH",t.EVENT_KEYBOARD="EVENT_KEYBOARD",t.EVENT_MOUSE="EVENT_MOUSE",t.EVENT_TOUCH="EVENT_TOUCH",t.EVENT_ACCELEROMETER="EVENT_ACCELEROMETER",t.EVENT_GAMEPAD="EVENT_GAMEPAD",t.EVENT_HANDLE="EVENT_HANDLE",t.EVENT_HMD="EVENT_HMD",t.EVENT_HANDHELD="EVENT_HANDHELD",t.WASM="WASM"}(el||(el={}));var nl=new(function(t){function e(){var e,i,n,r;(r=t.call(this)||this).networkType=void 0,r.isNative=void 0,r.isBrowser=void 0,r.isMobile=void 0,r.isLittleEndian=void 0,r.platform=void 0,r.language=void 0,r.nativeLanguage=void 0,r.os=void 0,r.osVersion=void 0,r.osMainVersion=void 0,r.browserType=void 0,r.browserVersion=void 0,r.isXR=void 0,r._battery=void 0,r._featureMap=void 0,r._initPromise=void 0;var s,o=window.navigator,a=o.userAgent.toLowerCase();null===(e=(i=o).getBattery)||void 0===e||e.call(i).then((function(t){r._battery=t})),r.networkType=Zu.LAN,r.isNative=!1,r.isBrowser=!0,r.isMobile=/mobile|android|iphone|ipad/.test(a),r.platform=r.isMobile?tl.MOBILE_BROWSER:tl.DESKTOP_BROWSER,r.isLittleEndian=(s=new ArrayBuffer(2),new DataView(s).setInt16(0,256,!0),256===new Int16Array(s)[0]);var h=o.language;r.nativeLanguage=h.toLowerCase(),h=(h=h||o.browserLanguage)?h.split("-")[0]:Qu.ENGLISH,r.language=h;var u=!1,l=!1,c="",_=0,d=/android\s*(\d+(?:\.\d+)*)/i.exec(a)||/android\s*(\d+(?:\.\d+)*)/i.exec(o.platform);d&&(u=!0,c=d[1]||"",_=parseInt(c)||0),(d=/(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(a))?(l=!0,c=d[2]||"",_=parseInt(c)||0):(/(iPhone|iPad|iPod)/.exec(o.platform)||"MacIntel"===o.platform&&o.maxTouchPoints&&o.maxTouchPoints>1)&&(l=!0,c="",_=0);var f=$u.UNKNOWN;-1!==o.appVersion.indexOf("Win")?f=$u.WINDOWS:l?f=$u.IOS:-1!==o.appVersion.indexOf("Mac")?f=$u.OSX:-1!==o.appVersion.indexOf("X11")&&-1===o.appVersion.indexOf("Linux")?f=$u.LINUX:u?f=$u.ANDROID:-1===o.appVersion.indexOf("Linux")&&-1===a.indexOf("ubuntu")||(f=$u.LINUX),r.os=f,r.osVersion=c,r.osMainVersion=_,r.browserType=Ju.UNKNOWN;var p=/wechat|weixin|micromessenger/i.exec(a)||/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(a)||/qq|qqbrowser|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(a)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(a),m=p?p[0].toLowerCase():$u.UNKNOWN;("safari"===m&&u||"qq"===m&&/android.*applewebkit/i.test(a))&&(m=Ju.ANDROID);var y={micromessenger:Ju.WECHAT,wechat:Ju.WECHAT,weixin:Ju.WECHAT,trident:Ju.IE,edge:Ju.EDGE,"360 aphone":Ju.BROWSER_360,mxbrowser:Ju.MAXTHON,"opr/":Ju.OPERA,ubrowser:Ju.UC,huaweibrowser:Ju.HUAWEI};r.browserType=y[m]||m,r.browserVersion="";var v=/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i.exec(a);v||(v=/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i.exec(a)),r.browserVersion=v?v[4]:"",r.isXR=!1;var S,T=document.createElement("canvas");T.getContext("2d");try{S=T.toDataURL("image/webp").startsWith("data:image/webp")}catch(t){S=!1}if(r.browserType===Ju.SAFARI){var A,b=null===(A=/ version\/(\d+)/.exec(a))||void 0===A?void 0:A[1];"string"==typeof b&&Number.parseInt(b)>=14&&(S=!0)}var E=void 0!==document.documentElement.ontouchstart||void 0!==document.ontouchstart||g,C=void 0!==document.documentElement.onmouseup||g,w=void 0!==navigator.xr,x=function(){if((r.os===$u.IOS||r.os===$u.OSX)&&/(OS 15_4)|(Version\/15.4)/.test(window.navigator.userAgent))return!1;try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var t=new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0]));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){return!1}return!1}();return r._featureMap=((n={})[el.WEBP]=S,n[el.IMAGE_BITMAP]=!1,n[el.WEB_VIEW]=!0,n[el.VIDEO_PLAYER]=!0,n[el.SAFE_AREA]=!1,n[el.HPE]=!1,n[el.INPUT_TOUCH]=E,n[el.EVENT_KEYBOARD]=void 0!==document.documentElement.onkeyup||g,n[el.EVENT_MOUSE]=C,n[el.EVENT_TOUCH]=E||C,n[el.EVENT_ACCELEROMETER]=void 0!==window.DeviceMotionEvent||void 0!==window.DeviceOrientationEvent,n[el.EVENT_GAMEPAD]=void 0!==navigator.getGamepads||void 0!==navigator.webkitGetGamepads||w,n[el.EVENT_HANDLE]=false,n[el.EVENT_HMD]=w,n[el.EVENT_HANDHELD]=w,n[el.WASM]=x,n),r._initPromise=[],r._initPromise.push(r._supportsImageBitmapPromise()),r._registerEvent(),r}s(e,t);var i=e.prototype;return i._supportsImageBitmapPromise=function(){var t=this;if("undefined"!=typeof createImageBitmap&&"undefined"!=typeof Blob){var e=document.createElement("canvas");e.width=e.height=2;var i=createImageBitmap(e,{});if(i instanceof Promise)return i.then((function(e){t._setFeature(el.IMAGE_BITMAP,!0),null==e||e.close()}))}return Promise.resolve()},i._registerEvent=function(){var t,e=this;t=void 0!==document.hidden?"hidden":void 0!==document.mozHidden?"mozHidden":void 0!==document.msHidden?"msHidden":void 0!==document.webkitHidden?"webkitHidden":"hidden";var i=!1,n=function(){i||(i=!0,e.emit("hide"))},r=function(t,n,r,s,o){i&&(i=!1,e.emit("show",t,n,r,s,o))};if(t)for(var s=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],o=0;o<s.length;o++)document.addEventListener(s[o],(function(e){var i=document[t];(i=i||e.hidden)?n():r()}));else window.addEventListener("blur",n),window.addEventListener("focus",r);window.navigator.userAgent.indexOf("MicroMessenger")>-1&&(window.onfocus=r),"onpageshow"in window&&"onpagehide"in window&&(window.addEventListener("pagehide",n),window.addEventListener("pageshow",r),document.addEventListener("pagehide",n),document.addEventListener("pageshow",r))},i._setFeature=function(t,e){return this._featureMap[t]=e},i.init=function(){return Promise.all(this._initPromise)},i.hasFeature=function(t){return this._featureMap[t]},i.getBatteryLevel=function(){return this._battery?this._battery.level:1},i.triggerGC=function(){},i.openURL=function(t){window.open(t)},i.now=function(){return Date.now?Date.now():+new Date},i.restartJSVM=function(){},i.exit=function(){window.close()},i.close=function(){this.emit("close")},e}(Ku)),rl=/(\.[^\.\/\?\\]*)(\?.*)?$/,sl=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,ol=/[^\.\/]+\/\.\.\//;function al(){for(var t="",e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];for(var r=0,s=i;r<s.length;r++){var o=s[r];t=(t+(""===t?"":"/")+o).replace(/(\/|\\\\)$/,"")}return t}function hl(t){var e=rl.exec(t);return e?e[1]:""}function ul(t){if(t){var e=t.lastIndexOf(".");if(-1!==e)return t.substring(0,e)}return t}function ll(t,e){var i=t.indexOf("?");i>0&&(t=t.substring(0,i));var n=/(\/|\\)([^\/\\]+)$/g.exec(t.replace(/(\/|\\)$/,""));if(!n)return t;var r=n[2];return e&&t.substring(t.length-e.length).toLowerCase()===e.toLowerCase()?r.substring(0,r.length-e.length):r}function cl(t){var e=sl.exec(t);return e?e[2]:""}function _l(t,e){e=e||"";var i=t.indexOf("?"),n="";return i>0&&(n=t.substring(i),t=t.substring(0,i)),(i=t.lastIndexOf("."))<0?t+e+n:t.substring(0,i)+e+n}function dl(t,e,i){if(0===e.indexOf("."))return _l(t,e);var n=t.indexOf("?"),r="",s=i?hl(t):"";return n>0&&(r=t.substring(n),t=t.substring(0,n)),n=(n=t.lastIndexOf("/"))<=0?0:n+1,t.substring(0,n)+e+s+r}function fl(t){var e=t=String(t);do{e=t,t=t.replace(ol,"")}while(e.length!==t.length);return t}function pl(t){return t.replace(/[\/\\]$/,"")}function ml(){return nl.os===$u.WINDOWS?"\\":"/"}t("bD",Object.freeze({__proto__:null,join:al,extname:hl,mainFileName:ul,basename:ll,dirname:cl,changeExtname:_l,changeBasename:dl,_normalize:fl,stripSep:pl,getSeperator:ml}));var gl=new on;function yl(t,e,i,n){n||(n=new on),t.convertToUINode(e,i,n);var r=i.position;return n.add(r),n}function vl(t,e,i){return i||(i=new on),t.worldToScreen(e,i),i.x/=v.view.getScaleX(),i.y/=v.view.getScaleY(),i}var Sl,Tl=t("bN",{WorldNode3DToLocalNodeUI:yl,WorldNode3DToWorldNodeUI:vl});v.pipelineUtils=Tl,nt(v.pipelineUtils,"cc.pipelineUtils",[{name:"WorldNode3DToLocalNodeUI",newName:"convertToUINode",targetName:"cc.Camera.prototype",customFunction:function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=e[0],r=e[3]||gl;return n.convertToUINode(e[1],e[2],r),r.add(e[2].position),e[3]||r.clone()}}]),st(fe,"js",[{name:"js",suggest:"'js.js' is deprecated since v3.7.0, please access 'js' directly instead."}]),function(t){t[t.PORTRAIT=1]="PORTRAIT",t[t.PORTRAIT_UPSIDE_DOWN=2]="PORTRAIT_UPSIDE_DOWN",t[t.LANDSCAPE_LEFT=4]="LANDSCAPE_LEFT",t[t.LANDSCAPE_RIGHT=8]="LANDSCAPE_RIGHT",t[t.LANDSCAPE=12]="LANDSCAPE",t[t.AUTO=13]="AUTO"}(Sl||(Sl={}));var Al,bl={auto:Sl.AUTO,landscape:Sl.LANDSCAPE,portrait:Sl.PORTRAIT};!function(t){t[t.Unknown=0]="Unknown",t[t.SubFrame=1]="SubFrame",t[t.BrowserWindow=2]="BrowserWindow",t[t.Fullscreen=3]="Fullscreen"}(Al||(Al={}));var El=new(function(t){function e(){var e,i,n,r,s,o;(e=t.call(this)||this).isFrameRotated=!1,e.handleResizeEvent=!0,e._gameFrame=void 0,e._gameContainer=void 0,e._gameCanvas=void 0,e._isProportionalToFrame=!1,e._cachedFrameStyle={width:"0px",height:"0px"},e._cachedContainerStyle={width:"0px",height:"0px"},e._cbToUpdateFrameBuffer=void 0,e._supportFullScreen=!1,e._touchEventName=void 0,e._onFullscreenChange=void 0,e._onFullscreenError=void 0,e._orientationChangeTimeoutId=-1,e._cachedFrameSize=new Vn(0,0),e._exactFitScreen=!1,e._isHeadlessMode=!1,e._fn={},e._fnGroup=[["requestFullscreen","exitFullscreen","fullscreenchange","fullscreenEnabled","fullscreenElement","fullscreenerror"],["requestFullScreen","exitFullScreen","fullScreenchange","fullScreenEnabled","fullScreenElement","fullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitfullscreenchange","webkitIsFullScreen","webkitCurrentFullScreenElement","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozFullScreen","mozFullScreenElement","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","MSFullscreenChange","msFullscreenEnabled","msFullscreenElement","msfullscreenerror"]],e._resolutionScale=1,e._orientation=Sl.AUTO,e._gameFrame=document.getElementById("GameDiv"),e._gameContainer=document.getElementById("Cocos3dGameContainer"),e._gameCanvas=document.getElementById("GameCanvas"),e._gameFrame||(e._gameFrame=document.createElement("div"),e._gameFrame.setAttribute("id","GameDiv"),null===(i=e._gameCanvas)||void 0===i||null===(n=i.parentNode)||void 0===n||n.insertBefore(e._gameFrame,e._gameCanvas),e._gameFrame.appendChild(e._gameCanvas)),e._gameContainer||(e._gameContainer=document.createElement("div"),e._gameContainer.setAttribute("id","Cocos3dGameContainer"),null===(r=e._gameCanvas)||void 0===r||null===(s=r.parentNode)||void 0===s||s.insertBefore(e._gameContainer,e._gameCanvas),e._gameContainer.appendChild(e._gameCanvas));for(var a=e._fnGroup,h=0;h<a.length;h++)if(o=a[h],void 0!==document[o[1]]){for(var u=0;u<o.length;u++)e._fn[a[0][u]]=o[u];break}return e._supportFullScreen=void 0!==e._fn.requestFullscreen,e._touchEventName="ontouchstart"in window?"touchend":"mousedown",e._registerEvent(),e}s(e,t);var i=e.prototype;return i.init=function(t,e){this._cbToUpdateFrameBuffer=e,this.orientation=bl[t.configOrientation],this._exactFitScreen=t.exactFitScreen,this._isHeadlessMode=t.isHeadlessMode,this._resizeFrame()},i.requestFullScreen=function(){var t=this;return new Promise((function(e,i){t.isFullScreen?e():(t._cachedFrameSize=t.windowSize,t._doRequestFullScreen().then((function(){e()})).catch((function(){var n=t._getFullscreenTarget();n?n.addEventListener(t._touchEventName,(function(){t._doRequestFullScreen().then((function(){e()})).catch(i)}),{once:!0,capture:!0}):i(new Error("Cannot access fullscreen target"))})))}))},i.exitFullScreen=function(){var t=this;return new Promise((function(e,i){var n=document[t._fn.exitFullscreen]();window.Promise&&n instanceof Promise?n.then((function(){t.windowSize=t._cachedFrameSize,e()})).catch(i):(t.windowSize=t._cachedFrameSize,e())}))},i._registerEvent=function(){var t=this;document.addEventListener(this._fn.fullscreenerror,(function(){var e;null===(e=t._onFullscreenError)||void 0===e||e.call(t)})),window.addEventListener("resize",(function(){t.handleResizeEvent&&t._resizeFrame()})),"function"==typeof window.matchMedia&&function e(){var i,n,r=window.devicePixelRatio;null===(i=window.matchMedia("(resolution: "+r+"dppx)"))||void 0===i||null===(n=i.addEventListener)||void 0===n||n.call(i,"change",(function(){t.emit("window-resize",t.windowSize.width,t.windowSize.height),e()}),{once:!0})}(),window.addEventListener("orientationchange",(function(){-1!==t._orientationChangeTimeoutId&&clearTimeout(t._orientationChangeTimeoutId),t._orientationChangeTimeoutId=setTimeout((function(){t.handleResizeEvent&&(t._updateFrameState(),t._resizeFrame(),t.emit("orientation-change",t.windowSize.width,t.windowSize.height),t._orientationChangeTimeoutId=-1)}),200)})),document.addEventListener(this._fn.fullscreenchange,(function(){var e;null===(e=t._onFullscreenChange)||void 0===e||e.call(t),t.emit("fullscreen-change",t.windowSize.width,t.windowSize.height)}))},i._convertToSizeInCssPixels=function(t){var e=t.clone(),i=this.devicePixelRatio;return e.width/=i,e.height/=i,e},i._resizeFrame=function(t){if(this._gameFrame){if(this._gameFrame.style.display="flex",this._gameFrame.style["justify-content"]="center",this._gameFrame.style["align-items"]="center",this._windowType===Al.SubFrame){if(!t)return void this._updateContainer();this._gameFrame.style.width=t.width+"px",this._gameFrame.style.height=t.height+"px"}else{var e=window.innerWidth,i=window.innerHeight;this.isFrameRotated?(this._gameFrame.style["-webkit-transform"]="rotate(90deg)",this._gameFrame.style.transform="rotate(90deg)",this._gameFrame.style["-webkit-transform-origin"]="0px 0px 0px",this._gameFrame.style.transformOrigin="0px 0px 0px",this._gameFrame.style.margin="0 0 0 "+e+"px",this._gameFrame.style.width=i+"px",this._gameFrame.style.height=e+"px"):(this._gameFrame.style["-webkit-transform"]="rotate(0deg)",this._gameFrame.style.transform="rotate(0deg)",this._gameFrame.style.margin="0px auto",this._gameFrame.style.width=e+"px",this._gameFrame.style.height=i+"px")}this._updateContainer()}},i._getFullscreenTarget=function(){var t=this._windowType;return t===Al.Fullscreen?document[this._fn.fullscreenElement]:t===Al.SubFrame?this._gameFrame:document.body},i._doRequestFullScreen=function(){var t=this;return new Promise((function(e,i){if(t._supportFullScreen){var n=t._getFullscreenTarget();if(n){t._onFullscreenChange=void 0,t._onFullscreenError=void 0;var r=n[t._fn.requestFullscreen]();window.Promise&&r instanceof Promise?r.then(e).catch(i):(t._onFullscreenChange=e,t._onFullscreenError=i)}else i(new Error("Cannot access fullscreen target"))}else i(new Error("fullscreen is not supported"))}))},i._updateFrameState=function(){var t=this.orientation,e=window.innerWidth>window.innerHeight;this.isFrameRotated=nl.isMobile&&(e&&t===Sl.PORTRAIT||!e&&t===Sl.LANDSCAPE)},i._updateContainer=function(){if(this._gameContainer){if(this.isProportionalToFrame){if(!this._gameFrame)return void Y(9201);var t,e,i=v.view.getDesignResolutionSize(),n=this._gameFrame,r=n.clientWidth,s=n.clientHeight,o=i.width,a=i.height,h=r/o,u=s/a,l=this._gameContainer.style;h<u?(t=r,e=a*h):(t=o*u,e=s),l.width=t+"px",l.height=e+"px"}else{var c=this._gameContainer.style;c.width="100%",c.height="100%"}!this._gameFrame||this._cachedFrameStyle.width===this._gameFrame.style.width&&this._cachedFrameStyle.height===this._gameFrame.style.height&&this._cachedContainerStyle.width===this._gameContainer.style.width&&this._cachedContainerStyle.height===this._gameContainer.style.height||(this.emit("window-resize",this.windowSize.width,this.windowSize.height),this._cachedFrameStyle.width=this._gameFrame.style.width,this._cachedFrameStyle.height=this._gameFrame.style.height,this._cachedContainerStyle.width=this._gameContainer.style.width,this._cachedContainerStyle.height=this._gameContainer.style.height)}else Y(9201)},n(e,[{key:"supportFullScreen",get:function(){return this._supportFullScreen}},{key:"isFullScreen",get:function(){return!!this._supportFullScreen&&!!document[this._fn.fullscreenElement]}},{key:"devicePixelRatio",get:function(){var t;return Math.min(null!==(t=window.devicePixelRatio)&&void 0!==t?t:1,2)}},{key:"windowSize",get:function(){var t=this._windowSizeInCssPixels,e=this.devicePixelRatio;return t.width*=e,t.height*=e,t},set:function(t){this._windowType===Al.SubFrame?this._resizeFrame(this._convertToSizeInCssPixels(t)):Y(9202)}},{key:"resolution",get:function(){var t=this.windowSize,e=this.resolutionScale;return new Vn(t.width*e,t.height*e)}},{key:"resolutionScale",get:function(){return this._resolutionScale},set:function(t){var e;t!==this._resolutionScale&&(this._resolutionScale=t,null===(e=this._cbToUpdateFrameBuffer)||void 0===e||e.call(this))}},{key:"orientation",get:function(){return this._orientation},set:function(t){this._orientation!==t&&(this._orientation=t,this._updateFrameState())}},{key:"safeAreaEdge",get:function(){var t=this.devicePixelRatio;return{top:parseInt(getComputedStyle(document.documentElement).getPropertyValue("--safe-top")||"0")*t,bottom:parseInt(getComputedStyle(document.documentElement).getPropertyValue("--safe-bottom")||"0")*t,left:parseInt(getComputedStyle(document.documentElement).getPropertyValue("--safe-left")||"0")*t,right:parseInt(getComputedStyle(document.documentElement).getPropertyValue("--safe-right")||"0")*t}}},{key:"isProportionalToFrame",get:function(){return this._isProportionalToFrame},set:function(t){this._isProportionalToFrame!==t&&(this._isProportionalToFrame=t,this._updateContainer())}},{key:"_windowSizeInCssPixels",get:function(){if(this.isProportionalToFrame)return this._gameContainer?new Vn(this._gameContainer.clientWidth,this._gameContainer.clientHeight):(Y(9201),new Vn(0,0));var t,e,i;switch(this._windowType){case Al.SubFrame:return this._gameFrame?new Vn(this._gameFrame.clientWidth,this._gameFrame.clientHeight):(Y(9201),new Vn(0,0));case Al.Fullscreen:return t=this._getFullscreenTarget(),e=this.isFrameRotated?t.clientHeight:t.clientWidth,i=this.isFrameRotated?t.clientWidth:t.clientHeight,new Vn(e,i);case Al.BrowserWindow:return e=this.isFrameRotated?window.innerHeight:window.innerWidth,i=this.isFrameRotated?window.innerWidth:window.innerHeight,new Vn(e,i);case Al.Unknown:default:return new Vn(0,0)}}},{key:"_windowType",get:function(){return this._isHeadlessMode?Al.Unknown:this.isFullScreen?Al.Fullscreen:this._gameFrame?this._exactFitScreen?Al.BrowserWindow:Al.SubFrame:(Y(9201),Al.Unknown)}}]),e}(Ku)),Cl=function(){function t(){}var e=t.prototype;return e.init=function(){var t,e,i=null===(t=Ee.querySettings(be.Category.SCREEN,"exactFitScreen"))||void 0===t||t,n=null!==(e=Ee.querySettings(be.Category.SCREEN,"orientation"))&&void 0!==e?e:"auto",r=3===Ee.querySettings(be.Category.RENDERING,"renderMode");El.init({exactFitScreen:i,configOrientation:n,isHeadlessMode:r},(function(){var t,e=v.director;null!==(t=e.root)&&void 0!==t&&t.pipeline?e.root.pipeline.shadingScale=El.resolutionScale:Y(1220)}))},e.fullScreen=function(){return El.isFullScreen},e.requestFullScreen=function(t,e,i){return arguments.length>0&&Y(1400,"screen.requestFullScreen(element, onFullScreenChange?, onFullScreenError?)","screen.requestFullScreen(): Promise"),El.requestFullScreen().then((function(){null==e||e.call(document)})).catch((function(t){V(t),null==i||i.call(document)}))},e.exitFullScreen=function(){return El.exitFullScreen()},e.autoFullScreen=function(t,e){var i;null===(i=this.requestFullScreen(t,e))||void 0===i||i.catch((function(t){k(t)}))},e.disableAutoFullScreen=function(){},e.on=function(t,e,i){El.on(t,e,i)},e.once=function(t,e,i){El.once(t,e,i)},e.off=function(t,e,i){El.off(t,e,i)},n(t,[{key:"devicePixelRatio",get:function(){return El.devicePixelRatio}},{key:"windowSize",get:function(){return El.windowSize},set:function(t){El.windowSize=t}},{key:"resolution",get:function(){return El.resolution}},{key:"supportsFullScreen",get:function(){return El.supportFullScreen}}]),t}(),wl=t("cg",new Cl);v.screen=wl;var xl=t("ch",{Feature:el,hasFeature:function(t){return nl.hasFeature(t)},NetworkType:Zu,Language:Qu,OS:$u,Platform:tl,BrowserType:Ju,isNative:nl.isNative,isBrowser:nl.isBrowser,isMobile:nl.isMobile,isLittleEndian:nl.isLittleEndian,platform:nl.platform,language:nl.language,languageCode:nl.nativeLanguage,os:nl.os,osVersion:nl.osVersion,osMainVersion:nl.osMainVersion,browserType:nl.browserType,browserVersion:nl.browserVersion,isXR:nl.isXR,windowPixelResolution:wl.windowSize,capabilities:{canvas:!0,opengl:!0,webp:nl.hasFeature(el.WEBP),imageBitmap:nl.hasFeature(el.IMAGE_BITMAP),touches:nl.hasFeature(el.INPUT_TOUCH),mouse:nl.hasFeature(el.EVENT_MOUSE),keyboard:nl.hasFeature(el.EVENT_KEYBOARD),accelerometer:nl.hasFeature(el.EVENT_ACCELEROMETER)},localStorage:{},getNetworkType:function(){return nl.networkType},getBatteryLevel:function(){return nl.getBatteryLevel()},garbageCollect:function(){nl.triggerGC()},isObjectValid:function(t){return null!=t},__isWebIOS14OrIPadOS14Env:!1,dump:function(){var t="";t+="isMobile : "+this.isMobile+"\r\n",t+="language : "+this.language+"\r\n",t+="browserType : "+this.browserType+"\r\n",t+="browserVersion : "+this.browserVersion+"\r\n",t+="supports webp: "+xl.hasFeature(el.WEBP)+"\r\n",t+="supports bitmap: "+xl.hasFeature(el.IMAGE_BITMAP)+"\r\n",t+="supports touches: "+xl.hasFeature(el.INPUT_TOUCH)+"\r\n",t+="supports mouse: "+xl.hasFeature(el.EVENT_MOUSE)+"\r\n",t+="supports keyboard: "+xl.hasFeature(el.EVENT_KEYBOARD)+"\r\n",t+="supports accelerometer: "+xl.hasFeature(el.EVENT_ACCELEROMETER)+"\r\n",t+="os : "+this.os+"\r\n",t+="osVersion : "+this.osVersion+"\r\n",t+="platform : "+this.platform+"\r\n",F(t+="Using "+(v.game.renderType===v.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n")},openURL:function(t){nl.openURL(t)},init:function(){var t=this;return Promise.resolve().then((function(){return nl.init()})).then((function(){try{var e=xl.localStorage=window.localStorage;e.setItem("storage",""),e.removeItem("storage"),e=null}catch(e){var i=function(){Y(5200)};t.localStorage={getItem:i,setItem:i,clear:i,removeItem:i,key:i,length:0}}t.__isWebIOS14OrIPadOS14Env=(xl.os===$u.IOS||xl.os===$u.OSX)&&nl.isBrowser&&/(OS 14)|(Version\/14)/.test(window.navigator.userAgent)}))},now:function(){return nl.now()},restartVM:function(){nl.restartJSVM()},getSafeAreaRect:function(){var t=v.view,e=El.safeAreaEdge,i=El.windowSize,n=new Ln(e.left,e.bottom),r=new Ln(i.width-e.right,i.height-e.top);t._convertToUISpace(n),t._convertToUISpace(r);var s=n.x,o=n.y,a=r.x-n.x,h=r.y-n.y;return new Un(s,o,a,h)}});v.sys=xl,st(v,"cc",[{name:"winSize",suggest:"please use view.getVisibleSize() instead."}]),st(xl,"sys",[{name:"capabilities",suggest:"please use sys.hasFeature() method instead."}]),nt(xl,"sys",["UNKNOWN","ENGLISH","CHINESE","FRENCH","ITALIAN","GERMAN","SPANISH","DUTCH","RUSSIAN","KOREAN","JAPANESE","HUNGARIAN","PORTUGUESE","ARABIC","NORWEGIAN","POLISH","TURKISH","UKRAINIAN","ROMANIAN","BULGARIAN"].map((function(t){return{name:"LANGUAGE_"+t,newName:t,target:xl.Language,targetName:"sys.Language"}}))),nt(xl,"sys",["UNKNOWN","IOS","ANDROID","WINDOWS","LINUX","OSX"].map((function(t){return{name:"OS_"+t,newName:t,target:xl.OS,targetName:"sys.OS"}}))),nt(xl,"sys",["UNKNOWN","WECHAT","ANDROID","IE","EDGE","QQ","MOBILE_QQ","UC","UCBS","BAIDU_APP","BAIDU","MAXTHON","OPERA","OUPENG","MIUI","FIREFOX","SAFARI","CHROME","LIEBAO","QZONE","SOUGOU","HUAWEI"].map((function(t){return{name:"BROWSER_TYPE_"+t,newName:t,target:xl.BrowserType,targetName:"sys.BrowserType"}}))),nt(xl,"sys",[{name:"BROWSER_TYPE_360",newName:"BROWSER_360",target:xl.BrowserType,targetName:"sys.BrowserType"}]),nt(xl,"sys",["UNKNOWN","EDITOR_PAGE","EDITOR_CORE","MOBILE_BROWSER","DESKTOP_BROWSER","WIN32","MACOS","IOS","ANDROID","OHOS","WECHAT_GAME","BAIDU_MINI_GAME","XIAOMI_QUICK_GAME","ALIPAY_MINI_GAME","BYTEDANCE_MINI_GAME","OPPO_MINI_GAME","VIVO_MINI_GAME","HUAWEI_QUICK_GAME","COCOSPLAY","LINKSURE_MINI_GAME","QTT_MINI_GAME"].map((function(t){return{name:t,target:xl.Platform,targetName:"sys.Platform"}}))),nt(xl,"sys",[{name:"IPHONE",newName:"IOS",target:xl.Platform,targetName:"sys.Platform"},{name:"IPAD",newName:"IOS",target:xl.Platform,targetName:"sys.Platform"}]),rt(xl,"sys",["LINUX","BLACKBERRY","NACL","EMSCRIPTEN","TIZEN","WINRT","WP8","QQ_PLAY","FB_PLAYABLE_ADS"].map((function(t){return{name:t}}))),nt(xl,"sys",[{name:"windowPixelResolution",target:wl,targetName:"screen",newName:"windowSize"}]),st(wl,"screen",[{name:"autoFullScreen",suggest:"please use screen.requestFullScreen() instead."},{name:"disableAutoFullScreen"}]);var Rl=t("cj",{topLeft:v.v2(0,0),topRight:v.v2(0,0),top:v.v2(0,0),bottomLeft:v.v2(0,0),bottomRight:v.v2(0,0),bottom:v.v2(0,0),center:v.v2(0,0),left:v.v2(0,0),right:v.v2(0,0),width:0,height:0,init:function(t){var e=this.width=t.width,i=this.height=t.height,n=t.x,r=t.y,s=r+i,o=n+e;this.topLeft.x=n,this.topLeft.y=s,this.topRight.x=o,this.topRight.y=s,this.top.x=n+e/2,this.top.y=s,this.bottomLeft.x=n,this.bottomLeft.y=r,this.bottomRight.x=o,this.bottomRight.y=r,this.bottom.x=n+e/2,this.bottom.y=r,this.center.x=n+e/2,this.center.y=r+i/2,this.left.x=n,this.left.y=r+i/2,this.right.x=o,this.right.y=r+i/2}});v.visibleRect=Rl;var Il=String.prototype.charCodeAt;function Bl(t){return this[t]}function Dl(t,e){for(var i=t.length,n=e^i,r=0,s="string"==typeof t?Il:Bl;i>=4;){var o=255&s.call(t,r)|(255&s.call(t,++r))<<8|(255&s.call(t,++r))<<16|(255&s.call(t,++r))<<24;o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(o=1540483477*(65535&(o^=o>>>24))+((1540483477*(o>>>16)&65535)<<16)),i-=4,++r}switch(i){case 3:n^=(255&s.call(t,r+2))<<16;case 2:n^=(255&s.call(t,r+1))<<8;case 1:n=1540483477*(65535&(n^=255&s.call(t,r)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}function Pl(){}v.easing=ja,Pl.prototype.once=function(t,e,i){return this.on(t,e,i,!0)},Pl.prototype.targetOff=function(t){this.removeAll(t)},t("cC",Object.freeze({__proto__:null,syncNodeValues:function(t){var e=t._lpos;t.setPositionForJS(e.x,e.y,e.z);var i=t._lscale;t.setScaleForJS(i.x,i.y,i.z);var n=t._lrot;t.setRotationForJS(n.x,n.y,n.z,n.w);var r=t._euler;t.setRotationFromEulerForJS(r.x,r.y,r.z)},updateChildrenForDeserialize:function t(e){if(e){var i=e.children;if(i){var n=i.length;if(n){e._setChildren(i);for(var r=0;r<n;++r)t(i[r])}}}},ExtraEventMethods:Pl}));var Ol=function(){function t(){this._finalizationRegistry=null,this._gcObjects=new WeakMap}var e=t.prototype;return e.registerGCObject=function(t){return t},e.init=function(){},e.finalizationRegistryCallback=function(t){var e=this._gcObjects.get(t);e&&(this._gcObjects.delete(t),e.destroy()),this._finalizationRegistry.unregister(t)},e.destroy=function(){},t}(),Ml=t("cQ",new Ol),Ll=t("cR",function(){function t(){return Ml.registerGCObject(this)}return t.prototype.destroy=function(){},t}());function Nl(t,e){for(var i,n=d(e);!(i=n()).done;){var r=i.value;Array.isArray(r)?Nl(t,r):t.push(r)}}function Fl(t){var e=[];return Nl(e,t),e.join("")}v.math=jn,v.geometry=xu;var kl,Vl,Gl,Ul,zl,Hl,Wl,jl,Xl,ql,Yl,Kl,Jl,Ql,Zl,$l,tc,ec,ic,nc,rc,sc,oc,ac,hc,uc,lc,cc,_c,dc,fc,pc,mc,gc,yc,vc,Sc,Tc,Ac,bc,Ec,Cc,wc,xc,Rc=function(t,e,i){for(var n=0;n<e.length;++n)t.length<=n&&t.push(new i),t[n].copy(e[n]);t.length=e.length};!function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.SWAPCHAIN=1]="SWAPCHAIN",t[t.BUFFER=2]="BUFFER",t[t.TEXTURE=3]="TEXTURE",t[t.RENDER_PASS=4]="RENDER_PASS",t[t.FRAMEBUFFER=5]="FRAMEBUFFER",t[t.SAMPLER=6]="SAMPLER",t[t.SHADER=7]="SHADER",t[t.DESCRIPTOR_SET_LAYOUT=8]="DESCRIPTOR_SET_LAYOUT",t[t.PIPELINE_LAYOUT=9]="PIPELINE_LAYOUT",t[t.PIPELINE_STATE=10]="PIPELINE_STATE",t[t.DESCRIPTOR_SET=11]="DESCRIPTOR_SET",t[t.INPUT_ASSEMBLER=12]="INPUT_ASSEMBLER",t[t.COMMAND_BUFFER=13]="COMMAND_BUFFER",t[t.QUEUE=14]="QUEUE",t[t.QUERY_POOL=15]="QUERY_POOL",t[t.GLOBAL_BARRIER=16]="GLOBAL_BARRIER",t[t.TEXTURE_BARRIER=17]="TEXTURE_BARRIER",t[t.BUFFER_BARRIER=18]="BUFFER_BARRIER",t[t.COUNT=19]="COUNT"}(kl||(kl={})),function(t){t[t.UNREADY=0]="UNREADY",t[t.FAILED=1]="FAILED",t[t.SUCCESS=2]="SUCCESS"}(Vl||(Vl={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.GLES2=1]="GLES2",t[t.GLES3=2]="GLES3",t[t.METAL=3]="METAL",t[t.VULKAN=4]="VULKAN",t[t.NVN=5]="NVN",t[t.WEBGL=6]="WEBGL",t[t.WEBGL2=7]="WEBGL2",t[t.WEBGPU=8]="WEBGPU"}(Gl||(Gl={})),function(t){t[t.IDENTITY=0]="IDENTITY",t[t.ROTATE_90=1]="ROTATE_90",t[t.ROTATE_180=2]="ROTATE_180",t[t.ROTATE_270=3]="ROTATE_270"}(Ul||(Ul={})),function(t){t[t.ELEMENT_INDEX_UINT=0]="ELEMENT_INDEX_UINT",t[t.INSTANCED_ARRAYS=1]="INSTANCED_ARRAYS",t[t.MULTIPLE_RENDER_TARGETS=2]="MULTIPLE_RENDER_TARGETS",t[t.BLEND_MINMAX=3]="BLEND_MINMAX",t[t.COMPUTE_SHADER=4]="COMPUTE_SHADER",t[t.INPUT_ATTACHMENT_BENEFIT=5]="INPUT_ATTACHMENT_BENEFIT",t[t.SUBPASS_COLOR_INPUT=6]="SUBPASS_COLOR_INPUT",t[t.SUBPASS_DEPTH_STENCIL_INPUT=7]="SUBPASS_DEPTH_STENCIL_INPUT",t[t.RASTERIZATION_ORDER_COHERENT=8]="RASTERIZATION_ORDER_COHERENT",t[t.MULTI_SAMPLE_RESOLVE_DEPTH_STENCIL=9]="MULTI_SAMPLE_RESOLVE_DEPTH_STENCIL",t[t.COUNT=10]="COUNT"}(zl||(zl={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.A8=1]="A8",t[t.L8=2]="L8",t[t.LA8=3]="LA8",t[t.R8=4]="R8",t[t.R8SN=5]="R8SN",t[t.R8UI=6]="R8UI",t[t.R8I=7]="R8I",t[t.R16F=8]="R16F",t[t.R16UI=9]="R16UI",t[t.R16I=10]="R16I",t[t.R32F=11]="R32F",t[t.R32UI=12]="R32UI",t[t.R32I=13]="R32I",t[t.RG8=14]="RG8",t[t.RG8SN=15]="RG8SN",t[t.RG8UI=16]="RG8UI",t[t.RG8I=17]="RG8I",t[t.RG16F=18]="RG16F",t[t.RG16UI=19]="RG16UI",t[t.RG16I=20]="RG16I",t[t.RG32F=21]="RG32F",t[t.RG32UI=22]="RG32UI",t[t.RG32I=23]="RG32I",t[t.RGB8=24]="RGB8",t[t.SRGB8=25]="SRGB8",t[t.RGB8SN=26]="RGB8SN",t[t.RGB8UI=27]="RGB8UI",t[t.RGB8I=28]="RGB8I",t[t.RGB16F=29]="RGB16F",t[t.RGB16UI=30]="RGB16UI",t[t.RGB16I=31]="RGB16I",t[t.RGB32F=32]="RGB32F",t[t.RGB32UI=33]="RGB32UI",t[t.RGB32I=34]="RGB32I",t[t.RGBA8=35]="RGBA8",t[t.BGRA8=36]="BGRA8",t[t.SRGB8_A8=37]="SRGB8_A8",t[t.RGBA8SN=38]="RGBA8SN",t[t.RGBA8UI=39]="RGBA8UI",t[t.RGBA8I=40]="RGBA8I",t[t.RGBA16F=41]="RGBA16F",t[t.RGBA16UI=42]="RGBA16UI",t[t.RGBA16I=43]="RGBA16I",t[t.RGBA32F=44]="RGBA32F",t[t.RGBA32UI=45]="RGBA32UI",t[t.RGBA32I=46]="RGBA32I",t[t.R5G6B5=47]="R5G6B5",t[t.R11G11B10F=48]="R11G11B10F",t[t.RGB5A1=49]="RGB5A1",t[t.RGBA4=50]="RGBA4",t[t.RGB10A2=51]="RGB10A2",t[t.RGB10A2UI=52]="RGB10A2UI",t[t.RGB9E5=53]="RGB9E5",t[t.DEPTH=54]="DEPTH",t[t.DEPTH_STENCIL=55]="DEPTH_STENCIL",t[t.BC1=56]="BC1",t[t.BC1_ALPHA=57]="BC1_ALPHA",t[t.BC1_SRGB=58]="BC1_SRGB",t[t.BC1_SRGB_ALPHA=59]="BC1_SRGB_ALPHA",t[t.BC2=60]="BC2",t[t.BC2_SRGB=61]="BC2_SRGB",t[t.BC3=62]="BC3",t[t.BC3_SRGB=63]="BC3_SRGB",t[t.BC4=64]="BC4",t[t.BC4_SNORM=65]="BC4_SNORM",t[t.BC5=66]="BC5",t[t.BC5_SNORM=67]="BC5_SNORM",t[t.BC6H_UF16=68]="BC6H_UF16",t[t.BC6H_SF16=69]="BC6H_SF16",t[t.BC7=70]="BC7",t[t.BC7_SRGB=71]="BC7_SRGB",t[t.ETC_RGB8=72]="ETC_RGB8",t[t.ETC2_RGB8=73]="ETC2_RGB8",t[t.ETC2_SRGB8=74]="ETC2_SRGB8",t[t.ETC2_RGB8_A1=75]="ETC2_RGB8_A1",t[t.ETC2_SRGB8_A1=76]="ETC2_SRGB8_A1",t[t.ETC2_RGBA8=77]="ETC2_RGBA8",t[t.ETC2_SRGB8_A8=78]="ETC2_SRGB8_A8",t[t.EAC_R11=79]="EAC_R11",t[t.EAC_R11SN=80]="EAC_R11SN",t[t.EAC_RG11=81]="EAC_RG11",t[t.EAC_RG11SN=82]="EAC_RG11SN",t[t.PVRTC_RGB2=83]="PVRTC_RGB2",t[t.PVRTC_RGBA2=84]="PVRTC_RGBA2",t[t.PVRTC_RGB4=85]="PVRTC_RGB4",t[t.PVRTC_RGBA4=86]="PVRTC_RGBA4",t[t.PVRTC2_2BPP=87]="PVRTC2_2BPP",t[t.PVRTC2_4BPP=88]="PVRTC2_4BPP",t[t.ASTC_RGBA_4X4=89]="ASTC_RGBA_4X4",t[t.ASTC_RGBA_5X4=90]="ASTC_RGBA_5X4",t[t.ASTC_RGBA_5X5=91]="ASTC_RGBA_5X5",t[t.ASTC_RGBA_6X5=92]="ASTC_RGBA_6X5",t[t.ASTC_RGBA_6X6=93]="ASTC_RGBA_6X6",t[t.ASTC_RGBA_8X5=94]="ASTC_RGBA_8X5",t[t.ASTC_RGBA_8X6=95]="ASTC_RGBA_8X6",t[t.ASTC_RGBA_8X8=96]="ASTC_RGBA_8X8",t[t.ASTC_RGBA_10X5=97]="ASTC_RGBA_10X5",t[t.ASTC_RGBA_10X6=98]="ASTC_RGBA_10X6",t[t.ASTC_RGBA_10X8=99]="ASTC_RGBA_10X8",t[t.ASTC_RGBA_10X10=100]="ASTC_RGBA_10X10",t[t.ASTC_RGBA_12X10=101]="ASTC_RGBA_12X10",t[t.ASTC_RGBA_12X12=102]="ASTC_RGBA_12X12",t[t.ASTC_SRGBA_4X4=103]="ASTC_SRGBA_4X4",t[t.ASTC_SRGBA_5X4=104]="ASTC_SRGBA_5X4",t[t.ASTC_SRGBA_5X5=105]="ASTC_SRGBA_5X5",t[t.ASTC_SRGBA_6X5=106]="ASTC_SRGBA_6X5",t[t.ASTC_SRGBA_6X6=107]="ASTC_SRGBA_6X6",t[t.ASTC_SRGBA_8X5=108]="ASTC_SRGBA_8X5",t[t.ASTC_SRGBA_8X6=109]="ASTC_SRGBA_8X6",t[t.ASTC_SRGBA_8X8=110]="ASTC_SRGBA_8X8",t[t.ASTC_SRGBA_10X5=111]="ASTC_SRGBA_10X5",t[t.ASTC_SRGBA_10X6=112]="ASTC_SRGBA_10X6",t[t.ASTC_SRGBA_10X8=113]="ASTC_SRGBA_10X8",t[t.ASTC_SRGBA_10X10=114]="ASTC_SRGBA_10X10",t[t.ASTC_SRGBA_12X10=115]="ASTC_SRGBA_12X10",t[t.ASTC_SRGBA_12X12=116]="ASTC_SRGBA_12X12",t[t.COUNT=117]="COUNT"}(Hl||(Hl={})),function(t){t[t.NONE=0]="NONE",t[t.UNORM=1]="UNORM",t[t.SNORM=2]="SNORM",t[t.UINT=3]="UINT",t[t.INT=4]="INT",t[t.UFLOAT=5]="UFLOAT",t[t.FLOAT=6]="FLOAT"}(Wl||(Wl={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.BOOL=1]="BOOL",t[t.BOOL2=2]="BOOL2",t[t.BOOL3=3]="BOOL3",t[t.BOOL4=4]="BOOL4",t[t.INT=5]="INT",t[t.INT2=6]="INT2",t[t.INT3=7]="INT3",t[t.INT4=8]="INT4",t[t.UINT=9]="UINT",t[t.UINT2=10]="UINT2",t[t.UINT3=11]="UINT3",t[t.UINT4=12]="UINT4",t[t.FLOAT=13]="FLOAT",t[t.FLOAT2=14]="FLOAT2",t[t.FLOAT3=15]="FLOAT3",t[t.FLOAT4=16]="FLOAT4",t[t.MAT2=17]="MAT2",t[t.MAT2X3=18]="MAT2X3",t[t.MAT2X4=19]="MAT2X4",t[t.MAT3X2=20]="MAT3X2",t[t.MAT3=21]="MAT3",t[t.MAT3X4=22]="MAT3X4",t[t.MAT4X2=23]="MAT4X2",t[t.MAT4X3=24]="MAT4X3",t[t.MAT4=25]="MAT4",t[t.SAMPLER1D=26]="SAMPLER1D",t[t.SAMPLER1D_ARRAY=27]="SAMPLER1D_ARRAY",t[t.SAMPLER2D=28]="SAMPLER2D",t[t.SAMPLER2D_ARRAY=29]="SAMPLER2D_ARRAY",t[t.SAMPLER3D=30]="SAMPLER3D",t[t.SAMPLER_CUBE=31]="SAMPLER_CUBE",t[t.SAMPLER=32]="SAMPLER",t[t.TEXTURE1D=33]="TEXTURE1D",t[t.TEXTURE1D_ARRAY=34]="TEXTURE1D_ARRAY",t[t.TEXTURE2D=35]="TEXTURE2D",t[t.TEXTURE2D_ARRAY=36]="TEXTURE2D_ARRAY",t[t.TEXTURE3D=37]="TEXTURE3D",t[t.TEXTURE_CUBE=38]="TEXTURE_CUBE",t[t.IMAGE1D=39]="IMAGE1D",t[t.IMAGE1D_ARRAY=40]="IMAGE1D_ARRAY",t[t.IMAGE2D=41]="IMAGE2D",t[t.IMAGE2D_ARRAY=42]="IMAGE2D_ARRAY",t[t.IMAGE3D=43]="IMAGE3D",t[t.IMAGE_CUBE=44]="IMAGE_CUBE",t[t.SUBPASS_INPUT=45]="SUBPASS_INPUT",t[t.COUNT=46]="COUNT"}(jl||(jl={})),function(t){t[t.NONE=0]="NONE",t[t.TRANSFER_SRC=1]="TRANSFER_SRC",t[t.TRANSFER_DST=2]="TRANSFER_DST",t[t.INDEX=4]="INDEX",t[t.VERTEX=8]="VERTEX",t[t.UNIFORM=16]="UNIFORM",t[t.STORAGE=32]="STORAGE",t[t.INDIRECT=64]="INDIRECT"}(Xl||(Xl={})),function(t){t[t.NONE=0]="NONE"}(ql||(ql={})),function(t){t[t.NONE=0]="NONE",t[t.READ_ONLY=1]="READ_ONLY",t[t.WRITE_ONLY=2]="WRITE_ONLY",t[t.READ_WRITE=3]="READ_WRITE"}(Yl||(Yl={})),function(t){t[t.NONE=0]="NONE",t[t.DEVICE=1]="DEVICE",t[t.HOST=2]="HOST"}(Kl||(Kl={})),function(t){t[t.TEX1D=0]="TEX1D",t[t.TEX2D=1]="TEX2D",t[t.TEX3D=2]="TEX3D",t[t.CUBE=3]="CUBE",t[t.TEX1D_ARRAY=4]="TEX1D_ARRAY",t[t.TEX2D_ARRAY=5]="TEX2D_ARRAY"}(Jl||(Jl={})),function(t){t[t.NONE=0]="NONE",t[t.TRANSFER_SRC=1]="TRANSFER_SRC",t[t.TRANSFER_DST=2]="TRANSFER_DST",t[t.SAMPLED=4]="SAMPLED",t[t.STORAGE=8]="STORAGE",t[t.COLOR_ATTACHMENT=16]="COLOR_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=32]="DEPTH_STENCIL_ATTACHMENT",t[t.INPUT_ATTACHMENT=64]="INPUT_ATTACHMENT"}(Ql||(Ql={})),function(t){t[t.NONE=0]="NONE",t[t.GEN_MIPMAP=1]="GEN_MIPMAP",t[t.GENERAL_LAYOUT=2]="GENERAL_LAYOUT",t[t.EXTERNAL_OES=4]="EXTERNAL_OES",t[t.EXTERNAL_NORMAL=8]="EXTERNAL_NORMAL",t[t.LAZILY_ALLOCATED=16]="LAZILY_ALLOCATED",t[t.MUTABLE_VIEW_FORMAT=64]="MUTABLE_VIEW_FORMAT",t[t.MUTABLE_STORAGE=128]="MUTABLE_STORAGE"}(Zl||(Zl={})),function(t){t[t.NONE=0]="NONE",t[t.RENDER_TARGET=1]="RENDER_TARGET",t[t.SAMPLED_TEXTURE=2]="SAMPLED_TEXTURE",t[t.LINEAR_FILTER=4]="LINEAR_FILTER",t[t.STORAGE_TEXTURE=8]="STORAGE_TEXTURE",t[t.VERTEX_ATTRIBUTE=16]="VERTEX_ATTRIBUTE"}($l||($l={})),function(t){t[t.X1=1]="X1",t[t.X2=2]="X2",t[t.X4=4]="X4",t[t.X8=8]="X8",t[t.X16=16]="X16",t[t.X32=32]="X32",t[t.X64=64]="X64"}(tc||(tc={})),function(t){t[t.OFF=0]="OFF",t[t.ON=1]="ON",t[t.RELAXED=2]="RELAXED",t[t.MAILBOX=3]="MAILBOX",t[t.HALF=4]="HALF"}(ec||(ec={})),function(t){t[t.NONE=0]="NONE",t[t.POINT=1]="POINT",t[t.LINEAR=2]="LINEAR",t[t.ANISOTROPIC=3]="ANISOTROPIC"}(ic||(ic={})),function(t){t[t.WRAP=0]="WRAP",t[t.MIRROR=1]="MIRROR",t[t.CLAMP=2]="CLAMP",t[t.BORDER=3]="BORDER"}(nc||(nc={})),function(t){t[t.NEVER=0]="NEVER",t[t.LESS=1]="LESS",t[t.EQUAL=2]="EQUAL",t[t.LESS_EQUAL=3]="LESS_EQUAL",t[t.GREATER=4]="GREATER",t[t.NOT_EQUAL=5]="NOT_EQUAL",t[t.GREATER_EQUAL=6]="GREATER_EQUAL",t[t.ALWAYS=7]="ALWAYS"}(rc||(rc={})),function(t){t[t.ZERO=0]="ZERO",t[t.KEEP=1]="KEEP",t[t.REPLACE=2]="REPLACE",t[t.INCR=3]="INCR",t[t.DECR=4]="DECR",t[t.INVERT=5]="INVERT",t[t.INCR_WRAP=6]="INCR_WRAP",t[t.DECR_WRAP=7]="DECR_WRAP"}(sc||(sc={})),function(t){t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=2]="SRC_ALPHA",t[t.DST_ALPHA=3]="DST_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=4]="ONE_MINUS_SRC_ALPHA",t[t.ONE_MINUS_DST_ALPHA=5]="ONE_MINUS_DST_ALPHA",t[t.SRC_COLOR=6]="SRC_COLOR",t[t.DST_COLOR=7]="DST_COLOR",t[t.ONE_MINUS_SRC_COLOR=8]="ONE_MINUS_SRC_COLOR",t[t.ONE_MINUS_DST_COLOR=9]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=10]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=11]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=12]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=13]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=14]="ONE_MINUS_CONSTANT_ALPHA"}(oc||(oc={})),function(t){t[t.ADD=0]="ADD",t[t.SUB=1]="SUB",t[t.REV_SUB=2]="REV_SUB",t[t.MIN=3]="MIN",t[t.MAX=4]="MAX"}(ac||(ac={})),function(t){t[t.NONE=0]="NONE",t[t.R=1]="R",t[t.G=2]="G",t[t.B=4]="B",t[t.A=8]="A",t[t.ALL=15]="ALL"}(hc||(hc={})),function(t){t[t.NONE=0]="NONE",t[t.VERTEX=1]="VERTEX",t[t.CONTROL=2]="CONTROL",t[t.EVALUATION=4]="EVALUATION",t[t.GEOMETRY=8]="GEOMETRY",t[t.FRAGMENT=16]="FRAGMENT",t[t.COMPUTE=32]="COMPUTE",t[t.ALL=63]="ALL"}(uc||(uc={})),function(t){t[t.LOAD=0]="LOAD",t[t.CLEAR=1]="CLEAR",t[t.DISCARD=2]="DISCARD"}(lc||(lc={})),function(t){t[t.STORE=0]="STORE",t[t.DISCARD=1]="DISCARD"}(cc||(cc={})),function(t){t[t.NONE=0]="NONE",t[t.INDIRECT_BUFFER=1]="INDIRECT_BUFFER",t[t.INDEX_BUFFER=2]="INDEX_BUFFER",t[t.VERTEX_BUFFER=4]="VERTEX_BUFFER",t[t.VERTEX_SHADER_READ_UNIFORM_BUFFER=8]="VERTEX_SHADER_READ_UNIFORM_BUFFER",t[t.VERTEX_SHADER_READ_TEXTURE=16]="VERTEX_SHADER_READ_TEXTURE",t[t.VERTEX_SHADER_READ_OTHER=32]="VERTEX_SHADER_READ_OTHER",t[t.FRAGMENT_SHADER_READ_UNIFORM_BUFFER=64]="FRAGMENT_SHADER_READ_UNIFORM_BUFFER",t[t.FRAGMENT_SHADER_READ_TEXTURE=128]="FRAGMENT_SHADER_READ_TEXTURE",t[t.FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT=256]="FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT",t[t.FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT=512]="FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT",t[t.FRAGMENT_SHADER_READ_OTHER=1024]="FRAGMENT_SHADER_READ_OTHER",t[t.COLOR_ATTACHMENT_READ=2048]="COLOR_ATTACHMENT_READ",t[t.DEPTH_STENCIL_ATTACHMENT_READ=4096]="DEPTH_STENCIL_ATTACHMENT_READ",t[t.COMPUTE_SHADER_READ_UNIFORM_BUFFER=8192]="COMPUTE_SHADER_READ_UNIFORM_BUFFER",t[t.COMPUTE_SHADER_READ_TEXTURE=16384]="COMPUTE_SHADER_READ_TEXTURE",t[t.COMPUTE_SHADER_READ_OTHER=32768]="COMPUTE_SHADER_READ_OTHER",t[t.TRANSFER_READ=65536]="TRANSFER_READ",t[t.HOST_READ=131072]="HOST_READ",t[t.PRESENT=262144]="PRESENT",t[t.VERTEX_SHADER_WRITE=524288]="VERTEX_SHADER_WRITE",t[t.FRAGMENT_SHADER_WRITE=1048576]="FRAGMENT_SHADER_WRITE",t[t.COLOR_ATTACHMENT_WRITE=2097152]="COLOR_ATTACHMENT_WRITE",t[t.DEPTH_STENCIL_ATTACHMENT_WRITE=4194304]="DEPTH_STENCIL_ATTACHMENT_WRITE",t[t.COMPUTE_SHADER_WRITE=8388608]="COMPUTE_SHADER_WRITE",t[t.TRANSFER_WRITE=16777216]="TRANSFER_WRITE",t[t.HOST_PREINITIALIZED=33554432]="HOST_PREINITIALIZED",t[t.HOST_WRITE=67108864]="HOST_WRITE"}(_c||(_c={})),function(t){t[t.NONE=0]="NONE",t[t.SAMPLE_ZERO=1]="SAMPLE_ZERO",t[t.AVERAGE=2]="AVERAGE",t[t.MIN=3]="MIN",t[t.MAX=4]="MAX"}(dc||(dc={})),function(t){t[t.GRAPHICS=0]="GRAPHICS",t[t.COMPUTE=1]="COMPUTE",t[t.RAY_TRACING=2]="RAY_TRACING"}(fc||(fc={})),function(t){t[t.POINT_LIST=0]="POINT_LIST",t[t.LINE_LIST=1]="LINE_LIST",t[t.LINE_STRIP=2]="LINE_STRIP",t[t.LINE_LOOP=3]="LINE_LOOP",t[t.LINE_LIST_ADJACENCY=4]="LINE_LIST_ADJACENCY",t[t.LINE_STRIP_ADJACENCY=5]="LINE_STRIP_ADJACENCY",t[t.ISO_LINE_LIST=6]="ISO_LINE_LIST",t[t.TRIANGLE_LIST=7]="TRIANGLE_LIST",t[t.TRIANGLE_STRIP=8]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=9]="TRIANGLE_FAN",t[t.TRIANGLE_LIST_ADJACENCY=10]="TRIANGLE_LIST_ADJACENCY",t[t.TRIANGLE_STRIP_ADJACENCY=11]="TRIANGLE_STRIP_ADJACENCY",t[t.TRIANGLE_PATCH_ADJACENCY=12]="TRIANGLE_PATCH_ADJACENCY",t[t.QUAD_PATCH_LIST=13]="QUAD_PATCH_LIST"}(pc||(pc={})),function(t){t[t.FILL=0]="FILL",t[t.POINT=1]="POINT",t[t.LINE=2]="LINE"}(mc||(mc={})),function(t){t[t.GOURAND=0]="GOURAND",t[t.FLAT=1]="FLAT"}(gc||(gc={})),function(t){t[t.NONE=0]="NONE",t[t.FRONT=1]="FRONT",t[t.BACK=2]="BACK"}(yc||(yc={})),function(t){t[t.NONE=0]="NONE",t[t.LINE_WIDTH=1]="LINE_WIDTH",t[t.DEPTH_BIAS=2]="DEPTH_BIAS",t[t.BLEND_CONSTANTS=4]="BLEND_CONSTANTS",t[t.DEPTH_BOUNDS=8]="DEPTH_BOUNDS",t[t.STENCIL_WRITE_MASK=16]="STENCIL_WRITE_MASK",t[t.STENCIL_COMPARE_MASK=32]="STENCIL_COMPARE_MASK"}(vc||(vc={})),function(t){t[t.FRONT=1]="FRONT",t[t.BACK=2]="BACK",t[t.ALL=3]="ALL"}(Sc||(Sc={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.UNIFORM_BUFFER=1]="UNIFORM_BUFFER",t[t.DYNAMIC_UNIFORM_BUFFER=2]="DYNAMIC_UNIFORM_BUFFER",t[t.STORAGE_BUFFER=4]="STORAGE_BUFFER",t[t.DYNAMIC_STORAGE_BUFFER=8]="DYNAMIC_STORAGE_BUFFER",t[t.SAMPLER_TEXTURE=16]="SAMPLER_TEXTURE",t[t.SAMPLER=32]="SAMPLER",t[t.TEXTURE=64]="TEXTURE",t[t.STORAGE_IMAGE=128]="STORAGE_IMAGE",t[t.INPUT_ATTACHMENT=256]="INPUT_ATTACHMENT"}(Tc||(Tc={})),function(t){t[t.GRAPHICS=0]="GRAPHICS",t[t.COMPUTE=1]="COMPUTE",t[t.TRANSFER=2]="TRANSFER"}(Ac||(Ac={})),function(t){t[t.OCCLUSION=0]="OCCLUSION",t[t.PIPELINE_STATISTICS=1]="PIPELINE_STATISTICS",t[t.TIMESTAMP=2]="TIMESTAMP"}(bc||(bc={})),function(t){t[t.PRIMARY=0]="PRIMARY",t[t.SECONDARY=1]="SECONDARY"}(Ec||(Ec={})),function(t){t[t.NONE=0]="NONE",t[t.COLOR=1]="COLOR",t[t.DEPTH=2]="DEPTH",t[t.STENCIL=4]="STENCIL",t[t.DEPTH_STENCIL=6]="DEPTH_STENCIL",t[t.ALL=7]="ALL"}(Cc||(Cc={})),function(t){t[t.FULL=0]="FULL",t[t.SPLIT_BEGIN=1]="SPLIT_BEGIN",t[t.SPLIT_END=2]="SPLIT_END"}(wc||(wc={})),function(t){t[t.RASTER=0]="RASTER",t[t.COMPUTE=1]="COMPUTE",t[t.COPY=2]="COPY",t[t.MOVE=3]="MOVE",t[t.RAYTRACE=4]="RAYTRACE",t[t.PRESENT=5]="PRESENT"}(xc||(xc={}));var Ic,Bc=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=i}return t.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t}(),Dc=function(){function t(t,e,i,n,r,s,o,a,h,u,l,c,_,d,f,p,m,g,y,v,S,T,A,b){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===_&&(_=0),void 0===d&&(d=0),void 0===f&&(f=0),void 0===p&&(p=1),void 0===m&&(m=0),void 0===g&&(g=0),void 0===y&&(y=new Bc),void 0===v&&(v=new Bc),void 0===S&&(S=!1),void 0===T&&(T=-1),void 0===A&&(A=1),void 0===b&&(b=1),this.maxVertexAttributes=t,this.maxVertexUniformVectors=e,this.maxFragmentUniformVectors=i,this.maxTextureUnits=n,this.maxImageUnits=r,this.maxVertexTextureUnits=s,this.maxColorRenderTargets=o,this.maxShaderStorageBufferBindings=a,this.maxShaderStorageBlockSize=h,this.maxUniformBufferBindings=u,this.maxUniformBlockSize=l,this.maxTextureSize=c,this.maxCubeMapTextureSize=_,this.maxArrayTextureLayers=d,this.max3DTextureSize=f,this.uboOffsetAlignment=p,this.maxComputeSharedMemorySize=m,this.maxComputeWorkGroupInvocations=g,this.maxComputeWorkGroupSize=y,this.maxComputeWorkGroupCount=v,this.supportQuery=S,this.clipSpaceMinZ=T,this.screenSpaceSignY=A,this.clipSpaceSignY=b}return t.prototype.copy=function(t){return this.maxVertexAttributes=t.maxVertexAttributes,this.maxVertexUniformVectors=t.maxVertexUniformVectors,this.maxFragmentUniformVectors=t.maxFragmentUniformVectors,this.maxTextureUnits=t.maxTextureUnits,this.maxImageUnits=t.maxImageUnits,this.maxVertexTextureUnits=t.maxVertexTextureUnits,this.maxColorRenderTargets=t.maxColorRenderTargets,this.maxShaderStorageBufferBindings=t.maxShaderStorageBufferBindings,this.maxShaderStorageBlockSize=t.maxShaderStorageBlockSize,this.maxUniformBufferBindings=t.maxUniformBufferBindings,this.maxUniformBlockSize=t.maxUniformBlockSize,this.maxTextureSize=t.maxTextureSize,this.maxCubeMapTextureSize=t.maxCubeMapTextureSize,this.maxArrayTextureLayers=t.maxArrayTextureLayers,this.max3DTextureSize=t.max3DTextureSize,this.uboOffsetAlignment=t.uboOffsetAlignment,this.maxComputeSharedMemorySize=t.maxComputeSharedMemorySize,this.maxComputeWorkGroupInvocations=t.maxComputeWorkGroupInvocations,this.maxComputeWorkGroupSize.copy(t.maxComputeWorkGroupSize),this.maxComputeWorkGroupCount.copy(t.maxComputeWorkGroupCount),this.supportQuery=t.supportQuery,this.clipSpaceMinZ=t.clipSpaceMinZ,this.screenSpaceSignY=t.screenSpaceSignY,this.clipSpaceSignY=t.clipSpaceSignY,this},t}(),Pc=function(){function t(t){void 0===t&&(t=!0),this.enableBarrierDeduce=t}return t.prototype.copy=function(t){return this.enableBarrierDeduce=t.enableBarrierDeduce,this},t}(),Oc=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=i}return t.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t}(),Mc=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n}return t.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},t}(),Lc=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=1),this.width=t,this.height=e,this.depth=i}return t.prototype.copy=function(t){return this.width=t.width,this.height=t.height,this.depth=t.depth,this},t}(),Nc=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=1),this.mipLevel=t,this.baseArrayLayer=e,this.layerCount=i}return t.prototype.copy=function(t){return this.mipLevel=t.mipLevel,this.baseArrayLayer=t.baseArrayLayer,this.layerCount=t.layerCount,this},t}(),Fc=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=1),this.baseMipLevel=t,this.levelCount=e,this.baseArrayLayer=i,this.layerCount=n}return t.prototype.copy=function(t){return this.baseMipLevel=t.baseMipLevel,this.levelCount=t.levelCount,this.baseArrayLayer=t.baseArrayLayer,this.layerCount=t.layerCount,this},t}(),kc=function(){function t(t,e,i,n,r){void 0===t&&(t=new Nc),void 0===e&&(e=new Oc),void 0===i&&(i=new Nc),void 0===n&&(n=new Oc),void 0===r&&(r=new Lc),this.srcSubres=t,this.srcOffset=e,this.dstSubres=i,this.dstOffset=n,this.extent=r}return t.prototype.copy=function(t){return this.srcSubres.copy(t.srcSubres),this.srcOffset.copy(t.srcOffset),this.dstSubres.copy(t.dstSubres),this.dstOffset.copy(t.dstOffset),this.extent.copy(t.extent),this},t}(),Vc=function(){function t(t,e,i,n,r,s){void 0===t&&(t=new Nc),void 0===e&&(e=new Oc),void 0===i&&(i=new Lc),void 0===n&&(n=new Nc),void 0===r&&(r=new Oc),void 0===s&&(s=new Lc),this.srcSubres=t,this.srcOffset=e,this.srcExtent=i,this.dstSubres=n,this.dstOffset=r,this.dstExtent=s}return t.prototype.copy=function(t){return this.srcSubres.copy(t.srcSubres),this.srcOffset.copy(t.srcOffset),this.srcExtent.copy(t.srcExtent),this.dstSubres.copy(t.dstSubres),this.dstOffset.copy(t.dstOffset),this.dstExtent.copy(t.dstExtent),this},t}(),Gc=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=new Oc),void 0===r&&(r=new Lc),void 0===s&&(s=new Nc),this.buffOffset=t,this.buffStride=e,this.buffTexHeight=i,this.texOffset=n,this.texExtent=r,this.texSubres=s}return t.prototype.copy=function(t){return this.buffOffset=t.buffOffset,this.buffStride=t.buffStride,this.buffTexHeight=t.buffTexHeight,this.texOffset.copy(t.texOffset),this.texExtent.copy(t.texExtent),this.texSubres.copy(t.texSubres),this},t}(),Uc=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=1),this.left=t,this.top=e,this.width=i,this.height=n,this.minDepth=r,this.maxDepth=s}var e=t.prototype;return e.copy=function(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this.minDepth=t.minDepth,this.maxDepth=t.maxDepth,this},e.reset=function(){this.left=0,this.top=0,this.width=0,this.height=0,this.minDepth=0,this.maxDepth=1},t}(),zc=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=i,this.w=n}var e=t.prototype;return e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.set=function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},e.reset=function(){this.x=0,this.y=0,this.z=0,this.w=0},t}(),Hc=function(){function t(t,e,i,n,r,s,o,a){void 0===t&&(t=[0]),void 0===e&&(e=[0]),void 0===i&&(i=[0]),void 0===n&&(n=[0]),void 0===r&&(r=[0]),void 0===s&&(s=[0]),void 0===o&&(o=[0]),void 0===a&&(a=[0]),this.maxBlockCounts=t,this.maxSamplerTextureCounts=e,this.maxSamplerCounts=i,this.maxTextureCounts=n,this.maxBufferCounts=r,this.maxImageCounts=s,this.maxSubpassInputCounts=o,this.setIndices=a}return t.prototype.copy=function(t){return this.maxBlockCounts=t.maxBlockCounts.slice(),this.maxSamplerTextureCounts=t.maxSamplerTextureCounts.slice(),this.maxSamplerCounts=t.maxSamplerCounts.slice(),this.maxTextureCounts=t.maxTextureCounts.slice(),this.maxBufferCounts=t.maxBufferCounts.slice(),this.maxImageCounts=t.maxImageCounts.slice(),this.maxSubpassInputCounts=t.maxSubpassInputCounts.slice(),this.setIndices=t.setIndices.slice(),this},t}(),Wc=function(){function t(t,e,i,n,r){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=ec.ON),void 0===n&&(n=0),void 0===r&&(r=0),this.windowId=t,this.windowHandle=e,this.vsyncMode=i,this.width=n,this.height=r}return t.prototype.copy=function(t){return this.windowId=t.windowId,this.windowHandle=t.windowHandle,this.vsyncMode=t.vsyncMode,this.width=t.width,this.height=t.height,this},t}(),jc=function(){function t(t){void 0===t&&(t=new Hc),this.bindingMappingInfo=t}return t.prototype.copy=function(t){return this.bindingMappingInfo.copy(t.bindingMappingInfo),this},t}(),Xc=function(){function t(t,e,i,n,r){void 0===t&&(t=Xl.NONE),void 0===e&&(e=Kl.NONE),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=ql.NONE),this.usage=t,this.memUsage=e,this.size=i,this.stride=n,this.flags=r}return t.prototype.copy=function(t){return this.usage=t.usage,this.memUsage=t.memUsage,this.size=t.size,this.stride=t.stride,this.flags=t.flags,this},t}(),qc=function(){function t(t,e,i){void 0===t&&(t=null),void 0===e&&(e=0),void 0===i&&(i=0),this.buffer=t,this.offset=e,this.range=i}return t.prototype.copy=function(t){return this.buffer=t.buffer,this.offset=t.offset,this.range=t.range,this},t}(),Yc=function(){function t(t,e,i,n,r,s,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),this.vertexCount=t,this.firstVertex=e,this.indexCount=i,this.firstIndex=n,this.vertexOffset=r,this.instanceCount=s,this.firstInstance=o}return t.prototype.copy=function(t){return this.vertexCount=t.vertexCount,this.firstVertex=t.firstVertex,this.indexCount=t.indexCount,this.firstIndex=t.firstIndex,this.vertexOffset=t.vertexOffset,this.instanceCount=t.instanceCount,this.firstInstance=t.firstInstance,this},t}(),Kc=function(){function t(t,e,i,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=null),void 0===r&&(r=0),this.groupCountX=t,this.groupCountY=e,this.groupCountZ=i,this.indirectBuffer=n,this.indirectOffset=r}return t.prototype.copy=function(t){return this.groupCountX=t.groupCountX,this.groupCountY=t.groupCountY,this.groupCountZ=t.groupCountZ,this.indirectBuffer=t.indirectBuffer,this.indirectOffset=t.indirectOffset,this},t}(),Jc=function(){function t(t){void 0===t&&(t=[]),this.drawInfos=t}return t.prototype.copy=function(t){return Rc(this.drawInfos,t.drawInfos,Yc),this},t}(),Qc=function(){function t(t,e,i,n,r,s,o,a,h,u,l){void 0===t&&(t=Jl.TEX2D),void 0===e&&(e=Ql.NONE),void 0===i&&(i=Hl.UNKNOWN),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=Zl.NONE),void 0===o&&(o=1),void 0===a&&(a=1),void 0===h&&(h=tc.X1),void 0===u&&(u=1),void 0===l&&(l=0),this.type=t,this.usage=e,this.format=i,this.width=n,this.height=r,this.flags=s,this.layerCount=o,this.levelCount=a,this.samples=h,this.depth=u,this.externalRes=l}return t.prototype.copy=function(t){return this.type=t.type,this.usage=t.usage,this.format=t.format,this.width=t.width,this.height=t.height,this.flags=t.flags,this.layerCount=t.layerCount,this.levelCount=t.levelCount,this.samples=t.samples,this.depth=t.depth,this.externalRes=t.externalRes,this},t}(),Zc=function(){function t(t,e,i,n,r,s,o){void 0===t&&(t=null),void 0===e&&(e=Jl.TEX2D),void 0===i&&(i=Hl.UNKNOWN),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=0),void 0===o&&(o=1),this.texture=t,this.type=e,this.format=i,this.baseLevel=n,this.levelCount=r,this.baseLayer=s,this.layerCount=o}return t.prototype.copy=function(t){return this.texture=t.texture,this.type=t.type,this.format=t.format,this.baseLevel=t.baseLevel,this.levelCount=t.levelCount,this.baseLayer=t.baseLayer,this.layerCount=t.layerCount,this},t}(),$c=function(){function t(t,e,i,n,r,s,o,a){void 0===t&&(t=ic.LINEAR),void 0===e&&(e=ic.LINEAR),void 0===i&&(i=ic.NONE),void 0===n&&(n=nc.WRAP),void 0===r&&(r=nc.WRAP),void 0===s&&(s=nc.WRAP),void 0===o&&(o=0),void 0===a&&(a=rc.ALWAYS),this.minFilter=t,this.magFilter=e,this.mipFilter=i,this.addressU=n,this.addressV=r,this.addressW=s,this.maxAnisotropy=o,this.cmpFunc=a}return t.prototype.copy=function(t){return this.minFilter=t.minFilter,this.magFilter=t.magFilter,this.mipFilter=t.mipFilter,this.addressU=t.addressU,this.addressV=t.addressV,this.addressW=t.addressW,this.maxAnisotropy=t.maxAnisotropy,this.cmpFunc=t.cmpFunc,this},t}(),t_=function(){function t(t,e,i){void 0===t&&(t=""),void 0===e&&(e=jl.UNKNOWN),void 0===i&&(i=0),this.name=t,this.type=e,this.count=i}return t.prototype.copy=function(t){return this.name=t.name,this.type=t.type,this.count=t.count,this},t}(),e_=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=""),void 0===n&&(n=[]),void 0===r&&(r=0),void 0===s&&(s=0),this.set=t,this.binding=e,this.name=i,this.members=n,this.count=r,this.flattened=s}return t.prototype.copy=function(t){return this.set=t.set,this.binding=t.binding,this.name=t.name,Rc(this.members,t.members,t_),this.count=t.count,this.flattened=t.flattened,this},t}(),i_=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=""),void 0===n&&(n=jl.UNKNOWN),void 0===r&&(r=0),void 0===s&&(s=0),this.set=t,this.binding=e,this.name=i,this.type=n,this.count=r,this.flattened=s}return t.prototype.copy=function(t){return this.set=t.set,this.binding=t.binding,this.name=t.name,this.type=t.type,this.count=t.count,this.flattened=t.flattened,this},t}(),n_=function(){function t(t,e,i,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=""),void 0===n&&(n=0),void 0===r&&(r=0),this.set=t,this.binding=e,this.name=i,this.count=n,this.flattened=r}return t.prototype.copy=function(t){return this.set=t.set,this.binding=t.binding,this.name=t.name,this.count=t.count,this.flattened=t.flattened,this},t}(),r_=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=""),void 0===n&&(n=jl.UNKNOWN),void 0===r&&(r=0),void 0===s&&(s=0),this.set=t,this.binding=e,this.name=i,this.type=n,this.count=r,this.flattened=s}return t.prototype.copy=function(t){return this.set=t.set,this.binding=t.binding,this.name=t.name,this.type=t.type,this.count=t.count,this.flattened=t.flattened,this},t}(),s_=function(){function t(t,e,i,n,r,s,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=""),void 0===n&&(n=jl.UNKNOWN),void 0===r&&(r=0),void 0===s&&(s=Yl.READ_WRITE),void 0===o&&(o=0),this.set=t,this.binding=e,this.name=i,this.type=n,this.count=r,this.memoryAccess=s,this.flattened=o}return t.prototype.copy=function(t){return this.set=t.set,this.binding=t.binding,this.name=t.name,this.type=t.type,this.count=t.count,this.memoryAccess=t.memoryAccess,this.flattened=t.flattened,this},t}(),o_=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=""),void 0===n&&(n=0),void 0===r&&(r=Yl.READ_WRITE),void 0===s&&(s=0),this.set=t,this.binding=e,this.name=i,this.count=n,this.memoryAccess=r,this.flattened=s}return t.prototype.copy=function(t){return this.set=t.set,this.binding=t.binding,this.name=t.name,this.count=t.count,this.memoryAccess=t.memoryAccess,this.flattened=t.flattened,this},t}(),a_=function(){function t(t,e,i,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=""),void 0===n&&(n=0),void 0===r&&(r=0),this.set=t,this.binding=e,this.name=i,this.count=n,this.flattened=r}return t.prototype.copy=function(t){return this.set=t.set,this.binding=t.binding,this.name=t.name,this.count=t.count,this.flattened=t.flattened,this},t}(),h_=function(){function t(t,e){void 0===t&&(t=uc.NONE),void 0===e&&(e=""),this.stage=t,this.source=e}return t.prototype.copy=function(t){return this.stage=t.stage,this.source=t.source,this},t}(),u_=function(){function t(t,e,i,n,r,s){void 0===t&&(t=""),void 0===e&&(e=Hl.UNKNOWN),void 0===i&&(i=!1),void 0===n&&(n=0),void 0===r&&(r=!1),void 0===s&&(s=0),this.name=t,this.format=e,this.isNormalized=i,this.stream=n,this.isInstanced=r,this.location=s}return t.prototype.copy=function(t){return this.name=t.name,this.format=t.format,this.isNormalized=t.isNormalized,this.stream=t.stream,this.isInstanced=t.isInstanced,this.location=t.location,this},t}(),l_=function(){function t(t,e,i,n,r,s,o,a,h,u){void 0===t&&(t=""),void 0===e&&(e=[]),void 0===i&&(i=[]),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===s&&(s=[]),void 0===o&&(o=[]),void 0===a&&(a=[]),void 0===h&&(h=[]),void 0===u&&(u=[]),this.name=t,this.stages=e,this.attributes=i,this.blocks=n,this.buffers=r,this.samplerTextures=s,this.samplers=o,this.textures=a,this.images=h,this.subpassInputs=u}return t.prototype.copy=function(t){return this.name=t.name,Rc(this.stages,t.stages,h_),Rc(this.attributes,t.attributes,u_),Rc(this.blocks,t.blocks,e_),Rc(this.buffers,t.buffers,o_),Rc(this.samplerTextures,t.samplerTextures,i_),Rc(this.samplers,t.samplers,n_),Rc(this.textures,t.textures,r_),Rc(this.images,t.images,s_),Rc(this.subpassInputs,t.subpassInputs,a_),this},t}(),c_=function(){function t(t,e,i,n){void 0===t&&(t=[]),void 0===e&&(e=[]),void 0===i&&(i=null),void 0===n&&(n=null),this.attributes=t,this.vertexBuffers=e,this.indexBuffer=i,this.indirectBuffer=n}return t.prototype.copy=function(t){return Rc(this.attributes,t.attributes,u_),this.vertexBuffers=t.vertexBuffers.slice(),this.indexBuffer=t.indexBuffer,this.indirectBuffer=t.indirectBuffer,this},t}(),__=function(){function t(t,e,i,n,r){void 0===t&&(t=Hl.UNKNOWN),void 0===e&&(e=tc.X1),void 0===i&&(i=lc.CLEAR),void 0===n&&(n=cc.STORE),void 0===r&&(r=null),this.format=t,this.sampleCount=e,this.loadOp=i,this.storeOp=n,this.barrier=r}return t.prototype.copy=function(t){return this.format=t.format,this.sampleCount=t.sampleCount,this.loadOp=t.loadOp,this.storeOp=t.storeOp,this.barrier=t.barrier,this},t}(),d_=function(){function t(t,e,i,n,r,s,o){void 0===t&&(t=Hl.UNKNOWN),void 0===e&&(e=tc.X1),void 0===i&&(i=lc.CLEAR),void 0===n&&(n=cc.STORE),void 0===r&&(r=lc.CLEAR),void 0===s&&(s=cc.STORE),void 0===o&&(o=null),this.format=t,this.sampleCount=e,this.depthLoadOp=i,this.depthStoreOp=n,this.stencilLoadOp=r,this.stencilStoreOp=s,this.barrier=o}return t.prototype.copy=function(t){return this.format=t.format,this.sampleCount=t.sampleCount,this.depthLoadOp=t.depthLoadOp,this.depthStoreOp=t.depthStoreOp,this.stencilLoadOp=t.stencilLoadOp,this.stencilStoreOp=t.stencilStoreOp,this.barrier=t.barrier,this},t}(),f_=function(){function t(t,e,i,n,r,s,o,a){void 0===t&&(t=[]),void 0===e&&(e=[]),void 0===i&&(i=[]),void 0===n&&(n=[]),void 0===r&&(r=-1),void 0===s&&(s=-1),void 0===o&&(o=dc.NONE),void 0===a&&(a=dc.NONE),this.inputs=t,this.colors=e,this.resolves=i,this.preserves=n,this.depthStencil=r,this.depthStencilResolve=s,this.depthResolveMode=o,this.stencilResolveMode=a}return t.prototype.copy=function(t){return this.inputs=t.inputs.slice(),this.colors=t.colors.slice(),this.resolves=t.resolves.slice(),this.preserves=t.preserves.slice(),this.depthStencil=t.depthStencil,this.depthStencilResolve=t.depthStencilResolve,this.depthResolveMode=t.depthResolveMode,this.stencilResolveMode=t.stencilResolveMode,this},t}(),p_=function(){function t(t,e,i,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=null),void 0===n&&(n=[_c.NONE]),void 0===r&&(r=[_c.NONE]),this.srcSubpass=t,this.dstSubpass=e,this.generalBarrier=i,this.prevAccesses=n,this.nextAccesses=r}return t.prototype.copy=function(t){return this.srcSubpass=t.srcSubpass,this.dstSubpass=t.dstSubpass,this.generalBarrier=t.generalBarrier,this.prevAccesses=t.prevAccesses.slice(),this.nextAccesses=t.nextAccesses.slice(),this},t}(),m_=function(){function t(t,e,i,n,r){void 0===t&&(t=[]),void 0===e&&(e=new d_),void 0===i&&(i=new d_),void 0===n&&(n=[]),void 0===r&&(r=[]),this.colorAttachments=t,this.depthStencilAttachment=e,this.depthStencilResolveAttachment=i,this.subpasses=n,this.dependencies=r}return t.prototype.copy=function(t){return Rc(this.colorAttachments,t.colorAttachments,__),this.depthStencilAttachment.copy(t.depthStencilAttachment),this.depthStencilResolveAttachment.copy(t.depthStencilResolveAttachment),Rc(this.subpasses,t.subpasses,f_),Rc(this.dependencies,t.dependencies,p_),this},t}(),g_=function(){function t(t,e,i){void 0===t&&(t=_c.NONE),void 0===e&&(e=_c.NONE),void 0===i&&(i=wc.FULL),this.prevAccesses=t,this.nextAccesses=e,this.type=i}return t.prototype.copy=function(t){return this.prevAccesses=t.prevAccesses,this.nextAccesses=t.nextAccesses,this.type=t.type,this},t}(),y_=function(){function t(t,e,i,n,r,s,o,a,h,u){void 0===t&&(t=_c.NONE),void 0===e&&(e=_c.NONE),void 0===i&&(i=wc.FULL),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=0),void 0===o&&(o=1),void 0===a&&(a=!1),void 0===h&&(h=null),void 0===u&&(u=null),this.prevAccesses=t,this.nextAccesses=e,this.type=i,this.baseMipLevel=n,this.levelCount=r,this.baseSlice=s,this.sliceCount=o,this.discardContents=a,this.srcQueue=h,this.dstQueue=u}return t.prototype.copy=function(t){return this.prevAccesses=t.prevAccesses,this.nextAccesses=t.nextAccesses,this.type=t.type,this.baseMipLevel=t.baseMipLevel,this.levelCount=t.levelCount,this.baseSlice=t.baseSlice,this.sliceCount=t.sliceCount,this.discardContents=t.discardContents,this.srcQueue=t.srcQueue,this.dstQueue=t.dstQueue,this},t}(),v_=function(){function t(t,e,i,n,r,s,o,a){void 0===t&&(t=_c.NONE),void 0===e&&(e=_c.NONE),void 0===i&&(i=wc.FULL),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=!1),void 0===o&&(o=null),void 0===a&&(a=null),this.prevAccesses=t,this.nextAccesses=e,this.type=i,this.offset=n,this.size=r,this.discardContents=s,this.srcQueue=o,this.dstQueue=a}return t.prototype.copy=function(t){return this.prevAccesses=t.prevAccesses,this.nextAccesses=t.nextAccesses,this.type=t.type,this.offset=t.offset,this.size=t.size,this.discardContents=t.discardContents,this.srcQueue=t.srcQueue,this.dstQueue=t.dstQueue,this},t}(),S_=function(){function t(t,e,i,n){void 0===t&&(t=null),void 0===e&&(e=[]),void 0===i&&(i=null),void 0===n&&(n=null),this.renderPass=t,this.colorTextures=e,this.depthStencilTexture=i,this.depthStencilResolveTexture=n}return t.prototype.copy=function(t){return this.renderPass=t.renderPass,this.colorTextures=t.colorTextures.slice(),this.depthStencilTexture=t.depthStencilTexture,this.depthStencilResolveTexture=t.depthStencilResolveTexture,this},t}(),T_=function(){function t(t,e,i,n,r){void 0===t&&(t=-1),void 0===e&&(e=Tc.UNKNOWN),void 0===i&&(i=0),void 0===n&&(n=uc.NONE),void 0===r&&(r=[]),this.binding=t,this.descriptorType=e,this.count=i,this.stageFlags=n,this.immutableSamplers=r}return t.prototype.copy=function(t){return this.binding=t.binding,this.descriptorType=t.descriptorType,this.count=t.count,this.stageFlags=t.stageFlags,this.immutableSamplers=t.immutableSamplers.slice(),this},t}(),A_=function(){function t(t){void 0===t&&(t=[]),this.bindings=t}var e=t.prototype;return e.copy=function(t){return Rc(this.bindings,t.bindings,T_),this},e.reset=function(){this.bindings.length=0},t}(),b_=function(){function t(t){void 0===t&&(t=null),this.layout=t}return t.prototype.copy=function(t){return this.layout=t.layout,this},t}(),E_=function(){function t(t){void 0===t&&(t=[]),this.setLayouts=t}return t.prototype.copy=function(t){return this.setLayouts=t.setLayouts.slice(),this},t}(),C_=function(){function t(t){void 0===t&&(t=[]),this.attributes=t}return t.prototype.copy=function(t){return Rc(this.attributes,t.attributes,u_),this},t}(),w_=function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e=Ec.PRIMARY),this.queue=t,this.type=e}return t.prototype.copy=function(t){return this.queue=t.queue,this.type=t.type,this},t}(),x_=function(){function t(t){void 0===t&&(t=Ac.GRAPHICS),this.type=t}return t.prototype.copy=function(t){return this.type=t.type,this},t}(),R_=function(){function t(t,e,i){void 0===t&&(t=bc.OCCLUSION),void 0===e&&(e=32767),void 0===i&&(i=!0),this.type=t,this.maxQueryObjects=e,this.forceWait=i}return t.prototype.copy=function(t){return this.type=t.type,this.maxQueryObjects=t.maxQueryObjects,this.forceWait=t.forceWait,this},t}(),I_=function(t,e,i,n,r,s,o,a){void 0===t&&(t=""),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=Wl.NONE),void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===o&&(o=!1),void 0===a&&(a=!1),this.name=t,this.size=e,this.count=i,this.type=n,this.hasAlpha=r,this.hasDepth=s,this.hasStencil=o,this.isCompressed=a},B_=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.bufferSize=t,this.textureSize=e}return t.prototype.copy=function(t){return this.bufferSize=t.bufferSize,this.textureSize=t.textureSize,this},t}(),D_=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.writeMask=t,this.compareMask=e,this.reference=i}return t.prototype.copy=function(t){return this.writeMask=t.writeMask,this.compareMask=t.compareMask,this.reference=t.reference,this},t}(),P_=function(){function t(t,e,i,n,r,s,o,a,h,u,l){void 0===t&&(t=new Uc),void 0===e&&(e=new Mc),void 0===i&&(i=new zc),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=new D_),void 0===l&&(l=new D_),this.viewport=t,this.scissor=e,this.blendConstant=i,this.lineWidth=n,this.depthBiasConstant=r,this.depthBiasClamp=s,this.depthBiasSlope=o,this.depthMinBounds=a,this.depthMaxBounds=h,this.stencilStatesFront=u,this.stencilStatesBack=l}return t.prototype.copy=function(t){return this.viewport.copy(t.viewport),this.scissor.copy(t.scissor),this.blendConstant.copy(t.blendConstant),this.lineWidth=t.lineWidth,this.depthBiasConstant=t.depthBiasConstant,this.depthBiasClamp=t.depthBiasClamp,this.depthBiasSlope=t.depthBiasSlope,this.depthMinBounds=t.depthMinBounds,this.depthMaxBounds=t.depthMaxBounds,this.stencilStatesFront.copy(t.stencilStatesFront),this.stencilStatesBack.copy(t.stencilStatesBack),this},t}(),O_=function(t){function e(i){var n;return(n=t.call(this)||this)._objectType=kl.UNKNOWN,n._objectID=0,n._typedID=0,n._objectType=i,n._objectID=e._idTable[kl.UNKNOWN]++,n._typedID=e._idTable[i]++,n}return s(e,t),n(e,[{key:"objectType",get:function(){return this._objectType}},{key:"objectID",get:function(){return this._objectID}},{key:"typedID",get:function(){return this._typedID}}]),e}(Ll);O_._idTable=Array(kl.COUNT).fill(65536),function(t){t.ATTR_POSITION="a_position",t.ATTR_NORMAL="a_normal",t.ATTR_TANGENT="a_tangent",t.ATTR_BITANGENT="a_bitangent",t.ATTR_WEIGHTS="a_weights",t.ATTR_JOINTS="a_joints",t.ATTR_COLOR="a_color",t.ATTR_COLOR1="a_color1",t.ATTR_COLOR2="a_color2",t.ATTR_TEX_COORD="a_texCoord",t.ATTR_TEX_COORD1="a_texCoord1",t.ATTR_TEX_COORD2="a_texCoord2",t.ATTR_TEX_COORD3="a_texCoord3",t.ATTR_TEX_COORD4="a_texCoord4",t.ATTR_TEX_COORD5="a_texCoord5",t.ATTR_TEX_COORD6="a_texCoord6",t.ATTR_TEX_COORD7="a_texCoord7",t.ATTR_TEX_COORD8="a_texCoord8",t.ATTR_BATCH_ID="a_batch_id",t.ATTR_BATCH_UV="a_batch_uv"}(Ic||(Ic={}));var M_=Object.freeze([new I_("UNKNOWN",0,0,Wl.NONE,!1,!1,!1,!1),new I_("A8",1,1,Wl.UNORM,!0,!1,!1,!1),new I_("L8",1,1,Wl.UNORM,!1,!1,!1,!1),new I_("LA8",1,2,Wl.UNORM,!0,!1,!1,!1),new I_("R8",1,1,Wl.UNORM,!1,!1,!1,!1),new I_("R8SN",1,1,Wl.SNORM,!1,!1,!1,!1),new I_("R8UI",1,1,Wl.UINT,!1,!1,!1,!1),new I_("R8I",1,1,Wl.INT,!1,!1,!1,!1),new I_("R16F",2,1,Wl.FLOAT,!1,!1,!1,!1),new I_("R16UI",2,1,Wl.UINT,!1,!1,!1,!1),new I_("R16I",2,1,Wl.INT,!1,!1,!1,!1),new I_("R32F",4,1,Wl.FLOAT,!1,!1,!1,!1),new I_("R32UI",4,1,Wl.UINT,!1,!1,!1,!1),new I_("R32I",4,1,Wl.INT,!1,!1,!1,!1),new I_("RG8",2,2,Wl.UNORM,!1,!1,!1,!1),new I_("RG8SN",2,2,Wl.SNORM,!1,!1,!1,!1),new I_("RG8UI",2,2,Wl.UINT,!1,!1,!1,!1),new I_("RG8I",2,2,Wl.INT,!1,!1,!1,!1),new I_("RG16F",4,2,Wl.FLOAT,!1,!1,!1,!1),new I_("RG16UI",4,2,Wl.UINT,!1,!1,!1,!1),new I_("RG16I",4,2,Wl.INT,!1,!1,!1,!1),new I_("RG32F",8,2,Wl.FLOAT,!1,!1,!1,!1),new I_("RG32UI",8,2,Wl.UINT,!1,!1,!1,!1),new I_("RG32I",8,2,Wl.INT,!1,!1,!1,!1),new I_("RGB8",3,3,Wl.UNORM,!1,!1,!1,!1),new I_("SRGB8",3,3,Wl.UNORM,!1,!1,!1,!1),new I_("RGB8SN",3,3,Wl.SNORM,!1,!1,!1,!1),new I_("RGB8UI",3,3,Wl.UINT,!1,!1,!1,!1),new I_("RGB8I",3,3,Wl.INT,!1,!1,!1,!1),new I_("RGB16F",6,3,Wl.FLOAT,!1,!1,!1,!1),new I_("RGB16UI",6,3,Wl.UINT,!1,!1,!1,!1),new I_("RGB16I",6,3,Wl.INT,!1,!1,!1,!1),new I_("RGB32F",12,3,Wl.FLOAT,!1,!1,!1,!1),new I_("RGB32UI",12,3,Wl.UINT,!1,!1,!1,!1),new I_("RGB32I",12,3,Wl.INT,!1,!1,!1,!1),new I_("RGBA8",4,4,Wl.UNORM,!0,!1,!1,!1),new I_("BGRA8",4,4,Wl.UNORM,!0,!1,!1,!1),new I_("SRGB8_A8",4,4,Wl.UNORM,!0,!1,!1,!1),new I_("RGBA8SN",4,4,Wl.SNORM,!0,!1,!1,!1),new I_("RGBA8UI",4,4,Wl.UINT,!0,!1,!1,!1),new I_("RGBA8I",4,4,Wl.INT,!0,!1,!1,!1),new I_("RGBA16F",8,4,Wl.FLOAT,!0,!1,!1,!1),new I_("RGBA16UI",8,4,Wl.UINT,!0,!1,!1,!1),new I_("RGBA16I",8,4,Wl.INT,!0,!1,!1,!1),new I_("RGBA32F",16,4,Wl.FLOAT,!0,!1,!1,!1),new I_("RGBA32UI",16,4,Wl.UINT,!0,!1,!1,!1),new I_("RGBA32I",16,4,Wl.INT,!0,!1,!1,!1),new I_("R5G6B5",2,3,Wl.UNORM,!1,!1,!1,!1),new I_("R11G11B10F",4,3,Wl.FLOAT,!1,!1,!1,!1),new I_("RGB5A1",2,4,Wl.UNORM,!0,!1,!1,!1),new I_("RGBA4",2,4,Wl.UNORM,!0,!1,!1,!1),new I_("RGB10A2",2,4,Wl.UNORM,!0,!1,!1,!1),new I_("RGB10A2UI",2,4,Wl.UINT,!0,!1,!1,!1),new I_("RGB9E5",2,4,Wl.FLOAT,!0,!1,!1,!1),new I_("DEPTH",4,1,Wl.FLOAT,!1,!0,!1,!1),new I_("DEPTH_STENCIL",5,2,Wl.FLOAT,!1,!0,!0,!1),new I_("BC1",1,3,Wl.UNORM,!1,!1,!1,!0),new I_("BC1_ALPHA",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("BC1_SRGB",1,3,Wl.UNORM,!1,!1,!1,!0),new I_("BC1_SRGB_ALPHA",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("BC2",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("BC2_SRGB",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("BC3",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("BC3_SRGB",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("BC4",1,1,Wl.UNORM,!1,!1,!1,!0),new I_("BC4_SNORM",1,1,Wl.SNORM,!1,!1,!1,!0),new I_("BC5",1,2,Wl.UNORM,!1,!1,!1,!0),new I_("BC5_SNORM",1,2,Wl.SNORM,!1,!1,!1,!0),new I_("BC6H_UF16",1,3,Wl.UFLOAT,!1,!1,!1,!0),new I_("BC6H_SF16",1,3,Wl.FLOAT,!1,!1,!1,!0),new I_("BC7",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("BC7_SRGB",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ETC_RGB8",1,3,Wl.UNORM,!1,!1,!1,!0),new I_("ETC2_RGB8",1,3,Wl.UNORM,!1,!1,!1,!0),new I_("ETC2_SRGB8",1,3,Wl.UNORM,!1,!1,!1,!0),new I_("ETC2_RGB8_A1",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ETC2_SRGB8_A1",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ETC2_RGBA8",2,4,Wl.UNORM,!0,!1,!1,!0),new I_("ETC2_SRGB8_A8",2,4,Wl.UNORM,!0,!1,!1,!0),new I_("EAC_R11",1,1,Wl.UNORM,!1,!1,!1,!0),new I_("EAC_R11SN",1,1,Wl.SNORM,!1,!1,!1,!0),new I_("EAC_RG11",2,2,Wl.UNORM,!1,!1,!1,!0),new I_("EAC_RG11SN",2,2,Wl.SNORM,!1,!1,!1,!0),new I_("PVRTC_RGB2",2,3,Wl.UNORM,!1,!1,!1,!0),new I_("PVRTC_RGBA2",2,4,Wl.UNORM,!0,!1,!1,!0),new I_("PVRTC_RGB4",2,3,Wl.UNORM,!1,!1,!1,!0),new I_("PVRTC_RGBA4",2,4,Wl.UNORM,!0,!1,!1,!0),new I_("PVRTC2_2BPP",2,4,Wl.UNORM,!0,!1,!1,!0),new I_("PVRTC2_4BPP",2,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_4x4",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_5x4",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_5x5",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_6x5",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_6x6",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_8x5",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_8x6",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_8x8",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_10x5",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_10x6",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_10x8",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_10x10",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_12x10",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_RGBA_12x12",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_4x4",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_5x4",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_5x5",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_6x5",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_6x6",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_8x5",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_8x6",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_8x8",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_10x5",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_10x6",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_10x8",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_10x10",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_12x10",1,4,Wl.UNORM,!0,!1,!1,!0),new I_("ASTC_SRGBA_12x12",1,4,Wl.UNORM,!0,!1,!1,!0)]),L_=Tc.UNIFORM_BUFFER|Tc.DYNAMIC_UNIFORM_BUFFER|Tc.STORAGE_BUFFER|Tc.DYNAMIC_STORAGE_BUFFER,N_=Tc.SAMPLER_TEXTURE|Tc.SAMPLER|Tc.TEXTURE|Tc.STORAGE_IMAGE|Tc.INPUT_ATTACHMENT,F_=Tc.DYNAMIC_STORAGE_BUFFER|Tc.DYNAMIC_UNIFORM_BUFFER;function k_(t){return t>0&&0==(t&t-1)}function V_(t,e,i,n){if(!M_[t].isCompressed)return e*i*n*M_[t].size;switch(t){case Hl.BC1:case Hl.BC1_ALPHA:case Hl.BC1_SRGB:case Hl.BC1_SRGB_ALPHA:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case Hl.BC2:case Hl.BC2_SRGB:case Hl.BC3:case Hl.BC3_SRGB:case Hl.BC4:case Hl.BC4_SNORM:case Hl.BC6H_SF16:case Hl.BC6H_UF16:case Hl.BC7:case Hl.BC7_SRGB:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case Hl.BC5:case Hl.BC5_SNORM:return Math.ceil(e/4)*Math.ceil(i/4)*32*n;case Hl.ETC_RGB8:case Hl.ETC2_RGB8:case Hl.ETC2_SRGB8:case Hl.ETC2_RGB8_A1:case Hl.EAC_R11:case Hl.EAC_R11SN:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case Hl.ETC2_RGBA8:case Hl.ETC2_SRGB8_A1:case Hl.EAC_RG11:case Hl.EAC_RG11SN:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case Hl.PVRTC_RGB2:case Hl.PVRTC_RGBA2:case Hl.PVRTC2_2BPP:return Math.ceil(e/8)*Math.ceil(i/4)*8*n;case Hl.PVRTC_RGB4:case Hl.PVRTC_RGBA4:case Hl.PVRTC2_4BPP:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case Hl.ASTC_RGBA_4X4:case Hl.ASTC_SRGBA_4X4:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case Hl.ASTC_RGBA_5X4:case Hl.ASTC_SRGBA_5X4:return Math.ceil(e/5)*Math.ceil(i/4)*16*n;case Hl.ASTC_RGBA_5X5:case Hl.ASTC_SRGBA_5X5:return Math.ceil(e/5)*Math.ceil(i/5)*16*n;case Hl.ASTC_RGBA_6X5:case Hl.ASTC_SRGBA_6X5:return Math.ceil(e/6)*Math.ceil(i/5)*16*n;case Hl.ASTC_RGBA_6X6:case Hl.ASTC_SRGBA_6X6:return Math.ceil(e/6)*Math.ceil(i/6)*16*n;case Hl.ASTC_RGBA_8X5:case Hl.ASTC_SRGBA_8X5:return Math.ceil(e/8)*Math.ceil(i/5)*16*n;case Hl.ASTC_RGBA_8X6:case Hl.ASTC_SRGBA_8X6:return Math.ceil(e/8)*Math.ceil(i/6)*16*n;case Hl.ASTC_RGBA_8X8:case Hl.ASTC_SRGBA_8X8:return Math.ceil(e/8)*Math.ceil(i/8)*16*n;case Hl.ASTC_RGBA_10X5:case Hl.ASTC_SRGBA_10X5:return Math.ceil(e/10)*Math.ceil(i/5)*16*n;case Hl.ASTC_RGBA_10X6:case Hl.ASTC_SRGBA_10X6:return Math.ceil(e/10)*Math.ceil(i/6)*16*n;case Hl.ASTC_RGBA_10X8:case Hl.ASTC_SRGBA_10X8:return Math.ceil(e/10)*Math.ceil(i/8)*16*n;case Hl.ASTC_RGBA_10X10:case Hl.ASTC_SRGBA_10X10:return Math.ceil(e/10)*Math.ceil(i/10)*16*n;case Hl.ASTC_RGBA_12X10:case Hl.ASTC_SRGBA_12X10:return Math.ceil(e/12)*Math.ceil(i/10)*16*n;case Hl.ASTC_RGBA_12X12:case Hl.ASTC_SRGBA_12X12:return Math.ceil(e/12)*Math.ceil(i/12)*16*n;default:return 0}}function G_(t,e,i,n,r){for(var s=0,o=0;o<r;++o)s+=V_(t,e,i,n),e=Math.max(e>>1,1),i=Math.max(i>>1,1);return s}var U_=[0,4,8,12,16,4,8,12,16,4,8,12,16,4,8,12,16,16,24,32,24,36,48,32,48,64,4,4,4,4,4,4];function z_(t){return U_[t]||0}function H_(t){if(t.isCompressed)return Uint8Array;var e=t.size/t.count;switch(t.type){case Wl.UNORM:case Wl.UINT:switch(e){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array;default:return Uint8Array}case Wl.SNORM:case Wl.INT:switch(e){case 1:return Int8Array;case 2:return Int16Array;case 4:return Int32Array;default:return Int8Array}case Wl.FLOAT:switch(e){case 2:return Uint16Array;case 4:default:return Float32Array}}return Float32Array}function W_(t){switch(t){case Hl.BC1:case Hl.BC1_ALPHA:case Hl.BC1_SRGB:case Hl.BC1_SRGB_ALPHA:case Hl.BC2:case Hl.BC2_SRGB:case Hl.BC3:case Hl.BC3_SRGB:case Hl.BC4:case Hl.BC4_SNORM:case Hl.BC6H_SF16:case Hl.BC6H_UF16:case Hl.BC7:case Hl.BC7_SRGB:case Hl.BC5:case Hl.BC5_SNORM:case Hl.ETC_RGB8:case Hl.ETC2_RGB8:case Hl.ETC2_SRGB8:case Hl.ETC2_RGB8_A1:case Hl.EAC_R11:case Hl.EAC_R11SN:case Hl.ETC2_RGBA8:case Hl.ETC2_SRGB8_A1:case Hl.EAC_RG11:case Hl.EAC_RG11SN:return{width:4,height:4};case Hl.PVRTC_RGB2:case Hl.PVRTC_RGBA2:case Hl.PVRTC2_2BPP:return{width:8,height:4};case Hl.PVRTC_RGB4:case Hl.PVRTC_RGBA4:case Hl.PVRTC2_4BPP:return{width:4,height:4};case Hl.ASTC_RGBA_4X4:case Hl.ASTC_SRGBA_4X4:return{width:4,height:4};case Hl.ASTC_RGBA_5X4:case Hl.ASTC_SRGBA_5X4:return{width:5,height:4};case Hl.ASTC_RGBA_5X5:case Hl.ASTC_SRGBA_5X5:return{width:5,height:5};case Hl.ASTC_RGBA_6X5:case Hl.ASTC_SRGBA_6X5:return{width:6,height:5};case Hl.ASTC_RGBA_6X6:case Hl.ASTC_SRGBA_6X6:return{width:6,height:6};case Hl.ASTC_RGBA_8X5:case Hl.ASTC_SRGBA_8X5:return{width:8,height:5};case Hl.ASTC_RGBA_8X6:case Hl.ASTC_SRGBA_8X6:return{width:8,height:6};case Hl.ASTC_RGBA_8X8:case Hl.ASTC_SRGBA_8X8:return{width:8,height:8};case Hl.ASTC_RGBA_10X5:case Hl.ASTC_SRGBA_10X5:return{width:10,height:5};case Hl.ASTC_RGBA_10X6:case Hl.ASTC_SRGBA_10X6:return{width:10,height:6};case Hl.ASTC_RGBA_10X8:case Hl.ASTC_SRGBA_10X8:return{width:10,height:8};case Hl.ASTC_RGBA_10X10:case Hl.ASTC_SRGBA_10X10:return{width:10,height:10};case Hl.ASTC_RGBA_12X10:case Hl.ASTC_SRGBA_12X10:return{width:12,height:10};case Hl.ASTC_RGBA_12X12:case Hl.ASTC_SRGBA_12X12:return{width:12,height:12};default:return{width:1,height:1}}}function j_(t,e){return Math.ceil(t/e)*e}var X_=Object.freeze({__proto__:null,get ObjectType(){return kl},get Status(){return Vl},get API(){return Gl},get SurfaceTransform(){return Ul},get Feature(){return zl},get Format(){return Hl},get FormatType(){return Wl},get Type(){return jl},get BufferUsageBit(){return Xl},get BufferFlagBit(){return ql},get MemoryAccessBit(){return Yl},get MemoryUsageBit(){return Kl},get TextureType(){return Jl},get TextureUsageBit(){return Ql},get TextureFlagBit(){return Zl},get FormatFeatureBit(){return $l},get SampleCount(){return tc},get VsyncMode(){return ec},get Filter(){return ic},get Address(){return nc},get ComparisonFunc(){return rc},get StencilOp(){return sc},get BlendFactor(){return oc},get BlendOp(){return ac},get ColorMask(){return hc},get ShaderStageFlagBit(){return uc},get LoadOp(){return lc},get StoreOp(){return cc},get AccessFlagBit(){return _c},get ResolveMode(){return dc},get PipelineBindPoint(){return fc},get PrimitiveMode(){return pc},get PolygonMode(){return mc},get ShadeModel(){return gc},get CullMode(){return yc},get DynamicStateFlagBit(){return vc},get StencilFace(){return Sc},get DescriptorType(){return Tc},get QueueType(){return Ac},get QueryType(){return bc},get CommandBufferType(){return Ec},get ClearFlagBit(){return Cc},get BarrierType(){return wc},get PassType(){return xc},Size:Bc,DeviceCaps:Dc,DeviceOptions:Pc,Offset:Oc,Rect:Mc,Extent:Lc,TextureSubresLayers:Nc,TextureSubresRange:Fc,TextureCopy:kc,TextureBlit:Vc,BufferTextureCopy:Gc,Viewport:Uc,Color:zc,BindingMappingInfo:Hc,SwapchainInfo:Wc,DeviceInfo:jc,BufferInfo:Xc,BufferViewInfo:qc,DrawInfo:Yc,DispatchInfo:Kc,IndirectBuffer:Jc,TextureInfo:Qc,TextureViewInfo:Zc,SamplerInfo:$c,Uniform:t_,UniformBlock:e_,UniformSamplerTexture:i_,UniformSampler:n_,UniformTexture:r_,UniformStorageImage:s_,UniformStorageBuffer:o_,UniformInputAttachment:a_,ShaderStage:h_,Attribute:u_,ShaderInfo:l_,InputAssemblerInfo:c_,ColorAttachment:__,DepthStencilAttachment:d_,SubpassInfo:f_,SubpassDependency:p_,RenderPassInfo:m_,GeneralBarrierInfo:g_,TextureBarrierInfo:y_,BufferBarrierInfo:v_,FramebufferInfo:S_,DescriptorSetLayoutBinding:T_,DescriptorSetLayoutInfo:A_,DescriptorSetInfo:b_,PipelineLayoutInfo:E_,InputState:C_,CommandBufferInfo:w_,QueueInfo:x_,QueryPoolInfo:R_,FormatInfo:I_,MemoryStatus:B_,DynamicStencilStates:D_,DynamicStates:P_,GFXObject:O_,get AttributeName(){return Ic},FormatInfos:M_,DESCRIPTOR_BUFFER_TYPE:L_,DESCRIPTOR_SAMPLER_TYPE:N_,DESCRIPTOR_DYNAMIC_TYPE:F_,DRAW_INFO_SIZE:28,IsPowerOf2:k_,FormatSize:V_,FormatSurfaceSize:G_,GetTypeSize:z_,getTypedArrayConstructor:H_,formatAlignment:W_,alignTo:j_}),q_=function(t){function e(){var e;return(e=t.call(this,kl.BUFFER)||this)._usage=Xl.NONE,e._memUsage=Kl.NONE,e._size=0,e._stride=1,e._count=0,e._flags=ql.NONE,e._isBufferView=!1,e}return s(e,t),n(e,[{key:"usage",get:function(){return this._usage}},{key:"memUsage",get:function(){return this._memUsage}},{key:"size",get:function(){return this._size}},{key:"stride",get:function(){return this._stride}},{key:"count",get:function(){return this._count}},{key:"flags",get:function(){return this._flags}}]),e}(O_),Y_=function(t){function e(){var e;return(e=t.call(this,kl.COMMAND_BUFFER)||this)._queue=null,e._type=Ec.PRIMARY,e._numDrawCalls=0,e._numInstances=0,e._numTris=0,e}return s(e,t),n(e,[{key:"type",get:function(){return this._type}},{key:"queue",get:function(){return this._queue}},{key:"numDrawCalls",get:function(){return this._numDrawCalls}},{key:"numInstances",get:function(){return this._numInstances}},{key:"numTris",get:function(){return this._numTris}}]),e}(O_),K_=function(){function t(){this._gfxAPI=Gl.UNKNOWN,this._renderer="",this._vendor="",this._features=new Array(zl.COUNT),this._formatFeatures=new Array(Hl.COUNT),this._queue=null,this._cmdBuff=null,this._numDrawCalls=0,this._numInstances=0,this._numTris=0,this._memoryStatus=new B_,this._caps=new Dc,this._bindingMappingInfo=new Hc,this._samplers=new Map,this._generalBarrierss=new Map,this._textureBarriers=new Map,this._bufferBarriers=new Map}var e=t.prototype;return e.hasFeature=function(t){return this._features[t]},e.getFormatFeatures=function(t){return this._formatFeatures[t]},e.enableAutoBarrier=function(){},e.getMaxSampleCount=function(){return tc.X1},n(t,[{key:"gfxAPI",get:function(){return this._gfxAPI}},{key:"queue",get:function(){return this._queue}},{key:"commandBuffer",get:function(){return this._cmdBuff}},{key:"renderer",get:function(){return this._renderer}},{key:"vendor",get:function(){return this._vendor}},{key:"numDrawCalls",get:function(){return this._numDrawCalls}},{key:"numInstances",get:function(){return this._numInstances}},{key:"numTris",get:function(){return this._numTris}},{key:"memoryStatus",get:function(){return this._memoryStatus}},{key:"capabilities",get:function(){return this._caps}},{key:"bindingMappingInfo",get:function(){return this._bindingMappingInfo}}]),t}();K_.canvas=void 0;var J_=function(){function t(t){this._texture2D=null,this._texture3D=null,this._textureCube=null,this._texture2DArray=null;var e=new Uint8Array(64);if(e.fill(255),t.capabilities.maxTextureSize>=2){this._texture2D=t.createTexture(new Qc(Jl.TEX2D,Ql.STORAGE|Ql.SAMPLED,Hl.RGBA8,2,2,Zl.NONE));var i=new Gc(0,0,0,new Oc(0,0,0),new Lc(2,2,1));t.copyBuffersToTexture([e],this._texture2D,[i])}if(t.capabilities.maxTextureSize>=2){this._textureCube=t.createTexture(new Qc(Jl.CUBE,Ql.STORAGE|Ql.SAMPLED,Hl.RGBA8,2,2,Zl.NONE,6));var n=new Gc(0,0,0,new Oc(0,0,0),new Lc(2,2,1));t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=1,t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=2,t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=3,t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=4,t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=5,t.copyBuffersToTexture([e],this._textureCube,[n])}if(t.capabilities.max3DTextureSize>=2){this._texture3D=t.createTexture(new Qc(Jl.TEX3D,Ql.STORAGE|Ql.SAMPLED,Hl.RGBA8,2,2,Zl.NONE,1,1,tc.X1,2));var r=new Gc(0,0,0,new Oc(0,0,0),new Lc(2,2,2),new Nc(0,0,1));t.copyBuffersToTexture([e],this._texture3D,[r])}if(t.capabilities.maxArrayTextureLayers>=2){this._texture2DArray=t.createTexture(new Qc(Jl.TEX2D_ARRAY,Ql.STORAGE|Ql.SAMPLED,Hl.RGBA8,2,2,Zl.NONE,2));var s=new Gc(0,0,0,new Oc(0,0,0),new Lc(2,2,1),new Nc(0,0,1));t.copyBuffersToTexture([e],this._texture2DArray,[s]),s.texSubres.baseArrayLayer=1,t.copyBuffersToTexture([e],this._texture2DArray,[s])}}return t.prototype.getTexture=function(t){switch(t){case Jl.TEX2D:return this._texture2D;case Jl.TEX3D:return this._texture3D;case Jl.CUBE:return this._textureCube;case Jl.TEX2D_ARRAY:return this._texture2DArray;default:return null}},t}(),Q_=function(t){function e(){var e;return(e=t.call(this,kl.SWAPCHAIN)||this)._transform=Ul.IDENTITY,e._colorTexture=null,e._depthStencilTexture=null,e}return s(e,t),n(e,[{key:"colorTexture",get:function(){return this._colorTexture}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}},{key:"surfaceTransform",get:function(){return this._transform}},{key:"width",get:function(){return this._colorTexture.width}},{key:"height",get:function(){return this._colorTexture.height}}]),e}(O_),Z_=function(t){function e(){var e;return(e=t.call(this,kl.FRAMEBUFFER)||this)._renderPass=null,e._colorTextures=[],e._depthStencilTexture=null,e._width=0,e._height=0,e}return s(e,t),n(e,[{key:"renderPass",get:function(){return this._renderPass}},{key:"colorTextures",get:function(){return this._colorTextures}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}},{key:"width",get:function(){return this.colorTextures.length>0?this.colorTextures[0].width:this.depthStencilTexture?this.depthStencilTexture.width:this._width}},{key:"height",get:function(){return this.colorTextures.length>0?this.colorTextures[0].height:this.depthStencilTexture?this.depthStencilTexture.height:this._height}}]),e}(O_),$_=function(t){function e(){var e;return(e=t.call(this,kl.INPUT_ASSEMBLER)||this)._attributes=[],e._attributesHash=0,e._vertexBuffers=[],e._indexBuffer=null,e._indirectBuffer=null,e._drawInfo=new Yc,e}s(e,t);var i=e.prototype;return i.getVertexBuffer=function(t){return void 0===t&&(t=0),t<this._vertexBuffers.length?this._vertexBuffers[t]:null},i.computeAttributesHash=function(){for(var t="attrs",e=0;e<this.attributes.length;++e){var i=this.attributes[e];t+=","+i.name+","+i.format+","+i.isNormalized+","+i.stream+","+i.isInstanced+","+i.location}return Dl(t,666)},n(e,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexBuffers",get:function(){return this._vertexBuffers}},{key:"indexBuffer",get:function(){return this._indexBuffer}},{key:"indirectBuffer",get:function(){return this._indirectBuffer}},{key:"attributesHash",get:function(){return this._attributesHash}},{key:"vertexCount",get:function(){return this._drawInfo.vertexCount},set:function(t){this._drawInfo.vertexCount=t}},{key:"firstVertex",get:function(){return this._drawInfo.firstVertex},set:function(t){this._drawInfo.firstVertex=t}},{key:"indexCount",get:function(){return this._drawInfo.indexCount},set:function(t){this._drawInfo.indexCount=t}},{key:"firstIndex",get:function(){return this._drawInfo.firstIndex},set:function(t){this._drawInfo.firstIndex=t}},{key:"vertexOffset",get:function(){return this._drawInfo.vertexOffset},set:function(t){this._drawInfo.vertexOffset=t}},{key:"instanceCount",get:function(){return this._drawInfo.instanceCount},set:function(t){this._drawInfo.instanceCount=t}},{key:"firstInstance",get:function(){return this._drawInfo.firstInstance},set:function(t){this._drawInfo.firstInstance=t}},{key:"drawInfo",get:function(){return this._drawInfo},set:function(t){this._drawInfo=t}}]),e}(O_),td=function(t){function e(){var e;return(e=t.call(this,kl.DESCRIPTOR_SET)||this)._layout=null,e._buffers=[],e._textures=[],e._samplers=[],e._isDirty=!1,e}s(e,t);var i=e.prototype;return i.bindBuffer=function(t,e,i){void 0===i&&(i=0);var n=this._layout.bindingIndices[t],r=this._layout.bindings[n];if(r&&r.descriptorType&L_){var s=this._layout.descriptorIndices[t];this._buffers[s+i]!==e&&(this._buffers[s+i]=e,this._isDirty=!0)}},i.bindSampler=function(t,e,i){void 0===i&&(i=0);var n=this._layout.bindingIndices[t],r=this._layout.bindings[n];if(r&&r.descriptorType&N_){var s=this._layout.descriptorIndices[t];this._samplers[s+i]!==e&&(this._samplers[s+i]=e,this._isDirty=!0)}},i.bindTexture=function(t,e,i){void 0===i&&(i=0);var n=this._layout.bindingIndices[t],r=this._layout.bindings[n];if(r&&r.descriptorType&N_){var s=this._layout.descriptorIndices[t];this._textures[s+i]!==e&&(this._textures[s+i]=e,this._isDirty=!0)}},i.getBuffer=function(t,e){void 0===e&&(e=0);var i=this._layout.descriptorIndices[t];return this._buffers[i+e]},i.getSampler=function(t,e){void 0===e&&(e=0);var i=this._layout.descriptorIndices[t];return this._samplers[i+e]},i.getTexture=function(t,e){void 0===e&&(e=0);var i=this._layout.descriptorIndices[t];return this._textures[i+e]},n(e,[{key:"layout",get:function(){return this._layout}}]),e}(O_),ed=function(t){function e(){var e;return(e=t.call(this,kl.DESCRIPTOR_SET_LAYOUT)||this)._bindings=[],e._bindingIndices=[],e._descriptorIndices=[],e}return s(e,t),n(e,[{key:"bindings",get:function(){return this._bindings}},{key:"bindingIndices",get:function(){return this._bindingIndices}},{key:"descriptorIndices",get:function(){return this._descriptorIndices}}]),e}(O_),id=function(t){function e(){var e;return(e=t.call(this,kl.PIPELINE_LAYOUT)||this)._setLayouts=[],e}return s(e,t),n(e,[{key:"setLayouts",get:function(){return this._setLayouts}}]),e}(O_),nd=function(){function t(t,e,i,n,r,s,o,a,h,u,l,c){void 0===t&&(t=!1),void 0===e&&(e=mc.FILL),void 0===i&&(i=gc.GOURAND),void 0===n&&(n=yc.BACK),void 0===r&&(r=!0),void 0===s&&(s=!1),void 0===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=!0),void 0===l&&(l=!1),void 0===c&&(c=1),this.isDiscard=t,this.polygonMode=e,this.shadeModel=i,this.cullMode=n,this.isFrontFaceCCW=r,this.depthBiasEnabled=s,this.depthBias=o,this.depthBiasClamp=a,this.depthBiasSlop=h,this.isDepthClip=u,this.isMultisample=l,this.lineWidth=c}var e=t.prototype;return e.reset=function(){this.isDiscard=!1,this.polygonMode=mc.FILL,this.shadeModel=gc.GOURAND,this.cullMode=yc.BACK,this.isFrontFaceCCW=!0,this.depthBiasEnabled=!1,this.depthBias=0,this.depthBiasClamp=0,this.depthBiasSlop=0,this.isDepthClip=!0,this.isMultisample=!1,this.lineWidth=1},e.assign=function(t){Object.assign(this,t)},e.destroy=function(){},n(t,[{key:"native",get:function(){return this}}]),t}(),rd=function(){function t(t,e,i,n,r,s,o,a,h,u,l,c,_,d,f,p,m,g,y){void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i&&(i=rc.LESS),void 0===n&&(n=!1),void 0===r&&(r=rc.ALWAYS),void 0===s&&(s=65535),void 0===o&&(o=65535),void 0===a&&(a=sc.KEEP),void 0===h&&(h=sc.KEEP),void 0===u&&(u=sc.KEEP),void 0===l&&(l=1),void 0===c&&(c=!1),void 0===_&&(_=rc.ALWAYS),void 0===d&&(d=65535),void 0===f&&(f=65535),void 0===p&&(p=sc.KEEP),void 0===m&&(m=sc.KEEP),void 0===g&&(g=sc.KEEP),void 0===y&&(y=1),this.depthTest=t,this.depthWrite=e,this.depthFunc=i,this.stencilTestFront=n,this.stencilFuncFront=r,this.stencilReadMaskFront=s,this.stencilWriteMaskFront=o,this.stencilFailOpFront=a,this.stencilZFailOpFront=h,this.stencilPassOpFront=u,this.stencilRefFront=l,this.stencilTestBack=c,this.stencilFuncBack=_,this.stencilReadMaskBack=d,this.stencilWriteMaskBack=f,this.stencilFailOpBack=p,this.stencilZFailOpBack=m,this.stencilPassOpBack=g,this.stencilRefBack=y}var e=t.prototype;return e.reset=function(){this.depthTest=!0,this.depthWrite=!0,this.depthFunc=rc.LESS,this.stencilTestFront=!1,this.stencilFuncFront=rc.ALWAYS,this.stencilReadMaskFront=65535,this.stencilWriteMaskFront=65535,this.stencilFailOpFront=sc.KEEP,this.stencilZFailOpFront=sc.KEEP,this.stencilPassOpFront=sc.KEEP,this.stencilRefFront=1,this.stencilTestBack=!1,this.stencilFuncBack=rc.ALWAYS,this.stencilReadMaskBack=65535,this.stencilWriteMaskBack=65535,this.stencilFailOpBack=sc.KEEP,this.stencilZFailOpBack=sc.KEEP,this.stencilPassOpBack=sc.KEEP,this.stencilRefBack=1},e.assign=function(t){Object.assign(this,t)},e.destroy=function(){},n(t,[{key:"native",get:function(){return this}}]),t}(),sd=function(){function t(t,e,i,n,r,s,o,a){void 0===t&&(t=!1),void 0===e&&(e=oc.ONE),void 0===i&&(i=oc.ZERO),void 0===n&&(n=ac.ADD),void 0===r&&(r=oc.ONE),void 0===s&&(s=oc.ZERO),void 0===o&&(o=ac.ADD),void 0===a&&(a=hc.ALL),this.blend=t,this.blendSrc=e,this.blendDst=i,this.blendEq=n,this.blendSrcAlpha=r,this.blendDstAlpha=s,this.blendAlphaEq=o,this.blendColorMask=a}var e=t.prototype;return e.reset=function(){this.blend=!1,this.blendSrc=oc.ONE,this.blendDst=oc.ZERO,this.blendEq=ac.ADD,this.blendSrcAlpha=oc.ONE,this.blendDstAlpha=oc.ZERO,this.blendAlphaEq=ac.ADD,this.blendColorMask=hc.ALL},e.assign=function(t){Object.assign(this,t)},e.destroy=function(){},t}(),od=function(){function t(t,e,i,n){void 0===t&&(t=!1),void 0===e&&(e=!1),void 0===i&&(i=new zc),void 0===n&&(n=[new sd]),this.isA2C=t,this.isIndepend=e,this.blendColor=i,this.targets=n}var e=t.prototype;return e.setTarget=function(t,e){var i=this.targets[t];i||(i=this.targets[t]=new sd),Object.assign(i,e)},e.reset=function(){this.isA2C=!1,this.isIndepend=!1,this.blendColor.x=0,this.blendColor.y=0,this.blendColor.z=0,this.blendColor.w=0,this.targets.length=1,this.targets[0].reset()},e.destroy=function(){},n(t,[{key:"native",get:function(){return this}}]),t}(),ad=function(t,e,i,n,r,s,o,a,h,u){void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null),void 0===n&&(n=new C_),void 0===r&&(r=new nd),void 0===s&&(s=new rd),void 0===o&&(o=new od),void 0===a&&(a=pc.TRIANGLE_LIST),void 0===h&&(h=vc.NONE),void 0===u&&(u=fc.GRAPHICS),this.shader=t,this.pipelineLayout=e,this.renderPass=i,this.inputState=n,this.rasterizerState=r,this.depthStencilState=s,this.blendState=o,this.primitive=a,this.dynamicStates=h,this.bindPoint=u},hd=function(t){function e(){var e;return(e=t.call(this,kl.PIPELINE_STATE)||this)._shader=null,e._pipelineLayout=null,e._primitive=pc.TRIANGLE_LIST,e._is=null,e._rs=new nd,e._dss=new rd,e._bs=new od,e._dynamicStates=vc.NONE,e._renderPass=null,e}return s(e,t),n(e,[{key:"shader",get:function(){return this._shader}},{key:"pipelineLayout",get:function(){return this._pipelineLayout}},{key:"primitive",get:function(){return this._primitive}},{key:"rasterizerState",get:function(){return this._rs}},{key:"depthStencilState",get:function(){return this._dss}},{key:"blendState",get:function(){return this._bs}},{key:"inputState",get:function(){return this._is}},{key:"dynamicStates",get:function(){return this._dynamicStates}},{key:"renderPass",get:function(){return this._renderPass}}]),e}(O_),ud=function(t){function e(){var e;return(e=t.call(this,kl.QUEUE)||this)._type=Ac.GRAPHICS,e}return s(e,t),n(e,[{key:"type",get:function(){return this._type}}]),e}(O_),ld=function(t){function e(){var e;return(e=t.call(this,kl.RENDER_PASS)||this)._colorInfos=[],e._depthStencilInfo=null,e._subpasses=[],e._hash=0,e}return s(e,t),e.prototype.computeHash=function(){var t="";if(this._subpasses.length)for(var e=0;e<this._subpasses.length;++e){var i=this._subpasses[e];if(i.inputs.length){t+="ia";for(var n=0;n<i.inputs.length;++n){var r=this._colorInfos[i.inputs[n]];t+=","+r.format+","+r.sampleCount}}if(i.colors.length){t+="ca";for(var s=0;s<i.inputs.length;++s){var o=this._colorInfos[i.inputs[s]];t+=","+o.format+","+o.sampleCount}}if(i.depthStencil>=0){var a=this._colorInfos[i.depthStencil];t+="ds,"+a.format+","+a.sampleCount}}else{t+="ca";for(var h=0;h<this._colorInfos.length;++h){var u=this._colorInfos[h];t+=","+u.format+","+u.sampleCount}var l=this._depthStencilInfo;l&&(t+="ds,"+l.format+","+l.sampleCount)}return Dl(t,666)},n(e,[{key:"colorAttachments",get:function(){return this._colorInfos}},{key:"depthStencilAttachment",get:function(){return this._depthStencilInfo}},{key:"subPasses",get:function(){return this._subpasses}},{key:"hash",get:function(){return this._hash}}]),e}(O_),cd=function(t){function e(e,i){var n;return(n=t.call(this,kl.SAMPLER)||this)._info=new $c,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){var e=t.minFilter;return e|=t.magFilter<<2,e|=t.mipFilter<<4,e|=t.addressU<<6,e|=t.addressV<<8,e|=t.addressW<<10,(e|=t.maxAnisotropy<<12)|t.cmpFunc<<16},e.unpackFromHash=function(t){var e=new $c;return e.minFilter=(3&t)>>0,e.magFilter=(3&t)>>2,e.mipFilter=(3&t)>>4,e.addressU=(3&t)>>6,e.addressV=(3&t)>>8,e.addressW=(3&t)>>10,e.maxAnisotropy=(15&t)>>12,e.cmpFunc=(7&t)>>16,e},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(O_),_d=function(t){function e(){var e;return(e=t.call(this,kl.SHADER)||this)._name="",e._stages=[],e._attributes=[],e._blocks=[],e._samplers=[],e}return s(e,t),n(e,[{key:"name",get:function(){return this._name}},{key:"attributes",get:function(){return this._attributes}},{key:"blocks",get:function(){return this._blocks}},{key:"samplers",get:function(){return this._samplers}},{key:"stages",get:function(){return this._stages}}]),e}(O_),dd=function(t){function e(){var e;return(e=t.call(this,kl.TEXTURE)||this)._info=new Qc,e._viewInfo=new Zc,e._isPowerOf2=!1,e._isTextureView=!1,e._size=0,e}return s(e,t),e.getLevelCount=function(t,e){return Math.floor(Math.log2(Math.max(t,e)))},n(e,[{key:"type",get:function(){return this._info.type}},{key:"usage",get:function(){return this._info.usage}},{key:"format",get:function(){return this._info.format}},{key:"width",get:function(){return this._info.width}},{key:"height",get:function(){return this._info.height}},{key:"depth",get:function(){return this._info.depth}},{key:"layerCount",get:function(){return this._info.layerCount}},{key:"levelCount",get:function(){return this._info.levelCount}},{key:"samples",get:function(){return this._info.samples}},{key:"flags",get:function(){return this._info.flags}},{key:"size",get:function(){return this._size}},{key:"info",get:function(){return this._info}},{key:"viewInfo",get:function(){return this._viewInfo}},{key:"isTextureView",get:function(){return this._isTextureView}}]),e}(O_),fd=function(t){function e(e,i){var n;return(n=t.call(this,kl.GLOBAL_BARRIER)||this)._info=new g_,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){return Dl(t.prevAccesses+" "+t.nextAccesses+" "+t.type,666)},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(O_),pd=function(t){function e(e,i){var n;return(n=t.call(this,kl.TEXTURE_BARRIER)||this)._info=new y_,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){var e=t.prevAccesses+" "+t.nextAccesses;return e+=t.type,e+=t.baseMipLevel,e+=t.levelCount,e+=t.baseSlice,e+=t.sliceCount,e+=t.discardContents,e+=t.srcQueue?t.srcQueue.type:0,Dl(e+=t.dstQueue?t.dstQueue.type:0,666)},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(O_),md=function(t){function e(e,i){var n;return(n=t.call(this,kl.BUFFER_BARRIER)||this)._info=new v_,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){var e=t.prevAccesses+" "+t.nextAccesses;return e+=t.type,e+=t.offset,e+=t.size,e+=t.discardContents,e+=t.srcQueue?t.srcQueue.type:0,Dl(e+=t.dstQueue?t.dstQueue.type:0,666)},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(O_),gd={Device:K_,Swapchain:Q_,Buffer:q_,Texture:dd,Sampler:cd,Shader:_d,InputAssembler:$_,RenderPass:ld,Framebuffer:Z_,DescriptorSet:td,DescriptorSetLayout:ed,PipelineLayout:id,PipelineState:hd,CommandBuffer:Y_,Queue:ud,GeneralBarrier:fd,TextureBarrier:pd,BufferBarrier:md,RasterizerState:nd,BlendState:od,BlendTarget:sd,DepthStencilState:rd,PipelineStateInfo:ad};Object.assign(gd,X_),v.gfx=gd;var yd,vd,Sd={GFXDevice:!0,GFXBuffer:!0,GFXTexture:!0,GFXSampler:!0,GFXShader:!0,GFXInputAssembler:!0,GFXRenderPass:!0,GFXFramebuffer:!0,GFXPipelineState:!0,GFXCommandBuffer:!0,GFXQueue:!0,GFXObjectType:!0,GFXObject:!1,GFXAttributeName:!0,GFXType:!0,GFXFormat:!0,GFXBufferUsageBit:!0,GFXMemoryUsageBit:!0,GFXBufferFlagBit:!0,GFXBufferAccessBit:"MemoryAccessBit",GFXPrimitiveMode:!0,GFXPolygonMode:!0,GFXShadeModel:!0,GFXCullMode:!0,GFXComparisonFunc:!0,GFXStencilOp:!0,GFXBlendOp:!0,GFXBlendFactor:!0,GFXColorMask:!0,GFXFilter:!0,GFXAddress:!0,GFXTextureType:!0,GFXTextureUsageBit:!0,GFXSampleCount:!0,GFXTextureFlagBit:!0,GFXShaderStageFlagBit:!0,GFXDescriptorType:!0,GFXCommandBufferType:!0,GFXLoadOp:!0,GFXStoreOp:!0,GFXPipelineBindPoint:!0,GFXDynamicStateFlagBit:!0,GFXStencilFace:!0,GFXQueueType:!0,GFXRect:!0,GFXViewport:!0,GFXColor:!0,GFXClearFlag:!0,GFXOffset:!0,GFXExtent:!0,GFXTextureSubres:"TextureSubresLayers",GFXTextureCopy:!0,GFXBufferTextureCopy:!0,GFXFormatType:!0,GFXFormatInfo:!0,GFXMemoryStatus:!0,GFXFormatInfos:!0,GFXFormatSize:!0,GFXFormatSurfaceSize:!0,GFXGetTypeSize:!0,getTypedArrayConstructor:!1};for(var Td in Sd){var Ad=Sd[Td];!0===Ad?Ad=Td.slice(3):!1===Ad&&(Ad=Td),nt(v,"cc",[{name:Td,newName:Ad,target:v.gfx,targetName:"cc.gfx"}])}rt(v,"cc",[{name:"GFX_MAX_VERTEX_ATTRIBUTES"},{name:"GFX_MAX_TEXTURE_UNITS"},{name:"GFX_MAX_ATTACHMENTS"},{name:"GFX_MAX_BUFFER_BINDINGS"},{name:"GFXTextureLayout"}]),rt(zl,"Feature",[{name:"COLOR_FLOAT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R32F) & FormatFeatureBit.RENDER_TARGET;"},{name:"COLOR_HALF_FLOAT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R16F) & FormatFeatureBit.RENDER_TARGET;"},{name:"TEXTURE_FLOAT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = (device.getFormatFeatures(Format.R32F) & (FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE)) === (FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE);"},{name:"TEXTURE_HALF_FLOAT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = (device.getFormatFeatures(Format.R16F) & (FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE)) === (FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE);"},{name:"TEXTURE_FLOAT_LINEAR",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R32F) & FormatFeatureBit.LINEAR_FILTER;"},{name:"TEXTURE_HALF_FLOAT_LINEAR",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R16F) & FormatFeatureBit.LINEAR_FILTER;"},{name:"FORMAT_R11G11B10F",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R11G11B10F) !== FormatFeatureBit.NONE;"},{name:"FORMAT_SRGB",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.SRGB8) !== FormatFeatureBit.NONE;"},{name:"FORMAT_ETC1",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.ETC_RGB8) !== FormatFeatureBit.NONE;"},{name:"FORMAT_ETC2",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.ETC2_RGB8) !== FormatFeatureBit.NONE;"},{name:"FORMAT_DXT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.BC1) !== FormatFeatureBit.NONE;"},{name:"FORMAT_PVRTC",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.PVRTC_RGB2) !== FormatFeatureBit.NONE;"},{name:"FORMAT_ASTC",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.ASTC_RGBA_4x4) !== FormatFeatureBit.NONE;"},{name:"FORMAT_RGB8",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.RGB8) !== FormatFeatureBit.NONE;"}]),rt(__.prototype,"ColorAttachment",[{name:"beginAccesses",suggest:"Please assign to ColorAttachment.barrier instead"},{name:"endAccesses",suggest:"Please assign to ColorAttachment.barrier instead"}]),rt(d_.prototype,"DepthStencilAttachment",[{name:"beginAccesses",suggest:"Please assign to DepthStencilAttachment.barrier instead"},{name:"endAccesses",suggest:"Please assign to DepthStencilAttachment.barrier instead"}]),nt(K_.prototype,"Device",[{name:"getGlobalBarrier",newName:"getGeneralBarrier"}]),function(t){t[t.AUTO=0]="AUTO",t[t.CANVAS=1]="CANVAS",t[t.WEBGL=2]="WEBGL",t[t.HEADLESS=3]="HEADLESS"}(yd||(yd={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.CANVAS=0]="CANVAS",t[t.WEBGL=1]="WEBGL",t[t.OPENGL=2]="OPENGL",t[t.HEADLESS=3]="HEADLESS"}(vd||(vd={}));var bd=function(){function t(){this.initialized=!1,this._gfxDevice=void 0,this._canvas=null,this._swapchain=void 0,this._renderType=vd.UNKNOWN}var e=t.prototype;return e.init=function(t,e){if(!this.initialized){var i=Ee.querySettings(be.Category.RENDERING,"renderMode");if(this._canvas=t,this._renderType=this._determineRenderType(i),this._renderType===vd.WEBGL){var n=new jc(e),r=!!globalThis.WebGL2RenderingContext;globalThis.navigator.userAgent.toLowerCase(),xl.browserType===Ju.UC&&(r=!1);var s=[];r&&v.WebGL2Device&&s.push(v.WebGL2Device),v.WebGLDevice&&s.push(v.WebGLDevice),v.EmptyDevice&&s.push(v.EmptyDevice),K_.canvas=t;for(var o=0;o<s.length&&(this._gfxDevice=new s[o],!this._gfxDevice.initialize(n));o++);this._initSwapchain()}else this._renderType===vd.HEADLESS&&v.EmptyDevice&&(this._gfxDevice=new v.EmptyDevice,this._gfxDevice.initialize(new jc(e)),this._initSwapchain());if(!this._gfxDevice)return V("can not support canvas rendering in 3D"),void(this._renderType=vd.UNKNOWN);this._canvas&&(this._canvas.oncontextmenu=function(){return!1})}},e._initSwapchain=function(){var t=new Wc(1,this._canvas),e=wl.windowSize;t.width=e.width,t.height=e.height,this._swapchain=this._gfxDevice.createSwapchain(t)},e._determineRenderType=function(t){("number"!=typeof t||t>vd.HEADLESS||t<yd.AUTO)&&(t=yd.AUTO);var e=vd.CANVAS,i=!1;if(t===yd.CANVAS?(e=vd.CANVAS,i=!0):t===yd.AUTO||t===yd.WEBGL?(e=vd.WEBGL,i=!0):t===yd.HEADLESS&&(e=vd.HEADLESS,i=!0),!i)throw new Error(tt(3820,t));return e},n(t,[{key:"gfxDevice",get:function(){return this._gfxDevice}},{key:"swapchain",get:function(){return this._swapchain}}]),t}(),Ed=new bd;t("aC",Object.freeze({__proto__:null,DescriptorSet:td,Buffer:q_,CommandBuffer:Y_,get ObjectType(){return kl},get Status(){return Vl},get API(){return Gl},get SurfaceTransform(){return Ul},get Feature(){return zl},get Format(){return Hl},get FormatType(){return Wl},get Type(){return jl},get BufferUsageBit(){return Xl},get BufferFlagBit(){return ql},get MemoryAccessBit(){return Yl},get MemoryUsageBit(){return Kl},get TextureType(){return Jl},get TextureUsageBit(){return Ql},get TextureFlagBit(){return Zl},get FormatFeatureBit(){return $l},get SampleCount(){return tc},get VsyncMode(){return ec},get Filter(){return ic},get Address(){return nc},get ComparisonFunc(){return rc},get StencilOp(){return sc},get BlendFactor(){return oc},get BlendOp(){return ac},get ColorMask(){return hc},get ShaderStageFlagBit(){return uc},get LoadOp(){return lc},get StoreOp(){return cc},get AccessFlagBit(){return _c},get ResolveMode(){return dc},get PipelineBindPoint(){return fc},get PrimitiveMode(){return pc},get PolygonMode(){return mc},get ShadeModel(){return gc},get CullMode(){return yc},get DynamicStateFlagBit(){return vc},get StencilFace(){return Sc},get DescriptorType(){return Tc},get QueueType(){return Ac},get QueryType(){return bc},get CommandBufferType(){return Ec},get ClearFlagBit(){return Cc},get BarrierType(){return wc},get PassType(){return xc},Size:Bc,DeviceCaps:Dc,DeviceOptions:Pc,Offset:Oc,Rect:Mc,Extent:Lc,TextureSubresLayers:Nc,TextureSubresRange:Fc,TextureCopy:kc,TextureBlit:Vc,BufferTextureCopy:Gc,Viewport:Uc,Color:zc,BindingMappingInfo:Hc,SwapchainInfo:Wc,DeviceInfo:jc,BufferInfo:Xc,BufferViewInfo:qc,DrawInfo:Yc,DispatchInfo:Kc,IndirectBuffer:Jc,TextureInfo:Qc,TextureViewInfo:Zc,SamplerInfo:$c,Uniform:t_,UniformBlock:e_,UniformSamplerTexture:i_,UniformSampler:n_,UniformTexture:r_,UniformStorageImage:s_,UniformStorageBuffer:o_,UniformInputAttachment:a_,ShaderStage:h_,Attribute:u_,ShaderInfo:l_,InputAssemblerInfo:c_,ColorAttachment:__,DepthStencilAttachment:d_,SubpassInfo:f_,SubpassDependency:p_,RenderPassInfo:m_,GeneralBarrierInfo:g_,TextureBarrierInfo:y_,BufferBarrierInfo:v_,FramebufferInfo:S_,DescriptorSetLayoutBinding:T_,DescriptorSetLayoutInfo:A_,DescriptorSetInfo:b_,PipelineLayoutInfo:E_,InputState:C_,CommandBufferInfo:w_,QueueInfo:x_,QueryPoolInfo:R_,FormatInfo:I_,MemoryStatus:B_,DynamicStencilStates:D_,DynamicStates:P_,GFXObject:O_,get AttributeName(){return Ic},FormatInfos:M_,DESCRIPTOR_BUFFER_TYPE:L_,DESCRIPTOR_SAMPLER_TYPE:N_,DESCRIPTOR_DYNAMIC_TYPE:F_,DRAW_INFO_SIZE:28,IsPowerOf2:k_,FormatSize:V_,FormatSurfaceSize:G_,GetTypeSize:z_,getTypedArrayConstructor:H_,formatAlignment:W_,alignTo:j_,Device:K_,DefaultResource:J_,Swapchain:Q_,Framebuffer:Z_,InputAssembler:$_,DescriptorSetLayout:ed,PipelineLayout:id,BlendState:od,BlendTarget:sd,RasterizerState:nd,DepthStencilState:rd,PipelineStateInfo:ad,PipelineState:hd,Queue:ud,RenderPass:ld,Sampler:cd,Shader:_d,Texture:dd,GeneralBarrier:fd,TextureBarrier:pd,get LegacyRenderMode(){return yd},get RenderType(){return vd},DeviceManager:bd,deviceManager:Ed}));var Cd=new In;function wd(t,e,i,n){var r=i.chunk,s=i.data,o=r.vb,a=i.vertexCount;t.getWorldMatrix(Cd);for(var h=0,u=0;u<a;u++){var l=s[u],c=l.x,_=l.y,d=Cd.m03*c+Cd.m07*_+Cd.m15;d=d?1/d:1,o[h+0]=(Cd.m00*c+Cd.m04*_+Cd.m12)*d,o[h+1]=(Cd.m01*c+Cd.m05*_+Cd.m13)*d,o[h+2]=(Cd.m02*c+Cd.m06*_+Cd.m14)*d,dn.toArray(o,n,h+5),h+=9}r.bufferId;for(var f=r.vertexOffset,p=r.meshBuffer,m=r.meshBuffer.iData,g=p.indexOffset,y=0,v=a/4;y<v;y++){var S=f+4*y;m[g++]=S,m[g++]=S+1,m[g++]=S+2,m[g++]=S+1,m[g++]=S+3,m[g++]=S+2}p.indexOffset+=i.indexCount,p.setDirty()}var xd={},Rd=function(){function t(t){this._map=null,this._count=0,t?(this._map=t,this._count=Object.keys(t).length):(this._map=It(!0),this._count=0)}var e=t.prototype;return e.add=function(t,e){return t in this._map||this._count++,this._map[t]=e},e.get=function(t){return this._map[t]},e.has=function(t){return t in this._map},e.remove=function(t){var e=this._map[t];return t in this._map&&(delete this._map[t],this._count--),e},e.clear=function(){0!==this._count&&(this._map=It(!0),this._count=0)},e.forEach=function(t){for(var e in this._map)t(this._map[e],e)},e.find=function(t){for(var e in this._map)if(t(this._map[e],e))return this._map[e];return null},e.destroy=function(){this._map=null},n(t,[{key:"map",get:function(){return this._map}},{key:"count",get:function(){return this._count}}]),t}(),Id=function(){function t(e,i){this.id=t._pipelineId++,this.name="",this.pipes=[],this.name=e;for(var n=0,r=i.length;n<r;n++)this.pipes.push(i[n])}var e=t.prototype;return e.insert=function(t,e){return e>this.pipes.length?(Y(4921),this):(this.pipes.splice(e,0,t),this)},e.append=function(t){return this.pipes.push(t),this},e.remove=function(t){return this.pipes.splice(t,1),this},e.sync=function(t){var e=this.pipes;if(0===e.length)return null;t.isFinished=!1;for(var i=0,n=e.length;i<n;){var r=(0,e[i])(t);if(r)return t.isFinished=!0,r;++i!==n&&(t.input=t.output,t.output=null)}return t.isFinished=!0,t.output},e.async=function(t){0!==this.pipes.length&&(t.isFinished=!1,this._flow(0,t))},e._flow=function(t,e){var i=this;(0,this.pipes[t])(e,(function(n){n?(e.isFinished=!0,e.dispatch("complete",n)):++t<i.pipes.length?(e.input=e.output,e.output=null,i._flow(t,e)):(e.isFinished=!0,e.dispatch("complete",n,e.output))}))},t}();Id._pipelineId=0,function(){function t(t){if(this._weakMap={},void 0===window.WeakRef)throw new Error("this platform does not support WeakRef!");if(t)for(var e in t)this._weakMap[e]=new WeakRef(t[e])}var e=t.prototype;e.add=function(t,e){return this._weakMap[t]=new WeakRef(e),e},e.has=function(t){return t in this._weakMap&&!!this._weakMap[t].deref()},e.get=function(t){return this._weakMap[t]&&this._weakMap[t].deref()},e.remove=function(t){var e=this._weakMap[t];return delete this._weakMap[t],e&&e.deref()},e.clear=function(){this._weakMap=It(!0)},e.forEach=function(t){for(var e in this._weakMap){var i=this.get(e);i&&t(i,e)}},e.find=function(t){for(var e in this._weakMap){var i=this.get(e);if(i&&t(i,e))return this._weakMap[e].deref()}return null},e.destroy=function(){this._weakMap={}},n(t,[{key:"count",get:function(){return Object.values(this._weakMap).filter((function(t){return t.deref()})).length}}])}();var Bd,Dd=new Rd,Pd=new Rd,Od=new Rd,Md=new Rd,Ld=new Id("normal load",[]),Nd=new Id("fetch",[]),Fd=new Id("transform url",[]),kd=new Map;!function(t){t.UUID="uuid",t.PATH="path",t.DIR="dir",t.URL="url",t.SCENE="scene"}(Bd||(Bd={}));var Vd,Gd={default:{priority:0},preload:{maxConcurrency:6,maxRequestsPerFrame:2,priority:-1},scene:{maxConcurrency:20,maxRequestsPerFrame:20,priority:1},bundle:{maxConcurrency:20,maxRequestsPerFrame:20,priority:2},remote:{maxRetryCount:4}};!function(t){t.INTERNAL="internal",t.RESOURCES="resources",t.MAIN="main",t.START_SCENE="start-scene"}(Vd||(Vd={}));var Ud=function(){function t(e){this.id=t._taskId++,this.onComplete=null,this.onProgress=null,this.onError=null,this.source=null,this.output=null,this.input=null,this.progress=null,this.options=null,this.isFinished=!0,this.set(e)}t.create=function(e){var i;return 0!==t._deadPool.length?(i=t._deadPool.pop()).set(e):i=new t(e),i};var e=t.prototype;return e.set=function(t){void 0===t&&(t=Object.create(null)),this.onComplete=t.onComplete||null,this.onProgress=t.onProgress||null,this.onError=t.onError||null,this.source=this.input=t.input,this.output=null,this.progress=t.progress,this.options=t.options||Object.create(null)},e.dispatch=function(t,e,i,n,r){switch(t){case"complete":this.onComplete&&this.onComplete(e,i);break;case"progress":this.onProgress&&this.onProgress(e,i,n,r);break;case"error":this.onError&&this.onError(e,i,n,r);break;default:var s="on"+t[0].toUpperCase()+t.substr(1);"function"==typeof this[s]&&this[s](e,i,n,r)}},e.recycle=function(){t._deadPool.length!==t.MAX_DEAD_NUM&&(this.onComplete=null,this.onProgress=null,this.onError=null,this.source=this.output=this.input=null,this.progress=null,this.options=null,t._deadPool.push(this))},n(t,[{key:"isFinish",get:function(){return this.isFinished},set:function(t){this.isFinished=t}}]),t}();Ud.MAX_DEAD_NUM=500,Ud._taskId=0,Ud._deadPool=[];var zd="0123456789abcdef".split(""),Hd=["","","",""],Wd=Hd.concat(Hd,"-",Hd,"-",Hd,"-",Hd,"-",Hd,Hd,Hd),jd=Wd.map((function(t,e){return"-"===t?NaN:e})).filter(Number.isFinite);function Xd(t){var e=t.split("@")[0];if(22!==e.length)return t;Wd[0]=t[0],Wd[1]=t[1];for(var i=2,n=2;i<22;i+=2){var r=Be[t.charCodeAt(i)],s=Be[t.charCodeAt(i+1)];Wd[jd[n++]]=zd[r>>2],Wd[jd[n++]]=zd[(3&r)<<2|s>>4],Wd[jd[n++]]=zd[15&s]}return t.replace(e,Wd.join(""))}var qd=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/;function Yd(t){var e=qd.exec(t);return e?e[1]:""}function Kd(t,e){(e=e||Object.create(null)).__isNative__=e.isNative,e.nativeExt&&(e.ext=e.nativeExt);var i=Md.find((function(e){return!!e.getAssetInfo(t)}));return i&&(e.bundle=i.name),Zd(t,e)}function Jd(t){return!!t&&(t instanceof v.SceneAsset||t instanceof v.Scene)}function Qd(t){return t&&(46===t.charCodeAt(0)&&47===t.charCodeAt(1)?t=t.slice(2):47===t.charCodeAt(0)&&(t=t.slice(1))),t}function Zd(t,e){var i=Ud.create({input:t,options:e}),n=[];try{for(var r,s=d(Fd.sync(i));!(r=s()).done;){var o=r.value,a=o.url;o.recycle(),n.push(a)}}catch(t){for(var h,u=d(i.output);!(h=u()).done;)h.value.recycle();V(t.message,t.stack)}return i.recycle(),n.length>1?n:n[0]}var $d,tf,ef,nf=Object.freeze({__proto__:null,getUuidFromURL:Yd,getUrlWithUuid:Kd,isScene:Jd,normalize:Qd,transform:Zd,decodeUuid:Xd}),rf=io,sf=Qs,of=t("e8",qs("cc.Asset")((tf=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).loaded=!0,e._native=ef&&ef(),e._nativeUrl="",e._file=null,e._ref=0,Object.defineProperty(c(e),"_uuid",{value:"",writable:!0}),e}s(e,t),e.deserialize=function(t){return v.deserialize(t)};var i=e.prototype;return i.toString=function(){return this.nativeUrl},i.serialize=function(){},i._setRawAsset=function(t,e){void 0===e&&(e=!0),this._native=!1!==e?t||"":"/"+t},i.addRef=function(){return this._ref++,this},i.decRef=function(t){return void 0===t&&(t=!0),this._ref>0&&this._ref--,t&&v.assetManager._releaseManager.tryRelease(this),this},i.onLoaded=function(){},i.initDefault=function(t){t&&(this._uuid=t),this.isDefault=!0},i.validate=function(){return!0},i.destroy=function(){return U(tt(12101,this._uuid)),t.prototype.destroy.call(this)},n(e,[{key:"nativeUrl",get:function(){if(!this._nativeUrl){if(!this._native)return"";var t=this._native;if(47===t.charCodeAt(0))return t.slice(1);46===t.charCodeAt(0)?this._nativeUrl=Kd(this._uuid,{nativeExt:t,isNative:!0}):this._nativeUrl=Kd(this._uuid,{__nativeName__:t,nativeExt:hl(t),isNative:!0})}return this._nativeUrl}},{key:"uuid",get:function(){return this._uuid}},{key:"_nativeAsset",get:function(){return this._file},set:function(t){this._file=t}},{key:"nativeAsset",get:function(){return this._file}},{key:"_nativeDep",get:function(){if(this._native)return{__isNative__:!0,uuid:this._uuid,ext:this._native}}},{key:"refCount",get:function(){return this._ref}}]),e}(Yu(Ho)),ef=ks(tf.prototype,"_native",[rf],(function(){return""})),p(tf.prototype,"_nativeAsset",[sf],Object.getOwnPropertyDescriptor(tf.prototype,"_nativeAsset"),tf.prototype),$d=tf))||$d);of.prototype.createNode=null,v.Asset=of;var af,hf,uf,lf,cf,_f;!function(t){t[t.RGB565=Hl.R5G6B5]="RGB565",t[t.RGB5A1=Hl.RGB5A1]="RGB5A1",t[t.RGBA4444=Hl.RGBA4]="RGBA4444",t[t.RGB888=Hl.RGB8]="RGB888",t[t.RGB32F=Hl.RGB32F]="RGB32F",t[t.RGBA8888=Hl.RGBA8]="RGBA8888",t[t.RGBA32F=Hl.RGBA32F]="RGBA32F",t[t.A8=Hl.A8]="A8",t[t.I8=Hl.L8]="I8",t[t.AI8=Hl.LA8]="AI8",t[t.RGB_PVRTC_2BPPV1=Hl.PVRTC_RGB2]="RGB_PVRTC_2BPPV1",t[t.RGBA_PVRTC_2BPPV1=Hl.PVRTC_RGBA2]="RGBA_PVRTC_2BPPV1",t[t.RGB_A_PVRTC_2BPPV1=1024]="RGB_A_PVRTC_2BPPV1",t[t.RGB_PVRTC_4BPPV1=Hl.PVRTC_RGB4]="RGB_PVRTC_4BPPV1",t[t.RGBA_PVRTC_4BPPV1=Hl.PVRTC_RGBA4]="RGBA_PVRTC_4BPPV1",t[t.RGB_A_PVRTC_4BPPV1=1025]="RGB_A_PVRTC_4BPPV1",t[t.RGB_ETC1=Hl.ETC_RGB8]="RGB_ETC1",t[t.RGBA_ETC1=1026]="RGBA_ETC1",t[t.RGB_ETC2=Hl.ETC2_RGB8]="RGB_ETC2",t[t.RGBA_ETC2=Hl.ETC2_RGBA8]="RGBA_ETC2",t[t.RGBA_ASTC_4x4=Hl.ASTC_RGBA_4X4]="RGBA_ASTC_4x4",t[t.RGBA_ASTC_5x4=Hl.ASTC_RGBA_5X4]="RGBA_ASTC_5x4",t[t.RGBA_ASTC_5x5=Hl.ASTC_RGBA_5X5]="RGBA_ASTC_5x5",t[t.RGBA_ASTC_6x5=Hl.ASTC_RGBA_6X5]="RGBA_ASTC_6x5",t[t.RGBA_ASTC_6x6=Hl.ASTC_RGBA_6X6]="RGBA_ASTC_6x6",t[t.RGBA_ASTC_8x5=Hl.ASTC_RGBA_8X5]="RGBA_ASTC_8x5",t[t.RGBA_ASTC_8x6=Hl.ASTC_RGBA_8X6]="RGBA_ASTC_8x6",t[t.RGBA_ASTC_8x8=Hl.ASTC_RGBA_8X8]="RGBA_ASTC_8x8",t[t.RGBA_ASTC_10x5=Hl.ASTC_RGBA_10X5]="RGBA_ASTC_10x5",t[t.RGBA_ASTC_10x6=Hl.ASTC_RGBA_10X6]="RGBA_ASTC_10x6",t[t.RGBA_ASTC_10x8=Hl.ASTC_RGBA_10X8]="RGBA_ASTC_10x8",t[t.RGBA_ASTC_10x10=Hl.ASTC_RGBA_10X10]="RGBA_ASTC_10x10",t[t.RGBA_ASTC_12x10=Hl.ASTC_RGBA_12X10]="RGBA_ASTC_12x10",t[t.RGBA_ASTC_12x12=Hl.ASTC_RGBA_12X12]="RGBA_ASTC_12x12"}(af||(af={})),function(t){t[t.REPEAT=nc.WRAP]="REPEAT",t[t.CLAMP_TO_EDGE=nc.CLAMP]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=nc.MIRROR]="MIRRORED_REPEAT",t[t.CLAMP_TO_BORDER=nc.BORDER]="CLAMP_TO_BORDER"}(hf||(hf={})),function(t){t[t.NONE=ic.NONE]="NONE",t[t.LINEAR=ic.LINEAR]="LINEAR",t[t.NEAREST=ic.POINT]="NEAREST"}(uf||(uf={}));var df=1346981187,ff=ge({PVR:0,PKM:1,ASTC:2});function pf(t,e){return t[e]<<8|t[e+1]}function mf(t){return!!(xl.hasFeature(xl.Feature.IMAGE_BITMAP)&&t instanceof ImageBitmap)}var gf,yf,vf,Sf,Tf,Af,bf,Ef,Cf,wf,xf,Rf=t("ee",qs("cc.ImageAsset")(((_f=function(t){s(i,t),i.mergeCompressedTextureMips=function(t){var e=new Uint8Array(0),i=null;try{for(var n,r=8+4*t.length,s=0,o=d(t);!(n=o()).done;)s+=n.value.byteLength;s+=r,e=new Uint8Array(s);var a=new DataView(e.buffer,e.byteOffset,e.byteLength);a.setUint32(0,df,!0),a.setUint32(4,t.length,!0);for(var h=r,u=0;u<t.length;u++){var l=t[u];if(a.setUint32(8+4*u,l.byteLength,!0),l instanceof ArrayBuffer){var c=new Uint8Array(l);e.set(c,h)}else{var _=new Uint8Array(l.buffer,l.byteOffset,l.byteLength);e.set(_,h)}h+=l.byteLength}}catch(t){i=t,console.warn(i)}return e},i.parseCompressedTextures=function(t,e){var n={_data:new Uint8Array(0),_compressed:!0,width:0,height:0,format:0,mipmapLevelDataSize:[]},r=t instanceof ArrayBuffer?t:t.buffer,s=new DataView(r);if(s.getUint32(0,!0)===df){var o=s.getUint32(4,!0),a=s.getUint32(8,!0),h=8+4*o;i.parseCompressedTexture(t,0,h,a,e,n);for(var u=h+a,l=1;l<o;l++){var c=s.getUint32(8+4*l,!0);i.parseCompressedTexture(t,l,u,c,e,n),u+=c}}else i.parseCompressedTexture(t,0,0,0,e,n);return n},i.parseCompressedTexture=function(t,e,n,r,s,o){switch(s){case ff.PVR:i.parsePVRTexture(t,e,n,r,o);break;case ff.PKM:i.parsePKMTexture(t,e,n,r,o);break;case ff.ASTC:i.parseASTCTexture(t,e,n,r,o)}},i.parsePVRTexture=function(t,e,i,n,r){var s=t instanceof ArrayBuffer?t:t.buffer,o=new Int32Array(s,i,13);if(55727696===o[0]){var a=i+o[12]+52,h=n-o.byteLength;if(n>0){var u=new Uint8Array(s,a,h),l=new Uint8Array(r._data.byteLength+u.byteLength);l.set(r._data),l.set(u,r._data.byteLength),r._data=l,r.mipmapLevelDataSize[e]=h}else r._data=new Uint8Array(s,a);r.width=e>0?r.width:o[7],r.height=e>0?r.height:o[6]}else{if(559044176!==o[11])throw new Error("Invalid magic number in PVR header");var c=i+o[0],_=n-o.byteLength;if(n>0){var d=new Uint8Array(s,c,_),f=new Uint8Array(r._data.byteLength+d.byteLength);f.set(r._data),f.set(d,r._data.byteLength),r._data=f,r.mipmapLevelDataSize[e]=_}else r._data=new Uint8Array(s,c);r.width=e>0?r.width:o[1],r.height=e>0?r.height:o[2]}},i.parsePKMTexture=function(t,e,i,n,r){var s=t instanceof ArrayBuffer?t:t.buffer,o=new Uint8Array(s,i,16),a=pf(o,6);if(0!==a&&1!==a&&3!==a)throw new Error("Invalid magic number in ETC header");var h=i+16,u=n-16;if(n>0){var l=new Uint8Array(s,h,u),c=new Uint8Array(r._data.byteLength+l.byteLength);c.set(r._data),c.set(l,r._data.byteLength),r._data=c,r.mipmapLevelDataSize[e]=u}else r._data=new Uint8Array(s,h);r.width=e>0?r.width:pf(o,12),r.height=e>0?r.height:pf(o,14)},i.parseASTCTexture=function(t,e,i,n,r){var s=t instanceof ArrayBuffer?t:t.buffer,o=new Uint8Array(s,i,16);if(1554098963!==o[0]+(o[1]<<8)+(o[2]<<16)+(o[3]<<24))throw new Error("Invalid magic number in ASTC header");var a=o[4],h=o[5],u=o[6];if((a<3||a>6||h<3||h>6||u<3||u>6)&&(a<4||7===a||9===a||11===a||a>12||h<4||7===h||9===h||11===h||h>12||1!==u))throw new Error("Invalid block number in ASTC header");var l=function(t,e){return 4===t?af.RGBA_ASTC_4x4:5===t?4===e?af.RGBA_ASTC_5x4:af.RGBA_ASTC_5x5:6===t?5===e?af.RGBA_ASTC_6x5:af.RGBA_ASTC_6x6:8===t?5===e?af.RGBA_ASTC_8x5:6===e?af.RGBA_ASTC_8x6:af.RGBA_ASTC_8x8:10===t?5===e?af.RGBA_ASTC_10x5:6===e?af.RGBA_ASTC_10x6:8===e?af.RGBA_ASTC_10x8:af.RGBA_ASTC_10x10:10===e?af.RGBA_ASTC_12x10:af.RGBA_ASTC_12x12}(a,h),c=i+16,_=n-16;if(n>0){var d=new Uint8Array(s,c,_),f=new Uint8Array(r._data.byteLength+d.byteLength);f.set(r._data),f.set(d,r._data.byteLength),r._data=f,r.mipmapLevelDataSize[e]=_}else r._data=new Uint8Array(s,c);r.width=e>0?r.width:o[7]+(o[8]<<8)+(o[9]<<16),r.height=e>0?r.height:o[10]+(o[11]<<8)+(o[12]<<16),r.format=l};var e=i.prototype;function i(e){var i;return(i=t.call(this)||this)._nativeData=void 0,i._exportedExts=void 0,i._format=af.RGBA8888,i._width=0,i._height=0,i._nativeData={_data:null,width:0,height:0,format:0,_compressed:!1,mipmapLevelDataSize:[]},void 0!==e&&i.reset(e),i}return e.extractMipmap0=function(){if(this.mipmapLevelDataSize&&this.mipmapLevelDataSize.length>0){var t=this.mipmapLevelDataSize[0],e=this.data,n=new i({_data:new Uint8Array(e.buffer,0,t),_compressed:!0,width:this.width,height:this.height,format:this.format,mipmapLevelDataSize:[]});return n._uuid=""+this._uuid,n}return this},e.extractMipmaps=function(){var t=[];if(this.mipmapLevelDataSize&&this.mipmapLevelDataSize.length>0)for(var e,n=this.mipmapLevelDataSize,r=this.data,s=0,o=this.height,a=this.width,h=d(n);!(e=h()).done;){var u=e.value,l=new i({_data:new Uint8Array(r.buffer,s,u),_compressed:!0,width:a,height:o,format:this.format,mipmapLevelDataSize:[]});s+=u,l._uuid=""+this._uuid,a=Math.max(a>>1,1),o=Math.max(o>>1,1),t.push(l)}else t.push(this);return t},e.reset=function(t){mf(t)||t instanceof HTMLElement?this._nativeData=t:(this._nativeData=t,this._format=t.format)},e.destroy=function(){if(this.data&&this.data instanceof HTMLImageElement)this.data.src="",this._setRawAsset("");else if(mf(this.data)){var e;null===(e=this.data)||void 0===e||e.close()}return t.prototype.destroy.call(this)},e._serialize=function(){},e._deserialize=function(t){var e="";"string"==typeof t?e=t:(this._width=t.w,this._height=t.h,e=t.fmt);for(var n,r=Ed.gfxDevice,s=e.split("_"),o=Number.MAX_VALUE,a=this._format,h="",u=Ce.SUPPORT_TEXTURE_FORMATS,l=d(s);!(n=l()).done;){var c=n.value.split("@"),_=parseInt(c[0],void 0),f=i.extnames[_]||c[0],p=u.indexOf(f);if(-1!==p&&p<o){var m=c[1]?parseInt(c[1]):this._format;if(!(".astc"!==f||r&&r.getFormatFeatures(Hl.ASTC_RGBA_4X4)&$l.SAMPLED_TEXTURE))continue;if(!(".pvr"!==f||r&&r.getFormatFeatures(Hl.PVRTC_RGBA4)&$l.SAMPLED_TEXTURE))continue;if(!(m!==af.RGB_ETC1&&m!==af.RGBA_ETC1||r&&r.getFormatFeatures(Hl.ETC_RGB8)&$l.SAMPLED_TEXTURE))continue;if(!(m!==af.RGB_ETC2&&m!==af.RGBA_ETC2||r&&r.getFormatFeatures(Hl.ETC2_RGB8)&$l.SAMPLED_TEXTURE))continue;if(".webp"===f&&!xl.hasFeature(xl.Feature.WEBP))continue;o=p,h=f,a=m}}h?(this._setRawAsset(h),this._format=a):Y(3121)},e.initDefault=function(e){if(t.prototype.initDefault.call(this,e),i._sharedPlaceHolderCanvas)this.reset(i._sharedPlaceHolderCanvas);else{var n=T.document.createElement("canvas"),r=n.getContext("2d"),s=n.width=n.height=2;r.fillStyle="#ff00ff",r.fillRect(0,0,s,s),this.reset(n),i._sharedPlaceHolderCanvas=n}},e.validate=function(){return!!this.data},n(i,[{key:"_nativeAsset",get:function(){return this._nativeData},set:function(t){t instanceof HTMLElement||mf(t)||(t.format=t.format||this._format),this.reset(t)}},{key:"data",get:function(){return(t=this._nativeData)instanceof HTMLImageElement||t instanceof HTMLCanvasElement||mf(t)?this._nativeData:this._nativeData&&this._nativeData._data;var t}},{key:"width",get:function(){return this._nativeData.width||this._width}},{key:"height",get:function(){return this._nativeData.height||this._height}},{key:"format",get:function(){return this._format}},{key:"isCompressed",get:function(){return this._format>=af.RGB_ETC1&&this._format<=af.RGBA_ASTC_12x12||this._format>=af.RGB_A_PVRTC_2BPPV1&&this._format<=af.RGBA_ETC1}},{key:"mipmapLevelDataSize",get:function(){return this._nativeData.mipmapLevelDataSize}},{key:"url",get:function(){return this.nativeUrl}}]),i}(of)).extnames=[".png",".jpg",".jpeg",".bmp",".webp",".pvr",".pkm",".astc"],_f._sharedPlaceHolderCanvas=null,p((cf=_f).prototype,"_nativeAsset",[Ro],Object.getOwnPropertyDescriptor(cf.prototype,"_nativeAsset"),cf.prototype),lf=cf))||lf);v.ImageAsset=Rf,Se(Hl);var If,Bf,Df,Pf=new gt("Tex"),Of=qs("cc.TextureBase")(((xf=function(t){function e(){var e;return(e=t.call(this)||this)._format=vf&&vf(),e._minFilter=Sf&&Sf(),e._magFilter=Tf&&Tf(),e._mipFilter=Af&&Af(),e._wrapS=bf&&bf(),e._wrapT=Ef&&Ef(),e._wrapR=Cf&&Cf(),e._anisotropy=wf&&wf(),e._width=1,e._height=1,e._id=void 0,e._samplerInfo=new $c,e._gfxSampler=null,e._gfxDevice=null,e._textureHash=0,e._id=Pf.getNewId(),e._gfxDevice=e._getGFXDevice(),e._textureHash=Dl(e._id,666),e}s(e,t);var i=e.prototype;return i.getId=function(){return this._id},i.getPixelFormat=function(){return this._format},i.getAnisotropy=function(){return this._anisotropy},i.setWrapMode=function(t,e,i){void 0===i&&(i=t),this._wrapS=t,this._samplerInfo.addressU=t,this._wrapT=e,this._samplerInfo.addressV=e,this._wrapR=i,this._samplerInfo.addressW=i,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},i.setFilters=function(t,e){this._minFilter=t,this._samplerInfo.minFilter=t,this._magFilter=e,this._samplerInfo.magFilter=e,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},i.setMipFilter=function(t){this._mipFilter=t,this._samplerInfo.mipFilter=t,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},i.setAnisotropy=function(t){this._anisotropy=t,this._samplerInfo.maxAnisotropy=t,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},i.destroy=function(){var e,i=t.prototype.destroy.call(this);return i&&null!==(e=v.director.root)&&void 0!==e&&e.batcher2D&&v.director.root.batcher2D._releaseDescriptorSetCache(this._textureHash),i},i.getHash=function(){return this._textureHash},i.getGFXTexture=function(){return null},i.getSamplerInfo=function(){return this._samplerInfo},i.getGFXSampler=function(){return this._gfxSampler||(this._gfxDevice?this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo):J(9302)),this._gfxSampler},i._serialize=function(){return""},i._deserialize=function(t){var e=t.split(",");e.unshift(""),e.length>=5&&(this.setFilters(parseInt(e[1]),parseInt(e[2])),this.setWrapMode(parseInt(e[3]),parseInt(e[4]))),e.length>=7&&(this.setMipFilter(parseInt(e[5])),this.setAnisotropy(parseInt(e[6])))},i._getGFXDevice=function(){return Ed.gfxDevice},i._getGFXFormat=function(){return this._getGFXPixelFormat(this._format)},i._setGFXFormat=function(t){this._format=void 0===t?af.RGBA8888:t},i._getGFXPixelFormat=function(t){return t===af.RGBA_ETC1?t=af.RGB_ETC1:t===af.RGB_A_PVRTC_4BPPV1?t=af.RGB_PVRTC_4BPPV1:t===af.RGB_A_PVRTC_2BPPV1&&(t=af.RGB_PVRTC_2BPPV1),t},n(e,[{key:"isCompressed",get:function(){return this._format>=af.RGB_ETC1&&this._format<=af.RGBA_ASTC_12x12||this._format>=af.RGB_A_PVRTC_2BPPV1&&this._format<=af.RGBA_ETC1}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),e}(of)).PixelFormat=af,xf.WrapMode=hf,xf.Filter=uf,vf=ks((yf=xf).prototype,"_format",[io],(function(){return af.RGBA8888})),Sf=ks(yf.prototype,"_minFilter",[io],(function(){return uf.LINEAR})),Tf=ks(yf.prototype,"_magFilter",[io],(function(){return uf.LINEAR})),Af=ks(yf.prototype,"_mipFilter",[io],(function(){return uf.NONE})),bf=ks(yf.prototype,"_wrapS",[io],(function(){return hf.REPEAT})),Ef=ks(yf.prototype,"_wrapT",[io],(function(){return hf.REPEAT})),Cf=ks(yf.prototype,"_wrapR",[io],(function(){return hf.REPEAT})),wf=ks(yf.prototype,"_anisotropy",[io],(function(){return 0})),gf=yf))||gf;v.TextureBase=Of;var Mf=t("ek",qs("cc.Script")(If=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(of))||If);v._Script=Mf;var Lf=t("el",qs("cc.JavaScript")(Bf=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Mf))||Bf);v._JavaScript=Lf;var Nf,Ff,kf,Vf,Gf,Uf,zf,Hf=t("em",qs("cc.TypeScript")(Df=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Mf))||Df);v._TypeScript=Hf;var Wf,jf,Xf,qf,Yf,Kf,Jf,Qf,Zf,$f,tp,ep=t("dD",qs("cc.ClickEvent")((Ff=function(){function t(){this.target=kf&&kf(),this.component=Vf&&Vf(),this._componentId=Gf&&Gf(),this.handler=Uf&&Uf(),this.customEventData=zf&&zf()}t.emitEvents=function(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];for(var s=0,o=e.length;s<o;s++){var a=e[s];a instanceof t&&a.emit(n)}};var e=t.prototype;return e.emit=function(t){var e=this.target;if(v.isValid(e)){this._genCompIdIfNeeded();var i=v.js.getClassById(this._componentId),n=e.getComponent(i);if(v.isValid(n)){var r=n[this.handler];"function"==typeof r&&(null!=this.customEventData&&""!==this.customEventData&&(t=t.slice()).push(this.customEventData),r.apply(n,t))}}},e._compName2Id=function(t){var e=v.js.getClassByName(t);return v.js.getClassId(e)},e._compId2Name=function(t){var e=v.js.getClassById(t);return v.js.getClassName(e)},e._genCompIdIfNeeded=function(){this._componentId||(this._componentName=this.component,this.component="")},n(t,[{key:"_componentName",get:function(){return this._genCompIdIfNeeded(),this._compId2Name(this._componentId)},set:function(t){this._componentId=this._compName2Id(t)}}]),t}(),kf=ks(Ff.prototype,"target",[io],(function(){return null})),Vf=ks(Ff.prototype,"component",[io],(function(){return""})),Gf=ks(Ff.prototype,"_componentId",[io],(function(){return""})),Uf=ks(Ff.prototype,"handler",[io],(function(){return""})),zf=ks(Ff.prototype,"customEventData",[io],(function(){return""})),Nf=Ff))||Nf),ip=new gt("Comp"),np=Ho.Flags.IsOnLoadCalled,rp=t("dE",(Wf=qs("cc.Component"),jf=xo(Mf),Wf(((Qf=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).node=Yf&&Yf(),e._enabled=Kf&&Kf(),e.__prefab=Jf&&Jf(),e._sceneGetter=null,e._id=ip.getNewId(),e}s(e,t);var i=e.prototype;return i._getRenderScene=function(){return this._sceneGetter?this._sceneGetter():this.node.scene.renderScene},i.addComponent=function(t){return this.node.addComponent(t)},i.getComponent=function(t){return this.node.getComponent(t)},i.getComponents=function(t){return this.node.getComponents(t)},i.getComponentInChildren=function(t){return this.node.getComponentInChildren(t)},i.getComponentsInChildren=function(t){return this.node.getComponentsInChildren(t)},i.destroy=function(){return!!t.prototype.destroy.call(this)&&(this._enabled&&this.node.activeInHierarchy&&v.director._compScheduler.disableComp(this),!0)},i._onPreDestroy=function(){this.unscheduleAllCallbacks(),v.director._nodeActivator.destroyComp(this),this.node._removeComponent(this)},i._instantiate=function(t){return t||(t=v.instantiate._clone(this,this)),t&&(t.node=null),t},i.schedule=function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=v.macro.REPEAT_FOREVER),void 0===n&&(n=0),$(Boolean(t),1619),$((e=e||0)>=0,1620),i=Number.isNaN(i)?v.macro.REPEAT_FOREVER:i,n=n||0;var r=v.director.getScheduler(),s=r.isTargetPaused(this);r.schedule(t,this,e,i,n,s)},i.scheduleOnce=function(t,e){void 0===e&&(e=0),this.schedule(t,0,0,e)},i.unschedule=function(t){t&&v.director.getScheduler().unschedule(t,this)},i.unscheduleAllCallbacks=function(){v.director.getScheduler().unscheduleAllForTarget(this)},n(e,[{key:"name",get:function(){if(this._name)return this._name;var t=Bt(this),e=t.lastIndexOf(".");return e>=0&&(t=t.slice(e+1)),this.node?this.node.name+"<"+t+">":t},set:function(t){this._name=t}},{key:"uuid",get:function(){return this._id}},{key:"__scriptAsset",get:function(){return null}},{key:"enabled",get:function(){return this._enabled},set:function(t){if(this._enabled!==t&&(this._enabled=t,this.node.activeInHierarchy)){var e=v.director._compScheduler;t?e.enableComp(this):e.disableComp(this)}}},{key:"enabledInHierarchy",get:function(){return this._enabled&&this.node&&this.node.activeInHierarchy}},{key:"_isOnLoadCalled",get:function(){return this._objFlags&np}},{key:"internalUpdate",get:function(){return this.update}},{key:"internalLateUpdate",get:function(){return this.lateUpdate}},{key:"internalPreload",get:function(){return this.__preload}},{key:"internalOnLoad",get:function(){return this.onLoad}},{key:"internalStart",get:function(){return this.start}},{key:"internalOnEnable",get:function(){return this.onEnable}},{key:"internalOnDisable",get:function(){return this.onDisable}},{key:"internalOnDestroy",get:function(){return this.onDestroy}}]),e}(Ho)).EventHandler=ep,Qf._executionOrder=0,Qf._requireComponent=null,Qf.system=null,p((qf=Qf).prototype,"__scriptAsset",[jf],Object.getOwnPropertyDescriptor(qf.prototype,"__scriptAsset"),qf.prototype),Yf=ks(qf.prototype,"node",[io],(function(){return null})),Kf=ks(qf.prototype,"_enabled",[io],(function(){return!0})),Jf=ks(qf.prototype,"__prefab",[io],(function(){return null})),Xf=qf))||Xf));Ct(rp,"_registerEditorProps",(function(t,e){var i=e.requireComponent;i&&(Array.isArray(i)&&(i=i.filter(Boolean)),t._requireComponent=i);var n=e.executionOrder;n&&"number"==typeof n&&(t._executionOrder=n)})),v.Component=rp;var sp=t("d$",qs("cc.MissingScript")(($f=function(t){function e(){var e;return(e=t.call(this)||this)._$erialized=tp&&tp(),e}return s(e,t),e.safeFindClass=function(t){var e=te(t);if(e)return e;v.deserialize.reportMissingClass(t)},e.prototype.onLoad=function(){Y(4600,this.node.name)},e}(rp),tp=ks($f.prototype,"_$erialized",[io,ro],(function(){return null})),Zf=$f))||Zf);v._MissingScript=sp;try{var op=sp.__values__;0!==op.length&&"_$erialized"===op[op.length-1]||(V("The '_$erialized' prop in MissingScript is missing. Please contact jare."),V(" Error props: ['"+op+"']"))}catch($n){V("Error when checking MissingScript 5, "+$n)}var ap=function(){function t(t,e){this._document=void 0,this._chunks=void 0,this._document=t,this._chunks=e}return n(t,[{key:"document",get:function(){return this._document}},{key:"chunks",get:function(){return this._chunks}}]),t}();function hp(t){var e=t;return{chunks:e.chunks,document:e.document}}function up(t){if(t.length<16)throw new lp(tt(13102));var e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(1313817411!==e.getUint32(0,!0))throw new lp(tt(13100));var i=e.getUint32(4,!0);if(1!==i)throw new lp(tt(13101,i));if(e.getUint32(8,!0)!==e.byteLength)throw new lp(tt(13102));var n=12,r=e.getUint32(n,!0);n+=4;var s=new Uint8Array(e.buffer,n+e.byteOffset,r);n+=r;var o,a=function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);if("Buffer"in globalThis)return globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString();throw new Error(tt(13104))}(s);try{o=JSON.parse(a)}catch(t){throw new lp(t)}for(var h=[];n<e.byteLength;){n%8!=0&&(n+=8-n%8);var u=e.getUint32(n,!0);n+=4,h.push(new Uint8Array(e.buffer,n+e.byteOffset,u)),n+=u}if(n!==e.byteLength)throw new lp(tt(13102));return new ap(o,h)}var lp=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(l(Error));function cp(t,e,i,n,r){if(e instanceof v.ValueType){r||t.push("if(prop){");var s=Bt(e);t.push("s._deserializeFastDefinedObject(o"+i+",prop,"+s+");"),r||t.push("}else o"+i+"=null;")}else t.push("\nif (prop) {\n s._deserializeAndAssignField(o, prop, "+n+");\n} else {\n o"+i+"=null;\n}\n")}!function(){function t(){this._viewOrPaddings=[],this._length=0}var e=t.prototype;e.alignAs=function(t){if(0!==t){var e=this._length%t;if(0!==e){var i=t-e;return this._viewOrPaddings.push(i),this._length+=i,i}}return 0},e.append=function(t){var e=this._length;return this._viewOrPaddings.push(t),this._length+=t.byteLength,e},e.get=function(){var t=new Uint8Array(this._length),e=0;return this._viewOrPaddings.forEach((function(i){"number"==typeof i?e+=i:(t.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),e),e+=i.byteLength)})),t},n(t,[{key:"byteLength",get:function(){return this._length}}])}(),v.internal.parseCCONJson=hp,v.internal.decodeCCONBinary=up,v.internal.CCON=ap;var _p=pi.Attr.DELIMETER,dp=_p+"type",fp=_p+"default",pp=_p+"formerlySerializedAs";function mp(t,e){if(void 0===t)return e instanceof pi.Attr.PrimitiveType||e===li||e===ci;var i=typeof t;return"string"===i||"number"===i||"boolean"===i}var gp=function(t){function e(){return t.call(this,(function(t){t.clear()}),1)||this}return s(e,t),e}(re);gp.prototype.get=function(t,e,i,n,r){var s=this._get();return s?(s.reset(t,e,i,n,r),s):new yp(t,e,i,n,r)};var yp=function(){function t(t,e,i,n){this.deserializedList=void 0,this.deserializedData=void 0,this._ignoreEditorOnly=void 0,this.result=t,this.customEnv=n,this.deserializedList=[],this.deserializedData=null,this._classFinder=e,this._reportMissingClass=i,this._onDereferenced=null==e?void 0:e.onDereferenced}var e=t.prototype;return e.reset=function(t,e,i,n){this.result=t,this.customEnv=n,this._classFinder=e,this._reportMissingClass=i,this._onDereferenced=null==e?void 0:e.onDereferenced},e.clear=function(){this.result=null,this.customEnv=null,this.deserializedList.length=0,this.deserializedData=null,this._classFinder=null,this._reportMissingClass=null,this._onDereferenced=null},e.deserialize=function(t){var e,i=!1;t instanceof ap?(i=!0,e=t.document,t.chunks.length>0&&(t.chunks.length,this._mainBinChunk=t.chunks[0])):e=t,this._serializedData=e,this._context={fromCCON:i};var n=Array.isArray(e)?e[0]:e;return this.deserializedData=this._deserializeObject(n,0),this._serializedData=void 0,this._mainBinChunk=void 0,this._context=void 0,this.deserializedData},e._deserializeObject=function(t,e,i,n){switch(t.__type__){case"TypedArray":return this._deserializeTypedArrayView(t);case"TypedArrayRef":return this._deserializeTypedArrayViewRef(t);default:return t.__type__?this._deserializeTypeTaggedObject(t,e,i,n):Array.isArray(t)?this._deserializeArray(t):this._deserializePlainObject(t)}},e._deserializeTypedArrayView=function(t){return globalThis[t.ctor].from(t.array)},e._deserializeTypedArrayViewRef=function(t){var e=t.offset,i=t.length,n=t.ctor;return new globalThis[n](this._mainBinChunk.buffer,this._mainBinChunk.byteOffset+e,i)},e._deserializeArray=function(t){for(var e,i=new Array(t.length),n=0;n<t.length;n++)"object"==typeof(e=t[n])&&e?this._deserializeAndAssignField(i,e,""+n)&&(i[n]=null):i[n]=e;return i},e._deserializePlainObject=function(t){var e={};return this._fillPlainObject(e,t),e},e._deserializeTypeTaggedObject=function(t,e,i,n){var r=this,s=t.__type__,o=this._classFinder(s,t,i,n);if(!o)return this._classFinder===te&&this._reportMissingClass(s),null;var a=function(t){var i=new t;return e>=0&&(r.deserializedList[e]=i),i}(o);return this._deserializeInto(t,a,o),a},e._deserializeInto=function(t,e,i,n){void 0===n&&(n=!1),n||!e[Qo]?e._deserialize?e._deserialize(t.content,this):v.Class._isCCClass(i)?this._deserializeFireClass(e,t,i):this._deserializeFastDefinedObject(e,t,i):this._runCustomizedDeserialize(t,e,i)},e._runCustomizedDeserialize=function(t,e,i){var n=this,r={readProperty:function(e){var i=t[e];return"object"==typeof i&&i?n._deserializeObjectField(i):i},readThis:function(){n._deserializeInto(t,e,i,!0)},readSuper:function(){var r=zt(i);r&&n._deserializeInto(t,e,r)}};e[Qo](r,this._context)},e._deserializeFireClass=function(t,e,i){var n;if(i.hasOwnProperty("__deserialize__"))n=i.__deserialize__;else{n=function(t,e){for(var i=pi.Attr.getClassAttrs(e),n=e.__values__,r=["var prop;"],s=function(t){return we.test(ne(t))}(e),o=0;o<n.length;o++){var a=n[o],h=void 0,u=void 0;pi.IDENTIFIER_RE.test(a)?(u='"'+a+'"',h="."+a):h="["+(u=pi.escapeForJS(a))+"]";var l=h;if(i[a+pp]){var c=i[a+pp];l=pi.IDENTIFIER_RE.test(c)?"."+c:"["+pi.escapeForJS(c)+"]"}r.push("prop=d"+l+";"),r.push('if(typeof prop!=="undefined"){');var _=pi.getDefault(i[a+fp]),d=i[a+dp];s&&(void 0!==_||d)?mp(_,d)?r.push("o"+h+"=prop;"):cp(r,_,h,u,!0):(r.push('if(typeof prop!=="object"){o'+h+"=prop;}else{"),cp(r,_,h,u,!1),r.push("}")),r.push("}")}return(Ht(e,v.Node)||Ht(e,v.Component))&&r.push("d._id&&(o._id=d._id);"),"_$erialized"===n[n.length-1]&&(r.push("o._$erialized=JSON.parse(JSON.stringify(d));"),r.push("s._fillPlainObject(o._$erialized,d);")),Function("s","o","d","k",r.join(""))}(0,i);try{if(i===sp){var r=i.__values__;0!==r.length&&"_$erialized"===r[r.length-1]||(V("The '_$erialized' prop of MissingScript is missing. Will force the raw data to be save."),V(" Error props: ['"+r+"']. Please contact jare."));var s=n;n=function(t,e,i,n){s(t,e,i,n),e._$erialized||V("Unable to stash previously serialized data. "+JSON.stringify(i))}}}catch(t){V("Error when checking MissingScript 6, "+t)}Ct(i,"__deserialize__",n,!0)}n(this,t,e,i)},e._deserializeAndAssignField=function(t,e,i){var n=e.__id__;if("number"==typeof n){var r=this.deserializedList[n];if(r)t[i]=r;else{var s,o=this._serializedData[n];t[i]=this._deserializeObject(o,n,void 0,i),null===(s=this._onDereferenced)||void 0===s||s.call(this,this.deserializedList,n,t,i)}}else{var a=e.__uuid__;if(a){var h=e.__expectedType__;this.result.push(t,i,a,h)}else t[i]=this._deserializeObject(e,-1)}return!1},e._deserializeObjectField=function(t){var e=t.__id__;if("number"==typeof e){var i=this.deserializedList[e];if(i)return i;var n=this._serializedData[e];return this._deserializeObject(n,e,void 0,void 0)}if(t.__uuid__)throw t.__expectedType__,new Error("Asset reference field serialization is currently not supported in custom serialization.");return this._deserializeObject(t,-1)},e._fillPlainObject=function(t,e){for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];"object"!=typeof n?"__type__"!==i&&(t[i]=n):n?this._deserializeAndAssignField(t,n,i)&&(t[i]=null):t[i]=null}},e._deserializeFastDefinedObject=function(t,e,i){if(i===v.Vec2)return t.x=e.x||0,void(t.y=e.y||0);if(i===v.Vec3)return t.x=e.x||0,t.y=e.y||0,void(t.z=e.z||0);if(i!==v.Color){if(i===v.Size)return t.width=e.width||0,void(t.height=e.height||0);for(var n=pi.Attr.getClassAttrs(i),r=i.__values__,s=0;s<r.length;s++){var o=r[s],a=e[o];void 0!==a||e.hasOwnProperty(o)||(a=pi.getDefault(n[o+fp])),"object"!=typeof a?t[o]=a:a?this._deserializeAndAssignField(t,a,o):t[o]=null}}else{t.r=e.r||0,t.g=e.g||0,t.b=e.b||0;var h=e.a;t.a=void 0===h?255:h}},n(t,[{key:"ignoreEditorOnly",get:function(){return this._ignoreEditorOnly}}]),t}();yp.pool=new gp;var vp=[Ln,on,tn,Sn,dn,Vn,Un,In];function Sp(t,e){t.x=e[1],t.y=e[2],t.z=e[3],t.w=e[4]}var Tp=[function(t,e){t.x=e[1],t.y=e[2]},function(t,e){t.x=e[1],t.y=e[2],t.z=e[3]},Sp,Sp,function(t,e){t._val=e[1]},function(t,e){t.width=e[1],t.height=e[2]},function(t,e){t.x=e[1],t.y=e[2],t.width=e[3],t.height=e[4]},function(t,e){In.fromArray(t,e,1)}],Ap=t("e6",function(){function t(){this.uuidObjList=null,this.uuidPropList=null,this.uuidList=null,this.uuidTypeList=[]}var e=t.prototype;return e.init=function(t){t?(this.uuidObjList=t[8],this.uuidPropList=t[9],this.uuidList=t[10]):this.uuidList||(this.uuidList=[],this.uuidObjList=[],this.uuidPropList=[],this.uuidTypeList=[])},e.reset=function(){this.uuidList&&(this.uuidList.length=0,this.uuidObjList.length=0,this.uuidPropList.length=0,this.uuidTypeList.length=0)},e.push=function(t,e,i,n){this.uuidObjList.push(t),this.uuidPropList.push(e),this.uuidList.push(i),this.uuidTypeList.push(n||"")},t}());function bp(t,e){for(var i=t[4][e[0]],n=i[0],r=new(0,n[0]),s=n[1],o=n[2],a=i[i.length-1],h=1;h<a;++h)r[s[i[h]]]=e[h];for(;h<e.length;++h){var u=s[i[h]],l=n[i[h]+o];(0,Ip[l])(t,r,u,e[h])}return r}function Ep(t,e,i){var n=new e;return n._deserialize?n._deserialize(i,t[0]):J(5303,Bt(e)),n}function Cp(t,e,i,n){n>=0?e[i]=t[5][n]:t[7][3*~n]=e}function wp(t){return function(e,i,n,r){for(var s=0;s<r.length;++s)t(e,r,s,r[s]);i[n]=r}}function xp(t,e,i,n){e[i]=null,t[8][n]=e}function Rp(t,e,i,n){e[i]=bp(t,n)}Ap.pool=new re((function(t){t.reset()}),5),Ap.pool.get=function(){return this._get()||new Ap};var Ip=new Array(13);function Bp(t,e,i){return t||i(e),Object}function Dp(t,e,i,n,r,s,o){var a=t(e);if(!a){if(r)return void(i[n]=function(e,i,n){return function(){var r=t(n)||Bp(s,n,o);return e[i]=r,new r}}(i,n,e));a=Bp(s,e,o)}i[n]=a}function Pp(t,e,i,n){for(var r=i||te,s=t[3],o=0;o<s.length;++o){var a=s[o];"string"!=typeof a?Dp(r,a[0],a,0,e,i,n):Dp(r,a,s,o,e,i,n)}}function Op(t){var e=t[4];if(e)for(var i=t[3],n=0;n<e.length;++n){var r=e[n];r[0]=i[r[0]]}}function Mp(t,e,i){"string"==typeof t&&(t=JSON.parse(t));var n,r=!1;if(e||(e=Ap.pool.get(),r=!0),function(t){if(Array.isArray(t)){var e=t[0];return"number"==typeof e||e instanceof Lp}return!1}(t)){!function(t,e,i){var n;e.init(t),null!==(n=i)&&void 0!==n||(i={});var r=t[0],s=!1;if("object"==typeof r&&(s=r.preprocessed,r=r.version),r<1)throw new Error(tt(5304,r));var o,a=i;a._version=r,a.result=e,t[0]=a,s||(Pp(t,!1,i.classFinder,null!==(o=i.reportMissingClass)&&void 0!==o?o:Mp.reportMissingClass),Op(t))}(t,e,i);var s=t;v.game._isCloning=!0;var o=s[5],a=function(t){var e=t[5],i=t[6],n=0===i?0:i.length,r=e[e.length-1],s=e.length-n;"number"!=typeof r?r=0:(r<0&&(r=~r),--s);for(var o=0;o<s;++o)e[o]=bp(t,e[o]);for(var a=t[3],h=0;h<n;++h,++o){var u=i[h],l=e[o];if(u>=0){var c=a[u];e[o]=Ep(t,c,l)}else(0,Ip[u=~u])(t,e,o,l)}return r}(s);v.game._isCloning=!1,s[7]&&function(t,e,i){for(var n=t.length-1,r=0,s=3*t[n];r<s;r+=3){var o=t[r],a=e[t[r+2]],h=t[r+1];h>=0?o[i[h]]=a:o[~h]=a}for(;r<n;r+=3){var u=e[t[r]],l=e[t[r+2]],c=t[r+1];c>=0?u[i[c]]=l:u[~c]=l}}(s[7],o,s[2]),function(t){for(var e=t[5],i=t[2],n=t[1],r=t[8],s=t[9],o=t[10],a=0;a<r.length;++a){var h=r[a];"number"==typeof h&&(r[a]=e[h]);var u=s[a];"number"==typeof u&&(u=u>=0?i[u]:~u,s[a]=u);var l=o[a];"number"==typeof l&&(o[a]=n[l])}}(s),n=o[a]}else n=function(t,e,i){var n,r=(i=i||{}).classFinder||te,s=i.createAssetRefs||xl.platform===tl.EDITOR_CORE,o=i.customEnv,a=i.ignoreEditorOnly,h=null!==(n=i.reportMissingClass)&&void 0!==n?n:v.deserialize.reportMissingClass;e.init();var u=yp.pool.get(e,r,h,o,a);v.game._isCloning=!0;var l=u.deserialize(t);return v.game._isCloning=!1,yp.pool.put(u),s&&e.assignAssetsBy((function(t,e){return EditorExtends.serialize.asAsset(t,e.type)})),l}(t,e,i);return r&&Ap.pool.put(e),n}Ip[0]=function(t,e,i,n){e[i]=n},Ip[1]=Cp,Ip[2]=wp(Cp),Ip[3]=wp(xp),Ip[4]=Rp,Ip[5]=function(t,e,i,n){var r=n[0],s=e[i];(0,Tp[r])(s,n)},Ip[6]=xp,Ip[7]=function(t,e,i,n){e[i].set(n)},Ip[8]=function(t,e,i,n){var r=n[0],s=new vp[r];(0,Tp[r])(s,n),e[i]=s},Ip[9]=wp(Rp),Ip[10]=function(t,e,i,n){var r=t[3][n[0]];e[i]=Ep(t,r,n[1])},Ip[11]=function(t,e,i,n){var r=n[0];e[i]=r;for(var s=1;s<n.length;s+=3){var o=n[s],a=n[s+1],h=n[s+2];(0,Ip[a])(t,r,o,h)}},Ip[12]=function(t,e,i,n){for(var r=n[0],s=0;s<r.length;++s){var o=r[s],a=n[s+1];0!==a&&(0,Ip[a])(t,r,s,o)}e[i]=r},Mp.Details=Ap,Mp.reportMissingClass=function(t){J(5302,t)};var Lp=function(t){this.preprocessed=!0,this.version=t};function Np(t,e,i){return[1,0,0,[t],0,i?[e,-1]:[e],[0],0,[],[],[]]}v.deserialize=Mp;var Fp=new WeakMap,kp=new WeakSet,Vp=new WeakSet;function Gp(t,e){var i;i=sp.safeFindClass;var n,r=Ap.pool.get();try{n=Mp(t,r,{classFinder:i,customEnv:e})}catch(t){throw V(t),Ap.pool.put(r),t}n._uuid=e.__uuid__||"";for(var s=r.uuidList,o=r.uuidObjList,a=r.uuidPropList,h=r.uuidTypeList||[],u=[],l=0;l<s.length;l++){var c=s[l];u[l]={uuid:Xd(c),owner:o[l],prop:a[l],type:te(h[l])}}return Fp.set(n,u),n._native&&kp.add(n),Ap.pool.put(r),n}var Up=function(){function t(){this._depends=new Rd}var e=t.prototype;return e.init=function(){this._depends.clear()},e.getNativeDep=function(t){var e=this._depends.get(t);return e&&e.nativeDep?r({},e.nativeDep):null},e.getDeps=function(t){return this._depends.has(t)?this._depends.get(t).deps:[]},e.getDepsRecursively=function(t){var e=Object.create(null),i=[];return this._descend(t,e,i),i},e.remove=function(t){this._depends.remove(t)},e.parse=function(t,e){var i,n,r=null;if(Array.isArray(e)||e.__type__||e instanceof ap){if(this._depends.has(t))return this._depends.get(t);if(!Array.isArray(e)||"number"==typeof(n=(i=e[5])[i.length-1])&&n<0)try{var s=Gp(e,{__uuid__:t});(r=this._parseDepsFromAsset(s)).nativeDep&&(r.nativeDep.uuid=t),Od.add(t+"@import",s)}catch(e){Pd.remove(t+"@import"),r={deps:[]}}else r={deps:this._parseDepsFromJson(e)}}else{if(this._depends.has(t)&&(r=this._depends.get(t)).parsedFromExistAsset)return r;r=this._parseDepsFromAsset(e)}return this._depends.add(t,r),r},e._parseDepsFromAsset=function(t){for(var e={deps:[],parsedFromExistAsset:!0},i=Fp.get(t),n=0,r=i.length;n<r;n++)e.deps.push(i[n].uuid);return kp.has(t)&&(e.nativeDep=t._nativeDep),e},e._parseDepsFromJson=function(t){var e=function(t){return i=(e=t)[1],e[10].map((function(t){return i[t]}));var e,i}(t);return e.forEach((function(t,i){return e[i]=Xd(t)})),e},e._descend=function(t,e,i){for(var n=this.getDeps(t),r=0;r<n.length;r++){var s=n[r];e[s]||(e[s]=!0,i.push(s),this._descend(s,e,i))}},n(t,null,[{key:"instance",get:function(){return this._instance||(this._instance=new t),this._instance}}]),t}();Up._instance=void 0;var zp,Hp=Up.instance,Wp=[new Gc];function jp(t){return t&&0==(t&t-1)}var Xp,qp,Yp,Kp,Jp,Qp=qs("cc.SimpleTexture")(zp=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gfxTexture=null,e._gfxTextureView=null,e._mipmapLevel=1,e._textureWidth=0,e._textureHeight=0,e._baseLevel=0,e._maxLevel=1e3,e}s(e,t);var i=e.prototype;return i.getGFXTexture=function(){return this._gfxTextureView},i.destroy=function(){return this._tryDestroyTextureView(),this._tryDestroyTexture(),t.prototype.destroy.call(this)},i.updateImage=function(){this.updateMipmaps(0)},i.updateMipmaps=function(){},i.uploadData=function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this._gfxTexture&&!(this._mipmapLevel<=e)){var n=this._getGFXDevice();if(n){var r=Wp[0];r.texExtent.width=this._textureWidth>>e,r.texExtent.height=this._textureHeight>>e,r.texSubres.mipLevel=e,r.texSubres.baseArrayLayer=i,ArrayBuffer.isView(t)?n.copyBuffersToTexture([t],this._gfxTexture,Wp):n.copyTexImagesToTexture([t],this._gfxTexture,Wp)}}},i._assignImage=function(t,e,i){var n=t.data;if(n&&(this.uploadData(n,e,i),this._checkTextureLoaded(),Ce.CLEANUP_IMAGE_CACHE)){var r=Hp.getDeps(this._uuid),s=r.indexOf(t._uuid);-1!==s&&(ae(r,s),t.decRef())}},i._checkTextureLoaded=function(){this._textureReady()},i._textureReady=function(){this.loaded=!0,this.emit("load")},i._setMipmapLevel=function(t){this._mipmapLevel=t<1?1:t},i._setMipRange=function(t,e){this._baseLevel=t<1?0:t,this._maxLevel=e<1?0:e},i.setMipRange=function(t,e){$(t<=e,3124),this._setMipRange(t,e);var i=this._getGFXDevice();if(i){var n=this._createTextureView(i);this._tryDestroyTextureView(),this._gfxTextureView=n}},i._getGfxTextureCreateInfo=function(){return null},i._getGfxTextureViewCreateInfo=function(){return null},i._tryReset=function(){if(this._tryDestroyTextureView(),this._tryDestroyTexture(),0!==this._mipmapLevel){var t=this._getGFXDevice();t&&(this._createTexture(t),this._gfxTextureView=this._createTextureView(t))}},i.isUsingOfflineMipmaps=function(){return!1},i._createTexture=function(t){if(0!==this._width&&0!==this._height){var e=Zl.NONE;this._mipFilter!==uf.NONE&&function(t,e,i){return!(t.gfxAPI===Gl.WEBGL)||jp(e)&&jp(i)}(t,this._width,this._height)&&(this._mipmapLevel=function(t,e){for(var i=Math.max(t,e),n=0;i;)i>>=1,n++;return n}(this._width,this._height),this.isUsingOfflineMipmaps()||this.isCompressed||(e=Zl.GEN_MIPMAP));var i=this._getGfxTextureCreateInfo({usage:Ql.SAMPLED|Ql.TRANSFER_DST|Ql.COLOR_ATTACHMENT,format:this._getGFXFormat(),levelCount:this._mipmapLevel,flags:e});if(i){var n=t.createTexture(i);this._textureWidth=i.width,this._textureHeight=i.height,this._gfxTexture=n}}},i._createTextureView=function(t){if(!this._gfxTexture)return null;var e=this._maxLevel<this._mipmapLevel?this._maxLevel:this._mipmapLevel-1,i=this._getGfxTextureViewCreateInfo({texture:this._gfxTexture,format:this._getGFXFormat(),baseLevel:this._baseLevel,levelCount:e-this._baseLevel+1});return i?t.createTexture(i):null},i._tryDestroyTexture=function(){this._gfxTexture&&(this._gfxTexture.destroy(),this._gfxTexture=null)},i._tryDestroyTextureView=function(){this._gfxTextureView&&(this._gfxTextureView.destroy(),this._gfxTextureView=null)},n(e,[{key:"mipmapLevel",get:function(){return this._mipmapLevel}}]),e}(Of))||zp;v.SimpleTexture=Qp;var Zp=t("ef",(Xp=qs("cc.Texture2D"),qp=xo([Rf]),Xp((Kp=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._mipmaps=Jp&&Jp(),e._generatedMipmaps=[],e}s(e,t);var i=e.prototype;return i._setMipmapParams=function(t){var e=this;if(this._generatedMipmaps=t,this._setMipmapLevel(this._generatedMipmaps.length),this._generatedMipmaps.length>0){var i=this._generatedMipmaps[0];this.reset({width:i.width,height:i.height,format:i.format,mipmapLevel:this._generatedMipmaps.length,baseLevel:this._baseLevel,maxLevel:this._maxLevel}),this._generatedMipmaps.forEach((function(t,i){e._assignImage(t,i)}))}else this.reset({width:0,height:0,mipmapLevel:this._generatedMipmaps.length,baseLevel:this._baseLevel,maxLevel:this._maxLevel})},i.initialize=function(){this.mipmaps=this._mipmaps},i.onLoaded=function(){this.initialize()},i.reset=function(t){this._width=t.width,this._height=t.height,this._setGFXFormat(t.format);var e=void 0===t.mipmapLevel?1:t.mipmapLevel;this._setMipmapLevel(e);var i=void 0===t.baseLevel?0:t.baseLevel,n=void 0===t.maxLevel?1e3:t.maxLevel;this._setMipRange(i,n),this._tryReset()},i.create=function(t,e,i,n,r,s){void 0===i&&(i=af.RGBA8888),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=1e3),this.reset({width:t,height:e,format:i,mipmapLevel:n,baseLevel:r,maxLevel:s})},i.toString=function(){return 0!==this._mipmaps.length?this._mipmaps[0].url:""},i.updateMipmaps=function(t,e){if(void 0===t&&(t=0),!(t>=this._generatedMipmaps.length))for(var i=Math.min(void 0===e?this._generatedMipmaps.length:e,this._generatedMipmaps.length-t),n=0;n<i;++n){var r=t+n;this._assignImage(this._generatedMipmaps[r],r)}},i.getHtmlElementObj=function(){return this._mipmaps[0]&&this._mipmaps[0].data instanceof HTMLElement?this._mipmaps[0].data:null},i.destroy=function(){return this._mipmaps=[],this._generatedMipmaps=[],t.prototype.destroy.call(this)},i.description=function(){return"<cc.Texture2D | Name = "+(this._mipmaps[0]?this._mipmaps[0].url:"")+" | Dimension = "+this.width+" x "+this.height+">"},i.releaseTexture=function(){this.destroy()},i._serialize=function(){return null},i._deserialize=function(e,i){var n=e;t.prototype._deserialize.call(this,n.base,i),this._mipmaps=new Array(n.mipmaps.length);for(var r=0;r<n.mipmaps.length;++r)if(this._mipmaps[r]=new Rf,n.mipmaps[r]){var s=n.mipmaps[r];i.result.push(this._mipmaps,""+r,s,ne(Rf))}},i._getGfxTextureCreateInfo=function(t){var e=new Qc(Jl.TEX2D);return e.width=this._width,e.height=this._height,Object.assign(e,t),e},i._getGfxTextureViewCreateInfo=function(t){var e=new Zc;return e.type=Jl.TEX2D,Object.assign(e,t),e},i.initDefault=function(e){t.prototype.initDefault.call(this,e);var i=new Rf;i.initDefault(),this.image=i},i.validate=function(){return this.mipmaps&&0!==this.mipmaps.length},n(e,[{key:"mipmaps",get:function(){return this._mipmaps},set:function(t){this._mipmaps=t;var e=[];if(1===t.length){var i=t[0];e.push.apply(e,i.extractMipmaps())}else if(t.length>1)for(var n=0;n<t.length;++n){var r=t[n];e.push(r.extractMipmap0())}this._setMipmapParams(e)}},{key:"image",get:function(){return 0===this._mipmaps.length?null:this._mipmaps[0]},set:function(t){this.mipmaps=t?[t]:[]}}]),e}(Qp),Jp=ks(Kp.prototype,"_mipmaps",[qp],(function(){return[]})),Yp=Kp))||Yp));v.Texture2D=Zp;var $p=function(){function t(t,e){this._texture=void 0,this._width=void 0,this._height=void 0,this._x=void 0,this._y=void 0,this._nexty=void 0,this._innerTextureInfos={},this._innerSpriteFrames=void 0,this._count=void 0;var i=new tm;i.initWithSize(t,e),this._texture=i,this._width=t,this._height=e,this._x=2,this._y=2,this._nexty=2,this._innerTextureInfos={},this._innerSpriteFrames=[],this._count=0}var e=t.prototype;return e.insertSpriteFrame=function(t){var e=t.rect,i=t.texture,n=this._innerTextureInfos[i.getId()],r=e.x,s=e.y;if(n)r+=n.x,s+=n.y;else{var o=i.width,a=i.height;if(this._x+o+2>this._width&&(this._x=2,this._y=this._nexty),this._y+a+2>this._nexty&&(this._nexty=this._y+a+2),this._nexty>this._height)return null;v.internal.dynamicAtlasManager.textureBleeding&&((o<=8||a<=8)&&(this._texture.drawTextureAt(i.image,this._x-1,this._y-1),this._texture.drawTextureAt(i.image,this._x-1,this._y+1),this._texture.drawTextureAt(i.image,this._x+1,this._y-1),this._texture.drawTextureAt(i.image,this._x+1,this._y+1)),this._texture.drawTextureAt(i.image,this._x-1,this._y),this._texture.drawTextureAt(i.image,this._x+1,this._y),this._texture.drawTextureAt(i.image,this._x,this._y-1),this._texture.drawTextureAt(i.image,this._x,this._y+1)),this._texture.drawTextureAt(i.image,this._x,this._y),this._innerTextureInfos[i.getId()]={x:this._x,y:this._y,texture:i},this._count++,r+=this._x,s+=this._y,this._x+=o+2}var h={x:r,y:s,texture:this._texture};return this._innerSpriteFrames.push(t),h},e.deleteInnerTexture=function(t){t&&this._innerTextureInfos[t.getId()]&&(delete this._innerTextureInfos[t.getId()],this._count--)},e.isEmpty=function(){return this._count<=0},e.reset=function(){this._x=2,this._y=2,this._nexty=2;for(var t=this._innerSpriteFrames,e=0,i=t.length;e<i;e++){var n=t[e];n.isValid&&n._resetDynamicAtlasFrame()}this._innerSpriteFrames.length=0,this._innerTextureInfos={}},e.destroy=function(){this.reset(),this._texture.destroy()},t}(),tm=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=af.RGBA8888),this.reset({width:t,height:e,format:i})},i.drawTextureAt=function(t,e,i){var n=this.getGFXTexture();if(t&&n){var r=this._getGFXDevice();if(r){var s=new Gc;s.texOffset.x=e,s.texOffset.y=i,s.texExtent.width=t.width,s.texExtent.height=t.height,r.copyTexImagesToTexture([t.data],n,[s])}else console.warn("Unable to get device")}},e}(Zp),em={NONE:0,IGNORE_RAYCAST:1<<20,GIZMOS:1<<21,EDITOR:1<<22,UI_3D:1<<23,SCENE_GIZMO:1<<24,UI_2D:1<<25,PROFILER:1<<28,DEFAULT:1<<30,ALL:4294967295},im=t("dB",function(){function t(){}return t.init=function(){var e=Ee.querySettings(be.Category.ENGINE,"customLayers");if(e)for(var i=0;i<e.length;i++){var n=e[i];t.addLayer(n.name,n.bit)}},t.makeMaskInclude=function(t){for(var e,i=0,n=d(t);!(e=n()).done;)i|=e.value;return i},t.makeMaskExclude=function(e){return~t.makeMaskInclude(e)},t.addLayer=function(e,i){if(void 0!==i)if(i>19||i<0)console.warn("maximum layers reached.");else{var n=1<<i;t.Enum[e],tt(2104,e),t.Enum[e]=n,Ct(t.Enum,String(n),e),t.BitMask[e]=n,Ct(t.BitMask,String(n),e),pe.update(t.BitMask),ge.update(t.Enum)}else console.warn("bitNum can't be undefined")},t.deleteLayer=function(e){if(e>19||e<0)console.warn("do not change buildin layers.");else{var i=1<<e;delete t.Enum[t.Enum[i]],delete t.Enum[i],delete t.BitMask[t.BitMask[i]],delete t.BitMask[i],pe.update(t.BitMask),ge.update(t.Enum)}},t.nameToLayer=function(e){return void 0===e?(console.warn("name can't be undefined"),-1):A(t.Enum[e])},t.layerToName=function(e){return e>31||e<0?(console.warn("Unable to access unknown layer."),""):t.Enum[1<<e]},t}());im.Enum=ge(em),im.BitMask=pe(r({},em)),v.Layers=im;var nm,rm,sm=function(){var t=e.prototype;function e(t){this._uiComp=null,this._opacity=1,this._localOpacity=1,this.colorDirty=!0,this._uiTransformComp=null,this._node=void 0,this._node=t}return t.setOpacity=function(t){this._opacity=t},t.applyOpacity=function(t){this._opacity=this._localOpacity*t},e.markOpacityTree=function(){},n(e,[{key:"uiTransformComp",get:function(){return this._uiTransformComp||(this._uiTransformComp=this._node.getComponent("cc.UITransform")),this._uiTransformComp},set:function(t){this._uiTransformComp=t}},{key:"uiComp",get:function(){return this._uiComp},set:function(t){this._uiComp&&t?Y(12002):this._uiComp=t}},{key:"opacity",get:function(){return this._opacity}},{key:"localOpacity",get:function(){return this._localOpacity},set:function(t){this._localOpacity=t,this.colorDirty=!0}}]),e}();Ho.Flags.Destroying,v.GAME_VIEW,t("dH",nm),function(t){t[t.LOCAL=0]="LOCAL",t[t.WORLD=1]="WORLD"}(nm||t("dH",nm={})),t("dI",rm),function(t){t[t.NONE=0]="NONE",t[t.POSITION=1]="POSITION",t[t.ROTATION=2]="ROTATION",t[t.SCALE=4]="SCALE",t[t.RS=t.ROTATION|t.SCALE]="RS",t[t.TRS=t.POSITION|t.ROTATION|t.SCALE]="TRS",t[t.TRS_MASK=~t.TRS]="TRS_MASK"}(rm||t("dI",rm={})),v.internal.TransformBit=rm;var om,am,hm,um,lm,cm,_m,dm,fm,pm,mm,gm,ym,vm,Sm,Tm,Am,bm,Em=t("dJ",ge({Static:0,Stationary:1,Movable:2}));t("dK",om),function(t){t.TOUCH_START="touch-start",t.TOUCH_MOVE="touch-move",t.TOUCH_END="touch-end",t.TOUCH_CANCEL="touch-cancel",t.MOUSE_DOWN="mouse-down",t.MOUSE_MOVE="mouse-move",t.MOUSE_UP="mouse-up",t.MOUSE_WHEEL="mouse-wheel",t.MOUSE_ENTER="mouse-enter",t.MOUSE_LEAVE="mouse-leave",t.KEY_DOWN="keydown",t.KEY_UP="keyup",t.DEVICEMOTION="devicemotion",t.TRANSFORM_CHANGED="transform-changed",t.MOBILITY_CHANGED="mobility-changed",t.SCENE_CHANGED_FOR_PERSISTS="scene-changed-for-persists",t.SIZE_CHANGED="size-changed",t.ANCHOR_CHANGED="anchor-changed",t.COLOR_CHANGED="color-changed",t.CHILD_ADDED="child-added",t.CHILD_REMOVED="child-removed",t.PARENT_CHANGED="parent-changed",t.NODE_DESTROYED="node-destroyed",t.LAYER_CHANGED="layer-changed",t.SIBLING_ORDER_CHANGED="sibling-order-changed",t.CHILDREN_ORDER_CHANGED="sibling-order-changed",t.ACTIVE_IN_HIERARCHY_CHANGED="active-in-hierarchy-changed",t.COMPONENT_ADDED="component-added",t.COMPONENT_REMOVED="component-removed",t.LIGHT_PROBE_CHANGED="light-probe-changed",t.LIGHT_PROBE_BAKING_CHANGED="light-probe-baking-changed"}(om||t("dK",om={}));var Cm=Ho.Flags.Destroying,wm=Ho.Flags.DontDestroy,xm=Ho.Flags.Deactivating,Rm=new gt("Node");function Im(t){return t?"string"==typeof t?ee(t):t:(J(3804),null)}var Bm=new on,Dm=new on,Pm=new Sn,Om=new Sn,Mm=new Sn,Lm=new mn;new mn;var Nm,Fm,km,Vm,Gm,Um,zm,Hm,Wm,jm=new In,Xm=new In,qm=[],Ym=Symbol("ReserveContentsForAllSyncablePrefab"),Km=0,Jm=t("dz",(am=qs("cc.Node"),hm=xo(on),um=xo(Em),am(((bm=function(t){s(i,t);var e=i.prototype;function i(e){var i;return(i=t.call(this,e)||this)._parent=_m&&_m(),i._children=dm&&dm(),i._active=fm&&fm(),i._components=pm&&pm(),i._prefab=mm&&mm(),i._scene=null,i._activeInHierarchy=!1,i._id=Rm.getNewId(),i._name=void 0,i._eventProcessor=new v.NodeEventProcessor(c(i)),i._eventMask=0,i._siblingIndex=0,i._originalSceneId="",i._uiProps=new sm(c(i)),i._static=!1,i._lpos=gm&&gm(),i._lrot=ym&&ym(),i._lscale=vm&&vm(),i._mobility=Sm&&Sm(),i._layer=Tm&&Tm(),i._euler=Am&&Am(),i._transformFlags=rm.TRS,i._eulerDirty=!1,i._flagChangeVersion=0,i._hasChangedFlags=0,i._name=void 0!==e?e:"New Node",i._pos=new on,i._rot=new Sn,i._scale=new on(1,1,1),i._mat=new In,i}return e._setActiveInHierarchy=function(t){this._activeInHierarchy=t},i._setScene=function(t){t._updateScene()},i._findComponent=function(t,e){var i=e,n=t._components;if(i._sealed)for(var r=0;r<n.length;++r){var s=n[r];if(s.constructor===e)return s}else for(var o=0;o<n.length;++o){var a=n[o];if(a instanceof e)return a}return null},i._findComponents=function(t,e,i){var n=e,r=t._components;if(n._sealed)for(var s=0;s<r.length;++s){var o=r[s];o.constructor===e&&i.push(o)}else for(var a=0;a<r.length;++a){var h=r[a];h instanceof e&&i.push(h)}},i._findChildComponent=function(t,e){for(var n=0;n<t.length;++n){var r=t[n],s=i._findComponent(r,e);if(s)return s;if(r._children.length>0&&(s=i._findChildComponent(r._children,e)))return s}return null},i._findChildComponents=function(t,e,n){for(var r=0;r<t.length;++r){var s=t[r];i._findComponents(s,e,n),s._children.length>0&&i._findChildComponents(s._children,e,n)}},e.getWritableComponents=function(){return this._components},e._updateScene=function(){null==this._parent?V("Node %s(%s) has not attached to a scene.",this.name,this.uuid):this._scene=this._parent._scene},e.attr=function(t){Gt(this,t)},e.getParent=function(){return this._parent},e.modifyParent=function(t){this._parent=t},e.setParent=function(t,e){if(void 0===e&&(e=!1),e&&this.updateWorldTransform(),this._parent!==t){var i=this._parent,n=t;if(this._parent=n,this._siblingIndex=0,this._onSetParent(i,e),this.emit&&this.emit(om.PARENT_CHANGED,i),i&&!(i._objFlags&Cm)){var r=i._children.indexOf(this);i._children.splice(r,1),i._updateSiblingIndex(),i.emit&&i.emit(om.CHILD_REMOVED,this)}n&&(n._children.push(this),this._siblingIndex=n._children.length-1,n.emit&&n.emit(om.CHILD_ADDED,this)),this._onHierarchyChanged(i)}},e.getChildByUuid=function(t){if(!t)return F("Invalid uuid"),null;for(var e=this._children,i=0,n=e.length;i<n;i++)if(e[i]._id===t)return e[i];return null},e.getChildByName=function(t){if(!t)return F("Invalid name"),null;for(var e=this._children,i=0,n=e.length;i<n;i++)if(e[i]._name===t)return e[i];return null},e.getChildByPath=function(t){for(var e,i=t.split("/"),n=this,r=function(){var t=i[s];if(0===t.length)return 0;var e=n.children.find((function(e){return e.name===t}));if(!e)return{v:null};n=e},s=0;s<i.length;++s)if(0!==(e=r())&&e)return e.v;return n},e.addChild=function(t){t.setParent(this)},e.insertChild=function(t,e){t.setParent(this),t.setSiblingIndex(e)},e.getSiblingIndex=function(){return this._siblingIndex},e.setSiblingIndex=function(t){if(this._parent)if(this._parent._objFlags&xm)J(3821);else{var e=this._parent._children;t=-1!==t?t:e.length-1;var i=e.indexOf(this);t!==i&&(e.splice(i,1),t<e.length?e.splice(t,0,this):e.push(this),this._parent._updateSiblingIndex(),this._onSiblingIndexChanged&&this._onSiblingIndexChanged(t),this._eventProcessor.onUpdatingSiblingIndex())}},e.walk=function(t,e){var n=1,r=null,s=null,o=0,a=i._stacks[i._stackId];a||(a=[],i._stacks.push(a)),i._stackId++,a.length=0,a[0]=this;for(var h=null,u=!1;n;)if(s=a[--n])if(!u&&t?t(s):u&&e&&e(s),a[n]=null,u){if(h===this._parent)break;if(u=!1,r)if(r[++o])a[n]=r[o],n++;else if(h&&(a[n]=h,n++,u=!0,h._parent?(o=(r=h._parent._children).indexOf(h),h=h._parent):(h=null,r=null),o<0))break}else s._children.length>0?(h=s,r=s._children,o=0,a[n]=r[o],n++):(a[n]=s,n++,u=!0);a.length=0,i._stackId--},e.removeFromParent=function(){this._parent&&this._parent.removeChild(this)},e.removeChild=function(t){this._children.indexOf(t)>-1&&(t.parent=null)},e.removeAllChildren=function(){for(var t=this._children,e=t.length-1;e>=0;e--){var i=t[e];i&&(i.parent=null)}this._children.length=0},e.isChildOf=function(t){var e=this;do{if(e===t)return!0;e=e._parent}while(e);return!1},e.getComponent=function(t){var e=Im(t);return e?i._findComponent(this,e):null},e.getComponents=function(t){var e=Im(t),n=[];return e&&i._findComponents(this,e,n),n},e.getComponentInChildren=function(t){var e=Im(t);return e?i._findChildComponent(this._children,e):null},e.getComponentsInChildren=function(t){var e=Im(t),n=[];return e&&(i._findComponents(this,e,n),i._findChildComponents(this._children,e,n)),n},e.addComponent=function(t){var e;if("string"==typeof t){if(!(e=ee(t)))throw v._RF.peek()&&J(3808,t),TypeError(tt(3807,t))}else{if(!t)throw TypeError(tt(3804));e=t}if("function"!=typeof e)throw TypeError(tt(3809));if(!Ht(e,v.Component))throw TypeError(tt(3810));var i=e._requireComponent;if(i)if(Array.isArray(i))for(var n=0;n<i.length;n++){var r=i[n];this.getComponent(r)||this.addComponent(r)}else{var s=i;this.getComponent(s)||this.addComponent(s)}var o=new e;return o.node=this,this._components.push(o),this.emit(om.COMPONENT_ADDED,o),this._activeInHierarchy&&v.director._nodeActivator.activateComp(o),o},e.removeComponent=function(t){if(t){var e=null;(e=t instanceof rp?t:this.getComponent(t))&&e.destroy()}else J(3813)},e.on=function(t,e,i,n){switch(void 0===n&&(n=!1),t){case om.TRANSFORM_CHANGED:this._eventMask|=1}this._eventProcessor.on(t,e,i,n)},e.off=function(t,e,i,n){if(void 0===n&&(n=!1),this._eventProcessor.off(t,e,i,n),!this._eventProcessor.hasEventListener(t))switch(t){case om.TRANSFORM_CHANGED:this._eventMask&=-2}},e.once=function(t,e,i,n){this._eventProcessor.once(t,e,i,n)},e.emit=function(t,e,i,n,r,s){this._eventProcessor.emit(t,e,i,n,r,s)},e.dispatchEvent=function(t){this._eventProcessor.dispatchEvent(t)},e.hasEventListener=function(t,e,i){return this._eventProcessor.hasEventListener(t,e,i)},e.targetOff=function(t){this._eventProcessor.targetOff(t),1&this._eventMask&&!this._eventProcessor.hasEventListener(om.TRANSFORM_CHANGED)&&(this._eventMask&=-2)},e.destroy=function(){return!!t.prototype.destroy.call(this)&&(this.active=!1,!0)},e.destroyAllChildren=function(){for(var t=this._children,e=0;e<t.length;++e)t[e].destroy()},e._removeComponent=function(t){if(t){if(!(this._objFlags&Cm)){var e=this._components.indexOf(t);-1!==e?(this._components.splice(e,1),this.emit(om.COMPONENT_REMOVED,t)):t.node!==this&&J(3815)}}else J(3814)},e._updateSiblingIndex=function(){for(var t=0;t<this._children.length;++t)this._children[t]._siblingIndex=t;this.emit(om.CHILDREN_ORDER_CHANGED)},e._instantiate=function(t,e){return t||(t=v.instantiate._clone(this,this)),t._prefab,t._parent=null,t._onBatchCreated(e),t},e._onHierarchyChangedBase=function(){var t=this._parent;!this._persistNode||t instanceof v.Scene||v.game.removePersistRootNode(this);var e=this._active&&!(!t||!t._activeInHierarchy);this._activeInHierarchy!==e&&v.director._nodeActivator.activateNode(this,e)},e._onPreDestroyBase=function(){this._objFlags|=Cm;var t=this._parent,e=!!t&&0!=(t._objFlags&Cm);if(this._persistNode&&v.game.removePersistRootNode(this),!e&&t){this.emit(om.PARENT_CHANGED,this);var i=t._children.indexOf(this);t._children.splice(i,1),this._siblingIndex=0,t._updateSiblingIndex(),t.emit&&t.emit(om.CHILD_REMOVED,this)}this.emit(om.NODE_DESTROYED,this),this._eventProcessor.destroy();for(var n=this._children,r=0;r<n.length;++r)n[r]._destroyImmediate();for(var s=this._components,o=0;o<s.length;++o)s[o]._destroyImmediate();return e},i.isNode=function(t){return t instanceof i&&(t.constructor===i||!(t instanceof v.Scene))},e._onPreDestroy=function(){return this._onPreDestroyBase()},e[Jo]=function(t){t.writeThis()},e._onSetParent=function(t,e){if(void 0===e&&(e=!1),this._parent&&(null!=t&&t._scene===this._parent._scene||null==this._parent._scene||this.walk(i._setScene)),e){var n=this._parent;n?(n.updateWorldTransform(),wi(In.determinant(n._mat),0,Ei)?(Y(14300),this._transformFlags|=rm.TRS,this.updateWorldTransform()):(In.multiply(jm,In.invert(jm,n._mat),this._mat),In.toRTS(jm,this._lrot,this._lpos,this._lscale))):(on.copy(this._lpos,this._pos),Sn.copy(this._lrot,this._rot),on.copy(this._lscale,this._scale)),this._eulerDirty=!0}this.invalidateChildren(rm.TRS)},e._onHierarchyChanged=function(t){this.eventProcessor.reattach(),this._onHierarchyChangedBase(t)},e._onBatchCreated=function(t){this.hasChangedFlags=rm.TRS;for(var e=this._children.length,i=0;i<e;++i)this._children[i]._siblingIndex=i,this._children[i]._onBatchCreated(t)},e._onBeforeSerialize=function(){this.eulerAngles},e._onPostActivated=function(t){t?(this._eventProcessor.setEnabled(!0),this.invalidateChildren(rm.TRS),this._uiProps&&this._uiProps.uiComp&&(this._uiProps.uiComp.setNodeDirty(),this._uiProps.uiComp.setTextureDirty(),this._uiProps.uiComp.markForUpdateRenderData())):this._eventProcessor.setEnabled(!1)},e.translate=function(t,e){var i=e||nm.LOCAL;if(i===nm.LOCAL)on.transformQuat(Bm,t,this._lrot),this._lpos.x+=Bm.x,this._lpos.y+=Bm.y,this._lpos.z+=Bm.z;else if(i===nm.WORLD)if(this._parent){Sn.invert(Pm,this._parent.worldRotation),on.transformQuat(Bm,t,Pm);var n=this.worldScale;this._lpos.x+=Bm.x/n.x,this._lpos.y+=Bm.y/n.y,this._lpos.z+=Bm.z/n.z}else this._lpos.x+=t.x,this._lpos.y+=t.y,this._lpos.z+=t.z;this.invalidateChildren(rm.POSITION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.POSITION)},e.rotate=function(t,e){var i=e||nm.LOCAL;if(Sn.normalize(Pm,t),i===nm.LOCAL)Sn.multiply(this._lrot,this._lrot,Pm);else if(i===nm.WORLD){var n=this.worldRotation;Sn.multiply(Om,Pm,n),Sn.invert(Pm,n),Sn.multiply(Om,Pm,Om),Sn.multiply(this._lrot,this._lrot,Om)}this._eulerDirty=!0,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.ROTATION)},e.lookAt=function(t,e){this.getWorldPosition(Bm),on.subtract(Bm,Bm,t),on.normalize(Bm,Bm),Sn.fromViewUp(Pm,Bm,e),this.setWorldRotation(Pm)},e.invalidateChildren=function(t){var e,i,n=0,r=0,s=0,o=0,a=t|rm.POSITION;for(qm[0]=this;n>=0;){if(o=(e=qm[n--]).hasChangedFlags,e.isValid&&(e._transformFlags&o&t)!==t)for(e._transformFlags|=t,e.hasChangedFlags=o|t,s=(i=e._children).length,r=0;r<s;r++)qm[++n]=i[r];t=a}},e.updateWorldTransform=function(){if(this._transformFlags){for(var t,e=this,i=0;e&&e._transformFlags;)qm[i++]=e,e=e._parent;for(var n=0;i;){if(n|=(t=qm[--i])._transformFlags,e){if(n&rm.POSITION&&(on.transformMat4(t._pos,t._lpos,e._mat),t._mat.m12=t._pos.x,t._mat.m13=t._pos.y,t._mat.m14=t._pos.z),n&rm.RS){In.fromRTS(t._mat,t._lrot,t._lpos,t._lscale),In.multiply(t._mat,e._mat,t._mat);var r=n&rm.ROTATION?t._rot:null;In.toRTS(t._mat,r,null,t._scale)}}else n&rm.POSITION&&(on.copy(t._pos,t._lpos),t._mat.m12=t._pos.x,t._mat.m13=t._pos.y,t._mat.m14=t._pos.z),n&rm.RS&&(n&rm.ROTATION&&Sn.copy(t._rot,t._lrot),n&rm.SCALE&&on.copy(t._scale,t._lscale),In.fromRTS(t._mat,t._rot,t._pos,t._scale));t._transformFlags=rm.NONE,e=t}}},e.setPosition=function(t,e,i){void 0===e&&void 0===i?on.copy(this._lpos,t):void 0===i?on.set(this._lpos,t,e,this._lpos.z):on.set(this._lpos,t,e,i),this.invalidateChildren(rm.POSITION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.POSITION)},e.getPosition=function(t){return t?on.set(t,this._lpos.x,this._lpos.y,this._lpos.z):on.copy(new on,this._lpos)},e.setRotation=function(t,e,i,n){void 0===e||void 0===i||void 0===n?Sn.copy(this._lrot,t):Sn.set(this._lrot,t,e,i,n),this._eulerDirty=!0,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.ROTATION)},e.setRotationFromEuler=function(t,e,i){var n=void 0===i?this._euler.z:i;void 0===e?(on.copy(this._euler,t),Sn.fromEuler(this._lrot,t.x,t.y,t.z)):(on.set(this._euler,t,e,n),Sn.fromEuler(this._lrot,t,e,n)),this._eulerDirty=!1,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.ROTATION)},e.getRotation=function(t){return t?Sn.set(t,this._lrot.x,this._lrot.y,this._lrot.z,this._lrot.w):Sn.copy(new Sn,this._lrot)},e.setScale=function(t,e,i){void 0===e&&void 0===i?on.copy(this._lscale,t):void 0===i?on.set(this._lscale,t,e,this._lscale.z):on.set(this._lscale,t,e,i),this.invalidateChildren(rm.SCALE),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.SCALE)},e.getScale=function(t){return t?on.set(t,this._lscale.x,this._lscale.y,this._lscale.z):on.copy(new on,this._lscale)},e.inverseTransformPoint=function(t,e){on.copy(t,e);for(var i=this,n=0;i._parent;)qm[n++]=i,i=i._parent;for(;n>=0;)on.transformInverseRTS(t,t,i._lrot,i._lpos,i._lscale),i=qm[--n];return t},e.setWorldPosition=function(t,e,i){void 0===e||void 0===i?on.copy(this._pos,t):on.set(this._pos,t,e,i);var n=this._parent,r=this._lpos;n?(n.updateWorldTransform(),on.transformMat4(r,this._pos,In.invert(jm,n._mat))):on.copy(r,this._pos),this.invalidateChildren(rm.POSITION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.POSITION)},e.getWorldPosition=function(t){return this.updateWorldTransform(),t?on.copy(t,this._pos):on.copy(new on,this._pos)},e.setWorldRotation=function(t,e,i,n){void 0===e||void 0===i||void 0===n?Sn.copy(this._rot,t):Sn.set(this._rot,t,e,i,n),this._parent?(this._parent.updateWorldTransform(),Sn.multiply(this._lrot,Sn.conjugate(this._lrot,this._parent._rot),this._rot)):Sn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.ROTATION)},e.setWorldRotationFromEuler=function(t,e,i){Sn.fromEuler(this._rot,t,e,i),this._parent?(this._parent.updateWorldTransform(),Sn.multiply(this._lrot,Sn.conjugate(this._lrot,this._parent._rot),this._rot)):Sn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.ROTATION)},e.getWorldRotation=function(t){return this.updateWorldTransform(),t?Sn.copy(t,this._rot):Sn.copy(new Sn,this._rot)},e.setWorldScale=function(t,e,i){var n=this._parent;n&&this.updateWorldTransform(),void 0===e||void 0===i?on.copy(this._scale,t):on.set(this._scale,t,e,i),n?(Bm.x=this._scale.x/on.set(Dm,this._mat.m00,this._mat.m01,this._mat.m02).length(),Bm.y=this._scale.y/on.set(Dm,this._mat.m04,this._mat.m05,this._mat.m06).length(),Bm.z=this._scale.z/on.set(Dm,this._mat.m08,this._mat.m09,this._mat.m10).length(),In.scale(jm,this._mat,Bm),In.multiply(Xm,In.invert(Xm,n._mat),jm),mn.fromQuat(Lm,Sn.conjugate(Mm,this._lrot)),mn.multiplyMat4(Lm,Lm,Xm),this._lscale.x=on.set(Bm,Lm.m00,Lm.m01,Lm.m02).length(),this._lscale.y=on.set(Bm,Lm.m03,Lm.m04,Lm.m05).length(),this._lscale.z=on.set(Bm,Lm.m06,Lm.m07,Lm.m08).length()):on.copy(this._lscale,this._scale),this.invalidateChildren(rm.SCALE),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.SCALE)},e.getWorldScale=function(t){return this.updateWorldTransform(),t?on.copy(t,this._scale):on.copy(new on,this._scale)},e.getWorldMatrix=function(t){this.updateWorldTransform();var e=t||new In;return In.copy(e,this._mat)},e.getWorldRS=function(t){this.updateWorldTransform();var e=t||new In;return In.copy(e,this._mat),e.m12=0,e.m13=0,e.m14=0,e},e.getWorldRT=function(t){this.updateWorldTransform();var e=t||new In;return In.fromRT(e,this._rot,this._pos)},e.setRTS=function(t,e,i){var n=0;t&&(n|=rm.ROTATION,void 0!==t.w?(Sn.copy(this._lrot,t),this._eulerDirty=!0):(on.copy(this._euler,t),Sn.fromEuler(this._lrot,t.x,t.y,t.z),this._eulerDirty=!1)),e&&(on.copy(this._lpos,e),n|=rm.POSITION),i&&(on.copy(this._lscale,i),n|=rm.SCALE),n&&(this.invalidateChildren(n),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,n))},e.isTransformDirty=function(){return this._transformFlags!==rm.NONE},e.pauseSystemEvents=function(t){this._eventProcessor.setEnabled(!1,t)},e.resumeSystemEvents=function(t){this._eventProcessor.setEnabled(!0,t)},i.resetHasChangedFlags=function(){Km+=1},i.clearNodeArray=function(){i.ClearFrame<i.ClearRound?i.ClearFrame++:(i.ClearFrame=0,qm.length=0)},e.getPathInHierarchy=function(){for(var t=this.name,e=this.parent;e&&!(e instanceof v.Scene);)t=e.name+"/"+t,e=e.parent;return t},n(i,[{key:"components",get:function(){return this._components}},{key:"_persistNode",get:function(){return(this._objFlags&wm)>0},set:function(t){t?this._objFlags|=wm:this._objFlags&=~wm}},{key:"name",get:function(){return this._name},set:function(t){this._name=t}},{key:"uuid",get:function(){return this._id}},{key:"children",get:function(){return this._children}},{key:"active",get:function(){return this._active},set:function(t){if(t=!!t,this._active!==t){this._active=t;var e=this._parent;e&&e._activeInHierarchy&&v.director._nodeActivator.activateNode(this,t)}}},{key:"activeInHierarchy",get:function(){return this._activeInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(t){this.setParent(t)}},{key:"scene",get:function(){return this._scene}},{key:"eventProcessor",get:function(){return this._eventProcessor}},{key:"prefab",get:function(){return this._prefab}},{key:"id",set:function(t){this._id=t}},{key:"siblingIndex",get:function(){return this._siblingIndex},set:function(t){this._siblingIndex=t}},{key:"position",get:function(){return this._lpos},set:function(t){this.setPosition(t)}},{key:"worldPosition",get:function(){return this.updateWorldTransform(),this._pos},set:function(t){this.setWorldPosition(t)}},{key:"rotation",get:function(){return this._lrot},set:function(t){this.setRotation(t)}},{key:"eulerAngles",get:function(){return this._eulerDirty&&(Sn.toEuler(this._euler,this._lrot),this._eulerDirty=!1),this._euler},set:function(t){this.setRotationFromEuler(t.x,t.y,t.z)}},{key:"angle",get:function(){return this._euler.z},set:function(t){on.set(this._euler,0,0,t),Sn.fromAngleZ(this._lrot,t),this._eulerDirty=!1,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.ROTATION)}},{key:"worldRotation",get:function(){return this.updateWorldTransform(),this._rot},set:function(t){this.setWorldRotation(t)}},{key:"scale",get:function(){return this._lscale},set:function(t){this.setScale(t)}},{key:"worldScale",get:function(){return this.updateWorldTransform(),this._scale},set:function(t){this.setWorldScale(t)}},{key:"matrix",set:function(t){In.toRTS(t,this._lrot,this._lpos,this._lscale),this.invalidateChildren(rm.TRS),this._eulerDirty=!0,1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.TRS)}},{key:"worldMatrix",get:function(){return this.updateWorldTransform(),this._mat}},{key:"forward",get:function(){return on.transformQuat(new on,on.FORWARD,this.worldRotation)},set:function(t){var e=t.length();on.multiplyScalar(Bm,t,-1/e),Sn.fromViewUp(Pm,Bm),this.setWorldRotation(Pm)}},{key:"up",get:function(){return on.transformQuat(new on,on.UP,this.worldRotation)}},{key:"right",get:function(){return on.transformQuat(new on,on.RIGHT,this.worldRotation)}},{key:"mobility",get:function(){return this._mobility},set:function(t){this._mobility=t,this.emit(om.MOBILITY_CHANGED)}},{key:"layer",get:function(){return this._layer},set:function(t){this._layer=t,this._uiProps&&this._uiProps.uiComp&&(this._uiProps.uiComp.setNodeDirty(),this._uiProps.uiComp.markForUpdateRenderData()),this.emit(om.LAYER_CHANGED,this._layer)}},{key:"flagChangedVersion",get:function(){return this._flagChangeVersion}},{key:"hasChangedFlags",get:function(){return this._flagChangeVersion===Km?this._hasChangedFlags:0},set:function(t){this._flagChangeVersion=Km,this._hasChangedFlags=t}}]),i}(Ho)).idGenerator=Rm,bm._stacks=[[]],bm._stackId=0,bm.EventType=om,bm.NodeSpace=nm,bm.TransformDirtyBit=rm,bm.TransformBit=rm,bm.reserveContentsForAllSyncablePrefabTag=Ym,bm.ClearFrame=0,bm.ClearRound=1e3,p((cm=bm).prototype,"_persistNode",[Qs],Object.getOwnPropertyDescriptor(cm.prototype,"_persistNode"),cm.prototype),_m=ks(cm.prototype,"_parent",[io],(function(){return null})),dm=ks(cm.prototype,"_children",[io],(function(){return[]})),fm=ks(cm.prototype,"_active",[io],(function(){return!0})),pm=ks(cm.prototype,"_components",[io],(function(){return[]})),mm=ks(cm.prototype,"_prefab",[io],(function(){return null})),gm=ks(cm.prototype,"_lpos",[io],(function(){return new on})),ym=ks(cm.prototype,"_lrot",[io],(function(){return new Sn})),vm=ks(cm.prototype,"_lscale",[io],(function(){return new on(1,1,1)})),Sm=ks(cm.prototype,"_mobility",[io],(function(){return Em.Static})),Tm=ks(cm.prototype,"_layer",[io],(function(){return im.Enum.DEFAULT})),Am=ks(cm.prototype,"_euler",[io],(function(){return new on})),p(cm.prototype,"eulerAngles",[hm],Object.getOwnPropertyDescriptor(cm.prototype,"eulerAngles"),cm.prototype),p(cm.prototype,"mobility",[um],Object.getOwnPropertyDescriptor(cm.prototype,"mobility"),cm.prototype),lm=cm))||lm));v.Node=Jm,function(t){t[t.right=0]="right",t[t.left=1]="left",t[t.top=2]="top",t[t.bottom=3]="bottom",t[t.front=4]="front",t[t.back=5]="back"}(Hm||(Hm={})),function(t){t[t.NONE=0]="NONE",t[t.AUTO=1]="AUTO",t[t.BAKED_CONVOLUTION_MAP=2]="BAKED_CONVOLUTION_MAP"}(Wm||(Wm={}));var Qm=t("eg",qs("cc.TextureCube")(((zm=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).isRGBE=km&&km(),e._mipmapAtlas=Vm&&Vm(),e._mipmapMode=Gm&&Gm(),e._mipmaps=Um&&Um(),e._generatedMipmaps=[],e}s(e,t);var i=e.prototype;return i._setMipmapParams=function(t){var e=this;if(this._generatedMipmaps=t,this._setMipmapLevel(this._generatedMipmaps.length),this._generatedMipmaps.length>0){var i=this._generatedMipmaps[0].front;this.reset({width:i.width,height:i.height,format:i.format,mipmapLevel:this._generatedMipmaps.length,baseLevel:this._baseLevel,maxLevel:this._maxLevel}),this._generatedMipmaps.forEach((function(t,i){Zm(t,(function(t,n){e._assignImage(t,i,n)}))}))}else this.reset({width:0,height:0,mipmapLevel:this._generatedMipmaps.length,baseLevel:this._baseLevel,maxLevel:this._maxLevel})},i.isUsingOfflineMipmaps=function(){return this._mipmapMode===Wm.BAKED_CONVOLUTION_MAP},e.fromTexture2DArray=function(t,i){for(var n=[],r=t.length/6,s=0;s<r;s++){var o=6*s;n.push({front:t[o+Hm.front].image,back:t[o+Hm.back].image,left:t[o+Hm.left].image,right:t[o+Hm.right].image,top:t[o+Hm.top].image,bottom:t[o+Hm.bottom].image})}return(i=i||new e).mipmaps=n,i},i.onLoaded=function(){this._mipmapMode===Wm.BAKED_CONVOLUTION_MAP?this.mipmapAtlas=this._mipmapAtlas:this.mipmaps=this._mipmaps},i.reset=function(t){this._width=t.width,this._height=t.height,this._setGFXFormat(t.format);var e=void 0===t.mipmapLevel?1:t.mipmapLevel;this._setMipmapLevel(e);var i=void 0===t.baseLevel?0:t.baseLevel,n=void 0===t.maxLevel?1e3:t.maxLevel;this._setMipRange(i,n),this._tryReset()},i.updateMipmaps=function(t,e){var i=this;if(void 0===t&&(t=0),!(t>=this._generatedMipmaps.length))for(var n=Math.min(void 0===e?this._generatedMipmaps.length:e,this._generatedMipmaps.length-t),r=function(){var e=t+s;Zm(i._generatedMipmaps[e],(function(t,n){i._assignImage(t,e,n)}))},s=0;s<n;++s)r()},i.destroy=function(){return this._mipmaps=[],this._generatedMipmaps=[],this._mipmapAtlas=null,t.prototype.destroy.call(this)},i.releaseTexture=function(){this.destroy()},i._serialize=function(){return null},i._deserialize=function(e,i){var n=e;if(t.prototype._deserialize.call(this,n.base,i),this.isRGBE=n.rgbe,this._mipmapMode=n.mipmapMode,this._mipmapMode===Wm.BAKED_CONVOLUTION_MAP){var r=n.mipmapAtlas,s=n.mipmapLayout;this._mipmapAtlas={atlas:{},layout:s},this._mipmapAtlas.atlas={front:new Rf,back:new Rf,left:new Rf,right:new Rf,top:new Rf,bottom:new Rf};var o=ne(Rf);i.result.push(this._mipmapAtlas.atlas,"front",r.front,o),i.result.push(this._mipmapAtlas.atlas,"back",r.back,o),i.result.push(this._mipmapAtlas.atlas,"left",r.left,o),i.result.push(this._mipmapAtlas.atlas,"right",r.right,o),i.result.push(this._mipmapAtlas.atlas,"top",r.top,o),i.result.push(this._mipmapAtlas.atlas,"bottom",r.bottom,o)}else{this._mipmaps=new Array(n.mipmaps.length);for(var a=0;a<n.mipmaps.length;++a){this._mipmaps[a]={front:new Rf,back:new Rf,left:new Rf,right:new Rf,top:new Rf,bottom:new Rf};var h=n.mipmaps[a],u=ne(Rf);i.result.push(this._mipmaps[a],"front",h.front,u),i.result.push(this._mipmaps[a],"back",h.back,u),i.result.push(this._mipmaps[a],"left",h.left,u),i.result.push(this._mipmaps[a],"right",h.right,u),i.result.push(this._mipmaps[a],"top",h.top,u),i.result.push(this._mipmaps[a],"bottom",h.bottom,u)}}},i._getGfxTextureCreateInfo=function(t){var e=new Qc(Jl.CUBE);return e.width=this._width,e.height=this._height,e.layerCount=6,Object.assign(e,t),e},i._getGfxTextureViewCreateInfo=function(t){var e=new Zc;return e.type=Jl.CUBE,e.baseLayer=0,e.layerCount=6,Object.assign(e,t),e},i._uploadAtlas=function(){var t=this,e=this._mipmapAtlas.layout,i=e[0];this.reset({width:i.width,height:i.height,format:this._mipmapAtlas.atlas.front.format,mipmapLevel:e.length}),Zm(this._mipmapAtlas.atlas,(function(i,n){var r=new Zp;r.image=i,r.reset({width:i.width,height:i.height,format:i.format}),r.uploadData(i.data);for(var s=0;s<e.length;s++){var o=e[s],a=r.getGFXTexture().size,h=new Uint8Array(a),u=new Gc;u.texOffset.x=o.left,u.texOffset.y=o.top,u.texExtent.width=o.width,u.texExtent.height=o.height,t._getGFXDevice().copyTextureToBuffers(r.getGFXTexture(),[h],[u]);var l=new Rf({_data:h,_compressed:i.isCompressed,width:o.width,height:o.height,format:i.format});t._assignImage(l,o.level,n)}}))},i.initDefault=function(e){t.prototype.initDefault.call(this,e);var i=new Rf;i.initDefault(),this.mipmaps=[{front:i,back:i,top:i,bottom:i,left:i,right:i}]},i.validate=function(){if(this._mipmapMode===Wm.BAKED_CONVOLUTION_MAP){if(null===this.mipmapAtlas||0===this.mipmapAtlas.layout.length)return!1;var t=this.mipmapAtlas.atlas;return!!(t.top&&t.bottom&&t.front&&t.back&&t.left&&t.right)}return 0!==this._mipmaps.length&&!this._mipmaps.find((function(t){return!(t.top&&t.bottom&&t.front&&t.back&&t.left&&t.right)}))},n(e,[{key:"mipmaps",get:function(){return this._mipmaps},set:function(t){this._mipmaps=t;var e=[];if(1===t.length){var i=t[0],n=i.front.extractMipmaps(),r=i.back.extractMipmaps(),s=i.left.extractMipmaps(),o=i.right.extractMipmaps(),a=i.top.extractMipmaps(),h=i.bottom.extractMipmaps();if(n.length!==r.length||n.length!==s.length||n.length!==o.length||n.length!==a.length||n.length!==h.length)return console.error("The number of mipmaps of each face is different."),void this._setMipmapParams([]);for(var u=n.length,l=0;l<u;++l){var c={front:n[l],back:r[l],left:s[l],right:o[l],top:a[l],bottom:h[l]};e.push(c)}}else t.length>1&&t.forEach((function(t){var i={front:t.front.extractMipmap0(),back:t.back.extractMipmap0(),left:t.left.extractMipmap0(),right:t.right.extractMipmap0(),top:t.top.extractMipmap0(),bottom:t.bottom.extractMipmap0()};e.push(i)}));this._setMipmapParams(e)}},{key:"mipmapAtlas",get:function(){return this._mipmapAtlas},set:function(t){var e=this;if(this._mipmapAtlas=t,this._mipmapAtlas){var i=this._mipmapAtlas.atlas.front;if(i.data){var n=this._mipmapAtlas.atlas,r=this._mipmapAtlas.layout,s=r[0],o=Object.assign(T.document.createElement("canvas"),{width:i.width,height:i.height}).getContext("2d");this.reset({width:s.width,height:s.height,format:i.format,mipmapLevel:r.length});for(var a=function(){var t=r[h];Zm(n,(function(n,r){o.clearRect(0,0,i.width,i.height);var s=n.data;o.drawImage(s,0,0);var a=o.getImageData(t.left,t.top,t.width,t.height),h=new Rf({_data:a.data,_compressed:n.isCompressed,width:a.width,height:a.height,format:n.format});e._assignImage(h,t.level,r)}))},h=0;h<r.length;h++)a()}}else this.reset({width:0,height:0,mipmapLevel:0})}},{key:"image",get:function(){return 0===this._mipmaps.length?null:this._mipmaps[0]},set:function(t){this.mipmaps=t?[t]:[]}}]),e}(Qp)).FaceIndex=Hm,km=ks((Fm=zm).prototype,"isRGBE",[io],(function(){return!1})),Vm=ks(Fm.prototype,"_mipmapAtlas",[io],(function(){return null})),Gm=ks(Fm.prototype,"_mipmapMode",[io],(function(){return Wm.NONE})),Um=ks(Fm.prototype,"_mipmaps",[io],(function(){return[]})),Nm=Fm))||Nm);function Zm(t,e){e(t.front,Hm.front),e(t.back,Hm.back),e(t.left,Hm.left),e(t.right,Hm.right),e(t.top,Hm.top),e(t.bottom,Hm.bottom)}v.TextureCube=Qm;var $m,tg,eg,ig,ng,rg,sg,og,ag,hg,ug,lg,cg,_g,dg=function(){function t(){this._groundAlbedoHDR=new tn(.2,.2,.2,1),this._skyColorHDR=new tn(.2,.5,.8,1),this._skyIllumHDR=0,this._groundAlbedoLDR=new tn(.2,.2,.2,1),this._skyColorLDR=new tn(.2,.5,.8,1),this._skyIllumLDR=0,this._mipmapCount=1,this._enabled=!1}return t.prototype.initialize=function(t){this._skyColorHDR=t.skyColorHDR,this._groundAlbedoHDR.set(t.groundAlbedoHDR),this._skyIllumHDR=t.skyIllumHDR,this._skyColorLDR=t.skyColorLDR,this._groundAlbedoLDR.set(t.groundAlbedoLDR),this._skyIllumLDR=t.skyIllumLDR},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"skyColor",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._skyColorHDR:this._skyColorLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this._skyColorHDR.set(t):this._skyColorLDR.set(t)}},{key:"skyIllum",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._skyIllumHDR:this._skyIllumLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this._skyIllumHDR=t:this._skyIllumLDR=t}},{key:"groundAlbedo",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._groundAlbedoHDR:this._groundAlbedoLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this._groundAlbedoHDR.set(t):this._groundAlbedoLDR.set(t)}}]),t}();dg.SUN_ILLUM=65e3,dg.SKY_ILLUM=2e4,v.Ambient=dg;var fg,pg,mg="MainFlow",gg="ForwardFlow",yg="ShadowFlow";!function(t){t[t.DEFAULT=100]="DEFAULT",t[t.UI=200]="UI"}(fg||(fg={})),v.RenderPassStage=fg,function(t){t[t.MIN=0]="MIN",t[t.MAX=255]="MAX",t[t.DEFAULT=128]="DEFAULT"}(pg||(pg={}));var vg,Sg={bindings:[],layouts:{}},Tg={bindings:[],layouts:{}};!function(t){t[t.UBO_GLOBAL=0]="UBO_GLOBAL",t[t.UBO_CAMERA=1]="UBO_CAMERA",t[t.UBO_SHADOW=2]="UBO_SHADOW",t[t.UBO_CSM=3]="UBO_CSM",t[t.SAMPLER_SHADOWMAP=4]="SAMPLER_SHADOWMAP",t[t.SAMPLER_ENVIRONMENT=5]="SAMPLER_ENVIRONMENT",t[t.SAMPLER_SPOT_SHADOW_MAP=6]="SAMPLER_SPOT_SHADOW_MAP",t[t.SAMPLER_DIFFUSEMAP=7]="SAMPLER_DIFFUSEMAP",t[t.COUNT=8]="COUNT"}(vg||(vg={}));var Ag,bg=vg.SAMPLER_SHADOWMAP,Eg=vg.COUNT-bg;!function(t){t[t.UBO_LOCAL=0]="UBO_LOCAL",t[t.UBO_FORWARD_LIGHTS=1]="UBO_FORWARD_LIGHTS",t[t.UBO_SKINNING_ANIMATION=2]="UBO_SKINNING_ANIMATION",t[t.UBO_SKINNING_TEXTURE=3]="UBO_SKINNING_TEXTURE",t[t.UBO_MORPH=4]="UBO_MORPH",t[t.UBO_UI_LOCAL=5]="UBO_UI_LOCAL",t[t.UBO_SH=6]="UBO_SH",t[t.SAMPLER_JOINTS=7]="SAMPLER_JOINTS",t[t.SAMPLER_MORPH_POSITION=8]="SAMPLER_MORPH_POSITION",t[t.SAMPLER_MORPH_NORMAL=9]="SAMPLER_MORPH_NORMAL",t[t.SAMPLER_MORPH_TANGENT=10]="SAMPLER_MORPH_TANGENT",t[t.SAMPLER_LIGHTMAP=11]="SAMPLER_LIGHTMAP",t[t.SAMPLER_SPRITE=12]="SAMPLER_SPRITE",t[t.SAMPLER_REFLECTION=13]="SAMPLER_REFLECTION",t[t.STORAGE_REFLECTION=14]="STORAGE_REFLECTION",t[t.SAMPLER_REFLECTION_PROBE_CUBE=15]="SAMPLER_REFLECTION_PROBE_CUBE",t[t.SAMPLER_REFLECTION_PROBE_PLANAR=16]="SAMPLER_REFLECTION_PROBE_PLANAR",t[t.SAMPLER_REFLECTION_PROBE_DATA_MAP=17]="SAMPLER_REFLECTION_PROBE_DATA_MAP",t[t.SAMPLER_REFLECTION_PROBE_BLEND_CUBE=18]="SAMPLER_REFLECTION_PROBE_BLEND_CUBE",t[t.COUNT=19]="COUNT"}(Ag||(Ag={}));var Cg,wg=Ag.SAMPLER_JOINTS,xg=Ag.STORAGE_REFLECTION-wg,Rg=Ag.COUNT-wg-xg;!function(t){t[t.GLOBAL=0]="GLOBAL",t[t.MATERIAL=1]="MATERIAL",t[t.LOCAL=2]="LOCAL",t[t.COUNT=3]="COUNT"}(Cg||(Cg={}));var Ig=new Hc([bg,0,wg,0],[Eg,0,xg,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,Rg,0],[0,0,0,0],[0,2,1,3]),Bg=function(){};$m=Bg,Bg.TIME_OFFSET=0,Bg.SCREEN_SIZE_OFFSET=$m.TIME_OFFSET+4,Bg.NATIVE_SIZE_OFFSET=$m.SCREEN_SIZE_OFFSET+4,Bg.PROBE_INFO_OFFSET=$m.NATIVE_SIZE_OFFSET+4,Bg.DEBUG_VIEW_MODE_OFFSET=$m.PROBE_INFO_OFFSET+4,Bg.COUNT=$m.DEBUG_VIEW_MODE_OFFSET+4,Bg.SIZE=4*$m.COUNT,Bg.NAME="CCGlobal",Bg.BINDING=vg.UBO_GLOBAL,Bg.DESCRIPTOR=new T_($m.BINDING,Tc.UNIFORM_BUFFER,1,uc.ALL),Bg.LAYOUT=new e_(Cg.GLOBAL,$m.BINDING,$m.NAME,[new t_("cc_time",jl.FLOAT4,1),new t_("cc_screenSize",jl.FLOAT4,1),new t_("cc_nativeSize",jl.FLOAT4,1),new t_("cc_probeInfo",jl.FLOAT4,1),new t_("cc_debug_view_mode",jl.FLOAT4,1)],1),Sg.layouts[Bg.NAME]=Bg.LAYOUT,Sg.bindings[Bg.BINDING]=Bg.DESCRIPTOR;var Dg=function(){};tg=Dg,Dg.MAT_VIEW_OFFSET=0,Dg.MAT_VIEW_INV_OFFSET=tg.MAT_VIEW_OFFSET+16,Dg.MAT_PROJ_OFFSET=tg.MAT_VIEW_INV_OFFSET+16,Dg.MAT_PROJ_INV_OFFSET=tg.MAT_PROJ_OFFSET+16,Dg.MAT_VIEW_PROJ_OFFSET=tg.MAT_PROJ_INV_OFFSET+16,Dg.MAT_VIEW_PROJ_INV_OFFSET=tg.MAT_VIEW_PROJ_OFFSET+16,Dg.CAMERA_POS_OFFSET=tg.MAT_VIEW_PROJ_INV_OFFSET+16,Dg.SURFACE_TRANSFORM_OFFSET=tg.CAMERA_POS_OFFSET+4,Dg.SCREEN_SCALE_OFFSET=tg.SURFACE_TRANSFORM_OFFSET+4,Dg.EXPOSURE_OFFSET=tg.SCREEN_SCALE_OFFSET+4,Dg.MAIN_LIT_DIR_OFFSET=tg.EXPOSURE_OFFSET+4,Dg.MAIN_LIT_COLOR_OFFSET=tg.MAIN_LIT_DIR_OFFSET+4,Dg.AMBIENT_SKY_OFFSET=tg.MAIN_LIT_COLOR_OFFSET+4,Dg.AMBIENT_GROUND_OFFSET=tg.AMBIENT_SKY_OFFSET+4,Dg.GLOBAL_FOG_COLOR_OFFSET=tg.AMBIENT_GROUND_OFFSET+4,Dg.GLOBAL_FOG_BASE_OFFSET=tg.GLOBAL_FOG_COLOR_OFFSET+4,Dg.GLOBAL_FOG_ADD_OFFSET=tg.GLOBAL_FOG_BASE_OFFSET+4,Dg.NEAR_FAR_OFFSET=tg.GLOBAL_FOG_ADD_OFFSET+4,Dg.VIEW_PORT_OFFSET=tg.NEAR_FAR_OFFSET+4,Dg.COUNT=tg.VIEW_PORT_OFFSET+4,Dg.SIZE=4*tg.COUNT,Dg.NAME="CCCamera",Dg.BINDING=vg.UBO_CAMERA,Dg.DESCRIPTOR=new T_(tg.BINDING,Tc.UNIFORM_BUFFER,1,uc.ALL),Dg.LAYOUT=new e_(Cg.GLOBAL,tg.BINDING,tg.NAME,[new t_("cc_matView",jl.MAT4,1),new t_("cc_matViewInv",jl.MAT4,1),new t_("cc_matProj",jl.MAT4,1),new t_("cc_matProjInv",jl.MAT4,1),new t_("cc_matViewProj",jl.MAT4,1),new t_("cc_matViewProjInv",jl.MAT4,1),new t_("cc_cameraPos",jl.FLOAT4,1),new t_("cc_surfaceTransform",jl.FLOAT4,1),new t_("cc_screenScale",jl.FLOAT4,1),new t_("cc_exposure",jl.FLOAT4,1),new t_("cc_mainLitDir",jl.FLOAT4,1),new t_("cc_mainLitColor",jl.FLOAT4,1),new t_("cc_ambientSky",jl.FLOAT4,1),new t_("cc_ambientGround",jl.FLOAT4,1),new t_("cc_fogColor",jl.FLOAT4,1),new t_("cc_fogBase",jl.FLOAT4,1),new t_("cc_fogAdd",jl.FLOAT4,1),new t_("cc_nearFar",jl.FLOAT4,1),new t_("cc_viewPort",jl.FLOAT4,1)],1),Sg.layouts[Dg.NAME]=Dg.LAYOUT,Sg.bindings[Dg.BINDING]=Dg.DESCRIPTOR;var Pg=function(){};eg=Pg,Pg.MAT_LIGHT_VIEW_OFFSET=0,Pg.MAT_LIGHT_VIEW_PROJ_OFFSET=eg.MAT_LIGHT_VIEW_OFFSET+16,Pg.SHADOW_INV_PROJ_DEPTH_INFO_OFFSET=eg.MAT_LIGHT_VIEW_PROJ_OFFSET+16,Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET=eg.SHADOW_INV_PROJ_DEPTH_INFO_OFFSET+4,Pg.SHADOW_PROJ_INFO_OFFSET=eg.SHADOW_PROJ_DEPTH_INFO_OFFSET+4,Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET=eg.SHADOW_PROJ_INFO_OFFSET+4,Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET=eg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+4,Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET=eg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+4,Pg.SHADOW_COLOR_OFFSET=eg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+4,Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET=eg.SHADOW_COLOR_OFFSET+4,Pg.COUNT=eg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+4,Pg.SIZE=4*eg.COUNT,Pg.NAME="CCShadow",Pg.BINDING=vg.UBO_SHADOW,Pg.DESCRIPTOR=new T_(eg.BINDING,Tc.UNIFORM_BUFFER,1,uc.ALL),Pg.LAYOUT=new e_(Cg.GLOBAL,eg.BINDING,eg.NAME,[new t_("cc_matLightView",jl.MAT4,1),new t_("cc_matLightViewProj",jl.MAT4,1),new t_("cc_shadowInvProjDepthInfo",jl.FLOAT4,1),new t_("cc_shadowProjDepthInfo",jl.FLOAT4,1),new t_("cc_shadowProjInfo",jl.FLOAT4,1),new t_("cc_shadowNFLSInfo",jl.FLOAT4,1),new t_("cc_shadowWHPBInfo",jl.FLOAT4,1),new t_("cc_shadowLPNNInfo",jl.FLOAT4,1),new t_("cc_shadowColor",jl.FLOAT4,1),new t_("cc_planarNDInfo",jl.FLOAT4,1)],1),Sg.layouts[Pg.NAME]=Pg.LAYOUT,Sg.bindings[Pg.BINDING]=Pg.DESCRIPTOR;var Og=function(){};ig=Og,Og.CSM_LEVEL_COUNT=4,Og.CSM_VIEW_DIR_0_OFFSET=0,Og.CSM_VIEW_DIR_1_OFFSET=ig.CSM_VIEW_DIR_0_OFFSET+4*ig.CSM_LEVEL_COUNT,Og.CSM_VIEW_DIR_2_OFFSET=ig.CSM_VIEW_DIR_1_OFFSET+4*ig.CSM_LEVEL_COUNT,Og.CSM_ATLAS_OFFSET=ig.CSM_VIEW_DIR_2_OFFSET+4*ig.CSM_LEVEL_COUNT,Og.MAT_CSM_VIEW_PROJ_OFFSET=ig.CSM_ATLAS_OFFSET+4*ig.CSM_LEVEL_COUNT,Og.CSM_PROJ_DEPTH_INFO_OFFSET=ig.MAT_CSM_VIEW_PROJ_OFFSET+16*ig.CSM_LEVEL_COUNT,Og.CSM_PROJ_INFO_OFFSET=ig.CSM_PROJ_DEPTH_INFO_OFFSET+4*ig.CSM_LEVEL_COUNT,Og.CSM_SPLITS_INFO_OFFSET=ig.CSM_PROJ_INFO_OFFSET+4*ig.CSM_LEVEL_COUNT,Og.COUNT=ig.CSM_SPLITS_INFO_OFFSET+4,Og.SIZE=4*ig.COUNT,Og.NAME="CCCSM",Og.BINDING=vg.UBO_CSM,Og.DESCRIPTOR=new T_(ig.BINDING,Tc.UNIFORM_BUFFER,1,uc.FRAGMENT),Og.LAYOUT=new e_(Cg.GLOBAL,ig.BINDING,ig.NAME,[new t_("cc_csmViewDir0",jl.FLOAT4,ig.CSM_LEVEL_COUNT),new t_("cc_csmViewDir1",jl.FLOAT4,ig.CSM_LEVEL_COUNT),new t_("cc_csmViewDir2",jl.FLOAT4,ig.CSM_LEVEL_COUNT),new t_("cc_csmAtlas",jl.FLOAT4,ig.CSM_LEVEL_COUNT),new t_("cc_matCSMViewProj",jl.MAT4,ig.CSM_LEVEL_COUNT),new t_("cc_csmProjDepthInfo",jl.FLOAT4,ig.CSM_LEVEL_COUNT),new t_("cc_csmProjInfo",jl.FLOAT4,ig.CSM_LEVEL_COUNT),new t_("cc_csmSplitsInfo",jl.FLOAT4,1)],1),Sg.layouts[Og.NAME]=Og.LAYOUT,Sg.bindings[Og.BINDING]=Og.DESCRIPTOR;var Mg=vg.SAMPLER_SHADOWMAP,Lg=new T_(Mg,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),Ng=new i_(Cg.GLOBAL,Mg,"cc_shadowMap",jl.SAMPLER2D,1);Sg.layouts.cc_shadowMap=Ng,Sg.bindings[Mg]=Lg;var Fg=vg.SAMPLER_ENVIRONMENT,kg=new T_(Fg,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),Vg=new i_(Cg.GLOBAL,Fg,"cc_environment",jl.SAMPLER_CUBE,1);Sg.layouts.cc_environment=Vg,Sg.bindings[Fg]=kg;var Gg=vg.SAMPLER_DIFFUSEMAP,Ug=new T_(Gg,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),zg=new i_(Cg.GLOBAL,Gg,"cc_diffuseMap",jl.SAMPLER_CUBE,1);Sg.layouts.cc_diffuseMap=zg,Sg.bindings[Gg]=Ug;var Hg=vg.SAMPLER_SPOT_SHADOW_MAP,Wg=new T_(Hg,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),jg=new i_(Cg.GLOBAL,Hg,"cc_spotShadowMap",jl.SAMPLER2D,1);Sg.layouts.cc_spotShadowMap=jg,Sg.bindings[Hg]=Wg;var Xg=function(){};ng=Xg,Xg.MAT_WORLD_OFFSET=0,Xg.MAT_WORLD_IT_OFFSET=ng.MAT_WORLD_OFFSET+16,Xg.LIGHTINGMAP_UVPARAM=ng.MAT_WORLD_IT_OFFSET+16,Xg.LOCAL_SHADOW_BIAS=ng.LIGHTINGMAP_UVPARAM+4,Xg.REFLECTION_PROBE_DATA1=ng.LOCAL_SHADOW_BIAS+4,Xg.REFLECTION_PROBE_DATA2=ng.REFLECTION_PROBE_DATA1+4,Xg.REFLECTION_PROBE_BLEND_DATA1=ng.REFLECTION_PROBE_DATA2+4,Xg.REFLECTION_PROBE_BLEND_DATA2=ng.REFLECTION_PROBE_BLEND_DATA1+4,Xg.COUNT=ng.REFLECTION_PROBE_BLEND_DATA2+4,Xg.SIZE=4*ng.COUNT,Xg.NAME="CCLocal",Xg.BINDING=Ag.UBO_LOCAL,Xg.DESCRIPTOR=new T_(ng.BINDING,Tc.UNIFORM_BUFFER,1,uc.VERTEX|uc.FRAGMENT|uc.COMPUTE),Xg.LAYOUT=new e_(Cg.LOCAL,ng.BINDING,ng.NAME,[new t_("cc_matWorld",jl.MAT4,1),new t_("cc_matWorldIT",jl.MAT4,1),new t_("cc_lightingMapUVParam",jl.FLOAT4,1),new t_("cc_localShadowBias",jl.FLOAT4,1),new t_("cc_reflectionProbeData1",jl.FLOAT4,1),new t_("cc_reflectionProbeData2",jl.FLOAT4,1),new t_("cc_reflectionProbeBlendData1",jl.FLOAT4,1),new t_("cc_reflectionProbeBlendData2",jl.FLOAT4,1)],1),Tg.layouts[Xg.NAME]=Xg.LAYOUT,Tg.bindings[Xg.BINDING]=Xg.DESCRIPTOR;var qg=function(){};rg=qg,qg.WORLD_BOUND_CENTER=0,qg.WORLD_BOUND_HALF_EXTENTS=rg.WORLD_BOUND_CENTER+4,qg.COUNT=rg.WORLD_BOUND_HALF_EXTENTS+4,qg.SIZE=4*rg.COUNT,qg.NAME="CCWorldBound",qg.BINDING=Ag.UBO_LOCAL,qg.DESCRIPTOR=new T_(rg.BINDING,Tc.UNIFORM_BUFFER,1,uc.VERTEX|uc.COMPUTE),qg.LAYOUT=new e_(Cg.LOCAL,rg.BINDING,rg.NAME,[new t_("cc_worldBoundCenter",jl.FLOAT4,1),new t_("cc_worldBoundHalfExtents",jl.FLOAT4,1)],1),Tg.layouts[qg.NAME]=qg.LAYOUT,Tg.bindings[qg.BINDING]=qg.DESCRIPTOR;var Yg="a_matWorld0",Kg="a_sh_linear_const_r",Jg=function(){};sg=Jg,Jg.BATCHING_COUNT=10,Jg.MAT_WORLDS_OFFSET=0,Jg.COUNT=16*sg.BATCHING_COUNT,Jg.SIZE=4*sg.COUNT,Jg.NAME="CCLocalBatched",Jg.BINDING=Ag.UBO_LOCAL,Jg.DESCRIPTOR=new T_(sg.BINDING,Tc.UNIFORM_BUFFER,1,uc.VERTEX|uc.COMPUTE),Jg.LAYOUT=new e_(Cg.LOCAL,sg.BINDING,sg.NAME,[new t_("cc_matWorlds",jl.MAT4,sg.BATCHING_COUNT)],1),Tg.layouts[Jg.NAME]=Jg.LAYOUT,Tg.bindings[Jg.BINDING]=Jg.DESCRIPTOR;var Qg=function(){};og=Qg,Qg.LIGHTS_PER_PASS=1,Qg.LIGHT_POS_OFFSET=0,Qg.LIGHT_COLOR_OFFSET=og.LIGHT_POS_OFFSET+4*og.LIGHTS_PER_PASS,Qg.LIGHT_SIZE_RANGE_ANGLE_OFFSET=og.LIGHT_COLOR_OFFSET+4*og.LIGHTS_PER_PASS,Qg.LIGHT_DIR_OFFSET=og.LIGHT_SIZE_RANGE_ANGLE_OFFSET+4*og.LIGHTS_PER_PASS,Qg.LIGHT_BOUNDING_SIZE_VS_OFFSET=og.LIGHT_DIR_OFFSET+4*og.LIGHTS_PER_PASS,Qg.COUNT=og.LIGHT_BOUNDING_SIZE_VS_OFFSET+4*og.LIGHTS_PER_PASS,Qg.SIZE=4*og.COUNT,Qg.NAME="CCForwardLight",Qg.BINDING=Ag.UBO_FORWARD_LIGHTS,Qg.DESCRIPTOR=new T_(og.BINDING,Tc.DYNAMIC_UNIFORM_BUFFER,1,uc.FRAGMENT),Qg.LAYOUT=new e_(Cg.LOCAL,og.BINDING,og.NAME,[new t_("cc_lightPos",jl.FLOAT4,og.LIGHTS_PER_PASS),new t_("cc_lightColor",jl.FLOAT4,og.LIGHTS_PER_PASS),new t_("cc_lightSizeRangeAngle",jl.FLOAT4,og.LIGHTS_PER_PASS),new t_("cc_lightDir",jl.FLOAT4,og.LIGHTS_PER_PASS),new t_("cc_lightBoundingSizeVS",jl.FLOAT4,og.LIGHTS_PER_PASS)],1),Tg.layouts[Qg.NAME]=Qg.LAYOUT,Tg.bindings[Qg.BINDING]=Qg.DESCRIPTOR;var Zg=function(){};Zg.LIGHTS_PER_PASS=10;var $g=function(){};ag=$g,$g.JOINTS_TEXTURE_INFO_OFFSET=0,$g.COUNT=ag.JOINTS_TEXTURE_INFO_OFFSET+4,$g.SIZE=4*ag.COUNT,$g.NAME="CCSkinningTexture",$g.BINDING=Ag.UBO_SKINNING_TEXTURE,$g.DESCRIPTOR=new T_(ag.BINDING,Tc.UNIFORM_BUFFER,1,uc.VERTEX),$g.LAYOUT=new e_(Cg.LOCAL,ag.BINDING,ag.NAME,[new t_("cc_jointTextureInfo",jl.FLOAT4,1)],1),Tg.layouts[$g.NAME]=$g.LAYOUT,Tg.bindings[$g.BINDING]=$g.DESCRIPTOR;var ty=function(){};hg=ty,ty.JOINTS_ANIM_INFO_OFFSET=0,ty.COUNT=hg.JOINTS_ANIM_INFO_OFFSET+4,ty.SIZE=4*hg.COUNT,ty.NAME="CCSkinningAnimation",ty.BINDING=Ag.UBO_SKINNING_ANIMATION,ty.DESCRIPTOR=new T_(hg.BINDING,Tc.UNIFORM_BUFFER,1,uc.VERTEX),ty.LAYOUT=new e_(Cg.LOCAL,hg.BINDING,hg.NAME,[new t_("cc_jointAnimInfo",jl.FLOAT4,1)],1),Tg.layouts[ty.NAME]=ty.LAYOUT,Tg.bindings[ty.BINDING]=ty.DESCRIPTOR;var ey="a_jointAnimInfo",iy=function(){function t(){}return t.initLayout=function(e){t._jointUniformCapacity=e,t._count=12*e,t._size=4*t._count,t.LAYOUT.members[0].count=3*e},n(t,null,[{key:"JOINT_UNIFORM_CAPACITY",get:function(){return t._jointUniformCapacity}},{key:"COUNT",get:function(){return t._count}},{key:"SIZE",get:function(){return t._size}}]),t}();function ny(t){iy.initLayout(t),Tg.layouts[iy.NAME]=iy.LAYOUT,Tg.bindings[iy.BINDING]=iy.DESCRIPTOR}ug=iy,iy._jointUniformCapacity=0,iy._count=0,iy._size=0,iy.NAME="CCSkinning",iy.BINDING=Ag.UBO_SKINNING_TEXTURE,iy.DESCRIPTOR=new T_(ug.BINDING,Tc.UNIFORM_BUFFER,1,uc.VERTEX),iy.LAYOUT=new e_(Cg.LOCAL,ug.BINDING,ug.NAME,[new t_("cc_joints",jl.FLOAT4,1)],1);var ry=function(){};lg=ry,ry.MAX_MORPH_TARGET_COUNT=60,ry.OFFSET_OF_WEIGHTS=0,ry.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH=4*lg.MAX_MORPH_TARGET_COUNT,ry.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT=lg.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH+4,ry.OFFSET_OF_VERTICES_COUNT=lg.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT+4,ry.COUNT_BASE_4_BYTES=4*Math.ceil(lg.MAX_MORPH_TARGET_COUNT/4)+4,ry.SIZE=4*lg.COUNT_BASE_4_BYTES,ry.NAME="CCMorph",ry.BINDING=Ag.UBO_MORPH,ry.DESCRIPTOR=new T_(lg.BINDING,Tc.UNIFORM_BUFFER,1,uc.VERTEX),ry.LAYOUT=new e_(Cg.LOCAL,lg.BINDING,lg.NAME,[new t_("cc_displacementWeights",jl.FLOAT4,lg.MAX_MORPH_TARGET_COUNT/4),new t_("cc_displacementTextureInfo",jl.FLOAT4,1)],1),Tg.layouts[ry.NAME]=ry.LAYOUT,Tg.bindings[ry.BINDING]=ry.DESCRIPTOR;var sy=function(){};cg=sy,sy.NAME="CCUILocal",sy.BINDING=Ag.UBO_UI_LOCAL,sy.DESCRIPTOR=new T_(cg.BINDING,Tc.DYNAMIC_UNIFORM_BUFFER,1,uc.VERTEX),sy.LAYOUT=new e_(Cg.LOCAL,cg.BINDING,cg.NAME,[new t_("cc_local_data",jl.FLOAT4,1)],1),Tg.layouts[sy.NAME]=sy.LAYOUT,Tg.bindings[sy.BINDING]=sy.DESCRIPTOR;var oy=function(){};_g=oy,oy.SH_LINEAR_CONST_R_OFFSET=0,oy.SH_LINEAR_CONST_G_OFFSET=_g.SH_LINEAR_CONST_R_OFFSET+4,oy.SH_LINEAR_CONST_B_OFFSET=_g.SH_LINEAR_CONST_G_OFFSET+4,oy.SH_QUADRATIC_R_OFFSET=_g.SH_LINEAR_CONST_B_OFFSET+4,oy.SH_QUADRATIC_G_OFFSET=_g.SH_QUADRATIC_R_OFFSET+4,oy.SH_QUADRATIC_B_OFFSET=_g.SH_QUADRATIC_G_OFFSET+4,oy.SH_QUADRATIC_A_OFFSET=_g.SH_QUADRATIC_B_OFFSET+4,oy.COUNT=_g.SH_QUADRATIC_A_OFFSET+4,oy.SIZE=4*_g.COUNT,oy.NAME="CCSH",oy.BINDING=Ag.UBO_SH,oy.DESCRIPTOR=new T_(_g.BINDING,Tc.UNIFORM_BUFFER,1,uc.FRAGMENT),oy.LAYOUT=new e_(Cg.LOCAL,_g.BINDING,_g.NAME,[new t_("cc_sh_linear_const_r",jl.FLOAT4,1),new t_("cc_sh_linear_const_g",jl.FLOAT4,1),new t_("cc_sh_linear_const_b",jl.FLOAT4,1),new t_("cc_sh_quadratic_r",jl.FLOAT4,1),new t_("cc_sh_quadratic_g",jl.FLOAT4,1),new t_("cc_sh_quadratic_b",jl.FLOAT4,1),new t_("cc_sh_quadratic_a",jl.FLOAT4,1)],1),Tg.layouts[oy.NAME]=oy.LAYOUT,Tg.bindings[oy.BINDING]=oy.DESCRIPTOR;var ay=Ag.SAMPLER_JOINTS,hy=new T_(ay,Tc.SAMPLER_TEXTURE,1,uc.VERTEX),uy=new i_(Cg.LOCAL,ay,"cc_jointTexture",jl.SAMPLER2D,1);Tg.layouts.cc_jointTexture=uy,Tg.bindings[ay]=hy;var ly=Ag.SAMPLER_JOINTS,cy=new T_(ly,Tc.SAMPLER_TEXTURE,1,uc.VERTEX),_y=new i_(Cg.LOCAL,ly,"cc_realtimeJoint",jl.SAMPLER2D,1);Tg.layouts.cc_realtimeJoint=_y,Tg.bindings[ly]=cy;var dy=Ag.SAMPLER_MORPH_POSITION,fy=new T_(dy,Tc.SAMPLER_TEXTURE,1,uc.VERTEX),py=new i_(Cg.LOCAL,dy,"cc_PositionDisplacements",jl.SAMPLER2D,1);Tg.layouts.cc_PositionDisplacements=py,Tg.bindings[dy]=fy;var my=Ag.SAMPLER_MORPH_NORMAL,gy=new T_(my,Tc.SAMPLER_TEXTURE,1,uc.VERTEX),yy=new i_(Cg.LOCAL,my,"cc_NormalDisplacements",jl.SAMPLER2D,1);Tg.layouts.cc_NormalDisplacements=yy,Tg.bindings[my]=gy;var vy=Ag.SAMPLER_MORPH_TANGENT,Sy=new T_(vy,Tc.SAMPLER_TEXTURE,1,uc.VERTEX),Ty=new i_(Cg.LOCAL,vy,"cc_TangentDisplacements",jl.SAMPLER2D,1);Tg.layouts.cc_TangentDisplacements=Ty,Tg.bindings[vy]=Sy;var Ay=Ag.SAMPLER_LIGHTMAP,by=new T_(Ay,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),Ey=new i_(Cg.LOCAL,Ay,"cc_lightingMap",jl.SAMPLER2D,1);Tg.layouts.cc_lightingMap=Ey,Tg.bindings[Ay]=by;var Cy=Ag.SAMPLER_SPRITE,wy=new T_(Cy,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),xy=new i_(Cg.LOCAL,Cy,"cc_spriteTexture",jl.SAMPLER2D,1);Tg.layouts.cc_spriteTexture=xy,Tg.bindings[Cy]=wy;var Ry=Ag.SAMPLER_REFLECTION,Iy=new T_(Ry,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),By=new i_(Cg.LOCAL,Ry,"cc_reflectionTexture",jl.SAMPLER2D,1);Tg.layouts.cc_reflectionTexture=By,Tg.bindings[Ry]=Iy;var Dy=Ag.STORAGE_REFLECTION,Py=new T_(Dy,Tc.STORAGE_IMAGE,1,uc.COMPUTE),Oy=new s_(Cg.LOCAL,Dy,"cc_reflectionStorage",jl.IMAGE2D,1);Tg.layouts.cc_reflectionStorage=Oy,Tg.bindings[Dy]=Py;var My=Ag.SAMPLER_REFLECTION_PROBE_CUBE,Ly=new T_(My,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),Ny=new i_(Cg.LOCAL,My,"cc_reflectionProbeCubemap",jl.SAMPLER_CUBE,1);Tg.layouts.cc_reflectionProbeCubemap=Ny,Tg.bindings[My]=Ly;var Fy=Ag.SAMPLER_REFLECTION_PROBE_PLANAR,ky=new T_(Fy,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),Vy=new i_(Cg.LOCAL,Fy,"cc_reflectionProbePlanarMap",jl.SAMPLER2D,1);Tg.layouts.cc_reflectionProbePlanarMap=Vy,Tg.bindings[Fy]=ky;var Gy=Ag.SAMPLER_REFLECTION_PROBE_DATA_MAP,Uy=new T_(Gy,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),zy=new i_(Cg.LOCAL,Gy,"cc_reflectionProbeDataMap",jl.SAMPLER2D,1);Tg.layouts.cc_reflectionProbeDataMap=zy,Tg.bindings[Gy]=Uy;var Hy=Ag.SAMPLER_REFLECTION_PROBE_BLEND_CUBE,Wy=new T_(Hy,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT),jy=new i_(Cg.LOCAL,Hy,"cc_reflectionProbeBlendCubemap",jl.SAMPLER_CUBE,1);Tg.layouts.cc_reflectionProbeBlendCubemap=jy,Tg.bindings[Hy]=Wy;var Xy,qy,Yy,Ky=im.makeMaskExclude([im.BitMask.UI_2D,im.BitMask.GIZMOS,im.BitMask.EDITOR,im.BitMask.SCENE_GIZMO,im.BitMask.PROFILER]),Jy=im.makeMaskExclude([im.BitMask.UI_2D,im.BitMask.PROFILER]),Qy=im.Enum.ALL;function Zy(t){return(t.getFormatFeatures(Hl.R32F)&($l.RENDER_TARGET|$l.SAMPLED_TEXTURE))==($l.RENDER_TARGET|$l.SAMPLED_TEXTURE)&&!(t.gfxAPI===Gl.WEBGL)}function $y(t){return(t.getFormatFeatures(Hl.RGBA16F)&($l.RENDER_TARGET|$l.SAMPLED_TEXTURE))==($l.RENDER_TARGET|$l.SAMPLED_TEXTURE)&&!(t.gfxAPI===Gl.WEBGL)}function tv(){return!(!v.rendering||!v.rendering.enableEffectImport)}t("d7",Object.freeze({__proto__:null,PIPELINE_FLOW_MAIN:mg,PIPELINE_FLOW_FORWARD:gg,PIPELINE_FLOW_SHADOW:yg,PIPELINE_FLOW_SMAA:"SMAAFlow",PIPELINE_FLOW_TONEMAP:"ToneMapFlow",get RenderPassStage(){return fg},get RenderPriority(){return pg},globalDescriptorSetLayout:Sg,localDescriptorSetLayout:Tg,get PipelineGlobalBindings(){return vg},get ModelLocalBindings(){return Ag},get SetIndex(){return Cg},bindingMappingInfo:Ig,UBOGlobal:Bg,UBOCamera:Dg,UBOShadow:Pg,UBOCSM:Og,UNIFORM_SHADOWMAP_BINDING:Mg,UNIFORM_ENVIRONMENT_BINDING:Fg,UNIFORM_DIFFUSEMAP_BINDING:Gg,UNIFORM_SPOT_SHADOW_MAP_TEXTURE_BINDING:Hg,UBOLocal:Xg,UBOWorldBound:qg,INST_MAT_WORLD:Yg,INST_SH:Kg,UBOLocalBatched:Jg,UBOForwardLight:Qg,UBODeferredLight:Zg,JOINT_UNIFORM_CAPACITY:30,UBOSkinningTexture:$g,UBOSkinningAnimation:ty,INST_JOINT_ANIM_INFO:ey,UBOSkinning:iy,localDescriptorSetLayout_ResizeMaxJoints:ny,UBOMorph:ry,UBOUILocal:sy,UBOSH:oy,UNIFORM_JOINT_TEXTURE_BINDING:ay,UNIFORM_REALTIME_JOINT_TEXTURE_BINDING:ly,UNIFORM_POSITION_MORPH_TEXTURE_BINDING:dy,UNIFORM_NORMAL_MORPH_TEXTURE_BINDING:my,UNIFORM_TANGENT_MORPH_TEXTURE_BINDING:vy,UNIFORM_LIGHTMAP_TEXTURE_BINDING:Ay,UNIFORM_SPRITE_TEXTURE_BINDING:Cy,UNIFORM_REFLECTION_TEXTURE_BINDING:Ry,UNIFORM_REFLECTION_STORAGE_BINDING:Dy,UNIFORM_REFLECTION_PROBE_CUBEMAP_BINDING:My,UNIFORM_REFLECTION_PROBE_TEXTURE_BINDING:Fy,UNIFORM_REFLECTION_PROBE_DATA_MAP_BINDING:Gy,UNIFORM_REFLECTION_PROBE_BLEND_CUBEMAP_BINDING:Hy,CAMERA_DEFAULT_MASK:Ky,CAMERA_EDITOR_MASK:Jy,MODEL_ALWAYS_MASK:Qy,supportsR16HalfFloatTexture:function(t){return(t.getFormatFeatures(Hl.R16F)&($l.RENDER_TARGET|$l.SAMPLED_TEXTURE))==($l.RENDER_TARGET|$l.SAMPLED_TEXTURE)},supportsR32FloatTexture:Zy,supportsRGBA16HalfFloatTexture:$y,supportsRGBA32FloatTexture:function(t){return(t.getFormatFeatures(Hl.RGBA32F)&($l.RENDER_TARGET|$l.SAMPLED_TEXTURE))==($l.RENDER_TARGET|$l.SAMPLED_TEXTURE)&&!(t.gfxAPI===Gl.WEBGL)},isEnableEffect:tv}));var ev=4227858432,iv=66060288,nv=1044480,rv=function(t,e,i,n){return void 0===n&&(n=0),e<<26&ev|t<<20&iv|i<<12&nv|4095&n},sv=function(t){return(t&ev)>>>26},ov=function(t){return(t&iv)>>>20},av=function(t){return(t&nv)>>>12},hv=function(t){return 4095&t},uv=function(t,e){return 67108863&t|e<<26&ev},lv=((Xy={})[jl.UNKNOWN]=function(t,e,i){return void 0===i&&(i=0),Y(12010,i)},Xy[jl.INT]=function(t,e,i){return void 0===i&&(i=0),t[i]},Xy[jl.INT2]=function(t,e,i){return void 0===i&&(i=0),Ln.fromArray(e,t,i)},Xy[jl.INT3]=function(t,e,i){return void 0===i&&(i=0),on.fromArray(e,t,i)},Xy[jl.INT4]=function(t,e,i){return void 0===i&&(i=0),tn.fromArray(e,t,i)},Xy[jl.FLOAT]=function(t,e,i){return void 0===i&&(i=0),t[i]},Xy[jl.FLOAT2]=function(t,e,i){return void 0===i&&(i=0),Ln.fromArray(e,t,i)},Xy[jl.FLOAT3]=function(t,e,i){return void 0===i&&(i=0),on.fromArray(e,t,i)},Xy[jl.FLOAT4]=function(t,e,i){return void 0===i&&(i=0),tn.fromArray(e,t,i)},Xy[jl.MAT3]=function(t,e,i){return void 0===i&&(i=0),mn.fromArray(e,t,i)},Xy[jl.MAT4]=function(t,e,i){return void 0===i&&(i=0),In.fromArray(e,t,i)},Xy),cv=((qy={})[jl.UNKNOWN]=function(t,e,i){return void 0===i&&(i=0),Y(12010,i)},qy[jl.INT]=function(t,e,i){return void 0===i&&(i=0),t[i]=e},qy[jl.INT2]=function(t,e,i){return void 0===i&&(i=0),Ln.toArray(t,e,i)},qy[jl.INT3]=function(t,e,i){return void 0===i&&(i=0),on.toArray(t,e,i)},qy[jl.INT4]=function(t,e,i){return void 0===i&&(i=0),tn.toArray(t,e,i)},qy[jl.FLOAT]=function(t,e,i){return void 0===i&&(i=0),t[i]=e},qy[jl.FLOAT2]=function(t,e,i){return void 0===i&&(i=0),Ln.toArray(t,e,i)},qy[jl.FLOAT3]=function(t,e,i){return void 0===i&&(i=0),on.toArray(t,e,i)},qy[jl.FLOAT4]=function(t,e,i){return void 0===i&&(i=0),tn.toArray(t,e,i)},qy[jl.MAT3]=function(t,e,i){return void 0===i&&(i=0),mn.toArray(t,e,i)},qy[jl.MAT4]=function(t,e,i){return void 0===i&&(i=0),In.toArray(t,e,i)},qy),_v=((Yy={})[jl.INT]=function(t){return"number"==typeof t},Yy[jl.FLOAT]=function(t){return"number"==typeof t},Yy[jl.INT2]=function(t){return!!(t instanceof Ln)},Yy[jl.FLOAT2]=function(t){return!!(t instanceof Ln)},Yy[jl.INT3]=function(t){return!!(t instanceof on)},Yy[jl.FLOAT3]=function(t){return!!(t instanceof on)},Yy[jl.INT4]=function(t){return!!(t instanceof tn)},Yy[jl.FLOAT4]=function(t){return!!(t instanceof tn||t instanceof dn||t instanceof Sn)},Yy[jl.MAT3]=function(t){return!!(t instanceof mn)},Yy[jl.MAT4]=function(t){return!!(t instanceof In)},Yy),dv=[Object.freeze([0]),Object.freeze([0,0]),Object.freeze([0,0,0,0]),Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])];function fv(t){switch(t){case jl.BOOL:case jl.INT:case jl.UINT:case jl.FLOAT:return dv[0];case jl.BOOL2:case jl.INT2:case jl.UINT2:case jl.FLOAT2:return dv[1];case jl.BOOL4:case jl.INT4:case jl.UINT4:case jl.FLOAT4:return dv[2];case jl.MAT4:return dv[3];case jl.SAMPLER2D:return"default-texture";case jl.SAMPLER_CUBE:return"default-cube-texture";case jl.SAMPLER2D_ARRAY:return"default-array-texture";case jl.SAMPLER3D:return"default-3d-texture"}return dv[0]}function pv(t){switch(t){case jl.SAMPLER2D:return"-texture";case jl.SAMPLER_CUBE:return"-cube-texture";case jl.SAMPLER2D_ARRAY:return"-array-texture";case jl.SAMPLER3D:return"-3d-texture";default:return"-unknown"}}function mv(t,e){for(var i=Object.entries(e),n=!1,r=0;r<i.length;r++)t[i[r][0]]!==i[r][1]&&(t[i[r][0]]=i[r][1],n=!0);return n}function gv(t,e){switch(t.type){case"boolean":return"number"==typeof e?e.toString():e?"1":"0";case"string":return void 0!==e?e:t.options[0];case"number":return void 0!==e?e.toString():t.range[0].toString();default:return console.warn("unknown define type '"+t.type+"'"),"-1"}}function yv(t,e){for(var i=0;i<t.length;i++){var n=t[i];if("!"===n[0]){if(e[n.slice(1)])return!1}else if(!e[n])return!1}return!0}var vv=new Map;function Sv(t,e){if(e.count)return t+z_(e.type)*e.count;var i=vv.get(e.name);return void 0!==i?t+z_(e.type)*i:(console.error("uniform '"+e.name+"' must have a count"),t)}function Tv(t){return Math.ceil(Math.log2(Math.max(t,2)))}vv.set("cc_joints",iy.LAYOUT.members[0].count),vv.set("cc_lightPos",Qg.LIGHTS_PER_PASS),vv.set("cc_lightColor",Qg.LIGHTS_PER_PASS),vv.set("cc_lightSizeRangeAngle",Qg.LIGHTS_PER_PASS),vv.set("cc_lightDir",Qg.LIGHTS_PER_PASS),vv.set("cc_lightBoundingSizeVS",Qg.LIGHTS_PER_PASS);var Av=new A_;function bv(t,e,i,n,r){for(var s=t.builtins[n],o=[],a=function(){var t=s.blocks[h],e=i.layouts[t.name],n=e&&i.bindings.find((function(t){return t.binding===e.binding}));if(!(e&&n&&n.descriptorType&L_))return console.warn("builtin UBO '"+t.name+"' not available!"),1;o.push(e),r&&!r.includes(n)&&r.push(n)},h=0;h<s.blocks.length;h++)a();Array.prototype.unshift.apply(e.shaderInfo.blocks,o);for(var u=[],l=function(){var t=s.samplerTextures[c],e=i.layouts[t.name],n=e&&i.bindings.find((function(t){return t.binding===e.binding}));if(!(e&&n&&n.descriptorType&N_))return console.warn("builtin samplerTexture '"+t.name+"' not available!"),1;u.push(e),r&&!r.includes(n)&&r.push(n)},c=0;c<s.samplerTextures.length;c++)l();Array.prototype.unshift.apply(e.shaderInfo.samplerTextures,u),r&&r.sort((function(t,e){return t.binding-e.binding}))}function Ev(t){switch(t.gfxAPI){case Gl.GLES2:case Gl.WEBGL:return"glsl1";case Gl.GLES3:case Gl.WEBGL2:return"glsl3";default:return"glsl4"}}var Cv,wv,xv,Rv,Iv,Bv,Dv,Pv=new(function(){function t(){this._templates={},this._cache={},this._templateInfos={}}var e=t.prototype;return e.register=function(t){for(var e=0;e<t.shaders.length;e++)this.define(t.shaders[e]).effectName=t.name;for(var i=0;i<t.techniques.length;i++)for(var n=t.techniques[i],r=0;r<n.passes.length;r++){var s=n.passes[r];void 0!==s.propertyIndex&&void 0===s.properties&&(s.properties=n.passes[s.propertyIndex].properties)}},e.define=function(t){var e=this._templates[t.name];if(e&&e.hash===t.hash)return e;var i=r({},t);if(function(t){for(var e=0,i=function(){var i=t.defines[n],r=1;if("number"===i.type){var s=i.range;r=Tv(s[1]-s[0]+1),i._map=function(t){return t-s[0]}}else"string"===i.type?(r=Tv(i.options.length),i._map=function(t){return Math.max(0,i.options.findIndex((function(e){return e===t})))}):"boolean"===i.type&&(i._map=function(t){return t?1:0});i._offset=e,e+=r},n=0;n<t.defines.length;n++)i();for(var r in e>31&&(t.uber=!0),t.constantMacros="",t.builtins.statistics)t.constantMacros+="#define "+r+" "+t.builtins.statistics[r]+"\n"}(i),this._templates[t.name]=i,!this._templateInfos[i.hash]){var n={};n.samplerStartBinding=i.blocks.length,n.shaderInfo=new l_,n.blockSizes=[],n.bindings=[];for(var s=0;s<i.blocks.length;s++){var o=i.blocks[s];n.blockSizes.push(o.members.reduce(Sv,0)),n.bindings.push(new T_(o.binding,Tc.UNIFORM_BUFFER,1,o.stageFlags)),n.shaderInfo.blocks.push(new e_(Cg.MATERIAL,o.binding,o.name,o.members.map((function(t){return new t_(t.name,t.type,t.count)})),1))}for(var a=0;a<i.samplerTextures.length;a++){var h=i.samplerTextures[a];n.bindings.push(new T_(h.binding,Tc.SAMPLER_TEXTURE,h.count,h.stageFlags)),n.shaderInfo.samplerTextures.push(new i_(Cg.MATERIAL,h.binding,h.name,h.type,h.count))}for(var u=0;u<i.samplers.length;u++){var l=i.samplers[u];n.bindings.push(new T_(l.binding,Tc.SAMPLER,l.count,l.stageFlags)),n.shaderInfo.samplers.push(new n_(Cg.MATERIAL,l.binding,l.name,l.count))}for(var c=0;c<i.textures.length;c++){var _=i.textures[c];n.bindings.push(new T_(_.binding,Tc.TEXTURE,_.count,_.stageFlags)),n.shaderInfo.textures.push(new r_(Cg.MATERIAL,_.binding,_.name,_.type,_.count))}for(var d=0;d<i.buffers.length;d++){var f=i.buffers[d];n.bindings.push(new T_(f.binding,Tc.STORAGE_BUFFER,1,f.stageFlags)),n.shaderInfo.buffers.push(new o_(Cg.MATERIAL,f.binding,f.name,1,f.memoryAccess))}for(var p=0;p<i.images.length;p++){var m=i.images[p];n.bindings.push(new T_(m.binding,Tc.STORAGE_IMAGE,m.count,m.stageFlags)),n.shaderInfo.images.push(new s_(Cg.MATERIAL,m.binding,m.name,m.type,m.count,m.memoryAccess))}for(var g=0;g<i.subpassInputs.length;g++){var y=i.subpassInputs[g];n.bindings.push(new T_(y.binding,Tc.INPUT_ATTACHMENT,y.count,y.stageFlags)),n.shaderInfo.subpassInputs.push(new a_(Cg.MATERIAL,y.binding,y.name,y.count))}n.gfxAttributes=[];for(var v=0;v<i.attributes.length;v++){var S=i.attributes[v];n.gfxAttributes.push(new u_(S.name,S.format,S.isNormalized,0,S.isInstanced,S.location))}bv(i,n,Tg,"locals"),n.shaderInfo.stages.push(new h_(uc.VERTEX,"")),n.shaderInfo.stages.push(new h_(uc.FRAGMENT,"")),n.handleMap=function(t){for(var e={},i=0;i<t.blocks.length;i++)for(var n=t.blocks[i],r=n.members,s=0,o=0;o<r.length;o++){var a=r[o];e[a.name]=rv(n.binding,a.type,a.count,s),s+=(z_(a.type)>>2)*a.count}for(var h=0;h<t.samplerTextures.length;h++){var u=t.samplerTextures[h];e[u.name]=rv(u.binding,u.type,u.count)}return e}(i),n.setLayouts=[],this._templateInfos[i.hash]=n}return i},e.getTemplate=function(t){return this._templates[t]},e.getTemplateInfo=function(t){var e=this._templates[t].hash;return this._templateInfos[e]},e.getDescriptorSetLayout=function(t,e,i){void 0===i&&(i=!1);var n=this._templates[e],r=this._templateInfos[n.hash];return r.setLayouts.length||(Av.bindings=r.bindings,r.setLayouts[Cg.MATERIAL]=t.createDescriptorSetLayout(Av),Av.bindings=Tg.bindings,r.setLayouts[Cg.LOCAL]=t.createDescriptorSetLayout(Av)),r.setLayouts[i?Cg.LOCAL:Cg.MATERIAL]},e.hasProgram=function(t){return void 0!==this._templates[t]},e.getKey=function(t,e){return function(t,e){var i=t.defines;if(t.uber){for(var n="",r=0;r<i.length;r++){var s=i[r],o=e[s.name];if(o&&s._map){var a=s._map(o);n+=""+s._offset+a+"|"}}return""+n+t.hash}for(var h=0,u=0;u<i.length;u++){var l=i[u],c=e[l.name];c&&l._map&&(h|=l._map(c)<<l._offset)}return h.toString(16)+"|"+t.hash}(this._templates[t],e)},e.destroyShaderByDefines=function(t){var e=this,i=Object.keys(t);if(i.length)for(var n=i.map((function(e){var i=t[e];return"boolean"==typeof i&&(i=i?"1":"0"),new RegExp(""+e+i)})),r=Object.keys(this._cache).filter((function(t){return n.every((function(i){return i.test(e._cache[t].name)}))})),s=0;s<r.length;s++){var o=r[s],a=this._cache[o];U("destroyed shader "+a.name),a.destroy(),delete this._cache[o]}},e.getGFXShader=function(t,e,i,n,r){Object.assign(i,n.macros),r||(r=this.getKey(e,i));var s=this._cache[r];if(s)return s;var o=this._templates[e],a=this._templateInfos[o.hash];a.pipelineLayout||(this.getDescriptorSetLayout(t,e),bv(o,a,Sg,"globals"),a.setLayouts[Cg.GLOBAL]=n.descriptorSetLayout,a.pipelineLayout=t.createPipelineLayout(new E_(a.setLayouts)));var h=function(t,e){for(var i=[],n=0;n<e.length;n++){var r=e[n],s=r.name,o=t[s],a=gv(r,o),h=!o||"0"===o;i.push({name:s,value:a,isDefault:h})}return i}(i,o.defines),u=n.constantMacros+o.constantMacros+h.reduce((function(t,e){return t+"#define "+e.name+" "+e.value+"\n"}),""),l=o.glsl3,c=Ev(t);c?l=o[c]:console.error("Invalid GFX API!"),a.shaderInfo.stages[0].source=u+l.vert,a.shaderInfo.stages[1].source=u+l.frag,a.shaderInfo.attributes=function(t,e,i){for(var n=[],r=t.attributes,s=0;s<r.length;s++)yv(r[s].defines,i)&&n.push(e[s]);return n}(o,a.gfxAttributes,i),a.shaderInfo.name=function(t,e){return t+e.reduce((function(t,e){return e.isDefault?t:t+"|"+e.name+e.value}),"")}(e,h);var _=a.shaderInfo;return this._cache[r]=t.createShader(_)},t}());v.programLib=Pv;var Ov=["planar-shadow","skybox","deferred-lighting","bloom","hbao","copy-pass","post-process","profiler","splash-screen","unlit","sprite","particle","particle-gpu","particle-trail","billboard","terrain","graphics","clear-stencil","spine","occlusion-query","geometry-renderer","debug-renderer","ssss-blur","float-output-process"],Mv=t("eh",qs("cc.EffectAsset")(((Dv=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).techniques=xv&&xv(),e.shaders=Rv&&Rv(),e.combinations=Iv&&Iv(),e.hideInEditor=Bv&&Bv(),e}s(e,t),e.register=function(t){e._effects[t.name]=t,e._layoutValid=!1},e.remove=function(t){if("string"!=typeof t)e._effects[t.name]&&e._effects[t.name]===t&&delete e._effects[t.name];else{if(e._effects[t])return void delete e._effects[t];for(var i in e._effects)if(e._effects[i]._uuid===t)return void delete e._effects[i]}},e.get=function(t){if(e._effects[t])return e._effects[t];for(var i in e._effects)if(e._effects[i]._uuid===t)return e._effects[i];return Ov.includes(t)&&Y(16101,t),null},e.getAll=function(){return e._effects},e.isLayoutValid=function(){return e._layoutValid},e.setLayoutValid=function(){e._layoutValid=!0};var i=e.prototype;return i.onLoaded=function(){if(v.rendering&&v.rendering.enableEffectImport){!function(t){for(var e=0;e<t.techniques.length;e++)for(var i=t.techniques[e],n=0;n<i.passes.length;n++){var r=i.passes[n];void 0!==r.propertyIndex&&void 0===r.properties&&(r.properties=i.passes[r.propertyIndex].properties)}}(this);var t=v.rendering.programLib;t.addEffect(this),t.init(Ed.gfxDevice)}else Pv.register(this);e.register(this),v.game.once(v.Game.EVENT_RENDERER_INITED,this._precompile,this)},i._precompile=function(){var t=this;if(v.rendering&&v.rendering.enableEffectImport)v.rendering.programLib.precompileEffect(Ed.gfxDevice,this);else for(var e=v.director.root,i=function(){var i=t.shaders[n],s=t.combinations[n];if(!s)return 1;(function(t){return Object.keys(t).reduce((function(e,i){return e.reduce((function(e,n){for(var s=t[i],o=0;o<s.length;++o){var a=r({},n);a[i]=s[o],e.push(a)}return e}),[])}),[{}])})(s).forEach((function(t){return Pv.getGFXShader(Ed.gfxDevice,i.name,t,e.pipeline)}))},n=0;n<this.shaders.length;n++)i()},i.destroy=function(){return e.remove(this),t.prototype.destroy.call(this)},i.initDefault=function(i){t.prototype.initDefault.call(this,i);var n=e.get("builtin-unlit");this.name="builtin-unlit",this.shaders=n.shaders,this.combinations=n.combinations,this.techniques=n.techniques},i.validate=function(){return this.techniques.length>0&&this.shaders.length>0},e}(of))._effects={},Dv._layoutValid=!0,xv=ks((wv=Dv).prototype,"techniques",[io],(function(){return[]})),Rv=ks(wv.prototype,"shaders",[io],(function(){return[]})),Iv=ks(wv.prototype,"combinations",[io],(function(){return[]})),Bv=ks(wv.prototype,"hideInEditor",[io,ro],(function(){return!1})),Cv=wv))||Cv);v.EffectAsset=Mv;var Lv=function(){function t(){this.name="",this.base="",this.importBase="",this.nativeBase="",this.deps=null,this.assetInfos=new Rd,this.scenes=new Rd,this.paths=new Rd}var e=t.prototype;return e.init=function(t){var e=this;!function(t){var e=t.uuids,i=t.paths,n=t.types,r=t.deps,s=t.paths=Object.create(null);if(!1===t.debug){for(var o=0,a=e.length;o<a;o++)e[o]=Xd(e[o]);for(var h in i){var u=i[h],l=u[1];u[1]=n[l]}}else{for(var c=Object.create(null),_=0,d=e.length;_<d;_++){var f=e[_];e[_]=c[f]=Xd(f)}e=c}for(var p in i){var m=i[p];s[e[p]]=m}var g=t.scenes;for(var y in g){var v=g[y];g[y]=e[v]}var S=t.packs;for(var T in S)for(var A=S[T],b=0;b<A.length;++b)A[b]=e[A[b]];var E=t.versions;if(E)for(var C in E)for(var w=E[C],x=0;x<w.length;x+=2){var R=w[x];w[x]=e[R]||R}var I=t.redirect;if(I)for(var B=0;B<I.length;B+=2)I[B]=e[I[B]],I[B+1]=r[I[B+1]];if(t.extensionMap){var D=function(i){if(!Object.prototype.hasOwnProperty.call(t.extensionMap,i))return 1;t.extensionMap[i].forEach((function(n,r){t.extensionMap[i][r]=e[n]||n}))};for(var P in t.extensionMap)D(P)}}(t),this.importBase=t.importBase||"",this.nativeBase=t.nativeBase||"",this.base=t.base||"",this.name=t.name||"",this.deps=t.deps||[],this._initUuid(t.uuids),this._initPath(t.paths),this._initScene(t.scenes),this._initPackage(t.packs),this._initVersion(t.versions),this._initRedirect(t.redirect);var i=function(i){if(!Object.prototype.hasOwnProperty.call(t.extensionMap,i))return 1;t.extensionMap[i].forEach((function(t){var n=e.assetInfos.get(t);n&&(n.extension=i)}))};for(var n in t.extensionMap)i(n)},e.getInfoWithPath=function(t,e){if(!t)return null;t=Qd(t);var i=this.paths.get(t);if(i){if(!e)return i[0];for(var n=0,r=i.length;n<r;n++){var s=i[n];if(Ht(s.ctor,e))return s}}return null},e.getDirWithPath=function(t,e,i){"/"===(t=Qd(t))[t.length-1]&&(t=t.slice(0,-1));var n=i||[];return this.paths.forEach((function(i,r){if(r.startsWith(t)&&function(t,e){return!(t.length>e.length)||47===t.charCodeAt(e.length)}(r,t)||!t)for(var s=0,o=i.length;s<o;s++){var a=i[s];e&&!Ht(a.ctor,e)||n.push(a)}})),n},e.getAssetInfo=function(t){return this.assetInfos.get(t)||null},e.getSceneInfo=function(t){return t.endsWith(".scene")||(t+=".scene"),"/"===t[0]||t.startsWith("db://")||(t="/"+t),this.scenes.find((function(e,i){return i.endsWith(t)}))},e.destroy=function(){this.paths.destroy(),this.scenes.destroy(),this.assetInfos.destroy()},e._initUuid=function(t){if(t){this.assetInfos.clear();for(var e=0,i=t.length;e<i;e++){var n=t[e];this.assetInfos.add(n,{uuid:n})}}},e._initPath=function(t){if(t){var e=this.paths;for(var i in e.clear(),t){var n=t[i],r=n[0],s=n[1],o=3===n.length,a=this.assetInfos.get(i);a.path=r,a.ctor=te(s),e.has(r)?o?e.get(r).push(a):e.get(r).unshift(a):e.add(r,[a])}}},e._initScene=function(t){if(t){var e=this.scenes;e.clear();var i=this.assetInfos;for(var n in t){var r=t[n],s=i.get(r);s.url=n,e.add(n,s)}}},e._initPackage=function(t){if(t){var e=this.assetInfos;for(var i in t){var n=t[i],r={uuid:i,packedUuids:n,ext:".json"};e.add(i,r);for(var s=0,o=n.length;s<o;s++){var a=n[s],h=e.get(a),u=h.packs;u?1===o?u.unshift(r):u.push(r):h.packs=[r]}}}},e._initVersion=function(t){if(t){var e=this.assetInfos,i=t.import;if(i)for(var n=0,r=i.length;n<r;n+=2){var s=i[n];e.get(s).ver=i[n+1]}if(i=t.native)for(var o=0,a=i.length;o<a;o+=2){var h=i[o];e.get(h).nativeVer=i[o+1]}}},e._initRedirect=function(t){if(t)for(var e=this.assetInfos,i=0,n=t.length;i<n;i+=2){var r=t[i];e.get(r).redirect=t[i+1]}},t}();function Nv(t,e){t._uuid&&e.push(t._uuid)}function Fv(t,e){for(var i=Object.getOwnPropertyNames(t),n=0;n<i.length;n++){var r=i[n];if("node"!==r&&"__eventTargets"!==r){var s=t[r];if("object"==typeof s&&s)if(Array.isArray(s))for(var o=0;o<s.length;o++){var a=s[o];a instanceof of&&Nv(a,e)}else if(s.constructor&&s.constructor!==Object)s instanceof of&&Nv(s,e);else for(var h=Object.getOwnPropertyNames(s),u=0;u<h.length;u++){var l=s[h[u]];l instanceof of&&Nv(l,e)}}}}function kv(t,e){for(var i=0;i<t._components.length;i++)Fv(t._components[i],e);for(var n=0;n<t._children.length;n++)kv(t._children[n],e)}function Vv(t,e,i,n){i.push(t._uuid);for(var r=Hp.getDeps(t._uuid),s=0,o=r.length;s<o;s++){var a=Dd.get(r[s]);if(a){var h=a._uuid;h in e?e[h]+=n:e[h]=a.refCount+n,i.includes(h)||Vv(a,e,i,n)}}}var Gv=[],Uv=new(function(){function t(){this._persistNodeDeps=new Rd,this._toDelete=new Rd,this._eventListener=!1,this._dontDestroyAssets=[]}var e=t.prototype;return e.addIgnoredAsset=function(t){this._dontDestroyAssets.push(t._uuid)},e.init=function(){this._persistNodeDeps.clear(),this._toDelete.clear()},e._addPersistNodeRef=function(t){var e=[];kv(t,e);for(var i=0,n=e.length;i<n;i++){var r=Dd.get(e[i]);r&&r.addRef()}this._persistNodeDeps.add(t.uuid,e)},e._removePersistNodeRef=function(t){if(this._persistNodeDeps.has(t.uuid)){for(var e=this._persistNodeDeps.get(t.uuid),i=0,n=e.length;i<n;i++){var r=Dd.get(e[i]);r&&r.decRef()}this._persistNodeDeps.remove(t.uuid)}},e._autoRelease=function(t,e,i){if(t){for(var n=Hp.getDeps(t.uuid),r=0,s=n.length;r<s;r++){var o=Dd.get(n[r]);o&&o.decRef(t.autoReleaseAssets)}var a=Hp._depends.get(t.uuid);if(a&&a.persistDeps)for(var h=a.persistDeps,u=0,l=h.length;u<l;u++){var c=Dd.get(h[u]);c&&c.decRef(t.autoReleaseAssets)}t.uuid!==e.uuid&&Hp.remove(t.uuid)}var _=Hp._depends.get(e.uuid);for(var f in _&&(_.persistDeps=[]),i){for(var p,m,g=i[f],y=this._persistNodeDeps.get(g.uuid),v=d(y);!(m=v()).done;){var S=m.value,T=Dd.get(S);T&&T.addRef()}_&&(p=_.persistDeps).push.apply(p,y)}},e.tryRelease=function(t,e){void 0===e&&(e=!1),t instanceof of&&(e?this._free(t,e):(this._toDelete.add(t._uuid,t),this._eventListener||(this._eventListener=!0,Le(this._freeAssets.bind(this)))))},e._freeAssets=function(){var t=this;this._eventListener=!1,this._toDelete.forEach((function(e){t._free(e)})),this._toDelete.clear()},e._free=function(t,e){void 0===e&&(e=!1);var i=t._uuid;if(this._toDelete.remove(i),jo(t,!0)&&-1===this._dontDestroyAssets.indexOf(i)&&!(!e&&t.refCount>0&&function(t){var e=Object.create(null);if(e[t._uuid]=t.refCount,Vv(t,e,Gv,-1),Gv.length=0,0!==e[t._uuid])return e[t._uuid];for(var i in e)0!==e[i]&&Vv(Dd.get(i),e,Gv,1);return Gv.length=0,e[t._uuid]}(t)>0)){Dd.remove(i);for(var n=Hp.getDeps(i),r=0,s=n.length;r<s;r++){var o=Dd.get(n[r]);o&&(o.decRef(!1),this._free(o,!1))}t.destroy(),Hp.remove(i)}},t}()),zv=null;function Hv(t,e){for(var i=0,n=t.input.length;i<n;i++){var r=t.input[i];e&&!r.isNative&&r.content instanceof of&&r.content.decRef(!1),r.recycle()}t.input=null}function Wv(t,e){return e?/\?/.test(t)?t+"&_t="+Date.now():t+"?_t="+Date.now():t}function jv(t,e,i,n,r){void 0===r&&(r=0),t(r,(function(s,o){r++,!s||r>e?n&&n(s,o):setTimeout((function(){jv(t,e,i,n,r)}),i)}))}function Xv(t,e,i,n,s){try{for(var o=Hp.parse(t,e),a=0,h=o.deps.length;a<h;a++){var u=o.deps[a];u in i||(i[u]=!0,n.push({uuid:u,bundle:s&&s.name}))}o.nativeDep&&(s&&(o.nativeDep.bundle=s.name),n.push(r({},o.nativeDep)))}catch(t){V(t.message,t.stack)}}function qv(t,e,i){e&&(i=void 0!==i?i:v.assetManager.cacheAsset,Jd(e)||!i||e.isDefault||Dd.add(t,e))}function Yv(t,e,i){var n=0,r=[],s=t.length;0===s&&i&&i(r);for(var o=function(t){t&&r.push(t),++n===s&&i&&i(r)},a=0;a<s;a++)e(t[a],o)}function Kv(t,e,i){var n=t,r=e,s=i;if(void 0===i){var o="function"==typeof t;e?(s=e,o||(r=null)):void 0===e&&o&&(s=t,n=null,r=null),void 0!==e&&o&&(r=t,n=null)}return{options:n||Object.create(null),onProgress:r,onComplete:s}}function Jv(t,e,i){var n=t,r=e,s=i;if(void 0===i){var o=Ht(t,of);e?(s=e,o&&(r=null)):void 0!==e||o||(s=t,r=null,n=null),void 0===e||o||(r=t,n=null)}return{type:n,onProgress:r||zv,onComplete:s}}function Qv(t,e,i,n){if(void 0===n&&(n={}),!i[e]||n[e])return!1;n[e]=!0;var r=!1,s=Hp.getDeps(e);if(s)for(var o=0,a=s.length;o<a;o++){var h=s[o];if(h===t||Qv(t,h,i,n)){r=!0;break}}return r}function Zv(t){return function(e,i){if(t){var n=[];Array.isArray(i)?i.forEach((function(t){return t instanceof of&&n.push(t.addRef())})):i instanceof of&&n.push(i.addRef()),Le((function(){n.forEach((function(t){return t.decRef(!1)})),t(e,i)}))}}}var $v=function(){function t(){this._config=new Lv}var e=t.prototype;return e.getInfoWithPath=function(t,e){return this._config.getInfoWithPath(t,e)},e.getDirWithPath=function(t,e,i){return this._config.getDirWithPath(t,e,i)},e.getAssetInfo=function(t){return this._config.getAssetInfo(t)},e.getSceneInfo=function(t){return this._config.getSceneInfo(t)},e.init=function(t){this._config.init(t),Md.add(t.name,this)},e.load=function(t,e,i,n){var r=Jv(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete,h={__requestType__:Bd.PATH,type:s,bundle:this.name,__outputAsArray__:Array.isArray(t)};v.assetManager.loadAny(t,h,o,a)},e.preload=function(t,e,i,n){var r=Jv(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete;v.assetManager.preloadAny(t,{__requestType__:Bd.PATH,type:s,bundle:this.name},o,a)},e.loadDir=function(t,e,i,n){var r=Jv(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete;v.assetManager.loadAny(t,{__requestType__:Bd.DIR,type:s,bundle:this.name,__outputAsArray__:!0},o,a)},e.preloadDir=function(t,e,i,n){var r=Jv(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete;v.assetManager.preloadAny(t,{__requestType__:Bd.DIR,type:s,bundle:this.name},o,a)},e.loadScene=function(t,e,i,n){var r=Kv(e,i,n),s=r.options,o=r.onProgress,a=r.onComplete;s.preset=s.preset||"scene",s.bundle=this.name,v.assetManager.loadAny({scene:t},s,o,(function(t,e){if(t)V(t.message,t.stack);else if(e.scene){var i=e.scene;i._id=e._uuid,i.name=e.name}else t=new Error("The asset "+e._uuid+" is not a scene");a&&a(t,e)}))},e.preloadScene=function(t,e,i,n){var r=Kv(e,i,n),s=r.options,o=r.onProgress,a=r.onComplete;s.bundle=this.name,v.assetManager.preloadAny({scene:t},s,o,(function(e){e&&J(1210,t,e.message),a&&a(e)}))},e.get=function(t,e){var i=this.getInfoWithPath(t,e);return i&&Dd.get(i.uuid)||null},e.release=function(t,e){var i=this.get(t,e);i&&Uv.tryRelease(i,!0)},e.releaseUnusedAssets=function(){var t=this;Dd.forEach((function(e){var i=t.getAssetInfo(e._uuid);i&&!i.redirect&&Uv.tryRelease(e)}))},e.releaseAll=function(){var t=this;Dd.forEach((function(e){var i=t.getAssetInfo(e._uuid);i&&!i.redirect&&Uv.tryRelease(e,!0)}))},e._destroy=function(){this._config.destroy()},n(t,[{key:"config",get:function(){return this._config}},{key:"name",get:function(){return this._config.name}},{key:"deps",get:function(){return this._config.deps}},{key:"base",get:function(){return this._config.base}}]),t}(),tS=t("ep",new $v);function eS(t,e,i){var n=new T.Image;function r(){n.removeEventListener("load",r),n.removeEventListener("error",s),i&&i(null,n)}function s(){n.removeEventListener("load",r),n.removeEventListener("error",s),i&&i(new Error(tt(4930,t)))}return"file:"!==T.location.protocol&&(n.crossOrigin="anonymous"),n.addEventListener("load",r),n.addEventListener("error",s),n.src=t,n}function iS(t,e,i,n){var r=new XMLHttpRequest,s="download failed: "+t+", status: ";if(r.open("GET",t,!0),void 0!==e.xhrResponseType&&(r.responseType=e.xhrResponseType),void 0!==e.xhrWithCredentials&&(r.withCredentials=e.xhrWithCredentials),void 0!==e.xhrMimeType&&r.overrideMimeType&&r.overrideMimeType(e.xhrMimeType),void 0!==e.xhrTimeout&&(r.timeout=e.xhrTimeout),e.xhrHeader)for(var o in e.xhrHeader)r.setRequestHeader(o,e.xhrHeader[o]);return r.onload=function(){200===r.status||0===r.status?n&&n(null,r.response):n&&n(new Error(""+s+r.status+"(no response)"))},i&&(r.onprogress=function(t){t.lengthComputable&&i(t.loaded,t.total)}),r.onerror=function(){n&&n(new Error(""+s+r.status+"(error)"))},r.ontimeout=function(){n&&n(new Error(""+s+r.status+"(time out)"))},r.onabort=function(){n&&n(new Error(""+s+r.status+"(abort)"))},r.send(null),r}v.resources=tS;var nS=T.document,rS={};function sS(t,e,i){if(rS[t])return i&&i(null),null;var n=nS.createElement("script");function r(){n.parentNode.removeChild(n),n.removeEventListener("load",r,!1),n.removeEventListener("error",s,!1),rS[t]=!0,i&&i(null)}function s(){n.parentNode.removeChild(n),n.removeEventListener("load",r,!1),n.removeEventListener("error",s,!1),i&&i(new Error(tt(4928,t)))}return"file:"!==T.location.protocol&&(n.crossOrigin="anonymous"),n.async=e.scriptAsyncLoading||!1,n.src=t,n.addEventListener("load",r,!1),n.addEventListener("error",s,!1),nS.body.appendChild(n),n}var oS=/^(?:\w+:\/\/|\.+\/).+/,aS=function(t,e,i){(xl.hasFeature(xl.Feature.IMAGE_BITMAP)&&v.assetManager.allowImageBitmap?hS:eS)(t,e,i)},hS=function(t,e,i){e.xhrResponseType="blob",iS(t,e,e.onFileProgress,i)},uS=function(t,e,i){e.xhrResponseType="json",iS(t,e,e.onFileProgress,i)},lS=function(t,e,i){e.xhrResponseType="arraybuffer",iS(t,e,e.onFileProgress,i)},cS=function(t,e,i){AS._downloadJson(t,e,(function(e,n){if(e)i(e);else{var r=hp(n);Promise.all(r.chunks.map((function(i){return new Promise((function(n,r){AS._downloadArrayBuffer(""+ul(t)+i,{},(function(t,i){e?r(e):n(new Uint8Array(i))}))}))}))).then((function(t){var e=new ap(r.document,t);i(null,e)})).catch((function(t){i(t)}))}}))},_S=function(t,e,i){AS._downloadArrayBuffer(t,e,(function(t,e){if(t)i(t);else try{var n=up(new Uint8Array(e));i(null,n)}catch(t){i(t)}}))},dS=function(t,e,i){e.xhrResponseType="text",iS(t,e,e.onFileProgress,i)},fS=function(t,e,i){var n=ll(t),r=t;oS.test(r)||(r=-1!==AS.remoteBundles.indexOf(n)?AS.remoteServerAddress+"remote/"+n:"assets/"+n);var s=e.version||AS.bundleVers[n],o=0,a=null,h=null;uS(r+"/config."+(s?s+".":"")+"json",e,(function(t,e){h=t||h,(a=e)&&(a.base=r+"/"),2==++o&&i(h,a)})),sS(r+"/index."+(s?s+".":"")+"js",e,(function(t){h=t||h,2==++o&&i(h,a)}))},pS=function(){var t=e.prototype;function e(){this.maxConcurrency=15,this.maxRequestsPerFrame=15,this.maxRetryCount=3,this.appendTimeStamp=!1,this.limited=!0,this.retryInterval=2e3,this.bundleVers={},this.remoteBundles=[],this.downloadDomImage=eS,this.downloadDomAudio=null,this.downloadFile=iS,this.downloadScript=sS,this._downloadArrayBuffer=lS,this._downloadJson=uS,this._downloaders={".png":aS,".jpg":aS,".bmp":aS,".jpeg":aS,".gif":aS,".ico":aS,".tiff":aS,".webp":aS,".image":aS,".pvr":lS,".pkm":lS,".astc":lS,".txt":dS,".xml":dS,".vsh":dS,".fsh":dS,".atlas":dS,".tmx":dS,".tsx":dS,".json":uS,".ExportJson":uS,".plist":dS,".ccon":cS,".cconb":_S,".fnt":dS,".binary":lS,".bin":lS,".dbbin":lS,".skel":lS,".js":sS,bundle:fS,default:dS},this._downloading=new Rd,this._queue=[],this._queueDirty=!1,this._totalNum=0,this._totalNumThisPeriod=0,this._lastDate=-1,this._checkNextPeriod=!1,this._remoteServerAddress="",this._maxInterval=1/30}return t.init=function(t,e,i){void 0===t&&(t=""),void 0===e&&(e={}),void 0===i&&(i=[]),this._downloading.clear(),this._queue.length=0,this._remoteServerAddress=t,this.bundleVers=e,this.remoteBundles=i},t.register=function(t,e){"object"==typeof t?Gt(this._downloaders,t):this._downloaders[t]=e},t.download=function(t,e,i,n,r){var s=this,o=Pd.get(t);if(o)r(null,o);else{var a=this._downloading.get(t);if(a){a.push(r);var h=this._queue.find((function(e){return e.id===t}));if(!h)return;var u=n.priority||0;h.priority<u&&(h.priority=u,this._queueDirty=!0)}else{var l=void 0!==n.maxRetryCount?n.maxRetryCount:this.maxRetryCount,c=void 0!==n.maxConcurrency?n.maxConcurrency:this.maxConcurrency,_=void 0!==n.maxRequestsPerFrame?n.maxRequestsPerFrame:this.maxRequestsPerFrame,d=this._downloaders[i]||this._downloaders.default;jv((function(i,o){if(0===i&&s._downloading.add(t,[r]),s.limited){s._updateTime();var a=function(t,e){s._totalNum--,s._handleQueueInNextFrame(c,_),o(t,e)};s._totalNum<c&&s._totalNumThisPeriod<_?(d(Wv(e,s.appendTimeStamp),n,a),s._totalNum++,s._totalNumThisPeriod++):(s._queue.push({id:t,priority:n.priority||0,url:e,options:n,done:a,handler:d}),s._queueDirty=!0,s._totalNum<c&&s._handleQueueInNextFrame(c,_))}else d(Wv(e,s.appendTimeStamp),n,o)}),l,this.retryInterval,(function(e,i){e||Pd.add(t,i);for(var n=s._downloading.remove(t),r=0,o=n.length;r<o;r++)n[r](e,i)}))}}},t.loadSubpackage=function(t,e){v.assetManager.loadBundle(t,null,e)},t._updateTime=function(){var t=performance.now(),e=v.game.deltaTime,i=e>this._maxInterval?this._maxInterval:e;t-this._lastDate>1e3*i&&(this._totalNumThisPeriod=0,this._lastDate=t)},t._handleQueue=function(t,e){for(this._checkNextPeriod=!1,this._updateTime();this._queue.length>0&&this._totalNum<t&&this._totalNumThisPeriod<e;){this._queueDirty&&(this._queue.sort((function(t,e){return t.priority-e.priority})),this._queueDirty=!1);var i=this._queue.pop();if(!i)break;this._totalNum++,this._totalNumThisPeriod++,i.handler(Wv(i.url,this.appendTimeStamp),i.options,i.done)}this._handleQueueInNextFrame(t,e)},t._handleQueueInNextFrame=function(t,e){!this._checkNextPeriod&&this._queue.length>0&&(Le(this._handleQueue.bind(this),t,e),this._checkNextPeriod=!0)},n(e,[{key:"remoteServerAddress",get:function(){return this._remoteServerAddress}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}}]),e}();pS._instance=void 0;var mS,gS,yS,vS,SS,TS,AS=pS.instance,bS=pS.instance,ES=t("ed",qs("cc.JsonAsset")((gS=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).json=yS&&yS(),e}return s(e,t),e}(of),yS=ks(gS.prototype,"json",[io],(function(){return null})),mS=gS))||mS);v.JsonAsset=ES;var CS,wS,xS=t("ec",qs("cc.TextAsset")((SS=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).text=TS&&TS(),e}return s(e,t),e.prototype.toString=function(){return this.text},e}(of),TS=ks(SS.prototype,"text",[io],(function(){return""})),vS=SS))||vS);v.TextAsset=xS;var RS=t("e9",qs("cc.BufferAsset")((p((wS=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._buffer=null,e}s(e,t);var i=e.prototype;return i.buffer=function(){return this._buffer,this._buffer},i.validate=function(){return!!this._buffer},n(e,[{key:"_nativeAsset",get:function(){return this._buffer},set:function(t){t instanceof ArrayBuffer?this._buffer=t:this._buffer=t.buffer}}]),e}(of)).prototype,"_nativeAsset",[Ro],Object.getOwnPropertyDescriptor(wS.prototype,"_nativeAsset"),wS.prototype),CS=wS))||CS);function IS(t,e,i,n){var r=null,s=null;try{(r=new Rf)._nativeUrl=t,r._nativeAsset=e}catch(t){s=t}n(s,r)}function BS(t,e,i,n){var r=new ES;r.json=e,n(null,r)}function DS(t,e,i,n){var r=new xS;r.text=e,n(null,r)}function PS(t,e,i,n){var r=new RS;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}function OS(t,e,i,n){var r=new of;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}function MS(t,i,n,r){var s=Md.get(i.name);s||(s=i.name===Vd.RESOURCES?tS:new $v,i.base=i.base||t+"/",s.init(i)),e.import("virtual:///prerequisite-imports/"+s.name).then((function(){r(null,s)})).catch(r)}v.BufferAsset=RS;var LS=new(function(){function t(){this._creating=new Rd,this._producers={".png":IS,".jpg":IS,".bmp":IS,".jpeg":IS,".gif":IS,".ico":IS,".tiff":IS,".webp":IS,".image":IS,".pvr":IS,".pkm":IS,".txt":DS,".xml":DS,".vsh":DS,".fsh":DS,".atlas":DS,".tmx":DS,".tsx":DS,".fnt":DS,".json":BS,".ExportJson":BS,".binary":PS,".bin":PS,".dbbin":PS,".skel":PS,bundle:MS,default:OS}}var e=t.prototype;return e.register=function(t,e){"object"==typeof t?Gt(this._producers,t):this._producers[t]=e},e.create=function(t,e,i,n,r){var s=this,o=this._producers[i]||this._producers.default,a=Dd.get(t);if(n.reloadAsset||!a){var h=this._creating.get(t);h?h.push(r):(this._creating.add(t,[r]),o(t,e,n,(function(e,i){!e&&i instanceof of&&(i._uuid=t,qv(t,i,n.cacheAsset));for(var r=s._creating.remove(t),o=0,a=r.length;o<a;o++)r[o](e,i)})))}else r(null,a)},t}()),NS=new(function(){function t(){this._loading=new Rd,this._unpackers={".json":this.unpackJson}}var e=t.prototype;return e.unpackJson=function(t,e,i,n){var r=It(!0),s=null;if(Array.isArray(e)){(e=function(t){if(t[0]<1)throw new Error(tt(5304,t[0]));Pp(t,!0,void 0,Mp.reportMissingClass),Op(t);for(var e=new Lp(t[0]),i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=0;a<o.length;++a)o[a].unshift(e,i,n,r,s);return o}(e)).length!==t.length&&J(4915);for(var o=0;o<t.length;o++)r[t[o]+"@import"]=e[o]}else{var a=ne(Zp),h=ne(Rf);if(e.type===a&&e.data){var u=e.data;u.length!==t.length&&J(4915);for(var l=0;l<t.length;l++)r[t[l]+"@import"]=Np(a,{base:u[l][0],mipmaps:u[l][1]})}else{if(e.type!==h||!e.data)return void n(s=new Error("unmatched type pack!"),null);var c=e.data;c.length!==t.length&&J(4915);for(var _=0;_<t.length;_++)r[t[_]+"@import"]=c[_]}}n(s,r)},e.init=function(){this._loading.clear()},e.register=function(t,e){"object"==typeof t?Gt(this._unpackers,t):this._unpackers[t]=e},e.unpack=function(t,e,i,n,r){e?(0,this._unpackers[i])(t,e,n,r):r(new Error("package data is wrong!"))},e.load=function(t,e,i){var n=this;if(!t.isNative&&t.info&&t.info.packs)if(Pd.has(t.id))i(null,Pd.get(t.id));else{var r=t.info.packs,s=r.find((function(t){return n._loading.has(t.uuid)}));if(s)this._loading.get(s.uuid).push({onComplete:i,id:t.id});else{var o=r[0];this._loading.add(o.uuid,[{onComplete:i,id:t.id}]),t.config;var a=Zd(o.uuid,{ext:o.ext,bundle:t.config.name});bS.download(o.uuid,a,o.ext,t.options,(function(e,i){Pd.remove(o.uuid),e&&V(e.message,e.stack),n.unpack(o.packedUuids,i,o.ext,t.options,(function(t,i){if(!t)for(var r in i)Pd.add(r,i[r]);for(var s=n._loading.remove(o.uuid),a=0,h=s.length;a<h;a++){var u=s[a];if(e||t)u.onComplete(e||t);else{var l=i[u.id];l?u.onComplete(null,l):u.onComplete(new Error("can not retrieve data from package"))}}}))}))}}else bS.download(t.id,t.url,t.ext,t.options,i)},t}());function FS(t,e){var i=!1;t.progress||(t.progress={finish:0,total:t.input.length,canInvoke:!0},i=!0);var n=t.options,r=t.progress,s=[],o=r.total,a=n.__exclude__=n.__exclude__||Object.create(null);t.output=[],Yv(t.input,(function(n,h){if(!n.isNative&&Dd.has(n.uuid)){var u=Dd.get(n.uuid);return n.content=u.addRef(),t.output.push(n),r.canInvoke&&t.dispatch("progress",++r.finish,r.total,n),void h()}NS.load(n,t.options,(function(u,l){u?t.isFinished||(!v.assetManager.force||i?(V(u.message,u.stack),r.canInvoke=!1,e(u)):(t.output.push(n),r.canInvoke&&t.dispatch("progress",++r.finish,r.total,n))):t.isFinished||(n.file=l,t.output.push(n),n.isNative||(a[n.uuid]=!0,Xv(n.uuid,l,a,s,n.config),r.total=o+s.length),r.canInvoke&&t.dispatch("progress",++r.finish,r.total,n)),h()}))}),(function(){if(t.isFinished)return Hv(t,!0),void t.dispatch("error");if(s.length>0){var o=Ud.create({input:s,progress:r,options:n,onProgress:t.onProgress,onError:Ud.prototype.recycle,onComplete:function(n){var r;n||((r=t.output).push.apply(r,o.output),o.recycle()),i&&kS(t),e(n)}});Nd.async(o)}else i&&kS(t),e()}))}function kS(t){for(var e=t.output,i=0,n=e.length;i<n;i++)e[i].content&&e[i].content.decRef(!1)}var VS=new(function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.parse=function(t){var e=this._parseXML(t).documentElement;if("plist"!==e.tagName)return Y(5100),{};for(var i=null,n=0,r=e.childNodes.length;n<r&&1!==(i=e.childNodes[n]).nodeType;n++);return this._parseNode(i)},i._parseNode=function(t){var e=null,i=t.tagName;if("dict"===i)e=this._parseDict(t);else if("array"===i)e=this._parseArray(t);else if("string"===i)if(1===t.childNodes.length)e=t.firstChild.nodeValue;else{e="";for(var n=0;n<t.childNodes.length;n++)e+=t.childNodes[n].nodeValue}else"false"===i?e=!1:"true"===i?e=!0:"real"===i?e=parseFloat(t.firstChild.nodeValue):"integer"===i&&(e=parseInt(t.firstChild.nodeValue,10));return e},i._parseArray=function(t){for(var e=[],i=0,n=t.childNodes.length;i<n;i++){var r=t.childNodes[i];1===r.nodeType&&e.push(this._parseNode(r))}return e},i._parseDict=function(t){for(var e={},i="",n=0,r=t.childNodes.length;n<r;n++){var s=t.childNodes[n];1===s.nodeType&&("key"===s.tagName?i=s.firstChild.nodeValue:e[i]=this._parseNode(s))}return e},e}(function(){function t(){this._parser=null,globalThis.DOMParser&&(this._parser=new DOMParser)}var e=t.prototype;return e.parse=function(t){return this._parseXML(t)},e._parseXML=function(t){if(this._parser)return this._parser.parseFromString(t,"text/xml");throw new Error("Dom parser is not supported in this platform!")},t}())),GS=function(){function t(){this._parsing=new Rd,this._parsers={".png":this.parseImage,".jpg":this.parseImage,".bmp":this.parseImage,".jpeg":this.parseImage,".gif":this.parseImage,".ico":this.parseImage,".tiff":this.parseImage,".webp":this.parseImage,".image":this.parseImage,".pvr":this.parsePVRTex,".pkm":this.parsePKMTex,".astc":this.parseASTCTex,".plist":this.parsePlist,import:this.parseImport,".ccon":this.parseImport,".cconb":this.parseImport}}var e=t.prototype;return e.parseImage=function(t,e,i){t instanceof HTMLImageElement?i(null,t):createImageBitmap(t,{premultiplyAlpha:"none"}).then((function(t){i(null,t)}),(function(t){i(t,null)}))},e.parsePVRTex=function(t,e,i){var n=null,r=null;try{r=Rf.parseCompressedTextures(t,0)}catch(t){n=t,console.warn(n)}i(n,r)},e.parsePKMTex=function(t,e,i){var n=null,r=null;try{r=Rf.parseCompressedTextures(t,1)}catch(t){n=t,console.warn(n)}i(n,r)},e.parseASTCTex=function(t,e,i){var n=null,r=null;try{r=Rf.parseCompressedTextures(t,2)}catch(t){n=t,console.warn(n)}i(n,r)},e.parsePlist=function(t,e,i){var n=null,r=VS.parse(t);r||(n=new Error("parse failed")),i(n,r)},e.parseImport=function(t,e,i){if(t){var n=null,r=null;try{n=Gp(t,e)}catch(t){r=t}i(r,n)}else i(new Error("The json file of asset "+e.__uuid__+" is empty or missing"))},e.init=function(){this._parsing.clear()},e.register=function(t,e){"object"==typeof t?Gt(this._parsers,t):this._parsers[t]=e},e.parse=function(t,e,i,n,r){var s=this,o=Od.get(t);if(o)r(null,o);else{var a=this._parsing.get(t);if(a)a.push(r);else{var h=this._parsers[i];h?(this._parsing.add(t,[r]),h(e,n,(function(e,i){e?Pd.remove(t):Jd(i)||Od.add(t,i);for(var n=s._parsing.remove(t),r=0,o=n.length;r<o;r++)n[r](e,i)}))):r(null,e)}}},n(t,null,[{key:"instance",get:function(){return this._instance||(this._instance=new t),this._instance}}]),t}();GS._instance=void 0;var US=GS.instance;function zS(t,e){var i=!1;t.progress||(t.progress={finish:0,total:t.input.length,canInvoke:!0},i=!0);var n=t.options,r=t.progress;n.__exclude__=n.__exclude__||Object.create(null),t.output=[],Yv(t.input,(function(s,o){var a=Ud.create({input:s,onProgress:t.onProgress,options:n,progress:r,onComplete:function(n,h){n&&!t.isFinished&&(!v.assetManager.force||i?(V(n.message,n.stack),r.canInvoke=!1,e(n)):r.canInvoke&&t.dispatch("progress",++r.finish,r.total,s)),t.output.push(h),a.recycle(),o(null)}});HS.async(a)}),(function(){if(n.__exclude__=null,t.isFinished)return Hv(t,!0),void t.dispatch("error");!function(t){var e=t.source;if(t.options.__outputAsArray__||1!==e.length)for(var i=t.output=[],n=0,r=e.length;n<r;n++)i.push(e[n].content);else t.output=e[0].content}(t),Hv(t,!0),e()}))}var HS=new Id("loadOneAsset",[function(t,e){var i=t.output=t.input,n=i.options,r=i.isNative,s=i.uuid,o=i.file,a=n.reloadAsset;o||!a&&!r&&Dd.has(s)?e():NS.load(i,t.options,(function(t,n){i.file=n,e(t)}))},function(t,e){var i=t.output=t.input,n=t.progress,r=t.options.__exclude__,s=i.id,o=i.file,a=i.options;if(i.isNative)US.parse(s,o,i.ext,a,(function(r,o){r?e(r):(i.content=o,n.canInvoke&&t.dispatch("progress",++n.finish,n.total,i),Pd.remove(s),Od.remove(s),e())}));else{var h=i.uuid;if(h in r){var u=r[h],l=u.finish,c=u.content,_=u.err,f=u.callbacks;n.canInvoke&&t.dispatch("progress",++n.finish,n.total,i),l||Qv(h,h,r)?(c&&c.addRef(),i.content=c,e(_)):f.push({done:e,item:i})}else if(!a.reloadAsset&&Dd.has(h)){var p=Dd.get(h);i.content=p.addRef(),n.canInvoke&&t.dispatch("progress",++n.finish,n.total,i),e()}else a.__uuid__=h,US.parse(s,o,"import",a,(function(i,n){i?e(i):function(t,e,i){var n=t.input,r=t.progress,s=n,o=s.uuid,a=s.id,h=s.options,u=s.config,l=h.cacheAsset,c=[];e.addRef&&e.addRef(),Xv(o,e,Object.create(null),c,u),r.canInvoke&&t.dispatch("progress",++r.finish,r.total+=c.length,n);var _=t.options.__exclude__[o]={content:e,finish:!1,callbacks:[{done:i,item:n}]},f=Ud.create({input:c,options:t.options,onProgress:t.onProgress,onError:Ud.prototype.recycle,progress:r,onComplete:function(t){if(e.decRef&&e.decRef(!1),_.finish=!0,_.err=t,!t){for(var i,n=Array.isArray(f.output)?f.output:[f.output],r=Object.create(null),s=d(n);!(i=s()).done;){var h=i.value;h&&(r[h instanceof of?h._uuid+"@import":o+"@native"]=h)}!function(t,e,i){var n=Fp.get(e);if(n){for(var r=0,s=n.length;r<s;r++){var o=n[r],a=i[o.uuid+"@import"];if(a)o.owner[o.prop]=a.addRef();else{if(V("The asset "+o.uuid+" is missing!"),v.assetManager.dispatchAssetMissing(e,o.owner,o.prop,o.uuid),o.type&&o.type!==of){var h=new o.type;h.initDefault(o.uuid),o.owner[o.prop]=h}!0}}Fp.delete(e)}kp.has(e)&&(i[t+"@native"]?e._nativeAsset=i[t+"@native"]:(!0,console.error("the native asset of "+t+" is missing!")),kp.delete(e))}(o,e,r);try{"function"!=typeof e.onLoaded||Vp.has(e)||kp.has(e)||(e.onLoaded(),Vp.add(e))}catch(t){V("The asset "+o+" is invalid for some reason, detail message: "+t.message+", stack: "+t.stack)}Pd.remove(a),Od.remove(a),qv(o,e,l),f.recycle()}for(var u=_.callbacks,c=0,p=u.length;c<p;c++){var m=u[c];e.addRef&&e.addRef(),m.item.content=e,m.done(t)}u.length=0}});Ld.async(f)}(t,n,e)}))}}]);function WS(t,e){var i=t.options,n=Object.create(null),r=Object.create(null);for(var s in i)switch(s){case Bd.PATH:case Bd.UUID:case Bd.DIR:case Bd.SCENE:case Bd.URL:break;case"__requestType__":case"__isNative__":case"ext":case"type":case"__nativeName__":case"audioLoadMode":case"bundle":n[s]=i[s];break;case"__exclude__":case"__outputAsArray__":r[s]=i[s];break;default:n[s]=i[s],r[s]=i[s]}t.options=r;var o=Ud.create({input:t.input,options:n}),a=null;try{t.output=t.source=Fd.sync(o)}catch(t){a=t;for(var h=0,u=o.output.length;h<u;h++)o.output[h].recycle()}o.recycle(),e(a)}var jS=function(){function t(){this.uuid="",this.overrideUuid="",this.url="",this.ext=".json",this.content=null,this.file=null,this.info=null,this.config=null,this.isNative=!1,this.options=Object.create(null),this._id=""}return t.create=function(){return 0!==t._deadPool.length?t._deadPool.pop():new t},t.prototype.recycle=function(){t._deadPool.length!==t.MAX_DEAD_NUM&&(this._id="",this.uuid="",this.overrideUuid="",this.url="",this.ext=".json",this.content=null,this.file=null,this.info=null,this.config=null,this.isNative=!1,this.options=Object.create(null),t._deadPool.push(this))},n(t,[{key:"id",get:function(){return this._id||(this._id=(this.overrideUuid||this.uuid)+"@"+(this.isNative?"native":"import")),this._id}}]),t}();jS.MAX_DEAD_NUM=500,jS._deadPool=[];var XS=[];function qS(t){var e=t.options,i=Array.isArray(t.input)?t.input:[t.input];t.output=[];for(var n=function(){var n=i[r],s=jS.create(),o=null,a=null;if("string"==typeof n&&((n=Object.create(null))[e.__requestType__||Bd.UUID]=i[r]),"object"==typeof n){Vt(n,e),n.preset&&Vt(n,Gd[n.preset]);var h=function(){var t;switch(u){case Bd.UUID:var e,r=s.uuid=Xd(n.uuid);if(!n.bundle){var h=Md.find((function(t){return!!t.getAssetInfo(r)}));n.bundle=h&&h.name}if(Md.has(n.bundle)){if(o=Md.get(n.bundle).config,(a=o.getAssetInfo(r))&&a.redirect){if(!Md.has(a.redirect))throw new Error("Please load bundle "+a.redirect+" first");o=Md.get(a.redirect).config,a=o.getAssetInfo(r)}s.config=o,s.info=a}s.ext=n.ext||(null===(e=a)||void 0===e?void 0:e.extension)||".json";break;case"__requestType__":case"ext":case"bundle":case"preset":case"type":break;case Bd.DIR:if(Md.has(n.bundle)){Md.get(n.bundle).config.getDirWithPath(n.dir,n.type,XS);for(var l,c=d(XS);!(l=c()).done;){var _=l.value;i.push({uuid:_.uuid,__isNative__:!1,ext:_.extension||".json",bundle:n.bundle})}XS.length=0}s.recycle(),s=null;break;case Bd.PATH:if(Md.has(n.bundle)){if(o=Md.get(n.bundle).config,(a=o.getInfoWithPath(n.path,n.type))&&a.redirect){if(!Md.has(a.redirect))throw new Error("you need to load bundle "+a.redirect+" first");o=Md.get(a.redirect).config,a=o.getAssetInfo(a.uuid)}if(!a)throw s.recycle(),new Error("Bundle "+n.bundle+" doesn't contain "+n.path);s.config=o,s.uuid=a.uuid,s.info=a}s.ext=n.ext||(null===(t=a)||void 0===t?void 0:t.extension)||".json";break;case Bd.SCENE:if(!n.bundle){var f=Md.find((function(t){return!!t.getSceneInfo(n.scene)}));n.bundle=f&&f.name}if(Md.has(n.bundle)){if(o=Md.get(n.bundle).config,(a=o.getSceneInfo(n.scene))&&a.redirect){if(!Md.has(a.redirect))throw new Error("you need to load bundle "+a.redirect+" first");o=Md.get(a.redirect).config,a=o.getAssetInfo(a.uuid)}if(!a)throw s.recycle(),new Error("Bundle "+o.name+" doesn't contain scene "+n.scene);s.config=o,s.uuid=a.uuid,s.info=a}break;case"__isNative__":s.isNative=n.__isNative__;break;case Bd.URL:s.url=n.url,s.uuid=n.uuid||n.url,s.ext=n.ext||hl(n.url),s.isNative=void 0===n.__isNative__||n.__isNative__;break;default:s.options[u]=n[u]}if(!s)return 1};for(var u in n)if(h())break}if(!s)return 1;if(t.output.push(s),!s.uuid&&!s.url)throw new Error("Can not parse this input:"+JSON.stringify(n))},r=0;r<i.length;r++)n();return null}function YS(t){for(var e=t.output=t.input,i=function(){var t=e[n];if(kd.has(t.uuid)){var i=kd.get(t.uuid),r=Md.find((function(t){return!!t.getAssetInfo(i)}));if(r){var s;t.overrideUuid=i;var o=r.config,a=o.getAssetInfo(i);if(a&&a.redirect){if(!Md.has(a.redirect))throw new Error("Please load bundle "+a.redirect+" first");a=(o=Md.get(a.redirect).config).getAssetInfo(i)}t.config=o,t.info=a,t.ext=t.isNative?t.ext:(null===(s=a)||void 0===s?void 0:s.extension)||".json"}else Y(16201,i,t.uuid)}},n=0;n<e.length;n++)i()}function KS(t){for(var e=t.output=t.input,i=0;i<e.length;i++){var n=e[i];if(!n.url){var r,s,o=n.config;s=n.isNative?o&&o.nativeBase?o.base+o.nativeBase:v.assetManager.generalNativeBase:o&&o.importBase?o.base+o.importBase:v.assetManager.generalImportBase;var a=n.overrideUuid||n.uuid,h="";n.info&&(h=n.isNative?n.info.nativeVer?"."+n.info.nativeVer:"":n.info.ver?"."+n.info.ver:""),r=".ttf"===n.ext?s+"/"+a.slice(0,2)+"/"+a+h+"/"+n.options.__nativeName__:s+"/"+a.slice(0,2)+"/"+a+h+n.ext,n.url=r}}return null}var JS="asset-missing",QS=t("eo",function(){function t(){this.pipeline=Ld.append(WS).append(zS),this.fetchPipeline=Nd.append(WS).append(FS),this.transformPipeline=Fd.append(qS).append(YS).append(KS),this.bundles=Md,this.assets=Dd,this.assetsOverrideMap=kd,this.generalImportBase="",this.generalNativeBase="",this.dependUtil=Hp,this.force=false,this.allowImageBitmap=!1,this.utils=nf,this.downloader=bS,this.parser=US,this.packManager=NS,this.cacheAsset=!0,this.cacheManager=null,this.presets=Gd,this.factory=LS,this.preprocessPipe=WS,this.fetchPipe=FS,this.loadPipe=zS,this.references=null,this._releaseManager=Uv,this._files=Pd,this._parsed=Od,this._parsePipeline=null,this._projectBundles=[],this._eventTarget=new Ku}var e=t.prototype;return e.onAssetMissing=function(t,e){this._eventTarget.on(JS,t,e)},e.offAssetMissing=function(t,e){this._eventTarget.off(JS,t,e)},e.dispatchAssetMissing=function(t,e,i,n){this._eventTarget.emit(JS,t,e,i,n)},e.init=function(t){void 0===t&&(t={});var e=t.server||Ee.querySettings(be.Category.ASSETS,"server")||"",i=t.bundleVers||Ee.querySettings(be.Category.ASSETS,"bundleVers")||{},n=t.remoteBundles||Ee.querySettings(be.Category.ASSETS,"remoteBundles")||[],r=t.downloadMaxConcurrency||Ee.querySettings(be.Category.ASSETS,"downloadMaxConcurrency");r&&r>0&&(this.downloader.maxConcurrency=r),this._files.clear(),this._parsed.clear(),this._releaseManager.init(),this.assets.clear(),this.bundles.clear(),this.packManager.init(),this.downloader.init(e,i,n),this.parser.init(),this.dependUtil.init();var s=t.importBase||Ee.querySettings(be.Category.ASSETS,"importBase")||"";s&&s.endsWith("/")&&(s=s.substr(0,s.length-1));var o=t.nativeBase||Ee.querySettings(be.Category.ASSETS,"nativeBase")||"";o&&o.endsWith("/")&&(o=o.substr(0,o.length-1)),this.generalImportBase=s,this.generalNativeBase=o,this._projectBundles=Ee.querySettings(be.Category.ASSETS,"projectBundles")||[];var a=Ee.querySettings(be.Category.ASSETS,"assetsOverrides")||{};for(var h in a)this.assetsOverrideMap.set(h,a[h])},e.getBundle=function(t){return Md.get(t)||null},e.removeBundle=function(t){t._destroy(),Md.remove(t.name)},e.loadAny=function(t,e,i,n){var r=Kv(e,i,n),s=r.options,o=r.onProgress,a=r.onComplete;s.preset=s.preset||"default",t=Array.isArray(t)?t.slice():t;var h=Ud.create({input:t,onProgress:o,onComplete:Zv(a),options:s});Ld.async(h)},e.preloadAny=function(t,e,i,n){var r=Kv(e,i,n),s=r.options,o=r.onProgress,a=r.onComplete;s.preset=s.preset||"preload",t=Array.isArray(t)?t.slice():t;var h=Ud.create({input:t,onProgress:o,onComplete:Zv(a),options:s});Nd.async(h)},e.loadRemote=function(t,e,i){var n=Kv(e,void 0,i),r=n.options,s=n.onComplete;r.reloadAsset||!this.assets.has(t)?(r.__isNative__=!0,r.preset=r.preset||"remote",this.loadAny({url:t},r,null,(function(e,i){e?(V(e.message,e.stack),s&&s(e,i)):LS.create(t,i,r.ext||hl(t),r,(function(t,e){s&&s(t,e)}))}))):Zv(s)(null,this.assets.get(t))},e.loadBundle=function(t,e,i){var n=Kv(e,void 0,i),r=n.options,s=n.onComplete,o=ll(t);this.bundles.has(o)?Zv(s)(null,this.getBundle(o)):(r.preset=r.preset||"bundle",r.ext="bundle",r.__isNative__=!0,this.loadAny({url:t},r,null,(function(e,i){e?(V(e.message,e.stack),s&&s(e,i)):LS.create(t,i,"bundle",r,(function(t,e){s&&s(t,e)}))})))},e.releaseAsset=function(t){Uv.tryRelease(t,!0)},e.releaseUnusedAssets=function(){Dd.forEach((function(t){Uv.tryRelease(t)}))},e.releaseAll=function(){Dd.forEach((function(t){Uv.tryRelease(t,!0)}))},e.loadWithJson=function(){throw new Error("Only valid in Editor")},n(t,[{key:"main",get:function(){return Md.get(Vd.MAIN)||null}},{key:"resources",get:function(){return Md.get(Vd.RESOURCES)||null}}],[{key:"instance",get:function(){return this._instance||(this._instance=new t),this._instance}}]),t}());QS._instance=void 0,QS.Pipeline=Id,QS.Task=Ud,QS.Cache=Rd,QS.RequestItem=jS,QS.Bundle=$v,QS.BuiltinBundleName=Vd,QS.CacheManager=function(){this.cacheDir=void 0,this.cacheEnabled=void 0,this.autoClear=void 0,this.cacheInterval=void 0,this.deleteInterval=void 0,this.cachedFiles=void 0},QS.Downloader=pS,QS.Parser=GS,QS.DependUtil=Up;var ZS=t("en",v.assetManager=QS.instance);v.AssetManager=QS;var $S,tT,eT,iT=t("eu",function(){function t(){this._resources={},this._materialsToBeCompiled=[]}var e=t.prototype;return e.init=function(){for(var t=this._resources,e=new Uint8Array(16),i=new Uint8Array(16),n=new Uint8Array(16),r=new Uint8Array(16),s=new Uint8Array(16),o=0,a=0;a<4;a++)e[o]=0,e[o+1]=0,e[o+2]=0,e[o+3]=255,i[o]=0,i[o+1]=0,i[o+2]=0,i[o+3]=0,n[o]=119,n[o+1]=119,n[o+2]=119,n[o+3]=255,r[o]=255,r[o+1]=255,r[o+2]=255,r[o+3]=255,s[o]=127,s[o+1]=127,s[o+2]=255,s[o+3]=255,o+=4;var h=new Uint8Array(1024);o=0;for(var u=0;u<256;u++)h[o]=221,h[o+1]=221,h[o+2]=221,h[o+3]=255,o+=4;o=0;for(var l=0;l<8;l++){for(var c=0;c<8;c++)h[o]=85,h[o+1]=85,h[o+2]=85,h[o+3]=255,o+=4;o+=32}o+=32;for(var _=0;_<8;_++){for(var d=0;d<8;d++)h[o]=85,h[o+1]=85,h[o+2]=85,h[o+3]=255,o+=4;o+=32}var f={width:2,height:2,_data:e,_compressed:!1,format:Zp.PixelFormat.RGBA8888},p={width:2,height:2,_data:i,_compressed:!1,format:Zp.PixelFormat.RGBA8888},m={width:2,height:2,_data:n,_compressed:!1,format:Zp.PixelFormat.RGBA8888},g={width:2,height:2,_data:r,_compressed:!1,format:Zp.PixelFormat.RGBA8888},y={width:2,height:2,_data:s,_compressed:!1,format:Zp.PixelFormat.RGBA8888},S={width:16,height:16,_data:h,_compressed:!1,format:Zp.PixelFormat.RGBA8888},T=new Rf(f),A=new Zp;A._uuid="black-texture",A.image=T,t[A._uuid]=A;var b=new Rf(p),E=new Zp;E._uuid="empty-texture",E.image=b,t[E._uuid]=E;var C=new Qm;C._uuid="black-cube-texture",C.setMipFilter(Qm.Filter.NEAREST),C.image={front:new Rf(f),back:new Rf(f),left:new Rf(f),right:new Rf(f),top:new Rf(f),bottom:new Rf(f)},t[C._uuid]=C;var w=new Rf(m),x=new Zp;x._uuid="grey-texture",x.image=w,t[x._uuid]=x;var R=new Qm;R._uuid="grey-cube-texture",R.setMipFilter(Qm.Filter.NEAREST),R.image={front:new Rf(m),back:new Rf(m),left:new Rf(m),right:new Rf(m),top:new Rf(m),bottom:new Rf(m)},t[R._uuid]=R;var I=new Rf(g),B=new Zp;B._uuid="white-texture",B.image=I,t[B._uuid]=B;var D=new Qm;D._uuid="white-cube-texture",D.setMipFilter(Qm.Filter.NEAREST),D.image={front:new Rf(g),back:new Rf(g),left:new Rf(g),right:new Rf(g),top:new Rf(g),bottom:new Rf(g)},t[D._uuid]=D;var P=new Rf(y),O=new Zp;O._uuid="normal-texture",O.image=P,t[O._uuid]=O;var M=new Rf(S),L=new Zp;L._uuid="default-texture",L.image=M,t[L._uuid]=L;var N=new Qm;if(N.setMipFilter(Qm.Filter.NEAREST),N._uuid="default-cube-texture",N.image={front:new Rf(S),back:new Rf(S),left:new Rf(S),right:new Rf(S),top:new Rf(S),bottom:new Rf(S)},t[N._uuid]=N,v.SpriteFrame){var F=new v.SpriteFrame,k=T,V=new Zp;V.image=k,F.texture=V,F._uuid="default-spriteframe",t[F._uuid]=F}},e.addAsset=function(t,e){this._resources[t]=e},e.get=function(t){return this._resources[t]},e.loadBuiltinAssets=function(){var t=this,e=Ee.querySettings(be.Category.ENGINE,"builtinAssets");if(!e)return Promise.resolve();var i=this._resources;return new Promise((function(n,r){ZS.loadBundle(Vd.INTERNAL,(function(s){s?r(s):ZS.loadAny(e,(function(e,s){e?r(e):(s.forEach((function(e){i[e.name]=e,Uv.addIgnoredAsset(e),e instanceof v.Material&&t._materialsToBeCompiled.push(e)})),n())}))}))}))},e.compileBuiltinMaterial=function(){for(var t=0;t<this._materialsToBeCompiled.length;++t)for(var e=this._materialsToBeCompiled[t],i=0;i<e.passes.length;++i)e.passes[i].tryCompile();this._materialsToBeCompiled.length=0},t}()),nT=t("ev",v.builtinResMgr=new iT),rT=t("dw",($S=new Map,tT=0,function(t){return"number"==typeof t?t:($S.has(t)||($S.set(t,1<<tT),tT++),$S.get(t))})),sT=t("dp",function(){function t(t){this.instances=[],this.pass=void 0,this.hasPendingModels=!1,this.dynamicOffsets=[],this._device=void 0,this._device=t.device,this.pass=t}var e=t.prototype;return e.destroy=function(){for(var t=0;t<this.instances.length;++t){var e=this.instances[t];e.vb.destroy(),e.ia.destroy()}this.instances.length=0},e.merge=function(t,e,i){void 0===i&&(i=null);var n=t.instancedAttributeBlock,r=n.buffer.length;if(r){var s=t.inputAssembler,o=t.descriptorSet.getTexture(Ay),a=t.descriptorSet.getTexture(My),h=t.descriptorSet.getTexture(Fy),u=t.descriptorSet.getTexture(Hy),l=t.useReflectionProbeType,c=i;c||(c=t.shaders[e]);for(var _=t.descriptorSet,d=0;d<this.instances.length;++d){var f,p,m=this.instances[d];if(!((null===(f=m.ia.indexBuffer)||void 0===f?void 0:f.objectID)!==(null===(p=s.indexBuffer)||void 0===p?void 0:p.objectID)||m.count>=1024)&&m.lightingMap.objectID===o.objectID&&m.useReflectionProbeType===l&&m.reflectionProbeCubemap.objectID===a.objectID&&m.reflectionProbePlanarMap.objectID===h.objectID&&m.reflectionProbeBlendCubemap.objectID===u.objectID&&m.stride===r){if(m.count>=m.capacity){m.capacity<<=1;var g=m.stride*m.capacity,y=m.data;m.data=new Uint8Array(g),m.data.set(y),m.vb.resize(g)}return m.shader=c,m.descriptorSet=_,m.data.set(n.buffer,m.stride*m.count++),void(this.hasPendingModels=!0)}}for(var v=this._device.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,32*r,r)),S=new Uint8Array(32*r),T=s.vertexBuffers.slice(),A=s.attributes.slice(),b=s.indexBuffer,E=0;E<n.attributes.length;E++){var C=n.attributes[E],w=new u_(C.name,C.format,C.isNormalized,T.length,!0);A.push(w)}S.set(n.buffer),T.push(v);var x=new c_(A,T,b),R=this._device.createInputAssembler(x);this.instances.push({count:1,capacity:32,vb:v,data:S,ia:R,stride:r,shader:c,descriptorSet:_,lightingMap:o,reflectionProbeCubemap:a,reflectionProbePlanarMap:h,useReflectionProbeType:l,reflectionProbeBlendCubemap:u}),this.hasPendingModels=!0}},e.uploadBuffers=function(t){for(var e=0;e<this.instances.length;++e){var i=this.instances[e];i.count&&(i.ia.instanceCount=i.count,t.updateBuffer(i.vb,i.data))}},e.clear=function(){for(var t=0;t<this.instances.length;++t)this.instances[t].count=0;this.hasPendingModels=!1},t}()),oT=new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.DEVICE),aT=new qc(null),hT=new b_(null);!function(t){t[t.NONE=0]="NONE",t[t.INSTANCING=1]="INSTANCING"}(eT||(eT={}));var uT=function(){function t(t){this._rootBuffer=null,this._buffers=[],this._descriptorSet=null,this._pipelineLayout=null,this._passIndex=0,this._propertyIndex=0,this._programName="",this._dynamics={},this._propertyHandleMap={},this._rootBlock=null,this._blocksInt=[],this._blocks=[],this._shaderInfo=null,this._defines={},this._properties={},this._shader=null,this._bs=new od,this._dss=new rd,this._rs=new nd,this._priority=pg.DEFAULT,this._stage=fg.DEFAULT,this._phase=rT("default"),this._passID=4294967295,this._subpassID=4294967295,this._phaseID=4294967295,this._primitive=pc.TRIANGLE_LIST,this._batchingScheme=eT.NONE,this._dynamicStates=vc.NONE,this._instancedBuffers={},this._hash=0,this._root=void 0,this._device=void 0,this._rootBufferDirty=!1,this._root=t,this._device=Ed.gfxDevice}t.fillPipelineInfo=function(t,e){void 0!==e.priority&&(t._priority=e.priority),void 0!==e.primitive&&(t._primitive=e.primitive),void 0!==e.stage&&(t._stage=e.stage),void 0!==e.dynamicStates&&(t._dynamicStates=e.dynamicStates),void 0!==e.phase&&(t._phase=rT(e.phase));var i=t._bs;if(e.blendState){var n=e.blendState,r=n.targets;r&&r.forEach((function(t,e){i.setTarget(e,t)})),void 0!==n.isA2C&&(i.isA2C=n.isA2C),void 0!==n.isIndepend&&(i.isIndepend=n.isIndepend),void 0!==n.blendColor&&(i.blendColor=n.blendColor)}t._rs.assign(e.rasterizerState),t._dss.assign(e.depthStencilState)},t.getPassHash=function(t){var e="";if(v.rendering&&v.rendering.enableEffectImport){var i=v.rendering.programLib.getKey(t._phaseID,t.program,t.defines);e=t._phaseID.toString()+","+i}else e=Pv.getKey(t.program,t.defines);var n,r=e+","+t._primitive+","+t._dynamicStates;return r+=function(t){for(var e,i=",bs,"+t.isA2C,n=d(t.targets);!(e=n()).done;){var r=e.value;i+=",bt,"+r.blend+","+r.blendEq+","+r.blendAlphaEq+","+r.blendColorMask,i+=","+r.blendSrc+","+r.blendDst+","+r.blendSrcAlpha+","+r.blendDstAlpha}return i}(t._bs),r+=function(t){var e=",dss,"+t.depthTest+","+t.depthWrite+","+t.depthFunc;return e+=","+t.stencilTestFront+","+t.stencilFuncFront+","+t.stencilRefFront+","+t.stencilReadMaskFront,e+=","+t.stencilFailOpFront+","+t.stencilZFailOpFront+","+t.stencilPassOpFront+","+t.stencilWriteMaskFront,(e+=","+t.stencilTestBack+","+t.stencilFuncBack+","+t.stencilRefBack+","+t.stencilReadMaskBack)+","+t.stencilFailOpBack+","+t.stencilZFailOpBack+","+t.stencilPassOpBack+","+t.stencilWriteMaskBack}(t._dss),Dl(r+=",rs,"+(n=t._rs).cullMode+","+n.depthBias+","+n.isFrontFaceCCW,666)};var e=t.prototype;return e.initialize=function(t){this._doInit(t),this.resetUBOs(),this.resetTextures(),this.tryCompile()},e.getHandle=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=jl.UNKNOWN);var n=this._propertyHandleMap[t];return n?(i?n=uv(n,i):e&&(n=uv(n,sv(n)-e)),n+e):0},e.getBinding=function(e){var i=this.getHandle(e);return i?t.getBindingFromHandle(i):-1},e.setUniform=function(e,i){var n=t.getBindingFromHandle(e),r=t.getTypeFromHandle(e),s=t.getOffsetFromHandle(e),o=this._getBlockView(r,n);cv[r](o,i,s),this._rootBufferDirty=!0},e.getUniform=function(e,i){var n=t.getBindingFromHandle(e),r=t.getTypeFromHandle(e),s=t.getOffsetFromHandle(e),o=this._getBlockView(r,n);return lv[r](o,i,s)},e.setUniformArray=function(e,i){for(var n=t.getBindingFromHandle(e),r=t.getTypeFromHandle(e),s=z_(r)>>2,o=this._getBlockView(r,n),a=t.getOffsetFromHandle(e),h=0;h<i.length;h++,a+=s)null!==i[h]&&cv[r](o,i[h],a);this._rootBufferDirty=!0},e.bindTexture=function(t,e,i){this._descriptorSet.bindTexture(t,e,i||0)},e.bindSampler=function(t,e,i){this._descriptorSet.bindSampler(t,e,i||0)},e.setDynamicState=function(t,e){var i=this._dynamics[t];i&&i.value===e||(i.value=e,i.dirty=!0)},e.overridePipelineStates=function(){Y(12102)},e.update=function(){this._descriptorSet?(this._rootBuffer&&this._rootBufferDirty&&(this._rootBuffer.update(this._rootBlock),this._rootBufferDirty=!1),this._descriptorSet.update()):J(12006)},e.getInstancedBuffer=function(t){return void 0===t&&(t=0),this._instancedBuffers[t]||(this._instancedBuffers[t]=new sT(this))},e.destroy=function(){for(var t=0;t<this._shaderInfo.blocks.length;t++){var e=this._shaderInfo.blocks[t];this._buffers[e.binding].destroy()}for(var i in this._buffers=[],this._rootBuffer&&(this._rootBuffer.destroy(),this._rootBuffer=null),this._instancedBuffers)this._instancedBuffers[i].destroy();this._descriptorSet.destroy(),this._rs.destroy(),this._dss.destroy(),this._bs.destroy()},e.resetUniform=function(e){var i=this.getHandle(e);if(i){for(var n=t.getTypeFromHandle(i),r=t.getBindingFromHandle(i),s=t.getOffsetFromHandle(i),o=t.getCountFromHandle(i),a=this._getBlockView(n,r),h=this._properties[e],u=h&&h.value||fv(n),l=(z_(n)>>2)*o,c=0;c+u.length<=l;c+=u.length)a.set(u,s+c);this._rootBufferDirty=!0}},e.resetTexture=function(e,i){var n=this.getHandle(e);if(n){var r,s=t.getTypeFromHandle(n),o=t.getBindingFromHandle(n),a=this._properties[e],h=a&&a.value,u=(r="string"==typeof h?nT.get(""+h+pv(s)):h||nT.get(fv(s)))&&r.getGFXTexture(),l=a&&void 0!==a.samplerHash?cd.unpackFromHash(a.samplerHash):r&&r.getSamplerInfo(),c=this._device.getSampler(l);this._descriptorSet.bindSampler(o,c,i||0),this._descriptorSet.bindTexture(o,u,i||0)}},e.resetUBOs=function(){for(var t=0;t<this._shaderInfo.blocks.length;t++)for(var e=this._shaderInfo.blocks[t],i=0,n=0;n<e.members.length;n++){for(var r=e.members[n],s=this._getBlockView(r.type,e.binding),o=this._properties[r.name],a=o&&o.value||fv(r.type),h=(z_(r.type)>>2)*r.count,u=0;u+a.length<=h;u+=a.length)s.set(a,i+u);i+=h}this._rootBufferDirty=!0},e.resetTextures=function(){if(v.rendering)for(var t,e=d(this._shaderInfo.descriptors[Cg.MATERIAL].samplerTextures);!(t=e()).done;)for(var i=t.value,n=0;n<i.count;++n)this.resetTexture(i.name,n);else for(var r=0;r<this._shaderInfo.samplerTextures.length;r++)for(var s=this._shaderInfo.samplerTextures[r],o=0;o<s.count;o++)this.resetTexture(s.name,o)},e.tryCompile=function(){var e=this._root.pipeline;if(!e)return!1;if(this._syncBatchingScheme(),v.rendering&&v.rendering.enableEffectImport){var i=v.rendering.programLib,n=i.getProgramVariant(this._device,this._phaseID,this._programName,this._defines);if(!n)return Y(12103,this._programName),!1;this._shader=n.shader,this._pipelineLayout=i.getPipelineLayout(this.device,this._phaseID,this._programName)}else{var r=Pv.getGFXShader(this._device,this._programName,this._defines,e);if(!r)return Y(12104,this._programName),!1;this._shader=r,this._pipelineLayout=Pv.getTemplateInfo(this._programName).pipelineLayout}return this._hash=t.getPassHash(this),!0},e.getShaderVariant=function(t){if(void 0===t&&(t=null),!this._shader&&!this.tryCompile())return Y(12105),null;if(!t)return this._shader;for(var e=this._root.pipeline,i=0;i<t.length;i++){var n=t[i];this._defines[n.name]=n.value}this._isBlend&&(this._defines.CC_IS_TRANSPARENCY_PASS=1);var r=null;if(v.rendering&&v.rendering.enableEffectImport){var s=v.rendering.programLib.getProgramVariant(this._device,this._phaseID,this._programName,this._defines);s&&(r=s.shader)}else r=Pv.getGFXShader(this._device,this._programName,this._defines,e);for(var o=0;o<t.length;o++){var a=t[o];delete this._defines[a.name]}return r},e.beginChangeStatesSilently=function(){},e.endChangeStatesSilently=function(){},e._doInit=function(e,i){if(void 0===i&&(i=!1),this._priority=pg.DEFAULT,this._stage=fg.DEFAULT,v.rendering&&v.rendering.enableEffectImport){var n=v.rendering;if("number"==typeof e.phase?(this._passID=e._passID,this._subpassID=e._subpassID,this._phaseID=e._phaseID):(this._passID=n.getPassID(e.pass),this._passID!==n.INVALID_ID&&(e.subpass?(this._subpassID=n.getSubpassID(this._passID,e.subpass),this._phaseID=n.getPhaseID(this._subpassID,e.phase)):this._phaseID=n.getPhaseID(this._passID,e.phase))),this._passID===n.INVALID_ID)return void J(12107,e.program);if(this._phaseID===n.INVALID_ID)return void J(12108,e.program)}this._phase=rT("default"),this._primitive=pc.TRIANGLE_LIST,this._passIndex=e.passIndex,this._propertyIndex=void 0!==e.propertyIndex?e.propertyIndex:e.passIndex,this._programName=e.program,this._defines=i?r({},e.defines):e.defines,v.rendering&&v.rendering.enableEffectImport?this._shaderInfo=v.rendering.programLib.getProgramInfo(this._phaseID,this._programName):this._shaderInfo=Pv.getTemplate(e.program),this._properties=e.properties||this._properties;var s=this._device;t.fillPipelineInfo(this,e),e.stateOverrides&&t.fillPipelineInfo(this,e.stateOverrides),v.rendering&&v.rendering.enableEffectImport?hT.layout=v.rendering.programLib.getMaterialDescriptorSetLayout(this._device,this._phaseID,e.program):hT.layout=Pv.getDescriptorSetLayout(this._device,e.program),this._descriptorSet=this._device.createDescriptorSet(hT);var o,a,h=this._shaderInfo.blocks;if(v.rendering&&v.rendering.enableEffectImport){var u=v.rendering.programLib;o=u.getBlockSizes(this._phaseID,this._programName),a=u.getHandleMap(this._phaseID,this._programName)}else{var l=Pv.getTemplateInfo(e.program);o=l.blockSizes,a=l.handleMap}if(v.rendering&&v.rendering.enableEffectImport){var c=v.rendering.programLib.getShaderInfo(this._phaseID,this.program);this._buildMaterialUniformBlocks(s,c.blocks,o)}else this._buildUniformBlocks(s,h,o);var _=this._propertyHandleMap=a,d={};for(var f in this._properties){var p=this._properties[f];p.handleInfo&&(d[f]=this.getHandle.apply(this,p.handleInfo))}Object.assign(_,d)},e._buildUniformBlocks=function(t,e,i){for(var n=t.capabilities.uboOffsetAlignment,r=[],s=0,o=0,a=0;a<e.length;a++){var h=i[a];r.push(o),o+=Math.ceil(h/n)*n,s=h}var u=r[r.length-1]+s;u&&(oT.size=16*Math.ceil(u/16),this._rootBuffer=t.createBuffer(oT),this._rootBlock=new ArrayBuffer(u));for(var l=0,c=0;l<e.length;l++){var _=e[l].binding,d=i[l];aT.buffer=this._rootBuffer,aT.offset=r[c++],aT.range=16*Math.ceil(d/16);var f=this._buffers[_]=t.createBuffer(aT);this._blocks[_]=new Float32Array(this._rootBlock,aT.offset,d/Float32Array.BYTES_PER_ELEMENT),this._blocksInt[_]=new Int32Array(this._blocks[_].buffer,this._blocks[_].byteOffset,this._blocks[_].length),this._descriptorSet.bindBuffer(_,f)}},e._buildMaterialUniformBlocks=function(t,e,i){for(var n=t.capabilities.uboOffsetAlignment,r=[],s=0,o=0,a=0;a<e.length;a++)if(1===e[a].set){var h=i[a];r.push(o),o+=Math.ceil(h/n)*n,s=h}if(0!==s){var u=r[r.length-1]+s;u&&(oT.size=16*Math.ceil(u/16),this._rootBuffer=t.createBuffer(oT),this._rootBlock=new ArrayBuffer(u))}for(var l=0,c=0;l<e.length;l++)if(1===e[l].set){var _=e[l].binding,d=i[l];aT.buffer=this._rootBuffer,aT.offset=r[c++],aT.range=16*Math.ceil(d/16);var f=this._buffers[_]=t.createBuffer(aT);this._blocks[_]=new Float32Array(this._rootBlock,aT.offset,d/Float32Array.BYTES_PER_ELEMENT),this._blocksInt[_]=new Int32Array(this._blocks[_].buffer,this._blocks[_].byteOffset,this._blocks[_].length),this._descriptorSet.bindBuffer(_,f)}},e._syncBatchingScheme=function(){this._defines.USE_INSTANCING?this._device.hasFeature(zl.INSTANCED_ARRAYS)?this._batchingScheme=eT.INSTANCING:(this._defines.USE_INSTANCING=!1,this._batchingScheme=eT.NONE):this._batchingScheme=eT.NONE},e._getBlockView=function(t,e){return t<jl.FLOAT?this._blocksInt[e]:this._blocks[e]},e._initPassFromTarget=function(t,e,i){this._priority=t.priority,this._stage=t.stage,this._phase=t.phase,this._phaseID=t._phaseID,this._passID=t._passID,this._batchingScheme=t.batchingScheme,this._primitive=t.primitive,this._dynamicStates=t.dynamicStates,this._bs=t.blendState,this._dss=e,this._descriptorSet=t.descriptorSet,this._rs=t.rasterizerState,this._passIndex=t.passIndex,this._propertyIndex=t.propertyIndex,this._programName=t.program,this._defines=t.defines,this._shaderInfo=t._shaderInfo,this._properties=t._properties,this._blocks=t._blocks,this._blocksInt=t._blocksInt,this._dynamics=t._dynamics,this._shader=t._shader,v.rendering&&v.rendering.enableEffectImport?this._pipelineLayout=v.rendering.programLib.getPipelineLayout(this.device,this._phaseID,this._programName):this._pipelineLayout=Pv.getTemplateInfo(this._programName).pipelineLayout,this._hash=t._hash^i},e._updatePassHash=function(){this._hash=t.getPassHash(this)},e.setRootBufferDirty=function(t){this._rootBufferDirty=t},e.setPriority=function(t){this._priority=t},n(t,[{key:"_isBlend",get:function(){for(var t,e=!1,i=d(this.blendState.targets);!(t=i()).done;)t.value.blend&&(e=!0);return e}},{key:"root",get:function(){return this._root}},{key:"device",get:function(){return this._device}},{key:"shaderInfo",get:function(){return this._shaderInfo}},{key:"localSetLayout",get:function(){return v.rendering&&v.rendering.enableEffectImport?v.rendering.programLib.getLocalDescriptorSetLayout(this._device,this._phaseID,this._programName):Pv.getDescriptorSetLayout(this._device,this._programName,!0)}},{key:"program",get:function(){return this._programName}},{key:"properties",get:function(){return this._properties}},{key:"defines",get:function(){return this._defines}},{key:"passIndex",get:function(){return this._passIndex}},{key:"propertyIndex",get:function(){return this._propertyIndex}},{key:"dynamics",get:function(){return this._dynamics}},{key:"blocks",get:function(){return this._blocks}},{key:"blocksInt",get:function(){return this._blocksInt}},{key:"rootBufferDirty",get:function(){return this._rootBufferDirty}},{key:"priority",get:function(){return this._priority}},{key:"primitive",get:function(){return this._primitive}},{key:"stage",get:function(){return this._stage}},{key:"phase",get:function(){return this._phase}},{key:"passID",get:function(){return this._passID}},{key:"phaseID",get:function(){return this._phaseID}},{key:"rasterizerState",get:function(){return this._rs}},{key:"depthStencilState",get:function(){return this._dss}},{key:"blendState",get:function(){return this._bs}},{key:"dynamicStates",get:function(){return this._dynamicStates}},{key:"batchingScheme",get:function(){return this._batchingScheme}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"hash",get:function(){return this._hash}},{key:"pipelineLayout",get:function(){return this._pipelineLayout}}]),t}();uT.getTypeFromHandle=sv,uT.getBindingFromHandle=ov,uT.getCountFromHandle=av,uT.getOffsetFromHandle=hv;var lT=t("dq",function(){function t(){}return t.getOrCreatePipelineState=function(t,e,i,n,r){var s=e.hash^n.hash^r.attributesHash^i.typedID,o=this._PSOHashMap.get(s);if(!o){var a=e.pipelineLayout,h=new C_(r.attributes),u=new ad(i,a,n,h,e.rasterizerState,e.depthStencilState,e.blendState,e.primitive,e.dynamicStates);o=t.createPipelineState(u),this._PSOHashMap.set(s,o)}return o},t}());lT._PSOHashMap=new Map;var cT=new Uc,_T=new Mc;function dT(t,e){t.x=e.x*e.x,t.y=e.y*e.y,t.z=e.z*e.z}var fT,pT,mT,gT,yT,vT,ST,TT,AT,bT=null;function ET(){return bT}function CT(t,e,i,n,r){if(!tv()&&n&&n.enabled&&r===bT){var s=n.subModels[0],o=s.inputAssembler,a=s.passes,h=s.shaders,u=s.descriptorSet;cT.width=_T.width=r.window.width,cT.height=_T.height=r.window.height;var l=lT.getOrCreatePipelineState(t,a[0],h[0],e,o);i.setViewport(cT),i.setScissor(_T),i.bindPipelineState(l),i.bindDescriptorSet(Cg.MATERIAL,a[0].descriptorSet),i.bindDescriptorSet(Cg.LOCAL,u),i.bindInputAssembler(o),i.draw(o)}}var wT=new tn,xT=t("ei",(fT=qs("cc.Material"),pT=xo(Mv),fT((gT=function(t){function e(){var e;return(e=t.call(this)||this)._effectAsset=yT&&yT(),e._techIdx=vT&&vT(),e._defines=ST&&ST(),e._states=TT&&TT(),e._props=AT&&AT(),e._passes=[],e._hash=0,e}s(e,t),e.getHash=function(t){for(var e,i=0,n=d(t.passes);!(e=n()).done;)i^=e.value.hash;return i};var i=e.prototype;return i.initialize=function(t){this._passes.length?Y(12005):(this._defines||(this._defines=[]),this._states||(this._states=[]),this._props||(this._props=[]),this._fillInfo(t),this._update())},i.reset=function(t){this.initialize(t)},i.destroy=function(){return this._doDestroy(),t.prototype.destroy.call(this)},i.recompileShaders=function(){console.warn("Shaders in material asset '"+this.name+"' cannot be modified at runtime, please instantiate the material first.")},i.overridePipelineStates=function(){console.warn("Pipeline states in material asset '"+this.name+"' cannot be modified at runtime, please instantiate the material first.")},i.onLoaded=function(){this._update()},i.resetUniforms=function(t){void 0===t&&(t=!0),this._props.length=this._passes.length;for(var e=0;e<this._props.length;e++)this._props[e]={};if(t)for(var i,n=d(this._passes);!(i=n()).done;){var r=i.value;r.resetUBOs(),r.resetTextures()}},i.setProperty=function(t,e,i){var n=!1;if(void 0===i)for(var r=this._passes,s=r.length,o=0;o<s;o++){var a=r[o];this._uploadProperty(a,t,e)&&(this._props[a.propertyIndex][t]=e,n=!0)}else{if(i>=this._passes.length)return void console.warn("illegal pass index: "+i+".");var h=this._passes[i];this._uploadProperty(h,t,e)&&(this._props[h.propertyIndex][t]=e,n=!0)}n||console.warn("illegal property name: "+t+".")},i.getProperty=function(t,e){if(void 0===e)for(var i=this._props,n=i.length,r=0;r<n;r++){var s=i[r];if(t in s)return s[t]}else{if(e>=this._passes.length)return console.warn("illegal pass index: "+e+"."),null;var o=this._props[this._passes[e].propertyIndex];if(t in o)return o[t]}return null},i.copy=function(t,e){this._techIdx=t._techIdx,this._props.length=t._props.length;for(var i=0;i<t._props.length;i++)this._props[i]=r({},t._props[i]);this._defines.length=t._defines.length;for(var n=0;n<t._defines.length;n++)this._defines[n]=r({},t._defines[n]);this._states.length=t._states.length;for(var s=0;s<t._states.length;s++)this._states[s]=r({},t._states[s]);this._effectAsset=t._effectAsset,e&&this._fillInfo(e),this._update()},i._fillInfo=function(t){void 0!==t.technique&&(this._techIdx=t.technique),t.effectAsset?this._effectAsset=t.effectAsset:t.effectName&&(this._effectAsset=Mv.get(t.effectName)),t.defines&&this._prepareInfo(t.defines,this._defines),t.states&&this._prepareInfo(t.states,this._states)},i._prepareInfo=function(t,e){var i=t;if(!Array.isArray(i)){var n=this._effectAsset?this._effectAsset.techniques[this._techIdx].passes.length:1;i=Array(n).fill(i)}for(var r=0;r<i.length;++r)Object.assign(e[r]||(e[r]={}),i[r])},i._createPasses=function(){var t=this._effectAsset.techniques[this._techIdx||0];if(!t)return[];for(var e=t.passes.length,i=[],n=0;n<e;++n){var r=t.passes[n],s=r.passIndex=n,o=r.defines=this._defines[s]||(this._defines[s]={});if(r.stateOverrides=this._states[s]||(this._states[s]={}),void 0!==r.propertyIndex&&Object.assign(o,this._defines[r.propertyIndex]),void 0!==r.embeddedMacros&&Object.assign(o,r.embeddedMacros),!r.switch||o[r.switch]){var a=new uT(v.director.root);a.initialize(r),i.push(a)}}return i},i._update=function(t){var i=this;if(void 0===t&&(t=!0),this._effectAsset){this._passes=this._createPasses();var n=this._effectAsset.techniques[this._techIdx].passes.length;if(this._props.length=n,t)this._passes.forEach((function(t,e){var n=i._props[e];for(var r in n||(n=i._props[e]={}),void 0!==t.propertyIndex&&Object.assign(n,i._props[t.propertyIndex]),n)i._uploadProperty(t,r,n[r])}));else for(var r=0;r<this._props.length;r++)this._props[r]={}}this._hash=e.getHash(this)},i._uploadProperty=function(t,e,i){var n=t.getHandle(e);if(!n)return!1;if(uT.getTypeFromHandle(n)<jl.SAMPLER1D)if(Array.isArray(i))t.setUniformArray(n,i);else if(null!==i){var r;if(null!==(r=t.properties[e])&&void 0!==r&&r.linear){var s=i;dT(wT,s),wT.w=s.w,i=wT}t.setUniform(n,i)}else t.resetUniform(e);else if(Array.isArray(i))for(var o=0;o<i.length;o++)this._bindTexture(t,n,i[o],o);else i?this._bindTexture(t,n,i):t.resetTexture(e);return!0},i._bindTexture=function(t,e,i,n){var r=uT.getBindingFromHandle(e);if(i instanceof dd)t.bindTexture(r,i,n);else if(i instanceof Of){var s=i.getGFXTexture();if(!s||!s.width||!s.height)return;t.bindTexture(r,s,n),t.bindSampler(r,i.getGFXSampler(),n)}},i._doDestroy=function(){if(this._passes&&this._passes.length)for(var t,e=d(this._passes);!(t=e()).done;)t.value.destroy();this._passes.length=0},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.initialize({effectName:"builtin-unlit",defines:{USE_COLOR:!0},technique:0}),this.setProperty("mainColor",new dn("#ff00ff"))},i.validate=function(){return!!this._effectAsset&&!this._effectAsset.isDefault&&this.passes.length>0},n(e,[{key:"effectAsset",get:function(){return this._effectAsset}},{key:"effectName",get:function(){return this._effectAsset?this._effectAsset.name:""}},{key:"technique",get:function(){return this._techIdx}},{key:"passes",get:function(){return this._passes}},{key:"hash",get:function(){return this._hash}},{key:"parent",get:function(){return null}},{key:"owner",get:function(){return null}}]),e}(of),yT=ks(gT.prototype,"_effectAsset",[pT],(function(){return null})),vT=ks(gT.prototype,"_techIdx",[io],(function(){return 0})),ST=ks(gT.prototype,"_defines",[io],(function(){return[]})),TT=ks(gT.prototype,"_states",[io],(function(){return[]})),AT=ks(gT.prototype,"_props",[io],(function(){return[]})),mT=gT))||mT));v.Material=xT;var RT=ge({Low_256x256:256,Medium_512x512:512,High_1024x1024:1024,Ultra_2048x2048:2048}),IT=ge({Planar:0,ShadowMap:1}),BT=ge({HARD:0,SOFT:1,SOFT_2X:2,SOFT_4X:3}),DT=ge({LEVEL_1:1,LEVEL_2:2,LEVEL_3:3,LEVEL_4:4}),PT=ge({NONE:1,RemoveDuplicates:2,DisableRotationFix:3}),OT=IT.ShadowMap+1,MT=function(){function t(){this.fixedSphere=new gr(0,0,0,.01),this.maxReceived=4,this._matLight=new In,this._material=null,this._instancingMaterial=null,this._enabled=!1,this._type=OT,this._distance=0,this._planeBias=1,this._normal=new on(0,1,0),this._shadowColor=new dn(0,0,0,76),this._size=new Ln(1024,1024),this._shadowMapDirty=!1}var e=t.prototype;return e.getPlanarShader=function(t){this._material||(this._material=new xT,this._material.initialize({effectName:"pipeline/planar-shadow"}));var e=this._material.passes;return e.length>0?e[0].getShaderVariant(t):null},e.initialize=function(t){this._enabled=t.enabled,this._type=this.enabled?t.type:OT,this.normal=t.planeDirection,this.distance=t.planeHeight,this.planeBias=t.planeBias,this.shadowColor=t.shadowColor,this.maxReceived=t.maxReceived,t.shadowMapSize!==this._size.x&&(this.size.set(t.shadowMapSize,t.shadowMapSize),this._shadowMapDirty=!0)},e.activate=function(){if(this._enabled)if(this.type===IT.Planar)this._updatePlanarInfo();else{var t=v.director.root;t.pipeline.macros.CC_SHADOW_TYPE=2,t.onGlobalPipelineStateChanged()}else{var e=v.director.root;e.pipeline.macros.CC_SHADOW_TYPE=0,e.onGlobalPipelineStateChanged()}},e._updatePlanarInfo=function(){this._material||(this._material=new xT,this._material.initialize({effectName:"pipeline/planar-shadow"}));var t=v.director.root;t.pipeline.macros.CC_SHADOW_TYPE=1,t.onGlobalPipelineStateChanged()},e.destroy=function(){this._material&&this._material.destroy(),this._instancingMaterial&&this._instancingMaterial.destroy(),this.fixedSphere.destroy()},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t,this.activate()}},{key:"type",get:function(){return this._type},set:function(t){this._type=this.enabled?t:OT,this.activate()}},{key:"normal",get:function(){return this._normal},set:function(t){on.copy(this._normal,t)}},{key:"distance",get:function(){return this._distance},set:function(t){this._distance=t}},{key:"planeBias",get:function(){return this._planeBias},set:function(t){this._planeBias=t}},{key:"shadowColor",get:function(){return this._shadowColor},set:function(t){this._shadowColor=t}},{key:"size",get:function(){return this._size},set:function(t){this._size.set(t)}},{key:"shadowMapDirty",get:function(){return this._shadowMapDirty},set:function(t){this._shadowMapDirty=t}},{key:"matLight",get:function(){return this._matLight}},{key:"material",get:function(){return this._material}},{key:"instancingMaterial",get:function(){return this._instancingMaterial}}]),t}();MT.MAX_FAR=2e3,MT.COEFFICIENT_OF_EXPANSION=2*Math.sqrt(3),v.Shadows=MT;var LT=function(t){function e(e,i){var n;(n=t.call(this,e.root)||this)._parent=void 0,n._owner=void 0,n._dontNotify=!1,n._parent=e,n._owner=i,n._doInit(n._parent,!0);for(var r=0;r<n._shaderInfo.blocks.length;r++){var s=n._shaderInfo.blocks[r],o=n._blocks[s.binding],a=n._parent.blocks[s.binding];o.set(a)}n._rootBufferDirty=!0;for(var h=n._parent,u=0;u<n._shaderInfo.samplerTextures.length;u++)for(var l=n._shaderInfo.samplerTextures[u],_=0;_<l.count;_++){var d=h._descriptorSet.getSampler(l.binding,_),f=h._descriptorSet.getTexture(l.binding,_);n._descriptorSet.bindSampler(l.binding,d,_),n._descriptorSet.bindTexture(l.binding,f,_)}return t.prototype.tryCompile.call(c(n)),n}s(e,t);var i=e.prototype;return i.overridePipelineStates=function(t,e){this._bs.reset(),this._rs.reset(),this._dss.reset(),uT.fillPipelineInfo(this,t),uT.fillPipelineInfo(this,e),this._onStateChange()},i.tryCompile=function(e){if(e&&!mv(this._defines,e))return!1;var i=t.prototype.tryCompile.call(this);return this._onStateChange(),i},i.beginChangeStatesSilently=function(){this._dontNotify=!0},i.endChangeStatesSilently=function(){this._dontNotify=!1},i._syncBatchingScheme=function(){this._defines.USE_INSTANCING=!1,this._batchingScheme=eT.NONE},i._onStateChange=function(){this._hash=uT.getPassHash(this),this._owner.onPassStateChange(this._dontNotify)},n(e,[{key:"parent",get:function(){return this._parent}}]),e}(uT),NT=function(t){function e(e){var i;return(i=t.call(this)||this)._passes=[],i._parent=void 0,i._owner=void 0,i._subModelIdx=0,i._parent=e.parent,i._owner=e.owner||null,i._subModelIdx=e.subModelIdx||0,i.copy(i._parent),i}s(e,t);var i=e.prototype;return i.recompileShaders=function(t,e){if(this._passes&&this.effectAsset)if(void 0===e)for(var i,n=d(this._passes);!(i=n()).done;)i.value.tryCompile(t);else this._passes[e].tryCompile(t)},i.overridePipelineStates=function(t,e){if(this._passes&&this.effectAsset){var i=this.effectAsset.techniques[this.technique].passes;if(void 0===e)for(var n=0;n<this._passes.length;n++){var r=this._passes[n],s=this._states[n]||(this._states[n]={});for(var o in t)s[o]=t[o];r.overridePipelineStates(i[r.passIndex],s)}else{var a=this._states[e]||(this._states[e]={});for(var h in t)a[h]=t[h];this._passes[e].overridePipelineStates(i[e],a)}}},i.destroy=function(){return this._doDestroy(),!0},i.onPassStateChange=function(t){this._hash=xT.getHash(this),!t&&this._owner&&this._owner._onRebuildPSO(this._subModelIdx,this)},i._createPasses=function(){var t=[],e=this._parent.passes;if(!e)return t;for(var i=0;i<e.length;++i)t.push(new LT(e[i],this));return t},n(e,[{key:"parent",get:function(){return this._parent}},{key:"owner",get:function(){return this._owner}}]),e}(xT),FT=null,kT=null,VT=ge({HEMISPHERE_DIFFUSE:0,AUTOGEN_HEMISPHERE_DIFFUSE_WITH_REFLECTION:1,DIFFUSEMAP_WITH_REFLECTION:2}),GT=function(){function t(){this._envmapLDR=null,this._envmapHDR=null,this._diffuseMapLDR=null,this._diffuseMapHDR=null,this._globalDSManager=null,this._model=null,this._default=null,this._enabled=!1,this._useIBL=!1,this._useHDR=!0,this._useDiffuseMap=!1,this._editableMaterial=null,this._activated=!1,this._reflectionHDR=null,this._reflectionLDR=null,this._rotationAngle=0}var e=t.prototype;return e.initialize=function(t){this._activated=!1,this._enabled=t.enabled,this._useIBL=t.useIBL,this._useDiffuseMap=t.applyDiffuseMap,this._useHDR=t.useHDR},e.setEnvMaps=function(t,e){this._envmapHDR=t,this._envmapLDR=e,this._updateGlobalBinding(),this._updatePipeline()},e.setDiffuseMaps=function(t,e){this._diffuseMapHDR=t,this._diffuseMapLDR=e,this._updateGlobalBinding(),this._updatePipeline()},e.setSkyboxMaterial=function(t){t?(this._editableMaterial=new NT({parent:t}),this._editableMaterial.recompileShaders({USE_RGBE_CUBEMAP:this.isRGBE})):this._editableMaterial=null,this._updatePipeline()},e.setReflectionMaps=function(t,e){this._reflectionHDR=t,this._reflectionLDR=e,this._updateGlobalBinding(),this._updatePipeline()},e.setRotationAngle=function(t){this._rotationAngle=t},e.getRotationAngle=function(){return this._rotationAngle},e.updateMaterialRenderInfo=function(){this._updateGlobalBinding(),this._updatePipeline()},e.activate=function(){var t=v.director.root.pipeline;this._globalDSManager=t.globalDSManager,this._default=nT.get("default-cube-texture"),this._model||(this._model=v.director.root.createModel(v.renderer.scene.Model));var e=this._default.isRGBE;if(this._default.isUsingOfflineMipmaps(),this.envmap&&(e=this.envmap.isRGBE,this.envmap.isUsingOfflineMipmaps()),!kT){var i=new xT;i.initialize({effectName:"pipeline/skybox",defines:{USE_RGBE_CUBEMAP:e}}),kT=new NT({parent:i})}this.enabled&&(FT||(FT=v.utils.createMesh(v.primitives.box({width:2,height:2,length:2}))),this._editableMaterial?this._model.initSubModel(0,FT.renderingSubMeshes[0],this._editableMaterial):this._model.initSubModel(0,FT.renderingSubMeshes[0],kT)),this.envmap||(this.envmap=this._default),this.diffuseMap||(this.diffuseMap=this._default),this._updateGlobalBinding(),this._updatePipeline(),this._activated=!0},e._updatePipeline=function(){var t=v.director.root,e=t.pipeline,i=this.useIBL?this.isRGBE?2:1:0,n=this.useIBL&&this.useDiffuseMap&&this.diffuseMap&&this.diffuseMap!==this._default?this.isRGBE?2:1:0,r=this.useHDR,s=this.useConvolutionMap;if(e.macros.CC_USE_IBL===i&&e.macros.CC_USE_DIFFUSEMAP===n&&e.macros.CC_USE_HDR===r&&e.macros.CC_IBL_CONVOLUTED===s||(e.macros.CC_USE_IBL=i,e.macros.CC_USE_DIFFUSEMAP=n,e.macros.CC_USE_HDR=r,e.macros.CC_IBL_CONVOLUTED=s,this._activated&&t.onGlobalPipelineStateChanged()),this.enabled){var o=this.envmap?this.envmap:this._default,a=this._editableMaterial?this._editableMaterial:kT;a&&(a.setProperty("environmentMap",o),a.recompileShaders({USE_RGBE_CUBEMAP:this.isRGBE})),this._model&&(this._model.setSubModelMaterial(0,a),this._updateSubModes())}},e._updateGlobalBinding=function(){if(this._globalDSManager){var t=Ed.gfxDevice;if(this.reflectionMap){var e=this.reflectionMap.getGFXTexture(),i=t.getSampler(this.reflectionMap.getSamplerInfo());this._globalDSManager.bindSampler(Fg,i),this._globalDSManager.bindTexture(Fg,e)}else{var n=this.envmap?this.envmap:this._default;if(n){var r=n.getGFXTexture(),s=t.getSampler(n.getSamplerInfo());this._globalDSManager.bindSampler(Fg,s),this._globalDSManager.bindTexture(Fg,r)}}var o=this.diffuseMap?this.diffuseMap:this._default;if(o){var a=o.getGFXTexture(),h=t.getSampler(o.getSamplerInfo());this._globalDSManager.bindSampler(Gg,h),this._globalDSManager.bindTexture(Gg,a)}this._globalDSManager.update()}},e._updateSubModes=function(){if(this._model)for(var t=this._model.subModels,e=0;e<t.length;e++)t[e].update()},n(t,[{key:"model",get:function(){return this._model}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t,t?this.activate():this._updatePipeline()}},{key:"useHDR",get:function(){return this._useHDR},set:function(t){this._useHDR=t,this.setEnvMaps(this._envmapHDR,this._envmapLDR)}},{key:"useIBL",get:function(){return this._useIBL},set:function(t){this._useIBL=t,this._updatePipeline()}},{key:"useDiffuseMap",get:function(){return this._useDiffuseMap},set:function(t){this._useDiffuseMap=t,this._updatePipeline()}},{key:"isRGBE",get:function(){return!!this.envmap&&this.envmap.isRGBE}},{key:"useConvolutionMap",get:function(){return this.reflectionMap?this.reflectionMap.isUsingOfflineMipmaps():!!this.envmap&&this.envmap.isUsingOfflineMipmaps()}},{key:"envmap",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._envmapHDR:this._envmapLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this.setEnvMaps(t,this._envmapLDR):this.setEnvMaps(this._envmapHDR,t)}},{key:"diffuseMap",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._diffuseMapHDR:this._diffuseMapLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this.setDiffuseMaps(t,this._diffuseMapLDR):this.setDiffuseMaps(this._diffuseMapHDR,t)}},{key:"reflectionMap",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._reflectionHDR:this._reflectionLDR}},{key:"editableMaterial",get:function(){return this._editableMaterial}}]),t}();v.Skybox=GT;var UT=new tn,zT=ge({LINEAR:0,EXP:1,EXP_SQUARED:2,LAYERED:3}),HT=zT.LAYERED+1,WT=function(){function t(){this._fogColor=new dn("#C8C8C8"),this._colorArray=new tn(.2,.2,.2,1),this._enabled=!1,this._accurate=!1,this._type=0,this._fogDensity=.3,this._fogStart=.5,this._fogEnd=300,this._fogAtten=5,this._fogTop=1.5,this._fogRange=1.2,this._activated=!1}var e=t.prototype;return e.initialize=function(t){this._activated=!1,this.fogColor=t.fogColor,this._enabled=t.enabled,this._type=this.enabled?t.type:HT,this._accurate=t.accurate,this.fogDensity=t.fogDensity,this.fogStart=t.fogStart,this.fogEnd=t.fogEnd,this.fogAtten=t.fogAtten,this.fogTop=t.fogTop,this.fogRange=t.fogRange},e.activate=function(){this._updatePipeline(),this._activated=!0},e._updatePipeline=function(){var t=v.director.root,e=this.enabled?this.type:HT,i=this.accurate?1:0,n=t.pipeline;n.macros.CC_USE_FOG===e&&n.macros.CC_USE_ACCURATE_FOG===i||(n.macros.CC_USE_FOG=e,n.macros.CC_USE_ACCURATE_FOG=i,this._activated&&t.onGlobalPipelineStateChanged())},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t,t?this.activate():(this._type=HT,this._updatePipeline())}},{key:"accurate",get:function(){return this._accurate},set:function(t){this._accurate=t,this._updatePipeline()}},{key:"fogColor",get:function(){return this._fogColor},set:function(t){this._fogColor.set(t),UT.set(t.x,t.y,t.z,t.w),dT(this._colorArray,UT)}},{key:"type",get:function(){return this._type},set:function(t){this._type=this.enabled?t:HT,this.enabled&&this._updatePipeline()}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(t){this._fogDensity=t}},{key:"fogStart",get:function(){return this._fogStart},set:function(t){this._fogStart=t}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(t){this._fogEnd=t}},{key:"fogAtten",get:function(){return this._fogAtten},set:function(t){this._fogAtten=t}},{key:"fogTop",get:function(){return this._fogTop},set:function(t){this._fogTop=t}},{key:"fogRange",get:function(){return this._fogRange},set:function(t){this._fogRange=t}},{key:"colorArray",get:function(){return this._colorArray}}]),t}();v.Fog=WT;var jT,XT,qT,YT,KT,JT,QT,ZT,$T,tA,eA,iA,nA,rA,sA,oA,aA,hA,uA,lA,cA,_A,dA,fA,pA,mA,gA,yA,vA,SA,TA,AA,bA,EA,CA,wA,xA,RA,IA,BA,DA,PA,OA,MA,LA,NA,FA,kA,VA,GA,UA,zA,HA,WA,jA,XA,qA,YA,KA,JA,QA,ZA,$A,tb,eb,ib,nb,rb,sb,ob,ab,hb,ub,lb,cb,_b,db,fb,pb,mb,gb,yb,vb,Sb,Tb,Ab,bb,Eb,Cb,wb,xb,Rb,Ib,Bb,Db,Pb,Ob,Mb,Lb,Nb,Fb,kb,Vb,Gb,Ub,zb,Hb,Wb,jb,Xb,qb,Yb,Kb,Jb,Qb,Zb,$b,tE,eE,iE,nE,rE,sE,oE,aE,hE,uE,lE,cE,_E,dE=ge({DEFAULT:0,LINEAR:1}),fE=function(){function t(){this._toneMappingType=dE.DEFAULT,this._activated=!1}var e=t.prototype;return e.initialize=function(t){this._toneMappingType=t.toneMappingType},e.activate=function(){this._updatePipeline(),this._activated=!0},e._updatePipeline=function(){var t=v.director.root;t.pipeline.macros.CC_TONE_MAPPING_TYPE=this._toneMappingType,this._activated&&t.onGlobalPipelineStateChanged()},n(t,[{key:"toneMappingType",get:function(){return this._toneMappingType},set:function(t){this._toneMappingType=t,this._updatePipeline()}}]),t}(),pE=new on(0,1,0),mE=new on,gE=new tn,yE=new dn,vE=new Sn,SE=function(t){var e=1/Math.max(Math.max(Math.max(t.x,t.y),t.z),1e-4);e<1&&(t.x*=e,t.y*=e,t.z*=e)},TE=t("dL",(jT=qs("cc.AmbientInfo"),XT=xo(Ye),qT=no("_skyColor"),YT=no("_skyIllum"),KT=no("_groundAlbedo"),jT((p((QT=function(){function t(){this._skyColorHDR=ZT&&ZT(),this._skyIllumHDR=$T&&$T(),this._groundAlbedoHDR=tA&&tA(),this._skyColorLDR=eA&&eA(),this._skyIllumLDR=iA&&iA(),this._groundAlbedoLDR=nA&&nA(),this._resource=null}return t.prototype.activate=function(t){this._resource=t,this._resource.initialize(this)},n(t,[{key:"skyColorHDR",get:function(){return this._skyColorHDR}},{key:"groundAlbedoHDR",get:function(){return this._groundAlbedoHDR}},{key:"skyIllumHDR",get:function(){return this._skyIllumHDR}},{key:"skyColorLDR",get:function(){return this._skyColorLDR}},{key:"groundAlbedoLDR",get:function(){return this._groundAlbedoLDR}},{key:"skyIllumLDR",get:function(){return this._skyIllumLDR}},{key:"skyLightingColor",get:function(){var t=v.director.root.pipeline.pipelineSceneData.isHDR;return gE.set(t?this._skyColorHDR:this._skyColorLDR),SE(gE),yE.set(255*gE.x,255*gE.y,255*gE.z,255)},set:function(t){gE.set(t.x,t.y,t.z,t.w),v.director.root.pipeline.pipelineSceneData.isHDR?this._skyColorHDR.set(gE):this._skyColorLDR.set(gE),this._resource&&this._resource.skyColor.set(gE)}},{key:"skyColor",set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this._skyColorHDR.set(t):this._skyColorLDR.set(t),this._resource&&this._resource.skyColor.set(t)}},{key:"skyIllum",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._skyIllumHDR:this._skyIllumLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this._skyIllumHDR=t:this._skyIllumLDR=t,this._resource&&(this._resource.skyIllum=t)}},{key:"groundLightingColor",get:function(){var t=v.director.root.pipeline.pipelineSceneData.isHDR;return gE.set(t?this._groundAlbedoHDR:this._groundAlbedoLDR),SE(gE),yE.set(255*gE.x,255*gE.y,255*gE.z,255)},set:function(t){gE.set(t.x,t.y,t.z,t.w),v.director.root.pipeline.pipelineSceneData.isHDR?this._groundAlbedoHDR.set(gE):this._groundAlbedoLDR.set(gE),this._resource&&this._resource.groundAlbedo.set(gE)}},{key:"groundAlbedo",set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this._groundAlbedoHDR.set(t):this._groundAlbedoLDR.set(t),this._resource&&this._resource.groundAlbedo.set(t)}}]),t}()).prototype,"skyIllum",[XT],Object.getOwnPropertyDescriptor(QT.prototype,"skyIllum"),QT.prototype),ZT=ks(QT.prototype,"_skyColorHDR",[io,qT],(function(){return new tn(.2,.5,.8,1)})),$T=ks(QT.prototype,"_skyIllumHDR",[io,YT],(function(){return dg.SKY_ILLUM})),tA=ks(QT.prototype,"_groundAlbedoHDR",[io,KT],(function(){return new tn(.2,.2,.2,1)})),eA=ks(QT.prototype,"_skyColorLDR",[io],(function(){return new tn(.2,.5,.8,1)})),iA=ks(QT.prototype,"_skyIllumLDR",[io],(function(){return dg.SKY_ILLUM})),nA=ks(QT.prototype,"_groundAlbedoLDR",[io],(function(){return new tn(.2,.2,.2,1)})),JT=QT))||JT));v.AmbientInfo=TE;var AE=t("dM",(rA=qs("cc.SkyboxInfo"),sA=xo(VT),oA=xo(Qm),aA=xo(Ye),hA=xo(Qm),uA=xo(Qm),lA=xo(xT),cA=xo(Qm),_A=no("_envmap"),dA=xo(Qm),fA=xo(Qm),pA=xo(Qm),mA=xo(xT),gA=xo(Qm),yA=xo(Qm),rA((p((SA=function(){function t(){this._envLightingType=TA&&TA(),this._envmapHDR=AA&&AA(),this._envmapLDR=bA&&bA(),this._diffuseMapHDR=EA&&EA(),this._diffuseMapLDR=CA&&CA(),this._enabled=wA&&wA(),this._useHDR=xA&&xA(),this._editableMaterial=RA&&RA(),this._reflectionHDR=IA&&IA(),this._reflectionLDR=BA&&BA(),this._rotationAngle=DA&&DA(),this._resource=null}var e=t.prototype;return e.activate=function(t){this.envLightingType=this._envLightingType,this._resource=t,this._resource.initialize(this),this._resource.setEnvMaps(this._envmapHDR,this._envmapLDR),this._resource.setDiffuseMaps(this._diffuseMapHDR,this._diffuseMapLDR),this._resource.setSkyboxMaterial(this._editableMaterial),this._resource.setReflectionMaps(this._reflectionHDR,this._reflectionLDR),this._resource.setRotationAngle(this._rotationAngle),this._resource.activate()},e.updateEnvMap=function(t){t||(this.applyDiffuseMap=!1,this.useIBL=!1,this.envLightingType=VT.HEMISPHERE_DIFFUSE,Y(15001)),this._resource&&(this._resource.setEnvMaps(this._envmapHDR,this._envmapLDR),this._resource.setDiffuseMaps(this._diffuseMapHDR,this._diffuseMapLDR),this._resource.setReflectionMaps(this._reflectionHDR,this._reflectionLDR),this._resource.useDiffuseMap=this.applyDiffuseMap,this._resource.envmap=t)},e.setMaterialProperty=function(t,e,i){this._resource&&this._resource.enabled&&this._resource.editableMaterial&&(this._resource.editableMaterial.setProperty(t,e,i),this._resource.editableMaterial.passes.forEach((function(t){t.update()})))},n(t,[{key:"applyDiffuseMap",get:function(){return VT.DIFFUSEMAP_WITH_REFLECTION===this._envLightingType},set:function(t){this._resource&&(this._resource.useDiffuseMap=t)}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(this._enabled=t,this._resource&&(this._resource.enabled=this._enabled))}},{key:"envLightingType",get:function(){return this._envLightingType},set:function(t){this.envmap||VT.HEMISPHERE_DIFFUSE===t?(VT.HEMISPHERE_DIFFUSE===t?(this.useIBL=!1,this.applyDiffuseMap=!1):VT.AUTOGEN_HEMISPHERE_DIFFUSE_WITH_REFLECTION===t?(this.useIBL=!0,this.applyDiffuseMap=!1):VT.DIFFUSEMAP_WITH_REFLECTION===t&&(this.useIBL=!0,this.applyDiffuseMap=!0),this._envLightingType=t):(this.useIBL=!1,this.applyDiffuseMap=!1,this._envLightingType=VT.HEMISPHERE_DIFFUSE,Y(15001))}},{key:"useIBL",get:function(){return VT.HEMISPHERE_DIFFUSE!==this._envLightingType},set:function(t){this._resource&&(this._resource.useIBL=t)}},{key:"useHDR",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR=this._useHDR,this._useHDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR=t,this._useHDR=t,this._resource&&this.envLightingType===VT.DIFFUSEMAP_WITH_REFLECTION&&(null===this.diffuseMap?(this.envLightingType=VT.AUTOGEN_HEMISPHERE_DIFFUSE_WITH_REFLECTION,Y(15e3)):this.diffuseMap.isDefault&&Y(15002)),this._resource&&(this._resource.useHDR=this._useHDR,this._resource.updateMaterialRenderInfo())}},{key:"envmap",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._envmapHDR:this._envmapLDR},set:function(t){var e=v.director.root.pipeline.pipelineSceneData.isHDR;e?(this._envmapHDR=t,this._reflectionHDR=null):(this._envmapLDR=t,this._reflectionLDR=null),t||(e?this._diffuseMapHDR=null:this._diffuseMapLDR=null,this.applyDiffuseMap=!1,this.useIBL=!1,this.envLightingType=VT.HEMISPHERE_DIFFUSE,Y(15001)),this._resource&&(this._resource.setEnvMaps(this._envmapHDR,this._envmapLDR),this._resource.setDiffuseMaps(this._diffuseMapHDR,this._diffuseMapLDR),this._resource.setReflectionMaps(this._reflectionHDR,this._reflectionLDR),this._resource.useDiffuseMap=this.applyDiffuseMap,this._resource.envmap=t)}},{key:"rotationAngle",get:function(){return this._rotationAngle},set:function(t){this._rotationAngle=t,this._resource&&this._resource.setRotationAngle(this._rotationAngle)}},{key:"diffuseMap",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._diffuseMapHDR:this._diffuseMapLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this._diffuseMapHDR=t:this._diffuseMapLDR=t,this._resource&&this._resource.setDiffuseMaps(this._diffuseMapHDR,this._diffuseMapLDR)}},{key:"reflectionMap",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._reflectionHDR:this._reflectionLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this._reflectionHDR=t:this._reflectionLDR=t,this._resource&&this._resource.setReflectionMaps(this._reflectionHDR,this._reflectionLDR)}},{key:"skyboxMaterial",get:function(){return this._editableMaterial},set:function(t){this._editableMaterial=t,this._resource&&this._resource.setSkyboxMaterial(this._editableMaterial)}}]),t}()).prototype,"envLightingType",[sA],Object.getOwnPropertyDescriptor(SA.prototype,"envLightingType"),SA.prototype),p(SA.prototype,"envmap",[oA],Object.getOwnPropertyDescriptor(SA.prototype,"envmap"),SA.prototype),p(SA.prototype,"rotationAngle",[aA],Object.getOwnPropertyDescriptor(SA.prototype,"rotationAngle"),SA.prototype),p(SA.prototype,"diffuseMap",[hA],Object.getOwnPropertyDescriptor(SA.prototype,"diffuseMap"),SA.prototype),p(SA.prototype,"reflectionMap",[uA],Object.getOwnPropertyDescriptor(SA.prototype,"reflectionMap"),SA.prototype),p(SA.prototype,"skyboxMaterial",[lA],Object.getOwnPropertyDescriptor(SA.prototype,"skyboxMaterial"),SA.prototype),TA=ks(SA.prototype,"_envLightingType",[io],(function(){return VT.HEMISPHERE_DIFFUSE})),AA=ks(SA.prototype,"_envmapHDR",[io,cA,_A],(function(){return null})),bA=ks(SA.prototype,"_envmapLDR",[io,dA],(function(){return null})),EA=ks(SA.prototype,"_diffuseMapHDR",[io,fA],(function(){return null})),CA=ks(SA.prototype,"_diffuseMapLDR",[io,pA],(function(){return null})),wA=ks(SA.prototype,"_enabled",[io],(function(){return!1})),xA=ks(SA.prototype,"_useHDR",[io],(function(){return!0})),RA=ks(SA.prototype,"_editableMaterial",[io,mA],(function(){return null})),IA=ks(SA.prototype,"_reflectionHDR",[io,gA],(function(){return null})),BA=ks(SA.prototype,"_reflectionLDR",[io,yA],(function(){return null})),DA=ks(SA.prototype,"_rotationAngle",[io],(function(){return 0})),vA=SA))||vA));v.SkyboxInfo=AE;var bE=t("dN",(PA=qs("cc.FogInfo"),OA=xo(zT),MA=xo(Ye),LA=xo(Ye),NA=xo(Ye),FA=xo(Ye),kA=xo(Ye),VA=xo(Ye),PA(((ZA=function(){function t(){this._type=zA&&zA(),this._fogColor=HA&&HA(),this._enabled=WA&&WA(),this._fogDensity=jA&&jA(),this._fogStart=XA&&XA(),this._fogEnd=qA&&qA(),this._fogAtten=YA&&YA(),this._fogTop=KA&&KA(),this._fogRange=JA&&JA(),this._accurate=QA&&QA(),this._resource=null}return t.prototype.activate=function(t){this._resource=t,this._resource.initialize(this),this._resource.activate()},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(this._enabled=t,this._resource&&(this._resource.enabled=t,t&&(this._resource.type=this._type)))}},{key:"accurate",get:function(){return this._accurate},set:function(t){this._accurate!==t&&(this._accurate=t,this._resource&&(this._resource.accurate=t,t&&(this._resource.type=this._type)))}},{key:"fogColor",get:function(){return this._fogColor},set:function(t){this._fogColor.set(t),this._resource&&(this._resource.fogColor=this._fogColor)}},{key:"type",get:function(){return this._type},set:function(t){this._type=t,this._resource&&(this._resource.type=t)}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(t){this._fogDensity=t,this._resource&&(this._resource.fogDensity=t)}},{key:"fogStart",get:function(){return this._fogStart},set:function(t){this._fogStart=t,this._resource&&(this._resource.fogStart=t)}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(t){this._fogEnd=t,this._resource&&(this._resource.fogEnd=t)}},{key:"fogAtten",get:function(){return this._fogAtten},set:function(t){this._fogAtten=t,this._resource&&(this._resource.fogAtten=t)}},{key:"fogTop",get:function(){return this._fogTop},set:function(t){this._fogTop=t,this._resource&&(this._resource.fogTop=t)}},{key:"fogRange",get:function(){return this._fogRange},set:function(t){this._fogRange=t,this._resource&&(this._resource.fogRange=t)}}]),t}()).FogType=zT,p((UA=ZA).prototype,"type",[OA],Object.getOwnPropertyDescriptor(UA.prototype,"type"),UA.prototype),p(UA.prototype,"fogDensity",[MA],Object.getOwnPropertyDescriptor(UA.prototype,"fogDensity"),UA.prototype),p(UA.prototype,"fogStart",[LA],Object.getOwnPropertyDescriptor(UA.prototype,"fogStart"),UA.prototype),p(UA.prototype,"fogEnd",[NA],Object.getOwnPropertyDescriptor(UA.prototype,"fogEnd"),UA.prototype),p(UA.prototype,"fogAtten",[FA],Object.getOwnPropertyDescriptor(UA.prototype,"fogAtten"),UA.prototype),p(UA.prototype,"fogTop",[kA],Object.getOwnPropertyDescriptor(UA.prototype,"fogTop"),UA.prototype),p(UA.prototype,"fogRange",[VA],Object.getOwnPropertyDescriptor(UA.prototype,"fogRange"),UA.prototype),zA=ks(UA.prototype,"_type",[io],(function(){return zT.LINEAR})),HA=ks(UA.prototype,"_fogColor",[io],(function(){return new dn("#C8C8C8")})),WA=ks(UA.prototype,"_enabled",[io],(function(){return!1})),jA=ks(UA.prototype,"_fogDensity",[io],(function(){return.3})),XA=ks(UA.prototype,"_fogStart",[io],(function(){return.5})),qA=ks(UA.prototype,"_fogEnd",[io],(function(){return 300})),YA=ks(UA.prototype,"_fogAtten",[io],(function(){return 5})),KA=ks(UA.prototype,"_fogTop",[io],(function(){return 1.5})),JA=ks(UA.prototype,"_fogRange",[io],(function(){return 1.2})),QA=ks(UA.prototype,"_accurate",[io],(function(){return!1})),GA=UA))||GA)),EE=t("dO",($A=qs("cc.ShadowsInfo"),tb=xo(IT),eb=xo(Ye),ib=xo(Ye),nb=xo(qe),rb=xo(RT),$A((p((ob=function(){function t(){this._enabled=ab&&ab(),this._type=hb&&hb(),this._normal=ub&&ub(),this._distance=lb&&lb(),this._planeBias=cb&&cb(),this._shadowColor=_b&&_b(),this._maxReceived=db&&db(),this._size=fb&&fb(),this._resource=null}var e=t.prototype;return e.setPlaneFromNode=function(t){t.getWorldRotation(vE),this.planeDirection=on.transformQuat(mE,pE,vE),t.getWorldPosition(mE),this.planeHeight=on.dot(this._normal,mE)},e.activate=function(t){this._resource=t,this._resource.initialize(this),this._resource.activate()},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(this._enabled=t,this._resource&&(this._resource.enabled=t,t&&(this._resource.type=this._type)))}},{key:"type",get:function(){return this._type},set:function(t){this._type=t,this._resource&&(this._resource.type=t)}},{key:"shadowColor",get:function(){return this._shadowColor},set:function(t){this._shadowColor.set(t),this._resource&&(this._resource.shadowColor=t)}},{key:"planeDirection",get:function(){return this._normal},set:function(t){on.copy(this._normal,t),this._resource&&(this._resource.normal=t)}},{key:"planeHeight",get:function(){return this._distance},set:function(t){this._distance=t,this._resource&&(this._resource.distance=t)}},{key:"planeBias",get:function(){return this._planeBias},set:function(t){this._planeBias=t,this._resource&&(this._resource.planeBias=t)}},{key:"maxReceived",get:function(){return this._maxReceived},set:function(t){this._maxReceived=t,this._resource&&(this._resource.maxReceived=t)}},{key:"shadowMapSize",get:function(){return this._size.x},set:function(t){this._size.set(t,t),this._resource&&(this._resource.size.set(t,t),this._resource.shadowMapDirty=!0)}}]),t}()).prototype,"type",[tb],Object.getOwnPropertyDescriptor(ob.prototype,"type"),ob.prototype),p(ob.prototype,"planeHeight",[eb],Object.getOwnPropertyDescriptor(ob.prototype,"planeHeight"),ob.prototype),p(ob.prototype,"planeBias",[ib],Object.getOwnPropertyDescriptor(ob.prototype,"planeBias"),ob.prototype),p(ob.prototype,"maxReceived",[nb],Object.getOwnPropertyDescriptor(ob.prototype,"maxReceived"),ob.prototype),p(ob.prototype,"shadowMapSize",[rb],Object.getOwnPropertyDescriptor(ob.prototype,"shadowMapSize"),ob.prototype),ab=ks(ob.prototype,"_enabled",[io],(function(){return!1})),hb=ks(ob.prototype,"_type",[io],(function(){return IT.Planar})),ub=ks(ob.prototype,"_normal",[io],(function(){return new on(0,1,0)})),lb=ks(ob.prototype,"_distance",[io],(function(){return 0})),cb=ks(ob.prototype,"_planeBias",[io],(function(){return 1})),_b=ks(ob.prototype,"_shadowColor",[io],(function(){return new dn(0,0,0,76)})),db=ks(ob.prototype,"_maxReceived",[io],(function(){return 4})),fb=ks(ob.prototype,"_size",[io],(function(){return new Ln(1024,1024)})),sb=ob))||sb));v.ShadowsInfo=EE;var CE=t("dP",new on(-1024,-1024,-1024)),wE=t("dQ",new on(1024,1024,1024)),xE=t("dR",8),RE=t("dS",(pb=qs("cc.OctreeInfo"),mb=xo(qe),pb((p((yb=function(){function t(){this._enabled=vb&&vb(),this._minPos=Sb&&Sb(),this._maxPos=Tb&&Tb(),this._depth=Ab&&Ab(),this._resource=null}return t.prototype.activate=function(t){this._resource=t,this._resource.initialize(this)},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(this._enabled=t,this._resource&&(this._resource.enabled=t))}},{key:"minPos",get:function(){return this._minPos},set:function(t){this._minPos=t,this._resource&&(this._resource.minPos=t)}},{key:"maxPos",get:function(){return this._maxPos},set:function(t){this._maxPos=t,this._resource&&(this._resource.maxPos=t)}},{key:"depth",get:function(){return this._depth},set:function(t){this._depth=t,this._resource&&(this._resource.depth=t)}}]),t}()).prototype,"depth",[mb],Object.getOwnPropertyDescriptor(yb.prototype,"depth"),yb.prototype),vb=ks(yb.prototype,"_enabled",[io],(function(){return!1})),Sb=ks(yb.prototype,"_minPos",[io],(function(){return new on(CE)})),Tb=ks(yb.prototype,"_maxPos",[io],(function(){return new on(wE)})),Ab=ks(yb.prototype,"_depth",[io],(function(){return xE})),gb=yb))||gb));v.OctreeInfo=RE;var IE=t("dT",(bb=qs("cc.SkinInfo"),Eb=xo(Ye),Cb=xo(Ye),bb((p((xb=function(){function t(){this._enabled=Rb&&Rb(),this._blurRadius=Ib&&Ib(),this._sssIntensity=Bb&&Bb(),this._resource=null}return t.prototype.activate=function(t){this._resource=t,this._resource.initialize(this)},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(this._enabled=t,this._resource&&(this._resource.enabled=t))}},{key:"blurRadius",get:function(){return this._blurRadius},set:function(t){this._blurRadius=t,this._resource&&(this._resource.blurRadius=t)}},{key:"sssIntensity",get:function(){return this._sssIntensity},set:function(t){this._sssIntensity=t,this._resource&&(this._resource.sssIntensity=t)}}]),t}()).prototype,"blurRadius",[Eb],Object.getOwnPropertyDescriptor(xb.prototype,"blurRadius"),xb.prototype),p(xb.prototype,"sssIntensity",[Cb],Object.getOwnPropertyDescriptor(xb.prototype,"sssIntensity"),xb.prototype),Rb=ks(xb.prototype,"_enabled",[io],(function(){return!0})),Ib=ks(xb.prototype,"_blurRadius",[io],(function(){return.01})),Bb=ks(xb.prototype,"_sssIntensity",[io],(function(){return 3})),wb=xb))||wb));v.SkinInfo=IE;var BE=t("dU",(Db=qs("cc.PostSettingsInfo"),Pb=xo(dE),Db((p((Mb=function(){function t(){this._toneMappingType=Lb&&Lb(),this._resource=null}return t.prototype.activate=function(t){this._resource=t,this._resource.initialize(this),this._resource.activate()},n(t,[{key:"toneMappingType",get:function(){return this._toneMappingType},set:function(t){this._toneMappingType=t,this._resource&&(this._resource.toneMappingType=t)}}]),t}()).prototype,"toneMappingType",[Pb],Object.getOwnPropertyDescriptor(Mb.prototype,"toneMappingType"),Mb.prototype),Lb=ks(Mb.prototype,"_toneMappingType",[io],(function(){return dE.DEFAULT})),Ob=Mb))||Ob));v.PostSettingsInfo=BE;var DE,PE,OE,ME,LE,NE,FE,kE,VE,GE,UE,zE,HE,WE,jE,XE,qE,YE,KE,JE,QE,ZE,$E,tC,eC,iC,nC,rC,sC,oC,aC,hC,uC,lC,cC,_C,dC,fC,pC,mC,gC,yC,vC,SC,TC,AC,bC,EC,CC,wC,xC,RC,IC,BC,DC,PC,OC,MC,LC,NC,FC,kC,VC,GC,UC,zC,HC,WC,jC,XC=t("dV",(Nb=qs("cc.LightProbeInfo"),Fb=xo(Ye),kb=xo(qe),Vb=xo(qe),Gb=xo(Ye),Ub=xo(Ye),Nb((p((Hb=function(){function t(){this._giScale=Wb&&Wb(),this._giSamples=jb&&jb(),this._bounces=Xb&&Xb(),this._reduceRinging=qb&&qb(),this._showProbe=Yb&&Yb(),this._showWireframe=Kb&&Kb(),this._showConvex=Jb&&Jb(),this._data=Qb&&Qb(),this._lightProbeSphereVolume=Zb&&Zb(),this._nodes=[],this._scene=null,this._resource=null}var e=t.prototype;return e.activate=function(t,e){this._scene=t,this._resource=e,this._resource.initialize(this)},e.onProbeBakeFinished=function(){this.onProbeBakingChanged(this._scene)},e.onProbeBakeCleared=function(){this.clearSHCoefficients(),this.onProbeBakingChanged(this._scene)},e.onProbeBakingChanged=function(t){if(t){t.emit(om.LIGHT_PROBE_BAKING_CHANGED);for(var e=0;e<t.children.length;e++){var i=t.children[e];this.onProbeBakingChanged(i)}}},e.clearSHCoefficients=function(){if(this._data){for(var t=this._data.probes,e=0;e<t.length;e++)t[e].coefficients.length=0;this.clearAllSHUBOs()}},e.isUniqueNode=function(){return 1===this._nodes.length},e.addNode=function(t){if(!t)return!1;for(var e=0;e<this._nodes.length;e++)if(this._nodes[e].node===t)return!1;return this._nodes.push({node:t,probes:null}),!0},e.removeNode=function(t){if(!t)return!1;var e=this._nodes.findIndex((function(e){return e.node===t}));return-1!==e&&(this._nodes.splice(e,1),!0)},e.syncData=function(t,e){for(var i=0;i<this._nodes.length;i++)if(this._nodes[i].node===t)return void(this._nodes[i].probes=e)},e.update=function(t){if(void 0===t&&(t=!0),v.internal.LightProbesData){this._data||(this._data=new v.internal.LightProbesData,this._resource&&(this._resource.data=this._data));for(var e=[],i=0;i<this._nodes.length;i++){var n=this._nodes[i].node,r=this._nodes[i].probes,s=n.worldPosition;if(r)for(var o=0;o<r.length;o++){var a=new on(0,0,0);on.add(a,r[o],s),e.push(a)}}if(e.length<4)return this.resetAllTetraIndices(),void this._data.reset();this._data.updateProbes(e),t&&(this.resetAllTetraIndices(),this._data.updateTetrahedrons())}},e.clearAllSHUBOs=function(){if(this._scene){var t=this._scene.renderScene;if(t)for(var e=t.models,i=0;i<e.length;i++)e[i].clearSHUBOs()}},e.resetAllTetraIndices=function(){if(this._scene){var t=this._scene.renderScene;if(t)for(var e=t.models,i=0;i<e.length;i++)e[i].tetrahedronIndex=-1}},n(t,[{key:"giScale",get:function(){return this._giScale},set:function(t){this._giScale!==t&&(this._giScale=t,this._resource&&(this._resource.giScale=t))}},{key:"giSamples",get:function(){return this._giSamples},set:function(t){this._giSamples!==t&&(this._giSamples=t,this._resource&&(this._resource.giSamples=t))}},{key:"bounces",get:function(){return this._bounces},set:function(t){this._bounces!==t&&(this._bounces=t,this._resource&&(this._resource.bounces=t))}},{key:"reduceRinging",get:function(){return this._reduceRinging},set:function(t){this._reduceRinging!==t&&(this._reduceRinging=t,this._resource&&(this._resource.reduceRinging=t))}},{key:"showProbe",get:function(){return this._showProbe},set:function(t){this._showProbe!==t&&(this._showProbe=t,this._resource&&(this._resource.showProbe=t))}},{key:"showWireframe",get:function(){return this._showWireframe},set:function(t){this._showWireframe!==t&&(this._showWireframe=t,this._resource&&(this._resource.showWireframe=t))}},{key:"showConvex",get:function(){return this._showConvex},set:function(t){this._showConvex!==t&&(this._showConvex=t,this._resource&&(this._resource.showConvex=t))}},{key:"data",get:function(){return this._data},set:function(t){this._data!==t&&(this._data=t,this._resource&&(this._resource.data=t))}},{key:"lightProbeSphereVolume",get:function(){return this._lightProbeSphereVolume},set:function(t){this._lightProbeSphereVolume!==t&&(this._lightProbeSphereVolume=t,this._resource&&(this._resource.lightProbeSphereVolume=t))}}]),t}()).prototype,"giScale",[Fb],Object.getOwnPropertyDescriptor(Hb.prototype,"giScale"),Hb.prototype),p(Hb.prototype,"giSamples",[kb],Object.getOwnPropertyDescriptor(Hb.prototype,"giSamples"),Hb.prototype),p(Hb.prototype,"bounces",[Vb],Object.getOwnPropertyDescriptor(Hb.prototype,"bounces"),Hb.prototype),p(Hb.prototype,"reduceRinging",[Gb],Object.getOwnPropertyDescriptor(Hb.prototype,"reduceRinging"),Hb.prototype),p(Hb.prototype,"lightProbeSphereVolume",[Ub],Object.getOwnPropertyDescriptor(Hb.prototype,"lightProbeSphereVolume"),Hb.prototype),Wb=ks(Hb.prototype,"_giScale",[io],(function(){return 1})),jb=ks(Hb.prototype,"_giSamples",[io],(function(){return 1024})),Xb=ks(Hb.prototype,"_bounces",[io],(function(){return 2})),qb=ks(Hb.prototype,"_reduceRinging",[io],(function(){return 0})),Yb=ks(Hb.prototype,"_showProbe",[io],(function(){return!0})),Kb=ks(Hb.prototype,"_showWireframe",[io],(function(){return!0})),Jb=ks(Hb.prototype,"_showConvex",[io],(function(){return!1})),Qb=ks(Hb.prototype,"_data",[io],(function(){return null})),Zb=ks(Hb.prototype,"_lightProbeSphereVolume",[io],(function(){return 1})),zb=Hb))||zb)),qC=t("dW",($b=qs("cc.SceneGlobals"),tE=xo(AE),$b((iE=function(){function t(){this.ambient=nE&&nE(),this.shadows=rE&&rE(),this._skybox=sE&&sE(),this.fog=oE&&oE(),this.octree=aE&&aE(),this.skin=hE&&hE(),this.lightProbeInfo=uE&&uE(),this.postSettings=lE&&lE(),this.bakedWithStationaryMainLight=cE&&cE(),this.bakedWithHighpLightmap=_E&&_E(),this.disableLightmap=!1}return t.prototype.activate=function(t){var e=v.director.root.pipeline.pipelineSceneData;this.skybox.activate(e.skybox),this.ambient.activate(e.ambient),this.shadows.activate(e.shadows),this.fog.activate(e.fog),this.octree.activate(e.octree),this.skin.activate(e.skin),this.postSettings.activate(e.postSettings),this.lightProbeInfo&&e.lightProbes&&this.lightProbeInfo.activate(t,e.lightProbes),v.director.root.onGlobalPipelineStateChanged()},n(t,[{key:"skybox",get:function(){return this._skybox},set:function(t){this._skybox=t}}]),t}(),nE=ks(iE.prototype,"ambient",[io],(function(){return new TE})),rE=ks(iE.prototype,"shadows",[io],(function(){return new EE})),sE=ks(iE.prototype,"_skybox",[io],(function(){return new AE})),oE=ks(iE.prototype,"fog",[io],(function(){return new bE})),p(iE.prototype,"skybox",[tE],Object.getOwnPropertyDescriptor(iE.prototype,"skybox"),iE.prototype),aE=ks(iE.prototype,"octree",[io],(function(){return new RE})),hE=ks(iE.prototype,"skin",[io],(function(){return new IE})),uE=ks(iE.prototype,"lightProbeInfo",[io],(function(){return new XC})),lE=ks(iE.prototype,"postSettings",[io],(function(){return new BE})),cE=ks(iE.prototype,"bakedWithStationaryMainLight",[io],(function(){return!1})),_E=ks(iE.prototype,"bakedWithHighpLightmap",[io],(function(){return!1})),eE=iE))||eE));v.SceneGlobals=qC;var YC=(DE=qs("cc.TargetInfo"),PE=xo([Je]),DE((ME=function(){this.localID=LE&&LE()},LE=ks(ME.prototype,"localID",[io,PE],(function(){return[]})),OE=ME))||OE),KC=(NE=qs("cc.TargetOverrideInfo"),FE=xo(Ho),kE=xo(YC),VE=xo([Je]),GE=xo(Jm),UE=xo(YC),NE((HE=function(){this.source=WE&&WE(),this.sourceInfo=jE&&jE(),this.propertyPath=XE&&XE(),this.target=qE&&qE(),this.targetInfo=YE&&YE()},WE=ks(HE.prototype,"source",[io,FE],(function(){return null})),jE=ks(HE.prototype,"sourceInfo",[io,kE],(function(){return null})),XE=ks(HE.prototype,"propertyPath",[io,VE],(function(){return[]})),qE=ks(HE.prototype,"target",[io,GE],(function(){return null})),YE=ks(HE.prototype,"targetInfo",[io,UE],(function(){return null})),zE=HE))||zE),JC=qs("cc.CompPrefabInfo")((JE=function(){this.fileId=QE&&QE()},QE=ks(JE.prototype,"fileId",[io],(function(){return""})),KE=JE))||KE,QC=(ZE=qs("CCPropertyOverrideInfo"),$E=xo(YC),tC=xo([Je]),ZE((iC=function(){function t(){this.targetInfo=nC&&nC(),this.propertyPath=rC&&rC(),this.value=sC&&sC()}return t.prototype.isTarget=function(){},t}(),nC=ks(iC.prototype,"targetInfo",[io,$E],(function(){return null})),rC=ks(iC.prototype,"propertyPath",[io,tC],(function(){return[]})),sC=ks(iC.prototype,"value",[io],null),eC=iC))||eC),ZC=(oC=qs("cc.MountedChildrenInfo"),aC=xo(YC),hC=xo([Jm]),oC((lC=function(){function t(){this.targetInfo=cC&&cC(),this.nodes=_C&&_C()}return t.prototype.isTarget=function(){},t}(),cC=ks(lC.prototype,"targetInfo",[io,aC],(function(){return null})),_C=ks(lC.prototype,"nodes",[io,hC],(function(){return[]})),uC=lC))||uC),$C=(dC=qs("cc.MountedComponentsInfo"),fC=xo(YC),pC=xo([rp]),dC((gC=function(){function t(){this.targetInfo=yC&&yC(),this.components=vC&&vC()}return t.prototype.isTarget=function(){},t}(),yC=ks(gC.prototype,"targetInfo",[io,fC],(function(){return null})),vC=ks(gC.prototype,"components",[io,pC],(function(){return[]})),mC=gC))||mC),tw=(SC=qs("cc.PrefabInstance"),TC=xo(Jm),AC=xo([ZC]),bC=xo([$C]),EC=xo([QC]),CC=xo([YC]),SC((xC=function(){function t(){this.fileId=RC&&RC(),this.prefabRootNode=IC&&IC(),this.mountedChildren=BC&&BC(),this.mountedComponents=DC&&DC(),this.propertyOverrides=PC&&PC(),this.removedComponents=OC&&OC(),this.targetMap={},this.expanded=!1}var e=t.prototype;return e.findPropertyOverride=function(){},e.removePropertyOverride=function(){},t}(),RC=ks(xC.prototype,"fileId",[io],(function(){return""})),IC=ks(xC.prototype,"prefabRootNode",[io,TC],null),BC=ks(xC.prototype,"mountedChildren",[io,AC],(function(){return[]})),DC=ks(xC.prototype,"mountedComponents",[io,bC],(function(){return[]})),PC=ks(xC.prototype,"propertyOverrides",[io,EC],(function(){return[]})),OC=ks(xC.prototype,"removedComponents",[io,CC],(function(){return[]})),wC=xC))||wC),ew=(MC=qs("cc.PrefabInfo"),LC=xo(Jm),NC=xo(tw),FC=xo([KC]),MC((VC=function(){this.root=GC&&GC(),this.asset=UC&&UC(),this.fileId=zC&&zC(),this.instance=HC&&HC(),this.targetOverrides=WC&&WC(),this.nestedPrefabInstanceRoots=jC&&jC()},GC=ks(VC.prototype,"root",[io,LC],null),UC=ks(VC.prototype,"asset",[io],null),zC=ks(VC.prototype,"fileId",[io],(function(){return""})),HC=ks(VC.prototype,"instance",[io,NC],null),WC=ks(VC.prototype,"targetOverrides",[io,FC],null),jC=ks(VC.prototype,"nestedPrefabInstanceRoots",[io],null),kC=VC))||kC);function iw(t){var e=null==t?void 0:t.prefab;if(e&&e.instance){if(!e.asset)return J(3701,t.name),void(e.instance=void 0);var i=t._objFlags,n=t.getParent(),r=t.uuid;t[Io],v.game._isCloning=!0,e.asset._doInstantiate(t),v.game._isCloning=!1,t._objFlags=i,t.modifyParent(n),t.id=r,t.prefab&&(t.prefab.instance=e.instance)}}function nw(t,e,i){var n;if(e&&t){var r=e,s=null===(n=t.prefab)||void 0===n?void 0:n.instance;!i&&s&&(e[s.fileId]={},r=e[s.fileId]);var o=t.prefab;o&&(r[o.fileId]=t);for(var a=t.components,h=0;h<a.length;h++){var u=a[h];u.__prefab&&(r[u.__prefab.fileId]=u)}for(var l=0;l<t.children.length;l++)nw(t.children[l],r,!1)}}function rw(t,e){if(!t)return null;for(var i=e,n=0;n<t.length;n++){if(!i)return null;i=i[t[n]]}return i}function sw(t,e,i){if(e)for(var n=0;n<e.length;n++){var r=e[n];if(r&&r.targetInfo){var s=rw(r.targetInfo.localID,i);if(!s)continue;var o=i,a=r.targetInfo.localID;if(a.length>0)for(var h=0;h<a.length-1;h++)o=o[a[h]];if(r.nodes)for(var u=0;u<r.nodes.length;u++){var l=r.nodes[u];l&&!s.children.includes(l)&&(s.children.push(l),l.modifyParent(s),nw(l,o,!1),l.siblingIndex=s.children.length-1,lw(l,!0))}}}}function ow(t,e,i){if(e)for(var n=0;n<e.length;n++){var r=e[n];if(r&&r.targetInfo){var s=rw(r.targetInfo.localID,i);if(!s)continue;if(r.components)for(var o=0;o<r.components.length;o++){var a=r.components[o];a&&(a.node=s,s.getWritableComponents().push(a))}}}}function aw(t,e,i){if(e)for(var n=0;n<e.length;n++){var r=e[n];if(r){var s=rw(r.localID,i);if(!s||!s.node)continue;var o=s.node.components.indexOf(s);o>=0&&s.node.getWritableComponents().splice(o,1)}}}function hw(t,e,i){if(!(e.length<=0))for(var n=null,r=0;r<e.length;r++){var s=e[r];if(s&&s.targetInfo){if(!(n=rw(s.targetInfo.localID,i)))continue;var o=n,a=s.propertyPath.slice();if(a.length>0){var h=a.pop();if(!h)continue;for(var u=0;u<a.length&&(o=o[a[u]]);u++);if(!o)continue;if(Array.isArray(o))if("length"===h)o[h]=s.value;else{var l=Number.parseInt(h);Number.isInteger(l)&&l<o.length&&(o[h]=s.value)}else o[h]instanceof Ae?o[h].set(s.value):o[h]=s.value}}}}function uw(t){var e,i=null===(e=t.prefab)||void 0===e?void 0:e.targetOverrides;if(i)for(var n=0;n<i.length;n++){var r,s=i[n],o=s.source,a=s.sourceInfo;if(a){var h,u=s.source,l=null==u||null===(h=u.prefab)||void 0===h?void 0:h.instance;l&&l.targetMap&&(o=rw(a.localID,l.targetMap))}if(o){var c,_=s.targetInfo;if(_){var d=s.target,f=null==d||null===(r=d.prefab)||void 0===r?void 0:r.instance;if(f&&f.targetMap&&(c=rw(_.localID,f.targetMap))){var p=s.propertyPath.slice(),m=o;if(p.length>0){var g=p.pop();if(!g)return;for(var y=0;y<p.length&&(m=m[p[y]]);y++);if(!m)continue;m[g]=c}}}}}}function lw(t,e){var i;void 0===e&&(e=!1);var n=null==t||null===(i=t.prefab)||void 0===i?void 0:i.instance;if(n&&!n.expanded){iw(t),e&&t&&t.children&&t.children.forEach((function(t){lw(t,!0)}));var r={};n.targetMap=r,nw(t,r,!0),sw(0,n.mountedChildren,r),aw(0,n.removedComponents,r),ow(0,n.mountedComponents,r),hw(0,n.propertyOverrides,r),n.expanded=!0}else e&&t&&t.children&&t.children.forEach((function(t){lw(t,!0)}))}function cw(t){var e=t.prefab;e&&e.nestedPrefabInstanceRoots&&e.nestedPrefabInstanceRoots.forEach((function(t){lw(t)}))}v._PrefabInfo=ew;var _w,dw,fw,pw,mw,gw,yw,vw=Object.freeze({__proto__:null,createNodeWithPrefab:iw,generateTargetMap:nw,getTarget:rw,applyMountedChildren:sw,applyMountedComponents:ow,applyRemovedComponents:aw,applyPropertyOverrides:hw,applyTargetOverrides:uw,expandPrefabInstanceNode:lw,expandNestedPrefabInstanceNode:cw,applyNodeAndComponentId:function t(e,i){for(var n=e.components,r=e.children,s=0;s<n.length;s++){var o,a,h=n[s],u=null!==(o=null===(a=h.__prefab)||void 0===a?void 0:a.fileId)&&void 0!==o?o:"";h._id=""+i+u}for(var l=0;l<r.length;l++){var c=r[l],_=c.prefab,d=null!=_&&_.instance?_.instance.fileId:null==_?void 0:_.fileId;d&&(c.id=""+i+d,null!=_&&_.instance||t(c,i))}},TargetInfo:YC,TargetOverrideInfo:KC,CompPrefabInfo:JC,PropertyOverrideInfo:QC,MountedChildrenInfo:ZC,MountedComponentsInfo:$C,PrefabInstance:tw,PrefabInfo:ew}),Sw=t("dA",qs("cc.Scene")((dw=function(t){s(i,t);var e=i.prototype;function i(e){var i;return(i=t.call(this,e)||this).autoReleaseAssets=fw&&fw(),i._globals=pw&&pw(),i.dependAssets=null,i._renderScene=null,i._inited=void 0,i._prefabSyncedInLiveReload=!1,i._activeInHierarchy=!1,v.director&&v.director.root&&(i._renderScene=v.director.root.createScene({})),i._inited=!v.game||!v.game._isCloning,i}return e._updateScene=function(){this._scene=this},e.destroy=function(){var t=Ho.prototype.destroy.call(this);if(t)for(var e=this._children,i=0;i<e.length;++i)e[i].active=!1;return this._renderScene&&v.director.root.destroyScene(this._renderScene),this._active=!1,this._activeInHierarchy=!1,t},e.addComponent=function(){throw new Error(tt(3822))},e._onHierarchyChanged=function(){},e._onPostActivated=function(){},e._onBatchCreated=function(t){for(var e=this._children.length,i=0;i<e;++i)this._children[i]._siblingIndex=i,this._children[i]._onBatchCreated(t)},e.updateWorldTransform=function(){},e._instantiate=function(){},e._load=function(){this._inited||(cw(this),uw(this),this._onBatchCreated(g),this._inited=!0),this.walk(Jm._setScene)},e._activate=function(t){void 0===t&&(t=!0),v.director._nodeActivator.activateNode(this,t),this._globals.activate(this)},n(i,[{key:"renderScene",get:function(){return this._renderScene}},{key:"globals",get:function(){return this._globals}}]),i}(Jm),fw=ks(dw.prototype,"autoReleaseAssets",[io],(function(){return!1})),pw=ks(dw.prototype,"_globals",[io],(function(){return new qC})),_w=dw))||_w);v.Scene=Sw;var Tw=t("eb",qs("cc.SceneAsset")((gw=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).scene=yw&&yw(),e}s(e,t);var i=e.prototype;return i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.scene=new Sw("New Scene")},i.validate=function(){return!!this.scene},e}(of),yw=ks(gw.prototype,"scene",[io],(function(){return null})),mw=gw))||mw);v.SceneAsset=Tw,pt({SystemEventType:{newName:"Input.EventType",since:"3.3.0",removed:!1}}),pt({SystemEvent:{newName:"Input",since:"3.4.0",removed:!1},systemEvent:{newName:"input",since:"3.4.0",removed:!1}});var Aw,bw,Ew=t("ey",function(){function t(t,e){this.type=void 0,this.bubbles=void 0,this.target=null,this.currentTarget=null,this.eventPhase=0,this.propagationStopped=!1,this.propagationImmediateStopped=!1,this.type=t,this.bubbles=!!e}var e=t.prototype;return e.unuse=function(){this.type=t.NO_TYPE,this.target=null,this.currentTarget=null,this.eventPhase=t.NONE,this.propagationStopped=!1,this.propagationImmediateStopped=!1},e.reuse=function(t,e){this.type=t,this.bubbles=e||!1},e.isStopped=function(){return this.propagationStopped||this.propagationImmediateStopped},e.getCurrentTarget=function(){return this.currentTarget},e.getType=function(){return this.type},t}());Ew.NO_TYPE="no_type",Ew.TOUCH="touch",Ew.MOUSE="mouse",Ew.KEYBOARD="keyboard",Ew.ACCELERATION="acceleration",Ew.NONE=0,Ew.CAPTURING_PHASE=1,Ew.AT_TARGET=2,Ew.BUBBLING_PHASE=3,v.Event=Ew,t("ex",Aw),function(t){t.TOUCH_START="touch-start",t.TOUCH_MOVE="touch-move",t.TOUCH_END="touch-end",t.TOUCH_CANCEL="touch-cancel",t.MOUSE_DOWN="mouse-down",t.MOUSE_MOVE="mouse-move",t.MOUSE_UP="mouse-up",t.MOUSE_WHEEL="mouse-wheel",t.MOUSE_ENTER="mouse-enter",t.MOUSE_LEAVE="mouse-leave",t.KEY_DOWN="keydown",t.KEY_UP="keyup",t.DEVICEMOTION="devicemotion",t.TRANSFORM_CHANGED="transform-changed",t.SCENE_CHANGED_FOR_PERSISTS="scene-changed-for-persists",t.SIZE_CHANGED="size-changed",t.ANCHOR_CHANGED="anchor-changed",t.COLOR_CHANGED="color-changed",t.CHILD_ADDED="child-added",t.CHILD_REMOVED="child-removed",t.PARENT_CHANGED="parent-changed",t.NODE_DESTROYED="node-destroyed",t.LAYER_CHANGED="layer-changed",t.SIBLING_ORDER_CHANGED="sibling-order-changed"}(Aw||t("ex",Aw={})),function(t){t.TOUCH_START="touch-start",t.TOUCH_MOVE="touch-move",t.TOUCH_END="touch-end",t.TOUCH_CANCEL="touch-cancel",t.MOUSE_DOWN="mouse-down",t.MOUSE_MOVE="mouse-move",t.MOUSE_UP="mouse-up",t.MOUSE_WHEEL="mouse-wheel",t.KEY_DOWN="keydown",t.KEY_PRESSING="key-pressing",t.KEY_UP="keyup",t.DEVICEMOTION="devicemotion",t.GAMEPAD_INPUT="gamepad-input",t.GAMEPAD_CHANGE="gamepad-change",t.HANDLE_INPUT="handle-input",t.HANDLE_POSE_INPUT="handle-pose-input",t.HMD_POSE_INPUT="hmd-pose-input",t.HANDHELD_POSE_INPUT="handheld-pose-input"}(bw||(bw={})),v.SystemEventType=Aw;var Cw=t("ez",function(t){function e(e,i){var n;return(n=t.call(this,Aw.DEVICEMOTION,i)||this).acc=void 0,n.acc=e,n}return s(e,t),e}(Ew));Ew.EventAcceleration=Cw;var ww=t("eA",function(t){function e(e,i,n){var r;return"boolean"==typeof i&&(i=i?Aw.KEY_DOWN:Aw.KEY_UP),(r=t.call(this,i,n)||this).windowId=void 0,r.keyCode=void 0,r.rawEvent=void 0,r._isPressed=void 0,r._isPressed=i!==Aw.KEY_UP,"number"==typeof e?r.keyCode=e:(r.keyCode=e.keyCode,r.rawEvent=e),r.windowId=0,r}return s(e,t),n(e,[{key:"isPressed",get:function(){return this._isPressed}}]),e}(Ew));Ew.EventKeyboard=ww;var xw=t("eB",function(t){function e(i,n,r,s){var o;return(o=t.call(this,i,n)||this).movementX=0,o.movementY=0,o.windowId=0,o.preventSwallow=!1,o._eventType=void 0,o._button=e.BUTTON_MISSING,o._x=0,o._y=0,o._prevX=0,o._prevY=0,o._scrollX=0,o._scrollY=0,o._eventType=i,r&&(o._prevX=r.x,o._prevY=r.y),o.windowId=null!=s?s:o.windowId,o}s(e,t);var i=e.prototype;return i.setScrollData=function(t,e){this._scrollX=t,this._scrollY=e},i.getScrollX=function(){return this._scrollX},i.getScrollY=function(){return this._scrollY},i.setLocation=function(t,e){this._x=t,this._y=e},i.getLocation=function(t){return t||(t=new Ln),Ln.set(t,this._x,this._y),t},i.getLocationInView=function(t){return t||(t=new Ln),Ln.set(t,this._x,v.view._designResolutionSize.height-this._y),t},i.getUILocation=function(t){return t||(t=new Ln),Ln.set(t,this._x,this._y),v.view._convertToUISpace(t),t},i.getPreviousLocation=function(t){return t||(t=new Ln),Ln.set(t,this._prevX,this._prevY),t},i.getUIPreviousLocation=function(t){return t||(t=new Ln),Ln.set(t,this._prevX,this._prevY),v.view._convertToUISpace(t),t},i.getDelta=function(t){return t||(t=new Ln),Ln.set(t,this._x-this._prevX,this._y-this._prevY),t},i.getDeltaX=function(){return this._x-this._prevX},i.getDeltaY=function(){return this._y-this._prevY},i.getUIDelta=function(t){return t||(t=new Ln),Ln.set(t,(this._x-this._prevX)/v.view.getScaleX(),(this._y-this._prevY)/v.view.getScaleY()),t},i.getUIDeltaX=function(){return(this._x-this._prevX)/v.view.getScaleX()},i.getUIDeltaY=function(){return(this._y-this._prevY)/v.view.getScaleY()},i.setButton=function(t){this._button=t},i.getButton=function(){return this._button},i.getLocationX=function(){return this._x},i.getLocationY=function(){return this._y},i.getUILocationX=function(){var t=v.view.getViewportRect();return(this._x-t.x)/v.view.getScaleX()},i.getUILocationY=function(){var t=v.view.getViewportRect();return(this._y-t.y)/v.view.getScaleY()},n(e,[{key:"eventType",get:function(){return this._eventType}}]),e}(Ew));xw.BUTTON_MISSING=-1,xw.BUTTON_LEFT=0,xw.BUTTON_RIGHT=2,xw.BUTTON_MIDDLE=1,xw.BUTTON_4=3,xw.BUTTON_5=4,xw.BUTTON_6=5,xw.BUTTON_7=6,xw.BUTTON_8=7,Ew.EventMouse=xw;var Rw=new Ln,Iw=t("eC",function(t){function e(e,i,n,r){var s;return void 0===r&&(r=[]),(s=t.call(this,n,i)||this).touch=null,s.simulate=!1,s.windowId=0,s.preventSwallow=!1,s._eventCode=void 0,s._touches=void 0,s._allTouches=void 0,s._eventCode=n,s._touches=e||[],s._allTouches=r,s}s(e,t);var i=e.prototype;return i.getEventCode=function(){return this._eventCode},i.getTouches=function(){return this._touches},i.getAllTouches=function(){return this._allTouches},i.setLocation=function(t,e){this.touch&&this.touch.setTouchInfo(this.touch.getID(),t,e)},i.getLocation=function(t){return this.touch?this.touch.getLocation(t):new Ln},i.getUILocation=function(t){return this.touch?this.touch.getUILocation(t):new Ln},i.getLocationInView=function(t){return this.touch?this.touch.getLocationInView(t):new Ln},i.getPreviousLocation=function(t){return this.touch?this.touch.getPreviousLocation(t):new Ln},i.getStartLocation=function(t){return this.touch?this.touch.getStartLocation(t):new Ln},i.getUIStartLocation=function(t){return this.touch?this.touch.getUIStartLocation(t):new Ln},i.getID=function(){return this.touch?this.touch.getID():null},i.getDelta=function(t){return this.touch?this.touch.getDelta(t):new Ln},i.getUIDelta=function(t){return this.touch?this.touch.getUIDelta(t):new Ln},i.getDeltaX=function(){return this.touch?this.touch.getDelta(Rw).x:0},i.getDeltaY=function(){return this.touch?this.touch.getDelta(Rw).y:0},i.getLocationX=function(){return this.touch?this.touch.getLocationX():0},i.getLocationY=function(){return this.touch?this.touch.getLocationY():0},e}(Ew));Iw.MAX_TOUCHES=5,Ew.EventTouch=Iw;var Bw,Dw=t("eD",function(t){function e(e,i){var n;return(n=t.call(this,e,!1)||this).gamepad=void 0,n.gamepad=i,n}return s(e,t),e}(Ew)),Pw=t("eE",function(t){function e(e,i){var n;return(n=t.call(this,e,!1)||this).handleInputDevice=void 0,n.handleInputDevice=i,n}return s(e,t),e}(Ew)),Ow=t("eF",function(t){function e(e,i){var n;return(n=t.call(this,e,!1)||this).hmdInputDevice=void 0,n.hmdInputDevice=i,n}return s(e,t),e}(Ew)),Mw=(t("eG",function(t){function e(e,i){var n;return(n=t.call(this,e,!1)||this).handheldInputDevice=void 0,n.handheldInputDevice=i,n}return s(e,t),e}(Ew)),t("eH",(function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=void 0,this.y=void 0,this.z=void 0,this.timestamp=void 0,this.x=t,this.y=e,this.z=i,this.timestamp=n})));t("eI",Bw),function(t){t[t.NONE=0]="NONE",t[t.MOBILE_BACK=6]="MOBILE_BACK",t[t.BACKSPACE=8]="BACKSPACE",t[t.TAB=9]="TAB",t[t.ENTER=13]="ENTER",t[t.SHIFT_LEFT=16]="SHIFT_LEFT",t[t.CTRL_LEFT=17]="CTRL_LEFT",t[t.ALT_LEFT=18]="ALT_LEFT",t[t.PAUSE=19]="PAUSE",t[t.CAPS_LOCK=20]="CAPS_LOCK",t[t.ESCAPE=27]="ESCAPE",t[t.SPACE=32]="SPACE",t[t.PAGE_UP=33]="PAGE_UP",t[t.PAGE_DOWN=34]="PAGE_DOWN",t[t.END=35]="END",t[t.HOME=36]="HOME",t[t.ARROW_LEFT=37]="ARROW_LEFT",t[t.ARROW_UP=38]="ARROW_UP",t[t.ARROW_RIGHT=39]="ARROW_RIGHT",t[t.ARROW_DOWN=40]="ARROW_DOWN",t[t.INSERT=45]="INSERT",t[t.DELETE=46]="DELETE",t[t.DIGIT_0=48]="DIGIT_0",t[t.DIGIT_1=49]="DIGIT_1",t[t.DIGIT_2=50]="DIGIT_2",t[t.DIGIT_3=51]="DIGIT_3",t[t.DIGIT_4=52]="DIGIT_4",t[t.DIGIT_5=53]="DIGIT_5",t[t.DIGIT_6=54]="DIGIT_6",t[t.DIGIT_7=55]="DIGIT_7",t[t.DIGIT_8=56]="DIGIT_8",t[t.DIGIT_9=57]="DIGIT_9",t[t.KEY_A=65]="KEY_A",t[t.KEY_B=66]="KEY_B",t[t.KEY_C=67]="KEY_C",t[t.KEY_D=68]="KEY_D",t[t.KEY_E=69]="KEY_E",t[t.KEY_F=70]="KEY_F",t[t.KEY_G=71]="KEY_G",t[t.KEY_H=72]="KEY_H",t[t.KEY_I=73]="KEY_I",t[t.KEY_J=74]="KEY_J",t[t.KEY_K=75]="KEY_K",t[t.KEY_L=76]="KEY_L",t[t.KEY_M=77]="KEY_M",t[t.KEY_N=78]="KEY_N",t[t.KEY_O=79]="KEY_O",t[t.KEY_P=80]="KEY_P",t[t.KEY_Q=81]="KEY_Q",t[t.KEY_R=82]="KEY_R",t[t.KEY_S=83]="KEY_S",t[t.KEY_T=84]="KEY_T",t[t.KEY_U=85]="KEY_U",t[t.KEY_V=86]="KEY_V",t[t.KEY_W=87]="KEY_W",t[t.KEY_X=88]="KEY_X",t[t.KEY_Y=89]="KEY_Y",t[t.KEY_Z=90]="KEY_Z",t[t.NUM_0=96]="NUM_0",t[t.NUM_1=97]="NUM_1",t[t.NUM_2=98]="NUM_2",t[t.NUM_3=99]="NUM_3",t[t.NUM_4=100]="NUM_4",t[t.NUM_5=101]="NUM_5",t[t.NUM_6=102]="NUM_6",t[t.NUM_7=103]="NUM_7",t[t.NUM_8=104]="NUM_8",t[t.NUM_9=105]="NUM_9",t[t.NUM_MULTIPLY=106]="NUM_MULTIPLY",t[t.NUM_PLUS=107]="NUM_PLUS",t[t.NUM_SUBTRACT=109]="NUM_SUBTRACT",t[t.NUM_DECIMAL=110]="NUM_DECIMAL",t[t.NUM_DIVIDE=111]="NUM_DIVIDE",t[t.F1=112]="F1",t[t.F2=113]="F2",t[t.F3=114]="F3",t[t.F4=115]="F4",t[t.F5=116]="F5",t[t.F6=117]="F6",t[t.F7=118]="F7",t[t.F8=119]="F8",t[t.F9=120]="F9",t[t.F10=121]="F10",t[t.F11=122]="F11",t[t.F12=123]="F12",t[t.NUM_LOCK=144]="NUM_LOCK",t[t.SCROLL_LOCK=145]="SCROLL_LOCK",t[t.SEMICOLON=186]="SEMICOLON",t[t.EQUAL=187]="EQUAL",t[t.COMMA=188]="COMMA",t[t.DASH=189]="DASH",t[t.PERIOD=190]="PERIOD",t[t.SLASH=191]="SLASH",t[t.BACK_QUOTE=192]="BACK_QUOTE",t[t.BRACKET_LEFT=219]="BRACKET_LEFT",t[t.BACKSLASH=220]="BACKSLASH",t[t.BRACKET_RIGHT=221]="BRACKET_RIGHT",t[t.QUOTE=222]="QUOTE",t[t.SHIFT_RIGHT=2e3]="SHIFT_RIGHT",t[t.CTRL_RIGHT=2001]="CTRL_RIGHT",t[t.ALT_RIGHT=2002]="ALT_RIGHT",t[t.NUM_ENTER=2003]="NUM_ENTER"}(Bw||t("eI",Bw={}));var Lw=new Ln,Nw=t("eJ",function(){function t(t,e,i){void 0===i&&(i=0),this._point=new Ln,this._prevPoint=new Ln,this._lastModified=0,this._id=0,this._startPoint=new Ln,this._startPointCaptured=!1,this.setTouchInfo(i,t,e)}var e=t.prototype;return e.getLocation=function(t){return t||(t=new Ln),t.set(this._point.x,this._point.y),t},e.getLocationX=function(){return this._point.x},e.getLocationY=function(){return this._point.y},e.getUILocation=function(t){return t||(t=new Ln),t.set(this._point.x,this._point.y),v.view._convertToUISpace(t),t},e.getUILocationX=function(){var t=v.view.getViewportRect();return(this._point.x-t.x)/v.view.getScaleX()},e.getUILocationY=function(){var t=v.view.getViewportRect();return(this._point.y-t.y)/v.view.getScaleY()},e.getPreviousLocation=function(t){return t||(t=new Ln),t.set(this._prevPoint.x,this._prevPoint.y),t},e.getUIPreviousLocation=function(t){return t||(t=new Ln),t.set(this._prevPoint.x,this._prevPoint.y),v.view._convertToUISpace(t),t},e.getStartLocation=function(t){return t||(t=new Ln),t.set(this._startPoint.x,this._startPoint.y),t},e.getUIStartLocation=function(t){return t||(t=new Ln),t.set(this._startPoint.x,this._startPoint.y),v.view._convertToUISpace(t),t},e.getDelta=function(t){return t||(t=new Ln),t.set(this._point),t.subtract(this._prevPoint),t},e.getUIDelta=function(t){return t||(t=new Ln),Lw.set(this._point),Lw.subtract(this._prevPoint),t.set(v.view.getScaleX(),v.view.getScaleY()),Ln.divide(t,Lw,t),t},e.getLocationInView=function(t){return t||(t=new Ln),t.set(this._point.x,v.view._designResolutionSize.height-this._point.y),t},e.getPreviousLocationInView=function(t){return t||(t=new Ln),t.set(this._prevPoint.x,v.view._designResolutionSize.height-this._prevPoint.y),t},e.getStartLocationInView=function(t){return t||(t=new Ln),t.set(this._startPoint.x,v.view._designResolutionSize.height-this._startPoint.y),t},e.getID=function(){return this._id},e.setTouchInfo=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this._prevPoint=this._point,this._point=new Ln(e||0,i||0),this._id=t,this._startPointCaptured||(this._startPoint=new Ln(this._point),this._startPointCaptured=!0)},e.setPoint=function(t,e){"object"==typeof t?(this._point.x=t.x,this._point.y=t.y):(this._point.x=t||0,this._point.y=e||0),this._lastModified=v.game.frameStartTime},e.setPrevPoint=function(t,e){this._prevPoint="object"==typeof t?new Ln(t.x,t.y):new Ln(t||0,e||0),this._lastModified=v.game.frameStartTime},e.clone=function(){var e=this.getID();this.getStartLocation(Lw);var i=new t(Lw.x,Lw.y,e);return this.getLocation(Lw),i.setPoint(Lw.x,Lw.y),this.getPreviousLocation(Lw),i.setPrevPoint(Lw),i},n(t,[{key:"lastModified",get:function(){return this._lastModified}}]),t}());v.Touch=Nw;var Fw=function(){function t(){this._intervalInMileSeconds=200,this._accelTimer=0,this._eventTarget=new Ku,this._deviceEventName=void 0,this._globalEventClass=void 0,this._didAccelerateFunc=void 0,this._globalEventClass=window.DeviceMotionEvent||window.DeviceOrientationEvent,nl.browserType===Ju.MOBILE_QQ&&(this._globalEventClass=window.DeviceOrientationEvent),this._deviceEventName=this._globalEventClass===window.DeviceMotionEvent?"devicemotion":"deviceorientation",this._didAccelerateFunc=this._didAccelerate.bind(this)}var e=t.prototype;return e._registerEvent=function(){this._accelTimer=performance.now(),window.addEventListener(this._deviceEventName,this._didAccelerateFunc,!1)},e._unregisterEvent=function(){this._accelTimer=0,window.removeEventListener(this._deviceEventName,this._didAccelerateFunc,!1)},e._didAccelerate=function(t){var e=performance.now();if(!(e-this._accelTimer<this._intervalInMileSeconds)){this._accelTimer=e;var i=0,n=0,r=0;if(this._globalEventClass===window.DeviceMotionEvent){var s=t.accelerationIncludingGravity;i=.1*((null==s?void 0:s.x)||0),n=.1*((null==s?void 0:s.y)||0),r=.1*((null==s?void 0:s.z)||0)}else{var o=t;i=(o.gamma||0)/90*.981,n=-(o.beta||0)/90*.981,r=(o.alpha||0)/90*.981}if(El.isFrameRotated){var a=i;i=-n,n=a}var h=i;90===window.orientation?(i=-n,n=h):-90===window.orientation?(i=n,n=-h):180===window.orientation&&(i=-i,n=-n),nl.os===$u.ANDROID&&nl.browserType!==Ju.MOBILE_QQ&&(i=-i,n=-n);var u=performance.now(),l=new Mw(i,n,r,u),c=new Cw(l);this._eventTarget.emit(bw.DEVICEMOTION,c)}},e.start=function(){var t=this;window.DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceMotionEvent.requestPermission().then((function(e){"granted"===e&&t._registerEvent()})).catch((function(t){k(t)})):this._registerEvent()},e.stop=function(){this._unregisterEvent()},e.setInterval=function(t){this._intervalInMileSeconds=t},e.on=function(t,e,i){this._eventTarget.on(t,e,i)},t}(),kw=function(){},Vw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){throw new Error("Method not implemented.")},e}(kw),Gw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){throw new Error("Method not implemented.")},e}(kw),Uw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){throw new Error("Method not implemented.")},e}(kw),zw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){throw new Error("Method not implemented.")},e}(kw),Hw=function(t){function e(e){var i;return(i=t.call(this)||this).positive=void 0,i.negative=void 0,i.positive=e.positive,i.negative=e.negative,i}return s(e,t),e.prototype.getValue=function(){var t=this.positive.getValue(),e=this.negative.getValue();return Math.abs(t)>Math.abs(e)?t:-e},e}(Vw),Ww=function(t){function e(e){var i;return(i=t.call(this)||this).up=void 0,i.down=void 0,i.left=void 0,i.right=void 0,i.xAxis=void 0,i.yAxis=void 0,i.up=e.up,i.down=e.down,i.left=e.left,i.right=e.right,i.xAxis=new Hw({positive:i.right,negative:i.left}),i.yAxis=new Hw({positive:i.up,negative:i.down}),i}return s(e,t),e.prototype.getValue=function(){return new Ln(this.xAxis.getValue(),this.yAxis.getValue())},e}(Gw);!function(t){function e(e){var i;return(i=t.call(this)||this).up=void 0,i.down=void 0,i.left=void 0,i.right=void 0,i.forward=void 0,i.backward=void 0,i.xAxis=void 0,i.yAxis=void 0,i.zAxis=void 0,i.up=e.up,i.down=e.down,i.left=e.left,i.right=e.right,i.forward=e.forward,i.backward=e.backward,i.xAxis=new Hw({positive:i.right,negative:i.left}),i.yAxis=new Hw({positive:i.up,negative:i.down}),i.zAxis=new Hw({positive:i.forward,negative:i.backward}),i}s(e,t),e.prototype.getValue=function(){return new on(this.xAxis.getValue(),this.yAxis.getValue(),this.zAxis.getValue())}}(Uw);var jw,Xw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){return t.prototype.getValue.call(this)},e}(Vw),qw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Ww),Yw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Ww),Kw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){return t.prototype.getValue.call(this)},e}(zw),Jw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){return t.prototype.getValue.call(this)},e}(Uw),Qw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){return t.prototype.getValue.call(this)},e}(Vw),Zw="left",$w="right",tx=[];!function(t){t[t.HAND_LEFT=1]="HAND_LEFT",t[t.HAND_RIGHT=4]="HAND_RIGHT",t[t.AIM_LEFT=2]="AIM_LEFT",t[t.AIM_RIGHT=5]="AIM_RIGHT"}(jw||(jw={}));var ex,ix,nx,rx,sx,ox=function(){function t(t){var e;this._buttonNorth=void 0,this._buttonEast=void 0,this._buttonWest=void 0,this._buttonSouth=void 0,this._buttonL1=void 0,this._buttonL2=void 0,this._buttonL3=void 0,this._buttonR1=void 0,this._buttonR2=void 0,this._buttonR3=void 0,this._buttonShare=void 0,this._buttonOptions=void 0,this._dpad=void 0,this._leftStick=void 0,this._rightStick=void 0,this._buttonStart=void 0,this._gripLeft=void 0,this._gripRight=void 0,this._handLeftPosition=void 0,this._handLeftOrientation=void 0,this._handRightPosition=void 0,this._handRightOrientation=void 0,this._aimLeftPosition=void 0,this._aimLeftOrientation=void 0,this._aimRightPosition=void 0,this._aimRightOrientation=void 0,this._deviceId=-1,this._connected=!1,this._webPoseState=((e={})[jw.HAND_LEFT]={position:on.ZERO,orientation:Sn.IDENTITY},e[jw.HAND_RIGHT]={position:on.ZERO,orientation:Sn.IDENTITY},e[jw.AIM_LEFT]={position:on.ZERO,orientation:Sn.IDENTITY},e[jw.AIM_RIGHT]={position:on.ZERO,orientation:Sn.IDENTITY},e),this._deviceId=t,this._initInputSource()}t._init=function(){nl.hasFeature(el.EVENT_GAMEPAD)&&t._registerEvent()},t._on=function(e,i,n){t._eventTarget.on(e,i,n)},t._removeInputDevice=function(e){var i=t.all.findIndex((function(t){return t.deviceId===e}));-1!==i&&ae(t.all,i)},t._getOrCreateInputDevice=function(e,i){var n=t.all.find((function(t){return t.deviceId===e}));return n||(n=new t(e),t.all.push(n)),n._connected=i,n},t._ensureDirectorDefined=function(e){t._intervalId=setInterval((function(){v.director&&v.Director&&(clearInterval(t._intervalId),t._intervalId=-1,e())}),50)},t._updateGamepadCnt=function(){for(var e=0,i=0,n=t._cachedWebGamepads.length;i<n;i++)t._cachedWebGamepads[i]&&e++;t._totalGamepadCnt=e},t._registerEvent=function(){t._ensureDirectorDefined((function(){t._cachedWebGamepads=t._getWebGamePads(),t._updateGamepadCnt(),v.director.on(v.Director.EVENT_BEGIN_FRAME,t._scanGamepads)})),window.addEventListener("gamepadconnected",(function(e){t._cachedWebGamepads[e.gamepad.index]=e.gamepad,t._updateGamepadCnt();var i=t._getOrCreateInputDevice(e.gamepad.index,!0);t._eventTarget.emit(bw.GAMEPAD_CHANGE,new Dw(bw.GAMEPAD_CHANGE,i))})),window.addEventListener("gamepaddisconnected",(function(e){t._cachedWebGamepads[e.gamepad.index]=null,t._updateGamepadCnt();var i=t._getOrCreateInputDevice(e.gamepad.index,!1);t._removeInputDevice(e.gamepad.index),t._eventTarget.emit(bw.GAMEPAD_CHANGE,new Dw(bw.GAMEPAD_CHANGE,i))}))},t._scanWebGamepads=function(e){if(0!==t._totalGamepadCnt){var i=t._getWebGamePads();if(i){for(var n=0;n<i.length;++n){var r=i[n];if(r){var s=t._cachedWebGamepads[r.index];if(s){for(var o=void 0,a=s.buttons,h=0;h<a.length;++h){var u=a[h],l=r.buttons[h];if(Math.abs(u.value-l.value)>.01){o=t._getOrCreateInputDevice(r.index,!0);break}}if(o){e.push(o);continue}for(var c=s.axes,_=0;_<c.length;++_){var d=c[_],f=r.axes[_];if(Math.abs(d-f)>.01){o=t._getOrCreateInputDevice(r.index,!0);break}}if(o){e.push(o);continue}}}}t._cachedWebGamepads=i}}},t._scanGamepads=function(){tx.length=0,t._scanWebGamepads(tx),t._scanWebXRGamepads(tx);for(var e=0;e<tx.length;++e){var i=tx[e];t._eventTarget.emit(bw.GAMEPAD_INPUT,new Dw(bw.GAMEPAD_INPUT,i))}t._scanWebXRGamepadsPose()},t._scanWebXRGamepads=function(e){var i,n,r=t._getWebXRGamepadMap();if(!r)return t._cachedWebXRGamepadMap=null,void(t.xr&&t.xr._connected&&(t.xr._connected=!1,t._eventTarget.emit(bw.GAMEPAD_CHANGE,new Dw(bw.GAMEPAD_CHANGE,t.xr)),e.push(t.xr)));t.xr||(t.xr=new t(-1));var s=r.get(Zw),o=r.get($w);s||o?t.xr._connected||(t.xr._connected=!0,t._eventTarget.emit(bw.GAMEPAD_CHANGE,new Dw(bw.GAMEPAD_CHANGE,t.xr))):t.xr._connected&&(t.xr._connected=!1,t._eventTarget.emit(bw.GAMEPAD_CHANGE,new Dw(bw.GAMEPAD_CHANGE,t.xr))),(t.checkGamepadChanged(s,null===(i=t._cachedWebXRGamepadMap)||void 0===i?void 0:i.get(Zw))||t.checkGamepadChanged(o,null===(n=t._cachedWebXRGamepadMap)||void 0===n?void 0:n.get($w)))&&e.push(t.xr),t._cachedWebXRGamepadMap||(t._cachedWebXRGamepadMap=new Map),t._cachedWebXRGamepadMap.set(Zw,t._copyCacheGamepadValue(s)),t._cachedWebXRGamepadMap.set($w,t._copyCacheGamepadValue(o))},t.checkGamepadChanged=function(t,e){if(!t&&!e)return!1;if(!t||!e)return!0;for(var i=e.buttons,n=0;n<i.length;++n){var r=i[n];if(0!==t.buttons[n].value||0!==r)return!0}for(var s=e.axes,o=0;o<s.length;++o){var a=s[o];if(0!==t.axes[o]||0!==a)return!0}return!1},t._copyCacheGamepadValue=function(t){if(t){for(var e={buttons:new Array(t.buttons.length),axes:new Array(t.axes.length)},i=0;i<t.buttons.length;++i)e.buttons[i]=t.buttons[i].value;for(var n=0;n<t.axes.length;++n)e.axes[n]=t.axes[n];return e}},t._scanWebXRGamepadsPose=function(){var e,i=null===(e=globalThis.__globalXR)||void 0===e?void 0:e.webxrHandlePoseInfos;if(i&&t.xr){for(var n=0;n<i.length;++n){var r=i[n];t.xr._updateWebPoseState(r)}t._eventTarget.emit(bw.HANDLE_POSE_INPUT,new Dw(bw.HANDLE_POSE_INPUT,t.xr))}},t._getWebXRGamepadMap=function(){var t;return null===(t=globalThis.__globalXR)||void 0===t?void 0:t.webxrGamepadMap},t._getWebGamePads=function(){return"function"==typeof navigator.getGamepads?navigator.getGamepads():"function"==typeof navigator.webkitGetGamepads?navigator.webkitGetGamepads():[]},t._getWebGamepad=function(e){for(var i=t._getWebGamePads(),n=0;n<i.length;++n){var r=i[n];if(r&&r.index===e)return r}};var e=t.prototype;return e._axisToButtons=function(t){var e=Math.abs(t);return t>0?{negative:0,positive:e}:t<0?{negative:e,positive:0}:{negative:0,positive:0}},e._updateWebPoseState=function(t){t.code!==jw.HAND_LEFT&&t.code!==jw.AIM_LEFT&&t.code!==jw.HAND_RIGHT&&t.code!==jw.AIM_RIGHT||(this._webPoseState[t.code]={position:new on(t.position.x,t.position.y,t.position.z),orientation:new Sn(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)})},e._initInputSource=function(){var e=this;this._buttonNorth=new Xw,this._buttonNorth.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);return n&&n.buttons.length>5?n.buttons[5].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[3].value:0},this._buttonEast=new Xw,this._buttonEast.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);return n&&n.buttons.length>5?n.buttons[5].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[1].value:0},this._buttonWest=new Xw,this._buttonWest.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);return n&&n.buttons.length>4?n.buttons[4].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[2].value:0},this._buttonSouth=new Xw,this._buttonSouth.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);return n&&n.buttons.length>4?n.buttons[4].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[0].value:0},this._buttonL1=new Xw,this._buttonL1.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[4].value:0},this._buttonL2=new Xw,this._buttonL2.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);return n&&n.buttons.length>0?n.buttons[0].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[6].value:0},this._buttonL3=new Xw,this._buttonL3.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);if(n){if(n.buttons.length>3&&0!==n.buttons[3].value)return n.buttons[3].value;if(n.buttons.length>2&&0!==n.buttons[2].value)return n.buttons[2].value}return 0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[10].value:0},this._buttonR1=new Xw,this._buttonR1.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[5].value:0},this._buttonR2=new Xw,this._buttonR2.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);return n&&n.buttons.length>0?n.buttons[0].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[7].value:0},this._buttonR3=new Xw,this._buttonR3.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);if(n){if(n.buttons.length>3&&0!==n.buttons[3].value)return n.buttons[3].value;if(n.buttons.length>2&&0!==n.buttons[2].value)return n.buttons[2].value}return 0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[11].value:0},this._buttonShare=new Xw,this._buttonShare.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[8].value:0},this._buttonOptions=new Xw,this._buttonOptions.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[9].value:0};var i=new Xw;i.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[12].value:0};var n=new Xw;n.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[13].value:0};var r=new Xw;r.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[14].value:0};var s=new Xw;s.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[15].value:0},this._dpad=new qw({up:i,down:n,left:r,right:s});var o=new Xw;o.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);if(n){if(n.axes.length>3&&0!==n.axes[3])return e._axisToButtons(n.axes[3]).negative;if(n.axes.length>1&&0!==n.axes[1])return e._axisToButtons(n.axes[1]).negative}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[1]).negative:0};var a=new Xw;a.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);if(n){if(n.axes.length>3&&0!==n.axes[3])return e._axisToButtons(n.axes[3]).positive;if(n.axes.length>1&&0!==n.axes[1])return e._axisToButtons(n.axes[1]).positive}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[1]).positive:0};var h=new Xw;h.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);if(n){if(n.axes.length>2&&0!==n.axes[2])return e._axisToButtons(n.axes[2]).negative;if(n.axes.length>0&&0!==n.axes[0])return e._axisToButtons(n.axes[0]).negative}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[0]).negative:0};var u=new Xw;u.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);if(n){if(n.axes.length>2&&0!==n.axes[2])return e._axisToButtons(n.axes[2]).positive;if(n.axes.length>0&&0!==n.axes[0])return e._axisToButtons(n.axes[0]).positive}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[0]).positive:0},this._leftStick=new Yw({up:o,down:a,left:h,right:u});var l=new Xw;l.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);if(n){if(n.axes.length>3&&0!==n.axes[3])return e._axisToButtons(n.axes[3]).negative;if(n.axes.length>1&&0!==n.axes[1])return e._axisToButtons(n.axes[1]).negative}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[3]).negative:0};var c=new Xw;c.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);if(n){if(n.axes.length>3&&0!==n.axes[3])return e._axisToButtons(n.axes[3]).positive;if(n.axes.length>1&&0!==n.axes[1])return e._axisToButtons(n.axes[1]).positive}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[3]).positive:0};var _=new Xw;_.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);if(n){if(n.axes.length>2&&0!==n.axes[2])return e._axisToButtons(n.axes[2]).negative;if(n.axes.length>0&&0!==n.axes[0])return e._axisToButtons(n.axes[0]).negative}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[2]).negative:0};var d=new Xw;d.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);if(n){if(n.axes.length>2&&0!==n.axes[2])return e._axisToButtons(n.axes[2]).positive;if(n.axes.length>0&&0!==n.axes[0])return e._axisToButtons(n.axes[0]).positive}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[2]).positive:0},this._rightStick=new Yw({up:l,down:c,left:_,right:d}),this._buttonStart=new Xw,this._buttonStart.getValue=function(){return 0},this._gripLeft=new Xw,this._gripLeft.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);if(n&&n.buttons.length>1)return n.buttons[1].value}return 0},this._gripRight=new Xw,this._gripRight.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);if(n&&n.buttons.length>1)return n.buttons[1].value}return 0},this._handLeftPosition=new Jw,this._handLeftPosition.getValue=function(){return e._webPoseState[jw.HAND_LEFT].position},this._handLeftOrientation=new Kw,this._handLeftOrientation.getValue=function(){return e._webPoseState[jw.HAND_LEFT].orientation},this._handRightPosition=new Jw,this._handRightPosition.getValue=function(){return e._webPoseState[jw.HAND_RIGHT].position},this._handRightOrientation=new Kw,this._handRightOrientation.getValue=function(){return e._webPoseState[jw.HAND_RIGHT].orientation},this._aimLeftPosition=new Jw,this._aimLeftPosition.getValue=function(){return e._webPoseState[jw.AIM_LEFT].position},this._aimLeftOrientation=new Kw,this._aimLeftOrientation.getValue=function(){return e._webPoseState[jw.AIM_LEFT].orientation},this._aimRightPosition=new Jw,this._aimRightPosition.getValue=function(){return e._webPoseState[jw.AIM_RIGHT].position},this._aimRightOrientation=new Kw,this._aimRightOrientation.getValue=function(){return e._webPoseState[jw.AIM_RIGHT].orientation}},n(t,[{key:"buttonNorth",get:function(){return this._buttonNorth}},{key:"buttonEast",get:function(){return this._buttonEast}},{key:"buttonWest",get:function(){return this._buttonWest}},{key:"buttonSouth",get:function(){return this._buttonSouth}},{key:"buttonL1",get:function(){return this._buttonL1}},{key:"buttonL2",get:function(){return this._buttonL2}},{key:"buttonL3",get:function(){return this._buttonL3}},{key:"buttonR1",get:function(){return this._buttonR1}},{key:"buttonR2",get:function(){return this._buttonR2}},{key:"buttonR3",get:function(){return this._buttonR3}},{key:"buttonShare",get:function(){return this._buttonShare}},{key:"buttonOptions",get:function(){return this._buttonOptions}},{key:"dpad",get:function(){return this._dpad}},{key:"leftStick",get:function(){return this._leftStick}},{key:"rightStick",get:function(){return this._rightStick}},{key:"buttonStart",get:function(){return this._buttonStart}},{key:"gripLeft",get:function(){return this._gripLeft}},{key:"gripRight",get:function(){return this._gripRight}},{key:"handLeftPosition",get:function(){return this._handLeftPosition}},{key:"handLeftOrientation",get:function(){return this._handLeftOrientation}},{key:"handRightPosition",get:function(){return this._handRightPosition}},{key:"handRightOrientation",get:function(){return this._handRightOrientation}},{key:"aimLeftPosition",get:function(){return this._aimLeftPosition}},{key:"aimLeftOrientation",get:function(){return this._aimLeftOrientation}},{key:"aimRightPosition",get:function(){return this._aimRightPosition}},{key:"aimRightOrientation",get:function(){return this._aimRightOrientation}},{key:"deviceId",get:function(){return this._deviceId}},{key:"connected",get:function(){return this._connected}}]),t}();ox.all=[],ox.xr=null,ox._eventTarget=new Ku,ox._cachedWebGamepads=[],ox._cachedWebXRGamepadMap=null,ox._intervalId=-1,ox._totalGamepadCnt=0,function(t){t[t.BUTTON_EAST=0]="BUTTON_EAST",t[t.BUTTON_SOUTH=1]="BUTTON_SOUTH",t[t.BUTTON_WEST=2]="BUTTON_WEST",t[t.BUTTON_NORTH=3]="BUTTON_NORTH",t[t.BUTTON_TRIGGER_LEFT=4]="BUTTON_TRIGGER_LEFT",t[t.BUTTON_TRIGGER_RIGHT=5]="BUTTON_TRIGGER_RIGHT",t[t.TRIGGER_LEFT=6]="TRIGGER_LEFT",t[t.TRIGGER_RIGHT=7]="TRIGGER_RIGHT",t[t.GRIP_LEFT=8]="GRIP_LEFT",t[t.GRIP_RIGHT=9]="GRIP_RIGHT",t[t.BUTTON_LEFT_STICK=10]="BUTTON_LEFT_STICK",t[t.LEFT_STICK_UP=11]="LEFT_STICK_UP",t[t.LEFT_STICK_DOWN=12]="LEFT_STICK_DOWN",t[t.LEFT_STICK_LEFT=13]="LEFT_STICK_LEFT",t[t.LEFT_STICK_RIGHT=14]="LEFT_STICK_RIGHT",t[t.BUTTON_RIGHT_STICK=15]="BUTTON_RIGHT_STICK",t[t.RIGHT_STICK_UP=16]="RIGHT_STICK_UP",t[t.RIGHT_STICK_DOWN=17]="RIGHT_STICK_DOWN",t[t.RIGHT_STICK_LEFT=18]="RIGHT_STICK_LEFT",t[t.RIGHT_STICK_RIGHT=19]="RIGHT_STICK_RIGHT",t[t.ROKID_MENU=20]="ROKID_MENU",t[t.ROKID_START=21]="ROKID_START"}(ex||(ex={})),function(t){t[t.KET_CLICK=0]="KET_CLICK",t[t.KET_STICK=1]="KET_STICK",t[t.KET_GRAB=2]="KET_GRAB",t[t.KET_TOUCH=3]="KET_TOUCH"}(ix||(ix={})),function(t){t[t.UNDEFINE=0]="UNDEFINE",t[t.A=1]="A",t[t.B=2]="B",t[t.X=3]="X",t[t.Y=4]="Y",t[t.L1=5]="L1",t[t.R1=6]="R1",t[t.MINUS=7]="MINUS",t[t.PLUS=8]="PLUS",t[t.L3=9]="L3",t[t.R3=10]="R3",t[t.MENU=11]="MENU",t[t.START=12]="START",t[t.TRIGGER_LEFT=13]="TRIGGER_LEFT",t[t.TRIGGER_RIGHT=14]="TRIGGER_RIGHT"}(nx||(nx={})),function(t){t[t.UNDEFINE=0]="UNDEFINE",t[t.X=1]="X",t[t.Y=2]="Y",t[t.LEFT_STICK_X=3]="LEFT_STICK_X",t[t.LEFT_STICK_Y=4]="LEFT_STICK_Y",t[t.RIGHT_STICK_X=5]="RIGHT_STICK_X",t[t.RIGHT_STICK_Y=6]="RIGHT_STICK_Y",t[t.L2=7]="L2",t[t.R2=8]="R2",t[t.LEFT_GRIP=9]="LEFT_GRIP",t[t.RIGHT_GRIP=10]="RIGHT_GRIP"}(rx||(rx={})),function(t){t[t.UNDEFINE=0]="UNDEFINE",t[t.A=1]="A",t[t.B=2]="B",t[t.X=3]="X",t[t.Y=4]="Y",t[t.LEFT_TRIGGER=5]="LEFT_TRIGGER",t[t.RIGHT_TRIGGER=6]="RIGHT_TRIGGER",t[t.LEFT_THUMBSTICK=7]="LEFT_THUMBSTICK",t[t.RIGHT_THUMBSTICK=8]="RIGHT_THUMBSTICK"}(sx||(sx={}));var ax,hx={1:ex.BUTTON_EAST,2:ex.BUTTON_SOUTH,3:ex.BUTTON_NORTH,4:ex.BUTTON_WEST,9:ex.BUTTON_LEFT_STICK,10:ex.BUTTON_RIGHT_STICK,11:ex.ROKID_MENU,12:ex.ROKID_START,13:ex.BUTTON_TRIGGER_LEFT,14:ex.BUTTON_TRIGGER_RIGHT},ux=function(){function t(){var t,e,i=this;this._eventTarget=new Ku,this._buttonNorth=void 0,this._buttonEast=void 0,this._buttonWest=void 0,this._buttonSouth=void 0,this._buttonTriggerLeft=void 0,this._buttonTriggerRight=void 0,this._triggerLeft=void 0,this._triggerRight=void 0,this._gripLeft=void 0,this._gripRight=void 0,this._leftStick=void 0,this._rightStick=void 0,this._buttonLeftStick=void 0,this._buttonRightStick=void 0,this._buttonOptions=void 0,this._buttonStart=void 0,this._handLeftPosition=void 0,this._handLeftOrientation=void 0,this._handRightPosition=void 0,this._handRightOrientation=void 0,this._aimLeftPosition=void 0,this._aimLeftOrientation=void 0,this._aimRightPosition=void 0,this._aimRightOrientation=void 0,this._touchButtonA=void 0,this._touchButtonB=void 0,this._touchButtonX=void 0,this._touchButtonY=void 0,this._touchButtonTriggerLeft=void 0,this._touchButtonTriggerRight=void 0,this._touchButtonThumbStickLeft=void 0,this._touchButtonThumbStickRight=void 0,this._nativeButtonState=((t={})[ex.BUTTON_SOUTH]=0,t[ex.BUTTON_EAST]=0,t[ex.BUTTON_WEST]=0,t[ex.BUTTON_NORTH]=0,t[ex.BUTTON_TRIGGER_LEFT]=0,t[ex.BUTTON_TRIGGER_RIGHT]=0,t[ex.TRIGGER_LEFT]=0,t[ex.TRIGGER_RIGHT]=0,t[ex.GRIP_LEFT]=0,t[ex.GRIP_RIGHT]=0,t[ex.LEFT_STICK_UP]=0,t[ex.LEFT_STICK_DOWN]=0,t[ex.LEFT_STICK_LEFT]=0,t[ex.LEFT_STICK_RIGHT]=0,t[ex.RIGHT_STICK_UP]=0,t[ex.RIGHT_STICK_DOWN]=0,t[ex.RIGHT_STICK_LEFT]=0,t[ex.RIGHT_STICK_RIGHT]=0,t[ex.BUTTON_LEFT_STICK]=0,t[ex.BUTTON_RIGHT_STICK]=0,t[ex.ROKID_MENU]=0,t[ex.ROKID_START]=0,t),this._nativeTouchState=((e={})[sx.UNDEFINE]=0,e[sx.A]=0,e[sx.B]=0,e[sx.X]=0,e[sx.Y]=0,e[sx.LEFT_TRIGGER]=0,e[sx.RIGHT_TRIGGER]=0,e[sx.LEFT_THUMBSTICK]=0,e[sx.RIGHT_THUMBSTICK]=0,e),this._initInputSource(),window.addEventListener("xr-remote-input",(function(t){var e=t,n=e.detail.keyEventType,r=e.detail.stickAxisCode,s=e.detail.stickAxisValue,o=e.detail.stickKeyCode,a=e.detail.isButtonPressed,h=e.detail.touchCode,u=e.detail.touchValue;if(n===ix.KET_CLICK){var l=hx[o];i._nativeButtonState[l]=a?1:0}else if(n===ix.KET_STICK||n===ix.KET_GRAB){var c,_,d;switch(r){case rx.LEFT_STICK_X:c=ex.LEFT_STICK_LEFT,_=ex.LEFT_STICK_RIGHT,d=i._axisToButtons(s);break;case rx.LEFT_STICK_Y:c=ex.LEFT_STICK_DOWN,_=ex.LEFT_STICK_UP,d=i._axisToButtons(s);break;case rx.RIGHT_STICK_X:c=ex.RIGHT_STICK_LEFT,_=ex.RIGHT_STICK_RIGHT,d=i._axisToButtons(s);break;case rx.RIGHT_STICK_Y:c=ex.RIGHT_STICK_DOWN,_=ex.RIGHT_STICK_UP,d=i._axisToButtons(s);break;case rx.L2:i._nativeButtonState[ex.TRIGGER_LEFT]=s;break;case rx.R2:i._nativeButtonState[ex.TRIGGER_RIGHT]=s;break;case rx.LEFT_GRIP:i._nativeButtonState[ex.GRIP_LEFT]=s;break;case rx.RIGHT_GRIP:i._nativeButtonState[ex.GRIP_RIGHT]=s}c&&_&&d&&(i._nativeButtonState[c]=d.negative,i._nativeButtonState[_]=d.positive)}else if(n===ix.KET_TOUCH)switch(h){case sx.A:case sx.B:case sx.X:case sx.Y:case sx.LEFT_TRIGGER:case sx.RIGHT_TRIGGER:case sx.LEFT_THUMBSTICK:case sx.RIGHT_THUMBSTICK:i._nativeTouchState[h]=u}i._eventTarget.emit(bw.HANDLE_INPUT,new Pw(bw.HANDLE_INPUT,i))}))}var e=t.prototype;return e._axisToButtons=function(t){var e=Math.abs(t);return t>0?{negative:0,positive:e}:t<0?{negative:e,positive:0}:{negative:0,positive:0}},e._on=function(t,e,i){this._eventTarget.on(t,e,i)},e._initInputSource=function(){var t=this;this._buttonNorth=new Xw,this._buttonNorth.getValue=function(){return t._nativeButtonState[ex.BUTTON_NORTH]},this._buttonEast=new Xw,this._buttonEast.getValue=function(){return t._nativeButtonState[ex.BUTTON_EAST]},this._buttonWest=new Xw,this._buttonWest.getValue=function(){return t._nativeButtonState[ex.BUTTON_WEST]},this._buttonSouth=new Xw,this._buttonSouth.getValue=function(){return t._nativeButtonState[ex.BUTTON_SOUTH]},this._buttonTriggerLeft=new Xw,this._buttonTriggerLeft.getValue=function(){return t._nativeButtonState[ex.BUTTON_TRIGGER_LEFT]},this._buttonTriggerRight=new Xw,this._buttonTriggerRight.getValue=function(){return t._nativeButtonState[ex.BUTTON_TRIGGER_RIGHT]},this._triggerLeft=new Xw,this._triggerLeft.getValue=function(){return t._nativeButtonState[ex.TRIGGER_LEFT]},this._triggerRight=new Xw,this._triggerRight.getValue=function(){return t._nativeButtonState[ex.TRIGGER_RIGHT]},this._gripLeft=new Xw,this._gripLeft.getValue=function(){return t._nativeButtonState[ex.GRIP_LEFT]},this._gripRight=new Xw,this._gripRight.getValue=function(){return t._nativeButtonState[ex.GRIP_RIGHT]},this._buttonLeftStick=new Xw,this._buttonLeftStick.getValue=function(){return t._nativeButtonState[ex.BUTTON_LEFT_STICK]};var e=new Xw;e.getValue=function(){return t._nativeButtonState[ex.LEFT_STICK_UP]};var i=new Xw;i.getValue=function(){return t._nativeButtonState[ex.LEFT_STICK_DOWN]};var n=new Xw;n.getValue=function(){return t._nativeButtonState[ex.LEFT_STICK_LEFT]};var r=new Xw;r.getValue=function(){return t._nativeButtonState[ex.LEFT_STICK_RIGHT]},this._leftStick=new Yw({up:e,down:i,left:n,right:r}),this._buttonRightStick=new Xw,this._buttonRightStick.getValue=function(){return t._nativeButtonState[ex.BUTTON_RIGHT_STICK]};var s=new Xw;s.getValue=function(){return t._nativeButtonState[ex.RIGHT_STICK_UP]};var o=new Xw;o.getValue=function(){return t._nativeButtonState[ex.RIGHT_STICK_DOWN]};var a=new Xw;a.getValue=function(){return t._nativeButtonState[ex.RIGHT_STICK_LEFT]};var h=new Xw;h.getValue=function(){return t._nativeButtonState[ex.RIGHT_STICK_RIGHT]},this._rightStick=new Yw({up:s,down:o,left:a,right:h}),this._buttonOptions=new Xw,this._buttonOptions.getValue=function(){return t._nativeButtonState[ex.ROKID_MENU]},this._buttonStart=new Xw,this._buttonStart.getValue=function(){return t._nativeButtonState[ex.ROKID_START]},this._handLeftPosition=new Jw,this._handLeftPosition.getValue=function(){return on.ZERO},this._handLeftOrientation=new Kw,this._handLeftOrientation.getValue=function(){return Sn.IDENTITY},this._handRightPosition=new Jw,this._handRightPosition.getValue=function(){return on.ZERO},this._handRightOrientation=new Kw,this._handRightOrientation.getValue=function(){return Sn.IDENTITY},this._aimLeftPosition=new Jw,this._aimLeftPosition.getValue=function(){return on.ZERO},this._aimLeftOrientation=new Kw,this._aimLeftOrientation.getValue=function(){return Sn.IDENTITY},this._aimRightPosition=new Jw,this._aimRightPosition.getValue=function(){return on.ZERO},this._aimRightOrientation=new Kw,this._aimRightOrientation.getValue=function(){return Sn.IDENTITY},this._touchButtonA=new Qw,this._touchButtonA.getValue=function(){return t._nativeTouchState[sx.A]},this._touchButtonB=new Qw,this._touchButtonB.getValue=function(){return t._nativeTouchState[sx.B]},this._touchButtonX=new Qw,this._touchButtonX.getValue=function(){return t._nativeTouchState[sx.X]},this._touchButtonY=new Qw,this._touchButtonY.getValue=function(){return t._nativeTouchState[sx.Y]},this._touchButtonTriggerLeft=new Qw,this._touchButtonTriggerLeft.getValue=function(){return t._nativeTouchState[sx.LEFT_TRIGGER]},this._touchButtonTriggerRight=new Qw,this._touchButtonTriggerRight.getValue=function(){return t._nativeTouchState[sx.RIGHT_TRIGGER]},this._touchButtonThumbStickLeft=new Qw,this._touchButtonThumbStickLeft.getValue=function(){return t._nativeTouchState[sx.LEFT_THUMBSTICK]},this._touchButtonThumbStickRight=new Qw,this._touchButtonThumbStickRight.getValue=function(){return t._nativeTouchState[sx.RIGHT_THUMBSTICK]}},n(t,[{key:"buttonNorth",get:function(){return this._buttonNorth}},{key:"buttonEast",get:function(){return this._buttonEast}},{key:"buttonWest",get:function(){return this._buttonWest}},{key:"buttonSouth",get:function(){return this._buttonSouth}},{key:"buttonTriggerLeft",get:function(){return this._buttonTriggerLeft}},{key:"buttonTriggerRight",get:function(){return this._buttonTriggerRight}},{key:"triggerLeft",get:function(){return this._triggerLeft}},{key:"triggerRight",get:function(){return this._triggerRight}},{key:"gripLeft",get:function(){return this._gripLeft}},{key:"gripRight",get:function(){return this._gripRight}},{key:"leftStick",get:function(){return this._leftStick}},{key:"rightStick",get:function(){return this._rightStick}},{key:"buttonLeftStick",get:function(){return this._buttonLeftStick}},{key:"buttonRightStick",get:function(){return this._buttonRightStick}},{key:"buttonOptions",get:function(){return this._buttonOptions}},{key:"buttonStart",get:function(){return this._buttonStart}},{key:"handLeftPosition",get:function(){return this._handLeftPosition}},{key:"handLeftOrientation",get:function(){return this._handLeftOrientation}},{key:"handRightPosition",get:function(){return this._handRightPosition}},{key:"handRightOrientation",get:function(){return this._handRightOrientation}},{key:"aimLeftPosition",get:function(){return this._aimLeftPosition}},{key:"aimLeftOrientation",get:function(){return this._aimLeftOrientation}},{key:"aimRightPosition",get:function(){return this._aimRightPosition}},{key:"aimRightOrientation",get:function(){return this._aimRightOrientation}},{key:"touchButtonA",get:function(){return this._touchButtonA}},{key:"touchButtonB",get:function(){return this._touchButtonB}},{key:"touchButtonX",get:function(){return this._touchButtonX}},{key:"touchButtonY",get:function(){return this._touchButtonY}},{key:"touchButtonTriggerLeft",get:function(){return this._touchButtonTriggerLeft}},{key:"touchButtonTriggerRight",get:function(){return this._touchButtonTriggerRight}},{key:"touchButtonThumbStickLeft",get:function(){return this._touchButtonThumbStickLeft}},{key:"touchButtonThumbStickRight",get:function(){return this._touchButtonThumbStickRight}}]),t}();!function(t){t[t.VIEW_LEFT=0]="VIEW_LEFT",t[t.VIEW_RIGHT=3]="VIEW_RIGHT",t[t.HEAD_MIDDLE=6]="HEAD_MIDDLE"}(ax||(ax={}));var lx,cx,_x=function(){function t(){var t;this._eventTarget=new Ku,this._intervalId=-1,this._viewLeftPosition=void 0,this._viewLeftOrientation=void 0,this._viewRightPosition=void 0,this._viewRightOrientation=void 0,this._headMiddlePosition=void 0,this._headMiddleOrientation=void 0,this._webPoseState=((t={})[ax.VIEW_LEFT]={position:on.ZERO,orientation:Sn.IDENTITY},t[ax.VIEW_RIGHT]={position:on.ZERO,orientation:Sn.IDENTITY},t[ax.HEAD_MIDDLE]={position:on.ZERO,orientation:Sn.IDENTITY},t),this._initInputSource(),this._registerEvent()}var e=t.prototype;return e._ensureDirectorDefined=function(){var t=this;return new Promise((function(e){t._intervalId=setInterval((function(){v.director&&v.Director&&(clearInterval(t._intervalId),t._intervalId=-1,e())}),50)}))},e._registerEvent=function(){var t=this;this._ensureDirectorDefined().then((function(){v.director.on(v.Director.EVENT_BEGIN_FRAME,t._scanHmd,t)})).catch((function(){}))},e._scanHmd=function(){var t,e=null===(t=globalThis.__globalXR)||void 0===t?void 0:t.webxrHmdPoseInfos;if(e){for(var i=0;i<e.length;++i){var n=e[i];this._updateWebPoseState(n)}this._eventTarget.emit(bw.HMD_POSE_INPUT,new Ow(bw.HMD_POSE_INPUT,this))}},e._on=function(t,e,i){this._eventTarget.on(t,e,i)},e._updateWebPoseState=function(t){t.code!==ax.VIEW_LEFT&&t.code!==ax.VIEW_RIGHT&&t.code!==ax.HEAD_MIDDLE||(this._webPoseState[t.code]={position:new on(t.position.x,t.position.y,t.position.z),orientation:new Sn(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)})},e._initInputSource=function(){var t=this;this._viewLeftPosition=new Jw,this._viewLeftPosition.getValue=function(){return t._webPoseState[ax.VIEW_LEFT].position},this._viewLeftOrientation=new Kw,this._viewLeftOrientation.getValue=function(){return t._webPoseState[ax.VIEW_LEFT].orientation},this._viewRightPosition=new Jw,this._viewRightPosition.getValue=function(){return t._webPoseState[ax.VIEW_RIGHT].position},this._viewRightOrientation=new Kw,this._viewRightOrientation.getValue=function(){return t._webPoseState[ax.VIEW_RIGHT].orientation},this._headMiddlePosition=new Jw,this._headMiddlePosition.getValue=function(){return t._webPoseState[ax.HEAD_MIDDLE].position},this._headMiddleOrientation=new Kw,this._headMiddleOrientation.getValue=function(){return t._webPoseState[ax.HEAD_MIDDLE].orientation}},n(t,[{key:"viewLeftPosition",get:function(){return this._viewLeftPosition}},{key:"viewLeftOrientation",get:function(){return this._viewLeftOrientation}},{key:"viewRightPosition",get:function(){return this._viewRightPosition}},{key:"viewRightOrientation",get:function(){return this._viewRightOrientation}},{key:"headMiddlePosition",get:function(){return this._headMiddlePosition}},{key:"headMiddleOrientation",get:function(){return this._headMiddleOrientation}}]),t}(),dx=function(){function t(){this._eventTarget=new Ku,this._handheldPosition=void 0,this._handheldOrientation=void 0,this._initInputSource()}var e=t.prototype;return e._on=function(t,e,i){this._eventTarget.on(t,e,i)},e._initInputSource=function(){this._handheldPosition=new Jw,this._handheldPosition.getValue=function(){return on.ZERO},this._handheldOrientation=new Kw,this._handheldOrientation.getValue=function(){return Sn.IDENTITY}},n(t,[{key:"handheldPosition",get:function(){return this._handheldPosition}},{key:"handheldOrientation",get:function(){return this._handheldOrientation}}]),t}(),fx={Backspace:Bw.BACKSPACE,Tab:Bw.TAB,Enter:Bw.ENTER,ShiftLeft:Bw.SHIFT_LEFT,ControlLeft:Bw.CTRL_LEFT,AltLeft:Bw.ALT_LEFT,ShiftRight:Bw.SHIFT_RIGHT,ControlRight:Bw.CTRL_RIGHT,AltRight:Bw.ALT_RIGHT,Pause:Bw.PAUSE,CapsLock:Bw.CAPS_LOCK,Escape:Bw.ESCAPE,Space:Bw.SPACE,PageUp:Bw.PAGE_UP,PageDown:Bw.PAGE_DOWN,End:Bw.END,Home:Bw.HOME,ArrowLeft:Bw.ARROW_LEFT,ArrowUp:Bw.ARROW_UP,ArrowRight:Bw.ARROW_RIGHT,ArrowDown:Bw.ARROW_DOWN,Insert:Bw.INSERT,Delete:Bw.DELETE,Digit0:Bw.DIGIT_0,Digit1:Bw.DIGIT_1,Digit2:Bw.DIGIT_2,Digit3:Bw.DIGIT_3,Digit4:Bw.DIGIT_4,Digit5:Bw.DIGIT_5,Digit6:Bw.DIGIT_6,Digit7:Bw.DIGIT_7,Digit8:Bw.DIGIT_8,Digit9:Bw.DIGIT_9,KeyA:Bw.KEY_A,KeyB:Bw.KEY_B,KeyC:Bw.KEY_C,KeyD:Bw.KEY_D,KeyE:Bw.KEY_E,KeyF:Bw.KEY_F,KeyG:Bw.KEY_G,KeyH:Bw.KEY_H,KeyI:Bw.KEY_I,KeyJ:Bw.KEY_J,KeyK:Bw.KEY_K,KeyL:Bw.KEY_L,KeyM:Bw.KEY_M,KeyN:Bw.KEY_N,KeyO:Bw.KEY_O,KeyP:Bw.KEY_P,KeyQ:Bw.KEY_Q,KeyR:Bw.KEY_R,KeyS:Bw.KEY_S,KeyT:Bw.KEY_T,KeyU:Bw.KEY_U,KeyV:Bw.KEY_V,KeyW:Bw.KEY_W,KeyX:Bw.KEY_X,KeyY:Bw.KEY_Y,KeyZ:Bw.KEY_Z,Numpad0:Bw.NUM_0,Numpad1:Bw.NUM_1,Numpad2:Bw.NUM_2,Numpad3:Bw.NUM_3,Numpad4:Bw.NUM_4,Numpad5:Bw.NUM_5,Numpad6:Bw.NUM_6,Numpad7:Bw.NUM_7,Numpad8:Bw.NUM_8,Numpad9:Bw.NUM_9,NumpadMultiply:Bw.NUM_MULTIPLY,NumpadAdd:Bw.NUM_PLUS,NumpadSubtract:Bw.NUM_SUBTRACT,NumpadDecimal:Bw.NUM_DECIMAL,NumpadDivide:Bw.NUM_DIVIDE,NumpadEnter:Bw.NUM_ENTER,F1:Bw.F1,F2:Bw.F2,F3:Bw.F3,F4:Bw.F4,F5:Bw.F5,F6:Bw.F6,F7:Bw.F7,F8:Bw.F8,F9:Bw.F9,F10:Bw.F10,F11:Bw.F11,F12:Bw.F12,NumLock:Bw.NUM_LOCK,ScrollLock:Bw.SCROLL_LOCK,Semicolon:Bw.SEMICOLON,Equal:Bw.EQUAL,Comma:Bw.COMMA,Minus:Bw.DASH,Period:Bw.PERIOD,Slash:Bw.SLASH,Backquote:Bw.BACK_QUOTE,BracketLeft:Bw.BRACKET_LEFT,Backslash:Bw.BACKSLASH,BracketRight:Bw.BRACKET_RIGHT,Quote:Bw.QUOTE},px=function(){function t(){this._eventTarget=new Ku,this._registerEvent()}var e=t.prototype;return e.dispatchKeyboardDownEvent=function(t){this._handleKeyboardDown(t)},e.dispatchKeyboardUpEvent=function(t){this._handleKeyboardUp(t)},e.on=function(t,e,i){this._eventTarget.on(t,e,i)},e._registerEvent=function(){var t=document.getElementById("GameCanvas");null==t||t.addEventListener("keydown",this._handleKeyboardDown.bind(this)),null==t||t.addEventListener("keyup",this._handleKeyboardUp.bind(this))},e._getInputEvent=function(t,e){var i,n=(i=t.code,fx[i]||Bw.NONE);return new ww(n,e)},e._handleKeyboardDown=function(t){if(t.stopPropagation(),t.preventDefault(),t.repeat){var e=this._getInputEvent(t,bw.KEY_PRESSING);this._eventTarget.emit(bw.KEY_PRESSING,e)}else{var i=this._getInputEvent(t,bw.KEY_DOWN);this._eventTarget.emit(bw.KEY_DOWN,i)}},e._handleKeyboardUp=function(t){var e=this._getInputEvent(t,bw.KEY_UP);t.stopPropagation(),t.preventDefault(),this._eventTarget.emit(bw.KEY_UP,e)},t}(),mx=function(){function t(){this._canvas=void 0,this._eventTarget=new Ku,this._pointLocked=!1,this._isPressed=!1,this._preMousePos=new Ln,this._handleMouseDown=void 0,this._handleMouseMove=void 0,this._handleMouseUp=void 0,nl.hasFeature(el.EVENT_MOUSE)&&(this._canvas=document.getElementById("GameCanvas"),this._canvas||console.warn("failed to access canvas"),this._handleMouseDown=this._createCallback(bw.MOUSE_DOWN),this._handleMouseMove=this._createCallback(bw.MOUSE_MOVE),this._handleMouseUp=this._createCallback(bw.MOUSE_UP),this._registerEvent())}var e=t.prototype;return e.dispatchMouseDownEvent=function(t){this._handleMouseDown(t)},e.dispatchMouseMoveEvent=function(t){this._handleMouseMove(t)},e.dispatchMouseUpEvent=function(t){this._handleMouseUp(t)},e.dispatchScrollEvent=function(t){this._handleMouseWheel(t)},e.on=function(t,e,i){this._eventTarget.on(t,e,i)},e._getCanvasRect=function(){var t=this._canvas,e=null==t?void 0:t.getBoundingClientRect();return e?new Un(e.x,e.y,e.width,e.height):new Un(0,0,0,0)},e._getLocation=function(t){var e=this._getCanvasRect(),i=El.devicePixelRatio,n=this._pointLocked?this._preMousePos.x/i+t.movementX:t.clientX-e.x,r=this._pointLocked?this._preMousePos.y/i-t.movementY:e.y+e.height-t.clientY;return new Ln(n*=i,r*=i)},e._registerEvent=function(){var t,e,i,n,r=this;window.addEventListener("mousedown",(function(){r._isPressed=!0})),null===(t=this._canvas)||void 0===t||t.addEventListener("mousedown",this._handleMouseDown),null===(e=this._canvas)||void 0===e||e.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp),null===(i=this._canvas)||void 0===i||i.addEventListener("mouseup",this._handleMouseUp),null===(n=this._canvas)||void 0===n||n.addEventListener("wheel",this._handleMouseWheel.bind(this)),this._registerPointerLockEvent()},e._registerPointerLockEvent=function(){var t=this,e=function(){var e=t._canvas;document.pointerLockElement===e||document.mozPointerLockElement===e?t._pointLocked=!0:t._pointLocked=!1};"onpointerlockchange"in document?document.addEventListener("pointerlockchange",e,!1):"onmozpointerlockchange"in document&&document.addEventListener("mozpointerlockchange",e,!1)},e._createCallback=function(t){var e=this;return function(i){var n,r=e._getLocation(i),s=i.button,o=i.buttons,a=s;switch(t){case bw.MOUSE_DOWN:null===(n=e._canvas)||void 0===n||n.focus(),e._isPressed=!0;break;case bw.MOUSE_UP:e._isPressed=!1;break;case bw.MOUSE_MOVE:a=1&o?xw.BUTTON_LEFT:2&o?xw.BUTTON_RIGHT:4&o?xw.BUTTON_MIDDLE:xw.BUTTON_MISSING}var h=new xw(t,!1,e._preMousePos);h.setLocation(r.x,r.y),h.setButton(a),h.movementX=i.movementX,h.movementY=i.movementY,e._preMousePos.set(r.x,r.y),i.stopPropagation(),i.target===e._canvas&&i.preventDefault(),e._eventTarget.emit(t,h)}},e._handleMouseWheel=function(t){var e=bw.MOUSE_WHEEL,i=this._getLocation(t),n=t.button,r=new xw(e,!1,this._preMousePos);r.setLocation(i.x,i.y),r.setButton(n),r.movementX=t.movementX,r.movementY=t.movementY,r.setScrollData(5*t.deltaX,5*-t.deltaY),this._preMousePos.set(i.x,i.y),t.stopPropagation(),t.target===this._canvas&&t.preventDefault(),this._eventTarget.emit(e,r)},t}(),gx=new Ln,yx=new(function(){function t(){this._touchMap=void 0,this._maxTouches=8,this._touchMap=new Map}var e=t.prototype;return e._createTouch=function(t,e,i){if(this._touchMap.has(t))F("Cannot create the same touch object.");else{if(!this._checkTouchMapSizeMoreThanMax(t)){var n=new Nw(e,i,t);return this._touchMap.set(t,n),this._updateTouch(n,e,i),n}F("The touches is more than MAX_TOUCHES.")}},e.releaseTouch=function(t){this._touchMap.has(t)&&this._touchMap.delete(t)},e.getTouch=function(t){return this._touchMap.get(t)},e.getOrCreateTouch=function(t,e,i){var n=this.getTouch(t);return n?this._updateTouch(n,e,i):n=this._createTouch(t,e,i),n},e.getAllTouches=function(){var t=[];return this._touchMap.forEach((function(e){e&&t.push(e)})),t},e.getTouchCount=function(){return yx._touchMap.size},e._updateTouch=function(t,e,i){t.getLocation(gx),t.setPrevPoint(gx),t.setPoint(e,i)},e._checkTouchMapSizeMoreThanMax=function(t){var e=this;if(this._touchMap.has(t))return!1;var i=Ce.ENABLE_MULTI_TOUCH?this._maxTouches:1;if(this._touchMap.size<i)return!1;var n=performance.now();return this._touchMap.forEach((function(t){n-t.lastModified>Ce.TOUCH_TIMEOUT&&(F("The touches is more than MAX_TOUCHES, release touch id "+t.getID()+"."),e.releaseTouch(t.getID()))})),i>=this._touchMap.size},t}()),vx=function(){function t(){this._canvas=void 0,this._eventTarget=new Ku,nl.hasFeature(el.INPUT_TOUCH)&&(this._canvas=document.getElementById("GameCanvas"),this._canvas||k("failed to access canvas"),this._registerEvent())}var e=t.prototype;return e._registerEvent=function(){var t,e,i,n;null===(t=this._canvas)||void 0===t||t.addEventListener("touchstart",this._createCallback(bw.TOUCH_START)),null===(e=this._canvas)||void 0===e||e.addEventListener("touchmove",this._createCallback(bw.TOUCH_MOVE)),null===(i=this._canvas)||void 0===i||i.addEventListener("touchend",this._createCallback(bw.TOUCH_END)),null===(n=this._canvas)||void 0===n||n.addEventListener("touchcancel",this._createCallback(bw.TOUCH_CANCEL))},e._createCallback=function(t){var e=this;return function(i){for(var n,r=e._getCanvasRect(),s=[],o=i.changedTouches.length,a=0;a<o;++a){var h=i.changedTouches[a],u=h.identifier;if(null!==u){var l=e._getLocation(h,r),c=yx.getOrCreateTouch(u,l.x,l.y);c&&(t!==bw.TOUCH_END&&t!==bw.TOUCH_CANCEL||yx.releaseTouch(u),s.push(c))}}if(i.stopPropagation(),i.target===e._canvas&&i.preventDefault(),t===bw.TOUCH_START&&(null===(n=e._canvas)||void 0===n||n.focus()),s.length>0){var _=new Iw(s,!1,t,Ce.ENABLE_MULTI_TOUCH?yx.getAllTouches():s);e._eventTarget.emit(t,_)}}},e._getCanvasRect=function(){var t=this._canvas,e=null==t?void 0:t.getBoundingClientRect();return e?new Un(e.x,e.y,e.width,e.height):new Un(0,0,0,0)},e._getLocation=function(t,e){if(globalThis.__globalXR&&globalThis.__globalXR.ar&&globalThis.__globalXR.ar.isWebXR())return new Ln(t.clientX,t.clientY);var i=t.clientX-e.x,n=e.y+e.height-t.clientY;if(El.isFrameRotated){var r=i;i=e.height-n,n=r}var s=El.devicePixelRatio;return new Ln(i*=s,n*=s)},e.on=function(t,e,i){this._eventTarget.on(t,e,i)},t}();!function(t){t[t.GLOBAL=0]="GLOBAL",t[t.UI=1]="UI"}(cx||(cx={}));var Sx=function(){function t(t){this.priority=cx.GLOBAL,this._inputEventTarget=void 0,this._inputEventTarget=t}return t.prototype.dispatchEvent=function(t){return this._inputEventTarget.emit(t.type,t),!0},t}(),Tx=((lx={})[bw.MOUSE_DOWN]=bw.TOUCH_START,lx[bw.MOUSE_MOVE]=bw.TOUCH_MOVE,lx[bw.MOUSE_UP]=bw.TOUCH_END,lx),Ax=t("eL",function(){function t(){this._dispatchImmediately=!0,this._eventTarget=new Ku,this._touchInput=new vx,this._mouseInput=new mx,this._keyboardInput=new px,this._accelerometerInput=new Fw,this._handleInput=new ux,this._hmdInput=new _x,this._handheldInput=new dx,this._eventTouchList=[],this._eventMouseList=[],this._eventKeyboardList=[],this._eventAccelerationList=[],this._eventGamepadList=[],this._eventHandleList=[],this._eventHMDList=[],this._eventHandheldList=[],this._needSimulateTouchMoveEvent=!1,this._inputEventDispatcher=void 0,this._eventDispatcherList=[],this._registerEvent(),this._inputEventDispatcher=new Sx(this._eventTarget),this._registerEventDispatcher(this._inputEventDispatcher),ox._init()}var e=t.prototype;return e._dispatchMouseDownEvent=function(t){var e,i;null===(e=(i=this._mouseInput).dispatchMouseDownEvent)||void 0===e||e.call(i,t)},e._dispatchMouseMoveEvent=function(t){var e,i;null===(e=(i=this._mouseInput).dispatchMouseMoveEvent)||void 0===e||e.call(i,t)},e._dispatchMouseUpEvent=function(t){var e,i;null===(e=(i=this._mouseInput).dispatchMouseUpEvent)||void 0===e||e.call(i,t)},e._dispatchMouseScrollEvent=function(t){var e,i;null===(e=(i=this._mouseInput).dispatchScrollEvent)||void 0===e||e.call(i,t)},e._dispatchKeyboardDownEvent=function(t){var e,i;null===(e=(i=this._keyboardInput).dispatchKeyboardDownEvent)||void 0===e||e.call(i,t)},e._dispatchKeyboardUpEvent=function(t){var e,i;null===(e=(i=this._keyboardInput).dispatchKeyboardUpEvent)||void 0===e||e.call(i,t)},e.on=function(t,e,i){return this._eventTarget.on(t,e,i),e},e.once=function(t,e,i){return this._eventTarget.once(t,e,i),e},e.off=function(t,e,i){this._eventTarget.off(t,e,i)},e.getTouch=function(t){return yx.getTouch(t)},e.getAllTouches=function(){return yx.getAllTouches()},e.getTouchCount=function(){return yx.getTouchCount()},e.setAccelerometerEnabled=function(t){t?this._accelerometerInput.start():this._accelerometerInput.stop()},e.setAccelerometerInterval=function(t){this._accelerometerInput.setInterval(t)},e._simulateEventTouch=function(t){var e=Tx[t.type],i=yx.getOrCreateTouch(0,t.getLocationX(),t.getLocationY());if(i){var n=[i],r=new Iw(n,!1,e,e===bw.TOUCH_END?[]:n);r.windowId=t.windowId,e===bw.TOUCH_END&&yx.releaseTouch(0),this._dispatchOrPushEventTouch(r,this._eventTouchList)}},e._registerEventDispatcher=function(t){this._eventDispatcherList.push(t),this._eventDispatcherList.sort((function(t,e){return e.priority-t.priority}))},e._emitEvent=function(t){for(var e=this._eventDispatcherList.length,i=0;i<e;++i){var n=this._eventDispatcherList[i];try{if(!n.dispatchEvent(t))break}catch(e){V("Error occurs in an event listener: "+t.type),V(e)}}},e._registerEvent=function(){var t=this;if(xl.hasFeature(xl.Feature.INPUT_TOUCH)){var e=this._eventTouchList;this._touchInput.on(bw.TOUCH_START,(function(i){t._dispatchOrPushEventTouch(i,e)})),this._touchInput.on(bw.TOUCH_MOVE,(function(i){t._dispatchOrPushEventTouch(i,e)})),this._touchInput.on(bw.TOUCH_END,(function(i){t._dispatchOrPushEventTouch(i,e)})),this._touchInput.on(bw.TOUCH_CANCEL,(function(i){t._dispatchOrPushEventTouch(i,e)}))}if(xl.hasFeature(xl.Feature.EVENT_MOUSE)){var i=this._eventMouseList;this._mouseInput.on(bw.MOUSE_DOWN,(function(e){t._needSimulateTouchMoveEvent=!0,t._simulateEventTouch(e),t._dispatchOrPushEvent(e,i)})),this._mouseInput.on(bw.MOUSE_MOVE,(function(e){t._needSimulateTouchMoveEvent&&t._simulateEventTouch(e),t._dispatchOrPushEvent(e,i)})),this._mouseInput.on(bw.MOUSE_UP,(function(e){t._needSimulateTouchMoveEvent=!1,t._simulateEventTouch(e),t._dispatchOrPushEvent(e,i)})),this._mouseInput.on(bw.MOUSE_WHEEL,(function(e){t._dispatchOrPushEvent(e,i)}))}if(xl.hasFeature(xl.Feature.EVENT_KEYBOARD)){var n=this._eventKeyboardList;this._keyboardInput.on(bw.KEY_DOWN,(function(e){t._dispatchOrPushEvent(e,n)})),this._keyboardInput.on(bw.KEY_PRESSING,(function(e){t._dispatchOrPushEvent(e,n)})),this._keyboardInput.on(bw.KEY_UP,(function(e){t._dispatchOrPushEvent(e,n)}))}if(xl.hasFeature(xl.Feature.EVENT_ACCELEROMETER)){var r=this._eventAccelerationList;this._accelerometerInput.on(bw.DEVICEMOTION,(function(e){t._dispatchOrPushEvent(e,r)}))}if(xl.hasFeature(xl.Feature.EVENT_GAMEPAD)){var s=this._eventGamepadList;ox._on(bw.GAMEPAD_CHANGE,(function(e){t._dispatchOrPushEvent(e,s)})),ox._on(bw.GAMEPAD_INPUT,(function(e){t._dispatchOrPushEvent(e,s)})),ox._on(bw.HANDLE_POSE_INPUT,(function(e){t._dispatchOrPushEvent(e,s)}))}if(xl.hasFeature(xl.Feature.EVENT_HANDLE)){var o=this._eventHandleList;this._handleInput._on(bw.HANDLE_INPUT,(function(e){t._dispatchOrPushEvent(e,o)})),this._handleInput._on(bw.HANDLE_POSE_INPUT,(function(e){t._dispatchOrPushEvent(e,o)}))}if(xl.hasFeature(xl.Feature.EVENT_HMD)){var a=this._eventHMDList;this._hmdInput._on(bw.HMD_POSE_INPUT,(function(e){t._dispatchOrPushEvent(e,a)}))}if(xl.hasFeature(xl.Feature.EVENT_HANDHELD)){var h=this._eventHandheldList;this._handheldInput._on(bw.HANDHELD_POSE_INPUT,(function(e){t._dispatchOrPushEvent(e,h)}))}},e._clearEvents=function(){this._eventMouseList.length=0,this._eventTouchList.length=0,this._eventKeyboardList.length=0,this._eventAccelerationList.length=0,this._eventGamepadList.length=0,this._eventHandleList.length=0,this._eventHMDList.length=0},e._dispatchOrPushEvent=function(t,e){this._dispatchImmediately?this._emitEvent(t):e.push(t)},e._dispatchOrPushEventTouch=function(t,e){if(this._dispatchImmediately)for(var i=t.getTouches(),n=i.length,r=0;r<n;++r)t.touch=i[r],t.propagationStopped=t.propagationImmediateStopped=!1,this._emitEvent(t);else e.push(t)},e._frameDispatchEvents=function(){for(var t=this._eventHMDList,e=0,i=t.length;e<i;++e){var n=t[e];this._emitEvent(n)}for(var r=this._eventHandheldList,s=0,o=r.length;s<o;++s){var a=r[s];this._emitEvent(a)}for(var h=this._eventMouseList,u=0,l=h.length;u<l;++u){var c=h[u];this._emitEvent(c)}for(var _=this._eventTouchList,d=0,f=_.length;d<f;++d)for(var p=_[d],m=p.getTouches(),g=m.length,y=0;y<g;++y)p.touch=m[y],p.propagationStopped=p.propagationImmediateStopped=!1,this._emitEvent(p);for(var v=this._eventKeyboardList,S=0,T=v.length;S<T;++S){var A=v[S];this._emitEvent(A)}for(var b=this._eventAccelerationList,E=0,C=b.length;E<C;++E){var w=b[E];this._emitEvent(w)}for(var x=this._eventGamepadList,R=0,I=x.length;R<I;++R){var B=x[R];this._emitEvent(B)}for(var D=this._eventHandleList,P=0,O=D.length;P<O;++P){var M=D[P];this._emitEvent(M)}this._clearEvents()},t}());Ax.EventType=bw;var bx=t("eK",new Ax),Ex=t("eN",function(t){function e(){var e;return e=t.call(this)||this,bx.on(bw.MOUSE_DOWN,(function(t){e.emit(Aw.MOUSE_DOWN,t)})),bx.on(bw.MOUSE_MOVE,(function(t){e.emit(Aw.MOUSE_MOVE,t)})),bx.on(bw.MOUSE_UP,(function(t){e.emit(Aw.MOUSE_UP,t)})),bx.on(bw.MOUSE_WHEEL,(function(t){e.emit(Aw.MOUSE_WHEEL,t)})),bx.on(bw.TOUCH_START,(function(t){e.emit(Aw.TOUCH_START,t.touch,t)})),bx.on(bw.TOUCH_MOVE,(function(t){e.emit(Aw.TOUCH_MOVE,t.touch,t)})),bx.on(bw.TOUCH_END,(function(t){e.emit(Aw.TOUCH_END,t.touch,t)})),bx.on(bw.TOUCH_CANCEL,(function(t){e.emit(Aw.TOUCH_CANCEL,t.touch,t)})),bx.on(bw.KEY_DOWN,(function(t){e.emit(Aw.KEY_DOWN,t)})),bx.on(bw.KEY_PRESSING,(function(t){e.emit(Aw.KEY_DOWN,t)})),bx.on(bw.KEY_UP,(function(t){e.emit(Aw.KEY_UP,t)})),bx.on(bw.DEVICEMOTION,(function(t){e.emit(Aw.DEVICEMOTION,t)})),e}s(e,t);var i=e.prototype;return i.setAccelerometerEnabled=function(t){bx.setAccelerometerEnabled(t)},i.setAccelerometerInterval=function(t){bx.setAccelerometerInterval(t)},i.on=function(e,i,n,r){return t.prototype.on.call(this,e,i,n,r),i},i.off=function(e,i,n){t.prototype.off.call(this,e,i,n)},e}(Ku));Ex.EventType=Aw,v.SystemEvent=Ex;var Cx,wx,xx,Rx,Ix,Bx,Dx,Px,Ox=t("eM",new Ex);v.systemEvent=Ox,nt(Aw,"Node.EventType",[{name:"POSITION_PART",newName:"TRANSFORM_CHANGED"},{name:"ROTATION_PART",newName:"TRANSFORM_CHANGED"},{name:"SCALE_PART",newName:"TRANSFORM_CHANGED"}]),nt(Ew,"Event",[{name:"ACCELERATION",newName:"DEVICEMOTION",target:Ex.EventType,targetName:"SystemEvent.EventType"}]),st(Ew,"Event",[{name:"TOUCH",suggest:"please use SystemEvent.EventType.TOUCH_START, SystemEvent.EventType.TOUCH_MOVE, SystemEvent.EventType.TOUCH_END and SystemEvent.EventType.TOUCH_CANCEL instead"},{name:"MOUSE",suggest:"please use SystemEvent.EventType.MOUSE_DOWN, SystemEvent.EventType.MOUSE_MOVE, SystemEvent.EventType.MOUSE_UP, SystemEvent.EventType.MOUSE_WHEEL, Node.EventType.MOUSE_ENTER and Node.EventType.MOUSE_LEAVE instead"},{name:"KEYBOARD",suggest:"please use SystemEvent.EventType.KEY_DOWN and SystemEvent.EventType.KEY_UP instead"}]),nt(xw,"EventMouse",["DOWN","UP","MOVE"].map((function(t){return{name:t,newName:"MOUSE_"+t,target:Ex.EventType,targetName:"SystemEvent.EventType"}}))),nt(xw,"EventMouse",[{name:"SCROLL",newName:"MOUSE_WHEEL",target:Ex.EventType,targetName:"SystemEvent.EventType"}]),st(xw.prototype,"EventMouse.prototype",[{name:"eventType",suggest:"please use EventMouse.prototype.type instead"}]),nt(Iw,"EventTouch",[{name:"BEGAN",newName:"TOUCH_START",target:Ex.EventType,targetName:"SystemEvent.EventType"}]),nt(Iw,"EventTouch",[{name:"MOVED",newName:"TOUCH_MOVE",target:Ex.EventType,targetName:"SystemEvent.EventType"}]),nt(Iw,"EventTouch",[{name:"ENDED",newName:"TOUCH_END",target:Ex.EventType,targetName:"SystemEvent.EventType"}]),nt(Iw,"EventTouch",[{name:"CANCELLED",newName:"TOUCH_CANCEL",target:Ex.EventType,targetName:"SystemEvent.EventType"}]),st(Iw.prototype,"EventTouch.prototype",[{name:"getEventCode",suggest:"please use EventTouch.prototype.type instead"}]),nt(Iw.prototype,"EventTouch.prototype",[{name:"getUILocationInView",newName:"getLocationInView",target:Iw,targetName:"EventTouch"}]),st(Ce.KEY,"macro.KEY",["back","menu","0","1","2","3","4","5","6","7","8","9","0","*","+","-","/",";","=",",",".","[","]","dpadLeft","dpadRight","dpadUp","dpadDown","dpadCenter"].map((function(t){return{name:t}}))),st(Ce.KEY,"macro.KEY",[{name:"shift",suggest:"please use KeyCode.SHIFT_LEFT instead"}]),st(Ce.KEY,"macro.KEY",[{name:"ctrl",suggest:"please use KeyCode.CTRL_LEFT instead"}]),st(Ce.KEY,"macro.KEY",[{name:"alt",suggest:"please use KeyCode.ALT_LEFT instead"}]),st(Ce,"macro",[{name:"KEY",suggest:"please use KeyCode instead"}]),function(t){t[t.VERTICAL=0]="VERTICAL",t[t.HORIZONTAL=1]="HORIZONTAL"}(Cx||(Cx={})),function(t){t[t.ORTHO=0]="ORTHO",t[t.PERSPECTIVE=1]="PERSPECTIVE"}(wx||(wx={})),function(t){t[t.F1_8=0]="F1_8",t[t.F2_0=1]="F2_0",t[t.F2_2=2]="F2_2",t[t.F2_5=3]="F2_5",t[t.F2_8=4]="F2_8",t[t.F3_2=5]="F3_2",t[t.F3_5=6]="F3_5",t[t.F4_0=7]="F4_0",t[t.F4_5=8]="F4_5",t[t.F5_0=9]="F5_0",t[t.F5_6=10]="F5_6",t[t.F6_3=11]="F6_3",t[t.F7_1=12]="F7_1",t[t.F8_0=13]="F8_0",t[t.F9_0=14]="F9_0",t[t.F10_0=15]="F10_0",t[t.F11_0=16]="F11_0",t[t.F13_0=17]="F13_0",t[t.F14_0=18]="F14_0",t[t.F16_0=19]="F16_0",t[t.F18_0=20]="F18_0",t[t.F20_0=21]="F20_0",t[t.F22_0=22]="F22_0"}(xx||(xx={})),function(t){t[t.ISO100=0]="ISO100",t[t.ISO200=1]="ISO200",t[t.ISO400=2]="ISO400",t[t.ISO800=3]="ISO800"}(Rx||(Rx={})),function(t){t[t.D1=0]="D1",t[t.D2=1]="D2",t[t.D4=2]="D4",t[t.D8=3]="D8",t[t.D15=4]="D15",t[t.D30=5]="D30",t[t.D60=6]="D60",t[t.D125=7]="D125",t[t.D250=8]="D250",t[t.D500=9]="D500",t[t.D1000=10]="D1000",t[t.D2000=11]="D2000",t[t.D4000=12]="D4000"}(Ix||(Ix={})),function(t){t[t.DEFAULT=-1]="DEFAULT",t[t.LEFT_EYE=0]="LEFT_EYE",t[t.RIGHT_EYE=1]="RIGHT_EYE",t[t.MAIN=2]="MAIN"}(Bx||(Bx={})),function(t){t[t.NO_TRACKING=0]="NO_TRACKING",t[t.POSITION_AND_ROTATION=1]="POSITION_AND_ROTATION",t[t.POSITION=2]="POSITION",t[t.ROTATION=3]="ROTATION"}(Dx||(Dx={})),function(t){t[t.EDITOR=0]="EDITOR",t[t.GAME_VIEW=1]="GAME_VIEW",t[t.SCENE_VIEW=2]="SCENE_VIEW",t[t.PREVIEW=3]="PREVIEW",t[t.GAME=100]="GAME"}(Px||(Px={}));var Mx,Lx=[1.8,2,2.2,2.5,2.8,3.2,3.5,4,4.5,5,5.6,6.3,7.1,8,9,10,11,13,14,16,18,20,22],Nx=[1,.5,1/4,1/8,1/15,1/30,1/60,.008,.004,.002,.001,5e-4,1/4e3],Fx=[100,200,400,800],kx=new on,Vx=new on,Gx=new In,Ux=Cc.STENCIL<<1,zx=[],Hx=function(){function t(t){if(this.isWindowSize=!0,this.screenScale=void 0,this.postProcess=null,this.usePostProcess=!1,this.pipeline="",this._device=void 0,this._scene=null,this._node=null,this._name=null,this._enabled=!1,this._proj=-1,this._aspect=void 0,this._orthoHeight=10,this._fovAxis=Cx.VERTICAL,this._fov=Bi(45),this._nearClip=1,this._farClip=1e3,this._clearColor=new zc(.2,.2,.2,1),this._viewport=new Un(0,0,1,1),this._orientedViewport=new Un(0,0,1,1),this._curTransform=Ul.IDENTITY,this._isProjDirty=!0,this._matView=new In,this._matProj=new In,this._matProjInv=new In,this._matViewProj=new In,this._matViewProjInv=new In,this._frustum=new xs,this._forward=new on,this._position=new on,this._priority=0,this._aperture=xx.F16_0,this._apertureValue=void 0,this._shutter=Ix.D125,this._shutterValue=0,this._iso=Rx.ISO100,this._isoValue=0,this._window=null,this._width=1,this._height=1,this._clearFlag=Cc.NONE,this._clearDepth=1,this._visibility=Ky,this._exposure=0,this._clearStencil=0,this._geometryRenderer=null,this._windowId=0,this._cameraType=Bx.DEFAULT,this._trackingType=Dx.NO_TRACKING,this._usage=Px.GAME,this._device=t,this._apertureValue=Lx[this._aperture],this._shutterValue=Nx[this._shutter],this._isoValue=Fx[this._iso],this._aspect=this.screenScale=1,this._frustum.accurate=!0,!zx.length){var e=t.capabilities.clipSpaceSignY;zx[Ul.IDENTITY]=new In(1,0,0,0,0,e),zx[Ul.ROTATE_90]=new In(0,1,0,0,-e,0),zx[Ul.ROTATE_180]=new In(-1,0,0,0,0,-e),zx[Ul.ROTATE_270]=new In(0,-1,0,0,e,0)}}var e=t.prototype;return e._updateAspect=function(t){if(void 0===t&&(t=!0),this._aspect=this.window.width*this._viewport.width/(this.window.height*this._viewport.height),t){var e=this.window.swapchain;(e&&e.surfaceTransform||Ul.IDENTITY)%2&&(this._aspect=1/this._aspect)}this._isProjDirty=!0},e.initialize=function(t){void 0!==t.usage?this._usage=t.usage:this.setDefaultUsage(),void 0!==t.trackingType&&(this._trackingType=t.trackingType),void 0!==t.cameraType&&(this._cameraType=t.cameraType),this.node=t.node,this._width=1,this._height=1,this.clearFlag=Cc.NONE,this.clearDepth=1,this.visibility=Ky,this._name=t.name,this._proj=t.projection,this._priority=t.priority||0,this._aspect=this.screenScale=1,this.updateExposure(),this.changeTargetWindow(t.window)},e.destroy=function(){var t;this._node=null,this.detachFromScene(),this._window&&(this._window.detachCamera(this),this.window=null),this._name=null,null===(t=this._geometryRenderer)||void 0===t||t.destroy()},e.attachToScene=function(t){this._enabled=!0,this._scene=t},e.detachFromScene=function(){this._enabled=!1,this._scene=null},e.resize=function(t,e){this._window&&(this._width=t,this._height=e,this._aspect=t*this._viewport.width/(e*this._viewport.height),this._isProjDirty=!0)},e.setFixedSize=function(t,e){this._width=t,this._height=e,this._updateAspect(),this.isWindowSize=!1},e.syncCameraEditor=function(){},e.update=function(t){var e;if(void 0===t&&(t=!1),this._node){var i=!1,n=globalThis.__globalXR;if(n&&n.isWebXR&&n.webXRWindowMap&&n.updateViewport){var r=n.webXRMatProjs?1/n.webXRMatProjs.length:1,s=n.webXRWindowMap.get(this._window);this.setViewportInOrientedSpace(new Un(r*s,0,r,1))}(this._node.hasChangedFlags||t)&&(In.invert(this._matView,this._node.worldMatrix),this._forward.x=-this._matView.m02,this._forward.y=-this._matView.m06,this._forward.z=-this._matView.m10,In.multiply(this._matView,(new In).scale(this._node.worldScale),this._matView),this._node.getWorldPosition(this._position),i=!0);var o=null===(e=this.window)||void 0===e?void 0:e.swapchain,a=o&&o.surfaceTransform||Ul.IDENTITY;if(this._isProjDirty||this._curTransform!==a){this._curTransform=a;var h=this._device.capabilities.clipSpaceSignY;if(this._proj===wx.PERSPECTIVE)if(n&&n.isWebXR&&n.webXRWindowMap&&n.webXRMatProjs){var u=n.webXRWindowMap.get(this._window);this._matProj.set(n.webXRMatProjs[u])}else In.perspective(this._matProj,this._fov,this._aspect,this._nearClip,this._farClip,this._fovAxis===Cx.VERTICAL,this._device.capabilities.clipSpaceMinZ,h,a);else{var l=this._orthoHeight*this._aspect,c=this._orthoHeight;In.ortho(this._matProj,-l,l,-c,c,this._nearClip,this._farClip,this._device.capabilities.clipSpaceMinZ,h,a)}In.invert(this._matProjInv,this._matProj),i=!0,this._isProjDirty=!1}i&&(In.multiply(this._matViewProj,this._matProj,this._matView),In.invert(this._matViewProjInv,this._matViewProj),this._frustum.update(this._matViewProj,this._matViewProjInv))}},e.setViewportInOrientedSpace=function(t){var e,i=t.x,n=t.width,r=t.height,s=this._device.capabilities.screenSpaceSignY<0?1-t.y-r:t.y,o=null===(e=this.window)||void 0===e?void 0:e.swapchain;switch(o&&o.surfaceTransform||Ul.IDENTITY){case Ul.ROTATE_90:this._viewport.x=1-s-r,this._viewport.y=i,this._viewport.width=r,this._viewport.height=n;break;case Ul.ROTATE_180:this._viewport.x=1-i-n,this._viewport.y=1-s-r,this._viewport.width=n,this._viewport.height=r;break;case Ul.ROTATE_270:this._viewport.x=s,this._viewport.y=1-i-n,this._viewport.width=r,this._viewport.height=n;break;case Ul.IDENTITY:this._viewport.x=i,this._viewport.y=s,this._viewport.width=n,this._viewport.height=r}this._orientedViewport.x=i,this._orientedViewport.y=s,this._orientedViewport.width=n,this._orientedViewport.height=r,this.resize(this.width,this.height)},e.initGeometryRenderer=function(){var t;this._geometryRenderer||(this._geometryRenderer=v.internal.GeometryRenderer?new v.internal.GeometryRenderer:null,null===(t=this._geometryRenderer)||void 0===t||t.activate(this._device))},e.changeTargetWindow=function(t){void 0===t&&(t=null),this._window&&this._window.detachCamera(this);var e=t||v.director.root.mainWindow;if(e){e.attachCamera(this),this.window=e;var i=e.swapchain;(i&&i.surfaceTransform||Ul.IDENTITY)%2?this.resize(e.height,e.width):this.resize(e.width,e.height)}},e.detachCamera=function(){this._window&&this._window.detachCamera(this)},e.screenPointToRay=function(t,e,i){if(!this._node)return null;var n=this.width,r=this.height,s=this._orientedViewport.x*n,o=this._orientedViewport.y*r,a=this._orientedViewport.width*n,h=this._orientedViewport.height*r,u=this._proj===wx.PERSPECTIVE,l=this._device.capabilities.clipSpaceSignY,c=Rn[this._curTransform];on.set(kx,(e-s)/a*2-1,(i-o)/h*2-1,u?1:-1);var _=kx.x,d=kx.y;return kx.x=_*c[0]+d*c[2]*l,kx.y=_*c[1]+d*c[3]*l,on.transformMat4(u?kx:t.o,kx,this._matViewProjInv),u?(this._node.getWorldPosition(Vx),or.fromPoints(t,Vx,kx)):on.transformQuat(t.d,on.FORWARD,this._node.worldRotation),t},e.screenToWorld=function(t,e){var i=this.width,n=this.height,r=this._orientedViewport.x*i,s=this._orientedViewport.y*n,o=this._orientedViewport.width*i,a=this._orientedViewport.height*n,h=this._device.capabilities.clipSpaceSignY,u=Rn[this._curTransform];if(this._proj===wx.PERSPECTIVE){on.set(t,(e.x-r)/o*2-1,(e.y-s)/a*2-1,1);var l=t.x,c=t.y;t.x=l*u[0]+c*u[2]*h,t.y=l*u[1]+c*u[3]*h,on.transformMat4(t,t,this._matViewProjInv),this._node&&this._node.getWorldPosition(kx),on.lerp(t,kx,t,Ii(this._nearClip/this._farClip,1,e.z))}else{on.set(t,(e.x-r)/o*2-1,(e.y-s)/a*2-1,2*e.z-1);var _=t.x,d=t.y;t.x=_*u[0]+d*u[2]*h,t.y=_*u[1]+d*u[3]*h,on.transformMat4(t,t,this._matViewProjInv)}return t},e.worldToScreen=function(t,e){var i=this._device.capabilities.clipSpaceSignY,n=Rn[this._curTransform];on.transformMat4(t,e,this._matViewProj);var r=t.x,s=t.y;t.x=r*n[0]+s*n[2]*i,t.y=r*n[1]+s*n[3]*i;var o=this.width,a=this.height,h=this._orientedViewport.x*o,u=this._orientedViewport.y*a,l=this._orientedViewport.width*o,c=this._orientedViewport.height*a;return t.x=h+.5*(t.x+1)*l,t.y=u+.5*(t.y+1)*c,t.z=.5*t.z+.5,t},e.worldMatrixToScreen=function(t,e,i,n){In.multiply(t,this._matViewProj,e),In.multiply(t,zx[this._curTransform],t);var r=i/2,s=n/2;return In.identity(Gx),In.transform(Gx,Gx,on.set(kx,r,s,0)),In.scale(Gx,Gx,on.set(kx,r,s,1)),In.multiply(t,Gx,t),t},e.calculateObliqueMat=function(t){var e=new tn(Math.sign(t.x),Math.sign(t.y),1,1).transformMat4(this._matProjInv),i=new tn(this._matProj.m03,this._matProj.m07,this._matProj.m11,this._matProj.m15),n=2/tn.dot(t,e),r=t.multiplyScalar(n).subtract(i);this._matProj.m02=r.x,this._matProj.m06=r.y,this._matProj.m10=r.z,this._matProj.m14=r.w},e.getClipSpaceMinz=function(){return this._device.capabilities.clipSpaceMinZ},e.setExposure=function(t){this._exposure=.833333/Math.pow(2,t)},e.updateExposure=function(){var t=Math.log2(this._apertureValue*this._apertureValue/this._shutterValue*100/this._isoValue);this.setExposure(t)},e.setDefaultUsage=function(){this._usage=Px.GAME},n(t,[{key:"name",get:function(){return this._name}},{key:"scene",get:function(){return this._scene}},{key:"node",get:function(){return this._node},set:function(t){this._node=t}},{key:"systemWindowId",get:function(){return this._windowId}},{key:"window",get:function(){return this._window},set:function(t){this._window=t}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"position",get:function(){return this._position},set:function(t){this._position=t}},{key:"forward",get:function(){return this._forward},set:function(t){this._forward=t}},{key:"aperture",get:function(){return this._aperture},set:function(t){this._aperture=t,this._apertureValue=Lx[this._aperture],this.updateExposure()}},{key:"apertureValue",get:function(){return this._apertureValue}},{key:"shutter",get:function(){return this._shutter},set:function(t){this._shutter=t,this._shutterValue=Nx[this._shutter],this.updateExposure()}},{key:"shutterValue",get:function(){return this._shutterValue}},{key:"iso",get:function(){return this._iso},set:function(t){this._iso=t,this._isoValue=Fx[this._iso],this.updateExposure()}},{key:"isoValue",get:function(){return this._isoValue}},{key:"exposure",get:function(){return this._exposure}},{key:"clearFlag",get:function(){return this._clearFlag},set:function(t){this._clearFlag=t}},{key:"clearColor",get:function(){return this._clearColor},set:function(t){this._clearColor.x=t.x,this._clearColor.y=t.y,this._clearColor.z=t.z,this._clearColor.w=t.w}},{key:"clearDepth",get:function(){return this._clearDepth},set:function(t){this._clearDepth=t}},{key:"clearStencil",get:function(){return this._clearStencil},set:function(t){this._clearStencil=t}},{key:"projectionType",get:function(){return this._proj},set:function(t){this._proj=t,this._isProjDirty=!0}},{key:"aspect",get:function(){return this._aspect}},{key:"orthoHeight",get:function(){return this._orthoHeight},set:function(t){this._orthoHeight=t,this._isProjDirty=!0}},{key:"fovAxis",get:function(){return this._fovAxis},set:function(t){this._fovAxis=t,this._isProjDirty=!0}},{key:"fov",get:function(){return this._fov},set:function(t){this._fov=t,this._isProjDirty=!0}},{key:"nearClip",get:function(){return this._nearClip},set:function(t){this._nearClip=t,this._isProjDirty=!0}},{key:"farClip",get:function(){return this._farClip},set:function(t){this._farClip=t,this._isProjDirty=!0}},{key:"viewport",get:function(){return this._viewport},set:function(t){Y(8302),this.setViewportInOrientedSpace(t)}},{key:"frustum",get:function(){return this._frustum},set:function(t){this._frustum=t}},{key:"matView",get:function(){return this._matView}},{key:"matProj",get:function(){return this._matProj}},{key:"matProjInv",get:function(){return this._matProjInv}},{key:"matViewProj",get:function(){return this._matViewProj}},{key:"matViewProjInv",get:function(){return this._matViewProjInv}},{key:"surfaceTransform",get:function(){return this._curTransform}},{key:"geometryRenderer",get:function(){return this._geometryRenderer}},{key:"cameraType",get:function(){return this._cameraType},set:function(t){this._cameraType=t}},{key:"trackingType",get:function(){return this._trackingType},set:function(t){this._trackingType=t}},{key:"cameraUsage",get:function(){return this._usage},set:function(t){this._usage=t}}],[{key:"standardExposureValue",get:function(){return 1/38400}},{key:"standardLightMeterScale",get:function(){return 1e4}}]),t}(),Wx=new on,jx=gr.create(0,0,0,1),Xx=new Ss(0,0,0,.5,.5,.5),qx=new Ss,Yx=new Bu((function(){return{model:null,depth:0}}),128);function Kx(t,e){var i=0;t.node&&(on.subtract(Wx,t.worldBounds?t.worldBounds.center:t.node.worldPosition,e.position),i=on.dot(Wx,e.forward));var n=Yx.alloc();return n.model=t,n.depth=i,n}function Jx(t,e){var i=t.pipelineSceneData,n=i.validPunctualLights;n.length=0;for(var r=e.scene.spotLights,s=0;s<r.length;s++){var o=r[s];o.baked&&!e.node.scene.globals.disableLightmap||(gr.set(jx,o.position.x,o.position.y,o.position.z,o.range),as.sphereFrustum(jx,e.frustum)&&n.push(o))}for(var a=e.scene.sphereLights,h=0;h<a.length;h++){var u=a[h];u.baked&&!e.node.scene.globals.disableLightmap||(gr.set(jx,u.position.x,u.position.y,u.position.z,u.range),as.sphereFrustum(jx,e.frustum)&&n.push(u))}for(var l=e.scene.pointLights,c=0;c<l.length;c++){var _=l[c];_.baked||(gr.set(jx,_.position.x,_.position.y,_.position.z,_.range),as.sphereFrustum(jx,e.frustum)&&n.push(_))}for(var d=e.scene.rangedDirLights,f=0;f<d.length;f++){var p=d[f];Ss.transform(qx,Xx,p.node.getWorldMatrix()),as.aabbFrustum(qx,e.frustum)&&n.push(p)}i.validPunctualLights=n}function Qx(t,e){var i=e.scene,n=i.mainLight,r=t.pipelineSceneData,s=r.shadows,o=r.skybox,a=r.csmLayers,h=r.renderObjects;Yx.freeArray(h),h.length=0;var u=a.castShadowObjects;u.length=0;var l=a.layerObjects;l.clear(),s.enabled&&(t.pipelineUBO.updateShadowUBORange(Pg.SHADOW_COLOR_OFFSET,s.shadowColor),s.type===IT.ShadowMap&&n&&n.node&&a.update(r,e)),e.clearFlag&Ux&&(o.enabled&&o.model?h.push(Kx(o.model,e)):e.cameraUsage!==Px.EDITOR&&e.cameraUsage!==Px.SCENE_VIEW&&v.warnID(15100,e.name));var c=i.models,_=e.visibility;function d(t){if(t.enabled){if(i.isCulledByLod(e,t))return;if(t.castShadow&&(u.push(Kx(t,e)),l.push(Kx(t,e))),t.node&&(_&t.node.layer)===t.node.layer||_&t.visFlags){if(t.worldBounds&&!as.aabbFrustum(t.worldBounds,e.frustum))return;h.push(Kx(t,e))}}}for(var f=0;f<c.length;f++)d(c[f])}var Zx=new __;Zx.format=Hl.RGBA8;var $x=new d_;$x.format=Hl.DEPTH_STENCIL;var tR,eR,iR=new m_([Zx],$x),nR={width:1,height:1,renderPassInfo:iR},rR=t("ej",qs("cc.RenderTexture")(Mx=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._window=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._name=t.name||"",this._width=t.width,this._height=t.height,this._initWindow(t)},i.reset=function(t){this.initialize(t)},i.destroy=function(){if(this._window){var e=v.director.root;null==e||e.destroyWindow(this._window),this._window=null}return t.prototype.destroy.call(this)},i.resize=function(t,e){this._width=Math.floor(xi(t,1,2048)),this._height=Math.floor(xi(e,1,2048)),this._window&&this._window.resize(this._width,this._height),this.emit("resize",this._window)},i._serialize=function(){return{}},i._deserialize=function(e,i){var n=e;this._width=n.w,this._height=n.h,this._name=n.n,t.prototype._deserialize.call(this,n.base,i)},i.getGFXTexture=function(){return this._window&&this._window.framebuffer.colorTextures[0]},i.onLoaded=function(){this._initWindow()},i._initWindow=function(t){var e=v.director.root;nR.title=this._name,nR.width=this._width,nR.height=this._height,nR.renderPassInfo=t&&t.passInfo?t.passInfo:iR,nR.externalResLow=t&&t.externalResLow?t.externalResLow:0,nR.externalResHigh=t&&t.externalResHigh?t.externalResHigh:0,nR.externalFlag=t&&t.externalFlag?t.externalFlag:Zl.NONE,Zx.barrier=Ed.gfxDevice.getGeneralBarrier(new g_(_c.FRAGMENT_SHADER_READ_TEXTURE,_c.FRAGMENT_SHADER_READ_TEXTURE)),this._window?(this._window.destroy(),this._window.initialize(Ed.gfxDevice,nR)):this._window=e.createWindow(nR)},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this._width=this._height=1,this._initWindow()},i.validate=function(){return this.width>=1&&this.width<=2048&&this.height>=1&&this.height<=2048},i.readPixels=function(t,e,i,n,r){void 0===t&&(t=0),void 0===e&&(e=0),i=i||this.width,n=n||this.height;var s=this.getGFXTexture();if(!s)return J(7606),null;var o=4*i*n;if(void 0===r)r=new Uint8Array(o);else if(r.length<o)return J(7607,o),null;var a=this._getGFXDevice(),h=[],u=[],l=new Gc;return l.texOffset.x=t,l.texOffset.y=e,l.texExtent.width=i,l.texExtent.height=n,u.push(l),h.push(r),null==a||a.copyTextureToBuffers(s,h,u),r},n(e,[{key:"window",get:function(){return this._window}}]),e}(Of))||Mx);v.RenderTexture=rR,function(t){t[t.SKYBOX=Ux|Cc.DEPTH_STENCIL]="SKYBOX",t[t.SOLID_COLOR=Cc.ALL]="SOLID_COLOR"}(tR||(tR={})),function(t){t[t.CUBE=0]="CUBE",t[t.PLANAR=1]="PLANAR"}(eR||(eR={}));var sR,oR=[new on(0,-90,0),new on(0,90,0),new on(90,0,0),new on(-90,0,0),new on(0,0,0),new on(0,180,0)],aR=function(){function t(t){this.bakedCubeTextures=[],this.realtimePlanarTexture=null,this._resolution=256,this._clearFlag=tR.SKYBOX,this._backgroundColor=new dn(0,0,0,255),this._visibility=Ky,this._probeType=eR.CUBE,this._cubemap=null,this._size=new on(1,1,1),this._camera=null,this._probeId=0,this._needRefresh=!1,this._needRender=!1,this._node=null,this._cameraNode=null,this._boundingBox=null,this._cameraWorldPos=new on,this._cameraWorldRotation=new Sn,this._forward=new on,this._up=new on,this._previewSphere=null,this._previewPlane=null,this._probeId=t}var e=t.prototype;return e.initialize=function(t,e){this._node=t,this._cameraNode=e;var i=this.node.getWorldPosition();this._boundingBox=Ss.create(i.x,i.y,i.z,this._size.x,this._size.y,this._size.z),this._createCamera(e)},e.initBakedTextures=function(){if(0===this.bakedCubeTextures.length)for(var t=0;t<6;t++){var e=this._createTargetTexture(this._resolution,this._resolution);this.bakedCubeTextures.push(e)}},e.captureCubemap=function(){this.initBakedTextures(),this._resetCameraParams(),this._needRender=!0},e.renderPlanarReflection=function(t){if(t){if(!this.realtimePlanarTexture){var e=v.view.getDesignResolutionSize();this.realtimePlanarTexture=this._createTargetTexture(e.width,e.height),v.internal.reflectionProbeManager.updatePlanarMap(this,this.realtimePlanarTexture.getGFXTexture())}this._syncCameraParams(t),this._transformReflectionCamera(t),this._needRender=!0}},e.switchProbeType=function(t,e){t===eR.CUBE?this._needRender=!1:null!==e&&this.renderPlanarReflection(e)},e.getProbeId=function(){return this._probeId},e.updateProbeId=function(t){this._probeId=t},e.renderArea=function(){return this._probeType===eR.PLANAR?new Ln(this.realtimePlanarTexture.width,this.realtimePlanarTexture.height):new Ln(this.resolution,this.resolution)},e.isFinishedRendering=function(){return!0},e.validate=function(){return null!==this.cubemap},e.destroy=function(){this._camera&&(this._camera.destroy(),this._camera=null);for(var t=0;t<this.bakedCubeTextures.length;t++)this.bakedCubeTextures[t].destroy();this.bakedCubeTextures=[],this.realtimePlanarTexture&&(this.realtimePlanarTexture.destroy(),this.realtimePlanarTexture=null)},e.enable=function(){},e.disable=function(){},e.updateCameraDir=function(t){this.cameraNode.setRotationFromEuler(oR[t]),this.camera.update(!0)},e.updateBoundingBox=function(){if(this.node){var t=this.node.getWorldPosition();Ss.set(this._boundingBox,t.x,t.y,t.z,this._size.x,this._size.y,this._size.z)}},e.hasFrameBuffer=function(t){if(this.probeType===eR.PLANAR){var e;if(!this.realtimePlanarTexture)return!1;if((null===(e=this.realtimePlanarTexture.window)||void 0===e?void 0:e.framebuffer)===t)return!0}else{if(0===this.bakedCubeTextures.length)return!1;for(var i=0;i<this.bakedCubeTextures.length;i++){var n;if((null===(n=this.bakedCubeTextures[i].window)||void 0===n?void 0:n.framebuffer)===t)return!0}}return!1},e.isRGBE=function(){return!0},e._syncCameraParams=function(t){this.camera.projectionType=t.projectionType,this.camera.orthoHeight=t.orthoHeight,this.camera.nearClip=t.nearClip,this.camera.farClip=t.farClip,this.camera.fov=t.fov,this.camera.clearFlag=t.clearFlag,this.camera.clearColor=t.clearColor,this.camera.priority=t.priority-1,this.camera.resize(t.width,t.height)},e._createCamera=function(t){var e=v.director.root;if(!this._camera){if(this._camera=e.createCamera(),!this._camera)return null;this._camera.initialize({name:t.name,node:t,projection:wx.PERSPECTIVE,window:e&&e.tempWindow,priority:0,cameraType:Bx.DEFAULT,trackingType:Dx.NO_TRACKING})}return this._camera.setViewportInOrientedSpace(new Un(0,0,1,1)),this._camera.fovAxis=Cx.VERTICAL,this._camera.fov=Bi(90),this._camera.orthoHeight=10,this._camera.nearClip=1,this._camera.farClip=1e3,this._camera.clearColor=this._backgroundColor,this._camera.clearDepth=1,this._camera.clearStencil=0,this._camera.clearFlag=this._clearFlag,this._camera.visibility=this._visibility,this._camera.aperture=xx.F16_0,this._camera.shutter=Ix.D125,this._camera.iso=Rx.ISO100,this._camera},e._resetCameraParams=function(){this.camera.projectionType=wx.PERSPECTIVE,this.camera.orthoHeight=10,this.camera.nearClip=1,this.camera.farClip=1e3,this.camera.fov=Bi(90),this.camera.priority=0,this.camera.resize(this.resolution,this.resolution),this.camera.visibility=this._visibility,this.camera.clearFlag=this._clearFlag,this.camera.clearColor=this._backgroundColor,this.cameraNode.worldPosition=this.node.worldPosition,this.cameraNode.worldRotation=this.node.worldRotation,this.camera.update(!0)},e._createTargetTexture=function(t,e){var i=new rR;return i.reset({width:t,height:e}),i},e._transformReflectionCamera=function(t){var e=on.dot(this.node.worldPosition,this.node.up);this._reflect(this._cameraWorldPos,t.node.worldPosition,this.node.up,e),this.cameraNode.worldPosition=this._cameraWorldPos,on.transformQuat(this._forward,on.FORWARD,t.node.worldRotation),this._reflect(this._forward,this._forward,this.node.up,0),this._forward.normalize(),this._forward.negative(),on.transformQuat(this._up,on.UP,t.node.worldRotation),this._reflect(this._up,this._up,this.node.up,0),this._up.normalize(),Sn.fromViewUp(this._cameraWorldRotation,this._forward,this._up),this.cameraNode.worldRotation=this._cameraWorldRotation,this.camera.update(!0);var i=new tn(this.node.up.x,this.node.up.y,this.node.up.z,-on.dot(this.node.up,this.node.worldPosition));i.transformMat4(this.camera.matView.clone().invert().transpose()),this.camera.calculateObliqueMat(i)},e._reflect=function(t,e,i,n){var r=on.clone(i);r.normalize();var s=on.dot(r,e)-n;return r.multiplyScalar(2*s),on.subtract(t,e,r),t},n(t,[{key:"probeType",get:function(){return this._probeType},set:function(t){this._probeType=t}},{key:"resolution",get:function(){return this._resolution},set:function(t){t!==this._resolution&&this.bakedCubeTextures.forEach((function(e){e.resize(t,t)})),this._resolution=t}},{key:"clearFlag",get:function(){return this._clearFlag},set:function(t){this._clearFlag=t,this.camera.clearFlag=this._clearFlag}},{key:"backgroundColor",get:function(){return this._backgroundColor},set:function(t){this._backgroundColor=t,this.camera.clearColor=this._backgroundColor}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t,this._camera.visibility=this._visibility}},{key:"size",get:function(){return this._size},set:function(t){this._size.set(t);var e=this.node.getWorldPosition();Ss.set(this._boundingBox,e.x,e.y,e.z,this._size.x,this._size.y,this._size.z)}},{key:"cubemap",get:function(){return this._cubemap},set:function(t){this._cubemap=t}},{key:"node",get:function(){return this._node}},{key:"camera",get:function(){return this._camera}},{key:"needRefresh",get:function(){return this._needRefresh},set:function(t){this._needRefresh=t}},{key:"needRender",get:function(){return this._needRender},set:function(t){this._needRender=t}},{key:"boundingBox",get:function(){return this._boundingBox}},{key:"cameraNode",get:function(){return this._cameraNode},set:function(t){this._cameraNode=t}},{key:"previewSphere",get:function(){return this._previewSphere},set:function(t){this._previewSphere=t}},{key:"previewPlane",get:function(){return this._previewPlane},set:function(t){this._previewPlane=t}}]),t}();function hR(t,e){e<1e3?e=1e3:e>15e3&&(e=15e3);var i=e*e,n=(.860117757+.000154118254*e+1.28641212e-7*i)/(1+.000842420235*e+7.08145163e-7*i),r=(.317398726+422806245e-13*e+4.20481691e-8*i)/(1-289741816e-13*e+1.61456053e-7*i),s=2*n-8*r+4,o=3*n/s,a=2*r/s,h=1/a*o,u=1/a*(1-o-a);t.x=3.2404542*h-1.5371385+-.4985314*u,t.y=-.969266*h+1.8760108+.041556*u,t.z=.0556434*h-.2040259+1.0572252*u}!function(t){t[t.DIRECTIONAL=0]="DIRECTIONAL",t[t.SPHERE=1]="SPHERE",t[t.SPOT=2]="SPOT",t[t.POINT=3]="POINT",t[t.RANGED_DIRECTIONAL=4]="RANGED_DIRECTIONAL",t[t.UNKNOWN=5]="UNKNOWN"}(sR||(sR={}));var uR,lR,cR,_R,dR,fR,pR,mR,gR,yR,vR,SR,TR=function(t){return 4*Math.PI*Math.PI*t*t},AR=function(){function t(){this._baked=!1,this._color=new on(1,1,1),this._colorTemp=6550,this._colorTempRGB=new on(1,1,1),this._finalColor=new on(1,1,1),this._scene=null,this._node=null,this._name=null,this._useColorTemperature=!1,this._type=sR.UNKNOWN,this._visibility=Ky}var e=t.prototype;return e.initialize=function(){this.color=new on(1,1,1),this.colorTemperature=6550},e.attachToScene=function(t){this._scene=t},e.detachFromScene=function(){this._scene=null},e.destroy=function(){this._name=null,this._node=null},e.update=function(){},n(t,[{key:"baked",get:function(){return this._baked},set:function(t){this._baked=t}},{key:"color",get:function(){return this._color},set:function(t){this._color.set(t),this._useColorTemperature&&on.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(t){this._useColorTemperature=t,t&&on.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"colorTemperature",get:function(){return this._colorTemp},set:function(t){this._colorTemp=t,hR(this._colorTempRGB,this._colorTemp),this._useColorTemperature&&on.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"colorTemperatureRGB",get:function(){return this._colorTempRGB}},{key:"finalColor",get:function(){return this._finalColor}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t}},{key:"node",get:function(){return this._node},set:function(t){this._node=t,this._node&&(this._node.hasChangedFlags|=rm.ROTATION)}},{key:"type",get:function(){return this._type}},{key:"name",get:function(){return this._name},set:function(t){this._name=t}},{key:"scene",get:function(){return this._scene}}]),t}();!function(t){t[t.PER_INSTANCE=0]="PER_INSTANCE",t[t.PER_BATCH=1]="PER_BATCH",t[t.PER_PHASE=2]="PER_PHASE",t[t.PER_PASS=3]="PER_PASS",t[t.COUNT=4]="COUNT"}(uR||(uR={})),function(t){t[t.CONSTANTS=0]="CONSTANTS",t[t.CBV=1]="CBV",t[t.UAV=2]="UAV",t[t.SRV=3]="SRV",t[t.TABLE=4]="TABLE",t[t.SSV=5]="SSV"}(lR||(lR={})),function(t){t[t.MANAGED=0]="MANAGED",t[t.MEMORYLESS=1]="MEMORYLESS",t[t.PERSISTENT=2]="PERSISTENT",t[t.EXTERNAL=3]="EXTERNAL",t[t.BACKBUFFER=4]="BACKBUFFER"}(cR||(cR={})),function(t){t[t.NONE=0]="NONE",t[t.OPAQUE=1]="OPAQUE",t[t.MASK=2]="MASK",t[t.BLEND=3]="BLEND",t[t.RENDER_OPAQUE=1]="RENDER_OPAQUE",t[t.RENDER_CUTOUT=2]="RENDER_CUTOUT",t[t.RENDER_TRANSPARENT=3]="RENDER_TRANSPARENT"}(_R||(_R={})),function(t){t[t.BUFFER=0]="BUFFER",t[t.TEXTURE1D=1]="TEXTURE1D",t[t.TEXTURE2D=2]="TEXTURE2D",t[t.TEXTURE3D=3]="TEXTURE3D"}(dR||(dR={})),function(t){t[t.NONE=0]="NONE",t[t.UNIFORM=1]="UNIFORM",t[t.INDIRECT=2]="INDIRECT",t[t.STORAGE=4]="STORAGE",t[t.SAMPLED=8]="SAMPLED",t[t.COLOR_ATTACHMENT=16]="COLOR_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=32]="DEPTH_STENCIL_ATTACHMENT",t[t.INPUT_ATTACHMENT=64]="INPUT_ATTACHMENT",t[t.SHADING_RATE=128]="SHADING_RATE",t[t.TRANSFER_SRC=256]="TRANSFER_SRC",t[t.TRANSFER_DST=512]="TRANSFER_DST"}(fR||(fR={})),function(t){t[t.SYNC=0]="SYNC",t[t.ASYNC=1]="ASYNC"}(pR||(pR={})),function(t){t[t.NONE=0]="NONE",t[t.OPAQUE=1]="OPAQUE",t[t.MASK=2]="MASK",t[t.BLEND=4]="BLEND",t[t.OPAQUE_OBJECT=1]="OPAQUE_OBJECT",t[t.CUTOUT_OBJECT=2]="CUTOUT_OBJECT",t[t.TRANSPARENT_OBJECT=4]="TRANSPARENT_OBJECT",t[t.SHADOW_CASTER=8]="SHADOW_CASTER",t[t.UI=16]="UI",t[t.DEFAULT_LIGHTING=32]="DEFAULT_LIGHTING",t[t.VOLUMETRIC_LIGHTING=64]="VOLUMETRIC_LIGHTING",t[t.CLUSTERED_LIGHTING=128]="CLUSTERED_LIGHTING",t[t.PLANAR_SHADOW=256]="PLANAR_SHADOW",t[t.GEOMETRY=512]="GEOMETRY",t[t.PROFILER=1024]="PROFILER",t[t.DRAW_INSTANCING=2048]="DRAW_INSTANCING",t[t.DRAW_NON_INSTANCING=4096]="DRAW_NON_INSTANCING",t[t.REFLECTION_PROBE=8192]="REFLECTION_PROBE",t[t.GPU_DRIVEN=16384]="GPU_DRIVEN",t[t.NON_BUILTIN=32768]="NON_BUILTIN",t[t.ALL=4294967295]="ALL"}(mR||(mR={})),function(t){t[t.NONE=0]="NONE",t[t.DEFAULT=1]="DEFAULT",t[t.CLUSTERED=2]="CLUSTERED"}(gR||(gR={})),function(t){t[t.RENDER_TARGET=0]="RENDER_TARGET",t[t.DEPTH_STENCIL=1]="DEPTH_STENCIL",t[t.SHADING_RATE=2]="SHADING_RATE"}(yR||(yR={})),function(t){t[t.READ=0]="READ",t[t.READ_WRITE=1]="READ_WRITE",t[t.WRITE=2]="WRITE"}(vR||(vR={})),function(t){t[t.NONE=0]="NONE",t[t.FLOAT_TYPE=1]="FLOAT_TYPE",t[t.INT_TYPE=2]="INT_TYPE"}(SR||(SR={}));var bR,ER,CR=function(){function t(t,e,i,n){void 0===t&&(t=null),void 0===e&&(e=0),void 0===i&&(i=!1),void 0===n&&(n=null),this.light=void 0,this.probe=void 0,this.level=void 0,this.culledByLight=void 0,this.light=t,this.probe=n,this.level=e,this.culledByLight=i}return t.prototype.reset=function(t,e,i,n){void 0===t&&(t=null),void 0===e&&(e=0),void 0===i&&(i=!1),void 0===n&&(n=null),this.light=t,this.probe=n,this.level=e,this.culledByLight=i},t}();!function(t){t[t.UNIFORM_BUFFER=0]="UNIFORM_BUFFER",t[t.DYNAMIC_UNIFORM_BUFFER=1]="DYNAMIC_UNIFORM_BUFFER",t[t.SAMPLER_TEXTURE=2]="SAMPLER_TEXTURE",t[t.SAMPLER=3]="SAMPLER",t[t.TEXTURE=4]="TEXTURE",t[t.STORAGE_BUFFER=5]="STORAGE_BUFFER",t[t.DYNAMIC_STORAGE_BUFFER=6]="DYNAMIC_STORAGE_BUFFER",t[t.STORAGE_IMAGE=7]="STORAGE_IMAGE",t[t.INPUT_ATTACHMENT=8]="INPUT_ATTACHMENT"}(bR||(bR={})),function(t){t[t.NONE=0]="NONE",t[t.COLOR=1]="COLOR",t[t.DEPTH=2]="DEPTH",t[t.STENCIL=4]="STENCIL"}(ER||(ER={}));var wR,xR=function(){function t(t,e,i,n,r,s,o){void 0===t&&(t=new Uint8Array(0)),void 0===e&&(e=""),void 0===i&&(i=4294967295),void 0===n&&(n=4294967295),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),this.source=void 0,this.target=void 0,this.mipLevels=void 0,this.numSlices=void 0,this.targetMostDetailedMip=void 0,this.targetFirstSlice=void 0,this.targetPlaneSlice=void 0,this.source=t,this.target=e,this.mipLevels=i,this.numSlices=n,this.targetMostDetailedMip=r,this.targetFirstSlice=s,this.targetPlaneSlice=o}return t.prototype.reset=function(t,e,i,n,r,s){void 0===t&&(t=""),void 0===e&&(e=4294967295),void 0===i&&(i=4294967295),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),this.target=t,this.mipLevels=e,this.numSlices=i,this.targetMostDetailedMip=n,this.targetFirstSlice=r,this.targetPlaneSlice=s},t}();rt(Of.prototype,"TextureBase.prototype",[{name:"hasPremultipliedAlpha"},{name:"setPremultiplyAlpha"},{name:"setFlipY"}]),nt(rR.prototype,"RenderTexture.prototype",[{name:"getGFXWindow",customFunction:function(){return this.window}}]);var RR=((wR={})[Wl.UNORM]="Uint",wR[Wl.SNORM]="Int",wR[Wl.UINT]="Uint",wR[Wl.INT]="Int",wR[Wl.UFLOAT]="Float",wR[Wl.FLOAT]="Float",wR.default="Uint",wR);function IR(t){return""+(RR[t.type]||RR.default)+t.size/t.count*8}function BR(t,e,i,n,r){void 0===i&&(i=Hl.R32F),void 0===n&&(n=0),void 0===r&&(r=0);var s=M_[i];r||(r=s.size);for(var o="set"+IR(s),a=s.size/s.count,h=Math.floor(e.length/s.count),u=xl.isLittleEndian,l=0;l<h;++l)for(var c=n+r*l,_=0;_<s.count;++_){var d=c+a*_;t[o](d,e[s.count*l+_],u)}}function DR(t,e,i,n,r,s){void 0===e&&(e=Hl.R32F),void 0===i&&(i=0),void 0===n&&(n=t.byteLength-i),void 0===r&&(r=0),void 0===s&&(s=[]);var o=M_[e];r||(r=o.size);for(var a="get"+IR(o),h=o.size/o.count,u=Math.floor(n/r),l=xl.isLittleEndian,c=0;c<u;++c)for(var _=i+r*c,d=0;d<o.count;++d){var f=_+h*d;s[o.count*c+d]=t[a](f,l)}return s}function PR(t,e,i,n,r,s,o){void 0===i&&(i=Hl.R32F),void 0===n&&(n=0),void 0===r&&(r=t.byteLength-n),void 0===s&&(s=0),o||(o=new DataView(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)));var a=M_[i];s||(s=a.size);for(var h="set"+IR(a),u="get"+IR(a),l=a.size/a.count,c=Math.floor(r/s),_=xl.isLittleEndian,d=0;d<c;++d)for(var f=n+s*d,p=0;p<a.count;++p){var m=f+l*p,g=t[u](m,_);o[h](m,e(g,p,t),_)}return o}var OR=t("ea",function(){function t(t,e,i,n,r,s){void 0===n&&(n=null),void 0===r&&(r=null),void 0===s&&(s=!0),this.mesh=void 0,this.subMeshIdx=void 0,this._flatBuffers=[],this._jointMappedBuffers=void 0,this._jointMappedBufferIndices=void 0,this._vertexIdChannel=void 0,this._geometricInfo=void 0,this._vertexBuffers=void 0,this._attributes=void 0,this._indexBuffer=null,this._indirectBuffer=null,this._primitiveMode=void 0,this._iaInfo=void 0,this._isOwnerOfIndexBuffer=!0,this._drawInfo=null,this._attributes=e,this._vertexBuffers=t,this._indexBuffer=n,this._indirectBuffer=r,this._primitiveMode=i,this._iaInfo=new c_(e,t,n,r),this._isOwnerOfIndexBuffer=s}var e=t.prototype;return e.invalidateGeometricInfo=function(){this._geometricInfo=void 0},e.genFlatBuffers=function(){if(!this._flatBuffers.length&&this.mesh&&void 0!==this.subMeshIdx){var t=this.mesh,e=0,i=t.struct.primitives[this.subMeshIdx];i.indexView&&(e=i.indexView.count);for(var n=0;n<i.vertexBundelIndices.length;n++){var r=i.vertexBundelIndices[n],s=t.struct.vertexBundles[r],o=i.indexView?i.indexView.count:s.view.count,a=s.view.stride,h=a*o,u=new Uint8Array(t.data.buffer,s.view.offset,s.view.length),l=new Uint8Array(i.indexView?h:s.view.length);if(i.indexView){for(var c=t.readIndices(this.subMeshIdx),_=0;_<e;++_)for(var d=_*a,f=c[_]*a,p=0;p<a;++p)l[d+p]=u[f+p];this._flatBuffers.push({stride:a,count:o,buffer:l})}else l.set(t.data.subarray(s.view.offset,s.view.offset+s.view.length)),this._flatBuffers.push({stride:a,count:o,buffer:l})}}},e.destroy=function(){for(var t=0;t<this.vertexBuffers.length;t++)this.vertexBuffers[t].destroy();if(this.vertexBuffers.length=0,this._indexBuffer&&(this._isOwnerOfIndexBuffer&&this._indexBuffer.destroy(),this._indexBuffer=null),this._jointMappedBuffers&&this._jointMappedBufferIndices){for(var e=0;e<this._jointMappedBufferIndices.length;e++)this._jointMappedBuffers[this._jointMappedBufferIndices[e]].destroy();this._jointMappedBuffers=void 0,this._jointMappedBufferIndices=void 0}this._indirectBuffer&&(this._indirectBuffer.destroy(),this._indirectBuffer=null)},e.enableVertexIdChannel=function(t){if(!this._vertexIdChannel){var e=this.vertexBuffers.length,i=this.attributes.length,n=this._allocVertexIdBuffer(t);this._vertexBuffers.push(n),this._attributes.push(new u_("a_vertexId",Hl.R32F,!1,e)),this._iaInfo.attributes=this._attributes,this._iaInfo.vertexBuffers=this._vertexBuffers,this._vertexIdChannel={stream:e,index:i}}},e._allocVertexIdBuffer=function(t){for(var e=0===this.vertexBuffers.length||0===this.vertexBuffers[0].stride?0:this.vertexBuffers[0].size/this.vertexBuffers[0].stride,i=new Float32Array(e),n=0;n<e;++n)i[n]=n+.5;var r=t.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,i.byteLength,i.BYTES_PER_ELEMENT));return r.update(i),r},n(t,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexBuffers",get:function(){return this._vertexBuffers}},{key:"indexBuffer",get:function(){return this._indexBuffer}},{key:"indirectBuffer",get:function(){return this._indirectBuffer}},{key:"primitiveMode",get:function(){return this._primitiveMode}},{key:"geometricInfo",get:function(){if(this._geometricInfo)return this._geometricInfo;if(void 0===this.mesh)return t.EMPTY_GEOMETRIC_INFO;if(void 0===this.subMeshIdx)return t.EMPTY_GEOMETRIC_INFO;var e,i=this.mesh,n=this.subMeshIdx,r=this.attributes.find((function(t){return t.name===Ic.ATTR_POSITION}));if(!r)return t.EMPTY_GEOMETRIC_INFO;switch(r.format){case Hl.RG32F:case Hl.RGB32F:if(!(e=i.readAttribute(n,Ic.ATTR_POSITION)))return t.EMPTY_GEOMETRIC_INFO;break;case Hl.RGBA32F:var s=i.readAttribute(n,Ic.ATTR_POSITION);if(!s)return t.EMPTY_GEOMETRIC_INFO;var o=s.length/4;e=new Float32Array(3*o);for(var a=0;a<o;++a){var h=3*a,u=4*a;e[h]=s[u],e[h+1]=s[u+1],e[h+2]=s[u+2]}break;case Hl.RG16F:case Hl.RGB16F:var l=i.readAttribute(n,Ic.ATTR_POSITION);if(!l)return t.EMPTY_GEOMETRIC_INFO;e=new Float32Array(l.length);for(var c=0;c<l.length;++c)e[c]=Zi(l[c]);break;case Hl.RGBA16F:var _=i.readAttribute(n,Ic.ATTR_POSITION);if(!_)return t.EMPTY_GEOMETRIC_INFO;var d=_.length/4;e=new Float32Array(3*d);for(var f=0;f<d;++f){var p=3*f,m=4*f;e[p]=Zi(_[m]),e[p+1]=Zi(_[m+1]),e[p+2]=Zi(_[m+2])}break;default:return t.EMPTY_GEOMETRIC_INFO}var g=i.readIndices(n)||void 0,y=new on,v=new on,S=M_[r.format].count;2===S?(y.set(e[0],e[1],0),v.set(e[0],e[1],0)):(y.set(e[0],e[1],e[2]),v.set(e[0],e[1],e[2]));for(var T=0;T<e.length;T+=S)2===S?(y.x=e[T]>y.x?e[T]:y.x,y.y=e[T+1]>y.y?e[T+1]:y.y,v.x=e[T]<v.x?e[T]:v.x,v.y=e[T+1]<v.y?e[T+1]:v.y):(y.x=e[T]>y.x?e[T]:y.x,y.y=e[T+1]>y.y?e[T+1]:y.y,y.z=e[T+2]>y.z?e[T+2]:y.z,v.x=e[T]<v.x?e[T]:v.x,v.y=e[T+1]<v.y?e[T+1]:v.y,v.z=e[T+2]<v.z?e[T+2]:v.z);return this._geometricInfo={positions:e,indices:g,boundingBox:{max:y,min:v}},this._geometricInfo}},{key:"drawInfo",get:function(){return this._drawInfo},set:function(t){this._drawInfo=t}},{key:"flatBuffers",get:function(){return this._flatBuffers}},{key:"jointMappedBuffers",get:function(){var t=this;if(this._jointMappedBuffers)return this._jointMappedBuffers;var e=this._jointMappedBuffers=[],i=this._jointMappedBufferIndices=[];if(!this.mesh||void 0===this.subMeshIdx)return this._jointMappedBuffers=this.vertexBuffers;var n,r,s=this.mesh.struct,o=s.primitives[this.subMeshIdx];if(!s.jointMaps||void 0===o.jointMapIndex||!s.jointMaps[o.jointMapIndex])return this._jointMappedBuffers=this.vertexBuffers;for(var a=v.director.root.device,h=function(){var h=s.vertexBundles[o.vertexBundelIndices[u]];r=0,n=Hl.UNKNOWN;for(var l=0;l<h.attributes.length;l++){var c=h.attributes[l];if(c.name===Ic.ATTR_JOINTS){n=c.format;break}r+=M_[c.format].size}if(n){var _=new Uint8Array(t.mesh.data.buffer,h.view.offset,h.view.length),d=new DataView(_.slice().buffer),f=s.jointMaps[o.jointMapIndex];PR(d,(function(t){return f.indexOf(t)}),n,r,h.view.length,h.view.stride,d);var p=a.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,h.view.length,h.view.stride));p.update(d.buffer),e.push(p),i.push(u)}else e.push(t.vertexBuffers[o.vertexBundelIndices[u]])},u=0;u<o.vertexBundelIndices.length;u++)h();return this._vertexIdChannel&&e.push(this._allocVertexIdBuffer(a)),e}},{key:"iaInfo",get:function(){return this._iaInfo}}]),t}());OR.EMPTY_GEOMETRIC_INFO={positions:new Float32Array,indices:new Uint8Array,boundingBox:{min:on.ZERO,max:on.ZERO}};var MR,LR=t("dt",function(){function t(){this._singleMode=0,this._compositeModeValue=0,this._lightingWithAlbedo=!0,this._csmLayerColoration=!1,this._activate()}var e=t.prototype;return e.isCompositeModeEnabled=function(t){return 0!=(this._compositeModeValue&1<<t)},e.enableCompositeMode=function(t,e){this._enableCompositeMode(t,e),this._updatePipeline()},e.enableAllCompositeMode=function(t){this._enableAllCompositeMode(t),this._updatePipeline()},e.isEnabled=function(){return 0!==this._getType()},e.reset=function(){this._activate(),this._updatePipeline()},e._activate=function(){this._singleMode=0,this._enableAllCompositeMode(!0),this._lightingWithAlbedo=!0,this._csmLayerColoration=!1},e._updatePipeline=function(){var t=v.director.root,e=t.pipeline,i=this._getType();e.macros.CC_USE_DEBUG_VIEW!==i&&(e.macros.CC_USE_DEBUG_VIEW=i,t.onGlobalPipelineStateChanged())},e._enableCompositeMode=function(t,e){e?this._compositeModeValue|=1<<t:this._compositeModeValue&=~(1<<t)},e._enableAllCompositeMode=function(t){for(var e=0;e<17;e++)t?this._compositeModeValue|=1<<e:this._compositeModeValue&=~(1<<e)},e._getType=function(){if(0!==this._singleMode)return 1;if(!0!==this._lightingWithAlbedo||!1!==this._csmLayerColoration)return 2;for(var t=0;t<17;t++)if(!this.isCompositeModeEnabled(t))return 2;return 0},n(t,[{key:"singleMode",get:function(){return this._singleMode},set:function(t){this._singleMode=t,this._updatePipeline()}},{key:"lightingWithAlbedo",get:function(){return this._lightingWithAlbedo},set:function(t){this._lightingWithAlbedo=t,this._updatePipeline()}},{key:"csmLayerColoration",get:function(){return this._csmLayerColoration},set:function(t){this._csmLayerColoration=t,this._updatePipeline()}},{key:"debugViewType",get:function(){return this._getType()}}]),t}()),NR=new Ss(0,0,0,.5,.5,.5),FR=new Ss;function kR(t,e){var i=t.pipelineSceneData,n=i.validPunctualLights;n.length=0;for(var r=gr.create(0,0,0,1),s=e.scene.spotLights,o=0;o<s.length;o++){var a=s[o];a.baked&&!e.node.scene.globals.disableLightmap||(gr.set(r,a.position.x,a.position.y,a.position.z,a.range),as.sphereFrustum(r,e.frustum)&&n.push(a))}for(var h=e.scene.sphereLights,u=0;u<h.length;u++){var l=h[u];l.baked&&!e.node.scene.globals.disableLightmap||(gr.set(r,l.position.x,l.position.y,l.position.z,l.range),as.sphereFrustum(r,e.frustum)&&n.push(l))}for(var c=e.scene.pointLights,_=0;_<c.length;_++){var d=c[_];d.baked||(gr.set(r,d.position.x,d.position.y,d.position.z,d.range),as.sphereFrustum(r,e.frustum)&&n.push(d))}for(var f=e.scene.rangedDirLights,p=0;p<f.length;p++){var m=f[p];Ss.transform(FR,NR,m.node.getWorldMatrix()),as.aabbFrustum(FR,e.frustum)&&n.push(m)}i.validPunctualLights=n}!function(t){t[t.NONE=0]="NONE",t[t.FXAA=1]="FXAA",t[t.FXAAHQ=2]="FXAAHQ"}(MR||(MR={}));var VR=[];function GR(t){return VR.includes(t)||VR.push(t),VR.indexOf(t)}function UR(t,e){var i=lc.CLEAR;return t&Cc.COLOR||e!==yR.RENDER_TARGET||(i=t&Ux?lc.CLEAR:lc.LOAD),(t&Cc.DEPTH_STENCIL)!==Cc.DEPTH_STENCIL&&e===yR.DEPTH_STENCIL&&(t&Cc.DEPTH||(i=lc.LOAD),t&Cc.STENCIL||(i=lc.LOAD)),i}function zR(t,e,i,n,r,s){void 0===n&&(n=null),void 0===r&&(r=0),void 0===s&&(s=void 0),s=s||new Mc;var o=t?t.viewport:new Mc(0,0,1,1),a=e,h=i;if(s.x=o.x*a,s.y=o.y*h,s.width=o.width*a,s.height=o.height*h,n)switch(n.type){case sR.DIRECTIONAL:var u=n;if(u.shadowFixedArea||u.csmLevel===DT.LEVEL_1)s.x=0,s.y=0,s.width=a,s.height=h;else{var l=v.director.root.device.capabilities.screenSpaceSignY;s.x=r%2*.5*a,s.y=l>0?.5*(1-Math.floor(r/2))*h:.5*Math.floor(r/2)*h,s.width=.5*a,s.height=.5*h}break;case sR.SPOT:s.x=0,s.y=0,s.width=a,s.height=h}return s}var HR=function(){function t(t){void 0===t&&(t=MR.NONE),this.antiAliasing=MR.NONE,this.antiAliasing=t,this._init()}return t.prototype._init=function(){this.postMaterial=new xT,this.postMaterial.name="builtin-post-process-material",this.postMaterial.initialize({effectName:"pipeline/post-process",defines:{ANTIALIAS_TYPE:this.antiAliasing}});for(var t=0;t<this.postMaterial.passes.length;++t)this.postMaterial.passes[t].tryCompile()},t}(),WR=function(){function t(){this.shadowEnabled=!1,this.mainLightShadowNames=new Array,this.spotLightShadowNames=new Array,this.validLights=[]}return t.prototype.reset=function(){this.shadowEnabled=!1,this.mainLightShadowNames.length=0,this.spotLightShadowNames.length=0,this.validLights.length=0},t}();new WR;var jR=function(){function t(t){this.enableCluster=void 0,this.enableCluster=t?1:0,this._init()}return t.prototype._init=function(){this.deferredLightingMaterial=new xT,this.deferredLightingMaterial.name="builtin-deferred-material",this.deferredLightingMaterial.initialize({effectName:"pipeline/deferred-lighting",defines:{CC_ENABLE_CLUSTERED_LIGHT_CULLING:this.enableCluster,CC_RECEIVE_SHADOW:1}});for(var t=0;t<this.deferredLightingMaterial.passes.length;++t)this.deferredLightingMaterial.passes[t].tryCompile()},t}();function XR(t,e){for(var i,n=d(e.descriptorSetLayoutData.descriptorBlocks);!(i=n()).done;)for(var r=i.value,s=0;s!==r.descriptors.length;++s)if(t===r.descriptors[s].descriptorID)return r.offset+s;return-1}function qR(t){for(var e,i=v.director.root.pipeline.layoutGraph,n=i.vertices(),r=i.attributeIndex.get(t),s=d(n);!(e=s()).done;)for(var o,a=e.value,h=d(i.getLayout(a).descriptorSets);!(o=h()).done;){var u=o.value;u[0];for(var l,c=u[1],_=d(c.descriptorSetLayoutData.descriptorBlocks);!(l=_()).done;)for(var f,p=d(l.value.descriptors);!(f=p()).done;)if(f.value.descriptorID===r)return XR(r,c)}return-1}var YR=new Map;function KR(t){var e=YR.get(t);if(e)return e;var i=v.director.root.pipeline,n=i.layoutGraph.locateChild(i.layoutGraph.nullVertex(),t);G(4294967295!==n);var r=i.layoutGraph.getLayout(n).descriptorSets.get(uR.PER_PASS);return YR.set(t,r),r}var JR=[.0484,.187,.567,1.99,7.41],QR=[.1,.118,.113,.358,.078],ZR=new on,$R=new on,tI=new tn,eI=new tn;!function(){var t=e.prototype;function e(){this.ssssFov=45/57.3,this.ssssWidth=.01,this.boundingBox=.4,this.ssssScale=3,this._v3SSSSStrength=new on(.48,.41,.28),this._v3SSSSFallOff=new on(1,.37,.3),this._kernel=[],this._init()}t._gaussian=function(t,e,i){var n=i/(.001+this._v3SSSSFallOff.x);t.x=Math.exp(-n*n/(2*e))/(6.28*e);var r=i/(.001+this._v3SSSSFallOff.y);t.y=Math.exp(-r*r/(2*e))/(6.28*e);var s=i/(.001+this._v3SSSSFallOff.z);t.z=Math.exp(-s*s/(2*e))/(6.28*e)},t._profile=function(t,e){for(var i=0;i<5;i++)this._gaussian($R,JR[i],e),$R.multiplyScalar(QR[i]),t.add($R)},t._updateSampleCount=function(){for(var t=this._v3SSSSStrength,e=0;e<25;e++){var i=.25*e-3,n=i<0?-1:1;this._kernel[e].w=3*n*Math.abs(Math.pow(i,2))/Math.pow(3,2)}for(var r=0;r<25;r++){var s=((r>0?Math.abs(this._kernel[r].w-this._kernel[r-1].w):0)+(r<24?Math.abs(this._kernel[r].w-this._kernel[r+1].w):0))/2;ZR.set(0),this._profile(ZR,this._kernel[r].w),ZR.multiplyScalar(s),this._kernel[r].x=ZR.x,this._kernel[r].y=ZR.y,this._kernel[r].z=ZR.z}tI.set(this._kernel[12]);for(var o=12;o>0;o--)eI.set(this._kernel[o-1]),this._kernel[o].set(eI);this._kernel[0].set(tI),ZR.set(0);for(var a=0;a<25;a++)ZR.add3f(this._kernel[a].x,this._kernel[a].y,this._kernel[a].z);for(var h=0;h<25;h++)this._kernel[h].x/=ZR.x,this._kernel[h].y/=ZR.y,this._kernel[h].z/=ZR.z;this._kernel[0].x=1*(1-t.x)+t.x*this._kernel[0].x,this._kernel[0].y=1*(1-t.y)+t.y*this._kernel[0].y,this._kernel[0].z=1*(1-t.z)+t.z*this._kernel[0].z;for(var u=1;u<25;u++)this._kernel[u].x*=t.x,this._kernel[u].y*=t.y,this._kernel[u].z*=t.z},t._updateBlurPass=function(){if(this.ssssBlurMaterial){var t=this.ssssBlurMaterial.passes[0];t.beginChangeStatesSilently(),t.tryCompile(),t.endChangeStatesSilently();var e=this.ssssBlurMaterial.passes[1];e.beginChangeStatesSilently(),e.tryCompile(),e.endChangeStatesSilently();var i=this.ssssBlurMaterial.passes[2];i.beginChangeStatesSilently(),i.tryCompile(),i.endChangeStatesSilently()}},t._init=function(){if(!this.ssssBlurMaterial){this.ssssBlurMaterial=new xT,this.ssssBlurMaterial._uuid="builtin-ssssBlur-material",this.ssssBlurMaterial.initialize({effectName:"pipeline/ssss-blur"});for(var t=0;t<this.ssssBlurMaterial.passes.length;++t)this.ssssBlurMaterial.passes[t].tryCompile();this._updateBlurPass();for(var e=0;e<25;e++)this._kernel[e]=new tn;this._updateSampleCount()}},n(e,[{key:"ssssStrength",get:function(){return this._v3SSSSStrength},set:function(t){this._v3SSSSStrength=t,this._updateSampleCount()}},{key:"ssssFallOff",get:function(){return this._v3SSSSFallOff},set:function(t){this._v3SSSSFallOff=t,this._updateSampleCount()}},{key:"kernel",get:function(){return this._kernel}}])}(),function(){var t=e.prototype;function e(){this._uvDepthToEyePosParams=new tn,this._radiusParam=new tn,this._miscParam=new tn,this._blurParam=new tn,this._depthTexFullResolution=new Ln(1024),this._depthTexResolution=new Ln(1024),this._sceneScale=1,this._cameraFov=Bi(45),this._radiusScale=1,this._angleBiasDegree=10,this._aoStrength=1,this._blurSharpness=8,this._aoSaturation=1,this._randomDirAndJitter=[238,91,87,255,251,44,119,255,247,64,250,255,232,5,225,255,253,177,140,255,250,51,84,255,243,76,97,255,252,36,232,255,235,100,24,255,252,36,158,255,254,20,142,255,245,135,124,255,251,43,121,255,253,31,145,255,235,98,160,255,240,146,198,255],this._init(),this.update()}t._init=function(){if(!this.hbaoMaterial){this.hbaoMaterial=new xT,this.hbaoMaterial.name="builtin-hbao-material",this.hbaoMaterial.initialize({effectName:"pipeline/post-process/hbao"});for(var t=0;t<this.hbaoMaterial.passes.length;++t)this.hbaoMaterial.passes[t].tryCompile();for(var e=Zp.PixelFormat.RGBA8888,i=new Uint8Array(64),n=0;n<this._randomDirAndJitter.length;n++)i[n]=this._randomDirAndJitter[n];var r=new Rf({width:4,height:4,_data:i,_compressed:!1,format:e});this.randomTexture=new Zp,this.randomTexture.setFilters(Zp.Filter.NEAREST,Zp.Filter.NEAREST),this.randomTexture.setMipFilter(Zp.Filter.NONE),this.randomTexture.setWrapMode(Zp.WrapMode.REPEAT,Zp.WrapMode.REPEAT,Zp.WrapMode.REPEAT),this.randomTexture.image=r,this.hbaoMaterial.setProperty("RandomTex",this.randomTexture,0)}},t.update=function(){var t=this._radiusScale*this._sceneScale,e=t*t,i=-1/e,n=.1*Math.min(this._depthTexFullResolution.x,this._depthTexFullResolution.y);this._radiusParam.set(t,e,i,n);var r=new Ln(this._depthTexResolution.y/this._depthTexResolution.x,1),s=new Ln(r.x/Math.tan(.5*this._cameraFov),r.y/Math.tan(.5*this._cameraFov)),o=Math.tan(Bi(this._angleBiasDegree)),a=this._aoStrength;this._miscParam.set(s.x,s.y,o,a);var h=new Ln(2/s.x,-2/s.y),u=new Ln(-1/s.x,1/s.y);this._uvDepthToEyePosParams.set(h.x,h.y,u.x,u.y);var l=this._sceneScale/this._blurSharpness*1.6651092;this._blurParam.set(.11541560320000001,l,this._blurSharpness/8,this._aoSaturation)},n(e,[{key:"uvDepthToEyePosParams",get:function(){return this._uvDepthToEyePosParams}},{key:"radiusParam",get:function(){return this._radiusParam}},{key:"miscParam",get:function(){return this._miscParam}},{key:"blurParam",get:function(){return this._blurParam}},{key:"depthTexFullResolution",set:function(t){this._depthTexFullResolution.set(t)}},{key:"depthTexResolution",set:function(t){this._depthTexResolution.set(t)}},{key:"sceneScale",set:function(t){this._sceneScale=t}},{key:"cameraFov",set:function(t){this._cameraFov=t}},{key:"radiusScale",set:function(t){this._radiusScale=t}},{key:"angleBiasDegree",set:function(t){this._angleBiasDegree=t}},{key:"aoStrength",set:function(t){this._aoStrength=t}},{key:"blurSharpness",set:function(t){this._blurSharpness=t}},{key:"aoSaturation",set:function(t){this._aoSaturation=t}}])}(),new Ln;var iI=function(){var t=e.prototype;function e(){this.clusters_x_threads=16,this.clusters_y_threads=8,this.clusters_z_threads=1,this.dispatchX=1,this.dispatchY=1,this.dispatchZ=1,this._init()}return t._initMaterial=function(t,e){var i=new xT;i.name=t,i.initialize({effectName:e});for(var n=0;n<i.passes.length;++n)i.passes[n].tryCompile();return i},t._init=function(){this.clusterBuildCS=this._initMaterial("builtin-cluster-build-cs-material","pipeline/cluster-build"),this.clusterLightCullingCS=this._initMaterial("builtin-cluster-culling-cs-material","pipeline/cluster-culling"),this.dispatchX=16/this.clusters_x_threads,this.dispatchY=8/this.clusters_y_threads,this.dispatchZ=24/this.clusters_z_threads},e}(),nI=null;function rI(t,e){!function(t,e){kR(e,t);var i=e.pipelineSceneData,n=80*Vi(Math.max(i.validPunctualLights.length,1)),r=GR(t),s="clusterLightBuffer"+r,o="globalIndexBuffer"+r,a=e;a.containsResource(o)||a.addStorageBuffer(o,Hl.UNKNOWN,4,cR.PERSISTENT),a.containsResource(s)||a.addStorageBuffer(s,Hl.UNKNOWN,n,cR.PERSISTENT),a.updateStorageBuffer(s,n);var h=function(t,e,i,n){for(var r,s=new ArrayBuffer(t),o=new Float32Array(s),a=n.pipelineSceneData,h=i.exposure,u=0,l=d(a.validPunctualLights);!(r=l()).done;){var c=r.value,_=20*u,f=_+0,p=_+4,m=_+8,g=_+12,y=_+16,v=0,S=0,T=void 0;if(c.type===sR.POINT){var A=c;T=A.position,S=A.luminanceLDR,v=A.luminanceHDR,o[m]=0,o[m+1]=A.range,o[m+2]=0,o[m+3]=0}else if(c.type===sR.SPHERE){var b=c;T=b.position,S=b.luminanceLDR,v=b.luminanceHDR,o[m]=b.size,o[m+1]=b.range,o[m+2]=0,o[m+3]=0}else if(c.type===sR.SPOT){var E=c;T=E.position,S=E.luminanceLDR,v=E.luminanceHDR,o[m]=E.size,o[m+1]=E.range,o[m+2]=E.spotAngle,o[m+3]=0;var C=E.direction;o[g]=C.x,o[g+1]=C.y,o[g+2]=C.z,o[g+3]=0}else if(c.type===sR.RANGED_DIRECTIONAL){var w=c;T=w.position,S=w.illuminanceLDR,v=w.illuminanceHDR;var x=w.right;o[m]=x.x,o[m+1]=x.y,o[m+2]=x.z,o[m+3]=0;var R=w.direction;o[g]=R.x,o[g+1]=R.y,o[g+2]=R.z,o[g+3]=0;var I=w.scale;o[y]=.5*I.x,o[y+1]=.5*I.y,o[y+2]=.5*I.z,o[y+3]=0}o[f]=T.x,o[f+1]=T.y,o[f+2]=T.z,o[f+3]=c.type;var B=c.color;if(c.useColorTemperature){var D=c.colorTemperatureRGB;o[p]=B.x*D.x,o[p+1]=B.y*D.y,o[p+2]=B.z*D.z}else o[p]=B.x,o[p+1]=B.y,o[p+2]=B.z;o[p+3]=a.isHDR?v*h*1e4:S,u++}return o[15]=a.validPunctualLights.length,s}(n,0,t,e),u=new ArrayBuffer(4);new Uint32Array(u)[0]=0;var l=new xR(new Uint8Array(h),s),c=new xR(new Uint8Array(u),o);a.addUploadPass([l,c])}(t,e);var i=e;nI||(nI=new iI),function(t,e,i){var n="clusterBuffer"+GR(t);i.containsResource(n)||i.addStorageBuffer(n,Hl.UNKNOWN,98304,cR.MANAGED),i.updateStorageBuffer(n,98304);var r=i.addComputePass("cluster-build-cs");r.addStorageBuffer(n,vR.WRITE,"b_clustersBuffer"),r.addQueue().addDispatch(e.dispatchX,e.dispatchY,e.dispatchZ,e.clusterBuildCS,0);var s=t.width*i.pipelineSceneData.shadingScale,o=t.height*i.pipelineSceneData.shadingScale;"setCurrConstant"in r&&r.addConstant("CCConst","cluster-build-cs"),r.setVec4("cc_nearFar",new tn(t.nearClip,t.farClip,t.getClipSpaceMinz(),0)),r.setVec4("cc_viewPort",new tn(0,0,s,o)),r.setVec4("cc_workGroup",new tn(16,8,24,0)),r.setMat4("cc_matView",t.matView),r.setMat4("cc_matProjInv",t.matProjInv)}(t,nI,i),function(t,e,i){var n=GR(t),r="clusterBuffer"+n,s="clusterLightBuffer"+n,o="globalIndexBuffer"+n,a="clusterLightIndicesBuffer"+n,h="clusterLightGridBuffer"+n;i.containsResource(a)||i.addStorageBuffer(a,Hl.UNKNOWN,2457600,cR.MANAGED),i.containsResource(h)||i.addStorageBuffer(h,Hl.UNKNOWN,49152,cR.MANAGED);var u=i.addComputePass("cluster-culling-cs");u.addStorageBuffer(s,vR.READ,"b_ccLightsBuffer"),u.addStorageBuffer(r,vR.READ,"b_clustersBuffer"),u.addStorageBuffer(a,vR.WRITE,"b_clusterLightIndicesBuffer"),u.addStorageBuffer(h,vR.WRITE,"b_clusterLightGridBuffer"),u.addStorageBuffer(o,vR.WRITE,"b_globalIndexBuffer"),u.addQueue().addDispatch(e.dispatchX,e.dispatchY,e.dispatchZ,e.clusterLightCullingCS,0);var l=t.width*i.pipelineSceneData.shadingScale,c=t.height*i.pipelineSceneData.shadingScale;"setCurrConstant"in u&&u.addConstant("CCConst","cluster-build-cs"),u.setVec4("cc_nearFar",new tn(t.nearClip,t.farClip,t.getClipSpaceMinz(),0)),u.setVec4("cc_viewPort",new tn(l,c,l,c)),u.setVec4("cc_workGroup",new tn(16,8,24,0)),u.setMat4("cc_matView",t.matView),u.setMat4("cc_matProjInv",t.matProjInv)}(t,nI,i)}var sI,oI,aI,hI,uI,lI=new $c(ic.LINEAR,ic.LINEAR,ic.NONE,nc.CLAMP,nc.CLAMP,nc.CLAMP),cI=new $c(ic.POINT,ic.POINT,ic.NONE,nc.CLAMP,nc.CLAMP,nc.CLAMP),_I=function(){function t(t){this._device=void 0,this._descriptorSetMap=new Map,this._globalDescriptorSet=void 0,this._descriptorSetLayout=void 0,this._linearSampler=void 0,this._pointSampler=void 0,this._device=t,this._linearSampler=this._device.getSampler(lI),this._pointSampler=this._device.getSampler(cI);var e=new A_(Sg.bindings);this._descriptorSetLayout=this._device.createDescriptorSetLayout(e),this._globalDescriptorSet=this._device.createDescriptorSet(new b_(this._descriptorSetLayout))}var e=t.prototype;return e.regenLayout=function(){var t=new A_(Sg.bindings);this._descriptorSetLayout=this._device.createDescriptorSetLayout(t),this._globalDescriptorSet=this._device.createDescriptorSet(new b_(this._descriptorSetLayout))},e.bindBuffer=function(t,e){this._globalDescriptorSet.bindBuffer(t,e);for(var i=this._descriptorSetMap.values(),n=i.next();!n.done;)n.value.bindBuffer(t,e),n=i.next()},e.bindSampler=function(t,e){this._globalDescriptorSet.bindSampler(t,e);for(var i=this._descriptorSetMap.values(),n=i.next();!n.done;)n.value.bindSampler(t,e),n=i.next()},e.bindTexture=function(t,e){this._globalDescriptorSet.bindTexture(t,e);for(var i=this._descriptorSetMap.values(),n=i.next();!n.done;)n.value.bindTexture(t,e),n=i.next()},e.update=function(){this._globalDescriptorSet.update();for(var t=this._descriptorSetMap.values(),e=t.next();!e.done;)e.value.update(),e=t.next()},e.getOrCreateDescriptorSet=function(t){var e=this._device;if(!this._descriptorSetMap.has(t)){var i=tv()?KR("default").descriptorSet:this._globalDescriptorSet,n=e.createDescriptorSet(new b_(tv()?KR("default").descriptorSetLayout:this._descriptorSetLayout));this._descriptorSetMap.set(t,n);for(var r=vg.UBO_GLOBAL;r<vg.COUNT;r++)n.bindBuffer(r,i.getBuffer(r)),n.bindSampler(r,i.getSampler(r)),n.bindTexture(r,i.getTexture(r));var s=e.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,Pg.SIZE,Pg.SIZE)),o=tv()?qR("CCShadow"):Pg.BINDING;n.bindBuffer(o,s),n.update()}return this._descriptorSetMap.get(t)},e.destroy=function(){this._descriptorSetLayout.destroy()},n(t,[{key:"descriptorSetMap",get:function(){return this._descriptorSetMap}},{key:"linearSampler",get:function(){return this._linearSampler}},{key:"pointSampler",get:function(){return this._pointSampler}},{key:"descriptorSetLayout",get:function(){return this._descriptorSetLayout}},{key:"globalDescriptorSet",get:function(){return this._globalDescriptorSet},set:function(t){this._globalDescriptorSet=t}}]),t}(),dI=new In,fI=new In,pI=new In,mI=new tn,gI=new tn(0,0,1,0),yI=new on,vI=function(){function t(){this._globalUBO=new Float32Array(Bg.COUNT),this._cameraUBO=new Float32Array(Dg.COUNT),this._shadowUBO=new Float32Array(Pg.COUNT),this._csmUBO=new Float32Array(Og.COUNT)}t.updateGlobalUBOView=function(t,e){var i=v.director,n=i.root,r=e,s=Math.floor(t.width),o=Math.floor(t.height);r[Bg.TIME_OFFSET]=n.cumulativeTime,r[Bg.TIME_OFFSET+1]=n.frameTime,r[Bg.TIME_OFFSET+2]=i.getTotalFrames(),r[Bg.TIME_OFFSET+3]=n.cumulativeTime-Math.floor(n.frameTime),r[Bg.SCREEN_SIZE_OFFSET]=s,r[Bg.SCREEN_SIZE_OFFSET+1]=o,r[Bg.SCREEN_SIZE_OFFSET+2]=1/s,r[Bg.SCREEN_SIZE_OFFSET+3]=1/o,r[Bg.NATIVE_SIZE_OFFSET]=s,r[Bg.NATIVE_SIZE_OFFSET+1]=o,r[Bg.NATIVE_SIZE_OFFSET+2]=1/r[Bg.NATIVE_SIZE_OFFSET],r[Bg.NATIVE_SIZE_OFFSET+3]=1/r[Bg.NATIVE_SIZE_OFFSET+1],v.internal.reflectionProbeManager&&(r[Bg.PROBE_INFO_OFFSET]=v.internal.reflectionProbeManager.getMaxProbeId()+1);for(var a=n.debugView,h=0;h<=3;h++)r[Bg.DEBUG_VIEW_MODE_OFFSET+h]=0;if(a.isEnabled()){r[Bg.DEBUG_VIEW_MODE_OFFSET]=a.singleMode;for(var u=0;u<17;u++){var l=u%8;r[Bg.DEBUG_VIEW_MODE_OFFSET+1+(u>>3)]+=(a.isCompositeModeEnabled(u)?1:0)*Math.pow(10,l)}r[Bg.DEBUG_VIEW_MODE_OFFSET+3]+=(a.lightingWithAlbedo?1:0)*Math.pow(10,6),r[Bg.DEBUG_VIEW_MODE_OFFSET+3]+=(a.csmLayerColoration?1:0)*Math.pow(10,7)}},t.updateCameraUBOView=function(t,e,i){var n,r=(i.scene?i.scene:v.director.getScene().renderScene).mainLight,s=t.pipelineSceneData,o=s.ambient,a=s.skybox,h=s.fog,u=s.shadows,l=e,c=i.exposure,_=s.isHDR;if(l[Dg.SCREEN_SCALE_OFFSET]=s.shadingScale,l[Dg.SCREEN_SCALE_OFFSET+1]=s.shadingScale,l[Dg.SCREEN_SCALE_OFFSET+2]=1/l[Dg.SCREEN_SCALE_OFFSET],l[Dg.SCREEN_SCALE_OFFSET+3]=1/l[Dg.SCREEN_SCALE_OFFSET+1],l[Dg.EXPOSURE_OFFSET]=c,l[Dg.EXPOSURE_OFFSET+1]=1/c,l[Dg.EXPOSURE_OFFSET+2]=_?1:0,l[Dg.EXPOSURE_OFFSET+3]=1/Hx.standardExposureValue,r){var d=r.shadowEnabled&&u.type===IT.ShadowMap?1:0,f=r.direction;if(gI.set(f.x,f.y,f.z,d),tn.toArray(l,gI,Dg.MAIN_LIT_DIR_OFFSET),on.toArray(l,r.color,Dg.MAIN_LIT_COLOR_OFFSET),r.useColorTemperature){var p=r.colorTemperatureRGB;l[Dg.MAIN_LIT_COLOR_OFFSET]*=p.x,l[Dg.MAIN_LIT_COLOR_OFFSET+1]*=p.y,l[Dg.MAIN_LIT_COLOR_OFFSET+2]*=p.z}l[Dg.MAIN_LIT_COLOR_OFFSET+3]=_?r.illuminance*c:r.illuminance}else gI.set(0,0,1,0),tn.toArray(l,gI,Dg.MAIN_LIT_DIR_OFFSET),tn.toArray(l,tn.ZERO,Dg.MAIN_LIT_COLOR_OFFSET);var m=o.skyColor;m.w=_?o.skyIllum*c:o.skyIllum,l[Dg.AMBIENT_SKY_OFFSET+0]=m.x,l[Dg.AMBIENT_SKY_OFFSET+1]=m.y,l[Dg.AMBIENT_SKY_OFFSET+2]=m.z,l[Dg.AMBIENT_SKY_OFFSET+3]=m.w,l[Dg.AMBIENT_GROUND_OFFSET+0]=o.groundAlbedo.x,l[Dg.AMBIENT_GROUND_OFFSET+1]=o.groundAlbedo.y,l[Dg.AMBIENT_GROUND_OFFSET+2]=o.groundAlbedo.z,l[Dg.AMBIENT_GROUND_OFFSET+3]=a.envmap?null===(n=a.envmap)||void 0===n?void 0:n.mipmapLevel:1,In.toArray(l,i.matView,Dg.MAT_VIEW_OFFSET),In.toArray(l,i.node.worldMatrix,Dg.MAT_VIEW_INV_OFFSET),on.toArray(l,i.position,Dg.CAMERA_POS_OFFSET),In.toArray(l,i.matProj,Dg.MAT_PROJ_OFFSET),In.toArray(l,i.matProjInv,Dg.MAT_PROJ_INV_OFFSET),In.toArray(l,i.matViewProj,Dg.MAT_VIEW_PROJ_OFFSET),In.toArray(l,i.matViewProjInv,Dg.MAT_VIEW_PROJ_INV_OFFSET),l[Dg.CAMERA_POS_OFFSET+3]=this.getCombineSignY(),l[Dg.SURFACE_TRANSFORM_OFFSET]=i.surfaceTransform,l[Dg.SURFACE_TRANSFORM_OFFSET+1]=i.cameraUsage,l[Dg.SURFACE_TRANSFORM_OFFSET+2]=Math.cos(Bi(s.skybox.getRotationAngle())),l[Dg.SURFACE_TRANSFORM_OFFSET+3]=Math.sin(Bi(s.skybox.getRotationAngle()));var g=h.colorArray;l[Dg.GLOBAL_FOG_COLOR_OFFSET]=g.x,l[Dg.GLOBAL_FOG_COLOR_OFFSET+1]=g.y,l[Dg.GLOBAL_FOG_COLOR_OFFSET+2]=g.z,l[Dg.GLOBAL_FOG_COLOR_OFFSET+3]=g.z,l[Dg.GLOBAL_FOG_BASE_OFFSET]=h.fogStart,l[Dg.GLOBAL_FOG_BASE_OFFSET+1]=h.fogEnd,l[Dg.GLOBAL_FOG_BASE_OFFSET+2]=h.fogDensity,l[Dg.GLOBAL_FOG_ADD_OFFSET]=h.fogTop,l[Dg.GLOBAL_FOG_ADD_OFFSET+1]=h.fogRange,l[Dg.GLOBAL_FOG_ADD_OFFSET+2]=h.fogAtten,l[Dg.NEAR_FAR_OFFSET]=i.nearClip,l[Dg.NEAR_FAR_OFFSET+1]=i.farClip,l[Dg.NEAR_FAR_OFFSET+2]=i.getClipSpaceMinz(),l[Dg.VIEW_PORT_OFFSET]=s.shadingScale*i.window.width*i.viewport.x,l[Dg.VIEW_PORT_OFFSET+1]=s.shadingScale*i.window.height*i.viewport.y,l[Dg.VIEW_PORT_OFFSET+2]=s.shadingScale*i.window.width*i.viewport.z,l[Dg.VIEW_PORT_OFFSET+3]=s.shadingScale*i.window.height*i.viewport.w},t.getPCFRadius=function(t,e){var i=t.size.x;switch(e.shadowPcf){case BT.HARD:return 0;case BT.SOFT:return 1/(.5*i);case BT.SOFT_2X:return 2/(.5*i);case BT.SOFT_4X:return 3/(.5*i)}return 0},t.updatePlanarNormalAndDistance=function(t,e){on.normalize(yI,t.normal),e[Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+0]=yI.x,e[Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+1]=yI.y,e[Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+2]=yI.z,e[Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+3]=-t.distance},t.updateShadowUBOView=function(e,i,n,r){var s=e.device,o=r.scene.mainLight,a=e.pipelineSceneData,h=a.shadows,u=a.csmLayers,l=i,c=n,_=a.csmSupported,d=Zy(s)?0:1;if(o&&h.enabled){if(h.type===IT.ShadowMap){if(o.shadowEnabled){if(o.shadowFixedArea||o.csmLevel===DT.LEVEL_1||!_){var f=u.specialLayer.matShadowView,p=u.specialLayer.matShadowProj,m=u.specialLayer.matShadowViewProj,g=.1,y=0,v=0;o.shadowFixedArea?(g=o.shadowNear,y=o.shadowFar,v=0):(y=u.specialLayer.shadowCameraFar,v=1),In.toArray(l,f,Pg.MAT_LIGHT_VIEW_OFFSET),l[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+0]=p.m10,l[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+1]=p.m14,l[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+2]=p.m11,l[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+3]=p.m15,l[Pg.SHADOW_PROJ_INFO_OFFSET+0]=p.m00,l[Pg.SHADOW_PROJ_INFO_OFFSET+1]=p.m05,l[Pg.SHADOW_PROJ_INFO_OFFSET+2]=1/p.m00,l[Pg.SHADOW_PROJ_INFO_OFFSET+3]=1/p.m05,In.toArray(l,m,Pg.MAT_LIGHT_VIEW_PROJ_OFFSET),mI.set(g,y,0,1-o.shadowSaturation),tn.toArray(l,mI,Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET),mI.set(sR.DIRECTIONAL,d,o.shadowNormalBias,v),tn.toArray(l,mI,Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET)}else{for(var S=this.getPCFRadius(h,o),T=0;T<o.csmLevel;T++){var A=u.layers[T],b=A.matShadowView;mI.set(b.m00,b.m04,b.m08,S),tn.toArray(c,mI,Og.CSM_VIEW_DIR_0_OFFSET+4*T),mI.set(b.m01,b.m05,b.m09,A.splitCameraNear),tn.toArray(c,mI,Og.CSM_VIEW_DIR_1_OFFSET+4*T),mI.set(b.m02,b.m06,b.m10,A.splitCameraFar),tn.toArray(c,mI,Og.CSM_VIEW_DIR_2_OFFSET+4*T);var E=A.csmAtlas;tn.toArray(c,E,Og.CSM_ATLAS_OFFSET+4*T);var C=A.matShadowViewProj;In.toArray(c,C,Og.MAT_CSM_VIEW_PROJ_OFFSET+16*T);var w=A.matShadowProj;c[Og.CSM_PROJ_DEPTH_INFO_OFFSET+0+4*T]=w.m10,c[Og.CSM_PROJ_DEPTH_INFO_OFFSET+1+4*T]=w.m14,c[Og.CSM_PROJ_DEPTH_INFO_OFFSET+2+4*T]=w.m11,c[Og.CSM_PROJ_DEPTH_INFO_OFFSET+3+4*T]=w.m15,c[Og.CSM_PROJ_INFO_OFFSET+0+4*T]=w.m00,c[Og.CSM_PROJ_INFO_OFFSET+1+4*T]=w.m05,c[Og.CSM_PROJ_INFO_OFFSET+2+4*T]=1/w.m00,c[Og.CSM_PROJ_INFO_OFFSET+3+4*T]=1/w.m05}mI.set(o.csmTransitionRange,0,0,0),tn.toArray(c,mI,Og.CSM_SPLITS_INFO_OFFSET),mI.set(.1,o.shadowDistance,0,1-o.shadowSaturation),tn.toArray(l,mI,Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET),mI.set(sR.DIRECTIONAL,d,o.shadowNormalBias,o.csmLevel),tn.toArray(l,mI,Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET)}mI.set(h.size.x,h.size.y,o.shadowPcf,o.shadowBias),tn.toArray(l,mI,Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET)}}else t.updatePlanarNormalAndDistance(h,l),mI.set(0,0,0,h.planeBias),tn.toArray(l,mI,Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET);dn.toArray(l,h.shadowColor,Pg.SHADOW_COLOR_OFFSET)}},t.updateShadowUBOLightView=function(t,e,i,n){var r=t.device,s=t.pipelineSceneData,o=s.shadows,a=s.csmLayers,h=e,u=Zy(r)?0:1,l=t.device.capabilities,c=s.csmSupported;switch(i.type){case sR.DIRECTIONAL:var _=i;if(o.enabled&&_&&_.shadowEnabled&&o.type===IT.ShadowMap){var d,f,p,m=.1,g=0,y=0;if(_.shadowFixedArea||_.csmLevel===DT.LEVEL_1||!c)d=a.specialLayer.matShadowView,f=a.specialLayer.matShadowProj,p=a.specialLayer.matShadowViewProj,_.shadowFixedArea?(m=_.shadowNear,g=_.shadowFar,y=0):(m=.1,g=a.specialLayer.shadowCameraFar,y=1),mI.set(sR.DIRECTIONAL,u,_.shadowNormalBias,0),tn.toArray(h,mI,Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET);else{var v=a.layers[n];d=v.matShadowView,f=v.matShadowProj,p=v.matShadowViewProj,m=v.splitCameraNear,g=v.splitCameraFar,y=_.csmLevel}In.toArray(h,d,Pg.MAT_LIGHT_VIEW_OFFSET),h[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+0]=f.m10,h[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+1]=f.m14,h[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+2]=f.m11,h[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+3]=f.m15,h[Pg.SHADOW_PROJ_INFO_OFFSET+0]=f.m00,h[Pg.SHADOW_PROJ_INFO_OFFSET+1]=f.m05,h[Pg.SHADOW_PROJ_INFO_OFFSET+2]=1/f.m00,h[Pg.SHADOW_PROJ_INFO_OFFSET+3]=1/f.m05,In.toArray(h,p,Pg.MAT_LIGHT_VIEW_PROJ_OFFSET),mI.set(m,g,0,1-_.shadowSaturation),tn.toArray(h,mI,Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET),mI.set(sR.DIRECTIONAL,u,_.shadowNormalBias,y),tn.toArray(h,mI,Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET),mI.set(o.size.x,o.size.y,_.shadowPcf,_.shadowBias),tn.toArray(h,mI,Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET)}break;case sR.SPOT:var S=i;o.enabled&&S&&S.shadowEnabled&&(In.invert(dI,i.node.getWorldMatrix()),In.toArray(h,dI,Pg.MAT_LIGHT_VIEW_OFFSET),In.perspective(fI,S.angle,1,.001,S.range,!0,l.clipSpaceMinZ,l.clipSpaceSignY,0),In.multiply(pI,fI,dI),In.toArray(h,pI,Pg.MAT_LIGHT_VIEW_PROJ_OFFSET),mI.set(.01,i.range,0,0),tn.toArray(h,mI,Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET),mI.set(o.size.x,o.size.y,S.shadowPcf,S.shadowBias),tn.toArray(h,mI,Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET),mI.set(sR.SPOT,u,S.shadowNormalBias,0),tn.toArray(h,mI,Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET))}dn.toArray(h,o.shadowColor,Pg.SHADOW_COLOR_OFFSET)},t.getCombineSignY=function(){return t._combineSignY};var e=t.prototype;return e._initCombineSignY=function(){var e=this._device;t._combineSignY=.5*e.capabilities.screenSpaceSignY+.5<<1|.5*e.capabilities.clipSpaceSignY+.5},e.activate=function(t,e){this._device=t,this._pipeline=e;var i=this._pipeline.descriptorSet;if(!tv()){this._initCombineSignY();var n=t.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,Bg.SIZE,Bg.SIZE));i.bindBuffer(Bg.BINDING,n);var r=t.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,Dg.SIZE,Dg.SIZE));i.bindBuffer(Dg.BINDING,r);var s=t.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,Pg.SIZE,Pg.SIZE)),o=tv()?qR("CCShadow"):Pg.BINDING;i.bindBuffer(o,s);var a=t.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,Og.SIZE,Og.SIZE)),h=tv()?qR("CCCSM"):Og.BINDING;i.bindBuffer(h,a)}},e.updateGlobalUBO=function(e){var i=this._pipeline.globalDSManager,n=this._pipeline.descriptorSet,r=this._pipeline.commandBuffers;n.update(),t.updateGlobalUBOView(e,this._globalUBO),r[0].updateBuffer(n.getBuffer(Bg.BINDING),this._globalUBO),i.bindBuffer(Bg.BINDING,n.getBuffer(Bg.BINDING)),i.update()},e.updateCameraUBO=function(e){var i=this._pipeline.globalDSManager,n=this._pipeline.descriptorSet,r=this._pipeline.commandBuffers;t.updateCameraUBOView(this._pipeline,this._cameraUBO,e),r[0].updateBuffer(n.getBuffer(Dg.BINDING),this._cameraUBO),i.bindBuffer(Dg.BINDING,n.getBuffer(Dg.BINDING)),i.update()},e.updateShadowUBO=function(e){var i=this._pipeline.pipelineSceneData;if(i.shadows.enabled){var n=this._pipeline.descriptorSet,r=this._pipeline.commandBuffers,s=i.shadowFrameBufferMap,o=e.scene.mainLight;o&&s.has(o)&&n.bindTexture(Mg,s.get(o).colorTextures[0]),t.updateShadowUBOView(this._pipeline,this._shadowUBO,this._csmUBO,e),n.update();var a=tv()?qR("CCShadow"):Pg.BINDING;r[0].updateBuffer(n.getBuffer(a),this._shadowUBO);var h=tv()?qR("CCCSM"):Og.BINDING;r[0].updateBuffer(n.getBuffer(h),this._csmUBO)}},e.updateShadowUBOLight=function(e,i,n){void 0===n&&(n=0),t.updateShadowUBOLightView(this._pipeline,this._shadowUBO,i,n),e.bindTexture(Mg,nT.get("default-texture").getGFXTexture()),e.bindTexture(Hg,nT.get("default-texture").getGFXTexture()),e.update();var r=tv()?qR("CCShadow"):Pg.BINDING;this._pipeline.commandBuffers[0].updateBuffer(e.getBuffer(r),this._shadowUBO)},e.updateShadowUBORange=function(t,e){e instanceof In?In.toArray(this._shadowUBO,e,t):e instanceof dn&&dn.toArray(this._shadowUBO,e,t)},e.destroy=function(){},t}();vI._combineSignY=0;var SI,TI,AI,bI,EI,CI,wI,xI,RI=t("da",qs("RenderStage")((oI=function(){function t(){this._name=aI&&aI(),this._priority=hI&&hI(),this._enabled=!0,this._tag=uI&&uI(),this._pipeline=void 0,this._flow=void 0}var e=t.prototype;return e.initialize=function(t){return this._name=t.name,this._priority=t.priority,t.tag&&(this._tag=t.tag),!0},e.activate=function(t,e){this._pipeline=t,this._flow=e},n(t,[{key:"name",get:function(){return this._name}},{key:"priority",get:function(){return this._priority}},{key:"tag",get:function(){return this._tag}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}}]),t}(),aI=ks(oI.prototype,"_name",[io],(function(){return""})),hI=ks(oI.prototype,"_priority",[io],(function(){return 0})),uI=ks(oI.prototype,"_tag",[io],(function(){return 0})),sI=oI))||sI);v.RenderStage=RI;var II,BI=t("d9",(SI=qs("RenderFlow"),TI=xo([RI]),SI((bI=function(){function t(){this._name=EI&&EI(),this._priority=CI&&CI(),this._tag=wI&&wI(),this._stages=xI&&xI(),this._pipeline=void 0}var e=t.prototype;return e.initialize=function(t){return this._name=t.name,this._priority=t.priority,this._stages=t.stages,t.tag&&(this._tag=t.tag),!0},e.activate=function(t){this._pipeline=t,this._stages.sort((function(t,e){return t.priority-e.priority}));for(var e=0,i=this._stages.length;e<i;e++)this._stages[e].activate(t,this)},e.render=function(t){for(var e=0,i=this._stages.length;e<i;e++)this._stages[e].enabled&&this._stages[e].render(t)},e.destroy=function(){for(var t=0,e=this._stages.length;t<e;t++)this._stages[t].destroy();this._stages.length=0},n(t,[{key:"name",get:function(){return this._name}},{key:"priority",get:function(){return this._priority}},{key:"tag",get:function(){return this._tag}},{key:"stages",get:function(){return this._stages}},{key:"pipeline",get:function(){return this._pipeline}}]),t}(),EI=ks(bI.prototype,"_name",[io],(function(){return""})),CI=ks(bI.prototype,"_priority",[io],(function(){return 0})),wI=ks(bI.prototype,"_tag",[io],(function(){return 0})),xI=ks(bI.prototype,"_stages",[TI,io],(function(){return[]})),AI=bI))||AI));v.RenderFlow=BI,t("ds",II),function(t){t.RENDER_FRAME_BEGIN="render-frame-begin",t.RENDER_FRAME_END="render-frame-end",t.RENDER_CAMERA_BEGIN="render-camera-begin",t.RENDER_CAMERA_END="render-camera-end",t.ATTACHMENT_SCALE_CAHNGED="attachment-scale-changed"}(II||t("ds",II={}));var DI,PI,OI,MI,LI,NI,FI,kI,VI,GI,UI,zI,HI,WI,jI,XI,qI,YI,KI,JI,QI,ZI,$I,tB,eB,iB,nB,rB,sB,oB,aB,hB,uB,lB,cB,_B,dB,fB,pB,mB,gB,yB,vB,SB,TB,AB,bB,EB,CB,wB,xB,RB,IB,BB,DB,PB,OB,MB,LB,NB,FB,kB,VB,GB,UB,zB,HB,WB,jB,XB,qB,YB,KB,JB,QB,ZB,$B,tD,eD,iD,nD,rD,sD,oD,aD,hD,uD,lD,cD,_D,dD=t("dr",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).eventTargetOn=t.prototype.on,e.eventTargetOnce=t.prototype.once,e}s(e,t);var i=e.prototype;return i.on=function(t,e,i,n){return this.eventTargetOn(t,e,i,n)},i.once=function(t,e,i){return this.eventTargetOnce(t,e,i)},e}(Ku)),fD=new Mc,pD=new Uc,mD=function(){this.renderPass=null,this.sampler=null,this.prefiterTex=null,this.downsampleTexs=[],this.upsampleTexs=[],this.combineTex=null,this.prefilterFramebuffer=null,this.downsampleFramebuffers=[],this.upsampleFramebuffers=[],this.combineFramebuffer=null},gD=function(){this.quadIB=null,this.quadVB=null,this.quadIA=null},yD=t("d8",(DI=qs("cc.RenderPipeline"),PI=xo([BI]),DI((MI=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._tag=LI&&LI(),e._flows=NI&&NI(),e._quadIB=null,e._quadVBOnscreen=null,e._quadVBOffscreen=null,e._quadIAOnscreen=null,e._quadIAOffscreen=null,e._eventProcessor=new dD,e._device=void 0,e._globalDSManager=void 0,e._descriptorSet=void 0,e._commandBuffers=[],e._pipelineUBO=new vI,e._macros={},e._constantMacros="",e._profiler=null,e._geometryRenderer=null,e._pipelineRenderData=null,e._renderPasses=new Map,e._width=0,e._height=0,e._lastUsedRenderArea=new Mc,e._clusterEnabled=!1,e._bloomEnabled=!1,e}s(e,t);var i=e.prototype;return i.getPipelineRenderData=function(){return this._pipelineRenderData},i.initialize=function(t){return this._flows=t.flows,t.tag&&(this._tag=t.tag),!0},i.createRenderPass=function(t,e,i){var n=this._device,r=new __,s=new d_;r.format=e,s.format=i,s.stencilStoreOp=cc.DISCARD,s.depthStoreOp=cc.DISCARD,t&Cc.COLOR||(t&Ux?r.loadOp=lc.CLEAR:(r.loadOp=lc.LOAD,r.barrier=n.getGeneralBarrier(new g_(_c.COLOR_ATTACHMENT_WRITE,_c.COLOR_ATTACHMENT_WRITE)))),(t&Cc.DEPTH_STENCIL)!==Cc.DEPTH_STENCIL&&(t&Cc.DEPTH||(s.depthLoadOp=lc.LOAD),t&Cc.STENCIL||(s.stencilLoadOp=lc.LOAD)),s.barrier=n.getGeneralBarrier(new g_(_c.DEPTH_STENCIL_ATTACHMENT_WRITE,_c.DEPTH_STENCIL_ATTACHMENT_WRITE));var o=new m_([r],s);return n.createRenderPass(o)},i.getRenderPass=function(t,e){var i=function(t){for(var e,i=666,n=d(t.colorTextures);!(e=n()).done;){var r=e.value,s=null==r?void 0:r.info;i=Dl(s.type+"_"+s.usage+"_"+s.format+"_"+s.width+"_"+s.height+"_"+s.flags+"_\n "+s.layerCount+"_"+s.levelCount+"_"+s.samples+"_"+s.depth+"_"+s.externalRes,i)}if(t.depthStencilTexture){var o=t.depthStencilTexture.info;i=Dl(o.type+"_"+o.usage+"_"+o.format+"_"+o.width+"_"+o.height+"_"+o.flags+"_\n "+o.layerCount+"_"+o.levelCount+"_"+o.samples+"_"+o.depth+"_"+o.externalRes,i)}return i}(e),n=Dl(i+"_"+t,666),r=this._renderPasses.get(n);return r||(r=this.createRenderPass(t,e.colorTextures[0].format,e.depthStencilTexture.format),this._renderPasses.set(n,r),r)},i.newFramebufferByRatio=function(t){for(var e=this.pipelineSceneData,i=this._width*e.shadingScale,n=this._height*e.shadingScale,r=t.colorTextures,s=0;s<r.length;s++)r[s].resize(i,n);t.depthStencilTexture&&t.depthStencilTexture.resize(i,n);var o=this._device.createFramebuffer(new S_(t.renderPass,r,t.depthStencilTexture));return t.destroy(),o},i.generateRenderArea=function(t,e){var i=t.viewport,n=t.window.width,r=t.window.height;e.x=i.x*n,e.y=i.y*r,e.width=i.width*n,e.height=i.height*r},i.generateViewport=function(t,e){this.generateRenderArea(t,fD),e||(e=pD);var i=this.pipelineSceneData.shadingScale;return e.left=fD.x*i,e.top=fD.y*i,e.width=fD.width*i,e.height=fD.height*i,e},i.generateScissor=function(t,e){e||(e=fD),this.generateRenderArea(t,e);var i=this.pipelineSceneData.shadingScale;return e.x*=i,e.y*=i,e.width*=i,e.height*=i,e},i.getMacroString=function(t){var e=this._macros[t];return void 0===e?"":e},i.getMacroInt=function(t){var e=this._macros[t];return void 0===e?0:e},i.getMacroBool=function(t){var e=this._macros[t];return void 0!==e&&e},i.setMacroString=function(t,e){this._macros[t]=e},i.setMacroInt=function(t,e){this._macros[t]=e},i.setMacroBool=function(t,e){this._macros[t]=e},i.activate=function(){this._device=Ed.gfxDevice,this._generateConstantMacros(),this._globalDSManager=new _I(this._device),this._descriptorSet=this._globalDSManager.globalDescriptorSet,this._pipelineUBO.activate(this._device,this),this._macros.CC_USE_HDR=this._pipelineSceneData.isHDR,this._macros.CC_USE_DEBUG_VIEW=0,this._generateConstantMacros(),this._pipelineSceneData.activate(this._device);for(var t=0;t<this._flows.length;t++)this._flows[t].activate(this);return!0},i._ensureEnoughSize=function(){},i.render=function(t){if(0!==t.length){this.updateGeometryRenderer(t),this._commandBuffers[0].begin(),this.emit(II.RENDER_FRAME_BEGIN,t),this._ensureEnoughSize(t),function(t){for(var e=t.length-1;e>=0;--e){var i=t[e];if(i.window.swapchain)return void(bT=i)}bT=null}(t);for(var e=0;e<t.length;e++){var i=t[e];if(i.scene){this.emit(II.RENDER_CAMERA_BEGIN,i),Jx(this,i),Qx(this,i),this._pipelineUBO.updateGlobalUBO(i.window),this._pipelineUBO.updateCameraUBO(i);for(var n=0;n<this._flows.length;n++)this._flows[n].render(i);this.emit(II.RENDER_CAMERA_END,i)}}this.emit(II.RENDER_FRAME_END,t),this._commandBuffers[0].end(),this._device.queue.submit(this._commandBuffers)}},i._destroyQuadInputAssembler=function(){this._quadIB&&(this._quadIB.destroy(),this._quadIB=null),this._quadVBOnscreen&&(this._quadVBOnscreen.destroy(),this._quadVBOnscreen=null),this._quadVBOffscreen&&(this._quadVBOffscreen.destroy(),this._quadVBOffscreen=null),this._quadIAOnscreen&&(this._quadIAOnscreen.destroy(),this._quadIAOnscreen=null),this._quadIAOffscreen&&(this._quadIAOffscreen.destroy(),this._quadIAOffscreen=null)},i._destroyBloomData=function(){var t,e=this._pipelineRenderData.bloom;if(null!==e){e.prefiterTex&&e.prefiterTex.destroy(),e.prefilterFramebuffer&&e.prefilterFramebuffer.destroy();for(var i=0;i<e.downsampleTexs.length;++i)e.downsampleTexs[i].destroy(),e.downsampleFramebuffers[i].destroy();e.downsampleTexs.length=0,e.downsampleFramebuffers.length=0;for(var n=0;n<e.upsampleTexs.length;++n)e.upsampleTexs[n].destroy(),e.upsampleFramebuffers[n].destroy();e.upsampleTexs.length=0,e.upsampleFramebuffers.length=0,e.combineTex&&e.combineTex.destroy(),e.combineFramebuffer&&e.combineFramebuffer.destroy(),null===(t=e.renderPass)||void 0===t||t.destroy(),this._pipelineRenderData.bloom=null}},i._genQuadVertexData=function(t,e){var i=new Float32Array(16),n=e.x/this._width,r=(e.x+e.width)/this._width,s=e.y/this._height,o=(e.y+e.height)/this._height;if(this.device.capabilities.screenSpaceSignY>0){var a=o;o=s,s=a}var h=0;switch(t){case Ul.IDENTITY:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=o,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=o,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=s;break;case Ul.ROTATE_90:h=0,i[h++]=-1,i[h++]=-1,i[h++]=r,i[h++]=o,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=s,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=o,i[h++]=1,i[h++]=1,i[h++]=n,i[h++]=s;break;case Ul.ROTATE_180:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=s,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=o,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=o;break;case Ul.ROTATE_270:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=-1,i[h++]=n,i[h++]=o,i[h++]=-1,i[h++]=1,i[h++]=r,i[h++]=s,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=o}return i},i._createQuadInputAssembler=function(){var t=new gD,e=4*Float32Array.BYTES_PER_ELEMENT,i=4*e,n=this._device.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE|Kl.HOST,i,e));if(!n)return t;var r=Uint8Array.BYTES_PER_ELEMENT,s=6*r,o=this._device.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,s,r));if(!o)return t;var a=new Uint8Array(6);a[0]=0,a[1]=1,a[2]=2,a[3]=1,a[4]=3,a[5]=2,o.update(a);var h=new Array(2);h[0]=new u_("a_position",Hl.RG32F),h[1]=new u_("a_texCoord",Hl.RG32F);var u=this._device.createInputAssembler(new c_(h,[n],o));return t.quadIB=o,t.quadVB=n,t.quadIA=u,t},i.updateQuadVertexData=function(t,e){var i=this._lastUsedRenderArea;if(i.x!==t.x||i.y!==t.y||i.width!==t.width||i.height!==t.height){var n=this._genQuadVertexData(Ul.IDENTITY,t);this._quadVBOffscreen.update(n);var r=this._genQuadVertexData(e.swapchain&&e.swapchain.surfaceTransform||Ul.IDENTITY,t);this._quadVBOnscreen.update(r),i.copy(t)}},i.destroy=function(){for(var e,i,n=0;n<this._flows.length;n++)this._flows[n].destroy();this._flows.length=0,this._descriptorSet&&this._descriptorSet.destroy(),null===(e=this._globalDSManager)||void 0===e||e.destroy();for(var r=0;r<this._commandBuffers.length;r++)this._commandBuffers[r].destroy();return this._commandBuffers.length=0,this._pipelineUBO.destroy(),null===(i=this._pipelineSceneData)||void 0===i||i.destroy(),t.prototype.destroy.call(this)},i.onGlobalPipelineStateChanged=function(){},i._generateConstantMacros=function(){var t="";t+="#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE "+(this.device.getFormatFeatures(Hl.RGBA32F)&($l.RENDER_TARGET|$l.SAMPLED_TEXTURE)?1:0)+"\n",t+="#define CC_ENABLE_CLUSTERED_LIGHT_CULLING "+(this._clusterEnabled?1:0)+"\n",t+="#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS "+this.device.capabilities.maxVertexUniformVectors+"\n",t+="#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS "+this.device.capabilities.maxFragmentUniformVectors+"\n",t+="#define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT "+(this.device.hasFeature(zl.INPUT_ATTACHMENT_BENEFIT)?1:0)+"\n",t+="#define CC_PLATFORM_ANDROID_AND_WEBGL "+(nl.os===$u.ANDROID&&nl.isBrowser?1:0)+"\n",t+="#define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES "+(Ce.ENABLE_WEBGL_HIGHP_STRUCT_VALUES?1:0)+"\n",t+="#define CC_JOINT_UNIFORM_CAPACITY "+iy.JOINT_UNIFORM_CAPACITY+"\n",this._constantMacros=t},i.updateGeometryRenderer=function(t){if(!this._geometryRenderer)for(var e=0;e<t.length;e++){var i=t[e];if(i&&i.window&&i.window.swapchain)return i.initGeometryRenderer(),void(this._geometryRenderer=i.geometryRenderer)}},i.generateBloomRenderData=function(){if(null==this._pipelineRenderData.bloom){var t=this._pipelineRenderData.bloom=new mD,e=this.device,i=new __;i.format=Hl.RGBA8,i.loadOp=lc.CLEAR,i.storeOp=cc.STORE,i.barrier=e.getGeneralBarrier(new g_(_c.NONE,_c.COLOR_ATTACHMENT_WRITE)),t.renderPass=e.createRenderPass(new m_([i]));var n=this._width,r=this._height;t.prefiterTex=e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA8,n>>1,r>>1)),t.prefilterFramebuffer=e.createFramebuffer(new S_(t.renderPass,[t.prefiterTex])),n>>=1,r>>=1;for(var s=0;s<6;++s)t.downsampleTexs.push(e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA8,n>>1,r>>1))),t.downsampleFramebuffers[s]=e.createFramebuffer(new S_(t.renderPass,[t.downsampleTexs[s]])),t.upsampleTexs.push(e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA8,n,r))),t.upsampleFramebuffers[s]=e.createFramebuffer(new S_(t.renderPass,[t.upsampleTexs[s]])),n>>=1,r>>=1;t.combineTex=e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA8,this._width,this._height)),t.combineFramebuffer=e.createFramebuffer(new S_(t.renderPass,[t.combineTex])),t.sampler=this.globalDSManager.linearSampler}},i.on=function(t,e,i,n){return this._eventProcessor.on(t,e,i,n)},i.once=function(t,e,i){return this._eventProcessor.once(t,e,i)},i.off=function(t,e,i){this._eventProcessor.off(t,e,i)},i.emit=function(t,e,i,n,r,s){this._eventProcessor.emit(t,e,i,n,r,s)},i.targetOff=function(t){this._eventProcessor.targetOff(t)},i.removeAll=function(t){this._eventProcessor.removeAll(t)},i.hasEventListener=function(t,e,i){return this._eventProcessor.hasEventListener(t,e,i)},n(e,[{key:"tag",get:function(){return this._tag}},{key:"flows",get:function(){return this._flows}},{key:"quadIAOnscreen",get:function(){return this._quadIAOnscreen}},{key:"quadIAOffscreen",get:function(){return this._quadIAOffscreen}},{key:"constantMacros",get:function(){return this._constantMacros}},{key:"macros",get:function(){return this._macros}},{key:"device",get:function(){return this._device}},{key:"globalDSManager",get:function(){return this._globalDSManager}},{key:"descriptorSetLayout",get:function(){return this._globalDSManager.descriptorSetLayout}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"commandBuffers",get:function(){return this._commandBuffers}},{key:"pipelineUBO",get:function(){return this._pipelineUBO}},{key:"pipelineSceneData",get:function(){return this._pipelineSceneData}},{key:"profiler",get:function(){return this._profiler},set:function(t){this._profiler=t}},{key:"geometryRenderer",get:function(){return this._geometryRenderer}},{key:"clusterEnabled",get:function(){return this._clusterEnabled},set:function(t){this._clusterEnabled=t}},{key:"bloomEnabled",get:function(){return this._bloomEnabled},set:function(t){this._bloomEnabled=t}},{key:"shadingScale",get:function(){return this._pipelineSceneData.shadingScale},set:function(t){this._pipelineSceneData.shadingScale!==t&&(this._pipelineSceneData.shadingScale=t,this.emit(II.ATTACHMENT_SCALE_CAHNGED,t))}}]),e}(of),LI=ks(MI.prototype,"_tag",[io],(function(){return 0})),NI=ks(MI.prototype,"_flows",[PI,io],(function(){return[]})),OI=MI))||OI));v.RenderPipeline=yD,function(t){t[t.BLOOM=18]="BLOOM",t[t.POST_PROCESS=19]="POST_PROCESS",t[t.UI=20]="UI"}(FI||(FI={})),function(t){t[t.AR=5]="AR",t[t.FORWARD=10]="FORWARD"}(kI||(kI={})),function(t){t[t.SHADOW=0]="SHADOW",t[t.FORWARD=1]="FORWARD",t[t.UI=10]="UI"}(VI||(VI={})),function(t){t[t.GBUFFER=10]="GBUFFER",t[t.LIGHTING=15]="LIGHTING",t[t.TRANSPARENT=18]="TRANSPARENT"}(GI||(GI={})),function(t){t[t.SHADOW=0]="SHADOW",t[t.MAIN=1]="MAIN",t[t.UI=10]="UI"}(UI||(UI={})),Se(Jl),Se(Ql),Se(cc),Se(lc),Se(_c),Se(Hl),function(t){t[t.SCENE=0]="SCENE",t[t.POSTPROCESS=1]="POSTPROCESS",t[t.UI=2]="UI"}(_D||(_D={})),Se(_D),zI=qs("RenderTextureDesc"),HI=xo(Jl),WI=xo(Ql),jI=xo(Hl),zI((XI=function(){this.name=qI&&qI(),this.type=YI&&YI(),this.usage=KI&&KI(),this.format=JI&&JI(),this.width=QI&&QI(),this.height=ZI&&ZI()},qI=ks(XI.prototype,"name",[io],(function(){return""})),YI=ks(XI.prototype,"type",[HI],(function(){return Jl.TEX2D})),KI=ks(XI.prototype,"usage",[WI],(function(){return Ql.COLOR_ATTACHMENT})),JI=ks(XI.prototype,"format",[jI],(function(){return Hl.UNKNOWN})),QI=ks(XI.prototype,"width",[io],(function(){return-1})),ZI=ks(XI.prototype,"height",[io],(function(){return-1})),XI));var vD=($I=qs("RenderTextureConfig"),tB=xo(rR),$I((iB=function(){this.name=nB&&nB(),this.texture=rB&&rB()},nB=ks(iB.prototype,"name",[io],(function(){return""})),rB=ks(iB.prototype,"texture",[tB],(function(){return null})),eB=iB))||eB);sB=qs("MaterialConfig"),oB=xo(xT),sB((aB=function(){this.name=hB&&hB(),this.material=uB&&uB()},hB=ks(aB.prototype,"name",[io],(function(){return""})),uB=ks(aB.prototype,"material",[oB],(function(){return null})),aB)),lB=qs("FrameBufferDesc"),cB=xo([Je]),_B=xo(rR),lB((dB=function(){this.name=fB&&fB(),this.renderPass=pB&&pB(),this.colorTextures=mB&&mB(),this.depthStencilTexture=gB&&gB(),this.texture=yB&&yB()},fB=ks(dB.prototype,"name",[io],(function(){return""})),pB=ks(dB.prototype,"renderPass",[io],(function(){return 0})),mB=ks(dB.prototype,"colorTextures",[cB],(function(){return[]})),gB=ks(dB.prototype,"depthStencilTexture",[io],(function(){return""})),yB=ks(dB.prototype,"texture",[_B],(function(){return null})),dB));var SD,TD=(vB=qs("ColorDesc"),SB=xo(Hl),TB=xo(lc),AB=xo(cc),bB=xo(_c),EB=xo(_c),vB((wB=function(){this.format=xB&&xB(),this.loadOp=RB&&RB(),this.storeOp=IB&&IB(),this.sampleCount=BB&&BB(),this.beginAccesses=DB&&DB(),this.endAccesses=PB&&PB()},xB=ks(wB.prototype,"format",[SB],(function(){return Hl.UNKNOWN})),RB=ks(wB.prototype,"loadOp",[TB],(function(){return lc.CLEAR})),IB=ks(wB.prototype,"storeOp",[AB],(function(){return cc.STORE})),BB=ks(wB.prototype,"sampleCount",[io],(function(){return 1})),DB=ks(wB.prototype,"beginAccesses",[bB],(function(){return _c.NONE})),PB=ks(wB.prototype,"endAccesses",[EB],(function(){return _c.COLOR_ATTACHMENT_WRITE})),CB=wB))||CB),AD=(OB=qs("DepthStencilDesc"),MB=xo(Hl),LB=xo(lc),NB=xo(cc),FB=xo(lc),kB=xo(cc),VB=xo(_c),GB=xo(_c),OB((zB=function(){this.format=HB&&HB(),this.depthLoadOp=WB&&WB(),this.depthStoreOp=jB&&jB(),this.stencilLoadOp=XB&&XB(),this.stencilStoreOp=qB&&qB(),this.sampleCount=YB&&YB(),this.beginAccesses=KB&&KB(),this.endAccesses=JB&&JB()},HB=ks(zB.prototype,"format",[MB],(function(){return Hl.UNKNOWN})),WB=ks(zB.prototype,"depthLoadOp",[LB],(function(){return lc.CLEAR})),jB=ks(zB.prototype,"depthStoreOp",[NB],(function(){return cc.STORE})),XB=ks(zB.prototype,"stencilLoadOp",[FB],(function(){return lc.CLEAR})),qB=ks(zB.prototype,"stencilStoreOp",[kB],(function(){return cc.STORE})),YB=ks(zB.prototype,"sampleCount",[io],(function(){return 1})),KB=ks(zB.prototype,"beginAccesses",[VB],(function(){return _c.NONE})),JB=ks(zB.prototype,"endAccesses",[GB],(function(){return _c.DEPTH_STENCIL_ATTACHMENT_WRITE})),UB=zB))||UB);QB=qs("RenderPassDesc"),ZB=xo([TD]),$B=xo(AD),QB((tD=function(){this.index=eD&&eD(),this.colorAttachments=iD&&iD(),this.depthStencilAttachment=nD&&nD()},eD=ks(tD.prototype,"index",[io],(function(){return-1})),iD=ks(tD.prototype,"colorAttachments",[ZB],(function(){return[]})),nD=ks(tD.prototype,"depthStencilAttachment",[$B],(function(){return new AD})),tD)),function(t){t[t.FRONT_TO_BACK=0]="FRONT_TO_BACK",t[t.BACK_TO_FRONT=1]="BACK_TO_FRONT"}(SD||(SD={})),Se(SD);var bD=(rD=qs("RenderQueueDesc"),sD=xo(SD),oD=xo([Je]),rD((hD=function(){this.isTransparent=uD&&uD(),this.sortMode=lD&&lD(),this.stages=cD&&cD()},uD=ks(hD.prototype,"isTransparent",[io],(function(){return!1})),lD=ks(hD.prototype,"sortMode",[sD],(function(){return SD.FRONT_TO_BACK})),cD=ks(hD.prototype,"stages",[oD],(function(){return[]})),aD=hD))||aD);function ED(t,e){return t.hash-e.hash||t.depth-e.depth||t.shaderId-e.shaderId}function CD(t,e){return t.priority-e.priority||t.hash-e.hash||e.depth-t.depth||t.shaderId-e.shaderId}var wD=function(){function t(t){this.queue=void 0,this._passDesc=void 0,this._passPool=void 0,this._passDesc=t,this._passPool=new Du((function(){return{priority:0,hash:0,depth:0,shaderId:0,subModel:null,passIdx:0}}),64),this.queue=new Pu(64,this._passDesc.sortFunc)}var e=t.prototype;return e.clear=function(){this.queue.clear(),this._passPool.reset()},e.insertRenderPass=function(t,e,i){var n=t.model.subModels[e],r=n.passes[i],s=n.shaders[i];if(r.blendState.targets[0].blend!==this._passDesc.isTransparent||!(r.phase&this._passDesc.phases))return!1;var o=0|r.priority<<16|n.priority<<8|i,a=this._passPool.add();return a.priority=t.model.priority,a.hash=o,a.depth=t.depth||0,a.shaderId=s.typedID,a.subModel=n,a.passIdx=i,this.queue.push(a),!0},e.sort=function(){this.queue.sort()},e.recordCommandBuffer=function(t,e,i){for(var n=0;n<this.queue.length;++n){var r=this.queue.array[n],s=r.subModel,o=r.passIdx,a=s.inputAssembler,h=s.passes[o],u=s.shaders[o],l=lT.getOrCreatePipelineState(t,h,u,e,a);i.bindPipelineState(l),i.bindDescriptorSet(Cg.MATERIAL,h.descriptorSet),i.bindDescriptorSet(Cg.LOCAL,s.descriptorSet),i.bindInputAssembler(a),i.draw(a)}},t}();function xD(t){for(var e=0,i=0;i<t.stages.length;i++)e|=rT(t.stages[i]);var n=ED;switch(t.sortMode){case SD.BACK_TO_FRONT:n=CD;break;case SD.FRONT_TO_BACK:n=ED}return new wD({isTransparent:t.isTransparent,phases:e,sortFunc:n})}function RD(t){t.clear()}function ID(t){t.sort()}var BD,DD,PD,OD,MD,LD,ND=function(){function t(){this.queue=new Set,this._renderQueue=[]}var e=t.prototype;return e.clear=function(){for(var t=this.queue.values(),e=t.next();!e.done;)e.value.clear(),e=t.next();this._renderQueue.length=0,this.queue.clear()},e.sort=function(){for(var t=this.queue.values(),e=t.next();!e.done;)e.value.pass.blendState.targets[0].blend||this._renderQueue.push(e.value),e=t.next();for(e=(t=this.queue.values()).next();!e.done;)e.value.pass.blendState.targets[0].blend&&this._renderQueue.push(e.value),e=t.next()},e.uploadBuffers=function(t){for(var e=this.queue.values(),i=e.next();!i.done;)i.value.hasPendingModels&&i.value.uploadBuffers(t),i=e.next()},e.recordCommandBuffer=function(t,e,i,n,r){void 0===n&&(n=null);for(var s=0===this._renderQueue.length?this.queue.values():this._renderQueue[Symbol.iterator](),o=s.next();!o.done;){var a=o.value,h=a.instances,u=a.pass;if(a.hasPendingModels){i.bindDescriptorSet(Cg.MATERIAL,u.descriptorSet);for(var l=null,c=0;c<h.length;++c){var _=h[c];if(_.count){var d=_.shader,f=lT.getOrCreatePipelineState(t,u,d,e,_.ia);l!==f&&(i.bindPipelineState(f),l=f),n&&i.bindDescriptorSet(Cg.GLOBAL,n),r?i.bindDescriptorSet(Cg.LOCAL,_.descriptorSet,r):i.bindDescriptorSet(Cg.LOCAL,_.descriptorSet,o.value.dynamicOffsets),i.bindInputAssembler(_.ia),i.draw(_.ia)}}}o=s.next()}},t}(),FD=[new zc(0,0,0,0),new zc(0,0,0,0),new zc(0,0,0,0)],kD=t("di",(BD=qs("GbufferStage"),DD=xo([bD]),BD(((LD=function(t){function e(){var e;return(e=t.call(this)||this).renderQueues=MD&&MD(),e._renderQueues=[],e._renderArea=new Mc,e._instancedQueue=void 0,e._phaseID=rT("default"),e._instancedQueue=new ND,e}s(e,t);var i=e.prototype;return i.initialize=function(e){return t.prototype.initialize.call(this,e),e.renderQueues&&(this.renderQueues=e.renderQueues),!0},i.activate=function(e,i){t.prototype.activate.call(this,e,i);for(var n=0;n<this.renderQueues.length;n++)this._renderQueues[n]=xD(this.renderQueues[n])},i.destroy=function(){},i.render=function(t){this._instancedQueue.clear();var e=this._pipeline,i=e.device;this._renderQueues.forEach(RD),e.generateRenderArea(t,this._renderArea),e.updateQuadVertexData(this._renderArea,t.window);for(var n=e.pipelineSceneData.renderObjects,r=0,s=0,o=0,a=0;a<n.length;++a){var h=n[a],u=h.model.subModels;for(r=0;r<u.length;++r){var l=u[r],c=l.passes;for(s=0;s<c.length;++s){var _=c[s];if(_.phase===this._phaseID)if(_.batchingScheme===eT.INSTANCING){var d=_.getInstancedBuffer();d.merge(l,s),this._instancedQueue.queue.add(d)}else for(o=0;o<this._renderQueues.length;o++)this._renderQueues[o].insertRenderPass(h,r,s)}}}this._renderQueues.forEach(ID);var f=e.commandBuffers[0];this._instancedQueue.uploadBuffers(f),t.clearFlag&Cc.COLOR&&(e.pipelineSceneData.isHDR?dT(FD[0],t.clearColor):(FD[0].x=t.clearColor.x,FD[0].y=t.clearColor.y,FD[0].z=t.clearColor.z)),FD[0].w=t.clearColor.w;var p=e.getPipelineRenderData().gbufferFrameBuffer,m=p.renderPass;f.beginRenderPass(m,p,this._renderArea,FD,t.clearDepth,t.clearStencil),f.setScissor(e.generateScissor(t)),f.setViewport(e.generateViewport(t)),f.bindDescriptorSet(Cg.GLOBAL,e.descriptorSet);for(var g=0;g<this.renderQueues.length;g++)this._renderQueues[g].recordCommandBuffer(i,m,f);this._instancedQueue.recordCommandBuffer(i,m,f),f.endRenderPass()},e}(RI)).initInfo={name:"GbufferStage",priority:GI.GBUFFER,tag:0,renderQueues:[{isTransparent:!1,sortMode:SD.FRONT_TO_BACK,stages:["default"]},{isTransparent:!0,sortMode:SD.BACK_TO_FRONT,stages:["default"]}]},MD=ks((OD=LD).prototype,"renderQueues",[DD,io],(function(){return[]})),PD=OD))||PD)),VD=new Ss,GD=rT("planar-shadow");function UD(t){var e=t.passes,i=v.rendering;tv()&&(GD=i.getPhaseID(i.getPassID("default"),"planar-shadow"));for(var n=0;n<e.length;n++)if((!i||!i.enableEffectImport)&&e[n].phase===GD||tv()&&e[n].phaseID===GD)return n;return-1}var zD,HD,WD,jD,XD,qD,YD,KD,JD,QD,ZD,$D,tP,eP,iP,nP,rP,sP=function(){function t(t){this._subModelArray=[],this._shaderArray=[],this._passArray=[],this._castModels=[],this._instancedQueue=new ND,this._pipeline=void 0,this._pipeline=t}var e=t.prototype;return e.clear=function(){this._subModelArray.length=0,this._shaderArray.length=0,this._passArray.length=0,this._instancedQueue.clear(),this._castModels.length=0},e.gatherShadowPasses=function(t,e){this.clear();var i=this._pipeline.pipelineSceneData.shadows;if(i.enabled&&i.type===IT.Planar&&!(i.normal.length()<1e-6)){var n=t.scene,r=t.frustum,s=0!=(t.visibility&im.BitMask.DEFAULT);if(n.mainLight&&s){for(var o=n.models,a=t.visibility,h=0;h<o.length;h++){var u=o[h];n.isCulledByLod(t,u)||u.enabled&&u.node&&u.castShadow&&u.node&&(a&u.node.layer)===u.node.layer&&this._castModels.push(u)}for(var l=0;l<this._castModels.length;l++){var c=this._castModels[l];if(!c.worldBounds||(Ss.transform(VD,c.worldBounds,i.matLight),as.aabbFrustum(VD,r)))for(var _=c.subModels,d=0;d<_.length;d++){var f=_[d],p=UD(f);if(p<0){this._subModelArray.push(f);var m=i.getPlanarShader(f.patches);if(!m)continue;this._shaderArray.push(m),this._passArray.push(i.material.passes[0])}else{var g=f.passes[p];if(g.batchingScheme===eT.INSTANCING){var y=g.getInstancedBuffer();y.merge(f,p),this._instancedQueue.queue.add(y)}else{var v=f.shaders[p];this._subModelArray.push(f),v&&this._shaderArray.push(v),this._passArray.push(g)}}}}this._instancedQueue.uploadBuffers(e)}}},e.recordCommandBuffer=function(t,e,i){var n=this._pipeline.pipelineSceneData.shadows;if(n.enabled&&n.type===IT.Planar){this._instancedQueue.recordCommandBuffer(t,e,i);for(var r=0;r<this._subModelArray.length;++r){var s=this._subModelArray[r],o=this._shaderArray[r],a=this._passArray[r],h=s.inputAssembler,u=lT.getOrCreatePipelineState(t,a,o,e,h),l=a.descriptorSet;i.bindPipelineState(u),i.bindDescriptorSet(Cg.MATERIAL,l),i.bindDescriptorSet(Cg.LOCAL,s.descriptorSet),i.bindInputAssembler(h),i.draw(h)}}},t}(),oP=function(){function t(){this._phaseID=rT("default");var t=v.rendering;tv()&&(this._phaseID=t.getPhaseID(t.getPassID("default"),"default"))}var e=t.prototype;return e.activate=function(t){this._pipeline=t},e.render=function(t,e){for(var i=this._pipeline,n=i.device,r=i.commandBuffers[0],s=t.scene.batches,o=0;o<s.length;o++){var a=s[o],h=!1;if(t.visibility&a.visFlags&&(h=!0),h)for(var u=a.shaders.length,l=0;l<u;l++){var c=a.passes[l];if(c.phase===this._phaseID){var _=a.shaders[l],d=a.inputAssembler,f=lT.getOrCreatePipelineState(n,c,_,e,d);r.bindPipelineState(f),r.bindDescriptorSet(Cg.MATERIAL,c.descriptorSet);var p=a.descriptorSet;r.bindDescriptorSet(Cg.LOCAL,p),r.bindInputAssembler(d),r.draw(d)}}}},t}(),aP=new on,hP=new Ss(0,0,0,.5,.5,.5),uP=new Ss,lP=[new zc(0,0,0,1)],cP=t("dj",(zD=qs("LightingStage"),HD=xo(xT),WD=xo([bD]),zD(((KD=function(t){function e(){var e;return(e=t.call(this)||this)._deferredLitsBufs=null,e._maxDeferredLights=Zg.LIGHTS_PER_PASS,e._lightBufferData=void 0,e._lightMeterScale=1e4,e._descriptorSet=null,e._descriptorSetLayout=void 0,e._renderArea=new Mc,e._uiPhase=void 0,e._deferredMaterial=qD&&qD(),e.renderQueues=YD&&YD(),e._phaseID=rT("default"),e._renderQueues=[],e._uiPhase=new oP,e}s(e,t);var i=e.prototype;return i.initialize=function(e){return t.prototype.initialize.call(this,e),!0},i.gatherLights=function(t){for(var e=this._pipeline,i=e.commandBuffers[0],n=t.scene.sphereLights,r=t.scene.spotLights,s=t.scene.pointLights,o=t.scene.rangedDirLights,a=gr.create(0,0,0,1),h=new Float32Array(4),u=t.exposure,l=0,c=tn.length,_=c*this._maxDeferredLights,d=0;d<n.length&&l<this._maxDeferredLights;d++,++l){var f=n[d];if(gr.set(a,f.position.x,f.position.y,f.position.z,f.range),as.sphereFrustum(a,t.frustum)){if(on.toArray(h,f.position),h[3]=sR.SPHERE,this._lightBufferData.set(h,l*c),on.toArray(h,f.color),f.useColorTemperature){var p=f.finalColor;h[0]=p.x,h[1]=p.y,h[2]=p.z}e.pipelineSceneData.isHDR?h[3]=f.luminance*u*this._lightMeterScale:h[3]=f.luminance,this._lightBufferData.set(h,l*c+1*_),h[0]=f.size,h[1]=f.range,h[2]=0,this._lightBufferData.set(h,l*c+2*_)}}for(var m=0;m<r.length&&l<this._maxDeferredLights;m++,++l){var g=r[m];if(gr.set(a,g.position.x,g.position.y,g.position.z,g.range),as.sphereFrustum(a,t.frustum)){if(on.toArray(h,g.position),h[3]=sR.SPOT,this._lightBufferData.set(h,l*c+0*_),on.toArray(h,g.color),g.useColorTemperature){var y=g.finalColor;h[0]=y.x,h[1]=y.y,h[2]=y.z}e.pipelineSceneData.isHDR?h[3]=g.luminance*u*this._lightMeterScale:h[3]=g.luminance,this._lightBufferData.set(h,l*c+1*_),h[0]=g.size,h[1]=g.range,h[2]=g.spotAngle,this._lightBufferData.set(h,l*c+2*_),on.toArray(h,g.direction),this._lightBufferData.set(h,l*c+3*_)}}for(var v=0;v<s.length&&l<this._maxDeferredLights;v++,++l){var S=s[v];if(gr.set(a,S.position.x,S.position.y,S.position.z,S.range),as.sphereFrustum(a,t.frustum)){if(on.toArray(h,S.position),h[3]=sR.POINT,this._lightBufferData.set(h,l*c),on.toArray(h,S.color),S.useColorTemperature){var T=S.finalColor;h[0]=T.x,h[1]=T.y,h[2]=T.z}e.pipelineSceneData.isHDR?h[3]=S.luminance*u*this._lightMeterScale:h[3]=S.luminance,this._lightBufferData.set(h,l*c+1*_),h[0]=0,h[1]=S.range,h[2]=0,this._lightBufferData.set(h,l*c+2*_)}}for(var A=0;A<o.length&&l<this._maxDeferredLights;A++,++l){var b=o[A];if(Ss.transform(uP,hP,b.node.getWorldMatrix()),as.aabbFrustum(uP,t.frustum)){if(on.toArray(h,b.position),h[3]=sR.RANGED_DIRECTIONAL,this._lightBufferData.set(h,l*c),on.toArray(h,b.color),b.useColorTemperature){var E=b.finalColor;h[0]=E.x,h[1]=E.y,h[2]=E.z}e.pipelineSceneData.isHDR?h[3]=b.illuminance*u:h[3]=b.illuminance,this._lightBufferData.set(h,l*c+1*_),on.toArray(h,b.right),h[3]=0,this._lightBufferData.set(h,l*c+2*_),on.toArray(h,b.direction),h[3]=0,this._lightBufferData.set(h,l*c+3*_);var C=b.scale;aP.set(.5*C.x,.5*C.y,.5*C.z),on.toArray(h,aP),h[3]=0,this._lightBufferData.set(h,l*c+4*_)}}var w=3*_+3;this._lightBufferData.set([l],w),i.updateBuffer(this._deferredLitsBufs,this._lightBufferData)},i._createStageDescriptor=function(t){var e=this._pipeline.device,i=16*Float32Array.BYTES_PER_ELEMENT*this._maxDeferredLights;i=Math.ceil(i/e.capabilities.uboOffsetAlignment)*e.capabilities.uboOffsetAlignment,this._deferredLitsBufs=e.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,i,e.capabilities.uboOffsetAlignment));var n=e.createBuffer(new qc(this._deferredLitsBufs,0,i));this._lightBufferData=new Float32Array(i/Float32Array.BYTES_PER_ELEMENT),this._descriptorSet=e.createDescriptorSet(new b_(t.localSetLayout)),this._descriptorSet.bindBuffer(Qg.BINDING,n);var r=e.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.DEVICE,Xg.SIZE,Xg.SIZE));this._descriptorSet.bindBuffer(Xg.BINDING,r)},i.activate=function(e,i){t.prototype.activate.call(this,e,i),this._uiPhase.activate(e);for(var n=0;n<this.renderQueues.length;n++)this._renderQueues[n]=xD(this.renderQueues[n]);this._planarQueue=new sP(this._pipeline),this._deferredMaterial&&(e.pipelineSceneData.deferredLightingMaterial=this._deferredMaterial)},i.destroy=function(){var t;null===(t=this._deferredLitsBufs)||void 0===t||t.destroy(),this._deferredLitsBufs=null,this._descriptorSet=null},i.render=function(t){var e,i=this._pipeline,n=i.device,r=i.commandBuffers[0],s=i.pipelineSceneData,o=s.renderObjects;this._planarQueue.gatherShadowPasses(t,r),i.generateRenderArea(t,this._renderArea);for(var a=i.getPipelineRenderData(),h=s.deferredLightingMaterial.passes[0],u=h.getShaderVariant(),l=0;l<3;++l)h.descriptorSet.bindTexture(l,a.gbufferRenderTargets[l]),h.descriptorSet.bindSampler(l,a.sampler);h.descriptorSet.bindTexture(3,a.outputDepth),h.descriptorSet.bindSampler(3,a.sampler),h.descriptorSet.update(),this._descriptorSet||this._createStageDescriptor(h),this.gatherLights(t),t.clearFlag&Cc.COLOR&&(lP[0].x=t.clearColor.x,lP[0].y=t.clearColor.y,lP[0].z=t.clearColor.z),lP[0].w=0;var c=a.outputFrameBuffer,_=c.renderPass;i.pipelineUBO.updateShadowUBO(t),r.beginRenderPass(_,c,this._renderArea,lP,t.clearDepth,t.clearStencil),r.setScissor(i.generateScissor(t)),r.setViewport(i.generateViewport(t)),r.bindDescriptorSet(Cg.GLOBAL,i.descriptorSet);var d=i.quadIAOffscreen,f=null;null!=h&&null!=u&&null!=d&&(f=lT.getOrCreatePipelineState(n,h,u,_,d)),null!=f&&(this._descriptorSet.update(),r.bindPipelineState(f),r.bindDescriptorSet(Cg.MATERIAL,h.descriptorSet),r.bindDescriptorSet(Cg.LOCAL,this._descriptorSet),r.bindInputAssembler(d),r.draw(d)),this._renderQueues.forEach(RD);for(var p=0,m=0,g=0,y=0;y<o.length;++y){var v=o[y],S=v.model.subModels;for(p=0;p<S.length;++p){var T=S[p].passes;for(m=0;m<T.length;++m)if(T[m].phase===this._phaseID)for(g=0;g<this._renderQueues.length;g++)this._renderQueues[g].insertRenderPass(v,p,m)}}if(o.length>0){this._renderQueues.forEach(ID);for(var A=0;A<this._renderQueues.length;A++)this._renderQueues[A].recordCommandBuffer(n,_,r);this._planarQueue.recordCommandBuffer(n,_,r)}null===(e=t.geometryRenderer)||void 0===e||e.render(_,r,i.pipelineSceneData),this._uiPhase.render(t,_),r.endRenderPass()},e}(RI)).initInfo={name:"LightingStage",priority:GI.LIGHTING,tag:0},qD=ks((XD=KD).prototype,"_deferredMaterial",[HD,io],(function(){return null})),YD=ks(XD.prototype,"renderQueues",[WD,io],(function(){return[]})),jD=XD))||jD)),_P=[new zc(0,0,0,1)],dP=t("dl",(JD=qs("PostProcessStage"),QD=xo(xT),ZD=xo([bD]),JD(((nP=function(t){function e(){var e;return(e=t.call(this)||this)._postProcessMaterial=eP&&eP(),e.renderQueues=iP&&iP(),e._renderArea=new Mc,e._stageDesc=void 0,e._localUBO=void 0,e._uiPhase=new oP,e}s(e,t);var i=e.prototype;return i.initialize=function(e){return t.prototype.initialize.call(this,e),!0},i.activate=function(e,i){t.prototype.activate.call(this,e,i),this._postProcessMaterial&&(e.pipelineSceneData.postprocessMaterial=this._postProcessMaterial),this._uiPhase.activate(e)},i.destroy=function(){},i.render=function(t){var e=this._pipeline,i=e.device,n=e.pipelineSceneData,r=e.commandBuffers[0];e.pipelineUBO.updateCameraUBO(t);var s=t.viewport;this._renderArea.x=s.x*t.window.width,this._renderArea.y=s.y*t.window.height,this._renderArea.width=s.width*t.window.width,this._renderArea.height=s.height*t.window.height;var o=e.getPipelineRenderData(),a=t.window.framebuffer,h=e.getRenderPass(t.clearFlag,a);t.clearFlag&Cc.COLOR&&(_P[0].x=t.clearColor.x,_P[0].y=t.clearColor.y,_P[0].z=t.clearColor.z),_P[0].w=t.clearColor.w,r.beginRenderPass(h,a,this._renderArea,_P,t.clearDepth,t.clearStencil),r.bindDescriptorSet(Cg.GLOBAL,e.descriptorSet);var u=n.postprocessMaterial.passes[0],l=u.getShaderVariant();e.bloomEnabled?u.descriptorSet.bindTexture(0,o.bloom.combineTex):u.descriptorSet.bindTexture(0,o.outputRenderTargets[0]),u.descriptorSet.bindSampler(0,o.sampler),u.descriptorSet.update();var c=t.window.swapchain?e.quadIAOnscreen:e.quadIAOffscreen,_=null;null!=u&&null!=l&&null!=c&&(_=lT.getOrCreatePipelineState(i,u,l,h,c));var d=e.pipelineSceneData.renderObjects;null!=_&&d.length>0&&(this._stageDesc||(this._stageDesc=i.createDescriptorSet(new b_(u.localSetLayout)),this._localUBO=i.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.DEVICE,Xg.SIZE,Xg.SIZE)),this._stageDesc.bindBuffer(Xg.BINDING,this._localUBO)),this._stageDesc.update(),r.bindPipelineState(_),r.bindDescriptorSet(Cg.MATERIAL,u.descriptorSet),r.bindDescriptorSet(Cg.LOCAL,this._stageDesc),r.bindInputAssembler(c),r.draw(c)),this._uiPhase.render(t,h),CT(i,h,r,e.profiler,t),r.endRenderPass()},e}(RI)).initInfo={name:"PostProcessStage",priority:FI.POST_PROCESS,tag:0},eP=ks((tP=nP).prototype,"_postProcessMaterial",[QD,io],(function(){return null})),iP=ks(tP.prototype,"renderQueues",[ZD,io],(function(){return[]})),$D=tP))||$D)),fP=function(){function t(){this._enabled=!1,this._minPos=new on(0,0,0),this._maxPos=new on(0,0,0),this._depth=0}return t.prototype.initialize=function(t){this._enabled=t.enabled,this._minPos=t.minPos,this._maxPos=t.maxPos,this._depth=t.depth},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"minPos",get:function(){return this._minPos},set:function(t){this._minPos=t}},{key:"maxPos",get:function(){return this._maxPos},set:function(t){this._maxPos=t}},{key:"depth",get:function(){return this._depth},set:function(t){this._depth=t}}]),t}(),pP=new In,mP=new In,gP=new In,yP=new In,vP=new In,SP=new In,TP=new In,AP=new on(0,0,0),bP=new on,EP=new Ln,CP=new on,wP=new on,xP=new on(1e7,1e7,1e7),RP=new on(-1e7,-1e7,-1e7),IP=new on,BP=0,DP=0,PP=function(){function t(t){this._shadowObjects=[],this._shadowCameraFar=0,this._level=void 0,this._matShadowView=new In,this._matShadowProj=new In,this._matShadowViewProj=new In,this._validFrustum=new xs,this._splitFrustum=new xs,this._lightViewFrustum=new xs,this._castLightViewBoundingBox=new Ss,this._level=t,this._validFrustum.accurate=!0,this._splitFrustum.accurate=!0,this._lightViewFrustum.accurate=!0}var e=t.prototype;return e.copyToValidFrustum=function(t){xs.copy(this._validFrustum,t)},e.calculateValidFrustumOrtho=function(t,e,i,n,r){xs.createOrtho(this._validFrustum,t,e,i,n,r)},e.calculateSplitFrustum=function(t,e,i,n){this._splitFrustum.split(i,n,t.aspect,t.fov,e)},e.destroy=function(){this._shadowObjects.length=0},e.createMatrix=function(t,e,i){var n=v.director.root.device,r=t.shadowInvisibleOcclusionRange;xs.copy(this._lightViewFrustum,this._splitFrustum),In.fromRT(mP,t.node.rotation,AP),In.invert(gP,mP);var s,o,a=gP.clone();this._lightViewFrustum.transform(gP),Ss.fromPoints(this._castLightViewBoundingBox,xP,RP),this._castLightViewBoundingBox.mergeFrustum(this._lightViewFrustum),t.csmOptimizationMode===PT.DisableRotationFix?(s=2*this._castLightViewBoundingBox.halfExtents.x,o=2*this._castLightViewBoundingBox.halfExtents.y):s=o=on.distance(this._lightViewFrustum.vertices[0],this._lightViewFrustum.vertices[6]);var h=v.director.root.pipeline.pipelineSceneData.csmSupported?t.csmLevel:1;if(h>1&&t.csmOptimizationMode===PT.RemoveDuplicates)if(this._level>=h-1)DP=this._castLightViewBoundingBox.halfExtents.z,BP=this._castLightViewBoundingBox.center.z;else{var u=Math.abs(this._castLightViewBoundingBox.center.z-BP)+DP;this._castLightViewBoundingBox.halfExtents.z=Math.max(this._castLightViewBoundingBox.center.z,u)}var l=this._castLightViewBoundingBox.halfExtents.z;this._shadowCameraFar=2*l+r;var c=this._castLightViewBoundingBox.center;if(IP.set(c.x,c.y,c.z+l+r),on.transformMat4(IP,IP,mP),In.fromRT(mP,t.node.rotation,IP),In.invert(gP,mP),!i){var _=.5*s,d=.5*o;In.ortho(yP,-_,_,-d,d,.1,this._shadowCameraFar,n.capabilities.clipSpaceMinZ,n.capabilities.clipSpaceSignY),In.multiply(SP,yP,a),on.transformMat4(bP,IP,SP);var f=2/e;EP.set(f,f);var p=bP.x%EP.x,m=bP.y%EP.y;CP.set(bP.x-p,bP.y-m,bP.z),In.invert(TP,SP),on.transformMat4(wP,CP,TP),In.fromRT(mP,t.node.rotation,wP),In.invert(gP,mP),In.multiply(vP,yP,gP),In.copy(this._matShadowView,gP),In.copy(this._matShadowProj,yP),In.copy(this._matShadowViewProj,vP)}xs.createOrtho(this._validFrustum,s,o,.1,this._shadowCameraFar,mP)},n(t,[{key:"level",get:function(){return this._level}},{key:"shadowObjects",get:function(){return this._shadowObjects}},{key:"shadowCameraFar",get:function(){return this._shadowCameraFar},set:function(t){this._shadowCameraFar=t}},{key:"matShadowView",get:function(){return this._matShadowView},set:function(t){this._matShadowView=t}},{key:"matShadowProj",get:function(){return this._matShadowProj},set:function(t){this._matShadowProj=t}},{key:"matShadowViewProj",get:function(){return this._matShadowViewProj},set:function(t){this._matShadowViewProj=t}},{key:"validFrustum",get:function(){return this._validFrustum}},{key:"splitFrustum",get:function(){return this._splitFrustum}},{key:"lightViewFrustum",get:function(){return this._lightViewFrustum}},{key:"castLightViewBoundingBox",get:function(){return this._castLightViewBoundingBox}}]),t}(),OP=function(t){function e(e){var i;return(i=t.call(this,e)||this)._splitCameraNear=0,i._splitCameraFar=0,i._csmAtlas=new tn,i._calculateAtlas(e),i}s(e,t);var i=e.prototype;return i.destroy=function(){t.prototype.destroy.call(this)},i._calculateAtlas=function(t){var e=v.director.root.device.capabilities.clipSpaceSignY,i=t%2-.5,n=(.5-Math.floor(t/2))*e;this._csmAtlas.set(.5,.5,i,n)},n(e,[{key:"splitCameraNear",get:function(){return this._splitCameraNear},set:function(t){this._splitCameraNear=t}},{key:"splitCameraFar",get:function(){return this._splitCameraFar},set:function(t){this._splitCameraFar=t}},{key:"csmAtlas",get:function(){return this._csmAtlas},set:function(t){this._csmAtlas=t}}]),e}(PP),MP=function(){function t(){this._castShadowObjects=[],this._layerObjects=new Pu(64),this._layers=[],this._levelCount=0,this._specialLayer=new PP(1),this._shadowDistance=0;for(var t=0;t<DT.LEVEL_4;t++)this._layers[t]=new OP(t)}var e=t.prototype;return e.update=function(t,e){var i=e.scene.mainLight;if(null!==i){var n=t.shadows,r=v.director.root.pipeline.pipelineSceneData.csmSupported?i.csmLevel:1,s=i.shadowDistance;n.enabled&&i.shadowEnabled&&(i.shadowFixedArea?this._updateFixedArea(i):((i.csmNeedUpdate||this._levelCount!==r||this._shadowDistance!==s)&&(this._splitFrustumLevels(i),this._levelCount=r,this._shadowDistance=s),this._calculateCSM(e,i,n)))}},e.destroy=function(){this._castShadowObjects.length=0;for(var t=0;t<this._layers.length;t++)this._layers[t].destroy();this._layers.length=0},e._updateFixedArea=function(t){var e=v.director.root.device,i=t.shadowOrthoSize,n=t.shadowOrthoSize,r=t.shadowNear,s=t.shadowFar;In.fromRT(mP,t.node.getWorldRotation(),t.node.getWorldPosition()),In.invert(gP,mP),In.ortho(yP,-i,i,-n,n,r,s,e.capabilities.clipSpaceMinZ,e.capabilities.clipSpaceSignY),In.multiply(vP,yP,gP),this._specialLayer.matShadowView=gP,this._specialLayer.matShadowProj=yP,this._specialLayer.matShadowViewProj=vP,this._specialLayer.calculateValidFrustumOrtho(2*i,2*n,r,s,mP)},e._splitFrustumLevels=function(t){var e=.1,i=t.shadowDistance,n=i/e,r=v.director.root.pipeline.pipelineSceneData.csmSupported?t.csmLevel:1,s=t.csmLayerLambda;this._layers[0].splitCameraNear=e;for(var o=1;o<r;o++){var a=o/r,h=s*e*Math.pow(n,a)+(1-s)*(e+(i-e)*a),u=1.005*h;this._layers[o].splitCameraNear=h,this._layers[o-1].splitCameraFar=u}this._layers[r-1].splitCameraFar=i,t.csmNeedUpdate=!1},e._calculateCSM=function(t,e,i){var n=v.director.root.pipeline.pipelineSceneData.csmSupported?e.csmLevel:1,r=n>1?.5*i.size.x:i.size.x;if(!(r<0)){this._getCameraWorldMatrix(pP,t);for(var s=n-1;s>=0;s--){var o=this._layers[s],a=o.splitCameraNear,h=o.splitCameraFar;o.calculateSplitFrustum(t,pP,a,h),o.createMatrix(e,r,!1)}n===DT.LEVEL_1?(this._specialLayer.shadowCameraFar=this._layers[0].shadowCameraFar,In.copy(this._specialLayer.matShadowView,this._layers[0].matShadowView),In.copy(this._specialLayer.matShadowProj,this._layers[0].matShadowProj),In.copy(this._specialLayer.matShadowViewProj,this._layers[0].matShadowViewProj),this._specialLayer.copyToValidFrustum(this._layers[0].validFrustum)):(this._specialLayer.calculateSplitFrustum(t,pP,.1,e.shadowDistance),this._specialLayer.createMatrix(e,r,!0))}},e._getCameraWorldMatrix=function(t,e){if(e.node){var i=e.node,n=i.getWorldPosition(),r=i.getWorldRotation();In.fromRT(t,r,n)}},n(t,[{key:"castShadowObjects",get:function(){return this._castShadowObjects}},{key:"layerObjects",get:function(){return this._layerObjects}},{key:"layers",get:function(){return this._layers}},{key:"specialLayer",get:function(){return this._specialLayer}}]),t}(),LP=function(){function t(){this._enabled=!0,this._blurRadius=.01,this._sssIntensity=3}return t.prototype.initialize=function(t){this._enabled=t.enabled,this._blurRadius=t.blurRadius,this._sssIntensity=t.sssIntensity},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"blurRadius",get:function(){return this._blurRadius},set:function(t){this._blurRadius=t}},{key:"sssIntensity",get:function(){return this._sssIntensity},set:function(t){this._sssIntensity=t}}]),t}(),NP=t("db",function(){function t(){this.fog=new WT,this.ambient=new dg,this.skybox=new GT,this.shadows=new MT,this.csmLayers=new MP,this.octree=new fP,this.skin=new LP,this.postSettings=new fE,this.lightProbes=v.internal.LightProbes?new v.internal.LightProbes:null,this.validPunctualLights=[],this.renderObjects=[],this.shadowFrameBufferMap=new Map,this._geometryRendererMaterials=[],this._geometryRendererPasses=[],this._geometryRendererShaders=[],this._occlusionQueryVertexBuffer=null,this._occlusionQueryIndicesBuffer=null,this._occlusionQueryInputAssembler=null,this._occlusionQueryMaterial=null,this._occlusionQueryShader=null,this._isHDR=!0,this._shadingScale=1,this._csmSupported=!0,this._standardSkinMeshRenderer=null,this._standardSkinModel=null,this._skinMaterialModel=null,this._shadingScale=1}var e=t.prototype;return e.activate=function(t){return this._device=t,this.initGeometryRendererMaterials(),this.initOcclusionQuery(),!0},e.initGeometryRendererMaterials=function(){for(var t=0,e=0;e<6;e++){this._geometryRendererMaterials[e]=new xT,this._geometryRendererMaterials[e]._uuid="geometry-renderer-material-"+e,this._geometryRendererMaterials[e].initialize({effectName:"internal/builtin-geometry-renderer",technique:e});for(var i=0;i<this._geometryRendererMaterials[e].passes.length;++i)this._geometryRendererPasses[t]=this._geometryRendererMaterials[e].passes[i],this._geometryRendererShaders[t]=this._geometryRendererMaterials[e].passes[i].getShaderVariant(),t++}},e.initOcclusionQuery=function(){if(this._occlusionQueryInputAssembler||(this._occlusionQueryInputAssembler=this._createOcclusionQueryIA()),!this._occlusionQueryMaterial){var t=new xT;t._uuid="default-occlusion-query-material",t.initialize({effectName:"internal/builtin-occlusion-query"}),this._occlusionQueryMaterial=t,t.passes.length>0&&(this._occlusionQueryShader=t.passes[0].getShaderVariant())}},e.getOcclusionQueryPass=function(){return this._occlusionQueryMaterial&&this._occlusionQueryMaterial.passes.length>0?this._occlusionQueryMaterial.passes[0]:null},e.updatePipelineSceneData=function(){},e.destroy=function(){var t,e,i;this.shadows.destroy(),this.csmLayers.destroy(),this.validPunctualLights.length=0,null===(t=this._occlusionQueryInputAssembler)||void 0===t||t.destroy(),this._occlusionQueryInputAssembler=null,null===(e=this._occlusionQueryVertexBuffer)||void 0===e||e.destroy(),this._occlusionQueryVertexBuffer=null,null===(i=this._occlusionQueryIndicesBuffer)||void 0===i||i.destroy(),this._occlusionQueryIndicesBuffer=null,this._standardSkinMeshRenderer=null,this._standardSkinModel=null,this._skinMaterialModel=null},e._createOcclusionQueryIA=function(){var t=this._device,e=new Float32Array([-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,1,1,1,1,1]),i=3*Float32Array.BYTES_PER_ELEMENT,n=8*i;this._occlusionQueryVertexBuffer=t.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,n,i)),this._occlusionQueryVertexBuffer.update(e);var r=new Uint16Array([0,2,1,1,2,3,4,5,6,5,7,6,1,3,7,1,7,5,0,4,6,0,6,2,0,1,5,0,5,4,2,6,7,2,7,3]),s=Uint16Array.BYTES_PER_ELEMENT,o=36*s;this._occlusionQueryIndicesBuffer=t.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,o,s)),this._occlusionQueryIndicesBuffer.update(r);var a=[new u_("a_position",Hl.RGB32F)],h=new c_(a,[this._occlusionQueryVertexBuffer],this._occlusionQueryIndicesBuffer);return t.createInputAssembler(h)},n(t,[{key:"isHDR",get:function(){return this._isHDR},set:function(t){this._isHDR=t}},{key:"shadingScale",get:function(){return this._shadingScale},set:function(t){this._shadingScale=t}},{key:"csmSupported",get:function(){return this._csmSupported},set:function(t){this._csmSupported=t}},{key:"standardSkinModel",get:function(){return this._standardSkinModel},set:function(t){this._standardSkinModel=t}},{key:"standardSkinMeshRenderer",get:function(){return this._standardSkinMeshRenderer},set:function(t){this._standardSkinMeshRenderer&&this._standardSkinMeshRenderer!==t&&this._standardSkinMeshRenderer.clearGlobalStandardSkinObjectFlag(),this._standardSkinMeshRenderer=t,this.standardSkinModel=t?t.model:null}},{key:"skinMaterialModel",get:function(){return this._skinMaterialModel},set:function(t){this._skinMaterialModel=t}},{key:"geometryRendererPasses",get:function(){return this._geometryRendererPasses}},{key:"geometryRendererShaders",get:function(){return this._geometryRendererShaders}}]),t}());!function(t){t[t.NONE=0]="NONE",t[t.FXAA=1]="FXAA"}(rP||(rP={}));var FP,kP,VP,GP,UP,zP,HP,WP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._antiAliasing=rP.NONE,e}s(e,t);var i=e.prototype;return i.updatePipelineSceneData=function(){this.updatePipelinePassInfo()},i.updateBloomPass=function(){if(this._bloomMaterial){var t=this._bloomMaterial.passes[0];t.beginChangeStatesSilently(),t.tryCompile(),t.endChangeStatesSilently();for(var e=0;e<6;++e){var i=this._bloomMaterial.passes[1+e];i.beginChangeStatesSilently(),i.tryCompile(),i.endChangeStatesSilently();var n=this._bloomMaterial.passes[7+e];n.beginChangeStatesSilently(),n.tryCompile(),n.endChangeStatesSilently()}var r=this._bloomMaterial.passes[13];r.beginChangeStatesSilently(),r.tryCompile(),r.endChangeStatesSilently()}},i.updatePostProcessPass=function(){if(this.postprocessMaterial){var t=this.postprocessMaterial.passes[0];t.beginChangeStatesSilently(),t.tryCompile(),t.endChangeStatesSilently()}},i.initPipelinePassInfo=function(){var t=new xT;t._uuid="builtin-deferred-material",t.initialize({effectName:"pipeline/deferred-lighting"});for(var e=0;e<t.passes.length;++e)t.passes[e].tryCompile();this._deferredLightingMaterial=t;var i=new xT;i._uuid="builtin-bloom-material",i.initialize({effectName:"pipeline/bloom"});for(var n=0;n<i.passes.length;++n)i.passes[n].tryCompile();this._bloomMaterial=i;var r=new xT;r._uuid="builtin-post-process-material",r.initialize({effectName:"pipeline/post-process",defines:{ANTIALIAS_TYPE:this._antiAliasing}});for(var s=0;s<r.passes.length;++s)r.passes[s].tryCompile();this._postprocessMaterial=r,this.updatePipelinePassInfo()},i.updatePipelinePassInfo=function(){this.updateBloomPass(),this.updatePostProcessPass(),this.updateDeferredPassInfo()},i.activate=function(e){return t.prototype.activate.call(this,e),this.initPipelinePassInfo(),!0},i.updateDeferredPassInfo=function(){this.updateDeferredLightPass()},i.updateDeferredLightPass=function(){if(this._deferredLightingMaterial){v.director.root.pipeline.macros.CC_RECEIVE_SHADOW=1;var t=this._deferredLightingMaterial.passes[0];t.beginChangeStatesSilently(),t.tryCompile(),t.endChangeStatesSilently()}},n(e,[{key:"antiAliasing",get:function(){return this._antiAliasing},set:function(t){if(this._antiAliasing=t,this._postprocessMaterial){var e=this._postprocessMaterial.passes[0].defines;Object.assign(e,{ANTIALIAS_TYPE:t});var i=new xT;i.initialize({effectAsset:this._postprocessMaterial.effectAsset,defines:e});for(var n=0;n<i.passes.length;++n)i.passes[n].tryCompile();this._postprocessMaterial=i}}},{key:"bloomMaterial",get:function(){return this._bloomMaterial},set:function(t){this._bloomMaterial!==t&&t&&(this._bloomMaterial=t,this.updatePipelinePassInfo())}},{key:"postprocessMaterial",get:function(){return this._postprocessMaterial},set:function(t){this._postprocessMaterial!==t&&t&&(this._postprocessMaterial=t,this.updatePipelinePassInfo())}},{key:"deferredLightingMaterial",get:function(){return this._deferredLightingMaterial},set:function(t){this._deferredLightingMaterial!==t&&t&&(this._deferredLightingMaterial=t,this.updatePipelinePassInfo())}}]),e}(NP),jP=[new zc(0,0,0,1)],XP=function(){};FP=XP,XP.TEXTURE_SIZE_OFFSET=0,XP.COUNT=FP.TEXTURE_SIZE_OFFSET+4,XP.SIZE=4*FP.COUNT;var qP,YP,KP=t("dk",(kP=qs("BloomStage"),VP=xo(xT),kP(((HP=function(t){function e(){var e;return(e=t.call(this)||this).threshold=1,e.intensity=.8,e.iterations=2,e._bloomMaterial=zP&&zP(),e._renderArea=new Mc,e._bloomUBO=[],e}s(e,t);var i=e.prototype;return i.initialize=function(e){return t.prototype.initialize.call(this,e),!0},i.activate=function(e,i){t.prototype.activate.call(this,e,i),this._bloomMaterial&&(e.pipelineSceneData.bloomMaterial=this._bloomMaterial)},i.destroy=function(){},i.render=function(t){var e,i=this._pipeline;if(i.generateBloomRenderData(),(null!==(e=t.window)&&void 0!==e&&e.swapchain||i.macros.CC_PIPELINE_TYPE)&&i.bloomEnabled&&0!==i.pipelineSceneData.renderObjects.length){if(0===this._bloomUBO.length)for(var n=0;n<14;++n)this._bloomUBO[n]=i.device.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,XP.SIZE,XP.SIZE));t.clearFlag&Cc.COLOR&&(jP[0].x=t.clearColor.x,jP[0].y=t.clearColor.y,jP[0].z=t.clearColor.z),jP[0].w=t.clearColor.w,this._prefilterPass(t,i),this._downsamplePass(t,i),this._upsamplePass(t,i),this._combinePass(t,i)}},i._prefilterPass=function(t,e){e.generateRenderArea(t,this._renderArea),this._renderArea.width>>=1,this._renderArea.height>>=1;var i=e.commandBuffers[0],n=e.pipelineSceneData.bloomMaterial.passes[0],r=e.getPipelineRenderData(),s=r.bloom,o=new Float32Array(XP.COUNT);o[XP.TEXTURE_SIZE_OFFSET+2]=this.threshold,i.updateBuffer(this._bloomUBO[0],o),i.beginRenderPass(s.renderPass,s.prefilterFramebuffer,this._renderArea,jP,0,0),i.bindDescriptorSet(Cg.GLOBAL,e.descriptorSet),n.descriptorSet.bindBuffer(0,this._bloomUBO[0]),n.descriptorSet.bindTexture(1,r.outputRenderTargets[0]),n.descriptorSet.bindSampler(1,s.sampler),n.descriptorSet.update(),i.bindDescriptorSet(Cg.MATERIAL,n.descriptorSet);var a=t.window.swapchain?e.quadIAOffscreen:e.quadIAOnscreen,h=null,u=n.getShaderVariant();null!=n&&null!=u&&null!=a&&(h=lT.getOrCreatePipelineState(e.device,n,u,s.renderPass,a)),null!=h&&(i.bindPipelineState(h),i.bindInputAssembler(a),i.draw(a)),i.endRenderPass()},i._downsamplePass=function(t,e){e.generateRenderArea(t,this._renderArea),this._renderArea.width>>=1,this._renderArea.height>>=1;for(var i=e.commandBuffers[0],n=e.pipelineSceneData.bloomMaterial,r=e.getPipelineRenderData().bloom,s=new Float32Array(XP.COUNT),o=0;o<this.iterations;++o){s[XP.TEXTURE_SIZE_OFFSET+0]=this._renderArea.width,s[XP.TEXTURE_SIZE_OFFSET+1]=this._renderArea.height,i.updateBuffer(this._bloomUBO[o+1],s),this._renderArea.width>>=1,this._renderArea.height>>=1,i.beginRenderPass(r.renderPass,r.downsampleFramebuffers[o],this._renderArea,jP,0,0);var a=n.passes[1+o],h=a.getShaderVariant();a.descriptorSet.bindBuffer(0,this._bloomUBO[o+1]),0===o?a.descriptorSet.bindTexture(1,r.prefiterTex):a.descriptorSet.bindTexture(1,r.downsampleTexs[o-1]),a.descriptorSet.bindSampler(1,r.sampler),a.descriptorSet.update(),i.bindDescriptorSet(Cg.MATERIAL,a.descriptorSet);var u=t.window.swapchain?e.quadIAOffscreen:e.quadIAOnscreen,l=null;null!=a&&null!=h&&null!=u&&(l=lT.getOrCreatePipelineState(e.device,a,h,r.renderPass,u)),null!=l&&(i.bindPipelineState(l),i.bindInputAssembler(u),i.draw(u)),i.endRenderPass()}},i._upsamplePass=function(t,e){var i=e.getPipelineRenderData().bloom;e.generateRenderArea(t,this._renderArea),this._renderArea.width>>=this.iterations+1,this._renderArea.height>>=this.iterations+1;for(var n=e.commandBuffers[0],r=e.pipelineSceneData.bloomMaterial,s=new Float32Array(XP.COUNT),o=0;o<this.iterations;++o){var a=o+6+1;s[XP.TEXTURE_SIZE_OFFSET+0]=this._renderArea.width,s[XP.TEXTURE_SIZE_OFFSET+1]=this._renderArea.height,n.updateBuffer(this._bloomUBO[a],s),this._renderArea.width<<=1,this._renderArea.height<<=1,n.beginRenderPass(i.renderPass,i.upsampleFramebuffers[this.iterations-1-o],this._renderArea,jP,0,0);var h=r.passes[7+o],u=h.getShaderVariant();h.descriptorSet.bindBuffer(0,this._bloomUBO[a]),0===o?h.descriptorSet.bindTexture(1,i.downsampleTexs[this.iterations-1]):h.descriptorSet.bindTexture(1,i.upsampleTexs[this.iterations-o]),h.descriptorSet.bindSampler(1,i.sampler),h.descriptorSet.update(),n.bindDescriptorSet(Cg.MATERIAL,h.descriptorSet);var l=t.window.swapchain?e.quadIAOffscreen:e.quadIAOnscreen,c=null;null!=h&&null!=u&&null!=l&&(c=lT.getOrCreatePipelineState(e.device,h,u,i.renderPass,l)),null!=c&&(n.bindPipelineState(c),n.bindInputAssembler(l),n.draw(l)),n.endRenderPass()}},i._combinePass=function(t,e){e.generateRenderArea(t,this._renderArea);var i=e.commandBuffers[0],n=e.pipelineSceneData.bloomMaterial,r=e.getPipelineRenderData(),s=r.bloom,o=new Float32Array(XP.COUNT);o[XP.TEXTURE_SIZE_OFFSET+3]=this.intensity,i.updateBuffer(this._bloomUBO[13],o),i.beginRenderPass(s.renderPass,s.combineFramebuffer,this._renderArea,jP,0,0),i.bindDescriptorSet(Cg.GLOBAL,e.descriptorSet);var a=n.passes[13];a.descriptorSet.bindBuffer(0,this._bloomUBO[13]),a.descriptorSet.bindTexture(1,r.outputRenderTargets[0]),a.descriptorSet.bindTexture(2,s.upsampleTexs[0]),a.descriptorSet.bindSampler(1,s.sampler),a.descriptorSet.bindSampler(2,s.sampler),a.descriptorSet.update(),i.bindDescriptorSet(Cg.MATERIAL,a.descriptorSet);var h=t.window.swapchain?e.quadIAOffscreen:e.quadIAOnscreen,u=null,l=a.getShaderVariant();null!=a&&null!=l&&null!=h&&(u=lT.getOrCreatePipelineState(e.device,a,l,s.renderPass,h)),null!=u&&(i.bindPipelineState(u),i.bindInputAssembler(h),i.draw(h)),i.endRenderPass()},e}(RI)).initInfo={name:"BloomStage",priority:FI.BLOOM,tag:0},zP=ks((UP=HP).prototype,"_bloomMaterial",[VP,io],(function(){return null})),GP=UP))||GP)),JP=t("dh",qs("MainFlow")(((YP=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.initialize=function(e){if(t.prototype.initialize.call(this,e),0===this._stages.length){var i=new kD;i.initialize(kD.initInfo),this._stages.push(i);var n=new cP;n.initialize(cP.initInfo),this._stages.push(n);var r=new KP;r.initialize(KP.initInfo),this._stages.push(r);var s=new dP;s.initialize(dP.initInfo),this._stages.push(s)}return!0},i.activate=function(e){t.prototype.activate.call(this,e)},i.render=function(e){t.prototype.render.call(this,e)},i.destroy=function(){t.prototype.destroy.call(this)},e}(BI)).initInfo={name:mg,priority:UI.MAIN,stages:[]},qP=YP))||qP),QP=rT("shadow-caster");function ZP(t){var e=t.passes,i=v.rendering;tv()&&(QP=i.getPhaseID(i.getPassID("default"),"shadow-caster"));for(var n=0;n<e.length;n++)if((!i||!i.enableEffectImport)&&e[n].phase===QP||tv()&&e[n].phaseID===QP)return n;return-1}var $P,tO,eO,iO,nO,rO,sO,oO,aO,hO=function(){function t(t){this._pipeline=void 0,this._subModelsArray=[],this._passArray=[],this._shaderArray=[],this._instancedQueue=void 0,this._pipeline=t,this._instancedQueue=new ND}var e=t.prototype;return e.gatherLightPasses=function(t,e,i,n){void 0===n&&(n=0),this.clear();var r=this._pipeline.pipelineSceneData,s=r.shadows;if(e&&s.enabled&&s.type===IT.ShadowMap){switch(e.type){case sR.DIRECTIONAL:var o=e;if(o.shadowEnabled){var a,h=r.csmLayers;!function(t,e,i){var n=t.scene.mainLight,r=e.csmLayers.layerObjects,s=i.validFrustum,o=i.shadowObjects;o.length=0;for(var a=t.visibility,h=r.length-1;h>=0;h--){var u=r.array[h];if(u){var l=u.model;l&&l.enabled&&l.node&&((a&l.node.layer)===l.node.layer||a&l.visFlags)&&l.worldBounds&&l.castShadow?as.aabbFrustum(l.worldBounds,s)&&(o.push(u),i.level<n.csmLevel&&n.csmOptimizationMode===PT.RemoveDuplicates&&as.aabbFrustumCompletelyInside(l.worldBounds,s)&&r.fastRemove(h)):r.fastRemove(h)}else r.fastRemove(h)}}(t,r,a=o.shadowFixedArea?h.specialLayer:h.layers[n]);for(var u=a.shadowObjects,l=0;l<u.length;l++){var c=u[l].model;this.add(c,n)}}break;case sR.SPOT:var _=e;if(_.shadowEnabled)for(var d=_.visibility,f=r.csmLayers.castShadowObjects,p=0;p<f.length;p++){var m=f[p].model;(!m.worldBounds||(d&m.node.layer)===m.node.layer&&as.aabbFrustum(m.worldBounds,_.frustum))&&this.add(m,n)}}this._instancedQueue.uploadBuffers(i)}},e.clear=function(){this._subModelsArray.length=0,this._shaderArray.length=0,this._passArray.length=0,this._instancedQueue.clear()},e.add=function(t,e){for(var i=t.subModels,n=0;n<i.length;n++){var r=i[n],s=ZP(r);if(!(s<0)){var o=r.passes[s];if(o.batchingScheme===eT.INSTANCING){var a=o.getInstancedBuffer(e);a.merge(r,s),this._instancedQueue.queue.add(a)}else{var h=r.shaders[s];this._subModelsArray.push(r),h&&this._shaderArray.push(h),this._passArray.push(o)}}}},e.recordCommandBuffer=function(t,e,i){this._instancedQueue.recordCommandBuffer(t,e,i);for(var n=0;n<this._subModelsArray.length;++n){var r=this._subModelsArray[n],s=this._shaderArray[n],o=this._passArray[n],a=r.inputAssembler,h=lT.getOrCreatePipelineState(t,o,s,e,a),u=o.descriptorSet;i.bindPipelineState(h),i.bindDescriptorSet(Cg.MATERIAL,u),i.bindDescriptorSet(Cg.LOCAL,r.descriptorSet),i.bindInputAssembler(a),i.draw(a)}},t}(),uO=[new zc(1,1,1,1)],lO=t("dn",qs("ShadowStage")(((tO=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._additiveShadowQueue=void 0,e._shadowFrameBuffer=null,e._renderArea=new Mc,e._light=null,e._globalDS=null,e._level=0,e._isShadowMapCleared=!1,e}s(e,t);var i=e.prototype;return i.setUsage=function(t,e,i,n){void 0===n&&(n=0),this._globalDS=t,this._light=e,this._shadowFrameBuffer=i,this._level=n},i.destroy=function(){var t;this._shadowFrameBuffer=null,this._globalDS=null,this._light=null,null===(t=this._additiveShadowQueue)||void 0===t||t.clear()},i.clearFramebuffer=function(t){if(this._light&&this._shadowFrameBuffer&&!this._isShadowMapCleared){uO[0].w=t.clearColor.w;var e=this._pipeline,i=e.pipelineSceneData,n=i.shadingScale,r=i.shadows,s=t.viewport,o=r.size;this._renderArea.x=s.x*o.x,this._renderArea.y=s.y*o.y,this._renderArea.width=s.width*o.x*n,this._renderArea.height=s.height*o.y*n;var a=e.commandBuffers[0],h=this._shadowFrameBuffer.renderPass;a.beginRenderPass(h,this._shadowFrameBuffer,this._renderArea,uO,t.clearDepth,t.clearStencil),a.endRenderPass(),this._isShadowMapCleared=!0}},i.render=function(t){var e=this._pipeline,i=e.pipelineSceneData,n=i.shadows,r=this._globalDS,s=e.commandBuffers[0],o=this._level,a=e.device;if(this._light&&this._shadowFrameBuffer){this._pipeline.pipelineUBO.updateShadowUBOLight(r,this._light,o),this._additiveShadowQueue.gatherLightPasses(t,this._light,s,o);var h=n.size;switch(this._light.type){case sR.DIRECTIONAL:var u=this._light;if(u.shadowFixedArea||u.csmLevel===DT.LEVEL_1||!i.csmSupported)this._renderArea.x=0,this._renderArea.y=0,this._renderArea.width=h.x,this._renderArea.height=h.y;else{var l=a.capabilities.screenSpaceSignY;this._renderArea.x=o%2*.5*h.x,this._renderArea.y=l>0?.5*(1-Math.floor(o/2))*h.y:.5*Math.floor(o/2)*h.y,this._renderArea.width=.5*h.x,this._renderArea.height=.5*h.y}break;case sR.SPOT:this._renderArea.x=0,this._renderArea.y=0,this._renderArea.width=h.x,this._renderArea.height=h.y}var c=this._shadowFrameBuffer.renderPass;s.beginRenderPass(c,this._shadowFrameBuffer,this._renderArea,uO,t.clearDepth,t.clearStencil),s.bindDescriptorSet(Cg.GLOBAL,r),this._additiveShadowQueue.recordCommandBuffer(a,c,s),s.endRenderPass(),this._isShadowMapCleared=!1}},i.activate=function(e,i){t.prototype.activate.call(this,e,i),this._additiveShadowQueue=new hO(e),this._isShadowMapCleared=!1},e}(RI)).initInfo={name:"ShadowStage",priority:kI.FORWARD,tag:0},$P=tO))||$P),cO=[],_O=t("dm",qs("ShadowFlow")(((iO=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._shadowRenderPass=null,e}s(e,t);var i=e.prototype;return i.initialize=function(e){if(t.prototype.initialize.call(this,e),0===this._stages.length){var i=new lO;i.initialize(lO.initInfo),this._stages.push(i)}return!0},i.activate=function(e){t.prototype.activate.call(this,e);var i=Zy(e.device)?0:1;e.macros.CC_SHADOWMAP_FORMAT=i;var n=e.device.gfxAPI===Gl.WEBGL?1:0;e.macros.CC_SHADOWMAP_USE_LINEAR_DEPTH=n,e.pipelineSceneData.csmSupported=e.device.capabilities.maxFragmentUniformVectors>=(Bg.COUNT+Dg.COUNT+Pg.COUNT+Og.COUNT)/4,e.macros.CC_SUPPORT_CASCADED_SHADOW_MAP=e.pipelineSceneData.csmSupported,e.macros.CC_SHADOW_TYPE=0,e.macros.CC_DIR_SHADOW_PCF_TYPE=BT.HARD,e.macros.CC_DIR_LIGHT_SHADOW_TYPE=0,e.macros.CC_CASCADED_LAYERS_TRANSITION=0,e.onGlobalPipelineStateChanged()},i.render=function(t){var e=this._pipeline,i=e.pipelineSceneData.shadows,n=e.pipelineSceneData.csmLayers,r=e.pipelineSceneData.shadowFrameBufferMap,s=n.castShadowObjects,o=this._pipeline.pipelineSceneData.validPunctualLights;if(i.enabled&&i.type===IT.ShadowMap){for(var a=0,h=0;a<i.maxReceived&&h<o.length;){var u=o[h];u.type===sR.SPOT&&u.shadowEnabled&&(cO.push(u),a++),h++}if(0!==s.length){i.shadowMapDirty&&this.resizeShadowMap();var l=t.scene.mainLight;if(l&&l.shadowEnabled){var c=e.descriptorSet;r.has(l)||this._initShadowFrameBuffer(e,l,t.window.swapchain);var _=r.get(l);if(l.shadowFixedArea)this._renderStage(t,l,_,c);else for(var d=e.pipelineSceneData.csmSupported?l.csmLevel:1,f=0;f<d;f++)this._renderStage(t,l,_,c,f)}for(var p=0;p<cO.length;p++){var m=cO[p],g=e.globalDSManager.getOrCreateDescriptorSet(m);r.has(m)||this._initShadowFrameBuffer(e,m,t.window.swapchain);var y=r.get(m);this._renderStage(t,m,y,g)}cO.length=0}else this.clearShadowMap(cO,t)}},i.destroy=function(){if(t.prototype.destroy.call(this),this._pipeline){for(var e=this._pipeline.pipelineSceneData.shadowFrameBufferMap,i=Array.from(e.values()),n=0;n<i.length;n++){var r=i[n];if(r){for(var s=r.colorTextures,o=0;o<s.length;o++){var a=s[o];a&&a.destroy()}s.length=0;var h=r.depthStencilTexture;h&&h.destroy(),r.destroy()}}e.clear()}this._shadowRenderPass&&this._shadowRenderPass.destroy()},i._initShadowFrameBuffer=function(t,e){var i=t.device,n=t.pipelineSceneData.shadows.size,r=t.pipelineSceneData.shadowFrameBufferMap,s=Zy(i)?Hl.R32F:Hl.RGBA8;if(!this._shadowRenderPass){var o=new __;o.format=s,o.loadOp=lc.CLEAR,o.storeOp=cc.STORE,o.sampleCount=1;var a=new d_;a.format=Hl.DEPTH_STENCIL,a.depthLoadOp=lc.CLEAR,a.depthStoreOp=cc.DISCARD,a.stencilLoadOp=lc.CLEAR,a.stencilStoreOp=cc.DISCARD,a.sampleCount=1;var h=new m_([o],a);this._shadowRenderPass=i.createRenderPass(h)}var u=[];u.push(i.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,s,n.x,n.y)));var l=i.createTexture(new Qc(Jl.TEX2D,Ql.DEPTH_STENCIL_ATTACHMENT,Hl.DEPTH_STENCIL,n.x,n.y)),c=i.createFramebuffer(new S_(this._shadowRenderPass,u,l));r.set(e,c)},i._renderStage=function(t,e,i,n,r){void 0===r&&(r=0);for(var s=0;s<this._stages.length;s++){var o=this._stages[s];o.setUsage(n,e,i,r),o.render(t)}},i.clearShadowMap=function(t,e){var i=this._pipeline,n=i.pipelineSceneData,r=e.scene.mainLight;if(r){var s=this._pipeline.descriptorSet;n.shadowFrameBufferMap.has(r)||this._initShadowFrameBuffer(this._pipeline,r,e.window.swapchain);for(var o=n.shadowFrameBufferMap.get(r),a=0;a<this._stages.length;a++){var h=this._stages[a];h.setUsage(s,r,o),h.clearFramebuffer(e)}}for(var u=0;u<t.length;u++){var l=t[u],c=i.globalDSManager.getOrCreateDescriptorSet(l);n.shadowFrameBufferMap.has(l)||this._initShadowFrameBuffer(this._pipeline,l,e.window.swapchain);for(var _=n.shadowFrameBufferMap.get(l),d=0;d<this._stages.length;d++){var f=this._stages[d];f.setUsage(c,l,_),f.clearFramebuffer(e)}}},i.resizeShadowMap=function(){for(var t,e=this._pipeline.pipelineSceneData.shadows,i=e.size,n=this._pipeline,r=n.device,s=n.pipelineSceneData.shadowFrameBufferMap,o=Zy(r)?Hl.R32F:Hl.RGBA8,a=d(s.keys());!(t=a()).done;){var h=t.value,u=s.get(h);if(u){var l=[];l.push(n.device.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,o,i.x,i.y)));var c=u.depthStencilTexture;c&&c.resize(i.x,i.y);var _=u.renderPass;u.destroy();var f=r.createFramebuffer(new S_(_,l,c));s.set(h,f)}}e.shadowMapDirty=!1},e}(BI)).initInfo={name:yg,priority:VI.SHADOW,tag:_D.SCENE,stages:[]},eO=iO))||eO),dO=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).gbufferFrameBuffer=null,e.gbufferRenderTargets=[],e}return s(e,t),e}((function(){this.outputFrameBuffer=null,this.outputRenderTargets=[],this.outputDepth=null,this.sampler=null,this.bloom=null})),fO=t("dg",(nO=qs("DeferredPipeline"),rO=xo([vD]),nO((oO=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gbufferRenderPass=null,e._lightingRenderPass=null,e.renderTextures=aO&&aO(),e}s(e,t);var i=e.prototype;return i.initialize=function(e){if(t.prototype.initialize.call(this,e),0===this._flows.length){var i=new _O;i.initialize(_O.initInfo),this._flows.push(i);var n=new JP;n.initialize(JP.initInfo),this._flows.push(n)}return!0},i.activate=function(e){return this._macros={CC_PIPELINE_TYPE:1},this._pipelineSceneData=new WP,!(!t.prototype.activate.call(this,e)||!this._activeRenderer(e)&&(J(2402),1))},i.destroy=function(){this._destroyUBOs(),this._destroyQuadInputAssembler(),this._destroyDeferredData();for(var e=this._renderPasses.values(),i=e.next();!i.done;)i.value.destroy(),i=e.next();return this._commandBuffers.length=0,t.prototype.destroy.call(this)},i.onGlobalPipelineStateChanged=function(){this.pipelineSceneData.updatePipelineSceneData()},i.getPipelineRenderData=function(){return this._pipelineRenderData||this._generateDeferredRenderData(),this._pipelineRenderData},i._activeRenderer=function(t){var e=this.device;this._commandBuffers.push(e.commandBuffer);var i=this.globalDSManager.pointSampler;this._descriptorSet.bindSampler(Mg,i),this._descriptorSet.bindTexture(Mg,nT.get("default-texture").getGFXTexture()),this._descriptorSet.bindSampler(Hg,i),this._descriptorSet.bindTexture(Hg,nT.get("default-texture").getGFXTexture()),this._descriptorSet.update();var n=new gD;if(!(n=this._createQuadInputAssembler()).quadIB||!n.quadVB||!n.quadIA)return!1;this._quadIB=n.quadIB,this._quadVBOffscreen=n.quadVB,this._quadIAOffscreen=n.quadIA;var r=this._createQuadInputAssembler();if(!r.quadIB||!r.quadVB||!r.quadIA)return!1;if(this._quadVBOnscreen=r.quadVB,this._quadIAOnscreen=r.quadIA,!this._gbufferRenderPass){var s=new __;s.format=Hl.RGBA16F,s.loadOp=lc.CLEAR,s.storeOp=cc.STORE;var o=new __;o.format=Hl.RGBA16F,o.loadOp=lc.CLEAR,o.storeOp=cc.STORE;var a=new __;a.format=Hl.RGBA16F,a.loadOp=lc.CLEAR,a.storeOp=cc.STORE;var h=new d_;h.format=Hl.DEPTH_STENCIL,h.depthLoadOp=lc.CLEAR,h.depthStoreOp=cc.STORE,h.stencilLoadOp=lc.CLEAR,h.stencilStoreOp=cc.STORE;var u=new m_([s,o,a],h);this._gbufferRenderPass=e.createRenderPass(u)}if(!this._lightingRenderPass){var l=new __;l.format=Hl.RGBA8,l.loadOp=lc.CLEAR,l.storeOp=cc.STORE,l.barrier=e.getGeneralBarrier(new g_(_c.NONE,_c.COLOR_ATTACHMENT_WRITE));var c=new d_;c.format=Hl.DEPTH_STENCIL,c.depthLoadOp=lc.LOAD,c.depthStoreOp=cc.DISCARD,c.stencilLoadOp=lc.LOAD,c.stencilStoreOp=cc.DISCARD,l.barrier=e.getGeneralBarrier(new g_(_c.DEPTH_STENCIL_ATTACHMENT_WRITE,_c.DEPTH_STENCIL_ATTACHMENT_WRITE));var _=new m_([l],c);this._lightingRenderPass=e.createRenderPass(_)}return this._width=t.width,this._height=t.height,this._generateDeferredRenderData(),!0},i._destroyUBOs=function(){this._descriptorSet&&(this._descriptorSet.getBuffer(Bg.BINDING).destroy(),this._descriptorSet.getBuffer(Pg.BINDING).destroy(),this._descriptorSet.getBuffer(Dg.BINDING).destroy(),this._descriptorSet.getTexture(Mg).destroy(),this._descriptorSet.getTexture(Hg).destroy())},i._destroyDeferredData=function(){var t=this._pipelineRenderData;if(t){t.gbufferFrameBuffer&&t.gbufferFrameBuffer.destroy(),t.outputFrameBuffer&&t.outputFrameBuffer.destroy(),t.outputDepth&&t.outputDepth.destroy();for(var e=0;e<t.gbufferRenderTargets.length;e++)t.gbufferRenderTargets[e].destroy();t.gbufferRenderTargets.length=0;for(var i=0;i<t.outputRenderTargets.length;i++)t.outputRenderTargets[i].destroy();t.outputRenderTargets.length=0,this._destroyBloomData()}this._pipelineRenderData=null},i._ensureEnoughSize=function(t){for(var e=this._width,i=this._height,n=0;n<t.length;++n){var r=t[n].window;e=Math.max(r.width,e),i=Math.max(r.height,i)}e===this._width&&i===this._height||(this._width=e,this._height=i,this._destroyDeferredData(),this._generateDeferredRenderData())},i._generateDeferredRenderData=function(){for(var t=this,e=this.device,i=this._pipelineRenderData=new dO,n=this.pipelineSceneData,r=0;r<3;++r)i.gbufferRenderTargets.push(e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA16F,this._width*n.shadingScale,this._height*n.shadingScale)));i.outputDepth=e.createTexture(new Qc(Jl.TEX2D,Ql.DEPTH_STENCIL_ATTACHMENT|Ql.SAMPLED,Hl.DEPTH_STENCIL,this._width*n.shadingScale,this._height*n.shadingScale)),i.gbufferFrameBuffer=e.createFramebuffer(new S_(this._gbufferRenderPass,i.gbufferRenderTargets,i.outputDepth)),i.outputRenderTargets.push(e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA16F,this._width*n.shadingScale,this._height*n.shadingScale))),i.outputFrameBuffer=e.createFramebuffer(new S_(this._lightingRenderPass,i.outputRenderTargets,null)),i.sampler=this.globalDSManager.pointSampler,this.on(II.ATTACHMENT_SCALE_CAHNGED,(function(e){i.sampler=e<1?t.globalDSManager.pointSampler:t.globalDSManager.linearSampler,i.gbufferFrameBuffer=t.newFramebufferByRatio(i.gbufferFrameBuffer),i.gbufferFrameBuffer=t.newFramebufferByRatio(i.outputFrameBuffer)}))},e}(yD),aO=ks(oO.prototype,"renderTextures",[rO,io],(function(){return[]})),sO=oO))||sO)),pO=new Bu((function(){return{subModel:null,passIdx:-1,dynamicOffsets:[],lights:[]}}),16),mO=new on,gO=new Float32Array(4),yO=[],vO=[],SO=new In,TO=new In,AO=new Ss(0,0,0,.5,.5,.5),bO=new Ss;function EO(t,e){return!(!e.worldBounds||as.aabbWithAABB(e.worldBounds,t.aabb))}function CO(t,e){return!(!e.worldBounds||as.aabbWithAABB(e.worldBounds,t.aabb)&&as.aabbFrustum(e.worldBounds,t.frustum))}function wO(t,e){return!(!e.worldBounds||as.aabbWithAABB(e.worldBounds,t.aabb))}function xO(t,e){return Ss.transform(bO,AO,t.node.getWorldMatrix()),!(!e.worldBounds||as.aabbWithAABB(e.worldBounds,bO))}var RO="forward-add",IO=rT(RO),BO=[];function DO(t,e,i){void 0===i&&(i="default");var n=v.rendering;tv()&&(IO=n.getPhaseID(n.getPassID(i),RO)),e.length=0;for(var r=!1,s=0;s<t.length;s++){for(var o=t[s].passes,a=-1,h=0;h<o.length;h++)if((!n||!n.enableEffectImport)&&o[h].phase===IO||tv()&&o[h].phaseID===IO){a=h,r=!0;break}e.push(a)}return r}var PO,OO,MO,LO,NO,FO,kO,VO,GO=function(){function t(t){this._pipeline=void 0,this._device=void 0,this._lightPasses=[],this._instancedLightPassPool=pO.alloc(),this._shadowUBO=new Float32Array(Pg.COUNT),this._lightBufferCount=16,this._lightBufferStride=void 0,this._lightBufferElementCount=void 0,this._lightBuffer=void 0,this._firstLightBufferView=void 0,this._lightBufferData=void 0,this._instancedQueues=[],this._lightMeterScale=1e4,this._pipeline=t,this._device=t.device;var e=this._device.capabilities.uboOffsetAlignment;this._lightBufferStride=Math.ceil(Qg.SIZE/e)*e,this._lightBufferElementCount=this._lightBufferStride/Float32Array.BYTES_PER_ELEMENT,this._lightBuffer=this._device.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,this._lightBufferStride*this._lightBufferCount,this._lightBufferStride)),this._firstLightBufferView=this._device.createBuffer(new qc(this._lightBuffer,0,Qg.SIZE)),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount)}var e=t.prototype;return e.clear=function(){this._instancedQueues.forEach((function(t){t.clear()})),this._instancedQueues.length=0;for(var t=0;t<this._lightPasses.length;t++){var e=this._lightPasses[t];e.dynamicOffsets.length=0,e.lights.length=0}pO.freeArray(this._lightPasses),this._lightPasses.length=0,this._instancedLightPassPool.dynamicOffsets.length=0,this._instancedLightPassPool.lights.length=0},e.destroy=function(){for(var t=this._pipeline.globalDSManager.descriptorSetMap,e=t.keys,i=0;i<e.length;i++){var n=e[i],r=t.get(n);if(r){var s=tv()?qR("CCShadow"):Pg.BINDING;r.getBuffer(s).destroy(),r.getTexture(Mg).destroy(),r.getTexture(Hg).destroy(),r.destroy()}t.delete(n)}},e._bindForwardAddLight=function(t,e){void 0===e&&(e="default");for(var i=this._pipeline.pipelineSceneData.renderObjects,n=0;n<i.length;n++){var r=i[n].model,s=r.subModels;if(DO(s,BO,e)&&(vO.length=0,this._lightCulling(r,t),vO.length||!(t.length>0)))for(var o=0;o<s.length;o++){var a=BO[o];if(!(a<0)){var h=s[o],u=h.passes[a];h.passes[0].blendState.targets[0].blend||(tv()&&qR("CCForwardLight"),h.descriptorSet.bindBuffer(Qg.BINDING,this._firstLightBufferView),h.descriptorSet.update(),this._addRenderQueue(u,h,r,a))}}}},e.gatherLightPasses=function(t,e,i){void 0===i&&(i="default"),this.clear();var n=this._pipeline.pipelineSceneData.validPunctualLights;if(n.length){this._updateUBOs(t,e),this._updateLightDescriptorSet(t,e),this._bindForwardAddLight(n,i);for(var r=0;r<n.length;r++){var s=n[r];this._instancedLightPassPool.lights.push(s),this._instancedLightPassPool.dynamicOffsets.push(this._lightBufferStride*r)}this._instancedQueues.forEach((function(t){t.uploadBuffers(e)}))}else this._bindForwardAddLight(n,i)},e.recordCommandBuffer=function(t,e,i){for(var n=this._pipeline.globalDSManager,r=0;r<this._instancedQueues.length;++r){var s=this._instancedLightPassPool.lights[r];yO[0]=this._instancedLightPassPool.dynamicOffsets[r];var o=n.getOrCreateDescriptorSet(s);this._instancedQueues[r].recordCommandBuffer(t,e,i,o,yO)}for(var a=0;a<this._lightPasses.length;a++){var h=this._lightPasses[a],u=h.subModel,l=h.passIdx,c=h.dynamicOffsets,_=h.lights,d=u.passes[l],f=u.shaders[l],p=u.inputAssembler,m=lT.getOrCreatePipelineState(t,d,f,e,p),g=d.descriptorSet,y=u.descriptorSet;i.bindPipelineState(m),i.bindDescriptorSet(Cg.MATERIAL,g),i.bindInputAssembler(p);for(var v=0;v<c.length;++v){var S=_[v],T=n.getOrCreateDescriptorSet(S);yO[0]=c[v],i.bindDescriptorSet(Cg.GLOBAL,T),i.bindDescriptorSet(Cg.LOCAL,y,yO),i.draw(p)}}},e._lightCulling=function(t,e){for(var i=!1,n=0;n<e.length;n++){var r=e[n];switch(r.type){case sR.SPHERE:i=EO(r,t);break;case sR.SPOT:i=CO(r,t);break;case sR.POINT:i=wO(r,t);break;case sR.RANGED_DIRECTIONAL:i=xO(r,t)}i||vO.push(n)}},e._addRenderQueue=function(t,e,i,n){var r=this._pipeline.pipelineSceneData.validPunctualLights,s=t.batchingScheme,o=null;s===eT.NONE&&((o=pO.alloc()).subModel=e,o.passIdx=n);for(var a=0;a<vO.length;a++){var h=vO[a],u=r[h];if((u.visibility&i.node.layer)===i.node.layer)switch(s){case eT.INSTANCING:var l=t.getInstancedBuffer(a);l.merge(e,n),l.dynamicOffsets[0]=this._lightBufferStride,this._instancedQueues[a]||(this._instancedQueues[a]=new ND),this._instancedQueues[a].queue.add(l);break;default:o.lights.push(u),o.dynamicOffsets.push(this._lightBufferStride*h)}}s===eT.NONE&&this._lightPasses.push(o)},e._updateLightDescriptorSet=function(t,e){for(var i=this._pipeline.device,n=this._pipeline.pipelineSceneData,r=n.shadows,s=n.shadowFrameBufferMap,o=t.scene.mainLight,a=Zy(i)?0:1,h=this._pipeline.globalDSManager,u=n.validPunctualLights,l=this._pipeline.device.capabilities,c=0;c<u.length;c++){var _=u[c],d=h.getOrCreateDescriptorSet(_);if(d){var f=void 0,p=void 0;switch(_.type){case sR.SPHERE:o&&vI.updatePlanarNormalAndDistance(r,this._shadowUBO),this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+0]=r.size.x,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+1]=r.size.y,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+2]=1,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+3]=0,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+0]=sR.SPHERE,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+1]=a,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+2]=0,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+3]=0,dn.toArray(this._shadowUBO,r.shadowColor,Pg.SHADOW_COLOR_OFFSET);break;case sR.SPOT:var m=_;if(o&&vI.updatePlanarNormalAndDistance(r,this._shadowUBO),In.invert(SO,_.node.getWorldMatrix()),In.perspective(TO,_.angle,1,.001,_.range,!0,l.clipSpaceMinZ,l.clipSpaceSignY,0),f=TO.clone(),p=TO.clone().invert(),In.multiply(TO,TO,SO),In.toArray(this._shadowUBO,SO,Pg.MAT_LIGHT_VIEW_OFFSET),In.toArray(this._shadowUBO,TO,Pg.MAT_LIGHT_VIEW_PROJ_OFFSET),this._shadowUBO[Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+0]=.01,this._shadowUBO[Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+1]=_.range,this._shadowUBO[Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+2]=0,this._shadowUBO[Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+3]=0,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+0]=r.size.x,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+1]=r.size.y,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+2]=m.shadowPcf,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+3]=m.shadowBias,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+0]=sR.SPOT,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+1]=a,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+2]=m.shadowNormalBias,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+3]=0,this._shadowUBO[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+0]=f.m10,this._shadowUBO[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+1]=f.m14,this._shadowUBO[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+2]=f.m11,this._shadowUBO[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+3]=f.m15,this._shadowUBO[Pg.SHADOW_INV_PROJ_DEPTH_INFO_OFFSET+0]=p.m10,this._shadowUBO[Pg.SHADOW_INV_PROJ_DEPTH_INFO_OFFSET+1]=p.m14,this._shadowUBO[Pg.SHADOW_INV_PROJ_DEPTH_INFO_OFFSET+2]=p.m11,this._shadowUBO[Pg.SHADOW_INV_PROJ_DEPTH_INFO_OFFSET+3]=p.m15,this._shadowUBO[Pg.SHADOW_PROJ_INFO_OFFSET+0]=f.m00,this._shadowUBO[Pg.SHADOW_PROJ_INFO_OFFSET+1]=f.m05,this._shadowUBO[Pg.SHADOW_PROJ_INFO_OFFSET+2]=1/f.m00,this._shadowUBO[Pg.SHADOW_PROJ_INFO_OFFSET+3]=1/f.m05,dn.toArray(this._shadowUBO,r.shadowColor,Pg.SHADOW_COLOR_OFFSET),s.has(_)){var g,y=null===(g=s.get(_))||void 0===g?void 0:g.colorTextures[0];y&&d.bindTexture(Hg,y)}break;case sR.POINT:o&&vI.updatePlanarNormalAndDistance(r,this._shadowUBO),this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+0]=r.size.x,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+1]=r.size.y,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+2]=1,this._shadowUBO[Pg.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+3]=0,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+0]=sR.POINT,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+1]=a,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+2]=0,this._shadowUBO[Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+3]=0,dn.toArray(this._shadowUBO,r.shadowColor,Pg.SHADOW_COLOR_OFFSET)}d.update();var v=tv()?qR("CCShadow"):Pg.BINDING;e.updateBuffer(d.getBuffer(v),this._shadowUBO)}}},e._updateUBOs=function(t,e){var i=t.exposure,n=this._pipeline.pipelineSceneData,r=n.isHDR,s=n.shadows,o=n.validPunctualLights;o.length>this._lightBufferCount&&(this._firstLightBufferView.destroy(),this._lightBufferCount=Vi(o.length),this._lightBuffer.resize(this._lightBufferStride*this._lightBufferCount),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount),this._firstLightBufferView=Ed.gfxDevice.createBuffer(new qc(this._lightBuffer,0,Qg.SIZE)));for(var a=0,h=0;a<o.length;a++,h+=this._lightBufferElementCount){var u=o[a];switch(u.type){case sR.SPHERE:if(on.toArray(gO,u.position),gO[3]=sR.SPHERE,this._lightBufferData.set(gO,h+Qg.LIGHT_POS_OFFSET),gO[0]=u.size,gO[1]=u.range,gO[2]=0,gO[3]=0,this._lightBufferData.set(gO,h+Qg.LIGHT_SIZE_RANGE_ANGLE_OFFSET),on.toArray(gO,u.color),u.useColorTemperature){var l=u.finalColor;gO[0]=l.x,gO[1]=l.y,gO[2]=l.z}gO[3]=r?u.luminance*i*this._lightMeterScale:u.luminance,this._lightBufferData.set(gO,h+Qg.LIGHT_COLOR_OFFSET);break;case sR.SPOT:if(on.toArray(gO,u.position),gO[3]=sR.SPOT,this._lightBufferData.set(gO,h+Qg.LIGHT_POS_OFFSET),gO[0]=u.size,gO[1]=u.range,gO[2]=u.spotAngle,gO[3]=s.enabled&&u.shadowEnabled&&s.type===IT.ShadowMap?1:0,this._lightBufferData.set(gO,h+Qg.LIGHT_SIZE_RANGE_ANGLE_OFFSET),on.toArray(gO,u.direction),this._lightBufferData.set(gO,h+Qg.LIGHT_DIR_OFFSET),on.toArray(gO,u.color),u.useColorTemperature){var c=u.finalColor;gO[0]=c.x,gO[1]=c.y,gO[2]=c.z}gO[3]=r?u.luminance*i*this._lightMeterScale:u.luminance,this._lightBufferData.set(gO,h+Qg.LIGHT_COLOR_OFFSET);break;case sR.POINT:if(on.toArray(gO,u.position),gO[3]=sR.POINT,this._lightBufferData.set(gO,h+Qg.LIGHT_POS_OFFSET),gO[0]=0,gO[1]=u.range,gO[2]=0,gO[3]=0,this._lightBufferData.set(gO,h+Qg.LIGHT_SIZE_RANGE_ANGLE_OFFSET),on.toArray(gO,u.color),u.useColorTemperature){var _=u.finalColor;gO[0]=_.x,gO[1]=_.y,gO[2]=_.z}gO[3]=r?u.luminance*i*this._lightMeterScale:u.luminance,this._lightBufferData.set(gO,h+Qg.LIGHT_COLOR_OFFSET);break;case sR.RANGED_DIRECTIONAL:on.toArray(gO,u.position),gO[3]=sR.RANGED_DIRECTIONAL,this._lightBufferData.set(gO,h+Qg.LIGHT_POS_OFFSET),on.toArray(gO,u.right),gO[3]=0,this._lightBufferData.set(gO,h+Qg.LIGHT_SIZE_RANGE_ANGLE_OFFSET),on.toArray(gO,u.direction),gO[3]=0,this._lightBufferData.set(gO,h+Qg.LIGHT_DIR_OFFSET);var d=u.scale;if(mO.set(.5*d.x,.5*d.y,.5*d.z),on.toArray(gO,mO),gO[3]=0,this._lightBufferData.set(gO,h+Qg.LIGHT_BOUNDING_SIZE_VS_OFFSET),on.toArray(gO,u.color),u.useColorTemperature){var f=u.finalColor;gO[0]=f.x,gO[1]=f.y,gO[2]=f.z}gO[3]=r?u.illuminance*i:u.illuminance,this._lightBufferData.set(gO,h+Qg.LIGHT_COLOR_OFFSET)}}e.updateBuffer(this._lightBuffer,this._lightBufferData)},t}(),UO=[new zc(0,0,0,1)],zO=t("df",(PO=qs("ForwardStage"),OO=xo([bD]),PO(((FO=function(t){function e(){var e;return(e=t.call(this)||this).renderQueues=NO&&NO(),e._renderQueues=[],e._renderArea=new Mc,e._instancedQueue=void 0,e._phaseID=rT("default"),e._clearFlag=4294967295,e.additiveInstanceQueues=[],e._instancedQueue=new ND,e._uiPhase=new oP,e}s(e,t);var i=e.prototype;return i.addRenderInstancedQueue=function(t){this.additiveInstanceQueues.includes(t)||this.additiveInstanceQueues.push(t)},i.removeRenderInstancedQueue=function(t){var e=this.additiveInstanceQueues.indexOf(t);e>-1&&this.additiveInstanceQueues.splice(e,1)},i.initialize=function(e){return t.prototype.initialize.call(this,e),e.renderQueues&&(this.renderQueues=e.renderQueues),!0},i.activate=function(e,i){t.prototype.activate.call(this,e,i);for(var n=0;n<this.renderQueues.length;n++)this._renderQueues[n]=xD(this.renderQueues[n]);this._additiveLightQueue=new GO(this._pipeline),this._planarQueue=new sP(this._pipeline),this._uiPhase.activate(e)},i.destroy=function(){},i.render=function(t){var e;this._instancedQueue.clear();var i=this._pipeline,n=i.device;this._renderQueues.forEach(RD);for(var r=i.pipelineSceneData.renderObjects,s=0,o=0,a=0,h=0;h<r.length;++h){var u=r[h],l=u.model.subModels;for(s=0;s<l.length;++s){var c=l[s],_=c.passes;for(o=0;o<_.length;++o){var d=_[o];if(d.phase===this._phaseID)if(d.batchingScheme===eT.INSTANCING){var f=d.getInstancedBuffer();f.merge(c,o),this._instancedQueue.queue.add(f)}else for(a=0;a<this._renderQueues.length;a++)this._renderQueues[a].insertRenderPass(u,s,o)}}}this._instancedQueue.sort(),this._renderQueues.forEach(ID);var p=i.commandBuffers[0];i.pipelineUBO.updateShadowUBO(t);for(var m=0;m<this.additiveInstanceQueues.length;m++)this.additiveInstanceQueues[m].uploadBuffers(p);this._instancedQueue.uploadBuffers(p),this._additiveLightQueue.gatherLightPasses(t,p),this._planarQueue.gatherShadowPasses(t,p),t.clearFlag&Cc.COLOR&&(UO[0].x=t.clearColor.x,UO[0].y=t.clearColor.y,UO[0].z=t.clearColor.z,UO[0].w=t.clearColor.w),i.generateRenderArea(t,this._renderArea);var g=t.window.framebuffer,y=i.getRenderPass(t.clearFlag&this._clearFlag,g);p.beginRenderPass(y,g,this._renderArea,UO,t.clearDepth,t.clearStencil),p.bindDescriptorSet(Cg.GLOBAL,i.descriptorSet),this._renderQueues[0].recordCommandBuffer(n,y,p);for(var v=0;v<this.additiveInstanceQueues.length;v++)this.additiveInstanceQueues[v].recordCommandBuffer(n,y,p);this._instancedQueue.recordCommandBuffer(n,y,p),this._additiveLightQueue.recordCommandBuffer(n,y,p),p.bindDescriptorSet(Cg.GLOBAL,i.descriptorSet),this._planarQueue.recordCommandBuffer(n,y,p),this._renderQueues[1].recordCommandBuffer(n,y,p),null===(e=t.geometryRenderer)||void 0===e||e.render(y,p,i.pipelineSceneData),this._uiPhase.render(t,y),CT(n,y,p,i.profiler,t),p.endRenderPass()},e}(RI)).initInfo={name:"ForwardStage",priority:kI.FORWARD,tag:0,renderQueues:[{isTransparent:!1,sortMode:SD.FRONT_TO_BACK,stages:["default"]},{isTransparent:!0,sortMode:SD.BACK_TO_FRONT,stages:["default","planarShadow"]}]},NO=ks((LO=FO).prototype,"renderQueues",[OO,io],(function(){return[]})),MO=LO))||MO)),HO=t("de",qs("ForwardFlow")(((VO=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.initialize=function(e){if(t.prototype.initialize.call(this,e),0===this._stages.length){var i=new zO;i.initialize(zO.initInfo),this._stages.push(i)}return!0},i.activate=function(e){t.prototype.activate.call(this,e)},i.render=function(e){t.prototype.render.call(this,e)},i.destroy=function(){t.prototype.destroy.call(this)},e}(BI)).initInfo={name:gg,priority:VI.FORWARD,stages:[]},kO=VO))||kO),WO="CC_USE_RGBE_OUTPUT",jO=rT("default"),XO=rT("reflect-map");function qO(t){var e=t.passes,i=v.rendering;tv()&&(jO=i.getPhaseID(i.getPassID("default"),"default"));for(var n=0;n<e.length;n++)if((!i||!i.enableEffectImport)&&e[n].phase===jO||tv()&&e[n].phaseID===jO)return n;return-1}function YO(t){var e=t.passes,i=v.rendering;tv()&&(XO=i.getPhaseID(i.getPassID("default"),"reflect-map"));for(var n=0;n<e.length;n++)if((!i||!i.enableEffectImport)&&e[n].phase===XO||tv()&&e[n].phaseID===XO)return n;return-1}var KO,JO,QO,ZO,$O,tM,eM,iM,nM,rM=function(){function t(t){this._pipeline=void 0,this._subModelsArray=[],this._passArray=[],this._shaderArray=[],this._rgbeSubModelsArray=[],this._instancedQueue=void 0,this._patches=[],this._pipeline=t,this._instancedQueue=new ND}var e=t.prototype;return e.gatherRenderObjects=function(t,e,i){this.clear();var n=e.scene,r=this._pipeline.pipelineSceneData.skybox;r.enabled&&r.model&&t.camera.clearFlag&Ux&&this.add(r.model);for(var s=n.models,o=t.visibility,a=0;a<s.length;a++){var h=s[a];h.node&&!n.isCulledByLod(e,h)&&((o&h.node.layer)===h.node.layer||o&h.visFlags)&&h.enabled&&h.worldBounds&&h.bakeToReflectionProbe&&(t.probeType===eR.CUBE?as.aabbWithAABB(h.worldBounds,t.boundingBox)&&this.add(h):as.aabbFrustum(h.worldBounds,t.camera.frustum)&&this.add(h))}this._instancedQueue.uploadBuffers(i)},e.clear=function(){this._subModelsArray.length=0,this._shaderArray.length=0,this._passArray.length=0,this._instancedQueue.clear(),this._rgbeSubModelsArray.length=0},e.add=function(t){for(var e=t.subModels,i=0;i<e.length;i++){var n=e[i];if(!n.passes[0].blendState.targets[0].blend){var r=YO(n),s=!0;if(r<0&&(r=qO(n),s=!1),!(r<0)){var o=n.passes[r],a=o.batchingScheme;if(!s){this._patches=[],this._patches=this._patches.concat(n.patches);var h=[{name:WO,value:!0}];this._patches=this._patches.concat(h),n.onMacroPatchesStateChanged(this._patches),this._rgbeSubModelsArray.push(n)}if(a===eT.INSTANCING){var u=o.getInstancedBuffer();u.merge(n,r),this._instancedQueue.queue.add(u)}else{var l=n.shaders[r];this._subModelsArray.push(n),l&&this._shaderArray.push(l),this._passArray.push(o)}}}}},e.recordCommandBuffer=function(t,e,i){this._instancedQueue.recordCommandBuffer(t,e,i);for(var n=0;n<this._subModelsArray.length;++n){var r=this._subModelsArray[n],s=this._shaderArray[n],o=this._passArray[n],a=r.inputAssembler,h=lT.getOrCreatePipelineState(t,o,s,e,a),u=o.descriptorSet;i.bindPipelineState(h),i.bindDescriptorSet(Cg.MATERIAL,u),i.bindDescriptorSet(Cg.LOCAL,r.descriptorSet),i.bindInputAssembler(a),i.draw(a)}this.resetRGBEMacro(),this._instancedQueue.clear()},e.resetRGBEMacro=function(){for(var t=0;t<this._rgbeSubModelsArray.length;t++){this._patches=[];var e=this._rgbeSubModelsArray[t];if(this._patches=this._patches.concat(e.patches),this._patches){for(var i=0;i<this._patches.length;i++)if(this._patches[i].name===WO){this._patches.splice(i,1);break}e.onMacroPatchesStateChanged(this._patches)}}},t}(),sM=[new zc(1,1,1,1)],oM=t("dv",qs("ReflectionProbeStage")(((JO=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._frameBuffer=null,e._renderArea=new Mc,e._probe=null,e._probeRenderQueue=void 0,e._rgbeColor=new on,e}s(e,t);var i=e.prototype;return i.setUsageInfo=function(t,e){this._probe=t,this._frameBuffer=e},i.destroy=function(){var t;this._frameBuffer=null,null===(t=this._probeRenderQueue)||void 0===t||t.clear()},i.clearFramebuffer=function(t){if(this._frameBuffer){sM[0].w=t.clearColor.w;var e=this._pipeline,i=e.pipelineSceneData.shadingScale,n=t.viewport,r=this._probe.resolution;this._renderArea.x=n.x*r,this._renderArea.y=n.y*r,this._renderArea.width=n.width*r*i,this._renderArea.height=n.height*r*i;var s=e.commandBuffers[0],o=this._frameBuffer.renderPass;s.beginRenderPass(o,this._frameBuffer,this._renderArea,sM,t.clearDepth,t.clearStencil),s.endRenderPass()}},i.render=function(t){var e=this._pipeline,i=e.commandBuffers[0];this._probeRenderQueue.gatherRenderObjects(this._probe,t,i),e.pipelineUBO.updateCameraUBO(this._probe.camera),this._renderArea.x=0,this._renderArea.y=0,this._renderArea.width=this._probe.renderArea().x,this._renderArea.height=this._probe.renderArea().y;var n=this._frameBuffer.renderPass;if(this._probe.camera.clearFlag&Cc.COLOR){this._rgbeColor.x=this._probe.camera.clearColor.x,this._rgbeColor.y=this._probe.camera.clearColor.y,this._rgbeColor.z=this._probe.camera.clearColor.z;var r=function(t){var e=Math.max(Math.max(t.x,t.y),t.z),i=128;e>1e-4&&(i=Math.log(e)/Math.log(1.1),i=xi((i=Math.ceil(i))+128,0,255));var n=1/Math.pow(1.1,i-128),r=function(t,e,i){if(e>i){var n=e;e=i,i=n}return t<e?e:t>i?i:t}(t.multiplyScalar(n),new on(0,0,0),new on(1,1,1));r.multiplyScalar(255);var s,o,a=pn(r).add((s=r.subtract(pn(r)))<(o=new on(.5,.5,.5))?o:s);return new tn(a.x/255,a.y/255,a.z/255,i/255)}(this._rgbeColor);sM[0].x=r.x,sM[0].y=r.y,sM[0].z=r.z,sM[0].w=r.w}var s=e.device;i.beginRenderPass(n,this._frameBuffer,this._renderArea,sM,this._probe.camera.clearDepth,this._probe.camera.clearStencil),i.bindDescriptorSet(Cg.GLOBAL,e.descriptorSet),this._probeRenderQueue.recordCommandBuffer(s,n,i),i.endRenderPass(),e.pipelineUBO.updateCameraUBO(t)},i.activate=function(e,i){t.prototype.activate.call(this,e,i),this._probeRenderQueue=new rM(e)},e}(RI)).initInfo={name:"ReflectionProbeStage",priority:kI.FORWARD,tag:0},KO=JO))||KO),aM=t("du",qs("ReflectionProbeFlow")(((ZO=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.initialize=function(e){if(t.prototype.initialize.call(this,e),0===this._stages.length){var i=new oM;i.initialize(oM.initInfo),this._stages.push(i)}return!0},i.activate=function(e){t.prototype.activate.call(this,e)},i.render=function(t){if(v.internal.reflectionProbeManager)for(var e=v.internal.reflectionProbeManager.getProbes(),i=0;i<e.length;i++)e[i].needRender&&e[i].probeType===eR.PLANAR&&this._renderStage(t,e[i])},i.destroy=function(){t.prototype.destroy.call(this)},i._renderStage=function(t,e){for(var i=0;i<this._stages.length;i++){var n=this._stages[i];if(e.probeType===eR.PLANAR)v.internal.reflectionProbeManager.updatePlanarMap(e,null),n.setUsageInfo(e,e.realtimePlanarTexture.window.framebuffer),n.render(t),v.internal.reflectionProbeManager.updatePlanarMap(e,e.realtimePlanarTexture.getGFXTexture());else{for(var r=0;r<6;r++){var s=e.bakedCubeTextures[r];if(!s)return;e.updateCameraDir(r),n.setUsageInfo(e,s.window.framebuffer),n.render(t)}e.needRender=!1}}},e}(BI)).initInfo={name:"PIPELINE_FLOW_RELECTION_PROBE",priority:0,tag:_D.SCENE,stages:[]},QO=ZO))||QO);function hM(){var t=new lM;return t.initialize({flows:[]}),t}var uM,lM=t("dc",($O=qs("ForwardPipeline"),tM=xo([vD]),$O((iM=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).renderTextures=nM&&nM(),e._postRenderPass=null,e}s(e,t);var i=e.prototype;return i.initialize=function(e){if(t.prototype.initialize.call(this,e),0===this._flows.length){var i=new _O;i.initialize(_O.initInfo),this._flows.push(i);var n=new aM;n.initialize(aM.initInfo),this._flows.push(n);var r=new HO;r.initialize(HO.initInfo),this._flows.push(r)}return!0},i.activate=function(e){return this._macros={CC_PIPELINE_TYPE:0},this._pipelineSceneData=new NP,!(!t.prototype.activate.call(this,e)||!this._activeRenderer(e)&&(J(2402),1))},i._ensureEnoughSize=function(t){for(var e=this._width,i=this._height,n=0;n<t.length;++n){var r=t[n].window;e=Math.max(r.width,e),i=Math.max(r.height,i)}e===this._width&&i===this._height||(this._width=e,this._height=i)},i.destroy=function(){this._destroyUBOs(),this._destroyQuadInputAssembler();for(var e=this._renderPasses.values(),i=e.next();!i.done;)i.value.destroy(),i=e.next();return this._commandBuffers.length=0,t.prototype.destroy.call(this)},i._activeRenderer=function(){var t=this.device;this._commandBuffers.push(t.commandBuffer);var e=this.globalDSManager.pointSampler;return this._descriptorSet.bindSampler(Mg,e),this._descriptorSet.bindTexture(Mg,nT.get("default-texture").getGFXTexture()),this._descriptorSet.bindSampler(Hg,e),this._descriptorSet.bindTexture(Hg,nT.get("default-texture").getGFXTexture()),this._descriptorSet.update(),!0},i._destroyUBOs=function(){this._descriptorSet&&(this._descriptorSet.getBuffer(Bg.BINDING).destroy(),this._descriptorSet.getBuffer(Pg.BINDING).destroy(),this._descriptorSet.getBuffer(Dg.BINDING).destroy(),this._descriptorSet.getTexture(Mg).destroy(),this._descriptorSet.getTexture(Hg).destroy())},n(e,[{key:"postRenderPass",get:function(){return this._postRenderPass}}]),e}(yD),nM=ks(iM.prototype,"renderTextures",[tM,io],(function(){return[]})),eM=iM))||eM)),cM=new b_(null),_M=function(){function t(){this._device=null,this._passes=null,this._shaders=null,this._subMesh=null,this._patches=null,this._priority=pg.DEFAULT,this._inputAssembler=null,this._descriptorSet=null,this._worldBoundDescriptorSet=null,this._reflectionTex=null,this._reflectionSampler=null,this._instancedAttributeBlock={buffer:null,views:[],attributes:[]},this._instancedWorldMatrixIndex=-1,this._instancedSHIndex=-1,this._useReflectionProbeType=0}var e=t.prototype;return e.initialize=function(t,e,i){void 0===i&&(i=null);var n=v.director.root;this._device=Ed.gfxDevice,cM.layout=e[0].localSetLayout,this._inputAssembler=this._device.createInputAssembler(t.iaInfo),this._descriptorSet=this._device.createDescriptorSet(cM);var r=v.director.root.pipeline.pipelineSceneData.getOcclusionQueryPass();if(r){var s=new b_(null);s.layout=r.localSetLayout,this._worldBoundDescriptorSet=this._device.createDescriptorSet(s)}this._subMesh=t,this._patches=i?i.sort():null,this._passes=e,this._flushPassInfo(),this.priority=pg.DEFAULT;var o=v.rendering;if((!o||!o.enableEffectImport)&&e[0].phase===rT("reflection")||tv()&&e[0].phaseID===o.getPhaseID(o.getPassID("default"),"reflection")){var a=n.mainWindow.width,h=n.mainWindow.height,u=512;h<a?(a=u*a/h,h=u):h=u*h/(a=u),this._reflectionTex=this._device.createTexture(new Qc(Jl.TEX2D,Ql.STORAGE|Ql.TRANSFER_SRC|Ql.SAMPLED,Hl.RGBA8,a,h)),this.descriptorSet.bindTexture(Ry,this._reflectionTex),this._reflectionSampler=this._device.getSampler(new $c(ic.LINEAR,ic.LINEAR,ic.NONE,nc.CLAMP,nc.CLAMP,nc.CLAMP)),this.descriptorSet.bindSampler(Ry,this._reflectionSampler),this.descriptorSet.bindTexture(Dy,this._reflectionTex)}},e.destroy=function(){var t;this._descriptorSet.destroy(),this._descriptorSet=null,this._inputAssembler.destroy(),this._inputAssembler=null,null===(t=this._worldBoundDescriptorSet)||void 0===t||t.destroy(),this._worldBoundDescriptorSet=null,this.priority=pg.DEFAULT,this._patches=null,this._subMesh=null,this._passes=null,this._shaders=null,this._reflectionTex&&this._reflectionTex.destroy(),this._reflectionTex=null,this._reflectionSampler=null},e.update=function(){for(var t,e=0;e<this._passes.length;++e)this._passes[e].update();this._descriptorSet.update(),null===(t=this._worldBoundDescriptorSet)||void 0===t||t.update()},e.onPipelineStateChanged=function(){var t=this._passes;if(t){for(var e=0;e<t.length;e++){var i=t[e];i.beginChangeStatesSilently(),i.tryCompile(),i.endChangeStatesSilently()}this._flushPassInfo()}},e.onMacroPatchesStateChanged=function(t){if((t||this._patches)&&(!t||(t=t.sort(),!this._patches||t.length!==this._patches.length||JSON.stringify(t)!==JSON.stringify(this._patches)))){this._patches=t;var e=this._passes;if(e){for(var i=0;i<e.length;i++){var n=e[i];n.beginChangeStatesSilently(),n.tryCompile(),n.endChangeStatesSilently()}this._flushPassInfo()}}},e.onGeometryChanged=function(){if(this._subMesh){var t=this._subMesh.drawInfo;if(this._inputAssembler&&t){var e=this._inputAssembler.drawInfo;Object.keys(t).forEach((function(i){e[i]=t[i]})),this._inputAssembler.drawInfo=e}}},e.getInstancedAttributeIndex=function(t){for(var e=this.instancedAttributeBlock.attributes,i=0;i<e.length;i++)if(e[i].name===t)return i;return-1},e.updateInstancedWorldMatrix=function(t,e){var i=this.instancedAttributeBlock.views,n=i[e],r=i[e+1],s=i[e+2];n[0]=t.m00,n[1]=t.m01,n[2]=t.m02,n[3]=t.m12,r[0]=t.m04,r[1]=t.m05,r[2]=t.m06,r[3]=t.m13,s[0]=t.m08,s[1]=t.m09,s[2]=t.m10,s[3]=t.m14},e.updateInstancedSH=function(t,e){for(var i=this.instancedAttributeBlock.views,n=(oy.SH_QUADRATIC_R_OFFSET-oy.SH_LINEAR_CONST_R_OFFSET)/4,r=0,s=e;s<e+n;s++)for(var o=0;o<4;o++)i[s][o]=t[r++]},e.UpdateInstancedAttributes=function(t){this.instancedWorldMatrixIndex=-1,this.instancedSHIndex=-1;var e=this.passes[0];if(e.device.hasFeature(zl.INSTANCED_ARRAYS)){for(var i=0,n=0;n<t.length;n++){var r=t[n];r.isInstanced&&(i+=M_[r.format].size)}var s=this.instancedAttributeBlock;s.buffer=new Uint8Array(i),s.views.length=s.attributes.length=0;for(var o=0,a=0;a<t.length;a++){var h=t[a];if(h.isInstanced){var u=new u_;u.format=h.format,u.name=h.name,u.isNormalized=h.isNormalized,u.location=h.location,s.attributes.push(u);var l=M_[h.format],c=new(H_(l))(s.buffer.buffer,o,l.count);s.views.push(c),o+=l.size}}e.batchingScheme===eT.INSTANCING&&e.getInstancedBuffer().destroy(),this.instancedWorldMatrixIndex=this.getInstancedAttributeIndex(Yg),this.instancedSHIndex=this.getInstancedAttributeIndex(Kg)}},e._flushPassInfo=function(){var t=this._passes;if(t){this._shaders||(this._shaders=[]),this._shaders.length=t.length;for(var e=0,i=t.length;e<i;e++)this._shaders[e]=t[e].getShaderVariant(this.patches)}},n(t,[{key:"passes",get:function(){return this._passes},set:function(t){t.length>8?J(12004,8):(this._passes=t,this._flushPassInfo(),this._descriptorSet&&(this._descriptorSet.destroy(),cM.layout=t[0].localSetLayout,this._descriptorSet=this._device.createDescriptorSet(cM)))}},{key:"shaders",get:function(){return this._shaders}},{key:"subMesh",get:function(){return this._subMesh},set:function(t){this._inputAssembler.destroy(),this._inputAssembler=this._device.createInputAssembler(t.iaInfo),this._subMesh=t}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t}},{key:"inputAssembler",get:function(){return this._inputAssembler}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"worldBoundDescriptorSet",get:function(){return this._worldBoundDescriptorSet}},{key:"patches",get:function(){return this._patches}},{key:"instancedAttributeBlock",get:function(){return this._instancedAttributeBlock}},{key:"instancedWorldMatrixIndex",get:function(){return this._instancedWorldMatrixIndex},set:function(t){this._instancedWorldMatrixIndex=t}},{key:"instancedSHIndex",get:function(){return this._instancedSHIndex},set:function(t){this._instancedSHIndex=t}},{key:"useReflectionProbeType",get:function(){return this._useReflectionProbeType},set:function(t){this._useReflectionProbeType=t}}]),t}();t("am",uM),function(t){t[t.NONE=0]="NONE",t[t.BAKED_CUBEMAP=1]="BAKED_CUBEMAP",t[t.PLANAR_REFLECTION=2]="PLANAR_REFLECTION",t[t.BLEND_PROBES=3]="BLEND_PROBES",t[t.BLEND_PROBES_AND_SKYBOX=4]="BLEND_PROBES_AND_SKYBOX"}(uM||t("am",uM={}));var dM,fM=new In,pM=[{name:"CC_RECEIVE_SHADOW",value:!0}],mM=[{name:"CC_USE_LIGHTMAP",value:1}],gM=[{name:"CC_USE_LIGHTMAP",value:2}],yM=[{name:"CC_LIGHT_MAP_VERSION",value:2}],vM=[{name:"CC_USE_LIGHT_PROBE",value:!0}];!function(t){t[t.DEFAULT=0]="DEFAULT",t[t.SKINNING=1]="SKINNING",t[t.BAKED_SKINNING=2]="BAKED_SKINNING",t[t.BATCH_2D=3]="BATCH_2D",t[t.PARTICLE_BATCH=4]="PARTICLE_BATCH",t[t.LINE=5]="LINE"}(dM||(dM={}));var SM,TM,AM,bM,EM=new $c(ic.LINEAR,ic.LINEAR,ic.NONE,nc.CLAMP,nc.CLAMP,nc.CLAMP),CM=new $c(ic.LINEAR,ic.LINEAR,ic.LINEAR,nc.CLAMP,nc.CLAMP,nc.CLAMP),wM=function(){function t(){this.type=dM.DEFAULT,this.scene=null,this.isDynamicBatching=!1,this._worldBounds=null,this._modelBounds=null,this._subModels=[],this._node=null,this._transform=null,this._device=void 0,this._inited=!1,this._descriptorSetCount=1,this._updateStamp=-1,this._localDataUpdated=!0,this._localData=new Float32Array(Xg.COUNT),this._localBuffer=null,this._localSHData=null,this._localSHBuffer=null,this._lightmap=null,this._lightmapUVParam=new tn,this._tetrahedronIndex=-1,this._lastWorldBoundCenter=new on(1/0,1/0,1/0),this._useLightProbe=!1,this._worldBoundBuffer=null,this._receiveShadow=!1,this._castShadow=!1,this._receiveDirLight=!0,this._shadowBias=0,this._shadowNormalBias=0,this._reflectionProbeId=-1,this._reflectionProbeBlendId=-1,this._reflectionProbeBlendWeight=0,this._enabled=!0,this._visFlags=im.Enum.NONE,this._priority=0,this._bakeToReflectionProbe=!0,this._reflectionProbeType=uM.NONE,this._device=Ed.gfxDevice}var e=t.prototype;return e.initialize=function(){this._inited||(this._receiveShadow=!0,this.castShadow=!1,this.enabled=!0,this.visFlags=im.Enum.NONE,this._inited=!0,this._bakeToReflectionProbe=!0,this._reflectionProbeType=uM.NONE)},e.destroy=function(){for(var t=this._subModels,e=0;e<t.length;e++)this._subModels[e].destroy();this._localBuffer&&(this._localBuffer.destroy(),this._localBuffer=null),this._localSHBuffer&&(this._localSHBuffer.destroy(),this._localSHBuffer=null),this._worldBoundBuffer&&(this._worldBoundBuffer.destroy(),this._worldBoundBuffer=null),this._worldBounds=null,this._modelBounds=null,this._subModels.length=0,this._inited=!1,this._localDataUpdated=!0,this._transform=null,this._node=null,this.isDynamicBatching=!1},e.attachToScene=function(t){this.scene=t,this._localDataUpdated=!0},e.detachFromScene=function(){this.scene=null},e.updateTransform=function(){var t=this.transform;if(t.hasChangedFlags||t.isTransformDirty()){t.updateWorldTransform(),this._localDataUpdated=!0;var e=this._worldBounds;this._modelBounds&&e&&this._modelBounds.transform(t._mat,t._pos,t._rot,t._scale,e)}},e.updateWorldBound=function(){var t=this.transform;if(null!==t){t.updateWorldTransform(),this._localDataUpdated=!0;var e=this._worldBounds;this._modelBounds&&e&&this._modelBounds.transform(t._mat,t._pos,t._rot,t._scale,e)}},e.updateUBOs=function(t){for(var e=this._subModels,i=0;i<e.length;i++)e[i].update();this._updateStamp=t,this.updateSHUBOs();var n=this.node.scene.globals.shadows.enabled&&this.node.scene.globals.shadows.type===IT.Planar;if(this._localDataUpdated){this._localDataUpdated=!1;for(var r=this.transform._mat,s=!1,o=0;o<e.length;o++){var a=e[o],h=a.instancedWorldMatrixIndex;h>=0?a.updateInstancedWorldMatrix(r,h):s=!0}(s||n)&&this._localBuffer&&(In.toArray(this._localData,r,Xg.MAT_WORLD_OFFSET),In.invert(fM,r),In.transpose(fM,fM),In.toArray(this._localData,fM,Xg.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData))}},e.invalidateLocalData=function(){this._localDataUpdated=!0},e.showTetrahedron=function(){return this.isLightProbeAvailable()},e.isLightProbeAvailable=function(){if(!this._useLightProbe)return!1;var t=v.director.root.pipeline.pipelineSceneData.lightProbes;return!(!t||t.empty()||!this._worldBounds)},e.updateSHBuffer=function(){if(this._localSHData){for(var t=this._subModels,e=!1,i=0;i<t.length;i++){var n=t[i],r=n.instancedSHIndex;r>=0?n.updateInstancedSH(this._localSHData,r):e=!0}e&&this._localSHBuffer&&this._localSHBuffer.update(this._localSHData)}},e.clearSHUBOs=function(){if(this._localSHData){for(var t=0;t<oy.COUNT;t++)this._localSHData[t]=0;this.updateSHBuffer()}},e.updateSHUBOs=function(){if(this.isLightProbeAvailable()){var t=this._worldBounds.center;if(!t.equals(this._lastWorldBoundCenter,Ei)){var e=[],i=new tn(0,0,0,0),n=v.director.root.pipeline.pipelineSceneData.lightProbes;this._lastWorldBoundCenter.set(t),this._tetrahedronIndex=n.data.getInterpolationWeights(t,this._tetrahedronIndex,i),n.data.getInterpolationSHCoefficients(this._tetrahedronIndex,i,e)&&this._localSHData&&(v.internal.SH.reduceRinging(e,n.reduceRinging),v.internal.SH.updateUBOData(this._localSHData,oy.SH_LINEAR_CONST_R_OFFSET,e),this.updateSHBuffer())}}},e.createBoundingShape=function(t,e){t&&e&&(this._modelBounds||(this._modelBounds=Ss.create()),this._worldBounds||(this._worldBounds=Ss.create()),Ss.fromPoints(this._modelBounds,t,e),Ss.copy(this._worldBounds,this._modelBounds))},e._createSubModel=function(){return new _M},e.initSubModel=function(t,e,i){this.initialize(),null==this._subModels[t]?this._subModels[t]=this._createSubModel():this._subModels[t].destroy(),this._subModels[t].initialize(e,i.passes,this.getMacroPatches(t)),this._updateAttributesAndBinding(t)},e.setSubModelMesh=function(t,e){this._subModels[t]&&(this._subModels[t].subMesh=e)},e.setSubModelMaterial=function(t,e){this._subModels[t]&&(this._subModels[t].passes=e.passes,this._updateAttributesAndBinding(t))},e.onGlobalPipelineStateChanged=function(){for(var t=this._subModels,e=0;e<t.length;e++)t[e].onPipelineStateChanged()},e.onMacroPatchesStateChanged=function(){for(var t=this._subModels,e=0;e<t.length;e++)t[e].onMacroPatchesStateChanged(this.getMacroPatches(e))},e.onGeometryChanged=function(){for(var t=this._subModels,e=0;e<t.length;e++)t[e].onGeometryChanged()},e.initLightingmap=function(t,e){this._lightmap=t,this._lightmapUVParam=e},e.updateLightingmap=function(t,e){tn.toArray(this._localData,e,Xg.LIGHTINGMAP_UVPARAM),this._localDataUpdated=!0,this._lightmap=t,this._lightmapUVParam=e,this.onMacroPatchesStateChanged(),t||(t=nT.get("empty-texture"));var i=t.getGFXTexture();if(i)for(var n=this._device.getSampler(t.mipmaps.length>1?CM:EM),r=this._subModels,s=0;s<r.length;s++){var o=r[s].descriptorSet;o.bindTexture(Ay,i),o.bindSampler(Ay,n),o.update()}},e.updateReflectionProbeCubemap=function(t){this._localDataUpdated=!0,this.onMacroPatchesStateChanged(),t||(t=nT.get("default-cube-texture"));var e=t.getGFXTexture();if(e)for(var i=this._device.getSampler(t.getSamplerInfo()),n=this._subModels,r=0;r<n.length;r++){var s=n[r].descriptorSet;s&&(s.bindSampler(My,i),s.bindTexture(My,e),s.update())}},e.updateReflectionProbeBlendCubemap=function(t){this._localDataUpdated=!0,this.onMacroPatchesStateChanged(),t||(t=nT.get("default-cube-texture"));var e=t.getGFXTexture();if(e)for(var i=this._device.getSampler(t.getSamplerInfo()),n=this._subModels,r=0;r<n.length;r++){var s=n[r].descriptorSet;s&&(s.bindSampler(Hy,i),s.bindTexture(Hy,e),s.update())}},e.updateReflectionProbePlanarMap=function(t){this._localDataUpdated=!0,this.onMacroPatchesStateChanged();var e=this._device.getSampler(new $c(ic.LINEAR,ic.LINEAR,ic.NONE,nc.CLAMP,nc.CLAMP,nc.CLAMP));if(t||(t=nT.get("empty-texture").getGFXTexture()),t)for(var i=this._subModels,n=0;n<i.length;n++){var r=i[n].descriptorSet;r&&(r.bindTexture(Fy,t),r.bindSampler(Fy,e),r.update())}},e.updateReflectionProbeDataMap=function(t){this._localDataUpdated=!0,this.onMacroPatchesStateChanged(),t||(t=nT.get("empty-texture"));var e=t.getGFXTexture();if(e)for(var i=this._subModels,n=0;n<i.length;n++){var r=i[n].descriptorSet;r&&(r.bindTexture(Gy,e),r.bindSampler(Gy,t.getGFXSampler()),r.update())}},e.updateLocalShadowBias=function(){var t=this._localData;t[Xg.LOCAL_SHADOW_BIAS+0]=this._shadowBias,t[Xg.LOCAL_SHADOW_BIAS+1]=this._shadowNormalBias,this._localDataUpdated=!0},e.updateReflectionProbeId=function(){var t=this._localData;t[Xg.LOCAL_SHADOW_BIAS+2]=this._reflectionProbeId,t[Xg.LOCAL_SHADOW_BIAS+3]=this._reflectionProbeBlendId;var e=null,i=null;if(v.internal.reflectionProbeManager&&(e=v.internal.reflectionProbeManager.getProbeById(this._reflectionProbeId),i=v.internal.reflectionProbeManager.getProbeById(this._reflectionProbeBlendId)),e){if(e.probeType===eR.PLANAR)t[Xg.REFLECTION_PROBE_DATA1]=e.node.up.x,t[Xg.REFLECTION_PROBE_DATA1+1]=e.node.up.y,t[Xg.REFLECTION_PROBE_DATA1+2]=e.node.up.z,t[Xg.REFLECTION_PROBE_DATA1+3]=1,t[Xg.REFLECTION_PROBE_DATA2]=1,t[Xg.REFLECTION_PROBE_DATA2+1]=0,t[Xg.REFLECTION_PROBE_DATA2+2]=0,t[Xg.REFLECTION_PROBE_DATA2+3]=1;else{t[Xg.REFLECTION_PROBE_DATA1]=e.node.worldPosition.x,t[Xg.REFLECTION_PROBE_DATA1+1]=e.node.worldPosition.y,t[Xg.REFLECTION_PROBE_DATA1+2]=e.node.worldPosition.z,t[Xg.REFLECTION_PROBE_DATA1+3]=0,t[Xg.REFLECTION_PROBE_DATA2]=e.size.x,t[Xg.REFLECTION_PROBE_DATA2+1]=e.size.y,t[Xg.REFLECTION_PROBE_DATA2+2]=e.size.z;var n=e.isRGBE()?1e3:0;t[Xg.REFLECTION_PROBE_DATA2+3]=e.cubemap?e.cubemap.mipmapLevel+n:1+n}if(this._reflectionProbeType===uM.BLEND_PROBES||this._reflectionProbeType===uM.BLEND_PROBES_AND_SKYBOX)if(i){t[Xg.REFLECTION_PROBE_BLEND_DATA1]=i.node.worldPosition.x,t[Xg.REFLECTION_PROBE_BLEND_DATA1+1]=i.node.worldPosition.y,t[Xg.REFLECTION_PROBE_BLEND_DATA1+2]=i.node.worldPosition.z,t[Xg.REFLECTION_PROBE_BLEND_DATA1+3]=this.reflectionProbeBlendWeight,t[Xg.REFLECTION_PROBE_BLEND_DATA2]=i.size.x,t[Xg.REFLECTION_PROBE_BLEND_DATA2+1]=i.size.y,t[Xg.REFLECTION_PROBE_BLEND_DATA2+2]=i.size.z;var r=i.isRGBE()?1e3:0;t[Xg.REFLECTION_PROBE_BLEND_DATA2+3]=i.cubemap?i.cubemap.mipmapLevel+r:1+r}else this._reflectionProbeType===uM.BLEND_PROBES_AND_SKYBOX&&(t[Xg.REFLECTION_PROBE_BLEND_DATA1+3]=this.reflectionProbeBlendWeight)}this._localDataUpdated=!0},e.getMacroPatches=function(){var t=this.receiveShadow?pM:null;if(null!=this._lightmap&&this.node&&this.node.scene&&!this.node.scene.globals.disableLightmap){var e=this.node.scene.globals.bakedWithStationaryMainLight?gM:mM;t=t?t.concat(e):e,this.node.scene.globals.bakedWithHighpLightmap&&(t=t.concat(yM))}this._useLightProbe&&(t=t?t.concat(vM):vM);var i=[{name:"CC_USE_REFLECTION_PROBE",value:this._reflectionProbeType}];t=t?t.concat(i):i;var n=[{name:"CC_DISABLE_DIRECTIONAL_LIGHT",value:!this._receiveDirLight}];return t?t.concat(n):n},e._updateAttributesAndBinding=function(t){var e=this._subModels[t];if(e){this._initLocalDescriptors(t),this._updateLocalDescriptors(t,e.descriptorSet),this._initLocalSHDescriptors(t),this._updateLocalSHDescriptors(t,e.descriptorSet),this._initWorldBoundDescriptors(t),e.worldBoundDescriptorSet&&this._updateWorldBoundDescriptors(t,e.worldBoundDescriptorSet);for(var i,n=[],r=new Set,s=d(e.passes);!(i=s()).done;)for(var o,a=d(i.value.getShaderVariant(e.patches).attributes);!(o=a()).done;){var h=o.value;r.has(h.name)||(n.push(h),r.add(h.name))}this._updateInstancedAttributes(n,e)}},e._updateInstancedAttributes=function(t,e){e.UpdateInstancedAttributes(t),this._localDataUpdated=!0},e._initLocalDescriptors=function(){this._localBuffer||(this._localBuffer=this._device.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.DEVICE,Xg.SIZE,Xg.SIZE)))},e._initLocalSHDescriptors=function(){this._useLightProbe&&(this._localSHData||(this._localSHData=new Float32Array(oy.COUNT)),this._localSHBuffer||(this._localSHBuffer=this._device.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.DEVICE,oy.SIZE,oy.SIZE))))},e._initWorldBoundDescriptors=function(){this._worldBoundBuffer||(this._worldBoundBuffer=this._device.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.DEVICE,qg.SIZE,qg.SIZE)))},e._updateLocalDescriptors=function(t,e){this._localBuffer&&e.bindBuffer(Xg.BINDING,this._localBuffer)},e._updateLocalSHDescriptors=function(t,e){this._localSHBuffer&&e.bindBuffer(oy.BINDING,this._localSHBuffer)},e._updateWorldBoundDescriptors=function(t,e){this._worldBoundBuffer&&e.bindBuffer(qg.BINDING,this._worldBoundBuffer)},n(t,[{key:"subModels",get:function(){return this._subModels}},{key:"inited",get:function(){return this._inited}},{key:"worldBounds",get:function(){return this._worldBounds}},{key:"modelBounds",get:function(){return this._modelBounds}},{key:"localBuffer",get:function(){return this._localBuffer}},{key:"localSHBuffer",get:function(){return this._localSHBuffer}},{key:"worldBoundBuffer",get:function(){return this._worldBoundBuffer}},{key:"updateStamp",get:function(){return this._updateStamp}},{key:"useLightProbe",get:function(){return this._useLightProbe},set:function(t){this._useLightProbe=t,this.onMacroPatchesStateChanged()}},{key:"tetrahedronIndex",get:function(){return this._tetrahedronIndex},set:function(t){this._tetrahedronIndex=t}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t}},{key:"receiveShadow",get:function(){return this._receiveShadow},set:function(t){this._receiveShadow=t,this.onMacroPatchesStateChanged()}},{key:"castShadow",get:function(){return this._castShadow},set:function(t){this._castShadow=t}},{key:"receiveDirLight",get:function(){return this._receiveDirLight},set:function(t){this._receiveDirLight=t,this.onMacroPatchesStateChanged()}},{key:"node",get:function(){return this._node},set:function(t){this._node=t}},{key:"transform",get:function(){return this._transform},set:function(t){this._transform=t}},{key:"visFlags",get:function(){return this._visFlags},set:function(t){this._visFlags=t}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t}},{key:"bakeToReflectionProbe",get:function(){return this._bakeToReflectionProbe},set:function(t){this._bakeToReflectionProbe=t}},{key:"reflectionProbeType",get:function(){return this._reflectionProbeType},set:function(t){this._reflectionProbeType=t;for(var e=this._subModels,i=0;i<e.length;i++)e[i].useReflectionProbeType=t;this.onMacroPatchesStateChanged()}},{key:"reflectionProbeId",get:function(){return this._reflectionProbeId},set:function(t){this._reflectionProbeId=t}},{key:"reflectionProbeBlendId",get:function(){return this._reflectionProbeBlendId},set:function(t){this._reflectionProbeBlendId=t}},{key:"reflectionProbeBlendWeight",get:function(){return this._reflectionProbeBlendWeight},set:function(t){this._reflectionProbeBlendWeight=t}}]),t}(),xM=new on(0,0,-1),RM=new on,IM=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new on(1,-1,-1),e._illuminanceHDR=dg.SUN_ILLUM,e._illuminanceLDR=1,e._shadowEnabled=!1,e._shadowPcf=BT.HARD,e._shadowBias=1e-5,e._shadowNormalBias=0,e._shadowSaturation=1,e._shadowDistance=50,e._shadowInvisibleOcclusionRange=200,e._csmLevel=DT.LEVEL_4,e._csmNeedUpdate=!1,e._csmLayerLambda=.75,e._csmOptimizationMode=PT.DisableRotationFix,e._csmLayersTransition=!1,e._csmTransitionRange=.05,e._shadowFixedArea=!1,e._shadowNear=.1,e._shadowFar=10,e._shadowOrthoSize=5,e._type=sR.DIRECTIONAL,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.illuminance=dg.SUN_ILLUM,this.direction=new on(1,-1,-1)},i.update=function(){this._node&&this._node.hasChangedFlags&&(this.direction=on.transformQuat(RM,xM,this._node.worldRotation))},i.activate=function(){var t=v.director.root,e=t.pipeline;this._shadowEnabled?(this._shadowFixedArea||!e.pipelineSceneData.csmSupported?e.macros.CC_DIR_LIGHT_SHADOW_TYPE=1:this.csmLevel>1&&e.pipelineSceneData.csmSupported?(e.macros.CC_DIR_LIGHT_SHADOW_TYPE=2,e.macros.CC_CASCADED_LAYERS_TRANSITION=this._csmLayersTransition):e.macros.CC_DIR_LIGHT_SHADOW_TYPE=1,e.macros.CC_DIR_SHADOW_PCF_TYPE=this._shadowPcf):e.macros.CC_DIR_LIGHT_SHADOW_TYPE=0,t.onGlobalPipelineStateChanged()},n(e,[{key:"direction",get:function(){return this._dir},set:function(t){on.normalize(this._dir,t)}},{key:"illuminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this.illuminanceHDR=t:this.illuminanceLDR=t}},{key:"illuminanceHDR",get:function(){return this._illuminanceHDR},set:function(t){this._illuminanceHDR=t}},{key:"illuminanceLDR",get:function(){return this._illuminanceLDR},set:function(t){this._illuminanceLDR=t}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this.activate()}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this.activate()}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t}},{key:"shadowSaturation",get:function(){return this._shadowSaturation},set:function(t){this._shadowSaturation=t}},{key:"shadowDistance",get:function(){return this._shadowDistance},set:function(t){this._shadowDistance=Math.min(t,MT.MAX_FAR)}},{key:"shadowInvisibleOcclusionRange",get:function(){return this._shadowInvisibleOcclusionRange},set:function(t){this._shadowInvisibleOcclusionRange=Math.min(t,MT.MAX_FAR)}},{key:"csmLevel",get:function(){return this._csmLevel},set:function(t){this._csmLevel=t,this.activate()}},{key:"csmNeedUpdate",get:function(){return this._csmNeedUpdate},set:function(t){this._csmNeedUpdate=t}},{key:"csmLayerLambda",get:function(){return this._csmLayerLambda},set:function(t){this._csmLayerLambda=t}},{key:"csmOptimizationMode",get:function(){return this._csmOptimizationMode},set:function(t){this._csmOptimizationMode=t}},{key:"shadowFixedArea",get:function(){return this._shadowFixedArea},set:function(t){this._shadowFixedArea=t,this.activate()}},{key:"shadowNear",get:function(){return this._shadowNear},set:function(t){this._shadowNear=t}},{key:"shadowFar",get:function(){return this._shadowFar},set:function(t){this._shadowFar=Math.min(t,MT.MAX_FAR)}},{key:"shadowOrthoSize",get:function(){return this._shadowOrthoSize},set:function(t){this._shadowOrthoSize=t}},{key:"csmLayersTransition",get:function(){return this._csmLayersTransition},set:function(t){this._csmLayersTransition=t,this.activate()}},{key:"csmTransitionRange",get:function(){return this._csmTransitionRange},set:function(t){this._csmTransitionRange=t}}]),e}(AR),BM=function(t){function e(){var e;return(e=t.call(this)||this)._needUpdate=!1,e._size=.15,e._range=1,e._luminanceHDR=0,e._luminanceLDR=0,e._pos=void 0,e._aabb=void 0,e._aabb=Ss.create(),e._pos=new on,e._type=sR.SPHERE,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.size=.15,this.range=1,this.luminanceHDR=1700/TR(.15),this.luminanceLDR=1},i.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var t=this._range;Ss.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,t,t,t),this._needUpdate=!1}},n(e,[{key:"position",get:function(){return this._pos}},{key:"size",get:function(){return this._size},set:function(t){this._size=t}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._needUpdate=!0}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this.luminanceHDR=t:this.luminanceLDR=t}},{key:"luminanceHDR",get:function(){return this._luminanceHDR},set:function(t){this._luminanceHDR=t}},{key:"luminanceLDR",set:function(t){this._luminanceLDR=t}},{key:"aabb",get:function(){return this._aabb}}]),e}(AR),DM=new on(0,0,-1),PM=new Sn,OM=new In,MM=new In,LM=new In,NM=new In,FM=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new on(1,-1,-1),e._range=5,e._spotAngle=Math.cos(Math.PI/6),e._pos=void 0,e._aabb=void 0,e._frustum=void 0,e._angle=0,e._needUpdate=!1,e._size=.15,e._luminanceHDR=0,e._luminanceLDR=0,e._shadowEnabled=!1,e._shadowPcf=BT.HARD,e._shadowBias=1e-5,e._shadowNormalBias=0,e._aabb=Ss.create(),e._frustum=xs.create(),e._pos=new on,e._type=sR.SPOT,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.size=.15,this.luminanceHDR=1700/TR(.15),this.luminanceLDR=1,this.range=Math.cos(Math.PI/6),this._dir.set(new on(1,-1,-1))},i.update=function(){this._node&&(this._node.hasChangedFlags||this._needUpdate)&&(this._node.getWorldPosition(this._pos),on.transformQuat(this._dir,DM,this._node.getWorldRotation(PM)),on.normalize(this._dir,this._dir),Ss.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,this._range,this._range,this._range),this._node.getWorldRT(OM),In.invert(OM,OM),In.perspective(MM,this._angle,1,.001,this._range),In.multiply(LM,MM,OM),this._frustum.update(LM,NM),this._needUpdate=!1)},n(e,[{key:"position",get:function(){return this._pos}},{key:"size",get:function(){return this._size},set:function(t){this._size=t}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._needUpdate=!0}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this.luminanceHDR=t:this.luminanceLDR=t}},{key:"luminanceHDR",get:function(){return this._luminanceHDR},set:function(t){this._luminanceHDR=t}},{key:"luminanceLDR",get:function(){return this._luminanceLDR},set:function(t){this._luminanceLDR=t}},{key:"direction",get:function(){return this._dir}},{key:"spotAngle",get:function(){return this._spotAngle},set:function(t){this._angle=t,this._spotAngle=Math.cos(.5*t),this._needUpdate=!0}},{key:"angle",get:function(){return this._angle}},{key:"aabb",get:function(){return this._aabb}},{key:"frustum",get:function(){return this._frustum}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t}}]),e}(AR),kM=function(t){function e(){var e;return(e=t.call(this)||this)._needUpdate=!1,e._range=1,e._luminanceHDR=0,e._luminanceLDR=0,e._pos=void 0,e._aabb=void 0,e._aabb=Ss.create(),e._pos=new on,e._type=sR.POINT,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.range=1,this.luminanceHDR=1700/TR(1),this.luminanceLDR=1},i.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var t=this._range;Ss.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,t,t,t),this._needUpdate=!1}},n(e,[{key:"position",get:function(){return this._pos}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._needUpdate=!0}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this.luminanceHDR=t:this.luminanceLDR=t}},{key:"luminanceHDR",get:function(){return this._luminanceHDR},set:function(t){this._luminanceHDR=t}},{key:"luminanceLDR",set:function(t){this._luminanceLDR=t}},{key:"aabb",get:function(){return this._aabb}}]),e}(AR),VM=new on(0,0,-1),GM=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new on(0,0,-1),e._pos=new on(0,0,0),e._scale=new on(1,1,1),e._right=new on(1,0,0),e._illuminanceHDR=dg.SUN_ILLUM,e._illuminanceLDR=1,e._type=sR.RANGED_DIRECTIONAL,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.illuminance=dg.SUN_ILLUM},i.update=function(){this._node&&this._node.hasChangedFlags&&(this._node.getWorldPosition(this._pos),this._node.getWorldScale(this._scale),on.transformQuat(this._dir,VM,this._node.worldRotation),on.transformQuat(this._right,on.RIGHT,this._node.worldRotation))},n(e,[{key:"direction",get:function(){return this._dir}},{key:"right",get:function(){return this._right}},{key:"position",get:function(){return this._pos}},{key:"scale",get:function(){return this._scale}},{key:"illuminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?this.illuminanceHDR=t:this.illuminanceLDR=t}},{key:"illuminanceHDR",get:function(){return this._illuminanceHDR},set:function(t){this._illuminanceHDR=t}},{key:"illuminanceLDR",get:function(){return this._illuminanceLDR},set:function(t){this._illuminanceLDR=t}}]),e}(AR),UM=function(){function t(){this.screenUsagePercentage=1,this._models=[]}var e=t.prototype;return e.addModel=function(t){this._models.splice(0,0,t)},e.eraseModel=function(t){var e=this._models.indexOf(t);e>=0&&this._models.splice(e,1)},e.clearModels=function(){this._models.length=0},n(t,[{key:"models",get:function(){return this._models}}]),t}(),zM=function(){function t(){this.scene=void 0,this.node=null,this._device=void 0,this.enabled=!0,this._localBoundaryCenter=new on(0,0,0),this._objectSize=1,this._lodDataArray=[],this._lockedLODLevelVec=[],this._isLockLevelChanged=!1,this._device=Ed.gfxDevice}var e=t.prototype;return e.attachToScene=function(t){this.scene=t},e.detachFromScene=function(){this.scene=null},e.lockLODLevels=function(t){if(t.length!==this._lockedLODLevelVec.length)this._isLockLevelChanged=!0;else for(var e=t.length,i=0;i<e;i++)if(t[i]!==this._lockedLODLevelVec[i]){this._isLockLevelChanged=!0;break}this._lockedLODLevelVec=t.slice()},e.isLockLevelChanged=function(){return this._isLockLevelChanged},e.resetLockChangeFlag=function(){this._isLockLevelChanged=!1},e.getLockedLODLevels=function(){return this._lockedLODLevelVec},e.clearLODs=function(){this._lodDataArray.length=0},e.insertLOD=function(t,e){this._lodDataArray.splice(t,0,e)},e.updateLOD=function(t,e){this._lodDataArray[t]=e},e.eraseLOD=function(t){this._lodDataArray.splice(t,1)},e.getVisibleLODLevel=function(t){for(var e=this.getScreenUsagePercentage(t),i=-1,n=0;n<this.lodCount;++n)if(e>=this.lodDataArray[n].screenUsagePercentage){i=n;break}return i},e.getScreenUsagePercentage=function(t){return this.node?(t.projectionType===wx.PERSPECTIVE&&(e=on.len(this.localBoundaryCenter.transformMat4(this.node.worldMatrix).subtract(t.node.worldPosition))),this.distanceToScreenUsagePercentage(t,e,this.getWorldSpaceSize())):0;var e},e.distanceToScreenUsagePercentage=function(t,e,i){return t.projectionType===wx.PERSPECTIVE?i*t.matProj.m05/(2*e):i*t.matProj.m05*.5},e.getWorldSpaceSize=function(){var t=this.node.scale;return Math.max(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z))*this.objectSize},n(t,[{key:"localBoundaryCenter",get:function(){return this._localBoundaryCenter.clone()},set:function(t){this._localBoundaryCenter.set(t)}},{key:"lodCount",get:function(){return this._lodDataArray.length}},{key:"objectSize",get:function(){return this._objectSize},set:function(t){this._objectSize=t}},{key:"lodDataArray",get:function(){return this._lodDataArray}}]),t}(),HM=Object.freeze({__proto__:null,get CameraFOVAxis(){return Cx},get CameraProjection(){return wx},get CameraAperture(){return xx},get CameraISO(){return Rx},get CameraShutter(){return Ix},get CameraType(){return Bx},get TrackingType(){return Dx},get CameraUsage(){return Px},SKYBOX_FLAG:Ux,Camera:Hx,get ModelType(){return dM},Model:wM,SubModel:_M,Ambient:dg,EnvironmentLightingType:VT,Skybox:GT,ShadowSize:RT,ShadowType:IT,PCFType:BT,CSMLevel:DT,CSMOptimizationMode:PT,Shadows:MT,FogType:zT,FOG_TYPE_NONE:HT,Fog:WT,Octree:fP,Skin:LP,ColorTemperatureToRGB:hR,get LightType(){return sR},nt2lm:TR,Light:AR,DirectionalLight:IM,SphereLight:BM,SpotLight:FM,PointLight:kM,RangedDirectionalLight:GM,get ProbeClearFlag(){return tR},get ProbeType(){return eR},ReflectionProbe:aR,LODData:UM,LODGroup:zM,ToneMappingType:dE,PostSettings:fE}),WM=function(){function t(t){this._root=void 0,this._name="",this._cameras=[],this._models=[],this._lodGroups=[],this._batches=[],this._directionalLights=[],this._sphereLights=[],this._spotLights=[],this._pointLights=[],this._rangedDirLights=[],this._mainLight=null,this._modelId=0,this._lodStateCache=null,this._root=t}t.registerCreateFunc=function(e){e._createSceneFun=function(e){return new t(e)}};var e=t.prototype;return e.initialize=function(t){return this._name=t.name,this._lodStateCache=new XM(this),!0},e.update=function(t){var e=this._mainLight;e&&e.update();for(var i=this._sphereLights,n=0;n<i.length;n++)i[n].update();for(var r=this._spotLights,s=0;s<r.length;s++)r[s].update();for(var o=this._pointLights,a=0;a<o.length;a++)o[a].update();for(var h=this._rangedDirLights,u=0;u<h.length;u++)h[u].update();for(var l=this._models,c=0;c<l.length;c++){var _=l[c];_.enabled&&(_.updateTransform(t),_.updateUBOs(t))}this._lodStateCache.updateLodState()},e.destroy=function(){this.removeCameras(),this.removeSphereLights(),this.removeSpotLights(),this.removeRangedDirLights(),this.removeModels(),this.removeLODGroups(),this._lodStateCache.clearCache()},e.isCulledByLod=function(t,e){return this._lodStateCache.isLodModelCulled(t,e)},e.addCamera=function(t){t.attachToScene(this),this._cameras.push(t),this._lodStateCache.addCamera(t)},e.removeCamera=function(t){for(var e=0;e<this._cameras.length;++e)if(this._cameras[e]===t)return this._cameras.splice(e,1),t.detachFromScene(),void this._lodStateCache.removeCamera(t)},e.removeCameras=function(){for(var t,e=d(this._cameras);!(t=e()).done;){var i=t.value;i.detachFromScene(),this._lodStateCache.removeCamera(i)}this._cameras.splice(0)},e.setMainLight=function(t){this._mainLight=t,this._mainLight&&this._mainLight.activate()},e.unsetMainLight=function(t){if(this._mainLight===t){var e=this._directionalLights;if(e.length)return this.setMainLight(e[e.length-1]),void(this._mainLight.node&&(this._mainLight.node.hasChangedFlags|=rm.ROTATION));this.setMainLight(null)}},e.addDirectionalLight=function(t){t.attachToScene(this),this._directionalLights.push(t)},e.removeDirectionalLight=function(t){for(var e=0;e<this._directionalLights.length;++e)if(this._directionalLights[e]===t)return t.detachFromScene(),void this._directionalLights.splice(e,1)},e.addSphereLight=function(t){t.attachToScene(this),this._sphereLights.push(t)},e.removeSphereLight=function(t){for(var e=0;e<this._sphereLights.length;++e)if(this._sphereLights[e]===t)return t.detachFromScene(),void this._sphereLights.splice(e,1)},e.addSpotLight=function(t){t.attachToScene(this),this._spotLights.push(t)},e.removeSpotLight=function(t){for(var e=0;e<this._spotLights.length;++e)if(this._spotLights[e]===t)return t.detachFromScene(),void this._spotLights.splice(e,1)},e.removeSphereLights=function(){for(var t=0;t<this._sphereLights.length;++t)this._sphereLights[t].detachFromScene();this._sphereLights.length=0},e.removeSpotLights=function(){for(var t=0;t<this._spotLights.length;++t)this._spotLights[t].detachFromScene();this._spotLights.length=0},e.addPointLight=function(t){t.attachToScene(this),this._pointLights.push(t)},e.removePointLight=function(t){for(var e=0;e<this._pointLights.length;++e)if(this._pointLights[e]===t)return t.detachFromScene(),void this._pointLights.splice(e,1)},e.removePointLights=function(){for(var t=0;t<this._pointLights.length;++t)this._pointLights[t].detachFromScene();this._pointLights.length=0},e.addRangedDirLight=function(t){t.attachToScene(this),this._rangedDirLights.push(t)},e.removeRangedDirLight=function(t){for(var e=0;e<this._rangedDirLights.length;++e)if(this._rangedDirLights[e]===t)return t.detachFromScene(),void this._rangedDirLights.splice(e,1)},e.removeRangedDirLights=function(){for(var t=0;t<this._rangedDirLights.length;++t)this._rangedDirLights[t].detachFromScene();this._rangedDirLights.length=0},e.addModel=function(t){t.attachToScene(this),this._models.push(t)},e.removeModel=function(t){for(var e=0;e<this._models.length;++e)if(this._models[e]===t)return this._lodStateCache.removeModel(t),t.detachFromScene(),void this._models.splice(e,1)},e.removeModels=function(){for(var t,e=d(this._models);!(t=e()).done;){var i=t.value;this._lodStateCache.removeModel(i),i.detachFromScene(),i.destroy()}this._models.length=0},e.addBatch=function(t){this._batches.push(t)},e.removeBatch=function(t){for(var e=0;e<this._batches.length;++e)if(this._batches[e]===t)return void this._batches.splice(e,1)},e.removeBatches=function(){this._batches.length=0},e.addLODGroup=function(t){this._lodGroups.push(t),t.attachToScene(this),this._lodStateCache.addLodGroup(t)},e.removeLODGroup=function(t){var e=this._lodGroups.indexOf(t);e>=0&&(this._lodGroups.splice(e,1),t.detachFromScene(),this._lodStateCache.removeLodGroup(t))},e.removeLODGroups=function(){for(var t,e=d(this._lodGroups);!(t=e()).done;){var i=t.value;this._lodStateCache.removeLodGroup(i)}this._lodGroups.length=0},e.onGlobalPipelineStateChanged=function(){for(var t,e=d(this._models);!(t=e()).done;)t.value.onGlobalPipelineStateChanged()},e.generateModelId=function(){return this._modelId++},n(t,[{key:"root",get:function(){return this._root}},{key:"name",get:function(){return this._name}},{key:"cameras",get:function(){return this._cameras}},{key:"mainLight",get:function(){return this._mainLight}},{key:"sphereLights",get:function(){return this._sphereLights}},{key:"spotLights",get:function(){return this._spotLights}},{key:"pointLights",get:function(){return this._pointLights}},{key:"rangedDirLights",get:function(){return this._rangedDirLights}},{key:"models",get:function(){return this._models}},{key:"batches",get:function(){return this._batches}},{key:"lodGroups",get:function(){return this._lodGroups}}]),t}(),jM=function(){this.usedLevel=-1,this.lastUsedLevel=-1,this.transformDirty=!0},XM=function(){function t(t){this._renderScene=null,this._modelsInLODGroup=new Map,this._lodStateInCamera=new Map,this._newAddedLodGroupVec=new Array,this._levelModels=new Map,this._renderScene=t}var e=t.prototype;return e.addCamera=function(t){for(var e,i=d(this._renderScene.lodGroups);!(e=i()).done;){var n=e.value.node.layer;if((t.visibility&n)===n){this._lodStateInCamera.has(t)||this._lodStateInCamera.set(t,new Map);break}}},e.removeCamera=function(t){this._lodStateInCamera.has(t)&&this._lodStateInCamera.delete(t)},e.addLodGroup=function(t){this._newAddedLodGroupVec.push(t);for(var e,i=d(this._renderScene.cameras);!(e=i()).done;){var n=e.value;if(!this._lodStateInCamera.has(n)){var r=t.node.layer;(n.visibility&r)===r&&this._lodStateInCamera.set(n,new Map)}}},e.removeLodGroup=function(t){for(var e=0;e<t.lodCount;e++)for(var i,n=d(t.lodDataArray[e].models);!(i=n()).done;){var r=i.value;this._modelsInLODGroup.delete(r)}for(var s,o=d(this._lodStateInCamera);!(s=o()).done;)s.value[1].delete(t);this._levelModels.delete(t)},e.removeModel=function(t){this._modelsInLODGroup.has(t)&&this._modelsInLODGroup.delete(t)},e.updateLodState=function(){for(var t,e=this,i=d(this._newAddedLodGroupVec);!(t=i()).done;){var n=t.value,r=this._levelModels.get(n);r||(r=new Map,this._levelModels.set(n,r));for(var s=0;s<n.lodCount;s++){var o=r.get(s);o||(o=new Array);for(var a,h=d(n.lodDataArray[s].models);!(a=h()).done;){var u=a.value,l=this._modelsInLODGroup.get(u);l||(l=new Map),this._modelsInLODGroup.set(u,l),o.push(u)}r.set(s,o)}}this._newAddedLodGroupVec.length=0;for(var c,_=function(){var t=c.value;if(t.enabled){var i=t.getLockedLODLevels();if(i.length>0){if(t.node.hasChangedFlags>0)for(var n,r=d(e._lodStateInCamera);!(n=r()).done;){var s=n.value,o=s[1].get(t);o||(o=new jM,s[1].set(t,o)),o.transformDirty=!0}if(t.isLockLevelChanged()){t.resetLockChangeFlag();var a=e._levelModels.get(t);if(a){a.forEach((function(t){t.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&i.clear()}))}));for(var h,u=d(i);!(h=u()).done;){var l=h.value,_=a.get(l);_&&_.forEach((function(t){var i=e._modelsInLODGroup.get(t);if(i&&t.node&&t.node.active)for(var n,r=d(e._lodStateInCamera);!(n=r()).done;){var s=n.value;i.set(s[0],!0)}}))}}}return 0}for(var f,p=!1,m=d(e._lodStateInCamera);!(f=m()).done;){var g=f.value,y=g[1].get(t);y||(y=new jM,g[1].set(t,y));var v=g[0].node.hasChangedFlags,S=t.node.hasChangedFlags;if(v>0||S>0||y.transformDirty){y.transformDirty&&(y.transformDirty=!1);var T=t.getVisibleLODLevel(g[0]);T!==y.usedLevel&&(y.lastUsedLevel=y.usedLevel,y.usedLevel=T,p=!0)}}var A=e._levelModels.get(t);if(!A)return 0;t.isLockLevelChanged()?(t.resetLockChangeFlag(),A.forEach((function(t){t.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&i.clear()}))})),p=!0):p&&e._lodStateInCamera.forEach((function(i){var n=i.get(t);if(n&&n.usedLevel!==n.lastUsedLevel){var r=A.get(n.lastUsedLevel);r&&r.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&i.clear()}))}})),p&&e._lodStateInCamera.forEach((function(i,n){var r=i.get(t);if(r){var s=r.usedLevel,o=A.get(s);o&&o.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&t.node&&t.node.active&&i.set(n,!0)}))}}))}},f=d(this._renderScene.lodGroups);!(c=f()).done;)_()},e.isLodModelCulled=function(t,e){var i=this._modelsInLODGroup.get(e);return!!i&&!i.has(t)},e.clearCache=function(){this._levelModels.clear(),this._modelsInLODGroup.clear(),this._lodStateInCamera.clear(),this._newAddedLodGroupVec.length=0},e.isLodGroupVisibleByCamera=function(t,e){var i=t.node.layer;return(e.visibility&i)===i},t}(),qM=((SM={})[Sl.PORTRAIT]=Ul.IDENTITY,SM[Sl.LANDSCAPE_RIGHT]=Ul.ROTATE_90,SM[Sl.PORTRAIT_UPSIDE_DOWN]=Ul.ROTATE_180,SM[Sl.LANDSCAPE_LEFT]=Ul.ROTATE_270,SM),YM=function(){function t(){this._title="",this._width=1,this._height=1,this._swapchain=null,this._renderPass=null,this._colorTextures=[],this._depthStencilTexture=null,this._cameras=[],this._hasOnScreenAttachments=!1,this._hasOffScreenAttachments=!1,this._framebuffer=null,this._device=null}t.registerCreateFunc=function(e){e._createWindowFun=function(){return new t}};var e=t.prototype;return e.initialize=function(t,e){if(void 0!==e.title&&(this._title=e.title),void 0!==e.swapchain&&(this._swapchain=e.swapchain),this._width=e.width,this._height=e.height,this._device=t,this._renderPass=t.createRenderPass(e.renderPassInfo),e.swapchain)this._swapchain=e.swapchain,this._colorTextures.push(e.swapchain.colorTexture),this._depthStencilTexture=e.swapchain.depthStencilTexture;else{for(var i=0;i<e.renderPassInfo.colorAttachments.length;i++){var n=new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED|Ql.TRANSFER_SRC,e.renderPassInfo.colorAttachments[i].format,this._width,this._height);e.externalFlag&&(e.externalFlag&Zl.EXTERNAL_NORMAL||e.externalFlag&Zl.EXTERNAL_OES)&&(n.flags|=e.externalFlag,n.externalRes=e.externalResLow?e.externalResLow:0),this._colorTextures.push(t.createTexture(n))}e.renderPassInfo.depthStencilAttachment.format!==Hl.UNKNOWN&&(this._depthStencilTexture=t.createTexture(new Qc(Jl.TEX2D,Ql.DEPTH_STENCIL_ATTACHMENT|Ql.SAMPLED,e.renderPassInfo.depthStencilAttachment.format,this._width,this._height)),this._hasOffScreenAttachments=!0)}return this._framebuffer=t.createFramebuffer(new S_(this._renderPass,this._colorTextures,this._depthStencilTexture)),!0},e.destroy=function(){this.clearCameras(),this._framebuffer&&(this._framebuffer.destroy(),this._framebuffer=null),this._depthStencilTexture&&(this._depthStencilTexture.destroy(),this._depthStencilTexture=null);for(var t=0;t<this._colorTextures.length;t++){var e=this._colorTextures[t];e&&e.destroy()}this._colorTextures.length=0,this._device=null},e.resize=function(t,e){if(this._swapchain)this._swapchain.resize(t,e,qM[El.orientation]),this._width=this._swapchain.width,this._height=this._swapchain.height;else{for(var i=0;i<this._colorTextures.length;i++)this._colorTextures[i].resize(t,e);this._depthStencilTexture&&this._depthStencilTexture.resize(t,e),this._width=t,this._height=e}this.framebuffer&&(this.framebuffer.destroy(),this._framebuffer=this._device.createFramebuffer(new S_(this._renderPass,this._colorTextures,this._depthStencilTexture)));for(var n,r=d(this._cameras);!(n=r()).done;)n.value.resize(t,e)},e.extractRenderCameras=function(t){for(var e=0;e<this._cameras.length;e++){var i=this._cameras[e];i.enabled&&(i.update(),t.push(i))}},e.attachCamera=function(t){for(var e=0;e<this._cameras.length;e++)if(this._cameras[e]===t)return;this._cameras.push(t),this.sortCameras()},e.detachCamera=function(t){for(var e=0;e<this._cameras.length;++e)if(this._cameras[e]===t)return void this._cameras.splice(e,1)},e.clearCameras=function(){this._cameras.length=0},e.sortCameras=function(){this._cameras.sort((function(t,e){return t.priority-e.priority}))},n(t,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"swapchain",get:function(){return this._swapchain}},{key:"framebuffer",get:function(){return this._framebuffer}},{key:"cameras",get:function(){return this._cameras}}]),t}();!function(t){t[t.NONE=-1]="NONE",t[t.LEFT=0]="LEFT",t[t.RIGHT=1]="RIGHT"}(TM||(TM={})),function(t){t[t.SESSION_RUNNING=2]="SESSION_RUNNING",t[t.VIEW_COUNT=6]="VIEW_COUNT",t[t.SWAPCHAIN_WIDTH=7]="SWAPCHAIN_WIDTH",t[t.SWAPCHAIN_HEIGHT=8]="SWAPCHAIN_HEIGHT",t[t.DEVICE_IPD=37]="DEVICE_IPD",t[t.SPLIT_AR_GLASSES=42]="SPLIT_AR_GLASSES"}(AM||(AM={})),function(t){t[t.VIEW_LEFT=0]="VIEW_LEFT",t[t.HAND_LEFT=1]="HAND_LEFT",t[t.AIM_LEFT=2]="AIM_LEFT",t[t.VIEW_RIGHT=3]="VIEW_RIGHT",t[t.HAND_RIGHT=4]="HAND_RIGHT",t[t.AIM_RIGHT=5]="AIM_RIGHT",t[t.HEAD_MIDDLE=6]="HEAD_MIDDLE"}(bM||(bM={}));var KM=t("aE",function(){function t(t){var e=this;this._createSceneFun=null,this._createWindowFun=null,this._device=void 0,this._windows=[],this._mainWindow=null,this._curWindow=null,this._tempWindow=null,this._usesCustomPipeline=!0,this._pipeline=null,this._pipelineEvent=null,this._classicPipeline=null,this._customPipeline=null,this._batcher=null,this._dataPoolMgr=void 0,this._scenes=[],this._modelPools=new Map,this._cameraPool=null,this._lightPools=new Map,this._debugView=new LR,this._fpsTime=0,this._frameCount=0,this._fps=0,this._fixedFPS=0,this._useDeferredPipeline=!1,this._fixedFPSFrameTime=0,this._cumulativeTime=0,this._frameTime=0,this._cameraList=[],this._device=t,this._dataPoolMgr=v.internal.DataPoolManager&&new v.internal.DataPoolManager(t),WM.registerCreateFunc(this),YM.registerCreateFunc(this),this._cameraPool=new Bu((function(){return new Hx(e._device)}),4,(function(t){return t.destroy()}))}var e=t.prototype;return e.initialize=function(){var t,e=Ed.swapchain,i=new __;i.format=e.colorTexture.format;var n=new d_;n.format=e.depthStencilTexture.format,n.depthStoreOp=cc.DISCARD,n.stencilStoreOp=cc.DISCARD;var r=new m_([i],n);this._mainWindow=this.createWindow({title:"rootMainWindow",width:e.width,height:e.height,renderPassInfo:r,swapchain:e}),this._curWindow=this._mainWindow;var s=Ee.querySettings(be.Category.ANIMATION,"customJointTextureLayouts")||[];null===(t=this._dataPoolMgr)||void 0===t||t.jointTexturePool.registerCustomTextureLayouts(s),this._resizeMaxJointForDS()},e.destroy=function(){this.destroyScenes(),this._pipeline&&(this._pipeline.destroy(),this._pipeline=null,this._pipelineEvent=null),this._batcher&&(this._batcher.destroy(),this._batcher=null),this._curWindow=null,this._mainWindow=null,this.dataPoolManager.clear(),v.rendering&&v.rendering.destroy()},e.resize=function(t,e){for(var i,n=d(this._windows);!(i=n()).done;){var r=i.value;r.swapchain&&r.resize(t,e)}},e.setRenderPipeline=function(t){var e=v.internal,i=v.director,n=v.rendering;t instanceof fO&&(this._useDeferredPipeline=!0);var r=!1;if(t||(t=hM(),r=!0),this._useDeferredPipeline&&this.device.hasFeature(zl.COMPUTE_SHADER)||(t.clusterEnabled=!1),t.bloomEnabled=!1,""!==Ce.CUSTOM_PIPELINE_NAME&&n&&this.usesCustomPipeline?(this._customPipeline=n.createCustomPipeline(),r=!0,this._pipeline=this._customPipeline,this._pipelineEvent=t):(this._classicPipeline=t,this._pipeline=this._classicPipeline,this._pipelineEvent=this._classicPipeline,this._usesCustomPipeline=!1),(Ee.querySettings(be.Category.RENDERING,"renderMode")!==yd.HEADLESS||this._classicPipeline)&&!this._pipeline.activate(this._mainWindow.swapchain))return r&&this._pipeline.destroy(),this._classicPipeline=null,this._customPipeline=null,this._pipeline=null,this._pipelineEvent=null,!1;var s=i.getScene();return s&&s.globals.activate(),this.onGlobalPipelineStateChanged(),!(!this._batcher&&e.Batcher2D&&(this._batcher=new e.Batcher2D(this),!this._batcher.initialize())&&(this.destroy(),1))},e.onGlobalPipelineStateChanged=function(){for(var t=0;t<this._scenes.length;t++)this._scenes[t].onGlobalPipelineStateChanged();this._pipeline.pipelineSceneData.skybox.enabled&&this._pipeline.pipelineSceneData.skybox.model.onGlobalPipelineStateChanged(),this._pipeline.onGlobalPipelineStateChanged()},e.activeWindow=function(t){this._curWindow=t},e.resetCumulativeTime=function(){this._cumulativeTime=0},e.frameMove=function(t){var e;this._frameTime=t,++this._frameCount,this._cumulativeTime+=t,this._fpsTime+=t,this._fpsTime>1&&(this._fps=this._frameCount,this._frameCount=0,this._fpsTime=0),null!==(e=globalThis.__globalXR)&&void 0!==e&&e.isWebXR?this._doWebXRFrameMove():(this._frameMoveBegin(),this._frameMoveProcess(),this._frameMoveEnd())},e.createWindow=function(t){var e=this._createWindowFun(this);return e.initialize(this.device,t),this._windows.push(e),e},e.destroyWindow=function(t){for(var e=0;e<this._windows.length;++e)if(this._windows[e]===t)return t.destroy(),void this._windows.splice(e,1)},e.destroyWindows=function(){for(var t,e=d(this._windows);!(t=e()).done;)t.value.destroy();this._windows.length=0},e.createScene=function(t){var e=this._createSceneFun(this);return e.initialize(t),this._scenes.push(e),e},e.destroyScene=function(t){for(var e=0;e<this._scenes.length;++e)if(this._scenes[e]===t)return t.destroy(),void this._scenes.splice(e,1)},e.destroyScenes=function(){for(var t,e=d(this._scenes);!(t=e()).done;)t.value.destroy();this._scenes.length=0},e.createModel=function(t){var e=this._modelPools.get(t);e||(this._modelPools.set(t,new Bu((function(){return new t}),10,(function(t){return t.destroy()}))),e=this._modelPools.get(t));var i=e.alloc();return i.initialize(),i},e.destroyModel=function(t){var e=this._modelPools.get(t.constructor);e?(e.free(t),t.scene&&t.scene.removeModel(t)):Y(1300,t.constructor.name),t.destroy()},e.createCamera=function(){return this._cameraPool.alloc()},e.createLight=function(t){var e=this._lightPools.get(t);e||(this._lightPools.set(t,new Bu((function(){return new t}),4,(function(t){return t.destroy()}))),e=this._lightPools.get(t));var i=e.alloc();return i.initialize(),i},e.destroyLight=function(t){if(t.scene)switch(t.type){case sR.DIRECTIONAL:t.scene.removeDirectionalLight(t);break;case sR.SPHERE:t.scene.removeSphereLight(t);break;case sR.SPOT:t.scene.removeSpotLight(t);break;case sR.POINT:t.scene.removePointLight(t);break;case sR.RANGED_DIRECTIONAL:t.scene.removeRangedDirLight(t)}t.destroy()},e.recycleLight=function(t){var e=this._lightPools.get(t.constructor);if(e&&(e.free(t),t.scene))switch(t.type){case sR.DIRECTIONAL:t.scene.removeDirectionalLight(t);break;case sR.SPHERE:t.scene.removeSphereLight(t);break;case sR.SPOT:t.scene.removeSpotLight(t);break;case sR.POINT:t.scene.removePointLight(t);break;case sR.RANGED_DIRECTIONAL:t.scene.removeRangedDirLight(t)}},e._doWebXRFrameMove=function(){var t=globalThis.__globalXR;if(t){var e=this._windows,i=this._cameraList,n=t.webXRMatProjs?t.webXRMatProjs.length:1;t.webXRWindowMap||(t.webXRWindowMap=new Map);for(var r=[],s=t.webxrHmdPoseInfos,o=0;o<n;o++){for(var a,h=d(e);!(a=h()).done;){var u=a.value;r=r.concat(u.cameras),u.swapchain&&t.webXRWindowMap.set(u,o)}if(s){for(var l=[0,0,0],c=0;c<s.length;c++){var _=s[c];if(_.code===bM.VIEW_LEFT&&o===TM.LEFT||_.code===bM.VIEW_RIGHT&&o===TM.RIGHT){l[0]=_.position.x,l[1]=_.position.y,l[2]=_.position.z;break}}for(var f,p=d(r);!(f=p()).done;){var m=f.value;m.trackingType!==Dx.NO_TRACKING&&m.node&&(m.trackingType===Dx.ROTATION&&(l=[0,0,0]),m.node.setPosition(l[0],l[1],l[2]))}}r.length=0,this._frameMoveBegin(),this._frameMoveProcess();for(var g=i.length-1;g>=0;g--){var y=i[g];(o===TM.LEFT&&y.cameraType===Bx.RIGHT_EYE||o===TM.RIGHT&&y.cameraType===Bx.LEFT_EYE)&&i.splice(g,1)}this._frameMoveEnd()}}},e._frameMoveBegin=function(){for(var t=0;t<this._scenes.length;++t)this._scenes[t].removeBatches();this._cameraList.length=0},e._frameMoveProcess=function(){for(var t=v.director,e=this._windows,i=this._cameraList,n=0;n<e.length;n++)e[n].extractRenderCameras(i);if(this._pipeline&&i.length>0){this._device.acquire([Ed.swapchain]);var r=this._scenes,s=t.getTotalFrames();this._batcher&&(this._batcher.update(),this._batcher.uploadBuffers());for(var o=0;o<r.length;o++)r[o].update(s)}},e._frameMoveEnd=function(){var t=v.director,e=v.Director,i=this._cameraList;if(this._pipeline&&i.length>0){t.emit(e.EVENT_BEFORE_COMMIT),i.sort((function(t,e){return t.priority-e.priority}));for(var n=0;n<i.length;++n){var r;null===(r=i[n].geometryRenderer)||void 0===r||r.update()}t.emit(e.EVENT_BEFORE_RENDER),this._pipeline.render(i),t.emit(e.EVENT_AFTER_RENDER),this._device.present()}this._batcher&&this._batcher.reset()},e._resizeMaxJointForDS=function(){var t=Math.max((Bg.COUNT+Dg.COUNT+Pg.COUNT+Xg.COUNT+qg.COUNT)/4,100),e=Math.floor((Ed.gfxDevice.capabilities.maxVertexUniformVectors-t)/3);ny(e=e<256?e:256)},n(t,[{key:"device",get:function(){return this._device}},{key:"mainWindow",get:function(){return this._mainWindow}},{key:"curWindow",get:function(){return this._curWindow},set:function(t){this._curWindow=t}},{key:"tempWindow",get:function(){return this._tempWindow},set:function(t){this._tempWindow=t}},{key:"windows",get:function(){return this._windows}},{key:"usesCustomPipeline",get:function(){return this._usesCustomPipeline}},{key:"pipeline",get:function(){return this._pipeline}},{key:"customPipeline",get:function(){return this._customPipeline}},{key:"pipelineEvent",get:function(){return this._pipelineEvent}},{key:"batcher2D",get:function(){return this._batcher}},{key:"scenes",get:function(){return this._scenes}},{key:"debugView",get:function(){return this._debugView}},{key:"cumulativeTime",get:function(){return this._cumulativeTime}},{key:"frameTime",get:function(){return this._frameTime}},{key:"frameCount",get:function(){return this._frameCount}},{key:"fps",get:function(){return this._fps}},{key:"fixedFPS",get:function(){return this._fixedFPS},set:function(t){t>0?(this._fixedFPS=t,this._fixedFPSFrameTime=1e3/t):this._fixedFPSFrameTime=0}},{key:"dataPoolManager",get:function(){return this._dataPoolMgr}},{key:"useDeferredPipeline",get:function(){return this._useDeferredPipeline}},{key:"cameraList",get:function(){return this._cameraList}}]),t}());v.Root=KM,pi.Attr.setClassAttr(ep,"target","type","Object"),pi.Attr.setClassAttr(ep,"target","ctor",Jm);var JM,QM=new Array(16),ZM=null,$M=new Ln,tL=[om.TOUCH_START,om.TOUCH_MOVE,om.TOUCH_END,om.TOUCH_CANCEL],eL=[om.MOUSE_DOWN,om.MOUSE_ENTER,om.MOUSE_MOVE,om.MOUSE_LEAVE,om.MOUSE_UP,om.MOUSE_WHEEL];!function(t){t[t.ADD_POINTER_EVENT_PROCESSOR=0]="ADD_POINTER_EVENT_PROCESSOR",t[t.REMOVE_POINTER_EVENT_PROCESSOR=1]="REMOVE_POINTER_EVENT_PROCESSOR",t[t.MARK_LIST_DIRTY=2]="MARK_LIST_DIRTY"}(JM||(JM={}));var iL,nL=function(){function t(t){this.claimedTouchIdList=[],this.maskList=null,this.cachedCameraPriority=0,this.previousMouseIn=!1,this.bubblingTarget=null,this.capturingTarget=null,this.shouldHandleEventMouse=!1,this.shouldHandleEventTouch=!1,this._dispatchingTouch=null,this._isEnabled=!1,this._node=void 0,this._node=t}var e=t.prototype;return e.setEnabled=function(e,i){if(void 0===i&&(i=!1),this._isEnabled!==e){this._isEnabled=e;var n=this.node.children;if(e&&this._attachMask(),t.callbacksInvoker.emit(JM.MARK_LIST_DIRTY),i&&n.length>0)for(var r=0;r<n.length;++r)n[r].eventProcessor.setEnabled(e,!0)}},e.reattach=function(){var e,i=this;this.node.walk((function(n){e||(e=i._searchComponentsInParent(t._maskComp)),n.eventProcessor.maskList=e}))},e.destroy=function(){if(ZM===this._node&&(ZM=null),this.capturingTarget&&this.capturingTarget.clear(),this.bubblingTarget&&this.bubblingTarget.clear(),t.callbacksInvoker.emit(JM.REMOVE_POINTER_EVENT_PROCESSOR,this),this._dispatchingTouch){var e=new Iw([this._dispatchingTouch],!0,bw.TOUCH_CANCEL);e.touch=this._dispatchingTouch,this.dispatchEvent(e),this._dispatchingTouch=null}},e.on=function(t,e,i,n){var r,s;return this._tryEmittingAddEvent(t),((n=!!n)?null!==(r=this.capturingTarget)&&void 0!==r?r:this.capturingTarget=this._newCallbacksInvoker():null!==(s=this.bubblingTarget)&&void 0!==s?s:this.bubblingTarget=this._newCallbacksInvoker()).on(t,e,i),e},e.once=function(t,e,i,n){var r,s;return this._tryEmittingAddEvent(t),((n=!!n)?null!==(r=this.capturingTarget)&&void 0!==r?r:this.capturingTarget=this._newCallbacksInvoker():null!==(s=this.bubblingTarget)&&void 0!==s?s:this.bubblingTarget=this._newCallbacksInvoker()).on(t,e,i,!0),e},e.off=function(t,e,i,n){var r;null===(r=(n=!!n)?this.capturingTarget:this.bubblingTarget)||void 0===r||r.off(t,e,i)},e.targetOff=function(e){var i,n;null===(i=this.capturingTarget)||void 0===i||i.removeAll(e),null===(n=this.bubblingTarget)||void 0===n||n.removeAll(e),this.shouldHandleEventTouch&&!this._hasTouchListeners()&&(this.shouldHandleEventTouch=!1),this.shouldHandleEventMouse&&!this._hasMouseListeners()&&(this.shouldHandleEventMouse=!1),this._hasPointerListeners()||t.callbacksInvoker.emit(JM.REMOVE_POINTER_EVENT_PROCESSOR,this)},e.emit=function(t,e,i,n,r,s){var o;null===(o=this.bubblingTarget)||void 0===o||o.emit(t,e,i,n,r,s)},e.dispatchEvent=function(t){var e,i=this.node,n=0;for(t.target=i,QM.length=0,this.getCapturingTargets(t.type,QM),t.eventPhase=1,n=QM.length-1;n>=0;--n)if((e=QM[n]).eventProcessor.capturingTarget&&(t.currentTarget=e,e.eventProcessor.capturingTarget.emit(t.type,t,QM),t.propagationStopped))return void(QM.length=0);if(QM.length=0,t.eventPhase=2,t.currentTarget=i,this.capturingTarget&&this.capturingTarget.emit(t.type,t),!t.propagationImmediateStopped&&this.bubblingTarget&&this.bubblingTarget.emit(t.type,t),!t.propagationStopped&&t.bubbles)for(this.getBubblingTargets(t.type,QM),t.eventPhase=3,n=0;n<QM.length;++n)if((e=QM[n]).eventProcessor.bubblingTarget&&(t.currentTarget=e,e.eventProcessor.bubblingTarget.emit(t.type,t),t.propagationStopped))return void(QM.length=0);QM.length=0},e.hasEventListener=function(t,e,i){var n=!1;return this.bubblingTarget&&(n=this.bubblingTarget.hasEventListener(t,e,i)),!n&&this.capturingTarget&&(n=this.capturingTarget.hasEventListener(t,e,i)),n},e.getCapturingTargets=function(t,e){for(var i=this._node.parent;i;){var n;null!==(n=i.eventProcessor.capturingTarget)&&void 0!==n&&n.hasEventListener(t)&&e.push(i),i=i.parent}},e.getBubblingTargets=function(t,e){for(var i=this._node.parent;i;){var n;null!==(n=i.eventProcessor.bubblingTarget)&&void 0!==n&&n.hasEventListener(t)&&e.push(i),i=i.parent}},e.onUpdatingSiblingIndex=function(){t.callbacksInvoker.emit(JM.MARK_LIST_DIRTY)},e._searchComponentsInParent=function(t){var e=this.node;if(t){for(var i=0,n=[],r=e;r&&Jm.isNode(r);r=r.parent,++i){var s=r.getComponent(t);if(s){var o={index:i,comp:s};n?n.push(o):n=[o]}}return n.length>0?n:null}return null},e._attachMask=function(){this.maskList=this._searchComponentsInParent(t._maskComp)},e._isTouchEvent=function(t){return-1!==tL.indexOf(t)},e._isMouseEvent=function(t){return-1!==eL.indexOf(t)},e._hasTouchListeners=function(){for(var t=0;t<tL.length;++t){var e=tL[t];if(this.hasEventListener(e))return!0}return!1},e._hasMouseListeners=function(){for(var t=0;t<eL.length;++t){var e=eL[t];if(this.hasEventListener(e))return!0}return!1},e._hasPointerListeners=function(){return!!this._hasTouchListeners()||this._hasMouseListeners()},e._tryEmittingAddEvent=function(e){var i=this._isTouchEvent(e),n=this._isMouseEvent(e);i?this.shouldHandleEventTouch=!0:n&&(this.shouldHandleEventMouse=!0),!i&&!n||this._hasPointerListeners()||t.callbacksInvoker.emit(JM.ADD_POINTER_EVENT_PROCESSOR,this)},e._newCallbacksInvoker=function(){var e=this,i=new qu;return i._registerOffCallback((function(){e.shouldHandleEventTouch&&!e._hasTouchListeners()&&(e.shouldHandleEventTouch=!1),e.shouldHandleEventMouse&&!e._hasMouseListeners()&&(e.shouldHandleEventMouse=!1),e._hasPointerListeners()||t.callbacksInvoker.emit(JM.REMOVE_POINTER_EVENT_PROCESSOR,e)})),i},e._handleEventMouse=function(t){switch(t.type){case bw.MOUSE_DOWN:return this._handleMouseDown(t);case bw.MOUSE_MOVE:return this._handleMouseMove(t);case bw.MOUSE_UP:return this._handleMouseUp(t);case bw.MOUSE_WHEEL:return this._handleMouseWheel(t);default:return!1}},e._handleMouseDown=function(t){var e=this._node;return!(!e||!e._uiProps.uiTransformComp||(t.getLocation($M),!e._uiProps.uiTransformComp.hitTest($M,t.windowId)||(t.type=om.MOUSE_DOWN,t.bubbles=!0,e.dispatchEvent(t),t.propagationStopped=!0,0)))},e._handleMouseMove=function(t){var e=this._node;return!(!e||!e._uiProps.uiTransformComp||(t.getLocation($M),e._uiProps.uiTransformComp.hitTest($M,t.windowId)?(this.previousMouseIn||(ZM&&ZM!==e&&(t.type=om.MOUSE_LEAVE,ZM.dispatchEvent(t),ZM.eventProcessor.previousMouseIn=!1),ZM=e,t.type=om.MOUSE_ENTER,e.dispatchEvent(t),this.previousMouseIn=!0),t.type=om.MOUSE_MOVE,t.bubbles=!0,e.dispatchEvent(t),t.propagationStopped=!0,0):(this.previousMouseIn&&(t.type=om.MOUSE_LEAVE,e.dispatchEvent(t),this.previousMouseIn=!1,ZM=null),1)))},e._handleMouseUp=function(t){var e=this._node;return!(!e||!e._uiProps.uiTransformComp||(t.getLocation($M),!e._uiProps.uiTransformComp.hitTest($M,t.windowId)||(t.type=om.MOUSE_UP,t.bubbles=!0,e.dispatchEvent(t),t.propagationStopped=!0,0)))},e._handleMouseWheel=function(t){var e=this._node;return!(!e||!e._uiProps.uiTransformComp||(t.getLocation($M),!e._uiProps.uiTransformComp.hitTest($M,t.windowId)||(t.type=om.MOUSE_WHEEL,t.bubbles=!0,e.dispatchEvent(t),t.propagationStopped=!0,0)))},e._handleEventTouch=function(t){switch(t.type){case bw.TOUCH_START:return this._handleTouchStart(t);case bw.TOUCH_MOVE:return this._handleTouchMove(t);case bw.TOUCH_END:return this._handleTouchEnd(t);case bw.TOUCH_CANCEL:return this._handleTouchCancel(t);default:return!1}},e._handleTouchStart=function(t){var e=this.node;return!(!e||!e._uiProps.uiTransformComp||(t.getLocation($M),!e._uiProps.uiTransformComp.hitTest($M,t.windowId)||(t.type=om.TOUCH_START,t.bubbles=!0,this._dispatchingTouch=t.touch,e.dispatchEvent(t),0)))},e._handleTouchMove=function(t){var e=this.node;return!(!e||!e._uiProps.uiTransformComp||(t.type=om.TOUCH_MOVE,t.bubbles=!0,this._dispatchingTouch=t.touch,e.dispatchEvent(t),0))},e._handleTouchEnd=function(t){var e=this.node;e&&e._uiProps.uiTransformComp&&(t.getLocation($M),e._uiProps.uiTransformComp.hitTest($M,t.windowId)?t.type=om.TOUCH_END:t.type=om.TOUCH_CANCEL,t.bubbles=!0,e.dispatchEvent(t),this._dispatchingTouch=null)},e._handleTouchCancel=function(t){var e=this.node;e&&e._uiProps.uiTransformComp&&(t.type=om.TOUCH_CANCEL,t.bubbles=!0,e.dispatchEvent(t),this._dispatchingTouch=null)},n(t,[{key:"isEnabled",get:function(){return this._isEnabled}},{key:"node",get:function(){return this._node}}]),t}();nL._maskComp=null,nL.callbacksInvoker=new qu,v.NodeEventProcessor=nL,nt(Jm.prototype,"Node",[{name:"childrenCount",newName:"children.length",customGetter:function(){return this.children.length}}]),nt(Jm.prototype,"Node",[{name:"width",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._uiProps.uiTransformComp.width},customSetter:function(t){this._uiProps.uiTransformComp.width=t}},{name:"height",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._uiProps.uiTransformComp.height},customSetter:function(t){this._uiProps.uiTransformComp.height=t}},{name:"anchorX",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._uiProps.uiTransformComp.anchorX},customSetter:function(t){this._uiProps.uiTransformComp.anchorX=t}},{name:"anchorY",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._uiProps.uiTransformComp.anchorY},customSetter:function(t){this._uiProps.uiTransformComp.anchorY=t}},{name:"getAnchorPoint",targetName:"node.getComponent(UITransform)",customFunction:function(t){return t||(t=new Ln),t.set(this._uiProps.uiTransformComp.anchorPoint),t}},{name:"setAnchorPoint",targetName:"node.getComponent(UITransform)",customFunction:function(t,e){this._uiProps.uiTransformComp.setAnchorPoint(t,e)}},{name:"getContentSize",targetName:"node.getComponent(UITransform)",customFunction:function(t){return t||(t=new Vn),t.set(this._uiProps.uiTransformComp.contentSize),t}},{name:"setContentSize",targetName:"node.getComponent(UITransform)",customFunction:function(t,e){"number"==typeof t?this._uiProps.uiTransformComp.setContentSize(t,e):this._uiProps.uiTransformComp.setContentSize(t)}}]),rt(qC.prototype,"SceneGlobals.prototype",[{name:"aspect"},{name:"selfShadow"},{name:"linear"},{name:"packing"},{name:"autoAdapt"},{name:"fixedArea"},{name:"pcf"},{name:"bias"},{name:"normalBias"},{name:"near"},{name:"far"},{name:"shadowDistance"},{name:"invisibleOcclusionRange"},{name:"orthoSize"},{name:"saturation"}]),nt(qC.prototype,"SceneGlobals.prototype",[{name:"distance",newName:"planeHeight"},{name:"normal",newName:"planeDirection"},{name:"size",newName:"shadowMapSize"}]),rt(Jm.prototype,"Node.prototype",[{name:"addLayer"},{name:"removeLayer"}]),nt(sm.prototype,"NodeUIProperties",[{name:"opacityDirty",newName:"colorDirty"}]),rt(im,"Layers",[{name:"All"},{name:"RaycastMask"},{name:"check"}]),nt(im,"Layers",[{name:"Default",newName:"DEFAULT",target:im.Enum,targetName:"Layers.Enum"},{name:"Always",newName:"ALWAYS",target:im.Enum,targetName:"Layers.Enum"},{name:"IgnoreRaycast",newName:"IGNORE_RAYCAST",target:im.Enum,targetName:"Layers.Enum"},{name:"Gizmos",newName:"GIZMOS",target:im.Enum,targetName:"Layers.Enum"},{name:"Editor",newName:"EDITOR",target:im.Enum,targetName:"Layers.Enum"},{name:"UI",newName:"UI_3D",target:im.Enum,targetName:"Layers.Enum"},{name:"UI2D",newName:"UI_2D",target:im.Enum,targetName:"Layers.Enum"},{name:"SceneGizmo",newName:"SCENE_GIZMO",target:im.Enum,targetName:"Layers.Enum"},{name:"makeInclusiveMask",newName:"makeMaskInclude",target:im,targetName:"Layers"},{name:"makeExclusiveMask",newName:"makeMaskExclude",target:im,targetName:"Layers"}]),rt(im.Enum,"Layers.Enum",[{name:"ALWAYS"}]),rt(im.BitMask,"Layers.BitMask",[{name:"ALWAYS"}]);var rL=Ho.Flags.HideInHierarchy,sL=Ho.Flags.DontSave,oL=t("dX",qs("cc.PrivateNode")(iL=function(t){function e(e){var i;return Y(12003,(i=t.call(this,e)||this).name),i.hideFlags|=sL|rL,i}return s(e,t),e}(Jm))||iL);function aL(t,e){if(!e){var i=v.director.getScene();if(!i)return null;e=i}return e.getChildByPath(t)}nt(Aw,"SystemEventType",["MOUSE_ENTER","MOUSE_LEAVE","TRANSFORM_CHANGED","SCENE_CHANGED_FOR_PERSISTS","SIZE_CHANGED","ANCHOR_CHANGED","COLOR_CHANGED","CHILD_ADDED","CHILD_REMOVED","PARENT_CHANGED","NODE_DESTROYED","LAYER_CHANGED","SIBLING_ORDER_CHANGED"].map((function(t){return{name:t,target:Jm.EventType,targetName:"Node.EventType"}}))),nt(Jm.EventType,"Node.EventType",[{name:"DEVICEMOTION",target:Ex.EventType,targetName:"SystemEvent.EventType"},{name:"KEY_DOWN",target:Ex.EventType,targetName:"SystemEvent.EventType"},{name:"KEY_UP",target:Ex.EventType,targetName:"SystemEvent.EventType"}]),v.PrivateNode=oL,pt({BaseNode:{newName:"Node",since:"3.7.0",removed:!1}}),v.find=aL;var hL=ae,uL=Ho.Flags.IsStartCalled,lL=Ho.Flags.IsOnEnableCalled;function cL(t,e){for(var i=e.constructor._executionOrder,n=e._id,r=0,s=t.length-1,o=s>>>1;r<=s;o=r+s>>>1){var a=t[o],h=a.constructor._executionOrder;if(h>i)s=o-1;else if(h<i)r=o+1;else{var u=a._id;if(u>n)s=o-1;else{if(!(u<n))return o;r=o+1}}}return~r}function _L(t,e){for(var i=t.array,n=t.i+1;n<i.length;){var r=i[n];r.node._activeInHierarchy?++n:(t.removeAt(n),e&&(r._objFlags&=~e))}}Ho.Flags.IsEditorOnEnableCalled;var dL=function(){function t(t){this._zero=void 0,this._neg=void 0,this._pos=void 0,this._invoke=void 0;var e=se;this._zero=new e([]),this._neg=new e([]),this._pos=new e([]),this._invoke=t}return n(t,[{key:"zero",get:function(){return this._zero}},{key:"neg",get:function(){return this._neg}},{key:"pos",get:function(){return this._pos}}]),t}();function fL(t,e){return t.constructor._executionOrder-e.constructor._executionOrder}dL.stableRemoveInactive=_L;var pL=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.add=function(t){var e=t.constructor._executionOrder;(0===e?this._zero:e<0?this._neg:this._pos).array.push(t)},i.remove=function(t){var e=t.constructor._executionOrder;(0===e?this._zero:e<0?this._neg:this._pos).fastRemove(t)},i.cancelInactive=function(t){_L(this._zero,t),_L(this._neg,t),_L(this._pos,t)},i.invoke=function(){var t=this._neg;t.array.length>0&&(t.array.sort(fL),this._invoke(t),t.array.length=0),this._invoke(this._zero),this._zero.array.length=0;var e=this._pos;e.array.length>0&&(e.array.sort(fL),this._invoke(e),e.array.length=0)},e}(dL),mL=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.add=function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.array.push(t);else{var i=e<0?this._neg.array:this._pos.array,n=cL(i,t);n<0&&i.splice(~n,0,t)}},i.remove=function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.fastRemove(t);else{var i=e<0?this._neg:this._pos,n=cL(i.array,t);n>=0&&i.removeAt(n)}},i.invoke=function(t){this._neg.array.length>0&&this._invoke(this._neg,t),this._invoke(this._zero,t),this._pos.array.length>0&&this._invoke(this._pos,t)},e}(dL);function gL(t,e,i){var n="var a=it.array;for(it.i=0;it.i<a.length;++it.i){var c=a[it.i];"+t+"}",r=e?Function("it","dt",n):Function("it",n);return function(t,e,i){return function(n,r){try{e(n,r)}catch(e){v._throw(e);var s=n.array;for(i&&(s[n.i]._objFlags|=i),++n.i;n.i<s.length;++n.i)try{t(s[n.i],r)}catch(t){v._throw(t),i&&(s[n.i]._objFlags|=i)}}}}(Function("c","dt",t),r,i)}var yL=gL("c.start();c._objFlags|="+uL,!1,uL),vL=gL("c.update(dt)",!0),SL=gL("c.lateUpdate(dt)",!0),TL=function(t){var e=v.director._compScheduler,i=t.array;for(t.i=0;t.i<i.length;++t.i){var n=i[t.i];n._enabled&&(n.onEnable(),!n.node._activeInHierarchy||e._onEnabled(n))}},AL=function(){function t(){this.startInvoker=void 0,this.updateInvoker=void 0,this.lateUpdateInvoker=void 0,this._deferredComps=[],this._updating=void 0,this.unscheduleAll()}var e=t.prototype;return e.unscheduleAll=function(){this.startInvoker=new pL(yL),this.updateInvoker=new mL(vL),this.lateUpdateInvoker=new mL(SL),this._updating=!1},e._onEnabled=function(t){v.director.getScheduler().resumeTarget(t),t._objFlags|=lL,this._updating?this._deferredComps.push(t):this._scheduleImmediate(t)},e._onDisabled=function(t){v.director.getScheduler().pauseTarget(t),t._objFlags&=~lL;var e=this._deferredComps.indexOf(t);e>=0?hL(this._deferredComps,e):(!t.internalStart||t._objFlags&uL||this.startInvoker.remove(t),t.internalUpdate&&this.updateInvoker.remove(t),t.internalLateUpdate&&this.lateUpdateInvoker.remove(t))},e.enableComp=function(t,e){if(!(t._objFlags&lL)){if(t.internalOnEnable){if(e)return void e.add(t);if(t.internalOnEnable(),!t.node.activeInHierarchy)return}this._onEnabled(t)}},e.disableComp=function(t){t._objFlags&lL&&(t.internalOnDisable&&t.internalOnDisable(),this._onDisabled(t))},e.startPhase=function(){this._updating=!0,this.startInvoker.invoke(),this._startForNewComps()},e.updatePhase=function(t){this.updateInvoker.invoke(t)},e.lateUpdatePhase=function(t){this.lateUpdateInvoker.invoke(t),this._updating=!1,this._startForNewComps()},e._startForNewComps=function(){this._deferredComps.length>0&&(this._deferredSchedule(),this.startInvoker.invoke())},e._scheduleImmediate=function(t){"function"!=typeof t.internalStart||t._objFlags&uL||this.startInvoker.add(t),"function"==typeof t.internalUpdate&&this.updateInvoker.add(t),"function"==typeof t.internalLateUpdate&&this.lateUpdateInvoker.add(t)},e._deferredSchedule=function(){for(var t=this._deferredComps,e=0,i=t.length;e<i;e++)this._scheduleImmediate(t[e]);t.length=0},t}(),bL=Ho.Flags.IsPreloadStarted,EL=Ho.Flags.IsOnLoadStarted,CL=Ho.Flags.IsOnLoadCalled,wL=Ho.Flags.IsOnEnableCalled,xL=Ho.Flags.Deactivating,RL=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.add=function(t){this._zero.array.push(t)},i.remove=function(t){this._zero.fastRemove(t)},i.cancelInactive=function(t){dL.stableRemoveInactive(this._zero,t)},i.invoke=function(){this._invoke(this._zero),this._zero.array.length=0},e}(dL),IL=gL("c.__preload();"),BL=gL("c.onLoad();c._objFlags|="+CL,!1,CL),DL=new re(4);function PL(t,e,i){J(3817,t.name,i),console.log("Corrupted component value:",e),e?t._removeComponent(e):oe(t.getWritableComponents(),i)}DL.get=function(){var t=this._get()||{preload:new RL(IL),onLoad:new pL(BL),onEnable:new pL(TL)};t.preload.zero.i=-1;var e=t.onLoad;return e.zero.i=-1,e.neg.i=-1,e.pos.i=-1,(e=t.onEnable).zero.i=-1,e.neg.i=-1,e.pos.i=-1,t};var OL=t("dF",function(){function t(){this._activatingStack=void 0,this.reset()}var e=t.prototype;return e.reset=function(){this._activatingStack=[]},e.activateNode=function(t,e){if(e){var i=DL.get();i&&(this._activatingStack.push(i),this._activateNodeRecursively(t,i.preload,i.onLoad,i.onEnable),i.preload.invoke(),i.onLoad.invoke(),i.onEnable.invoke(),this._activatingStack.pop(),DL.put(i))}else{this._deactivateNodeRecursively(t);for(var n,r=d(this._activatingStack);!(n=r()).done;){var s=n.value;s.preload.cancelInactive(bL),s.onLoad.cancelInactive(EL),s.onEnable.cancelInactive(wL)}}t.emit(om.ACTIVE_IN_HIERARCHY_CHANGED,t)},e.activateComp=function(t,e,i,n){if(jo(t,!0)&&(t._objFlags&bL||(t._objFlags|=bL,t.internalPreload&&(e?e.add(t):t.internalPreload())),t._objFlags&EL||(t._objFlags|=EL,t.internalOnLoad?i?i.add(t):(t.internalOnLoad(),t._objFlags|=CL):t._objFlags|=CL),t._enabled)){if(!t.node.activeInHierarchy)return;v.director._compScheduler.enableComp(t,n)}},e.destroyComp=function(t){v.director._compScheduler.disableComp(t),t.internalOnDestroy&&t._objFlags&CL&&t.internalOnDestroy()},e._activateNodeRecursively=function(t,e,i,n){if(t._objFlags&xL)J(3816,t.name);else{t._setActiveInHierarchy(!0);for(var r=t.components.length,s=0;s<r;++s){var o=t.components[s];o instanceof v.Component?this.activateComp(o,e,i,n):(PL(t,o,s),--s,--r)}for(var a=0,h=t.children.length;a<h;++a){var u=t.children[a];u.active&&this._activateNodeRecursively(u,e,i,n)}t._onPostActivated(!0)}},e._deactivateNodeRecursively=function(t){t._objFlags|=xL,t._setActiveInHierarchy(!1);for(var e=t.components.length,i=0;i<e;++i){var n=t.components[i];if(n._enabled&&(v.director._compScheduler.disableComp(n),t.activeInHierarchy))return void(t._objFlags&=~xL)}for(var r=0,s=t.children.length;r<s;++r){var o=t.children[r];if(o.activeInHierarchy&&(this._deactivateNodeRecursively(o),t.activeInHierarchy))return void(t._objFlags&=~xL)}t._onPostActivated(!1),t._objFlags&=~xL},t}()),ML=Ho.Flags.Destroyed,LL=Ho.Flags.PersistentMask,NL=pi.Attr.DELIMETER+"default",FL=pi.IDENTIFIER_RE,kL="var ",VL="o",GL={"cc.ClickEvent":!1,"cc.PrefabInfo":!1},UL=pi.escapeForJS,zL=function(){function t(t,e){this.varName=void 0,this.expression=void 0,this.varName=t,this.expression=e}return t.prototype.toString=function(){return kL+this.varName+"="+this.expression+";"},t}();function HL(t,e){return e instanceof zL?new zL(e.varName,t+e.expression):t+e}function WL(t,e,i){Array.isArray(i)?(i[0]=HL(e,i[0]),t.push(i)):t.push(HL(e,i)+";")}var jL=function(){function t(t){this._exps=void 0,this._targetExp=void 0,this._exps=[],this._targetExp=t}var e=t.prototype;return e.append=function(t,e){this._exps.push([t,e])},e.writeCode=function(t){var e;if(this._exps.length>1)t.push("t="+this._targetExp+";"),e="t";else{if(1!==this._exps.length)return;e=this._targetExp}for(var i=0;i<this._exps.length;i++){var n=this._exps[i];WL(t,e+XL(n[0])+"=",n[1])}},t}();function XL(t){return FL.test(t)?"."+t:"["+UL(t)+"]"}jL.pool=void 0,jL.pool=new re((function(t){t._exps.length=0,t._targetExp=null}),1),jL.pool.get=function(t){var e=this._get()||new jL;return e._targetExp=t,e};var qL,YL,KL,JL,QL,ZL,$L=function(){function t(t,e){var i;this.parent=void 0,this.objsToClear_iN$t=void 0,this.codeArray=void 0,this.objs=void 0,this.funcs=void 0,this.funcModuleCache=void 0,this.globalVariables=void 0,this.globalVariableId=void 0,this.localVariableId=void 0,this.result=void 0,this.parent=e,this.objsToClear_iN$t=[],this.codeArray=[],this.objs=[],this.funcs=[],this.funcModuleCache=It(),Gt(this.funcModuleCache,GL),this.globalVariables=[],this.globalVariableId=0,this.localVariableId=0,this.codeArray.push("var o,t;","if(R){","o=R;","}else{","o=R=new "+this.getFuncModule(t.constructor,!0)+"();","}"),t._iN$t={globalVar:"R"},this.objsToClear_iN$t.push(t),this.enumerateObject(this.codeArray,t),this.globalVariables.length>0&&(i=kL+this.globalVariables.join(",")+";");var n=Fl(["return (function(R){",i||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",n)(this.objs,this.funcs);for(var r=0,s=this.objsToClear_iN$t.length;r<s;++r)this.objsToClear_iN$t[r]._iN$t=null;this.objsToClear_iN$t.length=0}var e=t.prototype;return e.getFuncModule=function(t,e){var i=Bt(t);if(i){var n=this.funcModuleCache[i];if(n)return n;if(void 0===n){var r=-1!==i.indexOf(".");if(r)try{if(r=t===Function("return "+i)())return this.funcModuleCache[i]=i,i}catch(t){}}}var s=this.funcs.indexOf(t);s<0&&(s=this.funcs.length,this.funcs.push(t));var o="F["+s+"]";return e&&(o="("+o+")"),this.funcModuleCache[i]=o,o},e.getObjRef=function(t){var e=this.objs.indexOf(t);return e<0&&(e=this.objs.length,this.objs.push(t)),"O["+e+"]"},e.setValueType=function(t,e,i,n){var r=jL.pool.get(n),s=e.constructor.__props__;s||(s=Object.keys(e));for(var o=0;o<s.length;o++){var a=s[o],h=i[a];if(e[a]!==h){var u=this.enumerateField(i,a,h);r.append(a,u)}}r.writeCode(t),jL.pool.put(r)},e.enumerateCCClass=function(t,e,i){for(var n=i.__values__,r=pi.Attr.getClassAttrs(i),s=0;s<n.length;s++){var o=n[s],a=e[o],h=r[o+NL];if(!tN(h,a))if("object"==typeof a&&a instanceof v.ValueType&&(h=pi.getDefault(h))&&h.constructor===a.constructor){var u=VL+XL(o);this.setValueType(t,h,a,u)}else this.setObjProp(t,e,o,a)}},e.instantiateArray=function(t){if(0===t.length)return"[]";var e="a"+ ++this.localVariableId,i=[new zL(e,"new Array("+t.length+")")];t._iN$t={globalVar:"",source:i},this.objsToClear_iN$t.push(t);for(var n=0;n<t.length;++n)WL(i,e+"["+n+"]=",this.enumerateField(t,n,t[n]));return i},e.instantiateTypedArray=function(t){var e=t.constructor.name;if(0===t.length)return"new "+e;var i="a"+ ++this.localVariableId,n=[new zL(i,"new "+e+"("+t.length+")")];t._iN$t={globalVar:"",source:n},this.objsToClear_iN$t.push(t);for(var r=0;r<t.length;++r)0!==t[r]&&WL(n,i+"["+r+"]=",t[r]);return n},e.enumerateField=function(t,e,i){if("object"==typeof i&&i){var n=i._iN$t;if(n){var r=n.globalVar;if(!r){r=n.globalVar="v"+ ++this.globalVariableId,this.globalVariables.push(r);var s=n.source[0];n.source[0]=HL(r+"=",s)}return r}return ArrayBuffer.isView(i)?this.instantiateTypedArray(i):Array.isArray(i)?this.instantiateArray(i):this.instantiateObj(i)}return"function"==typeof i?this.getFuncModule(i):"string"==typeof i?UL(i):("_objFlags"===e&&Wo(t)&&(i&=LL),i)},e.setObjProp=function(t,e,i,n){WL(t,VL+XL(i)+"=",this.enumerateField(e,i,n))},e.enumerateObject=function(t,e){var i=e.constructor;if(mi(i))this.enumerateCCClass(t,e,i);else for(var n in e)if(e.hasOwnProperty(n)&&(95!==n.charCodeAt(0)||95!==n.charCodeAt(1)||"__type__"===n)){var r=e[n];"object"==typeof r&&r&&r===e._iN$t||this.setObjProp(t,e,n,r)}},e.instantiateObj=function(t){if(t instanceof v.ValueType)return pi.getNewValueTypeCode(t);if(t instanceof v.Asset)return this.getObjRef(t);if(t._objFlags&ML)return null;var e,i=t.constructor;if(mi(i)){if(this.parent)if(this.parent instanceof v.Component){if(t instanceof v.Node||t instanceof v.Component)return this.getObjRef(t)}else if(this.parent instanceof v.Node)if(t instanceof v.Node){if(!t.isChildOf(this.parent))return this.getObjRef(t)}else if(t instanceof v.Component){var n;if(null===(n=t.node)||void 0===n||!n.isChildOf(this.parent))return this.getObjRef(t)}e=new zL(VL,"new "+this.getFuncModule(i,!0)+"()")}else if(i===Object)e=new zL(VL,"{}");else{if(i)return this.getObjRef(t);e=new zL(VL,"Object.create(null)")}var r=[e];return t._iN$t={globalVar:"",source:r},this.objsToClear_iN$t.push(t),this.enumerateObject(r,t),["(function(){",r,"return o;})();"]},t}();function tN(t,e){if("function"==typeof t)try{t=t()}catch(t){return!1}if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e&&t.constructor===e.constructor)if(t instanceof v.ValueType){if(t.equals(e))return!0}else{if(Array.isArray(t))return 0===t.length&&0===e.length;if(t.constructor===Object)return bt(t)&&bt(e)}return!1}var eN=ge({AUTO:0,SINGLE_INSTANCE:1,MULTI_INSTANCE:2}),iN=t("dG",qs("cc.Prefab")(((ZL=function(t){function e(){var e;return(e=t.call(this)||this).data=KL&&KL(),e.optimizationPolicy=JL&&JL(),e.persistent=QL&&QL(),e._createFunction=void 0,e._instantiatedTimes=void 0,e._createFunction=null,e._instantiatedTimes=0,e}s(e,t);var i=e.prototype;return i.createNode=function(t){var e=v.instantiate(this);e.name=this.name,t(null,e)},i.compileCreateFunction=function(){var t,e;this._createFunction=(e=(t=this.data)instanceof v.Node&&t,new $L(t,e).result)},i._doInstantiate=function(t){return this.data._prefab||Y(3700),this._createFunction||this.compileCreateFunction(),this._createFunction(t)},i._instantiate=function(){var t;return this.optimizationPolicy!==eN.SINGLE_INSTANCE&&(this.optimizationPolicy===eN.MULTI_INSTANCE||this._instantiatedTimes+1>=e.OptimizationPolicyThreshold)?(t=this._doInstantiate(),this.data._instantiate(t)):t=this.data._instantiate(),++this._instantiatedTimes,t},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.data=new Jm,this.data.name="(Missing Node)";var i=new v._PrefabInfo;i.asset=this,i.root=this.data,this.data._prefab=i},i.validate=function(){return!!this.data},i.onLoaded=function(){var t=this.data;cw(t),uw(t)},e}(of)).OptimizationPolicy=eN,ZL.OptimizationPolicyThreshold=3,KL=ks((YL=ZL).prototype,"data",[io],(function(){return null})),JL=ks(YL.prototype,"optimizationPolicy",[io],(function(){return eN.AUTO})),QL=ks(YL.prototype,"persistent",[io],(function(){return!1})),qL=YL))||qL);Ct(iN,"_utils",vw),v.Prefab=iN,Dt(v,"cc._Prefab","Prefab");var nN=new(function(){function t(){this._allRenderers=[],this._dirtyRenderers=[],this._dirtyVersion=0}var e=t.prototype;return e.addRenderer=function(t){-1===t._internalId&&(t._internalId=this._allRenderers.length,this._allRenderers.push(t))},e.removeRenderer=function(t){if(-1!==t._internalId){var e=t._internalId;this._allRenderers[this._allRenderers.length-1]._internalId=e,ae(this._allRenderers,e),t._internalId=-1,t._dirtyVersion===this._dirtyVersion&&(ue(this._dirtyRenderers,t),t._dirtyVersion=-1)}},e.markDirtyRenderer=function(t){t._dirtyVersion!==this._dirtyVersion&&-1!==t._internalId&&(this._dirtyRenderers.push(t),t._dirtyVersion=this._dirtyVersion)},e.updateAllDirtyRenderers=function(){for(var t=this._dirtyRenderers.length,e=this._dirtyRenderers,i=0;i<t;i++)e[i].updateRenderer();this._dirtyRenderers.length=0,this._dirtyVersion++},t}()),rN=[".png",".jpg",".bmp",".jpeg",".gif",".ico",".tiff",".webp",".image",".pvr",".pkm",".astc"],sN=[".mp3",".ogg",".wav",".m4a"];function oN(){return!0}var aN={transformURL:function(t){var e=Yd(t);if(!e)return t;var i=Md.find((function(t){return!!t.getAssetInfo(e)}));if(!i)return t;var n,r=i.getAssetInfo(e);if(!(n=t.startsWith(i.base+i.config.nativeBase)?r.nativeVer||"":r.ver||"")||-1!==t.indexOf(n))return t;var s=!1;if(".ttf"===hl(t)&&(s=!0),s){var o=cl(t),a=ll(t);t=o+"."+n+"/"+a}else t=t.replace(/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,})/,(function(t){return t+"."+n}));return t}},hN=t("eq",function(){function t(){this._autoReleaseSetting=Object.create(null),this._parseLoadResArgs=Jv}var e=t.prototype;return e.load=function(t,e,i){void 0===i&&void 0!==e&&(i=e,e=null);for(var n=Array.isArray(t)?t:[t],r=0;r<n.length;r++){var s=n[r];"string"==typeof s?n[r]={url:s,__isNative__:!0}:(s.type&&(s.ext="."+s.type,s.type=void 0),s.url&&(s.__isNative__=!0))}var o=[],a=[];ZS.loadAny(n,null,(function(t,i,n){n.content&&(rN.includes(n.ext)?o.push(n.content):sN.includes(n.ext)&&a.push(n.content)),e&&e(t,i,n)}),(function(t,e){var r=null;if(!t){e=Array.isArray(e)?e:[e];for(var s=function(t){var i=e[t];if(!(i instanceof of)){var r=i,s=n[t].url;o.includes(r)?LS.create(s,i,".png",{},(function(i,n){r=e[t]=n})):a.includes(r)&&LS.create(s,i,".mp3",{},(function(i,n){r=e[t]=n})),Dd.add(s,r)}},h=0;h<e.length;h++)s(h);if(e.length>1){var u=Object.create(null);e.forEach((function(t){u[t._uuid]=t})),r={isCompleted:oN,_map:u}}else r=e[0]}i&&i(t,r)}))},e.getXMLHttpRequest=function(){return new XMLHttpRequest},e.getItem=function(t){return ZS.assets.has(t)?{content:ZS.assets.get(t)}:null},e.loadRes=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete,h=hl(t);h&&!tS.getInfoWithPath(t,s)&&(t=t.slice(0,-h.length)),tS.load(t,s,o,a)},e.loadResArray=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete;t.forEach((function(e,i){var n=hl(e);n&&!tS.getInfoWithPath(e,s)&&(t[i]=e.slice(0,-n.length))})),tS.load(t,s,o,a)},e.loadResDir=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete;tS.loadDir(t,s,o,(function(e,i){var n=[];e||(n=tS.getDirWithPath(t,s).map((function(t){return t.path}))),a&&a(e,i,n)}))},e.getRes=function(t,e){return Dd.has(t)?Dd.get(t):tS.get(t,e)},e.getResCount=function(){return Dd.count},e.getDependsRecursively=function(t){if(!t)return[];var e="string"==typeof t?t:t._uuid;return Hp.getDepsRecursively(e).concat([e])},e.addDownloadHandlers=function(t){var e=Object.create(null),i=function(){var i=t[n];e["."+n]=function(t,e,n){i({url:t},n)}};for(var n in t)i();bS.register(e)},e.addLoadHandlers=function(t){var e=Object.create(null),i=function(){var i=t[n];e["."+n]=function(t,e,n){i({content:t},n)}};for(var n in t)i();US.register(e)},e.release=function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++){var i=t[e];"string"==typeof i&&(i=Dd.get(i)),ZS.releaseAsset(i)}else t&&("string"==typeof t&&(t=Dd.get(t)),ZS.releaseAsset(t))},e.releaseAsset=function(t){ZS.releaseAsset(t)},e.releaseRes=function(t,e){tS.release(t,e)},e.releaseAll=function(){ZS.releaseAll(),Dd.clear()},e.removeItem=function(t){return!!Dd.remove(t)},e.setAutoRelease=function(t,e){"object"==typeof t&&(t=t._uuid),this._autoReleaseSetting[t]=!!e},e.setAutoReleaseRecursively=function(t,e){"object"==typeof t&&(t=t._uuid),e=!!e,this._autoReleaseSetting[t]=e;for(var i=Hp.getDepsRecursively(t),n=0;n<i.length;n++)this._autoReleaseSetting[i[n]]=e},e.isAutoRelease=function(t){return"object"==typeof t&&(t=t._uuid),!!this._autoReleaseSetting[t]},n(t,[{key:"onProgress",set:function(t){zv=t}},{key:"_cache",get:function(){if(Dd instanceof Rd)return Dd.map;var t={};return Dd.forEach((function(e,i){t[i]=e})),t}},{key:"md5Pipe",get:function(){return aN}},{key:"downloader",get:function(){return bS}},{key:"loader",get:function(){return ZS.parser}}]),t}()),uN=t("er",new hN),lN=t("es",{init:function(t){t.importBase=t.libraryPath,t.nativeBase=t.rawAssetsBase,ZS.init(t),t.rawAssets&&tS.init({base:"",deps:[],scenes:{},redirect:[],debug:!0,packs:{},types:[],versions:{import:[],native:[]},name:Vd.RESOURCES,importBase:t.importBase,nativeBase:t.nativeBase,paths:t.rawAssets.assets,uuids:Object.keys(t.rawAssets.assets),extensionMap:{}})},loadAsset:function(t,e){ZS.loadAny(t,e)}}),cN=t("et",{});nt(cN,"url",[{name:"normalize",target:ZS.utils,targetName:"assetManager.utils",newName:"normalize"},{name:"raw",targetName:"Asset.prototype",newName:"nativeUrl",customFunction:function(t){return t.startsWith("resources/")?Zd({path:_l(t.substr(10)),bundle:Vd.RESOURCES,__isNative__:!0,ext:hl(t)}):""}}]),rt(lN,"AssetLibrary",[{name:"getLibUrlNoExt",suggest:"AssetLibrary.getLibUrlNoExt was removed, if you want to transform url, please use assetManager.utils.getUrlWithUuid instead"},{name:"queryAssetInfo",suggest:"AssetLibrary.queryAssetInfo was removed"}]),rt(uN,"loader",[{name:"releaseResDir",suggest:"loader.releaseResDir was removed, please use assetManager.releaseAsset instead"},{name:"flowInDeps",suggest:"loader.flowInDeps was removed"},{name:"assetLoader",suggest:"loader.assetLoader was removed, assetLoader and md5Pipe were merged into assetManager.transformPipeline"}]),nt(v,"cc",[{name:"loader",newName:"assetManager",logTimes:1,customGetter:function(){return uN}},{name:"AssetLibrary",newName:"assetManager",logTimes:1,customGetter:function(){return lN}},{name:"Pipeline",target:QS,targetName:"AssetManager",newName:"Pipeline",logTimes:1},{name:"url",targetName:"assetManager",newName:"utils",logTimes:1,customGetter:function(){return cN}}]),rt(v,"cc",[{name:"LoadingItems",suggest:tt(1400,"LoadingItems","AssetManager.Task")}]),nt(Ce,"macro",[{name:"DOWNLOAD_MAX_CONCURRENT",target:bS,targetName:"assetManager.downloader",newName:"maxConcurrency"}]);var _N=Uv._autoRelease;Uv._autoRelease=function(t,e,i){_N.call(Uv,t,e,i);for(var n=uN._autoReleaseSetting,r=Object.keys(n),s=0;s<r.length;s++){var o=r[s];if(!0===n[o]){var a=Dd.get(o);a&&Uv.tryRelease(a)}}};var dN=t("e1",function(t){function e(){var e;return(e=t.call(this)||this)._compScheduler=void 0,e._nodeActivator=void 0,e._invalid=void 0,e._paused=void 0,e._root=void 0,e._loadingScene=void 0,e._scene=void 0,e._totalFrames=void 0,e._scheduler=void 0,e._systems=void 0,e._persistRootNodes={},e._invalid=!1,e._paused=!1,e._root=null,e._loadingScene="",e._scene=null,e._totalFrames=0,e._scheduler=new Vu,e._compScheduler=new AL,e._nodeActivator=new OL,e._systems=[],e}s(e,t);var i=e.prototype;return i.calculateDeltaTime=function(){},i.end=function(){var t=this;this.once(e.EVENT_END_FRAME,(function(){t.purgeDirector()}))},i.pause=function(){this._paused||(this._paused=!0)},i.purgeDirector=function(){this._scheduler.unscheduleAll(),this._compScheduler.unscheduleAll(),this._nodeActivator.reset(),jo(this._scene)&&this._scene.destroy(),this._scene=null,this.stopAnimation(),ZS.releaseAll()},i.reset=function(){var t;for(var i in this.purgeDirector(),this._persistRootNodes)this.removePersistRootNode(this._persistRootNodes[i]);null===(t=this.getScene())||void 0===t||t.destroy(),this.emit(e.EVENT_RESET),this.startAnimation()},i.runSceneImmediate=function(t,i,n){var r=this;t instanceof Tw&&(t=t.scene),$(t instanceof Sw,1216),t._load();for(var s=Object.keys(this._persistRootNodes).map((function(t){return r._persistRootNodes[t]})),o=0;o<s.length;o++){var a=s[o];a.emit(Jm.EventType.SCENE_CHANGED_FOR_PERSISTS,t.renderScene);var h=t.uuid===a._originalSceneId&&t.getChildByUuid(a.uuid);if(h){var u=h.getSiblingIndex();a.hideFlags&=~Ho.Flags.DontSave,a.hideFlags|=Ho.Flags.DontSave&h.hideFlags,h._destroyImmediate(),t.insertChild(a,u)}else a.hideFlags|=Ho.Flags.DontSave,a.parent=t}var l=this._scene;jo(l)&&l.destroy(),Uv._autoRelease(l,t,this._persistRootNodes),this._scene=null,Ho._deferredDestroy(),i&&i(),this.emit(e.EVENT_BEFORE_SCENE_LAUNCH,t),this._scene=t,t._activate(),this._root&&this._root.resetCumulativeTime(),this.startAnimation(),n&&n(null,t),this.emit(e.EVENT_AFTER_SCENE_LAUNCH,t)},i.runScene=function(t,i,n){var r=this;t instanceof Tw&&(t=t.scene),$(Boolean(t),1205),$(t instanceof Sw,1216),this.once(e.EVENT_END_FRAME,(function(){r.runSceneImmediate(t,i,n)}))},i.loadScene=function(t,i,n){var r=this;if(this._loadingScene)return Y(1208,t,this._loadingScene),!1;var s=ZS.bundles.find((function(e){return!!e.getSceneInfo(t)}));return s?(this.emit(e.EVENT_BEFORE_SCENE_LOADING,t),this._loadingScene=t,console.time("LoadScene "+t),s.loadScene(t,(function(e,s){console.timeEnd("LoadScene "+t),r._loadingScene="",e?(V(e),i&&i(e)):r.runSceneImmediate(s,n,i)})),!0):(J(1209,t),!1)},i.preloadScene=function(t,e,i){var n=ZS.bundles.find((function(e){return!!e.getSceneInfo(t)}));if(n)n.preloadScene(t,null,e,i);else{var r='Can not preload the scene "'+t+'" because it is not in the build settings.';i&&i(new Error(r)),V("preloadScene: "+r)}},i.resume=function(){this._paused&&(this._paused=!1)},i.getScene=function(){return this._scene},i.getDeltaTime=function(){return v.game.deltaTime},i.getTotalTime=function(){return v.game.totalTime},i.getCurrentTime=function(){return v.game.frameStartTime},i.getTotalFrames=function(){return this._totalFrames},i.isPaused=function(){return this._paused},i.getScheduler=function(){return this._scheduler},i.setScheduler=function(t){this._scheduler!==t&&(this.unregisterSystem(this._scheduler),this._scheduler=t,this.registerSystem(Vu.ID,t,200))},i.registerSystem=function(t,e,i){e.id=t,e.priority=i,this._systems.push(e),this._systems.sort(Ou.sortByPriority)},i.unregisterSystem=function(t){ue(this._systems,t),this._systems.sort(Ou.sortByPriority)},i.getSystem=function(t){return this._systems.find((function(e){return e.id===t}))},i.getAnimationManager=function(){return this.getSystem(v.AnimationManager.ID)},i.startAnimation=function(){this._invalid=!1},i.stopAnimation=function(){this._invalid=!0},i.mainLoop=function(t){var e;e=v.game._calculateDT(t),this.tick(e)},i.tick=function(t){if(!this._invalid){if(this.emit(e.EVENT_BEGIN_FRAME),bx._frameDispatchEvents(),!this._paused){this.emit(e.EVENT_BEFORE_UPDATE),this._compScheduler.startPhase(),this._compScheduler.updatePhase(t);for(var i=0;i<this._systems.length;++i)this._systems[i].update(t);this._compScheduler.lateUpdatePhase(t),this.emit(e.EVENT_AFTER_UPDATE),Ho._deferredDestroy();for(var n=0;n<this._systems.length;++n)this._systems[n].postUpdate(t)}this.emit(e.EVENT_BEFORE_DRAW),nN.updateAllDirtyRenderers(),this._root.frameMove(t),this.emit(e.EVENT_AFTER_DRAW),Jm.resetHasChangedFlags(),Jm.clearNodeArray(),Iu.update(t),this.emit(e.EVENT_END_FRAME),this._totalFrames++}},i.buildRenderPipeline=function(){this._root&&(this._root.customPipeline.beginSetup(),v.rendering.getCustomPipeline(Ce.CUSTOM_PIPELINE_NAME).setup(this._root.cameraList,this._root.customPipeline),this._root.customPipeline.endSetup())},i.setupRenderPipelineBuilder=function(){""!==Ce.CUSTOM_PIPELINE_NAME&&v.rendering&&this._root&&this._root.usesCustomPipeline&&this.on(e.EVENT_BEFORE_RENDER,this.buildRenderPipeline,this)},i.init=function(){this._totalFrames=0,this._paused=!1,this.registerSystem(Vu.ID,this._scheduler,200),this._root=new KM(Ed.gfxDevice),this._root.initialize({}),this.setupRenderPipelineBuilder();for(var t=0;t<this._systems.length;t++)this._systems[t].init();this.emit(e.EVENT_INIT)},i.addPersistRootNode=function(t){if(Jm.isNode(t)&&t.uuid){var e=t.uuid;if(!this._persistRootNodes[e]){var i=this._scene;if(jo(i))if(t.parent){if(!(t.parent instanceof Sw))return void Y(3801);if(t.parent!==i)return void Y(3802);t._originalSceneId=i.uuid}else t.parent=i,t._originalSceneId=i.uuid;this._persistRootNodes[e]=t,t._persistNode=!0,Uv._addPersistNodeRef(t)}}else Y(3800)},i.removePersistRootNode=function(t){var e=t.uuid||"";t===this._persistRootNodes[e]&&(delete this._persistRootNodes[e],t._persistNode=!1,t._originalSceneId="",Uv._removePersistNodeRef(t))},i.isPersistRootNode=function(t){return!!t._persistNode},n(e,[{key:"root",get:function(){return this._root}}]),e}(Ku));dN.EVENT_INIT="director_init",dN.EVENT_RESET="director_reset",dN.EVENT_BEFORE_SCENE_LOADING="director_before_scene_loading",dN.EVENT_BEFORE_SCENE_LAUNCH="director_before_scene_launch",dN.EVENT_AFTER_SCENE_LAUNCH="director_after_scene_launch",dN.EVENT_BEFORE_UPDATE="director_before_update",dN.EVENT_AFTER_UPDATE="director_after_update",dN.EVENT_BEFORE_DRAW="director_before_draw",dN.EVENT_AFTER_DRAW="director_after_draw",dN.EVENT_BEFORE_COMMIT="director_before_commit",dN.EVENT_BEFORE_RENDER="director_before_render",dN.EVENT_AFTER_RENDER="director_after_render",dN.EVENT_BEFORE_PHYSICS="director_before_physics",dN.EVENT_AFTER_PHYSICS="director_after_physics",dN.EVENT_BEGIN_FRAME="director_begin_frame",dN.EVENT_END_FRAME="director_end_frame",dN.instance=void 0,v.Director=dN;var fN=t("e2",dN.instance=v.director=new dN),pN=function(){function t(){var t=this;this._stHandle=0,this._onTick=null,this._targetFrameRate=60,this._frameTime=0,this._startTime=0,this._isPlaying=!1,this._frameCount=0,this._callback=null,this._rAF=void 0,this._cAF=void 0,this._handleRAF=function(){var e=performance.now()-t._startTime;Math.floor(e/t._frameTime)<t._frameCount?t._rAF.call(window,t._handleRAF):(t._frameCount++,t._callback&&t._callback()),performance.now()-t._startTime>2e3&&(t._startTime=performance.now(),t._frameCount=0)},this._frameTime=1e3/this._targetFrameRate,this._rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame,this._cAF=window.cancelAnimationFrame||window.cancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.ocancelAnimationFrame}var e=t.prototype;return e.start=function(){var t,e=this;if(!this._isPlaying){var i=void 0===this._rAF||(null===(t=globalThis.__globalXR)||void 0===t?void 0:t.isWebXR);this._startTime=performance.now(),this._stHandle=this._stTime((function t(){i&&(e._startTime=performance.now()),e._isPlaying&&(e._stHandle=e._stTime(t)),e._onTick&&e._onTick()})),this._isPlaying=!0,this._frameCount=0}},e.stop=function(){this._isPlaying&&(this._ctTime(this._stHandle),this._stHandle=0,this._isPlaying=!1,this._frameCount=0)},e._stTime=function(t){var e;if(void 0===this._rAF||null!==(e=globalThis.__globalXR)&&void 0!==e&&e.isWebXR){var i=performance.now(),n=Math.max(0,i-this._startTime),r=Math.max(0,this._frameTime-n);return setTimeout(t,r)}return this._callback=t,this._rAF.call(window,this._handleRAF)},e._ctTime=function(t){var e;void 0===this._cAF||null!==(e=globalThis.__globalXR)&&void 0!==e&&e.isWebXR?clearTimeout(t):t&&this._cAF.call(window,t)},n(t,[{key:"targetFrameRate",get:function(){return this._targetFrameRate},set:function(t){this._targetFrameRate!==t&&(this._targetFrameRate=t,this._frameTime=1e3/this._targetFrameRate,this._isPlaying&&(this.stop(),this.start()))}},{key:"onTick",get:function(){return this._onTick},set:function(t){this._onTick=t}}]),t}();st(yD.prototype,"RenderPipeline.prototype",[{name:"geometryRenderer",suggest:"please use camera.geometryRenderer instead."}]);var mN=new Ln,gN=function(){var t=e.prototype;function e(){this.settings=void 0,this._curTime=0,this.device=void 0,this.swapchain=void 0,this.shader=void 0,this.sampler=void 0,this.cmdBuff=void 0,this.quadAssmebler=void 0,this.vertexBuffers=void 0,this.indicesBuffers=void 0,this.renderArea=void 0,this.clearColors=void 0,this.projection=void 0,this.isMobile=!1,this.bgMat=void 0,this.bgImage=void 0,this.bgTexture=void 0,this.logoMat=void 0,this.logoImage=void 0,this.logoTexture=void 0,this.watermarkMat=void 0,this.watermarkTexture=void 0,this.bgWidth=1920,this.bgHeight=1080,this.bgRatio=16/9,this.logoWidthTemp=140,this.logoHeightTemp=200,this.logoWidth=0,this.logoHeight=0,this.logoXTrans=.5,this.logoYTrans=1/6+2.5/6,this.textSize=24,this.textHeight=24,this.textXTrans=.5,this.textYExtraTrans=32,this.textExpandSize=4,this.scaleSize=1}return t.init=function(){var t,e,i,n,r,s,o=this;if(this.settings={displayRatio:null!==(t=Ee.querySettings(be.Category.SPLASH_SCREEN,"displayRatio"))&&void 0!==t?t:.4,totalTime:null!==(e=Ee.querySettings(be.Category.SPLASH_SCREEN,"totalTime"))&&void 0!==e?e:3e3,watermarkLocation:null!==(i=Ee.querySettings(be.Category.SPLASH_SCREEN,"watermarkLocation"))&&void 0!==i?i:"default",autoFit:null===(n=Ee.querySettings(be.Category.SPLASH_SCREEN,"autoFit"))||void 0===n||n,logo:null!==(r=Ee.querySettings(be.Category.SPLASH_SCREEN,"logo"))&&void 0!==r?r:void 0,background:null!==(s=Ee.querySettings(be.Category.SPLASH_SCREEN,"background"))&&void 0!==s?s:void 0},this._curTime=0,!(this.settings.totalTime<=0||void 0===this.settings.logo||void 0===this.settings.background)){this.device=v.director.root.device,this.swapchain=v.director.root.mainWindow.swapchain,this.preInit(),this.initLayout(),"default"===this.settings.logo.type&&this.initWaterMark();var a=Promise.resolve(),h=Promise.resolve();return"custom"===this.settings.background.type&&(a=new Promise((function(t,e){o.bgImage=new T.Image,o.bgImage.onload=function(){o.initBG(),t()},o.bgImage.onerror=function(){e()},o.bgImage.src=o.settings.background.base64}))),"none"!==this.settings.logo.type&&(h=new Promise((function(t,e){o.logoImage=new T.Image,o.logoImage.onload=function(){o.initLogo(),t()},o.logoImage.onerror=function(){e()},o.logoImage.src=o.settings.logo.base64}))),Promise.all([a,h])}return this.settings.totalTime=0,Promise.resolve([])},t.preInit=function(){var t,e=null===(t=this.settings.background)||void 0===t?void 0:t.color;this.clearColors=e?[new zc(e.x,e.y,e.z,e.w)]:[new zc(0,0,0,1)];var i=this.device,n=this.swapchain;this.renderArea=new Mc(0,0,n.width,n.height),this.cmdBuff=i.commandBuffer;var r=new Float32Array([.5,.5,1,0,-.5,.5,0,0,.5,-.5,1,1,-.5,-.5,0,1]),s=4*Float32Array.BYTES_PER_ELEMENT,o=4*s;this.vertexBuffers=i.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,o,s)),this.vertexBuffers.update(r);var a=new Uint16Array([0,1,2,1,3,2]),h=Uint16Array.BYTES_PER_ELEMENT,u=6*h;this.indicesBuffers=i.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,u,h)),this.indicesBuffers.update(a);var l=[new u_("a_position",Hl.RG32F),new u_("a_texCoord",Hl.RG32F)],c=new c_(l,[this.vertexBuffers],this.indicesBuffers);this.quadAssmebler=i.createInputAssembler(c),this.projection=new In,In.ortho(this.projection,-1,1,-1,1,-1,1,i.capabilities.clipSpaceMinZ,i.capabilities.clipSpaceSignY,n.surfaceTransform),this.isMobile=xl.isMobile},t.initLayout=function(){this.isMobile?(this.bgWidth=812,this.bgHeight=375,this.logoWidthTemp=70,this.logoHeightTemp=100,this.textSize=12,this.textHeight=this.textSize+this.textExpandSize,this.textXTrans=.5,this.textYExtraTrans=16):(this.bgWidth=1920,this.bgHeight=1080,this.logoWidthTemp=140,this.logoHeightTemp=200,this.textSize=24,this.textHeight=this.textSize+this.textExpandSize,this.textXTrans=.5,this.textYExtraTrans=32),this.logoXTrans=.5,this.logoYTrans=1/6+2.5/6,this.initScale()},t.initScale=function(){var t=this.swapchain.width,e=this.swapchain.height,i=this.isMobile?375:1080,n=this.isMobile?812:1920;if(t>e){var r=n;n=i,i=r}this.scaleSize=t/e>16/9?e/n:t/i},t.update=function(t){var e=this.settings,i=this.device,n=this.swapchain;In.ortho(this.projection,-1,1,-1,1,-1,1,i.capabilities.clipSpaceMinZ,i.capabilities.clipSpaceSignY,n.surfaceTransform);var r=n.width,s=n.height;this.initScale(),this._curTime+=1e3*t;var o=ra(Ri(this._curTime/e.totalTime)),a=1,h=1;"custom"===this.settings.background.type&&(r<s?(a=s*this.bgRatio,h=s):(a=r,h=r*this.bgRatio),this.bgMat.setProperty("resolution",mN.set(r,s),0),this.bgMat.setProperty("scale",mN.set(a,h),0),this.bgMat.setProperty("translate",mN.set(.5*r,.5*s),0),this.bgMat.setProperty("percent",1),this.bgMat.setProperty("u_projection",this.projection),this.bgMat.passes[0].update());var u=s*this.logoYTrans;if("none"!==this.settings.logo.type&&(a=this.logoWidth*this.scaleSize*e.displayRatio,h=this.logoHeight*this.scaleSize*e.displayRatio,this.logoMat.setProperty("resolution",mN.set(r,s),0),this.logoMat.setProperty("scale",mN.set(a,h),0),this.logoMat.setProperty("translate",mN.set(r*this.logoXTrans,u),0),this.logoMat.setProperty("percent",o),this.logoMat.setProperty("u_projection",this.projection),this.logoMat.passes[0].update()),"default"===this.settings.logo.type&&this.watermarkMat){var l=this.watermarkTexture.width,c=this.watermarkTexture.height;a=l,h=c;var _=u-(.5*this.logoHeight*e.displayRatio+this.textYExtraTrans)*this.scaleSize-.5*c;this.watermarkMat.setProperty("resolution",mN.set(r,s),0),this.watermarkMat.setProperty("scale",mN.set(a,h),0),this.watermarkMat.setProperty("translate",mN.set(r*this.textXTrans,_),0),this.watermarkMat.setProperty("percent",o),this.watermarkMat.setProperty("u_projection",this.projection),this.watermarkMat.passes[0].update()}this.frame()},t.initBG=function(){var t=this.device;this.bgMat=new xT,this.bgMat.initialize({effectName:"util/splash-screen"});var e=new $c;e.addressU=nc.CLAMP,e.addressV=nc.CLAMP,e.addressW=nc.CLAMP,this.sampler=t.getSampler(e),this.bgTexture=t.createTexture(new Qc(Jl.TEX2D,Ql.SAMPLED|Ql.TRANSFER_DST,Hl.RGBA8,this.bgImage.width,this.bgImage.height));var i=this.bgMat.passes[0],n=i.getBinding("mainTexture");i.bindTexture(n,this.bgTexture),this.shader=i.getShaderVariant();var r=i.descriptorSet;r.bindSampler(n,this.sampler),r.update();var s=new Gc;s.texExtent.width=this.bgImage.width,s.texExtent.height=this.bgImage.height,s.texExtent.depth=1,t.copyTexImagesToTexture([this.bgImage],this.bgTexture,[s])},t.initLogo=function(){var t=this.device;this.logoMat=new xT,this.logoMat.initialize({effectName:"util/splash-screen"});var e=new $c;e.addressU=nc.CLAMP,e.addressV=nc.CLAMP,e.addressW=nc.CLAMP,this.sampler=t.getSampler(e),this.logoTexture=t.createTexture(new Qc(Jl.TEX2D,Ql.SAMPLED|Ql.TRANSFER_DST,Hl.RGBA8,this.logoImage.width,this.logoImage.height));var i=this.logoMat.passes[0],n=i.getBinding("mainTexture");i.bindTexture(n,this.logoTexture),this.shader=i.getShaderVariant();var r=i.descriptorSet;r.bindSampler(n,this.sampler),r.update();var s=new Gc;s.texExtent.width=this.logoImage.width,s.texExtent.height=this.logoImage.height,s.texExtent.depth=1,t.copyTexImagesToTexture([this.logoImage],this.logoTexture,[s]);var o=this.logoImage.width/this.logoImage.height;o<1?(this.logoWidth=this.logoWidthTemp,this.logoHeight=this.logoWidthTemp/o):(this.logoWidth=this.logoHeightTemp*o,this.logoHeight=this.logoHeightTemp)},t.initWaterMark=function(){var t=T.document.createElement("canvas");t.height=this.textHeight*this.scaleSize,t.style.width=""+t.width,t.style.height=""+t.height;var e="Created with Cocos",i=t.getContext("2d");i.font=this.textSize*this.scaleSize+"px Arial",i.textBaseline="top",i.textAlign="center",i.fillStyle="#707070";var n=i.measureText(e).width+10;t.width=n,i.font=this.textSize*this.scaleSize+"px Arial",i.textBaseline="top",i.textAlign="center",i.fillStyle="#707070",i.fillText(e,t.width/2,0);var r=new Gc;r.texExtent.width=t.width,r.texExtent.height=t.height,r.texExtent.depth=1,this.watermarkTexture=this.device.createTexture(new Qc(Jl.TEX2D,Ql.SAMPLED|Ql.TRANSFER_DST,Hl.RGBA8,t.width,t.height)),this.device.copyTexImagesToTexture([t],this.watermarkTexture,[r]),this.watermarkMat=new xT,this.watermarkMat.initialize({effectName:"util/splash-screen"});var s=this.watermarkMat.passes[0],o=s.getBinding("mainTexture");s.bindTexture(o,this.watermarkTexture),s.descriptorSet.update()},t.frame=function(){var t=this.device,e=this.swapchain;if(!xl.isXR||xr.entry.isRenderAllowable())for(var i=xl.isXR?2:1,n=0;n<i;n++){if(xl.isXR){xr.entry.renderLoopStart(n);var r=xr.entry.getEyeFov(n),s=1,o=1;n===TM.LEFT?s=Math.abs(Math.tan(r[0]))/Math.abs(Math.tan(r[1])):n===TM.RIGHT&&(o=Math.abs(Math.tan(r[1]))/Math.abs(Math.tan(r[0]))),In.ortho(this.projection,-s,o,-1,1,-1,1,t.capabilities.clipSpaceMinZ,t.capabilities.clipSpaceSignY,e.surfaceTransform),this.projection.m00=Rn[e.surfaceTransform][0],this.projection.m05=Rn[e.surfaceTransform][3]*t.capabilities.clipSpaceSignY,"custom"===this.settings.background.type&&(this.bgMat.setProperty("u_projection",this.projection),this.bgMat.passes[0].update()),"none"!==this.settings.logo.type&&(this.logoMat.setProperty("u_projection",this.projection),this.logoMat.passes[0].update()),"default"===this.settings.logo.type&&this.watermarkMat&&(this.watermarkMat.setProperty("u_projection",this.projection),this.watermarkMat.passes[0].update())}t.enableAutoBarrier(!0),t.acquire([e]);var a=this.cmdBuff,h=v.director.root.mainWindow.framebuffer,u=this.renderArea;if(u.width=e.width,u.height=e.height,a.begin(),a.beginRenderPass(h.renderPass,h,u,this.clearColors,1,0),"custom"===this.settings.background.type){var l=this.bgMat.passes[0],c=lT.getOrCreatePipelineState(t,l,this.shader,h.renderPass,this.quadAssmebler);a.bindPipelineState(c),a.bindDescriptorSet(Cg.MATERIAL,l.descriptorSet),a.bindInputAssembler(this.quadAssmebler),a.draw(this.quadAssmebler)}if("none"!==this.settings.logo.type){var _=this.logoMat.passes[0],d=lT.getOrCreatePipelineState(t,_,this.shader,h.renderPass,this.quadAssmebler);a.bindPipelineState(d),a.bindDescriptorSet(Cg.MATERIAL,_.descriptorSet),a.bindInputAssembler(this.quadAssmebler),a.draw(this.quadAssmebler)}if("default"===this.settings.logo.type&&this.watermarkMat){var f=this.watermarkMat.passes[0],p=lT.getOrCreatePipelineState(t,f,this.shader,h.renderPass,this.quadAssmebler);a.bindPipelineState(p),a.bindDescriptorSet(Cg.MATERIAL,f.descriptorSet),a.bindInputAssembler(this.quadAssmebler),a.draw(this.quadAssmebler)}a.endRenderPass(),a.end(),t.flushCommands([a]),t.queue.submit([a]),t.present(),t.enableAutoBarrier(!v.rendering),xl.isXR&&xr.entry.renderLoopEnd(n)}},t.destroy=function(){this.device=null,this.swapchain=null,this.clearColors=null,"custom"===this.settings.background.type&&(this.bgImage.destroy&&this.bgImage.destroy(),this.bgImage=null,this.bgMat.destroy(),this.bgMat=null,this.bgTexture.destroy(),this.bgTexture=null),"none"!==this.settings.logo.type&&(this.logoImage.destroy&&this.logoImage.destroy(),this.logoImage=null,this.logoMat.destroy(),this.logoMat=null,this.logoTexture.destroy(),this.logoTexture=null),this.renderArea=null,this.cmdBuff=null,this.shader=null,this.quadAssmebler.destroy(),this.quadAssmebler=null,this.vertexBuffers.destroy(),this.vertexBuffers=null,this.indicesBuffers.destroy(),this.indicesBuffers=null,this.sampler=null,"default"===this.settings.logo.type&&this.watermarkTexture&&(this.watermarkMat.destroy(),this.watermarkMat=null,this.watermarkTexture.destroy(),this.watermarkTexture=null),this.settings=null},n(e,[{key:"isFinished",get:function(){return this._curTime>=this.settings.totalTime}},{key:"curTime",get:function(){return this._curTime},set:function(t){this._curTime=t}}],[{key:"instance",get:function(){return e._ins||(e._ins=new e),e._ins}}]),e}();gN._ins=void 0,v.internal.SplashScreen=gN;var yN=new(function(){function t(){this._data=null}return t.prototype.init=function(t){var e=this;return void 0===t&&(t=""),v.rendering&&v.rendering.enableEffectImport&&t?new Promise((function(i,n){var r=new XMLHttpRequest;r.open("GET",t),r.responseType="arraybuffer",r.onload=function(){e._data=r.response,i()},r.onerror=function(){n(new Error("request effect settings failed!"))},r.send(null)})):Promise.resolve()},n(t,[{key:"data",get:function(){return this._data}}]),t}());v.effectSettings=yN;var vN=t("e3",function(t){function i(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).frame=null,e.container=null,e.canvas=null,e.renderType=-1,e.eventTargetOn=t.prototype.on,e.eventTargetOnce=t.prototype.once,e.config={},e.onStart=null,e.frameTime=1e3/60,e._isCloning=!1,e._inited=!1,e._engineInited=!1,e._rendererInitialized=!1,e._paused=!0,e._pausedByEngine=!1,e._frameRate=60,e._pacer=null,e._initTime=0,e._startTime=0,e._deltaTime=0,e._useFixedDeltaTime=!1,e._shouldLoadLaunchScene=!0,e.onPreBaseInitDelegate=new il,e.onPostBaseInitDelegate=new il,e.onPreInfrastructureInitDelegate=new il,e.onPostInfrastructureInitDelegate=new il,e.onPreSubsystemInitDelegate=new il,e.onPostSubsystemInitDelegate=new il,e.onPreProjectInitDelegate=new il,e.onPostProjectInitDelegate=new il,e}s(i,t);var r=i.prototype;return r.setFrameRate=function(t){this.frameRate=t},r.getFrameRate=function(){return this.frameRate},r.step=function(){fN.tick(this._calculateDT(!0))},r.pauseByEngine=function(){this._paused||(this._pausedByEngine=!0,this.pause())},r.resumeByEngine=function(){this._pausedByEngine&&(this.resume(),this._pausedByEngine=!1)},r.pause=function(){var t;this._paused||(this._paused=!0,null===(t=this._pacer)||void 0===t||t.stop(),this.emit(i.EVENT_PAUSE))},r.resume=function(){var t;this._paused&&(bx._clearEvents(),this._paused=!1,null===(t=this._pacer)||void 0===t||t.start(),this.emit(i.EVENT_RESUME))},r.isPaused=function(){return this._paused},r.restart=function(){var t=this;return new Promise((function(t){fN.once(dN.EVENT_END_FRAME,(function(){return t()}))})).then((function(){fN.reset(),v.Object._deferredDestroy(),t.pause(),t.resume(),t._shouldLoadLaunchScene=!0,gN.instance.curTime=0,t._safeEmit(i.EVENT_RESTART)}))},r.end=function(){nl.close()},r.on=function(t,e,i,n){return this.canRegisterEvent(t)&&e.call(i),this.eventTargetOn(t,e,i,n)},r.once=function(t,e,i){return this.canRegisterEvent(t)?e.call(i):this.eventTargetOnce(t,e,i)},r.canRegisterEvent=function(t){return this._engineInited&&t===i.EVENT_ENGINE_INITED||this._inited&&t===i.EVENT_GAME_INITED||this._rendererInitialized&&t===i.EVENT_RENDERER_INITED},r.init=function(t){var n=this;return this._compatibleWithOldParams(t),Promise.resolve().then((function(){return n.emit(i.EVENT_PRE_BASE_INIT),n.onPreBaseInitDelegate.dispatch()})).then((function(){z(t.debugMode||Q.NONE)})).then((function(){return xl.init()})).then((function(){n._initEvents()})).then((function(){return Ee.init(t.settingsPath,t.overrideSettings)})).then((function(){return n.emit(i.EVENT_POST_BASE_INIT),n.onPostBaseInitDelegate.dispatch()})).then((function(){return n.emit(i.EVENT_PRE_INFRASTRUCTURE_INIT),n.onPreInfrastructureInitDelegate.dispatch()})).then((function(){Ce.init(),n._initXR();var t={frame:document.querySelector("#GameDiv"),container:document.querySelector("#Cocos3dGameContainer"),canvas:document.querySelector("#GameCanvas")};t&&(n.canvas=t.canvas,n.frame=t.frame,n.container=t.container),wl.init(),Ml.init(),Ed.init(n.canvas,Ig),""===Ce.CUSTOM_PIPELINE_NAME&&(v.rendering=void 0),ZS.init(),nT.init(),im.init(),n.initPacer()})).then((function(){return n.emit(i.EVENT_POST_INFRASTRUCTURE_INIT),n.onPostInfrastructureInitDelegate.dispatch()})).then((function(){return n.emit(i.EVENT_PRE_SUBSYSTEM_INIT),n.onPreSubsystemInitDelegate.dispatch()})).then((function(){return yN.init(Ee.querySettings(be.Category.RENDERING,"effectSettingsPath"))})).then((function(){if(v.rendering&&v.rendering.enableEffectImport)if(Ee.querySettings(be.Category.RENDERING,"renderMode")!==yd.HEADLESS){var t=yN.data;null!==t?v.rendering.init(Ed.gfxDevice,t):J(1102)}else v.rendering.init(Ed.gfxDevice,null)})).then((function(){var t=Ee.querySettings(be.Category.SCRIPTING,"scriptPackages");return t?Promise.all(t.map((function(t){return e.import(t)}))):Promise.resolve([])})).then((function(){return fN.init(),nT.loadBuiltinAssets()})).then((function(){return n.emit(i.EVENT_POST_SUBSYSTEM_INIT),n.onPostSubsystemInitDelegate.dispatch()})).then((function(){F("Cocos Creator v"+S),n.emit(i.EVENT_ENGINE_INITED),n._engineInited=!0})).then((function(){return n.emit(i.EVENT_PRE_PROJECT_INIT),n.onPreProjectInitDelegate.dispatch()})).then((function(){var t=Ee.querySettings(be.Category.PLUGINS,"jsList"),e=Promise.resolve();return t&&t.forEach((function(t){e=e.then((function(){return e="src/"+t,new Promise((function(t,i){var n;function r(t){t.filename===e&&(n=t.error)}window.addEventListener("error",r);var s=document.createElement("script");s.charset="utf-8",s.async=!0,s.crossOrigin="anonymous",s.addEventListener("error",(function(){window.removeEventListener("error",r),i(Error("Error loading "+e))})),s.addEventListener("load",(function(){window.removeEventListener("error",r),document.head.removeChild(s),n?i(n):t()})),s.src=e.replace("#","%23"),document.head.appendChild(s)}));var e}))})),e})).then((function(){return n._loadProjectBundles()})).then((function(){return n._loadCCEScripts()})).then((function(){return n._setupRenderPipeline()})).then((function(){return n._loadPreloadAssets()})).then((function(){return nT.compileBuiltinMaterial(),gN.instance.init()})).then((function(){return n.emit(i.EVENT_POST_PROJECT_INIT),n.onPostProjectInitDelegate.dispatch()})).then((function(){n._inited=!0,n._safeEmit(i.EVENT_GAME_INITED)}))},r._initXR=function(){var t;if(void 0===globalThis.__globalXR&&(globalThis.__globalXR={}),globalThis.__globalXR.webxrCompatible=null!==(t=Ee.querySettings(be.Category.XR,"webxrCompatible"))&&void 0!==t&&t,xl.isXR){var e,i;xr.entry=xr.XrEntry.getInstance();var n=null!==(e=Ee.querySettings(be.Category.RENDERING,"msaa"))&&void 0!==e?e:1,r=null!==(i=Ee.querySettings(be.Category.RENDERING,"renderingScale"))&&void 0!==i?i:1;xr.entry.setMultisamplesRTT(n),xr.entry.setRenderingScale(r)}},r._compatibleWithOldParams=function(t){var e=t.overrideSettings=t.overrideSettings||{};"showFPS"in t&&(e.profiling=e.profiling||{},e.profiling.showFPS=t.showFPS),"frameRate"in t&&(e.screen=e.screen||{},e.screen.frameRate=t.frameRate),"renderMode"in t&&(e.rendering=e.rendering||{},e.rendering.renderMode=t.renderMode),"renderPipeline"in t&&(e.rendering=e.rendering||{},e.rendering.renderPipeline=t.renderPipeline),"assetOptions"in t&&(e.assets=e.assets||{},Object.assign(e.assets,t.assetOptions)),"customJointTextureLayouts"in t&&(e.animation=e.animation||{},e.animation.customJointTextureLayouts=t.customJointTextureLayouts),"physics"in t&&(e.physics=e.physics||{},Object.assign(e.physics,t.physics)),"orientation"in t&&(e.screen=e.screen||{},e.screen.orientation=t.orientation),"exactFitScreen"in t&&(e.screen=e.screen||{},e.screen.exactFitScreen=t.exactFitScreen)},r._loadPreloadAssets=function(){var t=Ee.querySettings(be.Category.ASSETS,"preloadAssets");return t?Promise.all(t.map((function(t){return new Promise((function(e,i){ZS.loadAny(t,(function(t){t?i(t):e()}))}))}))):Promise.resolve([])},r._loadCCEScripts=function(){return new Promise((function(t){t()}))},r._loadProjectBundles=function(){var t=Ee.querySettings(be.Category.ASSETS,"preloadBundles");return t?Promise.all(t.map((function(t){var e=t.bundle,i=t.version;return new Promise((function(t,n){var r={};i&&(r.version=i),ZS.loadBundle(e,r,(function(e){e?n(e):t()}))}))}))):Promise.resolve([])},r.run=function(t){t&&(this.onStart=t),this._inited&&this.resume()},r._calculateDT=function(t){if(this._useFixedDeltaTime=t,t)return this._startTime=performance.now(),this.frameTime/1e3;var e=performance.now();return this._deltaTime=e>this._startTime?(e-this._startTime)/1e3:0,this._deltaTime>i.DEBUG_DT_THRESHOLD&&(this._deltaTime=this.frameTime/1e3),this._startTime=e,this._deltaTime},r._updateCallback=function(){var t=this;if(this._inited)if(gN.instance.isFinished)if(this._shouldLoadLaunchScene){this._shouldLoadLaunchScene=!1;var e,i=Ee.querySettings(be.Category.LAUNCH,"launchScene");i?fN.loadScene(i,(function(){var e;X(1103,i),t._initTime=performance.now(),fN.startAnimation(),null===(e=t.onStart)||void 0===e||e.call(t)})):(this._initTime=performance.now(),fN.startAnimation(),null===(e=this.onStart)||void 0===e||e.call(this))}else fN.tick(this._calculateDT(!1));else gN.instance.update(this._calculateDT(!1))},r.initPacer=function(){var t,e=null!==(t=Ee.querySettings(be.Category.SCREEN,"frameRate"))&&void 0!==t?t:60;G("number"==typeof e),this._pacer=new pN,this._pacer.onTick=this._updateCallback.bind(this),this.frameRate=e},r._initEvents=function(){nl.on("show",this._onShow,this),nl.on("hide",this._onHide,this),nl.on("close",this._onClose,this)},r._onHide=function(){this.emit(i.EVENT_HIDE),this.pauseByEngine()},r._onShow=function(){this.emit(i.EVENT_SHOW),this.resumeByEngine()},r._onClose=function(){this.emit(i.EVENT_CLOSE),nl.exit()},r.addPersistRootNode=function(t){fN.addPersistRootNode(t)},r.removePersistRootNode=function(t){fN.removePersistRootNode(t)},r.isPersistRootNode=function(t){return fN.isPersistRootNode(t)},r._setupRenderPipeline=function(){var t=this,e=Ee.querySettings(be.Category.RENDERING,"renderPipeline");return e?new Promise((function(t,i){ZS.loadAny(e,(function(e,n){return!e&&n instanceof yD?t(n):i(e)}))})).then((function(e){t._setRenderPipeline(e)})).catch((function(i){k(i),k("Failed load render pipeline: "+e+", engine failed to initialize, will fallback to default pipeline"),t._setRenderPipeline()})):this._setRenderPipeline()},r._setRenderPipeline=function(t){fN.root.setRenderPipeline(t)||this._setRenderPipeline(),this._rendererInitialized=!0,this._safeEmit(i.EVENT_RENDERER_INITED)},r._safeEmit=function(t){this.emit(t)},n(i,[{key:"inited",get:function(){return this._inited}},{key:"frameRate",get:function(){return this._frameRate},set:function(t){"number"!=typeof t&&(t=parseInt(t,10),Number.isNaN(t)&&(t=60)),this._frameRate=t,this.frameTime=1e3/t,this._pacer&&(this._pacer.targetFrameRate=this._frameRate)}},{key:"deltaTime",get:function(){return this._useFixedDeltaTime?this.frameTime/1e3:this._deltaTime}},{key:"totalTime",get:function(){return performance.now()-this._initTime}},{key:"frameStartTime",get:function(){return this._startTime}}]),i}(Ku));vN.EVENT_HIDE="game_on_hide",vN.EVENT_SHOW="game_on_show",vN.EVENT_LOW_MEMORY="game_on_low_memory",vN.EVENT_GAME_INITED="game_inited",vN.EVENT_ENGINE_INITED="engine_inited",vN.EVENT_RENDERER_INITED="renderer_inited",vN.EVENT_PRE_BASE_INIT="pre_base_init",vN.EVENT_POST_BASE_INIT="post_base_init",vN.EVENT_PRE_INFRASTRUCTURE_INIT="pre_infrastructure_init",vN.EVENT_POST_INFRASTRUCTURE_INIT="post_infrastructure_init",vN.EVENT_PRE_SUBSYSTEM_INIT="pre_subsystem_init",vN.EVENT_POST_SUBSYSTEM_INIT="post_subsystem_init",vN.EVENT_PRE_PROJECT_INIT="pre_project_init",vN.EVENT_POST_PROJECT_INIT="post_project_init",vN.EVENT_RESTART="game_on_restart",vN.EVENT_PAUSE="game_on_pause",vN.EVENT_RESUME="game_on_resume",vN.EVENT_CLOSE="game_on_close",vN.RENDER_TYPE_CANVAS=0,vN.RENDER_TYPE_WEBGL=1,vN.RENDER_TYPE_OPENGL=2,vN.RENDER_TYPE_HEADLESS=3,vN.DEBUG_DT_THRESHOLD=1,v.Game=vN;var SN=t("e4",v.game=new vN);st(dN.prototype,"director",[{name:"calculateDeltaTime"},{name:"getDeltaTime",suggest:"Use game.deltaTime instead"},{name:"getTotalTime",suggest:"Use game.totalTime instead"},{name:"getCurrentTime",suggest:"Use game.frameStartTime instead"}]),rt(dN.prototype,"director",[{name:"setAnimationInterval",suggest:"please use game.frameRate instead"},{name:"getAnimationInterval",suggest:"please use game.frameRate instead"},{name:"getRunningScene",suggest:"please use getScene instead"},{name:"setDepthTest",suggest:"please use camera API instead"},{name:"setClearColor",suggest:"please use camera API instead"},{name:"getWinSize",suggest:"please use view.getVisibleSize instead"},{name:"getWinSizeInPixels"},{name:"purgeCachedData",suggest:"please use assetManager.releaseAll instead"},{name:"convertToGL"},{name:"convertToUI"}]),nt(fN,"director",[{name:"_getSceneUuid",targetName:"assetManager.main",newName:"getSceneInfo",customFunction:function(t){var e;return ZS.main?null===(e=ZS.main.getSceneInfo(t))||void 0===e?void 0:e.uuid:""}}]),st(SN,"game",[{name:"collisionMatrix"},{name:"groupList"}]),nt(SN,"game",[{name:"_sceneInfos",targetName:"assetManager.main",newName:"getSceneInfo",customGetter:function(){var t=[];return ZS.main&&ZS.main.config.scenes.forEach((function(e){t.push(e)})),t}}]);var TN=t("a0",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._atlases=[],e._atlasIndex=-1,e._maxAtlasCount=5,e._textureSize=2048,e._maxFrameSize=512,e._textureBleeding=!0,e._enabled=!1,e}s(e,t);var i=e.prototype;return i.newAtlas=function(){var t=this._atlases[++this._atlasIndex];return t||(t=new $p(this._textureSize,this._textureSize),this._atlases.push(t)),t},i.beforeSceneLoad=function(){this.reset()},i.init=function(){this.enabled=!Ce.CLEANUP_IMAGE_CACHE},i.insertSpriteFrame=function(t){if(!this._enabled||this._atlasIndex===this._maxAtlasCount||!t||t._original)return null;if(!t.packable)return null;var e=t.texture.getSamplerInfo();if(e.minFilter!==uf.LINEAR||e.magFilter!==uf.LINEAR||e.mipFilter!==uf.NONE)return null;var i=this._atlases[this._atlasIndex];i||(i=this.newAtlas());var n=i.insertSpriteFrame(t);return n||this._atlasIndex===this._maxAtlasCount?n:(i=this.newAtlas()).insertSpriteFrame(t)},i.reset=function(){for(var t=0,e=this._atlases.length;t<e;t++)this._atlases[t].destroy();this._atlases.length=0,this._atlasIndex=-1},i.deleteAtlasSpriteFrame=function(t){if(t._original){for(var e=this._atlases.length-1;e>=0;e--)ue(this._atlases[e]._innerSpriteFrames,t);var i=t._original._texture;this.deleteAtlasTexture(i)}},i.deleteAtlasTexture=function(t){if(t)for(var e=this._atlases.length-1;e>=0;e--)this._atlases[e].deleteInnerTexture(t),this._atlases[e].isEmpty()&&(this._atlases[e].destroy(),this._atlases.splice(e,1),this._atlasIndex--)},i.packToDynamicAtlas=function(t,e){if(this._enabled&&e&&!e._original&&e.packable&&e.texture&&e.texture.width>0&&e.texture.height>0){var i=this.insertSpriteFrame(e);i&&e._setDynamicAtlasFrame(i)}},n(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(t?(this.reset(),v.director.on(v.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):(this.reset(),v.director.off(v.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)),this._enabled=t)}},{key:"maxAtlasCount",get:function(){return this._maxAtlasCount},set:function(t){this._maxAtlasCount=t}},{key:"atlasCount",get:function(){return this._atlases.length}},{key:"textureBleeding",get:function(){return this._textureBleeding},set:function(t){this._textureBleeding=t}},{key:"textureSize",get:function(){return this._textureSize},set:function(t){this._textureSize=t}},{key:"maxFrameSize",get:function(){return this._maxFrameSize},set:function(t){this._maxFrameSize=t}}]),e}(Ou));TN.instance=void 0;var AN,bN=t("a1",TN.instance=new TN);fN.registerSystem("dynamicAtlasManager",bN,0),v.internal.dynamicAtlasManager=bN,function(t){t[t.positions=Ic.ATTR_POSITION]="positions",t[t.normals=Ic.ATTR_NORMAL]="normals",t[t.uvs=Ic.ATTR_TEX_COORD]="uvs",t[t.colors=Ic.ATTR_COLOR]="colors"}(AN||(AN={}));var EN=function(){function t(){this._arrayBufferOrPaddings=[],this._length=0}var e=t.prototype;return e.setNextAlignment=function(t){if(0!==t){var e=this._length%t;if(0!==e){var i=t-e;this._arrayBufferOrPaddings.push(i),this._length+=i}}},e.addBuffer=function(t){var e=this._length;return this._arrayBufferOrPaddings.push(t),this._length+=t.byteLength,e},e.getLength=function(){return this._length},e.getCombined=function(){var t=new Uint8Array(this._length),e=0;return this._arrayBufferOrPaddings.forEach((function(i){"number"==typeof i?e+=i:(t.set(new Uint8Array(i),e),e+=i.byteLength)})),t.buffer},t}(),CN=function(){function t(t,e){if(this._mesh=void 0,this._subMeshRenderings=[],this._mesh=t,this._mesh.struct.morph){var i=this._mesh.struct.primitives.length;this._subMeshRenderings=new Array(i).fill(null);for(var n=0;n<i;++n){var r=this._mesh.struct.morph.subMeshMorphs[n];r&&(r.targets.length>ry.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[n]=new xN(this._mesh,n,this._mesh.struct.morph,e):this._subMeshRenderings[n]=new wN(this._mesh,n,this._mesh.struct.morph,e))}}}return t.prototype.createInstance=function(){for(var t=this,e=this._mesh.struct.primitives.length,i=new Array(e),n=0;n<e;++n){var r,s;i[n]=null!==(r=null===(s=this._subMeshRenderings[n])||void 0===s?void 0:s.createInstance())&&void 0!==r?r:null}return{setWeights:function(t,e){var n;null===(n=i[t])||void 0===n||n.setWeights(e)},requiredPatches:function(e){t._mesh.struct.morph;var n=t._mesh.struct.morph.subMeshMorphs[e],r=i[e];if(null===r)return null;var s=[{name:"CC_USE_MORPH",value:!0},{name:"CC_MORPH_TARGET_COUNT",value:n.targets.length}];return n.attributes.includes(Ic.ATTR_POSITION)&&s.push({name:"CC_MORPH_TARGET_HAS_POSITION",value:!0}),n.attributes.includes(Ic.ATTR_NORMAL)&&s.push({name:"CC_MORPH_TARGET_HAS_NORMAL",value:!0}),n.attributes.includes(Ic.ATTR_TANGENT)&&s.push({name:"CC_MORPH_TARGET_HAS_TANGENT",value:!0}),s.push.apply(s,r.requiredPatches()),s},adaptPipelineState:function(t,e){var n;null===(n=i[t])||void 0===n||n.adaptPipelineState(e)},destroy:function(){for(var t=0,e=i;t<e.length;t++){var n=e[t];null==n||n.destroy()}}}},t}(),wN=function(){function t(t,e,i,n){this._gfxDevice=void 0,this._subMeshMorph=void 0,this._textureInfo=void 0,this._attributes=void 0,this._verticesCount=void 0,this._gfxDevice=n;var r=i.subMeshMorphs[e];this._subMeshMorph=r,DN(t,e,n);var s=t.struct.vertexBundles[t.struct.primitives[e].vertexBundelIndices[0]].view.count;this._verticesCount=s;var o=r.targets.length,a=BN(n,s*o);this._textureInfo={width:a.width,height:a.height},this._attributes=r.attributes.map((function(e,i){var n=a.create(),o=n.valueView;return r.targets.forEach((function(e,n){for(var r=e.displacements[i],a=new Float32Array(t.data.buffer,t.data.byteOffset+r.offset,r.count),h=s*n*4,u=0;u<s;++u)o[h+4*u+0]=a[3*u+0],o[h+4*u+1]=a[3*u+1],o[h+4*u+2]=a[3*u+2]})),n.updatePixels(),{name:e,morphTexture:n}}))}var e=t.prototype;return e.destroy=function(){for(var t,e=d(this._attributes);!(t=e()).done;)t.value.morphTexture.destroy()},e.createInstance=function(){var t=this,e=new IN(this._gfxDevice,this._subMeshMorph.targets.length);return e.setMorphTextureInfo(this._textureInfo.width,this._textureInfo.height),e.setVerticesCount(this._verticesCount),e.commit(),{setWeights:function(t){e.setWeights(t),e.commit()},requiredPatches:function(){return[{name:"CC_MORPH_TARGET_USE_TEXTURE",value:!0}]},adaptPipelineState:function(i){for(var n,r=d(t._attributes);!(n=r()).done;){var s=n.value,o=void 0;switch(s.name){case Ic.ATTR_POSITION:o=dy;break;case Ic.ATTR_NORMAL:o=my;break;case Ic.ATTR_TANGENT:o=vy;break;default:k("Unexpected attribute!")}void 0!==o&&(i.bindSampler(o,s.morphTexture.sampler),i.bindTexture(o,s.morphTexture.texture))}i.bindBuffer(ry.BINDING,e.buffer),i.update()},destroy:function(){}}},t}(),xN=function(){function t(t,e,i,n){this._gfxDevice=void 0,this._attributes=[],this._gfxDevice=n;var r=i.subMeshMorphs[e];DN(t,e,n),this._attributes=r.attributes.map((function(e,i){return{name:e,targets:r.targets.map((function(e){return{displacements:new Float32Array(t.data.buffer,t.data.byteOffset+e.displacements[i].offset,e.displacements[i].count)}}))}}))}return t.prototype.createInstance=function(){return new RN(this,this._attributes[0].targets[0].displacements.length/3,this._gfxDevice)},n(t,[{key:"data",get:function(){return this._attributes}}]),t}(),RN=function(){function t(t,e,i){this._attributes=void 0,this._owner=void 0,this._morphUniforms=void 0,this._owner=t,this._morphUniforms=new IN(i,0);var n=BN(i,e);this._morphUniforms.setMorphTextureInfo(n.width,n.height),this._morphUniforms.commit(),this._attributes=this._owner.data.map((function(t){var e=n.create();return{attributeName:t.name,morphTexture:e}}))}var e=t.prototype;return e.setWeights=function(t){for(var e=0;e<this._attributes.length;++e){var i=this._attributes[e],n=i.morphTexture.valueView,r=this._owner.data[e];t.length,r.targets.length;for(var s=0;s<r.targets.length;++s){var o=r.targets[s].displacements,a=t[s],h=o.length/3;if(0===s)for(var u=0;u<h;++u)n[4*u+0]=o[3*u+0]*a,n[4*u+1]=o[3*u+1]*a,n[4*u+2]=o[3*u+2]*a;else if(0!==a)for(var l=0;l<h;++l)n[4*l+0]+=o[3*l+0]*a,n[4*l+1]+=o[3*l+1]*a,n[4*l+2]+=o[3*l+2]*a}i.morphTexture.updatePixels()}},e.requiredPatches=function(){return[{name:"CC_MORPH_TARGET_USE_TEXTURE",value:!0},{name:"CC_MORPH_PRECOMPUTED",value:!0}]},e.adaptPipelineState=function(t){for(var e,i=d(this._attributes);!(e=i()).done;){var n=e.value,r=void 0;switch(n.attributeName){case Ic.ATTR_POSITION:r=dy;break;case Ic.ATTR_NORMAL:r=my;break;case Ic.ATTR_TANGENT:r=vy;break;default:k("Unexpected attribute!")}void 0!==r&&(t.bindSampler(r,n.morphTexture.sampler),t.bindTexture(r,n.morphTexture.texture))}t.bindBuffer(ry.BINDING,this._morphUniforms.buffer),t.update()},e.destroy=function(){this._morphUniforms.destroy();for(var t=0;t<this._attributes.length;++t)this._attributes[t].morphTexture.destroy()},t}(),IN=function(){function t(t,e){this._targetCount=void 0,this._localBuffer=void 0,this._remoteBuffer=void 0,this._targetCount=e,this._localBuffer=new DataView(new ArrayBuffer(ry.SIZE)),this._remoteBuffer=t.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,ry.SIZE,ry.SIZE))}var e=t.prototype;return e.destroy=function(){this._remoteBuffer.destroy()},e.setWeights=function(t){t.length,this._targetCount;for(var e=0;e<t.length;++e)this._localBuffer.setFloat32(ry.OFFSET_OF_WEIGHTS+4*e,t[e],v.sys.isLittleEndian)},e.setMorphTextureInfo=function(t,e){this._localBuffer.setFloat32(ry.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH,t,v.sys.isLittleEndian),this._localBuffer.setFloat32(ry.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT,e,v.sys.isLittleEndian)},e.setVerticesCount=function(t){this._localBuffer.setFloat32(ry.OFFSET_OF_VERTICES_COUNT,t,v.sys.isLittleEndian)},e.commit=function(){this._remoteBuffer.update(this._localBuffer.buffer)},n(t,[{key:"buffer",get:function(){return this._remoteBuffer}}]),t}();function BN(t,e){var i,n,r,s;t.getFormatFeatures(Hl.RGBA32F)&$l.SAMPLED_TEXTURE?(i=e,r=16,n=Zp.PixelFormat.RGBA32F,s=Float32Array):(i=4*e,r=4,n=Zp.PixelFormat.RGBA8888,s=Uint8Array);var o=function(t){t<5&&(t=5);var e=A(Vi(t)),i=e>>1;return{width:1<<(1&e?i+1:i),height:1<<i}}(i),a=o.width,h=o.height;return{width:a,height:h,create:function(){var e=new ArrayBuffer(a*h*r),i=new Float32Array(e),o=s===Float32Array?i:new s(e),u=new Rf({width:a,height:h,_data:o,_compressed:!1,format:n}),l=new Zp;l.setFilters(Zp.Filter.NEAREST,Zp.Filter.NEAREST),l.setMipFilter(Zp.Filter.NONE),l.setWrapMode(Zp.WrapMode.CLAMP_TO_EDGE,Zp.WrapMode.CLAMP_TO_EDGE,Zp.WrapMode.CLAMP_TO_EDGE),l.image=u,l.getGFXTexture()||k("Unexpected: failed to create morph texture?");var c=t.getSampler(l.getSamplerInfo());return{get texture(){return l.getGFXTexture()},get sampler(){return c},get valueView(){return i},destroy:function(){l.destroy()},updatePixels:function(){l.uploadData(o)}}}}}function DN(t,e,i){t.renderingSubMeshes[e].enableVertexIdChannel(i)}function PN(t,i){return(n=t,new Promise((function(t,i){try{n=new URL(n,e.meta.url).href,fetch(n).then((function(e){return e.arrayBuffer().then(t)})).catch((function(){}))}catch(t){i(t)}}))).then((function(t){return WebAssembly.instantiate(t,i)}));var n}function ON(){return Promise.resolve()}var MN={};SN.onPostInfrastructureInitDelegate.add((function(){return ON().then((function(){return Promise.all([e.import("./meshopt_decoder.asm-43e747aa.js"),e.import("./meshopt_decoder.wasm-ebbcb6df.js"),e.import("./meshopt_decoder.wasm-43855155.js")]).then((function(t){var e,i,n,r=t[0].default,s=t[1].default,o=t[2].default;return xl.hasFeature(xl.Feature.WASM)?(i=s,n=o,Promise.all([i.ready((function(t){return PN(n,t)}))]).then((function(){MN.supported=i.supported,MN.ready=Promise.resolve(),MN.decodeVertexBuffer=i.decodeVertexBuffer,MN.decodeIndexBuffer=i.decodeIndexBuffer,MN.decodeIndexSequence=i.decodeIndexSequence,MN.decodeGltfBuffer=i.decodeGltfBuffer,MN.useWorkers=i.useWorkers,MN.decodeGltfBufferAsync=i.decodeGltfBufferAsync,X(14203)}))):(e=r,Promise.all([e.ready]).then((function(){MN.supported=e.supported,MN.ready=Promise.resolve(),MN.decodeVertexBuffer=e.decodeVertexBuffer,MN.decodeIndexBuffer=e.decodeIndexBuffer,MN.decodeIndexSequence=e.decodeIndexSequence,MN.decodeGltfBuffer=e.decodeGltfBuffer,MN.useWorkers=e.useWorkers,MN.decodeGltfBufferAsync=e.decodeGltfBufferAsync,X(14202)})))}))}))}));
  2. /** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
  3. var LN={};(function(){function t(t){throw t}var e=void 0,i=!0,n=this;function r(t,i){var r,s=t.split("."),o=n;!(s[0]in o)&&o.execScript&&o.execScript("var "+s[0]);for(;s.length&&(r=s.shift());)s.length||i===e?o=o[r]?o[r]:o[r]={}:o[r]=i}var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array;function o(t){if("string"==typeof t){var e,i,n=t.split("");for(e=0,i=n.length;e<i;e++)n[e]=(255&n[e].charCodeAt(0))>>>0;t=n}for(var r,s=1,o=0,a=t.length,h=0;0<a;){a-=r=1024<a?1024:a;do{o+=s+=t[h++]}while(--r);s%=65521,o%=65521}return(o<<16|s)>>>0}function a(e,i){this.index="number"==typeof i?i:0,this.i=0,this.buffer=e instanceof(s?Uint8Array:Array)?e:new(s?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}a.prototype.f=function(){var t,e=this.buffer,i=e.length,n=new(s?Uint8Array:Array)(i<<1);if(s)n.set(e);else for(t=0;t<i;++t)n[t]=e[t];return this.buffer=n},a.prototype.d=function(t,e,i){var n,r=this.buffer,s=this.index,o=this.i,a=r[s];if(i&&1<e&&(t=8<e?(d[255&t]<<24|d[t>>>8&255]<<16|d[t>>>16&255]<<8|d[t>>>24&255])>>32-e:d[t]>>8-e),8>e+o)a=a<<e|t,o+=e;else for(n=0;n<e;++n)a=a<<1|t>>e-n-1&1,8==++o&&(o=0,r[s++]=d[a],a=0,s===r.length&&(r=this.f()));r[s]=a,this.buffer=r,this.i=o,this.index=s},a.prototype.finish=function(){var t,e=this.buffer,i=this.index;return 0<this.i&&(e[i]<<=8-this.i,e[i]=d[e[i]],i++),s?t=e.subarray(0,i):(e.length=i,t=e),t};var h,u=new(s?Uint8Array:Array)(256);for(h=0;256>h;++h){for(var l=_=h,c=7,_=_>>>1;_;_>>>=1)l<<=1,l|=1&_,--c;u[h]=(l<<c&255)>>>0}var d=u;function f(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function p(t){var e,i,n,r,o,a,h,u,l,c=t.length,_=0,d=Number.POSITIVE_INFINITY;for(u=0;u<c;++u)t[u]>_&&(_=t[u]),t[u]<d&&(d=t[u]);for(e=1<<_,i=new(s?Uint32Array:Array)(e),n=1,r=0,o=2;n<=_;){for(u=0;u<c;++u)if(t[u]===n){for(a=0,h=r,l=0;l<n;++l)a=a<<1|1&h,h>>=1;for(l=a;l<e;l+=o)i[l]=n<<16|u;++r}++n,r<<=1,o<<=1}return[i,_,d]}function m(t,e){this.h=y,this.w=0,this.input=t,this.b=0,e&&(e.lazy&&(this.w=e.lazy),"number"==typeof e.compressionType&&(this.h=e.compressionType),e.outputBuffer&&(this.a=s&&e.outputBuffer instanceof Array?new Uint8Array(e.outputBuffer):e.outputBuffer),"number"==typeof e.outputIndex&&(this.b=e.outputIndex)),this.a||(this.a=new(s?Uint8Array:Array)(32768))}f.prototype.getParent=function(t){return 2*((t-2)/4|0)},f.prototype.push=function(t,e){var i,n,r,s=this.buffer;for(i=this.length,s[this.length++]=e,s[this.length++]=t;0<i&&(n=this.getParent(i),s[i]>s[n]);)r=s[i],s[i]=s[n],s[n]=r,r=s[i+1],s[i+1]=s[n+1],s[n+1]=r,i=n;return this.length},f.prototype.pop=function(){var t,e,i,n,r,s=this.buffer;for(e=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],r=0;!((n=2*r+2)>=this.length)&&(n+2<this.length&&s[n+2]>s[n]&&(n+=2),s[n]>s[r]);)i=s[r],s[r]=s[n],s[n]=i,i=s[r+1],s[r+1]=s[n+1],s[n+1]=i,r=n;return{index:t,value:e,length:this.length}};var g,y=2,v={NONE:0,r:1,j:y,N:3},S=[];for(g=0;288>g;g++)switch(i){case 143>=g:S.push([g+48,8]);break;case 255>=g:S.push([g-144+400,9]);break;case 279>=g:S.push([g-256+0,7]);break;case 287>=g:S.push([g-280+192,8]);break;default:t("invalid literal: "+g)}function T(t,e){this.length=t,this.G=e}function A(){var e=b;switch(i){case 3===e:return[257,e-3,0];case 4===e:return[258,e-4,0];case 5===e:return[259,e-5,0];case 6===e:return[260,e-6,0];case 7===e:return[261,e-7,0];case 8===e:return[262,e-8,0];case 9===e:return[263,e-9,0];case 10===e:return[264,e-10,0];case 12>=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}m.prototype.n=function(){var n,r,o,h,u=this.input;switch(this.h){case 0:for(o=0,h=u.length;o<h;){var l,c,_,d=r=s?u.subarray(o,o+65535):u.slice(o,o+65535),f=(o+=r.length)===h,p=e,m=e,g=this.a,v=this.b;if(s){for(g=new Uint8Array(this.a.buffer);g.length<=v+d.length+5;)g=new Uint8Array(g.length<<1);g.set(this.a)}if(l=f?1:0,g[v++]=0|l,_=65536+~(c=d.length)&65535,g[v++]=255&c,g[v++]=c>>>8&255,g[v++]=255&_,g[v++]=_>>>8&255,s)g.set(d,v),v+=d.length,g=g.subarray(0,v);else{for(p=0,m=d.length;p<m;++p)g[v++]=d[p];g.length=v}this.b=v,this.a=g}break;case 1:var T=new a(new Uint8Array(this.a.buffer),this.b);T.d(1,1,i),T.d(1,2,i);var A,b,E,C=x(this,u);for(A=0,b=C.length;A<b;A++)if(E=C[A],a.prototype.d.apply(T,S[E]),256<E)T.d(C[++A],C[++A],i),T.d(C[++A],5),T.d(C[++A],C[++A],i);else if(256===E)break;this.a=T.finish(),this.b=this.a.length;break;case y:var w,B,D,P,O,M,L,N,F,k,V,G,U,z,H,W=new a(new Uint8Array(this.a),this.b),j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],X=Array(19);for(w=y,W.d(1,1,i),W.d(w,2,i),B=x(this,u),L=I(M=R(this.L,15)),F=I(N=R(this.K,7)),D=286;257<D&&0===M[D-1];D--);for(P=30;1<P&&0===N[P-1];P--);var q,Y,K,J,Q,Z,$=D,tt=P,et=new(s?Uint32Array:Array)($+tt),it=new(s?Uint32Array:Array)(316),nt=new(s?Uint8Array:Array)(19);for(q=Y=0;q<$;q++)et[Y++]=M[q];for(q=0;q<tt;q++)et[Y++]=N[q];if(!s)for(q=0,J=nt.length;q<J;++q)nt[q]=0;for(q=Q=0,J=et.length;q<J;q+=Y){for(Y=1;q+Y<J&&et[q+Y]===et[q];++Y);if(K=Y,0===et[q])if(3>K)for(;0<K--;)it[Q++]=0,nt[0]++;else for(;0<K;)(Z=138>K?K:138)>K-3&&Z<K&&(Z=K-3),10>=Z?(it[Q++]=17,it[Q++]=Z-3,nt[17]++):(it[Q++]=18,it[Q++]=Z-11,nt[18]++),K-=Z;else if(it[Q++]=et[q],nt[et[q]]++,3>--K)for(;0<K--;)it[Q++]=et[q],nt[et[q]]++;else for(;0<K;)(Z=6>K?K:6)>K-3&&Z<K&&(Z=K-3),it[Q++]=16,it[Q++]=Z-3,nt[16]++,K-=Z}for(n=s?it.subarray(0,Q):it.slice(0,Q),k=R(nt,7),z=0;19>z;z++)X[z]=k[j[z]];for(O=19;4<O&&0===X[O-1];O--);for(V=I(k),W.d(D-257,5,i),W.d(P-1,5,i),W.d(O-4,4,i),z=0;z<O;z++)W.d(X[z],3,i);for(z=0,H=n.length;z<H;z++)if(G=n[z],W.d(V[G],k[G],i),16<=G){switch(z++,G){case 16:U=2;break;case 17:U=3;break;case 18:U=7;break;default:t("invalid code: "+G)}W.d(n[z],U,i)}var rt,st,ot,at,ht,ut,lt,ct,_t=[L,M],dt=[F,N];for(ht=_t[0],ut=_t[1],lt=dt[0],ct=dt[1],rt=0,st=B.length;rt<st;++rt)if(ot=B[rt],W.d(ht[ot],ut[ot],i),256<ot)W.d(B[++rt],B[++rt],i),at=B[++rt],W.d(lt[at],ct[at],i),W.d(B[++rt],B[++rt],i);else if(256===ot)break;this.a=W.finish(),this.b=this.a.length;break;default:t("invalid compression type")}return this.a};var b,E,C=[];for(b=3;258>=b;b++)E=A(),C[b]=E[2]<<24|E[1]<<16|E[0];var w=s?new Uint32Array(C):C;function x(n,r){function o(e,n){var r,s,o,a,h=e.G,u=[],l=0;switch(r=w[e.length],u[l++]=65535&r,u[l++]=r>>16&255,u[l++]=r>>24,i){case 1===h:s=[0,h-1,0];break;case 2===h:s=[1,h-2,0];break;case 3===h:s=[2,h-3,0];break;case 4===h:s=[3,h-4,0];break;case 6>=h:s=[4,h-5,1];break;case 8>=h:s=[5,h-7,1];break;case 12>=h:s=[6,h-9,2];break;case 16>=h:s=[7,h-13,2];break;case 24>=h:s=[8,h-17,3];break;case 32>=h:s=[9,h-25,3];break;case 48>=h:s=[10,h-33,4];break;case 64>=h:s=[11,h-49,4];break;case 96>=h:s=[12,h-65,5];break;case 128>=h:s=[13,h-97,5];break;case 192>=h:s=[14,h-129,6];break;case 256>=h:s=[15,h-193,6];break;case 384>=h:s=[16,h-257,7];break;case 512>=h:s=[17,h-385,7];break;case 768>=h:s=[18,h-513,8];break;case 1024>=h:s=[19,h-769,8];break;case 1536>=h:s=[20,h-1025,9];break;case 2048>=h:s=[21,h-1537,9];break;case 3072>=h:s=[22,h-2049,10];break;case 4096>=h:s=[23,h-3073,10];break;case 6144>=h:s=[24,h-4097,11];break;case 8192>=h:s=[25,h-6145,11];break;case 12288>=h:s=[26,h-8193,12];break;case 16384>=h:s=[27,h-12289,12];break;case 24576>=h:s=[28,h-16385,13];break;case 32768>=h:s=[29,h-24577,13];break;default:t("invalid distance")}for(r=s,u[l++]=r[0],u[l++]=r[1],u[l++]=r[2],o=0,a=u.length;o<a;++o)g[y++]=u[o];S[u[0]]++,A[u[3]]++,v=e.length+n-1,f=null}var a,h,u,l,c,_,d,f,p,m={},g=s?new Uint16Array(2*r.length):[],y=0,v=0,S=new(s?Uint32Array:Array)(286),A=new(s?Uint32Array:Array)(30),b=n.w;if(!s){for(u=0;285>=u;)S[u++]=0;for(u=0;29>=u;)A[u++]=0}for(S[256]=1,a=0,h=r.length;a<h;++a){for(u=c=0,l=3;u<l&&a+u!==h;++u)c=c<<8|r[a+u];if(m[c]===e&&(m[c]=[]),_=m[c],!(0<v--)){for(;0<_.length&&32768<a-_[0];)_.shift();if(a+3>=h){for(f&&o(f,-1),u=0,l=h-a;u<l;++u)p=r[a+u],g[y++]=p,++S[p];break}if(0<_.length){var E=e,C=e,x=0,R=e,I=e,B=e,D=r.length,P=(I=0,_.length);t:for(;I<P;I++){if(E=_[P-I-1],R=3,3<x){for(B=x;3<B;B--)if(r[E+B-1]!==r[a+B-1])continue t;R=x}for(;258>R&&a+R<D&&r[E+R]===r[a+R];)++R;if(R>x&&(C=E,x=R),258===R)break}d=new T(x,a-C),f?f.length<d.length?(p=r[a-1],g[y++]=p,++S[p],o(d,0)):o(f,-1):d.length<b?f=d:o(d,0)}else f?o(f,-1):(p=r[a],g[y++]=p,++S[p])}_.push(a)}return g[y++]=256,S[256]++,n.L=S,n.K=A,s?g.subarray(0,y):g}function R(t,e){function i(t){var e=b[t][E[t]];e===y?(i(t+1),i(t+1)):--T[e],++E[t]}var n,r,o,a,h,u=t.length,l=new f(572),c=new(s?Uint8Array:Array)(u);if(!s)for(a=0;a<u;a++)c[a]=0;for(a=0;a<u;++a)0<t[a]&&l.push(a,t[a]);if(n=Array(l.length/2),r=new(s?Uint32Array:Array)(l.length/2),1===n.length)return c[l.pop().index]=1,c;for(a=0,h=l.length/2;a<h;++a)n[a]=l.pop(),r[a]=n[a].value;var _,d,p,m,g,y=r.length,v=new(s?Uint16Array:Array)(e),S=new(s?Uint8Array:Array)(e),T=new(s?Uint8Array:Array)(y),A=Array(e),b=Array(e),E=Array(e),C=(1<<e)-y,w=1<<e-1;for(v[e-1]=y,d=0;d<e;++d)C<w?S[d]=0:(S[d]=1,C-=w),C<<=1,v[e-2-d]=(v[e-1-d]/2|0)+y;for(v[0]=S[0],A[0]=Array(v[0]),b[0]=Array(v[0]),d=1;d<e;++d)v[d]>2*v[d-1]+S[d]&&(v[d]=2*v[d-1]+S[d]),A[d]=Array(v[d]),b[d]=Array(v[d]);for(_=0;_<y;++_)T[_]=e;for(p=0;p<v[e-1];++p)A[e-1][p]=r[p],b[e-1][p]=p;for(_=0;_<e;++_)E[_]=0;for(1===S[e-1]&&(--T[0],++E[e-1]),d=e-2;0<=d;--d){for(m=_=0,g=E[d+1],p=0;p<v[d];p++)(m=A[d+1][g]+A[d+1][g+1])>r[_]?(A[d][p]=m,b[d][p]=y,g+=2):(A[d][p]=r[_],b[d][p]=_,++_);E[d]=0,1===S[d]&&i(d)}for(o=T,a=0,h=n.length;a<h;++a)c[n[a].index]=o[a];return c}function I(e){var i,n,r,o,a=new(s?Uint16Array:Array)(e.length),h=[],u=[],l=0;for(i=0,n=e.length;i<n;i++)h[e[i]]=1+(0|h[e[i]]);for(i=1,n=16;i<=n;i++)u[i]=l,(l+=0|h[i])>1<<i&&t("overcommitted"),l<<=1;for(65536>l&&t("undercommitted"),i=0,n=e.length;i<n;i++)for(l=u[e[i]],u[e[i]]+=1,r=a[i]=0,o=e[i];r<o;r++)a[i]=a[i]<<1|1&l,l>>>=1;return a}function B(t,e){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=D.j;var i,n={};for(i in!e&&(e={})||"number"!=typeof e.compressionType||(this.h=e.compressionType),e)n[i]=e[i];n.outputBuffer=this.a,this.z=new m(this.input,n)}var D=v;function P(e,i){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=s?new Uint8Array(e):e,this.s=!1,this.m=M,this.B=!1,!i&&(i={})||(i.index&&(this.c=i.index),i.bufferSize&&(this.l=i.bufferSize),i.bufferType&&(this.m=i.bufferType),i.resize&&(this.B=i.resize)),this.m){case O:this.b=32768,this.a=new(s?Uint8Array:Array)(32768+this.l+258);break;case M:this.b=0,this.a=new(s?Uint8Array:Array)(this.l),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}B.prototype.n=function(){var e,i,n,r,a,h,u,l=0;switch(u=this.a,e=lt){case lt:i=Math.LOG2E*Math.log(32768)-8;break;default:t(Error("invalid compression method"))}switch(n=i<<4|e,u[l++]=n,e){case lt:switch(this.h){case D.NONE:a=0;break;case D.r:a=1;break;case D.j:a=2;break;default:t(Error("unsupported compression type"))}break;default:t(Error("invalid compression method"))}return r=a<<6|0,u[l++]=r|31-(256*n+r)%31,h=o(this.input),this.z.b=l,l=(u=this.z.n()).length,s&&((u=new Uint8Array(u.buffer)).length<=l+4&&(this.a=new Uint8Array(u.length+4),this.a.set(u),u=this.a),u=u.subarray(0,l+4)),u[l++]=h>>24&255,u[l++]=h>>16&255,u[l++]=h>>8&255,u[l++]=255&h,u},r("Zlib.Deflate",B),r("Zlib.Deflate.compress",(function(t,e){return new B(t,e).n()})),r("Zlib.Deflate.CompressionType",D),r("Zlib.Deflate.CompressionType.NONE",D.NONE),r("Zlib.Deflate.CompressionType.FIXED",D.r),r("Zlib.Deflate.CompressionType.DYNAMIC",D.j);var O=0,M=1,L={D:O,C:M};P.prototype.p=function(){for(;!this.s;){var n=tt(this,3);switch(1&n&&(this.s=i),n>>>=1){case 0:var r=this.input,o=this.c,a=this.a,h=this.b,u=e,l=e,c=e,_=a.length,d=e;switch(this.e=this.g=0,(u=r[o++])===e&&t(Error("invalid uncompressed block header: LEN (first byte)")),l=u,(u=r[o++])===e&&t(Error("invalid uncompressed block header: LEN (second byte)")),l|=u<<8,(u=r[o++])===e&&t(Error("invalid uncompressed block header: NLEN (first byte)")),c=u,(u=r[o++])===e&&t(Error("invalid uncompressed block header: NLEN (second byte)")),l===~(c|=u<<8)&&t(Error("invalid uncompressed block header: length verify")),o+l>r.length&&t(Error("input buffer is broken")),this.m){case O:for(;h+l>a.length;){if(l-=d=_-h,s)a.set(r.subarray(o,o+d),h),h+=d,o+=d;else for(;d--;)a[h++]=r[o++];this.b=h,a=this.f(),h=this.b}break;case M:for(;h+l>a.length;)a=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(s)a.set(r.subarray(o,o+l),h),h+=l,o+=l;else for(;l--;)a[h++]=r[o++];this.c=o,this.b=h,this.a=a;break;case 1:this.o(Q,$);break;case 2:it(this);break;default:t(Error("unknown BTYPE: "+n))}}return this.t()};var N,F,k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V=s?new Uint16Array(k):k,G=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],U=s?new Uint16Array(G):G,z=[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],H=s?new Uint8Array(z):z,W=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],j=s?new Uint16Array(W):W,X=[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],q=s?new Uint8Array(X):X,Y=new(s?Uint8Array:Array)(288);for(N=0,F=Y.length;N<F;++N)Y[N]=143>=N?8:255>=N?9:279>=N?7:8;var K,J,Q=p(Y),Z=new(s?Uint8Array:Array)(30);for(K=0,J=Z.length;K<J;++K)Z[K]=5;var $=p(Z);function tt(i,n){for(var r,s=i.g,o=i.e,a=i.input,h=i.c;o<n;)(r=a[h++])===e&&t(Error("input buffer is broken")),s|=r<<o,o+=8;return r=s&(1<<n)-1,i.g=s>>>n,i.e=o-n,i.c=h,r}function et(i,n){for(var r,s,o,a=i.g,h=i.e,u=i.input,l=i.c,c=n[0],_=n[1];h<_;)(r=u[l++])===e&&t(Error("input buffer is broken")),a|=r<<h,h+=8;return o=(s=c[a&(1<<_)-1])>>>16,i.g=a>>o,i.e=h-o,i.c=l,65535&s}function it(t){function e(t,e,i){var n,r,s,o;for(o=0;o<t;)switch(n=et(this,e),n){case 16:for(s=3+tt(this,2);s--;)i[o++]=r;break;case 17:for(s=3+tt(this,3);s--;)i[o++]=0;r=0;break;case 18:for(s=11+tt(this,7);s--;)i[o++]=0;r=0;break;default:r=i[o++]=n}return i}var i,n,r,o,a=tt(t,5)+257,h=tt(t,5)+1,u=tt(t,4)+4,l=new(s?Uint8Array:Array)(V.length);for(o=0;o<u;++o)l[V[o]]=tt(t,3);i=p(l),n=new(s?Uint8Array:Array)(a),r=new(s?Uint8Array:Array)(h),t.o(p(e.call(t,a,i,n)),p(e.call(t,h,i,r)))}function nt(e,i){var n,r;switch(this.input=e,this.c=0,!i&&(i={})||(i.index&&(this.c=i.index),i.verify&&(this.M=i.verify)),n=e[this.c++],r=e[this.c++],15&n){case lt:this.method=lt;break;default:t(Error("unsupported compression method"))}0!=((n<<8)+r)%31&&t(Error("invalid fcheck flag:"+((n<<8)+r)%31)),32&r&&t(Error("fdict flag is not supported")),this.A=new P(e,{index:this.c,bufferSize:i.bufferSize,bufferType:i.bufferType,resize:i.resize})}P.prototype.o=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,o,a,h=i.length-258;256!==(r=et(this,t));)if(256>r)n>=h&&(this.b=n,i=this.f(),n=this.b),i[n++]=r;else for(a=U[s=r-257],0<H[s]&&(a+=tt(this,H[s])),r=et(this,e),o=j[r],0<q[r]&&(o+=tt(this,q[r])),n>=h&&(this.b=n,i=this.f(),n=this.b);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},P.prototype.I=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,o,a,h=i.length;256!==(r=et(this,t));)if(256>r)n>=h&&(h=(i=this.f()).length),i[n++]=r;else for(a=U[s=r-257],0<H[s]&&(a+=tt(this,H[s])),r=et(this,e),o=j[r],0<q[r]&&(o+=tt(this,q[r])),n+a>h&&(h=(i=this.f()).length);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},P.prototype.f=function(){var t,e,i=new(s?Uint8Array:Array)(this.b-32768),n=this.b-32768,r=this.a;if(s)i.set(r.subarray(32768,i.length));else for(t=0,e=i.length;t<e;++t)i[t]=r[t+32768];if(this.k.push(i),this.q+=i.length,s)r.set(r.subarray(n,n+32768));else for(t=0;32768>t;++t)r[t]=r[n+t];return this.b=32768,r},P.prototype.J=function(t){var e,i,n,r=this.input.length/this.c+1|0,o=this.input,a=this.a;return t&&("number"==typeof t.v&&(r=t.v),"number"==typeof t.F&&(r+=t.F)),i=2>r?(n=(o.length-this.c)/this.u[2]/2*258|0)<a.length?a.length+n:a.length<<1:a.length*r,s?(e=new Uint8Array(i)).set(a):e=a,this.a=e},P.prototype.t=function(){var t,e,i,n,r,o=0,a=this.a,h=this.k,u=new(s?Uint8Array:Array)(this.q+(this.b-32768));if(0===h.length)return s?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);for(e=0,i=h.length;e<i;++e)for(n=0,r=(t=h[e]).length;n<r;++n)u[o++]=t[n];for(e=32768,i=this.b;e<i;++e)u[o++]=a[e];return this.k=[],this.buffer=u},P.prototype.H=function(){var t,e=this.b;return s?this.B?(t=new Uint8Array(e)).set(this.a.subarray(0,e)):t=this.a.subarray(0,e):(this.a.length>e&&(this.a.length=e),t=this.a),this.buffer=t},nt.prototype.p=function(){var e,i=this.input;return e=this.A.p(),this.c=this.A.c,this.M&&(i[this.c++]<<24|i[this.c++]<<16|i[this.c++]<<8|i[this.c++])>>>0!==o(e)&&t(Error("invalid adler-32 checksum")),e},r("Zlib.Inflate",nt),r("Zlib.Inflate.BufferType",L),L.ADAPTIVE=L.C,L.BLOCK=L.D,r("Zlib.Inflate.prototype.decompress",nt.prototype.p);var rt,st,ot=new(s?Uint8Array:Array)(288);for(rt=0,st=ot.length;rt<st;++rt)ot[rt]=143>=rt?8:255>=rt?9:279>=rt?7:8;p(ot);var at,ht,ut=new(s?Uint8Array:Array)(30);for(at=0,ht=ut.length;at<ht;++at)ut[at]=5;p(ut);var lt=8}).call(LN);var NN,FN,kN,VN,GN,UN=LN.Zlib;function zN(t){switch(t){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array;default:return Uint8Array}}UN.Deflate=UN.Deflate,UN.Deflate.compress=UN.Deflate.compress,UN.Inflate=UN.Inflate,UN.Inflate.BufferType=UN.Inflate.BufferType,UN.Inflate.prototype.decompress=UN.Inflate.prototype.decompress;var HN=new on,WN=new on,jN=new Uint8Array,XN=t("a6",qs("cc.Mesh")((FN=function(t){function e(){var e;return(e=t.call(this)||this).morphRendering=null,e._struct=kN&&kN(),e._hash=VN&&VN(),e._data=jN,e._initialized=!1,e._allowDataAccess=GN&&GN(),e._isMeshDataUploaded=!1,e._renderingSubMeshes=null,e._boneSpaceBounds=new Map,e._jointBufferIndices=null,e}s(e,t);var i=e.prototype;return i.onLoaded=function(){this.initialize()},i.initialize=function(){if(!this._initialized){this._initialized=!0;var t={struct:this.struct,data:this.data};if(t.struct.compressed&&(t=$N(t)),this.struct.encoded&&(t=ZN(t)),!this.struct.quantized||Ed.gfxDevice.getFormatFeatures(Hl.RGB16F)&$l.VERTEX_ATTRIBUTE||(t=function(t){var e=JSON.parse(JSON.stringify(t.struct)),i=new EN;function n(t,e,i,n,r,s,o){for(var a=0;a<i;a++)for(var h=0;h<n;h++)e(o*a+r*h,t(s*a+r*h))}function r(t,e,i,n,r,s){for(var o=0;o<i;o++)for(var a=0;a<n;a++)e(s*o+4*a,Zi(t(r*o+2*a)))}i.setNextAlignment(0);for(var s=0;s<e.vertexBundles.length;++s){for(var o=e.vertexBundles[s],a=o.view,h=o.attributes,u=t.struct.vertexBundles[s].attributes,l=[],c=[],_=[],f=0;f<h.length;++f){var p=h[f],m=JN(new DataView(t.data.buffer,a.offset+qN(u,f)),p.format),g=!0;switch(p.format){case Hl.R16F:p.format=Hl.R32F;break;case Hl.RG16F:p.format=Hl.RG32F;break;case Hl.RGB16F:p.format=Hl.RGB32F;break;case Hl.RGBA16F:p.format=Hl.RGBA32F;break;default:g=!1}l.push(M_[p.format].size),c.push(g),_.push(m)}for(var y=l.reduce((function(t,e){return t+e}),0),v=new Uint8Array(y*a.count),S=0;S<h.length;++S){var T=h[S],A=_[S],b=QN(new DataView(v.buffer,qN(h,S)),T.format),E=c[S],C=M_[T.format];E?r(A,b,a.count,C.count,a.stride,y):n(A,b,a.count,C.count,C.size/C.count,a.stride,y)}i.setNextAlignment(y);var w={offset:i.getLength(),length:v.byteLength,count:a.count,stride:y};o.view=w,i.addBuffer(v)}for(var x,R=d(e.primitives);!(x=R()).done;){var I=x.value;if(void 0!==I.indexView){var B=I.indexView,D=new Uint8Array(t.data.buffer,B.offset,B.length);i.setNextAlignment(B.stride);var P={offset:i.getLength(),length:D.byteLength,count:B.count,stride:B.stride};I.indexView=P,i.addBuffer(D)}}var O=new Uint8Array(i.getCombined());return e.quantized=!1,{struct:e,data:O}}(t)),this._struct=t.struct,this._data=t.data,this._struct.dynamic){for(var e=Ed.gfxDevice,i=[],n=[],r=0;r<this._struct.vertexBundles.length;r++){var s=this._struct.vertexBundles[r],o=e.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,s.view.length,s.view.stride));i.push(o)}for(var a=0;a<this._struct.primitives.length;a++){var h=this._struct.primitives[a],u=h.indexView,l=null;u&&(l=e.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,u.length,u.stride)));for(var c=[],_=0;_<h.vertexBundelIndices.length;_++){var f=h.vertexBundelIndices[_];c.push(i[f])}for(var p=[],m=0;m<h.vertexBundelIndices.length;m++)for(var g,y=h.vertexBundelIndices[m],v=d(this._struct.vertexBundles[y].attributes);!(g=v()).done;){var S=g.value,T=new u_;T.copy(S),p.push(T)}var A=new OR(c,p,h.primitiveMode,l);A.drawInfo=new Yc,A.mesh=this,A.subMeshIdx=a,n.push(A)}this._renderingSubMeshes=n}else{for(var b=this._data.buffer,E=Ed.gfxDevice,C=this._createVertexBuffers(E,b),w=[],x=[],R=0;R<this._struct.primitives.length;R++){var I=this._struct.primitives[R];if(0!==I.vertexBundelIndices.length){var B=null,D=void 0;if(I.indexView){var P=I.indexView,O=P.stride,M=P.length;if(4===O&&!E.hasFeature(zl.ELEMENT_INDEX_UINT)){var L=this._struct.vertexBundles[I.vertexBundelIndices[0]].view.count;if(L>=65536){Y(10001,L,65536);continue}O>>=1,M>>=1}B=E.createBuffer(new Xc(Xl.INDEX,Kl.DEVICE,M,O)),w.push(B),D=new(zN(P.stride))(b,P.offset,P.count),P.stride!==O&&(D=zN(O).from(D)),B.update(D)}var N=I.vertexBundelIndices.map((function(t){return C[t]})),F=[];if(I.vertexBundelIndices.length>0)for(var k=I.vertexBundelIndices[0],V=this._struct.vertexBundles[k].attributes,G=0;G<V.length;++G){var U=V[G];F[G]=new u_(U.name,U.format,U.isNormalized,U.stream,U.isInstanced,U.location)}var z=new OR(N,F,I.primitiveMode,B);z.mesh=this,z.subMeshIdx=R,x.push(z)}}this._renderingSubMeshes=x,this._struct.morph&&(this.morphRendering=function(t,e){return new CN(t,e)}(this,E)),this._isMeshDataUploaded=!0,this._allowDataAccess||this.releaseData()}}},i.updateSubMesh=function(t,e){if(this._struct.dynamic)if(t>=this._struct.primitives.length)Y(14201);else{var i=[];if(e.positions.length>0&&i.push(e.positions),e.normals&&e.normals.length>0&&i.push(e.normals),e.uvs&&e.uvs.length>0&&i.push(e.uvs),e.tangents&&e.tangents.length>0&&i.push(e.tangents),e.colors&&e.colors.length>0&&i.push(e.colors),e.customAttributes)for(var n=0;n<e.customAttributes.length;n++)i.push(e.customAttributes[n].values);for(var r=this._struct.dynamic,s=r.info,o=this._struct.primitives[t],a=this._renderingSubMeshes[t],h=a.drawInfo,u=0;u<i.length;u++){var l=i[u],c=this._struct.vertexBundles[o.vertexBundelIndices[u]],_=c.view.stride,f=l.byteLength/_,p=l.byteLength,m=new Uint8Array(this._data.buffer,c.view.offset,p),g=new Uint8Array(l.buffer,l.byteOffset,p),y=a.vertexBuffers[u];s.maxSubMeshVertices,p>0&&(m.set(g),y.update(g,p)),c.view.count=f,h.vertexCount=f}if(o.indexView){var v=o.indexView,S=v.stride,T=2===S?e.indices16.length:e.indices32.length,A=T*S,b=new Uint8Array(this._data.buffer,v.offset,A),E=2===S?new Uint8Array(e.indices16.buffer,e.indices16.byteOffset,A):new Uint8Array(e.indices32.buffer,e.indices32.byteOffset,A),C=a.indexBuffer;s.maxSubMeshIndices,A>0&&(b.set(E),C.update(E,A)),v.count=T,h.indexCount=T}if(e.minPos&&e.maxPos){var w=new on(e.minPos.x,e.minPos.y,e.minPos.z),x=new on(e.maxPos.x,e.maxPos.y,e.maxPos.z);r.bounds[t]||(r.bounds[t]=new Ss),Ss.fromPoints(r.bounds[t],w,x);for(var R,I=new on,B=new on,D=d(r.bounds);!(R=D()).done;){var P=R.value;P&&(P.getBoundary(I,B),on.min(w,I,w),on.max(x,B,x))}this._struct.minPosition=new on(w.x,w.y,w.z),this._struct.maxPosition=new on(x.x,x.y,x.z)}a.invalidateGeometricInfo()}else Y(14200)},i.destroy=function(){return this.destroyRenderingMesh(),t.prototype.destroy.call(this)},i.destroyRenderingMesh=function(){if(this._renderingSubMeshes){for(var t=0;t<this._renderingSubMeshes.length;t++)this._renderingSubMeshes[t].destroy();this._renderingSubMeshes=null,this._initialized=!1,this._isMeshDataUploaded=!1}},i.assign=function(t,e){this.reset({struct:t,data:e})},i.reset=function(t){this.destroyRenderingMesh(),this._struct=t.struct,this._data=t.data,this._hash=0},i.getBoneSpaceBounds=function(t){if(this._boneSpaceBounds.has(t.hash))return this._boneSpaceBounds.get(t.hash);var e=[];this._boneSpaceBounds.set(t.hash,e);for(var i=[],n=t.bindposes,r=0;r<n.length;r++)e.push(new Ss(1/0,1/0,1/0,-1/0,-1/0,-1/0)),i.push(!1);for(var s=this._struct.primitives,o=0;o<s.length;o++){var a=this.readAttribute(o,Ic.ATTR_JOINTS),h=this.readAttribute(o,Ic.ATTR_WEIGHTS),u=this.readAttribute(o,Ic.ATTR_POSITION);if(a&&h&&u)for(var l=Math.min(a.length/4,h.length/4,u.length/3),c=0;c<l;c++){on.set(HN,u[3*c+0],u[3*c+1],u[3*c+2]);for(var _=0;_<4;++_){var d=4*c+_,f=a[d];if(!(0===h[d]||f>=n.length)){on.transformMat4(WN,HN,n[f]),i[f]=!0;var p=e[f];on.min(p.center,p.center,WN),on.max(p.halfExtents,p.halfExtents,WN)}}}}for(var m=0;m<n.length;m++){var g=e[m];i[m]?Ss.fromPoints(g,g.center,g.halfExtents):e[m]=null}return e},i.merge=function(t,e,i){if(i&&!this.validateMergingMesh(t))return!1;var n=new on,r=e&&new Sn,s=e&&new Ss;if(r&&e.getRotation(r),!this._initialized){var o=JSON.parse(JSON.stringify(t._struct)),a=t._data.slice();if(e){o.maxPosition&&o.minPosition&&(on.add(s.center,o.maxPosition,o.minPosition),on.multiplyScalar(s.center,s.center,.5),on.subtract(s.halfExtents,o.maxPosition,o.minPosition),on.multiplyScalar(s.halfExtents,s.halfExtents,.5),Ss.transform(s,s,e),on.add(o.maxPosition,s.center,s.halfExtents),on.subtract(o.minPosition,s.center,s.halfExtents));for(var h=0;h<o.vertexBundles.length;h++)for(var u=o.vertexBundles[h],l=0;l<u.attributes.length;l++)if(u.attributes[l].name===Ic.ATTR_POSITION||u.attributes[l].name===Ic.ATTR_NORMAL){var c=u.attributes[l].format,_=new DataView(a.buffer,u.view.offset+qN(u.attributes,l)),f=JN(_,c),p=QN(_,c);if(!f||!p)continue;for(var m=u.view.count,g=u.view.stride,y=KN(c),v=0;v<m;v++){var S=v*g,T=S+y,A=T+y;switch(n.set(f(S),f(T),f(A)),u.attributes[l].name){case Ic.ATTR_POSITION:n.transformMat4(e);break;case Ic.ATTR_NORMAL:on.transformQuat(n,n,r)}p(S,n.x),p(T,n.y),p(A,n.z)}}}return this.reset({struct:o,data:a}),this.initialize(),!0}for(var b,E,C,w,x,R=new EN,I=0,B=0,D=0,P=0,O=0,M=0,L=0,N=0,F=!1,k=new Array(this._struct.vertexBundles.length),V=0;V<this._struct.vertexBundles.length;++V){var G=this._struct.vertexBundles[V],U=t._struct.vertexBundles[V];D=G.view.offset,P=U.view.offset,B=G.view.stride,I=G.view.count+U.view.count,b=new ArrayBuffer(I*B),E=new Uint8Array(b),D+=(C=this._data.subarray(D,D+G.view.length)).length,P+=(w=t._data.subarray(P,P+U.view.length)).length,E.set(C),O=0;for(var z,H=d(G.attributes);!(z=H()).done;){var W=z.value;L=0,F=!1;for(var j,X=d(U.attributes);!(j=X()).done;){var q=j.value;if(W.name===q.name&&W.format===q.format){F=!0;break}L+=M_[q.format].size}if(F){N=M_[W.format].size,M=G.view.length+O;for(var Y=0;Y<U.view.count;++Y){if(x=w.subarray(L,L+N),E.set(x,M),(W.name===Ic.ATTR_POSITION||W.name===Ic.ATTR_NORMAL)&&e){var K=new Float32Array(E.buffer,M,3);switch(n.set(K[0],K[1],K[2]),W.name){case Ic.ATTR_POSITION:n.transformMat4(e);break;case Ic.ATTR_NORMAL:on.transformQuat(n,n,r)}K[0]=n.x,K[1]=n.y,K[2]=n.z}M+=G.view.stride,L+=U.view.stride}}O+=M_[W.format].size}k[V]={attributes:G.attributes,view:{offset:R.getLength(),length:b.byteLength,count:I,stride:B}},R.addBuffer(b)}for(var J,Q,Z,$=0,tt=2,et=new Array(this._struct.primitives.length),it=0;it<this._struct.primitives.length;++it){var nt=this._struct.primitives[it],rt=t._struct.primitives[it];et[it]={primitiveMode:nt.primitiveMode,vertexBundelIndices:nt.vertexBundelIndices};for(var st,ot=0,at=d(nt.vertexBundelIndices);!(st=at()).done;){var ht=st.value;ot=Math.max(ot,this._struct.vertexBundles[ht].view.count)}if(nt.indexView&&rt.indexView){$=nt.indexView.count,$+=rt.indexView.count,D=nt.indexView.offset,P=rt.indexView.offset,tt=$<256?1:$<65536?2:4;var ut=new ArrayBuffer($*tt);if(J=2===tt?new Uint16Array(ut):1===tt?new Uint8Array(ut):new Uint32Array(ut),Q=2===nt.indexView.stride?new Uint16Array(this._data.buffer,D,nt.indexView.count):1===nt.indexView.stride?new Uint8Array(this._data.buffer,D,nt.indexView.count):new Uint32Array(this._data.buffer,D,nt.indexView.count),tt===nt.indexView.stride)J.set(Q);else for(var lt=0;lt<nt.indexView.count;++lt)J[lt]=Q[lt];D+=nt.indexView.length,Z=2===rt.indexView.stride?new Uint16Array(t._data.buffer,P,rt.indexView.count):1===rt.indexView.stride?new Uint8Array(t._data.buffer,P,rt.indexView.count):new Uint32Array(t._data.buffer,P,rt.indexView.count);for(var ct=0;ct<rt.indexView.count;++ct)J[nt.indexView.count+ct]=ot+Z[ct];P+=rt.indexView.length,et[it].indexView={offset:R.getLength(),length:ut.byteLength,count:$,stride:tt},R.setNextAlignment(tt),R.addBuffer(ut)}}var _t={vertexBundles:k,primitives:et,minPosition:this._struct.minPosition,maxPosition:this._struct.maxPosition};return _t.minPosition&&t._struct.minPosition&&_t.maxPosition&&t._struct.maxPosition&&(e?(on.add(s.center,t._struct.maxPosition,t._struct.minPosition),on.multiplyScalar(s.center,s.center,.5),on.subtract(s.halfExtents,t._struct.maxPosition,t._struct.minPosition),on.multiplyScalar(s.halfExtents,s.halfExtents,.5),Ss.transform(s,s,e),on.add(n,s.center,s.halfExtents),on.max(_t.maxPosition,_t.maxPosition,n),on.subtract(n,s.center,s.halfExtents),on.min(_t.minPosition,_t.minPosition,n)):(on.min(_t.minPosition,_t.minPosition,t._struct.minPosition),on.max(_t.maxPosition,_t.maxPosition,t._struct.maxPosition))),this.reset({struct:_t,data:new Uint8Array(R.getCombined())}),this.initialize(),!0},i.validateMergingMesh=function(t){if(this._struct.dynamic||t._struct.dynamic)return!1;if(this._struct.vertexBundles.length!==t._struct.vertexBundles.length)return!1;for(var e=0;e<this._struct.vertexBundles.length;++e){var i=this._struct.vertexBundles[e],n=t._struct.vertexBundles[e];if(i.attributes.length!==n.attributes.length)return!1;for(var r=0;r<i.attributes.length;++r)if(i.attributes[r].format!==n.attributes[r].format)return!1}if(this._struct.primitives.length!==t._struct.primitives.length)return!1;for(var s=0;s<this._struct.primitives.length;++s){var o=this._struct.primitives[s],a=t._struct.primitives[s];if(o.vertexBundelIndices.length!==a.vertexBundelIndices.length)return!1;for(var h=0;h<o.vertexBundelIndices.length;++h)if(o.vertexBundelIndices[h]!==a.vertexBundelIndices[h])return!1;if(o.primitiveMode!==a.primitiveMode)return!1;if(o.indexView){if(void 0===a.indexView)return!1}else if(a.indexView)return!1}return!0},i.readAttribute=function(t,e){var i=this,n=null;return this._accessAttribute(t,e,(function(t,e){var r=t.view.count,s=t.attributes[e].format,o=H_(M_[s]);if(0!==r){var a=new DataView(i._data.buffer,t.view.offset+qN(t.attributes,e)),h=M_[s],u=JN(a,s);if(o&&u){for(var l=h.count,c=new o(r*l),_=t.view.stride,d=0;d<r;++d)for(var f=0;f<l;++f)c[l*d+f]=u(_*d+c.BYTES_PER_ELEMENT*f);n=c}}})),n},i.copyAttribute=function(t,e,i,n,r){var s=this,o=!1;return this._accessAttribute(t,e,(function(t,e){var a=t.view.count;if(0!==a){var h=t.attributes[e].format,u=new DataView(s._data.buffer,t.view.offset+qN(t.attributes,e)),l=new DataView(i,r),c=M_[h],_=JN(u,h),d=QN(l,h);if(_&&d){for(var f=c.count,p=t.view.stride,m=KN(h),g=n,y=m,v=0;v<a;++v)for(var S=0;S<f;++S)d(g*v+y*S,_(p*v+m*S));o=!0}}else o=!0})),o},i.readIndices=function(t){if(t>=this._struct.primitives.length)return null;var e=this._struct.primitives[t];if(!e.indexView)return null;var i=e.indexView.stride;return new(1===i?Uint8Array:2===i?Uint16Array:Uint32Array)(this._data.buffer,e.indexView.offset,e.indexView.count)},i.copyIndices=function(t,e){if(t>=this._struct.primitives.length)return!1;var i=this._struct.primitives[t];if(!i.indexView)return!1;for(var n=i.indexView.count,r=1===i.indexView.stride?Hl.R8UI:2===i.indexView.stride?Hl.R16UI:Hl.R32UI,s=JN(new DataView(this._data.buffer),r),o=0;o<n;++o)e[o]=s(i.indexView.offset+M_[r].size*o);return!0},i.readAttributeFormat=function(t,e){var i=null;return this._accessAttribute(t,e,(function(t,e){var n=t.attributes[e].format;i=M_[n]})),i},i._accessAttribute=function(t,e,i){if(!(t>=this._struct.primitives.length))for(var n,r=d(this._struct.primitives[t].vertexBundelIndices);!(n=r()).done;){var s=n.value,o=this._struct.vertexBundles[s],a=o.attributes.findIndex((function(t){return t.name===e}));if(!(a<0)){i(o,a);break}}},i._createVertexBuffers=function(t,e){return this._struct.vertexBundles.map((function(i){var n=t.createBuffer(new Xc(Xl.VERTEX,Kl.DEVICE,i.view.length,i.view.stride)),r=new Uint8Array(e,i.view.offset,i.view.length);return n.update(r),n}))},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.reset({struct:{vertexBundles:[],primitives:[]},data:jN})},i.releaseData=function(){this._data=jN},n(e,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(t){this._data=new Uint8Array(t)}},{key:"subMeshCount",get:function(){var t=this.renderingSubMeshes;return t?t.length:0}},{key:"minPosition",get:function(){return this.struct.minPosition}},{key:"maxPosition",get:function(){return this.struct.maxPosition}},{key:"struct",get:function(){return this._struct}},{key:"data",get:function(){return this._data}},{key:"hash",get:function(){return this._hash||(this._hash=Dl(this._data,666)),this._hash}},{key:"jointBufferIndices",get:function(){return this._jointBufferIndices?this._jointBufferIndices:this._jointBufferIndices=this._struct.primitives.map((function(t){return t.jointMapIndex||0}))}},{key:"renderingSubMeshes",get:function(){return this.initialize(),this._renderingSubMeshes}},{key:"allowDataAccess",get:function(){return this._allowDataAccess},set:function(t){this._allowDataAccess=t,this._isMeshDataUploaded&&!this._allowDataAccess&&this.releaseData()}}]),e}(of),kN=ks(FN.prototype,"_struct",[io],(function(){return{vertexBundles:[],primitives:[]}})),VN=ks(FN.prototype,"_hash",[io],(function(){return 0})),GN=ks(FN.prototype,"_allowDataAccess",[io],(function(){return!0})),NN=FN))||NN);function qN(t,e){for(var i=0,n=0;n<e;++n){var r=t[n];i+=M_[r.format].size}return i}v.Mesh=XN;var YN=xl.isLittleEndian;function KN(t){var e=M_[t];return e.size/e.count}function JN(t,e){var i=M_[e],n=i.size/i.count;switch(i.type){case Wl.UNORM:switch(n){case 1:return function(e){return t.getUint8(e)};case 2:return function(e){return t.getUint16(e,YN)};case 4:return function(e){return t.getUint32(e,YN)}}break;case Wl.SNORM:case Wl.INT:switch(n){case 1:return function(e){return t.getInt8(e)};case 2:return function(e){return t.getInt16(e,YN)};case 4:return function(e){return t.getInt32(e,YN)}}break;case Wl.UINT:switch(n){case 1:return function(e){return t.getUint8(e)};case 2:return function(e){return t.getUint16(e,YN)};case 4:return function(e){return t.getUint32(e,YN)}}break;case Wl.FLOAT:switch(n){case 2:return function(e){return t.getUint16(e,YN)};case 4:return function(e){return t.getFloat32(e,YN)}}}return null}function QN(t,e){var i=M_[e],n=i.size/i.count;switch(i.type){case Wl.UNORM:switch(n){case 1:return function(e,i){return t.setUint8(e,i)};case 2:return function(e,i){return t.setUint16(e,i,YN)};case 4:return function(e,i){return t.setUint32(e,i,YN)}}break;case Wl.SNORM:case Wl.INT:switch(n){case 1:return function(e,i){return t.setInt8(e,i)};case 2:return function(e,i){return t.setInt16(e,i,YN)};case 4:return function(e,i){return t.setInt32(e,i,YN)}}break;case Wl.UINT:switch(n){case 1:return function(e,i){return t.setUint8(e,i)};case 2:return function(e,i){return t.setUint16(e,i,YN)};case 4:return function(e,i){return t.setUint32(e,i,YN)}}break;case Wl.FLOAT:switch(n){case 2:return function(e,i){return t.setUint16(e,i,YN)};case 4:return function(e,i){return t.setFloat32(e,i,YN)}}}return null}function ZN(t){if(!t.struct.encoded)return t;var e=function(t){t<0&&J(14204,t)},i=JSON.parse(JSON.stringify(t.struct)),n=new EN;n.setNextAlignment(0);for(var r,s=d(i.vertexBundles);!(r=s()).done;){var o=r.value,a=o.view,h=a.count*a.stride,u=new Uint8Array(h),l=new Uint8Array(t.data.buffer,a.offset,a.length);e(MN.decodeVertexBuffer(u,a.count,a.stride,l)),n.setNextAlignment(a.stride);var c={offset:n.getLength(),length:u.byteLength,count:a.count,stride:a.stride};o.view=c,n.addBuffer(u)}for(var _,f=d(i.primitives);!(_=f()).done;){var p=_.value;if(void 0!==p.indexView){var m=p.indexView,g=m.count*m.stride,y=new Uint8Array(g),v=new Uint8Array(t.data.buffer,m.offset,m.length);e(MN.decodeIndexBuffer(y,m.count,m.stride,v)),n.setNextAlignment(m.stride);var S={offset:n.getLength(),length:y.byteLength,count:m.count,stride:m.stride};p.indexView=S,n.addBuffer(y)}}return{struct:i,data:new Uint8Array(n.getCombined())}}function $N(t){var e=new UN.Inflate(t.data).decompress();return t.data=e,t.struct.compressed=!1,t}var tF=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_NORMAL,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_TANGENT,Hl.RGBA32F),new u_(Ic.ATTR_COLOR,Hl.RGBA32F)],eF=new on;function iF(t,e,i){i=i||{};var n,r=[],s=0,o=[],a=0,h=t.positions.slice();if(h.length>0){if(n=null,t.attributes)for(var u,l=d(t.attributes);!(u=l()).done;){var c=u.value;if(c.name===Ic.ATTR_POSITION){n=c;break}}n||(n=tF[0]),r.push(n);var _=M_[n.format];a=Math.max(a,Math.floor(h.length/_.count)),o.push({offset:s,data:h,attribute:n}),s+=_.size}if(t.normals&&t.normals.length>0){if(n=null,t.attributes)for(var f,p=d(t.attributes);!(f=p()).done;){var m=f.value;if(m.name===Ic.ATTR_NORMAL){n=m;break}}n||(n=tF[1]);var g=M_[n.format];r.push(n),a=Math.max(a,Math.floor(t.normals.length/g.count)),o.push({offset:s,data:t.normals,attribute:n}),s+=g.size}if(t.uvs&&t.uvs.length>0){if(n=null,t.attributes)for(var y,v=d(t.attributes);!(y=v()).done;){var S=y.value;if(S.name===Ic.ATTR_TEX_COORD){n=S;break}}n||(n=tF[2]);var T=M_[n.format];r.push(n),a=Math.max(a,Math.floor(t.uvs.length/T.count)),o.push({offset:s,data:t.uvs,attribute:n}),s+=T.size}if(t.tangents&&t.tangents.length>0){if(n=null,t.attributes)for(var A,b=d(t.attributes);!(A=b()).done;){var E=A.value;if(E.name===Ic.ATTR_TANGENT){n=E;break}}n||(n=tF[3]);var C=M_[n.format];r.push(n),a=Math.max(a,Math.floor(t.tangents.length/C.count)),o.push({offset:s,data:t.tangents,attribute:n}),s+=C.size}if(t.colors&&t.colors.length>0){if(n=null,t.attributes)for(var w,x=d(t.attributes);!(w=x()).done;){var R=w.value;if(R.name===Ic.ATTR_COLOR){n=R;break}}n||(n=tF[4]);var I=M_[n.format];r.push(n),a=Math.max(a,Math.floor(t.colors.length/I.count)),o.push({offset:s,data:t.colors,attribute:n}),s+=I.size}if(t.customAttributes)for(var B=0;B<t.customAttributes.length;B++){var D=t.customAttributes[B],P=M_[D.attr.format];r.push(D.attr),a=Math.max(a,Math.floor(D.values.length/P.count)),o.push({offset:s,data:D.values,attribute:D.attr}),s+=P.size}for(var O=new EN,M=new ArrayBuffer(a*s),L=new DataView(M),N=0,F=o;N<F.length;N++){var k=F[N];BR(L,k.data,k.attribute.format,k.offset,s)}O.setNextAlignment(0);var V={attributes:r,view:{offset:O.getLength(),length:M.byteLength,count:a,stride:s}};O.addBuffer(M);var G=null,U=0;if(t.indices){var z=t.indices;U=z.length,G=new ArrayBuffer(2*U),BR(new DataView(G),z,Hl.R16UI)}var H={primitiveMode:t.primitiveMode||pc.TRIANGLE_LIST,vertexBundelIndices:[0]};G&&(O.setNextAlignment(2),H.indexView={offset:O.getLength(),length:G.byteLength,count:U,stride:2},O.addBuffer(G));var W=t.minPos;if(!W&&i.calculateBounds){W=on.set(new on,1/0,1/0,1/0);for(var j=0;j<a;++j)on.set(eF,h[3*j+0],h[3*j+1],h[3*j+2]),on.min(W,W,eF)}var X=t.maxPos;if(!X&&i.calculateBounds){X=on.set(new on,-1/0,-1/0,-1/0);for(var q=0;q<a;++q)on.set(eF,h[3*q+0],h[3*q+1],h[3*q+2]),on.max(X,X,eF)}var Y={vertexBundles:[V],primitives:[H]};return W&&(Y.minPosition=new on(W.x,W.y,W.z)),X&&(Y.maxPosition=new on(X.x,X.y,X.z)),e||(e=new XN),e.reset({struct:Y,data:new Uint8Array(O.getCombined())}),e}function nF(t,e){if(e>0){var i=t%e;if(0!==i)return e-i}return 0}var rF,sF,oF=function(){function t(){}return t.createMesh=function(t,e,i){return iF(t,e,i)},t.createDynamicMesh=function(t,e,i,n){return function(t,e,i,n){n=n||{maxSubMeshes:1,maxSubMeshVertices:1024,maxSubMeshIndices:1024};var r=[],s=0;if(e.positions.length>0&&r.push(new u_(Ic.ATTR_POSITION,Hl.RGB32F,!1,s++,!1,0)),e.normals&&e.normals.length>0&&r.push(new u_(Ic.ATTR_NORMAL,Hl.RGB32F,!1,s++,!1,0)),e.uvs&&e.uvs.length>0&&r.push(new u_(Ic.ATTR_TEX_COORD,Hl.RG32F,!1,s++,!1,0)),e.tangents&&e.tangents.length>0&&r.push(new u_(Ic.ATTR_TANGENT,Hl.RGBA32F,!1,s++,!1,0)),e.colors&&e.colors.length>0&&r.push(new u_(Ic.ATTR_COLOR,Hl.RGBA32F,!1,s++,!1,0)),e.customAttributes)for(var o=0;o<e.customAttributes.length;o++){var a=e.customAttributes[o],h=new u_;h.copy(a.attr),h.stream=s++,r.push(h)}for(var u=[],l=[],c=0,_=0;_<n.maxSubMeshes;_++){for(var f,p={vertexBundelIndices:[],primitiveMode:e.primitiveMode||pc.TRIANGLE_LIST},m=d(r);!(f=m()).done;){var g=f.value,y=M_[g.format],v=n.maxSubMeshVertices*y.size,S={view:{offset:c,length:v,count:0,stride:y.size},attributes:[g]},T=u.length;p.vertexBundelIndices.push(T),u.push(S),c+=v}var A=0;if(e.indices16&&e.indices16.length>0?A=2:e.indices32&&e.indices32.length>0&&(A=4),A>0){c+=nF(c,A);var b=n.maxSubMeshIndices*A,E={offset:c,length:b,count:0,stride:A};p.indexView=E,c+=b}l.push(p)}var C={info:{maxSubMeshes:n.maxSubMeshes,maxSubMeshVertices:n.maxSubMeshVertices,maxSubMeshIndices:n.maxSubMeshIndices},bounds:[]};C.bounds.length=n.maxSubMeshes;var w={struct:{vertexBundles:u,primitives:l,dynamic:C},data:new Uint8Array(c)};return i||(i=new XN),i.reset(w),i.initialize(),i.updateSubMesh(t,e),i}(t,e,i,n)},t.decodeMesh=function(t){return ZN(t)},t.inflateMesh=function(t){return $N(t)},t}(),aF=Object.freeze({__proto__:null,find:aL,toPPM:function(t,e,i){return"P3 "+e+" "+i+" 255\n"+t.filter((function(t,e){return e%4<3})).toString()+"\n"},readMesh:function(t,e){void 0===e&&(e=0);for(var i,n={positions:[]},r=new DataView(t.data.buffer,t.data.byteOffset,t.data.byteLength),s=t.struct,o=s.primitives[e],a=d(o.vertexBundelIndices);!(i=a()).done;)for(var h,u=i.value,l=s.vertexBundles[u],c=l.view.offset,_=l.view,f=_.length,p=_.stride,m=d(l.attributes);!(h=m()).done;){var g=h.value,y=AN[g.name];y&&(n[y]=(n[y]||[]).concat(DR(r,g.format,c,f,p))),c+=M_[g.format].size}var v=o.indexView;return n.indices=DR(r,Hl["R"+8*v.stride+"UI"],v.offset,v.length),n},createMesh:iF,MeshUtils:oF,readBuffer:DR,writeBuffer:BR,mapBuffer:PR});t("a4",aF);var hF,uF=new on,lF=new In;!function(t){t[t.RECT=0]="RECT",t[t.POLYGON=1]="POLYGON"}(hF||(hF={}));var cF,_F,dF,fF=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],pF=t("b",qs("cc.SpriteFrame")(((sF=function(t){function e(){var e;return(e=t.call(this)||this).vertices=null,e.uv=[],e.unbiasUV=[],e.uvSliced=[],e._rect=new Un,e._trimmedBorder=new tn,e._offset=new Ln,e._originalSize=new Vn,e._rotated=!1,e._capInsets=[0,0,0,0],e._atlasUuid="",e._texture=void 0,e._isFlipUVY=!1,e._isFlipUVX=!1,e._original=null,e._packable=!0,e._pixelsToUnit=100,e._pivot=new Ln(.5,.5),e._meshType=hF.RECT,e._extrude=0,e._customOutLine=[],e._minPos=new on,e._maxPos=new on,e}s(e,t),e.createWithImage=function(t){var i=t instanceof Rf?t:new Rf(t),n=new Zp;n.image=i;var r=new e;return r.texture=n,r};var i=e.prototype;return i.textureLoaded=function(){return!!this.texture},i.isRotated=function(){return this._rotated},i.setRotated=function(t){this.rotated=t},i.getRect=function(t){return t?(t.set(this._rect),t):this._rect.clone()},i.setRect=function(t){this.rect=t},i.getOriginalSize=function(t){return t?(t.set(this._originalSize),t):this._originalSize.clone()},i.setOriginalSize=function(t){this.originalSize=t},i.getOffset=function(t){return t?(t.set(this._offset),t):this._offset.clone()},i.setOffset=function(t){this.offset=t},i.getGFXTexture=function(){return this._texture.getGFXTexture()},i.getGFXSampler=function(){return this._texture.getGFXSampler()},i.getHash=function(){return this._texture.getHash()},i.getSamplerInfo=function(){return this._texture.getSamplerInfo()},i.reset=function(t,e){void 0===e&&(e=!1);var i=!1;e&&(this._originalSize.set(0,0),this._rect.set(0,0,0,0),this._offset.set(0,0),this._capInsets=[0,0,0,0],this._rotated=!1,i=!0),t&&(t.texture&&(this._rect.x=this._rect.y=0,this._rect.width=t.texture.width,this._rect.height=t.texture.height,this._refreshTexture(t.texture),this.checkRect(this._texture)),t.originalSize&&this._originalSize.set(t.originalSize),t.rect&&this._rect.set(t.rect),t.offset&&this._offset.set(t.offset),void 0!==t.borderTop&&(this._capInsets[1]=t.borderTop),void 0!==t.borderBottom&&(this._capInsets[3]=t.borderBottom),void 0!==t.borderLeft&&(this._capInsets[0]=t.borderLeft),void 0!==t.borderRight&&(this._capInsets[2]=t.borderRight),void 0!==t.isRotate&&(this._rotated=!!t.isRotate),void 0!==t.isFlipUv&&(this._isFlipUVY=!!t.isFlipUv),i=!0),i&&this.texture&&this._calculateUV(),this._calcTrimmedBorder()},i.checkRect=function(t){var e=this._rect,i=e.x,n=e.y;return this._rotated?(i+=e.height,n+=e.width):(i+=e.width,n+=e.height),i>t.width?(J(3300,this.name+"/"+t.name,i,t.width),!1):!(n>t.height&&(J(3301,this.name+"/"+t.name,n,t.height),1))},i._calcTrimmedBorder=function(){var t=this._originalSize.width,e=this._originalSize.height,i=.5*(t-this._rect.width),n=.5*(e-this._rect.height);this._trimmedBorder.x=this._offset.x+i,this._trimmedBorder.y=this._offset.x-i,this._trimmedBorder.z=this._offset.y+n,this._trimmedBorder.w=this._offset.y-n},i.ensureMeshData=function(){this._mesh||(this._initVertices(),this._createMesh())},i.destroy=function(){return this._packable&&bN&&bN.deleteAtlasSpriteFrame(this),t.prototype.destroy.call(this)},i._calculateSlicedUV=function(){var t=this._rect,i=this.texture,n=i.width,r=i.height,s=this._capInsets[0],o=this._capInsets[2],a=t.width-s-o,h=this._capInsets[1],u=this._capInsets[3],l=t.height-h-u,c=this.uvSliced;if(c.length=0,this._rotated){fF[0].u=t.x/n,fF[1].u=(t.x+u)/n,fF[2].u=(t.x+u+l)/n,fF[3].u=(t.x+t.height)/n,fF[3].v=t.y/r,fF[2].v=(t.y+s)/r,fF[1].v=(t.y+s+a)/r,fF[0].v=(t.y+t.width)/r;for(var _=0;_<4;++_)for(var d=fF[_],f=0;f<4;++f){var p=fF[3-f];c.push({u:d.u,v:p.v})}}else{fF[0].u=t.x/n,fF[1].u=(t.x+s)/n,fF[2].u=(t.x+s+a)/n,fF[3].u=(t.x+t.width)/n,fF[3].v=t.y/r,fF[2].v=(t.y+h)/r,fF[1].v=(t.y+h+l)/r,fF[0].v=(t.y+t.height)/r;for(var m=0;m<4;++m)for(var g=fF[m],y=0;y<4;++y){var v=fF[y];c.push({u:v.u,v:g.v})}}this.emit(e.EVENT_UV_UPDATED,this)},i._calculateUV=function(){var t=this._rect,e=this.uv,i=this.unbiasUV,n=this.texture,r=n.width,s=n.height;if(this._rotated){var o=0===r?0:t.x/r,a=0===r?1:(t.x+t.height)/r,h=0===s?0:t.y/s,u=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=a,e[1]=u,e[2]=a,e[3]=h,e[4]=o,e[5]=u,e[6]=o,e[7]=h):this._isFlipUVX?(e[0]=a,e[1]=h,e[2]=a,e[3]=u,e[4]=o,e[5]=h,e[6]=o,e[7]=u):this._isFlipUVY?(e[0]=o,e[1]=u,e[2]=o,e[3]=h,e[4]=a,e[5]=u,e[6]=a,e[7]=h):(e[0]=o,e[1]=h,e[2]=o,e[3]=u,e[4]=a,e[5]=h,e[6]=a,e[7]=u);var l=0===r?0:t.x/r,c=0===r?1:(t.x+t.height)/r,_=0===s?0:t.y/s,d=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=c,i[1]=d,i[2]=c,i[3]=_,i[4]=l,i[5]=d,i[6]=l,i[7]=_):this._isFlipUVX?(i[0]=c,i[1]=_,i[2]=c,i[3]=d,i[4]=l,i[5]=_,i[6]=l,i[7]=d):this._isFlipUVY?(i[0]=l,i[1]=d,i[2]=l,i[3]=_,i[4]=c,i[5]=d,i[6]=c,i[7]=_):(i[0]=l,i[1]=_,i[2]=l,i[3]=d,i[4]=c,i[5]=_,i[6]=c,i[7]=d)}else{var f=0===r?0:t.x/r,p=0===r?1:(t.x+t.width)/r,m=0===s?1:(t.y+t.height)/s,g=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=p,e[1]=g,e[2]=f,e[3]=g,e[4]=p,e[5]=m,e[6]=f,e[7]=m):this._isFlipUVX?(e[0]=p,e[1]=m,e[2]=f,e[3]=m,e[4]=p,e[5]=g,e[6]=f,e[7]=g):this._isFlipUVY?(e[0]=f,e[1]=g,e[2]=p,e[3]=g,e[4]=f,e[5]=m,e[6]=p,e[7]=m):(e[0]=f,e[1]=m,e[2]=p,e[3]=m,e[4]=f,e[5]=g,e[6]=p,e[7]=g);var y=0===r?0:t.x/r,v=0===r?1:(t.x+t.width)/r,S=0===s?1:(t.y+t.height)/s,T=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=v,i[1]=T,i[2]=y,i[3]=T,i[4]=v,i[5]=S,i[6]=y,i[7]=S):this._isFlipUVX?(i[0]=v,i[1]=S,i[2]=y,i[3]=S,i[4]=v,i[5]=T,i[6]=y,i[7]=T):this._isFlipUVY?(i[0]=y,i[1]=T,i[2]=v,i[3]=T,i[4]=y,i[5]=S,i[6]=v,i[7]=S):(i[0]=y,i[1]=S,i[2]=v,i[3]=S,i[4]=y,i[5]=T,i[6]=v,i[7]=T)}this._calculateSlicedUV()},i._setDynamicAtlasFrame=function(t){t&&(this._original={_texture:this._texture,_x:this._rect.x,_y:this._rect.y},this._texture=t.texture,this._rect.x=t.x,this._rect.y=t.y,this._calculateUV())},i._resetDynamicAtlasFrame=function(){this._original&&(this._rect.x=this._original._x,this._rect.y=this._original._y,this._texture=this._original._texture,this._original=null,this._calculateUV())},i._checkPackable=function(){var t=bN;if(t){var e=this._texture;if(e instanceof Zp&&!e.isCompressed){var i=this.width,n=this.height;if(!e.image||i>t.maxFrameSize||n>t.maxFrameSize)this._packable=!1;else{var r=T.HTMLCanvasElement;e.image&&e.image instanceof r&&(this._packable=!0)}}else this._packable=!1}},i._serialize=function(){return null},i._deserialize=function(t){var e=t,i=e.rect;i&&(this._rect=new Un(i.x,i.y,i.width,i.height));var n=e.offset;e.offset&&(this._offset=new Ln(n.x,n.y));var r=e.originalSize;e.originalSize&&(this._originalSize=new Vn(r.width,r.height)),this._rotated=!!e.rotated,this._name=e.name,this._packable=!!e.packable,this._pixelsToUnit=e.pixelsToUnit;var s=e.pivot;s&&(this._pivot=new Ln(s.x,s.y)),this._meshType=e.meshType;var o=e.capInsets;o&&(this._capInsets[0]=o[0],this._capInsets[1]=o[1],this._capInsets[2]=o[2],this._capInsets[3]=o[3]);var a=e.vertices;if(a){this.vertices||(this.vertices={rawPosition:[],positions:[],indexes:a.indexes,uv:a.uv,nuv:a.nuv,minPos:new on(a.minPos.x,a.minPos.y,a.minPos.z),maxPos:new on(a.maxPos.x,a.maxPos.y,a.maxPos.z)}),this.vertices.rawPosition.length=0;for(var h=a.rawPosition,u=0;u<h.length;u+=3)this.vertices.rawPosition.push(new on(h[u],h[u+1],h[u+2]));this._updateMeshVertices()}},i.clone=function(){var t,i,n,r,s=new e,o=this.vertices;return s.vertices=o?{rawPosition:o.rawPosition.slice(0),positions:o.positions.slice(0),indexes:o.indexes.slice(0),uv:o.uv.slice(0),nuv:o.nuv.slice(0),minPos:o.minPos.clone(),maxPos:o.minPos.clone()}:null,(t=s.uv).splice.apply(t,[0,s.uv.length].concat(this.uv)),(i=s.unbiasUV).splice.apply(i,[0,s.unbiasUV.length].concat(this.unbiasUV)),(n=s.uvSliced).splice.apply(n,[0,s.uvSliced.length].concat(this.uvSliced)),s._rect.set(this._rect),s._offset.set(this._offset),s._originalSize.set(this._originalSize),s._rotated=this._rotated,(r=s._capInsets).splice.apply(r,[0,s._capInsets.length].concat(this._capInsets)),s._atlasUuid=this._atlasUuid,s._texture=this._texture,s._isFlipUVX=this._isFlipUVX,s._isFlipUVY=this._isFlipUVY,s._pixelsToUnit=this._pixelsToUnit,s._pivot.set(this._pivot),s._meshType=this._meshType,s},i._refreshTexture=function(t){this._texture=t;var e=this._texture,i={},n=!1;0!==this._rect.width&&0!==this._rect.height&&this.checkRect(e)||(i.rect=new Un(0,0,e.width,e.height),n=!0),(0===this._originalSize.width||0===this._originalSize.height||n)&&(i.originalSize=new Vn(e.width,e.height),n=!0),n&&this.reset(i),this._checkPackable(),this._mesh&&this._updateMesh()},i.onLoaded=function(){this._calcTrimmedBorder()},i.initDefault=function(e){t.prototype.initDefault.call(this,e);var i=new Zp;i.initDefault(),this._refreshTexture(i),this._calculateUV()},i.validate=function(){return this._texture&&this._rect&&0!==this._rect.width&&0!==this._rect.height},i._initVertices=function(){if(this.vertices?(this.vertices.rawPosition.length=0,this.vertices.positions.length=0,this.vertices.indexes.length=0,this.vertices.uv.length=0,this.vertices.nuv.length=0,this.vertices.minPos.set(0,0,0),this.vertices.maxPos.set(0,0,0)):this.vertices={rawPosition:[],positions:[],indexes:[],uv:[],nuv:[],minPos:new on,maxPos:new on},this._meshType===hF.POLYGON);else{var t=this.texture,e=t.width,i=t.height,n=this.rect,r=n.width,s=n.height,o=n.x,a=i-n.y-s,h=r/2,u=s/2,l=0===e?0:o/e,c=0===e?1:(o+r)/e,_=0===i?1:(a+s)/i,d=0===i?0:n.y/i;uF.set(-h,-u,0),this.vertices.rawPosition.push(uF.clone()),this.vertices.uv.push(o),this.vertices.uv.push(a+s),this.vertices.nuv.push(l),this.vertices.nuv.push(d),this.vertices.minPos.set(uF),uF.set(h,-u,0),this.vertices.rawPosition.push(uF.clone()),this.vertices.uv.push(o+r),this.vertices.uv.push(a+s),this.vertices.nuv.push(c),this.vertices.nuv.push(d),uF.set(-h,u,0),this.vertices.rawPosition.push(uF.clone()),this.vertices.uv.push(o),this.vertices.uv.push(a),this.vertices.nuv.push(l),this.vertices.nuv.push(_),uF.set(h,u,0),this.vertices.rawPosition.push(uF.clone()),this.vertices.uv.push(o+r),this.vertices.uv.push(a),this.vertices.nuv.push(c),this.vertices.nuv.push(_),this.vertices.maxPos.set(uF),this.vertices.indexes.push(0),this.vertices.indexes.push(1),this.vertices.indexes.push(2),this.vertices.indexes.push(2),this.vertices.indexes.push(1),this.vertices.indexes.push(3)}this._updateMeshVertices()},i._updateMeshVertices=function(){lF.identity();var t=1/this._pixelsToUnit,e=-(this._pivot.x-.5)*this.rect.width*t,i=-(this._pivot.y-.5)*this.rect.height*t,n=new on(e,i,0);lF.transform(n),n.set(t,t,1),lF.scale(n);for(var r=this.vertices,s=0;s<r.rawPosition.length;s++){var o=r.rawPosition[s];on.transformMat4(n,o,lF),on.toArray(r.positions,n,3*s)}on.transformMat4(this._minPos,r.minPos,lF),on.transformMat4(this._maxPos,r.maxPos,lF)},i._createMesh=function(){this._mesh=iF({primitiveMode:pc.TRIANGLE_LIST,positions:this.vertices.positions,uvs:this.vertices.nuv,indices:this.vertices.indexes,minPos:this._minPos,maxPos:this._maxPos,attributes:[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F)]})},i._updateMesh=function(){this._mesh&&this._mesh.destroy(),this._initVertices(),this._createMesh()},n(e,[{key:"insetTop",get:function(){return this._capInsets[1]},set:function(t){this._capInsets[1]!==t&&(this._capInsets[1]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetBottom",get:function(){return this._capInsets[3]},set:function(t){this._capInsets[3]!==t&&(this._capInsets[3]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetLeft",get:function(){return this._capInsets[0]},set:function(t){this._capInsets[0]!==t&&(this._capInsets[0]=t,this._texture&&this._calculateSlicedUV())}},{key:"insetRight",get:function(){return this._capInsets[2]},set:function(t){this._capInsets[2]!==t&&(this._capInsets[2]=t,this._texture&&this._calculateSlicedUV())}},{key:"rect",get:function(){return this._rect},set:function(t){this._rect.equals(t)||(this._rect.set(t),this._texture&&this._calculateUV(),this._calcTrimmedBorder())}},{key:"originalSize",get:function(){return this._originalSize},set:function(t){this._originalSize.equals(t)||(this._originalSize.set(t),this._texture&&this._calculateUV(),this._calcTrimmedBorder())}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset.set(t),this._calcTrimmedBorder()}},{key:"rotated",get:function(){return this._rotated},set:function(t){this._rotated!==t&&(this._rotated=t,this._texture&&this._calculateUV())}},{key:"texture",get:function(){return this._texture},set:function(t){t?t!==this._texture&&this.reset({texture:t},!0):Y(3122,this.name)}},{key:"atlasUuid",get:function(){return this._atlasUuid},set:function(t){this._atlasUuid=t}},{key:"width",get:function(){return this._texture.width}},{key:"height",get:function(){return this._texture.height}},{key:"_textureSource",set:function(t){globalThis.Build?this._texture=t:t&&(this._refreshTexture(t),this._calculateUV())}},{key:"flipUVX",get:function(){return this._isFlipUVX},set:function(t){this._isFlipUVX=t,this._calculateUV()}},{key:"flipUVY",get:function(){return this._isFlipUVY},set:function(t){this._isFlipUVY=t,this._calculateUV()}},{key:"packable",get:function(){return this._packable},set:function(t){this._packable=t}},{key:"original",get:function(){return this._original}},{key:"pixelsToUnit",get:function(){return this._pixelsToUnit}},{key:"pivot",get:function(){return this._pivot}},{key:"mesh",get:function(){return this._mesh}},{key:"trimmedBorder",get:function(){return this._trimmedBorder}}]),e}(of)).EVENT_UV_UPDATED="uv_updated",sF.MeshType=hF,rF=sF))||rF);v.SpriteFrame=pF;var mF,gF=t("a",qs("cc.SpriteAtlas")((_F=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).spriteFrames=dF&&dF(),e}s(e,t);var i=e.prototype;return i.getTexture=function(){var t=Object.keys(this.spriteFrames);if(t.length>0){var e=this.spriteFrames[t[0]];return e&&e.texture}return null},i.getSpriteFrame=function(t){var e=this.spriteFrames[t];return e?(e.name||(e.name=t),e):null},i.getSpriteFrames=function(){for(var t=[],e=this.spriteFrames,i=0,n=Object.keys(e);i<n.length;i++){var r=n[i];t.push(e[r])}return t},i._serialize=function(){},i._deserialize=function(t,e){var i=t;this._name=i.name;var n=i.spriteFrames;this.spriteFrames=It();for(var r=0;r<n.length;r+=2)e.result.push(this.spriteFrames,n[r],n[r+1],ne(pF))},e}(of),dF=ks(_F.prototype,"spriteFrames",[io],(function(){return It()})),cF=_F))||cF);v.SpriteAtlas=gF;var yF,vF,SF,TF=t("F",qs("cc.Font")(mF=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(of))||mF);v.Font=TF;var AF,bF,EF,CF,wF,xF,RF,IF,BF=t("T",qs("cc.TTFFont")((vF=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._fontFamily=SF&&SF(),e}return s(e,t),e.prototype.initDefault=function(e){this._fontFamily="Arial",t.prototype.initDefault.call(this,e)},n(e,[{key:"_nativeAsset",get:function(){return this._fontFamily},set:function(t){this._fontFamily=t||"Arial"}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,__nativeName__:this._native,ext:hl(this._native),__isNative__:!0}}}]),e}(TF),SF=ks(vF.prototype,"_fontFamily",[io],(function(){return null})),p(vF.prototype,"_nativeAsset",[Ro,wo],Object.getOwnPropertyDescriptor(vF.prototype,"_nativeAsset"),vF.prototype),p(vF.prototype,"_nativeDep",[Ro],Object.getOwnPropertyDescriptor(vF.prototype,"_nativeDep"),vF.prototype),yF=vF))||yF);v.TTFFont=BF;var DF,PF=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.offsetX=0,this.offsetY=0,this.textureID=0,this.valid=!1,this.xAdvance=0},OF=function(){function t(t){this.letterDefinitions={},this.texture=t}var e=t.prototype;return e.addLetterDefinitions=function(t,e){this.letterDefinitions[t]=e},e.cloneLetterDefinition=function(){for(var t={},e=0,i=Object.keys(this.letterDefinitions);e<i.length;e++){var n=i[e],r=new PF;Gt(r,this.letterDefinitions[n]),t[n]=r}return t},e.getTexture=function(){return this.texture},e.getLetter=function(t){return this.letterDefinitions[t]},e.getLetterDefinitionForChar=function(t){var e=t.charCodeAt(0);return this.letterDefinitions.hasOwnProperty(e)?this.letterDefinitions[e]:null},e.clear=function(){this.letterDefinitions={}},t}(),MF=t("B",(AF=qs("cc.BitmapFont"),bF=xo(pF),AF((CF=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).fntDataStr=wF&&wF(),e.spriteFrame=xF&&xF(),e.fontSize=RF&&RF(),e.fntConfig=IF&&IF(),e}return s(e,t),e.prototype.onLoaded=function(){var t=this.spriteFrame;!this.fontDefDictionary&&t&&(this.fontDefDictionary=new OF(t.texture));var e=this.fntConfig;if(e){var i=e.fontDefDictionary;for(var n in i){var r=new PF,s=i[n].rect;r.offsetX=i[n].xOffset,r.offsetY=i[n].yOffset,r.w=s.width,r.h=s.height,r.u=s.x,r.v=s.y,r.textureID=0,r.valid=!0,r.xAdvance=i[n].xAdvance,this.fontDefDictionary.addLetterDefinitions(n,r)}}else k("The fnt config is not exists!")},e}(TF),wF=ks(CF.prototype,"fntDataStr",[io],(function(){return""})),xF=ks(CF.prototype,"spriteFrame",[bF],(function(){return null})),RF=ks(CF.prototype,"fontSize",[io],(function(){return-1})),IF=ks(CF.prototype,"fntConfig",[io],(function(){return null})),EF=CF))||EF));v.BitmapFont=MF;var LF=t("L",qs("cc.LabelAtlas")(DF=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(MF))||DF);v.LabelAtlas=LF;var NF=t("A",.26),FF=t("D",(NF+1)/2-NF);var kF=new re(2);kF.get=function(){return this._get()||{key:"",value:0,prev:null,next:null}};var VF,GF=new(t("J",function(){function t(t){this.count=0,this.limit=0,this.datas={},this.limit=t}var e=t.prototype;return e.moveToHead=function(t){t.next=this.head,t.prev=null,this.head&&(this.head.prev=t),this.head=t,this.tail||(this.tail=t),this.count++,this.datas[t.key]=t},e.put=function(t,e){var i=kF.get();if(i.key=t,i.value=e,this.count>=this.limit){var n=this.tail;delete this.datas[n.key],this.count--,this.tail=n.prev,this.tail.next=null,n.prev=null,n.next=null,kF.put(n)}this.moveToHead(i)},e.remove=function(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.datas[t.key],this.count--},e.get=function(t){var e=this.datas[t];return e?(this.remove(e),this.moveToHead(e),e.value):null},e.clear=function(){this.count=0,this.datas={},this.head=null,this.tail=null},e.has=function(t){return!!this.datas[t]},e.delete=function(t){var e=this.datas[t];this.remove(e)},t}()))(100),UF=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,zF=/^[!,.:;'}\]%\?>、‘“》?。,!]/,HF=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+|\S)$/,WF=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+$/,jF=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]/;function XF(t){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(t)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(t)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(t)}function qF(t){var e=t.charCodeAt(0);return e>=9&&e<=13||32===e||133===e||160===e||5760===e||e>=8192&&e<=8202||8232===e||8233===e||8239===e||8287===e||12288===e}function YF(t,e,i){var n=(i||t.font)+"🎮"+e,r=GF.get(n);if(null!==r)return r;var s=t.measureText(e),o=s&&s.width||0;return GF.put(n,o),o}function KF(t,e,i){var n=e,r=i,s=t[e];if(s>="\udc00"&&s<="\udfff"&&n--,void 0!==i)if(i-1!==e){var o=t[i-1];o>="\ud800"&&o<="\udbff"&&r--}else s>="\ud800"&&s<="\udbff"&&r++;return t.substring(n,r)}function JF(t){return jF.exec(t)}function QF(t){return WF.exec(t)}function ZF(t,e,i,n){var r=[];if(0===t.length||i<0)return r.push(""),r;for(var s=t;e>i&&s.length>1;){for(var o=s.length*(i/e)|0,a=KF(s,o),h=e-n(a),u=a,l=0,c=0;h>i&&c++<100;)o*=i/h,h=e-n(a=KF(s,o|=0));for(c=0;a&&h<=i&&c++<100;){var _=UF.exec(a);u=a,h=e-n(a=KF(s,o+=l=_?_[0].length:1))}0==(o-=l)?(o=1,u=KF(s,1)):1===o&&s[0]>="\ud800"&&s[0]<="\udbff"&&(o=2,u=KF(s,2));var d=KF(s,0,o),f=void 0;zF.test(u||a)&&(0==(o-=(f=HF.exec(d))?f[0].length:0)&&(o=1),u=KF(s,o),d=KF(s,0,o)),jF.test(u)&&(f=WF.exec(d))&&d!==f[0]&&(u=KF(s,o-=f[0].length),d=KF(s,0,o)),(0===r.length||(d=d.trim()).length>0)&&r.push(d),e=n(s=u||a)}return(0===r.length||(s=s.trim()).length>0)&&r.push(s),r}var $F,tk=function(){function t(){this.pool=[]}t.getInstance=function(){return VF||(VF=new t),VF};var e=t.prototype;return e.get=function(){var t=this.pool.pop();if(!t){var e=T.document.createElement("canvas"),i=e.getContext("2d");t={canvas:e,context:i}}return t},e.put=function(t){this.pool.length>=Ce.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(t)},t}(),ek=dn.WHITE.clone(),ik=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.texture=null,this.offsetX=0,this.offsetY=0,this.valid=!1,this.xAdvance=0},nk="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",rk=function(){function t(t,e){this.image=null,this.labelInfo=void 0,this.char=void 0,this.data=null,this.canvas=null,this.context=null,this.width=0,this.height=0,this.offsetY=0,this.hash=void 0,this.char=t,this.labelInfo=e,this.hash=""+t.charCodeAt(0)+e.hash}var e=t.prototype;return e.updateRenderData=function(){this._updateProperties(),this._updateTexture()},e.destroy=function(){this.image=null,tk.getInstance().put(this.data)},e._updateProperties=function(){if(this.data=tk.getInstance().get(),this.canvas=this.data.canvas,this.context=this.data.context,this.context){var t=this.labelInfo.fontScale;this.context.font=this.labelInfo.fontDesc;var e=YF(this.context,this.char,this.labelInfo.fontDesc),i=2*this.labelInfo.margin+2;this.width=parseFloat(e.toFixed(2))*t+i,this.height=(1+NF)*this.labelInfo.fontSize*t+i,this.offsetY=-this.labelInfo.fontSize*NF*t/2}this.canvas.width!==this.width&&(this.canvas.width=this.width),this.canvas.height!==this.height&&(this.canvas.height=this.height),this.image||(this.image=new Rf),this.image.reset(this.canvas)},e._updateTexture=function(){if(this.context&&this.canvas){var t=this.context,e=this.labelInfo,i=this.canvas.width,n=this.canvas.height,r=e.fontScale;t.textAlign="center",t.textBaseline="alphabetic",t.clearRect(0,0,i,n),t.fillStyle=nk,t.fillRect(0,0,i,n),t.font=e.fontDesc.replace(/(\d+)(\.\d+)?(px|em|rem|pt)/g,(function(t,e,i,n){return(+e*r+(+i||0)*r).toString()+n}));var s=e.fontSize*r,o=i/2,a=n/2+s*FF+0*s,h=e.color;if(t.lineJoin="round",t.fillStyle="rgba("+h.r+", "+h.g+", "+h.b+", 1)",e.isOutlined){var u=e.out||ek;t.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", "+u.a/255+")",t.lineWidth=2*e.margin*r,t.strokeText(this.char,o,a)}t.fillText(this.char,o,a)}},t}(),sk=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=af.RGBA8888),this.reset({width:t,height:e,format:i})},i.drawTextureAt=function(t,e,i){var n=this.getGFXTexture();if(t&&n){var r=this._getGFXDevice();if(r){var s=new Gc;s.texOffset.x=e,s.texOffset.y=i,s.texExtent.width=t.width,s.texExtent.height=t.height,r.copyTexImagesToTexture([t.data],n,[s])}else console.warn("Unable to get device")}},e}(Zp),ok=function(){function t(t,e){this._x=0,this._y=0,this._nextY=0,this._width=0,this._height=0,this._halfBleed=0,this._dirty=!1;var i=new sk;i.initWithSize(t,e),this.fontDefDictionary=new OF(i),this._halfBleed=1,this._width=t,this._height=e,fN.on(dN.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}var e=t.prototype;return e.insertLetterTexture=function(t){var e=t.image,i=fN.root.device;if(!e||!this.fontDefDictionary||!i)return null;var n=e.width,r=e.height;if(this._x+n+0>this._width&&(this._x=0,this._y=this._nextY),this._y+r>this._nextY&&(this._nextY=this._y+r+0),this._nextY>this._height)return Y(12100),null;this.fontDefDictionary.texture.drawTextureAt(e,this._x,this._y),this._dirty=!0;var s=new ik;return s.u=this._x+this._halfBleed,s.v=this._y+this._halfBleed,s.texture=this.fontDefDictionary.texture,s.valid=!0,s.w=t.width-2,s.h=t.height-2,s.xAdvance=s.w,s.offsetY=t.offsetY,this._x+=n+0,this.fontDefDictionary.addLetterDefinitions(t.hash,s),s},e.update=function(){this._dirty&&(this._dirty=!1)},e.reset=function(){this._x=0,this._y=0,this._nextY=0,this.fontDefDictionary.clear()},e.destroy=function(){this.reset(),this.fontDefDictionary&&(this.fontDefDictionary.texture.destroy(),this.fontDefDictionary.texture=null)},e.getTexture=function(){return this.fontDefDictionary.getTexture()},e.beforeSceneLoad=function(){this.clearAllCache()},e.clearAllCache=function(){this.destroy();var t=new sk;t.initWithSize(this._width,this._height),this.fontDefDictionary.texture=t},e.getLetter=function(t){return this.fontDefDictionary.letterDefinitions[t]},e.getLetterDefinitionForChar=function(t,e){var i=t.charCodeAt(0)+e.hash,n=this.fontDefDictionary.letterDefinitions[i];if(!n){var r=new rk(t,e);r.updateRenderData(),n=this.insertLetterTexture(r),r.destroy()}return n},n(t,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),t}(),ak={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:dn.WHITE.clone(),isOutlined:!1,out:dn.WHITE.clone(),margin:0,fontScale:1},hk=[new u_(Ic.ATTR_POSITION,Hl.RGB32F)],uk=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_COLOR,Hl.RGBA32F)],lk=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_COLOR,Hl.RGBA32F)],ck=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_COLOR,Hl.RGBA8,!0)],_k=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_COLOR,Hl.RGBA32F),new u_(Ic.ATTR_COLOR2,Hl.RGBA32F)],dk=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_COLOR,Hl.RGBA8,!0),new u_(Ic.ATTR_COLOR2,Hl.RGBA8,!0)];function fk(t){for(var e=0,i=0;i<t.length;i++){var n=t[i];e+=M_[n.format].count}return e}function pk(t){for(var e=0,i=0;i<t.length;i++){var n=t[i];e+=M_[n.format].size}return e}v.internal.vfmtPosUvColor=lk,v.internal.vfmtPosUvTwoColor=_k,v.internal.vfmtPosUvColor4B=ck,v.internal.vfmtPosUvTwoColor4B=dk,t("w",Object.freeze({__proto__:null,vfmt:hk,vfmtPosColor:uk,vfmtPosUvColor:lk,vfmtPosUvColor4B:ck,vfmtPosUvTwoColor:_k,vfmtPosUvTwoColor4B:dk,getComponentPerVertex:fk,getAttributeStride:pk})),function(t){t[t.byteOffset=0]="byteOffset",t[t.vertexOffset=1]="vertexOffset",t[t.indexOffset=2]="indexOffset",t[t.dirty=3]="dirty",t[t.count=4]="count"}($F||($F={}));var mk,gk,yk,vk,Sk,Tk,Ak=t("M",function(){var t=e.prototype;function e(){this._byteOffset=0,this._vertexOffset=0,this._indexOffset=0,this._dirty=!1,this._floatsPerVertex=0,this._vData=null,this._iData=null,this._vertexFormatBytes=0,this._initVDataCount=0,this._initIDataCount=0,this._attributes=null,this._iaPool=[],this._iaInfo=null,this._nextFreeIAHandle=0,this.initSharedBuffer(),this.syncSharedBufferToNative()}return t.initSharedBuffer=function(){},t.syncSharedBufferToNative=function(){},t.initialize=function(t,e,i,n){this._initVDataCount=i,this._initIDataCount=n,this._attributes=e,this.floatsPerVertex=pk(e)>>2,this._initVDataCount,this._floatsPerVertex,tt(9005),this.vData&&this.iData||(this.vData=new Float32Array(this._initVDataCount),this.iData=new Uint16Array(this._initIDataCount)),this._iaPool.push(this.createNewIA(t))},t.reset=function(){this._nextFreeIAHandle=0,this.dirty=!1},t.destroy=function(){this.reset(),this._attributes=null,this._iaInfo=null,this.vData=null,this.iData=null;for(var t=0;t<this._iaPool.length;++t){var e=this._iaPool[t];e.vertexBuffers[0]&&e.vertexBuffers[0].destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.ia.destroy()}this._iaPool.length=0},t.setDirty=function(){this.dirty=!0},t.request=function(){return Y(9002),!1},t.requireFreeIA=function(t){return this._iaPool.length<=this._nextFreeIAHandle&&this._iaPool.push(this.createNewIA(t)),this._iaPool[this._nextFreeIAHandle++].ia},t.recycleIA=function(t){for(var e=this._iaPool,i=0;i<this._nextFreeIAHandle;++i)if(t===e[i].ia){var n=e[i];return e[i]=e[--this._nextFreeIAHandle],void(e[this._nextFreeIAHandle]=n)}},t.checkCapacity=function(t,e){var i=(this.vertexOffset+t)*this._floatsPerVertex,n=this.indexOffset+e;return!(i>this._initVDataCount||n>this._initIDataCount)},t.uploadBuffers=function(){if(0!==this.byteOffset&&this._dirty){var t=xl.__isWebIOS14OrIPadOS14Env,e=t?this._nextFreeIAHandle:1;if(t&&e/this._iaPool.length<.5){for(var i=e/.5,n=this._iaPool.length-1;n>=i;n--){var r=this._iaPool[n];r.vertexBuffers[0]&&r.vertexBuffers[0].destroy(),r.indexBuffer&&r.indexBuffer.destroy(),r.ia.destroy()}this._iaPool.length=i}for(var s=this.byteOffset,o=this.indexOffset,a=0;a<e;++a){var h=this._iaPool[a],u=new Float32Array(this.vData.buffer,0,s>>2),l=new Uint16Array(this.iData.buffer,0,o),c=h.vertexBuffers[0];s>c.size&&c.resize(s),c.update(u),2*o>h.indexBuffer.size&&h.indexBuffer.resize(2*o),h.indexBuffer.update(l)}this.dirty=!1}},t.createNewIA=function(t){var e,i,n;if(xl.__isWebIOS14OrIPadOS14Env||!this._iaPool[0]){var r=this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT,s=Uint16Array.BYTES_PER_ELEMENT,o=t.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,r,r));n=t.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,s,s)),i=[o],this._iaInfo=new c_(this._attributes,i,n),e=t.createInputAssembler(this._iaInfo)}else e=t.createInputAssembler(this._iaInfo),i=this._iaInfo.vertexBuffers,n=this._iaInfo.indexBuffer;return{ia:e,vertexBuffers:i,indexBuffer:n}},n(e,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}},{key:"byteOffset",get:function(){return this._byteOffset},set:function(t){this._byteOffset=t}},{key:"vertexOffset",get:function(){return this._vertexOffset},set:function(t){this._vertexOffset=t}},{key:"indexOffset",get:function(){return this._indexOffset},set:function(t){this._indexOffset=t}},{key:"dirty",get:function(){return this._dirty},set:function(t){this._dirty=t}},{key:"floatsPerVertex",get:function(){return this._floatsPerVertex},set:function(t){this._floatsPerVertex=t}},{key:"vData",get:function(){return this._vData},set:function(t){this._vData=t}},{key:"iData",get:function(){return this._iData},set:function(t){this._iData=t}},{key:"nativeObj",get:function(){return this._nativeObj}},{key:"sharedBuffer",get:function(){return this._sharedBuffer}}]),e}()),bk=function(){function t(t,e){this._device=null,this._attributes=null,this._vertexFormatBytes=void 0,this._floatsPerVertex=void 0,this._buffers=[],this._device=t,this._attributes=e,this._floatsPerVertex=pk(e)>>2,this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT}var e=t.prototype;return e.initialize=function(){},e.reset=function(){},e.request=function(){},e.appendBuffers=function(){},e.uploadBuffers=function(){},e.destroy=function(){this._attributes.length=0},n(t,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}},{key:"floatsPerVertex",get:function(){return this._floatsPerVertex}}]),t}(),Ek=new Bu((function(){return{offset:0,length:0}}),32),Ck=function(){function t(t,e,i,n,r,s){this._ib=void 0,this.vertexAccessor=t,this.bufferId=e,this.meshBuffer=i,this.vertexOffset=n,this.vb=r,this.indexCount=s,this._ib=new Uint16Array(s),t.getMeshBuffer(e)}return t.prototype.setIndexBuffer=function(){},n(t,[{key:"ib",get:function(){return this._ib}}]),t}(),wk=function(t){function e(i,n,r,s){var o;return(o=t.call(this,i,n)||this)._freeLists=[],o._vCount=0,o._iCount=0,o._id=0,o._vCount=r||Math.floor(1024*Ce.BATCHER2D_MEM_INCREMENT/o._vertexFormatBytes),o._iCount=s||o._vCount*e.IB_SCALE,o._id=e.generateID(),o._allocateBuffer(),o}s(e,t);var i=e.prototype;return i.destroy=function(){for(var e=0;e<this._buffers.length;++e){this._buffers[e].destroy();for(var i=this._freeLists[e],n=0;n<i.length;++n)Ek.free(i[n])}this._buffers.length=0,this._freeLists.length=0,t.prototype.destroy.call(this)},i.reset=function(){for(var t=0;t<this._buffers.length;++t){var e=this._buffers[t];e.indexOffset=0,e.reset()}},i.getVertexBuffer=function(t){return this._buffers[t].vData},i.getIndexBuffer=function(t){return this._buffers[t].iData},i.getMeshBuffer=function(t){return this._buffers[t]},i.uploadBuffers=function(){for(var t=0;t<this._buffers.length;++t){var e=this._freeLists[t][0],i=this._buffers[t];(!e||e.length<i.vData.byteLength)&&i.uploadBuffers()}},i.appendIndices=function(t,e){var i=this._buffers[t];if(e.length){var n=i.indexOffset+e.length;if(i.iData.length<n){var r=Math.floor(1.25*n),s=new Uint16Array(r);s.set(i.iData),i.iData=s}i.iData.set(e,i.indexOffset),i.indexOffset+=e.length}},i.allocateChunk=function(t,e){for(var i,n=t*this.vertexFormatBytes,r=null,s=0,o=-1,a=null,h=0;h<this._buffers.length;++h){r=this._buffers[h],i=this._freeLists[h];for(var u=0;u<i.length;++u)if(i[u].length>=n){a=i[u],s=h,o=u;break}if(a)break}if(a||(s=this._allocateBuffer(),(r=this._buffers[s])&&r.checkCapacity(t,e)&&(o=0,a=this._freeLists[s][o])),a){var l=a.offset/this.vertexFormatBytes,c=new Float32Array(r.vData.buffer,a.offset,n>>2).fill(0);return this._allocateChunkFromEntry(s,o,a,n),new Ck(this,s,r,l,c,e)}return J(9004,n),null},i.recycleChunk=function(t){var e=this._freeLists[t.bufferId],i=this._buffers[t.bufferId],n=t.vertexOffset*this.vertexFormatBytes,r=t.vb.byteLength;if(0!==r){for(var s=!1,o=0,a=null,h=e[o];h&&h.offset<n;)a=h,h=e[++o];if(a&&0==n-(a.offset+a.length)&&(a.length+=r,n=a.offset,r=a.length,h&&h.offset-(n+r)==0&&(a.length+=h.length,e.splice(o,1),Ek.free(h),h=null),s=!0),!s&&h){if(0==h.offset-(n+r))h.offset=n,h.length+=r;else{var u=Ek.alloc();u.offset=n,u.length=r,e.splice(o,0,u)}s=!0}if(s)n+r===i.byteOffset&&(i.byteOffset=n);else{var l=Ek.alloc();l.offset=n,l.length=r,e.push(l)}}},i._allocateChunkFromEntry=function(t,e,i,n){var r=i.length-n,s=i.offset+n,o=this._buffers[t];o.byteOffset<s&&(o.byteOffset=s),$(r>=0,9004,t,i.offset,i.length),0===r?(this._freeLists[t].splice(e,1),Ek.free(i)):(i.offset+=n,i.length=r)},i._allocateBuffer=function(){$(this._buffers.length===this._freeLists.length,9003);var t=new Ak,e=this._vCount*this._floatsPerVertex;t.initialize(this._device,this._attributes,e,this._iCount),this._buffers.push(t);var i=Ek.alloc();i.offset=0,i.length=t.vData.byteLength;var n=[i];return this._freeLists.push(n),fN.root.batcher2D.syncMeshBuffersToNative(this.id,this._buffers),this._buffers.length-1},e.generateID=function(){return e.ID_COUNT++},n(e,[{key:"id",get:function(){return this._id}}]),e}(bk);wk.IB_SCALE=4,wk.ID_COUNT=0,function(t){t[t.DrawInfoType=0]="DrawInfoType",t[t.VertDirty=1]="VertDirty",t[t.IsMeshBuffer=2]="IsMeshBuffer",t[t.Stride=3]="Stride",t[t.Count=4]="Count"}(mk||(mk={})),function(t){t[t.BufferID=0]="BufferID",t[t.AccessorID=1]="AccessorID",t[t.Count=2]="Count"}(gk||(gk={})),function(t){t[t.VertexOffset=0]="VertexOffset",t[t.IndexOffset=1]="IndexOffset",t[t.VBCount=2]="VBCount",t[t.IBCount=3]="IBCount",t[t.DataHash=4]="DataHash",t[t.Count=5]="Count"}(yk||(yk={})),function(t){t[t.COMP=0]="COMP",t[t.MODEL=1]="MODEL",t[t.MIDDLEWARE=2]="MIDDLEWARE",t[t.SUB_NODE=3]="SUB_NODE"}(vk||(vk={})),function(){function t(t){this._accId=-1,this._bufferId=-1,this._vertexOffset=0,this._indexOffset=0,this._vb=null,this._ib=null,this._vData=null,this._iData=null,this._vertDirty=!1,this._vbCount=0,this._ibCount=0,this._dataHash=0,this._isMeshBuffer=!1,this._material=null,this._texture=null,this._sampler=null,this._stride=0,this._useLocal=!1,this._model=null,this._drawInfoType=vk.COMP,this._subNode=null,this._uint8SharedBuffer=void 0,this._uint16SharedBuffer=void 0,this._uint32SharedBuffer=void 0,this.init(t);var e=this._nativeObj.getAttrSharedBufferForJS(),i=0;this._uint8SharedBuffer=new Uint8Array(e,i,mk.Count),i+=mk.Count*Uint8Array.BYTES_PER_ELEMENT,this._uint16SharedBuffer=new Uint16Array(e,i,gk.Count),i+=gk.Count*Uint16Array.BYTES_PER_ELEMENT,this._uint32SharedBuffer=new Uint32Array(e,i,yk.Count)}var e=t.prototype;e.init=function(){},e.clear=function(){this._bufferId=0,this._vertexOffset=0,this._indexOffset=0,this._vertDirty=!1},e.setAccId=function(t){this._accId=t},e.setBufferId=function(t){this._bufferId=t},e.setAccAndBuffer=function(t,e){this._bufferId=e,this._accId=t},e.setVertexOffset=function(t){this._vertexOffset=t},e.setIndexOffset=function(t){this._indexOffset=t},e.setVB=function(){},e.setIB=function(){},e.setVData=function(){},e.setIData=function(){},e.setVBCount=function(t){this._vbCount=t},e.setIBCount=function(){},e.setVertDirty=function(t){this._vertDirty=t},e.setDataHash=function(t){this._dataHash=t},e.setIsMeshBuffer=function(t){this._isMeshBuffer=t},e.setMaterial=function(t){this._material=t},e.setTexture=function(t){this._texture=t},e.setSampler=function(t){this._sampler=t},e.setModel=function(){},e.setDrawInfoType=function(t){this._drawInfoType=t},e.setSubNode=function(t){this._subNode=t},e.setStride=function(t){this._stride=t},e.initRender2dBuffer=function(){},e.fillRender2dBuffer=function(){},n(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"render2dBuffer",get:function(){return this._render2dBuffer}}])}(),function(t){t[t.DISABLED=0]="DISABLED",t[t.CLEAR=1]="CLEAR",t[t.ENTER_LEVEL=2]="ENTER_LEVEL",t[t.ENABLED=3]="ENABLED",t[t.EXIT_LEVEL=4]="EXIT_LEVEL",t[t.CLEAR_INVERTED=5]="CLEAR_INVERTED",t[t.ENTER_LEVEL_INVERTED=6]="ENTER_LEVEL_INVERTED"}(Sk||(Sk={})),function(t){t[t.stencilTest=0]="stencilTest",t[t.func=1]="func",t[t.stencilMask=2]="stencilMask",t[t.writeMask=3]="writeMask",t[t.failOp=4]="failOp",t[t.zFailOp=5]="zFailOp",t[t.passOp=6]="passOp",t[t.ref=7]="ref",t[t.count=8]="count"}(Tk||(Tk={}));var xk,Rk,Ik,Bk,Dk,Pk=t("S",function(){function t(){this._maskStack=[],this._stencilPattern={stencilTest:!0,func:rc.ALWAYS,stencilMask:65535,writeMask:65535,failOp:sc.KEEP,zFailOp:sc.KEEP,passOp:sc.KEEP,ref:1},this._stage=Sk.DISABLED,this.stencilStateMap=new Map,this.stencilStateMapWithDepth=new Map}var e=t.prototype;return e.pushMask=function(t){this._maskStack.push(t)},e.clear=function(t){return t.stencilStage!==Sk.ENTER_LEVEL?Sk.CLEAR_INVERTED:Sk.CLEAR},e.enableMask=function(){this.stage=Sk.ENABLED},e.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=Sk.DISABLED:this.stage=Sk.ENABLED)},e.getWriteMask=function(){return 1<<this._maskStack.length-1},e.getExitWriteMask=function(){return 1<<this._maskStack.length},e.getStencilRef=function(){for(var t=0,e=0;e<this._maskStack.length;++e)t+=1<<e;return t},e.getMaskStackSize=function(){return this._maskStack.length},e.reset=function(){this._maskStack.length=0,this.stage=Sk.DISABLED},e.destroy=function(){this.stencilStateMap.forEach((function(t){t.destroy()})),this.stencilStateMap.clear()},e.getStencilStage=function(t,e){var i=0,n=!1,r=!1,s=rc.LESS,o=this.stencilStateMap;if(e&&e.passes[0]){var a=e.passes[0].depthStencilState,h=0,u=0;a.depthTest&&(h=1),a.depthWrite&&(u=1),i=h|u<<1|a.depthFunc<<2|t<<6|this._maskStack.length<<9,n=a.depthTest,r=a.depthWrite,s=a.depthFunc,o=this.stencilStateMapWithDepth}else i=t<<16|this._maskStack.length;if(o&&o.has(i))return o.get(i);this.setStateFromStage(t);var l=new rd(n,r,s,this._stencilPattern.stencilTest,this._stencilPattern.func,this._stencilPattern.stencilMask,this._stencilPattern.writeMask,this._stencilPattern.failOp,this._stencilPattern.zFailOp,this._stencilPattern.passOp,this._stencilPattern.ref,this._stencilPattern.stencilTest,this._stencilPattern.func,this._stencilPattern.stencilMask,this._stencilPattern.writeMask,this._stencilPattern.failOp,this._stencilPattern.zFailOp,this._stencilPattern.passOp,this._stencilPattern.ref);return o.set(i,l),l},e.getStencilHash=function(t){return t<<8|this._maskStack.length},e.setStateFromStage=function(t){var e=this._stencilPattern;t===Sk.DISABLED?(e.stencilTest=!1,e.func=rc.ALWAYS,e.failOp=sc.KEEP,e.stencilMask=e.writeMask=65535,e.ref=1):(e.stencilTest=!0,t===Sk.ENABLED?(e.func=rc.EQUAL,e.failOp=sc.KEEP,e.stencilMask=e.ref=this.getStencilRef(),e.writeMask=this.getWriteMask()):t===Sk.CLEAR?(e.func=rc.NEVER,e.failOp=sc.ZERO,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()):t===Sk.CLEAR_INVERTED||t===Sk.ENTER_LEVEL?(e.func=rc.NEVER,e.failOp=sc.REPLACE,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()):t===Sk.ENTER_LEVEL_INVERTED&&(e.func=rc.NEVER,e.failOp=sc.ZERO,e.writeMask=e.stencilMask=e.ref=this.getWriteMask()))},n(t,[{key:"stage",get:function(){return this._stage},set:function(t){this._stage=t}},{key:"pattern",get:function(){return this._stencilPattern}}]),t}());Pk.sharedManager=null,Pk.sharedManager=new Pk,function(t){t[t.STATIC=0]="STATIC",t[t.DYNAMIC=1]="DYNAMIC",t[t.CROSSED=2]="CROSSED"}(xk||(xk={})),function(t){t[t.localOpacity=0]="localOpacity",t[t.count=1]="count"}(Rk||(Rk={})),function(t){t[t.colorR=0]="colorR",t[t.colorG=1]="colorG",t[t.colorB=2]="colorB",t[t.colorA=3]="colorA",t[t.maskMode=4]="maskMode",t[t.count=5]="count"}(Ik||(Ik={})),function(t){t[t.colorDirty=0]="colorDirty",t[t.enabled=1]="enabled",t[t.useLocal=2]="useLocal",t[t.count=3]="count"}(Bk||(Bk={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.MASK_INVERTED=2]="MASK_INVERTED",t[t.MASK_NODE=3]="MASK_NODE",t[t.MASK_NODE_INVERTED=4]="MASK_NODE_INVERTED"}(Dk||(Dk={}));var Ok,Mk,Lk,Nk,Fk,kk,Vk,Gk,Uk,zk,Hk,Wk=function(){function t(){this._renderEntityType=xk.STATIC,this._dynamicDrawInfoArr=[],this._node=null,this._renderTransform=null,this._stencilStage=Sk.DISABLED,this._useLocal=!1,this._maskMode=Dk.NONE,this._color=dn.WHITE,this._localOpacity=255,this._colorDirty=!0,this._enabled=!1}var e=t.prototype;return e.addDynamicRenderDrawInfo=function(){},e.removeDynamicRenderDrawInfo=function(){},e.clearDynamicRenderDrawInfos=function(){},e.clearStaticRenderDrawInfos=function(){},e.setDynamicRenderDrawInfo=function(){},e.setMaskMode=function(t){this._maskMode=t},e.getStaticRenderDrawInfo=function(){return null},e.setNode=function(t){this._node=t},e.setRenderTransform=function(t){this._renderTransform=t},e.setStencilStage=function(t){this._stencilStage=t},e.setUseLocal=function(t){this._useLocal=t},e.initSharedBuffer=function(){},n(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"renderDrawInfoArr",get:function(){return this._dynamicDrawInfoArr}},{key:"renderEntityType",get:function(){return this._renderEntityType}},{key:"color",get:function(){return this._color},set:function(t){this._color=t}},{key:"localOpacity",get:function(){return this._localOpacity},set:function(t){this._localOpacity=t}},{key:"colorDirty",get:function(){return this._colorDirty},set:function(t){this._colorDirty=t}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}}]),t}(),jk=pk(lk)>>2,Xk=t("t",function(){function t(t){void 0===t&&(t=lk),this.chunk=null,this._renderDrawInfo=null,this._material=null,this._dataHash=0,this._isMeshBuffer=!1,this._vc=0,this._ic=0,this._floatStride=0,this._vertexFormat=lk,this._drawInfoType=vk.COMP,this._multiOwner=!1,this._batcher=null,this._floatStride=t===lk?jk:pk(t)>>2,this._vertexFormat=t}var e=t.prototype;return e.isValid=function(){return this._ic>0&&this.chunk.vertexAccessor},e.initRenderDrawInfo=function(t,e){void 0===e&&(e=vk.COMP)},e.removeRenderDrawInfo=function(){},e.setRenderDrawInfoAttributes=function(){},n(t,[{key:"vertexCount",get:function(){return this._vc}},{key:"indexCount",get:function(){return this._ic}},{key:"stride",get:function(){return this._floatStride<<2}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vertexFormat",get:function(){return this._vertexFormat}},{key:"drawInfoType",get:function(){return this._drawInfoType},set:function(t){this._drawInfoType=t,this._renderDrawInfo&&this._renderDrawInfo.setDrawInfoType(t)}},{key:"renderDrawInfo",get:function(){return this._renderDrawInfo}},{key:"material",get:function(){return this._material},set:function(t){this._material=t,this._renderDrawInfo&&this._renderDrawInfo.setMaterial(t)}},{key:"dataHash",get:function(){return this._dataHash},set:function(t){this._dataHash=t,this._renderDrawInfo&&this._renderDrawInfo.setDataHash(t)}},{key:"multiOwner",get:function(){return this._multiOwner},set:function(t){this._multiOwner=t}},{key:"batcher",get:function(){return this._batcher||(this._batcher=fN.root.batcher2D),this._batcher}}]),t}()),qk=t("u",function(t){function e(e,i){var n;return void 0===e&&(e=lk),(n=t.call(this,e)||this)._vertDirty=!0,n._textureHash=0,n.indices=null,n.layer=0,n.nodeDirty=!0,n.passDirty=!0,n.textureDirty=!0,n.hashDirty=!0,n._data=[],n._frame=null,n._accessor=null,n.vertexRow=1,n.vertexCol=1,i||(i=n.batcher.switchBufferAccessor(n._vertexFormat)),n._accessor=i,n}s(e,t),e.add=function(t,i){void 0===t&&(t=lk);var n=new e(t,i);return i||(i=fN.root.batcher2D.switchBufferAccessor(n._vertexFormat)),n._accessor=i,n},e.remove=function(t){t.clear(),t._accessor=null};var i=e.prototype;return i.resize=function(t,e){t===this._vc&&e===this._ic&&this.chunk||(this._vc=t,this._ic=e,this.chunk&&(this._accessor.recycleChunk(this.chunk),this.chunk=null),this.chunk=this._accessor.allocateChunk(t,e),this.updateHash())},i.setRenderDrawInfoAttributes=function(){},i.fillDrawInfoAttributes=function(){},i.syncRender2dBuffer=function(){},i.resizeAndCopy=function(t,e){if(t!==this._vc||e!==this._ic||!this.chunk){this._vc=t,this._ic=e;var i=this.chunk;this.chunk=this._accessor.allocateChunk(t,e),i&&(this.chunk.vb.set(i.vb),this._accessor.recycleChunk(i)),this.updateHash()}},i.getMeshBuffer=function(){return this.chunk&&this._accessor?this._accessor.getMeshBuffer(this.chunk.bufferId):null},i.updateNode=function(t){this.layer=t.node.layer,this.nodeDirty=!1,this.hashDirty=!0},i.updatePass=function(t){this.material=t.getRenderMaterial(0),this.passDirty=!1,this.hashDirty=!0},i.updateTexture=function(t){this.frame=t,this.textureHash=t.getHash(),this.textureDirty=!1,this.hashDirty=!0},i.updateHash=function(){var t=""+(this.chunk?this.chunk.bufferId:-1)+this.layer+" "+this.textureHash;this.dataHash=Dl(t,666),this.hashDirty=!1},i.updateRenderData=function(t,e){if(this.passDirty&&(this.material=t.getRenderMaterial(0),this.passDirty=!1,this.hashDirty=!0,this._renderDrawInfo&&this._renderDrawInfo.setMaterial(this.material)),this.nodeDirty){var i=t.node.scene?t._getRenderScene():null;this.layer=t.node.layer,null!==i&&(this.nodeDirty=!1),this.hashDirty=!0}this.textureDirty&&(this.frame=e,this.textureHash=e.getHash(),this.textureDirty=!1,this.hashDirty=!0,this._renderDrawInfo&&(this._renderDrawInfo.setTexture(this.frame?this.frame.getGFXTexture():null),this._renderDrawInfo.setSampler(this.frame?this.frame.getGFXSampler():null))),this.hashDirty&&(this.updateHash(),this._renderDrawInfo&&this._renderDrawInfo.setDataHash(this.dataHash))},i.clear=function(){this.resize(0,0),this._data.length=0,this.indices=null,this.vertDirty=!0,this.material=null,this.nodeDirty=!0,this.passDirty=!0,this.textureDirty=!0,this.hashDirty=!0,this.layer=0,this.frame=null,this.textureHash=0,this.dataHash=0},e.createStaticVBAccessor=function(t,e,i){var n=fN.root.device;return new wk(n,t,e,i)},n(e,[{key:"dataLength",get:function(){return this._data.length},set:function(t){var e=this._data;if(e.length!==t){for(var i=e.length;i<t;i++)e.push({x:0,y:0,z:0,u:0,v:0,color:dn.WHITE.clone()});e.length=t}this.syncRender2dBuffer()}},{key:"data",get:function(){return this._data}},{key:"vertDirty",get:function(){return this._vertDirty},set:function(t){this._vertDirty=t,this._renderDrawInfo&&t&&this._renderDrawInfo.setVertDirty(t)}},{key:"textureHash",get:function(){return this._textureHash},set:function(t){this._textureHash=t}},{key:"frame",get:function(){return this._frame},set:function(t){this._frame=t,this._renderDrawInfo&&(this._frame?(this._renderDrawInfo.setTexture(this._frame.getGFXTexture()),this._renderDrawInfo.setSampler(this._frame.getGFXSampler())):(this._renderDrawInfo.setTexture(null),this._renderDrawInfo.setSampler(null)))}},{key:"accessor",get:function(){return this._accessor}}]),e}(Xk)),Yk=t("v",function(t){function e(e){var i;return void 0===e&&(e=lk),(i=t.call(this,e)||this)._isMeshBuffer=!0,i.vData=void 0,i.iData=void 0,i.vertexStart=0,i.vertexRange=0,i.indexStart=0,i.indexRange=0,i.lastFilledIndex=0,i.lastFilledVertex=0,i.frame=void 0,i._byteLength=0,i._vertexBuffers=[],i._indexBuffer=null,i._iaPool=null,i._iaInfo=null,i.vData=new Float32Array(256*i.stride),i.iData=new Uint16Array(1536),i}s(e,t),e.add=function(t){void 0===t&&(t=lk);var i=new e;return i._floatStride=t===lk?jk:pk(t)>>2,i._vertexFormat=t,i},e.remove=function(t){t.clear()};var i=e.prototype;return i.request=function(t,e){var i=this._byteLength+t*this.stride;return!!this.reserve(t,e)&&(this._vc+=t,this._ic+=e,this._byteLength=i,this.vertexRange=this._vc,this.indexRange=this._ic,!0)},i.reserve=function(t,e){var i=this._byteLength+t*this.stride,n=this.indexCount+e;if(t+this.vertexCount>65535)return!1;var r=this.vData.byteLength,s=this.iData.length,o=this.vData.length,a=this.iData.length;if(i>r||n>s){for(;r<i||s<n;)r=4*(o*=2),s=a*=2;this._reallocBuffer(o,a)}return!0},i.resize=function(t,e){var i=t*this.stride;t>=0&&e>=0&&i<=this.vData.byteLength&&this.iData.length,this._vc=t,this._ic=e,this._byteLength=i,this.updateRange(0,t,0,e)},i.updateRange=function(t,e,i,n){e>=0&&n>=0&&e<=this._vc&&this._ic,this.vertexStart=t,this.indexStart=i,this.vertexRange=e,this.indexRange=n},i.requestIA=function(t){this._initIAInfo(t);var e=this._iaPool.add();return e.firstIndex=this.indexStart,e.indexCount=this.indexRange,e},i.uploadBuffers=function(){if(0!==this._byteLength&&this._vertexBuffers[0]&&this._indexBuffer){var t=this._ic,e=new Float32Array(this.vData.buffer,0,this._byteLength>>2),i=new Uint16Array(this.iData.buffer,0,t),n=this._vertexBuffers[0];this._byteLength>n.size&&n.resize(this._byteLength),n.update(e);var r=t<<1;r>this._indexBuffer.size&&this._indexBuffer.resize(r),this._indexBuffer.update(i)}},i.freeIAPool=function(){this._iaPool&&this._iaPool.reset()},i.reset=function(){this._vc=0,this._ic=0,this._byteLength=0,this.vertexStart=0,this.vertexRange=0,this.indexStart=0,this.indexRange=0,this.lastFilledIndex=0,this.lastFilledVertex=0,this.material=null,this.freeIAPool()},i.clear=function(){this.reset(),this._iaPool&&this._iaPool.destroy(),this._vertexBuffers[0]&&(this._vertexBuffers[0].destroy(),this._vertexBuffers=[]),this._iaInfo=null,this.vData=new Float32Array(256*this.stride),this.iData=new Uint16Array(1536)},i._initIAInfo=function(t){var e=this;if(!this._iaInfo){var i=this.stride,n=this._vertexBuffers;n.length||n.push(t.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,i,i)));var r=Uint16Array.BYTES_PER_ELEMENT;this._indexBuffer||(this._indexBuffer=t.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,r,r))),this._iaInfo=new c_(this._vertexFormat,n,this._indexBuffer),this._iaPool=new Du((function(){return t.createInputAssembler(e._iaInfo)}),1,(function(t){t.destroy()}))}},i._reallocBuffer=function(t,e){var i=this.vData;this.vData=new Float32Array(t),i&&this.vData.set(i,0);var n=this.iData;this.iData=new Uint16Array(e),n&&this.iData.set(n,0)},i.setRenderDrawInfoAttributes=function(){},i.particleInitRenderDrawInfo=function(){},n(e,[{key:"formatByte",get:function(){return this.stride},set:function(){}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vDataOffset",get:function(){return this._byteLength>>>2}}]),e}(Xk)),Kk=new Ln,Jk=new Ln,Qk=new on,Zk=new In,$k=new In,tV=new In,eV=new In(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),iV=new Un,nV=t("e",qs("cc.UITransform")(Ok=Ks(110)(Ok=Js(((Fk=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._priority=0,e._contentSize=Lk&&Lk(),e._anchorPoint=Nk&&Nk(),e}s(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiTransformComp=this},i.onLoad=function(){this.node.parent&&e.insertChangeMap(this.node.parent)},i.onEnable=function(){this.node.on(om.PARENT_CHANGED,this._parentChanged,this),this._markRenderDataDirty()},i.onDisable=function(){this.node.off(om.PARENT_CHANGED,this._parentChanged,this)},i.onDestroy=function(){this.node._uiProps.uiTransformComp=null},i.setContentSize=function(t,e){var i,n,r=this._contentSize;if(void 0===e){if(wi((t=t).width,r.width,Ei)&&wi(t.height,r.height,Ei))return;i=t.width,n=t.height}else{if(wi(t=t,r.width,Ei)&&wi(e,r.height,Ei))return;i=t,n=e}r.width=i,r.height=n,this.node.emit(om.SIZE_CHANGED),this._markRenderDataDirty()},i.setAnchorPoint=function(t,e){var i=this._anchorPoint;if(void 0===e){if((t=t).x===i.x&&t.y===i.y)return;i.x=t.x,i.y=t.y}else{if(t===i.x&&e===i.y)return;i.x=t,i.y=e}this.node.emit(om.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty()},i.isHit=function(t){for(var e=this._contentSize.width,i=this._contentSize.height,n=Kk,r=Jk,s=this._getRenderScene().cameras,o=0;o<s.length;o++){var a=s[o];if(a.visibility&this.node.layer){a.node.getWorldRT(Zk);var h=Zk.m12,u=Zk.m13,l=Rl.center;if(Zk.m12=l.x-(Zk.m00*h+Zk.m04*u),Zk.m13=l.y-(Zk.m01*h+Zk.m05*u),In.invert(Zk,Zk),Ln.transformMat4(n,t,Zk),this.node.getWorldMatrix(tV),In.invert(Zk,tV),!In.strictEquals(Zk,eV)){Ln.transformMat4(r,n,Zk),r.x+=this._anchorPoint.x*e,r.y+=this._anchorPoint.y*i;var c=!1;if(r.x>=0&&r.y>=0&&r.x<=e&&r.y<=i&&(c=this._maskTest(n)),c)return!0}}}return!1},i.hitTest=function(t,e){void 0===e&&(e=0);for(var i=this._contentSize.width,n=this._contentSize.height,r=Qk,s=Kk,o=Jk,a=this._getRenderScene().cameras,h=0;h<a.length;h++){var u=a[h];if(u.visibility&this.node.layer&&(!u.window||u.window.swapchain)&&u.systemWindowId===e&&(on.set(r,t.x,t.y,0),u.screenToWorld(r,r),Ln.set(s,r.x,r.y),this.node.getWorldMatrix(tV),In.invert(Zk,tV),!In.strictEquals(Zk,eV))){Ln.transformMat4(o,s,Zk),o.x+=this._anchorPoint.x*i,o.y+=this._anchorPoint.y*n;var l=!1;if(o.x>=0&&o.y>=0&&o.x<=i&&o.y<=n&&(l=this._maskTest(s)),l)return!0}}return!1},i._maskTest=function(t){var e,i,n=null===(e=this.node)||void 0===e||null===(i=e.eventProcessor)||void 0===i?void 0:i.maskList;if(n)for(var r=this.node,s=n.length,o=0,a=0;r&&a<s;++o,r=r.parent){var h=n[a];if(o===h.index){if(r!==h.comp.node){n.length=a;break}var u=h.comp;if(u&&u._enabled&&!u.isHit(t))return!1;a++}else if(o>h.index){n.length=a;break}}return!0},i.convertToNodeSpaceAR=function(t,e){return this.node.getWorldMatrix(tV),In.invert(Zk,tV),e||(e=new on),on.transformMat4(e,t,Zk)},i.convertToWorldSpaceAR=function(t,e){return this.node.getWorldMatrix(tV),e||(e=new on),on.transformMat4(e,t,tV)},i.getBoundingBox=function(){var t=new Un;return this._selfBoundingBox(t),In.fromSRT($k,this.node.rotation,this.node.position,this.node.scale),t.transformMat4($k),t},i.getBoundingBoxToWorld=function(){for(var t=new Un,i=this.node.children,n=0;n<i.length;++n){var r=i[n];if(r&&r.active){var s=r.getComponent(e);s&&s.contentSize.width&&s.contentSize.height&&(s._selfBoundingBox(iV),iV.transformMat4(r.worldMatrix),0===t.width?t.set(iV):Un.union(t,t,iV))}}return this._contentSize.width&&this._contentSize.height&&(this._selfBoundingBox(iV),iV.transformMat4(this.node.worldMatrix),0===t.width?t.set(iV):Un.union(t,t,iV)),t},i.getBoundingBoxTo=function(t){var i=new Un,n=this.node.children;In.invert(Zk,t);for(var r=0;r<n.length;++r){var s=n[r];if(s&&s.active){var o=s.getComponent(e);o&&o.contentSize.width&&o.contentSize.height&&(o._selfBoundingBox(iV),In.multiply($k,s.worldMatrix,Zk),iV.transformMat4($k),0===i.width?i.set(iV):Un.union(i,i,iV))}}return this._contentSize.width&&this._contentSize.height&&(this._selfBoundingBox(iV),In.multiply($k,this.node.worldMatrix,Zk),iV.transformMat4($k),0===i.width?i.set(iV):Un.union(i,i,iV)),i},i.getComputeAABB=function(t){var e=this._contentSize.width,i=this._contentSize.height;iV.set(-this._anchorPoint.x*e,-this._anchorPoint.y*i,e,i),iV.transformMat4(this.node.worldMatrix);var n=iV.x+.5*iV.width,r=iV.y+.5*iV.height,s=this.node.worldPosition.z,o=iV.width/2,a=iV.height/2;return null!=t?(Ss.set(t,n,r,s,o,a,.001),t):new Ss(n,r,s,o,a,.001)},i._selfBoundingBox=function(t){var e=this._contentSize.width,i=this._contentSize.height;return t.set(-this._anchorPoint.x*e,-this._anchorPoint.y*i,e,i),t},i._parentChanged=function(){this.node.getComponent("cc.RenderRoot2D")||this.node.parent&&e.insertChangeMap(this.node.parent)},i._markRenderDataDirty=function(){var t=this.node._uiProps.uiComp;t&&t.markForUpdateRenderData()},e.insertChangeMap=function(t){var i=t.uuid;e.priorityChangeNodeMap.has(i)||e.priorityChangeNodeMap.set(i,t)},e._sortChildrenSibling=function(t){var e=t.children;e&&e.sort((function(t,e){var i=t._uiProps.uiTransformComp,n=e._uiProps.uiTransformComp,r=(i?i._priority:0)-(n?n._priority:0);return 0===r?t.getSiblingIndex()-e.getSiblingIndex():r}))},e._sortSiblings=function(){e.priorityChangeNodeMap.forEach((function(t){e._sortChildrenSibling(t),t._updateSiblingIndex(),t.emit("childrenSiblingOrderChanged")})),e.priorityChangeNodeMap.clear()},e._cleanChangeMap=function(){e.priorityChangeNodeMap.clear()},n(e,[{key:"contentSize",get:function(){return this._contentSize},set:function(t){this._contentSize.equals(t)||(this._contentSize.set(t),this.node.emit(om.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"width",get:function(){return this._contentSize.width},set:function(t){this._contentSize.width!==t&&(this._contentSize.width=t,this.node.emit(om.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"height",get:function(){return this._contentSize.height},set:function(t){this.contentSize.height!==t&&(this._contentSize.height=t,this.node.emit(om.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"anchorPoint",get:function(){return this._anchorPoint},set:function(t){this._anchorPoint.equals(t)||(this._anchorPoint.set(t),this.node.emit(om.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"anchorX",get:function(){return this._anchorPoint.x},set:function(t){this._anchorPoint.x!==t&&(this._anchorPoint.x=t,this.node.emit(om.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"anchorY",get:function(){return this._anchorPoint.y},set:function(t){this._anchorPoint.y!==t&&(this._anchorPoint.y=t,this.node.emit(om.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority!==t&&(this.node.getComponent("cc.RenderRoot2D")?Y(6706):(this._priority=t,this.node.parent&&e.insertChangeMap(this.node.parent)))}},{key:"visibility",get:function(){var t=fN.root.batcher2D.getFirstRenderCamera(this.node);return t?t.visibility:0}},{key:"cameraPriority",get:function(){var t=fN.root.batcher2D.getFirstRenderCamera(this.node);return t?t.priority:0}}]),e}(rp)).EventType=om,Fk.priorityChangeNodeMap=new Map,Lk=ks((Mk=Fk).prototype,"_contentSize",[io],(function(){return new Vn(100,100)})),Nk=ks(Mk.prototype,"_anchorPoint",[io],(function(){return new Ln(.5,.5)})),Ok=Mk))||Ok)||Ok)||Ok);fN.on(dN.EVENT_AFTER_UPDATE,nV._sortSiblings),fN.on(dN.EVENT_BEFORE_SCENE_LAUNCH,nV._cleanChangeMap);var rV,sV,oV,aV,hV,uV,lV,cV,_V,dV,fV,pV,mV,gV={parent:null,owner:null,subModelIdx:0},yV=Js,vV=xo,SV=t("d_",(kk=qs("cc.Renderer"),Vk=vV(xT),Gk=vV([xT]),kk(Uk=yV((p((zk=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._materials=Hk&&Hk(),e._materialInstances=[],e}s(e,t);var i=e.prototype;return i.getMaterial=function(t){return this.getSharedMaterial(t)},i.setMaterial=function(t,e){this.setSharedMaterial(t,e)},i.getSharedMaterial=function(t){return t<0||t>=this._materials.length?null:this._materials[t]},i.setSharedMaterial=function(t,e){t&&t instanceof NT&&J(12012),this._materials[e]=t;var i=this._materialInstances[e];i&&(i.destroy(),this._materialInstances[e]=null),this._onMaterialModified(e,this._materials[e])},i.getMaterialInstance=function(t){if(!this._materials[t])return null;if(!this._materialInstances[t]){gV.parent=this._materials[t],gV.owner=this,gV.subModelIdx=t;var e=new NT(gV);gV.parent=null,gV.owner=null,gV.subModelIdx=0,this.setMaterialInstance(e,t)}return this._materialInstances[t]},i.setMaterialInstance=function(t,e){if("number"==typeof t){Y(12007);var i=t;t=e,e=i}var n=this._materialInstances[e];t&&t.parent?t!==n&&(this._materialInstances[e]=t,this._onMaterialModified(e,t)):(t!==this._materials[e]||n)&&this.setSharedMaterial(t,e)},i.getRenderMaterial=function(t){return this._materialInstances[t]||this._materials[t]},i._onMaterialModified=function(){},i._onRebuildPSO=function(){},i._clearMaterials=function(){},n(e,[{key:"sharedMaterial",get:function(){return this.getSharedMaterial(0)}},{key:"sharedMaterials",get:function(){return this._materials},set:function(t){for(var e=0;e<t.length;e++)t[e]!==this._materials[e]&&this.setSharedMaterial(t[e],e);if(t.length<this._materials.length){for(var i=t.length;i<this._materials.length;i++)this.setSharedMaterial(null,i);this._materials.splice(t.length)}}},{key:"material",get:function(){return this.getMaterialInstance(0)},set:function(t){(1!==this._materials.length||this._materialInstances[0]||this._materials[0]!==t)&&this.setMaterialInstance(t,0)}},{key:"materials",get:function(){for(var t=0;t<this._materials.length;t++)this._materialInstances[t]=this.getMaterialInstance(t);return this._materialInstances},set:function(t){for(var e=t.length,i=this._materials.length,n=e;n<i;n++)this.setMaterialInstance(null,n);this._materials.length=e,this._materialInstances.length=e;for(var r=0;r<e;r++)this._materialInstances[r]!=t[r]&&this.setMaterialInstance(t[r],r)}}]),e}(rp)).prototype,"sharedMaterials",[Vk],Object.getOwnPropertyDescriptor(zk.prototype,"sharedMaterials"),zk.prototype),Hk=ks(zk.prototype,"_materials",[Gk],(function(){return[]})),Uk=zk))||Uk)||Uk));Se(oc),Se(ac),Se(hc),t("I",mV),function(t){t[t.ADD_COLOR=0]="ADD_COLOR",t[t.ADD_COLOR_AND_TEXTURE=1]="ADD_COLOR_AND_TEXTURE",t[t.GRAYSCALE=2]="GRAYSCALE",t[t.USE_ALPHA_SEPARATED=3]="USE_ALPHA_SEPARATED",t[t.USE_ALPHA_SEPARATED_AND_GRAY=4]="USE_ALPHA_SEPARATED_AND_GRAY"}(mV||t("I",mV={}));var TV=t("d",(rV=qs("cc.UIRenderer"),sV=Ys(nV),oV=xo(xT),aV=xo(xT),rV(hV=sV(((pV=function(t){function e(){var e;return(e=t.call(this)||this)._renderData=null,e._materials=lV&&lV(),e._customMaterial=cV&&cV(),e._srcBlendFactor=_V&&_V(),e._dstBlendFactor=dV&&dV(),e._color=fV&&fV(),e._stencilStage=Sk.DISABLED,e._assembler=null,e._postAssembler=null,e._renderDataFlag=!0,e._renderFlag=!0,e._renderEntity=void 0,e._instanceMaterialType=-1,e._srcBlendFactorCache=oc.SRC_ALPHA,e._dstBlendFactorCache=oc.ONE_MINUS_SRC_ALPHA,e._dirtyVersion=-1,e._internalId=-1,e._flagChangedVersion=-1,e._useVertexOpacity=!1,e._lastParent=null,e._renderEntity=e.createRenderEntity(),e}s(e,t);var i=e.prototype;return i.setRenderData=function(t){this._renderData=t},i.onLoad=function(){this._renderEntity.setNode(this.node)},i.__preload=function(){this.node._uiProps.uiComp=this,this._flushAssembler&&this._flushAssembler()},i.onEnable=function(){this.node.on(om.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.on(om.SIZE_CHANGED,this._nodeStateChange,this),this.node.on(om.PARENT_CHANGED,this._colorDirty,this),this.updateMaterial(),this._colorDirty(),nN.addRenderer(this),this.markForUpdateRenderData()},i.onRestore=function(){this.updateMaterial(),this.markForUpdateRenderData()},i.onDisable=function(){this.node.off(om.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.off(om.SIZE_CHANGED,this._nodeStateChange,this),this.node.off(om.PARENT_CHANGED,this._colorDirty,this),nN.removeRenderer(this),this._renderFlag=!1,this._renderEntity.enabled=!1},i.onDestroy=function(){if(this._renderEntity.setNode(null),this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this.destroyRenderData(),this._materialInstances)for(var t=0;t<this._materialInstances.length;t++){var e=this._materialInstances[t];e&&e.destroy()}},i.markForUpdateRenderData=function(t){if(void 0===t&&(t=!0),t){var e=this._renderData;e&&(e.vertDirty=!0),nN.markDirtyRenderer(this)}},i.requestRenderData=function(t){void 0===t&&(t=vk.COMP);var e=qk.add();return e.initRenderDrawInfo(this,t),this._renderData=e,e},i.destroyRenderData=function(){this._renderData&&(this._renderData.removeRenderDrawInfo(this),qk.remove(this._renderData),this._renderData=null)},i.updateRenderer=function(){this._assembler&&this._assembler.updateRenderData(this),this._renderFlag=this._canRender(),this._renderEntity.enabled=this._renderFlag},i.fillBuffers=function(t){this._renderFlag&&this._render(t)},i.postUpdateAssembler=function(t){this._postAssembler&&this._renderFlag&&this._postRender(t)},i._render=function(){},i._postRender=function(){},i._canRender=function(){return null!==this.getSharedMaterial(0)&&this._enabled&&this._color.a>0},i._postCanRender=function(){},i.updateMaterial=function(){if(this._customMaterial)this.getSharedMaterial(0)!==this._customMaterial&&this.setSharedMaterial(this._customMaterial,0);else{var t=this._updateBuiltinMaterial();this.setSharedMaterial(t,0),this.stencilStage!==Sk.ENTER_LEVEL&&this.stencilStage!==Sk.ENTER_LEVEL_INVERTED||this.getMaterialInstance(0).recompileShaders({USE_ALPHA_TEST:!0}),this._updateBlendFunc()}},i._updateColor=function(){if(this.node._uiProps.colorDirty=!0,this.setEntityColorDirty(!0),this.setEntityColor(this._color),this.setEntityOpacity(this.node._uiProps.localOpacity),this._assembler){this._assembler.updateColor(this);var t=this._renderFlag;if(this._renderFlag=this._canRender(),this.setEntityEnabled(this._renderFlag),t!==this._renderFlag){var e=this.renderData;e&&(e.vertDirty=!0)}}},e.setEntityColorDirtyRecursively=function(t,i){var n=t._uiProps.uiComp;n&&n.color&&(n._renderEntity.colorDirty=i);for(var r=0;r<t.children.length;r++)e.setEntityColorDirtyRecursively(t.children[r],i)},i.setEntityColorDirty=function(){},i.setEntityColor=function(){},i.setEntityOpacity=function(){},i.setEntityEnabled=function(){},i._updateBlendFunc=function(){var t=this.getRenderMaterial(0).passes[0].blendState.targets[0];if(this._dstBlendFactorCache=t.blendDst,this._srcBlendFactorCache=t.blendSrc,this._dstBlendFactorCache!==this._dstBlendFactor||this._srcBlendFactorCache!==this._srcBlendFactor){(t=this.getMaterialInstance(0).passes[0].blendState.targets[0]).blend=!0,t.blendDstAlpha=oc.ONE_MINUS_SRC_ALPHA,t.blendDst=this._dstBlendFactor,t.blendSrc=this._srcBlendFactor;var e=this.getMaterialInstance(0).passes[0];e.blendState.setTarget(0,t),e._updatePassHash(),this._dstBlendFactorCache=this._dstBlendFactor,this._srcBlendFactorCache=this._srcBlendFactor}},i._nodeStateChange=function(){this._renderData&&this.markForUpdateRenderData();for(var t=0;t<this.node.children.length;++t){var i=this.node.children[t].getComponent(e);i&&i.markForUpdateRenderData()}},i._colorDirty=function(){this.node._uiProps.colorDirty=!0,this.setEntityColorDirty(!0)},i._onMaterialModified=function(e,i){this._renderData&&(this.markForUpdateRenderData(),this._renderData.passDirty=!0),t.prototype._onMaterialModified.call(this,e,i)},i._updateBuiltinMaterial=function(){var t;switch(this._instanceMaterialType){case mV.ADD_COLOR:t=nT.get("ui-base-material");break;case mV.GRAYSCALE:t=nT.get("ui-sprite-gray-material");break;case mV.USE_ALPHA_SEPARATED:t=nT.get("ui-sprite-alpha-sep-material");break;case mV.USE_ALPHA_SEPARATED_AND_GRAY:t=nT.get("ui-sprite-gray-alpha-sep-material");break;default:t=nT.get("ui-sprite-material")}return t},i.setNodeDirty=function(){this._renderData&&(this._renderData.nodeDirty=!0)},i.setTextureDirty=function(){this._renderData&&(this._renderData.textureDirty=!0)},i.createRenderEntity=function(){return new Wk(xk.STATIC)},n(e,[{key:"sharedMaterials",get:function(){return this._materials},set:function(t){for(var e=0;e<t.length;e++)t[e]!==this._materials[e]&&this.setSharedMaterial(t[e],e);if(t.length<this._materials.length){for(var i=t.length;i<this._materials.length;i++)this.setSharedMaterial(null,i);this._materials.splice(t.length)}}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this.updateMaterial()}},{key:"color",get:function(){return this._color},set:function(t){this._color.equals(t)||(this._color.set(t),this._updateColor())}},{key:"renderData",get:function(){return this._renderData}},{key:"useVertexOpacity",get:function(){return this._useVertexOpacity}},{key:"stencilStage",get:function(){return this._stencilStage},set:function(t){this._stencilStage=t,this._renderEntity.setStencilStage(t)}},{key:"srcBlendFactor",get:function(){return this._srcBlendFactor},set:function(t){this._srcBlendFactor=t}},{key:"batcher",get:function(){return fN.root.batcher2D}},{key:"renderEntity",get:function(){return this._renderEntity}}]),e}(SV)).BlendState=oc,pV.Assembler=null,pV.PostAssembler=null,p((uV=pV).prototype,"sharedMaterials",[Ro],Object.getOwnPropertyDescriptor(uV.prototype,"sharedMaterials"),uV.prototype),p(uV.prototype,"customMaterial",[oV],Object.getOwnPropertyDescriptor(uV.prototype,"customMaterial"),uV.prototype),lV=ks(uV.prototype,"_materials",[Ro],(function(){return[]})),cV=ks(uV.prototype,"_customMaterial",[aV],(function(){return null})),_V=ks(uV.prototype,"_srcBlendFactor",[io],(function(){return oc.SRC_ALPHA})),dV=ks(uV.prototype,"_dstBlendFactor",[io],(function(){return oc.ONE_MINUS_SRC_ALPHA})),fV=ks(uV.prototype,"_color",[io],(function(){return dn.WHITE.clone()})),hV=uV))||hV)||hV));v.internal.UIRenderer=TV;var AV,bV,EV,CV,wV,xV,RV,IV,BV,DV,PV,OV,MV,LV,NV,FV,kV,VV,GV,UV,zV,HV,WV,jV,XV,qV,YV,KV,JV,QV,ZV,$V,tG,eG,iG,nG,rG,sG,oG=function(){function t(){this.isBold=!1,this.isItalic=!1,this.isUnderline=!1,this.underlineHeight=1,this.isOutlined=!1,this.outlineColor=dn.WHITE.clone(),this.outlineWidth=1,this.hasShadow=!1,this.shadowColor=dn.BLACK.clone(),this.shadowBlur=2,this.shadowOffsetX=0,this.shadowOffsetY=0,this.color=dn.WHITE.clone(),this.fontSize=40,this.actualFontSize=0,this.isSystemFontUsed=!1,this.originFontSize=0,this.bmfontScale=1,this.fontFamily="Arial",this.fontDesc="",this.fntConfig=null,this.spriteFrame=null,this.fontScale=1}return t.prototype.reset=function(){this.isBold=!1,this.isItalic=!1,this.isUnderline=!1,this.underlineHeight=1,this.isOutlined=!1,this.outlineColor.set(),this.outlineWidth=1,this.hasShadow=!1,this.shadowColor.set(),this.shadowBlur=2,this.shadowOffsetX=0,this.shadowOffsetY=0},t}(),aG=function(){function t(){this.horizontalAlign=0,this.verticalAlign=0,this.wrapping=!0,this.overFlow=0,this.lineHeight=10,this.maxLineWidth=0,this.spacingX=0,this.textWidthTemp=0,this.textHeightTemp=0,this.textDimensions=new Vn,this.horizontalKerning=[],this.numberOfLines=1,this.linesOffsetX=[],this.letterOffsetY=0,this.tailoredTopY=0,this.tailoredBottomY=0,this.textDesiredHeight=0,this.linesWidth=[]}return t.prototype.reset=function(){this.horizontalAlign=0,this.verticalAlign=0,this.wrapping=!0,this.overFlow=0,this.lineHeight=10,this.maxLineWidth=0,this.spacingX=0,this.textWidthTemp=0,this.textHeightTemp=0,this.textDimensions.set(),this.horizontalKerning.length=0,this.numberOfLines=1,this.linesOffsetX.length=0,this.letterOffsetY=0,this.tailoredTopY=0,this.tailoredBottomY=0,this.textDesiredHeight=0,this.linesWidth.length=0},t}(),hG=function(){function t(){this.parsedString=[],this.nodeContentSize=Vn.ZERO.clone(),this.canvasSize=new Vn,this.canvasPadding=new Un,this.contentSizeExtend=Vn.ZERO.clone(),this.startPosition=Ln.ZERO.clone()}return t.prototype.reset=function(){this.parsedString.length=0,this.nodeContentSize.set(0,0),this.canvasSize.set(),this.canvasPadding.set(),this.contentSizeExtend.set(),this.startPosition.set()},t}(),uG=function(){function t(){this.quadCount=0,this.vertexBuffer=[],this.texture=null,this.uiTransAnchorX=.5,this.uiTransAnchorY=.5}return t.prototype.reset=function(){this.quadCount=0,this.vertexBuffer.length=0,this.texture=null,this.uiTransAnchorX=.5,this.uiTransAnchorY=.5},t}();dn.WHITE.clone(),t("H",iG),function(t){t[t.LEFT=0]="LEFT",t[t.CENTER=1]="CENTER",t[t.RIGHT=2]="RIGHT"}(iG||t("H",iG={})),Se(iG),t("V",nG),function(t){t[t.TOP=0]="TOP",t[t.CENTER=1]="CENTER",t[t.BOTTOM=2]="BOTTOM"}(nG||t("V",nG={})),Se(nG),t("O",rG),function(t){t[t.NONE=0]="NONE",t[t.CLAMP=1]="CLAMP",t[t.SHRINK=2]="SHRINK",t[t.RESIZE_HEIGHT=3]="RESIZE_HEIGHT"}(rG||t("O",rG={})),Se(rG),t("q",sG),function(t){t[t.NONE=0]="NONE",t[t.BITMAP=1]="BITMAP",t[t.CHAR=2]="CHAR"}(sG||t("q",sG={})),Se(sG);var lG=t("r",(AV=qs("cc.Label"),bV=Ks(110),EV=xo(iG),CV=xo(nG),wV=xo(rG),xV=xo(TF),RV=xo(sG),AV(IV=bV(((eG=function(t){function e(){var e;return(e=t.call(this)||this)._string=DV&&DV(),e._horizontalAlign=PV&&PV(),e._verticalAlign=OV&&OV(),e._actualFontSize=MV&&MV(),e._fontSize=LV&&LV(),e._fontFamily=NV&&NV(),e._lineHeight=FV&&FV(),e._overflow=kV&&kV(),e._enableWrapText=VV&&VV(),e._font=GV&&GV(),e._isSystemFontUsed=UV&&UV(),e._spacingX=zV&&zV(),e._isItalic=HV&&HV(),e._isBold=WV&&WV(),e._isUnderline=jV&&jV(),e._underlineHeight=XV&&XV(),e._cacheMode=qV&&qV(),e._enableOutline=YV&&YV(),e._outlineColor=KV&&KV(),e._outlineWidth=JV&&JV(),e._enableShadow=QV&&QV(),e._shadowColor=ZV&&ZV(),e._shadowOffset=$V&&$V(),e._shadowBlur=tG&&tG(),e._N$file=null,e._texture=null,e._ttfSpriteFrame=null,e._userDefinedFont=null,e._assemblerData=null,e._fontAtlas=null,e._letterTexture=null,e._contentWidth=0,e._textStyle=null,e._textLayout=null,e._textRenderData=null,e._textLayoutData=null,e._ttfSpriteFrame=null,e._textStyle=new oG,e._textLayout=new aG,e._textLayoutData=new hG,e._textRenderData=new uG,e}s(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this._font||this._isSystemFontUsed||(this.useSystemFont=!0),this._isSystemFontUsed&&!this._fontFamily&&(this.fontFamily="Arial"),this._applyFontTexture()},i.onDestroy=function(){if(this._assembler&&this._assembler.resetAssemblerData&&this._assembler.resetAssemblerData(this._assemblerData),this._assemblerData=null,this._ttfSpriteFrame){this._ttfSpriteFrame._resetDynamicAtlasFrame();var e=this._ttfSpriteFrame.texture;if(this._ttfSpriteFrame.destroy(),e){var i=e;i.image&&i.image.destroy(),e.destroy()}this._ttfSpriteFrame=null}this._letterTexture=null,t.prototype.onDestroy.call(this)},i.updateRenderData=function(t){void 0===t&&(t=!1),t&&(this._flushAssembler(),this.renderData&&(this.renderData.vertDirty=!0),this._applyFontTexture()),this._assembler&&this._assembler.updateRenderData(this)},i._render=function(t){t.commitComp(this,this.renderData,this._texture,this._assembler,null)},i._updateColor=function(){t.prototype._updateColor.call(this),this.markForUpdateRenderData()},i.setEntityColor=function(){},i._canRender=function(){if(!t.prototype._canRender.call(this)||!this._string)return!1;var e=this._font;if(e&&e instanceof MF){var i=e.spriteFrame;if(!i||!i.texture)return!1}return!0},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this.destroyRenderData(),this._assembler=t,this.textStyle.reset(),this.textLayout.reset(),this.textLayoutData.reset(),this.textRenderData.reset()),this.renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this.renderData.material=this.material,this._updateColor())},i._applyFontTexture=function(){this.markForUpdateRenderData();var t=this._font;if(t instanceof MF){var e=t.spriteFrame;e&&e.texture&&(this._texture=e,this.renderData&&(this.renderData.textureDirty=!0),this.changeMaterialForDefine(),this._assembler&&this._assembler.updateRenderData(this))}else{if(this.cacheMode===sG.CHAR)this._letterTexture=this._assembler.getAssemblerData(),this._texture=this._letterTexture;else if(!this._ttfSpriteFrame){this._ttfSpriteFrame=new pF,this._assemblerData=this._assembler.getAssemblerData();var i=new Rf(this._assemblerData.canvas),n=new Zp;n.image=i,this._ttfSpriteFrame.texture=n}this.cacheMode!==sG.CHAR&&(this._texture=this._ttfSpriteFrame),this.changeMaterialForDefine()}},i.changeMaterialForDefine=function(){if(this._texture){var t=!1;if(this.cacheMode!==sG.CHAR){var e=this._texture.texture;if(e instanceof Of){var i=e.getPixelFormat();t=i===af.RGBA_ETC1||i===af.RGB_A_PVRTC_4BPPV1||i===af.RGB_A_PVRTC_2BPPV1}}this._instanceMaterialType=t?mV.USE_ALPHA_SEPARATED:mV.ADD_COLOR_AND_TEXTURE,this.updateMaterial()}},i._updateBlendFunc=function(){t.prototype._updateBlendFunc.call(this)},n(e,[{key:"string",get:function(){return this._string},set:function(t){t=null==t?"":t.toString(),this._string!==t&&(this._string=t,this.markForUpdateRenderData())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(t){this._horizontalAlign!==t&&(this._horizontalAlign=t,this.markForUpdateRenderData())}},{key:"verticalAlign",get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!==t&&(this._verticalAlign=t,this.markForUpdateRenderData())}},{key:"actualFontSize",get:function(){return this._actualFontSize},set:function(t){this._actualFontSize=t}},{key:"fontSize",get:function(){return this._fontSize},set:function(t){this._fontSize!==t&&(this._fontSize=t,this.markForUpdateRenderData())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this.markForUpdateRenderData())}},{key:"spacingX",get:function(){return this._spacingX},set:function(t){this._spacingX!==t&&(this._spacingX=t,this.markForUpdateRenderData())}},{key:"overflow",get:function(){return this._overflow},set:function(t){this._overflow!==t&&(this._overflow=t,this.markForUpdateRenderData())}},{key:"enableWrapText",get:function(){return this._enableWrapText},set:function(t){this._enableWrapText!==t&&(this._enableWrapText=t,this.markForUpdateRenderData())}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this.destroyRenderData(),this._isSystemFontUsed=!!t,t&&(this.font=null),this._flushAssembler(),this.markForUpdateRenderData())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this.markForUpdateRenderData())}},{key:"font",get:function(){return this._font},set:function(t){this._font!==t&&(this._isSystemFontUsed=!t,this._font=t,this.destroyRenderData(),this._fontAtlas=null,this.updateRenderData(!0))}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode!==t&&(this._cacheMode!==sG.BITMAP||this._font instanceof MF||!this._ttfSpriteFrame||this._ttfSpriteFrame._resetDynamicAtlasFrame(),this._cacheMode===sG.CHAR&&(this._ttfSpriteFrame=null),this._cacheMode=t,this.updateRenderData(!0))}},{key:"isBold",get:function(){return this._isBold},set:function(t){this._isBold!==t&&(this._isBold=t,this.markForUpdateRenderData())}},{key:"isItalic",get:function(){return this._isItalic},set:function(t){this._isItalic!==t&&(this._isItalic=t,this.markForUpdateRenderData())}},{key:"isUnderline",get:function(){return this._isUnderline},set:function(t){this._isUnderline!==t&&(this._isUnderline=t,this.markForUpdateRenderData())}},{key:"underlineHeight",get:function(){return this._underlineHeight},set:function(t){this._underlineHeight!==t&&(this._underlineHeight=t,this.markForUpdateRenderData())}},{key:"enableOutline",get:function(){return this._enableOutline},set:function(t){this._enableOutline!==t&&(this._enableOutline=t,this.markForUpdateRenderData())}},{key:"outlineColor",get:function(){return this._outlineColor},set:function(t){this._outlineColor!==t&&(this._outlineColor.set(t),this.markForUpdateRenderData())}},{key:"outlineWidth",get:function(){return this._outlineWidth},set:function(t){this._outlineWidth!==t&&(this._outlineWidth=t,this.markForUpdateRenderData())}},{key:"enableShadow",get:function(){return this._enableShadow},set:function(t){this._enableShadow!==t&&(this._enableShadow=t,this.markForUpdateRenderData())}},{key:"shadowColor",get:function(){return this._shadowColor},set:function(t){this._shadowColor!==t&&(this._shadowColor.set(t),this.markForUpdateRenderData())}},{key:"shadowOffset",get:function(){return this._shadowOffset},set:function(t){this._shadowOffset!==t&&(this._shadowOffset.set(t),this.markForUpdateRenderData())}},{key:"shadowBlur",get:function(){return this._shadowBlur},set:function(t){this._shadowBlur!==t&&(this._shadowBlur=t,this.markForUpdateRenderData())}},{key:"spriteFrame",get:function(){return this._texture}},{key:"ttfSpriteFrame",get:function(){return this._ttfSpriteFrame}},{key:"assemblerData",get:function(){return this._assemblerData}},{key:"fontAtlas",get:function(){return this._fontAtlas},set:function(t){this._fontAtlas=t}},{key:"_bmFontOriginalSize",get:function(){return this._font instanceof MF?this._font.fontSize:-1}},{key:"textStyle",get:function(){return this._textStyle}},{key:"textLayout",get:function(){return this._textLayout}},{key:"textRenderData",get:function(){return this._textRenderData}},{key:"textLayoutData",get:function(){return this._textLayoutData}},{key:"contentWidth",get:function(){return this._contentWidth},set:function(t){this._contentWidth=t}}]),e}(TV)).HorizontalAlign=iG,eG.VerticalAlign=nG,eG.Overflow=rG,eG.CacheMode=sG,eG._canvasPool=tk.getInstance(),p((BV=eG).prototype,"horizontalAlign",[EV],Object.getOwnPropertyDescriptor(BV.prototype,"horizontalAlign"),BV.prototype),p(BV.prototype,"verticalAlign",[CV],Object.getOwnPropertyDescriptor(BV.prototype,"verticalAlign"),BV.prototype),p(BV.prototype,"overflow",[wV],Object.getOwnPropertyDescriptor(BV.prototype,"overflow"),BV.prototype),p(BV.prototype,"font",[xV],Object.getOwnPropertyDescriptor(BV.prototype,"font"),BV.prototype),p(BV.prototype,"cacheMode",[RV],Object.getOwnPropertyDescriptor(BV.prototype,"cacheMode"),BV.prototype),DV=ks(BV.prototype,"_string",[io],(function(){return"label"})),PV=ks(BV.prototype,"_horizontalAlign",[io],(function(){return iG.CENTER})),OV=ks(BV.prototype,"_verticalAlign",[io],(function(){return nG.CENTER})),MV=ks(BV.prototype,"_actualFontSize",[io],(function(){return 0})),LV=ks(BV.prototype,"_fontSize",[io],(function(){return 40})),NV=ks(BV.prototype,"_fontFamily",[io],(function(){return"Arial"})),FV=ks(BV.prototype,"_lineHeight",[io],(function(){return 40})),kV=ks(BV.prototype,"_overflow",[io],(function(){return rG.NONE})),VV=ks(BV.prototype,"_enableWrapText",[io],(function(){return!0})),GV=ks(BV.prototype,"_font",[io],(function(){return null})),UV=ks(BV.prototype,"_isSystemFontUsed",[io],(function(){return!0})),zV=ks(BV.prototype,"_spacingX",[io],(function(){return 0})),HV=ks(BV.prototype,"_isItalic",[io],(function(){return!1})),WV=ks(BV.prototype,"_isBold",[io],(function(){return!1})),jV=ks(BV.prototype,"_isUnderline",[io],(function(){return!1})),XV=ks(BV.prototype,"_underlineHeight",[io],(function(){return 2})),qV=ks(BV.prototype,"_cacheMode",[io],(function(){return sG.NONE})),YV=ks(BV.prototype,"_enableOutline",[io],(function(){return!1})),KV=ks(BV.prototype,"_outlineColor",[io],(function(){return new dn(0,0,0,255)})),JV=ks(BV.prototype,"_outlineWidth",[io],(function(){return 2})),QV=ks(BV.prototype,"_enableShadow",[io],(function(){return!1})),ZV=ks(BV.prototype,"_shadowColor",[io],(function(){return new dn(0,0,0,255)})),$V=ks(BV.prototype,"_shadowOffset",[io],(function(){return new Ln(2,2)})),tG=ks(BV.prototype,"_shadowBlur",[io],(function(){return 2})),IV=BV))||IV)||IV));v.Label=lG;var cG,_G,dG=0,fG={};function pG(t){return--t,t|=t>>16,t|=t>>8,t|=t>>4,t|=t>>2,t|=t>>1,++t}function mG(t,e){return Math.ceil(t/e)*e}!function(t){t[t.OPAQUE=0]="OPAQUE",t[t.TRANSPARENT=1]="TRANSPARENT",t[t.OVERLAY=2]="OVERLAY"}(cG||(cG={})),function(t){t[t.DEFAULT=1]="DEFAULT",t[t.FORWARD=2]="FORWARD",t[t.SHADOWCAST=4]="SHADOWCAST"}(_G||(_G={}));var gG,yG,vG,SG,TG,AG,bG,EG,CG,wG=function(){function t(t){this._device=void 0,this._format=Hl.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new Gc,this._region1=new Gc,this._region2=new Gc,this._roundUpFn=null,this._bufferViewCtor=Uint8Array,this._channels=4,this._alignment=1,this._device=t}var e=t.prototype;return e.initialize=function(t){var e=M_[t.format];this._format=t.format,this._formatSize=e.size,this._channels=e.count,this._bufferViewCtor=H_(e),this._roundUpFn=t.roundUpFn||null,this._alignment=t.alignment||1,t.inOrderFree&&(this.alloc=this._McDonaldAlloc)},e.destroy=function(){for(var t=0;t<this._chunkCount;++t)this._chunks[t].texture.destroy();this._chunks.length=0,this._handles.length=0},e.alloc=function(t,e){t=mG(t,this._alignment);var i=-1,n=-1;if(void 0!==e&&(i=e,n=this._findAvailableSpace(t,i)),n<0)for(var r=0;r<this._chunkCount&&(i=r,!((n=this._findAvailableSpace(t,i))>=0));++r);if(n>=0){var s=this._chunks[i];s.start+=t;var o={chunkIdx:i,start:n,end:n+t,texture:s.texture};return this._handles.push(o),o}var a=Math.sqrt(t/this._formatSize),h=this._roundUpFn&&this._roundUpFn(a,this._formatSize)||Math.max(1024,pG(a)),u=this._chunks[this.createChunk(h)];u.start+=t;var l={chunkIdx:this._chunkCount-1,start:0,end:t,texture:u.texture};return this._handles.push(l),l},e.free=function(t){for(var e=0;e<this._handles.length;++e)if(this._handles[e]===t)return this._chunks[t.chunkIdx].end=t.end,void this._handles.splice(e,1)},e.createChunk=function(t){var e=t*t*this._formatSize;U("TextureBufferPool: Allocate chunk "+this._chunkCount+", size: "+e+", format: "+this._format);var i={texture:this._device.createTexture(new Qc(Jl.TEX2D,Ql.SAMPLED|Ql.TRANSFER_DST,this._format,t,t)),size:e,start:0,end:e};return this._chunks[this._chunkCount]=i,this._chunkCount++},e.update=function(t,e){var i=[],n=[],r=t.start/this._formatSize,s=e.byteLength/this._formatSize,o=r%t.texture.width,a=Math.floor(r/t.texture.width),h=Math.min(t.texture.width-o,s),u=0;o>0&&(this._region0.texOffset.x=o,this._region0.texOffset.y=a,this._region0.texExtent.width=h,this._region0.texExtent.height=1,i.push(new this._bufferViewCtor(e,u*this._formatSize,h*this._channels)),n.push(this._region0),o=0,a+=1,s-=h,u+=h),s>0&&(this._region1.texOffset.x=o,this._region1.texOffset.y=a,s>t.texture.width?(this._region1.texExtent.width=t.texture.width,this._region1.texExtent.height=Math.floor(s/t.texture.width),h=this._region1.texExtent.width*this._region1.texExtent.height):(h=s,this._region1.texExtent.width=h,this._region1.texExtent.height=1),i.push(new this._bufferViewCtor(e,u*this._formatSize,h*this._channels)),n.push(this._region1),o=0,a+=this._region1.texExtent.height,s-=h,u+=h),s>0&&(this._region2.texOffset.x=o,this._region2.texOffset.y=a,this._region2.texExtent.width=s,this._region2.texExtent.height=1,i.push(new this._bufferViewCtor(e,u*this._formatSize,s*this._channels)),n.push(this._region2)),this._device.copyBuffersToTexture(i,t.texture,n)},e._findAvailableSpace=function(t,e){var i=this._chunks[e],n=!1,r=i.start;if(r+t<=i.size)n=!0;else{r=0;for(var s=this._handles.filter((function(t){return t.chunkIdx===e})).sort((function(t,e){return t.start-e.start})),o=0;o<s.length;o++){var a=s[o];if(r+t<=a.start){n=!0;break}r=a.end}!n&&r+t<=i.size&&(n=!0)}return n?r:-1},e._McDonaldAlloc=function(t){t=mG(t,this._alignment);for(var e=0;e<this._chunkCount;++e){var i=this._chunks[e],n=!1,r=i.start;if(r+t<=i.end?n=!0:r>i.end?r+t<=i.size?n=!0:t<=i.end&&(i.start=r=0,n=!0):r===i.end&&(i.start=r=0,i.end=i.size,t<=i.end&&(n=!0)),n){i.start+=t;var s={chunkIdx:e,start:r,end:r+t,texture:i.texture};return this._handles.push(s),s}}var o=Math.sqrt(t/this._formatSize),a=this._roundUpFn&&this._roundUpFn(o,this._formatSize)||Math.max(1024,pG(o)),h=this._chunks[this.createChunk(a)];h.start+=t;var u={chunkIdx:this._chunkCount,start:0,end:t,texture:h.texture};return this._handles.push(u),u},t}(),xG=function(){function t(t,e,i){this._arrayBuffers=[],this._chunkSize=void 0,this._chunkSize=i*(1<<e)}return t.prototype.allocateNewChunk=function(){return new ArrayBuffer(this._chunkSize)},t}();!function(t){t[t.UINT32=0]="UINT32",t[t.FLOAT32=1]="FLOAT32",t[t.NEVER=2]="NEVER"}(CG||(CG={}));var RG,IG,BG=function(){function t(t,e,i,n,r){void 0===r&&(r=8),this._dataType=void 0,this._dataMembers=void 0,this._elementCount=void 0,this._entryBits=void 0,this._stride=void 0,this._entriesPerChunk=void 0,this._entryMask=void 0,this._chunkMask=void 0,this._poolFlag=void 0,this._arrayBuffers=[],this._freeLists=[],this._uint32BufferViews=[],this._float32BufferViews=[],this._hasUint32=!1,this._hasFloat32=!1,this._nativePool=void 0,this._elementCount=n.COUNT,this._entryBits=r,this._dataType=e,this._dataMembers=i,this._stride=4*this._elementCount,this._entriesPerChunk=1<<r,this._entryMask=this._entriesPerChunk-1,this._poolFlag=1<<30,this._chunkMask=~(this._entryMask|this._poolFlag),this._nativePool=new xG(t,r,this._stride);var s=CG.NEVER,o=!1,a=!1;for(var h in e){if(o=this._hasFloat32,(a=this._hasUint32)&&o)break;s=e[h],o||s!==CG.FLOAT32?a||s!==CG.UINT32||(this._hasUint32=!0):this._hasFloat32=!0}}var e=t.prototype;return e.alloc=function(){for(var t=0;t<this._freeLists.length;t++){var e=this._freeLists[t];if(e.length){var i=e[e.length-1];return e.length--,(t<<this._entryBits)+i+this._poolFlag}}for(var n=this._nativePool.allocateNewChunk(),r=[],s=[],o=[],a=this._hasFloat32,h=this._hasUint32,u=0;u<this._entriesPerChunk;u++)a&&r.push(new Float32Array(n,this._stride*u,this._elementCount)),h&&s.push(new Uint32Array(n,this._stride*u,this._elementCount)),u&&o.push(u);return h&&this._uint32BufferViews.push(s),a&&this._float32BufferViews.push(r),this._freeLists.push(o),this._arrayBuffers.push(n),(t<<this._entryBits)+this._poolFlag},e.getBuffer=function(t){var e=(this._chunkMask&t)>>this._entryBits,i=this._entryMask&t;return(this._hasFloat32?this._float32BufferViews:this._uint32BufferViews)[e][i]},e.getTypedArray=function(t,e){var i=(this._chunkMask&t)>>this._entryBits,n=this._entryMask&t,r=e,s=(this._dataType[e]===CG.UINT32?this._uint32BufferViews:this._float32BufferViews)[i][n],o=this._dataMembers[e];return s.subarray(r,r+o)},e.free=function(t){var e=(this._chunkMask&t)>>this._entryBits,i=this._entryMask&t;(this._hasUint32?this._uint32BufferViews:this._float32BufferViews)[e][i].fill(0),this._freeLists[e].push(i)},t}();!function(t){t[t.NODE=0]="NODE",t[t.PASS=1]="PASS",t[t.AABB=2]="AABB",t[t.RENDER2D=3]="RENDER2D"}(RG||(RG={})),function(t){t[t.POSITION=0]="POSITION",t[t.UV=3]="UV",t[t.COLOR=5]="COLOR",t[t.COUNT=9]="COUNT"}(IG||(IG={}));var DG,PG=((gG={})[IG.POSITION]=CG.FLOAT32,gG[IG.UV]=CG.FLOAT32,gG[IG.COLOR]=CG.UINT32,gG[IG.COUNT]=CG.NEVER,gG),OG=((yG={})[IG.POSITION]=IG.UV-IG.POSITION,yG[IG.UV]=IG.COLOR-IG.UV,yG[IG.COLOR]=IG.COUNT-IG.COLOR,yG[IG.COUNT]=1,yG),MG=new BG(RG.RENDER2D,PG,OG,IG);!function(t){t[t.DIRTY_FLAG=0]="DIRTY_FLAG",t[t.LAYER=1]="LAYER",t[t.WORLD_SCALE=2]="WORLD_SCALE",t[t.WORLD_POSITION=5]="WORLD_POSITION",t[t.WORLD_ROTATION=8]="WORLD_ROTATION",t[t.WORLD_MATRIX=12]="WORLD_MATRIX",t[t.LOCAL_SCALE=28]="LOCAL_SCALE",t[t.LOCAL_POSITION=31]="LOCAL_POSITION",t[t.LOCAL_ROTATION=34]="LOCAL_ROTATION",t[t.COUNT=38]="COUNT"}(DG||(DG={}));var LG,NG=((vG={})[DG.DIRTY_FLAG]=CG.UINT32,vG[DG.LAYER]=CG.UINT32,vG[DG.WORLD_SCALE]=CG.FLOAT32,vG[DG.WORLD_POSITION]=CG.FLOAT32,vG[DG.WORLD_ROTATION]=CG.FLOAT32,vG[DG.WORLD_MATRIX]=CG.FLOAT32,vG[DG.LOCAL_SCALE]=CG.FLOAT32,vG[DG.LOCAL_POSITION]=CG.FLOAT32,vG[DG.LOCAL_ROTATION]=CG.FLOAT32,vG[DG.COUNT]=CG.NEVER,vG),FG=((SG={})[DG.DIRTY_FLAG]=DG.LAYER-DG.DIRTY_FLAG,SG[DG.LAYER]=DG.WORLD_SCALE-DG.LAYER,SG[DG.WORLD_SCALE]=DG.WORLD_POSITION-DG.WORLD_SCALE,SG[DG.WORLD_POSITION]=DG.WORLD_ROTATION-DG.WORLD_POSITION,SG[DG.WORLD_ROTATION]=DG.WORLD_MATRIX-DG.WORLD_ROTATION,SG[DG.WORLD_MATRIX]=DG.LOCAL_SCALE-DG.WORLD_MATRIX,SG[DG.LOCAL_SCALE]=DG.LOCAL_POSITION-DG.LOCAL_SCALE,SG[DG.LOCAL_POSITION]=DG.LOCAL_ROTATION-DG.LOCAL_POSITION,SG[DG.LOCAL_ROTATION]=DG.COUNT-DG.LOCAL_ROTATION,SG[DG.COUNT]=1,SG),kG=new BG(RG.NODE,NG,FG,DG);!function(t){t[t.PRIORITY=0]="PRIORITY",t[t.STAGE=1]="STAGE",t[t.PHASE=2]="PHASE",t[t.PRIMITIVE=3]="PRIMITIVE",t[t.BATCHING_SCHEME=4]="BATCHING_SCHEME",t[t.DYNAMIC_STATE=5]="DYNAMIC_STATE",t[t.HASH=6]="HASH",t[t.COUNT=7]="COUNT"}(LG||(LG={}));var VG,GG=((TG={})[LG.PRIORITY]=CG.UINT32,TG[LG.STAGE]=CG.UINT32,TG[LG.PHASE]=CG.UINT32,TG[LG.PRIMITIVE]=CG.UINT32,TG[LG.BATCHING_SCHEME]=CG.UINT32,TG[LG.DYNAMIC_STATE]=CG.UINT32,TG[LG.HASH]=CG.UINT32,TG[LG.COUNT]=CG.NEVER,TG),UG=((AG={})[LG.PRIORITY]=LG.STAGE-LG.PRIORITY,AG[LG.STAGE]=LG.PHASE-LG.STAGE,AG[LG.PHASE]=LG.PRIMITIVE-LG.PHASE,AG[LG.PRIMITIVE]=LG.BATCHING_SCHEME-LG.PRIMITIVE,AG[LG.BATCHING_SCHEME]=LG.DYNAMIC_STATE-LG.BATCHING_SCHEME,AG[LG.DYNAMIC_STATE]=LG.HASH-LG.DYNAMIC_STATE,AG[LG.HASH]=LG.COUNT-LG.HASH,AG[LG.COUNT]=1,AG),zG=new BG(RG.PASS,GG,UG,LG);!function(t){t[t.CENTER=0]="CENTER",t[t.HALFEXTENTS=3]="HALFEXTENTS",t[t.COUNT=6]="COUNT"}(VG||(VG={}));var HG=((bG={})[VG.CENTER]=CG.FLOAT32,bG[VG.HALFEXTENTS]=CG.FLOAT32,bG[VG.COUNT]=CG.NEVER,bG),WG=((EG={})[VG.CENTER]=VG.HALFEXTENTS-VG.CENTER,EG[VG.HALFEXTENTS]=VG.COUNT-VG.HALFEXTENTS,EG[VG.COUNT]=1,EG),jG=new BG(RG.AABB,HG,WG,VG);rt(WM.prototype,"RenderScene.prototype",[{name:"raycastUI2DNode"},{name:"raycastUINode"}]),rt(WM.prototype,"RenderScene.prototype",[{name:"raycastAll",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllModels",suggest:"using intersect.rayModel in geometry"},{name:"raycastSingleModel",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllCanvas",suggest:"using intersect.rayAABB in geometry"},{name:"rayResultCanvas"},{name:"rayResultModels"},{name:"rayResultAll"},{name:"rayResultSingleModel"}]),rt(wM.prototype,"Model.prototype",[{name:"isInstancingEnabled"},{name:"instancedAttributes"}]);var XG={};rt(XG,"CameraVisFlags",[{name:"GENERAL"}]),nt(XG,"CameraVisFlags",[{name:"PROFILER",newName:"PROFILER",target:im.BitMask,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:im.BitMask,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:im.BitMask,targetName:"EDITOR"},{name:"UI",newName:"UI",target:im.BitMask,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:im.BitMask,targetName:"UI_2D"}]),v.CameraVisFlags=XG;var qG={};rt(qG,"VisibilityFlags",[{name:"GENERAL"}]),nt(qG,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:im.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:im.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:im.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:im.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:im.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:im.Enum,targetName:"UI_2D"}]),v.VisibilityFlags=qG,nt(uT.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),rt(Hx.prototype,"Camera.prototype",[{name:"getSplitFrustum"},{name:"setMatView"},{name:"setMatViewInv"},{name:"setMatProjInv"},{name:"setMatViewProjInv"},{name:"setMatProj"},{name:"setMatViewProj"},{name:"getMatViewInv"}]),rt(MT.prototype,"Shadows.prototype",[{name:"aspect"},{name:"selfShadow"},{name:"linear"},{name:"packing"},{name:"autoAdapt"},{name:"fixedArea"},{name:"pcf"},{name:"bias"},{name:"normalBias"},{name:"near"},{name:"far"},{name:"shadowDistance"},{name:"invisibleOcclusionRange"},{name:"orthoSize"},{name:"saturation"}]),rt(FM.prototype,"SpotLight.prototype",[{name:"aspect"}]),nt(_M.prototype,"SubModel.prototype",[{name:"subMeshData",newName:"subMesh"}]),rt(_M.prototype,"SubModel.prototype",[{name:"getSubModel",suggest:"Use `subModels[i]` instead"},{name:"subModelNum",suggest:"Use `subModels.length` instead"}]);var YG,KG,JG,QG=function(t){if(void 0===fG[t]){var e=1<<dG;fG[t]=e,dG+=1}},ZG=Object.freeze({__proto__:null,addStage:QG,scene:HM,createIA:function(t,e){if(!e.positions)return console.error("The data must have positions field"),null;for(var i=[],n=e.positions.length/3,r=0;r<n;++r)i.push(e.positions[3*r],e.positions[3*r+1],e.positions[3*r+2]),e.normals&&i.push(e.normals[3*r],e.normals[3*r+1],e.normals[3*r+2]),e.uvs&&i.push(e.uvs[2*r],e.uvs[2*r+1]),e.colors&&i.push(e.colors[3*r],e.colors[3*r+1],e.colors[3*r+2]);var s=[];s.push(new u_(Ic.ATTR_POSITION,Hl.RGB32F)),e.normals&&s.push(new u_(Ic.ATTR_NORMAL,Hl.RGB32F)),e.uvs&&s.push(new u_(Ic.ATTR_TEX_COORD,Hl.RG32F)),e.colors&&s.push(new u_(Ic.ATTR_COLOR,Hl.RGB32F));var o=t.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,4*i.length,4*i.length/n));o.update(new Float32Array(i));var a=null;return e.indices&&(a=t.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,2*e.indices.length,2))).update(new Uint16Array(e.indices)),t.createInputAssembler(new c_(s,[o],a))},programLib:Pv,getDeviceShaderVersion:Ev,get RenderQueue(){return cG},get PassStage(){return _G},genHandle:rv,getTypeFromHandle:sv,getBindingFromHandle:ov,getCountFromHandle:av,getOffsetFromHandle:hv,customizeType:uv,type2reader:lv,type2writer:cv,type2validator:_v,getDefaultFromType:fv,getStringFromType:pv,overrideMacros:mv,get BatchingSchemes(){return eT},Pass:uT,nearestPOT:pG,TextureBufferPool:wG,MaterialInstance:NT,PassInstance:LT,get PoolType(){return RG},NULL_HANDLE:0,get Render2dView(){return IG},Render2dPool:MG,get NodeView(){return DG},NodePool:kG,get PassView(){return LG},PassPool:zG,get AABBView(){return VG},AABBPool:jG,RenderScene:WM,CameraVisFlags:XG,VisibilityFlags:qG});t("aD",ZG),function(t){t[t.BUTT=0]="BUTT",t[t.ROUND=1]="ROUND",t[t.SQUARE=2]="SQUARE"}(YG||(YG={})),Se(YG),function(t){t[t.BEVEL=0]="BEVEL",t[t.ROUND=1]="ROUND",t[t.MITER=2]="MITER"}(KG||(KG={})),Se(KG),function(t){t[t.PT_CORNER=1]="PT_CORNER",t[t.PT_LEFT=2]="PT_LEFT",t[t.PT_BEVEL=4]="PT_BEVEL",t[t.PT_INNERBEVEL=8]="PT_INNERBEVEL"}(JG||(JG={})),Se(JG);var $G=Math.PI,tU=Math.min,eU=Math.max,iU=Math.cos,nU=Math.sin,rU=Math.abs,sU=Math.sign,oU=.5522847493;function aU(t,e,i,n,r){t.moveTo(e-n,i),t.bezierCurveTo(e-n,i+r*oU,e-n*oU,i+r,e,i+r),t.bezierCurveTo(e+n*oU,i+r,e+n,i+r*oU,e+n,i),t.bezierCurveTo(e+n,i-r*oU,e+n*oU,i-r,e,i-r),t.bezierCurveTo(e-n*oU,i-r,e-n,i-r*oU,e-n,i),t.close()}function hU(t,e,i,n,r,s,o,a,h,u,l){var c,_,d,f,p,m,g,y,v,S,T,A,b,E,C,w;u>10||(p=.5*(s+a),m=.5*(o+h),g=.5*((c=.5*(e+n))+(d=.5*(n+s))),y=.5*((_=.5*(i+r))+(f=.5*(r+o))),((C=rU((n-a)*(E=h-i)-(r-h)*(b=a-e)))+(w=rU((s-a)*E-(o-h)*b)))*(C+w)<t.tessTol*(b*b+E*E)?t.addPoint(a,h,0===l?l|JG.PT_BEVEL:l):(hU(t,e,i,c,_,g,y,T=.5*(g+(v=.5*(d+p))),A=.5*(y+(S=.5*(f+m))),u+1,0),hU(t,T,A,v,S,p,m,a,h,u+1,l)))}var uU,lU,cU,_U,dU,fU,pU,mU,gU,yU,vU,SU,TU,AU,bU,EU,CU,wU,xU,RU,IU,BU,DU,PU,OU,MU,LU,NU,FU,kU,VU,GU,UU,zU,HU,WU,jU,XU=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).dx=0,e.dy=0,e.dmx=0,e.dmy=0,e.flags=0,e.len=0,e}return s(e,t),e.prototype.reset=function(){this.dx=0,this.dy=0,this.dmx=0,this.dmy=0,this.flags=0,this.len=0},e}(Ln),qU=function(){function t(){this.closed=!1,this.bevel=0,this.complex=!0,this.points=[]}return t.prototype.reset=function(){this.closed=!1,this.bevel=0,this.complex=!0,this.points.length=0},t}(),YU=function(){function t(t){this.dataOffset=0,this.updatePathOffset=!1,this.pathLength=0,this.pathOffset=0,this.paths=[],this.tessTol=.25,this.distTol=.01,this.fillColor=dn.WHITE.clone(),this.lineCap=YG.BUTT,this.strokeColor=dn.BLACK.clone(),this.lineJoin=KG.MITER,this.lineWidth=0,this.pointsOffset=0,this._commandX=0,this._commandY=0,this._points=[],this._renderDataList=[],this._curPath=null,this._comp=void 0,this._comp=t}var e=t.prototype;return e.moveTo=function(t,e){this.updatePathOffset&&(this.pathOffset=this.pathLength,this.updatePathOffset=!1),this._addPath(),this.addPoint(t,e,JG.PT_CORNER),this._commandX=t,this._commandY=e},e.lineTo=function(t,e){this.addPoint(t,e,JG.PT_CORNER),this._commandX=t,this._commandY=e},e.bezierCurveTo=function(t,e,i,n,r,s){var o=this._curPath,a=o.points[o.points.length-1];a&&(a.x!==t||a.y!==e||i!==r||n!==s?(hU(this,a.x,a.y,t,e,i,n,r,s,0,JG.PT_CORNER),this._commandX=r,this._commandY=s):this.lineTo(r,s))},e.quadraticCurveTo=function(t,e,i,n){var r=this._commandX,s=this._commandY;this.bezierCurveTo(r+2/3*(t-r),s+2/3*(e-s),i+2/3*(t-i),n+2/3*(e-n),i,n)},e.arc=function(t,e,i,n,r,s){!function(t,e,i,n,r,s,o){var a,h,u=0,l=0,c=0,_=0,d=0,f=0,p=0,m=0,g=0,y=0,v=0,S=0,T=0,A=0;if(l=s-r,o=o||!1)if(rU(l)>=2*$G)l=2*$G;else for(;l<0;)l+=2*$G;else if(rU(l)>=2*$G)l=2*-$G;else for(;l>0;)l-=2*$G;for(h=0|eU(1,tU(rU(l)/(.5*$G)+.5,5)),c=rU(4/3*(1-iU(a=l/h/2))/nU(a)),o||(c=-c),A=0;A<=h;A++)f=e+(_=iU(u=r+l*(A/h)))*n,p=i+(d=nU(u))*n,m=-d*n*c,g=_*n*c,0===A?t.moveTo(f,p):t.bezierCurveTo(y+S,v+T,f-m,p-g,f,p),y=f,v=p,S=m,T=g}(this,t,e,i,n,r,s)},e.ellipse=function(t,e,i,n){aU(this,t,e,i,n),this._curPath.complex=!1},e.circle=function(t,e,i){aU(this,t,e,i,i),this._curPath.complex=!1},e.rect=function(t,e,i,n){this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+n),this.lineTo(t,e+n),this.close(),this._curPath.complex=!1},e.roundRect=function(t,e,i,n,r){!function(t,e,i,n,r,s){if(s<.1)t.rect(e,i,n,r);else{var o=tU(s,.5*rU(n))*sU(n),a=tU(s,.5*rU(r))*sU(r);t.moveTo(e,i+a),t.lineTo(e,i+r-a),t.bezierCurveTo(e,i+r-a*(1-oU),e+o*(1-oU),i+r,e+o,i+r),t.lineTo(e+n-o,i+r),t.bezierCurveTo(e+n-o*(1-oU),i+r,e+n,i+r-a*(1-oU),e+n,i+r-a),t.lineTo(e+n,i+a),t.bezierCurveTo(e+n,i+a*(1-oU),e+n-o*(1-oU),i,e+n-o,i),t.lineTo(e+o,i),t.bezierCurveTo(e+o*(1-oU),i,e,i+a*(1-oU),e,i+a),t.close()}}(this,t,e,i,n,r),this._curPath.complex=!1},e.clear=function(){this.pathLength=0,this.pathOffset=0,this.pointsOffset=0,this.dataOffset=0,this._curPath=null,this.paths.length=0,this._points.length=0;for(var t=this._renderDataList,e=0,i=t.length;e<i;e++){var n=t[e];n&&(Yk.remove(n),n.removeRenderDrawInfo(this._comp))}this._renderDataList.length=0},e.close=function(){this._curPath.closed=!0},e.requestRenderData=function(){var t=Yk.add();return this._renderDataList.push(t),t},e.getRenderDataList=function(){return 0===this._renderDataList.length&&this.requestRenderData(),this._renderDataList},e.addPoint=function(t,e,i){var n=this._curPath;if(n){var r=this._points,s=n.points,o=r[this.pointsOffset++];o?(o.x=t,o.y=e):(o=new XU(t,e),r.push(o)),o.flags=i,s.push(o)}},e._addPath=function(){var t=this.pathLength,e=this.paths[t];return e?e.reset():(e=new qU,this.paths.push(e)),this.pathLength++,this._curPath=e,e},t}(),KU=uk.concat([new u_("a_dist",Hl.R32F)]),JU=fk(KU),QU=pk(KU),ZU=t("G",(uU=qs("cc.Graphics"),lU=Ks(110),cU=xo(KG),_U=xo(YG),uU(dU=lU(((TU=function(t){function e(){var e;return(e=t.call(this)||this).impl=null,e.model=null,e._lineWidth=pU&&pU(),e._strokeColor=mU&&mU(),e._lineJoin=gU&&gU(),e._lineCap=yU&&yU(),e._fillColor=vU&&vU(),e._miterLimit=SU&&SU(),e._isDrawing=!1,e._isNeedUploadData=!0,e._graphicsUseSubMeshes=[],e._instanceMaterialType=mV.ADD_COLOR,e.impl=new YU(c(e)),e}s(e,t);var i=e.prototype;return i.onRestore=function(){this.impl||this._flushAssembler()},i.onLoad=function(){t.prototype.onLoad.call(this),this.model=fN.root.createModel(wM),this.model.node=this.model.transform=this.node,this._flushAssembler()},i.onEnable=function(){t.prototype.onEnable.call(this),this._updateMtlForGraphics()},i.onDestroy=function(){this._sceneGetter=null,this.model&&(fN.root.destroyModel(this.model),this.model=null);var e=this._graphicsUseSubMeshes.length;if(e>0){for(var i=0;i<e;++i)this._graphicsUseSubMeshes[i].destroy();this._graphicsUseSubMeshes.length=0}this.impl&&(this._isDrawing=!1,this.impl.clear(),this.impl=null),t.prototype.onDestroy.call(this)},i.moveTo=function(t,e){this.impl&&this.impl.moveTo(t,e)},i.lineTo=function(t,e){this.impl&&this.impl.lineTo(t,e)},i.bezierCurveTo=function(t,e,i,n,r,s){this.impl&&this.impl.bezierCurveTo(t,e,i,n,r,s)},i.quadraticCurveTo=function(t,e,i,n){this.impl&&this.impl.quadraticCurveTo(t,e,i,n)},i.arc=function(t,e,i,n,r,s){this.impl&&this.impl.arc(t,e,i,n,r,s)},i.ellipse=function(t,e,i,n){this.impl&&this.impl.ellipse(t,e,i,n)},i.circle=function(t,e,i){this.impl&&this.impl.circle(t,e,i)},i.rect=function(t,e,i,n){this.impl&&this.impl.rect(t,e,i,n)},i.roundRect=function(t,e,i,n,r){this.impl&&this.impl.roundRect(t,e,i,n,r)},i.fillRect=function(t,e,i,n){this.rect(t,e,i,n),this.fill()},i.clear=function(){if(this.impl){if(this.impl.clear(),this._isDrawing=!1,this.model)for(var t=0;t<this.model.subModels.length;t++)this.model.subModels[t].inputAssembler.indexCount=0;this.markForUpdateRenderData()}},i.close=function(){this.impl&&this.impl.close()},i.stroke=function(){this._assembler||this._flushAssembler(),this._isDrawing=!0,this._isNeedUploadData=!0,this._assembler.stroke(this)},i.fill=function(){this._assembler||this._flushAssembler(),this._isDrawing=!0,this._isNeedUploadData=!0,this._assembler.fill(this)},i._updateMtlForGraphics=function(){var t;this._customMaterial?t=this.getMaterialInstance(0):(t=nT.get("ui-graphics-material"),this.setSharedMaterial(t,0),(t=this.getMaterialInstance(0)).recompileShaders({USE_LOCAL:!0}))},i.activeSubModel=function(t){if(this.model){if(this.model.subModels.length<=t){var e=Ed.gfxDevice,i=e.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,65535*QU,QU)),n=e.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,131070*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),r=new OR([i],KU,pc.TRIANGLE_LIST,n);r.subMeshIdx=0,this.model.initSubModel(t,r,this.getMaterialInstance(0)),this._graphicsUseSubMeshes.push(r)}}else Y(4500,this.node.name)},i._uploadData=function(){var t=this.impl;if(t){var e=t&&t.getRenderDataList();if(!(e.length<=0)&&this.model){for(var i=this.model.subModels,n=0;n<e.length;n++){var r=e[n],s=i[n].inputAssembler;if(r.lastFilledVertex!==r.vertexStart){var o=new Float32Array(r.vData.buffer,0,r.vertexStart*JU);s.vertexBuffers[0].update(o),s.vertexCount=r.vertexStart;var a=new Uint16Array(r.iData.buffer,0,r.indexStart);s.indexBuffer.update(a),s.indexCount=r.indexStart,r.lastFilledVertex=r.vertexStart,r.lastFilledIndex=r.indexStart}}this._isNeedUploadData=!1}}},i._render=function(t){if(this._isNeedUploadData){if(this.impl){var e=this.impl.getRenderDataList(),i=this.model.subModels.length;if(e.length>i)for(var n=i;n<e.length;n++)this.activeSubModel(n)}this._uploadData()}t.commitModel(this,this.model,this.getMaterialInstance(0))},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t)},i._canRender=function(){return!!t.prototype._canRender.call(this)&&!!this.model&&this._isDrawing},i.updateRenderer=function(){t.prototype.updateRenderer.call(this)},i.createRenderEntity=function(){return new Wk(xk.DYNAMIC)},n(e,[{key:"lineWidth",get:function(){return this._lineWidth},set:function(t){this._lineWidth=t,this.impl&&(this.impl.lineWidth=t)}},{key:"lineJoin",get:function(){return this._lineJoin},set:function(t){this._lineJoin=t,this.impl&&(this.impl.lineJoin=t)}},{key:"lineCap",get:function(){return this._lineCap},set:function(t){this._lineCap=t,this.impl&&(this.impl.lineCap=t)}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(t){this.impl&&(this._strokeColor.set(t),this.impl.strokeColor=this._strokeColor)}},{key:"fillColor",get:function(){return this._fillColor},set:function(t){this.impl&&(this._fillColor.set(t),this.impl.fillColor=this._fillColor)}},{key:"miterLimit",get:function(){return this._miterLimit},set:function(t){this._miterLimit=t}},{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&this._color.set(t)}},{key:"graphicsNativeProxy",get:function(){return this._graphicsNativeProxy}}]),e}(TV)).LineJoin=KG,TU.LineCap=YG,p((fU=TU).prototype,"lineJoin",[cU],Object.getOwnPropertyDescriptor(fU.prototype,"lineJoin"),fU.prototype),p(fU.prototype,"lineCap",[_U],Object.getOwnPropertyDescriptor(fU.prototype,"lineCap"),fU.prototype),p(fU.prototype,"color",[Ro],Object.getOwnPropertyDescriptor(fU.prototype,"color"),fU.prototype),pU=ks(fU.prototype,"_lineWidth",[io],(function(){return 1})),mU=ks(fU.prototype,"_strokeColor",[io],(function(){return dn.BLACK.clone()})),gU=ks(fU.prototype,"_lineJoin",[io],(function(){return KG.MITER})),yU=ks(fU.prototype,"_lineCap",[io],(function(){return YG.BUTT})),vU=ks(fU.prototype,"_fillColor",[io],(function(){return dn.WHITE.clone()})),SU=ks(fU.prototype,"_miterLimit",[io],(function(){return 10})),dU=fU))||dU)||dU));v.Graphics=ZU,function(t){t[t.SIMPLE=0]="SIMPLE",t[t.SLICED=1]="SLICED",t[t.TILED=2]="TILED",t[t.FILLED=3]="FILLED"}(zU||(zU={})),Se(zU),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.RADIAL=2]="RADIAL"}(HU||(HU={})),Se(HU),function(t){t[t.CUSTOM=0]="CUSTOM",t[t.TRIMMED=1]="TRIMMED",t[t.RAW=2]="RAW"}(WU||(WU={})),Se(WU),function(t){t.SPRITE_FRAME_CHANGED="spriteframe-changed"}(jU||(jU={}));var $U,tz,ez,iz,nz,rz,sz,oz,az,hz,uz=t("j",(AU=qs("cc.Sprite"),bU=Ks(110),EU=xo(gF),CU=xo(pF),wU=xo(zU),xU=xo(HU),RU=xo(WU),AU(IU=bU(((UU=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._spriteFrame=DU&&DU(),e._type=PU&&PU(),e._fillType=OU&&OU(),e._sizeMode=MU&&MU(),e._fillCenter=LU&&LU(),e._fillStart=NU&&NU(),e._fillRange=FU&&FU(),e._isTrimmedMode=kU&&kU(),e._useGrayscale=VU&&VU(),e._atlas=GU&&GU(),e}s(e,t);var i=e.prototype;return i.__preload=function(){this.changeMaterialForDefine(),t.prototype.__preload.call(this)},i.onEnable=function(){t.prototype.onEnable.call(this),this._activateMaterial();var e=this._spriteFrame;e&&(this._updateUVs(),this._type===zU.SLICED&&e.on(pF.EVENT_UV_UPDATED,this._updateUVs,this))},i.onDisable=function(){t.prototype.onDisable.call(this),this._spriteFrame&&this._type===zU.SLICED&&this._spriteFrame.off(pF.EVENT_UV_UPDATED,this._updateUVs,this)},i.onDestroy=function(){t.prototype.onDestroy.call(this)},i.changeSpriteFrameFromAtlas=function(t){if(this._atlas){var e=this._atlas.getSpriteFrame(t);this.spriteFrame=e}else console.warn("SpriteAtlas is null.")},i.changeMaterialForDefine=function(){var t,e=this._instanceMaterialType;this._spriteFrame&&(t=this._spriteFrame.texture);var i=!1;if(t instanceof Of){var n=t.getPixelFormat();i=n===af.RGBA_ETC1||n===af.RGB_A_PVRTC_4BPPV1||n===af.RGB_A_PVRTC_2BPPV1}i&&this.grayscale?this._instanceMaterialType=mV.USE_ALPHA_SEPARATED_AND_GRAY:i?this._instanceMaterialType=mV.USE_ALPHA_SEPARATED:this.grayscale?this._instanceMaterialType=mV.GRAYSCALE:this._instanceMaterialType=mV.ADD_COLOR_AND_TEXTURE,e!==this._instanceMaterialType&&this.updateMaterial()},i._updateBuiltinMaterial=function(){var e=t.prototype._updateBuiltinMaterial.call(this);if(this.spriteFrame&&this.spriteFrame.texture instanceof rR){var i=r({SAMPLE_FROM_RT:!0},e.passes[0].defines),n=new xT;n.initialize({effectAsset:e.effectAsset,defines:i}),e=n}return e},i._render=function(t){t.commitComp(this,this.renderData,this._spriteFrame,this._assembler,null)},i._canRender=function(){if(!t.prototype._canRender.call(this))return!1;var e=this._spriteFrame;return!(!e||!e.texture)},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this.destroyRenderData(),this._assembler=t),this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._renderData.material=this.getRenderMaterial(0),this.markForUpdateRenderData(),this.spriteFrame&&this._assembler.updateUVs(this),this._updateColor()),this._spriteFrame&&(this._type===zU.SLICED?this._spriteFrame.on(pF.EVENT_UV_UPDATED,this._updateUVs,this):this._spriteFrame.off(pF.EVENT_UV_UPDATED,this._updateUVs,this))},i._applySpriteSize=function(){if(this._spriteFrame)if(WU.RAW===this._sizeMode){var t=this._spriteFrame.originalSize;this.node._uiProps.uiTransformComp.setContentSize(t)}else if(WU.TRIMMED===this._sizeMode){var e=this._spriteFrame.rect;this.node._uiProps.uiTransformComp.setContentSize(e.width,e.height)}},i._resized=function(){},i._activateMaterial=function(){var t=this._spriteFrame,e=this.getRenderMaterial(0);t&&e&&this.markForUpdateRenderData(),this.renderData&&(this.renderData.material=e)},i._updateUVs=function(){this._assembler&&this._assembler.updateUVs(this)},i._applySpriteFrame=function(t){var e=this._spriteFrame;t&&this._type===zU.SLICED&&t.off(pF.EVENT_UV_UPDATED,this._updateUVs,this);var i=!1;e&&(t&&t.texture===e.texture||(i=!0),i&&(this.renderData&&(this.renderData.textureDirty=!0),this.changeMaterialForDefine()),this._applySpriteSize(),this._type===zU.SLICED&&e.on(pF.EVENT_UV_UPDATED,this._updateUVs,this))},n(e,[{key:"spriteAtlas",get:function(){return this._atlas},set:function(t){this._atlas!==t&&(this._atlas=t)}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){if(this._spriteFrame!==t){var e=this._spriteFrame;this._spriteFrame=t,this.markForUpdateRenderData(),this._applySpriteFrame(e)}}},{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this._flushAssembler())}},{key:"fillType",get:function(){return this._fillType},set:function(t){this._fillType!==t&&(t===HU.RADIAL||this._fillType===HU.RADIAL?this.destroyRenderData():this.renderData&&this.markForUpdateRenderData(!0)),this._fillType=t,this._flushAssembler()}},{key:"fillCenter",get:function(){return this._fillCenter},set:function(t){this._fillCenter.x=t.x,this._fillCenter.y=t.y,this._type===zU.FILLED&&this.renderData&&this.markForUpdateRenderData()}},{key:"fillStart",get:function(){return this._fillStart},set:function(t){this._fillStart=xi(t,0,1),this._type===zU.FILLED&&this.renderData&&(this.markForUpdateRenderData(),this._updateUVs())}},{key:"fillRange",get:function(){return this._fillRange},set:function(t){this._fillRange=xi(t,-1,1),this._type===zU.FILLED&&this.renderData&&(this.markForUpdateRenderData(),this._updateUVs())}},{key:"trim",get:function(){return this._isTrimmedMode},set:function(t){this._isTrimmedMode!==t&&(this._isTrimmedMode=t,this._type===zU.SIMPLE&&this.renderData&&this.markForUpdateRenderData(!0))}},{key:"grayscale",get:function(){return this._useGrayscale},set:function(t){this._useGrayscale!==t&&(this._useGrayscale=t,this.changeMaterialForDefine(),this.updateMaterial())}},{key:"sizeMode",get:function(){return this._sizeMode},set:function(t){this._sizeMode!==t&&(this._sizeMode=t,t!==WU.CUSTOM&&this._applySpriteSize())}}]),e}(TV)).FillType=HU,UU.Type=zU,UU.SizeMode=WU,UU.EventType=jU,p((BU=UU).prototype,"spriteAtlas",[EU],Object.getOwnPropertyDescriptor(BU.prototype,"spriteAtlas"),BU.prototype),p(BU.prototype,"spriteFrame",[CU],Object.getOwnPropertyDescriptor(BU.prototype,"spriteFrame"),BU.prototype),p(BU.prototype,"type",[wU],Object.getOwnPropertyDescriptor(BU.prototype,"type"),BU.prototype),p(BU.prototype,"fillType",[xU],Object.getOwnPropertyDescriptor(BU.prototype,"fillType"),BU.prototype),p(BU.prototype,"sizeMode",[RU],Object.getOwnPropertyDescriptor(BU.prototype,"sizeMode"),BU.prototype),DU=ks(BU.prototype,"_spriteFrame",[io],(function(){return null})),PU=ks(BU.prototype,"_type",[io],(function(){return zU.SIMPLE})),OU=ks(BU.prototype,"_fillType",[io],(function(){return HU.HORIZONTAL})),MU=ks(BU.prototype,"_sizeMode",[io],(function(){return WU.TRIMMED})),LU=ks(BU.prototype,"_fillCenter",[io],(function(){return new Ln(0,0)})),NU=ks(BU.prototype,"_fillStart",[io],(function(){return 0})),FU=ks(BU.prototype,"_fillRange",[io],(function(){return 0})),kU=ks(BU.prototype,"_isTrimmedMode",[io],(function(){return!0})),VU=ks(BU.prototype,"_useGrayscale",[io],(function(){return!1})),GU=ks(BU.prototype,"_atlas",[io],(function(){return null})),IU=BU))||IU)||IU));v.Sprite=uz;var lz,cz=new In,_z=new Ln,dz=new In,fz=[];!function(t){t[t.GRAPHICS_RECT=0]="GRAPHICS_RECT",t[t.GRAPHICS_ELLIPSE=1]="GRAPHICS_ELLIPSE",t[t.GRAPHICS_STENCIL=2]="GRAPHICS_STENCIL",t[t.SPRITE_STENCIL=3]="SPRITE_STENCIL"}(lz||(lz={})),Se(lz);var pz=t("h",($U=qs("cc.Mask"),tz=Ks(110),ez=xo(lz),$U(iz=tz(((hz=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._type=rz&&rz(),e._inverted=sz&&sz(),e._segments=oz&&oz(),e._alphaThreshold=az&&az(),e._sprite=null,e._graphics=null,e._stencilStage=Sk.DISABLED,e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._changeRenderType()},i.onEnable=function(){this._changeRenderType(),this._updateGraphics(),this._enableRender(),this.node.on(om.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.on(om.SIZE_CHANGED,this._nodeStateChange,this)},i.onRestore=function(){this._changeRenderType(),this._updateGraphics()},i.onDisable=function(){this._disableRender(),this.node.off(om.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.off(om.SIZE_CHANGED,this._nodeStateChange,this)},i.onDestroy=function(){this._removeMaskNode()},i.isHit=function(t){var e=this.node._uiProps.uiTransformComp,i=e.contentSize,n=i.width,r=i.height,s=_z;this.node.getWorldMatrix(cz),In.invert(dz,cz),Ln.transformMat4(s,t,dz);var o=e.anchorPoint;s.x+=o.x*n,s.y+=o.y*r;var a=!1;if(this.type===lz.GRAPHICS_RECT||this.type===lz.GRAPHICS_STENCIL||this.type===lz.SPRITE_STENCIL)a=s.x>=0&&s.y>=0&&s.x<=n&&s.y<=r;else if(this.type===lz.GRAPHICS_ELLIPSE){var h=n/2,u=r/2,l=s.x-.5*n,c=s.y-.5*r;a=l*l/(h*h)+c*c/(u*u)<1}return this._inverted&&(a=!a),a},i._nodeStateChange=function(){this._updateGraphics()},i._changeRenderType=function(){this._type!==lz.SPRITE_STENCIL?this._createGraphics():this._createSprite()},i._createSprite=function(){if(!this._sprite){var t=this._sprite=this.node.getComponent(uz);if(!t){var e=this.node;t=this._sprite=e.addComponent(uz)}}this._sprite.stencilStage=this.inverted?Sk.ENTER_LEVEL_INVERTED:Sk.ENTER_LEVEL,this._sprite.updateMaterial()},i._createGraphics=function(){if(!this._graphics){var t=this._graphics=this.node.getComponent(ZU);if(!t){var e=this.node;t=this._graphics=e.addComponent(ZU)}t.lineWidth=1;var i=dn.WHITE.clone();i.a=0,t.fillColor=i}this._graphics.stencilStage=this.inverted?Sk.ENTER_LEVEL_INVERTED:Sk.ENTER_LEVEL},i._updateGraphics=function(){if(this._graphics&&(this._type===lz.GRAPHICS_RECT||this._type===lz.GRAPHICS_ELLIPSE)){var t=this.node._uiProps.uiTransformComp,e=this._graphics;e.clear();var i=t.contentSize,n=i.width,r=i.height,s=t.anchorPoint,o=-n*s.x,a=-r*s.y;if(this._type===lz.GRAPHICS_RECT)e.rect(o,a,n,r);else if(this._type===lz.GRAPHICS_ELLIPSE){for(var h=function(t,e,i){fz.length=0;for(var n=2*Math.PI/i,r=0;r<i;++r)fz.push(new on(e.x*Math.cos(n*r)+t.x,e.y*Math.sin(n*r)+t.y,0));return fz}(new on(o+n/2,a+r/2,0),new on(n/2,r/2,0),this._segments),u=0;u<h.length;++u){var l=h[u];0===u?e.moveTo(l.x,l.y):e.lineTo(l.x,l.y)}e.close()}e.fill()}},i._enableRender=function(){this.subComp&&(this.subComp.enabled=!0)},i._disableRender=function(){this.subComp&&(this.subComp.stencilStage=Sk.DISABLED,this.subComp.updateMaterial(),this.node.activeInHierarchy&&(this.subComp.enabled=!1))},i._removeMaskNode=function(){this._sprite&&(this._sprite=null),this._graphics&&(this._graphics=null)},i.markForUpdateRenderData=function(t){void 0===t&&(t=!0),Y(9007),this.subComp&&this.subComp.markForUpdateRenderData(t)},i.requestRenderData=function(){Y(9007)},i.destroyRenderData=function(){Y(9007)},i.updateRenderer=function(){Y(9007),this.subComp&&this.subComp.updateRenderer()},i.fillBuffers=function(){Y(9007)},i.postUpdateAssembler=function(){Y(9007)},i.setNodeDirty=function(){Y(9007),this.subComp&&this.subComp.setNodeDirty()},i.setTextureDirty=function(){Y(9007),this.subComp&&this.subComp.setTextureDirty()},i.getMaterial=function(t){return Y(9007),this.subComp?this.subComp.getSharedMaterial(t):null},i.setMaterial=function(t,e){Y(9007),this.subComp&&this.subComp.setMaterial(t,e)},i.getMaterialInstance=function(t){return Y(9007),this.subComp?this.subComp.getMaterialInstance(t):null},i.setMaterialInstance=function(t,e){Y(9007),this.subComp&&this.subComp.setMaterialInstance(t,e)},i.getRenderMaterial=function(t){return Y(9007),this.subComp?this.subComp.getRenderMaterial(t):null},n(e,[{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this._type!==lz.SPRITE_STENCIL?(this._sprite&&(this.node.removeComponent(uz),this._sprite._destroyImmediate(),this._sprite=null),this._changeRenderType(),this._updateGraphics()):(this._graphics&&(this._graphics.clear(),this.node.removeComponent(ZU),this._graphics._destroyImmediate(),this._graphics=null),this._changeRenderType()))}},{key:"inverted",get:function(){return this._inverted},set:function(t){this._inverted=t,this.subComp.stencilStage=this.inverted?Sk.ENTER_LEVEL_INVERTED:Sk.ENTER_LEVEL}},{key:"segments",get:function(){return this._segments},set:function(t){this._segments!==t&&(this._segments=xi(t,3,1e4),this._updateGraphics())}},{key:"spriteFrame",get:function(){return this._sprite?this._sprite.spriteFrame:null},set:function(t){this._sprite?this._sprite.spriteFrame=t:V("please change type to sprite_stencil first")}},{key:"alphaThreshold",get:function(){return this._alphaThreshold},set:function(t){this._alphaThreshold!==t&&(this._alphaThreshold=t,this.type===lz.SPRITE_STENCIL&&this._sprite&&this._sprite.getMaterialInstance(0).setProperty("alphaThreshold",this._alphaThreshold))}},{key:"subComp",get:function(){return this._graphics||this._sprite}},{key:"customMaterial",get:function(){return Y(9007),this.subComp?this.subComp.customMaterial:null},set:function(t){Y(9007),this.subComp&&(this.subComp.customMaterial=t)}},{key:"color",get:function(){return Y(9007),this.subComp?this.subComp.color:null},set:function(t){Y(9007),this.subComp&&t&&(this.subComp.color=t)}},{key:"sharedMaterial",get:function(){return Y(9007),this.subComp?this.subComp.sharedMaterial:null}},{key:"sharedMaterials",get:function(){return Y(9007),this.subComp?this.subComp.sharedMaterials:null},set:function(t){Y(9007),this.subComp&&t&&(this.subComp.sharedMaterials=t)}},{key:"material",get:function(){return Y(9007),this.subComp?this.subComp.material:null},set:function(t){Y(9007),this.subComp&&(this.subComp.material=t)}},{key:"materials",get:function(){return Y(9007),this.subComp?this.subComp.materials:[null]},set:function(t){Y(9007),this.subComp&&(this.subComp.materials=t)}}]),e}(rp)).Type=lz,p((nz=hz).prototype,"type",[ez],Object.getOwnPropertyDescriptor(nz.prototype,"type"),nz.prototype),rz=ks(nz.prototype,"_type",[io],(function(){return lz.GRAPHICS_RECT})),sz=ks(nz.prototype,"_inverted",[io],(function(){return!1})),oz=ks(nz.prototype,"_segments",[io],(function(){return 64})),az=ks(nz.prototype,"_alphaThreshold",[io],(function(){return.1})),iz=nz))||iz)||iz));nL._maskComp=pz,v.Mask=pz;var mz,gz,yz,vz,Sz,Tz,Az,bz=/^(click)(\s)*=|(param)(\s)*=/,Ez=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/,Cz=t("z",function(){function t(){this._specialSymbolArray=[],this._stack=[],this._resultObjectArray=[],this._specialSymbolArray.push([/&lt;/g,"<"]),this._specialSymbolArray.push([/&gt;/g,">"]),this._specialSymbolArray.push([/&amp;/g,"&"]),this._specialSymbolArray.push([/&quot;/g,'"']),this._specialSymbolArray.push([/&apos;/g,"'"])}var e=t.prototype;return e.parse=function(t){this._resultObjectArray.length=0,this._stack.length=0;for(var e=0,i=t.length;e<i;){var n=t.indexOf(">",e),r=-1;if(n>=0&&(r=t.lastIndexOf("<",n))<e-1&&(r=t.indexOf("<",n+1),n=t.indexOf(">",r+1)),r<0)this._stack.pop(),this._processResult(t.substring(e)),e=i;else{var s=t.substring(e,r),o=t.substring(r+1,n);""===o&&(s=t.substring(e,n+1)),this._processResult(s),-1===n?n=r:"/"===t.charAt(r+1)?this._stack.pop():this._addToStack(o),e=n+1}}return this._resultObjectArray},e._attributeToObject=function(t){t=t.trim();var e={},i=/^(color|size)(\s)*=/.exec(t),n="",r=0,s="";if(i){if(n=i[0],""===(t=t.substring(n.length).trim()))return e;switch(r=t.indexOf(" "),n[0]){case"c":e.color=r>-1?t.substring(0,r).trim():t;break;case"s":e.size=parseInt(t)}return r>-1&&(s=t.substring(r+1).trim(),e.event=this._processEventHandler(s)),e}if((i=/^(br(\s)*\/)/.exec(t))&&i[0].length>0&&(n=i[0].trim()).startsWith("br")&&"/"===n[n.length-1])return e.isNewLine=!0,this._resultObjectArray.push({text:"",style:{isNewLine:!0}}),e;var o="",a=-1;if((i=/^(img(\s)*src(\s)*=[^>]+\/)/.exec(t))&&i[0].length>0&&(n=i[0].trim()).startsWith("img")&&"/"===n[n.length-1]){var h;i=Ez.exec(t);for(var u=!1;i;){var l=(n=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length)).length;if(n=(n=n.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),o=t.substring(l).trim(),a="src"===n?this.getRightQuotationIndex(o):-1,h=(r=o.indexOf(" ",a+1>=o.length?-1:a+1))>-1?o.substr(0,r):o,t=o.substring(r).trim(),h.endsWith("/")&&(h=h.slice(0,-1)),"src"===n){switch(h.charCodeAt(0)){case 34:case 39:u=!0,h=h.slice(1,-1)}e.isImage=!0,e.src=h}else if("height"===n)e.imageHeight=parseInt(h);else if("width"===n)e.imageWidth=parseInt(h);else if("align"===n){switch(h.charCodeAt(0)){case 34:case 39:h=h.slice(1,-1)}e.imageAlign=h.toLowerCase()}else"offset"===n?e.imageOffset=h:"click"===n&&(e.event=this._processEventHandler(n+"="+h));e.event&&"param"===n&&(e.event[n]=h.replace(/^"|"$/g,"")),i=Ez.exec(t)}return u&&e.isImage&&this._resultObjectArray.push({text:"",style:e}),{}}if(i=/^(outline(\s)*[^>]*)/.exec(t)){var c={color:"#ffffff",width:1};if(t=i[0].substring("outline".length).trim()){var _,d=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(i=d.exec(t);i;)n=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length),_=(r=(o=t.substring(n.length).trim()).indexOf(" "))>-1?o.substr(0,r):o,n=(n=n.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),t=o.substring(r).trim(),"click"===n?e.event=this._processEventHandler(n+"="+_):"color"===n?c.color=_:"width"===n&&(c.width=parseInt(_)),e.event&&"param"===n&&(e.event[n]=_.replace(/^"|"$/g,"")),i=d.exec(t)}e.outline=c}if((i=/^(on|u|b|i)(\s)*/.exec(t))&&i[0].length>0){switch(n=i[0],t=t.substring(n.length).trim(),n[0]){case"u":e.underline=!0;break;case"i":e.italic=!0;break;case"b":e.bold=!0}if(""===t)return e;e.event=this._processEventHandler(t)}return e},e.getRightQuotationIndex=function(t){var e=-1,i=-1,n=t.indexOf("'"),r=t.indexOf('"'),s=r>-1&&(r<n||-1===n);return n>-1&&(n<r||-1===r)?(e=n,i=t.indexOf("'",e+1>=t.length?-1:e+1)):s&&(e=r,i=t.indexOf('"',e+1>=t.length?-1:e+1)),i},e._processEventHandler=function(t){for(var e={},i=0,n=!1,r=bz.exec(t);r;){var s=r[0],o="";if(n=!1,'"'===(t=t.substring(s.length).trim()).charAt(0))(i=t.indexOf('"',1))>-1&&(o=t.substring(1,i).trim(),n=!0),i++;else if("'"===t.charAt(0))(i=t.indexOf("'",1))>-1&&(o=t.substring(1,i).trim(),n=!0),i++;else{var a=/(\S)+/.exec(t);i=(o=a?a[0]:"").length}n&&(e[s=s.substring(0,s.length-1).trim()]=o),t=t.substring(i).trim(),r=bz.exec(t)}return e},e._addToStack=function(t){var e=this._attributeToObject(t);if(0===this._stack.length)this._stack.push(e);else{if(e.isNewLine||e.isImage)return;var i=this._stack[this._stack.length-1];for(var n in i)e[n]||(e[n]=i[n]);this._stack.push(e)}},e._processResult=function(t){0!==t.length&&(t=this._escapeSpecialSymbol(t),this._stack.length>0?this._resultObjectArray.push({text:t,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:t}))},e._escapeSpecialSymbol=function(t){for(var e,i=d(this._specialSymbolArray);!(e=i()).done;){var n=e.value,r=n[0],s=n[1];t=t.replace(r,s)}return t},t}()),wz=t("m",qs("cc.LabelOutline")(mz=Ks(110)(mz=Ys(lG)(mz=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onEnable=function(){this.node.getComponent(lG).enableOutline=!0},i.onDisable=function(){this.node.getComponent(lG).enableOutline=!1},n(e,[{key:"color",get:function(){return this.node.getComponent(lG).outlineColor},set:function(t){this.node.getComponent(lG).outlineColor=t}},{key:"width",get:function(){return this.node.getComponent(lG).outlineWidth},set:function(t){this.node.getComponent(lG).outlineWidth=t}}]),e}(rp))||mz)||mz)||mz);v.LabelOutline=wz,pt({RenderComponent:{newName:"UIRenderer",since:"1.2.0",removed:!0},UITransformComponent:{newName:"UITransform",since:"1.2.0",removed:!1},CanvasComponent:{newName:"Canvas",since:"1.2.0",removed:!1}}),pt({UIRenderable:{newName:"UIRenderer",since:"3.0.0",removed:!0}}),pt({Renderable2D:{newName:"UIRenderer",since:"3.6.0",removed:!1}});var xz,Rz,Iz,Bz,Dz,Pz,Oz,Mz,Lz,Nz,Fz,kz,Vz,Gz,Uz,zz,Hz,Wz,jz,Xz,qz,Yz,Kz,Jz,Qz,Zz,$z,tH,eH,iH,nH,rH,sH,oH,aH,hH,uH=qs("cc.PostProcess")(gz=Js(((Az=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).global=vz&&vz(),e._shadingScale=Sz&&Sz(),e.enableShadingScaleInEditor=Tz&&Tz(),e.settings=new Map,e}s(e,t);var i=e.prototype;return i.addSetting=function(t){this.settings.set(t.constructor,t)},i.removeSetting=function(t){this.settings.delete(t.constructor)},i.getSetting=function(t){return this.settings.get(t)},i.onEnable=function(){e.all.push(this)},i.onDisable=function(){var t=e.all.indexOf(this);-1!==t&&e.all.splice(t,1)},n(e,[{key:"shadingScale",get:function(){return this._shadingScale},set:function(t){this._shadingScale=t}}]),e}(rp)).all=[],vz=ks((yz=Az).prototype,"global",[Qs,io],(function(){return!0})),Sz=ks(yz.prototype,"_shadingScale",[io],(function(){return 1})),p(yz.prototype,"shadingScale",[Qs],Object.getOwnPropertyDescriptor(yz.prototype,"shadingScale"),yz.prototype),Tz=ks(yz.prototype,"enableShadingScaleInEditor",[Qs,io],(function(){return!1})),gz=yz))||gz)||gz,lH=new on,cH=ge(wx),_H=ge(Cx),dH=ge(xx),fH=ge(Ix),pH=ge(Rx),mH=ge({SKYBOX:Ux|Cc.DEPTH_STENCIL,SOLID_COLOR:Cc.ALL,DEPTH_ONLY:Cc.DEPTH_STENCIL,DONT_CLEAR:Cc.NONE}),gH=t("dY",(xz=qs("cc.Camera"),Rz=xo(im.BitMask),Iz=xo(mH),Bz=xo(cH),Dz=xo(_H),Pz=xo(dH),Oz=xo(fH),Mz=xo(pH),Lz=xo(rR),Nz=xo(uH),xz(((aH=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._projection=Vz&&Vz(),e._priority=Gz&&Gz(),e._fov=Uz&&Uz(),e._fovAxis=zz&&zz(),e._orthoHeight=Hz&&Hz(),e._near=Wz&&Wz(),e._far=jz&&jz(),e._color=Xz&&Xz(),e._depth=qz&&qz(),e._stencil=Yz&&Yz(),e._clearFlags=Kz&&Kz(),e._rect=Jz&&Jz(),e._aperture=Qz&&Qz(),e._shutter=Zz&&Zz(),e._iso=$z&&$z(),e._screenScale=tH&&tH(),e._visibility=eH&&eH(),e._targetTexture=iH&&iH(),e._postProcess=nH&&nH(),e._usePostProcess=rH&&rH(),e._camera=null,e._inEditorMode=!1,e._flows=void 0,e._cameraType=sH&&sH(),e._trackingType=oH&&oH(),e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._createCamera()},i.onEnable=function(){this.node.hasChangedFlags|=rm.POSITION,this._camera&&this._attachToScene()},i.onDisable=function(){this._camera&&this._detachFromScene()},i.onDestroy=function(){this._camera&&(this._camera.destroy(),this._camera=null),this._targetTexture&&this._targetTexture.off("resize")},i.screenPointToRay=function(t,e,i){return i||(i=or.create()),this._camera&&this._camera.screenPointToRay(i,t,e),i},i.worldToScreen=function(t,e){return e||(e=new on),this._camera&&this._camera.worldToScreen(e,t),e},i.screenToWorld=function(t,e){return e||(e=this.node.getWorldPosition()),this._camera&&this._camera.screenToWorld(e,t),e},i.convertToUINode=function(t,e,i){if(i||(i=new on),!this._camera)return i;this.worldToScreen(t,lH);var n=e.getComponent("cc.UITransform"),r=v.view.getVisibleSize(),s=lH.x-.5*this._camera.width,o=lH.y-.5*this._camera.height;return lH.x=s/v.view.getScaleX()+.5*r.width,lH.y=o/v.view.getScaleY()+.5*r.height,n&&n.convertToNodeSpaceAR(lH,i),i},i._createCamera=function(){this._camera||(this._camera=v.director.root.createCamera(),this._camera.initialize({name:this.node.name,node:this.node,projection:this._projection,window:this._inEditorMode?v.director.root&&v.director.root.mainWindow:v.director.root&&v.director.root.tempWindow,priority:this._priority,cameraType:this.cameraType,trackingType:this.trackingType}),this._camera.setViewportInOrientedSpace(this._rect),this._camera.fovAxis=this._fovAxis,this._camera.fov=Bi(this._fov),this._camera.orthoHeight=this._orthoHeight,this._camera.nearClip=this._near,this._camera.farClip=this._far,this._camera.clearColor=this._color,this._camera.clearDepth=this._depth,this._camera.clearStencil=this._stencil,this._camera.clearFlag=this._clearFlags,this._camera.visibility=this._visibility,this._camera.aperture=this._aperture,this._camera.shutter=this._shutter,this._camera.iso=this._iso,this._camera.postProcess=this._postProcess,this._camera.usePostProcess=this._usePostProcess),this._updateTargetTexture()},i._attachToScene=function(){this.node.scene&&this._camera&&(this._camera&&this._camera.scene&&this._camera.scene.removeCamera(this._camera),this._getRenderScene().addCamera(this._camera))},i._detachFromScene=function(){this._camera&&this._camera.scene&&this._camera.scene.removeCamera(this._camera)},i._checkTargetTextureEvent=function(t){var e=this;t&&t.off("resize"),this._targetTexture&&this._targetTexture.on("resize",(function(t){e._camera&&e._camera.setFixedSize(t.width,t.height)}),this)},i._updateTargetTexture=function(){if(this._camera&&this._targetTexture){var t=this._targetTexture.window;this._camera.changeTargetWindow(t),this._camera.setFixedSize(t.width,t.height)}},n(e,[{key:"camera",get:function(){return this._camera}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t,this._camera&&(this._camera.priority=t)}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t,this._camera&&(this._camera.visibility=t)}},{key:"clearFlags",get:function(){return this._clearFlags},set:function(t){this._clearFlags=t,this._camera&&(this._camera.clearFlag=t)}},{key:"clearColor",get:function(){return this._color},set:function(t){this._color.set(t),this._camera&&(this._camera.clearColor=this._color)}},{key:"clearDepth",get:function(){return this._depth},set:function(t){this._depth=t,this._camera&&(this._camera.clearDepth=t)}},{key:"clearStencil",get:function(){return this._stencil},set:function(t){this._stencil=t,this._camera&&(this._camera.clearStencil=t)}},{key:"projection",get:function(){return this._projection},set:function(t){this._projection=t,this._camera&&(this._camera.projectionType=t)}},{key:"fovAxis",get:function(){return this._fovAxis},set:function(t){t!==this._fovAxis&&(this._fovAxis=t,this._camera&&(this._camera.fovAxis=t,t===Cx.VERTICAL?this.fov=this._fov*this._camera.aspect:this.fov=this._fov/this._camera.aspect))}},{key:"fov",get:function(){return this._fov},set:function(t){this._fov=t,this._camera&&(this._camera.fov=Bi(t))}},{key:"orthoHeight",get:function(){return this._orthoHeight},set:function(t){this._orthoHeight=t,this._camera&&(this._camera.orthoHeight=t)}},{key:"near",get:function(){return this._near},set:function(t){this._near=t,this._camera&&(this._camera.nearClip=t)}},{key:"far",get:function(){return this._far},set:function(t){this._far=t,this._camera&&(this._camera.farClip=t)}},{key:"aperture",get:function(){return this._aperture},set:function(t){this._aperture=t,this._camera&&(this._camera.aperture=t)}},{key:"shutter",get:function(){return this._shutter},set:function(t){this._shutter=t,this._camera&&(this._camera.shutter=t)}},{key:"iso",get:function(){return this._iso},set:function(t){this._iso=t,this._camera&&(this._camera.iso=t)}},{key:"rect",get:function(){return this._rect},set:function(t){this._rect=t,this._camera&&this._camera.setViewportInOrientedSpace(t)}},{key:"targetTexture",get:function(){return this._targetTexture},set:function(t){if(this._targetTexture!==t){var i=this._targetTexture;this._targetTexture=t,this._checkTargetTextureEvent(i),this._updateTargetTexture(),!t&&this._camera&&(this._camera.changeTargetWindow(null),this._camera.isWindowSize=!0),this.node.emit(e.TARGET_TEXTURE_CHANGE,this)}}},{key:"usePostProcess",get:function(){return this._usePostProcess},set:function(t){this._usePostProcess=t,this._camera&&(this._camera.usePostProcess=t)}},{key:"postProcess",get:function(){return this._postProcess},set:function(t){this._postProcess=t,this._camera&&(this._camera.postProcess=t)}},{key:"screenScale",get:function(){return this._screenScale},set:function(t){this._screenScale=t,this._camera&&(this._camera.screenScale=t)}},{key:"inEditorMode",get:function(){return this._inEditorMode},set:function(t){this._inEditorMode=t,this._camera&&this._camera.changeTargetWindow(t?v.director.root&&v.director.root.mainWindow:v.director.root&&v.director.root.tempWindow)}},{key:"cameraType",get:function(){return this._cameraType},set:function(t){this._cameraType!==t&&(this._cameraType=t,this.camera&&(this.camera.cameraType=t))}},{key:"trackingType",get:function(){return this._trackingType},set:function(t){this._trackingType!==t&&(this._trackingType=t,this.camera&&(this.camera.trackingType=t))}}]),e}(rp)).ProjectionType=cH,aH.FOVAxis=_H,aH.ClearFlag=mH,aH.Aperture=dH,aH.Shutter=fH,aH.ISO=pH,aH.TARGET_TEXTURE_CHANGE="tex-change",Vz=ks((kz=aH).prototype,"_projection",[io],(function(){return cH.PERSPECTIVE})),Gz=ks(kz.prototype,"_priority",[io],(function(){return 0})),Uz=ks(kz.prototype,"_fov",[io],(function(){return 45})),zz=ks(kz.prototype,"_fovAxis",[io],(function(){return _H.VERTICAL})),Hz=ks(kz.prototype,"_orthoHeight",[io],(function(){return 10})),Wz=ks(kz.prototype,"_near",[io],(function(){return 1})),jz=ks(kz.prototype,"_far",[io],(function(){return 1e3})),Xz=ks(kz.prototype,"_color",[io],(function(){return new dn("#333333")})),qz=ks(kz.prototype,"_depth",[io],(function(){return 1})),Yz=ks(kz.prototype,"_stencil",[io],(function(){return 0})),Kz=ks(kz.prototype,"_clearFlags",[io],(function(){return mH.SOLID_COLOR})),Jz=ks(kz.prototype,"_rect",[io],(function(){return new Un(0,0,1,1)})),Qz=ks(kz.prototype,"_aperture",[io],(function(){return dH.F16_0})),Zz=ks(kz.prototype,"_shutter",[io],(function(){return fH.D125})),$z=ks(kz.prototype,"_iso",[io],(function(){return pH.ISO100})),tH=ks(kz.prototype,"_screenScale",[io],(function(){return 1})),eH=ks(kz.prototype,"_visibility",[io],(function(){return Ky})),iH=ks(kz.prototype,"_targetTexture",[io],(function(){return null})),nH=ks(kz.prototype,"_postProcess",[io],(function(){return null})),rH=ks(kz.prototype,"_usePostProcess",[io],(function(){return!1})),sH=ks(kz.prototype,"_cameraType",[io],(function(){return Bx.DEFAULT})),oH=ks(kz.prototype,"_trackingType",[io],(function(){return Dx.NO_TRACKING})),p(kz.prototype,"visibility",[Rz],Object.getOwnPropertyDescriptor(kz.prototype,"visibility"),kz.prototype),p(kz.prototype,"clearFlags",[Iz],Object.getOwnPropertyDescriptor(kz.prototype,"clearFlags"),kz.prototype),p(kz.prototype,"projection",[Bz],Object.getOwnPropertyDescriptor(kz.prototype,"projection"),kz.prototype),p(kz.prototype,"fovAxis",[Dz],Object.getOwnPropertyDescriptor(kz.prototype,"fovAxis"),kz.prototype),p(kz.prototype,"aperture",[Pz],Object.getOwnPropertyDescriptor(kz.prototype,"aperture"),kz.prototype),p(kz.prototype,"shutter",[Oz],Object.getOwnPropertyDescriptor(kz.prototype,"shutter"),kz.prototype),p(kz.prototype,"iso",[Mz],Object.getOwnPropertyDescriptor(kz.prototype,"iso"),kz.prototype),p(kz.prototype,"targetTexture",[Lz],Object.getOwnPropertyDescriptor(kz.prototype,"targetTexture"),kz.prototype),p(kz.prototype,"usePostProcess",[Qs],Object.getOwnPropertyDescriptor(kz.prototype,"usePostProcess"),kz.prototype),p(kz.prototype,"postProcess",[Nz],Object.getOwnPropertyDescriptor(kz.prototype,"postProcess"),kz.prototype),Fz=kz))||Fz));v.Camera=gH;var yH=new Vn,vH=((hH={})[Ce.ORIENTATION_AUTO]=Sl.AUTO,hH[Ce.ORIENTATION_LANDSCAPE]=Sl.LANDSCAPE,hH[Ce.ORIENTATION_PORTRAIT]=Sl.PORTRAIT,hH),SH=t("gg",function(t){function e(){var e;(e=t.call(this)||this)._designResolutionSize=void 0,e._scaleX=void 0,e._scaleY=void 0,e._viewportRect=void 0,e._visibleRect=void 0,e._autoFullScreen=void 0,e._retinaEnabled=void 0,e._resizeCallback=void 0,e._resolutionPolicy=void 0,e._rpExactFit=void 0,e._rpShowAll=void 0,e._rpNoBorder=void 0,e._rpFixedHeight=void 0,e._rpFixedWidth=void 0;var i=TH,n=AH;return e._designResolutionSize=new Vn(0,0),e._scaleX=1,e._scaleY=1,e._viewportRect=new Un(0,0,0,0),e._visibleRect=new Un(0,0,0,0),e._autoFullScreen=!1,e._retinaEnabled=!1,e._resizeCallback=null,e._rpExactFit=new bH(i.EQUAL_TO_FRAME,n.EXACT_FIT),e._rpShowAll=new bH(i.EQUAL_TO_FRAME,n.SHOW_ALL),e._rpNoBorder=new bH(i.EQUAL_TO_FRAME,n.NO_BORDER),e._rpFixedHeight=new bH(i.EQUAL_TO_FRAME,n.FIXED_HEIGHT),e._rpFixedWidth=new bH(i.EQUAL_TO_FRAME,n.FIXED_WIDTH),e._resolutionPolicy=e._rpShowAll,e}s(e,t);var i=e.prototype;return i.init=function(){var t=wl.windowSize,e=t.width,i=t.height;this._designResolutionSize.width=e,this._designResolutionSize.height=i,this._viewportRect.width=e,this._viewportRect.height=i,this._visibleRect.width=e,this._visibleRect.height=i,yH.width=this._visibleRect.width,yH.height=this._visibleRect.height,Rl&&Rl.init(this._visibleRect),this.resizeWithBrowserSize(!0);var n=Ee.querySettings(be.Category.SCREEN,"designResolution");n&&this.setDesignResolutionSize(Number(n.width),Number(n.height),n.policy||bH.FIXED_HEIGHT),wl.on("window-resize",this._updateAdaptResult,this),wl.on("orientation-change",this._updateAdaptResult,this),wl.on("fullscreen-change",this._updateAdaptResult,this)},i.resizeWithBrowserSize=function(t){El.handleResizeEvent=t},i.setResizeCallback=function(t){"function"!=typeof t&&null!=t||(this._resizeCallback=t)},i.setOrientation=function(t){El.orientation=vH[t]},i.adjustViewportMeta=function(){},i.enableRetina=function(t){this._retinaEnabled=!!t},i.isRetinaEnabled=function(){return this._retinaEnabled},i.enableAutoFullScreen=function(t){t!==this._autoFullScreen&&(this._autoFullScreen=t,t&&wl.requestFullScreen().catch((function(){})))},i.isAutoFullScreenEnabled=function(){return this._autoFullScreen},i.setCanvasSize=function(t,e){El.resolutionScale=1;var i=El.devicePixelRatio,n=new Vn(t*i,e*i);wl.windowSize=n},i.getCanvasSize=function(){return wl.windowSize},i.getFrameSize=function(){var t=El.devicePixelRatio,e=wl.windowSize;return e.width/=t,e.height/=t,e},i.setFrameSize=function(t,e){var i=El.devicePixelRatio;wl.windowSize=new Vn(t*i,e*i)},i.getVisibleSize=function(){return new Vn(this._visibleRect.width,this._visibleRect.height)},i.getVisibleSizeInPixel=function(){return new Vn(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},i.getVisibleOrigin=function(){return new Ln(this._visibleRect.x,this._visibleRect.y)},i.getVisibleOriginInPixel=function(){return new Ln(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},i.getResolutionPolicy=function(){return this._resolutionPolicy},i._updateResolutionPolicy=function(t){if(t instanceof bH)this._resolutionPolicy=t;else{var e=bH;t===e.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit),t===e.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll),t===e.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder),t===e.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight),t===e.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},i.setResolutionPolicy=function(t){this._updateResolutionPolicy(t);var e=CH.getDesignResolutionSize();CH.setDesignResolutionSize(e.width,e.height,t)},i.setDesignResolutionSize=function(t,e,i){if(t>0&&e>0){this._updateResolutionPolicy(i);var n=this._resolutionPolicy;n&&n.preApply(this),this._designResolutionSize.width=t,this._designResolutionSize.height=e;var r=n.apply(this,this._designResolutionSize);if(r.scale&&2===r.scale.length&&(this._scaleX=r.scale[0],this._scaleY=r.scale[1]),r.viewport){var s=this._viewportRect,o=this._visibleRect,a=r.viewport;s.x=a.x,s.y=a.y,s.width=a.width,s.height=a.height,o.x=0,o.y=0,o.width=a.width/this._scaleX,o.height=a.height/this._scaleY}n.postApply(this),yH.width=this._visibleRect.width,yH.height=this._visibleRect.height,Rl&&Rl.init(this._visibleRect),this.emit("design-resolution-changed")}else J(2200)},i.getDesignResolutionSize=function(){return new Vn(this._designResolutionSize.width,this._designResolutionSize.height)},i.setRealPixelResolution=function(t,e,i){document.documentElement.style.width=t+"px",document.body.style.width=t+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(t,e,i)},i.getViewportRect=function(){return this._viewportRect},i.getScaleX=function(){return this._scaleX},i.getScaleY=function(){return this._scaleY},i.getDevicePixelRatio=function(){return El.devicePixelRatio},i.convertToLocationInView=function(t,e,i,n){void 0===n&&(n=new Ln);var r=El.devicePixelRatio*(t-i.left),s=El.devicePixelRatio*(i.top+i.height-e);return El.isFrameRotated?(n.x=wl.windowSize.width-s,n.y=r):(n.x=r,n.y=s),n},i._convertToUISpace=function(t){var e=this._viewportRect;t.x=(t.x-e.x)/this._scaleX,t.y=(t.y-e.y)/this._scaleY},i._updateAdaptResult=function(t,e,i){var n;v.director.root.resize(t,e,void 0===i||0===i?1:i);var r=this._designResolutionSize.width,s=this._designResolutionSize.height;t>0&&this.setDesignResolutionSize(r,s,this._resolutionPolicy),this.emit("canvas-resize"),null===(n=this._resizeCallback)||void 0===n||n.call(this)},e}(Yu(Ou)));SH.instance=void 0;var TH=function(){function t(){this.name="ContainerStrategy"}var e=t.prototype;return e.preApply=function(){},e.apply=function(){},e.postApply=function(){},e._setupCanvas=function(){var t=v.game.canvas;if(t){var e=wl.windowSize;t.width!==e.width&&(t.width=e.width),t.height!==e.height&&(t.height=e.height)}},t}();TH.EQUAL_TO_FRAME=void 0,TH.PROPORTION_TO_FRAME=void 0;var AH=function(){function t(){this.name="ContentStrategy",this._result=void 0,this._result={scale:[1,1],viewport:null}}var e=t.prototype;return e.preApply=function(){},e.apply=function(){return{scale:[1,1]}},e.postApply=function(){},e._buildResult=function(t,e,i,n,r,s){Math.abs(t-i)<2&&(i=t),Math.abs(e-n)<2&&(n=e);var o=new Un(Math.round((t-i)/2),Math.round((e-n)/2),i,n);return this._result.scale=[r,s],this._result.viewport=o,this._result},t}();AH.EXACT_FIT=void 0,AH.SHOW_ALL=void 0,AH.NO_BORDER=void 0,AH.FIXED_HEIGHT=void 0,AH.FIXED_WIDTH=void 0,function(){var t=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="EqualToFrame",e}return s(e,t),e.prototype.apply=function(){El.isProportionalToFrame=!1,this._setupCanvas()},e}(TH),e=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="ProportionalToFrame",e}return s(e,t),e.prototype.apply=function(){El.isProportionalToFrame=!0,this._setupCanvas()},e}(TH);TH.EQUAL_TO_FRAME=new t,TH.PROPORTION_TO_FRAME=new e;var i=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="ExactFit",e}return s(e,t),e.prototype.apply=function(t,e){var i=wl.windowSize,n=i.width,r=i.height,s=n/e.width,o=r/e.height;return this._buildResult(n,r,n,r,s,o)},e}(AH),n=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="ShowAll",e}return s(e,t),e.prototype.apply=function(t,e){var i,n,r=wl.windowSize,s=r.width,o=r.height,a=e.width,h=e.height,u=s/a,l=o/h,c=0;return u<l?(i=s,n=h*(c=u)):(i=a*(c=l),n=o),this._buildResult(s,o,i,n,c,c)},e}(AH),r=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="NoBorder",e}return s(e,t),e.prototype.apply=function(t,e){var i,n,r,s=wl.windowSize,o=s.width,a=s.height,h=e.width,u=e.height,l=o/h,c=a/u;return l<c?(n=h*(i=c),r=a):(n=o,r=u*(i=l)),this._buildResult(o,a,n,r,i,i)},e}(AH),o=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="FixedHeight",e}return s(e,t),e.prototype.apply=function(t,e){var i=wl.windowSize,n=i.width,r=i.height,s=r/e.height,o=n,a=r;return this._buildResult(n,r,o,a,s,s)},e}(AH),a=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).name="FixedWidth",e}return s(e,t),e.prototype.apply=function(t,e){var i=wl.windowSize,n=i.width,r=i.height,s=n/e.width,o=n,a=r;return this._buildResult(n,r,o,a,s,s)},e}(AH);AH.EXACT_FIT=new i,AH.SHOW_ALL=new n,AH.NO_BORDER=new r,AH.FIXED_HEIGHT=new o,AH.FIXED_WIDTH=new a}();var bH=t("gh",function(){function t(t,e){this.name="ResolutionPolicy",this._containerStrategy=void 0,this._contentStrategy=void 0,this._containerStrategy=null,this._contentStrategy=null,this.setContainerStrategy(t),this.setContentStrategy(e)}var e=t.prototype;return e.preApply=function(t){this._contentStrategy.preApply(t)},e.apply=function(t,e){return this._containerStrategy.apply(t,e),this._contentStrategy.apply(t,e)},e.postApply=function(t){this._contentStrategy.postApply(t)},e.setContainerStrategy=function(t){t instanceof TH&&(this._containerStrategy=t)},e.setContentStrategy=function(t){t instanceof AH&&(this._contentStrategy=t)},n(t,[{key:"canvasSize",get:function(){return wl.windowSize}}]),t}());bH.EXACT_FIT=0,bH.NO_BORDER=1,bH.SHOW_ALL=2,bH.FIXED_HEIGHT=3,bH.FIXED_WIDTH=4,bH.UNKNOWN=5,bH.ContainerStrategy=TH,bH.ContentStrategy=AH,v.ResolutionPolicy=bH;var EH,CH=t("gi",SH.instance=v.view=new SH);fN.registerSystem("view",CH,0),v.winSize=yH;var wH,xH,RH,IH,BH,DH,PH,OH,MH,LH=t("R",qs("cc.RenderRoot2D")(EH=Ks(100)(EH=Ys(nV)(EH=Js(EH=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onEnable=function(){v.director.root.batcher2D.addScreen(this)},i.onDisable=function(){v.director.root.batcher2D.removeScreen(this)},i.onDestroy=function(){v.director.root.batcher2D.removeScreen(this)},e}(rp))||EH)||EH)||EH)||EH),NH=new on,FH=ge({OVERLAY:0,INTERSPERSE:1}),kH=t("C",(wH=qs("cc.Canvas"),xH=Ks(100),RH=xo(gH),IH=xo(gH),wH(BH=xH(BH=Js((p((DH=function(t){function e(){var e;return(e=t.call(this)||this)._cameraComponent=PH&&PH(),e._alignCanvasWithScreen=OH&&OH(),e._thisOnCameraResized=void 0,e.fitDesignResolution_EDITOR=void 0,e._pos=new on,e._renderMode=FH.OVERLAY,e._thisOnCameraResized=e._onResizeCamera.bind(c(e)),e}s(e,t);var i=e.prototype;return i.__preload=function(){var t=this.getComponent("cc.Widget");t&&t.updateAlignment(),this._cameraComponent&&(this._cameraComponent._createCamera(),this._cameraComponent.node.on(gH.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)),this._onResizeCamera(),this.node.on(om.TRANSFORM_CHANGED,this._thisOnCameraResized)},i.onEnable=function(){t.prototype.onEnable.call(this),this._cameraComponent&&this._cameraComponent.node.on(gH.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)},i.onDisable=function(){t.prototype.onDisable.call(this),this._cameraComponent&&this._cameraComponent.node.off(gH.TARGET_TEXTURE_CHANGE,this._thisOnCameraResized)},i.onDestroy=function(){t.prototype.onDestroy.call(this),this.node.off(om.TRANSFORM_CHANGED,this._thisOnCameraResized)},i._onResizeCamera=function(){if(this._cameraComponent&&this._alignCanvasWithScreen){if(this._cameraComponent.targetTexture)this._cameraComponent.orthoHeight=Rl.height/2;else{var t=wl.windowSize;this._cameraComponent.orthoHeight=t.height/CH.getScaleY()/2}this.node.getWorldPosition(NH),this._cameraComponent.node.setWorldPosition(NH.x,NH.y,1e3)}},i._getViewPriority=function(){if(this._cameraComponent){var t,e=null===(t=this.cameraComponent)||void 0===t?void 0:t.priority;return this._renderMode===FH.OVERLAY?e|1<<30:e&~(1<<30)}return 0},n(e,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){this._renderMode=t,this._cameraComponent&&(this._cameraComponent.priority=this._getViewPriority())}},{key:"cameraComponent",get:function(){return this._cameraComponent},set:function(t){this._cameraComponent!==t&&(this._cameraComponent=t,this._onResizeCamera())}},{key:"alignCanvasWithScreen",get:function(){return this._alignCanvasWithScreen},set:function(t){this._alignCanvasWithScreen=t,this._onResizeCamera()}}]),e}(LH)).prototype,"cameraComponent",[RH],Object.getOwnPropertyDescriptor(DH.prototype,"cameraComponent"),DH.prototype),PH=ks(DH.prototype,"_cameraComponent",[IH],(function(){return null})),OH=ks(DH.prototype,"_alignCanvasWithScreen",[io],(function(){return!0})),BH=DH))||BH)||BH)||BH));function VH(t,e,i){var n=t.o,r=t.d,s=1/r.x,o=1/r.y,a=1/r.z,h=(e.x-n.x)*s,u=(i.x-n.x)*s,l=(e.y-n.y)*o,c=(i.y-n.y)*o,_=(e.z-n.z)*a,d=(i.z-n.z)*a,f=Math.max(Math.max(Math.min(h,u),Math.min(l,c)),Math.min(_,d)),p=Math.min(Math.min(Math.max(h,u),Math.max(l,c)),Math.max(_,d));return p<0||f>p?0:f>0?f:p}v.Canvas=kH,rt(t("U",qs("cc.UIComponent")(MH=Ys(nV)(MH=Ks(110)(MH=Js(MH=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._lastParent=null,e.stencilStage=Sk.DISABLED,e}s(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){},i.onDisable=function(){},i.onDestroy=function(){this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null)},i.postUpdateAssembler=function(){},i.markForUpdateRenderData=function(){},i.setNodeDirty=function(){},i.setTextureDirty=function(){},e}(rp))||MH)||MH)||MH)||MH).prototype,"UIComponent",[{name:"_visibility"},{name:"setVisibility"}]),nt(kH.prototype,"Canvas.prototype",[{name:"camera",newName:"cameraComponent.camera",customGetter:function(){var t;return null===(t=this._cameraComponent)||void 0===t?void 0:t.camera}},{name:"clearFlag",newName:"cameraComponent.clearFlags",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearFlags:0},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.clearFlags=t)}},{name:"color",newName:"cameraComponent.clearColor",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearColor:dn.BLACK},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.clearColor=t)}},{name:"priority",newName:"cameraComponent.priority",customGetter:function(){return this._cameraComponent?this._cameraComponent.priority:0},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.priority=t)}},{name:"targetTexture",newName:"cameraComponent.targetTexture",customGetter:function(){return this._cameraComponent?this._cameraComponent.targetTexture:null},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.targetTexture=t)}},{name:"visibility",newName:"cameraComponent.visibility",customGetter:function(){return this._cameraComponent?this._cameraComponent.visibility:0}}]),st(nV.prototype,"UITransform.prototype",[{name:"priority",suggest:"Please use setSiblingIndex to change index of the current node in its parent's children array."}]),v.UITransformComponent=nV,Qt(nV,"cc.UITransformComponent"),Qt(TV,"cc.RenderComponent"),v.CanvasComponent=kH,Qt(kH,"cc.CanvasComponent"),v.internal.Renderable2D=TV,Qt(TV,"cc.Renderable2D");var GH,UH,zH,HH,WH,jH,XH,qH=(GH=ds.create(),UH={distance:1/0,doubleSided:!1,mode:lu.ANY},zH=0,HH=function(t,e,i,n,r,s){t===lu.CLOSEST?(zH>e||0===zH)&&(zH=e,s&&(0===s.length?s.push({distance:e,vertexIndex0:i/3,vertexIndex1:n/3,vertexIndex2:r/3}):(s[0].distance=e,s[0].vertexIndex0=i/3,s[0].vertexIndex1=n/3,s[0].vertexIndex2=r/3))):(zH=e,s&&s.push({distance:e,vertexIndex0:i/3,vertexIndex1:n/3,vertexIndex2:r/3}))},function(t,e,i){if(zH=0,0===e.geometricInfo.positions.length)return zH;var n=void 0===i?UH:i;if(VH(t,e.geometricInfo.boundingBox.min,e.geometricInfo.boundingBox.max)){var r=e.primitiveMode,s=e.geometricInfo;!function(t,e,i,n,r){if(i===pc.TRIANGLE_LIST)for(var s=e.length,o=0;o<s;o+=3){var a=3*e[o],h=3*e[o+1],u=3*e[o+2];on.set(GH.a,t[a],t[a+1],t[a+2]),on.set(GH.b,t[h],t[h+1],t[h+2]),on.set(GH.c,t[u],t[u+1],t[u+2]);var l=as.rayTriangle(n,GH,r.doubleSided);if(!(0===l||l>r.distance)&&(HH(r.mode,l,a,h,u,r.result),r.mode===lu.ANY))return l}else if(i===pc.TRIANGLE_STRIP)for(var c=e.length-2,_=0,d=0;d<c;d+=1){var f=3*e[d-_],p=3*e[d+_+1],m=3*e[d+2];on.set(GH.a,t[f],t[f+1],t[f+2]),on.set(GH.b,t[p],t[p+1],t[p+2]),on.set(GH.c,t[m],t[m+1],t[m+2]),_=~_;var g=as.rayTriangle(n,GH,r.doubleSided);if(!(0===g||g>r.distance)&&(HH(r.mode,g,f,p,m,r.result),r.mode===lu.ANY))return g}else if(i===pc.TRIANGLE_FAN){var y=e.length-1,v=3*e[0];on.set(GH.a,t[v],t[v+1],t[v+2]);for(var S=1;S<y;S+=1){var T=3*e[S],A=3*e[S+1];on.set(GH.b,t[T],t[T+1],t[T+2]),on.set(GH.c,t[A],t[A+1],t[A+2]);var b=as.rayTriangle(n,GH,r.doubleSided);if(!(0===b||b>r.distance)&&(HH(r.mode,b,v,T,A,r.result),r.mode===lu.ANY))return b}}}(s.positions,s.indices,r,t,n)}return zH}),YH=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:lu.ANY};return function(i,n,r){t=0;var s=void 0===r?e:r,o=n.renderingSubMeshes.length,a=n.struct.minPosition,h=n.struct.maxPosition;if(a&&h&&!VH(i,a,h))return t;for(var u=0;u<o;u++){var l=n.renderingSubMeshes[u],c=qH(i,l,s);if(c)if(s.mode===lu.CLOSEST)(0===t||t>c)&&(t=c,s.subIndices&&(s.subIndices[0]=u));else if(t=c,s.subIndices&&s.subIndices.push(u),s.mode===lu.ANY)return c}return t&&s.mode===lu.CLOSEST&&(s.result&&(s.result[0].distance=t,s.result.length=1),s.subIndices&&(s.subIndices.length=1)),t}}(),KH=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:lu.ANY},i=new or,n=new In;return function(r,s,o){t=0;var a=void 0===o?e:o,h=s.worldBounds;if(h&&!as.rayAABB(r,h))return t;or.copy(i,r),s.node&&(In.invert(n,s.node.getWorldMatrix(n)),on.transformMat4(i.o,r.o,n),on.transformMat4Normal(i.d,r.d,n));for(var u=s.subModels,l=0;l<u.length;l++){var c=u[l].subMesh,_=qH(i,c,a);if(_)if(a.mode===lu.CLOSEST)(0===t||t>_)&&(t=_,a.subIndices&&(a.subIndices[0]=l));else if(t=_,a.subIndices&&a.subIndices.push(l),a.mode===lu.ANY)return _}return t&&a.mode===lu.CLOSEST&&(a.result&&(a.result[0].distance=t,a.result.length=1),a.subIndices&&(a.subIndices.length=1)),t}}();as.rayModel=KH,as.raySubMesh=qH,as.rayMesh=YH,rT("specular-pass");var JH,QH,ZH,$H,tW,eW,iW,nW,rW,sW,oW,aW,hW,uW,lW,cW,_W,dW=t("dZ",qs("cc.ModelRenderer")((jH=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._visFlags=XH&&XH(),e._models=[],e._priority=0,e}s(e,t);var i=e.prototype;return i._collectModels=function(){return this._models},i.onEnable=function(){this._updatePriority()},i._attachToScene=function(){},i._detachFromScene=function(){},i._onVisibilityChange=function(){},i._updatePriority=function(){if(this._models.length>0)for(var t=0;t<this._models.length;t++)this._models[t].priority=this._priority},n(e,[{key:"visibility",get:function(){return this._visFlags},set:function(t){this._visFlags=t,this._onVisibilityChange(t)}},{key:"priority",get:function(){return this._priority},set:function(t){t!==this._priority&&(this._priority=t,this._updatePriority())}}]),e}(SV),XH=ks(jH.prototype,"_visFlags",[io],(function(){return im.Enum.NONE})),WH=jH))||WH),fW=io,pW=xo;t("e0",(JH=qs("cc.PrefabLink"),QH=pW(iN),JH(($H=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).prefab=tW&&tW(),e}return s(e,t),e}(rp),tW=ks($H.prototype,"prefab",[QH,fW],(function(){return null})),ZH=$H))||ZH)),nt(gH,"Camera",[{name:"CameraClearFlag",newName:"ClearFlag"}]),nt(gH.prototype,"Camera.prototype",[{name:"color",newName:"clearColor"},{name:"depth",newName:"clearDepth"},{name:"stencil",newName:"clearStencil"}]),st(SV.prototype,"Renderer.prototype",[{name:"getMaterial",suggest:"please use renderer.getSharedMaterial instead."}]),v.CameraComponent=gH,Qt(gH,"cc.CameraComponent"),v.RenderableComponent=dW,Qt(dW,"cc.RenderableComponent"),function(t){t[t.SIMPLE=0]="SIMPLE",t[t.SLICED=1]="SLICED",t[t.TILED=2]="TILED"}(_W||(_W={})),t("f",(eW=qs("cc.SpriteRenderer"),iW=Ks(100),nW=xo(pF),eW(rW=iW((p((sW=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._spriteFrame=oW&&oW(),e._mode=aW&&aW(),e._color=hW&&hW(),e._flipX=uW&&uW(),e._flipY=lW&&lW(),e._size=cW&&cW(),e._model=null,e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._spriteFrame&&(this._spriteFrame.mesh||this._spriteFrame.ensureMeshData(),this._spriteFrame.mesh.initialize()),this._updateModels()},i.onRestore=function(){this._updateModels(),this.enabledInHierarchy&&this._attachToScene()},i.onEnable=function(){t.prototype.onEnable.call(this),this._model||this._updateModels(),this._attachToScene()},i.onDisable=function(){this._model&&this._detachFromScene()},i.onDestroy=function(){this._model&&(v.director.root.destroyModel(this._model),this._model=null,this._models.length=0)},i._updateModels=function(){if(this._spriteFrame){var t=this._model;if(t?(t.destroy(),t.initialize(),t.node=t.transform=this.node):this._createModel(),this._model){var e=this._spriteFrame.mesh;this._model.createBoundingShape(e.struct.minPosition,e.struct.maxPosition),this._updateModelParams(),this._onUpdateLocalDescriptorSet()}}},i._createModel=function(){var t=this._model=v.director.root.createModel(wM);t.visFlags=this.visibility,t.node=t.transform=this.node,this._models.length=0,this._models.push(this._model)},i._updateModelParams=function(){if(this._spriteFrame&&this._model){this._spriteFrame.ensureMeshData();var t=this._spriteFrame.mesh;this.node.hasChangedFlags|=rm.POSITION,this._model.transform.hasChangedFlags|=rm.POSITION;var e=t?t.renderingSubMeshes:null;if(e)for(var i=e.length,n=0;n<i;++n){var r=this.getRenderMaterial(n);r&&!r.isValid&&(r=null);var s=e[n];s&&this._model.initSubModel(n,s,r||this._getBuiltinMaterial())}this._model.enabled=!0}},i._getBuiltinMaterial=function(){return nT.get("missing-material")},i._onMaterialModified=function(e,i){t.prototype._onMaterialModified.call(this,e,i),this._spriteFrame&&this._model&&this._model.inited&&this._onRebuildPSO(e,i||this._getBuiltinMaterial())},i._onRebuildPSO=function(t,e){this._model&&this._model.inited&&(this._model.setSubModelMaterial(t,e),this._onUpdateLocalDescriptorSet())},i._onUpdateLocalDescriptorSet=function(){if(this._spriteFrame&&this._model&&this._model.inited)for(var t=this._spriteFrame.getGFXTexture(),e=this._spriteFrame.getGFXSampler(),i=this._model.subModels,n=Ag.SAMPLER_SPRITE,r=0;r<i.length;r++){var s=i[r].descriptorSet;s.bindTexture(n,t),s.bindSampler(n,e),s.update()}},i._attachToScene=function(){if(this.node.scene&&this._model){var t=this._getRenderScene();null!==this._model.scene&&this._detachFromScene(),t.addModel(this._model)}},i._detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},n(e,[{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._spriteFrame!==t&&(this._spriteFrame,this._spriteFrame=t,this._spriteFrame&&(this._spriteFrame.ensureMeshData(),this._spriteFrame.mesh.initialize()),this._updateModels(),this.enabledInHierarchy&&this._attachToScene())}},{key:"model",get:function(){return this._model}}]),e}(dW)).prototype,"spriteFrame",[nW],Object.getOwnPropertyDescriptor(sW.prototype,"spriteFrame"),sW.prototype),oW=ks(sW.prototype,"_spriteFrame",[io],(function(){return null})),aW=ks(sW.prototype,"_mode",[io],(function(){return _W.SIMPLE})),hW=ks(sW.prototype,"_color",[io],(function(){return dn.WHITE.clone()})),uW=ks(sW.prototype,"_flipX",[io],(function(){return!1})),lW=ks(sW.prototype,"_flipY",[io],(function(){return!1})),cW=ks(sW.prototype,"_size",[io],(function(){return new Ln})),rW=sW))||rW)||rW));var mW,gW,yW,vW,SW,TW,AW,bW,EW,CW,wW,xW,RW,IW,BW,DW,PW,OW,MW,LW,NW,FW,kW,VW,GW,UW=new Cz,zW="RICHTEXT_CHILD",HW="RICHTEXT_Image_CHILD",WW=new Ln,jW=new Ln,XW=new re((function(t){if(!v.isValid(t.node))return!1;var e=t.node.getComponent(wz);return e&&(e.width=0),!0}),20),qW=new re((function(t){return v.isValid(t.node)}),10);function YW(t){return{node:new Jm(t),comp:null,lineCount:0,styleIndex:0,imageOffset:"",clickParam:"",clickHandler:"",type:t}}function KW(t,e){var i;t===zW?i=XW._get():t===HW&&(i=qW._get());var n=(i=i||YW(t)).node;return n||(n=new Jm(t)),n.hideFlags|=Ho.Flags.DontSave|Ho.Flags.HideInHierarchy,n.active=!0,t===HW?(i.comp=n.getComponent(uz)||n.addComponent(uz),i.comp.spriteFrame=e,i.comp.type=uz.Type.SLICED,i.comp.sizeMode=uz.SizeMode.CUSTOM):(i.comp=n.getComponent(lG)||n.addComponent(lG),i.comp.string=e,i.comp.horizontalAlign=iG.LEFT,i.comp.verticalAlign=nG.TOP,i.comp.underlineHeight=2),n.setPosition(0,0,0),n._uiProps.uiTransformComp.setAnchorPoint(.5,.5),i.node=n,i.lineCount=0,i.styleIndex=0,i.imageOffset="",i.clickParam="",i.clickHandler="",i}var JW,QW=t("i",(mW=qs("cc.RichText"),gW=Ks(110),yW=xo(iG),vW=xo(nG),SW=xo(dn),TW=xo(TF),AW=xo(sG),bW=xo(gF),mW(EW=gW(((GW=function(t){function e(){var e;return(e=t.call(this)||this)._lineHeight=wW&&wW(),e._string=xW&&xW(),e._horizontalAlign=RW&&RW(),e._verticalAlign=IW&&IW(),e._fontSize=BW&&BW(),e._fontColor=DW&&DW(),e._maxWidth=PW&&PW(),e._fontFamily=OW&&OW(),e._font=MW&&MW(),e._isSystemFontUsed=LW&&LW(),e._userDefinedFont=NW&&NW(),e._cacheMode=FW&&FW(),e._imageAtlas=kW&&kW(),e._handleTouchEvent=VW&&VW(),e._textArray=[],e._segments=[],e._labelSegmentsCache=[],e._linesWidth=[],e._lineCount=1,e._labelWidth=0,e._labelHeight=0,e._layoutDirty=!0,e._lineOffsetX=0,e._updateRichTextStatus=void 0,e._labelChildrenNum=0,e._updateRichTextStatus=e._updateRichText,e}s(e,t);var i=e.prototype;return i.onLoad=function(){this.node.on(om.LAYER_CHANGED,this._applyLayer,this),this.node.on(om.ANCHOR_CHANGED,this._updateRichTextPosition,this)},i.onEnable=function(){this.handleTouchEvent&&this._addEventListeners(),this._updateRichText(),this._activateChildren(!0)},i.onDisable=function(){this.handleTouchEvent&&this._removeEventListeners(),this._activateChildren(!1)},i.onRestore=function(){},i.onDestroy=function(){for(var t,e=d(this._segments);!(t=e()).done;){var i=t.value;i.node.removeFromParent(),i.type===zW?XW.put(i):i.type===HW&&qW.put(i)}this.node.off(om.ANCHOR_CHANGED,this._updateRichTextPosition,this),this.node.off(om.LAYER_CHANGED,this._applyLayer,this)},i._addEventListeners=function(){this.node.on(om.TOUCH_END,this._onTouchEnded,this)},i._removeEventListeners=function(){this.node.off(om.TOUCH_END,this._onTouchEnded,this)},i._updateLabelSegmentTextAttributes=function(){var t=this;this._segments.forEach((function(e){t._applyTextAttribute(e)}))},i._createFontLabel=function(t){return KW(zW,t)},i._createImage=function(t){return KW(HW,t)},i._onTTFLoaded=function(){this._font,this._layoutDirty=!0,this._updateRichText()},i.splitLongStringApproximatelyIn2048=function(t,e){var i=[];if(t.length*this.fontSize<=1638.4)return i.push(t),i;if(this._calculateSize(WW,e,t),WW.x<2048)i.push(t);else for(var n=t.split("\n"),r=0;r<n.length;r++)if(this._calculateSize(WW,e,n[r]),WW.x<2048)i.push(n[r]);else{var s=this.splitLongStringOver2048(n[r],e);i.push.apply(i,s)}return i},i.splitLongStringOver2048=function(t,e){var i=[],n=t,r=0,s=n.length/2,o=n.substring(r,s),a=n.substring(s),h=this._calculateSize(WW,e,o),u=this._calculateSize(jW,e,a),l=this._maxWidth;0===this._maxWidth&&(l=2047.9);for(var c=1*l;h.x>c;){if((s/=2)<1){s*=2;break}o=o.substring(r,s),a=n.substring(s),this._calculateSize(h,e,o)}for(var _=1e3,d=1;_&&r<t.length;){for(;_&&h.x<c;){var f=JF(a);f&&f.length>0&&(d=f[0].length),s+=d,o=n.substring(r,s),a=n.substring(s),this._calculateSize(h,e,o),_--}for(;_&&o.length>=2&&h.x>c;)s-=d,o=n.substring(r,s),this._calculateSize(h,e,o),d=1,_--;if(o.length>=2){var p=QF(o);p&&p.length>0&&o!==p[0]&&(s-=p[0].length,o=n.substring(r,s))}if(i.push(o),r=s,s+=o.length,o=n.substring(r,s),a=n.substring(s),this._calculateSize(u,e,a),this._calculateSize(h,e,o),_--,u.x<2048&&h.x<c){i.push(o),r=t.length,s=t.length,o=a,""!==a&&i.push(o);break}}return i},i._measureText=function(t,e){var i=this,n=function(e){return i._calculateSize(WW,t,e).x};return e?n(e):n},i._calculateSize=function(t,e,i){var n;0===this._labelSegmentsCache.length?(n=this._createFontLabel(i),this._labelSegmentsCache.push(n)):(n=this._labelSegmentsCache[0]).node.getComponent(lG).string=i,n.styleIndex=e,this._applyTextAttribute(n);var r=n.node._uiProps.uiTransformComp.contentSize;return Ln.set(t,r.x,r.y),t},i._onTouchEnded=function(t){for(var e,i=this,n=this.node.getComponents(rp),r=function(){var r=e.value,s=r.clickHandler,o=r.clickParam;s&&i._containsTouchLocation(r,t.touch.getUILocation())&&(n.forEach((function(e){var i=e[s];e.enabledInHierarchy&&i&&i.call(e,t,o)})),t.propagationStopped=!0)},s=d(this._segments);!(e=s()).done;)r()},i._containsTouchLocation=function(t,e){var i=t.node.getComponent(nV);return!!i&&i.getBoundingBoxToWorld().contains(e)},i._resetState=function(){for(var t=this.node.children,e=t.length-1;e>=0;e--){var i=t[e];if(i.name===zW||i.name===HW){i.parent=null;var n=YW(i.name);n.node=i,i.name===zW?(n.comp=i.getComponent(lG),XW.put(n)):(n.comp=i.getComponent(uz),qW.put(n)),this._labelChildrenNum--}}this._segments.length=0,this._labelSegmentsCache.length=0,this._linesWidth.length=0,this._lineOffsetX=0,this._lineCount=1,this._labelWidth=0,this._labelHeight=0,this._layoutDirty=!0},i._activateChildren=function(t){for(var e=this.node.children.length-1;e>=0;e--){var i=this.node.children[e];i.name!==zW&&i.name!==HW||(i.active=t)}},i._addLabelSegment=function(t,e){var i;if(0===this._labelSegmentsCache.length)i=this._createFontLabel(t);else{var n=(i=this._labelSegmentsCache.pop()).node.getComponent(lG);n&&(n.string=t)}var r=i.comp;return r.verticalAlign!==this._verticalAlign&&(r.verticalAlign=this._verticalAlign),i.styleIndex=e,i.lineCount=this._lineCount,i.node._uiProps.uiTransformComp.setAnchorPoint(0,0),i.node.layer=this.node.layer,this.node.insertChild(i.node,this._labelChildrenNum++),this._applyTextAttribute(i),this._segments.push(i),i},i._updateRichTextWithMaxWidth=function(t,e,i){var n=e;if(this._lineOffsetX>0&&n+this._lineOffsetX>this._maxWidth)for(var r=0;this._lineOffsetX<=this._maxWidth;){var s=this._getFirstWordLen(t,r,t.length),o=t.substr(r,s),a=this._measureText(i,o);if(!(this._lineOffsetX+a<=this._maxWidth)){if(r>0){var h=t.substr(0,r);this._addLabelSegment(h,i),t=t.substr(r,t.length),n=this._measureText(i,t)}this._updateLineInfo();break}this._lineOffsetX+=a,r+=s}if(n>this._maxWidth)for(var u=ZF(t,n,this._maxWidth,this._measureText(i)),l=0;l<u.length;++l){var c=u[l],_=this._addLabelSegment(c,i).node._uiProps.uiTransformComp.contentSize;this._lineOffsetX+=_.width,u.length>1&&l<u.length-1&&this._updateLineInfo()}else this._lineOffsetX+=n,this._addLabelSegment(t,i)},i._isLastComponentCR=function(t){return t.length-1===t.lastIndexOf("\n")},i._updateLineInfo=function(){this._linesWidth.push(this._lineOffsetX),this._lineOffsetX=0,this._lineCount++},i._needsUpdateTextLayout=function(t){if(this._layoutDirty||!this._textArray||!t)return!0;if(this._textArray.length!==t.length)return!0;for(var e=0;e<this._textArray.length;e++){var i=this._textArray[e],n=t[e];if(i.text!==n.text)return!0;var r=i.style,s=n.style;if(r){if(s){if(!!s.outline!=!!r.outline)return!0;if(r.size!==s.size||r.italic!==s.italic||r.isImage!==s.isImage)return!0;if(r.src!==s.src||r.imageAlign!==s.imageAlign||r.imageHeight!==s.imageHeight||r.imageWidth!==s.imageWidth||r.imageOffset!==s.imageOffset)return!0}else if(r.size||r.italic||r.isImage||r.outline)return!0}else if(s&&(s.size||s.italic||s.isImage||s.outline))return!0}return!1},i._addRichTextImageElement=function(t){if(t.style){var e=t.style,i=e.src,n=this._imageAtlas&&i&&this._imageAtlas.getSpriteFrame(i);if(n){var r=this._createImage(n);switch(r.comp,e.imageAlign){case"top":r.node._uiProps.uiTransformComp.setAnchorPoint(0,1);break;case"center":r.node._uiProps.uiTransformComp.setAnchorPoint(0,.5);break;default:r.node._uiProps.uiTransformComp.setAnchorPoint(0,0)}e.imageOffset&&(r.imageOffset=e.imageOffset),r.node.layer=this.node.layer,this.node.insertChild(r.node,this._labelChildrenNum++),this._segments.push(r);var s=n.rect.clone(),o=1,a=s.width,h=s.height,u=e.imageWidth||0,l=e.imageHeight||0;l>0?(a*=o=l/h,h*=o):(a*=o=this._lineHeight/h,h*=o),u>0&&(a=u),this._maxWidth>0?(this._lineOffsetX+a>this._maxWidth&&this._updateLineInfo(),this._lineOffsetX+=a):(this._lineOffsetX+=a,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),r.node._uiProps.uiTransformComp.setContentSize(a,h),r.lineCount=this._lineCount,r.clickHandler="",r.clickParam="";var c=e.event;c&&(r.clickHandler=c.click,r.clickParam=c.param)}else Y(4400)}},i._updateTextDefaultColor=function(){for(var t=0;t<this._segments.length;++t){var e,i,n=this._segments[t],r=n.node.getComponent(lG);r&&(null!==(e=this._textArray[n.styleIndex])&&void 0!==e&&null!==(i=e.style)&&void 0!==i&&i.color||(r.color=this._fontColor))}},i._updateRichText=function(){if(this.enabledInHierarchy){var t=UW.parse(this._string);if(!this._needsUpdateTextLayout(t))return this._textArray=t.slice(),void this._updateLabelSegmentTextAttributes();this._textArray=t.slice(),this._resetState();for(var e,i=!1,n=0;n<this._textArray.length;++n){var r=this._textArray[n],s=r.text;if(void 0!==s){if(""===s){if(r.style&&r.style.isNewLine){this._updateLineInfo();continue}if(r.style&&r.style.isImage&&this._imageAtlas){this._addRichTextImageElement(r);continue}}for(var o=(s=this.splitLongStringApproximatelyIn2048(s,n).join("\n")).split("\n"),a=0;a<o.length;++a){var h=o[a];if(""!==h)if(i=!1,this._maxWidth>0){var u=this._measureText(n,h);this._updateRichTextWithMaxWidth(h,u,n),o.length>1&&a<o.length-1&&this._updateLineInfo()}else e=this._addLabelSegment(h,n),this._lineOffsetX+=e.node._uiProps.uiTransformComp.width,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX),o.length>1&&a<o.length-1&&this._updateLineInfo();else{if(this._isLastComponentCR(s)&&a===o.length-1)continue;this._updateLineInfo(),i=!0}}}}i||this._linesWidth.push(this._lineOffsetX),this._maxWidth>0&&(this._labelWidth=this._maxWidth),this._labelHeight=(this._lineCount+NF)*this._lineHeight,this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},i._getFirstWordLen=function(t,e,i){var n=t.charAt(e);if(XF(n)||qF(n))return 1;for(var r=1,s=e+1;s<i&&!qF(n=t.charAt(s))&&!XF(n);++s)r++;return r},i._updateRichTextPosition=function(){for(var t=0,e=1,i=this._lineCount,n=this.node._uiProps.uiTransformComp,r=n.anchorX,s=n.anchorY,o=0;o<this._segments.length;++o){var a=this._segments[o],h=a.lineCount;h>e&&(t=0,e=h);var u=this._labelWidth*(.5*this._horizontalAlign-r);switch(this._horizontalAlign){case iG.LEFT:break;case iG.CENTER:u-=this._linesWidth[h-1]/2;break;case iG.RIGHT:u-=this._linesWidth[h-1]}var l=a.node.position;if(a.node.setPosition(t+u,this._lineHeight*(i-h)-this._labelHeight*s,l.z),h===e&&(t+=a.node._uiProps.uiTransformComp.width),a.node.getComponent(uz)){var c=a.node.position.clone(),_=this._lineHeight,d=this._lineHeight*(1+NF);switch(a.node._uiProps.uiTransformComp.anchorY){case 1:c.y+=_+(d-_)/2;break;case.5:c.y+=d/2;break;default:c.y+=(d-_)/2}if(a.imageOffset){var f=a.imageOffset.split(",");if(1===f.length&&f[0]){var p=parseFloat(f[0]);Number.isInteger(p)&&(c.y+=p)}else if(2===f.length){var m=parseFloat(f[0]),g=parseFloat(f[1]);Number.isInteger(m)&&(c.x+=m),Number.isInteger(g)&&(c.y+=g)}}a.node.position=c}var y=a.node.getComponent(wz);if(y){var v=a.node.position.clone();v.y-=y.width,a.node.position=v}}},i._convertLiteralColorValue=function(t){var e=t.toUpperCase();return dn[e]?dn[e]:(new dn).fromHEX(t)},i._applyTextAttribute=function(t){var e=t.node.getComponent(lG);if(e){this._resetLabelState(e);var i,n=t.styleIndex;if(this._textArray[n]&&(i=this._textArray[n].style),i){if(i.color?e.color=this._convertLiteralColorValue(i.color):e.color=this._fontColor,e.isBold=!!i.bold,e.isItalic=!!i.italic,e.isUnderline=!!i.underline,i.outline){var r=t.node.getComponent(wz);r||(r=t.node.addComponent(wz)),r.color=this._convertLiteralColorValue(i.outline.color),r.width=i.outline.width}e.fontSize=i.size||this._fontSize,t.clickHandler="",t.clickParam="";var s=i.event;s&&(t.clickHandler=s.click||"",t.clickParam=s.param||"")}e.cacheMode=this._cacheMode,this._font instanceof TF&&!this._isSystemFontUsed?e.font=this._font:e.fontFamily=this._fontFamily,e.useSystemFont=this._isSystemFontUsed,e.lineHeight=this._lineHeight,e.updateRenderData(!0)}},i._applyLayer=function(){for(var t,e=d(this._segments);!(t=e()).done;)t.value.node.layer=this.node.layer},i._resetLabelState=function(t){t.fontSize=this._fontSize,t.color=this._fontColor,t.isBold=!1,t.isItalic=!1,t.isUnderline=!1},n(e,[{key:"string",get:function(){return this._string},set:function(t){this._string!==t&&(this._string=t,this._updateRichTextStatus())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(t){this.horizontalAlign!==t&&(this._horizontalAlign=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"verticalAlign",get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!==t&&(this._verticalAlign=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontSize",get:function(){return this._fontSize},set:function(t){this._fontSize!==t&&(this._fontSize=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontColor",get:function(){return this._fontColor},set:function(t){this._fontColor!==t&&(this._fontColor=t,this._updateTextDefaultColor())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"font",get:function(){return this._font},set:function(t){this._font!==t&&(this._font=t,this._layoutDirty=!0,this._font?(this.useSystemFont=!1,this._onTTFLoaded()):this.useSystemFont=!0,this._updateRichTextStatus())}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this._isSystemFontUsed=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode!==t&&(this._cacheMode=t,this._updateRichTextStatus())}},{key:"maxWidth",get:function(){return this._maxWidth},set:function(t){this._maxWidth!==t&&(this._maxWidth=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"imageAtlas",get:function(){return this._imageAtlas},set:function(t){this._imageAtlas!==t&&(this._imageAtlas=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"handleTouchEvent",get:function(){return this._handleTouchEvent},set:function(t){this._handleTouchEvent!==t&&(this._handleTouchEvent=t,this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners()))}}]),e}(rp)).HorizontalAlign=iG,GW.VerticalAlign=nG,p((CW=GW).prototype,"horizontalAlign",[yW],Object.getOwnPropertyDescriptor(CW.prototype,"horizontalAlign"),CW.prototype),p(CW.prototype,"verticalAlign",[vW],Object.getOwnPropertyDescriptor(CW.prototype,"verticalAlign"),CW.prototype),p(CW.prototype,"fontColor",[SW],Object.getOwnPropertyDescriptor(CW.prototype,"fontColor"),CW.prototype),p(CW.prototype,"font",[TW],Object.getOwnPropertyDescriptor(CW.prototype,"font"),CW.prototype),p(CW.prototype,"cacheMode",[AW],Object.getOwnPropertyDescriptor(CW.prototype,"cacheMode"),CW.prototype),p(CW.prototype,"imageAtlas",[bW],Object.getOwnPropertyDescriptor(CW.prototype,"imageAtlas"),CW.prototype),wW=ks(CW.prototype,"_lineHeight",[io],(function(){return 40})),xW=ks(CW.prototype,"_string",[io],(function(){return"<color=#00ff00>Rich</color><color=#0fffff>Text</color>"})),RW=ks(CW.prototype,"_horizontalAlign",[io],(function(){return iG.LEFT})),IW=ks(CW.prototype,"_verticalAlign",[io],(function(){return nG.TOP})),BW=ks(CW.prototype,"_fontSize",[io],(function(){return 40})),DW=ks(CW.prototype,"_fontColor",[io],(function(){return dn.WHITE.clone()})),PW=ks(CW.prototype,"_maxWidth",[io],(function(){return 0})),OW=ks(CW.prototype,"_fontFamily",[io],(function(){return"Arial"})),MW=ks(CW.prototype,"_font",[io],(function(){return null})),LW=ks(CW.prototype,"_isSystemFontUsed",[io],(function(){return!0})),NW=ks(CW.prototype,"_userDefinedFont",[io],(function(){return null})),FW=ks(CW.prototype,"_cacheMode",[io],(function(){return sG.NONE})),kW=ks(CW.prototype,"_imageAtlas",[io],(function(){return null})),VW=ks(CW.prototype,"_handleTouchEvent",[io],(function(){return!0})),EW=CW))||EW)||EW));v.RichText=QW;var ZW=t("k",qs("cc.UIMeshRenderer")(JW=Ks(110)(JW=function(t){function e(){var e;return(e=t.call(this)||this)._modelComponent=null,e._dirtyVersion=-1,e._internalId=-1,e.stencilStage=Sk.DISABLED,e._renderData=null,e._renderEntity=new Wk(xk.DYNAMIC),e}s(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){nN.addRenderer(this),this.markForUpdateRenderData()},i.onDisable=function(){nN.removeRenderer(this),this.renderEntity.enabled=this._canRender()},i.onLoad=function(){this.node._uiProps.uiTransformComp||this.node.addComponent("cc.UITransform"),this._modelComponent=this.getComponent("cc.ModelRenderer"),this._modelComponent?this.renderEntity.setNode(this.node):k("node '"+(this.node&&this.node.name)+"' doesn't have any renderable component")},i.onDestroy=function(){this.renderEntity.setNode(null),this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this._modelComponent=this.getComponent("cc.ModelRenderer"),this._modelComponent&&(this._modelComponent._sceneGetter=null)},i._render=function(t){if(this._modelComponent){var e=this._modelComponent._collectModels();this._modelComponent._detachFromScene();for(var i=0;i<e.length;i++)e[i].enabled&&t.commitModel(this,e[i],this._modelComponent.material);return!0}return!1},i.fillBuffers=function(t){this.enabled&&this._render(t)},i.updateRenderer=function(){},i._uploadRenderData=function(){},i.postUpdateAssembler=function(){},i.update=function(){this._fitUIRenderQueue()},i._fitUIRenderQueue=function(){if(this._modelComponent)for(var t=this._modelComponent.sharedMaterials.length,e=0;e<t;e++){var i=this._modelComponent.getMaterialInstance(e);if(null!=i)for(var n=i.passes,r=n.length,s=0;s<r;s++)n[s].setPriority(pg.MAX-11),i.recompileShaders({CC_FORCE_FORWARD_SHADING:!0},s)}},i.markForUpdateRenderData=function(){nN.markDirtyRenderer(this)},i.setNodeDirty=function(){},i.setTextureDirty=function(){},i._canRender=function(){return this.enabled&&null!==this._modelComponent},n(e,[{key:"modelComponent",get:function(){return this._modelComponent}},{key:"renderEntity",get:function(){return this._renderEntity}},{key:"renderData",get:function(){return this._renderData}}]),e}(rp))||JW)||JW);v.UIMeshRenderer=ZW;var $W,tj,ej,ij,nj,rj,sj=im.Enum.NONE|im.Enum.UI_3D,oj=function(){function t(){this.model=null,this.texture=null,this.sampler=null,this.useLocalData=null,this.isStatic=!1,this.textureHash=0,this.samplerHash=0,this._passes=[],this._shaders=[],this._visFlags=sj,this._inputAssembler=null,this._descriptorSet=null}var e=t.prototype;return e.destroy=function(){this._passes=[]},e.clear=function(){this._inputAssembler=null,this._descriptorSet=null,this.texture=null,this.sampler=null,this.textureHash=0,this.samplerHash=0,this.model=null,this.isStatic=!1,this.useLocalData=null,this.visFlags=sj},e.fillPasses=function(t,e,i,n){if(t){var r=t.passes;if(!r)return;this._shaders.length=r.length;for(var s=0;s<r.length;s++){this._passes[s]||(this._passes[s]=new uT(v.director.root));var o=r[s],a=this._passes[s];o.update(),e||(e=o.depthStencilState,i=0),a._initPassFromTarget(o,e,i),this._shaders[s]=a.getShaderVariant(n)}}},n(t,[{key:"inputAssembler",get:function(){return this._inputAssembler},set:function(t){this._inputAssembler=t}},{key:"descriptorSet",get:function(){return this._descriptorSet},set:function(t){this._descriptorSet=t}},{key:"visFlags",get:function(){return this._visFlags},set:function(t){this._visFlags=t}},{key:"passes",get:function(){return this._passes}},{key:"shaders",get:function(){return this._shaders}}]),t}(),aj=t("n",qs("cc.UIStaticBatch")($W=Ks(110)((p((tj=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._init=!1,e._bufferAccessor=null,e._dirty=!0,e._uiDrawBatchList=[],e}s(e,t);var i=e.prototype;return i.postUpdateAssembler=function(){},i.markAsDirty=function(){},i._requireDrawBatch=function(){var t=new oj;return t.isStatic=!0,this._uiDrawBatchList.push(t),t},i._clearData=function(){if(this._bufferAccessor){this._bufferAccessor.reset();for(var t=this._getBatcher(),e=0;e<this._uiDrawBatchList.length;e++)this._uiDrawBatchList[e].destroy(t)}this._uiDrawBatchList.length=0,this._init=!1},i._getBatcher=function(){return fN.root&&fN.root.batcher2D?fN.root.batcher2D:(Y(9301),null)},n(e,[{key:"color",get:function(){return this._color},set:function(t){this._color!==t&&this._color.set(t)}},{key:"drawBatchList",get:function(){return this._uiDrawBatchList}}]),e}(TV)).prototype,"color",[Ro],Object.getOwnPropertyDescriptor(tj.prototype,"color"),tj.prototype),$W=tj))||$W)||$W),hj=t("o",qs("cc.LabelShadow")(ej=Ks(110)(ej=Ys(lG)(ej=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onEnable=function(){this.node.getComponent(lG).enableShadow=!0},i.onDisable=function(){this.node.getComponent(lG).enableShadow=!1},n(e,[{key:"color",get:function(){return this.node.getComponent(lG).shadowColor},set:function(t){this.node.getComponent(lG).shadowColor=t}},{key:"offset",get:function(){return this.node.getComponent(lG).shadowOffset},set:function(t){this.node.getComponent(lG).shadowOffset=t}},{key:"blur",get:function(){return this.node.getComponent(lG).shadowBlur},set:function(t){this.node.getComponent(lG).shadowBlur=t}}]),e}(rp))||ej)||ej)||ej),uj=t("p",qs("cc.UIOpacity")(ij=Ks(110)(ij=Js((nj=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._setByParent=!1,e._opacity=rj&&rj(),e}s(e,t);var i=e.prototype;return i.setEntityLocalOpacityDirtyRecursively=function(){},e.setEntityLocalOpacityDirtyRecursively=function(t,i,n,r){if(t.isValid){var s=t._uiProps.uiComp,o=t.getComponent(e),a=n;s&&s.color?(s.renderEntity.colorDirty=i,o?(s.renderEntity.localOpacity=a*o.opacity/255,o._setByParent=r):s.renderEntity.localOpacity=a,s.node._uiProps.localOpacity=s.renderEntity.localOpacity,a=1):o&&(a=a*o.opacity/255,o._setByParent=r);for(var h=0;h<t.children.length;h++)e.setEntityLocalOpacityDirtyRecursively(t.children[h],i||a<1,a,!0)}},i.onEnable=function(){this._setByParent||(this.node._uiProps.localOpacity=this._opacity/255,this.setEntityLocalOpacityDirtyRecursively(!0))},i.onDisable=function(){this._setByParent||(this.node._uiProps.localOpacity=1,this.setEntityLocalOpacityDirtyRecursively(!0))},n(e,[{key:"opacity",get:function(){return this._opacity},set:function(t){this._opacity!==t&&(t=Fe(t,0,255),this._opacity=t,this.node._uiProps.localOpacity=t/255,this.setEntityLocalOpacityDirtyRecursively(!0))}}]),e}(rp),rj=ks(nj.prototype,"_opacity",[io],(function(){return 255})),ij=nj))||ij)||ij)||ij);v.MaskComponent=pz,Qt(pz,"cc.MaskComponent"),v.LabelComponent=lG,Qt(lG,"cc.LabelComponent"),v.LabelOutlineComponent=wz,Qt(wz,"cc.LabelOutlineComponent"),v.RichTextComponent=QW,Qt(QW,"cc.RichTextComponent"),v.SpriteComponent=uz,Qt(uz,"cc.SpriteComponent"),v.UIModelComponent=ZW,Qt(ZW,"cc.UIModelComponent"),v.GraphicsComponent=ZU,Qt(ZU,"cc.GraphicsComponent"),Qt(aj,"cc.UIStaticBatchComponent"),Qt(uj,"cc.UIOpacityComponent"),nt(pz.prototype,"Mask",[{name:"graphics",newName:"subComp",target:pz.prototype,targetName:"Mask"}]),nt(lz,"MaskType",[{name:"RECT",newName:"GRAPHICS_RECT",target:lz,targetName:"MaskType"},{name:"ELLIPSE",newName:"GRAPHICS_ELLIPSE",target:lz,targetName:"MaskType"},{name:"IMAGE_STENCIL",newName:"SPRITE_STENCIL",target:lz,targetName:"MaskType"}]),st(wz.prototype,"LabelOutline",[{name:"width",suggest:"Please use Label.outlineWidth instead."},{name:"color",suggest:"Please use Label.outlineColor instead."}]),st(hj.prototype,"LabelShadow",[{name:"color",suggest:"Please use Label.shadowColor instead."},{name:"offset",suggest:"Please use Label.shadowOffset instead."},{name:"blur",suggest:"Please use Label.shadowBlur instead."}]);var lj=function(t,e,i){this.i=void 0,this.x=void 0,this.y=void 0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=e,this.y=i};function cj(t,e,i,n,r){var s=0,o=null;if(r===function(t,e,i,n){for(var r=0,s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}(t,e,i,n)>0)for(s=e;s<i;s+=n)o=Ij(s,t[s],t[s+1],o);else for(s=i-n;s>=e;s-=n)o=Ij(s,t[s],t[s+1],o);return o&&Cj(o,o.next)&&(Bj(o),o=o.next),o}function _j(t,e){if(void 0===e&&(e=null),!t)return t;e||(e=t);var i=t,n=!1;do{if(n=!1,i.steiner||!Cj(i,i.next)&&0!==Ej(i.prev,i,i.next))i=i.next;else{if(Bj(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function dj(t,e,i,n,r,s,o){if(void 0===o&&(o=0),t){!o&&s&&function(t,e,i,n){var r=t;do{null===r.z&&(r.z=Sj(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e=0,i=null,n=null,r=null,s=null,o=0,a=0,h=0,u=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e<u&&(a++,n=n.nextZ);e++);for(h=u;a>0||h>0&&n;)0===a?(r=n,n=n.nextZ,h--):0!==h&&n?i.z<=n.z?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,h--):(r=i,i=i.nextZ,a--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,u*=2}while(o>1)}(r)}(t,n,r,s);for(var a=t,h=null,u=null;t.prev!==t.next;)if(h=t.prev,u=t.next,s?pj(t,n,r,s):fj(t))e.push(h.i/i),e.push(t.i/i),e.push(u.i/i),Bj(t),t=u.next,a=u.next;else if((t=u)===a){o?1===o?dj(t=mj(t,e,i),e,i,n,r,s,2):2===o&&gj(t,e,i,n,r,s):dj(_j(t),e,i,n,r,s,1);break}}}function fj(t){var e=t.prev,i=t,n=t.next;if(Ej(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(Aj(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Ej(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function pj(t,e,i,n){var r=t.prev,s=t,o=t.next;if(Ej(r,s,o)>=0)return!1;for(var a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,h=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,u=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,l=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,c=Sj(a,h,e,i,n),_=Sj(u,l,e,i,n),d=t.nextZ;d&&d.z<=_;){if(d!==t.prev&&d!==t.next&&Aj(r.x,r.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Ej(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=t.prevZ;d&&d.z>=c;){if(d!==t.prev&&d!==t.next&&Aj(r.x,r.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Ej(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function mj(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!Cj(r,s)&&wj(r,n,n.next,s)&&xj(r,s)&&xj(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),Bj(n),Bj(n.next),n=t=s),n=n.next}while(n!==t);return n}function gj(t,e,i,n,r,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&bj(o,a)){var h=Rj(o,a);return o=_j(o,o.next),h=_j(h,h.next),dj(o,e,i,n,r,s),void dj(h,e,i,n,r,s)}a=a.next}o=o.next}while(o!==t)}function yj(t,e){return t.x-e.x}function vj(t,e){if(e=function(t,e){var i=e,n=t.x,r=t.y,s=-1/0,o=null;do{if(r<=i.y&&r>=i.next.y){var a=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=n&&a>s){if(s=a,a===n){if(r===i.y)return i;if(r===i.next.y)return i.next}o=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!o)return null;if(n===s)return o.prev;var h,u=o,l=o.x,c=o.y,_=1/0;for(i=o.next;i!==u;)n>=i.x&&i.x>=l&&Aj(r<c?n:s,r,l,c,r<c?s:n,r,i.x,i.y)&&((h=Math.abs(r-i.y)/(n-i.x))<_||h===_&&i.x>o.x)&&xj(i,t)&&(o=i,_=h),i=i.next;return o}(t,e)){var i=Rj(e,t);_j(i,i.next)}}function Sj(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Tj(t){var e=t,i=t;do{e.x<i.x&&(i=e),e=e.next}while(e!==t);return i}function Aj(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function bj(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&wj(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&xj(t,e)&&xj(e,t)&&function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function Ej(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Cj(t,e){return t.x===e.x&&t.y===e.y}function wj(t,e,i,n){return!!(Cj(t,e)&&Cj(i,n)||Cj(t,n)&&Cj(i,e))||Ej(t,e,i)>0!=Ej(t,e,n)>0&&Ej(i,n,t)>0!=Ej(i,n,e)>0}function xj(t,e){return Ej(t.prev,t,t.next)<0?Ej(t,e,t.next)>=0&&Ej(t,t.prev,e)>=0:Ej(t,e,t.prev)<0||Ej(t,t.next,e)<0}function Rj(t,e){var i=new lj(t.i,t.x,t.y),n=new lj(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Ij(t,e,i,n){var r=new lj(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Bj(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Dj(t,e,i){i=i||3;var n=e?e.length:0,r=n?e[0]*i:t.length,s=cj(t,0,r,i,!0),o=[];if(!s)return o;var a=0,h=0,u=0,l=0,c=0,_=0,d=0;if(n&&(s=function(t,e,i,n){var r,s=[],o=0,a=null;for(o=0,r=e.length;o<r;o++)(a=cj(t,e[o]*n,o<r-1?e[o+1]*n:t.length,n,!1))&&(a===a.next&&(a.steiner=!0),s.push(Tj(a)));if(s.sort(yj),!i)return i;for(o=0;o<s.length;o++)vj(s[o],i),i=_j(i,i.next);return i}(t,e,s,i)),t.length>80*i){a=u=t[0],h=l=t[1];for(var f=i;f<r;f+=i)(c=t[f])<a&&(a=c),(_=t[f+1])<h&&(h=_),c>u&&(u=c),_>l&&(l=_);d=Math.max(u-a,l-h)}return dj(s,o,i,a,h,d),o}for(var Pj=Math.PI,Oj=Math.min,Mj=Math.max,Lj=Math.ceil,Nj=Math.acos,Fj=Math.cos,kj=Math.sin,Vj=Math.atan2,Gj=null,Uj=null,zj=new dn,Hj=[],Wj=0;Wj<4;Wj++)Hj.push(new on);function jj(t,e,i){return t<e?e:t>i?i:t}var Xj={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(t,e){if(!Uj)return null;var i=Uj.getRenderDataList(),n=i[Uj.dataOffset];if(!n)return null;var r=n,s=r?r.vertexStart+e:0;return(s>65535||3*s>131070)&&(++Uj.dataOffset,Uj.dataOffset<i.length?n=i[Uj.dataOffset]:(n=Uj.requestRenderData(),i[Uj.dataOffset]=n),r=n),r&&r.vertexCount<s&&r.request(e,3*e),n},stroke:function(t){dn.copy(zj,t.strokeColor),t.impl&&(this._flattenPaths(t.impl),this._expandStroke(t),t.impl.updatePathOffset=!0,this.end(t))},fill:function(t){dn.copy(zj,t.fillColor),this._expandFill(t),t.impl&&(t.impl.updatePathOffset=!0),this.end(t)},end:function(t){t.markForUpdateRenderData()},_expandStroke:function(t){var e=.5*t.lineWidth,i=t.lineCap,n=t.lineJoin,r=t.miterLimit;if(Uj=t.impl){var s=function(t,e,i){var n=2*Nj(t/(t+i));return Mj(2,Lj(e/n))}(e,Pj,Uj.tessTol);this._calculateJoins(Uj,e,n,r);for(var o=Uj.paths,a=0,h=Uj.pathOffset,u=Uj.pathLength;h<u;h++){var l=o[h],c=l.points.length;n===KG.ROUND?a+=2*(c+l.bevel*(s+2)+1):a+=2*(c+5*l.bevel+1),l.closed||(i===YG.ROUND?a+=2*(2*s+2):a+=12)}var _=Gj=this.getRenderData(t,a);if(_){for(var d=_.vData,f=_.iData,p=Uj.pathOffset,m=Uj.pathLength;p<m;p++){var g=o[p],y=g.points,v=y.length,S=_.vertexStart,T=void 0,A=void 0,b=0,E=0,C=g.closed;if(C?(T=y[v-1],A=y[0],b=0,E=v):(T=y[0],A=y[1],b=1,E=v-1),A=A||T,!C){var w=new XU(A.x,A.y);w.subtract(T),w.normalize();var x=w.x,R=w.y;i===YG.BUTT?this._buttCapStart(T,x,R,e,0):i===YG.SQUARE?this._buttCapStart(T,x,R,e,e):i===YG.ROUND&&this._roundCapStart(T,x,R,e,s)}for(var I=b;I<E;++I)n===KG.ROUND?this._roundJoin(T,A,e,e,s):0!=(A.flags&(JG.PT_BEVEL|JG.PT_INNERBEVEL))?this._bevelJoin(T,A,e,e):(this._vSet(A.x+A.dmx*e,A.y+A.dmy*e,1),this._vSet(A.x-A.dmx*e,A.y-A.dmy*e,-1)),T=A,A=y[I+1];if(C){var B=8*S;this._vSet(d[B],d[B+1],1),this._vSet(d[B+8],d[B+8+1],-1)}else{var D=new XU(A.x,A.y);D.subtract(T),D.normalize();var P=D.x,O=D.y;i===YG.BUTT?this._buttCapEnd(A,P,O,e,0):i===YG.SQUARE?this._buttCapEnd(A,P,O,e,e):i===YG.ROUND&&this._roundCapEnd(A,P,O,e,s)}for(var M=_.indexStart,L=S+2,N=_.vertexStart;L<N;L++)f[M++]=L-2,f[M++]=L-1,f[M++]=L;_.indexStart=M}Gj=null,Uj=null}}},_expandFill:function(t){if(Uj=t.impl){for(var e=Uj.paths,i=0,n=Uj.pathOffset,r=Uj.pathLength;n<r;n++)i+=e[n].points.length;var s=Gj=this.getRenderData(t,i);if(s){for(var o=s,a=o.vData,h=o.iData,u=Uj.pathOffset,l=Uj.pathLength;u<l;u++){var c=e[u],_=c.points,d=_.length;if(0!==d){for(var f=s.vertexStart,p=0;p<d;++p)this._vSet(_[p].x,_[p].y);var m=s.indexStart;if(c.complex){for(var g=[],y=f,v=s.vertexStart;y<v;y++){var S=8*y;g.push(a[S++]),g.push(a[S++]),g.push(a[S++])}var T=Dj(g,null,3);if(!T||0===T.length)continue;for(var A=0,b=T.length;A<b;A++)h[m++]=T[A]+f}else for(var E=f,C=f+2,w=o.vertexStart;C<w;C++)h[m++]=E,h[m++]=C-1,h[m++]=C;o.indexStart=m}}Gj=null,Uj=null}}},_calculateJoins:function(t,e,i,n){var r=0;e>0&&(r=1/e);for(var s=t.paths,o=t.pathOffset,a=t.pathLength;o<a;o++){var h=s[o],u=h.points,l=u.length,c=u[l-1],_=u[0];h.bevel=0;for(var d=0;d<l;d++){var f,p,m=c.dy,g=-c.dx,y=_.dy,v=-_.dx;if(_.dmx=.5*(m+y),_.dmy=.5*(g+v),(f=_.dmx*_.dmx+_.dmy*_.dmy)>1e-6){var S=1/f;S>600&&(S=600),_.dmx*=S,_.dmy*=S}_.dx*c.dy-c.dx*_.dy>0&&(_.flags|=JG.PT_LEFT),f*(p=Mj(11,Oj(c.len,_.len)*r))*p<1&&(_.flags|=JG.PT_INNERBEVEL),_.flags&JG.PT_CORNER&&(f*n*n<1||i===KG.BEVEL||i===KG.ROUND)&&(_.flags|=JG.PT_BEVEL),0!=(_.flags&(JG.PT_BEVEL|JG.PT_INNERBEVEL))&&h.bevel++,c=_,_=u[d+1]}}},_flattenPaths:function(t){for(var e=t.paths,i=t.pathOffset,n=t.pathLength;i<n;i++){var r=e[i],s=r.points,o=s[s.length-1],a=s[0];s.length>2&&o.equals(a)&&(r.closed=!0,s.pop(),o=s[s.length-1]);for(var h=0,u=s.length;h<u;h++){var l=new XU(a.x,a.y);l.subtract(o),o.len=l.length(),(l.x||l.y)&&l.normalize(),o.dx=l.x,o.dy=l.y,o=a,a=s[h+1]}}},_chooseBevel:function(t,e,i,n){var r=i.x,s=i.y,o=0,a=0,h=0,u=0;return 0!==t?(o=r+e.dy*n,a=s-e.dx*n,h=r+i.dy*n,u=s-i.dx*n):(o=h=r+i.dmx*n,a=u=s+i.dmy*n),[o,a,h,u]},_buttCapStart:function(t,e,i,n,r){var s=t.x-e*r,o=t.y-i*r,a=i,h=-e;this._vSet(s+a*n,o+h*n,1),this._vSet(s-a*n,o-h*n,-1)},_buttCapEnd:function(t,e,i,n,r){var s=t.x+e*r,o=t.y+i*r,a=i,h=-e;this._vSet(s+a*n,o+h*n,1),this._vSet(s-a*n,o-h*n,-1)},_roundCapStart:function(t,e,i,n,r){for(var s=t.x,o=t.y,a=i,h=-e,u=0;u<r;u++){var l=u/(r-1)*Pj,c=Fj(l)*n,_=kj(l)*n;this._vSet(s-a*c-e*_,o-h*c-i*_,1),this._vSet(s,o,0)}this._vSet(s+a*n,o+h*n,1),this._vSet(s-a*n,o-h*n,-1)},_roundCapEnd:function(t,e,i,n,r){var s=t.x,o=t.y,a=i,h=-e;this._vSet(s+a*n,o+h*n,1),this._vSet(s-a*n,o-h*n,-1);for(var u=0;u<r;u++){var l=u/(r-1)*Pj,c=Fj(l)*n,_=kj(l)*n;this._vSet(s,o,0),this._vSet(s-a*c+e*_,o-h*c+i*_,1)}},_roundJoin:function(t,e,i,n,r){var s=t.dy,o=-t.dx,a=e.dy,h=-e.dx,u=e.x,l=e.y;if(0!=(e.flags&JG.PT_LEFT)){var c=this._chooseBevel(e.flags&JG.PT_INNERBEVEL,t,e,i),_=c[0],d=c[1],f=c[2],p=c[3],m=Vj(-o,-s),g=Vj(-h,-a);g>m&&(g-=2*Pj),this._vSet(_,d,1),this._vSet(u-s*n,e.y-o*n,-1);for(var y=jj(Lj((m-g)/Pj)*r,2,r),v=0;v<y;v++){var S=m+v/(y-1)*(g-m),T=u+Fj(S)*n,A=l+kj(S)*n;this._vSet(u,l,0),this._vSet(T,A,-1)}this._vSet(f,p,1),this._vSet(u-a*n,l-h*n,-1)}else{var b=this._chooseBevel(e.flags&JG.PT_INNERBEVEL,t,e,-n),E=b[0],C=b[1],w=b[2],x=b[3],R=Vj(o,s),I=Vj(h,a);I<R&&(I+=2*Pj),this._vSet(u+s*n,l+o*n,1),this._vSet(E,C,-1);for(var B=jj(Lj((I-R)/Pj)*r,2,r),D=0;D<B;D++){var P=R+D/(B-1)*(I-R),O=u+Fj(P)*i,M=l+kj(P)*i;this._vSet(O,M,1),this._vSet(u,l,0)}this._vSet(u+a*n,l+h*n,1),this._vSet(w,x,-1)}},_bevelJoin:function(t,e,i,n){var r=0,s=0,o=0,a=0,h=0,u=0,l=0,c=0,_=t.dy,d=-t.dx,f=e.dy,p=-e.dx;if(e.flags&JG.PT_LEFT){var m=this._chooseBevel(e.flags&JG.PT_INNERBEVEL,t,e,i);h=m[0],u=m[1],l=m[2],c=m[3],this._vSet(h,u,1),this._vSet(e.x-_*n,e.y-d*n,-1),this._vSet(l,c,1),this._vSet(e.x-f*n,e.y-p*n,-1)}else{var g=this._chooseBevel(e.flags&JG.PT_INNERBEVEL,t,e,-n);r=g[0],s=g[1],o=g[2],a=g[3],this._vSet(e.x+_*i,e.y+d*i,1),this._vSet(r,s,-1),this._vSet(e.x+f*i,e.y+p*i,1),this._vSet(o,a,-1)}},_vSet:function(t,e,i){if(void 0===i&&(i=0),Gj){var n=Gj,r=8*n.vertexStart,s=n.vData;s[r++]=t,s[r++]=e,s[r++]=0,dn.toArray(s,zj,r),r+=4,s[r++]=i,n.vertexStart++}}},qj=t("g",{getAssembler:function(){return Xj}});ZU.Assembler=qj;var Yj=["left","center","right"],Kj=2048,Jj=(1/255).toFixed(3),Qj=function(){this.char="",this.valid=!0,this.x=0,this.y=0,this.line=0,this.hash=""},Zj=function(){function t(){this._context=null,this._canvas=null,this._canvasData=null,this._lettersInfo=[],this._tmpRect=new Un,this._maxFontSize=100,this._fontScale=1,this._canvasData=tk.getInstance().get(),this._canvas=this._canvasData.canvas,this._context=this._canvasData.context}var e=t.prototype;return e.destroy=function(){tk.getInstance().put(this._canvasData),this._lettersInfo.length=0},e.processingString=function(t,e,i,n,r,s){if(t)e.fntConfig?this._fontScale=1:this._fontScale=this._getStyleFontScale(e.originFontSize,e.fontScale),ak.fontScale=this._fontScale,this._setupBMFontOverflowMetrics(i,n),this._updateFontScale(e),this._computeHorizontalKerningForText(e,i,r),this._alignText(e,i,n,r);else{var o=0;for(this._fontScale=this._getStyleFontScale(e.fontSize,e.fontScale),this._updatePaddingRect(e,n),this._calculateLabelFont(e,i,n,r);(n.canvasSize.width>Kj||n.canvasSize.height>Kj)&&o<=3;){if(++o>3)this._fontScale=1;else{var a=Math.max(n.canvasSize.width,n.canvasSize.height),h=Kj/a;this._fontScale*=h,this._fontScale=Math.max(1,this._fontScale)}this._updatePaddingRect(e,n),this._calculateLabelFont(e,i,n,r)}}s&&(s=n.parsedString)},e.generateRenderInfo=function(t,e,i,n,r,s,o){t?(this._computeAlignmentOffset(e,i,n),this.generateVertexData(t,e,i,n,r,s,o)):(this._updateLabelDimensions(e,i,n),this._updateTexture(e,i,n,r),this.generateVertexData(t,e,i,n,r,s,o))},e.setCanvasUsed=function(t,e){this._canvas=t,this._context=e},e._getStyleFontScale=function(t,e){var i=e;return i*t>this._maxFontSize&&t<this._maxFontSize&&(i=this._maxFontSize/t),i<1&&(i=1),i},e._calculateLabelFont=function(t,e,i,n){if(this._context){t.actualFontSize=t.fontSize*this._fontScale;var r=n.split("\n"),s=i.parsedString=r,o=this._getFontDesc(t.actualFontSize,t.fontFamily,t.isBold,t.isItalic);switch(this._context.font=t.fontDesc=o,e.overFlow){case rG.NONE:for(var a=0,h=0;h<r.length;++h){var u=YF(this._context,r[h],o);a=a>u?a:u}var l=a,c=(s.length+NF)*this._getLineHeight(e.lineHeight,t.actualFontSize,t.fontSize);i.canvasSize.width=l+i.canvasPadding.width*this._fontScale,i.canvasSize.height=c+i.canvasPadding.height*this._fontScale,i.nodeContentSize.width=(l+i.contentSizeExtend.width*this._fontScale)/this._fontScale,i.nodeContentSize.height=(c+i.contentSizeExtend.height*this._fontScale)/this._fontScale;break;case rG.SHRINK:this._calculateShrinkFont(r,t,e,i),this._calculateWrapText(r,t,e,i),i.canvasSize.width=i.nodeContentSize.width*this._fontScale,i.canvasSize.height=i.nodeContentSize.height*this._fontScale;break;case rG.CLAMP:this._calculateWrapText(r,t,e,i),i.canvasSize.width=i.nodeContentSize.width*this._fontScale,i.canvasSize.height=i.nodeContentSize.height*this._fontScale;break;case rG.RESIZE_HEIGHT:this._calculateWrapText(r,t,e,i);var _=(i.parsedString.length+NF)*this._getLineHeight(e.lineHeight,t.actualFontSize,t.fontSize);i.canvasSize.width=i.nodeContentSize.width*this._fontScale,i.canvasSize.height=_+i.canvasPadding.height*this._fontScale,i.nodeContentSize.height=(_+i.contentSizeExtend.height*this._fontScale)/this._fontScale}}},e._getFontDesc=function(t,e,i,n){var r=t.toString()+"px ";return r+=e,i&&(r="bold "+r),n&&(r="italic "+r),r},e._getLineHeight=function(t,e,i){return 0===t?e:t*e/i},e._calculateShrinkFont=function(t,e,i,n){if(this._context){var r=this._getFontDesc(e.actualFontSize,e.fontFamily,e.isBold,e.isItalic);this._context.font=r;var s=this._calculateParagraphLength(t,this._context,r),o=0,a=0,h=0,u=e.actualFontSize;if(i.wrapping){var l=n.nodeContentSize.width*this._fontScale,c=n.nodeContentSize.height*this._fontScale;if(l<0||c<0)return;a=c+1;for(var _=0,d=0|e.actualFontSize+1,f=0;_<d;){if((f=_+d+1>>1)<=0){X(4003);break}u=f,r=this._getFontDesc(u,e.fontFamily,e.isBold,e.isItalic),this._context.font=r;var p=this._getLineHeight(i.lineHeight,u,e.fontSize);for(a=0,o=0;o<t.length;++o){var m=YF(this._context,t[o],r);a+=ZF(t[o],m,l,this._measureText(this._context,r)).length*p}a>c?d=f-1:_=f}0===_?X(4003):(u=_,r=this._getFontDesc(u,e.fontFamily,e.isBold,e.isItalic),this._context.font=r)}else{for(a=t.length*this._getLineHeight(i.lineHeight,u,e.fontSize),o=0;o<t.length;++o)h<s[o]&&(h=s[o]);var g=(n.canvasSize.width-n.canvasPadding.width)*this._fontScale/h,y=n.canvasSize.height*this._fontScale/a;u=e.actualFontSize*Math.min(1,g,y)|0,r=this._getFontDesc(u,e.fontFamily,e.isBold,e.isItalic),this._context.font=r}e.actualFontSize=u,e.fontDesc=r}},e._calculateWrapText=function(t,e,i,n){if(i.wrapping&&this._context){var r=[],s=n.nodeContentSize.width*this._fontScale,o=this._getFontDesc(e.actualFontSize,e.fontFamily,e.isBold,e.isItalic);this._context.font=o;for(var a=0;a<t.length;++a){var h=YF(this._context,t[a],o),u=ZF(t[a],h,s,this._measureText(this._context,o));r=r.concat(u)}n.parsedString=r,e.fontDesc=o}},e._measureText=function(t,e){return function(i){return YF(t,i,e)}},e._calculateParagraphLength=function(t,e,i){for(var n,r=[],s=d(t);!(n=s()).done;){var o=YF(e,n.value,i);r.push(o)}return r},e._updatePaddingRect=function(t,e){var i=0,n=0,r=0,s=0,o=0;if(e.contentSizeExtend.width=e.contentSizeExtend.height=0,t.isOutlined&&(i=n=r=s=o=t.outlineWidth,e.contentSizeExtend.width=e.contentSizeExtend.height=2*o),t.hasShadow){var a=t.shadowBlur+o,h=t.shadowOffsetX,u=t.shadowOffsetY;r=Math.max(r,-h+a),s=Math.max(s,h+a),i=Math.max(i,u+a),n=Math.max(n,-u+a)}if(t.isItalic){var l=t.fontSize*Math.tan(.20943951);s+=l,e.contentSizeExtend.width+=l}e.canvasPadding.x=r,e.canvasPadding.y=i,e.canvasPadding.width=r+s,e.canvasPadding.height=i+n},e._updateLabelDimensions=function(t,e,i){i.canvasSize.width=Math.min(i.canvasSize.width,Kj),i.canvasSize.height=Math.min(i.canvasSize.height,Kj),this._canvas.width=i.canvasSize.width,this._canvas.height=i.canvasSize.height,this._context.font=t.fontDesc,this._context.textAlign=Yj[e.horizontalAlign],this._context.textBaseline="alphabetic"},e._calculateFillTextStartPosition=function(t,e,i){var n=0;e.horizontalAlign===iG.RIGHT?n=i.canvasSize.width-i.canvasPadding.width:e.horizontalAlign===iG.CENTER&&(n=(i.canvasSize.width-i.canvasPadding.width)/2);var r=this._getLineHeight(e.lineHeight,t.actualFontSize,t.fontSize)*(i.parsedString.length-1),s=t.actualFontSize*(1-NF/2);if(e.verticalAlign!==nG.TOP){var o=r+i.canvasPadding.height+t.actualFontSize-i.canvasSize.height;e.verticalAlign===nG.BOTTOM?s-=o+=NF/2*t.actualFontSize:s-=o/2}s+=0*t.actualFontSize,i.startPosition.set(n+i.canvasPadding.x,s+i.canvasPadding.y)},e._updateTexture=function(t,e,i,n){if(this._context&&this._canvas){this._context.clearRect(0,0,this._canvas.width,this._canvas.height),this._context.font=t.fontDesc,this._calculateFillTextStartPosition(t,e,i);var r=this._getLineHeight(e.lineHeight,t.actualFontSize,t.fontSize);this._context.lineJoin="round",t.isOutlined?(this._context.fillStyle="rgba("+t.outlineColor.r+", "+t.outlineColor.g+", "+t.outlineColor.b+", "+Jj+")",this._context.fillRect(0,0,this._canvas.width,this._canvas.height)):(this._context.fillStyle="rgba("+t.color.r+", "+t.color.g+", "+t.color.b+", "+Jj+")",this._context.fillRect(0,0,this._canvas.width,this._canvas.height)),this._context.fillStyle="rgb("+t.color.r+", "+t.color.g+", "+t.color.b+")";var s=new Ln(i.startPosition.x,i.startPosition.y),o=s.x,a=0;this._drawTextEffect(s,r,t,e,i);for(var h=0;h<i.parsedString.length;++h)a=s.y+h*r,t.isOutlined&&this._context.strokeText(i.parsedString[h],o,a),this._context.fillText(i.parsedString[h],o,a);t.hasShadow&&(this._context.shadowColor="transparent"),this._uploadTexture(n)}},e._uploadTexture=function(t){var e;t.texture&&this._canvas&&(e=t.texture instanceof pF?t.texture.texture:t.texture,0!==this._canvas.width&&0!==this._canvas.height&&(e.reset({width:this._canvas.width,height:this._canvas.height,mipmapLevel:1}),e.uploadData(this._canvas),e.setWrapMode(hf.CLAMP_TO_EDGE,hf.CLAMP_TO_EDGE),t.texture instanceof pF&&(t.texture.rect=new Un(0,0,this._canvas.width,this._canvas.height),t.texture._calculateUV()),v.director.root&&v.director.root.batcher2D&&v.director.root.batcher2D._releaseDescriptorSetCache(e.getHash())))},e._drawTextEffect=function(t,e,i,n,r){if(i.hasShadow||i.isOutlined||i.isUnderline){var s=r.parsedString.length>1&&i.hasShadow,o=this._measureText(this._context,i.fontDesc),a=0,h=0;i.hasShadow&&this._setupShadow(i),i.isOutlined&&this._setupOutline(i);for(var u=0;u<r.parsedString.length;++u)if(a=t.x,h=t.y+u*e,s&&(i.isOutlined&&this._context.strokeText(r.parsedString[u],a,h),this._context.fillText(r.parsedString[u],a,h)),i.isUnderline){var l=o(r.parsedString[u]),c=new Ln;n.horizontalAlign===iG.RIGHT?c.x=t.x-l:n.horizontalAlign===iG.CENTER?c.x=t.x-l/2:c.x=t.x,c.y=h+i.actualFontSize/8,this._context.fillRect(c.x,c.y,l,i.underlineHeight*this._fontScale)}s&&(this._context.shadowColor="transparent")}},e._setupOutline=function(t){this._context.strokeStyle="rgba("+t.outlineColor.r+", "+t.outlineColor.g+", "+t.outlineColor.b+", "+t.outlineColor.a/255+")",this._context.lineWidth=2*t.outlineWidth*this._fontScale},e._setupShadow=function(t){var e=this._fontScale;this._context.shadowColor="rgba("+t.shadowColor.r+", "+t.shadowColor.g+", "+t.shadowColor.b+", "+t.shadowColor.a/255+")",this._context.shadowBlur=t.shadowBlur*e,this._context.shadowOffsetX=t.shadowOffsetX*e,this._context.shadowOffsetY=-t.shadowOffsetY*e},e.generateVertexData=function(t,e,i,n,r,s,o){t?this._updateQuads(e,i,n,r,s,o):(this.updateQuatCount(r),o(e,n,r))},e.updateQuatCount=function(t){var e=t.vertexBuffer,i=t.quadCount;if(e.length!==i){for(var n=e.length;n<i;n++)e.push({x:0,y:0,z:0,u:0,v:0,color:dn.WHITE.clone()});e.length=i}},e._setupBMFontOverflowMetrics=function(t,e){var i=e.nodeContentSize.width,n=e.nodeContentSize.height;t.overFlow===rG.RESIZE_HEIGHT&&(n=0),t.overFlow===rG.NONE&&(i=0,n=0),t.textWidthTemp=i,t.textHeightTemp=n,t.textDimensions.width=i,t.textDimensions.height=n,t.maxLineWidth=i},e._updateFontScale=function(t){t.bmfontScale=t.actualFontSize/(t.originFontSize*this._fontScale)},e._computeHorizontalKerningForText=function(t,e,i){var n=i,r=n.length;if(t.fntConfig){var s=t.fntConfig.kerningDict,o=e.horizontalKerning;if(s&&0!==s.length)for(var a=-1,h=0;h<r;++h){var u=n.charCodeAt(h),l=s[a<<16|65535&u]||0;o[h]=h<r-1?l:0,a=u}}},e._alignText=function(t,e,i,n){this._multilineTextWrap(t,e,i,n,this._getFirstWordLen),e.overFlow===rG.SHRINK&&(t.fontSize>0&&this._isVerticalClamp(t,e,i,n,this)&&this._shrinkLabelToContentSize(t,e,i,n,this._isVerticalClamp),t.fontSize>0&&this._isHorizontalNeedShrink(e,i)&&this._shrinkLabelToContentSize(t,e,i,n,this._isHorizontalClamp)),this._parsedString(i,n)},e._parsedString=function(t,e){for(var i=[],n="",r=0,s=0,o=e.length;r<o;++r){var a=this._lettersInfo[r];a.valid&&(s===a.line?n+=a.char:(i=i.concat(n),s=a.line,n=""))}i=i.concat(n),t.parsedString=i},e._multilineTextWrap=function(t,e,i,n,r){e.linesWidth.length=0;for(var s=n,o=s.length,a=0,h=0,u=0,l=0,c=0,_=0,d=0,f=null,p=0;p<o;){var m=s.charAt(p);if("\n"!==m){for(var g=r(t,e,s,p,o),y=_,v=d,S=c,T=h,A=!1,b=new Ln,E=0;E<g;++E){var C=p+E;if("\r"!==(m=s.charAt(C)))if(f=ak.fontAtlas.getLetterDefinitionForChar(m,ak)){var w=T+f.offsetX*t.bmfontScale-ak.margin;if(e.wrapping&&e.maxLineWidth>0&&h>0&&w+f.w*t.bmfontScale>e.maxLineWidth&&!qF(m)){e.linesWidth.push(c),c=0,a++,h=0,u-=e.lineHeight*this._getFontScale(t,e)+0,A=!0;break}b.x=w,b.y=u-f.offsetY*t.bmfontScale,this._recordLetterInfo(b,m,C,a),C+1<e.horizontalKerning.length&&C<o-1&&(T+=e.horizontalKerning[C+1]*t.bmfontScale),T+=f.xAdvance*t.bmfontScale+e.spacingX,S=b.x+f.w*t.bmfontScale,y<b.y&&(y=b.y),v>b.y-f.h*t.bmfontScale&&(v=b.y-f.h*t.bmfontScale)}else this._recordPlaceholderInfo(C,m),null!=t.fntConfig?F("Can't find letter definition in texture atlas "+t.fntConfig.atlasName+" for letter:"+m):F("Can't find letter definition in font family "+t.fontFamily+" for letter:"+m);else this._recordPlaceholderInfo(C,m)}A||(h=T,_<y&&(_=y),d>v&&(d=v),l<(c=S)&&(l=c),p+=g)}else e.linesWidth.push(c),c=0,a++,h=0,u-=e.lineHeight*this._getFontScale(t,e)+0,this._recordPlaceholderInfo(p,m),p++}return e.linesWidth.push(c),e.numberOfLines=a+1,e.textDesiredHeight=e.numberOfLines*e.lineHeight*this._getFontScale(t,e),e.numberOfLines>1&&(e.textDesiredHeight+=0*(e.numberOfLines-1)),i.nodeContentSize.width=e.textWidthTemp,i.nodeContentSize.height=e.textHeightTemp,e.textWidthTemp<=0&&(i.nodeContentSize.width=parseFloat(l.toFixed(2))+2*ak.margin),e.textHeightTemp<=0&&(i.nodeContentSize.height=parseFloat(e.textDesiredHeight.toFixed(2))+2*ak.margin),e.tailoredTopY=i.nodeContentSize.height,e.tailoredBottomY=0,_>0&&(e.tailoredTopY=i.nodeContentSize.height+_),d<-e.textDesiredHeight&&(e.tailoredBottomY=e.textDesiredHeight+d),!0},e._recordPlaceholderInfo=function(t,e){if(t>=this._lettersInfo.length){var i=new Qj;this._lettersInfo.push(i)}this._lettersInfo[t].char=e,this._lettersInfo[t].hash=""+e.charCodeAt(0)+ak.hash,this._lettersInfo[t].valid=!1},e._recordLetterInfo=function(t,e,i,n){if(i>=this._lettersInfo.length){var r=new Qj;this._lettersInfo.push(r)}var s=""+e.charCodeAt(0)+ak.hash;this._lettersInfo[i].line=n,this._lettersInfo[i].char=e,this._lettersInfo[i].hash=s,this._lettersInfo[i].valid=ak.fontAtlas.getLetter(s).valid,this._lettersInfo[i].x=t.x,this._lettersInfo[i].y=t.y},e._getFirstWordLen=function(t,e,i,n,r){var s=i.charAt(n);if(XF(s)||"\n"===s||qF(s))return 1;var o=1,a=ak.fontAtlas.getLetterDefinitionForChar(s,ak);if(!a)return o;for(var h=a.xAdvance*t.bmfontScale+e.spacingX,u=n+1;u<r&&(s=i.charAt(u),a=ak.fontAtlas.getLetterDefinitionForChar(s,ak));++u){if(h+a.offsetX*t.bmfontScale+a.w*t.bmfontScale>e.maxLineWidth&&!qF(s)&&e.maxLineWidth>0)return o;if(h+=a.xAdvance*t.bmfontScale+e.spacingX,"\n"===s||qF(s)||XF(s))break;o++}return o},e._computeAlignmentOffset=function(t,e,i){switch(e.linesOffsetX.length=0,e.letterOffsetY=0,e.horizontalAlign){case iG.LEFT:for(var n=0;n<e.numberOfLines;++n)e.linesOffsetX.push(0);break;case iG.CENTER:for(var r=0,s=e.linesWidth.length;r<s;r++)e.linesOffsetX.push((i.nodeContentSize.width-e.linesWidth[r])/2);break;case iG.RIGHT:for(var o=0,a=e.linesWidth.length;o<a;o++)e.linesOffsetX.push(i.nodeContentSize.width-e.linesWidth[o])}if(e.letterOffsetY=i.nodeContentSize.height,e.verticalAlign!==nG.TOP){var h=i.nodeContentSize.height-e.textDesiredHeight+e.lineHeight*this._getFontScale(t,e)-t.originFontSize*this._fontScale*t.bmfontScale;e.verticalAlign===nG.BOTTOM?e.letterOffsetY-=h:e.letterOffsetY-=h/2}},e._getFontScale=function(t,e){return e.overFlow===rG.SHRINK?t.bmfontScale:1},e._isVerticalClamp=function(t,e,i){return e.textDesiredHeight>i.nodeContentSize.height},e._isHorizontalClamp=function(t,e,i,n,r){for(var s=!1,o=0,a=n.length;o<a;++o){var h=r._lettersInfo[o];if(h.valid){var u=ak.fontAtlas.getLetterDefinitionForChar(h.char,ak);if(!u)continue;var l=h.x+u.w*t.bmfontScale,c=h.line;if(e.textWidthTemp>0)if(e.wrapping){if(e.linesWidth[c]>i.nodeContentSize.width&&(l>i.nodeContentSize.width||l<0)){s=!0;break}}else if(l>i.nodeContentSize.width){s=!0;break}}}return s},e._isHorizontalNeedShrink=function(t,e){for(var i=0,n=t.linesWidth.length;i<n;++i)if(t.linesWidth[i]>e.nodeContentSize.width)return!0;return!1},e._shrinkLabelToContentSize=function(t,e,i,n,r){for(var s=0,o=0|t.actualFontSize,a=0;s<o;){var h=a=s+o+1>>1;if(h<=0)break;t.bmfontScale=h/(t.originFontSize*this._fontScale),this._multilineTextWrap(t,e,i,n,this._getFirstWordLen),this._computeAlignmentOffset(t,e,i),r(t,e,i,n,this)?o=a-1:s=a}s>=0&&this._scaleFontSizeDown(t,e,i,n,s)},e._scaleFontSizeDown=function(t,e,i,n,r){var s=!0;r||(r=.1,s=!1),t.actualFontSize=r,s&&(this._updateFontScale(t),this._multilineTextWrap(t,e,i,n,this._getFirstWordLen))},e._updateQuads=function(t,e,i,n,r,s){for(var o=t.spriteFrame?t.spriteFrame.texture:ak.fontAtlas.getTexture(),a=n.uiTransAnchorX*i.nodeContentSize.width,h=n.uiTransAnchorY*i.nodeContentSize.height,u=0,l=r.length;u<l;++u){var c=this._lettersInfo[u];if(c.valid){var _=ak.fontAtlas.getLetter(c.hash);if(_){this._tmpRect.height=_.h,this._tmpRect.width=_.w,this._tmpRect.x=_.u,this._tmpRect.y=_.v;var d=c.y+e.letterOffsetY;if(e.textHeightTemp>0){if(d>e.tailoredTopY){var f=d-e.tailoredTopY;this._tmpRect.y+=f,this._tmpRect.height-=f,d-=f}d-this._tmpRect.height*t.bmfontScale<e.tailoredBottomY&&e.overFlow===rG.CLAMP&&(this._tmpRect.height=d<e.tailoredBottomY?0:(d-e.tailoredBottomY)/t.bmfontScale)}var p=c.line,m=c.x+_.w/2*t.bmfontScale+e.linesOffsetX[p];if(e.textWidthTemp>0&&this._isHorizontalClamped(e,i,m,p)&&e.overFlow===rG.CLAMP&&(this._tmpRect.width=0),this._tmpRect.height>0&&this._tmpRect.width>0){var g=this._determineRect(t),y=c.x+e.linesOffsetX[c.line],v=n.quadCount;n.quadCount+=4,this.updateQuatCount(n),s(t,i,n,v,o,this._tmpRect,g,y-a,d-h)}}else k("Can't find letter in this bitmap-font")}}return!0},e._isHorizontalClamped=function(t,e,i,n){var r=t.linesWidth[n],s=i>e.nodeContentSize.width||i<0;return t.wrapping?r>e.nodeContentSize.width&&s:s},e._determineRect=function(t){var e=t.spriteFrame;if(!e)return!1;var i=e.isRotated(),n=e.getOriginalSize(),r=e.getRect(),s=e.getOffset(),o=s.x+(n.width-r.width)/2,a=s.y-(n.height-r.height)/2;if(i){var h=this._tmpRect.x;this._tmpRect.x=r.x+r.height-this._tmpRect.y-this._tmpRect.height-a,this._tmpRect.y=h+r.y-o,this._tmpRect.y<0&&(this._tmpRect.height+=a)}else this._tmpRect.x+=r.x-o,this._tmpRect.y+=r.y+a;return i},t}();Zj.instance=void 0,Zj.instance=new Zj;var $j,tX=new ok(64,64),eX=new OF(null),iX=null,nX=null,rX=null,sX=null,oX={updateProcessingData:function(t,e,i,n,r,s){t.fontSize=r.fontSize,t.actualFontSize=r.fontSize,t.originFontSize=rX?rX.fontSize:r.fontSize,e.horizontalAlign=r.horizontalAlign,e.verticalAlign=r.verticalAlign,e.spacingX=r.spacingX;var o=r.overflow;e.overFlow=o,e.lineHeight=r.lineHeight,i.nodeContentSize.width=s.width,i.nodeContentSize.height=s.height,o===rG.NONE?(e.wrapping=!1,i.nodeContentSize.width+=2*ak.margin,i.nodeContentSize.height+=2*ak.margin):o===rG.RESIZE_HEIGHT?(e.wrapping=!0,i.nodeContentSize.height+=2*ak.margin):e.wrapping=r.enableWrapText,n.uiTransAnchorX=s.anchorX,n.uiTransAnchorY=s.anchorY,ak.lineHeight=r.lineHeight,ak.fontSize=r.fontSize,t.spriteFrame=sX,t.fntConfig=rX,t.fontFamily=ak.fontFamily,t.color.set(r.color)},updateRenderData:function(t){if(t.renderData&&iX!==t){if(t.renderData.vertDirty){nX=(iX=t).node._uiProps.uiTransformComp;var e=t.renderData,i=Zj.instance,n=t.textStyle,r=t.textLayout,s=t.textLayoutData,o=t.textRenderData;n.fontScale=CH.getScaleX(),this._updateFontFamily(t),this.updateProcessingData(n,r,s,o,t,nX),this._updateLabelInfo(t),n.fontDesc=ak.fontDesc,i.processingString(!0,n,r,s,t.string),this.resetRenderData(t),o.quadCount=0,i.generateRenderInfo(!0,n,r,s,o,t.string,this.generateVertexData),e.dataLength=o.quadCount,e.resize(e.dataLength,e.dataLength/2*3);for(var a=e.data,h=0,u=o.quadCount;h<u;h++)a[h]=o.vertexBuffer[h];var l=e.indexCount;this.createQuadIndices(l),e.chunk.setIndexBuffer($j),iX.actualFontSize=n.actualFontSize,nX.setContentSize(s.nodeContentSize),this.updateUVs(t),this.updateColor(t),e.vertDirty=!1,iX=null,this._resetProperties()}t.spriteFrame&&t.renderData.updateRenderData(t,t.spriteFrame)}},updateUVs:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.vertexCount,r=e.data,s=3,o=0;o<n;o++){var a=r[o];i[s]=a.u,i[s+1]=a.v,s+=9}},updateColor:function(){},resetRenderData:function(t){var e=t.renderData;e.dataLength=0,e.resize(0,0)},generateVertexData:function(t,e,i,n,r,s,o,a,h){var u=n,l=t.bmfontScale,c=i.vertexBuffer,_=r.width,d=r.height,f=s.width,p=s.height,m=0,g=0,y=0,v=0;o?(m=s.x/_,v=(s.x+p)/_,g=(s.y+f)/d,y=s.y/d,c[u].u=m,c[u].v=y,c[u+1].u=m,c[u+1].v=g,c[u+2].u=v,c[u+2].v=y,c[u+3].u=v,c[u+3].v=g):(m=s.x/_,v=(s.x+f)/_,g=(s.y+p)/d,y=s.y/d,c[u].u=m,c[u].v=g,c[u+1].u=v,c[u+1].v=g,c[u+2].u=m,c[u+2].v=y,c[u+3].u=v,c[u+3].v=y),c[u].x=a,c[u].y=h-p*l,c[u+1].x=a+f*l,c[u+1].y=h-p*l,c[u+2].x=a,c[u+2].y=h,c[u+3].x=a+f*l,c[u+3].y=h},_updateFontFamily:function(t){var e=t.font;sX=e.spriteFrame,rX=e.fntConfig,ak.fontAtlas=e.fontDefDictionary,ak.fontAtlas||(t.cacheMode===sG.CHAR?ak.fontAtlas=tX:ak.fontAtlas=eX),bN.packToDynamicAtlas(t,sX)},_updateLabelInfo:function(){ak.hash="",ak.margin=0},_resetProperties:function(){rX=null,sX=null,ak.hash="",ak.margin=0},createQuadIndices:function(t){if(t%6==0){var e=t/6;$j=null,$j=new Uint16Array(t);for(var i=0,n=0;n<e;n++)$j[i++]=0+4*n,$j[i++]=1+4*n,$j[i++]=2+4*n,$j[i++]=1+4*n,$j[i++]=3+4*n,$j[i++]=2+4*n}else console.error("illegal index count!")}},aX=new dn(255,255,255,255),hX={createData:function(t){var e=t.requestRenderData();return e.resize(0,0),e},fillBuffers:function(t){var e=t.node;aX.set(t.color),aX.a=255*e._uiProps.opacity,wd(e,0,t.renderData,aX)},appendQuad:function(t,e,i,n,r,s,o){var a=t.renderData;if(a){var h=a.dataLength;a.dataLength+=4,a.resize(a.dataLength,a.dataLength/2*3);var u=a.data,l=e.width,c=e.height,_=i.width,d=i.height,f=0,p=0,m=0,g=0;n?(f=i.x/l,g=(i.x+d)/l,p=(i.y+_)/c,m=i.y/c,u[h].u=f,u[h].v=m,u[h+1].u=f,u[h+1].v=p,u[h+2].u=g,u[h+2].v=m,u[h+3].u=g,u[h+3].v=p):(f=i.x/l,g=(i.x+_)/l,p=(i.y+d)/c,m=i.y/c,u[h].u=f,u[h].v=p,u[h+1].u=g,u[h+1].v=p,u[h+2].u=f,u[h+2].v=m,u[h+3].u=g,u[h+3].v=m),u[h].x=r,u[h].y=s-d*o,u[h+1].x=r+_*o,u[h+1].y=s-d*o,u[h+2].x=r,u[h+2].y=s,u[h+3].x=r+_*o,u[h+3].y=s}}};Vt(hX,oX);var uX=null,lX=Gt(oX,{getAssemblerData:function(){return uX||(uX=new ok(1024,1024)),uX.getTexture()},_updateFontFamily:function(t){ak.fontAtlas=uX,ak.fontFamily=this._getFontFamily(t),t.enableOutline&&t.outlineWidth>0?(ak.isOutlined=!0,ak.margin=t.outlineWidth,ak.out=t.outlineColor.clone(),ak.out.a=t.outlineColor.a*t.color.a/255):(ak.isOutlined=!1,ak.margin=0)},_getFontFamily:function(t){var e="Arial";return t.useSystemFont?e=t.fontFamily||"Arial":t.font&&(e=t.font._nativeAsset||"Arial"),e},_updateLabelInfo:function(t){ak.fontDesc=this._getFontDesc(),ak.color=t.color,ak.hash=function(t){var e=t.color.toHEX(),i="";return t.isOutlined&&t.margin>0&&(i=i+t.margin+t.out.toHEX()),""+t.fontSize+t.fontFamily+e+i}(ak)},_getFontDesc:function(){return ak.fontSize.toString()+"px "+ak.fontFamily}}),cX=new dn(255,255,255,255),_X={createData:function(t){var e=t.requestRenderData();return e.resize(0,0),e},fillBuffers:function(t){if(t.renderData){var e=t.node;cX.a=255*e._uiProps.opacity,wd(e,0,t.renderData,cX)}},updateColor:function(){}};Vt(_X,lX);var dX=lG.Overflow,fX={updateProcessingData:function(t,e,i,n,r,s){t.isSystemFontUsed=r.useSystemFont,t.fontSize=r.fontSize,i.nodeContentSize.width=i.canvasSize.width=s.width,i.nodeContentSize.height=i.canvasSize.height=s.height,e.lineHeight=r.lineHeight,e.overFlow=r.overflow,r.overflow===dX.NONE?e.wrapping=!1:r.overflow===dX.RESIZE_HEIGHT?e.wrapping=!0:e.wrapping=r.enableWrapText,t.isBold=r.isBold,t.isItalic=r.isItalic,t.isUnderline=r.isUnderline,t.underlineHeight=r.underlineHeight,r.enableOutline&&r.outlineWidth>0?(t.isOutlined=!0,t.outlineColor.set(r.outlineColor),t.outlineWidth=r.outlineWidth):t.isOutlined=!1,r.enableShadow&&(r.shadowBlur>0||!wi(r.shadowOffset.x,0)||!wi(r.shadowOffset.y,0))?(t.hasShadow=!0,t.shadowColor.set(r.shadowColor),t.shadowBlur=r.shadowBlur,t.shadowOffsetX=r.shadowOffset.x,t.shadowOffsetY=r.shadowOffset.y):t.hasShadow=!1,t.color.set(r.color),n.texture=r.spriteFrame,n.uiTransAnchorX=s.anchorX,n.uiTransAnchorY=s.anchorY,e.horizontalAlign=r.horizontalAlign,e.verticalAlign=r.verticalAlign},getAssemblerData:function(){var t=lG._canvasPool.get();return t.canvas.width=t.canvas.height=1,t},resetAssemblerData:function(t){t&&lG._canvasPool.put(t)},updateRenderData:function(t){if(t.renderData){if(t.renderData.vertDirty){var e=t.node._uiProps.uiTransformComp,i=Zj.instance,n=t.textStyle,r=t.textLayout,s=t.textLayoutData,o=t.textRenderData;n.fontScale=CH.getScaleX(),this.updateProcessingData(n,r,s,o,t,e),i.setCanvasUsed(t.assemblerData.canvas,t.assemblerData.context),n.fontFamily=this._updateFontFamily(t),this._resetDynamicAtlas(t),i.processingString(!1,n,r,s,t.string),i.generateRenderInfo(!1,n,r,s,o,t.string,this.generateVertexData);var a=t.renderData;a.textureDirty=!0,this._calDynamicAtlas(t,s),t.actualFontSize=n.actualFontSize,e.setContentSize(s.nodeContentSize);var h=a.data;h[0]=o.vertexBuffer[0],h[1]=o.vertexBuffer[1],h[2]=o.vertexBuffer[2],h[3]=o.vertexBuffer[3],this.updateUVs(t),t.renderData.vertDirty=!1,t.contentWidth=s.nodeContentSize.width}t.spriteFrame&&t.renderData.updateRenderData(t,t.spriteFrame)}},generateVertexData:function(t,e,i){var n=i.vertexBuffer,r=e.nodeContentSize.width,s=e.nodeContentSize.height,o=i.uiTransAnchorX*r,a=i.uiTransAnchorY*s;n[0].x=-o,n[0].y=-a,n[1].x=r-o,n[1].y=-a,n[2].x=-o,n[2].y=s-a,n[3].x=r-o,n[3].y=s-a},updateVertexData:function(){},updateUVs:function(){},_updateFontFamily:function(t){return t.useSystemFont?t.fontFamily||"Arial":t.font&&t.font._nativeAsset||"Arial"},_calDynamicAtlas:function(t,e){if(!(t.cacheMode!==lG.CacheMode.BITMAP||e.canvasSize.width<=0||e.canvasSize.height<=0)){var i=t.ttfSpriteFrame;bN.packToDynamicAtlas(t,i)}},_resetDynamicAtlas:function(t){if(t.cacheMode===lG.CacheMode.BITMAP){var e=t.ttfSpriteFrame;bN.deleteAtlasSpriteFrame(e),e._resetDynamicAtlasFrame()}}},pX=dn.WHITE.clone(),mX=Uint16Array.from([0,1,2,1,3,2]),gX={createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6),t.textRenderData.quadCount=4;var i=e.chunk.vb;i[3]=i[21]=i[22]=i[31]=0,i[4]=i[12]=i[13]=i[30]=1;for(var n=5,r=0;r<4;r++)dn.toArray(i,pX,n),n+=9;return e.chunk.setIndexBuffer(mX),e},fillBuffers:function(t){for(var e=t.renderData,i=e.chunk,n=e.data,r=t.node,s=i.vb,o=r.worldMatrix,a=e.floatStride,h=0,u=n.length,l=0;l<u;l++){var c=n[l],_=c.x,d=c.y,f=o.m03*_+o.m07*d+o.m15;f=f?1/f:1,s[0+(h=l*a)]=(o.m00*_+o.m04*d+o.m12)*f,s[h+1]=(o.m01*_+o.m05*d+o.m13)*f,s[h+2]=(o.m02*_+o.m06*d+o.m14)*f}var p=i.vertexOffset,m=i.meshBuffer,g=i.meshBuffer.iData,y=m.indexOffset;g[y++]=p,g[y++]=p+1,g[y++]=p+2,g[y++]=p+2,g[y++]=p+1,g[y++]=p+3,m.indexOffset+=6},updateVertexData:function(t){var e=t.renderData;if(e){var i=t.node._uiProps.uiTransformComp,n=i.width,r=i.height,s=i.anchorX*n,o=i.anchorY*r,a=e.data;a[0].x=-s,a[0].y=-o,a[1].x=n-s,a[1].y=-o,a[2].x=-s,a[2].y=r-o,a[3].x=n-s,a[3].y=r-o}},updateUVs:function(t){var e=t.renderData;if(e&&t.ttfSpriteFrame){var i=e.chunk.vb,n=t.ttfSpriteFrame.uv;i[3]=n[0],i[4]=n[1],i[12]=n[2],i[13]=n[3],i[21]=n[4],i[22]=n[5],i[30]=n[6],i[31]=n[7]}},updateColor:function(){}};Vt(gX,fX);var yX=t("l",{getAssembler:function(t){var e=gX;return t.font instanceof MF?e=hX:t.cacheMode===lG.CacheMode.CHAR&&(e=_X),e}});lG.Assembler=yX;var vX=uz.FillType,SX=new In,TX=Uint16Array.from([0,1,2,1,3,2]),AX={updateRenderData:function(t){var e=t.spriteFrame;bN.packToDynamicAtlas(t,e);var i=t.renderData;if(i&&e){if(!i.vertDirty)return;var n=t.fillStart,r=t.fillRange;r<0&&(n+=r,r=-r),r=(r=(r=n+r)>1?1:r)<0?0:r;var s=(n=(n=n>1?1:n)<0?0:n)+(r=(r-=n)<0?0:r);s=s>1?1:s,this.updateUVs(t,n,s),this.updateVertexData(t,n,s),i.updateRenderData(t,e)}},updateUVs:function(t,e,i){var n=t.spriteFrame,r=t.renderData.chunk.vb,s=n.width,o=n.height,a=n.rect,h=0,u=0,l=0,c=0,_=0,d=0,f=0,p=0,m=0,g=0;switch(n.isRotated()?(h=a.x/s,u=(a.y+a.width)/o,l=_=h,f=m=(a.x+a.height)/s,d=g=u,c=p=a.y/o):(h=a.x/s,u=(a.y+a.height)/o,l=f=h,_=m=(a.x+a.width)/s,c=d=u,p=g=a.y/o),t.fillType){case vX.HORIZONTAL:r[3]=l+(_-l)*e,r[4]=c+(d-c)*e,r[12]=l+(_-l)*i,r[13]=c+(d-c)*i,r[21]=f+(m-f)*e,r[22]=p+(g-p)*e,r[30]=f+(m-f)*i,r[31]=p+(g-p)*i;break;case vX.VERTICAL:r[3]=l+(f-l)*e,r[4]=c+(p-c)*e,r[12]=_+(m-_)*e,r[13]=d+(g-d)*e,r[21]=l+(f-l)*i,r[22]=c+(p-c)*i,r[30]=_+(m-_)*i,r[31]=d+(g-d)*i;break;default:J(2626)}},updateVertexData:function(t,e,i){var n=t.renderData.data,r=t.node._uiProps.uiTransformComp,s=r.width,o=r.height,a=r.anchorX*s,h=r.anchorY*o,u=-a,l=-h,c=s-a,_=o-h,d=0;switch(t.fillType){case vX.HORIZONTAL:d=u+(c-u)*i,u+=(c-u)*e,c=d;break;case vX.VERTICAL:d=l+(_-l)*i,l+=(_-l)*e,_=d;break;default:J(2626)}n[0].x=u,n[0].y=l,n[1].x=c,n[1].y=l,n[2].x=u,n[2].y=_,n[3].x=c,n[3].y=_},createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6),e.chunk.setIndexBuffer(TX);for(var i,n=d(e.data);!(i=n()).done;)i.value.z=0;return e},updateWorldVertexData:function(t,e){t.node.getWorldMatrix(SX);for(var i=t.renderData.floatStride,n=t.renderData.data,r=e.vb,s=0,o=0;o<4;o++){var a=n[o],h=a.x,u=a.y,l=SX.m03*h+SX.m07*u+SX.m15;l=l?1/l:1,r[s=o*i]=(SX.m00*h+SX.m04*u+SX.m12)*l,r[s+1]=(SX.m01*h+SX.m05*u+SX.m13)*l,r[s+2]=(SX.m02*h+SX.m06*u+SX.m14)*l}},fillBuffers:function(t){var e=t.renderData,i=e.chunk;(t._flagChangedVersion!==t.node.flagChangedVersion||e.vertDirty)&&(this.updateWorldVertexData(t,i),e.vertDirty=!1,t._flagChangedVersion=t.node.flagChangedVersion),i.bufferId;var n=i.vertexOffset,r=i.meshBuffer,s=i.meshBuffer.iData,o=r.indexOffset;s[o++]=n,s[o++]=n+1,s[o++]=n+2,s[o++]=n+2,s[o++]=n+1,s[o++]=n+3,r.indexOffset+=6},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=5,s=t.color,o=s.r/255,a=s.g/255,h=s.b/255,u=t.node._uiProps.opacity,l=0;l<4;l++)i[r]=o,i[r+1]=a,i[r+2]=h,i[r+3]=u,r+=n}},bX=2*Math.PI,EX=1e-6,CX=new In,wX=[new Ln,new Ln,new Ln,new Ln],xX=new Array(4),RX=new Array(8),IX=[new Ln,new Ln,new Ln,new Ln],BX=[new Ln,new Ln,new Ln,new Ln],DX=new Ln,PX=[new Ln,new Ln,new Ln,new Ln],OX=null;function MX(t,e,i,n,r,s,o){var a=Math.sin(s);a=Math.abs(a)>EX?a:0;var h=Math.cos(s),u=0,l=0;if(0!==(h=Math.abs(h)>EX?h:0)){if(u=a/h,(t-r.x)*h>0){var c=r.y+u*(t-r.x);o[0].x=t,o[0].y=c}if((e-r.x)*h>0){var _=r.y+u*(e-r.x);o[2].x=e,o[2].y=_}}if(0!==a){if(l=h/a,(n-r.y)*a>0){var d=r.x+l*(n-r.y);o[3].x=d,o[3].y=n}if((i-r.y)*a>0){var f=r.x+l*(i-r.y);o[1].x=f,o[1].y=i}}}function LX(t,e){var i=e.x-t.x,n=e.y-t.y;if(0===i&&0===n)return 0;if(0===i)return n>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(n/i);return i<0&&(r+=Math.PI),r}function NX(t,e,i,n,r){var s=xX,o=s[0],a=s[1],h=s[2],u=s[3];t[e].x=i.x,t[e].y=i.y,t[e+1].x=n.x,t[e+1].y=n.y,t[e+2].x=r.x,t[e+2].y=r.y,FX((i.x-o)/(h-o),(i.y-a)/(u-a),t,e),FX((n.x-o)/(h-o),(n.y-a)/(u-a),t,e+1),FX((r.x-o)/(h-o),(r.y-a)/(u-a),t,e+2)}function FX(t,e,i,n){var r=RX,s=r[0]+(r[2]-r[0])*t,o=r[4]+(r[6]-r[4])*t,a=r[1]+(r[3]-r[1])*t,h=r[5]+(r[7]-r[5])*t,u=i[n];u.u=s+(o-s)*e,u.v=a+(h-a)*e}for(var kX={useModel:!1,createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.spriteFrame;bN.packToDynamicAtlas(t,e),this.updateUVs(t);var i=t.renderData;if(i&&e){if(!i.vertDirty)return;var n=i.data,r=t.fillStart,s=t.fillRange;for(s<0&&(r+=s,s=-s);r>=1;)r-=1;for(;r<0;)r+=1;var o=(r*=bX)+(s*=bX);!function(t){var e=t.node._uiProps.uiTransformComp,i=e.width,n=e.height,r=e.anchorX*i,s=e.anchorY*n,o=-r,a=-s,h=i-r,u=n-s,l=xX;l[0]=o,l[1]=a,l[2]=h,l[3]=u;var c=t.fillCenter,_=DX.x=Math.min(Math.max(0,c.x),1)*(h-o)+o,d=DX.y=Math.min(Math.max(0,c.y),1)*(u-a)+a;wX[0].x=wX[3].x=o,wX[1].x=wX[2].x=h,wX[0].y=wX[1].y=a,wX[2].y=wX[3].y=u;for(var f=0,p=PX;f<p.length;f++){var m=p[f];Ln.set(m,0,0)}_!==l[0]&&Ln.set(PX[0],3,0),_!==l[2]&&Ln.set(PX[2],1,2),d!==l[1]&&Ln.set(PX[1],0,1),d!==l[3]&&Ln.set(PX[3],2,3)}(t),function(t){var e=t.width,i=t.height,n=t.getRect(),r=0,s=0,o=0,a=0,h=RX;t.isRotated()?(r=n.x/e,s=(n.x+n.height)/e,o=n.y/i,a=(n.y+n.width)/i,h[0]=h[2]=r,h[4]=h[6]=s,h[3]=h[7]=a,h[1]=h[5]=o):(r=n.x/e,s=(n.x+n.width)/e,o=n.y/i,a=(n.y+n.height)/i,h[0]=h[4]=r,h[2]=h[6]=s,h[1]=h[3]=a,h[5]=h[7]=o)}(e),MX(xX[0],xX[2],xX[1],xX[3],DX,r,IX),MX(xX[0],xX[2],xX[1],xX[3],DX,r+s,BX);for(var a=0,h=0;h<4;++h){var u=PX[h];if(u)if(s>=bX)i.dataLength=a+3,NX(n,a,DX,wX[u.x],wX[u.y]),a+=3;else{var l=LX(DX,wX[u.x]),c=LX(DX,wX[u.y]);c<l&&(c+=bX),l-=bX,c-=bX;for(var _=0;_<3;++_)l>=o||(l>=r?(i.dataLength=a+3,NX(n,a,DX,wX[u.x],c>=o?BX[h]:wX[u.y]),a+=3):c>r&&(c<=o?(i.dataLength=a+3,NX(n,a,DX,IX[h],wX[u.y]),a+=3):(i.dataLength=a+3,NX(n,a,DX,IX[h],BX[h]),a+=3))),l+=bX,c+=bX}}0===a&&(i.dataLength=0),i.resize(a,a),i.updateRenderData(t,e)}},createQuadIndices:function(t){OX=null,OX=new Uint16Array(t);for(var e=0,i=0;i<t;i++)OX[e++]=i},fillBuffers:function(t){var e=t.node,i=t.renderData,n=i.chunk;(t._flagChangedVersion!==e.flagChangedVersion||i.vertDirty)&&(this.updateWorldVertexAndUVData(t,n),i.vertDirty=!1,t._flagChangedVersion=e.flagChangedVersion),this.updateColorLate(t),n.bufferId;for(var r=n.vertexOffset,s=n.meshBuffer,o=n.meshBuffer.iData,a=s.indexOffset,h=0;h<i.indexCount;h++)o[a+h]=r+h;s.indexOffset+=i.indexCount,s.setDirty()},updateWorldUVData:function(t){for(var e=t.renderData,i=e.floatStride,n=e.data,r=e.chunk.vb,s=0;s<n.length;s++){var o=s*i;r[o+3]=n[s].u,r[o+4]=n[s].v}},updateWorldVertexAndUVData:function(t,e){t.node.getWorldMatrix(CX);for(var i=t.renderData,n=i.floatStride,r=t.renderData.data,s=e.vb,o=i.vertexCount,a=0,h=0;h<o;h++){var u=r[h],l=u.x,c=u.y,_=CX.m03*l+CX.m07*c+CX.m15;_=_?1/_:1,s[a+0]=(CX.m00*l+CX.m04*c+CX.m12)*_,s[a+1]=(CX.m01*l+CX.m05*c+CX.m13)*_,s[a+2]=(CX.m02*l+CX.m06*c+CX.m14)*_,s[a+3]=u.u,s[a+4]=u.v,a+=n}},updateUVs:function(t){t.renderData.vertDirty=!0,t.markForUpdateRenderData()},updateColorLate:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=e.vertexCount,s=5,o=t.color,a=o.r/255,h=o.g/255,u=o.b/255,l=t.node._uiProps.opacity,c=0;c<r;c++)i[s]=a,i[s+1]=h,i[s+2]=u,i[s+3]=l,s+=n},updateColor:function(){}},VX=Uint16Array.from([0,1,2,1,3,2]),GX={createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.resize(4,6),e.chunk.setIndexBuffer(VX),e},updateRenderData:function(t){var e=t.spriteFrame;bN.packToDynamicAtlas(t,e),this.updateUVs(t);var i=t.renderData;i&&e&&(i.vertDirty&&this.updateVertexData(t),i.updateRenderData(t,e))},updateWorldVerts:function(t,e){for(var i=t.renderData,n=e.vb,r=i.data,s=t.node.worldMatrix,o=i.floatStride,a=0,h=r.length,u=0;u<h;u++){var l=r[u],c=l.x,_=l.y,d=s.m03*c+s.m07*_+s.m15;d=d?1/d:1,n[0+(a=u*o)]=(s.m00*c+s.m04*_+s.m12)*d,n[a+1]=(s.m01*c+s.m05*_+s.m13)*d,n[a+2]=(s.m02*c+s.m06*_+s.m14)*d}},fillBuffers:function(t){if(null!==t){var e=t.renderData,i=e.chunk;(t._flagChangedVersion!==t.node.flagChangedVersion||e.vertDirty)&&(this.updateWorldVerts(t,i),e.vertDirty=!1,t._flagChangedVersion=t.node.flagChangedVersion);var n=i.vertexOffset,r=i.meshBuffer,s=i.meshBuffer.iData,o=r.indexOffset,a=n;s[o++]=a,s[o++]=a+1,s[o++]=a+2,s[o++]=a+1,s[o++]=a+3,s[o++]=a+2,r.indexOffset+=6}},updateVertexData:function(t){var e=t.renderData;if(e){var i=t.node._uiProps.uiTransformComp,n=e.data,r=i.width,s=i.height,o=i.anchorX*r,a=i.anchorY*s,h=0,u=0,l=0,c=0;if(t.trim)h=-o,u=-a,l=r-o,c=s-a;else{var _=t.spriteFrame,d=_.originalSize,f=r/d.width,p=s/d.height,m=_.trimmedBorder;h=m.x*f-o,u=m.z*p-a,l=r+m.y*f-o,c=s+m.w*p-a}n[0].x=h,n[0].y=u,n[1].x=l,n[1].y=u,n[2].x=h,n[2].y=c,n[3].x=l,n[3].y=c,e.vertDirty=!0}},updateUVs:function(t){if(t.spriteFrame){var e=t.renderData.chunk.vb,i=t.spriteFrame.uv;e[3]=i[0],e[4]=i[1],e[12]=i[2],e[13]=i[3],e[21]=i[4],e[22]=i[5],e[30]=i[6],e[31]=i[7]}},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,n=5,r=t.color,s=r.r/255,o=r.g/255,a=r.b/255,h=r.a/255,u=0;u<4;u++,n+=e.floatStride)i[n]=s,i[n+1]=o,i[n+2]=a,i[n+3]=h}},UX=new In,zX=[],HX=0;HX<4;HX++)zX.push({x:0,y:0,z:0,u:0,v:0,color:new dn});var WX,jX,XX,qX,YX,KX,JX,QX={createData:function(t){var e=t.requestRenderData();return e.dataLength=16,e.resize(16,54),this.QUAD_INDICES=new Uint16Array(54),this.createQuadIndices(4,4),e.chunk.setIndexBuffer(this.QUAD_INDICES),e},createQuadIndices:function(t,e){for(var i=0,n=0;n<t-1;n++)for(var r=0;r<e-1;r++){var s=n*e+r;this.QUAD_INDICES[i++]=s,this.QUAD_INDICES[i++]=s+1,this.QUAD_INDICES[i++]=s+e,this.QUAD_INDICES[i++]=s+1,this.QUAD_INDICES[i++]=s+1+e,this.QUAD_INDICES[i++]=s+e}},updateRenderData:function(t){var e=t.spriteFrame;bN.packToDynamicAtlas(t,e),this.updateUVs(t);var i=t.renderData;i&&e&&(i.vertDirty&&this.updateVertexData(t),i.updateRenderData(t,e))},updateVertexData:function(t){var e=t.renderData,i=e.data,n=t.node._uiProps.uiTransformComp,r=n.width,s=n.height,o=n.anchorX*r,a=n.anchorY*s,h=t.spriteFrame,u=h.insetLeft,l=h.insetRight,c=h.insetTop,_=h.insetBottom,d=r-u-l,f=s-c-_,p=r/(u+l),m=s/(c+_);p=Number.isNaN(p)||p>1?1:p,m=Number.isNaN(m)||m>1?1:m,d=d<0?0:d,f=f<0?0:f,zX[0].x=-o,zX[0].y=-a,zX[1].x=u*p-o,zX[1].y=_*m-a,zX[2].x=zX[1].x+d,zX[2].y=zX[1].y+f,zX[3].x=r-o,zX[3].y=s-a;for(var g=0;g<4;g++)for(var y=0;y<4;y++){var v=4*g+y;v<e.dataLength&&g<zX.length&&y<zX.length&&(i[v].x=zX[y].x,i[v].y=zX[g].y)}},fillBuffers:function(t){var e=t.renderData,i=e.chunk;(t._flagChangedVersion!==t.node.flagChangedVersion||e.vertDirty)&&(this.updateWorldVertexData(t,i),e.vertDirty=!1,t._flagChangedVersion=t.node.flagChangedVersion),i.bufferId;for(var n=i.vertexOffset,r=i.meshBuffer,s=i.meshBuffer.iData,o=r.indexOffset,a=0;a<3;++a)for(var h=0;h<3;++h){var u=n+4*a+h;s[o++]=u,s[o++]=u+1,s[o++]=u+4,s[o++]=u+1,s[o++]=u+5,s[o++]=u+4}r.indexOffset=o},updateWorldVertexData:function(t,e){t.node.getWorldMatrix(UX);for(var i=t.renderData,n=i.floatStride,r=i.data,s=e.vb,o=0,a=0;a<4;++a)for(var h=r[4*a],u=0;u<4;++u){var l=r[u].x,c=h.y,_=UX.m03*l+UX.m07*c+UX.m15;_=_?1/_:1,s[0+(o=(4*a+u)*n)]=(UX.m00*l+UX.m04*c+UX.m12)*_,s[o+1]=(UX.m01*l+UX.m05*c+UX.m13)*_,s[o+2]=(UX.m02*l+UX.m06*c+UX.m14)*_}},updateUVs:function(t){if(t.spriteFrame)for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=t.spriteFrame.uvSliced,s=3,o=0;o<16;o++)i[s]=r[o].u,i[s+1]=r[o].v,s+=n},updateColor:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=5,s=t.color,o=s.r/255,a=s.g/255,h=s.b/255,u=t.node._uiProps.opacity,l=0;l<16;l++)i[r]=o,i[r+1]=a,i[r+2]=h,i[r+3]=u,r+=n}},ZX=new In,$X=0,tq=[],eq=null;function iq(t){return t&&(t.insetTop>0||t.insetBottom>0||t.insetLeft>0||t.insetRight>0)?2:0}var nq={createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.renderData,i=t.spriteFrame;if(i&&e&&e.vertDirty){var n=t.node._uiProps.uiTransformComp,r=Math.abs(n.width),s=Math.abs(n.height),o=i.getRect(),a=i.insetLeft,h=i.insetRight,u=o.width-a-h,l=i.insetTop,c=i.insetBottom,_=o.height-l-c,d=r-a-h,f=s-l-c;d=d>0?d:0,f=f>0?f:0;var p=0===u?d:d/u,m=0===_?f:f/_,g=iq(i),y=Math.ceil(m+g),v=Math.ceil(p+g);e.dataLength=4*y*v,this.updateVerts(t,d,f,y,v),e.vertexCount!==y*v*4&&(t.renderEntity.colorDirty=!0),e.resize(y*v*4,y*v*6),e.updateRenderData(t,i)}},createQuadIndices:function(t){if(t%6==0){var e=t/6;eq=null,eq=new Uint16Array(t);for(var i=0,n=0;n<e;n++)eq[i++]=0+4*n,eq[i++]=1+4*n,eq[i++]=2+4*n,eq[i++]=1+4*n,eq[i++]=3+4*n,eq[i++]=2+4*n}else V("illegal index count!")},updateUVs:function(t){t.renderData.vertDirty=!0,t.markForUpdateRenderData()},fillBuffers:function(t){var e=t.node,i=t.renderData,n=i.chunk;(t._flagChangedVersion!==e.flagChangedVersion||i.vertDirty)&&(this.updateWorldVertexAndUVData(t,n),i.vertDirty=!1,t._flagChangedVersion=e.flagChangedVersion),this.updateColorLate(t),n.bufferId;for(var r=n.vertexOffset,s=n.meshBuffer,o=n.meshBuffer.iData,a=s.indexOffset,h=0;h<i.indexCount;h+=6)o[a++]=r,o[a++]=r+1,o[a++]=r+2,o[a++]=r+1,o[a++]=r+3,o[a++]=r+2,r+=4,s.indexOffset+=6;s.setDirty()},updateWorldUVData:function(t){for(var e=t.renderData,i=e.floatStride,n=e.data,r=e.chunk.vb,s=0;s<n.length;s++){var o=s*i;r[o+3]=n[s].u,r[o+4]=n[s].v}},updateWorldVertexAndUVData:function(t,e){t.node.getWorldMatrix(ZX);for(var i=t.renderData,n=i.floatStride,r=i.data,s=e.vb,o=r.length,a=0;a<o;a++){var h=r[a].x,u=r[a].y,l=r[a].z,c=ZX.m03*h+ZX.m07*u+ZX.m11*l+ZX.m15;c=c?1/c:1;var _=a*n;s[_]=(ZX.m00*h+ZX.m04*u+ZX.m08*l+ZX.m12)*c,s[_+1]=(ZX.m01*h+ZX.m05*u+ZX.m09*l+ZX.m13)*c,s[_+2]=(ZX.m02*h+ZX.m06*u+ZX.m10*l+ZX.m14)*c}this.updateWorldUVData(t)},updateVerts:function(t,e,i,n,r){var s,o,a=t.node._uiProps.uiTransformComp,h=t.renderData.data,u=t.spriteFrame,l=u.rect,c=Math.abs(a.width),_=Math.abs(a.height),d=a.anchorX*c,f=a.anchorY*_,p=u.insetLeft,m=u.insetRight,g=l.width-p-m,y=u.insetTop,v=u.insetBottom,S=l.height-y-v,T=a.width/(p+m)>1?1:a.width/(p+m),A=a.height/(y+v)>1?1:a.height/(y+v);s=g>0?Math.floor(1e3*e)/1e3%g==0?g:e%g:e,o=S>0?Math.floor(1e3*i)/1e3%S==0?S:i%S:i,tq.length=0,$X=Math.max(n+1,r+1);for(var b=0;b<$X;b++)tq.push({x:0,y:0,z:0,u:0,v:0,color:new dn});var E=iq(u);if(0===E)for(var C=0;C<$X;C++)tq[C].x=C>=r?c-d:C*g-d,tq[C].y=C>=n?_-f:C*S-f;else for(var w=0;w<$X;w++)0===w?tq[w].x=-d:1===w?tq[w].x=p*T-d:w>1&&w<r-1?tq[w].x=g>0?p*T-d+g*(w-1):p+e-d:w===r-1?tq[w].x=p*T-d+s+g*(w-2):w>=r&&(tq[w].x=Math.min(p+e+m,c)-d),0===w?tq[w].y=-f:1===w?tq[w].y=v*A-f:w>1&&w<n-1?tq[w].y=S>0?v*A-f+S*(w-1):v+i-f:w===n-1?tq[w].y=v*A-f+o+S*(w-2):w>=n&&(tq[w].y=Math.min(v+i+y,_)-f);for(var x=0,R=0,I=0,B=0,D=0;D<n;++D){I=tq[D].y,B=tq[D+1].y;for(var P=0;P<r;++P){x=tq[P].x,R=tq[P+1].x;var O=4*(D*r+P);h[O].x=x,h[O].y=I,h[O+1].x=R,h[O+1].y=I,h[O+2].x=x,h[O+2].y=B,h[O+3].x=R,h[O+3].y=B}}var M=u.rotated;u.uv;var L=u.uvSliced;WX=L[0],jX=L[1],XX=L[2],qX=L[3],YX=L[4],KX=L[8],JX=L[12];for(var N=0,F=0,k=0===g?e:e/g,V=0===S?i:i/S,G=[],U=[],z=0;z<n;++z){F=i>S?i>=(E>0?z:z+1)*S?1:V%1:V;for(var H=0;H<r;++H){N=e>g?e>=(E>0?H:H+1)*g?1:k%1:k,M?(0===E?(G[0]=YX.u,G[1]=YX.u,G[2]=YX.u+(KX.u-YX.u)*F,U[0]=jX.v,U[1]=jX.v+(XX.v-jX.v)*N,U[2]=jX.v):(0===z?(G[0]=WX.u,G[1]=WX.u,G[2]=YX.u):z<n-1?(G[0]=YX.u,G[1]=YX.u,G[2]=YX.u+(KX.u-YX.u)*F):z===n-1&&(G[0]=KX.u,G[1]=KX.u,G[2]=JX.u),0===H?(U[0]=WX.v,U[1]=jX.v,U[2]=WX.v):H<r-1?(U[0]=jX.v,U[1]=jX.v+(XX.v-jX.v)*N,U[2]=jX.v):H===r-1&&(U[0]=XX.v,U[1]=qX.v,U[2]=XX.v)),G[3]=G[2],U[3]=U[1]):(0===E?(G[0]=jX.u,G[1]=jX.u+(XX.u-jX.u)*N,G[2]=jX.u,U[0]=YX.v,U[1]=YX.v,U[2]=YX.v+(KX.v-YX.v)*F):(0===H?(G[0]=WX.u,G[1]=jX.u,G[2]=WX.u):H<r-1?(G[0]=jX.u,G[1]=jX.u+(XX.u-jX.u)*N,G[2]=jX.u):H===r-1&&(G[0]=XX.u,G[1]=qX.u,G[2]=XX.u),0===z?(U[0]=WX.v,U[1]=WX.v,U[2]=YX.v):z<n-1?(U[0]=YX.v,U[1]=YX.v,U[2]=YX.v+(KX.v-YX.v)*F):z===n-1&&(U[0]=KX.v,U[1]=KX.v,U[2]=JX.v)),G[3]=G[1],U[3]=U[2]);var W=4*(z*r+H);h[W].u=G[0],h[W].v=U[0],h[W+1].u=G[1],h[W+1].v=U[1],h[W+2].u=G[2],h[W+2].v=U[2],h[W+3].u=G[3],h[W+3].v=U[3]}}},updateColorLate:function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=e.vertexCount,s=5,o=t.color,a=o.r/255,h=o.g/255,u=o.b/255,l=t.node._uiProps.opacity,c=0;c<r;c++)i[s]=a,i[s+1]=h,i[s+2]=u,i[s+3]=l,s+=n},updateColor:function(){}},rq=uz.Type,sq=uz.FillType,oq=t("s",{getAssembler:function(t){var e=GX,i=t;switch(i.type){case rq.SLICED:e=QX;break;case rq.TILED:e=nq;break;case rq.FILLED:e=i.fillType===sq.RADIAL?kX:AX}return e}});uz.Assembler=oq;var aq=[Ax.EventType.MOUSE_DOWN,Ax.EventType.MOUSE_MOVE,Ax.EventType.MOUSE_UP,Ax.EventType.MOUSE_WHEEL],hq=[Ax.EventType.TOUCH_START,Ax.EventType.TOUCH_MOVE,Ax.EventType.TOUCH_END,Ax.EventType.TOUCH_CANCEL];new(function(){function t(){this.priority=cx.UI,this._isListDirty=!1,this._inDispatchCount=0,this._pointerEventProcessorList=[],this._processorListToAdd=[],this._processorListToRemove=[],bx._registerEventDispatcher(this),nL.callbacksInvoker.on(JM.ADD_POINTER_EVENT_PROCESSOR,this.addPointerEventProcessor,this),nL.callbacksInvoker.on(JM.REMOVE_POINTER_EVENT_PROCESSOR,this.removePointerEventProcessor,this),nL.callbacksInvoker.on(JM.MARK_LIST_DIRTY,this._markListDirty,this)}var e=t.prototype;return e.dispatchEvent=function(t){var e=t.type;return hq.includes(e)?this.dispatchEventTouch(t):!aq.includes(e)||this.dispatchEventMouse(t)},e.addPointerEventProcessor=function(t){0===this._inDispatchCount?this._pointerEventProcessorList.includes(t)||(this._pointerEventProcessorList.push(t),this._isListDirty=!0):this._processorListToAdd.includes(t)||this._processorListToAdd.push(t),he(this._processorListToRemove,t)},e.removePointerEventProcessor=function(t){0===this._inDispatchCount?(he(this._pointerEventProcessorList,t),this._isListDirty=!0):this._processorListToRemove.includes(t)||this._processorListToRemove.push(t),he(this._processorListToAdd,t)},e.dispatchEventMouse=function(t){this._inDispatchCount++,this._sortPointerEventProcessorList();for(var e=this._pointerEventProcessorList,i=e.length,n=!0,r=0;r<i;++r){var s=e[r];if(s.isEnabled&&s.shouldHandleEventMouse&&s._handleEventMouse(t)){if(n=!1,!t.preventSwallow)break;t.preventSwallow=!1}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),n},e.dispatchEventTouch=function(t){this._inDispatchCount++,this._sortPointerEventProcessorList();for(var e=this._pointerEventProcessorList,i=e.length,n=t.touch,r=!0,s=0;s<i;++s){var o=e[s];if(o.isEnabled&&o.shouldHandleEventTouch)if(t.type===bw.TOUCH_START){if(o._handleEventTouch(t)){if(o.isEnabled)o.claimedTouchIdList.push(n.getID());else{var a=new Iw([t.touch],!0,bw.TOUCH_CANCEL);a.touch=t.touch,o.dispatchEvent(a),o.claimedTouchIdList.length=0}if(r=!1,!t.preventSwallow)break;t.preventSwallow=!1}}else if(o.claimedTouchIdList.length>0){var h=o.claimedTouchIdList.indexOf(n.getID());if(-1!==h){if(o._handleEventTouch(t),t.type!==bw.TOUCH_END&&t.type!==bw.TOUCH_CANCEL||oe(o.claimedTouchIdList,h),r=!1,!t.preventSwallow)break;t.preventSwallow=!1}}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),r},e._updatePointerEventProcessorList=function(){for(var t=this._processorListToAdd,e=t.length,i=0;i<e;++i)this.addPointerEventProcessor(t[i]);t.length=0;for(var n=this._processorListToRemove,r=n.length,s=0;s<r;++s)this.removePointerEventProcessor(n[s]);n.length=0},e._sortPointerEventProcessorList=function(){if(this._isListDirty){for(var t=this._pointerEventProcessorList,e=t.length,i=0;i<e;++i){var n=t[i],r=n.node;if(r._uiProps){var s=r._uiProps.uiTransformComp;n.cachedCameraPriority=s.cameraPriority}}t.sort(this._sortByPriority),this._isListDirty=!1}},e._sortByPriority=function(t,e){var i=t.node,n=e.node;if(!(e&&n&&n.activeInHierarchy&&n._uiProps.uiTransformComp))return-1;if(!(t&&i&&i.activeInHierarchy&&i._uiProps.uiTransformComp))return 1;if(t.cachedCameraPriority!==e.cachedCameraPriority)return e.cachedCameraPriority-t.cachedCameraPriority;for(var r=i,s=n,o=!1;(null===(a=r.parent)||void 0===a?void 0:a.uuid)!==(null===(h=s.parent)||void 0===h?void 0:h.uuid);){var a,h,u,l,c,_;r=null===(null===(u=r)||void 0===u||null===(l=u.parent)||void 0===l?void 0:l.parent)?(o=!0)&&n:r&&r.parent,s=null===(null===(c=s)||void 0===c||null===(_=c.parent)||void 0===_?void 0:_.parent)?(o=!0)&&i:s&&s.parent}if(r.uuid===s.uuid){if(r.uuid===n.uuid)return-1;if(r.uuid===i.uuid)return 1}var d=r?r.getSiblingIndex():0,f=s?s.getSiblingIndex():0;return o?d-f:f-d},e._markListDirty=function(){this._isListDirty=!0},t}());var uq=new b_(null),lq=new In,cq=t("x",function(){function t(t){var e=this;this.device=void 0,this._screens=[],this._staticVBBuffer=null,this._bufferAccessors=new Map,this._drawBatchPool=void 0,this._batches=void 0,this._currBID=-1,this._indexStart=0,this._emptyMaterial=new xT,this._currRenderData=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currStaticRoot=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0,this._currDepthStencilStateStage=null,this._currIsStatic=!1,this._currHash=0,this._currIsMiddleware=!1,this._middlewareEnableBatch=!1,this._middlewareBuffer=null,this._middlewareIndexStart=0,this._middlewareIndexCount=0,this._pOpacity=1,this._opacityDirty=0,this._descriptorSetCache=new dq,this._meshDataArray=[],this._maskClearModel=null,this._maskClearMtl=null,this._maskModelMesh=null,this._root=t,this.device=t.device,this._batches=new Pu(64),this._drawBatchPool=new Bu((function(){return new oj}),128,(function(t){return t.destroy(e)}))}var e=t.prototype;return e.initialize=function(){return!0},e.destroy=function(){for(var t=0;t<this._batches.length;t++)this._batches.array[t]&&this._batches.array[t].destroy(this);this._batches.destroy();for(var e,i=d(this._bufferAccessors.values());!(e=i()).done;)e.value.destroy();this._bufferAccessors.clear(),this._drawBatchPool&&this._drawBatchPool.destroy(),this._descriptorSetCache.destroy(),Pk.sharedManager.destroy(),this._maskClearModel&&this._maskModelMesh&&(v.director.root.destroyModel(this._maskClearModel),this._maskModelMesh.destroy()),this._maskClearMtl&&this._maskClearMtl.destroy()},e.syncRootNodesToNative=function(){},e.addScreen=function(t){this._screens.push(t),this._screens.sort(this._screenSort)},e.removeScreen=function(t){var e=this._screens.indexOf(t);-1!==e&&this._screens.splice(e,1)},e.sortScreens=function(){this._screens.sort(this._screenSort)},e.getFirstRenderCamera=function(t){if(t.scene&&t.scene.renderScene)for(var e=t.scene.renderScene.cameras,i=0;i<e.length;i++){var n=e[i];if(n.visibility&t.layer)return n}return null},e.update=function(){for(var t=this._screens,e=0,i=0;i<t.length;++i){var n=t[i],r=n._getRenderScene();if(n.enabledInHierarchy&&r){this._opacityDirty=0,this._pOpacity=1,this.walk(n.node),this.autoMergeBatches(this._currComponent),this.resetRenderStates();var s=0;if(this._batches.length>e)for(;e<this._batches.length;++e){var o=this._batches.array[e];if(o.model)for(var a=o.model.subModels,h=0;h<a.length;h++)a[h].priority=s++;else o.descriptorSet=this._descriptorSetCache.getDescriptorSet(o);r.addBatch(o)}}}},e.uploadBuffers=function(){if(this._batches.length>0){for(var t=this._meshDataArray.length,e=0;e<t;e++)this._meshDataArray[e].uploadBuffers();for(var i,n=d(this._bufferAccessors.values());!(i=n()).done;){var r=i.value;r.uploadBuffers(),r.reset()}this._descriptorSetCache.update()}},e.reset=function(){for(var t=0;t<this._batches.length;++t){var e=this._batches.array[t];e.isStatic||(e.clear(),this._drawBatchPool.free(e))}for(var i,n=d(this._bufferAccessors.values());!(i=n()).done;)i.value.reset();for(var r=this._meshDataArray.length,s=0;s<r;s++)this._meshDataArray[s].freeIAPool();this._meshDataArray.length=0,this._staticVBBuffer=null,this._currBID=-1,this._indexStart=0,this._currHash=0,this._currLayer=0,this._currRenderData=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currComponent=null,this._currTransform=null,this._batches.clear(),Pk.sharedManager.reset()},e.switchBufferAccessor=function(t){void 0===t&&(t=lk);var e=t===lk?36:pk(t);if(!this._staticVBBuffer||this._staticVBBuffer.vertexFormatBytes!==e){var i=this._bufferAccessors.get(e);i||(i=new wk(this.device,t),this._bufferAccessors.set(e,i)),this._staticVBBuffer=i,this._currBID=-1}return this._staticVBBuffer},e.registerBufferAccessor=function(t,e){this._bufferAccessors.set(t,e)},e.updateBuffer=function(t,e){var i=this.switchBufferAccessor(t);this._currBID!==e&&(this._currBID=e,this._indexStart=i.getMeshBuffer(e).indexOffset)},e.commitComp=function(t,e,i,n,r){var s,o=0,a=-1;if(e&&e.chunk){if(!e.isValid())return;o=e.dataHash,s=e.material,a=e.chunk.bufferId}t.stencilStage===Sk.ENTER_LEVEL||t.stencilStage===Sk.ENTER_LEVEL_INVERTED?this._insertMaskBatch(t):t.stencilStage=Pk.sharedManager.stage;var h=t.stencilStage;this._currHash===o&&0!==o&&this._currMaterial===s&&this._currDepthStencilStateStage===h||(this.autoMergeBatches(this._currComponent),e&&!e._isMeshBuffer&&this.updateBuffer(e.vertexFormat,a),this._currRenderData=e,this._currHash=e?e.dataHash:0,this._currComponent=t,this._currTransform=r,this._currMaterial=t.getRenderMaterial(0),this._currDepthStencilStateStage=h,this._currLayer=t.node.layer,i?(this._currTexture=i.getGFXTexture(),this._currSampler=i.getGFXSampler(),this._currTextureHash=i.getHash(),this._currSamplerHash=this._currSampler.hash):(this._currTexture=null,this._currSampler=null,this._currTextureHash=0,this._currSamplerHash=0)),n.fillBuffers(t,this)},e.commitIA=function(t,e,i,n,r){var s;this._currMaterial!==this._emptyMaterial&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates());var o=0;t&&(t.stencilStage=Pk.sharedManager.stage,s=null!==t.customMaterial?Pk.sharedManager.getStencilStage(t.stencilStage,n):Pk.sharedManager.getStencilStage(t.stencilStage),o=Pk.sharedManager.getStencilHash(t.stencilStage));var a=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();a.visFlags=t.node.layer,a.inputAssembler=e,a.useLocalData=r||null,i&&(a.texture=i.getGFXTexture(),a.sampler=i.getGFXSampler(),a.textureHash=i.getHash(),a.samplerHash=a.sampler.hash),a.fillPasses(n||null,s,o,null),this._batches.push(a)},e.commitMiddleware=function(t,e,i,n,r,s,o){var a=r.getGFXTexture();o&&this._middlewareEnableBatch&&this._middlewareBuffer===e&&this._currTexture===a&&this._currMaterial.hash===s.hash&&this._middlewareIndexStart+this._middlewareIndexCount===i&&this._currLayer===t.node.layer?this._middlewareIndexCount+=n:(this.autoMergeBatches(this._currComponent),this.resetRenderStates(),this._currComponent=t,this._currTexture=a,this._currSampler=r.getGFXSampler(),this._currTextureHash=r.getHash(),this._currLayer=t.node.layer,this._currSamplerHash=this._currSampler.hash,this._currHash=0,this._currTransform=o?null:t.node,this._middlewareEnableBatch=o,this._middlewareBuffer=e,this._currMaterial=s,this._middlewareIndexStart=i,this._middlewareIndexCount=n),this._currIsMiddleware=!0},e.commitModel=function(t,e,i){var n;this._currMaterial!==this._emptyMaterial&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates());var r=0;i&&(t.stencilStage===Sk.ENTER_LEVEL||t.stencilStage===Sk.ENTER_LEVEL_INVERTED?this._insertMaskBatch(t):t.stencilStage=Pk.sharedManager.stage,n=Pk.sharedManager.getStencilStage(t.stencilStage,i),r=Pk.sharedManager.getStencilHash(t.stencilStage));var s=v.director.getTotalFrames();e&&(e.updateTransform(s),e.updateUBOs(s));for(var o=0;o<e.subModels.length;o++){var a=this._drawBatchPool.alloc(),h=e.subModels[o];a.visFlags=t.node.layer,a.model=e,a.texture=null,a.sampler=null,a.useLocalData=null,n||(n=null),a.fillPasses(i,n,r,h.patches),a.inputAssembler=h.inputAssembler,a.model.visFlags=a.visFlags,a.descriptorSet=h.descriptorSet,this._batches.push(a)}},e.setupStaticBatch=function(t,e){this.finishMergeBatches(),this._staticVBBuffer=e,this.currStaticRoot=t},e.endStaticBatch=function(){this.finishMergeBatches(),this.currStaticRoot=null,this._staticVBBuffer=null,this.switchBufferAccessor()},e.commitStaticBatch=function(t){this._batches.concat(t.drawBatchList),this.finishMergeBatches()},e.autoMergeBatches=function(t){if(this._currIsMiddleware)this.mergeBatchesForMiddleware(t);else{var e=this._currMaterial;if(e){var i,n=this._currRenderData,r=this._staticVBBuffer;if(n&&n._isMeshBuffer)i=n.requestIA(this.device),-1===this._meshDataArray.indexOf(n)&&this._meshDataArray.push(n);else if(r){var s=this._currBID,o=r.getMeshBuffer(s);if(!o)return;var a=o.indexOffset-this._indexStart;if(a<=0)return;this._indexStart,o.indexOffset,o.setDirty(),(i=o.requireFreeIA(this.device)).firstIndex=this._indexStart,i.indexCount=a,this._indexStart=o.indexOffset}if(this._currBID=-1,i&&this._currTexture){var h,u=0;t&&(h=null!==t.customMaterial?Pk.sharedManager.getStencilStage(t.stencilStage,e):Pk.sharedManager.getStencilStage(t.stencilStage),u=Pk.sharedManager.getStencilHash(t.stencilStage));var l=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();l.visFlags=this._currLayer,l.texture=this._currTexture,l.sampler=this._currSampler,l.inputAssembler=i,l.useLocalData=this._currTransform,l.textureHash=this._currTextureHash,l.samplerHash=this._currSamplerHash,l.fillPasses(e,h,u,null),this._batches.push(l)}}}},e.mergeBatchesForMiddleware=function(t){var e,i;t.stencilStage=Pk.sharedManager.stage,e=null!==t.customMaterial?Pk.sharedManager.getStencilStage(t.stencilStage,this._currMaterial):Pk.sharedManager.getStencilStage(t.stencilStage),i=Pk.sharedManager.getStencilHash(t.stencilStage);var n=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();n.visFlags=t.node.layer;var r=this._middlewareBuffer.requireFreeIA(this.device);r.firstIndex=this._middlewareIndexStart,r.indexCount=this._middlewareIndexCount,n.inputAssembler=r,n.useLocalData=this._currTransform,n.texture=this._currTexture,n.sampler=this._currSampler,n.textureHash=this._currTextureHash,n.samplerHash=this._currSamplerHash,n.fillPasses(this._currMaterial||null,e,i,null),this._batches.push(n),this._currIsMiddleware=!1,this._middlewareBuffer=null},e.forceMergeBatches=function(t,e,i){this._currMaterial=t,e?(this._currTexture=e.getGFXTexture(),this._currSampler=e.getGFXSampler(),this._currTextureHash=e.getHash(),this._currSamplerHash=this._currSampler.hash):(this._currTexture=this._currSampler=null,this._currTextureHash=this._currSamplerHash=0),this._currLayer=i.node.layer,this.autoMergeBatches(i)},e.resetRenderStates=function(){this._currMaterial=this._emptyMaterial,this._currRenderData=null,this._currTexture=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0},e.finishMergeBatches=function(){this.autoMergeBatches(),this.resetRenderStates()},e.flushMaterial=function(t){this._currMaterial=t},e.walk=function(t,e){if(void 0===e&&(e=0),t.activeInHierarchy){var i=t.children,n=t._uiProps,r=n.uiComp,s=this._pOpacity,o=s,a=r&&r.color?r.color.a/255:1;if(this._pOpacity=o*=a*n.localOpacity,n.setOpacity(o),!wi(o,0,Ei)){if(n.colorDirty&&this._opacityDirty++,r&&r.enabledInHierarchy&&r.fillBuffers(this),this._opacityDirty&&r&&!r.useVertexOpacity&&r.renderData&&r.renderData.vertexCount>0){!function(t,e){for(var i,n,r,s=t.vertexFormat,o=t.chunk.vb,a=0,h=0;h<s.length;++h){if(i=s[h],(n=M_[i.format]).hasAlpha)if(r=t.floatStride,n.size/n.count==1)for(var u=~~xi(Math.round(255*e),0,255),l=a;l<o.length;l+=r)o[l]=(4294967040&o[l]|u)>>>0;else if(n.size/n.count==4)for(var c=a+3;c<o.length;c+=r)o[c]=e;a+=n.size>>2}}(r.renderData,o);var h=r.renderData.getMeshBuffer();h&&h.setDirty()}if(i.length>0&&!t._static)for(var u=0;u<i.length;++u){var l=i[u];this.walk(l,e)}n.colorDirty&&(this._opacityDirty--,n.colorDirty=!1)}this._pOpacity=s,r&&r.enabledInHierarchy&&(r.postUpdateAssembler(this),(r.stencilStage===Sk.ENTER_LEVEL||r.stencilStage===Sk.ENTER_LEVEL_INVERTED)&&Pk.sharedManager.getMaskStackSize()>0&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates(),Pk.sharedManager.exitMask())),e+=1}},e._screenSort=function(t,e){return t.node.getSiblingIndex()-e.node.getSiblingIndex()},e._releaseDescriptorSetCache=function(t){this._descriptorSetCache.releaseDescriptorSetCache(t)},e._createClearModel=function(){if(!this._maskClearModel){this._maskClearMtl=nT.get("default-clear-stencil"),this._maskClearModel=v.director.root.createModel(wM);var t=pk(hk),e=Ed.gfxDevice,i=e.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,4*t,t)),n=new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0]);i.update(n);var r=e.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,6*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),s=new Uint16Array([0,1,2,2,1,3]);r.update(s),this._maskModelMesh=new OR([i],hk,pc.TRIANGLE_LIST,r),this._maskModelMesh.subMeshIdx=0,this._maskClearModel.initSubModel(0,this._maskModelMesh,this._maskClearMtl)}},e._insertMaskBatch=function(t){this.autoMergeBatches(this._currComponent),this.resetRenderStates(),this._createClearModel(),this._maskClearModel.node=this._maskClearModel.transform=t.node;var e=Pk.sharedManager;e.pushMask(1);var i,n=e.clear(t),r=0,s=this._maskClearMtl;s&&(i=e.getStencilStage(n,s),r=e.getStencilHash(n));var o=this._maskClearModel,a=v.director.getTotalFrames();o&&(o.updateTransform(a),o.updateUBOs(a));for(var h=0;h<o.subModels.length;h++){var u=this._drawBatchPool.alloc(),l=o.subModels[h];u.visFlags=t.node.layer,u.model=o,u.texture=null,u.sampler=null,u.useLocalData=null,i||(i=null),u.fillPasses(s,i,r,l.patches),u.inputAssembler=l.inputAssembler,u.model.visFlags=u.visFlags,u.descriptorSet=l.descriptorSet,this._batches.push(u)}e.enableMask()},e.syncMeshBuffersToNative=function(){},n(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"currBufferAccessor",get:function(){return this._staticVBBuffer||(this._staticVBBuffer=this.switchBufferAccessor()),this._staticVBBuffer}},{key:"batches",get:function(){return this._batches}},{key:"currStaticRoot",set:function(t){this._currStaticRoot=t}},{key:"currIsStatic",set:function(t){this._currIsStatic=t}}]),t}()),_q=function(){function t(){this._descriptorSet=null,this._transform=null,this._textureHash=0,this._samplerHash=0,this._localBuffer=null,this._transformUpdate=!0;var t=Ed.gfxDevice;this._localData=new Float32Array(Xg.COUNT),this._localBuffer=t.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,Xg.SIZE,Xg.SIZE))}var e=t.prototype;return e.initialize=function(t){var e=Ed.gfxDevice;this._transform=t.useLocalData,this._textureHash=t.textureHash,this._samplerHash=t.samplerHash,uq.layout=t.passes[0].localSetLayout,this._descriptorSet=e.createDescriptorSet(uq),this._descriptorSet.bindBuffer(Xg.BINDING,this._localBuffer);var i=Ag.SAMPLER_SPRITE;this._descriptorSet.bindTexture(i,t.texture),this._descriptorSet.bindSampler(i,t.sampler),this._descriptorSet.update(),this._transformUpdate=!0},e.updateTransform=function(t){t!==this._transform&&(this._transform=t,this._transformUpdate=!0,this.uploadLocalData())},e.equals=function(t,e,i){return this._transform===t&&this._textureHash===e&&this._samplerHash===i},e.reset=function(){this._transform=null,this._textureHash=0,this._samplerHash=0},e.destroy=function(){this._localBuffer&&(this._localBuffer.destroy(),this._localBuffer=null),this._descriptorSet&&(this._descriptorSet.destroy(),this._descriptorSet=null),this._localData=null},e.isValid=function(){return this._transform&&this._transform.isValid},e.uploadLocalData=function(){var t=this._transform;if((t.hasChangedFlags||t.isTransformDirty())&&(t.updateWorldTransform(),this._transformUpdate=!0),this._transformUpdate){var e=t.worldMatrix;In.toArray(this._localData,e,Xg.MAT_WORLD_OFFSET),In.invert(lq,e),In.transpose(lq,lq);var i=In.determinant(lq),n=1/Math.sqrt(i);In.multiplyScalar(lq,lq,n),In.toArray(this._localData,lq,Xg.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData),this._transformUpdate=!1}},n(t,[{key:"descriptorSet",get:function(){return this._descriptorSet}}]),t}(),dq=function(){function t(){this._descriptorSetCache=new Map,this._dsCacheHashByTexture=new Map,this._localDescriptorSetCache=[],this._localCachePool=void 0,this._localCachePool=new Bu((function(){return new _q}),16,(function(t){return t.destroy()}))}var e=t.prototype;return e.getDescriptorSet=function(t){var e;if(v.director.root,t.useLocalData){for(var i=this._localDescriptorSetCache,n=0,r=i.length;n<r;n++){var s=i[n];if(s.equals(t.useLocalData,t.textureHash,t.samplerHash))return s.descriptorSet}var o=this._localCachePool.alloc();return o.initialize(t),this._localDescriptorSetCache.push(o),o.descriptorSet}if(e=t.textureHash^t.samplerHash,this._descriptorSetCache.has(e))return this._descriptorSetCache.get(e);uq.layout=t.passes[0].localSetLayout;var a=Ed.gfxDevice.createDescriptorSet(uq),h=Ag.SAMPLER_SPRITE;return a.bindTexture(h,t.texture),a.bindSampler(h,t.sampler),a.update(),this._descriptorSetCache.set(e,a),this._dsCacheHashByTexture.set(t.textureHash,e),a},e.update=function(){var t=this._localDescriptorSetCache,e=t.length;if(0!==e){for(var i=[],n=0;n<e;n++){var r=t[n];if(r.isValid())r.uploadLocalData();else{r.reset();var s=t.indexOf(r);i.push(s)}}for(var o=i.length-1;o>=0;o--){var a=i[o],h=t[a];t.splice(a,1),this._localCachePool.free(h)}}},e.reset=function(){for(var t=this._localDescriptorSetCache,e=t.length,i=0;i<e;i++){var n=t[i];this._localCachePool.free(n)}this._localDescriptorSetCache.length=0},e.releaseDescriptorSetCache=function(t){var e=this._dsCacheHashByTexture.get(t);e&&this._descriptorSetCache.has(e)&&(this._descriptorSetCache.get(e).destroy(),this._descriptorSetCache.delete(e),this._dsCacheHashByTexture.delete(t))},e.destroy=function(){for(var t,e=d(this._descriptorSetCache.values());!(t=e()).done;)t.value.destroy();this._descriptorSetCache.clear(),this._dsCacheHashByTexture.clear(),this._localDescriptorSetCache.length=0,this._localCachePool.destroy()},t}();v.internal.Batcher2D=cq,t("y",function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(oj)),st(Ak.prototype,"MeshBuffer",["byteStart","vertexStart","indicesStart","request"].map((function(t){return{name:t,suggest:"please use meshBuffer.accessor."+t+" instead"}}))),nt(Ak.prototype,"MeshBuffer",[{name:"indicesOffset",newName:"indexOffset"}]),rt(Ak.prototype,"MeshBuffer",[{name:"vertexBuffers"},{name:"indexBuffer"}]),nt(cq.prototype,"Batcher2D",[{name:"currBufferBatch",newName:"currBufferAccessor"},{name:"acquireBufferBatch",newName:"switchBufferAccessor"}]),rt(Yk.prototype,"MeshRenderData",[{name:"formatByte"},{name:"byteStart"},{name:"byteCount"}]),nt(Yk.prototype,"MeshRenderData",[{name:"indicesStart",newName:"indexStart"}]),t("Q",function(t){function e(e){var i;return i=t.call(this,e)||this,Y(9006),i}return s(e,t),e}(Yk));var fq,pq=T.document,mq=null,gq=-1,yq="BES bswy:->@123丁ぁᄁ",vq=Object.create(null),Sq=[],Tq=3e3;function Aq(){for(var t=!0,e=Date.now(),i=Sq.length-1;i>=0;i--){var n=Sq[i],r=n.fontFamilyName;if(e-n.startTime>Tq)Y(4933,r),n.onComplete(null,r),Sq.splice(i,1);else{var s=n.refWidth,o="40px "+r;mq.font=o,s!==YF(mq,yq,o)?(Sq.splice(i,1),n.onComplete(null,r)):t=!1}}t&&(clearInterval(gq),gq=-1)}function bq(t,e,i){var n=function(t){var e=t.lastIndexOf(".ttf");if(-1===e)return t;var i,n=t.lastIndexOf("/");return-1!==(i=-1===n?t.substring(0,e)+"_LABEL":t.substring(n+1,e)+"_LABEL").indexOf(" ")&&(i='"'+i+'"'),i}(t);if(vq[n])i(null,n);else{if(!mq){var r=pq.createElement("canvas");r.width=100,r.height=100,mq=r.getContext("2d")}var s="40px "+n,o=pq.createElement("style");o.type="text/css";var a="";Number.isNaN(n)?a+="@font-face { font-family:"+n+"; src:":a+='@font-face { font-family:"'+n+'"; src:',a+='url("'+t+'");',o.textContent=a+"}",pq.body.appendChild(o);var h=pq.createElement("div"),u=h.style;if(u.fontFamily=n,h.innerHTML=".",u.position="absolute",u.left="-100px",u.top="-100px",pq.body.appendChild(h),function(){if(void 0===fq)if("FontFace"in T){var t=/Gecko.*Firefox\/(\d+)/.exec(T.navigator.userAgent),e=/OS X.*Version\/10\..*Safari/.exec(T.navigator.userAgent)&&/Apple/.exec(T.navigator.vendor);fq=t?parseInt(t[1],10)>42:!e}else fq=!1;return fq}())!function(t,e,i){var n=new Promise((function(i,n){!function r(){Date.now()-t>=Tq?n():pq.fonts.load("40px "+e).then((function(t){t.length>=1?i():setTimeout(r,100)}),(function(){n()}))}()})),r=null,s=new Promise((function(t,e){r=setTimeout(e,Tq)}));Promise.race([s,n]).then((function(){r&&(clearTimeout(r),r=null),i(null,e)}),(function(){Y(4933,e),i(null,e)}))}(Date.now(),n,i);else{var l={fontFamilyName:n,refWidth:YF(mq,yq,s),onComplete:i,startTime:Date.now()};Sq.push(l),-1===gq&&(gq=setInterval(Aq,100))}vq[n]=o}}function Eq(t,e,i,n){var r=new BF;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}bS.register({".font":bq,".eot":bq,".ttf":bq,".woff":bq,".svg":bq,".ttc":bq}),LS.register({".font":Eq,".eot":Eq,".ttf":Eq,".woff":Eq,".svg":Eq,".ttc":Eq}),v.UI={MeshBuffer:Ak,spriteAssembler:oq,graphicsAssembler:qj,labelAssembler:yX,RenderData:qk,MeshRenderData:Yk},SN.on(vN.EVENT_POST_SUBSYSTEM_INIT,(function(){Dq.init()}));var Cq,wq,xq,Rq,Iq,Bq,Dq=t("a2",function(){function t(){}return t.getSortingPriority=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),(t+32768<<16|e+32768)>>>0},t.getLayerIndex=function(t){void 0===t&&(t=0);var e=0;return this.indexMap.has(t)?e=this.indexMap.get(t):J(2105),e},t.getLayerIndexByName=function(t){var e=this.getLayerByName(t);return this.getLayerIndex(e)},t.getLayerName=function(t){void 0===t&&(t=0);var e="";return this.nameMap.has(t)?e=this.nameMap.get(t):J(2105),e},t.getLayerByName=function(t){for(var e=this.nameMap.size,i=this.nameMap.keys(),n=0,r=0;r<e;r++)if(n=i.next().value,this.nameMap.get(n)===t)return n;return J(2106),0},t.isLayerValid=function(t){return!!this.indexMap.has(t)||(J(2105),!1)},t.getBuiltinLayers=function(){return[{id:0,name:"default",value:0}]},t.init=function(){var e=Ee.querySettings(be.Category.ENGINE,"sortingLayers");e&&0!==e.length||(e=this.getBuiltinLayers()),t.resetState();for(var i=0;i<e.length;i++){var n=e[i];t.setLayer(n.id,n.name,n.value),t.Enum[n.name]=n.id}ge.update(t.Enum),ge.sortList(t.Enum,(function(e,i){return t.getLayerIndex(e.value)-t.getLayerIndex(i.value)}))},t.setLayer=function(t,e,i){this.nameMap.set(t,e),this.indexMap.set(t,i)},t.resetState=function(){for(var e=Object.keys(t.Enum),i=0;i<e.length;i++)delete t.Enum[t.Enum[e[i]]],delete t.Enum[e[i]];t.indexMap.clear(),t.nameMap.clear()},t}());Dq.nameMap=new Map,Dq.indexMap=new Map,Dq.Enum=ge({default:0}),t("a3",(Cq=qs("cc.Sorting"),wq=xo(Dq.Enum),Cq(xq=Js((p((Rq=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._sortingLayer=Iq&&Iq(),e._sortingOrder=Bq&&Bq(),e._modelRenderer=null,e}s(e,t);var i=e.prototype;return i.__preload=function(){this._modelRenderer=this.getComponent("cc.ModelRenderer"),this._modelRenderer||Y(16301,this.node.name),this._updateSortingPriority()},i._updateSortingPriority=function(){var t=Dq.getLayerIndex(this._sortingLayer),e=Dq.getSortingPriority(t,this._sortingOrder);this._modelRenderer&&this._modelRenderer.isValid&&(this._modelRenderer.priority=e)},n(e,[{key:"sortingLayer",get:function(){return this._sortingLayer},set:function(t){t!==this._sortingLayer&&Dq.isLayerValid(t)&&(this._sortingLayer=t,this._updateSortingPriority())}},{key:"sortingOrder",get:function(){return this._sortingOrder},set:function(t){t!==this._sortingOrder&&(this._sortingOrder=xi(t,-32768,32767),this._updateSortingPriority())}}]),e}(rp)).prototype,"sortingLayer",[wq],Object.getOwnPropertyDescriptor(Rq.prototype,"sortingLayer"),Rq.prototype),Iq=ks(Rq.prototype,"_sortingLayer",[io],(function(){return Dq.Enum.default})),Bq=ks(Rq.prototype,"_sortingOrder",[io],(function(){return 0})),xq=Rq))||xq)||xq));var Pq,Oq,Mq,Lq,Nq,Fq,kq,Vq,Gq,Uq,zq,Hq,Wq,jq,Xq,qq,Yq,Kq,Jq,Qq,Zq,$q,tY,eY,iY,nY,rY,sY,oY,aY,hY,uY,lY,cY,_Y,dY,fY,pY,mY,gY,yY,vY,SY=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._morphRenderingInstance=null,e._usedMaterials=new Set,e}s(e,t);var i=e.prototype;return i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);if(this._morphRenderingInstance){var n=this._morphRenderingInstance.requiredPatches(e);if(n)return n.concat(null!=i?i:[])}return i},i.initSubModel=function(e,i,n){return t.prototype.initSubModel.call(this,e,i,this._launderMaterial(n))},i.destroy=function(){t.prototype.destroy.call(this),this._morphRenderingInstance=null},i.setSubModelMaterial=function(e,i){return t.prototype.setSubModelMaterial.call(this,e,this._launderMaterial(i))},i.setMorphRendering=function(t){this._morphRenderingInstance=t},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i),this._morphRenderingInstance&&this._morphRenderingInstance.adaptPipelineState(e,i)},i._launderMaterial=function(t){return t},e}(wM),TY=qs,AY=Ks,bY=xo,EY=no,CY=io,wY=rT("specular-pass");function xY(t){var e=t.passes,i=v.rendering;tv()&&(wY=i.getPhaseID(i.getPassID("specular-pass"),"default"));for(var n=0;n<e.length;n++)if((!i||!i.enableEffectImport)&&e[n].phase===wY||tv()&&e[n].phaseID===wY)return n;return-1}var RY,IY,BY,DY,PY,OY,MY,LY,NY=ge({OFF:0,ON:1}),FY=ge({OFF:0,ON:1}),kY=(Pq=TY("cc.ModelBakeSettings"),Oq=EY("_recieveShadow"),Mq=bY(qe),Lq=bY(Ke),Nq=bY(Ke),Fq=bY(ge(uM)),kq=bY(Ke),Pq(((Qq=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).texture=Uq&&Uq(),e.uvParam=zq&&zq(),e._bakeable=Hq&&Hq(),e._castShadow=Wq&&Wq(),e._receiveShadow=jq&&jq(),e._lightmapSize=Xq&&Xq(),e._useLightProbe=qq&&qq(),e._bakeToLightProbe=Yq&&Yq(),e._reflectionProbeType=Kq&&Kq(),e._bakeToReflectionProbe=Jq&&Jq(),e.probeCubemap=null,e.probeBlendCubemap=null,e.probePlanarmap=null,e}return s(e,t),n(e,[{key:"bakeable",get:function(){return this._bakeable},set:function(t){this._bakeable=t}},{key:"castShadow",get:function(){return this._castShadow},set:function(t){this._castShadow=t}},{key:"receiveShadow",get:function(){return this._receiveShadow},set:function(t){this._receiveShadow=t}},{key:"lightmapSize",get:function(){return this._lightmapSize},set:function(t){this._lightmapSize=t}},{key:"useLightProbe",get:function(){return this._useLightProbe},set:function(t){this._useLightProbe=t,this.emit(e.USE_LIGHT_PROBE_CHANGED)}},{key:"bakeToLightProbe",get:function(){return this._bakeToLightProbe},set:function(t){this._bakeToLightProbe=t}},{key:"reflectionProbe",get:function(){return this._reflectionProbeType},set:function(t){this._reflectionProbeType=t,this.emit(e.REFLECTION_PROBE_CHANGED)}},{key:"bakeToReflectionProbe",get:function(){return this._bakeToReflectionProbe},set:function(t){this._bakeToReflectionProbe=t,this.emit(e.BAKE_TO_REFLECTION_PROBE_CHANGED)}}]),e}(Ku)).USE_LIGHT_PROBE_CHANGED="use_light_probe_changed",Qq.REFLECTION_PROBE_CHANGED="reflection_probe_changed",Qq.BAKE_TO_REFLECTION_PROBE_CHANGED="bake_to_reflection_probe_changed",Uq=ks((Gq=Qq).prototype,"texture",[CY],(function(){return null})),zq=ks(Gq.prototype,"uvParam",[CY],(function(){return new tn})),Hq=ks(Gq.prototype,"_bakeable",[CY],(function(){return!1})),Wq=ks(Gq.prototype,"_castShadow",[CY],(function(){return!1})),jq=ks(Gq.prototype,"_receiveShadow",[Oq],(function(){return!1})),Xq=ks(Gq.prototype,"_lightmapSize",[CY],(function(){return 64})),qq=ks(Gq.prototype,"_useLightProbe",[CY],(function(){return!1})),Yq=ks(Gq.prototype,"_bakeToLightProbe",[CY],(function(){return!0})),Kq=ks(Gq.prototype,"_reflectionProbeType",[CY],(function(){return uM.NONE})),Jq=ks(Gq.prototype,"_bakeToReflectionProbe",[CY],(function(){return!0})),p(Gq.prototype,"lightmapSize",[Mq],Object.getOwnPropertyDescriptor(Gq.prototype,"lightmapSize"),Gq.prototype),p(Gq.prototype,"useLightProbe",[Lq],Object.getOwnPropertyDescriptor(Gq.prototype,"useLightProbe"),Gq.prototype),p(Gq.prototype,"bakeToLightProbe",[Nq],Object.getOwnPropertyDescriptor(Gq.prototype,"bakeToLightProbe"),Gq.prototype),p(Gq.prototype,"reflectionProbe",[Fq],Object.getOwnPropertyDescriptor(Gq.prototype,"reflectionProbe"),Gq.prototype),p(Gq.prototype,"bakeToReflectionProbe",[kq],Object.getOwnPropertyDescriptor(Gq.prototype,"bakeToReflectionProbe"),Gq.prototype),Vq=Gq))||Vq),VY=t("a8",(Zq=TY("cc.MeshRenderer"),$q=AY(100),tY=bY(Ye),eY=bY(Ye),iY=bY(NY),nY=bY(FY),rY=bY(XN),sY=bY(Ke),Zq(oY=$q(((vY=function(t){s(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this)||this).bakeSettings=hY&&hY(),e._mesh=uY&&uY(),e._shadowCastingMode=lY&&lY(),e._shadowReceivingMode=cY&&cY(),e._shadowBias=_Y&&_Y(),e._shadowNormalBias=dY&&dY(),e._reflectionProbeId=fY&&fY(),e._reflectionProbeBlendId=pY&&pY(),e._reflectionProbeBlendWeight=mY&&mY(),e._enabledGlobalStandardSkinObject=gY&&gY(),e._reflectionProbeDataMap=null,e._subMeshShapesWeights=[],e._modelType=void 0,e._model=null,e._morphInstance=null,e._enableMorph=yY&&yY(),e._modelType=wM,Ee.querySettings(be.Category.RENDERING,"highQualityMode")&&(e._shadowCastingMode=NY.ON,e.bakeSettings.castShadow=!0,e.bakeSettings.receiveShadow=!0),e}return e.onUpdateReceiveDirLight=function(t,e){void 0===e&&(e=!1),this._model&&(e?this._model.receiveDirLight=!1:this.node&&(t&this.node.layer)===this.node.layer||t&this._model.visFlags?this._model.receiveDirLight=!0:this._model.receiveDirLight=!1)},e.clearGlobalStandardSkinObjectFlag=function(){this._enabledGlobalStandardSkinObject=!1},e.onLoad=function(){this._mesh&&this._mesh.initialize(),this._validateShapeWeights()||this._initSubMeshShapesWeights(),this._watchMorphInMesh(),this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias(),this._updateUseLightProbe(),this._updateBakeToReflectionProbe(),this._updateUseReflectionProbe(),this._updateReceiveDirLight(),this._updateStandardSkin()},e.onRestore=function(){this._updateModels(),this.enabledInHierarchy&&this._attachToScene(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias(),this._updateUseLightProbe(),this._updateBakeToReflectionProbe(),this._updateUseReflectionProbe(),this._updateReceiveDirLight(),this._updateStandardSkin()},e.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(om.MOBILITY_CHANGED,this.onMobilityChanged,this),this.node.on(om.LIGHT_PROBE_BAKING_CHANGED,this.onLightProbeBakingChanged,this),this.bakeSettings.on(kY.USE_LIGHT_PROBE_CHANGED,this.onUseLightProbeChanged,this),this.bakeSettings.on(kY.REFLECTION_PROBE_CHANGED,this.onReflectionProbeChanged,this),this.bakeSettings.on(kY.BAKE_TO_REFLECTION_PROBE_CHANGED,this.onBakeToReflectionProbeChanged,this),this._model||this._updateModels(),this._model.onGlobalPipelineStateChanged(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateShadowBias(),this._updateShadowNormalBias(),this._updateBakeToReflectionProbe(),this._updateUseReflectionProbe(),this._onUpdateLocalShadowBiasAndProbeId(),this._updateUseLightProbe(),this._updateReceiveDirLight(),this._onUpdateReflectionProbeDataMap(),this._onUpdateLocalReflectionProbeData(),this._updateStandardSkin(),this._attachToScene()},e.onDisable=function(){this._model&&this._detachFromScene(),this.node.off(om.MOBILITY_CHANGED,this.onMobilityChanged,this),this.node.off(om.LIGHT_PROBE_BAKING_CHANGED,this.onLightProbeBakingChanged,this),this.bakeSettings.off(kY.USE_LIGHT_PROBE_CHANGED,this.onUseLightProbeChanged,this),this.bakeSettings.off(kY.REFLECTION_PROBE_CHANGED,this.onReflectionProbeChanged,this),this.bakeSettings.off(kY.BAKE_TO_REFLECTION_PROBE_CHANGED,this.onBakeToReflectionProbeChanged,this)},e.onDestroy=function(){this._model&&(v.director.root.destroyModel(this._model),this._model=null,this._models.length=0),this._morphInstance&&this._morphInstance.destroy()},e.onGeometryChanged=function(){if(this._model&&this._mesh){var t=this._mesh.struct;this._model.createBoundingShape(t.minPosition,t.maxPosition),this._model.updateWorldBound(),this._model.onGeometryChanged()}},e.getWeight=function(t,e){this._subMeshShapesWeights.length;var i=this._subMeshShapesWeights[t];return i.length,i[e]},e.setWeights=function(t,e){var i=this._subMeshShapesWeights;e>=i.length||i[e].length===t.length&&(i[e]=t.slice(0),this._uploadSubMeshShapesWeights(e))},e.setWeight=function(t,e,i){var n=this._subMeshShapesWeights;if(!(e>=n.length)){var r=n[e];i>=r.length||(r[i]=t,this._uploadSubMeshShapesWeights(e))}},e.setInstancedAttribute=function(t,e){if(this.model)for(var i=this.model.subModels,n=0;n<i.length;n++)for(var r=i[n].instancedAttributeBlock,s=r.attributes,o=r.views,a=0;a<s.length;a++)if(s[a].name===t){o[a].set(e);break}},e._updateLightmap=function(t,e,i,n,r){this.bakeSettings.texture=t,this.bakeSettings.uvParam.x=e,this.bakeSettings.uvParam.y=i,this.bakeSettings.uvParam.z=n,this.bakeSettings.uvParam.w=r,this._onUpdateLightingmap(),this._updateReceiveDirLight()},e.updateProbeCubemap=function(t){this.bakeSettings.probeCubemap&&this.bakeSettings.probeCubemap===t||(this.bakeSettings.probeCubemap=t,null!==this.model&&this.model.updateReflectionProbeCubemap(this.bakeSettings.probeCubemap))},e.updateProbeBlendCubemap=function(t){this.bakeSettings.probeBlendCubemap&&this.bakeSettings.probeBlendCubemap===t||(this.bakeSettings.probeBlendCubemap=t,null!==this.model&&this.model.updateReflectionProbeBlendCubemap(this.bakeSettings.probeBlendCubemap))},e.updateProbePlanarMap=function(t){this.bakeSettings.probePlanarmap!==t&&(this.bakeSettings.probePlanarmap=t,null!==this.model&&this.model.updateReflectionProbePlanarMap(this.bakeSettings.probePlanarmap))},e.updateReflectionProbeDataMap=function(t){this._reflectionProbeDataMap=t,null!==this.model&&this.model.updateReflectionProbeDataMap(t)},e.updateReflectionProbeId=function(t){this._reflectionProbeId=t,this.model&&(this.model.reflectionProbeId=t),this._onUpdateLocalShadowBiasAndProbeId()},e.updateReflectionProbeBlendId=function(t){this._reflectionProbeBlendId=t,this.model&&(this.model.reflectionProbeBlendId=t),this._onUpdateLocalShadowBiasAndProbeId()},e.updateReflectionProbeBlendWeight=function(t){this._reflectionProbeBlendWeight=t,this.model&&(this.model.reflectionProbeBlendWeight=t),this._onUpdateLocalReflectionProbeData()},e._updateReflectionProbeTexture=function(){if(this.model){var t=this.bakeSettings,e=t.reflectionProbe,i=t.probeBlendCubemap,n=t.probePlanarmap,r=t.probeCubemap;e===uM.BAKED_CUBEMAP?(this.model.updateReflectionProbeCubemap(r),this.model.updateReflectionProbePlanarMap(null),this.model.updateReflectionProbeBlendCubemap(null)):e===uM.BLEND_PROBES||e===uM.BLEND_PROBES_AND_SKYBOX?(this.model.updateReflectionProbeCubemap(r),this.model.updateReflectionProbeBlendCubemap(i),this.model.updateReflectionProbePlanarMap(null)):e===uM.PLANAR_REFLECTION?(this.model.updateReflectionProbePlanarMap(n),this.model.updateReflectionProbeCubemap(null),this.model.updateReflectionProbeBlendCubemap(null)):(this.model.updateReflectionProbeCubemap(null),this.model.updateReflectionProbePlanarMap(null),this.model.updateReflectionProbeBlendCubemap(null))}},e._updateModels=function(){if(this.enabledInHierarchy){var t=this._model;if(t?(t.destroy(),t.initialize(),t.node=t.transform=this.node):this._createModel(),this._model){if(this._mesh){var e=this._mesh.struct;this._model.createBoundingShape(e.minPosition,e.maxPosition),this._model.updateWorldBound()}this._model.initLightingmap(this.bakeSettings.texture,this.bakeSettings.uvParam),this._updateUseLightProbe(),this._updateUseReflectionProbeType(),this._updateModelParams(),this._onUpdateLightingmap(),this._onUpdateLocalShadowBiasAndProbeId(),this._updateUseReflectionProbe(),this._updateReceiveDirLight(),this._onUpdateReflectionProbeDataMap(),this._onUpdateLocalReflectionProbeData()}}},e._updateReceiveDirLight=function(){if(this._model){var t=this.node.scene;if(t&&t.renderScene){var e=t.renderScene.mainLight;if(e){var i=e.visibility;if(e.node)if(e.node.mobility===Em.Static){var n=!1;this.bakeSettings.texture&&!this.node.scene.globals.disableLightmap&&(n=!0),this.node.scene.globals.lightProbeInfo.data&&this.node.scene.globals.lightProbeInfo.data.hasCoefficients()&&this._model.useLightProbe&&(n=!0),this.onUpdateReceiveDirLight(i,n)}else this.onUpdateReceiveDirLight(i)}}}},e._createModel=function(){var t=this._morphInstance&&this._modelType===wM?SY:this._modelType,e=this._model=v.director.root.createModel(t);e.visFlags=this.visibility,e.node=e.transform=this.node,this._models.length=0,this._models.push(this._model),this._morphInstance&&e instanceof SY&&e.setMorphRendering(this._morphInstance)},e._attachToScene=function(){if(this.node.scene&&this._model){var t=this._getRenderScene();null!==this._model.scene&&this._detachFromScene(),t.addModel(this._model)}},e._detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},e._updateModelParams=function(){if(this._mesh&&this._model){this.node.hasChangedFlags|=rm.POSITION,this._model.transform.hasChangedFlags|=rm.POSITION,this._model.isDynamicBatching=this._isBatchingEnabled();var t=this._mesh?this._mesh.renderingSubMeshes.length:0,e=this._mesh.renderingSubMeshes;if(e)for(var i=0;i<t;++i){var n=this.getRenderMaterial(i);n&&!n.isValid&&(n=null);var r=e[i];r&&this._model.initSubModel(i,r,n||this._getBuiltinMaterial())}this._model.enabled=!0}},e._onUpdateLightingmap=function(){null!==this.model&&this.model.updateLightingmap(this.bakeSettings.texture,this.bakeSettings.uvParam),this.setInstancedAttribute("a_lightingMapUVParam",[this.bakeSettings.uvParam.x,this.bakeSettings.uvParam.y,this.bakeSettings.uvParam.z,this.bakeSettings.uvParam.w])},e._onUpdateLocalShadowBiasAndProbeId=function(){null!==this.model&&(this.model.updateLocalShadowBias(),this.model.updateReflectionProbeId()),this.setInstancedAttribute("a_localShadowBiasAndProbeId",[this._shadowBias,this._shadowNormalBias,this._reflectionProbeId,this._reflectionProbeBlendId])},e._onUpdateLocalReflectionProbeData=function(){this.bakeSettings.reflectionProbe!==uM.BAKED_CUBEMAP&&this.bakeSettings.reflectionProbe!==uM.BLEND_PROBES&&this.bakeSettings.reflectionProbe!==uM.BLEND_PROBES_AND_SKYBOX||(null!==this.model&&this.model.updateReflectionProbeId(),this.setInstancedAttribute("a_reflectionProbeData",[this._reflectionProbeBlendWeight,0,0,0]))},e._onUpdateReflectionProbeDataMap=function(){null!==this.model&&this.model.updateReflectionProbeDataMap(this._reflectionProbeDataMap)},e._onMaterialModified=function(t,e){this._model&&this._model.inited&&(this._onRebuildPSO(t,e||this._getBuiltinMaterial()),this._updateStandardSkin())},e._onRebuildPSO=function(t,e){this._model&&this._model.inited&&(this._model.isDynamicBatching=this._isBatchingEnabled(),this._model.setSubModelMaterial(t,e),this._onUpdateLightingmap(),this._onUpdateLocalShadowBiasAndProbeId(),this._updateReflectionProbeTexture(),this._onUpdateReflectionProbeDataMap(),this._onUpdateLocalReflectionProbeData())},e._onMeshChanged=function(){},e._clearMaterials=function(){if(this._model)for(var t=this._model.subModels,e=0;e<t.length;++e)this._onMaterialModified(e,null)},e._getBuiltinMaterial=function(){return nT.get("missing-material")},e._onVisibilityChange=function(t){this._model&&(this._model.visFlags=t)},e._updateShadowBias=function(){this._model&&(this._model.shadowBias=this._shadowBias)},e._updateShadowNormalBias=function(){this._model&&(this._model.shadowNormalBias=this._shadowNormalBias)},e._updateCastShadow=function(){this._model&&(this._shadowCastingMode===NY.OFF?this._model.castShadow=!1:(this._shadowCastingMode,NY.ON,this._shadowCastingMode,this._model.castShadow=!0))},e._updateReceiveShadow=function(){this._model&&(this._shadowReceivingMode===FY.OFF?this._model.receiveShadow=!1:this._model.receiveShadow=!0)},e.onMobilityChanged=function(){this._updateUseLightProbe(),this._updateReceiveDirLight()},e.onLightProbeBakingChanged=function(){this._updateReceiveDirLight()},e.onUseLightProbeChanged=function(){this._updateUseLightProbe()},e.onReflectionProbeChanged=function(){this._updateUseReflectionProbe(),this._onUpdateLocalShadowBiasAndProbeId(),this.bakeSettings.reflectionProbe===uM.BAKED_CUBEMAP||this.bakeSettings.reflectionProbe===uM.BLEND_PROBES||this.bakeSettings.reflectionProbe===uM.BLEND_PROBES_AND_SKYBOX?(v.internal.reflectionProbeManager.selectReflectionProbe(this._model),v.internal.reflectionProbeManager.getUsedReflectionProbe(this._model,!1)||Y(16302)):this.bakeSettings.reflectionProbe===uM.PLANAR_REFLECTION&&(v.internal.reflectionProbeManager.selectPlanarReflectionProbe(this._model),v.internal.reflectionProbeManager.getUsedReflectionProbe(this._model,!0)||Y(16302))},e.onBakeToReflectionProbeChanged=function(){this._updateBakeToReflectionProbe()},e._updateUseLightProbe=function(){if(this._model){var t=this.node;this._mesh&&t&&t.mobility===Em.Movable&&this.bakeSettings.useLightProbe?this._model.useLightProbe=!0:this._model.useLightProbe=!1}},e._isBatchingEnabled=function(){for(var t=0;t<this._materials.length;++t){var e=this._materials[t];if(e)for(var i=0;i<e.passes.length;++i)if(e.passes[i].batchingScheme)return!0}return!1},e._updateUseReflectionProbe=function(){this._model&&(this._model.reflectionProbeType=this.bakeSettings.reflectionProbe,this._updateReflectionProbeTexture())},e._updateUseReflectionProbeType=function(){this._model&&(this._model.reflectionProbeType=this.bakeSettings.reflectionProbe)},e._updateBakeToReflectionProbe=function(){this._model&&(this._model.bakeToReflectionProbe=this.bakeSettings.bakeToReflectionProbe)},e._watchMorphInMesh=function(){if(this._morphInstance&&(this._morphInstance.destroy(),this._morphInstance=null),this._enableMorph&&this._mesh&&this._mesh.struct.morph&&this._mesh.morphRendering){this._morphInstance=this._mesh.morphRendering.createInstance();for(var t=this._mesh.struct.primitives.length,e=0;e<t;++e)this._uploadSubMeshShapesWeights(e);this._model&&this._model instanceof SY&&this._model.setMorphRendering(this._morphInstance)}},e._initSubMeshShapesWeights=function(){var t=this._mesh;if(this._subMeshShapesWeights.length=0,t){var e=t.struct.morph;if(e){var i=e.weights;this._subMeshShapesWeights=e.subMeshMorphs.map((function(t){return t?t.weights?t.weights.slice(0):i?(i.length,t.targets.length,i.slice(0)):new Array(t.targets.length).fill(0):[]}))}}},e._validateShapeWeights=function(){var t=this._mesh,e=this._subMeshShapesWeights;if(!t||!t.struct.morph)return 0===e.length;var i=t.struct.morph;return i.subMeshMorphs.length===e.length&&e.every((function(t,e){var n,r,s=t.length;return(null!==(n=null===(r=i.subMeshMorphs[e])||void 0===r?void 0:r.targets.length)&&void 0!==n?n:0)===s}))},e._uploadSubMeshShapesWeights=function(t){var e;null===(e=this._morphInstance)||void 0===e||e.setWeights(t,this._subMeshShapesWeights[t])},e._updateStandardSkin=function(){var t=v.director.root.pipeline.pipelineSceneData;if(this._enabledGlobalStandardSkinObject&&(t.standardSkinMeshRenderer=this,t.standardSkinModel=this.model),!t.skinMaterialModel&&this._model)for(var e=this._model.subModels,i=0;i<e.length;i++)if(!(xY(e[i])<0))return void(t.skinMaterialModel=this._model)},n(i,[{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._updateShadowBias(),this._onUpdateLocalShadowBiasAndProbeId()}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._updateShadowNormalBias(),this._onUpdateLocalShadowBiasAndProbeId()}},{key:"shadowCastingMode",get:function(){return this._shadowCastingMode},set:function(t){this._shadowCastingMode=t,this._updateCastShadow()}},{key:"shadowCastingModeForInspector",get:function(){return this.shadowCastingMode===NY.ON},set:function(t){this.shadowCastingMode=!0===t?NY.ON:NY.OFF}},{key:"receiveShadow",get:function(){return this._shadowReceivingMode},set:function(t){this._shadowReceivingMode=t,this._updateReceiveShadow()}},{key:"receiveShadowForInspector",get:function(){return this._shadowReceivingMode===FY.ON},set:function(t){this._shadowReceivingMode=!0===t?FY.ON:FY.OFF,this._updateReceiveShadow()}},{key:"mesh",get:function(){return this._mesh},set:function(t){var e=this._mesh,i=this._mesh=t;null==i||i.initialize(),this._initSubMeshShapesWeights(),this._watchMorphInMesh(),this._onMeshChanged(e),this._updateModels(),this.enabledInHierarchy&&this._attachToScene(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateUseLightProbe(),this._updateUseReflectionProbe(),this._updateReceiveDirLight()}},{key:"model",get:function(){return this._model}},{key:"enableMorph",get:function(){return this._enableMorph},set:function(t){this._enableMorph=t}},{key:"isGlobalStandardSkinObject",get:function(){return this._enabledGlobalStandardSkinObject},set:function(t){v.director.root.pipeline.pipelineSceneData.standardSkinMeshRenderer=t?this:null,this._enabledGlobalStandardSkinObject=t}}]),i}(dW)).ShadowCastingMode=NY,vY.ShadowReceivingMode=FY,hY=ks((aY=vY).prototype,"bakeSettings",[CY],(function(){return new kY(this)})),uY=ks(aY.prototype,"_mesh",[CY],(function(){return null})),lY=ks(aY.prototype,"_shadowCastingMode",[CY],(function(){return NY.OFF})),cY=ks(aY.prototype,"_shadowReceivingMode",[CY],(function(){return FY.ON})),_Y=ks(aY.prototype,"_shadowBias",[CY],(function(){return 0})),dY=ks(aY.prototype,"_shadowNormalBias",[CY],(function(){return 0})),fY=ks(aY.prototype,"_reflectionProbeId",[CY],(function(){return-1})),pY=ks(aY.prototype,"_reflectionProbeBlendId",[CY],(function(){return-1})),mY=ks(aY.prototype,"_reflectionProbeBlendWeight",[CY],(function(){return 0})),gY=ks(aY.prototype,"_enabledGlobalStandardSkinObject",[CY],(function(){return!1})),p(aY.prototype,"shadowBias",[tY],Object.getOwnPropertyDescriptor(aY.prototype,"shadowBias"),aY.prototype),p(aY.prototype,"shadowNormalBias",[eY],Object.getOwnPropertyDescriptor(aY.prototype,"shadowNormalBias"),aY.prototype),p(aY.prototype,"shadowCastingMode",[iY],Object.getOwnPropertyDescriptor(aY.prototype,"shadowCastingMode"),aY.prototype),p(aY.prototype,"receiveShadow",[nY],Object.getOwnPropertyDescriptor(aY.prototype,"receiveShadow"),aY.prototype),p(aY.prototype,"mesh",[rY],Object.getOwnPropertyDescriptor(aY.prototype,"mesh"),aY.prototype),p(aY.prototype,"isGlobalStandardSkinObject",[sY],Object.getOwnPropertyDescriptor(aY.prototype,"isGlobalStandardSkinObject"),aY.prototype),yY=ks(aY.prototype,"_enableMorph",[CY],(function(){return!0})),oY=aY))||oY)||oY));function GY(t,e){var i=t.sharedMaterials.length;if(i!==e.sharedMaterials.length)return!1;for(var n=0;n<i;n++)if(t.getRenderMaterial(n)!==e.getRenderMaterial(n))return!1;return!0}t("a5",function(){function t(){}return t.batchStaticModel=function(t,e){var i=t.getComponentsInChildren(VY);if(i.length<2)return console.error("the number of static models to batch is less than 2,it needn't batch."),!1;for(var n=1;n<i.length;n++){if(!i[0].mesh.validateMergingMesh(i[n].mesh))return console.error("the meshes of "+i[0].node.name+" and "+i[n].node.name+" can't be merged"),!1;if(!GY(i[0],i[n]))return console.error("the materials of "+i[0].node.name+" and "+i[n].node.name+" can't be merged"),!1}var r=new XN,s=new In,o=new In;t.getWorldMatrix(o),In.invert(o,o);for(var a=0;a<i.length;a++){var h=i[a];h.node.getWorldMatrix(s),In.multiply(s,o,s),r.merge(i[a].mesh,s),h.enabled=!1}var u=e.addComponent(VY);return u.mesh=r,u.sharedMaterials=i[0].sharedMaterials,!0},t.unbatchStaticModel=function(t,e){for(var i=t.getComponentsInChildren(VY),n=0;n<i.length;n++)i[n].enabled=!0;var r=e.getComponent(VY);return r&&(r.mesh&&r.mesh.destroyRenderingMesh(),r.destroy()),!0},t}()),nt(XN.prototype,"Mesh.prototype",[{name:"renderingMesh",newName:"renderingSubMeshes"}]),rt(XN.prototype,"Mesh.prototype",[{name:"hasFlatBuffers"},{name:"destroyFlatBuffers"}]);var UY,zY,HY,WY,jY,XY,qY,YY,KY,JY,QY,ZY,$Y,tK,eK,iK,nK=t("a7",(RY=qs("cc.Skeleton"),IY=xo([Je]),BY=xo([In]),RY((PY=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._joints=OY&&OY(),e._bindposes=MY&&MY(),e._hash=LY&&LY(),e._invBindposes=null,e}s(e,t);var i=e.prototype;return i.destroy=function(){var e,i;return null===(e=v.director.root)||void 0===e||null===(i=e.dataPoolManager)||void 0===i||i.releaseSkeleton(this),t.prototype.destroy.call(this)},i.validate=function(){return this.joints.length>0&&this.bindposes.length>0},n(e,[{key:"joints",get:function(){return this._joints},set:function(t){this._joints=t}},{key:"bindposes",get:function(){return this._bindposes},set:function(t){this._bindposes=t}},{key:"inverseBindposes",get:function(){if(!this._invBindposes){this._invBindposes=[];for(var t=0;t<this._bindposes.length;t++){var e=new In;In.invert(e,this._bindposes[t]),this._invBindposes.push(e)}}return this._invBindposes}},{key:"hash",get:function(){if(!this._hash){for(var t="",e=0;e<this._bindposes.length;e++){var i=this._bindposes[e];t+=i.m00.toPrecision(2)+" "+i.m01.toPrecision(2)+" "+i.m02.toPrecision(2)+" "+i.m03.toPrecision(2)+" "+i.m04.toPrecision(2)+" "+i.m05.toPrecision(2)+" "+i.m06.toPrecision(2)+" "+i.m07.toPrecision(2)+" "+i.m08.toPrecision(2)+" "+i.m09.toPrecision(2)+" "+i.m10.toPrecision(2)+" "+i.m11.toPrecision(2)+" "+i.m12.toPrecision(2)+" "+i.m13.toPrecision(2)+" "+i.m14.toPrecision(2)+" "+i.m15.toPrecision(2)+"\n"}this._hash=Dl(t,666)}return this._hash}}]),e}(of),OY=ks(PY.prototype,"_joints",[IY],(function(){return[]})),MY=ks(PY.prototype,"_bindposes",[BY],(function(){return[]})),LY=ks(PY.prototype,"_hash",[io],(function(){return 0})),DY=PY))||DY));v.Skeleton=nK,rt(VY.prototype,"MeshRenderer.prototype",[{name:"enableDynamicBatching"},{name:"recieveShadows"}]),v.ModelComponent=VY,Qt(VY,"cc.ModelComponent");var rK,sK,oK,aK,hK,uK,lK,cK,_K,dK,fK,pK,mK,gK,yK,vK,SK,TK,AK,bK,EK,CK,wK,xK,RK,IK,BK,DK,PK,OK,MK,LK,NK,FK,kK,VK,GK,UK,zK,HK,WK,jK,XK,qK,YK,KK,JK,QK,ZK,$K,tJ,eJ,iJ,nJ,rJ,sJ,oJ,aJ,hJ,uJ,lJ,cJ,_J,dJ,fJ,pJ,mJ,gJ,yJ,vJ,SJ,TJ,AJ,bJ,EJ,CJ,wJ,xJ,RJ,IJ,BJ,DJ,PJ,OJ,MJ,LJ,NJ,FJ,kJ,VJ,GJ,UJ,zJ,HJ,WJ,jJ,XJ,qJ,YJ,KJ,JJ,QJ,ZJ,$J,tQ,eQ,iQ,nQ,rQ,sQ,oQ,aQ,hQ,uQ,lQ,cQ,_Q,dQ=new on,fQ=ge({LUMINOUS_FLUX:0,LUMINANCE:1}),pQ=qs("cc.StaticLightSettings")((zY=function(){function t(){this._baked=HY&&HY(),this._editorOnly=WY&&WY(),this._castShadow=jY&&jY()}return n(t,[{key:"editorOnly",get:function(){return this._editorOnly},set:function(t){this._editorOnly=t}},{key:"baked",get:function(){return this._baked},set:function(t){this._baked=t}},{key:"castShadow",get:function(){return this._castShadow},set:function(t){this._castShadow=t}}]),t}(),HY=ks(zY.prototype,"_baked",[io],(function(){return!1})),WY=ks(zY.prototype,"_editorOnly",[io],(function(){return!1})),jY=ks(zY.prototype,"_castShadow",[io],(function(){return!1})),UY=zY))||UY,mQ=t("aa",(XY=qs("cc.Light"),qY=xo(pQ),YY=xo(im.BitMask),XY(((iK=function(t){function e(){var e;return(e=t.call(this)||this)._color=QY&&QY(),e._useColorTemperature=ZY&&ZY(),e._colorTemperature=$Y&&$Y(),e._staticSettings=tK&&tK(),e._visibility=eK&&eK(),e._type=sR.UNKNOWN,e._lightType=void 0,e._light=null,e._lightType=AR,e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._createLight()},i.onEnable=function(){this._attachToScene()},i.onDisable=function(){this._detachFromScene()},i.onDestroy=function(){this._destroyLight()},i._createLight=function(){this._light||(this._light=v.director.root.createLight(this._lightType)),this.color=this._color,this.useColorTemperature=this._useColorTemperature,this.colorTemperature=this._colorTemperature,this._light.node=this.node,this._light.baked=this.baked,this._light.visibility=this.visibility},i._destroyLight=function(){this._light&&(v.director.root.recycleLight(this._light),this._light=null)},i._attachToScene=function(){if(this._detachFromScene(),this._light&&!this._light.scene&&this.node.scene){var t=this._getRenderScene();switch(this._type){case sR.DIRECTIONAL:t.addDirectionalLight(this._light),t.setMainLight(this._light);break;case sR.SPHERE:t.addSphereLight(this._light);break;case sR.SPOT:t.addSpotLight(this._light);break;case sR.POINT:t.addPointLight(this._light);break;case sR.RANGED_DIRECTIONAL:t.addRangedDirLight(this._light)}}},i._detachFromScene=function(){if(this._light&&this._light.scene){var t=this._light.scene;switch(this._type){case sR.DIRECTIONAL:t.removeDirectionalLight(this._light),t.unsetMainLight(this._light);break;case sR.SPHERE:t.removeSphereLight(this._light);break;case sR.SPOT:t.removeSpotLight(this._light);break;case sR.POINT:t.removePointLight(this._light);break;case sR.RANGED_DIRECTIONAL:t.removeRangedDirLight(this._light)}}},i._onUpdateReceiveDirLight=function(){},n(e,[{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._light&&(dQ.x=t.r/255,dQ.y=t.g/255,dQ.z=t.b/255,this._light.color=dQ)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(t){this._useColorTemperature=t,this._light&&(this._light.useColorTemperature=t)}},{key:"colorTemperature",get:function(){return this._colorTemperature},set:function(t){this._colorTemperature=t,this._light&&(this._light.colorTemperature=t)}},{key:"staticSettings",get:function(){return this._staticSettings},set:function(t){this._staticSettings=t}},{key:"type",get:function(){return this._type}},{key:"baked",get:function(){return this.staticSettings.baked},set:function(t){this.staticSettings.baked=t,null!==this._light&&(this._light.baked=t)}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t,this._light&&(this._light.visibility=t),this._onUpdateReceiveDirLight()}}]),e}(rp)).Type=sR,iK.PhotometricTerm=fQ,QY=ks((JY=iK).prototype,"_color",[io],(function(){return dn.WHITE.clone()})),ZY=ks(JY.prototype,"_useColorTemperature",[io],(function(){return!1})),$Y=ks(JY.prototype,"_colorTemperature",[io],(function(){return 6550})),tK=ks(JY.prototype,"_staticSettings",[io],(function(){return new pQ})),eK=ks(JY.prototype,"_visibility",[io],(function(){return Ky})),p(JY.prototype,"staticSettings",[qY],Object.getOwnPropertyDescriptor(JY.prototype,"staticSettings"),JY.prototype),p(JY.prototype,"visibility",[YY],Object.getOwnPropertyDescriptor(JY.prototype,"visibility"),JY.prototype),KY=JY))||KY)),gQ=Qs,yQ=io,vQ=no,SQ=xo,TQ=t("a9",(rK=qs("cc.DirectionalLight"),sK=vQ("_illuminance"),oK=SQ(qe),aK=gQ({group:{name:"DynamicShadowSettings",displayOrder:1}}),hK=SQ(Ke),uK=gQ({group:{name:"DynamicShadowSettings",displayOrder:5}}),lK=SQ(BT),cK=gQ({group:{name:"DynamicShadowSettings",displayOrder:6}}),_K=SQ(Ye),dK=gQ({group:{name:"DynamicShadowSettings",displayOrder:7}}),fK=SQ(Ye),pK=gQ({group:{name:"DynamicShadowSettings",displayOrder:8}}),mK=SQ(Ye),gK=gQ({group:{name:"DynamicShadowSettings",displayOrder:9}}),yK=SQ(Ye),vK=gQ({group:{name:"DynamicShadowSettings",displayOrder:22}}),SK=SQ(Ye),TK=gQ({group:{name:"DynamicShadowSettings",displayOrder:10}}),AK=SQ(DT),bK=gQ({group:{name:"DynamicShadowSettings",displayOrder:11}}),EK=SQ(Ke),CK=gQ({group:{name:"DynamicShadowSettings",displayOrder:12}}),wK=SQ(Ye),xK=gQ({group:{name:"DynamicShadowSettings",displayOrder:13}}),RK=SQ(PT),IK=gQ({group:{name:"DynamicShadowSettings",displayOrder:14}}),BK=SQ(Ke),DK=gQ({group:{name:"DynamicShadowSettings",displayOrder:15}}),PK=SQ(Ye),OK=gQ({group:{name:"DynamicShadowSettings",displayOrder:16}}),MK=SQ(Ye),LK=gQ({group:{name:"DynamicShadowSettings",displayOrder:17}}),NK=SQ(Ye),FK=gQ({group:{name:"DynamicShadowSettings",displayOrder:19}}),kK=SQ(Ke),VK=gQ({group:{name:"DynamicShadowSettings",displayOrder:20}}),GK=SQ(Ke),UK=gQ({group:{name:"DynamicShadowSettings",displayOrder:21}}),zK=SQ(Ye),rK((WK=function(t){function e(){var e;return(e=t.call(this)||this)._illuminanceHDR=jK&&jK(),e._illuminanceLDR=XK&&XK(),e._shadowEnabled=qK&&qK(),e._shadowPcf=YK&&YK(),e._shadowBias=KK&&KK(),e._shadowNormalBias=JK&&JK(),e._shadowSaturation=QK&&QK(),e._shadowDistance=ZK&&ZK(),e._shadowInvisibleOcclusionRange=$K&&$K(),e._csmLevel=tJ&&tJ(),e._csmLayerLambda=eJ&&eJ(),e._csmOptimizationMode=iJ&&iJ(),e._csmAdvancedOptions=nJ&&nJ(),e._csmLayersTransition=rJ&&rJ(),e._csmTransitionRange=sJ&&sJ(),e._shadowFixedArea=oJ&&oJ(),e._shadowNear=aJ&&aJ(),e._shadowFar=hJ&&hJ(),e._shadowOrthoSize=uJ&&uJ(),e._lightType=IM,Ee.querySettings(be.Category.RENDERING,"highQualityMode")&&(e._shadowPcf=BT.SOFT_2X,e._shadowDistance=50,e.enableCSM=!0,e.staticSettings.castShadow=!0),e}s(e,t);var i=e.prototype;return i._createLight=function(){if(t.prototype._createLight.call(this),this._type=sR.DIRECTIONAL,this._light){var e=this._light;e.illuminanceHDR=this._illuminanceHDR,e.illuminanceLDR=this._illuminanceLDR,e.shadowEnabled=this._shadowEnabled,e.shadowPcf=this._shadowPcf,e.shadowBias=this._shadowBias,e.shadowNormalBias=this._shadowNormalBias,e.shadowSaturation=this._shadowSaturation,e.shadowDistance=this._shadowDistance,e.shadowInvisibleOcclusionRange=this._shadowInvisibleOcclusionRange,e.shadowFixedArea=this._shadowFixedArea,e.shadowNear=this._shadowNear,e.shadowFar=this._shadowFar,e.shadowOrthoSize=this._shadowOrthoSize,e.csmLevel=this._csmLevel,e.csmLayerLambda=this._csmLayerLambda,e.csmOptimizationMode=this._csmOptimizationMode,e.csmLayersTransition=this._csmLayersTransition,e.csmTransitionRange=this._csmTransitionRange}},i._onUpdateReceiveDirLight=function(){if(this._light){t.prototype._onUpdateReceiveDirLight.call(this);var e=this.node.scene;if(e&&e.renderScene&&e.renderScene.mainLight===this._light)for(var i=e.renderScene.models,n=0;n<i.length;n++){var r=i[n];if(r.node){var s=r.node.getComponent(VY);s&&s.onUpdateReceiveDirLight(this._visibility)}}}},n(e,[{key:"illuminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?(this._illuminanceHDR=t,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR)):(this._illuminanceLDR=t,this._light&&(this._light.illuminanceLDR=this._illuminanceLDR))}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this._light&&(this._light.shadowEnabled=this._shadowEnabled)}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this._light&&(this._light.shadowPcf=this._shadowPcf)}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._light&&(this._light.shadowBias=this._shadowBias)}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._light&&(this._light.shadowNormalBias=this._shadowNormalBias)}},{key:"shadowSaturation",get:function(){return this._shadowSaturation},set:function(t){this._shadowSaturation=xi(t,0,1),this._light&&(this._light.shadowSaturation=this._shadowSaturation)}},{key:"shadowDistance",get:function(){return this._shadowDistance},set:function(t){this._shadowDistance=Math.min(t,MT.MAX_FAR),this._shadowDistance/.1<10&&Y(15003,this._shadowDistance),this._light&&(this._light.shadowDistance=this._shadowDistance,this._light.csmNeedUpdate=!0)}},{key:"shadowInvisibleOcclusionRange",get:function(){return this._shadowInvisibleOcclusionRange},set:function(t){this._shadowInvisibleOcclusionRange=Math.min(t,MT.MAX_FAR),this._light&&(this._light.shadowInvisibleOcclusionRange=this._shadowInvisibleOcclusionRange)}},{key:"csmLevel",get:function(){return this._csmLevel},set:function(t){this._csmLevel=t,this._light&&(this._light.csmLevel=this._csmLevel,this._light.csmNeedUpdate=!0)}},{key:"enableCSM",get:function(){return this._csmLevel>DT.LEVEL_1},set:function(t){this._csmLevel=t?DT.LEVEL_4:DT.LEVEL_1,this._light&&(this._light.csmLevel=this._csmLevel,this._light.csmNeedUpdate=!0)}},{key:"csmLayerLambda",get:function(){return this._csmLayerLambda},set:function(t){this._csmLayerLambda=t,this._light&&(this._light.csmLayerLambda=this._csmLayerLambda,this._light.csmNeedUpdate=!0)}},{key:"csmOptimizationMode",get:function(){return this._csmOptimizationMode},set:function(t){this._csmOptimizationMode=t,this._light&&(this._light.csmOptimizationMode=this._csmOptimizationMode)}},{key:"shadowFixedArea",get:function(){return this._shadowFixedArea},set:function(t){this._shadowFixedArea=t,this._light&&(this._light.shadowFixedArea=this._shadowFixedArea)}},{key:"shadowNear",get:function(){return this._shadowNear},set:function(t){this._shadowNear=t,this._light&&(this._light.shadowNear=this._shadowNear)}},{key:"shadowFar",get:function(){return this._shadowFar},set:function(t){this._shadowFar=Math.min(t,MT.MAX_FAR),this._light&&(this._light.shadowFar=this._shadowFar)}},{key:"shadowOrthoSize",get:function(){return this._shadowOrthoSize},set:function(t){this._shadowOrthoSize=t,this._light&&(this._light.shadowOrthoSize=this._shadowOrthoSize)}},{key:"csmAdvancedOptions",get:function(){return this._csmAdvancedOptions},set:function(t){this._csmAdvancedOptions=t}},{key:"csmLayersTransition",get:function(){return this._csmLayersTransition},set:function(t){this._csmLayersTransition=t,this._light&&(this._light.csmLayersTransition=t)}},{key:"csmTransitionRange",get:function(){return this._csmTransitionRange},set:function(t){this._csmTransitionRange=t,this._light&&(this._light.csmTransitionRange=t)}}]),e}(mQ),jK=ks(WK.prototype,"_illuminanceHDR",[gQ,sK],(function(){return 65e3})),XK=ks(WK.prototype,"_illuminanceLDR",[yQ],(function(){return 65e3*Hx.standardExposureValue})),qK=ks(WK.prototype,"_shadowEnabled",[yQ],(function(){return!1})),YK=ks(WK.prototype,"_shadowPcf",[yQ],(function(){return BT.HARD})),KK=ks(WK.prototype,"_shadowBias",[yQ],(function(){return 1e-5})),JK=ks(WK.prototype,"_shadowNormalBias",[yQ],(function(){return 0})),QK=ks(WK.prototype,"_shadowSaturation",[yQ],(function(){return 1})),ZK=ks(WK.prototype,"_shadowDistance",[yQ],(function(){return 50})),$K=ks(WK.prototype,"_shadowInvisibleOcclusionRange",[yQ],(function(){return 200})),tJ=ks(WK.prototype,"_csmLevel",[yQ],(function(){return DT.LEVEL_4})),eJ=ks(WK.prototype,"_csmLayerLambda",[yQ],(function(){return.75})),iJ=ks(WK.prototype,"_csmOptimizationMode",[yQ],(function(){return PT.RemoveDuplicates})),nJ=ks(WK.prototype,"_csmAdvancedOptions",[yQ],(function(){return!1})),rJ=ks(WK.prototype,"_csmLayersTransition",[yQ],(function(){return!1})),sJ=ks(WK.prototype,"_csmTransitionRange",[yQ],(function(){return.05})),oJ=ks(WK.prototype,"_shadowFixedArea",[yQ],(function(){return!1})),aJ=ks(WK.prototype,"_shadowNear",[yQ],(function(){return.1})),hJ=ks(WK.prototype,"_shadowFar",[yQ],(function(){return 10})),uJ=ks(WK.prototype,"_shadowOrthoSize",[yQ],(function(){return 5})),p(WK.prototype,"illuminance",[oK],Object.getOwnPropertyDescriptor(WK.prototype,"illuminance"),WK.prototype),p(WK.prototype,"shadowEnabled",[aK,hK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowEnabled"),WK.prototype),p(WK.prototype,"shadowPcf",[uK,lK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowPcf"),WK.prototype),p(WK.prototype,"shadowBias",[cK,_K],Object.getOwnPropertyDescriptor(WK.prototype,"shadowBias"),WK.prototype),p(WK.prototype,"shadowNormalBias",[dK,fK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowNormalBias"),WK.prototype),p(WK.prototype,"shadowSaturation",[pK,mK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowSaturation"),WK.prototype),p(WK.prototype,"shadowDistance",[gK,yK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowDistance"),WK.prototype),p(WK.prototype,"shadowInvisibleOcclusionRange",[vK,SK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowInvisibleOcclusionRange"),WK.prototype),p(WK.prototype,"csmLevel",[TK,AK],Object.getOwnPropertyDescriptor(WK.prototype,"csmLevel"),WK.prototype),p(WK.prototype,"enableCSM",[bK,EK],Object.getOwnPropertyDescriptor(WK.prototype,"enableCSM"),WK.prototype),p(WK.prototype,"csmLayerLambda",[CK,wK],Object.getOwnPropertyDescriptor(WK.prototype,"csmLayerLambda"),WK.prototype),p(WK.prototype,"csmOptimizationMode",[xK,RK],Object.getOwnPropertyDescriptor(WK.prototype,"csmOptimizationMode"),WK.prototype),p(WK.prototype,"shadowFixedArea",[IK,BK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowFixedArea"),WK.prototype),p(WK.prototype,"shadowNear",[DK,PK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowNear"),WK.prototype),p(WK.prototype,"shadowFar",[OK,MK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowFar"),WK.prototype),p(WK.prototype,"shadowOrthoSize",[LK,NK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowOrthoSize"),WK.prototype),p(WK.prototype,"csmAdvancedOptions",[FK,kK],Object.getOwnPropertyDescriptor(WK.prototype,"csmAdvancedOptions"),WK.prototype),p(WK.prototype,"csmLayersTransition",[VK,GK],Object.getOwnPropertyDescriptor(WK.prototype,"csmLayersTransition"),WK.prototype),p(WK.prototype,"csmTransitionRange",[UK,zK],Object.getOwnPropertyDescriptor(WK.prototype,"csmTransitionRange"),WK.prototype),HK=WK))||HK)),AQ=t("ab",(lJ=qs("cc.SphereLight"),cJ=no("_luminance"),_J=xo(qe),dJ=xo(qe),fJ=xo(fQ),pJ=xo(Ye),mJ=xo(Ye),lJ((yJ=function(t){function e(){var e;return(e=t.call(this)||this)._size=vJ&&vJ(),e._luminanceHDR=SJ&&SJ(),e._luminanceLDR=TJ&&TJ(),e._term=AJ&&AJ(),e._range=bJ&&bJ(),e._lightType=BM,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=sR.SPHERE,this.size=this._size,this.range=this._range,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR)},n(e,[{key:"luminousFlux",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*TR(this._size):this._luminanceLDR},set:function(t){var e=0;v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/TR(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"size",get:function(){return this._size},set:function(t){this._size=t,this._light&&(this._light.size=t)}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}}]),e}(mQ),vJ=ks(yJ.prototype,"_size",[io],(function(){return.15})),SJ=ks(yJ.prototype,"_luminanceHDR",[io,cJ],(function(){return 1700/TR(.15)})),TJ=ks(yJ.prototype,"_luminanceLDR",[io],(function(){return 1700/TR(.15)*Hx.standardExposureValue*Hx.standardLightMeterScale})),AJ=ks(yJ.prototype,"_term",[io],(function(){return fQ.LUMINOUS_FLUX})),bJ=ks(yJ.prototype,"_range",[io],(function(){return 1})),p(yJ.prototype,"luminousFlux",[_J],Object.getOwnPropertyDescriptor(yJ.prototype,"luminousFlux"),yJ.prototype),p(yJ.prototype,"luminance",[dJ],Object.getOwnPropertyDescriptor(yJ.prototype,"luminance"),yJ.prototype),p(yJ.prototype,"term",[fJ],Object.getOwnPropertyDescriptor(yJ.prototype,"term"),yJ.prototype),p(yJ.prototype,"size",[pJ],Object.getOwnPropertyDescriptor(yJ.prototype,"size"),yJ.prototype),p(yJ.prototype,"range",[mJ],Object.getOwnPropertyDescriptor(yJ.prototype,"range"),yJ.prototype),gJ=yJ))||gJ)),bQ=xo,EQ=io,CQ=no,wQ=Qs,xQ=t("ac",(EJ=qs("cc.SpotLight"),CJ=CQ("_luminance"),wJ=bQ(fQ),xJ=bQ(Ye),RJ=wQ({group:{name:"DynamicShadowSettings",displayOrder:1}}),IJ=bQ(Ke),BJ=wQ({group:{name:"DynamicShadowSettings",displayOrder:2}}),DJ=bQ(BT),PJ=wQ({group:{name:"DynamicShadowSettings",displayOrder:3}}),OJ=bQ(Ye),MJ=wQ({group:{name:"DynamicShadowSettings",displayOrder:4}}),LJ=bQ(Ye),EJ((FJ=function(t){function e(){var e;return(e=t.call(this)||this)._size=kJ&&kJ(),e._luminanceHDR=VJ&&VJ(),e._luminanceLDR=GJ&&GJ(),e._term=UJ&&UJ(),e._range=zJ&&zJ(),e._spotAngle=HJ&&HJ(),e._shadowEnabled=WJ&&WJ(),e._shadowPcf=jJ&&jJ(),e._shadowBias=XJ&&XJ(),e._shadowNormalBias=qJ&&qJ(),e._lightType=FM,e}return s(e,t),e.prototype._createLight=function(){if(t.prototype._createLight.call(this),this._type=sR.SPOT,this.size=this._size,this.range=this._range,this.spotAngle=this._spotAngle,this._light){var e=this._light;e.luminanceHDR=this._luminanceHDR,e.luminanceLDR=this._luminanceLDR,e.shadowEnabled=this._shadowEnabled,e.shadowPcf=this._shadowPcf,e.shadowBias=this._shadowBias,e.shadowNormalBias=this._shadowNormalBias}},n(e,[{key:"luminousFlux",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*TR(this._size):this._luminanceLDR},set:function(t){var e=0;v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/TR(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"size",get:function(){return this._size},set:function(t){this._size=t,this._light&&(this._light.size=t)}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}},{key:"spotAngle",get:function(){return this._spotAngle},set:function(t){this._spotAngle=t,this._light&&(this._light.spotAngle=Bi(t))}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this._light&&(this._light.shadowEnabled=t)}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this._light&&(this._light.shadowPcf=t)}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._light&&(this._light.shadowBias=t)}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._light&&(this._light.shadowNormalBias=t)}}]),e}(mQ),kJ=ks(FJ.prototype,"_size",[EQ],(function(){return.15})),VJ=ks(FJ.prototype,"_luminanceHDR",[EQ,CJ],(function(){return 1700/TR(.15)})),GJ=ks(FJ.prototype,"_luminanceLDR",[EQ],(function(){return 1700/TR(.15)*Hx.standardExposureValue*Hx.standardLightMeterScale})),UJ=ks(FJ.prototype,"_term",[EQ],(function(){return fQ.LUMINOUS_FLUX})),zJ=ks(FJ.prototype,"_range",[EQ],(function(){return 1})),HJ=ks(FJ.prototype,"_spotAngle",[EQ],(function(){return 60})),WJ=ks(FJ.prototype,"_shadowEnabled",[EQ],(function(){return!1})),jJ=ks(FJ.prototype,"_shadowPcf",[EQ],(function(){return BT.HARD})),XJ=ks(FJ.prototype,"_shadowBias",[EQ],(function(){return 1e-5})),qJ=ks(FJ.prototype,"_shadowNormalBias",[EQ],(function(){return 0})),p(FJ.prototype,"term",[wJ],Object.getOwnPropertyDescriptor(FJ.prototype,"term"),FJ.prototype),p(FJ.prototype,"size",[xJ],Object.getOwnPropertyDescriptor(FJ.prototype,"size"),FJ.prototype),p(FJ.prototype,"shadowEnabled",[RJ,IJ],Object.getOwnPropertyDescriptor(FJ.prototype,"shadowEnabled"),FJ.prototype),p(FJ.prototype,"shadowPcf",[BJ,DJ],Object.getOwnPropertyDescriptor(FJ.prototype,"shadowPcf"),FJ.prototype),p(FJ.prototype,"shadowBias",[PJ,OJ],Object.getOwnPropertyDescriptor(FJ.prototype,"shadowBias"),FJ.prototype),p(FJ.prototype,"shadowNormalBias",[MJ,LJ],Object.getOwnPropertyDescriptor(FJ.prototype,"shadowNormalBias"),FJ.prototype),NJ=FJ))||NJ));t("ad",(YJ=qs("cc.PointLight"),KJ=no("_luminance"),JJ=xo(qe),QJ=xo(qe),ZJ=xo(fQ),$J=xo(Ye),YJ((eQ=function(t){function e(){var e;return(e=t.call(this)||this)._luminanceHDR=iQ&&iQ(),e._luminanceLDR=nQ&&nQ(),e._term=rQ&&rQ(),e._range=sQ&&sQ(),e._lightType=kM,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=sR.POINT,this.range=this._range,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR)},n(e,[{key:"luminousFlux",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*TR(1):this._luminanceLDR},set:function(t){var e=0;v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/TR(1),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}}]),e}(mQ),iQ=ks(eQ.prototype,"_luminanceHDR",[io,KJ],(function(){return 1700/TR(.15)})),nQ=ks(eQ.prototype,"_luminanceLDR",[io],(function(){return 1700/TR(.15)*Hx.standardExposureValue*Hx.standardLightMeterScale})),rQ=ks(eQ.prototype,"_term",[io],(function(){return fQ.LUMINOUS_FLUX})),sQ=ks(eQ.prototype,"_range",[io],(function(){return 1})),p(eQ.prototype,"luminousFlux",[JJ],Object.getOwnPropertyDescriptor(eQ.prototype,"luminousFlux"),eQ.prototype),p(eQ.prototype,"luminance",[QJ],Object.getOwnPropertyDescriptor(eQ.prototype,"luminance"),eQ.prototype),p(eQ.prototype,"term",[ZJ],Object.getOwnPropertyDescriptor(eQ.prototype,"term"),eQ.prototype),p(eQ.prototype,"range",[$J],Object.getOwnPropertyDescriptor(eQ.prototype,"range"),eQ.prototype),tQ=eQ))||tQ)),t("ae",(oQ=qs("cc.RangedDirectionalLight"),aQ=no("_illuminance"),hQ=xo(qe),oQ((lQ=function(t){function e(){var e;return(e=t.call(this)||this)._illuminanceHDR=cQ&&cQ(),e._illuminanceLDR=_Q&&_Q(),e._lightType=GM,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=sR.RANGED_DIRECTIONAL,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR,this._light.illuminanceLDR=this._illuminanceLDR)},n(e,[{key:"illuminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){v.director.root.pipeline.pipelineSceneData.isHDR?(this._illuminanceHDR=t,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR)):(this._illuminanceLDR=t,this._light&&(this._light.illuminanceLDR=this._illuminanceLDR))}}]),e}(mQ),cQ=ks(lQ.prototype,"_illuminanceHDR",[Qs,aQ],(function(){return 65e3})),_Q=ks(lQ.prototype,"_illuminanceLDR",[io],(function(){return 65e3*Hx.standardExposureValue})),p(lQ.prototype,"illuminance",[hQ],Object.getOwnPropertyDescriptor(lQ.prototype,"illuminance"),lQ.prototype),uQ=lQ))||uQ)),v.LightComponent=mQ,Qt(mQ,"cc.LightComponent"),v.DirectionalLightComponent=TQ,Qt(TQ,"cc.DirectionalLightComponent"),v.SphereLightComponent=AQ,Qt(AQ,"cc.SphereLightComponent"),v.SpotLightComponent=xQ,Qt(xQ,"cc.SpotLightComponent"),nt(xQ.prototype,"SpotLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),nt(AQ.prototype,"SphereLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),nt(mQ.PhotometricTerm,"Light.PhotometricTerm",[{name:"LUMINOUS_POWER",newName:"LUMINOUS_FLUX"}]);var RQ=Symbol("BakeNodeCurves"),IQ=t("fR",function(){function t(){}return t.getOrExtract=function(e){var i=t.pool.get(e);if(!i||i.samples!==e.sample){i&&v.director.root.dataPoolManager.releaseAnimationClip(e);var n=Math.ceil(e.sample*e.duration)+1,r=e.sample;i=e[RQ](0,r,n),t.pool.set(e,i)}return i},t.destroy=function(e){t.pool.delete(e)},t}());IQ.pool=new Map;var BQ=new In;function DQ(t,e,i){for(In.identity(i);t!==e;)In.fromRTS(BQ,t.rotation,t.position,t.scale),In.multiply(i,BQ,i),t=t.parent;return i}var PQ=new $c(ic.POINT,ic.POINT,ic.NONE,nc.CLAMP,nc.CLAMP,nc.CLAMP),OQ=function(t,e,i){t[e+0]=i.m00,t[e+1]=i.m01,t[e+2]=i.m02,t[e+3]=i.m12,t[e+4]=i.m04,t[e+5]=i.m05,t[e+6]=i.m06,t[e+7]=i.m13,t[e+8]=i.m08,t[e+9]=i.m09,t[e+10]=i.m10,t[e+11]=i.m14};function MQ(t,e){var i=4/Math.sqrt(e);return 12*Math.ceil(Math.max(480*i,t)/12)}new Sn,new Sn,new on,new Sn,new on;var LQ=new on,NQ=new on,FQ=new on,kQ=new on,VQ=new In,GQ=new In,UQ=new Ss,zQ=Number.MAX_SAFE_INTEGER,HQ=function(){function t(t){this._device=void 0,this._pool=void 0,this._textureBuffers=new Map,this._formatSize=void 0,this._pixelsPerJoint=void 0,this._customPool=void 0,this._chunkIdxMap=new Map,this._device=t;var e=function(t){return t.getFormatFeatures(Hl.RGBA32F)&$l.SAMPLED_TEXTURE?Hl.RGBA32F:Hl.RGBA8}(this._device);this._formatSize=M_[e].size,this._pixelsPerJoint=48/this._formatSize,this._pool=new wG(t),this._pool.initialize({format:e,roundUpFn:MQ}),this._customPool=new wG(t),this._customPool.initialize({format:e,roundUpFn:MQ})}var e=t.prototype;return e.clear=function(){this._pool.destroy(),this._textureBuffers.clear()},e.registerCustomTextureLayouts=function(t){for(var e=0;e<t.length;e++){var i=t[e],n=i.textureLength;this._device.getFormatFeatures(Hl.RGBA32F)&$l.SAMPLED_TEXTURE||(n*=2);for(var r=this._customPool.createChunk(n),s=0;s<i.contents.length;s++){var o=i.contents[s],a=o.skeleton;this._chunkIdxMap.set(a,r);for(var h=0;h<o.clips.length;h++){var u=o.clips[h];this._chunkIdxMap.set(a^u,r)}}}},e.getDefaultPoseTexture=function(t,e,i){var n=0^t.hash,r=this._textureBuffers.get(n)||null;if(r&&r.bounds.has(e.hash))return r.refCount++,r;var s=t.joints,o=t.bindposes,a=null,h=!1,u=s.length;if(r)r.refCount++;else{var l=12*u,c=this._chunkIdxMap.get(n),_=void 0!==c?this._customPool.alloc(l*Float32Array.BYTES_PER_ELEMENT,c):this._pool.alloc(l*Float32Array.BYTES_PER_ELEMENT);if(!_)return r;r={pixelOffset:_.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:t.hash,clipHash:0,readyToBeDeleted:!1,handle:_},a=new Float32Array(l),h=!0}on.set(FQ,zQ,zQ,zQ),on.set(kQ,-zQ,-zQ,-zQ);for(var d=e.getBoneSpaceBounds(t),f=0,p=0;f<u;f++,p+=12){var m=i.getChildByPath(s[f]),g=m?DQ(m,i,VQ):t.inverseBindposes[f],y=d[f];y&&(Ss.transform(UQ,y,g),UQ.getBoundary(LQ,NQ),on.min(FQ,FQ,LQ),on.max(kQ,kQ,NQ)),h&&(m&&In.multiply(g,g,o[f]),OQ(a,p,m?g:In.IDENTITY))}var v=[new Ss];return r.bounds.set(e.hash,v),Ss.fromPoints(v[0],FQ,kQ),h&&(this._pool.update(r.handle,a.buffer),this._textureBuffers.set(n,r)),r},e.getSequencePoseTexture=function(t,e,i,n){var r=t.hash^e.hash,s=this._textureBuffers.get(r)||null;if(s&&s.bounds.has(i.hash))return s.refCount++,s;var o=t.joints,a=t.bindposes,h=IQ.getOrExtract(e).frames,u=null,l=!1,c=o.length;if(s)s.refCount++;else{var _=12*c*h,d=this._chunkIdxMap.get(r),f=void 0!==d?this._customPool.alloc(_*Float32Array.BYTES_PER_ELEMENT,d):this._pool.alloc(_*Float32Array.BYTES_PER_ELEMENT);if(!f)return null;var p=this._createAnimInfos(t,e,n);s={pixelOffset:f.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:t.hash,clipHash:e.hash,readyToBeDeleted:!1,handle:f,animInfos:p},u=new Float32Array(_),l=!0}var m=i.getBoneSpaceBounds(t),g=[];s.bounds.set(i.hash,g);for(var y=0;y<h;y++)g.push(new Ss(zQ,zQ,zQ,-zQ,-zQ,-zQ));for(var v=0,S=0;v<h;v++){for(var T=g[v],A=0;A<c;A++,S+=12){var b=s.animInfos[A],E=b.curveData,C=b.downstream,w=b.bindposeIdx,x=b.bindposeCorrection,R=void 0,I=!0;E&&C?R=In.multiply(VQ,E[v],C):E?R=E[v]:C?R=C:(R=t.inverseBindposes[w],I=!1);var B=m[A];if(B){var D=x?In.multiply(GQ,R,x):R;Ss.transform(UQ,B,D),UQ.getBoundary(LQ,NQ),on.min(T.center,T.center,LQ),on.max(T.halfExtents,T.halfExtents,NQ)}l&&(I&&In.multiply(VQ,R,a[w]),OQ(u,S,I?VQ:In.IDENTITY))}Ss.fromPoints(T,T.center,T.halfExtents)}return l&&(this._pool.update(s.handle,u.buffer),this._textureBuffers.set(r,s)),s},e.releaseHandle=function(t){if(t.refCount>0&&t.refCount--,!t.refCount&&t.readyToBeDeleted){var e=t.skeletonHash^t.clipHash;(void 0!==this._chunkIdxMap.get(e)?this._customPool:this._pool).free(t.handle),this._textureBuffers.get(e)===t&&this._textureBuffers.delete(e)}},e.releaseSkeleton=function(t){for(var e=this._textureBuffers.values(),i=e.next();!i.done;){var n=i.value;n.skeletonHash===t.hash&&(n.readyToBeDeleted=!0,n.refCount?this._textureBuffers.delete(n.skeletonHash^n.clipHash):this.releaseHandle(n)),i=e.next()}},e.releaseAnimationClip=function(t){for(var e=this._textureBuffers.values(),i=e.next();!i.done;){var n=i.value;n.clipHash===t.hash&&(n.readyToBeDeleted=!0,n.refCount?this._textureBuffers.delete(n.skeletonHash^n.clipHash):this.releaseHandle(n)),i=e.next()}},e._createAnimInfos=function(t,e,i){for(var n=[],r=t.joints,s=t.bindposes,o=r.length,a=IQ.getOrExtract(e),h=0;h<o;h++){for(var u=r[h],l=a.joints[u],c=i.getChildByPath(u),_=void 0,d=void 0;!l;){var f=u.lastIndexOf("/");if(u=u.substring(0,f),l=a.joints[u],c?(_||(_=new In),In.fromRTS(VQ,c.rotation,c.position,c.scale),In.multiply(_,VQ,_),c=c.parent):d=u,f<0)break}var p=h,m=void 0;if(void 0!==d&&l){p=h-1;for(var g=0;g<o;g++)if(r[g]===d){p=g,m=new In,In.multiply(m,s[g],t.inverseBindposes[h]);break}}n.push({curveData:l&&l.transforms,downstream:_,bindposeIdx:p,bindposeCorrection:m})}return n},n(t,[{key:"pixelsPerJoint",get:function(){return this._pixelsPerJoint}}]),t}(),WQ=function(){function t(t){this._pool=new Map,this._device=void 0,this._device=t}var e=t.prototype;return e.getData=function(t){void 0===t&&(t="-1");var e=this._pool.get(t);if(e)return e;var i=this._device.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,ty.SIZE,ty.SIZE)),n=new Float32Array([0,0,0,0]);i.update(n);var r={buffer:i,data:n,dirty:!1,dirtyForJSB:new Uint8Array([0]),currentClip:null};return this._pool.set(t,r),r},e.destroy=function(t){var e=this._pool.get(t);e&&(e.buffer.destroy(),this._pool.delete(t))},e.switchClip=function(t,e){return t.currentClip=e,t.data[0]=0,t.buffer.update(t.data),t.dirty=!1,t},e.clear=function(){for(var t,e=d(this._pool.values());!(t=e()).done;)t.value.buffer.destroy();this._pool.clear()},t}(),jQ=[],XQ=new Map;function qQ(t,e){for(var i=0,n=In.IDENTITY;t;){if(t.stamp===e||t.stamp+1===e&&!t.node.hasChangedFlags){n=t.world,t.stamp=e;break}t.stamp=e,jQ[i++]=t,t=t.parent}for(;i>0;){t=jQ[--i],jQ[i]=null;var r=t.node;In.fromRTS(t.local,r.rotation,r.position,r.scale),n=In.multiply(t.world,n,t.local)}return n}function YQ(t,e){for(var i,n=null,r=0;t!==e;){var s=t.uuid;if(XQ.has(s)){n=XQ.get(s);break}n={node:t,local:new In,world:new In,stamp:-1,parent:null},XQ.set(s,n),jQ[r++]=n,t=t.parent,n=null}for(;r>0;)i=jQ[--r],jQ[r]=null,i.parent=n,n=i;return n}function KQ(t){for(var e=XQ.get(t.uuid)||null;e;)XQ.delete(e.node.uuid),e=e.parent}var JQ=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!1}],QQ=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!0}];function ZQ(t,e,i,n){for(var r=0;r<i.length;r++){for(var s=i[r],o=-1,a=0;a<s.length;a++)if(s[a]===n){o=a;break}o>=0&&(e.push(r),t.push(o))}}var $Q=new on,tZ=new on,eZ=new on,iZ=new on,nZ=new In,rZ=new Ss,sZ=function(){this._format=af.RGBA32F,this._textures=[],this._buffers=[]};sZ.WIDTH=256,sZ.HEIGHT=3;var oZ,aZ,hZ,uZ,lZ,cZ,_Z,dZ,fZ,pZ,mZ,gZ,yZ,vZ,SZ,TZ,AZ,bZ,EZ,CZ,wZ,xZ,RZ,IZ,BZ,DZ,PZ,OZ,MZ,LZ,NZ,FZ,kZ=function(t){function e(){var e;return(e=t.call(this)||this)._buffers=[],e._dataArray=[],e._joints=[],e._bufferIndices=null,e._realTimeJointTexture=new sZ,e._realTimeTextureMode=!1,e.type=dM.SKINNING,e}s(e,t);var i=e.prototype;return i.destroy=function(){if(this.bindSkeleton(),this._buffers.length){for(var e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers.length=0}this._dataArray.length=0,this._realTimeJointTexture._textures.forEach((function(t){t.destroy()})),this._realTimeJointTexture._textures.length=0,this._realTimeJointTexture._buffers.length=0,t.prototype.destroy.call(this)},i.uploadAnimation=function(){},i.bindSkeleton=function(t,e,i){void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null);for(var n=0;n<this._joints.length;n++)KQ(this._joints[n].target);if(this._bufferIndices=null,this._joints.length=0,t&&e&&i){this._realTimeTextureMode=!1,iy.JOINT_UNIFORM_CAPACITY<t.joints.length&&(this._realTimeTextureMode=!0),this.transform=e;var r=i.getBoneSpaceBounds(t),s=i.struct.jointMaps;this._ensureEnoughBuffers(s&&s.length||1),this._bufferIndices=i.jointBufferIndices,this._initRealTimeJointTexture();for(var o=0;o<t.joints.length;o++){var a=r[o],h=e.getChildByPath(t.joints[o]);if(a&&h){var u=YQ(h,e),l=t.bindposes[o],c=[],_=[];s?ZQ(c,_,s,o):(c.push(o),_.push(0)),this._joints.push({indices:c,buffers:_,bound:a,target:h,bindpose:l,transform:u})}}}},i.updateTransform=function(t){var e=this.transform;(e.hasChangedFlags||e.isTransformDirty())&&(e.updateWorldTransform(),this._localDataUpdated=!0),on.set($Q,1/0,1/0,1/0),on.set(tZ,-1/0,-1/0,-1/0);for(var i=0;i<this._joints.length;i++){var n=this._joints[i],r=n.bound,s=qQ(n.transform,t);Ss.transform(rZ,r,s),rZ.getBoundary(eZ,iZ),on.min($Q,$Q,eZ),on.max(tZ,tZ,iZ)}var o=this._worldBounds;this._modelBounds&&o&&(Ss.fromPoints(this._modelBounds,$Q,tZ),this._modelBounds.transform(e._mat,e._pos,e._rot,e._scale,this._worldBounds))},i.updateUBOs=function(e){t.prototype.updateUBOs.call(this,e);for(var i=0;i<this._joints.length;i++){var n=this._joints[i],r=n.indices,s=n.buffers,o=n.transform,a=n.bindpose;In.multiply(nZ,o.world,a);for(var h=0;h<s.length;h++)OQ(this._dataArray[s[h]],12*r[h],nZ)}if(this._realTimeTextureMode)this._updateRealTimeJointTextureBuffer();else for(var u=0;u<this._buffers.length;u++)this._buffers[u].update(this._dataArray[u]);return!0},i.initSubModel=function(e,i,n){var r=i.vertexBuffers,s=i.iaInfo;s.vertexBuffers=i.jointMappedBuffers,t.prototype.initSubModel.call(this,e,i,n),s.vertexBuffers=r},i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e),n=JQ;return this._realTimeTextureMode&&(n=QQ),i?n.concat(i):n},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i);var n=this._bufferIndices[e];if(this._realTimeTextureMode)this._bindRealTimeJointTexture(n,i);else{var r=this._buffers[n];r&&i.bindBuffer(iy.BINDING,r)}},i._updateInstancedAttributes=function(e,i){i.passes[0].batchingScheme!==eT.NONE&&Y(3936,this.node.getPathInHierarchy()),t.prototype._updateInstancedAttributes.call(this,e,i)},i._ensureEnoughBuffers=function(t){if(this._buffers.length){for(var e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers.length=0}if(this._dataArray.length&&(this._dataArray.length=0),this._realTimeTextureMode)for(var i=0;i<t;i++){var n=sZ.WIDTH;this._dataArray[i]=new Float32Array(12*n)}else for(var r=0;r<t;r++){this._buffers[r]=this._device.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,iy.SIZE,iy.SIZE));var s=iy.JOINT_UNIFORM_CAPACITY;this._dataArray[r]=new Float32Array(12*s)}},i._initRealTimeJointTexture=function(){if(this._realTimeJointTexture._textures.length&&(this._realTimeJointTexture._textures.forEach((function(t){t.destroy()})),this._realTimeJointTexture._textures.length=0),this._realTimeJointTexture._buffers.length=0,this._realTimeTextureMode){var t=fN.root.device,e=sZ.WIDTH,i=sZ.HEIGHT;0==(t.getFormatFeatures(Hl.RGBA32F)&$l.SAMPLED_TEXTURE)&&(this._realTimeJointTexture._format=af.RGBA8888,e=4*sZ.WIDTH);for(var n=this._realTimeJointTexture._textures,r=this._realTimeJointTexture._buffers,s=this._realTimeJointTexture._format,o=0;o<this._dataArray.length;o++){r[o]=new Float32Array(4*sZ.HEIGHT*sZ.WIDTH);var a=r[o],h=s===af.RGBA32F?a:new Uint8Array(a.buffer),u=new Rf({width:e,height:i,_data:h,_compressed:!1,format:s}),l=new Zp;l.setFilters(Zp.Filter.NEAREST,Zp.Filter.NEAREST),l.setMipFilter(Zp.Filter.NONE),l.setWrapMode(Zp.WrapMode.CLAMP_TO_EDGE,Zp.WrapMode.CLAMP_TO_EDGE,Zp.WrapMode.CLAMP_TO_EDGE),l.image=u,n[o]=l}}},i._bindRealTimeJointTexture=function(t,e){if(this._realTimeTextureMode){var i=this._realTimeJointTexture._textures[t];if(i){var n=i.getGFXTexture(),r=i.getGFXSampler();e.bindTexture(ly,n),e.bindSampler(ly,r)}}},i._updateRealTimeJointTextureBuffer=function(){if(this._realTimeTextureMode)for(var t=this._realTimeJointTexture._textures,e=this._realTimeJointTexture._buffers,i=0;i<t.length;i++){for(var n=e[i],r=this._dataArray[i],s=r.length/12,o=0,a=0,h=0;h<s;h++)a=4*h,n[a++]=r[o++],n[a++]=r[o++],n[a++]=r[o++],n[a++]=r[o++],a=4*(h+sZ.WIDTH),n[a++]=r[o++],n[a++]=r[o++],n[a++]=r[o++],n[a++]=r[o++],a=4*(h+2*sZ.WIDTH),n[a++]=r[o++],n[a++]=r[o++],n[a++]=r[o++],n[a++]=r[o++];var u=this._realTimeJointTexture._format===af.RGBA32F?n:new Uint8Array(n.buffer);t[i].uploadData(u)}},e}(SY),VZ=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_BAKED_ANIMATION",value:!0}],GZ=function(t){function e(){var e;(e=t.call(this)||this).uploadedAnim=void 0,e._jointsMedium=void 0,e._skeleton=null,e._mesh=null,e._dataPoolManager=void 0,e._instAnimInfoIdx=-1,e.type=dM.BAKED_SKINNING,e._dataPoolManager=v.director.root.dataPoolManager;var i=new Float32Array(4),n=e._dataPoolManager.jointAnimationInfo.getData();return e._jointsMedium={buffer:null,jointTextureInfo:i,animInfo:n,texture:null,boundsInfo:null},e}s(e,t);var i=e.prototype;return i.destroy=function(){this.uploadedAnim=void 0,this._jointsMedium.boundsInfo=null,this._jointsMedium.buffer&&(this._jointsMedium.buffer.destroy(),this._jointsMedium.buffer=null),this._applyJointTexture(),t.prototype.destroy.call(this)},i.bindSkeleton=function(t,e,i){if(void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null),this._skeleton=t,this._mesh=i,t&&e&&i){this.transform=e;var n=this._dataPoolManager;this._jointsMedium.animInfo=n.jointAnimationInfo.getData(e.uuid),this._jointsMedium.buffer||(this._jointsMedium.buffer=this._device.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.DEVICE,$g.SIZE,$g.SIZE)))}},i.updateTransform=function(e){if(t.prototype.updateTransform.call(this,e),this.uploadedAnim){var i=this._jointsMedium,n=i.animInfo,r=i.boundsInfo[n.data[0]],s=this._worldBounds;if(s&&r){var o=this.transform;r.transform(o._mat,o._pos,o._rot,o._scale,s)}}},i.updateUBOs=function(e){t.prototype.updateUBOs.call(this,e);for(var i=this._jointsMedium.animInfo,n=!1,r=this._instAnimInfoIdx,s=0;s<this._subModels.length;s++){var o=this._subModels[s];r>=0?o.instancedAttributeBlock.views[r][0]=i.data[0]:n=!0}return n&&i.dirty&&(i.buffer.update(i.data),i.dirty=!1),!0},i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);return i?i.concat(VZ):VZ},i.uploadAnimation=function(t){if(this._skeleton&&this._mesh&&this.uploadedAnim!==t){this.uploadedAnim=t;var e=this._dataPoolManager,i=null;t?(i=e.jointTexturePool.getSequencePoseTexture(this._skeleton,t,this._mesh,this.transform),this._jointsMedium.boundsInfo=i&&i.bounds.get(this._mesh.hash),this._modelBounds=null):(i=e.jointTexturePool.getDefaultPoseTexture(this._skeleton,this._mesh,this.transform),this._jointsMedium.boundsInfo=null,this._modelBounds=i&&i.bounds.get(this._mesh.hash)[0]),this._applyJointTexture(i)}},i._applyJointTexture=function(t){void 0===t&&(t=null);var e=this._jointsMedium.texture;if(e&&e!==t&&this._dataPoolManager.jointTexturePool.releaseHandle(e),this._jointsMedium.texture=t,t){var i=this._jointsMedium,n=i.buffer,r=i.jointTextureInfo;r[0]=t.handle.texture.width,r[1]=this._skeleton.joints.length,r[2]=t.pixelOffset+.1,r[3]=1/r[0],this.updateInstancedJointTextureInfo(),n&&n.update(r);for(var s=t.handle.texture,o=0;o<this._subModels.length;++o)this._subModels[o].descriptorSet.bindTexture(ay,s)}},i._updateLocalDescriptors=function(e,i){t.prototype._updateLocalDescriptors.call(this,e,i);var n=this._jointsMedium,r=n.buffer,s=n.texture,o=n.animInfo;if(i.bindBuffer($g.BINDING,r),i.bindBuffer(ty.BINDING,o.buffer),s){var a=this._device.getSampler(PQ);i.bindTexture(ay,s.handle.texture),i.bindSampler(ay,a)}},i._updateInstancedAttributes=function(e,i){t.prototype._updateInstancedAttributes.call(this,e,i),this._instAnimInfoIdx=i.getInstancedAttributeIndex(ey),this.updateInstancedJointTextureInfo()},i.updateInstancedJointTextureInfo=function(){for(var t=this._jointsMedium,e=t.jointTextureInfo,i=t.animInfo,n=this._instAnimInfoIdx,r=0;r<this._subModels.length;r++){var s=this._subModels[r].instancedAttributeBlock.views;if(n>=0&&s.length>0){var o=s[n];o[0]=i.data[0],o[1]=e[1],o[2]=e[2]}}},e}(SY),UZ=t("af",(oZ=qs("cc.SkinnedMeshRenderer"),aZ=Ks(100),hZ=xo(nK),uZ=xo(Jm),lZ=xo(nK),cZ=xo(Jm),oZ(_Z=aZ((dZ=function(t){function e(){var e;return(e=t.call(this)||this)._skeleton=fZ&&fZ(),e._skinningRoot=pZ&&pZ(),e._clip=null,e.associatedAnimation=null,e._modelType=GZ,e}s(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this),this._tryBindAnimation()},i.onDestroy=function(){this.associatedAnimation&&(this.associatedAnimation.notifySkinnedMeshRemoved(this),this.associatedAnimation),t.prototype.onDestroy.call(this)},i.uploadAnimation=function(t){this._clip=t,this.model&&this.model.uploadAnimation&&this.model.uploadAnimation(t)},i.setUseBakedAnimation=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1);var i=t?GZ:kZ;(e||this._modelType!==i)&&(this._modelType=i,this._model&&(v.director.root.destroyModel(this._model),this._model=null,this._models.length=0,this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateUseLightProbe(),this.enabledInHierarchy&&this._attachToScene()))},i.setSharedMaterial=function(e,i){t.prototype.setSharedMaterial.call(this,e,i),this._modelType===kZ&&this.getMaterialInstance(i)},i._updateModelParams=function(){this._update(),t.prototype._updateModelParams.call(this)},i._tryBindAnimation=function(){var t=this._skinningRoot;if(t){for(var e=!1,i=this.node;i;i=i.parent)if(i===t){e=!0;break}if(e){var n=t.getComponent("cc.SkeletalAnimation");n&&n.enabledInHierarchy?n.notifySkinnedMeshAdded(this):this.setUseBakedAnimation(!1)}}},i._update=function(){this.model&&(this.model.bindSkeleton(this._skeleton,this._skinningRoot,this._mesh),this.model.uploadAnimation&&this.model.uploadAnimation(this._clip))},n(e,[{key:"skeleton",get:function(){return this._skeleton},set:function(t){t!==this._skeleton&&(this._skeleton=t,this._update())}},{key:"skinningRoot",get:function(){return this._skinningRoot},set:function(t){t!==this._skinningRoot&&(this._skinningRoot=t,this._tryBindAnimation(),this._update())}},{key:"model",get:function(){return this._model}}]),e}(VY),fZ=ks(dZ.prototype,"_skeleton",[hZ],(function(){return null})),pZ=ks(dZ.prototype,"_skinningRoot",[uZ],(function(){return null})),p(dZ.prototype,"skeleton",[lZ],Object.getOwnPropertyDescriptor(dZ.prototype,"skeleton"),dZ.prototype),p(dZ.prototype,"skinningRoot",[cZ],Object.getOwnPropertyDescriptor(dZ.prototype,"skinningRoot"),dZ.prototype),_Z=dZ))||_Z)||_Z)),zZ=new u_(Ic.ATTR_BATCH_ID,Hl.R32F),HZ=new u_(Ic.ATTR_BATCH_UV,Hl.RG32F),WZ=M_[zZ.format].size+M_[HZ.format].size,jZ=t("ah",(mZ=qs("cc.SkinnedMeshUnit"),gZ=xo(XN),yZ=xo(nK),vZ=xo(xT),SZ=xo(UZ),mZ((AZ=function(){function t(){this.mesh=bZ&&bZ(),this.skeleton=EZ&&EZ(),this.material=CZ&&CZ(),this._localTransform=wZ&&wZ(),this._offset=xZ&&xZ(),this._size=RZ&&RZ()}return n(t,[{key:"offset",get:function(){return this._offset},set:function(t){Ln.copy(this._offset,t)}},{key:"size",get:function(){return this._size},set:function(t){Ln.copy(this._size,t)}},{key:"copyFrom",get:function(){return null},set:function(t){t&&(this.mesh=t.mesh,this.skeleton=t.skeleton,this.material=t.getSharedMaterial(0),t.skinningRoot&&DQ(t.node,t.skinningRoot,this._localTransform))}}]),t}(),bZ=ks(AZ.prototype,"mesh",[gZ],(function(){return null})),EZ=ks(AZ.prototype,"skeleton",[yZ],(function(){return null})),CZ=ks(AZ.prototype,"material",[vZ],(function(){return null})),wZ=ks(AZ.prototype,"_localTransform",[io],(function(){return new In})),xZ=ks(AZ.prototype,"_offset",[io],(function(){return new Ln(0,0)})),RZ=ks(AZ.prototype,"_size",[io],(function(){return new Ln(1,1)})),p(AZ.prototype,"copyFrom",[SZ],Object.getOwnPropertyDescriptor(AZ.prototype,"copyFrom"),AZ.prototype),TZ=AZ))||TZ)),XZ=new In;new In;var qZ,YZ,KZ,JZ,QZ,ZZ,$Z,t$,e$,i$,n$,r$,s$,o$,a$,h$,u$,l$=new on,c$=t("ag",(IZ=qs("cc.SkinnedMeshBatchRenderer"),BZ=Ks(100),DZ=xo([Je]),PZ=xo([jZ]),IZ(OZ=BZ((MZ=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).atlasSize=LZ&&LZ(),e.batchableTextureNames=NZ&&NZ(),e.units=FZ&&FZ(),e._textures={},e._batchMaterial=null,e}s(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this),this.cook()},i.onDestroy=function(){for(var e in this._textures)this._textures[e].destroy();this._textures={},this._mesh&&(this._mesh.destroy(),this._mesh=null),t.prototype.onDestroy.call(this)},i._onMaterialModified=function(e){this.cookMaterials(),t.prototype._onMaterialModified.call(this,e,this.getMaterialInstance(e))},i.cook=function(){this.cookMaterials(),this.cookSkeletons(),this.cookMeshes()},i.cookMaterials=function(){var t=this;this._batchMaterial||(this._batchMaterial=this.getSharedMaterial(0));var e=this.getMaterialInstance(0);if(e&&this._batchMaterial&&this._batchMaterial.effectAsset){e.copy(this._batchMaterial),this.resizeAtlases();for(var i=e.effectAsset.techniques[e.technique],n=function(n){var r=i.passes[n];if(!r.properties)return 1;var s=function(i){if(r.properties[i].type>=jl.SAMPLER1D){var s=null;t.batchableTextureNames.find((function(t){return t===i}))?((s=t._textures[i])||(s=t.createTexture(i)),t.cookTextures(s,i,n)):t.units.some((function(t){return s=t.material&&t.material.getProperty(i,n)})),s&&e.setProperty(i,s,n)}else{for(var o=[],a=0;a<t.units.length;a++){var h=t.units[a];h.material&&o.push(h.material.getProperty(i.slice(0,-3),n))}e.setProperty(i,o,n)}};for(var o in r.properties)s(o)},r=0;r<i.passes.length;r++)n(r)}else console.warn("incomplete batch material!")},i.cookSkeletons=function(){if(this._skinningRoot){for(var t=[],e=[],i=0;i<this.units.length;i++){var n=this.units[i];if(n&&n.skeleton){var r=n.skeleton;In.invert(XZ,n._localTransform);for(var s=function(){var i=r.joints[o];if(t.findIndex((function(t){return t===i}))>=0)return 1;t.push(i),e.push(In.multiply(new In,r.bindposes[o]||In.IDENTITY,XZ))},o=0;o<r.joints.length;o++)s()}}var a=Array.from(Array(t.length).keys()).sort((function(e,i){return t[e]>t[i]?1:t[e]<t[i]?-1:0})),h=new nK;h.joints=t.map((function(t,e,i){return i[a[e]]})),h.bindposes=e.map((function(t,e,i){return i[a[e]]})),this._skeleton&&this._skeleton.destroy(),this.skeleton=h}else console.warn("no skinning root specified!")},i.cookMeshes=function(){for(var t=this,e=!1,i=0;i<this.units.length;i++)if(this.units[i].mesh){e=!0;break}if(e&&this._skinningRoot){this._mesh?this._mesh.destroyRenderingMesh():this._mesh=new XN;for(var n=0,r=Hl.UNKNOWN,s=0,o=Hl.UNKNOWN,a=0,h=Hl.UNKNOWN,u=0,l=Hl.UNKNOWN,c=0,_=Hl.UNKNOWN,d=new Array(this.units.length),f=this.units.length,p=0;p<f;p++){var m=this.units[p];m&&m.skeleton&&(d[p]=m.skeleton.joints.map((function(e){return t._skeleton.joints.findIndex((function(t){return e===t}))})))}for(var g=function(){var e=t.units[y];if(!e||!e.mesh||!e.mesh.data)return 1;var i=t._createUnitMesh(y,e.mesh),f=new DataView(i.data.buffer);In.invert(XZ,e._localTransform),In.transpose(XZ,XZ);for(var p=e.offset,m=e.size,g=function(){var t=i.struct.vertexBundles[v];n=t.view.offset,r=Hl.UNKNOWN;for(var g=0;g<t.attributes.length;g++){var S=t.attributes[g];if(S.name===Ic.ATTR_POSITION){r=S.format;break}n+=M_[S.format].size}if(r){for(var T=DR(f,r,n,t.view.length,t.view.stride),A=0;A<T.length;A+=3)on.fromArray(l$,T,A),on.transformMat4(l$,l$,e._localTransform),on.toArray(T,l$,A);BR(f,T,r,n,t.view.stride)}s=t.view.offset,o=Hl.UNKNOWN;for(var b=0;b<t.attributes.length;b++){var E=t.attributes[b];if(E.name===Ic.ATTR_NORMAL){o=E.format;break}s+=M_[E.format].size}if(o){for(var C=DR(f,o,s,t.view.length,t.view.stride),w=0;w<C.length;w+=3)on.fromArray(l$,C,w),on.transformMat4Normal(l$,l$,XZ),on.toArray(C,l$,w);BR(f,C,o,s,t.view.stride)}a=t.view.offset,h=Hl.UNKNOWN;for(var x=0;x<t.attributes.length;x++){var R=t.attributes[x];if(R.name===Ic.ATTR_TANGENT){h=R.format;break}a+=M_[R.format].size}if(h){for(var I=DR(f,h,a,t.view.length,t.view.stride),B=0;B<I.length;B+=3)on.fromArray(l$,I,B),on.transformMat4Normal(l$,l$,XZ),on.toArray(I,l$,B);BR(f,I,h,a,t.view.stride)}u=t.view.offset,l=Hl.UNKNOWN;for(var D=0;D<t.attributes.length;D++){var P=t.attributes[D];if(P.name===Ic.ATTR_BATCH_UV){l=P.format;break}u+=M_[P.format].size}l&&PR(f,(function(t,e){var i,n=0===e?"x":"y";return(t=(i=t)-Math.floor(i))*m[n]+p[n]}),l,u,t.view.length,t.view.stride,f);var O=d[y];if(!O)return 1;c=t.view.offset,_=Hl.UNKNOWN;for(var M=0;M<t.attributes.length;M++){var L=t.attributes[M];if(L.name===Ic.ATTR_JOINTS){_=L.format;break}c+=M_[L.format].size}_&&PR(f,(function(t){return O[t]}),_,c,t.view.length,t.view.stride,f)},v=0;v<i.struct.vertexBundles.length;v++)g();t._mesh.merge(i)},y=0;y<f;y++)g();this._onMeshChanged(this._mesh),this._updateModels()}},i.cookTextures=function(t,e,i){for(var n=[],r=[],s=[],o=[],a=0;a<this.units.length;a++){var h=this.units[a];if(h.material){var u=h.material.getProperty(e,i);if(u&&u.image&&u.image.data){var l=new Gc;l.texOffset.x=h.offset.x*this.atlasSize,l.texOffset.y=h.offset.y*this.atlasSize,l.texExtent.width=h.size.x*this.atlasSize,l.texExtent.height=h.size.y*this.atlasSize;var c=u.image.data;ArrayBuffer.isView(c)?(s.push(c),o.push(l)):(n.push(c),r.push(l))}}}var _=t.getGFXTexture(),d=v.director.root.device;s.length>0&&d.copyBuffersToTexture(s,_,o),n.length>0&&d.copyTexImagesToTexture(n,_,r)},i.createTexture=function(t){var e=new Zp;return e.setFilters(uf.LINEAR,uf.LINEAR),e.setMipFilter(uf.NEAREST),e.reset({width:this.atlasSize,height:this.atlasSize,format:af.RGBA8888}),this._textures[t]=e,e},i.resizeAtlases=function(){for(var t in this._textures)this._textures[t].reset({width:this.atlasSize,height:this.atlasSize,format:af.RGBA8888})},i._createUnitMesh=function(t,e){for(var i=JSON.parse(JSON.stringify(e.struct)),n={},r=0;r<e.struct.primitives.length;r++){for(var s=e.struct.primitives[r],o=0,a=Hl.UNKNOWN,h=0;h<s.vertexBundelIndices.length;h++){var u=e.struct.vertexBundles[s.vertexBundelIndices[h]];o=u.view.offset,a=Hl.UNKNOWN;for(var l=0;l<u.attributes.length;l++){var c=u.attributes[l];if(c.name===Ic.ATTR_TEX_COORD){a=c.format;break}o+=M_[c.format].size}if(a)break}if(void 0===n[h]){n[h]=[a,o];var _=i.vertexBundles[h];_.attributes.push(zZ),_.attributes.push(HZ),_.view.offset=0,_.view.length+=_.view.count*WZ,_.view.stride+=WZ}}for(var d=0,f=0;f<i.vertexBundles.length;f++)d+=i.vertexBundles[f].view.length;for(var p=0;p<i.primitives.length;p++){var m=i.primitives[p];m.indexView&&(m.indexView.offset=d,d+=m.indexView.length)}var g=new Uint8Array(d),y=e.data,S=new DataView(g.buffer),T=new DataView(y.buffer),A=v.sys.isLittleEndian;for(var b in n)for(var E=i.vertexBundles[b],C=e.struct.vertexBundles[b],w=n[b],x=DR(T,w[0],w[1],C.view.length,C.view.stride),R=C.view,I=E.view,B=R.stride,D=I.stride,P=R.offset,O=I.offset,M=0;M<I.count;M++){var L=y.subarray(P,P+B);g.set(L,O),S.setFloat32(O+B,t),S.setFloat32(O+B+4,x[2*M],A),S.setFloat32(O+B+8,x[2*M+1],A),O+=D,P+=B}for(var N=0;N<i.primitives.length;N++){var F=e.struct.primitives[N],k=i.primitives[N];if(F.indexView&&k.indexView)for(var V=F.indexView.stride,G=k.indexView.stride,U=F.indexView.offset,z=k.indexView.offset,H=0;H<k.indexView.count;H++){var W=y.subarray(U,U+V);g.set(W,z),z+=G,U+=V}}var j=new XN;return j.reset({struct:i,data:g}),j},n(e,[{key:"mesh",get:function(){return t.prototype.mesh},set:function(t){this.mesh=t}},{key:"skeleton",get:function(){return t.prototype.skeleton},set:function(t){this.skeleton=t}}]),e}(UZ),LZ=ks(MZ.prototype,"atlasSize",[io],(function(){return 1024})),NZ=ks(MZ.prototype,"batchableTextureNames",[DZ,io],(function(){return[]})),FZ=ks(MZ.prototype,"units",[PZ,io],(function(){return[]})),p(MZ.prototype,"mesh",[Ro],Object.getOwnPropertyDescriptor(MZ.prototype,"mesh"),MZ.prototype),p(MZ.prototype,"skeleton",[Ro],Object.getOwnPropertyDescriptor(MZ.prototype,"skeleton"),MZ.prototype),OZ=MZ))||OZ)||OZ));v.SkinningModelComponent=UZ,Qt(UZ,"cc.SkinningModelComponent"),v.SkinningModelUnit=jZ,Qt(jZ,"cc.SkinningModelUnit"),v.BatchedSkinningModelComponent=c$,Qt(c$,"cc.BatchedSkinningModelComponent");var _$=[.25,.125,.01],d$=t("ai",(qZ=qs("cc.LOD"),YZ=xo([VY]),KZ=xo(Ye),JZ=xo([VY]),QZ=xo([qe]),qZ(($Z=function(){function t(){this._screenUsagePercentage=t$&&t$(),this._renderers=e$&&e$(),this._LODData=new UM,this._modelAddedCallback=void 0,this._LODData.screenUsagePercentage=this._screenUsagePercentage,this._modelAddedCallback=null}var e=t.prototype;return e.insertRenderer=function(t,e){(t<0||t>this._renderers.length)&&(t=this._renderers.length),this._renderers.splice(t,0,e);var i=!1;return e.model&&(i=!0,this._LODData.addModel(e.model)),this._modelAddedCallback&&i&&this._modelAddedCallback(),e},e.deleteRenderer=function(t){var e,i=this._renderers.splice(t,1),n=i.length>0?null===(e=i[0])||void 0===e?void 0:e.model:null;return n&&this._LODData.eraseModel(n),i[0]},e.getRenderer=function(t){return this._renderers[t]||null},e.setRenderer=function(t,e){t<0||t>=this.rendererCount?console.error("setRenderer to LOD error, index out of range"):(this.deleteRenderer(t),this.insertRenderer(t,e))},n(t,[{key:"screenUsagePercentage",get:function(){return this._screenUsagePercentage},set:function(t){this._screenUsagePercentage=t,this._LODData.screenUsagePercentage=t}},{key:"renderers",get:function(){return this._renderers},set:function(t){if(t!==this._renderers){var e=!1;this._renderers.length=0,this._LODData.clearModels();for(var i=0;i<t.length;i++){var n;this._renderers[i]=t[i];var r=null===(n=t[i])||void 0===n?void 0:n.model;r&&(e=!0,this._LODData.addModel(r))}this._modelAddedCallback&&e&&this._modelAddedCallback()}}},{key:"triangleCount",get:function(){var t=[];return this._renderers.forEach((function(e){var i=0;if(e&&e.mesh){var n=e.mesh.struct.primitives;null==n||n.forEach((function(t){t&&t.indexView&&(i+=t.indexView.count)}))}t.push(i/3)})),t}},{key:"rendererCount",get:function(){return this._renderers.length}},{key:"lodData",get:function(){return this._LODData}},{key:"modelAddedCallback",set:function(t){this._modelAddedCallback=t}}]),t}(),t$=ks($Z.prototype,"_screenUsagePercentage",[io],(function(){return 1})),e$=ks($Z.prototype,"_renderers",[YZ,io],(function(){return[]})),p($Z.prototype,"screenUsagePercentage",[KZ],Object.getOwnPropertyDescriptor($Z.prototype,"screenUsagePercentage"),$Z.prototype),p($Z.prototype,"renderers",[JZ],Object.getOwnPropertyDescriptor($Z.prototype,"renderers"),$Z.prototype),p($Z.prototype,"triangleCount",[QZ],Object.getOwnPropertyDescriptor($Z.prototype,"triangleCount"),$Z.prototype),ZZ=$Z))||ZZ)),f$=(t("aj",(i$=qs("cc.LODGroup"),n$=xo(Ye),r$=xo([d$]),i$((o$=function(t){function e(){var e;return(e=t.call(this)||this)._localBoundaryCenter=a$&&a$(),e._objectSize=h$&&h$(),e._LODs=u$&&u$(),e._lodGroup=new zM,e._eventRegistered=!1,e._forceUsedLevels=[],e}s(e,t);var i=e.prototype;return i.onLodModelAddedCallback=function(){0===this.objectSize&&this.recalculateBounds()},i.insertLOD=function(t,e,i){if((t<0||t>this.lodCount)&&(t=this.lodCount),i||(i=new d$),i.modelAddedCallback=this.onLodModelAddedCallback.bind(this),!e){var n=this.getLOD(t-1),r=this.getLOD(t);if(n&&r)e=(n.screenUsagePercentage+r.screenUsagePercentage)/2;else if(n&&!r)(e=n.screenUsagePercentage/2)>.01&&(e=.01);else if(r&&!n){e=r.screenUsagePercentage;var s=this.getLOD(t+1);r.screenUsagePercentage=(e+(s?s.screenUsagePercentage:0))/2}else e=_$[0]}return i.screenUsagePercentage=e,this._LODs.splice(t,0,i),this._lodGroup.insertLOD(t,i.lodData),this._updateDataToScene(),this.node&&this._emitChangeNode(this.node),i},i.eraseLOD=function(t){if(t<0||t>=this.lodCount)return console.warn("eraseLOD error, index out of range"),null;var e=this._LODs[t];return e?(this._LODs.splice(t,1),this._lodGroup.eraseLOD(t),this._updateDataToScene(),this._emitChangeNode(this.node),e):(console.warn("eraseLOD error, LOD not exist at specified index."),null)},i.getLOD=function(t){return t<0||t>=this.lodCount?(console.warn("getLOD error, index out of range"),null):this._LODs[t]},i.setLOD=function(t,e){t<0||t>=this.lodCount?console.warn("setLOD error, index out of range"):(this._LODs[t]=e,e.modelAddedCallback=this.onLodModelAddedCallback.bind(this),this.lodGroup.updateLOD(t,e.lodData),this._updateDataToScene())},i.recalculateBounds=function(){for(var t=new on,e=new on,i=null,n=new on,r=0;r<this.lodCount;++r){var s=this.getLOD(r);if(s)for(var o=0;o<s.rendererCount;++o){var a,h,u=s.getRenderer(o);if(u){null===(a=u.model)||void 0===a||a.updateWorldBound();var l=null===(h=u.model)||void 0===h?void 0:h.worldBounds;l&&(l.getBoundary(t,e),i?(on.min(i,i,t),on.max(n,n,e)):(i=t.clone(),n=e.clone()))}}}if(i){var c=i,_=new on(.5*(n.x+c.x),.5*(n.y+c.y),.5*(n.z+c.z)),d=new on(.5*(n.x-c.x),.5*(n.y-c.y),.5*(n.z-c.z)),f=function(t,e,i){var n,r,s=new Array(new on(t.x-e.x,t.y-e.y,t.z-e.z),new on(t.x-e.x,t.y+e.y,t.z-e.z),new on(t.x+e.x,t.y+e.y,t.z-e.z),new on(t.x+e.x,t.y-e.y,t.z-e.z),new on(t.x-e.x,t.y-e.y,t.z+e.z),new on(t.x-e.x,t.y+e.y,t.z+e.z),new on(t.x+e.x,t.y+e.y,t.z+e.z),new on(t.x+e.x,t.y-e.y,t.z+e.z));r=(n=s[0].transformMat4(i)).clone();for(var o=1;o<8;++o){var a=s[o].transformMat4(i);n=on.min(n,n,a),r=on.max(r,r,a)}return[n,r]}(_,d,this.node.worldMatrix.clone().invert()),p=f[0],m=f[1];_.set(.5*(m.x+p.x),.5*(m.y+p.y),.5*(m.z+p.z)),d.set(.5*(m.x-p.x),.5*(m.y-p.y),.5*(m.z-p.z)),this.localBoundaryCenter=_,this.objectSize=2*Math.max(d.x,d.y,d.z)}else this.localBoundaryCenter=new on(0,0,0),this.objectSize=0;this._emitChangeNode(this.node)},i.resetObjectSize=function(){if(1!==this.objectSize){0===this.objectSize&&(this.objectSize=1);var t=1/this.objectSize;this.objectSize=1;for(var e=0;e<this.lodCount;++e){var i=this.getLOD(e);i&&(i.screenUsagePercentage*=t)}this._emitChangeNode(this.node)}},i.forceLOD=function(t){this._forceUsedLevels=t<0?[]:[t],this.lodGroup.lockLODLevels(this._forceUsedLevels)},i.forceLODs=function(){},i.onLoad=function(){this._lodGroup.node=this.node,this._lodGroup.objectSize=this._objectSize,this._lodGroup.localBoundaryCenter=this._localBoundaryCenter,this._eventRegistered||(this.node.on(om.COMPONENT_REMOVED,this._onRemove,this),this._eventRegistered=!0),this._constructLOD()},i._onRemove=function(t){t===this&&this.onDisable()},i._constructLOD=function(){if(this.lodCount<1)for(var t=_$.length,e=0;e<t;e++)this.insertLOD(e,_$[e])},i.onRestore=function(){this._constructLOD(),this.enabledInHierarchy&&this._attachToScene()},i.onEnable=function(){var t=this;this._attachToScene(),0===this.objectSize&&this.recalculateBounds(),this.lodGroup.lockLODLevels(this._forceUsedLevels),this.lodCount>0&&this._lodGroup.lodCount<1&&this._LODs.forEach((function(e,i){e.lodData.screenUsagePercentage=e.screenUsagePercentage;var n=e.renderers;if(null!==n&&n.length>0)for(var r=0;r<n.length;r++){var s=e.lodData,o=n[r];s&&o&&o.model&&s.addModel(o.model)}t._lodGroup.insertLOD(i,e.lodData)}))},i.onDisable=function(){this._detachFromScene(),this.lodGroup.lockLODLevels([])},i._attachToScene=function(){if(this.node&&this.node.scene){var t=this._getRenderScene();this._lodGroup.scene&&this._detachFromScene(),t.addLODGroup(this._lodGroup)}},i._detachFromScene=function(){this._lodGroup.scene&&this._lodGroup.scene.removeLODGroup(this._lodGroup)},i._emitChangeNode=function(){},i._updateDataToScene=function(){this._detachFromScene(),this._attachToScene()},n(e,[{key:"localBoundaryCenter",get:function(){return this._localBoundaryCenter.clone()},set:function(t){this._localBoundaryCenter.set(t),this._lodGroup.localBoundaryCenter=t}},{key:"lodCount",get:function(){return this._LODs.length}},{key:"objectSize",get:function(){return this._objectSize},set:function(t){this._objectSize=t,this._lodGroup.objectSize=t}},{key:"LODs",get:function(){return this._LODs},set:function(t){var e=this;t!==this._LODs?(this._LODs.length=0,this.lodGroup.clearLODs(),t.forEach((function(t,i){e.lodGroup.insertLOD(i,t.lodData),e._LODs[i]=t,t.modelAddedCallback=e.onLodModelAddedCallback.bind(e)})),this._updateDataToScene()):this._updateDataToScene()}},{key:"lodGroup",get:function(){return this._lodGroup}}]),e}(rp),a$=ks(o$.prototype,"_localBoundaryCenter",[io],(function(){return new on(0,0,0)})),h$=ks(o$.prototype,"_objectSize",[io],(function(){return 0})),u$=ks(o$.prototype,"_LODs",[io],(function(){return[]})),p(o$.prototype,"objectSize",[n$],Object.getOwnPropertyDescriptor(o$.prototype,"objectSize"),o$.prototype),p(o$.prototype,"LODs",[r$],Object.getOwnPropertyDescriptor(o$.prototype,"LODs"),o$.prototype),s$=o$))||s$)),im.makeMaskExclude([im.BitMask.UI_2D,im.BitMask.UI_3D,im.BitMask.GIZMOS,im.BitMask.EDITOR,im.BitMask.SCENE_GIZMO,im.BitMask.PROFILER,im.Enum.IGNORE_RAYCAST])),p$=t("al",function(){function t(){this._probes=[],this._useCubeModels=new Map,this._usePlanarModels=new Map,this._updateForRuntime=!0,this._dataTexture=null,this._registeredEvent=!1}var e=t.prototype;return e.registerEvent=function(){this._registeredEvent||(v.director.on(v.Director.EVENT_BEFORE_UPDATE,this.onUpdateProbes,this),this._registeredEvent=!0)},e.onUpdateProbes=function(){if(0!==this._probes.length){var t=v.director.getScene();if(t&&t.renderScene)for(var e=t.renderScene.models,i=0;i<e.length;i++){var n=e[i];n.node&&n.node.layer&f$&&(n.reflectionProbeType===uM.BAKED_CUBEMAP||this._isUsedBlending(n)?this.selectReflectionProbe(n):n.reflectionProbeType===uM.PLANAR_REFLECTION&&this.selectPlanarReflectionProbe(n))}}},e.filterModelsForPlanarReflection=function(){if(0!==this._probes.length){var t=v.director.getScene();if(t&&t.renderScene)for(var e=t.renderScene.models,i=0;i<e.length;i++){var n=e[i];n.node&&n.node.layer&f$&&n.reflectionProbeType===uM.PLANAR_REFLECTION&&this.selectPlanarReflectionProbe(n)}}},e.clearPlanarReflectionMap=function(t){for(var e,i=d(this._usePlanarModels.entries());!(e=i()).done;){var n=e.value;n[1]===t&&this._updatePlanarMapOfModel(n[0],null,null)}},e.register=function(t){-1===this._probes.indexOf(t)&&(this._probes.push(t),this.updateProbeData())},e.unregister=function(t){for(var e=0;e<this._probes.length;e++)if(this._probes[e]===t){var i=this._probes.splice(e,1);i[0]&&this._removeDependentModels(i[0]);break}this.updateProbeData()},e.exists=function(t){if(0===this._probes.length)return!1;for(var e=0;e<this._probes.length;e++)if(this._probes[e].getProbeId()===t)return!0;return!1},e.getNewReflectionProbeId=function(){for(var t=0;;){if(!this.exists(t))return t;t++}},e.getProbes=function(){return this._probes},e.getProbeById=function(t){for(var e=0;e<this._probes.length;e++)if(this._probes[e].getProbeId()===t)return this._probes[e];return null},e.clearAll=function(){this._probes=[]},e.getProbeByCamera=function(t){for(var e=0;e<this._probes.length;e++)if(this._probes[e].camera===t)return this._probes[e];return null},e.updateBakedCubemap=function(t){var e=this._getModelsByProbe(t);if(t.cubemap){for(var i=0;i<e.length;i++){var n=e[i];this._updateCubemapOfModel(n,t)}if(t.needRefresh=!1,0===e.length)for(var r,s=d(this._useCubeModels.entries());!(r=s()).done;){var o=r.value;o[0].reflectionProbeBlendId===t.getProbeId()&&this._updateBlendCubemap(o[0],t)}}},e.updatePlanarMap=function(t,e){if(t.node&&t.node.scene){for(var i=this._getModelsByProbe(t),n=0;n<i.length;n++)this._updatePlanarMapOfModel(i[n],e,t);if(t.previewPlane){var r=t.previewPlane.getComponent(VY);r&&r.updateProbePlanarMap(e)}}},e.selectPlanarReflectionProbe=function(t){if(t.node&&t.worldBounds&&t.reflectionProbeType===uM.PLANAR_REFLECTION){for(var e=0;e<this._probes.length;e++){var i=this._probes[e];i.probeType===eR.PLANAR&&t.node.layer&f$&&(t.updateWorldBound(),as.aabbWithAABB(t.worldBounds,i.boundingBox)?this._usePlanarModels.set(t,i):this._usePlanarModels.has(t)&&this._usePlanarModels.get(t)===i&&(this._usePlanarModels.delete(t),this._updatePlanarMapOfModel(t,null,null)))}for(var n=0;n<this._probes.length;n++)this._probes[n].probeType===eR.PLANAR&&(this._probes[n].realtimePlanarTexture?this.updatePlanarMap(this._probes[n],this._probes[n].realtimePlanarTexture.getGFXTexture()):this.updatePlanarMap(this._probes[n],null))}},e.selectReflectionProbe=function(t){if(t.node&&t.worldBounds&&t.node.layer&f$){t.updateWorldBound();var e=this._getNearestProbe(t);e?this._useCubeModels.has(t)?(this._useCubeModels.get(t)!==e&&this._useCubeModels.set(t,e),e.needRefresh=!0):(this._useCubeModels.set(t,e),e.needRefresh=!0):(this._updateCubemapOfModel(t,null),this._useCubeModels.delete(t))}for(var i=0;i<this._probes.length;i++)(this._probes[i].needRefresh&&this._probes[i].probeType===eR.CUBE||this._isUsedBlending(t))&&this.updateBakedCubemap(this._probes[i])},e.updatePreviewSphere=function(t){if(t&&t.previewSphere){var e=t.previewSphere.getComponent(VY);e&&(e.updateProbeCubemap(t.cubemap),e.updateReflectionProbeId(t.getProbeId()))}},e.updatePreviewPlane=function(t){t&&t.previewPlane&&t.previewPlane.getComponent(VY)&&t.realtimePlanarTexture&&this.updatePlanarMap(t,t.realtimePlanarTexture.getGFXTexture())},e.updateProbeData=function(){if(0!==this._probes.length){var t=this.getMaxProbeId(),e=t+1;this._dataTexture&&this._dataTexture.destroy();for(var i=new Float32Array(12*e),n=0,r=0;r<=t;r++){var s=this.getProbeById(r);if(s){if(s.probeType===eR.CUBE){i[n]=s.node.worldPosition.x,i[n+1]=s.node.worldPosition.y,i[n+2]=s.node.worldPosition.z,i[n+3]=0,i[n+4]=s.size.x,i[n+5]=s.size.y,i[n+6]=s.size.z,i[n+7]=0;var o=s.isRGBE()?1e3:0;i[n+8]=s.cubemap?s.cubemap.mipmapLevel+o:1+o}else i[n]=s.node.up.x,i[n+1]=s.node.up.y,i[n+2]=s.node.up.z,i[n+3]=1,i[n+4]=1,i[n+5]=1,i[n+6]=0,i[n+7]=0,i[n+8]=1;n+=12}else n+=12}var a=new Uint8Array(i.buffer),h=new Rf({_data:a,_compressed:!1,width:12,height:e,format:af.RGBA8888});this._dataTexture=new Zp,this._dataTexture.setFilters(Zp.Filter.NONE,Zp.Filter.NONE),this._dataTexture.setMipFilter(Zp.Filter.NONE),this._dataTexture.setWrapMode(Zp.WrapMode.CLAMP_TO_EDGE,Zp.WrapMode.CLAMP_TO_EDGE,Zp.WrapMode.CLAMP_TO_EDGE),this._dataTexture.image=h,this._dataTexture.uploadData(a);for(var u=0;u<this._probes.length;u++)for(var l=this._probes[u],c=this._getModelsByProbe(l),_=0;_<c.length;_++){var d=c[_].node.getComponent(VY);d&&d.updateReflectionProbeDataMap(this._dataTexture)}}},e.getMaxProbeId=function(){return 0===this._probes.length?-1:1===this._probes.length?this._probes[0].getProbeId():(this._probes.sort((function(t,e){return t.getProbeId()-e.getProbeId()})),this._probes[this._probes.length-1].getProbeId())},e.getUsedReflectionProbe=function(t,e){if(e){if(this._usePlanarModels.has(t))return this._usePlanarModels.get(t)}else if(this._useCubeModels.has(t))return this._useCubeModels.get(t);return null},e.setReflectionProbe=function(t,e,i){void 0===i&&(i=null),e&&(this._useCubeModels.set(t,e),this._updateCubemapOfModel(t,e),i&&this._updateBlendProbeInfo(t,e,i))},e.updateProbeOfModels=function(){if(0!==this._probes.length){var t=v.director.getScene();if(t&&t.renderScene)for(var e=t.renderScene.models,i=0;i<e.length;i++){var n=e[i];n.node&&n.node.layer&f$&&(n.reflectionProbeType===uM.BAKED_CUBEMAP||n.reflectionProbeType===uM.PLANAR_REFLECTION||this._isUsedBlending(n))&&n.updateReflectionProbeId()}}},e._getNearestProbe=function(t){if(!t.node||!t.worldBounds||0===this._probes.length)return null;for(var e,i=null,n=1/0,r=d(this._probes);!(e=r()).done;){var s=e.value;if(s.probeType===eR.CUBE&&s.validate()&&as.aabbWithAABB(t.worldBounds,s.boundingBox)){var o=on.distance(t.node.worldPosition,s.node.worldPosition);o<n&&(n=o,i=s)}}return i},e._getBlendProbe=function(t){if(!t||!t.node||!t.worldBounds||this._probes.length<2)return null;for(var e=[],i=0;i<this._probes.length;i++)this._probes[i].probeType===eR.CUBE&&this._probes[i].validate()&&as.aabbWithAABB(t.worldBounds,this._probes[i].boundingBox)&&e.push(this._probes[i]);return e.sort((function(e,i){return on.distance(t.node.worldPosition,e.node.worldPosition)-on.distance(t.node.worldPosition,i.node.worldPosition)})),e.length>1?e[1]:null},e._getModelsByProbe=function(t){var e=[],i=this._useCubeModels;t.probeType===eR.PLANAR&&(i=this._usePlanarModels);for(var n,r=d(i.entries());!(n=r()).done;){var s=n.value;s[1]===t&&e.push(s[0])}return e},e._removeDependentModels=function(t){for(var e,i=d(this._useCubeModels.keys());!(e=i()).done;){var n=e.value,r=this._useCubeModels.get(n);void 0!==r&&r===t&&(this._useCubeModels.delete(n),this.selectReflectionProbe(n))}for(var s,o=d(this._usePlanarModels.keys());!(s=o()).done;){var a=s.value,h=this._usePlanarModels.get(a);void 0!==h&&h===t&&(this._usePlanarModels.delete(a),this.selectPlanarReflectionProbe(a))}},e._updateCubemapOfModel=function(t,e){var i=t.node;if(i){var n=i.getComponent(VY);if(n&&(n.updateProbeCubemap(e?e.cubemap:null),n.updateReflectionProbeId(e&&e.cubemap?e.getProbeId():-1),e&&(n.updateReflectionProbeDataMap(this._dataTexture),this._isUsedBlending(t)))){var r=this._getBlendProbe(t);this._updateBlendProbeInfo(t,e,r)}}},e._updatePlanarMapOfModel=function(t,e,i){var n=t.node.getComponent(VY);n&&(n.updateProbePlanarMap(e),i?(n.updateReflectionProbeId(i.getProbeId()),n.updateReflectionProbeDataMap(this._dataTexture)):n.updateReflectionProbeId(-1))},e._isUsedBlending=function(t){return t.reflectionProbeType===uM.BLEND_PROBES||t.reflectionProbeType===uM.BLEND_PROBES_AND_SKYBOX},e._updateBlendProbeInfo=function(t,e,i){var n=t.node;if(n){var r=n.getComponent(VY);r&&(i?(r.updateReflectionProbeBlendId(i.getProbeId()),r.updateProbeBlendCubemap(i.cubemap),r.updateReflectionProbeBlendWeight(this._calculateBlendWeight(t,e,i))):(r.updateReflectionProbeBlendId(-1),t.reflectionProbeType===uM.BLEND_PROBES_AND_SKYBOX&&r.updateReflectionProbeBlendWeight(this._calculateBlendWeight(t,e,i))))}},e._updateBlendCubemap=function(t,e){var i=t.node;if(i&&this._isUsedBlending(t)){var n=i.getComponent(VY);n&&n.updateProbeBlendCubemap(e.cubemap)}},e._calculateBlendWeight=function(t,e,i){if(i){var n=on.distance(t.node.worldPosition,e.node.worldPosition),r=on.distance(t.node.worldPosition,i.node.worldPosition);return 1-r/(n+r)}return t.reflectionProbeType===uM.BLEND_PROBES?0:t.reflectionProbeType===uM.BLEND_PROBES_AND_SKYBOX?this._calculateBlendOfSkybox(t.worldBounds,e.boundingBox):0},e._calculateBlendOfSkybox=function(t,e){if(!t)return 1;var i=new on,n=new on,r=new on,s=new on;if(on.subtract(i,t.center,t.halfExtents),on.add(n,t.center,t.halfExtents),on.subtract(r,e.center,e.halfExtents),on.add(s,e.center,e.halfExtents),i.x<=s.x&&n.x>=r.x&&i.y<=s.y&&n.y>=r.y&&i.z<=s.z&&n.z>=r.z){var o=new on;on.multiplyScalar(o,t.halfExtents,2);var a=i.x+o.x<=s.x&&n.x+o.x>=r.x,h=i.x-o.x<=s.x&&n.x-o.x>=r.x,u=i.y+o.y<=s.y&&n.y+o.y>=r.y,l=i.y-o.y<=s.y&&n.y-o.y>=r.y,c=i.z+o.z<=s.z&&n.z+o.z>=r.z,_=i.z-o.z<=s.z&&n.z-o.z>=r.z,d=[];if(!a){var f=n.x-s.x;d.push(f/o.x)}if(!h){var p=Math.abs(i.x-r.x);d.push(p/o.x)}if(!u){var m=n.y-s.y;d.push(m/o.y)}if(!l){var g=Math.abs(i.y-r.y);d.push(g/o.y)}if(!c){var y=n.z-s.z;d.push(y/o.z)}if(!_){var v=Math.abs(i.z-r.z);d.push(v/o.z)}return d.length>0?(d.sort((function(t,e){return e-t})),d[0]):0}return 1},n(t,[{key:"updateForRuntime",get:function(){return this._updateForRuntime},set:function(t){this._updateForRuntime=t}}]),t}());function m$(t){return void 0===(t=t||{}).includeNormal&&(t.includeNormal=!0),void 0===t.includeUV&&(t.includeUV=!0),t}p$.probeManager=void 0,p$.probeManager=new p$,v.internal.reflectionProbeManager=p$.probeManager;var g$=new on,y$=new on,v$=new on,S$=new on,T$=new on,A$=new on,b$=new on,E$=new on,C$=new on,w$=new on,x$=new on,R$=new on,I$=new on(0,0,0),B$=new on(0,0,0);function D$(t,e,i,n){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=2),void 0===n&&(n={});var r=.5*i,s=n.radialSegments||32,o=n.heightSegments||1,a=void 0===n.capped||n.capped,h=n.arc||2*Math.PI,u=0;a||(t>0&&u++,e>0&&u++);var l=(s+1)*(o+1);a&&(l+=(s+1)*u+s*u);var c=s*o*6;a&&(c+=s*u*3);var _=new Array(c),d=new Array(3*l),f=new Array(3*l),p=new Array(2*l),m=Math.max(t,e),g=new on(-m,-r,-m),y=new on(m,r,m),v=Math.sqrt(m*m+r*r),S=0,T=0;return function(){for(var n=[],a=t-e,u=a*a/i*Math.sign(a),l=0;l<=o;l++){for(var c=[],m=l/o,g=m*a+e,y=0;y<=s;++y){var v=y/s,A=v*h,b=Math.sin(A),E=Math.cos(A);d[3*S]=g*b,d[3*S+1]=m*i-r,d[3*S+2]=g*E,on.normalize(I$,on.set(B$,b,-u,E)),f[3*S]=I$.x,f[3*S+1]=I$.y,f[3*S+2]=I$.z,p[2*S]=2*(1-v)%1,p[2*S+1]=m,c.push(S),++S}n.push(c)}for(var C=0;C<o;++C)for(var w=0;w<s;++w){var x=n[C][w],R=n[C+1][w],I=n[C+1][w+1],B=n[C][w+1];_[T]=x,++T,_[T]=B,++T,_[T]=R,++T,_[T]=B,++T,_[T]=I,++T,_[T]=R,++T}}(),a&&(e>0&&A(!1),t>0&&A(!0)),{positions:d,normals:f,uvs:p,indices:_,minPos:g,maxPos:y,boundingRadius:v};function A(i){for(var n=i?t:e,o=i?1:-1,a=S,u=1;u<=s;++u)d[3*S]=0,d[3*S+1]=r*o,d[3*S+2]=0,f[3*S]=0,f[3*S+1]=o,f[3*S+2]=0,p[2*S]=.5,p[2*S+1]=.5,++S;for(var l=S,c=0;c<=s;++c){var m=c/s*h,g=Math.cos(m),y=Math.sin(m);d[3*S]=n*y,d[3*S+1]=r*o,d[3*S+2]=n*g,f[3*S]=0,f[3*S+1]=o,f[3*S+2]=0,p[2*S]=.5-.5*y*o,p[2*S+1]=.5+.5*g,++S}for(var v=0;v<s;++v){var A=a+v,b=l+v;i?(_[T]=b+1,++T,_[T]=A,++T,_[T]=b,++T):(_[T]=A,++T,_[T]=b+1,++T,_[T]=b,++T)}}}var P$=new on(0,0,0),O$=new on(0,0,0),M$=new on(0,0,0),L$=new on(0,0,0),N$=new on(0,0,0),F$=new on(0,0,0),k$=new on(0,0,0),V$=new on(0,0,0),G$=new on(0,0,0),U$=Object.freeze({__proto__:null,box:function(t){var e=(t=t||{}).widthSegments||1,i=t.heightSegments||1,n=t.lengthSegments||1,r=(t.width||1)/2,s=(t.height||1)/2,o=(t.length||1)/2,a=[on.set(T$,-r,-s,o),on.set(A$,r,-s,o),on.set(b$,r,s,o),on.set(E$,-r,s,o),on.set(C$,r,-s,-o),on.set(w$,-r,-s,-o),on.set(x$,-r,s,-o),on.set(R$,r,s,-o)],h=[[2,3,1],[4,5,7],[7,6,2],[1,0,4],[1,4,2],[5,0,6]],u=[[0,0,1],[0,0,-1],[0,1,0],[0,-1,0],[1,0,0],[-1,0,0]],l=[[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[0,0,-1,1],[0,0,1,1]],c=[],_=[],d=[],f=[],p=[],m=new on(-r,-s,-o),g=new on(r,s,o),y=Math.sqrt(r*r+s*s+o*o);function v(t,e,i){var n,r,s,o,m=c.length/3,g=h[t],y=u[t],v=l[t];for(o=0;o<=i;o++)for(s=0;s<=e;s++)if(n=s/e,r=o/i,on.lerp(g$,a[g[0]],a[g[1]],n),on.lerp(y$,a[g[0]],a[g[2]],r),on.subtract(v$,y$,a[g[0]]),on.add(S$,g$,v$),c.push(S$.x,S$.y,S$.z),_.push(y[0],y[1],y[2]),d.push(n,r),f.push(v[0],v[1],v[2],v[3]),s<e&&o<i){var S=e+1,T=s+o*S,A=s+(o+1)*S,b=s+1+(o+1)*S,E=s+1+o*S;p.push(m+T,m+E,m+A),p.push(m+A,m+E,m+b)}}return v(0,e,i),v(4,n,i),v(1,e,i),v(5,n,i),v(3,e,n),v(2,e,n),{positions:c,normals:_,uvs:d,tangents:f,indices:p,minPos:m,maxPos:g,boundingRadius:y}},cone:function(t,e,i){return void 0===t&&(t=.5),void 0===e&&(e=1),void 0===i&&(i={}),D$(0,t,e,i)},cylinder:D$,plane:function(t){var e=function(t){return(t=m$(t)).width=t.width||10,t.length=t.length||10,t.widthSegments=t.widthSegments||10,t.lengthSegments=t.lengthSegments||10,t}(t),i=e.width,n=e.length,r=e.widthSegments,s=e.lengthSegments,o=.5*i,a=.5*n,h=[],u=[],l=[],c=new on(-o,0,-a),_=new on(o,0,a),d=Math.sqrt(i*i+n*n);on.set(N$,-o,0,a),on.set(F$,o,0,a),on.set(k$,-o,0,-a);for(var f=0;f<=s;f++)for(var p=0;p<=r;p++){var m=p/r,g=f/s;if(on.lerp(P$,N$,F$,m),on.lerp(O$,N$,k$,g),on.subtract(M$,O$,N$),on.add(L$,P$,M$),h.push(L$.x,L$.y,L$.z),e.includeUV&&u.push(m,g),p<r&&f<s){var y=r+1,v=p+f*y,S=p+(f+1)*y,T=p+1+(f+1)*y,A=p+1+f*y;l.push(v,A,S),l.push(A,T,S)}}var b={positions:h,indices:l,minPos:c,maxPos:_,boundingRadius:d};if(e.includeNormal){var E=(s+1)*(r+1),C=new Array(3*E);b.normals=C;for(var w=0;w<E;++w)C[3*w+0]=0,C[3*w+1]=1,C[3*w+2]=0}return e.includeUV&&(b.uvs=u),b},quad:function(t){var e=m$(t),i={positions:[-.5,-.5,0,-.5,.5,0,.5,.5,0,.5,-.5,0],indices:[0,3,1,3,2,1],minPos:{x:-.5,y:-.5,z:0},maxPos:{x:.5,y:.5,z:0},boundingRadius:Math.sqrt(.5)};return!1!==e.includeNormal&&(i.normals=[0,0,1,0,0,1,0,0,1,0,0,1]),!1!==e.includeUV&&(i.uvs=[0,0,0,1,1,1,1,0]),i},sphere:function(t,e){void 0===t&&(t=.5),void 0===e&&(e={});for(var i=void 0!==e.segments?e.segments:32,n=[],r=[],s=[],o=[],a=new on(-t,-t,-t),h=new on(t,t,t),u=t,l=0;l<=i;++l)for(var c=l*Math.PI/i,_=Math.sin(c),d=-Math.cos(c),f=0;f<=i;++f){var p=2*f*Math.PI/i-Math.PI/2,m=Math.sin(p)*_,g=d,y=Math.cos(p)*_,v=f/i,S=l/i;if(n.push(m*t,g*t,y*t),r.push(m,g,y),s.push(v,S),l<i&&f<i){var T=i+1,A=T*l+f,b=T*(l+1)+f,E=T*(l+1)+f+1,C=T*l+f+1;o.push(A,C,b),o.push(C,E,b)}}return{positions:n,indices:o,normals:r,uvs:s,minPos:a,maxPos:h,boundingRadius:u}},torus:function(t,e,i){void 0===t&&(t=.4),void 0===e&&(e=.1),void 0===i&&(i={});for(var n=i.radialSegments||32,r=i.tubularSegments||32,s=i.arc||2*Math.PI,o=[],a=[],h=[],u=[],l=new on(-t-e,-e,-t-e),c=new on(t+e,e,t+e),_=t+e,d=0;d<=n;d++)for(var f=0;f<=r;f++){var p=f/r,m=d/n,g=p*s,y=m*Math.PI*2,v=(t+e*Math.cos(y))*Math.sin(g),S=e*Math.sin(y),T=(t+e*Math.cos(y))*Math.cos(g),A=Math.sin(g)*Math.cos(y),b=Math.sin(y),E=Math.cos(g)*Math.cos(y);if(o.push(v,S,T),a.push(A,b,E),h.push(p,m),f<r&&d<n){var C=r+1,w=C*d+f,x=C*(d+1)+f,R=C*(d+1)+f+1,I=C*d+f+1;u.push(w,I,x),u.push(I,R,x)}}return{positions:o,normals:a,uvs:h,indices:u,minPos:l,maxPos:c,boundingRadius:_}},capsule:function(t,e,i,n){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=2),void 0===n&&(n={});var r=i-t-e,s=n.sides||32,o=n.heightSegments||32,a=e/i,h=r/i,u=t/i,l=Math.floor(o*a),c=Math.floor(o*u),_=Math.floor(o*h),d=r+e-i/2,f=e-i/2,p=e-i/2,m=n.arc||2*Math.PI,g=[],y=[],v=[],S=[],T=Math.max(t,e),A=new on(-T,-i/2,-T),b=new on(T,i/2,T),E=i/2,C=0,w=[];return function(){for(var t=0;t<=l;++t)for(var i=t*Math.PI/l/2,n=Math.sin(i),r=-Math.cos(i),a=0;a<=s;++a){var h=2*a*Math.PI/s-Math.PI/2,u=Math.sin(h)*n,c=r,_=Math.cos(h)*n,d=a/s,f=t/o;if(g.push(u*e,c*e+p,_*e),y.push(u,c,_),v.push(d,f),t<l&&a<s){var m=s+1,T=m*t+a,A=m*(t+1)+a,b=m*(t+1)+a+1,E=m*t+a+1;S.push(T,E,A),S.push(E,b,A)}++C}}(),function(){for(var i=(t-e)/r,n=0;n<=_;n++){for(var o=[],u=n/_,l=u*(t-e)+e,c=0;c<=s;++c){var d=c/s,p=u*h+a,T=d*m-m/4,A=Math.sin(T),b=Math.cos(T);g.push(l*A),g.push(u*r+f),g.push(l*b),on.normalize(V$,on.set(G$,A,-i,b)),y.push(V$.x),y.push(V$.y),y.push(V$.z),v.push(d,p),o.push(C),++C}w.push(o)}for(var E=0;E<_;++E)for(var x=0;x<s;++x){var R=w[E][x],I=w[E+1][x],B=w[E+1][x+1],D=w[E][x+1];S.push(R),S.push(D),S.push(I),S.push(D),S.push(B),S.push(I)}}(),function(){for(var e=0;e<=c;++e)for(var i=e*Math.PI/c/2+Math.PI/2,n=Math.sin(i),r=-Math.cos(i),a=0;a<=s;++a){var h=2*a*Math.PI/s-Math.PI/2,l=Math.sin(h)*n,f=r,p=Math.cos(h)*n,m=a/s,T=e/o+(1-u);if(g.push(l*t,f*t+d,p*t),y.push(l,f,p),v.push(m,T),e<c&&a<s){var A=s+1,b=A*e+a+w[_][s]+1,E=A*(e+1)+a+w[_][s]+1,C=A*(e+1)+a+1+w[_][s]+1,x=A*e+a+1+w[_][s]+1;S.push(b,x,E),S.push(x,C,E)}}}(),{positions:g,normals:y,uvs:v,indices:S,minPos:A,maxPos:b,boundingRadius:E}},circle:function(t){var e=function(t){return(t=m$(t)).segments=64,t}(t).segments,i=new Array(3*(e+1));i[0]=0,i[1]=0,i[2]=0;var n=new Array(1+2*e);n[0]=0;for(var r=2*Math.PI/e,s=0;s<e;++s){var o=r*s,a=Math.cos(o),h=Math.sin(o),u=3*(s+1);i[u+0]=a,i[u+1]=h,i[u+2]=0;var l=2*s;n[1+l]=s+1,n[1+(l+1)]=s+2}return e>0&&(n[n.length-1]=1),{positions:i,indices:n,minPos:{x:1,y:1,z:0},maxPos:{x:-1,y:-1,z:0},boundingRadius:1,primitiveMode:pc.TRIANGLE_FAN}},translate:function(t,e){for(var i=e.x||0,n=e.y||0,r=e.z||0,s=Math.floor(t.positions.length/3),o=0;o<s;++o){var a=3*o,h=3*o+1,u=3*o+2;t.positions[a]+=i,t.positions[h]+=n,t.positions[u]+=r}return t.minPos&&(t.minPos.x+=i,t.minPos.y+=n,t.minPos.z+=r),t.maxPos&&(t.maxPos.x+=i,t.maxPos.y+=n,t.maxPos.z+=r),t},scale:function(t,e){for(var i,n,r,s=null!==(i=e.x)&&void 0!==i?i:1,o=null!==(n=e.y)&&void 0!==n?n:1,a=null!==(r=e.z)&&void 0!==r?r:1,h=Math.floor(t.positions.length/3),u=0;u<h;++u){var l=3*u,c=3*u+1,_=3*u+2;t.positions[l]*=s,t.positions[c]*=o,t.positions[_]*=a}var d=t.minPos,f=t.maxPos;if(d&&(d.x*=s,d.y*=o,d.z*=a),f&&(f.x*=s,f.y*=o,f.z*=a),d&&f){if(s<0){var p=d.x;d.x=f.x,f.x=p}if(o<0){var m=d.y;d.y=f.y,f.y=m}if(a<0){var g=d.z;d.z=f.z,f.z=g}}return void 0!==t.boundingRadius&&(t.boundingRadius*=Math.max(Math.max(Math.abs(s),Math.abs(o)),Math.abs(a))),t},wireframed:function(t){var e=t.indices;if(!e)return t;if(t.primitiveMode&&t.primitiveMode!==pc.TRIANGLE_LIST)return t;for(var i=[[0,1],[1,2],[2,0]],n=[],r={},s=0;s<e.length;s+=3)for(var o=0;o<3;++o){var a=e[s+i[o][0]],h=e[s+i[o][1]],u=a>h?h<<16|a:a<<16|h;void 0===r[u]&&(r[u]=0,n.push(a,h))}return t.indices=n,t.primitiveMode=pc.LINE_LIST,t},wireframe:function(t){for(var e=[[0,1],[1,2],[2,0]],i=[],n={},r=0;r<t.length;r+=3)for(var s=0;s<3;++s){var o=t[r+e[s][0]],a=t[r+e[s][1]],h=o>a?a<<16|o:o<<16|a;void 0===n[h]&&(n[h]=0,i.push(o,a))}return i},invWinding:function(t){for(var e=[],i=0;i<t.length;i+=3)e.push(t[i],t[i+2],t[i+1]);return e},toWavefrontOBJ:function(t,e){if(void 0===e&&(e=1),!t.indices||!t.uvs||!t.normals||void 0!==t.primitiveMode&&t.primitiveMode!==pc.TRIANGLE_LIST)return"";for(var i=t.positions,n=t.uvs,r=t.normals,s=t.indices,o=function(t){return s[t]+1+"/"+(s[t]+1)+"/"+(s[t]+1)},a="",h=0;h<i.length;h+=3)a+="v "+i[h]*e+" "+i[h+1]*e+" "+i[h+2]*e+"\n";for(var u=0;u<n.length;u+=2)a+="vt "+n[u]+" "+n[u+1]+"\n";for(var l=0;l<r.length;l+=3)a+="vn "+r[l]+" "+r[l+1]+" "+r[l+2]+"\n";for(var c=0;c<s.length;c+=3)a+="f "+o(c)+" "+o(c+1)+" "+o(c+2)+"\n";return a},normals:function(t,e,i){void 0===i&&(i=1);for(var n=new Array(2*t.length),r=0;r<t.length/3;++r){var s=3*r,o=6*r;n[o+0]=t[s+0],n[o+1]=t[s+1],n[o+2]=t[s+2],n[o+3]=t[s+0]+e[s+0]*i,n[o+4]=t[s+1]+e[s+1]*i,n[o+5]=t[s+2]+e[s+2]*i}return n},applyDefaultGeometryOptions:m$});t("fN",U$);var z$=new on;function H$(t){return t.x=Math.abs(t.x),t.y=Math.abs(t.y),t.z=Math.abs(t.z),t}var W$,j$,X$,q$,Y$,K$,J$,Q$,Z$,$$,t0,e0,i0,n0,r0,s0,o0,a0,h0,u0,l0,c0,_0,d0,f0=Object.freeze({__proto__:null,setWrap:function(t,e){t.__cc_wrapper__=e},getWrap:function(t){return t.__cc_wrapper__},maxComponent:function(t){return Math.max(t.x,Math.max(t.y,t.z))},VEC3_0:z$,TriggerEventObject:{type:"onTriggerEnter",selfCollider:null,otherCollider:null,impl:null},CharacterTriggerEventObject:{type:"onControllerTriggerEnter",collider:null,characterController:null,impl:null},CollisionEventObject:{type:"onCollisionEnter",selfCollider:null,otherCollider:null,contacts:[],impl:null},shrinkPositions:function(t){var e=[],i={};if(t.length>=3){e[0]=t[0],e[1]=t[1],e[2]=t[2];for(var n=t.length,r=3;r<n;r+=3){var s=t[r],o=t[r+1],a=t[r+2],h=String(s)+String(o)+String(a),u=Dl(h,666);i[u]!==h&&(i[u]=h,e.push(s),e.push(o),e.push(a))}}return e},absolute:H$,cylinder:D$});!function(t){t[t.Low_256x256=256]="Low_256x256",t[t.Medium_512x512=512]="Medium_512x512",t[t.High_768x768=768]="High_768x768"}(d0||(d0={})),t("ak",(W$=qs("cc.ReflectionProbe"),j$=xo(on),X$=xo(ge(eR)),q$=xo(ge(d0)),Y$=xo(ge(tR)),K$=xo(dn),J$=xo(im.BitMask),Q$=xo(gH),Z$=xo(Ke),$$=xo(Qm),W$(((_0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._lastSize=new on,e._resolution=i0&&i0(),e._clearFlag=n0&&n0(),e._backgroundColor=r0&&r0(),e._visibility=s0&&s0(),e._probeType=o0&&o0(),e._cubemap=a0&&a0(),e._size=h0&&h0(),e._sourceCamera=u0&&u0(),e._probeId=l0&&l0(),e._fastBake=c0&&c0(),e._probe=null,e._previewSphere=null,e._previewPlane=null,e._sourceCameraPos=new on(0,0,0),e._position=new on(0,0,0),e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._createProbe()},i.onEnable=function(){if(this._probe){var t=p$.probeManager.getProbeById(this._probeId);null!==t&&t!==this._probe&&(this._probeId=p$.probeManager.getNewReflectionProbeId(),this._probe.updateProbeId(this._probeId)),p$.probeManager.register(this._probe),p$.probeManager.onUpdateProbes(),this._probe.enable()}},i.onDisable=function(){this._probe&&(p$.probeManager.unregister(this._probe),this._probe.disable())},i.start=function(){this._sourceCamera&&this.probeType===eR.PLANAR&&(this.probe.renderPlanarReflection(this.sourceCamera.camera),p$.probeManager.filterModelsForPlanarReflection()),p$.probeManager.updateProbeData(),this._position=this.node.getWorldPosition().clone()},i.onDestroy=function(){this.probe&&this.probe.destroy()},i.update=function(){if(this.probe){this.probeType===eR.PLANAR&&this.sourceCamera&&(this.sourceCamera.node.hasChangedFlags&rm.TRS||!this._sourceCameraPos.equals(this.sourceCamera.node.getWorldPosition()))&&(this._sourceCameraPos=this.sourceCamera.node.getWorldPosition(),this.probe.renderPlanarReflection(this.sourceCamera.camera)),this.node.hasChangedFlags&rm.POSITION&&(this.probe.updateBoundingBox(),p$.probeManager.onUpdateProbes(),p$.probeManager.updateProbeData());var t=this.node.getWorldPosition();this._position.equals(t)||(this._position=t,this.probe.updateBoundingBox(),p$.probeManager.updateProbeData(),p$.probeManager.updateProbeOfModels())}},i.clearBakedCubemap=function(){this.cubemap=null,p$.probeManager.updateBakedCubemap(this.probe),p$.probeManager.updatePreviewSphere(this.probe)},i._createProbe=function(){if((-1===this._probeId||p$.probeManager.exists(this._probeId))&&(this._probeId=p$.probeManager.getNewReflectionProbeId()),this._probe=new aR(this._probeId),this._probe){var t=new Jm("ReflectionProbeCamera");t.hideFlags|=Ho.Flags.DontSave|Ho.Flags.HideInHierarchy,this.node.scene.addChild(t),this._probe.initialize(this.node,t),this.enabled&&p$.probeManager.register(this._probe),this._probe.resolution=this._resolution,this._probe.clearFlag=this._clearFlag,this._probe.backgroundColor=this._backgroundColor,this._probe.visibility=this._visibility,this._probe.probeType=this._probeType,this._probe.size=this._size,this._probe.cubemap=this._cubemap}},n(e,[{key:"size",get:function(){return this._size},set:function(t){this._size.set(t),H$(this._size),this.probe.size=this._size,this.probe&&(this.probe.updateBoundingBox(),p$.probeManager.onUpdateProbes(),p$.probeManager.updateProbeData(),p$.probeManager.updateProbeOfModels())}},{key:"probeType",get:function(){return this._probeType},set:function(t){if(this.probe.probeType=t,t!==this._probeType){var i=this._size.clone(),n=on.equals(this._lastSize,on.ZERO);this._probeType=t,this._probeType===eR.CUBE?(n&&this._size.set(e.DEFAULT_CUBE_SIZE),this.probe.switchProbeType(t,null),p$.probeManager.clearPlanarReflectionMap(this.probe)):(n&&this._size.set(e.DEFAULT_PLANER_SIZE),this._sourceCamera?this.probe.switchProbeType(t,this._sourceCamera.camera):k("the reflection camera is invalid, please set the reflection camera")),n||this._size.set(this._lastSize),this._lastSize.set(i),this.size=this._size}}},{key:"resolution",get:function(){return this._resolution},set:function(t){this._resolution=t,this.probe.resolution=t}},{key:"clearFlag",get:function(){return this._clearFlag},set:function(t){this._clearFlag=t,this.probe.clearFlag=this._clearFlag}},{key:"backgroundColor",get:function(){return this._backgroundColor},set:function(t){this._backgroundColor=t,this.probe.backgroundColor=this._backgroundColor}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t,this.probe.visibility=this._visibility}},{key:"sourceCamera",get:function(){return this._sourceCamera},set:function(t){this._sourceCamera=t,t&&(this.visibility=t.visibility,this.clearFlag=t.clearFlags,this.backgroundColor=t.clearColor,this.probeType===eR.PLANAR&&this.probe.switchProbeType(this.probeType,t.camera))}},{key:"fastBake",get:function(){return this._fastBake},set:function(t){this._fastBake=t}},{key:"cubemap",get:function(){return this._cubemap},set:function(t){this._cubemap=t,this.probe.cubemap=t,p$.probeManager.onUpdateProbes()}},{key:"probe",get:function(){return this._probe}},{key:"previewSphere",get:function(){return this._previewSphere},set:function(t){this._previewSphere=t,this.probe&&(this.probe.previewSphere=t,this._previewSphere&&p$.probeManager.updatePreviewSphere(this.probe))}},{key:"previewPlane",get:function(){return this._previewPlane},set:function(t){this._previewPlane=t,this.probe&&(this.probe.previewPlane=t,this._previewPlane&&p$.probeManager.updatePreviewPlane(this.probe))}}]),e}(rp)).DEFAULT_CUBE_SIZE=new on(1,1,1),_0.DEFAULT_PLANER_SIZE=new on(5,.5,5),i0=ks((e0=_0).prototype,"_resolution",[io],(function(){return 256})),n0=ks(e0.prototype,"_clearFlag",[io],(function(){return tR.SKYBOX})),r0=ks(e0.prototype,"_backgroundColor",[io],(function(){return new dn(0,0,0,255)})),s0=ks(e0.prototype,"_visibility",[io],(function(){return Ky})),o0=ks(e0.prototype,"_probeType",[io],(function(){return eR.CUBE})),a0=ks(e0.prototype,"_cubemap",[io],(function(){return null})),h0=ks(e0.prototype,"_size",[io],(function(){return new on(1,1,1)})),u0=ks(e0.prototype,"_sourceCamera",[io],(function(){return null})),l0=ks(e0.prototype,"_probeId",[io],(function(){return-1})),c0=ks(e0.prototype,"_fastBake",[io],(function(){return!1})),p(e0.prototype,"size",[j$],Object.getOwnPropertyDescriptor(e0.prototype,"size"),e0.prototype),p(e0.prototype,"probeType",[X$],Object.getOwnPropertyDescriptor(e0.prototype,"probeType"),e0.prototype),p(e0.prototype,"resolution",[q$],Object.getOwnPropertyDescriptor(e0.prototype,"resolution"),e0.prototype),p(e0.prototype,"clearFlag",[Y$],Object.getOwnPropertyDescriptor(e0.prototype,"clearFlag"),e0.prototype),p(e0.prototype,"backgroundColor",[K$],Object.getOwnPropertyDescriptor(e0.prototype,"backgroundColor"),e0.prototype),p(e0.prototype,"visibility",[J$],Object.getOwnPropertyDescriptor(e0.prototype,"visibility"),e0.prototype),p(e0.prototype,"sourceCamera",[Q$],Object.getOwnPropertyDescriptor(e0.prototype,"sourceCamera"),e0.prototype),p(e0.prototype,"fastBake",[Z$],Object.getOwnPropertyDescriptor(e0.prototype,"fastBake"),e0.prototype),p(e0.prototype,"cubemap",[$$],Object.getOwnPropertyDescriptor(e0.prototype,"cubemap"),e0.prototype),t0=e0))||t0)),v.utils=aF;var p0,m0,g0,y0,v0,S0=Symbol("CreateEval");qs("cc.animation.EmbeddedPlayer")((p0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).begin=m0&&m0(),e.end=g0&&g0(),e.reconciledSpeed=y0&&y0(),e.playable=v0&&v0(),e}return s(e,t),e}(Bo),m0=ks(p0.prototype,"begin",[io],(function(){return 0})),g0=ks(p0.prototype,"end",[io],(function(){return 0})),y0=ks(p0.prototype,"reconciledSpeed",[io],(function(){return!1})),v0=ks(p0.prototype,"playable",[io],(function(){return null})),p0));var T0,A0=function(){},b0=function(){function t(t){this._randomAccess=t}return t.prototype.setTime=function(){},n(t,[{key:"randomAccess",get:function(){return this._randomAccess}}]),t}(),E0=function(){function t(){this._isPlaying=!1,this._isPaused=!1,this._stepOnce=!1}var e=t.prototype;return e.play=function(){this._isPlaying?this._isPaused?(this._isPaused=!1,this.onResume()):this.onError(tt(3912)):(this._isPlaying=!0,this.onPlay())},e.stop=function(){this._isPlaying&&(this._isPlaying=!1,this.onStop(),this._isPaused=!1)},e.pause=function(){this._isPlaying&&!this._isPaused&&(this._isPaused=!0,this.onPause())},e.resume=function(){this._isPlaying&&this._isPaused&&(this._isPaused=!1,this.onResume())},e.step=function(){this.pause(),this._stepOnce=!0,this._isPlaying||this.play()},e.update=function(){},e.onPlay=function(){},e.onPause=function(){},e.onResume=function(){},e.onStop=function(){},e.onError=function(){},n(t,[{key:"isPlaying",get:function(){return this._isPlaying}},{key:"isPaused",get:function(){return this._isPaused}},{key:"isMotionless",get:function(){return!this.isPlaying||this.isPaused}}]),t}();!function(t){t[t.Default=su.Default]="Default",t[t.Normal=su.Normal]="Normal",t[t.Reverse=su.Reverse]="Reverse",t[t.Loop=su.Loop]="Loop",t[t.LoopReverse=su.Loop|su.Reverse]="LoopReverse",t[t.PingPong=su.PingPong]="PingPong",t[t.PingPongReverse=su.PingPong|su.Reverse]="PingPongReverse"}(T0||(T0={})),Se(T0);var C0,w0=function(){function t(t){this.ratio=0,this.time=0,this.direction=1,this.stopped=!0,this.iterations=0,this.frameIndex=void 0,t&&this.set(t)}return t.prototype.set=function(t){this.ratio=t.ratio,this.time=t.time,this.direction=t.direction,this.stopped=t.stopped,this.iterations=t.iterations,this.frameIndex=t.frameIndex},t}(),x0=function(){function t(t){this.weight=0,this._pose=void 0,this._blendStateWriters=[],this._pose=t}var e=t.prototype;return e.destroy=function(){for(var t=0;t<this._blendStateWriters.length;++t)this._pose.destroyWriter(this._blendStateWriters[t]);this._blendStateWriters.length=0},e.createPoseWriter=function(t,e,i){var n=this._pose.createWriter(t,e,this,i);return this._blendStateWriters.push(n),n},t}();function R0(){return v.director.getAnimationManager()}!function(t){t.PLAY="play",t.STOP="stop",t.PAUSE="pause",t.RESUME="resume",t.LASTFRAME="lastframe",t.FINISHED="finished"}(C0||(C0={})),Se(C0);var I0,B0,D0,P0=t("ap",function(t){function e(e,i){var n;return void 0===i&&(i=""),(n=t.call(this)||this).duration=1,n.time=0,n.frameRate=0,n._targetNode=null,n._curveLoaded=!1,n._clip=void 0,n._speed=1,n._useSimpleProcess=!1,n._target=null,n._wrapMode=T0.Normal,n._repeatCount=1,n._delay=0,n._delayTime=0,n._currentFramePlayed=!1,n._name=void 0,n._lastIterations=NaN,n._lastWrapInfo=null,n._wrappedInfo=new w0,n._allowLastFrame=!1,n._blendStateWriterHost={weight:0},n._playbackDuration=0,n._invDuration=1,n._poseOutput=null,n._weight=1,n._clipEval=void 0,n._clipEventEval=void 0,n._clipEmbeddedPlayerEval=void 0,n._doNotCreateEval=!1,n._clip=e,n._name=i||e&&e.name,n._playbackRange={min:0,max:e.duration},n._playbackDuration=e.duration,e.duration||U("Clip "+e.name+" has zero duration."),n}s(e,t);var i=e.prototype;return i.initialize=function(t,e,i){if(!this._curveLoaded){this._curveLoaded=!0,this._poseOutput&&(this._poseOutput.destroy(),this._poseOutput=null),this._clipEval&&(this._clipEval=void 0),this._clipEventEval&&(this._clipEventEval=void 0),this._clipEmbeddedPlayerEval&&(this._clipEmbeddedPlayerEval.destroy(),this._clipEmbeddedPlayerEval=void 0),this._targetNode=t;var n=this._clip;if(this.duration=n.duration,this._invDuration=1/this.duration,this._speed=n.speed,this.wrapMode=n.wrapMode,this.frameRate=n.sample,this._playbackRange.min=0,this._playbackRange.max=n.duration,this._playbackDuration=n.duration,(this.wrapMode&su.Loop)===su.Loop?this.repeatCount=1/0:this.repeatCount=1,!this._doNotCreateEval){var r,s,o,a=null!==(r=null!=e?e:null===(s=R0())||void 0===s?void 0:s.blendState)&&void 0!==r?r:null;a&&(this._poseOutput=new x0(a)),this._clipEval=n.createEvaluator({target:t,pose:null!==(o=this._poseOutput)&&void 0!==o?o:void 0,mask:i})}n.containsAnyEvent()&&(this._clipEventEval=n.createEventEvaluator(this._targetNode)),n.containsAnyEmbeddedPlayer()&&(this._clipEmbeddedPlayerEval=n.createEmbeddedPlayerEvaluator(this._targetNode),this._clipEmbeddedPlayerEval.notifyHostSpeedChanged(this._speed))}},i.destroy=function(){this.isMotionless||R0().removeAnimation(this),this._poseOutput&&(this._poseOutput.destroy(),this._poseOutput=null),this._clipEval=void 0},i.emit=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];R0().pushDelayEvent(this._emit,this,e)},i.on=function(t,e,i){return this._target&&this._target.isValid?this._target.on(t,e,i):null},i.once=function(t,e,i){return this._target&&this._target.isValid?this._target.once(t,e,i):null},i.off=function(t,e,i){this._target&&this._target.isValid&&this._target.off(t,e,i)},i.allowLastFrameEvent=function(t){this._allowLastFrame=t},i._setEventTarget=function(t){this._target=t},i.setTime=function(t){this._currentFramePlayed=!1,this.time=t||0;var e,i=this.getWrappedInfo(t,this._wrappedInfo);null===(e=this._clipEventEval)||void 0===e||e.ignore(i.ratio,i.direction)},i.update=function(t){this._delayTime>0&&(this._delayTime-=t,this._delayTime>0)||(this._currentFramePlayed?this.time+=t*this._speed:this._currentFramePlayed=!0,this._process())},i.sample=function(){var t=this.getWrappedInfo(this.time,this._wrappedInfo);return this._sampleCurves(t.time),this._sampleEvents(t),this._sampleEmbeddedPlayers(t),t},i.onPlay=function(){var t;this.setTime(this._getPlaybackStart()),this._delayTime=this._delay,this._onReplayOrResume(),this.emit(C0.PLAY,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onStop=function(){var t;this.isPaused||this._onPauseOrStop(),this.emit(C0.STOP,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostStop()},i.onResume=function(){var t;this._onReplayOrResume(),this.emit(C0.RESUME,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onPause=function(){var t;this._onPauseOrStop(),this.emit(C0.PAUSE,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPause(this.current)},i._sampleCurves=function(t){var e=this._poseOutput,i=this._clipEval;e&&(e.weight=this.weight),i&&i.evaluate(t)},i._process=function(){this._useSimpleProcess?this.simpleProcess():this.process()},i.process=function(){var t,e=this.sample();this._allowLastFrame&&(t=this._lastWrapInfo?this._lastWrapInfo:this._lastWrapInfo=new w0(e),this.repeatCount>1&&(0|e.iterations)>(0|t.iterations)&&this.emit(C0.LASTFRAME,this),t.set(e)),e.stopped&&(this.stop(),this.emit(C0.FINISHED,this))},i.simpleProcess=function(){var t=this._playbackRange.min,e=this._playbackDuration,i=0,n=0;if(0!==e&&((i=this.time%e)<0&&(i+=e),n=(t+i)*this._invDuration),this._sampleCurves(t+i),this._clipEventEval||this._clipEmbeddedPlayerEval){var r=this.getWrappedInfo(this.time,this._wrappedInfo);this._sampleEvents(r),this._sampleEmbeddedPlayers(r)}this._allowLastFrame&&(Number.isNaN(this._lastIterations)&&(this._lastIterations=n),(this.time>0&&this._lastIterations>n||this.time<0&&this._lastIterations<n)&&this.emit(C0.LASTFRAME,this),this._lastIterations=n)},i._needReverse=function(t){var e=this.wrapMode,i=!1;return(e&su.PingPong)===su.PingPong&&(t-(0|t)==0&&t>0&&(t-=1),1&t&&(i=!i)),(e&su.Reverse)===su.Reverse&&(i=!i),i},i.getWrappedInfo=function(t,e){e=e||new w0;var i=this._playbackRange.min,n=this._playbackDuration,r=this.repeatCount;if(0===n)return e.time=0,e.ratio=0,e.direction=1,e.stopped=!!Number.isFinite(r),e.iterations=0,e;var s=!1,o=(t-=i)>0?t/n:-t/n;if(o>=r){o=r,s=!0;var a=r-(0|r);0===a&&(a=1),t=a*n*(t>0?1:-1)}if(t>n){var h=t%n;t=0===h?n:h}else t<0&&0!=(t%=n)&&(t+=n);var u=!1,l=this._wrapMode&su.ShouldWrap;l&&(u=this._needReverse(o));var c=u?-1:1;return this.speed<0&&(c*=-1),l&&u&&(t=n-t),e.time=i+t,e.ratio=e.time/this.duration,e.direction=c,e.stopped=s,e.iterations=o,e},i._getPlaybackStart=function(){return this._playbackRange.min},i._sampleEvents=function(t){var e;null===(e=this._clipEventEval)||void 0===e||e.sample(t.ratio,t.direction,t.iterations)},i._sampleEmbeddedPlayers=function(t){var e;null===(e=this._clipEmbeddedPlayerEval)||void 0===e||e.evaluate(t.time,Math.trunc(t.iterations))},i._emit=function(t,e){this._target&&this._target.isValid&&this._target.emit(t,t,e)},i._onReplayOrResume=function(){R0().addAnimation(this)},i._onPauseOrStop=function(){R0().removeAnimation(this)},n(e,[{key:"clip",get:function(){return this._clip}},{key:"name",get:function(){return this._name}},{key:"length",get:function(){return this.duration}},{key:"wrapMode",get:function(){return this._wrapMode},set:function(t){var e;this._wrapMode=t,this.time=0,t&su.Loop?this.repeatCount=1/0:this.repeatCount=1,null===(e=this._clipEventEval)||void 0===e||e.setWrapMode(t)}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(t){this._repeatCount=t;var e=this._wrapMode&su.ShouldWrap,i=(this.wrapMode&su.Reverse)===su.Reverse;this._useSimpleProcess=t===1/0&&!e&&!i}},{key:"delay",get:function(){return this._delay},set:function(t){this._delayTime=this._delay=t}},{key:"playbackRange",get:function(){return this._playbackRange},set:function(t){t.max,t.min,this._playbackRange.min=Math.max(t.min,0),this._playbackRange.max=Math.min(t.max,this.duration),this._playbackDuration=this._playbackRange.max-this._playbackRange.min,this.setTime(0)}},{key:"speed",get:function(){return this._speed},set:function(t){var e;this._speed=t,null===(e=this._clipEmbeddedPlayerEval)||void 0===e||e.notifyHostSpeedChanged(t)}},{key:"current",get:function(){return this.getWrappedInfo(this.time).time}},{key:"ratio",get:function(){return 0===this.duration?0:this.current/this.duration}},{key:"weight",get:function(){return this._weight},set:function(t){this._weight=t,this._poseOutput&&(this._poseOutput.weight=t)}},{key:"curveLoaded",get:function(){return this._curveLoaded}}]),e}(E0));v.AnimationState=P0,qs("cc.animation.EmbeddedAnimationClipPlayable")((I0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).path=B0&&B0(),e.clip=D0&&D0(),e}return s(e,t),e.prototype.instantiate=function(t){var e=this.clip,i=this.path;if(!e)return null;var n=t.getChildByPath(i);if(!n)return J(3938,i,t.getPathInHierarchy(),e.name),null;var r=new P0(e);return r.initialize(n),new L0(r)},e}(A0),B0=ks(I0.prototype,"path",[io],(function(){return""})),D0=ks(I0.prototype,"clip",[io],(function(){return null})),I0));var O0,M0,L0=function(t){function e(e){var i;return(i=t.call(this,!0)||this)._animationState=void 0,i._animationState=e,i}s(e,t);var i=e.prototype;return i.destroy=function(){this._animationState.destroy()},i.play=function(){this._animationState.play()},i.pause=function(){this._animationState.pause()},i.stop=function(){this._animationState.stop()},i.setSpeed=function(t){this._animationState.speed=t},i.setTime=function(t){this._animationState.time=t},e}(b0);qs("cc.animation.EmbeddedParticleSystemPlayable")((O0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).path=M0&&M0(),e}return s(e,t),e.prototype.instantiate=function(t){var e=t.getChildByPath(this.path);if(!e)return k("Hierarchy path "+this.path+" does not exists."),null;var i=ee("cc.ParticleSystem");if(!i)return k("Particle system is required for embedded particle system player."),null;var n=e.getComponent(i);return n?new z0(n):(k(this.path+" does not includes a particle system component."),null)},e}(A0),M0=ks(O0.prototype,"path",[io],(function(){return""})),O0));var N0,F0,k0,V0,G0,U0,z0=function(t){function e(e){var i;return(i=t.call(this,!1)||this)._particleSystem=void 0,i._particleSystem=e,i}s(e,t);var i=e.prototype;return i.destroy=function(){},i.play=function(){this._particleSystem.play()},i.pause=function(){this._particleSystem.stopEmitting()},i.stop=function(){this._particleSystem.stopEmitting()},i.setSpeed=function(t){this._particleSystem.simulationSpeed=t},e}(b0);function H0(t){return"string"==typeof t||"number"==typeof t}var W0,j0,X0,q0,Y0,K0,J0,Q0,Z0,$0,t1,e1,i1,n1,r1,s1,o1,a1,h1,u1=qs("cc.animation.HierarchyPath")((F0=function(){function t(t){this.path=k0&&k0(),this.path=t||""}return t.prototype.get=function(t){return t instanceof Jm?t.getChildByPath(this.path)||(Y(3926,t.name,this.path),null):(Y(3925),null)},t}(),k0=ks(F0.prototype,"path",[io],(function(){return""})),N0=F0))||N0,l1=qs("cc.animation.ComponentPath")((G0=function(){function t(t){this.component=U0&&U0(),this.component=t||""}return t.prototype.get=function(t){return t instanceof Jm?t.getComponent(this.component)||(Y(3928,t.name,this.component),null):(Y(3927),null)},t}(),U0=ks(G0.prototype,"component",[io],(function(){return""})),V0=G0))||V0,c1=Symbol("NormalizedFollow"),_1=Symbol("ConvertAsTrsPath"),d1=Symbol("TrackBinding"),f1=qs("cc.animation.TrackPath")((j0=function(){function t(){this._paths=X0&&X0()}var e=t.prototype;return e.toProperty=function(t){return this._paths.push(t),this},e.toElement=function(t){return this._paths.push(t),this},e.toHierarchy=function(t){return this._paths.push(new u1(t)),this},e.toComponent=function(t){var e=new l1("string"==typeof t?t:Bt(t));return this._paths.push(e),this},e.toCustomized=function(t){return this._paths.push(t),this},e.append=function(){for(var t,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];var r=(t=this._paths).concat.apply(t,i.map((function(t){return t._paths})));return this._paths=r,this},e.isPropertyAt=function(t){return"string"==typeof this._paths[t]},e.parsePropertyAt=function(t){return this._paths[t]},e.isElementAt=function(t){return"number"==typeof this._paths[t]},e.parseElementAt=function(t){return this._paths[t]},e.isHierarchyAt=function(t){return this._paths[t]instanceof u1},e.parseHierarchyAt=function(t){return this.isHierarchyAt(t),this._paths[t].path},e.isComponentAt=function(t){return this._paths[t]instanceof l1},e.parseComponentAt=function(t){return this.isComponentAt(t),this._paths[t].component},e.slice=function(e,i){var n=new t;return n._paths=this._paths.slice(e,i),n},e.trace=function(t,e,i){var n,r;return null!==(n=e)&&void 0!==n||(e=0),null!==(r=i)&&void 0!==r||(i=this._paths.length),this[c1](t,e,i)},e[_1]=function(){for(var t,e=this._paths,i=e.length,n=0,r="";n<i;++n){var s=e[n];if(!(s instanceof u1))break;s.path&&(r?r+="/"+s.path:r=s.path)}if(n===i)return null;if(n!==i-1)return null;switch(e[n]){case"position":case"scale":case"rotation":case"eulerAngles":t=e[n];break;default:return null}return{node:r,property:t}},e[c1]=function(t,e,i){for(var n=this._paths,r=t,s=e;s<i;++s){var o=n[s];if(H0(o)){if(!(o in r))return Y(3929,o),null;r=r[o]}else r=o.get(r);if(null===r)break}return r},n(t,[{key:"length",get:function(){return this._paths.length}}]),t}(),X0=ks(j0.prototype,"_paths",[io],(function(){return[]})),W0=j0))||W0,p1=qs("cc.animation.TrackBinding")(q0=oo(((Q0=function(){function t(){this.path=K0&&K0(),this.proxy=J0&&J0()}var e=t.prototype;return e.parseTrsPath=function(){return this.proxy?null:this.path[_1]()},e.createRuntimeBinding=function(e,i,n){var r=this.path,s=this.proxy,o=r.length,a=o-1;if(0===o||!r.isPropertyAt(a)&&!r.isElementAt(a)||s){if(s){var h=r[c1](e,0,o);if(null===h)return null;var u=s.forTarget(h);if(!u)return null;var l={setValue:function(t){u.set(t)}},c=u.get;return c&&(l.getValue=function(){return c.call(u)}),l}return J(3921),null}var _=r.isPropertyAt(a)?r.parsePropertyAt(a):r.parseElementAt(a),d=r[c1](e,0,o-1);if(null===d)return null;if(i&&d instanceof Jm&&function(t){return"position"===t||"rotation"===t||"scale"===t||"eulerAngles"===t}(_))return i.createPoseWriter(d,_,n);var f=t._animationFunctions.get(d.constructor);f||(f=new Map,t._animationFunctions.set(d.constructor,f));var p=f.get(_);return p||(p={setValue:Function("value","this.target."+_+" = value;"),getValue:Function("return this.target."+_+";")},f.set(_,p)),{target:d,setValue:p.setValue,getValue:p.getValue}},e.isMaskedOff=function(t){var e=this.parseTrsPath();if(!e)return!1;for(var i=t.joints[Symbol.iterator](),n=i.next();!n.done;n=i.next()){var r=n.value;if(r.path===e.node)return!r.enabled}return!1},t}())._animationFunctions=new WeakMap,K0=ks((Y0=Q0).prototype,"path",[io],(function(){return new f1})),J0=ks(Y0.prototype,"proxy",[io],null),q0=Y0))||q0)||q0,m1=qs("cc.animation.Track")(($0=function(){function t(){this._binding=t1&&t1()}var e=t.prototype;return e.channels=function(){return[]},e.range=function(){for(var t,e={min:1/0,max:-1/0},i=d(this.channels());!(t=i()).done;){var n=t.value;e.min=Math.min(e.min,n.curve.rangeMin),e.max=Math.max(e.max,n.curve.rangeMax)}return e},n(t,[{key:"path",get:function(){return this._binding.path},set:function(t){this._binding.path=t}},{key:"proxy",get:function(){return this._binding.proxy},set:function(t){this._binding.proxy=t}},{key:d1,get:function(){return this._binding}}]),t}(),t1=ks($0.prototype,"_binding",[io],(function(){return new p1})),Z0=$0))||Z0,g1=qs("cc.animation.Channel")((i1=function(){function t(t){this.name="",this._curve=n1&&n1(),this._curve=t}return n(t,[{key:"curve",get:function(){return this._curve}}]),t}(),n1=ks(i1.prototype,"_curve",[io],null),e1=i1))||e1,y1=qs("cc.animation.SingleChannelTrack")((s1=function(t){function e(){var e;return(e=t.call(this)||this)._channel=o1&&o1(),e._channel=new g1(e.createCurve()),e}s(e,t);var i=e.prototype;return i.channels=function(){return[this._channel]},i.createCurve=function(){throw new Error("Not impl")},i[S0]=function(){var t=this._channel.curve;return new v1(t)},n(e,[{key:"channel",get:function(){return this._channel}}]),e}(m1),o1=ks(s1.prototype,"_channel",[io],null),r1=s1))||r1,v1=function(){function t(t){this._curve=t}return t.prototype.evaluate=function(t){return this._curve.evaluate(t)},n(t,[{key:"requiresDefault",get:function(){return!1}}]),t}(),S1=io;qs("cc.animation.RealArrayTrack")((a1=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._channels=h1&&h1(),e}s(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[S0]=function(){return new V1(this._channels.map((function(t){return t.curve})))},n(e,[{key:"elementCount",get:function(){return this._channels.length},set:function(t){var e=this._channels.length;if(t<e)this._channels.splice(t);else if(t>e){var i;(i=this._channels).push.apply(i,Array.from({length:t-e},(function(){return new g1(new ih)})))}}}]),e}(m1),h1=ks(a1.prototype,"_channels",[S1],(function(){return[]})),a1));var T1,A1,b1,E1,C1,w1,x1,R1,I1,B1,D1,P1,O1,M1,L1,N1,F1,k1,V1=function(){function t(t){this._curves=t,this._result=new Array(t.length).fill(0)}return t.prototype.evaluate=function(t){for(var e=this._result,i=e.length,n=0;n<i;++n)e[n]=this._curves[n].evaluate(t);return this._result},n(t,[{key:"requiresDefault",get:function(){return!1}}]),t}(),G1=qs("cc.animation.UniformProxyFactory")((A1=function(){function t(t,e){this.passIndex=b1&&b1(),this.uniformName=E1&&E1(),function(t,e,i,n){i&&Object.defineProperty(t,"channelIndex",{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(n):void 0})}(this,0,C1,this),this.passIndex=e||0,this.uniformName=t||""}return t.prototype.forTarget=function(t){if(t instanceof xT){var e=this.passIndex,i=this.uniformName,n=this.channelIndex;if(e<0||e>=t.passes.length)Y(3941,t.name,e);else{var r=t.passes[e],s=r.getHandle(i);if(s){if(uT.getTypeFromHandle(s)<jl.SAMPLER1D){var o=void 0===n?s:r.getHandle(i,n,jl.FLOAT);return o?function(t,e){for(var i,n=d(t.shaderInfo.blocks);!(i=n()).done;)for(var r,s=d(i.value.members);!(r=s()).done;){var o=r.value;if(o.name===e)return o.count>1}return!1}(r,i)?{set:function(t){r.setUniformArray(o,t)}}:{set:function(t){r.setUniform(o,t)}}:void Y(3943,t.name,e,i,n)}var a=uT.getBindingFromHandle(s),h=r.properties[i],u=h&&h.value?""+h.value+pv(h.type):fv(h.type),l=nT.get(u);return l||(k("Illegal texture default value: "+u+"."),l=nT.get("default-texture")),{set:function(t){t||(t=l);var e=t.getGFXTexture();e&&e.width&&e.height&&(r.bindTexture(a,e),t instanceof Of&&r.bindSampler(a,Ed.gfxDevice.getSampler(t.getSamplerInfo())))}}}Y(3942,t.name,e,i)}}else Y(3940,t)},t}(),b1=ks(A1.prototype,"passIndex",[io],(function(){return 0})),E1=ks(A1.prototype,"uniformName",[io],(function(){return""})),C1=p(A1.prototype,"channelIndex",[Eo],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),T1=A1))||T1,U1=qs("cc.animation.MorphWeightValueProxy")((x1=function(){function t(){this.subMeshIndex=R1&&R1(),this.shapeIndex=I1&&I1()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeight(i,e.subMeshIndex,e.shapeIndex)}}},t}(),R1=ks(x1.prototype,"subMeshIndex",[io],(function(){return 0})),I1=ks(x1.prototype,"shapeIndex",[io],(function(){return 0})),w1=x1))||w1,z1=qs("cc.animation.MorphWeightsValueProxy")((D1=function(){function t(){this.subMeshIndex=P1&&P1()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeights(i,e.subMeshIndex)}}},t}(),P1=ks(D1.prototype,"subMeshIndex",[io],(function(){return 0})),B1=D1))||B1,H1=qs("cc.animation.MorphWeightsAllValueProxy")(O1=function(){function t(){}return t.prototype.forTarget=function(t){return{set:function(e){for(var i,n,r=null!==(i=null===(n=t.mesh)||void 0===n?void 0:n.struct.primitives.length)&&void 0!==i?i:0,s=0;s<r;++s)t.setWeights(e,s)}}},t}())||O1;function W1(t,e,i,n){var r,s,o,a,h,u=new e,l=new e,c=new e,_=qs(t)((s=function(){function t(t,i,n){this.dataPoint=o&&o(),this.inTangent=a&&a(),this.outTangent=h&&h(),this.dataPoint=t||new e,this.inTangent=i||new e,this.outTangent=n||new e}var r=t.prototype;return r.lerp=function(t,e,r){var s=this.dataPoint,o=t.dataPoint;l=i(l,this.inTangent,r),c=i(c,t.outTangent,r);var a=e*e*e,h=e*e,_=a-2*h+e,d=-2*a+3*h,f=a-h;return u=i(u,s,2*a-3*h+1),u=n(u,u,l,_),u=n(u,u,o,d),u=n(u,u,c,f)},r.getNoLerp=function(){return this.dataPoint},t}(),o=ks(s.prototype,"dataPoint",[io],(function(){return new e})),a=ks(s.prototype,"inTangent",[io],(function(){return new e})),h=ks(s.prototype,"outTangent",[io],(function(){return new e})),r=s))||r;if(e===Sn){var d=_.prototype.lerp;_.prototype.lerp=function(t,e,i){var n=d.call(this,t,e,i);return Sn.normalize(n,n),n}}return _}var j1,X1,q1,Y1,K1,J1=W1("cc.CubicSplineVec2Value",Ln,Ln.multiplyScalar,Ln.scaleAndAdd),Q1=W1("cc.CubicSplineVec3Value",on,on.multiplyScalar,on.scaleAndAdd),Z1=W1("cc.CubicSplineVec4Value",tn,tn.multiplyScalar,tn.scaleAndAdd),$1=W1("cc.CubicSplineQuatValue",Sn,Sn.multiplyScalar,Sn.scaleAndAdd),t2=qs("cc.CubicSplineNumberValue")((L1=function(){function t(t,e,i){this.dataPoint=N1&&N1(),this.inTangent=F1&&F1(),this.outTangent=k1&&k1(),this.dataPoint=t,this.inTangent=e,this.outTangent=i}var e=t.prototype;return e.lerp=function(t,e,i){var n=this.dataPoint,r=t.dataPoint,s=e*e*e,o=e*e;return n*(2*s-3*o+1)+this.outTangent*i*(s-2*o+e)+r*(-2*s+3*o)+t.inTangent*i*(s-o)},e.getNoLerp=function(){return this.dataPoint},t}(),N1=ks(L1.prototype,"dataPoint",[io],(function(){return 0})),F1=ks(L1.prototype,"inTangent",[io],(function(){return 0})),k1=ks(L1.prototype,"outTangent",[io],(function(){return 0})),M1=L1))||M1,e2=qs("cc.animation.RealTrack")(j1=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.createCurve=function(){return new ih},e}(y1))||j1;function i2(t){return 0===t.keyFramesCount?void 0:t}var n2,r2,s2,o2,a2,h2,u2,l2,c2=["X","Y","Z","W"],_2=qs("cc.animation.VectorTrack")((q1=function(t){function e(){var e;(e=t.call(this)||this)._channels=Y1&&Y1(),e._nComponents=K1&&K1(),e._channels=new Array(4);for(var i=0;i<e._channels.length;++i){var n=new g1(new ih);n.name=c2[i],e._channels[i]=n}return e}s(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[S0]=function(){switch(this._nComponents){default:case 2:return new d2(i2(this._channels[0].curve),i2(this._channels[1].curve));case 3:return new f2(i2(this._channels[0].curve),i2(this._channels[1].curve),i2(this._channels[2].curve));case 4:return new p2(i2(this._channels[0].curve),i2(this._channels[1].curve),i2(this._channels[2].curve),i2(this._channels[3].curve))}},n(e,[{key:"componentsCount",get:function(){return this._nComponents},set:function(t){this._nComponents=t}}]),e}(m1),Y1=ks(q1.prototype,"_channels",[io],null),K1=ks(q1.prototype,"_nComponents",[io],(function(){return 4})),X1=q1))||X1,d2=function(){function t(t,e){this._result=new Ln,this._x=t,this._y=e}return t.prototype.evaluate=function(t,e){return e&&Ln.copy(this._result,e),this._x&&(this._result.x=this._x.evaluate(t)),this._y&&(this._result.y=this._y.evaluate(t)),this._result},n(t,[{key:"requiresDefault",get:function(){return!this._x||!this._y}}]),t}(),f2=function(){function t(t,e,i){this._result=new on,this._x=t,this._y=e,this._z=i}return t.prototype.evaluate=function(t,e){var i=this._x,n=this._y,r=this._z,s=this._result;return e&&on.copy(s,e),i&&(s.x=i.evaluate(t)),n&&(s.y=n.evaluate(t)),r&&(s.z=r.evaluate(t)),s},n(t,[{key:"requiresDefault",get:function(){return!this._x||!this._y||!this._z}}]),t}(),p2=function(){function t(t,e,i,n){this._result=new tn,this._x=t,this._y=e,this._z=i,this._w=n}return t.prototype.evaluate=function(t,e){return e&&tn.copy(this._result,e),this._x&&(this._result.x=this._x.evaluate(t)),this._y&&(this._result.y=this._y.evaluate(t)),this._z&&(this._result.z=this._z.evaluate(t)),this._w&&(this._result.w=this._w.evaluate(t)),this._result},n(t,[{key:"requiresDefault",get:function(){return!(this._x&&this._y&&this._z&&this._w)}}]),t}(),m2=qs("cc.animation.QuatTrack")(n2=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.createCurve=function(){return new Uh},i[S0]=function(){return new g2(this.channels()[0].curve)},e}(y1))||n2,g2=function(){function t(t){this._result=new Sn,this._curve=t}return t.prototype.evaluate=function(t){return this._curve.evaluate(t,this._result),this._result},n(t,[{key:"requiresDefault",get:function(){return!1}}]),t}(),y2=["Red","Green","Blue","Alpha"],v2=qs("cc.animation.ColorTrack")((s2=function(t){function e(){var e;(e=t.call(this)||this)._channels=o2&&o2(),e._channels=new Array(4);for(var i=0;i<e._channels.length;++i){var n=new g1(new ih);n.name=y2[i],e._channels[i]=n}return e}s(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[S0]=function(){return new S2(i2(this._channels[0].curve),i2(this._channels[1].curve),i2(this._channels[2].curve),i2(this._channels[3].curve))},e}(m1),o2=ks(s2.prototype,"_channels",[io],null),r2=s2))||r2,S2=function(){function t(t,e,i,n){this._result=new dn,this._x=t,this._y=e,this._z=i,this._w=n}return t.prototype.evaluate=function(t,e){return e&&dn.copy(this._result,e),this._x&&(this._result.r=this._x.evaluate(t)),this._y&&(this._result.g=this._y.evaluate(t)),this._z&&(this._result.b=this._z.evaluate(t)),this._w&&(this._result.a=this._w.evaluate(t)),this._result},n(t,[{key:"requiresDefault",get:function(){return!(this._x&&this._y&&this._z&&this._w)}}]),t}(),T2=["Width","Height"],A2=qs("cc.animation.SizeTrack")((h2=function(t){function e(){var e;(e=t.call(this)||this)._channels=u2&&u2(),e._channels=new Array(2);for(var i=0;i<e._channels.length;++i){var n=new g1(new ih);n.name=T2[i],e._channels[i]=n}return e}s(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[S0]=function(){return new b2(i2(this._channels[0].curve),i2(this._channels[1].curve))},e}(m1),u2=ks(h2.prototype,"_channels",[io],null),a2=h2))||a2,b2=function(){function t(t,e){this._result=new Vn,this._width=t,this._height=e}return t.prototype.evaluate=function(t,e){return e&&(this._result.x=e.x,this._result.y=e.y),this._width&&(this._result.width=this._width.evaluate(t)),this._height&&(this._result.height=this._height.evaluate(t)),this._result},n(t,[{key:"requiresDefault",get:function(){return!this._width||!this._height}}]),t}(),E2=qs("cc.animation.ObjectTrack")(l2=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.createCurve=function(){return new Qh},e}(y1))||l2;t("an",Object.freeze({__proto__:null,UniformProxyFactory:G1,MorphWeightValueProxy:U1,MorphWeightsValueProxy:z1,MorphWeightsAllValueProxy:H1,Track:m1,TrackPath:f1,RealTrack:e2,VectorTrack:_2,QuatTrack:m2,ColorTrack:v2,SizeTrack:A2,ObjectTrack:E2,isPropertyPath:H0,isCustomPath:function(t,e){return t instanceof e},HierarchyPath:u1,ComponentPath:l1,CubicSplineVec2Value:J1,CubicSplineVec3Value:Q1,CubicSplineVec4Value:Z1,CubicSplineQuatValue:$1,CubicSplineNumberValue:t2}));var C2=t("ar",function(){function t(t){var e,i;this.ratios=void 0,this._findRatio=void 0,this.ratios=t;for(var n=!0,r=1,s=t.length;r<s;r++)if(e=t[r]-t[r-1],1===r)i=e;else if(Math.abs(e-i)>1e-6){n=!1;break}this._findRatio=n?I2:Ps}return t.prototype.sample=function(t){return this._findRatio(this.ratios,t)},t}());v.RatioSampler=C2;var w2=t("as",function(){function t(e,i){this.types=void 0,this.type=null,this._values=[],this._lerp=void 0,this._duration=void 0,this._array=void 0,this._duration=i,this._values=e.values;var n=function(e){return"string"==typeof e?e:Array.isArray(e)?e[0]===e[1]&&e[2]===e[3]?t.Linear:t.Bezier(e):t.Linear};if(void 0!==e.easingMethod)this.type=n(e.easingMethod);else if(Array.isArray(e.easingMethods))this.types=e.easingMethods.map(n);else if(void 0!==e.easingMethods){this.types=new Array(this._values.length).fill(null);for(var r=0,s=Object.keys(e.easingMethods);r<s.length;r++){var o=s[r];this.types[o]=n(e.easingMethods[o])}}else this.type=null;var a=e.values[0];(void 0===e.interpolate||e.interpolate)&&(this._lerp=N2(a)),void 0!==e._arrayLength&&(this._array=new Array(e._arrayLength))}t.Bezier=function(t){return t};var e=t.prototype;return e.hasLerp=function(){return!!this._lerp},e.valueAt=function(t){if(void 0===this._array){var e=this._values[t];return e&&e.getNoLerp?e.getNoLerp():e}for(var i=0;i<this._array.length;++i)this._array[i]=this._values[this._array.length*t+i];return this._array},e.valueBetween=function(t,e,i,n,r){if(this._lerp){var s=this.types?this.types[e]:this.type,o=r-i,a=(t-i)/o;if(s&&(a=R2(a,s)),void 0===this._array){var h=this._values[e],u=this._values[n];return this._lerp(h,u,a,o*this._duration)}for(var l=0;l<this._array.length;++l){var c=this._values[this._array.length*e+l],_=this._values[this._array.length*n+l];this._array[l]=this._lerp(c,_,a,o*this._duration)}return this._array}if(void 0===this._array)return this.valueAt(e);for(var d=0;d<this._array.length;++d)this._array[d]=this._values[this._array.length*e+d];return this._array},e.empty=function(){return 0===this._values.length},e.constant=function(){return 1===this._values.length},t}());function x2(t,e,i){var n=e.sample(i);if(n<0)if((n=~n)<=0)n=0;else{if(!(n>=e.ratios.length))return t.valueBetween(i,n-1,e.ratios[n-1],n,e.ratios[n]);n=e.ratios.length-1}return t.valueAt(n)}function R2(t,e){if("string"==typeof e){var i=ja[e];i?t=i(t):J(3906,e)}else Array.isArray(e)&&(t=Fh(e,t));return t}function I2(t,e){var i=t.length-1;if(0===i)return 0;var n=t[0];if(e<n)return 0;var r=t[i];if(e>r)return i;var s=(e=(e-n)/(r-n))/(1/i),o=0|s,a=1e-6;return s-o<a?o:o+1-s<a?o+1:~(o+1)}w2.Linear=null,v.AnimCurve=w2,t("at",function(){function t(){this.events=[]}return t.prototype.add=function(t,e){this.events.push({func:t||"",params:e||[]})},t}()),v.sampleAnimationCurve=x2;var B2,D2,P2,O2,M2,L2,N2=function(){function t(t,e,i,n){return t.lerp(e,i,n)}return function(e){if(null!==e){if("number"==typeof e)return Ii;if("object"==typeof e&&e.constructor){if(e instanceof Sn)return i=new Sn,function(t,e,n){return Sn.slerp(i,t,e,n)};if(e instanceof Ae)return function(t){var e=new t;return function(i,n,r){return t.lerp(e,i,n,r),e}}(e.constructor);if(e.constructor===Number)return Ii;if("function"==typeof e.lerp)return t}var i}}}(),F2=qs("cc.animation.UntypedTrackChannel")((D2=function(t){function e(){var e;return(e=t.call(this,new ih)||this).property=P2&&P2(),e}return s(e,t),e}(g1),P2=ks(D2.prototype,"property",[io],(function(){return""})),B2=D2))||B2,k2=qs("cc.animation.UntypedTrack")((M2=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._channels=L2&&L2(),e}s(e,t);var i=e.prototype;return i.channels=function(){return this._channels},i[S0]=function(){throw new Error("UntypedTrack should be handled specially. Please file an issue.")},i.createLegacyEval=function(t){var e=this,i=function(t){var i;return null===(i=e._channels.find((function(e){return e.property===t})))||void 0===i?void 0:i.curve};switch(!0){default:throw new Error(tt(3931));case t instanceof Ln:return new d2(i("x"),i("y"));case t instanceof on:return new f2(i("x"),i("y"),i("z"));case t instanceof tn:return new p2(i("x"),i("y"),i("z"),i("w"));case t instanceof dn:return new S2(i("r"),i("g"),i("b"),i("a"));case t instanceof Vn:return new b2(i("width"),i("height"))}},i.addChannel=function(t){var e=new F2;return e.property=t,this._channels.push(e),e},i.upgrade=function(t){var e=this,i=function(t,i){var n=e.channels().find((function(e){return e.property===t}));n&&(i.name=n.name,i.curve.assignSorted(Array.from(n.curve.times()),Array.from(n.curve.values())))},n=t(this.path,this.proxy);switch(n){default:break;case"vec2":case"vec3":case"vec4":var r=new _2;r.path=this.path,r.proxy=this.proxy,r.componentsCount="vec2"===n?2:"vec3"===n?3:4;var s=r.channels(),o=s[0],a=s[1],h=s[2],u=s[3];switch(n){case"vec4":i("w",u);case"vec3":i("z",h);default:case"vec2":i("x",o),i("y",a)}return r;case"color":var l=new v2,c=l.channels(),_=c[0],d=c[1],f=c[2],p=c[3];return i("r",_),i("g",d),i("b",f),i("a",p),i("x",_),i("y",d),i("z",f),i("w",p),l;case"size":}return null},e}(m1),L2=ks(M2.prototype,"_channels",[io],(function(){return[]})),O2=M2))||O2,V2=function(){function t(t){this._keys=[],this._curves=[],this._commonTargets=[],this._ratioSamplers=[],this._runtimeCurves=void 0,this._data=null,this._duration=void 0,this._duration=t}var e=t.prototype;return e.getPropertyCurves=function(){return this._runtimeCurves||this._createPropertyCurves(),this._runtimeCurves},e.toTracks=function(){for(var t,e=[],i=this.keys,n=this.curves,r=this.commonTargets,s=function(t,e,i){for(var n,r=new f1,s=d(e);!(n=s()).done;){var o=n.value;"string"==typeof o?r.toProperty(o):"number"==typeof o?r.toElement(o):o instanceof u1?r.toHierarchy(o.path):o instanceof l1?r.toComponent(o.component):r.toCustomized(o)}t.path=r,t.proxy=i},o=r.map((function(t){var i=new k2;return s(i,t.modifiers,t.valueAdapter),e.push(i),i})),a=function(){var n,r=t.value,a=r.data,h=a.values;if(0===h.length)return 0;var u=a.keys<0?[0]:i[a.keys],l=h[0],c=null===(n=a.interpolate)||void 0===n||n;a._arrayLength;var _,d=new U2(a,u.length),f=function(t){s(t,r.modifiers,r.valueAdapter)};if("number"==typeof r.commonTarget){if(!h.every((function(t){return"number"==typeof t})))return Y(3932),0;if(r.valueAdapter||1!==r.modifiers.length||"string"!=typeof r.modifiers[0])return Y(3933),0;var p=r.modifiers[0],m=o[r.commonTarget].addChannel(p).curve;_=m}!function(){if("number"==typeof l){if(!h.every((function(t){return"number"==typeof t})))return void Y(3934);var t;if(_)t=_;else{var i=new e2;f(i),e.push(i),t=i.channel.curve}var n=c?Os.LINEAR:Os.CONSTANT;return t.assignSorted(u,h.map((function(t){return{value:t,interpolationMode:n}}))),void d.convert(t)}if("object"==typeof l)switch(!0){default:break;case G2(h,Ln):case G2(h,on):case G2(h,tn):var r=l instanceof Ln?2:l instanceof on?3:4,s=new _2;f(s),s.componentsCount=r;var o=s.channels(),a=o[0].curve,p=o[1].curve,m=o[2].curve,g=o[3].curve,y=c?Os.LINEAR:Os.CONSTANT,v=function(t){return{value:t,interpolationMode:y}};switch(r){case 4:g.assignSorted(u,h.map((function(t){return v(t.w)}))),d.convert(g);case 3:m.assignSorted(u,h.map((function(t){return v(t.z)}))),d.convert(m);default:a.assignSorted(u,h.map((function(t){return v(t.x)}))),d.convert(a),p.assignSorted(u,h.map((function(t){return v(t.y)}))),d.convert(p)}return void e.push(s);case G2(h,Sn):var S=new m2;f(S);var T=c?Bh.SLERP:Bh.CONSTANT;return S.channel.curve.assignSorted(u,h.map((function(t){return{value:Sn.clone(t),interpolationMode:T}}))),d.convertQuatCurve(S.channel.curve),void e.push(S);case G2(h,dn):var A=new v2;f(A);var b=A.channels(),E=b[0].curve,C=b[1].curve,w=b[2].curve,x=b[3].curve,R=c?Os.LINEAR:Os.CONSTANT,I=function(t){return{value:t,interpolationMode:R}};return E.assignSorted(u,h.map((function(t){return I(t.r)}))),d.convert(E),C.assignSorted(u,h.map((function(t){return I(t.g)}))),d.convert(C),w.assignSorted(u,h.map((function(t){return I(t.b)}))),d.convert(w),x.assignSorted(u,h.map((function(t){return I(t.a)}))),d.convert(x),void e.push(A);case G2(h,Vn):var B=new A2;f(B);var D=B.channels(),P=D[0].curve,O=D[1].curve,M=c?Os.LINEAR:Os.CONSTANT,L=function(t){return{value:t,interpolationMode:M}};return P.assignSorted(u,h.map((function(t){return L(t.width)}))),d.convert(P),O.assignSorted(u,h.map((function(t){return L(t.height)}))),d.convert(O),void e.push(B);case G2(h,t2):d.nil;var N=new e2;f(N);var F=c?Os.CUBIC:Os.CONSTANT;return N.channel.curve.assignSorted(u,h.map((function(t){return{value:t.dataPoint,leftTangent:t.inTangent,rightTangent:t.outTangent,interpolationMode:F}}))),void e.push(N);case G2(h,J1):case G2(h,Q1):case G2(h,Z1):d.nil;var k=l instanceof J1?2:l instanceof Q1?3:4,V=new _2;f(V),V.componentsCount=k;var G=V.channels(),U=G[0],z=G[1],H=G[2],W=G[3],j=c?Os.LINEAR:Os.CONSTANT,X=function(t,e,i){return{value:t,leftTangent:e,rightTangent:i,interpolationMode:j}};switch(k){case 4:W.curve.assignSorted(u,h.map((function(t){return X(t.dataPoint.w,t.inTangent.w,t.outTangent.w)})));case 3:H.curve.assignSorted(u,h.map((function(t){return X(t.dataPoint.z,t.inTangent.z,t.outTangent.z)})));default:U.curve.assignSorted(u,h.map((function(t){return X(t.dataPoint.y,t.inTangent.y,t.outTangent.y)}))),z.curve.assignSorted(u,h.map((function(t){return X(t.dataPoint.x,t.inTangent.x,t.outTangent.x)})))}return void e.push(V);case h.every((function(t){return t instanceof $1})):Y(3935)}var q=new E2;f(q),q.channel.curve.assignSorted(u,h),e.push(q)}()},h=d(n);!(t=h()).done;)a();return e},e._createPropertyCurves=function(){var t=this;this._ratioSamplers=this._keys.map((function(e){return new C2(e.map((function(e){return e/t._duration})))})),this._runtimeCurves=this._curves.map((function(e){return{curve:new w2(e.data,t._duration),modifiers:e.modifiers,valueAdapter:e.valueAdapter,sampler:t._ratioSamplers[e.data.keys],commonTarget:e.commonTarget}}))},n(t,[{key:"keys",get:function(){return this._keys},set:function(t){this._keys=t}},{key:"curves",get:function(){return this._curves},set:function(t){this._curves=t,delete this._runtimeCurves}},{key:"commonTargets",get:function(){return this._commonTargets},set:function(t){this._commonTargets=t}},{key:"data",get:function(){return this._data}}]),t}();function G2(t,e){return t.every((function(t){return t instanceof e}))}var U2=function(){function t(t,e){this._easingMethods=void 0;var i=t.easingMethods;Array.isArray(i)?0===i.length&&0!==e?this._easingMethods=new Array(e).fill(null):this._easingMethods=i:this._easingMethods=void 0===i?new Array(e).fill(t.easingMethod):Array.from({length:e},(function(t,e){var n;return null!==(n=i[e])&&void 0!==n?n:null}))}var e=t.prototype;return e.convert=function(t){var e,i,n,r,s,o,a,h,u,l,c,_,d,f,p,m,g,y,v,S,T,A,b=this._easingMethods;if(b){var E=t.keyFramesCount;if(!(t.keyFramesCount<2)){Array.isArray(b)&&b.length;for(var C=E-1,w=0;w<C;++w){var x=b[w];x&&(Array.isArray(x)?(e=x,i=t.getKeyframeTime(w),n=t.getKeyframeValue(w),r=t.getKeyframeTime(w+1),s=t.getKeyframeValue(w+1),o=void 0,a=void 0,h=void 0,u=void 0,l=void 0,c=void 0,_=void 0,d=void 0,f=void 0,p=void 0,m=void 0,g=void 0,y=void 0,v=void 0,S=void 0,T=void 0,A=void 0,a=e[0],h=e[1],u=e[2],l=e[3],c=n.value,_=3*(r-i),d=3*(s.value-c),m=(1-u)*_,g=(1-l)*d,y=1/3,v=(p=h*d)/(f=a*_),S=Math.sqrt(f*f+p*p)*y,T=g/m,A=Math.sqrt(m*m+g*g)*y,n.interpolationMode=Os.CUBIC,n.tangentWeightMode=(o=n.tangentWeightMode)===Ls.NONE?Ls.RIGHT:o===Ls.LEFT?Ls.BOTH:o,n.rightTangent=v,n.rightTangentWeight=S,s.tangentWeightMode=function(t){return t===Ls.NONE?Ls.LEFT:t===Ls.RIGHT?Ls.BOTH:t}(s.tangentWeightMode),s.leftTangent=T,s.leftTangentWeight=A):z2(x,t,w))}}}},e.convertQuatCurve=function(t){var e=this._easingMethods;if(e){var i=t.keyFramesCount;if(!(t.keyFramesCount<2)){Array.isArray(e)&&e.length;for(var n=i-1,r=0;r<n;++r){var s=e[r];s&&(Array.isArray(s)?t.getKeyframeValue(r).easingMethod=s.slice():H2(s,t,r))}}}},n(t,[{key:"nil",get:function(){return!this._easingMethods||this._easingMethods.every((function(t){return null==t}))}}]),t}();function z2(t,e,i){e.keyFramesCount;var n=e.getKeyframeValue(i),r=f3[t];r===Wa.CONSTANT?n.interpolationMode=Os.CONSTANT:(n.interpolationMode=Os.LINEAR,n.easingMethod=r)}function H2(t,e,i){e.keyFramesCount;var n=e.getKeyframeValue(i),r=f3[t];n.easingMethod=r}var W2,j2,X2,q2,Y2,K2,J2,Q2,Z2,$2,t3,e3,i3,n3,r3,s3,o3,a3,h3,u3,l3,c3,_3,d3,f3={constant:Wa.CONSTANT,linear:Wa.LINEAR,quadIn:Wa.QUAD_IN,quadOut:Wa.QUAD_OUT,quadInOut:Wa.QUAD_IN_OUT,quadOutIn:Wa.QUAD_OUT_IN,cubicIn:Wa.CUBIC_IN,cubicOut:Wa.CUBIC_OUT,cubicInOut:Wa.CUBIC_IN_OUT,cubicOutIn:Wa.CUBIC_OUT_IN,quartIn:Wa.QUART_IN,quartOut:Wa.QUART_OUT,quartInOut:Wa.QUART_IN_OUT,quartOutIn:Wa.QUART_OUT_IN,quintIn:Wa.QUINT_IN,quintOut:Wa.QUINT_OUT,quintInOut:Wa.QUINT_IN_OUT,quintOutIn:Wa.QUINT_OUT_IN,sineIn:Wa.SINE_IN,sineOut:Wa.SINE_OUT,sineInOut:Wa.SINE_IN_OUT,sineOutIn:Wa.SINE_OUT_IN,expoIn:Wa.EXPO_IN,expoOut:Wa.EXPO_OUT,expoInOut:Wa.EXPO_IN_OUT,expoOutIn:Wa.EXPO_OUT_IN,circIn:Wa.CIRC_IN,circOut:Wa.CIRC_OUT,circInOut:Wa.CIRC_IN_OUT,circOutIn:Wa.CIRC_OUT_IN,elasticIn:Wa.ELASTIC_IN,elasticOut:Wa.ELASTIC_OUT,elasticInOut:Wa.ELASTIC_IN_OUT,elasticOutIn:Wa.ELASTIC_OUT_IN,backIn:Wa.BACK_IN,backOut:Wa.BACK_OUT,backInOut:Wa.BACK_IN_OUT,backOutIn:Wa.BACK_OUT_IN,bounceIn:Wa.BOUNCE_IN,bounceOut:Wa.BOUNCE_OUT,bounceInOut:Wa.BOUNCE_IN_OUT,bounceOutIn:Wa.BOUNCE_OUT_IN,smooth:Wa.SMOOTH,fade:Wa.FADE};var p3=qs,m3=io;function g3(){throw new Error("split() only valid in Editor.")}p3("cc.animation.ExoticAnimation")((W2=function(){function t(){this._nodeAnimations=j2&&j2()}var e=t.prototype;return e.createEvaluator=function(t){return new x3(this._nodeAnimations,t)},e.createEvaluatorForAnimationGraph=function(t){return new B3(this._nodeAnimations,t)},e.addNodeAnimation=function(t){var e=new y3(t);return this._nodeAnimations.push(e),e},e.collectAnimatedJoints=function(){return Array.from(new Set(this._nodeAnimations.map((function(t){return t.path}))))},e.split=function(){return g3()},e.toHashString=function(){return this._nodeAnimations.map((function(t){return t.toHashString()})).join("\n")},t}(),j2=ks(W2.prototype,"_nodeAnimations",[m3],(function(){return[]})),W2));var y3=p3("cc.animation.ExoticNodeAnimation")((q2=function(){function t(t){this._path=Y2&&Y2(),this._position=K2&&K2(),this._rotation=J2&&J2(),this._scale=Q2&&Q2(),this._path=t}var e=t.prototype;return e.createPosition=function(t,e){this._position=new E3(t,new A3(e))},e.createRotation=function(t,e){this._rotation=new E3(t,new b3(e))},e.createScale=function(t,e){this._scale=new E3(t,new A3(e))},e.createEvaluator=function(t){return new R3(this._path,this._position,this._rotation,this._scale,t)},e.createEvaluatorForAnimationGraph=function(t){var e=t.bindTransform(this._path);return e?new D3(e,this._position,this._rotation,this._scale):null},e.split=function(){return g3()},e.toHashString=function(){var t,e,i,n,r,s;return this._path+"\n"+(null!==(t=null===(e=this._position)||void 0===e?void 0:e.toHashString())&&void 0!==t?t:"")+(null!==(i=null===(n=this._scale)||void 0===n?void 0:n.toHashString())&&void 0!==i?i:"")+(null!==(r=null===(s=this._rotation)||void 0===s?void 0:s.toHashString())&&void 0!==r?r:"")},n(t,[{key:"path",get:function(){return this._path}}]),t}(),Y2=ks(q2.prototype,"_path",[m3],(function(){return""})),K2=ks(q2.prototype,"_position",[m3],(function(){return null})),J2=ks(q2.prototype,"_rotation",[m3],(function(){return null})),Q2=ks(q2.prototype,"_scale",[m3],(function(){return null})),X2=q2))||X2;function v3(t){return t.toPrecision(2)}function S3(t){return t.map((function(t){return Number.parseFloat(v3(t))})).join(" ")}var T3=p3("cc.animation.ExoticVectorLikeTrackValues")(($2=function(){function t(t){this._values=t3&&t3(),this._isQuantized=e3&&e3(),this._values=t}var e=t.prototype;return e.quantize=function(t){this._isQuantized,this._values=function(t,e){var i=P3[e],n=1<<i.BYTES_PER_ELEMENT,r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;t.forEach((function(t){r=Math.min(t,r),s=Math.max(t,s)}));var o=s-r,a=i.from(t,(function(t){return(t-r)/o*n}));return new k3(O3(t),a,o,r)}(this._values,t),this._isQuantized=!0},e.toHashString=function(){var t=this._isQuantized,e=this._values;return t+" "+(t?e.toHashString():S3(e))},n(t,[{key:"precision",get:function(){return this._isQuantized?this._values.originalPrecision:O3(this._values)}}]),t}(),t3=ks($2.prototype,"_values",[m3],null),e3=ks($2.prototype,"_isQuantized",[m3],(function(){return!1})),Z2=$2))||Z2,A3=p3("cc.animation.ExoticVec3TrackValues")(i3=function(t){function e(){return t.apply(this,arguments)||this}s(e,t),e.imitate=function(t,i){var n=new e(t);return i._isQuantized&&n.quantize(i._values.quantizationType),n};var i=e.prototype;return i.get=function(t,e){var i=this._values;this._isQuantized?U3(i,t,e):on.fromArray(e,i,3*t)},i.lerp=function(t,e,i,n,r,s){var o=this._values;this._isQuantized?(U3(o,t,n),U3(o,e,r)):(on.fromArray(n,o,3*t),on.fromArray(r,o,3*e)),on.lerp(s,n,r,i)},e}(T3))||i3,b3=p3("cc.animation.ExoticQuatTrackValues")(n3=function(t){function e(){return t.apply(this,arguments)||this}s(e,t),e.imitate=function(t,i){var n=new e(t);return i._isQuantized&&n.quantize(i._values.quantizationType),n};var i=e.prototype;return i.get=function(t,e){var i=this._values;this._isQuantized?z3(i,t,e):Sn.fromArray(e,i,4*t)},i.lerp=function(t,e,i,n,r,s){var o=this._values;this._isQuantized?(z3(o,t,n),z3(o,e,r)):(Sn.fromArray(n,o,4*t),Sn.fromArray(r,o,4*e)),Sn.slerp(s,n,r,i)},e}(T3))||n3,E3=p3("cc.animation.ExoticTrack")((s3=function(){function t(t,e){this.times=o3&&o3(),this.values=a3&&a3(),this.times=t,this.values=e}return t.prototype.toHashString=function(){var t=this.times,e=this.values;return"times: "+S3(t)+"; values: "+e.toHashString()},t}(),o3=ks(s3.prototype,"times",[m3],null),a3=ks(s3.prototype,"values",[m3],null),r3=s3))||r3;function C3(t,e){t.length,t.length;var i=0,n=0,r=Ps(t,e);if(r>=0)i=r;else{var s=~r,o=s-1;i=o;var a=t[s],h=t[o];n=(e-h)/(a-h)}return{index:i,ratio:n}}!function(){function t(){this._reset()}var e=t.prototype;e.calculate=function(t,e,i){if(this._reset(),!(e>i)){var n=t.length;if(n){var r=t[0],s=t[n-1],o=0,a=0;if(e<r);else if(e>=s)o=n-1,a=0;else{var h=C3(t,e);o=h.index,a=h.ratio}var u=0,l=0;if(i<r);else if(i>=s)u=n-1,l=0;else{var c=C3(t,i);u=c.index,l=c.ratio}var _=!a,d=!l;o!==u||a!==l?(_||(this.preLerpIndex=o,this.preLerpRatio=a),this.directKeyframesBegin=_?o:o+1,this.directKeyframesEnd=u+1,d||(this.postLerpIndex=u,this.postLerpRatio=l)):_?(this.directKeyframesBegin=o,this.directKeyframesEnd=o+1):(this.preLerpIndex=o,this.preLerpRatio=a)}}},e._reset=function(){this.preLerpIndex=-1,this.preLerpRatio=0,this.directKeyframesBegin=0,this.directKeyframesEnd=0,this.postLerpIndex=-1,this.postLerpRatio=0},n(t,[{key:"keyframesCount",get:function(){var t=this.preLerpIndex,e=this.directKeyframesBegin;return 0+(t<0?0:1)+(this.directKeyframesEnd-e)+(this.postLerpIndex<0?0:1)}}])}();var w3,x3=function(){function t(t,e){this._nodeEvaluations=void 0,this._nodeEvaluations=t.map((function(t){return t.createEvaluator(e)}))}return t.prototype.evaluate=function(t){this._nodeEvaluations.forEach((function(e){e.evaluate(t)}))},t}(),R3=function(){function t(t,e,i,n,r){this._position=null,this._rotation=null,this._scale=null,e&&(this._position=G3(e.times,e.values,on,t,"position",r)),i&&(this._rotation=G3(i.times,i.values,Sn,t,"rotation",r)),n&&(this._scale=G3(n.times,n.values,on,t,"scale",r))}return t.prototype.evaluate=function(t){if(this._position){var e=this._position.evaluator.evaluate(t);this._position.runtimeBinding.setValue(e)}if(this._rotation){var i=this._rotation.evaluator.evaluate(t);this._rotation.runtimeBinding.setValue(i)}if(this._scale){var n=this._scale.evaluator.evaluate(t);this._scale.runtimeBinding.setValue(n)}},t}(),I3=function(){function t(t,e,i){this._times=void 0,this._inputSampleResultCache={just:!1,index:-1,nextIndex:-1,ratio:0},this._values=void 0,this._prevValue=void 0,this._nextValue=void 0,this._resultValue=void 0,this._times=t,this._values=e,this._prevValue=new i,this._nextValue=new i,this._resultValue=new i}return t.prototype.evaluate=function(t){var e=this._times,i=this._values,n=this._resultValue;if(0===e.length)return n;var r=function(t,e,i){var n=t.length,r=t[0],s=t[n-1];if(e<r)i.just=!0,i.index=0;else if(e>s)i.just=!0,i.index=n-1;else{var o=Ps(t,e);if(o>=0)i.just=!0,i.index=o;else{var a=~o,h=a-1,u=t[h],l=t[a],c=(e-t[h])/(l-u);i.just=!1,i.index=h,i.nextIndex=a,i.ratio=c}}return i}(e,t,this._inputSampleResultCache);return r.just?i.get(r.index,n):i.lerp(r.index,r.nextIndex,r.ratio,this._prevValue,this._nextValue,n),n},t}(),B3=function(){function t(t,e){this._nodeEvaluations=void 0,this._nodeEvaluations=t.map((function(t){return t.createEvaluatorForAnimationGraph(e)})).filter((function(t){return!!t}))}var e=t.prototype;return e.destroy=function(){for(var t=this._nodeEvaluations,e=t.length,i=0;i<e;++i)t[i].destroy()},e.evaluate=function(t,e){for(var i=this._nodeEvaluations,n=i.length,r=0;r<n;++r)i[r].evaluate(t,e)},t}(),D3=function(){function t(t,e,i,n){this._position=null,this._rotation=null,this._scale=null,this._transformHandle=void 0,this._transformHandle=t,e&&(this._position=new I3(e.times,e.values,on)),i&&(this._rotation=new I3(i.times,i.values,Sn)),n&&(this._scale=new I3(n.times,n.values,on))}var e=t.prototype;return e.destroy=function(){this._transformHandle.destroy()},e.evaluate=function(t,e){var i=this._transformHandle.index,n=this._position,r=this._rotation,s=this._scale,o=e.transforms;if(n){var a=n.evaluate(t);o.setPosition(i,a)}if(r){var h=r.evaluate(t);o.setRotation(i,h)}if(s){var u=s.evaluate(t);o.setScale(i,u)}},t}(),P3={uint8:Uint8Array,uint16:Uint16Array};function O3(t){switch(t.BYTES_PER_ELEMENT){default:case 4:return w3.FLOAT_32;case 8:return w3.FLOAT_64}}!function(t){t[t.FLOAT_32=0]="FLOAT_32",t[t.FLOAT_64=1]="FLOAT_64"}(w3||(w3={}));var M3,L3,N3,F3,k3=p3("cc.animation.QuantizedFloatArray")((u3=function(){function t(t,e,i,n){void 0===n&&(n=0),this.originalPrecision=l3&&l3(),this.min=c3&&c3(),this.extent=_3&&_3(),this.values=d3&&d3(),this.originalPrecision=t,this.values=e,this.extent=i,this.min=n}return t.prototype.toHashString=function(){var t=this.originalPrecision,e=this.min,i=this.extent,n=this.values;return t+" "+v3(e)+" "+v3(i)+" "+n.join(" ")},n(t,[{key:"quantizationType",get:function(){switch(this.values.BYTES_PER_ELEMENT){default:case 1:return"uint8";case 2:return"uint16"}}}]),t}(),l3=ks(u3.prototype,"originalPrecision",[m3],null),c3=ks(u3.prototype,"min",[m3],null),_3=ks(u3.prototype,"extent",[m3],null),d3=ks(u3.prototype,"values",[m3],null),h3=u3))||h3;function V3(t,e){return t.values[e]/(1<<t.values.BYTES_PER_ELEMENT)*t.extent+t.min}function G3(t,e,i,n,r,s){var o=new p1;o.path=(new f1).toHierarchy(n).toProperty(r);var a=s(o);return a?{runtimeBinding:a,evaluator:new I3(t,e,i)}:null}function U3(t,e,i){on.set(i,V3(t,3*e+0),V3(t,3*e+1),V3(t,3*e+2))}function z3(t,e,i){Sn.set(i,V3(t,4*e+0),V3(t,4*e+1),V3(t,4*e+2),V3(t,4*e+3))}var H3,W3,j3,X3,q3,Y3,K3,J3,Q3,Z3,$3,t5,e5,i5,n5,r5,s5,o5,a5,h5=qs("cc.animation.AuxiliaryCurveEntry")((L3=function(){this.name=N3&&N3(),this.curve=F3&&F3()},N3=ks(L3.prototype,"name",[io],(function(){return""})),F3=ks(L3.prototype,"curve",[io],(function(){return new ih})),M3=L3))||M3;function u5(t,e,i){for(var n=t.components,r=n.length,s=0;s<r;++s){var o=n[s],a=o[e];"function"==typeof a&&a.apply(o,i)}}var l5=Symbol("SearchForRootBonePath"),c5=Symbol("ExoticAnimation"),_5=Symbol("[[EmbeddedPlayerCount]]"),d5=Symbol("[[GetEmbeddedPlayers]]"),f5=Symbol("[[AddEmbeddedPlayer]]"),p5=Symbol("[[RemoveEmbeddedPlayer]]"),m5=Symbol("[[ClearEmbeddedPlayers]]"),g5=Symbol("[[Additive Settings]]"),y5=t("ao",qs("cc.AnimationClip")(((n5=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).sample=j3&&j3(),e.speed=X3&&X3(),e.wrapMode=q3&&q3(),e.enableTrsBlending=Y3&&Y3(),e._duration=K3&&K3(),e._hash=J3&&J3(),e.frameRate=0,e._tracks=Q3&&Q3(),e._exoticAnimation=Z3&&Z3(),e._legacyData=void 0,e._legacyDataDirty=!1,e._events=$3&&$3(),e._embeddedPlayers=t5&&t5(),e._additiveSettings=e5&&e5(),e._auxiliaryCurveEntries=i5&&i5(),e._runtimeEvents={ratios:[],eventGroups:[]},e}s(e,t),e.createWithSpriteFrames=function(t,i){var n=new e;n.sample=i||n.sample,n.duration=t.length/n.sample;var r=1/n.sample,s=new E2;return s.path=(new f1).toComponent("cc.Sprite").toProperty("spriteFrame"),s.channels()[0].curve.assignSorted(t.map((function(t,e){return[r*e,t]}))),n.addTrack(s),n};var i=e.prototype;return i.onLoaded=function(){this.frameRate=this.sample,this.events=this._events},i.range=function(){for(var t={min:1/0,max:-1/0},e=this._tracks,i=e.length,n=0;n<i;++n){var r=e[n].range();t.min=Math.min(t.min,r.min),t.max=Math.max(t.max,r.max)}return t},i.getTrack=function(t){return this._tracks[t]},i.addTrack=function(t){var e=this._tracks.length;return this._tracks.push(t),e},i.removeTrack=function(t){this._tracks.splice(t,1)},i.clearTracks=function(){this._tracks.length=0},i.containsAnyEvent=function(){return 0!==this._events.length},i.createEventEvaluator=function(t){return new I5(t,this._runtimeEvents.ratios,this._runtimeEvents.eventGroups,this.wrapMode)},i.containsAnyEmbeddedPlayer=function(){return 0!==this._embeddedPlayers.length},i.createEmbeddedPlayerEvaluator=function(t){return new T5(this._embeddedPlayers,t)},i.createEvaluator=function(t){var e=this,i=t.target;return this._createEvalWithBinder(i,(function(n){if(!t.mask||!n.isMaskedOff(t.mask)){var r=n.createRuntimeBinding(i,e.enableTrsBlending?t.pose:void 0,!1);return null!=r?r:void 0}}),t.rootMotion)},i.destroy=function(){var e;return null!==(e=v.director.root)&&void 0!==e&&e.dataPoolManager&&v.director.root.dataPoolManager.releaseAnimationClip(this),IQ.destroy(this),t.prototype.destroy.call(this)},i[RQ]=function(t,e,i){for(var n=1/e,r=this._collectAnimatedJoints(),s=r.length,o={},a=0;a<s;++a)o[r[a]]={transforms:Array.from({length:i},(function(){return new In}))};var h=r.reduce((function(t,e){return t[e]=new E5,t}),{});for(var u in h){var l=h[u],c=u.lastIndexOf("/");if(c>=0){var _=u.substring(0,c),d=h[_];d&&(l.parent=d)}}for(var f=this._createEvalWithBinder(void 0,(function(t){var e=t.parseTrsPath();if(e){var i=h[e.node];if(i)return R5(i,e.property)}}),void 0),p=0;p<i;++p){var m=t+n*p;f.evaluate(m);for(var g=0;g<s;++g){var y=r[g];In.copy(o[y].transforms[p],h[y].globalTransform)}for(var v=0;v<s;++v){var S=r[v];h[S].invalidate()}}return{samples:e,frames:i,joints:o}},i.upgradeUntypedTracks=function(t){for(var e=[],i=[],n=this._tracks,r=n.length,s=0;s<r;++s){var o=n[s];if(o instanceof k2){var a=o.upgrade(t);a&&(e.push(a),i.push(o))}}for(var h=i.length,u=0;u<h;++u)he(n,i[u]);n.push.apply(n,e)},i[l5]=function(){return this._searchForRootBonePath()},i.getPropertyCurves=function(){return this._getLegacyData().getPropertyCurves()},i.updateEventDatas=function(){this.events=this._events},i.hasEvents=function(){return 0!==this.events.length},i.syncLegacyData=function(){this._legacyData&&(this._fromLegacy(this._legacyData),this._legacyData=void 0)},i[d5]=function(){return this._embeddedPlayers},i[f5]=function(t){this._embeddedPlayers.push(t)},i[p5]=function(t){var e=this._embeddedPlayers.indexOf(t);e>=0&&this._embeddedPlayers.splice(e,1)},i[m5]=function(){this._embeddedPlayers.length=0},i.getAuxiliaryCurveNames_experimental=function(){return this._auxiliaryCurveEntries.map((function(t){return t.name}))},i.hasAuxiliaryCurve_experimental=function(t){return!!this._findAuxiliaryCurveEntry(t)},i.addAuxiliaryCurve_experimental=function(t){var e=this._findAuxiliaryCurveEntry(t);return e||((e=new h5).name=t,this._auxiliaryCurveEntries.push(e)),e.curve},i.getAuxiliaryCurve_experimental=function(t){return this._findAuxiliaryCurveEntry(t).curve},i.renameAuxiliaryCurve_experimental=function(t,e){var i=this._findAuxiliaryCurveEntry(t);i&&(i.name=e)},i.removeAuxiliaryCurve_experimental=function(t){le(this._auxiliaryCurveEntries,(function(e){return e.name===t}))},i._trySyncLegacyData=function(){this._legacyDataDirty&&(this._legacyDataDirty=!1,this.syncLegacyData())},i._createEvalWithBinder=function(t,e,i){this._legacyDataDirty&&(this._legacyDataDirty=!1,this.syncLegacyData());var n,r=[];i&&(n=this._createRootMotionEvaluation(t,i,r));for(var s,o=[],a=this._tracks,h=a.length,u=0;u<h;++u){var l=a[u];if(!r.includes(l)&&!Array.from(l.channels()).every((function(t){return 0===t.curve.keyFramesCount}))){var c=e(l[d1]);if(c){var _=void 0;if(l instanceof k2){if(!c.getValue){J(3930);continue}var d=c.getValue();_=l.createLegacyEval(d)}else _=l[S0]();o.push(new S5(c,_))}}}return this._exoticAnimation&&(s=this._exoticAnimation.createEvaluator(e)),new A5(o,s,n)},i._createRootMotionEvaluation=function(t,e,i){if(t instanceof Jm){var n=this._searchForRootBonePath();if(n){var r=t.getChildByPath(n);if(r){for(var s=new b5,o=[],a=this._tracks,h=a.length,u=0;u<h;++u){var l=a[u],c=l[d1].parseTrsPath();if(c&&c.node===n){i.push(l);var _=R5(s,c.property);if(_){var d=l[S0]();o.push(new S5(_,d))}}}return new w5(r,this._duration,s,o)}Y(3924)}else Y(3923)}else J(3920)},i._searchForRootBonePath=function(){var t=this._tracks.map((function(t){var e=t[d1].parseTrsPath();if(e){var i=e.node;return{path:i,rank:i.split("/").length}}return{path:"",rank:0}}));t.sort((function(t,e){return t.rank-e.rank}));var e=t.findIndex((function(t){return 0!==t.rank}));if(e<0)return"";for(var i=t.length,n=t[e],r=!0,s=e+1;s<i;++s){var o=t[s];if(o.rank!==n.rank)break;if(o.path!==n.path){r=!1;break}}return r?n.path:""},i._getLegacyData=function(){return this._legacyData||(this._legacyData=this._toLegacy()),this._legacyData},i._toLegacy=function(){var t=new V2(this._duration);return t.keys=[],t.curves=[],t.commonTargets=[],t},i._fromLegacy=function(t){for(var e=t.toTracks(),i=e.length,n=0;n<i;++n)this.addTrack(e[n])},i._collectAnimatedJoints=function(){for(var t=new Set,e=this._tracks,i=e.length,n=0;n<i;++n){var r=e[n][d1].parseTrsPath();r&&t.add(r.node)}if(this._exoticAnimation)for(var s=this._exoticAnimation.collectAnimatedJoints(),o=s.length,a=0;a<o;++a)t.add(s[a]);return Array.from(t)},i._findAuxiliaryCurveEntry=function(t){return this._auxiliaryCurveEntries.find((function(e){return e.name===t}))},n(e,[{key:"duration",get:function(){return this._duration},set:function(t){this._duration=t}},{key:"tracksCount",get:function(){return this._tracks.length}},{key:"tracks",get:function(){return this._tracks}},{key:"hash",get:function(){var t,e;if(this._hash)return this._hash;var i="Exotic:"+(null!==(t=null===(e=this._exoticAnimation)||void 0===e?void 0:e.toHashString())&&void 0!==t?t:"");return this._hash=Dl(i,666)}},{key:"events",get:function(){return this._events},set:function(t){var e=this;this._events=t;for(var i=[],n=[],r=this.events.sort((function(t,e){return t.frame-e.frame})),s=r.length,o=function(){var t=r[a],s=t.frame/e._duration,o=i.findIndex((function(t){return t===s}));o<0&&(o=i.length,i.push(s),n.push({events:[]})),n[o].events.push({functionName:t.func,parameters:t.params})},a=0;a<s;++a)o();this._runtimeEvents={ratios:i,eventGroups:n}}},{key:c5,get:function(){return this._exoticAnimation}},{key:c5,set:function(t){this._exoticAnimation=t}},{key:"isAdditive_experimental",get:function(){return this._additiveSettings.enabled}},{key:g5,get:function(){return this._additiveSettings}},{key:"keys",get:function(){return this._getLegacyData().keys}},{key:"keys",set:function(t){this._legacyDataDirty=!0,this._getLegacyData().keys=t}},{key:"curves",get:function(){return this._legacyDataDirty=!0,this._getLegacyData().curves}},{key:"curves",set:function(t){this._getLegacyData().curves=t}},{key:"commonTargets",get:function(){return this._getLegacyData().commonTargets}},{key:"commonTargets",set:function(t){this._legacyDataDirty=!0,this._getLegacyData().commonTargets=t}},{key:"data",get:function(){return this._getLegacyData().data}},{key:"eventGroups",get:function(){return this._runtimeEvents.eventGroups}},{key:_5,get:function(){return this._embeddedPlayers.length}},{key:"auxiliaryCurveCount_experimental",get:function(){return this._auxiliaryCurveEntries.length}}]),e}(of)).WrapMode=T0,j3=ks((W3=n5).prototype,"sample",[io],(function(){return 60})),X3=ks(W3.prototype,"speed",[io],(function(){return 1})),q3=ks(W3.prototype,"wrapMode",[io],(function(){return T0.Normal})),Y3=ks(W3.prototype,"enableTrsBlending",[io],(function(){return!1})),K3=ks(W3.prototype,"_duration",[io],(function(){return 0})),J3=ks(W3.prototype,"_hash",[io],(function(){return 0})),Q3=ks(W3.prototype,"_tracks",[io],(function(){return[]})),Z3=ks(W3.prototype,"_exoticAnimation",[io],(function(){return null})),$3=ks(W3.prototype,"_events",[io],(function(){return[]})),t5=ks(W3.prototype,"_embeddedPlayers",[io],(function(){return[]})),e5=ks(W3.prototype,"_additiveSettings",[io],(function(){return new v5})),i5=ks(W3.prototype,"_auxiliaryCurveEntries",[io],(function(){return[]})),H3=W3))||H3),v5=qs("cc.AnimationClipAdditiveSettings")((s5=function(){this.enabled=o5&&o5(),this.refClip=a5&&a5()},o5=ks(s5.prototype,"enabled",[io],(function(){return!1})),a5=ks(s5.prototype,"refClip",[io],(function(){return null})),r5=s5))||r5;v.AnimationClip=y5;var S5=function(){function t(t,e){this._binding=void 0,this._trackEval=void 0,this._shouldEvaluateDefault=!0,this._binding=t,this._trackEval=e,this._shouldEvaluateDefault=!!t.getValue&&e.requiresDefault}return t.prototype.evaluate=function(t){var e=this._binding,i=this._trackEval,n=this._shouldEvaluateDefault?e.getValue():void 0,r=i.evaluate(t,n);e.setValue(r)},t}(),T5=function(){function t(t,e){this._embeddedPlayers=t,this._embeddedPlayerEvaluationInfos=t.map((function(t){var i=t.playable;if(!i)return null;var n=i.instantiate(e);return n?{instantiatedPlayer:n,entered:!1,hostPauseTime:0,lastIterations:0}:null}))}var e=t.prototype;return e.destroy=function(){for(var t=this._embeddedPlayerEvaluationInfos,e=t.length,i=0;i<e;++i){var n;null===(n=t[i])||void 0===n||n.instantiatedPlayer.destroy()}this._embeddedPlayerEvaluationInfos.length=0},e.evaluate=function(t,e){for(var i=this._embeddedPlayers,n=this._embeddedPlayerEvaluationInfos,r=i.length,s=0;s<r;++s){var o=n[s];if(o){var a=o.entered,h=o.instantiatedPlayer,u=o.lastIterations,l=i[s],c=l.begin,_=l.end;if(t>=c&&t<=_?a?e!==u&&(h.stop(),h.play(),o.entered=!0):(h.play(),o.entered=!0):a&&(h.stop(),o.entered=!1),o.lastIterations=e,o.entered){var d=t-c;o.instantiatedPlayer.setTime(d)}}}},e.notifyHostSpeedChanged=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r<n;++r){var s=i[r];if(s){var o=s.instantiatedPlayer;e[r].reconciledSpeed&&o.setSpeed(t)}}},e.notifyHostPlay=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r<n;++r){var s=i[r];if(s){var o=e[r],a=o.begin,h=o.end,u=s.instantiatedPlayer;if(s.entered){var l=s.hostPauseTime;if(u.randomAccess||wi(l,t,1e-5)){var c=xi(t,a,h);u.play(),u.setTime(c-a)}else u.stop()}}}},e.notifyHostPause=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r<n;++r){var s=i[r];if(s){var o=s.instantiatedPlayer;s.entered&&(o.pause(),s.hostPauseTime=t)}}},e.notifyHostStop=function(){for(var t=this._embeddedPlayers,e=this._embeddedPlayerEvaluationInfos,i=t.length,n=0;n<i;++n){var r=e[n];if(r){var s=r.instantiatedPlayer;r.entered&&(r.entered=!1,s.stop())}}},t}(),A5=function(){function t(t,e,i){this._exoticAnimationEvaluator=void 0,this._trackEvalStatues=[],this._rootMotionEvaluation=void 0,this._trackEvalStatues=t,this._exoticAnimationEvaluator=e,this._rootMotionEvaluation=i}var e=t.prototype;return e.evaluate=function(t){for(var e=this._trackEvalStatues,i=this._exoticAnimationEvaluator,n=e.length,r=0;r<n;++r)e[r].evaluate(t);i&&i.evaluate(t)},e.evaluateRootMotion=function(t,e){var i=this._rootMotionEvaluation;i&&i.evaluate(t,e)},t}(),b5=function(){function t(){this.position=new on,this.scale=new on(1,1,1),this.rotation=new Sn,this.eulerAngles=new on}return t.prototype.getTransform=function(t){In.fromRTS(t,this.rotation,this.position,this.scale)},t}(),E5=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).parent=null,e._dirty=!0,e._transform=new In,e}return s(e,t),e.prototype.invalidate=function(){this._dirty=!0},n(e,[{key:"globalTransform",get:function(){var t=this._transform;return this._dirty&&(this._dirty=!1,In.fromRTS(t,this.rotation,this.position,this.scale),this.parent&&In.multiply(t,this.parent.globalTransform,t)),this._transform}}]),e}(b5),C5=new In,w5=function(){function t(t,e,i,n){this._initialTransformCache=new In,this._clipEndTransformCache=new In,this._startTransformCache=new In,this._endTransformCache=new In,this._motionTransformCache=new In,this._translationMotionCache=new on,this._rotationMotionCache=new Sn,this._scaleMotionCache=new on,this._rootBone=t,this._duration=e,this._boneTransform=i,this._trackEvalStatuses=n}var e=t.prototype;return e.evaluate=function(t,e){var i=this._calcMotionTransform(t,e,this._motionTransformCache),n=this._translationMotionCache,r=this._rotationMotionCache,s=this._scaleMotionCache,o=this._rootBone;In.toRTS(i,r,n,s),on.add(n,n,o.position),o.setPosition(n),Sn.multiply(r,r,o.rotation),o.setRotation(r),on.multiply(s,s,o.scale),o.setScale(s)},e._calcMotionTransform=function(t,e,i){var n=this._duration,r=n-t,s=this._evaluateAt(t,this._startTransformCache);if(e<r){var o=this._evaluateAt(t+e,this._endTransformCache);x5(i,s,o)}else{In.identity(i);var a=function(t,e){x5(C5,t,e),In.multiply(i,i,C5)},h=e-r,u=Math.floor(h/n),l=h-u*n,c=this._evaluateAt(0,this._initialTransformCache),_=this._evaluateAt(n,this._clipEndTransformCache),d=this._evaluateAt(l,this._endTransformCache);a(s,_),x5(C5,c,_);for(var f=0;f<u;++f)In.multiply(i,i,C5);a(c,d)}return i},e._evaluateAt=function(t,e){for(var i=this._trackEvalStatuses,n=i.length,r=0;r<n;++r)i[r].evaluate(t);return this._boneTransform.getTransform(e),e},t}();function x5(t,e,i){In.invert(t,e),In.multiply(t,i,t)}function R5(t,e){switch(e){default:return;case"position":return{setValue:function(e){on.copy(t.position,e)}};case"rotation":return{setValue:function(e){Sn.copy(t.rotation,e)}};case"scale":return{setValue:function(e){on.copy(t.scale,e)}};case"eulerAngles":return{setValue:function(e){on.copy(t.eulerAngles,e)}}}}var I5=function(){function t(t,e,i,n){this._lastFrameIndex=-1,this._lastIterations=0,this._lastDirection=0,this._ignoreIndex=-1,this._sampled=!1,this._targetNode=t,this._ratios=e,this._eventGroups=i,this._wrapMode=n}var e=t.prototype;return e.setWrapMode=function(t){this._wrapMode=t},e.ignore=function(t,e){this._ignoreIndex=-1,this._sampled=!1;var i=D5(t,this._ratios);i<0&&(i=~i-1,e<0&&(i+=1),this._ignoreIndex=i)},e.reset=function(){this._lastFrameIndex=-1,this._lastIterations=0,this._lastDirection=0,this._ignoreIndex=-1,this._sampled=!1},e.sample=function(t,e,i){if(0!==this._eventGroups.length){var n=this._eventGroups.length,r=D5(t,this._ratios);if(r<0&&(r=~r-1,e<0&&(r+=1)),this._ignoreIndex!==r&&(this._ignoreIndex=-1),!this._sampled)return this._sampled=!0,this._doFire(r,!1),this._lastFrameIndex=r,this._lastIterations=i,void(this._lastDirection=e);var s=this._wrapMode,o=B5(i),a=B5(this._lastIterations),h=this._lastFrameIndex,u=this._lastDirection,l=-1!==a&&o!==a;if(h===r&&l&&1===n)this._doFire(0,!1);else if(h!==r||l){e=u;do{if(h!==r){if(-1===e&&0===h&&r>0?((s&su.PingPong)===su.PingPong?e*=-1:h=n,a++):1===e&&h===n-1&&r<n-1&&((s&su.PingPong)===su.PingPong?e*=-1:h=-1,a++),h===r)break;if(a>o)break}h+=e,this._doFire(h,!0)}while(h!==r&&h>-1&&h<n)}this._lastFrameIndex=r,this._lastIterations=i,this._lastDirection=e}},e._doFire=function(t,e){e?R0().pushDelayEvent(this._checkAndFire,this,[t]):this._checkAndFire(t)},e._checkAndFire=function(t){if(this._targetNode&&this._targetNode.isValid){var e=this._eventGroups;if(!(t<0||t>=e.length||this._ignoreIndex===t))for(var i=e[t],n=i.events.length,r=0;r<n;++r){var s=i.events[r];u5(this._targetNode,s.functionName,s.parameters)}}},t}();function B5(t){return t-(0|t)==0&&(t-=1),0|t}function D5(t,e){return Ps(e,t)}var P5,O5=function(){function t(){this._nodeBlendStates=new Map}var e=t.prototype;return e.createWriter=function(t,e,i,n){var r=this.ref(t,e);return new M5(t,e,r,i,n)},e.destroyWriter=function(t){var e=t;this.deRef(e.node,e.property)},e.ref=function(t,e){var i=this._nodeBlendStates.get(t);return i||(i=this.createNodeBlendState(),this._nodeBlendStates.set(t,i)),i.refProperty(t,e)},e.deRef=function(t,e){var i=this._nodeBlendStates.get(t);i&&(i.deRefProperty(e),i.empty&&this._nodeBlendStates.delete(t))},e.apply=function(){this._nodeBlendStates.forEach((function(t,e){t.apply(e)}))},t}(),M5=function(){function t(t,e,i,n,r){this._node=t,this._property=e,this._propertyBlendState=i,this._host=n,this._constants=r}var e=t.prototype;return e.getValue=function(){return this._node[this._property]},e.setValue=function(t){var e=this._propertyBlendState,i=this._host.weight;e.blend(t,i)},n(t,[{key:"node",get:function(){return this._node}},{key:"property",get:function(){return this._property}}]),t}();!function(t){t[t.POSITION=1]="POSITION",t[t.ROTATION=2]="ROTATION",t[t.SCALE=4]="SCALE",t[t.EULER_ANGLES=8]="EULER_ANGLES"}(P5||(P5={})),P5.POSITION,P5.ROTATION,P5.SCALE,P5.EULER_ANGLES;var L5,N5,F5=function(){function t(){this.refCount=0,this.accumulatedWeight=0,this.result=new on}var e=t.prototype;return e.blend=function(t,e){this.accumulatedWeight=function(t,e,i,n,r){var s=i+r;if(1!==r||i){if(s){var o=r/s;on.lerp(t,t,n,o)}}else on.copy(t,n);return s}(this.result,this.result,this.accumulatedWeight,t,e)},e.reset=function(){this.accumulatedWeight=0,on.zero(this.result)},t}(),k5=function(){function t(){this.refCount=0,this.accumulatedWeight=0,this.result=new Sn}var e=t.prototype;return e.blend=function(t,e){this.accumulatedWeight=function(t,e,i,n,r){var s=i+r;if(1!==r||i){if(s){var o=r/s;Sn.slerp(t,e,n,o)}}else Sn.copy(t,n);return s}(this.result,this.result,this.accumulatedWeight,t,e)},e.reset=function(){this.accumulatedWeight=0,Sn.identity(this.result)},t}(),V5=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.apply=function(e){var i=this._properties,n=i.position,r=i.scale,s=i.rotation,o=i.eulerAngles;n&&n.accumulatedWeight&&(this._transformApplyFlags|=P5.POSITION,n.accumulatedWeight<1&&n.blend(e.position,1-n.accumulatedWeight)),r&&r.accumulatedWeight&&(this._transformApplyFlags|=P5.SCALE,r.accumulatedWeight<1&&r.blend(e.scale,1-r.accumulatedWeight)),o&&o.accumulatedWeight&&(this._transformApplyFlags|=P5.EULER_ANGLES,o.accumulatedWeight<1&&o.blend(e.eulerAngles,1-o.accumulatedWeight)),s&&s.accumulatedWeight&&(this._transformApplyFlags|=P5.ROTATION,s.accumulatedWeight<1&&s.blend(e.rotation,1-s.accumulatedWeight)),t.prototype.apply.call(this,e),null==n||n.reset(),null==r||r.reset(),null==s||s.reset(),null==o||o.reset()},i._createVec3BlendState=function(){return new F5},i._createQuatBlendState=function(){return new k5},e}(function(){function t(){this._transformApplyFlags=0,this._properties={}}var e=t.prototype;return e.refProperty=function(t,e){var i,n,r,s=this._properties;switch(e){default:case"position":case"scale":case"eulerAngles":r=null!==(i=s[e])&&void 0!==i?i:s[e]=this._createVec3BlendState(t[e]);break;case"rotation":r=null!==(n=s[e])&&void 0!==n?n:s[e]=this._createQuatBlendState(t.rotation)}return++r.refCount,r},e.deRefProperty=function(t){var e=this._properties,i=e[t];i&&(--i.refCount,i.refCount>0||delete e[t])},e.apply=function(t){var e,i,n,r=this._transformApplyFlags,s=this._properties,o=s.position,a=s.scale,h=s.rotation,u=s.eulerAngles;r&&(o&&r&P5.POSITION&&(e=o.result),a&&r&P5.SCALE&&(i=a.result),u&&r&P5.EULER_ANGLES&&(n=u.result),h&&r&P5.ROTATION&&(n=h.result),(n||e||i)&&t.setRTS(n,e,i),this._transformApplyFlags=0)},n(t,[{key:"empty",get:function(){var t=this._properties;return!(t.position||t.rotation||t.eulerAngles||t.scale)}}]),t}()),G5=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.createNodeBlendState=function(){return new V5},e}(O5),U5=t("aw",qs(((N5=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._anims=new se([]),e._crossFades=new se([]),e._delayEvents=[],e._blendStateBuffer=new G5,e._sockets=[],e}s(e,t);var i=e.prototype;return i.addCrossFade=function(t){-1===this._crossFades.array.indexOf(t)&&this._crossFades.push(t)},i.removeCrossFade=function(t){var e=this._crossFades.array.indexOf(t);e>=0?this._crossFades.fastRemoveAt(e):J(3907)},i.update=function(t){var e=this._delayEvents,i=this._crossFades,n=this._sockets,r=i.array;for(i.i=0;i.i<r.length;++i.i)r[i.i].update(t);var s=this._anims,o=s.array;for(s.i=0;s.i<o.length;++s.i){var a=o[s.i];a.isMotionless||a.update(t)}this._blendStateBuffer.apply();for(var h=fN.getTotalFrames(),u=0,l=n.length;u<l;u++){var c=n[u],_=c.target,d=c.transform;_.matrix=qQ(d,h)}for(var f=0,p=e.length;f<p;f++){var m=e[f];m.fn.apply(m.thisArg,m.args)}e.length=0},i.destruct=function(){},i.addAnimation=function(t){-1===this._anims.array.indexOf(t)&&this._anims.push(t)},i.removeAnimation=function(t){var e=this._anims.array.indexOf(t);e>=0?this._anims.fastRemoveAt(e):J(3907)},i.pushDelayEvent=function(t,e,i){this._delayEvents.push({fn:t,thisArg:e,args:i})},i.addSockets=function(t,e){for(var i=this,n=function(){var n=e[r];if(i._sockets.find((function(t){return t.target===n.target})))return 1;var s=t.getChildByPath(n.path),o=n.target&&s&&YQ(s,t);o&&i._sockets.push({target:n.target,transform:o})},r=0;r<e.length;++r)n()},i.removeSockets=function(t,e){for(var i=0;i<e.length;++i)for(var n=e[i],r=0;r<this._sockets.length;++r){var s=this._sockets[r];if(s.target===n.target){KQ(s.transform.node),this._sockets[r]=this._sockets[this._sockets.length-1],this._sockets.length--;break}}},n(e,[{key:"blendState",get:function(){return this._blendStateBuffer}}]),e}(Ou)).ID="animation",L5=N5))||L5);fN.on(dN.EVENT_INIT,(function(){var t=new U5;fN.registerSystem(U5.ID,t,Ou.Priority.HIGH)})),v.AnimationManager=U5;var z5,H5,W5,j5,X5,q5,Y5,K5,J5,Q5,Z5,$5,t4,e4,i4=function(t){function e(e){var i;return(i=t.call(this)||this)._managedStates=[],i._fadings=[],i._scheduled=!1,i._scheduler=null!=e?e:R0(),i}s(e,t);var i=e.prototype;return i.update=function(t){if(!this.isMotionless){var e=this._managedStates,i=this._fadings;if(1===e.length&&1===i.length){var n=e[0].state;n&&(n.weight=1)}else this._calculateWeights(t);1===e.length&&1===i.length&&this._unscheduleThis()}},i.crossFade=function(t,e){var i;0===this._managedStates.length&&(e=0),0===e&&this.clear();var n=this._managedStates.find((function(e){return e.state===t}));n?null!==(i=n.state)&&void 0!==i&&i.isMotionless&&n.state.play():(n={state:t,reference:0},t&&t.play(),this._managedStates.push(n)),++n.reference,this._fadings.unshift({easeDuration:e,easeTime:0,target:n}),this.isMotionless||this._scheduleThis()},i.clear=function(){for(var t=0;t<this._managedStates.length;++t){var e=this._managedStates[t].state;e&&e.stop()}this._managedStates.length=0,this._fadings.length=0},i.onPlay=function(){t.prototype.onPlay.call(this),this._scheduleThis()},i.onPause=function(){t.prototype.onPause.call(this);for(var e=0;e<this._managedStates.length;++e){var i=this._managedStates[e].state;i&&i.pause()}this._unscheduleThis()},i.onResume=function(){t.prototype.onResume.call(this);for(var e=0;e<this._managedStates.length;++e){var i=this._managedStates[e].state;i&&i.resume()}this._scheduleThis()},i.onStop=function(){t.prototype.onStop.call(this),this.clear()},i._calculateWeights=function(t){for(var e=this._managedStates,i=this._fadings,n=0;n<e.length;++n){var r=e[n].state;r&&(r.weight=0)}for(var s=1,o=i.length,a=0;a<i.length;++a){var h=i[a];h.easeTime+=t;var u=0===h.easeDuration?1:Ri(h.easeTime/h.easeDuration),l=u*s;if(s*=1-u,h.target.state&&(h.target.state.weight+=l),h.easeTime>=h.easeDuration){o=a+1,h.easeTime=h.easeDuration;break}}if(o!==i.length){for(var c=o;c<i.length;++c){var _=i[c];--_.target.reference,_.target.reference<=0&&(_.target.state&&_.target.state.stop(),he(this._managedStates,_.target))}i.splice(o)}},i._scheduleThis=function(){this._scheduled||(this._scheduler.addCrossFade(this),this._scheduled=!0)},i._unscheduleThis=function(){this._scheduled&&(this._scheduler.removeCrossFade(this),this._scheduled=!1)},e}(E0),n4=t("aq",(z5=qs("cc.Animation"),H5=Ks(99),W5=xo([y5]),j5=xo(y5),X5=xo([y5]),z5(q5=H5(((Z5=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).playOnLoad=K5&&K5(),e._crossFade=new i4,e._nameToState=It(!0),e._clips=J5&&J5(),e._defaultClip=Q5&&Q5(),e._hasBeenPlayed=!1,e}s(e,t);var i=e.prototype;return i.onLoad=function(){for(var t in this.clips=this._clips,this._nameToState)this._nameToState[t].initialize(this.node)},i.start=function(){this.playOnLoad&&!this._hasBeenPlayed&&this._defaultClip&&this.crossFade(this._defaultClip.name,0)},i.onEnable=function(){this._crossFade.resume()},i.onDisable=function(){this._crossFade.pause()},i.onDestroy=function(){for(var t in this._crossFade.stop(),this._nameToState)this._nameToState[t].destroy();this._nameToState=It(!0)},i.play=function(t){if(this._hasBeenPlayed=!0,!t){if(!this._defaultClip)return;t=this._defaultClip.name}this.crossFade(t,0)},i.crossFade=function(t,e){void 0===e&&(e=.3),this._hasBeenPlayed=!0;var i=this._nameToState[t];i&&this.doPlayOrCrossFade(i,e)},i.pause=function(){this._crossFade.pause()},i.resume=function(){this._crossFade.resume()},i.stop=function(){this._crossFade.stop()},i.getState=function(t){var e=this._nameToState[t];return e&&!e.curveLoaded&&e.initialize(this.node),e||null},i.createState=function(t,e){return e=e||t.name,this.removeState(e),this._doCreateState(t,e)},i.removeState=function(t){var e=this._nameToState[t];e&&(e.allowLastFrameEvent(!1),e.stop(),delete this._nameToState[t])},i.addClip=function(t,e){return ce(this._clips,t)||this._clips.push(t),this.createState(t,e)},i.removeClip=function(t,e){var i;for(var n in this._nameToState){var r=this._nameToState[n];if(r.clip===t){i=r;break}}if(t===this._defaultClip){if(!e)return void Y(3902);this._defaultClip=null}if(i&&i.isPlaying){if(!e)return void Y(3903);i.stop()}this._clips=this._clips.filter((function(e){return e!==t})),i&&delete this._nameToState[i.name]},i.on=function(e,i,n,r){var s=t.prototype.on.call(this,e,i,n,r);return e===C0.LASTFRAME&&this._syncAllowLastFrameEvent(),s},i.once=function(e,i,n){var r=t.prototype.once.call(this,e,i,n);return e===C0.LASTFRAME&&this._syncAllowLastFrameEvent(),r},i.off=function(e,i,n){t.prototype.off.call(this,e,i,n),e===C0.LASTFRAME&&this._syncDisallowLastFrameEvent()},i._createState=function(t,e){return new P0(t,e)},i._doCreateState=function(t,e){var i=this._createState(t,e);return i._setEventTarget(this),i.allowLastFrameEvent(this.hasEventListener(C0.LASTFRAME)),this.node&&i.initialize(this.node),this._nameToState[i.name]=i,i},i.doPlayOrCrossFade=function(t,e){this._crossFade.play(),this._crossFade.crossFade(t,e)},i._removeStateOfAutomaticClip=function(t){for(var e in this._nameToState){var i=this._nameToState[e];r4(t,i.clip)&&(i.stop(),delete this._nameToState[e])}},i._syncAllowLastFrameEvent=function(){if(this.hasEventListener(C0.LASTFRAME))for(var t in this._nameToState)this._nameToState[t].allowLastFrameEvent(!0)},i._syncDisallowLastFrameEvent=function(){if(!this.hasEventListener(C0.LASTFRAME))for(var t in this._nameToState)this._nameToState[t].allowLastFrameEvent(!1)},n(e,[{key:"clips",get:function(){return this._clips},set:function(t){var e=this;this._crossFade&&this._crossFade.clear();for(var i,n=d(this._clips);!(i=n()).done;){var r=i.value;r&&this._removeStateOfAutomaticClip(r)}for(var s,o=d(t);!(s=o()).done;){var a=s.value;a&&this.createState(a)}var h=t.find((function(t){return r4(t,e._defaultClip)}));this._defaultClip=h||null,this._clips=t}},{key:"defaultClip",get:function(){return this._defaultClip},set:function(t){this._defaultClip=t,t&&(this._clips.findIndex((function(e){return r4(e,t)}))>=0||(this._clips.push(t),this.createState(t)))}}]),e}(Yu(rp))).EventType=C0,p((Y5=Z5).prototype,"clips",[W5],Object.getOwnPropertyDescriptor(Y5.prototype,"clips"),Y5.prototype),p(Y5.prototype,"defaultClip",[j5],Object.getOwnPropertyDescriptor(Y5.prototype,"defaultClip"),Y5.prototype),K5=ks(Y5.prototype,"playOnLoad",[io],(function(){return!1})),J5=ks(Y5.prototype,"_clips",[X5],(function(){return[]})),Q5=ks(Y5.prototype,"_defaultClip",[io],(function(){return null})),q5=Y5))||q5)||q5));function r4(t,e){return t===e||!!t&&!!e&&t._uuid===e._uuid&&t._uuid}v.Animation=n4,v.AnimationComponent=n4,Qt(n4,"cc.AnimationComponent"),function(t){t.PLAYED="play",t.PAUSED="pause",t.STOPPED="stop",t.SEEKED="seeked",t.ENDED="ended",t.INTERRUPTION_BEGIN="interruptionBegin",t.INTERRUPTION_END="interruptionEnd",t.USER_GESTURE="on_gesture"}($5||($5={})),function(t){t[t.DOM_AUDIO=0]="DOM_AUDIO",t[t.WEB_AUDIO=1]="WEB_AUDIO",t[t.MINIGAME_AUDIO=2]="MINIGAME_AUDIO",t[t.NATIVE_AUDIO=3]="NATIVE_AUDIO",t[t.UNKNOWN_AUDIO=4]="UNKNOWN_AUDIO"}(t4||(t4={})),function(t){t[t.INIT=0]="INIT",t[t.PLAYING=1]="PLAYING",t[t.PAUSED=2]="PAUSED",t[t.STOPPED=3]="STOPPED",t[t.INTERRUPTED=4]="INTERRUPTED"}(e4||(e4={}));var s4,o4=t("aB",function(){function t(){this._bufferView=void 0,this._normalizeFactor=1;for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(2===e.length)this._bufferView=e[0],this._normalizeFactor=e[1];else{var n=e[0],r=e[1],s=e[2];this._bufferView=new r(n),this._normalizeFactor=s}}return t.prototype.getData=function(t){return this._bufferView[t]*this._normalizeFactor},n(t,[{key:"length",get:function(){return this._bufferView.length}}]),t}()),a4=0;function h4(t,e){var i;e.invoking||(e.invoking=!0,(i=e.func).call.apply(i,[t].concat(e.args)).then((function(){e.invoking=!1,t._operationQueue.shift(),t._eventTarget.emit(e.id.toString()),function(t){for(var e=t._operationQueue.length,i=t._operationQueue.slice(),n=[],r=!1,s=e-1;s>=0;s--){var o=i[s];if("stop"===o.op){n.push(o);break}if("seek"===o.op)r||(n.push(o),r=!0);else{if(r){n.push(o);break}0===n.length&&n.push(o)}}t._operationQueue=n.reverse()}(t);var i=t._operationQueue[0];i&&h4(t,i)})).catch((function(){})))}function u4(t,e,i){var n=i.value;i.value=function(){for(var t=this,i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return new Promise((function(i){var s=a4++,o=t;o._operationQueue.push({op:e,id:s,func:n,args:r,invoking:!1}),o._eventTarget.once(s.toString(),i),h4(o,o._operationQueue[0])}))}}function l4(t){return new Promise((function(e){var i=t.play();return void 0===i?e():(i.then(e).catch((function(){var i=function i(){t.play().then((function(){null==n||n.removeEventListener("touchend",i,{capture:!0}),null==n||n.removeEventListener("mouseup",i,{capture:!0})})).catch((function(){})),e()},n=document.getElementById("GameCanvas");null==n||n.addEventListener("touchend",i,{capture:!0}),null==n||n.addEventListener("mouseup",i,{capture:!0})})),null)}))}var c4,_4,d4=function(){function t(t,e){this._domAudio=void 0,this._onPlayCb=void 0,this._onEndCb=void 0,this._domAudio=t,t.volume=e}var e=t.prototype;return e.play=function(){var t=this;l4(this._domAudio).then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t)})).catch((function(){}))},e.stop=function(){this._domAudio.pause()},n(t,[{key:"onPlay",get:function(){return this._onPlayCb},set:function(t){this._onPlayCb=t}},{key:"onEnd",get:function(){return this._onEndCb},set:function(t){this._onEndCb&&this._domAudio.removeEventListener("ended",this._onEndCb),this._onEndCb=t,t&&this._domAudio.addEventListener("ended",t)}}]),t}(),f4=(p((s4=function(){function t(t){var e=this;this._domAudio=void 0,this._state=e4.INIT,this._onEnded=void 0,this._eventTarget=new Ku,this._operationQueue=[],this._domAudio=t,SN.on(vN.EVENT_PAUSE,this._onInterruptedBegin,this),SN.on(vN.EVENT_RESUME,this._onInterruptedEnd,this),this._onEnded=function(){e.seek(0).catch((function(){})),e._state=e4.INIT,e._eventTarget.emit($5.ENDED)},this._domAudio.addEventListener("ended",this._onEnded)}var e=t.prototype;return e.destroy=function(){SN.off(vN.EVENT_PAUSE,this._onInterruptedBegin,this),SN.off(vN.EVENT_RESUME,this._onInterruptedEnd,this),this._domAudio.removeEventListener("ended",this._onEnded),this._domAudio=null},t.load=function(e){return new Promise((function(i){t.loadNative(e).then((function(e){i(new t(e))})).catch((function(){}))}))},t.loadNative=function(t){return new Promise((function(e,i){var n=document.createElement("audio"),r="canplaythrough";nl.os===$u.IOS?r="loadedmetadata":nl.browserType===Ju.FIREFOX&&(r="canplay");var s=setTimeout((function(){0===n.readyState?h():a()}),8e3),o=function(){clearTimeout(s),n.removeEventListener(r,a,!1),n.removeEventListener("error",h,!1)},a=function(){o(),e(n)},h=function(){o(),i("load audio failure - "+t)};n.addEventListener(r,a,!1),n.addEventListener("error",h,!1),n.src=t}))},t.loadOneShotAudio=function(e,i){return new Promise((function(n,r){t.loadNative(e).then((function(t){var e=new d4(t,i);n(e)})).catch(r)}))},e._onInterruptedBegin=function(){var t=this;this._state===e4.PLAYING&&this.pause().then((function(){t._state=e4.INTERRUPTED,t._eventTarget.emit($5.INTERRUPTION_BEGIN)})).catch((function(){}))},e._onInterruptedEnd=function(){var t=this;this._state===e4.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit($5.INTERRUPTION_END)})).catch((function(){}))},e.getPCMData=function(){},e.seek=function(t){return t=xi(t,0,this.duration),this._domAudio.currentTime=t,Promise.resolve()},e.play=function(){var t=this;return new Promise((function(e){l4(t._domAudio).then((function(){t._state=e4.PLAYING,e()})).catch((function(){}))}))},e.pause=function(){return this._domAudio.pause(),this._state=e4.PAUSED,Promise.resolve()},e.stop=function(){var t=this;return new Promise((function(e){t._domAudio.pause(),t._domAudio.currentTime=0,t._state=e4.STOPPED,e()}))},e.onInterruptionBegin=function(t){this._eventTarget.on($5.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off($5.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on($5.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off($5.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on($5.ENDED,t)},e.offEnded=function(t){this._eventTarget.off($5.ENDED,t)},n(t,[{key:"src",get:function(){return this._domAudio?this._domAudio.src:""}},{key:"type",get:function(){return t4.DOM_AUDIO}},{key:"state",get:function(){return this._state}},{key:"loop",get:function(){return this._domAudio.loop},set:function(t){this._domAudio.loop=t}},{key:"volume",get:function(){return this._domAudio.volume},set:function(t){t=Ri(t),this._domAudio.volume=t}},{key:"duration",get:function(){return this._domAudio.duration}},{key:"currentTime",get:function(){return this._domAudio.currentTime}},{key:"sampleRate",get:function(){return 0}}]),t}()).prototype,"seek",[u4],Object.getOwnPropertyDescriptor(s4.prototype,"seek"),s4.prototype),p(s4.prototype,"play",[u4],Object.getOwnPropertyDescriptor(s4.prototype,"play"),s4.prototype),p(s4.prototype,"pause",[u4],Object.getOwnPropertyDescriptor(s4.prototype,"pause"),s4.prototype),p(s4.prototype,"stop",[u4],Object.getOwnPropertyDescriptor(s4.prototype,"stop"),s4.prototype),s4),p4=function(){function t(t){this._nativeAudio=void 0,this._startTime=0,this._startOffset=0,this._isPaused=!0,this._nativeAudio=t}var e=t.prototype;return e.destroy=function(){this._nativeAudio=void 0},e._now=function(){return performance.now()/1e3},e._calculateCurrentTime=function(){var t=this._now()-this._startTime,e=this._startOffset+t;return e>=this.duration&&(this._startTime=this._now(),this._startOffset=0),e%this.duration},e.start=function(){this._isPaused=!1,this._startTime=this._now()},e.pause=function(){this._isPaused||(this._isPaused=!0,this._startOffset=this._calculateCurrentTime())},e.stop=function(){this._isPaused=!0,this._startOffset=0},e.seek=function(t){this._startTime=this._now(),this._startOffset=xi(t,0,this.duration)},n(t,[{key:"duration",get:function(){return this._nativeAudio.duration}},{key:"currentTime",get:function(){return this._isPaused?this._startOffset:this._calculateCurrentTime()}}]),t}(),m4=new(function(){function t(){this._audioBufferDataMap={}}var e=t.prototype;return e.addCache=function(t,e){this._audioBufferDataMap[t]?console.warn("Audio buffer "+t+" has been cached"):this._audioBufferDataMap[t]={usedCount:1,audioBuffer:e}},e.retainCache=function(t){var e=this._audioBufferDataMap[t];e?e.usedCount++:console.warn("Audio buffer cache "+t+" has not been added.")},e.getCache=function(t){var e=this._audioBufferDataMap[t];return null==e?void 0:e.audioBuffer},e.tryReleasingCache=function(t){var e=this._audioBufferDataMap[t];e?--e.usedCount<=0&&delete this._audioBufferDataMap[t]:console.warn("Audio buffer cache "+t+" has not been added.")},t}()),g4=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,y4="on-context-running",v4=function(){function t(){var t=this;this._eventTarget=void 0,this._context=void 0,this._isRunning=!1,this._context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),this._eventTarget=new Ku,this._context.onstatechange=function(){"running"===t._context.state?(t._isRunning=!0,t._eventTarget.emit(y4)):t._isRunning=!1}}var e=t.prototype;return e.onceRunning=function(t,e){this._eventTarget.once(y4,t,e)},e.offRunning=function(t,e){this._eventTarget.off(y4,t,e)},e.decodeAudioData=function(t){var e=this;return new Promise((function(i){var n=e._context.decodeAudioData(t,(function(t){i(t)}),(function(t){console.error("failed to load Web Audio",t)}));null==n||n.catch((function(t){k("decodeAudioData error",t)}))}))},e.runContext=function(){var t=this;return new Promise((function(e){if(t.isRunning)e();else{var i=t._context;if(i.resume)if(i.resume().catch((function(t){k("runContext error",t)})),"running"!==i.state){var n=document.getElementById("GameCanvas"),r=function t(){i.resume().then((function(){null==n||n.removeEventListener("touchend",t,{capture:!0}),null==n||n.removeEventListener("mouseup",t,{capture:!0}),e()})).catch((function(t){k("onGesture resume error",t)}))};null==n||n.addEventListener("touchend",r,{capture:!0}),null==n||n.addEventListener("mouseup",r,{capture:!0})}else e();else e()}}))},e.createBufferSource=function(t,e){var i=this._context.createBufferSource();return void 0!==t&&(i.buffer=t),void 0!==e&&(i.loop=e),i},e.createGain=function(t){void 0===t&&(t=1);var e=this._context.createGain();return this.setGainValue(e,t),e},e.setGainValue=function(t,e){if(t.gain.setTargetAtTime)try{t.gain.setTargetAtTime(e,this._context.currentTime,0)}catch(i){t.gain.setTargetAtTime(e,this._context.currentTime,.01)}else t.gain.value=e},e.connectContext=function(t){this._context&&t.connect(this._context.destination)},n(t,[{key:"isRunning",get:function(){return this._isRunning}},{key:"currentTime",get:function(){return this._context.currentTime}}]),t}();v4.support=!!g4,v4.support&&(_4=new v4);var S4,T4,A4,b4,E4=function(){function t(t,e,i){this._duration=void 0,this._bufferSourceNode=void 0,this._onPlayCb=void 0,this._currentTimer=0,this._url=void 0,this._onEndCb=void 0,this._duration=t.duration,this._url=i,this._bufferSourceNode=_4.createBufferSource(t,!1);var n=_4.createGain(e);this._bufferSourceNode.connect(n),_4.connectContext(n)}var e=t.prototype;return e.play=function(){var t=this;this._bufferSourceNode.start(),_4.runContext().then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t),t._currentTimer=window.setTimeout((function(){var e;m4.tryReleasingCache(t._url),null===(e=t.onEnd)||void 0===e||e.call(t)}),1e3*t._duration)})).catch((function(t){k("play error",t)}))},e.stop=function(){clearTimeout(this._currentTimer),m4.tryReleasingCache(this._url),this._bufferSourceNode.stop(),this._bufferSourceNode.disconnect(),this._bufferSourceNode.buffer=null},n(t,[{key:"onPlay",get:function(){return this._onPlayCb},set:function(t){this._onPlayCb=t}},{key:"onEnd",get:function(){return this._onEndCb},set:function(t){this._onEndCb=t}}]),t}(),C4=(p((c4=function(){function t(t,e){this._src=void 0,this._audioBuffer=void 0,this._sourceNode=void 0,this._gainNode=void 0,this._currentTimer=0,this._volume=1,this._loop=!1,this._state=e4.INIT,this._audioTimer=void 0,this._runningCallback=void 0,this._eventTarget=new Ku,this._operationQueue=[],this._audioBuffer=t,this._audioTimer=new p4(t),this._gainNode=_4.createGain(),_4.connectContext(this._gainNode),this._src=e,SN.on(vN.EVENT_PAUSE,this._onInterruptedBegin,this),SN.on(vN.EVENT_RESUME,this._onInterruptedEnd,this)}var e=t.prototype;return e.destroy=function(){window.clearTimeout(this._currentTimer),this._audioTimer.destroy(),this._audioBuffer&&(this._audioBuffer=null),m4.tryReleasingCache(this._src),SN.off(vN.EVENT_PAUSE,this._onInterruptedBegin,this),SN.off(vN.EVENT_RESUME,this._onInterruptedEnd,this),this.offRunning()},t.load=function(e){return new Promise((function(i){t.loadNative(e).then((function(n){i(new t(n,e))})).catch((function(t){k("load error",e,t)}))}))},t.loadNative=function(t){return new Promise((function(e,i){var n=m4.getCache(t);if(n)return m4.retainCache(t),void e(n);var r=new XMLHttpRequest,s="load audio failed: "+t+", status: ";r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=function(){200===r.status||0===r.status?_4.decodeAudioData(r.response).then((function(i){m4.addCache(t,i),e(i)})).catch((function(e){k("loadNative error",t,e)})):i(new Error(""+s+r.status+"(no response)"))},r.onerror=function(){i(new Error(""+s+r.status+"(error)"))},r.ontimeout=function(){i(new Error(""+s+r.status+"(time out)"))},r.onabort=function(){i(new Error(""+s+r.status+"(abort)"))},r.send(null)}))},t.loadOneShotAudio=function(e,i){return new Promise((function(n,r){t.loadNative(e).then((function(t){var r=new E4(t,i,e);n(r)})).catch(r)}))},e.getPCMData=function(t){return new o4(this._audioBuffer.getChannelData(t),1)},e._onInterruptedBegin=function(){var t=this;this._state===e4.PLAYING&&this.pause().then((function(){t._state=e4.INTERRUPTED,t._eventTarget.emit($5.INTERRUPTION_BEGIN)})).catch((function(t){k("_onInterruptedBegin error",t)}))},e._onInterruptedEnd=function(){var t=this;this._state===e4.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit($5.INTERRUPTION_END)})).catch((function(t){k("_onInterruptedEnd error",t)}))},e.offRunning=function(){this._runningCallback&&(_4.offRunning(this._runningCallback),this._runningCallback=void 0)},e.seek=function(t){var e=this;return new Promise((function(i){e.offRunning(),e._audioTimer.seek(t),e._state===e4.PLAYING?e._doPlay().then(i).catch((function(t){k("seek error",t)})):i()}))},e.play=function(){return this.offRunning(),this._doPlay()},e._doPlay=function(){var t=this;return new Promise((function(e){_4.isRunning?(t._startSourceNode(),e()):(t.offRunning(),t._runningCallback=function(){t._startSourceNode(),e()},_4.onceRunning(t._runningCallback),_4.runContext().catch((function(t){k("doPlay error",t)})))}))},e._startSourceNode=function(){var t=this;this._stopSourceNode(),this._sourceNode=_4.createBufferSource(this._audioBuffer,this.loop),this._sourceNode.connect(this._gainNode),this._sourceNode.loop=this._loop,this._sourceNode.start(0,this._audioTimer.currentTime),this._state=e4.PLAYING,this._audioTimer.start(),window.clearTimeout(this._currentTimer),this._currentTimer=window.setTimeout((function e(){t.loop?t._currentTimer=window.setTimeout(e,1e3*t._audioBuffer.duration):(t._audioTimer.stop(),t._eventTarget.emit($5.ENDED),t._state=e4.INIT)}),1e3*(this._audioBuffer.duration-this._audioTimer.currentTime))},e._stopSourceNode=function(){try{this._sourceNode&&(this._sourceNode.stop(),this._sourceNode.disconnect(),this._sourceNode.buffer=null,this._sourceNode=void 0)}catch(t){}},e.pause=function(){return this.offRunning(),this._state===e4.PLAYING&&this._sourceNode?(this._audioTimer.pause(),this._state=e4.PAUSED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.stop=function(){return this.offRunning(),this._sourceNode?(this._audioTimer.stop(),this._state=e4.STOPPED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):(this._audioTimer.stop(),this._state=e4.STOPPED,Promise.resolve())},e.onInterruptionBegin=function(t){this._eventTarget.on($5.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off($5.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on($5.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off($5.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on($5.ENDED,t)},e.offEnded=function(t){this._eventTarget.off($5.ENDED,t)},n(t,[{key:"sampleRate",get:function(){return this._audioBuffer.sampleRate}},{key:"src",get:function(){return this._src}},{key:"type",get:function(){return t4.WEB_AUDIO}},{key:"state",get:function(){return this._state}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._sourceNode&&(this._sourceNode.loop=t)}},{key:"volume",get:function(){return this._volume},set:function(t){t=Ri(t),this._volume=t,_4.setGainValue(this._gainNode,t)}},{key:"duration",get:function(){return this._audioBuffer.duration}},{key:"currentTime",get:function(){return this._audioTimer.currentTime}}]),t}()).prototype,"seek",[u4],Object.getOwnPropertyDescriptor(c4.prototype,"seek"),c4.prototype),p(c4.prototype,"play",[u4],Object.getOwnPropertyDescriptor(c4.prototype,"play"),c4.prototype),p(c4.prototype,"pause",[u4],Object.getOwnPropertyDescriptor(c4.prototype,"pause"),c4.prototype),p(c4.prototype,"stop",[u4],Object.getOwnPropertyDescriptor(c4.prototype,"stop"),c4.prototype),c4),w4=function(){function t(t){this._audio=void 0,this._audio=t}var e=t.prototype;return e.play=function(){this._audio.play()},e.stop=function(){this._audio.stop()},n(t,[{key:"onPlay",get:function(){return this._audio.onPlay},set:function(t){this._audio.onPlay=t}},{key:"onEnd",get:function(){return this._audio.onEnd},set:function(t){this._audio.onEnd=t}}]),t}(),x4=function(){function t(t){this._player=void 0,this._player=t}t.load=function(e,i){return new Promise((function(n){(null==i?void 0:i.audioLoadMode)!==t4.DOM_AUDIO&&v4.support?C4.load(e).then((function(e){n(new t(e))})).catch((function(){})):(v4.support||Y(5201),f4.load(e).then((function(e){n(new t(e))})).catch((function(){})))}))};var e=t.prototype;return e.destroy=function(){this._player.destroy()},t.loadNative=function(t,e){return(null==e?void 0:e.audioLoadMode)!==t4.DOM_AUDIO&&v4.support?C4.loadNative(t):(v4.support||Y(5201),f4.loadNative(t))},t.loadOneShotAudio=function(t,e,i){return new Promise((function(n,r){(null==i?void 0:i.audioLoadMode)!==t4.DOM_AUDIO&&v4.support?C4.loadOneShotAudio(t,e).then((function(t){n(new w4(t))})).catch(r):(v4.support||Y(5201),f4.loadOneShotAudio(t,e).then((function(t){n(new w4(t))})).catch(r))}))},e.getPCMData=function(t){return this._player.getPCMData(t)},e.seek=function(t){return this._player.seek(t)},e.play=function(){return this._player.play()},e.pause=function(){return this._player.pause()},e.stop=function(){return this._player.stop()},e.onInterruptionBegin=function(t){this._player.onInterruptionBegin(t)},e.offInterruptionBegin=function(t){this._player.offInterruptionBegin(t)},e.onInterruptionEnd=function(t){this._player.onInterruptionEnd(t)},e.offInterruptionEnd=function(t){this._player.offInterruptionEnd(t)},e.onEnded=function(t){this._player.onEnded(t)},e.offEnded=function(t){this._player.offEnded(t)},n(t,[{key:"src",get:function(){return this._player.src}},{key:"type",get:function(){return this._player.type}},{key:"state",get:function(){return this._player.state}},{key:"loop",get:function(){return this._player.loop},set:function(t){this._player.loop=t}},{key:"volume",get:function(){return this._player.volume},set:function(t){this._player.volume=t}},{key:"duration",get:function(){return this._player.duration}},{key:"currentTime",get:function(){return this._player.currentTime}},{key:"sampleRate",get:function(){return this._player.sampleRate}}]),t}();x4.maxAudioChannel=24;var R4=t("aA",qs("cc.AudioClip")(((b4=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._duration=A4&&A4(),e._loadMode=t4.UNKNOWN_AUDIO,e._meta=null,e._player=null,e}s(e,t);var i=e.prototype;return i.destroy=function(){var e,i=t.prototype.destroy.call(this);return null===(e=this._player)||void 0===e||e.destroy(),this._player=null,this._meta&&(this._meta.player=null),i},i.validate=function(){return!!this._meta},i.getDuration=function(){return this._duration?this._duration:this._meta?this._meta.duration:0},i.getCurrentTime=function(){return this._player?this._player.currentTime:0},i.getVolume=function(){return this._player?this._player.volume:0},i.getLoop=function(){return!!this._player&&this._player.loop},i.setCurrentTime=function(t){var e;null===(e=this._player)||void 0===e||e.seek(t).catch((function(){}))},i.setVolume=function(t){this._player&&(this._player.volume=t)},i.setLoop=function(t){this._player&&(this._player.loop=t)},i.play=function(){var t;null===(t=this._player)||void 0===t||t.play().catch((function(){}))},i.pause=function(){var t;null===(t=this._player)||void 0===t||t.pause().catch((function(){}))},i.stop=function(){var t;null===(t=this._player)||void 0===t||t.stop().catch((function(){}))},i.playOneShot=function(t){void 0===t&&(t=1),this._nativeAsset&&x4.loadOneShotAudio(this._nativeAsset.url,t).then((function(t){t.play()})).catch((function(){}))},n(e,[{key:"duration",set:function(t){this._duration=t}},{key:"_nativeAsset",get:function(){return this._meta},set:function(t){this._meta=t,t?(this._loadMode=t.type,this._player=t.player):(this._meta=null,this._loadMode=t4.UNKNOWN_AUDIO,this._duration=0)}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,audioLoadMode:this.loadMode,ext:this._native,__isNative__:!0}}},{key:"loadMode",get:function(){return this._loadMode}},{key:"state",get:function(){return this._player?this._player.state:e4.INIT}}]),e}(of)).AudioType=t4,A4=ks((T4=b4).prototype,"_duration",[io],(function(){return 0})),p(T4.prototype,"_nativeDep",[Ro],Object.getOwnPropertyDescriptor(T4.prototype,"_nativeDep"),T4.prototype),S4=T4))||S4);function I4(t,e,i){x4.load(t,{audioLoadMode:e.audioLoadMode}).then((function(e){var n={player:e,url:t,duration:e.duration,type:e.type};i(null,n)})).catch((function(t){i(t)}))}function B4(t,e,i,n){var r=new R4;r._nativeUrl=t,r._nativeAsset=e,r.duration=e.duration,n(null,r)}v.AudioClip=R4,bS.register({".mp3":I4,".ogg":I4,".wav":I4,".m4a":I4}),LS.register({".mp3":B4,".ogg":B4,".wav":B4,".m4a":B4});var D4,P4,O4,M4,L4,N4,F4,k4,V4,G4,U4,z4,H4=new(function(){function t(){this._oneShotAudioInfoList=[],this._audioPlayerInfoList=[]}var e=t.prototype;return e._findIndex=function(t,e){return t.findIndex((function(t){return t.audio===e}))},e._tryAddPlaying=function(t,e){var i=this._findIndex(t,e);return i>-1?(t[i].playTime=performance.now(),!1):(t.push({audio:e,playTime:performance.now()}),!0)},e.addPlaying=function(t){t instanceof x4?this._tryAddPlaying(this._audioPlayerInfoList,t):this._tryAddPlaying(this._oneShotAudioInfoList,t)},e._tryRemovePlaying=function(t,e){var i=this._findIndex(t,e);return-1!==i&&(ae(t,i),!0)},e.removePlaying=function(t){t instanceof x4?this._tryRemovePlaying(this._audioPlayerInfoList,t):this._tryRemovePlaying(this._oneShotAudioInfoList,t)},e.discardOnePlayingIfNeeded=function(){var t;this._audioPlayerInfoList.length+this._oneShotAudioInfoList.length<x4.maxAudioChannel||(this._oneShotAudioInfoList.length>0?this._oneShotAudioInfoList.forEach((function(e){(!t||e.playTime<t.playTime)&&(t=e)})):this._audioPlayerInfoList.forEach((function(e){(!t||e.playTime<t.playTime)&&(t=e)})),t&&(t.audio.stop(),this.removePlaying(t.audio)))},e.pause=function(){this._oneShotAudioInfoList.forEach((function(t){t.audio.stop()})),this._audioPlayerInfoList.forEach((function(t){t.audio.pause().catch((function(){}))}))},e.resume=function(){this._audioPlayerInfoList.forEach((function(t){t.audio.play().catch((function(){}))}))},t}()),W4="audiosource-loaded";!function(t){t.STARTED="started",t.ENDED="ended"}(U4||(U4={})),function(t){t.PLAY="play",t.STOP="stop",t.PAUSE="pause",t.SEEK="seek"}(z4||(z4={}));var j4=t("az",(D4=qs("cc.AudioSource"),P4=xo(R4),O4=xo(R4),D4(((G4=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._clip=N4&&N4(),e._player=null,e._hasRegisterListener=!1,e._loop=F4&&F4(),e._playOnAwake=k4&&k4(),e._volume=V4&&V4(),e._cachedCurrentTime=-1,e._operationsBeforeLoading=[],e._isLoaded=!1,e._lastSetClip=null,e}s(e,t);var i=e.prototype;return i._resetPlayer=function(){this._player&&(H4.removePlaying(this._player),this._unregisterListener(),this._player.destroy(),this._player=null)},i._syncPlayer=function(){var t=this,e=this._clip;if(this._lastSetClip!==e)return e?void(e._nativeAsset?(this._isLoaded=!1,this._lastSetClip=e,this._operationsBeforeLoading.length=0,x4.load(e._nativeAsset.url,{audioLoadMode:e.loadMode}).then((function(i){var n;t._lastSetClip===e?(t._isLoaded=!0,t._resetPlayer(),t._player=i,t._syncStates(),null===(n=t.node)||void 0===n||n.emit(W4)):i.destroy()})).catch((function(){}))):console.error("Invalid audio clip")):(this._lastSetClip=null,void this._resetPlayer())},i._registerListener=function(){var t=this;if(!this._hasRegisterListener&&this._player){var e=this._player;e.onEnded((function(){var i;H4.removePlaying(e),null===(i=t.node)||void 0===i||i.emit(U4.ENDED,t)})),e.onInterruptionBegin((function(){H4.removePlaying(e)})),e.onInterruptionEnd((function(){t._player===e&&H4.addPlaying(e)})),this._hasRegisterListener=!0}},i._unregisterListener=function(){this._player&&this._hasRegisterListener&&(this._player.offEnded(),this._player.offInterruptionBegin(),this._player.offInterruptionEnd(),this._hasRegisterListener=!1)},i.onLoad=function(){this._syncPlayer()},i.onEnable=function(){this._playOnAwake&&!this.playing&&this.play()},i.onDisable=function(){var t=this._getRootNode();null!=t&&t._persistNode||this.pause()},i.onDestroy=function(){this.stop(),this.clip=null},i.getPCMData=function(t){var e=this;return new Promise((function(i){if(0!==t&&1!==t)return console.warn("Only support channel index 0 or 1 to get buffer"),void i(void 0);var n;e._player?i(e._player.getPCMData(t)):null===(n=e.node)||void 0===n||n.once(W4,(function(){var n;i(null===(n=e._player)||void 0===n?void 0:n.getPCMData(t))}))}))},i.getSampleRate=function(){var t=this;return new Promise((function(e){var i;t._player?e(t._player.sampleRate):null===(i=t.node)||void 0===i||i.once(W4,(function(){e(t._player.sampleRate)}))}))},i._getRootNode=function(){for(var t,e,i=this.node,n=null===(t=i)||void 0===t||null===(e=t.parent)||void 0===e?void 0:e.parent;n;){var r,s,o;n=null===(s=i=null===(r=i)||void 0===r?void 0:r.parent)||void 0===s||null===(o=s.parent)||void 0===o?void 0:o.parent}return i},i.play=function(){var t=this;if(this._isLoaded||!this.clip){var e;this._registerListener(),H4.discardOnePlayingIfNeeded(),this.state===e4.PLAYING&&(null===(e=this._player)||void 0===e||e.stop().catch((function(){})));var i=this._player;i&&(i.play().then((function(){var e;null===(e=t.node)||void 0===e||e.emit(U4.STARTED,t)})).catch((function(){H4.removePlaying(i)})),H4.addPlaying(i))}else this._operationsBeforeLoading.push({op:z4.PLAY,params:null})},i.pause=function(){var t;this._isLoaded||!this.clip?null===(t=this._player)||void 0===t||t.pause().catch((function(){})):this._operationsBeforeLoading.push({op:z4.PAUSE,params:null})},i.stop=function(){this._isLoaded||!this.clip?this._player&&(this._player.stop().catch((function(){})),H4.removePlaying(this._player)):this._operationsBeforeLoading.push({op:z4.STOP,params:null})},i.playOneShot=function(t,e){var i;void 0===e&&(e=1),t._nativeAsset?x4.loadOneShotAudio(t._nativeAsset.url,this._volume*e,{audioLoadMode:t.loadMode}).then((function(t){i=t,H4.discardOnePlayingIfNeeded(),t.onEnd=function(){H4.removePlaying(t)},t.play(),H4.addPlaying(t)})).catch((function(){i&&H4.removePlaying(i)})):console.error("Invalid audio clip")},i._syncStates=function(){var t=this;this._player&&(this._player.loop=this._loop,this._player.volume=this._volume,this._operationsBeforeLoading.forEach((function(e){var i;e.op===z4.SEEK?(t._cachedCurrentTime=e.params&&e.params[0],t._player&&t._player.seek(t._cachedCurrentTime).catch((function(){}))):null===(i=t[e.op])||void 0===i||i.call(t)})),this._operationsBeforeLoading.length=0)},n(e,[{key:"clip",get:function(){return this._clip},set:function(t){t!==this._clip&&(this._clip=t,this._syncPlayer())}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._player&&(this._player.loop=t)}},{key:"playOnAwake",get:function(){return this._playOnAwake},set:function(t){this._playOnAwake=t}},{key:"volume",get:function(){return this._volume},set:function(t){Number.isNaN(t)?console.warn("illegal audio volume!"):(t=xi(t,0,1),this._player?(this._player.volume=t,this._volume=this._player.volume):this._volume=t)}},{key:"currentTime",get:function(){return this._player?this._player.currentTime:this._cachedCurrentTime<0?0:this._cachedCurrentTime},set:function(t){var e;Number.isNaN(t)?console.warn("illegal audio time!"):(t=xi(t,0,this.duration),this._isLoaded||!this.clip?(this._cachedCurrentTime=t,null===(e=this._player)||void 0===e||e.seek(this._cachedCurrentTime).catch((function(){}))):this._operationsBeforeLoading.push({op:z4.SEEK,params:[t]}))}},{key:"duration",get:function(){var t,e;return null!==(t=null===(e=this._clip)||void 0===e?void 0:e.getDuration())&&void 0!==t?t:this._player?this._player.duration:0}},{key:"state",get:function(){return this._player?this._player.state:e4.INIT}},{key:"playing",get:function(){return this.state===e.AudioState.PLAYING}}],[{key:"maxAudioChannel",get:function(){return x4.maxAudioChannel}}]),e}(rp)).AudioState=e4,G4.EventType=U4,N4=ks((L4=G4).prototype,"_clip",[P4],(function(){return null})),F4=ks(L4.prototype,"_loop",[io],(function(){return!1})),k4=ks(L4.prototype,"_playOnAwake",[io],(function(){return!0})),V4=ks(L4.prototype,"_volume",[io],(function(){return 1})),p(L4.prototype,"clip",[O4],Object.getOwnPropertyDescriptor(L4.prototype,"clip"),L4.prototype),M4=L4))||M4));function X4(t){for(var e=t.scene.batches,i=0;e&&i<e.length;i++){var n=e[i];if(t.visibility&n.visFlags)return!0}return!1}nt(R4,"AudioClip",[{name:"PlayingState",newName:"AudioState",target:j4,targetName:"AudioSource"}]),st(R4.prototype,"AudioClip.prototype",["state","play","pause","stop","playOneShot","setCurrentTime","setVolume","setLoop","getCurrentTime","getVolume","getLoop"].map((function(t){return{name:t,suggest:"please use AudioSource.prototype."+t+" instead"}}))),v.AudioSourceComponent=j4,Qt(j4,"cc.AudioSourceComponent"),v.log=F,v.warn=k,v.error=V,v.assert=G,v._throw=H,v.logID=X,v.warnID=Y,v.errorID=J,v.assertID=$,v.debug=ht,v.path={join:al,extname:hl,mainFileName:ul,basename:ll,dirname:cl,changeExtname:_l,changeBasename:dl,_normalize:fl,stripSep:pl,get sep(){return ml()}};var q4=function(t,e,i,n,r){this.camera=void 0,this.id=4294967295,this.windowID=4294967295,this.width=0,this.height=0,this.camera=t,this.id=e,this.windowID=i,this.width=n,this.height=r},Y4=new Map,K4=new Map;function J4(t){var e=K4.get(t.window);return void 0===e&&(e=K4.size,K4.set(t.window,e)),e}function Q4(t,e,i,n){var r=Y4.get(e);if(void 0!==r){var s=e.window.width,o=e.window.height;0===s&&(s=1),0===o&&(o=1);var a=J4(e);return r.width=s,r.height=o,r.windowID=a,n(t,r),r}var h=J4(e);return i(t,r=new q4(e,Y4.size,h,e.window.width?e.window.width:1,e.window.height?e.window.height:1)),Y4.set(e,r),r}function Z4(t,e,i,n){var r=i,s=n,o=e,a=t.device;if(!t.containsResource(o)){var h=Zy(a)?Hl.R32F:Hl.RGBA8;t.addRenderTarget(o,h,r,s,cR.MANAGED),t.addDepthStencil(o+"Depth",Hl.DEPTH_STENCIL,r,s,cR.MANAGED)}t.updateRenderTarget(o,r,s),t.updateDepthStencil(o+"Depth",r,s)}var $4=new WR;function t8(t,e){var i=e.camera;kR(t,i);var n=t,r=n.pipelineSceneData.shadows,s=t.pipelineSceneData.validPunctualLights,o=t.pipelineSceneData.shadows;if($4.reset(),!r.enabled||r.type!==IT.ShadowMap)return $4;$4.shadowEnabled=!0;for(var a=$4.validLights,h=0,u=0;h<r.maxReceived&&u<s.length;){var l=s[u];l.type===sR.SPOT&&l.shadowEnabled&&(a.push(l),h++),u++}var c=i.scene.mainLight,_=o.size.x,d=o.size.y;if(c&&c.shadowEnabled)if($4.mainLightShadowNames[0]="MainLightShadow"+e.id,c.shadowFixedArea)Z4(t,$4.mainLightShadowNames[0],_,d);else{var f=n.pipelineSceneData.csmSupported?c.csmLevel:1;$4.mainLightShadowNames[0]="MainLightShadow"+e.id;for(var p=0;p<f;p++)Z4(t,$4.mainLightShadowNames[0],_,d)}for(var m=0;m<a.length;m++){a[m];var g="SpotLightShadow"+m.toString()+e.id;$4.spotLightShadowNames[m]=g,Z4(t,$4.spotLightShadowNames[m],_,d)}return $4}var e8,i8=t8;function n8(t,e,i,n,r,s,o){var a=s,h=o,u=zR(i,s,o,n,r);s=u.width,o=u.height;var l=t;r||((e8=e.addRenderPass(s,o,"default")).name=t,e8.setViewport(new Uc(0,0,a,h)),e8.addRenderTarget(l,lc.CLEAR,cc.STORE,new zc(1,1,1,i.clearColor.w)),e8.addDepthStencil(l+"Depth",lc.CLEAR,cc.DISCARD,i.clearDepth,i.clearStencil,Cc.DEPTH_STENCIL));var c=e8.addQueue(_R.RENDER_OPAQUE,"shadow-caster");c.addSceneOfCamera(i,new CR(n,r),mR.SHADOW_CASTER),c.setViewport(new Uc(u.x,u.y,u.width,u.height))}function r8(t,e){if($4.shadowEnabled){var i=e.camera,n=t.pipelineSceneData.shadows,r=n.size.x,s=n.size.y,o=i.scene.mainLight;if(o&&o.shadowEnabled)if($4.mainLightShadowNames[0]="MainLightShadow"+e.id,o.shadowFixedArea)n8($4.mainLightShadowNames[0],t,i,o,0,r,s);else{var a=t.pipelineSceneData.csmSupported?o.csmLevel:1;$4.mainLightShadowNames[0]="MainLightShadow"+e.id;for(var h=0;h<a;h++)n8($4.mainLightShadowNames[0],t,i,o,h,r,s)}for(var u=0;u<$4.validLights.length;u++){var l=$4.validLights[u],c="SpotLightShadow"+u.toString()+e.id;$4.spotLightShadowNames[u]=c,n8(c,t,i,l,0,r,s)}}}function s8(t,e,i,n){var r=zR(e.camera,e.camera.window.width,e.camera.window.height),s=r.width,o=r.height,a=t.addRenderPass(s,o,"default"),h=e.camera;a.addRenderTarget(i,lc.LOAD,cc.STORE),a.addDepthStencil(u8.ds,lc.LOAD,cc.DISCARD);for(var u,l=d($4.mainLightShadowNames);!(u=l()).done;){var c=u.value;t.containsResource(c)&&a.addTexture(c,"cc_shadowMap")}for(var _,f=d($4.spotLightShadowNames);!(_=f()).done;){var p=_.value;t.containsResource(p)&&a.addTexture(p,"cc_spotShadowMap")}var m=mR.OPAQUE_OBJECT|mR.PLANAR_SHADOW|mR.CUTOUT_OBJECT|mR.DRAW_INSTANCING;m|=n?mR.CLUSTERED_LIGHTING:mR.DEFAULT_LIGHTING,a.addQueue(_R.RENDER_OPAQUE,"deferred-forward").addSceneOfCamera(h,new CR,m),a.addQueue(_R.RENDER_TRANSPARENT,"deferred-forward").addSceneOfCamera(h,new CR,mR.TRANSPARENT_OBJECT|mR.GEOMETRY)}function o8(t,e,i,n){void 0===i&&(i=!1),void 0===n&&(n=!0),r8(t,e);var r=e.id,s=zR(e.camera,e.camera.window.width,e.camera.window.height),o=s.width,a=s.height,h=t.addRenderPass(o,a,"default");h.name="ForwardPass"+r,h.setViewport(new Uc(s.x,s.y,o,a));for(var u,l=d($4.mainLightShadowNames);!(u=l()).done;){var c=u.value;t.containsResource(c)&&h.addTexture(c,"cc_shadowMap")}for(var _,f=d($4.spotLightShadowNames);!(_=f()).done;){var p=_.value;t.containsResource(p)&&h.addTexture(p,"cc_spotShadowMap")}var m=e.camera;h.addRenderTarget("ForwardColor"+e.id,i?lc.CLEAR:UR(m.clearFlag,yR.RENDER_TARGET),cc.STORE,new zc(m.clearColor.x,m.clearColor.y,m.clearColor.z,m.clearColor.w)),h.addDepthStencil("ForwardDepthStencil"+e.id,i?lc.CLEAR:UR(m.clearFlag,yR.DEPTH_STENCIL),i?cc.DISCARD:cc.STORE,m.clearDepth,m.clearStencil,m.clearFlag),h.addQueue(_R.RENDER_OPAQUE).addSceneOfCamera(m,new CR,mR.OPAQUE_OBJECT|mR.PLANAR_SHADOW|mR.CUTOUT_OBJECT|mR.DEFAULT_LIGHTING|mR.DRAW_INSTANCING);var g=mR.TRANSPARENT_OBJECT|mR.GEOMETRY;return i||(g|=mR.UI,h.showStatistics=!0),n&&h.addQueue(_R.RENDER_TRANSPARENT).addSceneOfCamera(m,new CR,g),{rtName:"ForwardColor"+e.id,dsName:"ForwardDepthStencil"+e.id}}var a8,h8,u8=new function(){this.color=void 0,this.normal=void 0,this.emissive=void 0,this.ds=void 0};function l8(t,e){var i=e.camera,n=zR(i,i.window.width,i.window.height),r=n.width,s=n.height,o=u8.color,a=u8.normal,h=u8.emissive,u=u8.ds,l=t.addRenderPass(r,s,"gbuffer");l.name="CameraGBufferPass"+e.id,l.setViewport(new Uc(n.x,n.y,r,s));var c=new zc(0,0,0,0);return i.clearFlag&Cc.COLOR&&(t.pipelineSceneData.isHDR?dT(c,i.clearColor):(c.x=i.clearColor.x,c.y=i.clearColor.y,c.z=i.clearColor.z)),l.addRenderTarget(o,lc.CLEAR,cc.STORE,c),l.addRenderTarget(h,lc.CLEAR,cc.STORE,new zc(0,0,0,0)),l.addRenderTarget(a,lc.CLEAR,cc.STORE,new zc(0,0,0,0)),l.addDepthStencil(u,lc.CLEAR,cc.STORE,i.clearDepth,i.clearStencil,i.clearFlag),l.addQueue(_R.RENDER_OPAQUE,"gbuffer").addSceneOfCamera(i,new CR,mR.OPAQUE_OBJECT|mR.CUTOUT_OBJECT),l}function c8(t,e,i){r8(t,e),a8||(a8=new jR(i));var n=t,r=e.camera,s=zR(r,r.window.width,r.window.height),o=s.width,a=s.height,h=GR(r),u="deferredLightingPassRTName"+e.id,l=n.addRenderPass(o,a,"deferred-lighting");l.name="CameraLightingPass"+e.id,l.setViewport(new Uc(s.x,s.y,o,a));for(var c,_=d($4.mainLightShadowNames);!(c=_()).done;){var f=c.value;n.containsResource(f)&&l.addTexture(f,"cc_shadowMap")}for(var p,m=d($4.spotLightShadowNames);!(p=m()).done;){var g=p.value;n.containsResource(g)&&l.addTexture(g,"cc_spotShadowMap")}n.containsResource(u8.color)&&(l.addTexture(u8.color,"albedoMap"),l.addTexture(u8.normal,"normalMap"),l.addTexture(u8.emissive,"emissiveMap"),l.addTexture(u8.ds,"depthStencil"));var y="clusterLightBuffer"+h,v="clusterLightIndicesBuffer"+h,S="clusterLightGridBuffer"+h;n.containsResource(y)&&(l.addStorageBuffer(y,vR.READ,"b_ccLightsBuffer"),l.addStorageBuffer(v,vR.READ,"b_clusterLightIndicesBuffer"),l.addStorageBuffer(S,vR.READ,"b_clusterLightGridBuffer"));var T=new zc(0,0,0,0);return r.clearFlag&Cc.COLOR&&(T.x=r.clearColor.x,T.y=r.clearColor.y,T.z=r.clearColor.z),T.w=0,l.addRenderTarget(u,lc.CLEAR,cc.STORE,T),l.addQueue(_R.RENDER_TRANSPARENT).addCameraQuad(r,a8.deferredLightingMaterial,0,mR.VOLUMETRIC_LIGHTING),{rtName:u}}function _8(t,e,i){h8||(h8=new HR);var n=e.id,r=e.camera,s=zR(r,r.window.width,r.window.height),o=s.width,a=s.height,h="postprocessPassRTName"+n,u="postprocessPassDS"+n,l=t.addRenderPass(o,a,"post-process");l.name="CameraPostprocessPass"+n,l.setViewport(new Uc(s.x,s.y,s.width,s.height)),t.containsResource(i)&&l.addTexture(i,"outputResultMap");var c=new zc(0,0,0,r.clearColor.w);return r.clearFlag&Cc.COLOR&&(c.x=r.clearColor.x,c.y=r.clearColor.y,c.z=r.clearColor.z),l.addRenderTarget(h,UR(r.clearFlag,yR.RENDER_TARGET),cc.STORE,c),l.addDepthStencil(u,UR(r.clearFlag,yR.DEPTH_STENCIL),cc.STORE,r.clearDepth,r.clearStencil,r.clearFlag),l.addQueue(_R.NONE).addCameraQuad(r,h8.postMaterial,0,mR.NONE),ET()===r&&(l.showStatistics=!0),{rtName:h,dsName:u}}function d8(t,e){var i=e.camera,n=zR(i,i.window.width,i.window.height),r=n.width,s=n.height,o="dsUIAndProfilerPassColor"+e.id,a="dsUIAndProfilerPassDS"+e.id,h=t.addRenderPass(r,s,"default");h.name="CameraUIAndProfilerPass"+e.id,h.setViewport(new Uc(n.x,n.y,r,s)),h.addRenderTarget(o,UR(i.clearFlag,yR.RENDER_TARGET),cc.STORE,new zc(i.clearColor.x,i.clearColor.y,i.clearColor.z,i.clearColor.w)),h.addDepthStencil(a,UR(i.clearFlag,yR.DEPTH_STENCIL),cc.STORE,i.clearDepth,i.clearStencil,i.clearFlag);var u=mR.UI;h.addQueue(_R.RENDER_TRANSPARENT).addSceneOfCamera(i,new CR,u),ET()===i&&(h.showStatistics=!0)}new zc(0,0,0,0),t("dx",function(){function t(){}var e=t.prototype;return e.setup=function(t,e){for(var i=0;i<t.length;i++){var n=t[i];null!==n.scene&&(e.update(n),o8(e,Q4(e,n,this.initResource,this.updateResource)))}},e.initResource=function(t,e){!function(t,e,i){void 0===i&&(i=!1);var n=e.camera,r=zR(n,n.window.width,n.window.height),s=r.width,o=r.height;t8(t,e),i?t.addRenderTarget("ForwardColor"+e.id,function(t){var e=t.getMacroBool("CC_USE_FLOAT_OUTPUT");return t.pipelineSceneData.isHDR&&e&&$y(t.device)?Hl.RGBA16F:Hl.RGBA8}(t),s,o,cR.PERSISTENT):t.addRenderWindow("ForwardColor"+e.id,Hl.BGRA8,s,o,e.camera.window),t.addDepthStencil("ForwardDepthStencil"+e.id,Hl.DEPTH_STENCIL,s,o)}(t,e)},e.updateResource=function(t,e){!function(t,e,i){void 0===i&&(i=!1);var n=e.camera,r=zR(n,n.window.width,n.window.height),s=r.width,o=r.height;i8(t,e),i?t.updateRenderTarget("ForwardColor"+e.id,s,o):t.updateRenderWindow("ForwardColor"+e.id,e.camera.window),t.updateDepthStencil("ForwardDepthStencil"+e.id,s,o)}(t,e)},t}()),t("dy",function(){function t(){}var e=t.prototype;return e.setup=function(t,e){for(var i=0;i<t.length;++i){var n=t[i];if(n.scene){e.update(n);var r=e.device.hasFeature(zl.COMPUTE_SHADER),s=n.cameraUsage===Px.GAME||n.cameraUsage===Px.GAME_VIEW,o=Q4(e,n,this.initResource,this.updateResource);if(s)if(X4(n))d8(e,o);else{r&&rI(n,e),l8(e,o);var a=c8(e,o,r);s8(e,o,a.rtName,r),_8(e,o,a.rtName)}else o8(e,o)}}},e.initResource=function(t,e){X4(e.camera)?function(t,e){var i=e.camera,n=zR(i,i.window.width,i.window.height),r=n.width,s=n.height,o="dsUIAndProfilerPassColor"+e.id,a="dsUIAndProfilerPassDS"+e.id;t.addRenderWindow(o,Hl.BGRA8,r,s,i.window),t.addDepthStencil(a,Hl.DEPTH_STENCIL,r,s,cR.MANAGED)}(t,e):(function(t,e){var i=e.camera,n=zR(i,i.window.width,i.window.height),r=n.width,s=n.height,o="gBufferPassColorCamera"+e.id,a="gBufferPassNormal"+e.id,h="gBufferPassEmissive"+e.id,u="gBufferPassDSCamera"+e.id,l=Hl.RGBA16F;t.addRenderTarget(o,l,r,s,cR.MANAGED),t.addRenderTarget(h,l,r,s,cR.MANAGED),t.addRenderTarget(a,l,r,s,cR.MANAGED),t.addDepthStencil(u,Hl.DEPTH_STENCIL,r,s,cR.MANAGED),u8.color=o,u8.normal=a,u8.emissive=h,u8.ds=u}(t,e),function(t,e){t8(t,e);var i=e.camera,n=zR(i,i.window.width,i.window.height),r=n.width,s=n.height,o="deferredLightingPassRTName"+e.id;t.addRenderTarget(o,Hl.RGBA8,r,s,cR.MANAGED)}(t,e),function(t,e){var i=e.id,n=e.camera,r=zR(n,n.window.width,n.window.height),s=r.width,o=r.height,a="postprocessPassRTName"+i,h="postprocessPassDS"+i;t.addRenderWindow(a,Hl.BGRA8,s,o,n.window),t.addDepthStencil(h,Hl.DEPTH_STENCIL,s,o,cR.MANAGED)}(t,e))},e.updateResource=function(t,e){X4(e.camera)?function(t,e){var i=e.camera,n=zR(i,i.window.width,i.window.height),r=n.width,s=n.height,o="dsUIAndProfilerPassColor"+e.id,a="dsUIAndProfilerPassDS"+e.id;t.updateRenderWindow(o,i.window),t.updateDepthStencil(a,r,s)}(t,e):(function(t,e){var i=e.camera,n=zR(i,i.window.width,i.window.height),r=n.width,s=n.height,o="gBufferPassColorCamera"+e.id,a="gBufferPassNormal"+e.id,h="gBufferPassEmissive"+e.id,u="gBufferPassDSCamera"+e.id;t.updateRenderTarget(o,r,s),t.updateRenderTarget(h,r,s),t.updateRenderTarget(a,r,s),t.updateDepthStencil(u,r,s)}(t,e),function(t,e){i8(t,e);var i=e.camera,n=zR(i,i.window.width,i.window.height),r=n.width,s=n.height,o="deferredLightingPassRTName"+e.id;t.updateRenderTarget(o,r,s)}(t,e),function(t,e){var i=e.id,n=e.camera,r=zR(n,n.window.width,n.window.height),s=r.width,o=r.height,a="postprocessPassRTName"+i,h="postprocessPassDS"+i;t.updateRenderWindow(a,n.window),t.updateDepthStencil(h,s,o)}(t,e))},t}());var f8=Ho.Flags.Destroyed,p8=Ho.Flags.PersistentMask,m8=[];function g8(t){var e;if(Wo(t)){if(function(t){return"function"==typeof t._instantiate}(t))return v.game._isCloning=!0,e=t._instantiate(null,!0),v.game._isCloning=!1,e;if(t instanceof v.Asset)throw new TypeError(tt(6903))}return v.game._isCloning=!0,e=y8(t),v.game._isCloning=!1,e}function y8(t,e){var i;v8(t,i=t._iN$t?t._iN$t:t.constructor?new(0,t.constructor):Object.create(null),e);for(var n=0,r=m8.length;n<r;++n)m8[n]._iN$t=null;return m8.length=0,i}function v8(t,e,i){Ct(t,"_iN$t",e,!0),m8.push(t);var n=t.constructor;if(mi(n))!function(t,e,i,n){for(var r=t.__values__,s=0;s<r.length;s++){var o=r[s],a=e[o];if("object"==typeof a&&a){var h=i[o];h instanceof Ae&&h.constructor===a.constructor?h.set(a):i[o]=a._iN$t||S8(a,n)}else i[o]=a}}(n,t,e,i);else for(var r in t)if(t.hasOwnProperty(r)&&(95!==r.charCodeAt(0)||95!==r.charCodeAt(1)||"__type__"===r||"__prefab"===r)){var s=t[r];if("object"==typeof s&&s){if(s===e)continue;e[r]=s._iN$t||S8(s,i)}else e[r]=s}Wo(t)&&(e._objFlags&=p8)}function S8(t,e){if(t instanceof Ae)return t.clone();if(t instanceof v.Asset)return t;var i;if(ArrayBuffer.isView(t)){var n=t.length;i=new t.constructor(n),t._iN$t=i,m8.push(t);for(var r=0;r<n;++r)i[r]=t[r];return i}if(Array.isArray(t)){var s=t.length;i=new Array(s),t._iN$t=i,m8.push(t);for(var o=0;o<s;++o){var a=t[o];i[o]="object"==typeof a&&a?a._iN$t||S8(a,e):a}return i}if(t._objFlags&f8)return null;var h=t.constructor;if(mi(h)){if(e)if(e instanceof rp){if(t instanceof Jm||t instanceof rp)return t}else if(e instanceof Jm)if(t instanceof Jm){if(!t.isChildOf(e))return t}else if(t instanceof rp&&t.node&&!t.node.isChildOf(e))return t;i=new h}else if(h===Object)i={};else{if(h)return t;i=Object.create(null)}return v8(t,i,e),i}g8._clone=y8,v.instantiate=g8;var T8,A8,b8=t("ew",function(){function t(t){this.poolHandlerComp=void 0,this._pool=void 0,this.poolHandlerComp=t,this._pool=[]}var e=t.prototype;return e.size=function(){return this._pool.length},e.clear=function(){for(var t=this._pool.length,e=0;e<t;++e)this._pool[e].destroy();this._pool.length=0},e.put=function(t){if(t&&-1===this._pool.indexOf(t)){t.removeFromParent();var e=this.poolHandlerComp?t.getComponent(this.poolHandlerComp):null;e&&e.unuse&&e.unuse(),this._pool.push(t)}},e.get=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=this._pool.length-1;if(n<0)return null;var r=this._pool[n];this._pool.length=n;var s=this.poolHandlerComp?r.getComponent(this.poolHandlerComp):null;return s&&s.reuse&&s.reuse(arguments),r},t}());v.NodePool=b8;var E8=null!==(T8=globalThis.jsb)&&void 0!==T8?T8:{};t("eO",{DownloaderHints:E8.DownloaderHints,Downloader:E8.Downloader,zipUtils:E8.zipUtils,fileUtils:E8.fileUtils,DebugRenderer:E8.DebugRenderer,copyTextToClipboard:null===(A8=E8.copyTextToClipboard)||void 0===A8?void 0:A8.bind(E8),garbageCollect:E8.garbageCollect,reflection:E8.reflection,bridge:E8.bridge,jsbBridgeWrapper:E8.jsbBridgeWrapper,AssetsManager:E8.AssetsManager,EventAssetsManager:E8.EventAssetsManager,Manifest:E8.Manifest,saveImageData:E8.saveImageData,process:E8.process,adpf:E8.adpf}),v.renderer=ZG;var C8,w8=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuDescriptorSet=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._layout=t.layout;var e=t.layout.gpuDescriptorSetLayout,i=e.bindings,n=e.descriptorIndices,r=e.descriptorCount;this._buffers=Array(r).fill(null),this._textures=Array(r).fill(null),this._samplers=Array(r).fill(null);var s=[];this._gpuDescriptorSet={gpuDescriptors:s,descriptorIndices:n};for(var o=0;o<i.length;++o)for(var a=i[o],h=0;h<a.count;h++)s.push({type:a.descriptorType,gpuBuffer:null,gpuTexture:null,gpuSampler:null})},i.destroy=function(){this._layout=null,this._gpuDescriptorSet=null},i.update=function(){if(this._isDirty&&this._gpuDescriptorSet){for(var t=this._gpuDescriptorSet.gpuDescriptors,e=0;e<t.length;++e)if(t[e].type&L_){var i=this._buffers[e];i&&(t[e].gpuBuffer=i.gpuBuffer||i.gpuBufferView)}else t[e].type&N_&&(this._textures[e]&&(t[e].gpuTexture=this._textures[e].gpuTexture),this._samplers[e]&&(t[e].gpuSampler=this._samplers[e].gpuSampler));this._isDirty=!1}},n(e,[{key:"gpuDescriptorSet",get:function(){return this._gpuDescriptorSet}}]),e}(td);!function(t){t[t.RGBA16F_EXT=34842]="RGBA16F_EXT",t[t.RGB16F_EXT=34843]="RGB16F_EXT",t[t.RGBA32F_EXT=34836]="RGBA32F_EXT",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",t[t.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",t[t.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",t[t.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",t[t.SRGB_EXT=35904]="SRGB_EXT",t[t.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",t[t.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"}(C8||(C8={}));var x8=function(){function t(){}return t.setInstance=function(e){t._instance=e},n(t,null,[{key:"instance",get:function(){return t._instance}}]),t}();function R8(t,e){switch(t){case Hl.R8:return e.UNSIGNED_BYTE;case Hl.R8SN:return e.BYTE;case Hl.R8UI:return e.UNSIGNED_BYTE;case Hl.R8I:return e.BYTE;case Hl.R16F:return C8.HALF_FLOAT_OES;case Hl.R16UI:return e.UNSIGNED_SHORT;case Hl.R16I:return e.SHORT;case Hl.R32F:return e.FLOAT;case Hl.R32UI:return e.UNSIGNED_INT;case Hl.R32I:return e.INT;case Hl.RG8:return e.UNSIGNED_BYTE;case Hl.RG8SN:return e.BYTE;case Hl.RG8UI:return e.UNSIGNED_BYTE;case Hl.RG8I:return e.BYTE;case Hl.RG16F:return C8.HALF_FLOAT_OES;case Hl.RG16UI:return e.UNSIGNED_SHORT;case Hl.RG16I:return e.SHORT;case Hl.RG32F:return e.FLOAT;case Hl.RG32UI:return e.UNSIGNED_INT;case Hl.RG32I:return e.INT;case Hl.RGB8:case Hl.SRGB8:return e.UNSIGNED_BYTE;case Hl.RGB8SN:return e.BYTE;case Hl.RGB8UI:return e.UNSIGNED_BYTE;case Hl.RGB8I:return e.BYTE;case Hl.RGB16F:return C8.HALF_FLOAT_OES;case Hl.RGB16UI:return e.UNSIGNED_SHORT;case Hl.RGB16I:return e.SHORT;case Hl.RGB32F:return e.FLOAT;case Hl.RGB32UI:return e.UNSIGNED_INT;case Hl.RGB32I:return e.INT;case Hl.BGRA8:case Hl.RGBA8:case Hl.SRGB8_A8:return e.UNSIGNED_BYTE;case Hl.RGBA8SN:return e.BYTE;case Hl.RGBA8UI:return e.UNSIGNED_BYTE;case Hl.RGBA8I:return e.BYTE;case Hl.RGBA16F:return C8.HALF_FLOAT_OES;case Hl.RGBA16UI:return e.UNSIGNED_SHORT;case Hl.RGBA16I:return e.SHORT;case Hl.RGBA32F:return e.FLOAT;case Hl.RGBA32UI:return e.UNSIGNED_INT;case Hl.RGBA32I:return e.INT;case Hl.R5G6B5:return e.UNSIGNED_SHORT_5_6_5;case Hl.R11G11B10F:return e.FLOAT;case Hl.RGB5A1:return e.UNSIGNED_SHORT_5_5_5_1;case Hl.RGBA4:return e.UNSIGNED_SHORT_4_4_4_4;case Hl.RGB10A2:return e.UNSIGNED_BYTE;case Hl.RGB10A2UI:return e.UNSIGNED_INT;case Hl.RGB9E5:return e.UNSIGNED_BYTE;case Hl.DEPTH:return e.UNSIGNED_INT;case Hl.DEPTH_STENCIL:return C8.UNSIGNED_INT_24_8_WEBGL;case Hl.BC1:case Hl.BC1_SRGB:case Hl.BC2:case Hl.BC2_SRGB:case Hl.BC3:case Hl.BC3_SRGB:case Hl.BC4:return e.UNSIGNED_BYTE;case Hl.BC4_SNORM:return e.BYTE;case Hl.BC5:return e.UNSIGNED_BYTE;case Hl.BC5_SNORM:return e.BYTE;case Hl.BC6H_SF16:case Hl.BC6H_UF16:return e.FLOAT;case Hl.BC7:case Hl.BC7_SRGB:case Hl.ETC_RGB8:case Hl.ETC2_RGB8:case Hl.ETC2_SRGB8:case Hl.ETC2_RGB8_A1:case Hl.ETC2_SRGB8_A1:case Hl.EAC_R11:return e.UNSIGNED_BYTE;case Hl.EAC_R11SN:return e.BYTE;case Hl.EAC_RG11:return e.UNSIGNED_BYTE;case Hl.EAC_RG11SN:return e.BYTE;case Hl.PVRTC_RGB2:case Hl.PVRTC_RGBA2:case Hl.PVRTC_RGB4:case Hl.PVRTC_RGBA4:case Hl.PVRTC2_2BPP:case Hl.PVRTC2_4BPP:return e.UNSIGNED_BYTE;case Hl.ASTC_RGBA_4X4:case Hl.ASTC_RGBA_5X4:case Hl.ASTC_RGBA_5X5:case Hl.ASTC_RGBA_6X5:case Hl.ASTC_RGBA_6X6:case Hl.ASTC_RGBA_8X5:case Hl.ASTC_RGBA_8X6:case Hl.ASTC_RGBA_8X8:case Hl.ASTC_RGBA_10X5:case Hl.ASTC_RGBA_10X6:case Hl.ASTC_RGBA_10X8:case Hl.ASTC_RGBA_10X10:case Hl.ASTC_RGBA_12X10:case Hl.ASTC_RGBA_12X12:case Hl.ASTC_SRGBA_4X4:case Hl.ASTC_SRGBA_5X4:case Hl.ASTC_SRGBA_5X5:case Hl.ASTC_SRGBA_6X5:case Hl.ASTC_SRGBA_6X6:case Hl.ASTC_SRGBA_8X5:case Hl.ASTC_SRGBA_8X6:case Hl.ASTC_SRGBA_8X8:case Hl.ASTC_SRGBA_10X5:case Hl.ASTC_SRGBA_10X6:case Hl.ASTC_SRGBA_10X8:case Hl.ASTC_SRGBA_10X10:case Hl.ASTC_SRGBA_12X10:case Hl.ASTC_SRGBA_12X12:default:return e.UNSIGNED_BYTE}}function I8(t,e){switch(t){case jl.BOOL:return e.BOOL;case jl.BOOL2:return e.BOOL_VEC2;case jl.BOOL3:return e.BOOL_VEC3;case jl.BOOL4:return e.BOOL_VEC4;case jl.INT:return e.INT;case jl.INT2:return e.INT_VEC2;case jl.INT3:return e.INT_VEC3;case jl.INT4:return e.INT_VEC4;case jl.UINT:return e.UNSIGNED_INT;case jl.FLOAT:return e.FLOAT;case jl.FLOAT2:return e.FLOAT_VEC2;case jl.FLOAT3:return e.FLOAT_VEC3;case jl.FLOAT4:return e.FLOAT_VEC4;case jl.MAT2:return e.FLOAT_MAT2;case jl.MAT3:return e.FLOAT_MAT3;case jl.MAT4:return e.FLOAT_MAT4;case jl.SAMPLER2D:return e.SAMPLER_2D;case jl.SAMPLER_CUBE:return e.SAMPLER_CUBE;default:return V("Unsupported GLType, convert to GL type failed."),jl.UNKNOWN}}function B8(t){switch(t){case jl.BOOL:case jl.BOOL2:case jl.BOOL3:case jl.BOOL4:case jl.INT:case jl.INT2:case jl.INT3:case jl.INT4:case jl.UINT:return Int32Array;case jl.FLOAT:case jl.FLOAT2:case jl.FLOAT3:case jl.FLOAT4:case jl.MAT2:case jl.MAT3:case jl.MAT4:return Float32Array;default:return V("Unsupported GLType, convert to TypedArrayConstructor failed."),Float32Array}}function D8(t,e){switch(t){case e.BOOL:return jl.BOOL;case e.BOOL_VEC2:return jl.BOOL2;case e.BOOL_VEC3:return jl.BOOL3;case e.BOOL_VEC4:return jl.BOOL4;case e.INT:return jl.INT;case e.INT_VEC2:return jl.INT2;case e.INT_VEC3:return jl.INT3;case e.INT_VEC4:return jl.INT4;case e.UNSIGNED_INT:return jl.UINT;case e.FLOAT:return jl.FLOAT;case e.FLOAT_VEC2:return jl.FLOAT2;case e.FLOAT_VEC3:return jl.FLOAT3;case e.FLOAT_VEC4:return jl.FLOAT4;case e.FLOAT_MAT2:return jl.MAT2;case e.FLOAT_MAT3:return jl.MAT3;case e.FLOAT_MAT4:return jl.MAT4;case e.SAMPLER_2D:return jl.SAMPLER2D;case e.SAMPLER_CUBE:return jl.SAMPLER_CUBE;default:return V("Unsupported GLType, convert to Type failed."),jl.UNKNOWN}}function P8(t,e){switch(t){case e.BOOL:return 4;case e.BOOL_VEC2:return 8;case e.BOOL_VEC3:return 12;case e.BOOL_VEC4:return 16;case e.INT:return 4;case e.INT_VEC2:return 8;case e.INT_VEC3:return 12;case e.INT_VEC4:return 16;case e.UNSIGNED_INT:case e.FLOAT:return 4;case e.FLOAT_VEC2:return 8;case e.FLOAT_VEC3:return 12;case e.FLOAT_VEC4:case e.FLOAT_MAT2:return 16;case e.FLOAT_MAT3:return 36;case e.FLOAT_MAT4:return 64;case e.SAMPLER_2D:case e.SAMPLER_CUBE:return 4;default:return V("Unsupported GLType, get type failed."),0}}function O8(t,e){switch(t){case e.FLOAT_MAT2:return 2;case e.FLOAT_MAT3:return 3;case e.FLOAT_MAT4:return 4;default:return 1}}x8._instance=null;var M8,L8=[512,513,514,515,516,517,518,519],N8=[0,7680,7681,7682,7683,5386,34055,34056],F8=[32774,32778,32779,32775,32776],k8=[0,1,770,772,771,773,768,774,769,775,776,32769,32770,32771,32772];!function(t){t[t.BEGIN_RENDER_PASS=0]="BEGIN_RENDER_PASS",t[t.END_RENDER_PASS=1]="END_RENDER_PASS",t[t.BIND_STATES=2]="BIND_STATES",t[t.DRAW=3]="DRAW",t[t.UPDATE_BUFFER=4]="UPDATE_BUFFER",t[t.COPY_BUFFER_TO_TEXTURE=5]="COPY_BUFFER_TO_TEXTURE",t[t.BLIT_TEXTURE=6]="BLIT_TEXTURE",t[t.COUNT=7]="COUNT"}(M8||(M8={}));var V8=function(t){this.cmdType=void 0,this.refCount=0,this.cmdType=t},G8=function(t){function e(){var e;return(e=t.call(this,M8.BEGIN_RENDER_PASS)||this).gpuRenderPass=null,e.gpuFramebuffer=null,e.renderArea=new Mc,e.clearFlag=Cc.NONE,e.clearColors=[],e.clearDepth=1,e.clearStencil=0,e}return s(e,t),e.prototype.clear=function(){this.gpuFramebuffer=null,this.clearColors.length=0},e}(V8),U8=function(t){function e(){var e;return(e=t.call(this,M8.BIND_STATES)||this).gpuPipelineState=null,e.gpuInputAssembler=null,e.gpuDescriptorSets=[],e.dynamicOffsets=[],e.dynamicStates=new P_,e}return s(e,t),e.prototype.clear=function(){this.gpuPipelineState=null,this.gpuDescriptorSets.length=0,this.gpuInputAssembler=null,this.dynamicOffsets.length=0},e}(V8),z8=function(t){function e(){var e;return(e=t.call(this,M8.DRAW)||this).drawInfo=new Yc,e}return s(e,t),e.prototype.clear=function(){},e}(V8),H8=function(t){function e(){var e;return(e=t.call(this,M8.UPDATE_BUFFER)||this).gpuBuffer=null,e.buffer=null,e.offset=0,e.size=0,e}return s(e,t),e.prototype.clear=function(){this.gpuBuffer=null,this.buffer=null},e}(V8),W8=function(t){function e(){var e;return(e=t.call(this,M8.COPY_BUFFER_TO_TEXTURE)||this).gpuTexture=null,e.buffers=[],e.regions=[],e}return s(e,t),e.prototype.clear=function(){this.gpuTexture=null,this.buffers.length=0,this.regions.length=0},e}(V8),j8=function(t){function e(){var e;return(e=t.call(this,M8.BLIT_TEXTURE)||this).srcTexture=null,e.dstTexture=null,e.regions=[],e.filter=ic.LINEAR,e}return s(e,t),e.prototype.clear=function(){this.srcTexture=null,this.dstTexture=null,this.regions.length=0},e}(V8),X8=function(){function t(){this.cmds=new Pu(1),this.beginRenderPassCmds=new Pu(1),this.bindStatesCmds=new Pu(1),this.drawCmds=new Pu(1),this.updateBufferCmds=new Pu(1),this.copyBufferToTextureCmds=new Pu(1),this.blitTextureCmds=new Pu(1)}return t.prototype.clearCmds=function(t){this.beginRenderPassCmds.length&&(t.beginRenderPassCmdPool.freeCmds(this.beginRenderPassCmds),this.beginRenderPassCmds.clear()),this.bindStatesCmds.length&&(t.bindStatesCmdPool.freeCmds(this.bindStatesCmds),this.bindStatesCmds.clear()),this.drawCmds.length&&(t.drawCmdPool.freeCmds(this.drawCmds),this.drawCmds.clear()),this.updateBufferCmds.length&&(t.updateBufferCmdPool.freeCmds(this.updateBufferCmds),this.updateBufferCmds.clear()),this.copyBufferToTextureCmds.length&&(t.copyBufferToTextureCmdPool.freeCmds(this.copyBufferToTextureCmds),this.copyBufferToTextureCmds.clear()),this.blitTextureCmds.length&&(t.blitTextureCmdPool.freeCmds(this.blitTextureCmds),this.blitTextureCmds.clear()),this.cmds.clear()},t}();function q8(t,e){var i=t.gl,n=t.stateCache,r=e.memUsage&Kl.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;if(e.usage&Xl.VERTEX){e.glTarget=i.ARRAY_BUFFER;var s=i.createBuffer();s&&(e.glBuffer=s,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),t6.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer),i.bufferData(i.ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null))}else if(e.usage&Xl.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;var o=i.createBuffer();o&&(e.glBuffer=o,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),t6.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null))}else e.usage&Xl.UNIFORM?(e.glTarget=i.NONE,e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer))):(e.usage&Xl.INDIRECT||e.usage&Xl.TRANSFER_DST||e.usage&Xl.TRANSFER_SRC||V("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE)}function Y8(t,e){var i=t.gl,n=t.stateCache;if(e.glBuffer){switch(e.glTarget){case i.ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),t.stateCache.glVAO=null),t6.gpuInputAssembler=null,i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null;break;case i.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),t.stateCache.glVAO=null),t6.gpuInputAssembler=null,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}function K8(t,e,i,n,r){if(e.usage&Xl.UNIFORM)ArrayBuffer.isView(i)?e.vf32.set(i,n/Float32Array.BYTES_PER_ELEMENT):e.vf32.set(new Float32Array(i),n/Float32Array.BYTES_PER_ELEMENT);else if(e.usage&Xl.INDIRECT){e.indirects.clearDraws();for(var s=i.drawInfos,o=0;o<s.length;++o)e.indirects.setDrawInfo(n+o,s[o])}else{var a=i,h=t.gl,u=t.stateCache;switch(e.glTarget){case h.ARRAY_BUFFER:t.extensions.useVAO&&u.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),u.glVAO=null),t6.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&(h.bindBuffer(h.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer);break;case h.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&u.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),u.glVAO=null),t6.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer);break;default:return void V("Unsupported BufferType, update buffer failed.")}r===a.byteLength?h.bufferSubData(e.glTarget,n,a):h.bufferSubData(e.glTarget,n,a.slice(0,r))}}function J8(t,e){for(var i,n=t.gl,r=function(){var t=e.gpuStages[s],i=0,r="",o=1;switch(t.type){case uc.VERTEX:r="VertexShader",i=n.VERTEX_SHADER;break;case uc.FRAGMENT:r="FragmentShader",i=n.FRAGMENT_SHADER;break;default:return V("Unsupported ShaderType."),{v:void 0}}var a=n.createShader(i);if(a&&(t.glShader=a,n.shaderSource(t.glShader,t.source),n.compileShader(t.glShader),!n.getShaderParameter(t.glShader,n.COMPILE_STATUS))){V(r+" in '"+e.name+"' compilation failed."),V("Shader source dump:",t.source.replace(/^|\n/g,(function(){return"\n"+o+++" "}))),V(n.getShaderInfoLog(t.glShader));for(var h=0;h<e.gpuStages.length;h++){var u=e.gpuStages[s];u.glShader&&(n.deleteShader(u.glShader),u.glShader=null)}return{v:void 0}}},s=0;s<e.gpuStages.length;s++)if(i=r())return i.v;var o=n.createProgram();if(o){e.glProgram=o;for(var a=0;a<e.gpuStages.length;a++){var h=e.gpuStages[a];n.attachShader(e.glProgram,h.glShader)}if(n.linkProgram(e.glProgram),t.extensions.destroyShadersImmediately)for(var u=0;u<e.gpuStages.length;u++){var l=e.gpuStages[u];l.glShader&&(n.detachShader(e.glProgram,l.glShader),n.deleteShader(l.glShader),l.glShader=null)}if(!n.getProgramParameter(e.glProgram,n.LINK_STATUS))return V("Failed to link shader '"+e.name+"'."),void V(n.getProgramInfoLog(e.glProgram));U("Shader '"+e.name+"' compilation succeeded.");var c=n.getProgramParameter(e.glProgram,n.ACTIVE_ATTRIBUTES);e.glInputs=new Array(c);for(var _=0;_<c;++_){var d=n.getActiveAttrib(e.glProgram,_);if(d){var f,p=d.name.indexOf("[");f=-1!==p?d.name.substr(0,p):d.name;var m=n.getAttribLocation(e.glProgram,f),g=D8(d.type,n),y=P8(d.type,n);e.glInputs[_]={binding:m,name:f,type:g,stride:y,count:d.size,size:y*d.size,glType:d.type,glLoc:m}}}if(e.blocks.length>0){e.glBlocks=new Array(e.blocks.length);for(var S=0;S<e.blocks.length;++S){var T=e.blocks[S],A={set:T.set,binding:T.binding,name:T.name,size:0,glUniforms:new Array(T.members.length),glActiveUniforms:[]};e.glBlocks[S]=A;for(var b=0;b<T.members.length;++b){var E=T.members[b],C=I8(E.type,n),w=P8(C,n),x=w*E.count;A.glUniforms[b]={binding:-1,name:E.name,type:E.type,stride:w,count:E.count,size:x,offset:0,glType:C,glLoc:null,array:null}}}}for(var R=0;R<e.subpassInputs.length;++R){var I=e.subpassInputs[R];e.samplerTextures.push(new i_(I.set,I.binding,I.name,jl.SAMPLER2D,I.count))}if(e.samplerTextures.length>0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var B=0;B<e.samplerTextures.length;++B){var D=e.samplerTextures[B];e.glSamplerTextures[B]={set:D.set,binding:D.binding,name:D.name,type:D.type,count:D.count,units:[],glUnits:null,glType:I8(D.type,n),glLoc:null}}}for(var P=n.getProgramParameter(e.glProgram,n.ACTIVE_UNIFORMS),O=0;O<P;++O){var M=n.getActiveUniform(e.glProgram,O);if(M&&M.type!==n.SAMPLER_2D&&M.type!==n.SAMPLER_CUBE){var L=n.getUniformLocation(e.glProgram,M.name);if(t.extensions.isLocationActive(L)){var N,F=M.name.indexOf("[");N=-1!==F?M.name.substr(0,F):M.name;for(var k=0;k<e.glBlocks.length;k++)for(var G=e.glBlocks[k],z=0;z<G.glUniforms.length;z++){var H=G.glUniforms[z];if(H.name===N){H.glLoc=L,H.count=M.size,H.size=H.stride*H.count,H.array=new(B8(H.type))(H.size/4),G.glActiveUniforms.push(H);break}}}}}for(var W=0;W<e.glBlocks.length;W++)for(var j=e.glBlocks[W],X=0;X<j.glUniforms.length;X++){var q=j.glUniforms[X];q.offset=j.size/4,j.size+=q.size}var Y=[],K=[],J=t.bindingMappings,Q=t.stateCache.texUnitCacheMap;if(v.rendering&&v.rendering.enableEffectImport)for(var Z=0;Z<e.samplerTextures.length;++Z){var $=e.samplerTextures[Z],tt=n.getUniformLocation(e.glProgram,$.name);t.extensions.isLocationActive(tt)&&(Y.push(e.glSamplerTextures[Z]),K.push(tt)),void 0===Q[$.name]&&(Q[$.name]=$.flattened%t.capabilities.maxTextureUnits)}else{for(var et=0,it=0;it<e.blocks.length;++it)e.blocks[it].set===J.flexibleSet&&et++;for(var nt=0,rt=0;rt<e.samplerTextures.length;++rt){var st=e.samplerTextures[rt],ot=n.getUniformLocation(e.glProgram,st.name);if(t.extensions.isLocationActive(ot)&&(Y.push(e.glSamplerTextures[rt]),K.push(ot)),void 0===Q[st.name]){var at=st.binding+J.samplerTextureOffsets[st.set]+nt;st.set===J.flexibleSet&&(at-=et),Q[st.name]=at%t.capabilities.maxTextureUnits,nt+=st.count-1}}}if(Y.length){for(var ht=[],ut=0;ut<Y.length;++ut){var lt=Y[ut],ct=Q[lt.name];if(void 0!==ct){lt.glLoc=K[ut];for(var _t=0;_t<lt.count;++_t){for(;ht[ct];)ct=(ct+1)%t.capabilities.maxTextureUnits;lt.units.push(ct),ht[ct]=!0}}}for(var dt=0,ft=0;ft<Y.length;++ft){var pt=Y[ft];if(!t.extensions.isLocationActive(pt.glLoc)){pt.glLoc=K[ft];for(var mt=0;mt<pt.count;++mt){for(;ht[dt];)dt=(dt+1)%t.capabilities.maxTextureUnits;void 0===Q[pt.name]&&(Q[pt.name]=dt),pt.units.push(dt),ht[dt]=!0}}}t.stateCache.glProgram!==e.glProgram&&n.useProgram(e.glProgram);for(var gt=0;gt<Y.length;gt++){var yt=Y[gt];yt.glUnits=new Int32Array(yt.units),n.uniform1iv(yt.glLoc,yt.glUnits)}t.stateCache.glProgram!==e.glProgram&&n.useProgram(t.stateCache.glProgram)}for(var vt=0;vt<e.glBlocks.length;)e.glBlocks[vt].glActiveUniforms.length?vt++:(e.glBlocks[vt]=e.glBlocks[e.glBlocks.length-1],e.glBlocks.length--);e.glSamplerTextures=Y}}function Q8(t,e){if(e.glProgram){var i=t.gl;if(!t.extensions.destroyShadersImmediately)for(var n=0;n<e.gpuStages.length;n++){var r=e.gpuStages[n];r.glShader&&(i.detachShader(e.glProgram,r.glShader),i.deleteShader(r.glShader),r.glShader=null)}i.deleteProgram(e.glProgram),t.stateCache.glProgram===e.glProgram&&(t.gl.useProgram(null),t.stateCache.glProgram=null),e.glProgram=null}}function Z8(t,e){var i=t.gl;e.glAttribs=new Array(e.attributes.length);for(var n=[0,0,0,0,0,0,0,0],r=0;r<e.attributes.length;++r){var s=e.attributes[r],o=void 0!==s.stream?s.stream:0,a=e.gpuVertexBuffers[o],h=R8(s.format,i),u=M_[s.format].size;e.glAttribs[r]={name:s.name,glBuffer:a.glBuffer,glType:h,size:u,count:M_[s.format].count,stride:a.stride,componentCount:O8(h,i),isNormalized:void 0!==s.isNormalized&&s.isNormalized,isInstanced:void 0!==s.isInstanced&&s.isInstanced,offset:n[o]},n[o]+=u}}function $8(t,e){for(var i=e.glVAOs.values(),n=i.next(),r=t.extensions.OES_vertex_array_object,s=t.stateCache.glVAO;!n.done;)r.deleteVertexArrayOES(n.value),s===n.value&&(r.bindVertexArrayOES(null),s=null),n=i.next();t.stateCache.glVAO=s,e.glVAOs.clear()}var t6={gpuPipelineState:null,gpuInputAssembler:null,glPrimitive:0},e6=new Mc;function i6(t,e,i,n,r,s,o){var a=t.gl,h=t.stateCache,u=0;if(i&&(e6.x=n.x<<i.lodLevel,e6.y=n.y<<i.lodLevel,e6.width=n.width<<i.lodLevel,e6.height=n.height<<i.lodLevel),i&&e){h.glFramebuffer!==i.glFramebuffer&&(a.bindFramebuffer(a.FRAMEBUFFER,i.glFramebuffer),h.glFramebuffer=i.glFramebuffer),h.viewport.left===e6.x&&h.viewport.top===e6.y&&h.viewport.width===e6.width&&h.viewport.height===e6.height||(a.viewport(e6.x,e6.y,e6.width,e6.height),h.viewport.left=e6.x,h.viewport.top=e6.y,h.viewport.width=e6.width,h.viewport.height=e6.height),h.scissorRect.x===e6.x&&h.scissorRect.y===e6.y&&h.scissorRect.width===e6.width&&h.scissorRect.height===e6.height||(a.scissor(e6.x,e6.y,e6.width,e6.height),h.scissorRect.x=e6.x,h.scissorRect.y=e6.y,h.scissorRect.width=e6.width,h.scissorRect.height=e6.height);var l=r.length;t.extensions.WEBGL_draw_buffers||(l=1);for(var c=0;c<l;++c){var _=e.colorAttachments[c];if(_.format!==Hl.UNKNOWN)switch(_.loadOp){case lc.LOAD:break;case lc.CLEAR:h.bs.targets[0].blendColorMask!==hc.ALL&&a.colorMask(!0,!0,!0,!0);var d=r[0];a.clearColor(d.x,d.y,d.z,d.w),u|=a.COLOR_BUFFER_BIT;break;case lc.DISCARD:}}if(e.depthStencilAttachment&&e.depthStencilAttachment.format!==Hl.UNKNOWN){switch(e.depthStencilAttachment.depthLoadOp){case lc.LOAD:break;case lc.CLEAR:h.dss.depthWrite||a.depthMask(!0),a.clearDepth(s),u|=a.DEPTH_BUFFER_BIT;break;case lc.DISCARD:}if(M_[e.depthStencilAttachment.format].hasStencil)switch(e.depthStencilAttachment.stencilLoadOp){case lc.LOAD:break;case lc.CLEAR:h.dss.stencilWriteMaskFront||a.stencilMaskSeparate(a.FRONT,65535),h.dss.stencilWriteMaskBack||a.stencilMaskSeparate(a.BACK,65535),a.clearStencil(o),u|=a.STENCIL_BUFFER_BIT;break;case lc.DISCARD:}}if(u&&a.clear(u),u&a.COLOR_BUFFER_BIT){var f=h.bs.targets[0].blendColorMask;if(f!==hc.ALL){var p=(f&hc.R)!==hc.NONE,m=(f&hc.G)!==hc.NONE,g=(f&hc.B)!==hc.NONE,y=(f&hc.A)!==hc.NONE;a.colorMask(p,m,g,y)}}u&a.DEPTH_BUFFER_BIT&&!h.dss.depthWrite&&a.depthMask(!1),u&a.STENCIL_BUFFER_BIT&&(h.dss.stencilWriteMaskFront||a.stencilMaskSeparate(a.FRONT,0),h.dss.stencilWriteMaskBack||a.stencilMaskSeparate(a.BACK,0))}}function n6(t,e,i,n,r,s){var o,a,h,u=t.gl,l=t.stateCache,c=e&&e.gpuShader,_=!1;if(e&&t6.gpuPipelineState!==e){if(t6.gpuPipelineState=e,t6.glPrimitive=e.glPrimitive,e.gpuShader){var d=e.gpuShader.glProgram;l.glProgram!==d&&(u.useProgram(d),l.glProgram=d,_=!0)}var f=e.rs;if(f){if(l.rs.cullMode!==f.cullMode){switch(f.cullMode){case yc.NONE:u.disable(u.CULL_FACE);break;case yc.FRONT:u.enable(u.CULL_FACE),u.cullFace(u.FRONT);break;case yc.BACK:u.enable(u.CULL_FACE),u.cullFace(u.BACK)}l.rs.cullMode=f.cullMode}var p=f.isFrontFaceCCW;l.rs.isFrontFaceCCW!==p&&(u.frontFace(p?u.CCW:u.CW),l.rs.isFrontFaceCCW=p),l.rs.depthBias===f.depthBias&&l.rs.depthBiasSlop===f.depthBiasSlop||(u.polygonOffset(f.depthBias,f.depthBiasSlop),l.rs.depthBias=f.depthBias,l.rs.depthBiasSlop=f.depthBiasSlop),l.rs.lineWidth!==f.lineWidth&&(u.lineWidth(f.lineWidth),l.rs.lineWidth=f.lineWidth)}var m=e.dss;m&&(l.dss.depthTest!==m.depthTest&&(m.depthTest?u.enable(u.DEPTH_TEST):u.disable(u.DEPTH_TEST),l.dss.depthTest=m.depthTest),l.dss.depthWrite!==m.depthWrite&&(u.depthMask(m.depthWrite),l.dss.depthWrite=m.depthWrite),l.dss.depthFunc!==m.depthFunc&&(u.depthFunc(L8[m.depthFunc]),l.dss.depthFunc=m.depthFunc),l.dss.stencilTestFront===m.stencilTestFront&&l.dss.stencilTestBack===m.stencilTestBack||(m.stencilTestFront||m.stencilTestBack?u.enable(u.STENCIL_TEST):u.disable(u.STENCIL_TEST),l.dss.stencilTestFront=m.stencilTestFront,l.dss.stencilTestBack=m.stencilTestBack),l.dss.stencilFuncFront===m.stencilFuncFront&&l.dss.stencilRefFront===m.stencilRefFront&&l.dss.stencilReadMaskFront===m.stencilReadMaskFront||(u.stencilFuncSeparate(u.FRONT,L8[m.stencilFuncFront],m.stencilRefFront,m.stencilReadMaskFront),l.dss.stencilFuncFront=m.stencilFuncFront,l.dss.stencilRefFront=m.stencilRefFront,l.dss.stencilReadMaskFront=m.stencilReadMaskFront),l.dss.stencilFailOpFront===m.stencilFailOpFront&&l.dss.stencilZFailOpFront===m.stencilZFailOpFront&&l.dss.stencilPassOpFront===m.stencilPassOpFront||(u.stencilOpSeparate(u.FRONT,N8[m.stencilFailOpFront],N8[m.stencilZFailOpFront],N8[m.stencilPassOpFront]),l.dss.stencilFailOpFront=m.stencilFailOpFront,l.dss.stencilZFailOpFront=m.stencilZFailOpFront,l.dss.stencilPassOpFront=m.stencilPassOpFront),l.dss.stencilWriteMaskFront!==m.stencilWriteMaskFront&&(u.stencilMaskSeparate(u.FRONT,m.stencilWriteMaskFront),l.dss.stencilWriteMaskFront=m.stencilWriteMaskFront),l.dss.stencilFuncBack===m.stencilFuncBack&&l.dss.stencilRefBack===m.stencilRefBack&&l.dss.stencilReadMaskBack===m.stencilReadMaskBack||(u.stencilFuncSeparate(u.BACK,L8[m.stencilFuncBack],m.stencilRefBack,m.stencilReadMaskBack),l.dss.stencilFuncBack=m.stencilFuncBack,l.dss.stencilRefBack=m.stencilRefBack,l.dss.stencilReadMaskBack=m.stencilReadMaskBack),l.dss.stencilFailOpBack===m.stencilFailOpBack&&l.dss.stencilZFailOpBack===m.stencilZFailOpBack&&l.dss.stencilPassOpBack===m.stencilPassOpBack||(u.stencilOpSeparate(u.BACK,N8[m.stencilFailOpBack],N8[m.stencilZFailOpBack],N8[m.stencilPassOpBack]),l.dss.stencilFailOpBack=m.stencilFailOpBack,l.dss.stencilZFailOpBack=m.stencilZFailOpBack,l.dss.stencilPassOpBack=m.stencilPassOpBack),l.dss.stencilWriteMaskBack!==m.stencilWriteMaskBack&&(u.stencilMaskSeparate(u.BACK,m.stencilWriteMaskBack),l.dss.stencilWriteMaskBack=m.stencilWriteMaskBack));var g=e.bs;if(g){l.bs.isA2C!==g.isA2C&&(g.isA2C?u.enable(u.SAMPLE_ALPHA_TO_COVERAGE):u.disable(u.SAMPLE_ALPHA_TO_COVERAGE),l.bs.isA2C=g.isA2C),l.bs.blendColor.x===g.blendColor.x&&l.bs.blendColor.y===g.blendColor.y&&l.bs.blendColor.z===g.blendColor.z&&l.bs.blendColor.w===g.blendColor.w||(u.blendColor(g.blendColor.x,g.blendColor.y,g.blendColor.z,g.blendColor.w),l.bs.blendColor.x=g.blendColor.x,l.bs.blendColor.y=g.blendColor.y,l.bs.blendColor.z=g.blendColor.z,l.bs.blendColor.w=g.blendColor.w);var y=g.targets[0],v=l.bs.targets[0];v.blend!==y.blend&&(y.blend?u.enable(u.BLEND):u.disable(u.BLEND),v.blend=y.blend),v.blendEq===y.blendEq&&v.blendAlphaEq===y.blendAlphaEq||(u.blendEquationSeparate(F8[y.blendEq],F8[y.blendAlphaEq]),v.blendEq=y.blendEq,v.blendAlphaEq=y.blendAlphaEq),v.blendSrc===y.blendSrc&&v.blendDst===y.blendDst&&v.blendSrcAlpha===y.blendSrcAlpha&&v.blendDstAlpha===y.blendDstAlpha||(u.blendFuncSeparate(k8[y.blendSrc],k8[y.blendDst],k8[y.blendSrcAlpha],k8[y.blendDstAlpha]),v.blendSrc=y.blendSrc,v.blendDst=y.blendDst,v.blendSrcAlpha=y.blendSrcAlpha,v.blendDstAlpha=y.blendDstAlpha),v.blendColorMask!==y.blendColorMask&&(u.colorMask((y.blendColorMask&hc.R)!==hc.NONE,(y.blendColorMask&hc.G)!==hc.NONE,(y.blendColorMask&hc.B)!==hc.NONE,(y.blendColorMask&hc.A)!==hc.NONE),v.blendColorMask=y.blendColorMask)}}if(e&&e.gpuPipelineLayout&&c){for(var S=c.glBlocks.length,T=e.gpuPipelineLayout.dynamicOffsetIndices,A=0;A<S;A++){var b=c.glBlocks[A],E=n[b.set],C=E&&E.descriptorIndices[b.binding],w=C>=0&&E.gpuDescriptors[C],x=null,R=0;if(w&&w.gpuBuffer){var I=w.gpuBuffer,B=T[b.set],D=B&&B[b.binding];D>=0&&(R=r[D]),"vf32"in I?x=I.vf32:(R+=I.offset,x=I.gpuBuffer.vf32),R>>=2}if(x)for(var P=b.glActiveUniforms.length,O=0;O<P;O++){var M=b.glActiveUniforms[O];switch(M.glType){case u.BOOL:case u.INT:for(var L=0;L<M.array.length;++L){var N=M.offset+R+L;if(x[N]!==M.array[L]){for(var F=L,k=N;F<M.array.length;++F,++k)M.array[F]=x[k];u.uniform1iv(M.glLoc,M.array);break}}break;case u.BOOL_VEC2:case u.INT_VEC2:for(var V=0;V<M.array.length;++V){var G=M.offset+R+V;if(x[G]!==M.array[V]){for(var U=V,z=G;U<M.array.length;++U,++z)M.array[U]=x[z];u.uniform2iv(M.glLoc,M.array);break}}break;case u.BOOL_VEC3:case u.INT_VEC3:for(var H=0;H<M.array.length;++H){var W=M.offset+R+H;if(x[W]!==M.array[H]){for(var j=H,X=W;j<M.array.length;++j,++X)M.array[j]=x[X];u.uniform3iv(M.glLoc,M.array);break}}break;case u.BOOL_VEC4:case u.INT_VEC4:for(var q=0;q<M.array.length;++q){var Y=M.offset+R+q;if(x[Y]!==M.array[q]){for(var K=q,J=Y;K<M.array.length;++K,++J)M.array[K]=x[J];u.uniform4iv(M.glLoc,M.array);break}}break;case u.FLOAT:for(var Q=0;Q<M.array.length;++Q){var Z=M.offset+R+Q;if(x[Z]!==M.array[Q]){for(var $=Q,tt=Z;$<M.array.length;++$,++tt)M.array[$]=x[tt];u.uniform1fv(M.glLoc,M.array);break}}break;case u.FLOAT_VEC2:for(var et=0;et<M.array.length;++et){var it=M.offset+R+et;if(x[it]!==M.array[et]){for(var nt=et,rt=it;nt<M.array.length;++nt,++rt)M.array[nt]=x[rt];u.uniform2fv(M.glLoc,M.array);break}}break;case u.FLOAT_VEC3:for(var st=0;st<M.array.length;++st){var ot=M.offset+R+st;if(x[ot]!==M.array[st]){for(var at=st,ht=ot;at<M.array.length;++at,++ht)M.array[at]=x[ht];u.uniform3fv(M.glLoc,M.array);break}}break;case u.FLOAT_VEC4:for(var ut=0;ut<M.array.length;++ut){var lt=M.offset+R+ut;if(x[lt]!==M.array[ut]){for(var ct=ut,_t=lt;ct<M.array.length;++ct,++_t)M.array[ct]=x[_t];u.uniform4fv(M.glLoc,M.array);break}}break;case u.FLOAT_MAT2:for(var dt=0;dt<M.array.length;++dt){var ft=M.offset+R+dt;if(x[ft]!==M.array[dt]){for(var pt=dt,mt=ft;pt<M.array.length;++pt,++mt)M.array[pt]=x[mt];u.uniformMatrix2fv(M.glLoc,!1,M.array);break}}break;case u.FLOAT_MAT3:for(var gt=0;gt<M.array.length;++gt){var yt=M.offset+R+gt;if(x[yt]!==M.array[gt]){for(var vt=gt,St=yt;vt<M.array.length;++vt,++St)M.array[vt]=x[St];u.uniformMatrix3fv(M.glLoc,!1,M.array);break}}break;case u.FLOAT_MAT4:for(var Tt=0;Tt<M.array.length;++Tt){var At=M.offset+R+Tt;if(x[At]!==M.array[Tt]){for(var bt=Tt,Et=At;bt<M.array.length;++bt,++Et)M.array[bt]=x[Et];u.uniformMatrix4fv(M.glLoc,!1,M.array);break}}}}}for(var Ct=c.glSamplerTextures.length,wt=0;wt<Ct;wt++)for(var xt=c.glSamplerTextures[wt],Rt=n[xt.set],It=Rt&&Rt.descriptorIndices[xt.binding],Bt=It>=0&&Rt.gpuDescriptors[It],Dt=xt.units.length,Pt=0;Pt<Dt;Pt++){var Ot=xt.units[Pt];if(Bt&&Bt.gpuSampler){if(Bt.gpuTexture&&Bt.gpuTexture.size>0){var Mt=Bt.gpuTexture,Lt=l.glTexUnits[Ot];Lt.glTexture!==Mt.glTexture&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),Mt.glTexture?u.bindTexture(Mt.glTarget,Mt.glTexture):u.bindTexture(Mt.glTarget,t.nullTex2D.gpuTexture.glTexture),Lt.glTexture=Mt.glTexture);var Nt=Bt.gpuSampler;Mt.isPowerOf2?(o=Nt.glWrapS,a=Nt.glWrapT):(o=u.CLAMP_TO_EDGE,a=u.CLAMP_TO_EDGE),h=Mt.isPowerOf2?Mt.mipLevel<=1&&(Nt.glMinFilter===u.LINEAR_MIPMAP_NEAREST||Nt.glMinFilter===u.LINEAR_MIPMAP_LINEAR)?u.LINEAR:Nt.glMinFilter:Nt.glMinFilter===u.LINEAR||Nt.glMinFilter===u.LINEAR_MIPMAP_NEAREST||Nt.glMinFilter===u.LINEAR_MIPMAP_LINEAR?u.LINEAR:u.NEAREST,Mt.glWrapS!==o&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),u.texParameteri(Mt.glTarget,u.TEXTURE_WRAP_S,o),Mt.glWrapS=o),Mt.glWrapT!==a&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),u.texParameteri(Mt.glTarget,u.TEXTURE_WRAP_T,a),Mt.glWrapT=a),Mt.glMinFilter!==h&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),u.texParameteri(Mt.glTarget,u.TEXTURE_MIN_FILTER,h),Mt.glMinFilter=h),Mt.glMagFilter!==Nt.glMagFilter&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),u.texParameteri(Mt.glTarget,u.TEXTURE_MAG_FILTER,Nt.glMagFilter),Mt.glMagFilter=Nt.glMagFilter)}Bt=Rt.gpuDescriptors[++It]}}}if(i&&c&&(_||t6.gpuInputAssembler!==i)){t6.gpuInputAssembler=i;var Ft=t.extensions.ANGLE_instanced_arrays;if(t.extensions.useVAO){var kt=t.extensions.OES_vertex_array_object,Vt=i.glVAOs.get(c.glProgram);if(!Vt){var Gt;Vt=kt.createVertexArrayOES(),i.glVAOs.set(c.glProgram,Vt),kt.bindVertexArrayOES(Vt),u.bindBuffer(u.ARRAY_BUFFER,null),u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,null),l.glArrayBuffer=null,l.glElementArrayBuffer=null;for(var Ut=c.glInputs.length,zt=0;zt<Ut;zt++){var Ht=c.glInputs[zt];Gt=null;for(var Wt=i.glAttribs.length,jt=0;jt<Wt;jt++){var Xt=i.glAttribs[jt];if(Xt.name===Ht.name){Gt=Xt;break}}if(Gt){l.glArrayBuffer!==Gt.glBuffer&&(u.bindBuffer(u.ARRAY_BUFFER,Gt.glBuffer),l.glArrayBuffer=Gt.glBuffer);for(var qt=0;qt<Gt.componentCount;++qt){var Yt=Ht.glLoc+qt,Kt=Gt.offset+Gt.size*qt;u.enableVertexAttribArray(Yt),l.glCurrentAttribLocs[Yt]=!0,u.vertexAttribPointer(Yt,Gt.count,Gt.glType,Gt.isNormalized,Gt.stride,Kt),Ft&&Ft.vertexAttribDivisorANGLE(Yt,Gt.isInstanced?1:0)}}}var Jt=i.gpuIndexBuffer;Jt&&u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,Jt.glBuffer),kt.bindVertexArrayOES(null),u.bindBuffer(u.ARRAY_BUFFER,null),u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,null),l.glArrayBuffer=null,l.glElementArrayBuffer=null}l.glVAO!==Vt&&(kt.bindVertexArrayOES(Vt),l.glVAO=Vt)}else{for(var Qt=0;Qt<t.capabilities.maxVertexAttributes;++Qt)l.glCurrentAttribLocs[Qt]=!1;for(var Zt=c.glInputs.length,$t=0;$t<Zt;$t++){for(var te=c.glInputs[$t],ee=null,ie=i.glAttribs.length,ne=0;ne<ie;ne++){var re=i.glAttribs[ne];if(re.name===te.name){ee=re;break}}if(ee){l.glArrayBuffer!==ee.glBuffer&&(u.bindBuffer(u.ARRAY_BUFFER,ee.glBuffer),l.glArrayBuffer=ee.glBuffer);for(var se=0;se<ee.componentCount;++se){var oe=te.glLoc+se,ae=ee.offset+ee.size*se;!l.glEnabledAttribLocs[oe]&&oe>=0&&(u.enableVertexAttribArray(oe),l.glEnabledAttribLocs[oe]=!0),l.glCurrentAttribLocs[oe]=!0,u.vertexAttribPointer(oe,ee.count,ee.glType,ee.isNormalized,ee.stride,ae),Ft&&Ft.vertexAttribDivisorANGLE(oe,ee.isInstanced?1:0)}}}var he=i.gpuIndexBuffer;he&&l.glElementArrayBuffer!==he.glBuffer&&(u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,he.glBuffer),l.glElementArrayBuffer=he.glBuffer);for(var ue=0;ue<t.capabilities.maxVertexAttributes;++ue)l.glEnabledAttribLocs[ue]!==l.glCurrentAttribLocs[ue]&&(u.disableVertexAttribArray(ue),l.glEnabledAttribLocs[ue]=!1)}}if(e&&e.dynamicStates.length)for(var le=e.dynamicStates.length,ce=0;ce<le;ce++)switch(e.dynamicStates[ce]){case vc.LINE_WIDTH:l.rs.lineWidth!==s.lineWidth&&(u.lineWidth(s.lineWidth),l.rs.lineWidth=s.lineWidth);break;case vc.DEPTH_BIAS:l.rs.depthBias===s.depthBiasConstant&&l.rs.depthBiasSlop===s.depthBiasSlope||(u.polygonOffset(s.depthBiasConstant,s.depthBiasSlope),l.rs.depthBias=s.depthBiasConstant,l.rs.depthBiasSlop=s.depthBiasSlope);break;case vc.BLEND_CONSTANTS:var _e=s.blendConstant;l.bs.blendColor.x===_e.x&&l.bs.blendColor.y===_e.y&&l.bs.blendColor.z===_e.z&&l.bs.blendColor.w===_e.w||(u.blendColor(_e.x,_e.y,_e.z,_e.w),l.bs.blendColor.copy(_e));break;case vc.STENCIL_WRITE_MASK:var de=s.stencilStatesFront,fe=s.stencilStatesBack;l.dss.stencilWriteMaskFront!==de.writeMask&&(u.stencilMaskSeparate(u.FRONT,de.writeMask),l.dss.stencilWriteMaskFront=de.writeMask),l.dss.stencilWriteMaskBack!==fe.writeMask&&(u.stencilMaskSeparate(u.BACK,fe.writeMask),l.dss.stencilWriteMaskBack=fe.writeMask);break;case vc.STENCIL_COMPARE_MASK:var pe=s.stencilStatesFront,me=s.stencilStatesBack;l.dss.stencilRefFront===pe.reference&&l.dss.stencilReadMaskFront===pe.compareMask||(u.stencilFuncSeparate(u.FRONT,L8[l.dss.stencilFuncFront],pe.reference,pe.compareMask),l.dss.stencilRefFront=pe.reference,l.dss.stencilReadMaskFront=pe.compareMask),l.dss.stencilRefBack===me.reference&&l.dss.stencilReadMaskBack===me.compareMask||(u.stencilFuncSeparate(u.BACK,L8[l.dss.stencilFuncBack],me.reference,me.compareMask),l.dss.stencilRefBack=me.reference,l.dss.stencilReadMaskBack=me.compareMask)}}function r6(t,e){var i=t.gl,n=t.extensions,r=n.ANGLE_instanced_arrays,s=n.WEBGL_multi_draw,o=t6.gpuInputAssembler,a=t6.glPrimitive;if(o){var h=o.gpuIndexBuffer;if(o.gpuIndirectBuffer){var u=o.gpuIndirectBuffer.indirects;if(u.drawByIndex){for(var l=0;l<u.drawCount;l++)u.byteOffsets[l]=u.offsets[l]*h.stride;if(s)u.instancedDraw?s.multiDrawElementsInstancedWEBGL(a,u.counts,0,o.glIndexType,u.byteOffsets,0,u.instances,0,u.drawCount):s.multiDrawElementsWEBGL(a,u.counts,0,o.glIndexType,u.byteOffsets,0,u.drawCount);else for(var c=0;c<u.drawCount;c++)u.instances[c]&&r?r.drawElementsInstancedANGLE(a,u.counts[c],o.glIndexType,u.byteOffsets[c],u.instances[c]):i.drawElements(a,u.counts[c],o.glIndexType,u.byteOffsets[c])}else if(s)u.instancedDraw?s.multiDrawArraysInstancedWEBGL(a,u.offsets,0,u.counts,0,u.instances,0,u.drawCount):s.multiDrawArraysWEBGL(a,u.offsets,0,u.counts,0,u.drawCount);else for(var _=0;_<u.drawCount;_++)u.instances[_]&&r?r.drawArraysInstancedANGLE(a,u.offsets[_],u.counts[_],u.instances[_]):i.drawArrays(a,u.offsets[_],u.counts[_])}else if(e.instanceCount&&r)if(h){if(e.indexCount>0){var d=e.firstIndex*h.stride;r.drawElementsInstancedANGLE(a,e.indexCount,o.glIndexType,d,e.instanceCount)}}else e.vertexCount>0&&r.drawArraysInstancedANGLE(a,e.firstVertex,e.vertexCount,e.instanceCount);else if(h){if(e.indexCount>0){var f=e.firstIndex*h.stride;i.drawElements(a,e.indexCount,o.glIndexType,f)}}else e.vertexCount>0&&i.drawArrays(a,e.firstVertex,e.vertexCount)}}var s6=new Array(M8.COUNT);function o6(t,e){s6.fill(0);for(var i=0;i<e.cmds.length;++i){var n=e.cmds.array[i],r=s6[n]++;switch(n){case M8.BEGIN_RENDER_PASS:var s=e.beginRenderPassCmds.array[r];i6(t,s.gpuRenderPass,s.gpuFramebuffer,s.renderArea,s.clearColors,s.clearDepth,s.clearStencil);break;case M8.BIND_STATES:var o=e.bindStatesCmds.array[r];n6(t,o.gpuPipelineState,o.gpuInputAssembler,o.gpuDescriptorSets,o.dynamicOffsets,o.dynamicStates);break;case M8.DRAW:r6(t,e.drawCmds.array[r].drawInfo);break;case M8.UPDATE_BUFFER:var a=e.updateBufferCmds.array[r];K8(t,a.gpuBuffer,a.buffer,a.offset,a.size);break;case M8.COPY_BUFFER_TO_TEXTURE:var h=e.copyBufferToTextureCmds.array[r];u6(t,h.buffers,h.gpuTexture,h.regions);break;case M8.BLIT_TEXTURE:var u=e.blitTextureCmds.array[r];l6(t,u.srcTexture,u.dstTexture,u.regions,u.filter)}}}var a6=new Uint8Array(1);function h6(t,e,i,n,r){var s=W_(e).height,o=V_(e,r.width,r.height,r.depth),a=V_(e,n.width,1,1),h=V_(e,n.width,n.height,1),u=V_(e,r.width,1,1),l=H_(M_[e]);a6.byteLength<o&&(a6=new Uint8Array(o));for(var c=0,_=i,d=0;d<r.depth;d++){_=i+h*d;for(var f=0;f<r.height;f+=s)a6.subarray(c,c+u).set(new Uint8Array(t.buffer,t.byteOffset+_,u)),c+=u,_+=a}var p=o/l.BYTES_PER_ELEMENT;return $(Number.isInteger(p),9101),new l(a6.buffer,0,p)}function u6(t,e,i,n){var r=t.gl,s=t.stateCache.glTexUnits[t.stateCache.texUnit];s.glTexture!==i.glTexture&&(r.bindTexture(i.glTarget,i.glTexture),s.glTexture=i.glTexture);var o=0,a=0,h=M_[i.format],u=H_(h),l=h.isCompressed,c=W_(i.format),_=new Lc,d=new Oc,f=new Lc;switch(i.glTarget){case r.TEXTURE_2D:for(var p=0;p<n.length;p++){var m=n[p],g=m.texSubres.mipLevel;d.x=0===m.texOffset.x?0:j_(m.texOffset.x,c.width),d.y=0===m.texOffset.y?0:j_(m.texOffset.y,c.height),_.width=m.texExtent.width<c.width?m.texExtent.width:j_(m.texExtent.width,c.width),_.height=m.texExtent.height<c.height?m.texExtent.width:j_(m.texExtent.height,c.height),f.width=m.buffStride>0?m.buffStride:_.width,f.height=m.buffTexHeight>0?m.buffTexHeight:_.height;var y=m.texExtent.width+d.x===i.width>>g?m.texExtent.width:_.width,v=m.texExtent.height+d.y===i.height>>g?m.texExtent.height:_.height,S=void 0,T=e[o++];if(f.width===_.width&&f.height===_.height){var A=V_(i.format,y,v,1)/u.BYTES_PER_ELEMENT;$(Number.isInteger(A),9101),S=new u(T.buffer,T.byteOffset+m.buffOffset,A)}else S=h6(T,i.format,m.buffOffset,f,_);l?i.glInternalFmt===C8.COMPRESSED_RGB_ETC1_WEBGL||t.extensions.noCompressedTexSubImage2D?r.compressedTexImage2D(r.TEXTURE_2D,g,i.glInternalFmt,y,v,0,S):r.compressedTexSubImage2D(r.TEXTURE_2D,g,d.x,d.y,y,v,i.glFormat,S):r.texSubImage2D(r.TEXTURE_2D,g,d.x,d.y,y,v,i.glFormat,i.glType,S)}break;case r.TEXTURE_CUBE_MAP:for(var b=0;b<n.length;b++){var E=n[b],C=E.texSubres.mipLevel;d.x=0===E.texOffset.x?0:j_(E.texOffset.x,c.width),d.y=0===E.texOffset.y?0:j_(E.texOffset.y,c.height),_.width=E.texExtent.width<c.width?E.texExtent.width:j_(E.texExtent.width,c.width),_.height=E.texExtent.height<c.height?E.texExtent.width:j_(E.texExtent.height,c.height),f.width=E.buffStride>0?E.buffStride:_.width,f.height=E.buffTexHeight>0?E.buffTexHeight:_.height;var w=E.texExtent.width+d.x===i.width>>C?E.texExtent.width:_.width,x=E.texExtent.height+d.y===i.height>>C?E.texExtent.height:_.height,R=E.texSubres.baseArrayLayer+E.texSubres.layerCount;for(a=E.texSubres.baseArrayLayer;a<R;++a){var I=void 0,B=e[o++];if(f.width===_.width&&f.height===_.height){var D=V_(i.format,w,x,1)/u.BYTES_PER_ELEMENT;$(Number.isInteger(D),9101),I=new u(B.buffer,B.byteOffset+E.buffOffset,D)}else I=h6(B,i.format,E.buffOffset,f,_);l?i.glInternalFmt===C8.COMPRESSED_RGB_ETC1_WEBGL||t.extensions.noCompressedTexSubImage2D?r.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+a,C,i.glInternalFmt,w,x,0,I):r.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+a,C,d.x,d.y,w,x,i.glFormat,I):r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+a,C,d.x,d.y,w,x,i.glFormat,i.glType,I)}}break;default:V("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&Zl.GEN_MIPMAP&&r.generateMipmap(i.glTarget)}function l6(t,e,i,n,r){t.blitManager.draw(e,i,n,r)}var c6=function(){function t(){this.counts=void 0,this.offsets=void 0,this.instances=void 0,this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1,this.byteOffsets=void 0,this._capacity=4,this.counts=new Int32Array(this._capacity),this.offsets=new Int32Array(this._capacity),this.instances=new Int32Array(this._capacity),this.byteOffsets=new Int32Array(this._capacity)}var e=t.prototype;return e.clearDraws=function(){this.drawCount=0,this.drawByIndex=!1,this.instancedDraw=!1},e.setDrawInfo=function(t,e){this._ensureCapacity(t),this.drawByIndex=e.indexCount>0,this.instancedDraw=!!e.instanceCount,this.drawCount=Math.max(t+1,this.drawCount),this.drawByIndex?(this.counts[t]=e.indexCount,this.offsets[t]=e.firstIndex):(this.counts[t]=e.vertexCount,this.offsets[t]=e.firstVertex),this.instances[t]=Math.max(1,e.instanceCount)},e._ensureCapacity=function(t){if(!(this._capacity>t)){this._capacity=Vi(t);var e=new Int32Array(this._capacity),i=new Int32Array(this._capacity),n=new Int32Array(this._capacity);this.byteOffsets=new Int32Array(this._capacity),e.set(this.counts),i.set(this.offsets),n.set(this.instances),this.counts=e,this.offsets=i,this.instances=n}},t}(),_6=function(){function t(){this._gpuShader=null,this._gpuDescriptorSetLayout=null,this._gpuPipelineLayout=null,this._gpuPipelineState=null,this._gpuVertexBuffer=null,this._gpuInputAssembler=null,this._gpuPointSampler=null,this._gpuLinearSampler=null,this._gpuDescriptorSet=null,this._gpuUniformBuffer=null,this._drawInfo=null,this._glFramebuffer=null,this._uniformBuffer=null;var t=x8.instance.gl,e=x8.instance.bindingMappingInfo.maxBlockCounts[0];this._gpuShader={name:"Blit Pass",blocks:[new e_(0,0,"BlitParams",[new t_("tilingOffsetSrc",jl.FLOAT4,1),new t_("tilingOffsetDst",jl.FLOAT4,1)],1)],samplerTextures:[new i_(0,e,"textureSrc",jl.SAMPLER2D,1)],subpassInputs:[],gpuStages:[{type:uc.VERTEX,source:"\n precision mediump float;\n\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n \n uniform vec4 tilingOffsetSrc;\n uniform vec4 tilingOffsetDst;\n \n varying vec2 v_texCoord;\n \n void main() {\n v_texCoord = a_texCoord * tilingOffsetSrc.xy + tilingOffsetSrc.zw;\n gl_Position = vec4((a_position + 1.0) * tilingOffsetDst.xy - 1.0 + tilingOffsetDst.zw * 2.0, 0, 1);\n }",glShader:null},{type:uc.FRAGMENT,source:"\n precision mediump float;\n uniform sampler2D textureSrc;\n\n varying vec2 v_texCoord;\n \n void main() {\n gl_FragColor = texture2D(textureSrc, v_texCoord);\n }",glShader:null}],glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplerTextures:[]},J8(x8.instance,this._gpuShader),this._gpuDescriptorSetLayout={bindings:[new T_(0,Tc.UNIFORM_BUFFER,1,uc.VERTEX),new T_(e,Tc.SAMPLER_TEXTURE,1,uc.FRAGMENT)],dynamicBindings:[],descriptorIndices:[],descriptorCount:e+1};for(var i=0;i<e;i++)this._gpuDescriptorSetLayout.descriptorIndices[i]=0;this._gpuDescriptorSetLayout.descriptorIndices.push(1),this._gpuPipelineLayout={gpuSetLayouts:[this._gpuDescriptorSetLayout],dynamicOffsetCount:0,dynamicOffsetOffsets:[0],dynamicOffsetIndices:[[]]},this._gpuPipelineState={glPrimitive:t.TRIANGLE_STRIP,gpuShader:this._gpuShader,gpuPipelineLayout:this._gpuPipelineLayout,rs:null,dss:new rd(!1,!1),bs:null,dynamicStates:[],gpuRenderPass:null},this._gpuVertexBuffer={usage:Xl.VERTEX,memUsage:Kl.DEVICE,size:16*Float32Array.BYTES_PER_ELEMENT,stride:4*Float32Array.BYTES_PER_ELEMENT,buffer:null,vf32:null,indirects:new c6,glTarget:0,glBuffer:null},q8(x8.instance,this._gpuVertexBuffer),x8.instance.memoryStatus.bufferSize+=this._gpuVertexBuffer.size;var n=new Float32Array([-1,-1,0,0,1,-1,1,0,-1,1,0,1,1,1,1,1]);K8(x8.instance,this._gpuVertexBuffer,n,0,n.length),this._gpuInputAssembler={attributes:[new u_("a_position",Hl.RG32F),new u_("a_texCoord",Hl.RG32F)],gpuVertexBuffers:[this._gpuVertexBuffer],gpuIndexBuffer:null,gpuIndirectBuffer:null,glAttribs:[],glIndexType:0,glVAOs:new Map},Z8(x8.instance,this._gpuInputAssembler),this._gpuPointSampler={glMinFilter:9728,glMagFilter:9728,glWrapS:10497,glWrapT:10497,glWrapR:10497},this._gpuLinearSampler={glMinFilter:9729,glMagFilter:9729,glWrapS:10497,glWrapT:10497,glWrapR:10497},this._uniformBuffer=new Float32Array(8),this._gpuUniformBuffer={usage:Xl.UNIFORM,memUsage:Kl.DEVICE,size:8*Float32Array.BYTES_PER_ELEMENT,stride:8*Float32Array.BYTES_PER_ELEMENT,buffer:this._uniformBuffer,vf32:null,indirects:new c6,glTarget:0,glBuffer:null},q8(x8.instance,this._gpuUniformBuffer),x8.instance.memoryStatus.bufferSize+=this._gpuUniformBuffer.size,this._gpuDescriptorSet={gpuDescriptors:[{type:Tc.UNIFORM_BUFFER,gpuBuffer:this._gpuUniformBuffer,gpuTexture:null,gpuSampler:null},{type:Tc.SAMPLER_TEXTURE,gpuBuffer:null,gpuTexture:null,gpuSampler:null}],descriptorIndices:this._gpuDescriptorSetLayout.descriptorIndices},this._drawInfo=new Yc(4,0,0,0,0,0,0),this._glFramebuffer=x8.instance.gl.createFramebuffer()}var e=t.prototype;return e.destroy=function(){this._glFramebuffer&&(x8.instance.gl.deleteFramebuffer(this._glFramebuffer),this._glFramebuffer=null),this._gpuVertexBuffer&&(x8.instance.memoryStatus.bufferSize-=this._gpuVertexBuffer.size,Y8(x8.instance,this._gpuVertexBuffer)),this._gpuUniformBuffer&&(x8.instance.memoryStatus.bufferSize-=this._gpuUniformBuffer.size,Y8(x8.instance,this._gpuUniformBuffer)),this._gpuShader&&Q8(x8.instance,this._gpuShader),this._gpuInputAssembler&&$8(x8.instance,this._gpuInputAssembler)},e.draw=function(t,e,i,n){var r=x8.instance,s=r.gl,o=r.stateCache,a=o.glFramebuffer;if(s.viewport(0,0,e.width,e.height),s.scissor(0,0,e.width,e.height),this._uniformBuffer&&this._gpuUniformBuffer&&this._gpuPipelineState&&this._gpuInputAssembler&&this._gpuDescriptorSet&&this._drawInfo){var h=this._gpuDescriptorSet.gpuDescriptors[1];h.gpuTexture=t,h.gpuSampler=n===ic.POINT?this._gpuPointSampler:this._gpuLinearSampler;var u=M_[e.format],l=s.COLOR_ATTACHMENT0;u.hasStencil?l=s.DEPTH_STENCIL_ATTACHMENT:u.hasDepth&&(l=s.DEPTH_ATTACHMENT);var c=i.map((function(t,e){return e}));c.sort((function(t,e){return i[t].srcSubres.mipLevel-i[e].srcSubres.mipLevel})),o.glFramebuffer!==this._glFramebuffer&&(r.gl.bindFramebuffer(r.gl.FRAMEBUFFER,this._glFramebuffer),o.glFramebuffer=this._glFramebuffer);var _=i[0].dstSubres.mipLevel;e.glTexture?s.framebufferTexture2D(s.FRAMEBUFFER,l,e.glTarget,e.glTexture,_):s.framebufferRenderbuffer(s.FRAMEBUFFER,l,s.RENDERBUFFER,e.glRenderbuffer);for(var d=0;d<c.length;++d){var f=i[c[d]];t.glTexture&&_!==f.srcSubres.mipLevel&&(_=f.srcSubres.mipLevel,s.framebufferTexture2D(s.FRAMEBUFFER,l,e.glTarget,e.glTexture,_));var p=t.width,m=t.height,g=e.width,y=e.height;this._uniformBuffer[0]=f.srcExtent.width/p,this._uniformBuffer[1]=f.srcExtent.height/m,this._uniformBuffer[2]=f.srcOffset.x/p,this._uniformBuffer[3]=f.srcOffset.y/m,this._uniformBuffer[4]=f.dstExtent.width/g,this._uniformBuffer[5]=f.dstExtent.height/y,this._uniformBuffer[6]=f.dstOffset.x/g,this._uniformBuffer[7]=f.dstOffset.y/y,K8(r,this._gpuUniformBuffer,this._uniformBuffer,0,this._uniformBuffer.length*Float32Array.BYTES_PER_ELEMENT),n6(r,this._gpuPipelineState,this._gpuInputAssembler,[this._gpuDescriptorSet],[],null),r6(r,this._drawInfo)}o.glFramebuffer!==a&&(r.gl.bindFramebuffer(r.gl.FRAMEBUFFER,a),o.glFramebuffer=a);var v=o.viewport;s.viewport(v.left,v.top,v.width,v.height);var S=o.scissorRect;s.scissor(S.x,S.y,S.width,S.height)}},t}(),d6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuBuffer=null,e._gpuBufferView=null,e._uniformBuffer=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){if("buffer"in t){this._isBufferView=!0;var e=t.buffer;this._usage=e.usage,this._memUsage=e.memUsage,this._size=this._stride=t.range,this._count=1,this._flags=e.flags,this._gpuBufferView={gpuBuffer:e.gpuBuffer,offset:t.offset,range:t.range}}else this._usage=t.usage,this._memUsage=t.memUsage,this._size=t.size,this._stride=Math.max(t.stride||this._size,1),this._count=this._size/this._stride,this._flags=t.flags,this._usage&Xl.UNIFORM&&this._size>0&&(this._uniformBuffer=new Uint8Array(this._size)),this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,vf32:null,indirects:new c6,glTarget:0,glBuffer:null},this._usage&Xl.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),q8(x8.instance,this._gpuBuffer),x8.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(Y8(x8.instance,this._gpuBuffer),x8.instance.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null)},i.resize=function(t){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var e=this._size;e!==t&&(this._size=t,this._count=this._size/this._stride,this._uniformBuffer&&(this._uniformBuffer=new Uint8Array(t)),this._gpuBuffer&&(this._uniformBuffer&&(this._gpuBuffer.buffer=this._uniformBuffer),this._gpuBuffer.size=t,t>0&&(function(t,e){var i=t.gl,n=t.stateCache,r=e.memUsage&Kl.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;e.usage&Xl.VERTEX?(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),t6.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),e.buffer?i.bufferData(i.ARRAY_BUFFER,e.buffer,r):i.bufferData(i.ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null):e.usage&Xl.INDEX?(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),t6.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),e.buffer?i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.buffer,r):i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null):e.usage&Xl.UNIFORM?e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer)):(e.usage&Xl.INDIRECT||e.usage&Xl.TRANSFER_DST||e.usage&Xl.TRANSFER_SRC||V("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE)}(x8.instance,this._gpuBuffer),x8.instance.memoryStatus.bufferSize-=e,x8.instance.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?console.warn("cannot update through buffer views!"):(i=void 0!==e?e:this._usage&Xl.INDIRECT?0:t.byteLength,K8(x8.instance,this._gpuBuffer,t,0,i))},n(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),e}(q_),f6=function(){function t(t,e){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(e),this._freeCmds=new Pu(e);for(var i=0;i<e;++i)this._frees[i]=new t;this._freeIdx=e-1}var e=t.prototype;return e.alloc=function(t){if(this._freeIdx<0){var e=2*this._frees.length,i=this._frees;this._frees=new Array(e);for(var n=e-i.length,r=0;r<n;++r)this._frees[r]=new t;for(var s=n,o=0;s<e;++s,++o)this._frees[s]=i[o];this._freeIdx+=n}var a=this._frees[this._freeIdx];return this._frees[this._freeIdx--]=null,++a.refCount,a},e.free=function(t){0==--t.refCount&&this._freeCmds.push(t)},e.freeCmds=function(t){for(var e=0;e<t.length;++e)0==--t.array[e].refCount&&this._freeCmds.push(t.array[e])},e.release=function(){for(var t=0;t<this._freeCmds.length;++t){var e=this._freeCmds.array[t];e.clear(),this._frees[++this._freeIdx]=e}this._freeCmds.clear()},t}(),p6=function(){function t(){this.beginRenderPassCmdPool=void 0,this.bindStatesCmdPool=void 0,this.drawCmdPool=void 0,this.updateBufferCmdPool=void 0,this.copyBufferToTextureCmdPool=void 0,this.blitTextureCmdPool=void 0,this.beginRenderPassCmdPool=new f6(G8,1),this.bindStatesCmdPool=new f6(U8,1),this.drawCmdPool=new f6(z8,1),this.updateBufferCmdPool=new f6(H8,1),this.copyBufferToTextureCmdPool=new f6(W8,1),this.blitTextureCmdPool=new f6(j8,1)}var e=t.prototype;return e.clearCmds=function(t){t.beginRenderPassCmds.length&&(this.beginRenderPassCmdPool.freeCmds(t.beginRenderPassCmds),t.beginRenderPassCmds.clear()),t.bindStatesCmds.length&&(this.bindStatesCmdPool.freeCmds(t.bindStatesCmds),t.bindStatesCmds.clear()),t.drawCmds.length&&(this.drawCmdPool.freeCmds(t.drawCmds),t.drawCmds.clear()),t.updateBufferCmds.length&&(this.updateBufferCmdPool.freeCmds(t.updateBufferCmds),t.updateBufferCmds.clear()),t.copyBufferToTextureCmds.length&&(this.copyBufferToTextureCmdPool.freeCmds(t.copyBufferToTextureCmds),t.copyBufferToTextureCmds.clear()),t.blitTextureCmds.length&&(this.blitTextureCmdPool.freeCmds(t.blitTextureCmds),t.blitTextureCmds.clear()),t.cmds.clear()},e.releaseCmds=function(){this.beginRenderPassCmdPool.release(),this.bindStatesCmdPool.release(),this.drawCmdPool.release(),this.updateBufferCmdPool.release(),this.copyBufferToTextureCmdPool.release(),this.blitTextureCmdPool.release()},t}(),m6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).cmdPackage=new X8,e._cmdAllocator=new p6,e._isInRenderPass=!1,e._curGPUPipelineState=null,e._curGPUInputAssembler=null,e._curGPUDescriptorSets=[],e._curDynamicOffsets=Array(8).fill(0),e._curDynamicStates=new P_,e._isStateInvalied=!1,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type,this._queue=t.queue;for(var e=x8.instance.bindingMappings.blockOffsets.length,i=0;i<e;i++)this._curGPUDescriptorSets.push(null)},i.destroy=function(){this._cmdAllocator.clearCmds(this.cmdPackage)},i.begin=function(){this._cmdAllocator.clearCmds(this.cmdPackage),this._curGPUPipelineState=null,this._curGPUInputAssembler=null,this._curGPUDescriptorSets.length=0,this._numDrawCalls=0,this._numInstances=0,this._numTris=0},i.end=function(){this._isStateInvalied&&this.bindStates(),this._isInRenderPass=!1},i.beginRenderPass=function(t,e,i,n,r,s){var o=this._cmdAllocator.beginRenderPassCmdPool.alloc(G8);o.gpuRenderPass=t.gpuRenderPass,o.gpuFramebuffer=e.gpuFramebuffer,o.renderArea.copy(i),o.clearColors.length=n.length;for(var a=0;a<n.length;++a)o.clearColors[a]=n[a];o.clearDepth=r,o.clearStencil=s,this.cmdPackage.beginRenderPassCmds.push(o),this.cmdPackage.cmds.push(M8.BEGIN_RENDER_PASS),this._isInRenderPass=!0},i.endRenderPass=function(){this._isInRenderPass=!1},i.bindPipelineState=function(t){var e=t.gpuPipelineState;e!==this._curGPUPipelineState&&(this._curGPUPipelineState=e,this._isStateInvalied=!0)},i.bindDescriptorSet=function(t,e,i){var n=e.gpuDescriptorSet;if(n!==this._curGPUDescriptorSets[t]&&(this._curGPUDescriptorSets[t]=n,this._isStateInvalied=!0),i){var r,s=null===(r=this._curGPUPipelineState)||void 0===r?void 0:r.gpuPipelineLayout;if(s){for(var o=this._curDynamicOffsets,a=s.dynamicOffsetOffsets[t],h=0;h<i.length;h++)o[a+h]=i[h];this._isStateInvalied=!0}}},i.bindInputAssembler=function(t){var e=t.gpuInputAssembler;this._curGPUInputAssembler=e,this._isStateInvalied=!0},i.setViewport=function(t){var e=this._curDynamicStates.viewport;e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height&&e.minDepth===t.minDepth&&e.maxDepth===t.maxDepth||(e.left=t.left,e.top=t.top,e.width=t.width,e.height=t.height,e.minDepth=t.minDepth,e.maxDepth=t.maxDepth,this._isStateInvalied=!0)},i.setScissor=function(t){var e=this._curDynamicStates.scissor;e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,this._isStateInvalied=!0)},i.setLineWidth=function(t){this._curDynamicStates.lineWidth!==t&&(this._curDynamicStates.lineWidth=t,this._isStateInvalied=!0)},i.setDepthBias=function(t,e,i){var n=this._curDynamicStates;n.depthBiasConstant===t&&n.depthBiasClamp===e&&n.depthBiasSlope===i||(n.depthBiasConstant=t,n.depthBiasClamp=e,n.depthBiasSlope=i,this._isStateInvalied=!0)},i.setBlendConstants=function(t){var e=this._curDynamicStates.blendConstant;e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w||(e.copy(t),this._isStateInvalied=!0)},i.setDepthBound=function(t,e){var i=this._curDynamicStates;i.depthMinBounds===t&&i.depthMaxBounds===e||(i.depthMinBounds=t,i.depthMaxBounds=e,this._isStateInvalied=!0)},i.setStencilWriteMask=function(t,e){var i=this._curDynamicStates.stencilStatesFront,n=this._curDynamicStates.stencilStatesBack;t&Sc.FRONT&&i.writeMask!==e&&(i.writeMask=e,this._isStateInvalied=!0),t&Sc.BACK&&n.writeMask!==e&&(n.writeMask=e,this._isStateInvalied=!0)},i.setStencilCompareMask=function(t,e,i){var n=this._curDynamicStates.stencilStatesFront,r=this._curDynamicStates.stencilStatesBack;t&Sc.FRONT&&(n.compareMask===i&&n.reference===e||(n.reference=e,n.compareMask=i,this._isStateInvalied=!0)),t&Sc.BACK&&(r.compareMask===i&&r.reference===e||(r.reference=e,r.compareMask=i,this._isStateInvalied=!0))},i.draw=function(t){if(this._type===Ec.PRIMARY&&this._isInRenderPass||this._type===Ec.SECONDARY){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t,i=this._cmdAllocator.drawCmdPool.alloc(z8);i.drawInfo.copy(e),this.cmdPackage.drawCmds.push(i),this.cmdPackage.cmds.push(M8.DRAW),++this._numDrawCalls,this._numInstances+=e.instanceCount;var n=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=n/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(n-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.updateBuffer=function(t,e,i){if(this._type===Ec.PRIMARY&&!this._isInRenderPass||this._type===Ec.SECONDARY){var n=t.gpuBuffer;if(n){var r,s=this._cmdAllocator.updateBufferCmdPool.alloc(H8),o=0;t.usage&Xl.INDIRECT||(o=void 0!==i?i:e.byteLength),r=e,s.gpuBuffer=n,s.buffer=r,s.offset=0,s.size=o,this.cmdPackage.updateBufferCmds.push(s),this.cmdPackage.cmds.push(M8.UPDATE_BUFFER)}}else console.error("Command 'updateBuffer' must be recorded outside a render pass.")},i.copyBuffersToTexture=function(t,e,i){if(this._type===Ec.PRIMARY&&!this._isInRenderPass||this._type===Ec.SECONDARY){var n=e.gpuTexture;if(n){var r=this._cmdAllocator.copyBufferToTextureCmdPool.alloc(W8);r&&(r.gpuTexture=n,r.regions=i,r.buffers=t,this.cmdPackage.copyBufferToTextureCmds.push(r),this.cmdPackage.cmds.push(M8.COPY_BUFFER_TO_TEXTURE))}}else console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.")},i.execute=function(t,e){for(var i=0;i<e;++i){for(var n=t[i],r=0;r<n.cmdPackage.beginRenderPassCmds.length;++r){var s=n.cmdPackage.beginRenderPassCmds.array[r];++s.refCount,this.cmdPackage.beginRenderPassCmds.push(s)}for(var o=0;o<n.cmdPackage.bindStatesCmds.length;++o){var a=n.cmdPackage.bindStatesCmds.array[o];++a.refCount,this.cmdPackage.bindStatesCmds.push(a)}for(var h=0;h<n.cmdPackage.drawCmds.length;++h){var u=n.cmdPackage.drawCmds.array[h];++u.refCount,this.cmdPackage.drawCmds.push(u)}for(var l=0;l<n.cmdPackage.updateBufferCmds.length;++l){var c=n.cmdPackage.updateBufferCmds.array[l];++c.refCount,this.cmdPackage.updateBufferCmds.push(c)}for(var _=0;_<n.cmdPackage.copyBufferToTextureCmds.length;++_){var d=n.cmdPackage.copyBufferToTextureCmds.array[_];++d.refCount,this.cmdPackage.copyBufferToTextureCmds.push(d)}for(var f=0;f<n.cmdPackage.blitTextureCmds.length;++f){var p=n.cmdPackage.blitTextureCmds.array[f];++p.refCount,this.cmdPackage.blitTextureCmds.push(p)}this.cmdPackage.cmds.concat(n.cmdPackage.cmds.array),this._numDrawCalls+=n._numDrawCalls,this._numInstances+=n._numInstances,this._numTris+=n._numTris}},i.pipelineBarrier=function(){},i.bindStates=function(){var t=this._cmdAllocator.bindStatesCmdPool.alloc(U8);t&&(t.gpuPipelineState=this._curGPUPipelineState,Array.prototype.push.apply(t.gpuDescriptorSets,this._curGPUDescriptorSets),Array.prototype.push.apply(t.dynamicOffsets,this._curDynamicOffsets),t.gpuInputAssembler=this._curGPUInputAssembler,t.dynamicStates.copy(this._curDynamicStates),this.cmdPackage.bindStatesCmds.push(t),this.cmdPackage.cmds.push(M8.BIND_STATES),this._isStateInvalied=!1)},i.blitTexture=function(t,e,i,n){var r=this._cmdAllocator.blitTextureCmdPool.alloc(j8);r.srcTexture=t.gpuTexture,r.dstTexture=e.gpuTexture,r.regions=i,r.filter=n,++this._numDrawCalls,this.cmdPackage.blitTextureCmds.push(r),this.cmdPackage.cmds.push(M8.BLIT_TEXTURE)},e}(Y_),g6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuFramebuffer=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._renderPass=t.renderPass,this._colorTextures=t.colorTextures||[],this._depthStencilTexture=t.depthStencilTexture||null;for(var e=0,i=[],n=0;n<t.colorTextures.length;++n){var r=t.colorTextures[n];r&&(i.push(r.gpuTexture),e=r.lodLevel)}var s=null;t.depthStencilTexture&&(s=t.depthStencilTexture.gpuTexture,e=t.depthStencilTexture.lodLevel);var o=Number.MAX_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER;this._gpuFramebuffer={gpuRenderPass:t.renderPass.gpuRenderPass,gpuColorTextures:i,gpuDepthStencilTexture:s,glFramebuffer:null,isOffscreen:!0,get width(){return this.gpuColorTextures.length>0?this.gpuColorTextures[0].width:this.gpuDepthStencilTexture?this.gpuDepthStencilTexture.width:o},set width(t){o=t},get height(){return this.gpuColorTextures.length>0?this.gpuColorTextures[0].height:this.gpuDepthStencilTexture?this.gpuDepthStencilTexture.height:a},set height(t){a=t},lodLevel:e},function(t,e){for(var i=0;i<e.gpuColorTextures.length;++i)if(e.gpuColorTextures[i].isSwapchainTexture)return void(e.isOffscreen=!1);var n=t.gl,r=[],s=n.createFramebuffer();if(s){e.glFramebuffer=s,t.stateCache.glFramebuffer!==e.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,e.glFramebuffer);for(var o=0;o<e.gpuColorTextures.length;++o){var a=e.gpuColorTextures[o];a&&(a.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,a.glTarget,a.glTexture,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,n.RENDERBUFFER,a.glRenderbuffer),r.push(n.COLOR_ATTACHMENT0+o),e.width=Math.min(e.width,a.width),e.height=Math.min(e.height,a.height))}var h=e.gpuDepthStencilTexture;if(h){var u=M_[h.format].hasStencil?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;h.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,u,h.glTarget,h.glTexture,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,u,n.RENDERBUFFER,h.glRenderbuffer),e.width=Math.min(e.width,h.width),e.height=Math.min(e.height,h.height)}t.extensions.WEBGL_draw_buffers&&t.extensions.WEBGL_draw_buffers.drawBuffersWEBGL(r);var l=n.checkFramebufferStatus(n.FRAMEBUFFER);if(l!==n.FRAMEBUFFER_COMPLETE)switch(l){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:V("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:V("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:V("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case n.FRAMEBUFFER_UNSUPPORTED:V("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED")}t.stateCache.glFramebuffer!==e.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,t.stateCache.glFramebuffer)}}(x8.instance,this._gpuFramebuffer),this._width=this._gpuFramebuffer.width,this._height=this._gpuFramebuffer.height},i.destroy=function(){var t,e;this._gpuFramebuffer&&(t=x8.instance,(e=this._gpuFramebuffer).glFramebuffer&&(t.gl.deleteFramebuffer(e.glFramebuffer),t.stateCache.glFramebuffer===e.glFramebuffer&&(t.gl.bindFramebuffer(t.gl.FRAMEBUFFER,null),t.stateCache.glFramebuffer=null),e.glFramebuffer=null),this._gpuFramebuffer=null)},n(e,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}}]),e}(Z_),y6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuInputAssembler=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){if(0!==t.vertexBuffers.length){if(this._attributes=t.attributes,this._attributesHash=this.computeAttributesHash(),this._vertexBuffers=t.vertexBuffers,t.indexBuffer)this._indexBuffer=t.indexBuffer,this._drawInfo.indexCount=this._indexBuffer.size/this._indexBuffer.stride,this._drawInfo.firstIndex=0;else{var e=this._vertexBuffers[0];this._drawInfo.vertexCount=e.size/e.stride,this._drawInfo.firstVertex=0,this._drawInfo.vertexOffset=0}this._drawInfo.instanceCount=0,this._drawInfo.firstInstance=0,this._indirectBuffer=t.indirectBuffer||null;for(var i=new Array(t.vertexBuffers.length),n=0;n<t.vertexBuffers.length;++n){var r=t.vertexBuffers[n];r.gpuBuffer&&(i[n]=r.gpuBuffer)}var s=null,o=0;if(t.indexBuffer&&(s=t.indexBuffer.gpuBuffer))switch(s.stride){case 1:o=5121;break;case 2:o=5123;break;case 4:o=5125;break;default:console.error("Error index buffer stride.")}var a=null;t.indirectBuffer&&(a=t.indirectBuffer.gpuBuffer),this._gpuInputAssembler={attributes:t.attributes,gpuVertexBuffers:i,gpuIndexBuffer:s,gpuIndirectBuffer:a,glAttribs:[],glIndexType:o,glVAOs:new Map},Z8(x8.instance,this._gpuInputAssembler)}else console.error("InputAssemblerInfo.vertexBuffers is null.")},i.destroy=function(){var t=x8.instance;this._gpuInputAssembler&&t.extensions.useVAO&&$8(t,this._gpuInputAssembler),this._gpuInputAssembler=null},n(e,[{key:"gpuInputAssembler",get:function(){return this._gpuInputAssembler}}]),e}($_),v6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuDescriptorSetLayout=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){Array.prototype.push.apply(this._bindings,t.bindings);for(var e=0,i=-1,n=[],r=0;r<this._bindings.length;r++){var s=this._bindings[r];n.push(e),e+=s.count,s.binding>i&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var o=this._descriptorIndices=Array(i+1).fill(-1),a=0;a<this._bindings.length;a++){var h=this._bindings[a];this._bindingIndices[h.binding]=a,o[h.binding]=n[a]}for(var u=[],l=0;l<this._bindings.length;l++){var c=this._bindings[l];if(c.descriptorType&F_)for(var _=0;_<c.count;_++)u.push(c.binding)}this._gpuDescriptorSetLayout={bindings:this._bindings,dynamicBindings:u,descriptorIndices:o,descriptorCount:e}},i.destroy=function(){this._bindings.length=0},n(e,[{key:"gpuDescriptorSetLayout",get:function(){return this._gpuDescriptorSetLayout}}]),e}(ed),S6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuPipelineLayout=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){Array.prototype.push.apply(this._setLayouts,t.setLayouts);for(var e=[],i=[],n=0,r=[],s=0;s<this._setLayouts.length;s++){for(var o=this._setLayouts[s],a=o.gpuDescriptorSetLayout.dynamicBindings,h=Array(o.bindingIndices.length).fill(-1),u=0;u<a.length;u++){var l=a[u];h[l]<0&&(h[l]=n+u)}i.push(o.gpuDescriptorSetLayout),e.push(h),r.push(n),n+=a.length}this._gpuPipelineLayout={gpuSetLayouts:i,dynamicOffsetIndices:e,dynamicOffsetCount:n,dynamicOffsetOffsets:r}},i.destroy=function(){this._setLayouts.length=0},n(e,[{key:"gpuPipelineLayout",get:function(){return this._gpuPipelineLayout}}]),e}(id),T6=[0,1,3,2,0,0,0,4,5,6,0,0,0,0],A6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuPipelineState=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._primitive=t.primitive,this._shader=t.shader,this._pipelineLayout=t.pipelineLayout;var e=this._bs;if(t.blendState){var i=t.blendState,n=i.targets;n&&n.forEach((function(t,i){e.setTarget(i,t)})),void 0!==i.isA2C&&(e.isA2C=i.isA2C),void 0!==i.isIndepend&&(e.isIndepend=i.isIndepend),void 0!==i.blendColor&&(e.blendColor=i.blendColor)}Object.assign(this._rs,t.rasterizerState),Object.assign(this._dss,t.depthStencilState),this._is=t.inputState,this._renderPass=t.renderPass,this._dynamicStates=t.dynamicStates;for(var r=[],s=0;s<31;s++)this._dynamicStates&1<<s&&r.push(1<<s);this._gpuPipelineState={glPrimitive:T6[t.primitive],gpuShader:t.shader.gpuShader,gpuPipelineLayout:t.pipelineLayout.gpuPipelineLayout,rs:t.rasterizerState,dss:t.depthStencilState,bs:t.blendState,gpuRenderPass:t.renderPass.gpuRenderPass,dynamicStates:r}},i.destroy=function(){this._gpuPipelineState=null},n(e,[{key:"gpuPipelineState",get:function(){return this._gpuPipelineState}}]),e}(hd),b6=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.beginRenderPass=function(t,e,i,n,r,s){i6(x8.instance,t.gpuRenderPass,e.gpuFramebuffer,i,n,r,s),this._isInRenderPass=!0},i.draw=function(t){if(this._isInRenderPass){this._isStateInvalied&&this.bindStates();var e="drawInfo"in t?t.drawInfo:t;r6(x8.instance,e),++this._numDrawCalls,this._numInstances+=e.instanceCount;var i=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=i/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(i-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},i.setViewport=function(t){var e=x8.instance,i=e.stateCache,n=e.gl;i.viewport.left===t.left&&i.viewport.top===t.top&&i.viewport.width===t.width&&i.viewport.height===t.height||(n.viewport(t.left,t.top,t.width,t.height),i.viewport.left=t.left,i.viewport.top=t.top,i.viewport.width=t.width,i.viewport.height=t.height)},i.setScissor=function(t){var e=x8.instance,i=e.stateCache,n=e.gl;i.scissorRect.x===t.x&&i.scissorRect.y===t.y&&i.scissorRect.width===t.width&&i.scissorRect.height===t.height||(n.scissor(t.x,t.y,t.width,t.height),i.scissorRect.x=t.x,i.scissorRect.y=t.y,i.scissorRect.width=t.width,i.scissorRect.height=t.height)},i.updateBuffer=function(t,e,i){if(this._isInRenderPass)console.error("Command 'updateBuffer' must be recorded outside a render pass.");else{var n,r=t.gpuBuffer;r&&(n=void 0!==i?i:t.usage&Xl.INDIRECT?0:e.byteLength,K8(x8.instance,r,e,0,n))}},i.copyBuffersToTexture=function(t,e,i){if(this._isInRenderPass)console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.");else{var n=e.gpuTexture;n&&u6(x8.instance,t,n,i)}},i.execute=function(t,e){for(var i=0;i<e;++i){var n=t[i];o6(x8.instance,n.cmdPackage),this._numDrawCalls+=n._numDrawCalls,this._numInstances+=n._numInstances,this._numTris+=n._numTris}},i.bindStates=function(){n6(x8.instance,this._curGPUPipelineState,this._curGPUInputAssembler,this._curGPUDescriptorSets,this._curDynamicOffsets,this._curDynamicStates),this._isStateInvalied=!1},i.blitTexture=function(t,e,i,n){var r=t.gpuTexture,s=e.gpuTexture;l6(x8.instance,r,s,i,n)},e}(m6),E6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).numDrawCalls=0,e.numInstances=0,e.numTris=0,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type},i.destroy=function(){},i.submit=function(t){for(var e=t.length,i=0;i<e;i++){var n=t[i];this.numDrawCalls+=n.numDrawCalls,this.numInstances+=n.numInstances,this.numTris+=n.numTris}},i.clear=function(){this.numDrawCalls=0,this.numInstances=0,this.numTris=0},e}(ud),C6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuRenderPass=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._colorInfos=t.colorAttachments,this._depthStencilInfo=t.depthStencilAttachment,this._subpasses=t.subpasses,this._gpuRenderPass={colorAttachments:this._colorInfos,depthStencilAttachment:this._depthStencilInfo},this._hash=this.computeHash()},i.destroy=function(){this._gpuRenderPass=null},n(e,[{key:"gpuRenderPass",get:function(){return this._gpuRenderPass}}]),e}(ld),w6=[10497,33648,33071,33071],x6=function(t){function e(e,i){var n;(n=t.call(this,e,i)||this)._gpuSampler=null;var r,s,o=n._info.minFilter,a=n._info.magFilter,h=n._info.mipFilter;r=o===ic.LINEAR||o===ic.ANISOTROPIC?h===ic.LINEAR||h===ic.ANISOTROPIC?9987:h===ic.POINT?9985:9729:h===ic.LINEAR||h===ic.ANISOTROPIC?9986:h===ic.POINT?9984:9728,s=a===ic.LINEAR||a===ic.ANISOTROPIC?9729:9728;var u=w6[n._info.addressU],l=w6[n._info.addressV],c=w6[n._info.addressW];return n._gpuSampler={glMinFilter:r,glMagFilter:s,glWrapS:u,glWrapT:l,glWrapR:c},n}return s(e,t),n(e,[{key:"gpuSampler",get:function(){return this._gpuSampler}}]),e}(cd),R6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuShader=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._name=t.name,this._stages=t.stages,this._attributes=t.attributes,this._blocks=t.blocks,this._samplers=t.samplers,this._gpuShader={name:t.name,blocks:t.blocks.slice(),samplerTextures:t.samplerTextures.slice(),subpassInputs:t.subpassInputs.slice(),gpuStages:new Array(t.stages.length),glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplerTextures:[]};for(var e=0;e<t.stages.length;++e){var i=t.stages[e];this._gpuShader.gpuStages[e]={type:i.stage,source:i.source,glShader:null}}},i.destroy=function(){this._gpuShader&&(Q8(x8.instance,this._gpuShader),this._gpuShader=null)},n(e,[{key:"gpuShader",get:function(){return null===this._gpuShader.glProgram&&J8(x8.instance,this._gpuShader),this._gpuShader}}]),e}(_d),I6=function(){function t(){this.glArrayBuffer=null,this.glElementArrayBuffer=null,this.glVAO=null,this.texUnit=0,this.glTexUnits=[],this.glRenderbuffer=null,this.glFramebuffer=null,this.viewport=new Uc,this.scissorRect=new Mc(0,0,0,0),this.rs=new nd,this.dss=new rd,this.bs=new od,this.glProgram=null,this.glEnabledAttribLocs=[],this.glCurrentAttribLocs=[],this.texUnitCacheMap={}}return t.prototype.initialize=function(t,e){for(var i=0;i<t;++i)this.glTexUnits.push({glTexture:null});this.glEnabledAttribLocs.length=e,this.glEnabledAttribLocs.fill(!1),this.glCurrentAttribLocs.length=e,this.glCurrentAttribLocs.fill(!1)},t}(),B6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._gpuTexture=null,e._lodLevel=0,e}s(e,t);var i=e.prototype;return i.initialize=function(t,e){var i=t,n=t;"texture"in t&&(i=n.texture.info,this._isTextureView=!0),this._info.copy(i),this._isPowerOf2=k_(this._info.width)&&k_(this._info.height),this._size=G_(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,this._isTextureView?(this._viewInfo.copy(n),this._lodLevel=n.baseLevel,this._gpuTexture=n.texture._gpuTexture):(this._gpuTexture={type:i.type,format:i.format,usage:i.usage,width:i.width,height:i.height,depth:i.depth,size:this._size,arrayLayer:i.layerCount,mipLevel:i.levelCount,samples:i.samples,flags:i.flags,isPowerOf2:this._isPowerOf2,glTarget:0,glInternalFmt:0,glFormat:0,glType:0,glUsage:0,glTexture:null,glRenderbuffer:null,glWrapS:0,glWrapT:0,glMinFilter:0,glMagFilter:0,isSwapchainTexture:e||!1},this._gpuTexture.isSwapchainTexture||(function(t,e){var i=t.gl;e.glFormat=e.glInternalFmt=function(t,e){switch(t){case Hl.A8:return e.ALPHA;case Hl.L8:return e.LUMINANCE;case Hl.LA8:return e.LUMINANCE_ALPHA;case Hl.RGB8:case Hl.RGB16F:case Hl.RGB32F:return e.RGB;case Hl.BGRA8:case Hl.RGBA8:case Hl.SRGB8_A8:case Hl.RGBA16F:case Hl.RGBA32F:return e.RGBA;case Hl.R5G6B5:return e.RGB;case Hl.RGB5A1:case Hl.RGBA4:return e.RGBA;case Hl.DEPTH:return e.DEPTH_COMPONENT;case Hl.DEPTH_STENCIL:return e.DEPTH_STENCIL;case Hl.BC1:return C8.COMPRESSED_RGB_S3TC_DXT1_EXT;case Hl.BC1_ALPHA:return C8.COMPRESSED_RGBA_S3TC_DXT1_EXT;case Hl.BC1_SRGB:return C8.COMPRESSED_SRGB_S3TC_DXT1_EXT;case Hl.BC1_SRGB_ALPHA:return C8.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case Hl.BC2:return C8.COMPRESSED_RGBA_S3TC_DXT3_EXT;case Hl.BC2_SRGB:return C8.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case Hl.BC3:return C8.COMPRESSED_RGBA_S3TC_DXT5_EXT;case Hl.BC3_SRGB:return C8.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case Hl.ETC_RGB8:return C8.COMPRESSED_RGB_ETC1_WEBGL;case Hl.ETC2_RGB8:return C8.COMPRESSED_RGB8_ETC2;case Hl.ETC2_SRGB8:return C8.COMPRESSED_SRGB8_ETC2;case Hl.ETC2_RGB8_A1:return C8.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case Hl.ETC2_SRGB8_A1:return C8.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case Hl.ETC2_RGBA8:return C8.COMPRESSED_RGBA8_ETC2_EAC;case Hl.ETC2_SRGB8_A8:return C8.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case Hl.EAC_R11:return C8.COMPRESSED_R11_EAC;case Hl.EAC_R11SN:return C8.COMPRESSED_SIGNED_R11_EAC;case Hl.EAC_RG11:return C8.COMPRESSED_RG11_EAC;case Hl.EAC_RG11SN:return C8.COMPRESSED_SIGNED_RG11_EAC;case Hl.PVRTC_RGB2:return C8.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case Hl.PVRTC_RGBA2:return C8.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case Hl.PVRTC_RGB4:return C8.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case Hl.PVRTC_RGBA4:return C8.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case Hl.ASTC_RGBA_4X4:return C8.COMPRESSED_RGBA_ASTC_4x4_KHR;case Hl.ASTC_RGBA_5X4:return C8.COMPRESSED_RGBA_ASTC_5x4_KHR;case Hl.ASTC_RGBA_5X5:return C8.COMPRESSED_RGBA_ASTC_5x5_KHR;case Hl.ASTC_RGBA_6X5:return C8.COMPRESSED_RGBA_ASTC_6x5_KHR;case Hl.ASTC_RGBA_6X6:return C8.COMPRESSED_RGBA_ASTC_6x6_KHR;case Hl.ASTC_RGBA_8X5:return C8.COMPRESSED_RGBA_ASTC_8x5_KHR;case Hl.ASTC_RGBA_8X6:return C8.COMPRESSED_RGBA_ASTC_8x6_KHR;case Hl.ASTC_RGBA_8X8:return C8.COMPRESSED_RGBA_ASTC_8x8_KHR;case Hl.ASTC_RGBA_10X5:return C8.COMPRESSED_RGBA_ASTC_10x5_KHR;case Hl.ASTC_RGBA_10X6:return C8.COMPRESSED_RGBA_ASTC_10x6_KHR;case Hl.ASTC_RGBA_10X8:return C8.COMPRESSED_RGBA_ASTC_10x8_KHR;case Hl.ASTC_RGBA_10X10:return C8.COMPRESSED_RGBA_ASTC_10x10_KHR;case Hl.ASTC_RGBA_12X10:return C8.COMPRESSED_RGBA_ASTC_12x10_KHR;case Hl.ASTC_RGBA_12X12:return C8.COMPRESSED_RGBA_ASTC_12x12_KHR;case Hl.ASTC_SRGBA_4X4:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case Hl.ASTC_SRGBA_5X4:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case Hl.ASTC_SRGBA_5X5:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case Hl.ASTC_SRGBA_6X5:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case Hl.ASTC_SRGBA_6X6:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case Hl.ASTC_SRGBA_8X5:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case Hl.ASTC_SRGBA_8X6:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case Hl.ASTC_SRGBA_8X8:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case Hl.ASTC_SRGBA_10X5:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case Hl.ASTC_SRGBA_10X6:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case Hl.ASTC_SRGBA_10X8:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case Hl.ASTC_SRGBA_10X10:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case Hl.ASTC_SRGBA_12X10:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case Hl.ASTC_SRGBA_12X12:return C8.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return V("Unsupported Format, convert to WebGL format failed."),e.RGBA}}(e.format,i),e.glType=R8(e.format,i);var n=e.width,r=e.height;switch(e.type){case Jl.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(n,r);if(s>t.capabilities.maxTextureSize&&J(9100,s,t.capabilities.maxTextureSize),t.textureExclusive[e.format]||t.extensions.WEBGL_depth_texture||!M_[e.format].hasDepth){if(e.glTexture=i.createTexture(),e.size>0){var o=t.stateCache.glTexUnits[t.stateCache.texUnit];if(o.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),o.glTexture=e.glTexture),M_[e.format].isCompressed)for(var a=0;a<e.mipLevel;++a){var h=V_(e.format,n,r,1),u=new Uint8Array(h);i.compressedTexImage2D(i.TEXTURE_2D,a,e.glInternalFmt,n,r,0,u),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else for(var l=0;l<e.mipLevel;++l)i.texImage2D(i.TEXTURE_2D,l,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null),n=Math.max(1,n>>1),r=Math.max(1,r>>1);e.isPowerOf2?(e.glWrapS=i.REPEAT,e.glWrapT=i.REPEAT):(e.glWrapS=i.CLAMP_TO_EDGE,e.glWrapT=i.CLAMP_TO_EDGE),e.glMinFilter=i.LINEAR,e.glMagFilter=i.LINEAR,i.texParameteri(e.glTarget,i.TEXTURE_WRAP_S,e.glWrapS),i.texParameteri(e.glTarget,i.TEXTURE_WRAP_T,e.glWrapT),i.texParameteri(e.glTarget,i.TEXTURE_MIN_FILTER,e.glMinFilter),i.texParameteri(e.glTarget,i.TEXTURE_MAG_FILTER,e.glMagFilter)}}else e.glInternalFmt=function(t,e){switch(t){case Hl.R5G6B5:return e.RGB565;case Hl.RGB5A1:return e.RGB5_A1;case Hl.RGBA4:return e.RGBA4;case Hl.RGBA16F:return C8.RGBA16F_EXT;case Hl.RGBA32F:return C8.RGBA32F_EXT;case Hl.SRGB8_A8:return C8.SRGB8_ALPHA8_EXT;case Hl.DEPTH:return e.DEPTH_COMPONENT16;case Hl.DEPTH_STENCIL:return e.DEPTH_STENCIL;default:return V("Unsupported Format, convert to WebGL internal format failed."),e.RGBA}}(e.format,i),e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,n,r));break;case Jl.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(n,r);if(c>t.capabilities.maxCubeMapTextureSize&&J(9100,c,t.capabilities.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var _=t.stateCache.glTexUnits[t.stateCache.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),_.glTexture=e.glTexture),M_[e.format].isCompressed)for(var d=0;d<6;++d){n=e.width,r=e.height;for(var f=0;f<e.mipLevel;++f){var p=V_(e.format,n,r,1),m=new Uint8Array(p);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+d,f,e.glInternalFmt,n,r,0,m),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}}else for(var g=0;g<6;++g){n=e.width,r=e.height;for(var y=0;y<e.mipLevel;++y)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+g,y,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}e.isPowerOf2?(e.glWrapS=i.REPEAT,e.glWrapT=i.REPEAT):(e.glWrapS=i.CLAMP_TO_EDGE,e.glWrapT=i.CLAMP_TO_EDGE),e.glMinFilter=i.LINEAR,e.glMagFilter=i.LINEAR,i.texParameteri(e.glTarget,i.TEXTURE_WRAP_S,e.glWrapS),i.texParameteri(e.glTarget,i.TEXTURE_WRAP_T,e.glWrapT),i.texParameteri(e.glTarget,i.TEXTURE_MIN_FILTER,e.glMinFilter),i.texParameteri(e.glTarget,i.TEXTURE_MAG_FILTER,e.glMagFilter)}break;default:V("Unsupported TextureType, create texture failed."),e.type=Jl.TEX2D,e.glTarget=i.TEXTURE_2D}}(x8.instance,this._gpuTexture),x8.instance.memoryStatus.textureSize+=this._size),this._viewInfo.texture=this,this._viewInfo.type=t.type,this._viewInfo.format=t.format,this._viewInfo.baseLevel=0,this._viewInfo.levelCount=t.levelCount,this._viewInfo.baseLayer=0,this._viewInfo.layerCount=t.layerCount)},i.destroy=function(){!this._isTextureView&&this._gpuTexture&&(function(t,e){var i=t.gl;if(e.glTexture){var n=t.stateCache.glTexUnits,r=t.stateCache.texUnit;i.deleteTexture(e.glTexture);for(var s=0;s<n.length;s++)n[s].glTexture===e.glTexture&&(i.activeTexture(i.TEXTURE0+s),r=s,i.bindTexture(e.glTarget,null),n[s].glTexture=null);t.stateCache.texUnit=r,e.glTexture=null}if(e.glRenderbuffer){var o=t.stateCache.glRenderbuffer;i.deleteRenderbuffer(e.glRenderbuffer),o===e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,null),o=null),e.glRenderbuffer=null}}(x8.instance,this._gpuTexture),x8.instance.memoryStatus.textureSize-=this._size,this._gpuTexture=null)},i.getGLTextureHandle=function(){var t=this._gpuTexture;return t?t.glTexture?t.glTexture:t.glRenderbuffer?t.glRenderbuffer:0:0},i.resize=function(t,i){if(this._info.width!==t||this._info.height!==i){this._info.levelCount===e.getLevelCount(this._info.width,this._info.height)?this._info.levelCount=e.getLevelCount(t,i):this._info.levelCount>1&&(this._info.levelCount=Math.min(this._info.levelCount,e.getLevelCount(t,i)));var n=this._size;this._info.width=t,this._info.height=i,this._size=G_(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,!this._isTextureView&&this._gpuTexture&&(this._gpuTexture.width=t,this._gpuTexture.height=i,this._gpuTexture.size=this._size,this._gpuTexture.isSwapchainTexture||(function(t,e){if(e.size){var i=t.gl,n=e.width,r=e.height;switch(e.type){case Jl.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(n,r);if(s>t.capabilities.maxTextureSize&&J(9100,s,t.capabilities.maxTextureSize),e.glRenderbuffer)t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,n,r);else if(e.glTexture){var o=t.stateCache.glTexUnits[t.stateCache.texUnit];if(o.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),o.glTexture=e.glTexture),M_[e.format].isCompressed)for(var a=0;a<e.mipLevel;++a){var h=V_(e.format,n,r,1),u=new Uint8Array(h);i.compressedTexImage2D(i.TEXTURE_2D,a,e.glInternalFmt,n,r,0,u),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}else for(var l=0;l<e.mipLevel;++l)i.texImage2D(i.TEXTURE_2D,l,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}break;case Jl.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(n,r);c>t.capabilities.maxCubeMapTextureSize&&J(9100,c,t.capabilities.maxTextureSize);var _=t.stateCache.glTexUnits[t.stateCache.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),_.glTexture=e.glTexture),M_[e.format].isCompressed)for(var d=0;d<6;++d){n=e.width,r=e.height;for(var f=0;f<e.mipLevel;++f){var p=V_(e.format,n,r,1),m=new Uint8Array(p);i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+d,f,e.glInternalFmt,n,r,0,m),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}}else for(var g=0;g<6;++g){n=e.width,r=e.height;for(var y=0;y<e.mipLevel;++y)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+g,y,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null),n=Math.max(1,n>>1),r=Math.max(1,r>>1)}break;default:V("Unsupported TextureType, create texture failed."),e.type=Jl.TEX2D,e.glTarget=i.TEXTURE_2D}}}(x8.instance,this._gpuTexture),x8.instance.memoryStatus.textureSize-=n,x8.instance.memoryStatus.textureSize+=this._size))}},i.initAsSwapchainTexture=function(t){var e=new Qc;e.format=t.format,e.usage=M_[t.format].hasDepth?Ql.DEPTH_STENCIL_ATTACHMENT:Ql.COLOR_ATTACHMENT,e.width=t.width,e.height=t.height,this.initialize(e,!0)},n(e,[{key:"gpuTexture",get:function(){return this._gpuTexture}},{key:"lodLevel",get:function(){return this._lodLevel}}]),e}(dd),D6="webglcontextlost";function P6(t,e){for(var i=["","WEBKIT_","MOZ_"],n=0;n<i.length;++n){var r=t.getExtension(i[n]+e);if(r)return r}return null}function O6(t){var e={EXT_texture_filter_anisotropic:P6(t,"EXT_texture_filter_anisotropic"),EXT_blend_minmax:P6(t,"EXT_blend_minmax"),EXT_frag_depth:P6(t,"EXT_frag_depth"),EXT_shader_texture_lod:P6(t,"EXT_shader_texture_lod"),EXT_sRGB:P6(t,"EXT_sRGB"),OES_vertex_array_object:P6(t,"OES_vertex_array_object"),EXT_color_buffer_half_float:P6(t,"EXT_color_buffer_half_float"),WEBGL_color_buffer_float:P6(t,"WEBGL_color_buffer_float"),WEBGL_compressed_texture_etc1:P6(t,"WEBGL_compressed_texture_etc1"),WEBGL_compressed_texture_etc:P6(t,"WEBGL_compressed_texture_etc"),WEBGL_compressed_texture_pvrtc:P6(t,"WEBGL_compressed_texture_pvrtc"),WEBGL_compressed_texture_s3tc:P6(t,"WEBGL_compressed_texture_s3tc"),WEBGL_compressed_texture_s3tc_srgb:P6(t,"WEBGL_compressed_texture_s3tc_srgb"),WEBGL_debug_shaders:P6(t,"WEBGL_debug_shaders"),WEBGL_draw_buffers:P6(t,"WEBGL_draw_buffers"),WEBGL_lose_context:P6(t,"WEBGL_lose_context"),WEBGL_depth_texture:P6(t,"WEBGL_depth_texture"),OES_texture_half_float:P6(t,"OES_texture_half_float"),OES_texture_half_float_linear:P6(t,"OES_texture_half_float_linear"),OES_texture_float:P6(t,"OES_texture_float"),OES_texture_float_linear:P6(t,"OES_texture_float_linear"),OES_standard_derivatives:P6(t,"OES_standard_derivatives"),OES_element_index_uint:P6(t,"OES_element_index_uint"),ANGLE_instanced_arrays:P6(t,"ANGLE_instanced_arrays"),WEBGL_debug_renderer_info:P6(t,"WEBGL_debug_renderer_info"),WEBGL_multi_draw:null,WEBGL_compressed_texture_astc:null,destroyShadersImmediately:!0,noCompressedTexSubImage2D:!1,isLocationActive:function(t){return!!t},useVAO:!1};return nl.os===$u.IOS&&14===nl.osMainVersion&&nl.isBrowser||(e.WEBGL_compressed_texture_astc=P6(t,"WEBGL_compressed_texture_astc")),nl.os!==$u.ANDROID&&nl.os!==$u.IOS&&(e.WEBGL_multi_draw=P6(t,"WEBGL_multi_draw")),nl.browserType===Ju.UC&&(e.ANGLE_instanced_arrays=null),nl.os===$u.IOS&&nl.osMainVersion<=10&&(e.destroyShadersImmediately=!1),e.OES_vertex_array_object&&(e.useVAO=!0),e}var M6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).stateCache=new I6,e.cmdAllocator=new p6,e.nullTex2D=null,e.nullTexCube=null,e._canvas=null,e._webGLContextLostHandler=null,e._extensions=null,e._blitManager=null,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._canvas=t.windowHandle,this._webGLContextLostHandler=this._onWebGLContextLost.bind(this),this._canvas.addEventListener(D6,this._onWebGLContextLost);var e=x8.instance.gl;this.stateCache.initialize(x8.instance.capabilities.maxTextureUnits,x8.instance.capabilities.maxVertexAttributes),this._extensions=O6(e),function(t){t.activeTexture(t.TEXTURE0),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.bindFramebuffer(t.FRAMEBUFFER,null),t.enable(t.SCISSOR_TEST),t.enable(t.CULL_FACE),t.cullFace(t.BACK),t.frontFace(t.CCW),t.disable(t.POLYGON_OFFSET_FILL),t.polygonOffset(0,0),t.enable(t.DEPTH_TEST),t.depthMask(!0),t.depthFunc(t.LESS),t.depthRange(0,1),t.stencilFuncSeparate(t.FRONT,t.ALWAYS,1,65535),t.stencilOpSeparate(t.FRONT,t.KEEP,t.KEEP,t.KEEP),t.stencilMaskSeparate(t.FRONT,65535),t.stencilFuncSeparate(t.BACK,t.ALWAYS,1,65535),t.stencilOpSeparate(t.BACK,t.KEEP,t.KEEP,t.KEEP),t.stencilMaskSeparate(t.BACK,65535),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.disable(t.BLEND),t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.colorMask(!0,!0,!0,!0),t.blendColor(0,0,0,0)}(e);var i=Hl.RGBA8,n=Hl.DEPTH_STENCIL,r=e.getParameter(e.DEPTH_BITS),s=e.getParameter(e.STENCIL_BITS);r&&s?n=Hl.DEPTH_STENCIL:r&&(n=Hl.DEPTH),this._colorTexture=new B6,this._colorTexture.initAsSwapchainTexture({swapchain:this,format:i,width:t.width,height:t.height}),this._depthStencilTexture=new B6,this._depthStencilTexture.initAsSwapchainTexture({swapchain:this,format:n,width:t.width,height:t.height}),this.nullTex2D=x8.instance.createTexture(new Qc(Jl.TEX2D,Ql.SAMPLED,Hl.RGBA8,2,2,Zl.GEN_MIPMAP)),this.nullTexCube=x8.instance.createTexture(new Qc(Jl.CUBE,Ql.SAMPLED,Hl.RGBA8,2,2,Zl.GEN_MIPMAP,6));var o=new Gc;o.texExtent.width=2,o.texExtent.height=2;var a=new Uint8Array(this.nullTex2D.size);a.fill(0),x8.instance.copyBuffersToTexture([a],this.nullTex2D,[o]),o.texSubres.layerCount=6,x8.instance.copyBuffersToTexture([a,a,a,a,a,a],this.nullTexCube,[o]),this._blitManager=new _6},i.destroy=function(){this._canvas&&this._webGLContextLostHandler&&(this._canvas.removeEventListener(D6,this._webGLContextLostHandler),this._webGLContextLostHandler=null),this.nullTex2D&&(this.nullTex2D.destroy(),this.nullTex2D=null),this.nullTexCube&&(this.nullTexCube.destroy(),this.nullTexCube=null),this._blitManager&&(this._blitManager.destroy(),this._blitManager=null),this._extensions=null,this._canvas=null},i.resize=function(t,e){this._colorTexture.width===t&&this._colorTexture.height===e||(U("Resizing swapchain: "+t+"x"+e),this._canvas.width=t,this._canvas.height=e,this._colorTexture.resize(t,e),this._depthStencilTexture.resize(t,e))},i._onWebGLContextLost=function(t){Y(11e3),k(t)},n(e,[{key:"extensions",get:function(){return this._extensions}},{key:"blitManager",get:function(){return this._blitManager}}]),e}(Q_),L6=t("eP",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._swapchain=null,e._context=null,e._bindingMappings=null,e._textureExclusive=new Array(Hl.COUNT),e}s(e,t);var i=e.prototype;return i.initialize=function(t){x8.setInstance(this),this._gfxAPI=Gl.WEBGL;var e=this._bindingMappingInfo=t.bindingMappingInfo,i=[],n=[],r=e.setIndices[0];i[r]=0,n[r]=0;for(var s=1;s<e.setIndices.length;++s){var o=e.setIndices[s],a=e.setIndices[s-1];i[o]=e.maxBlockCounts[a]+i[a],n[o]=e.maxSamplerTextureCounts[a]+n[a]}for(var h=0;h<e.setIndices.length;++h){var u=e.setIndices[h];n[u]-=e.maxBlockCounts[u]}this._bindingMappings={blockOffsets:i,samplerTextureOffsets:n,flexibleSet:e.setIndices[e.setIndices.length-1]};var l=this._context=function(t){var e=null;try{var i={alpha:Ce.ENABLE_TRANSPARENT_CANVAS,antialias:Ce.ENABLE_WEBGL_ANTIALIAS,depth:!0,stencil:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1};e=t.getContext("webgl",i)}catch(t){return null}return e}(K_.canvas);if(!l)return console.error("This device does not support WebGL."),!1;this._queue=this.createQueue(new x_(Ac.GRAPHICS)),this._cmdBuff=this.createCommandBuffer(new w_(this._queue)),this._caps.maxVertexAttributes=l.getParameter(l.MAX_VERTEX_ATTRIBS),this._caps.maxVertexUniformVectors=l.getParameter(l.MAX_VERTEX_UNIFORM_VECTORS),this._caps.maxFragmentUniformVectors=l.getParameter(l.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxTextureUnits=l.getParameter(l.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureUnits=l.getParameter(l.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=l.getParameter(l.MAX_TEXTURE_SIZE),this._caps.maxCubeMapTextureSize=l.getParameter(l.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxArrayTextureLayers=0,this._caps.max3DTextureSize=0,this._caps.maxUniformBufferBindings=16;var c=l.getSupportedExtensions(),_="";if(c)for(var f,p=d(c);!(f=p()).done;)_+=f.value+" ";var m=O6(l);m.WEBGL_debug_renderer_info?(this._renderer=l.getParameter(m.WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL),this._vendor=l.getParameter(m.WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL)):(this._renderer=l.getParameter(l.RENDERER),this._vendor=l.getParameter(l.VENDOR));var g=l.getParameter(l.VERSION);this._features.fill(!1),this.initFormatFeatures(m),m.EXT_blend_minmax&&(this._features[zl.BLEND_MINMAX]=!0),m.OES_element_index_uint&&(this._features[zl.ELEMENT_INDEX_UINT]=!0),m.ANGLE_instanced_arrays&&(this._features[zl.INSTANCED_ARRAYS]=!0),m.WEBGL_draw_buffers&&(this._features[zl.MULTIPLE_RENDER_TARGETS]=!0);var y="";return this.getFormatFeatures(Hl.ETC_RGB8)&&(y+="etc1 "),this.getFormatFeatures(Hl.ETC2_RGB8)&&(y+="etc2 "),this.getFormatFeatures(Hl.BC1)&&(y+="dxt "),this.getFormatFeatures(Hl.PVRTC_RGB2)&&(y+="pvrtc "),this.getFormatFeatures(Hl.ASTC_RGBA_4X4)&&(y+="astc "),U("WebGL device initialized."),U("RENDERER: "+this._renderer),U("VENDOR: "+this._vendor),U("VERSION: "+g),U("COMPRESSED_FORMAT: "+y),U("EXTENSIONS: "+_),!0},i.destroy=function(){this._queue&&(this._queue.destroy(),this._queue=null),this._cmdBuff&&(this._cmdBuff.destroy(),this._cmdBuff=null),this._swapchain=null},i.flushCommands=function(){},i.acquire=function(){},i.present=function(){var t=this._queue;this._numDrawCalls=t.numDrawCalls,this._numInstances=t.numInstances,this._numTris=t.numTris,t.clear()},i.initFormatFeatures=function(t){this._formatFeatures.fill($l.NONE),this._textureExclusive.fill(!0);var e=$l.RENDER_TARGET|$l.SAMPLED_TEXTURE|$l.LINEAR_FILTER;this._formatFeatures[Hl.RGB8]=e,this._formatFeatures[Hl.R5G6B5]=e,this._textureExclusive[Hl.R5G6B5]=!1,this._formatFeatures[Hl.RGBA8]=e,this._formatFeatures[Hl.RGBA4]=e,this._textureExclusive[Hl.RGBA4]=!1,this._formatFeatures[Hl.RGB5A1]=e,this._textureExclusive[Hl.RGB5A1]=!1,this._formatFeatures[Hl.DEPTH]=$l.RENDER_TARGET,this._textureExclusive[Hl.DEPTH]=!1,this._formatFeatures[Hl.DEPTH_STENCIL]=$l.RENDER_TARGET,this._textureExclusive[Hl.DEPTH_STENCIL]=!1,this._formatFeatures[Hl.R8I]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RG8I]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGB8I]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGBA8I]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.R8UI]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RG8UI]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGB8UI]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGBA8UI]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.R8I]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RG8I]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGB8I]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGBA8I]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.R8UI]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RG8UI]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGB8UI]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGBA8UI]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.R32F]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RG32F]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGB32F]|=$l.VERTEX_ATTRIBUTE,this._formatFeatures[Hl.RGBA32F]|=$l.VERTEX_ATTRIBUTE,t.EXT_sRGB&&(this._formatFeatures[Hl.SRGB8]=e,this._formatFeatures[Hl.SRGB8_A8]=e,this._textureExclusive[Hl.SRGB8_A8]=!1),t.WEBGL_depth_texture&&(this._formatFeatures[Hl.DEPTH]|=e,this._formatFeatures[Hl.DEPTH_STENCIL]|=e),t.WEBGL_color_buffer_float&&(this._formatFeatures[Hl.RGB32F]|=$l.RENDER_TARGET,this._formatFeatures[Hl.RGBA32F]|=$l.RENDER_TARGET,this._textureExclusive[Hl.RGB32F]=!1,this._textureExclusive[Hl.RGBA32F]=!1),t.EXT_color_buffer_half_float&&(this._formatFeatures[Hl.RGB16F]|=$l.RENDER_TARGET,this._formatFeatures[Hl.RGBA16F]|=$l.RENDER_TARGET,this._textureExclusive[Hl.RGB16F]=!1,this._textureExclusive[Hl.RGBA16F]=!1),t.OES_texture_float&&(this._formatFeatures[Hl.RGB32F]|=$l.RENDER_TARGET|$l.SAMPLED_TEXTURE,this._formatFeatures[Hl.RGBA32F]|=$l.RENDER_TARGET|$l.SAMPLED_TEXTURE),t.OES_texture_half_float&&(this._formatFeatures[Hl.RGB16F]|=$l.RENDER_TARGET|$l.SAMPLED_TEXTURE,this._formatFeatures[Hl.RGBA16F]|=$l.RENDER_TARGET|$l.SAMPLED_TEXTURE),t.OES_texture_float_linear&&(this._formatFeatures[Hl.RGB32F]|=$l.LINEAR_FILTER,this._formatFeatures[Hl.RGBA32F]|=$l.LINEAR_FILTER),t.OES_texture_half_float_linear&&(this._formatFeatures[Hl.RGB16F]|=$l.LINEAR_FILTER,this._formatFeatures[Hl.RGBA16F]|=$l.LINEAR_FILTER);var i=$l.SAMPLED_TEXTURE|$l.LINEAR_FILTER;t.WEBGL_compressed_texture_etc1&&(this._formatFeatures[Hl.ETC_RGB8]=i),t.WEBGL_compressed_texture_etc&&(this._formatFeatures[Hl.ETC2_RGB8]=i,this._formatFeatures[Hl.ETC2_RGBA8]=i,this._formatFeatures[Hl.ETC2_SRGB8]=i,this._formatFeatures[Hl.ETC2_SRGB8_A8]=i,this._formatFeatures[Hl.ETC2_RGB8_A1]=i,this._formatFeatures[Hl.ETC2_SRGB8_A1]=i),t.WEBGL_compressed_texture_s3tc&&(this._formatFeatures[Hl.BC1]=i,this._formatFeatures[Hl.BC1_ALPHA]=i,this._formatFeatures[Hl.BC1_SRGB]=i,this._formatFeatures[Hl.BC1_SRGB_ALPHA]=i,this._formatFeatures[Hl.BC2]=i,this._formatFeatures[Hl.BC2_SRGB]=i,this._formatFeatures[Hl.BC3]=i,this._formatFeatures[Hl.BC3_SRGB]=i),t.WEBGL_compressed_texture_pvrtc&&(this._formatFeatures[Hl.PVRTC_RGB2]|=i,this._formatFeatures[Hl.PVRTC_RGBA2]|=i,this._formatFeatures[Hl.PVRTC_RGB4]|=i,this._formatFeatures[Hl.PVRTC_RGBA4]|=i),t.WEBGL_compressed_texture_astc&&(this._formatFeatures[Hl.ASTC_RGBA_4X4]|=i,this._formatFeatures[Hl.ASTC_RGBA_5X4]|=i,this._formatFeatures[Hl.ASTC_RGBA_5X5]|=i,this._formatFeatures[Hl.ASTC_RGBA_6X5]|=i,this._formatFeatures[Hl.ASTC_RGBA_6X6]|=i,this._formatFeatures[Hl.ASTC_RGBA_8X5]|=i,this._formatFeatures[Hl.ASTC_RGBA_8X6]|=i,this._formatFeatures[Hl.ASTC_RGBA_8X8]|=i,this._formatFeatures[Hl.ASTC_RGBA_10X5]|=i,this._formatFeatures[Hl.ASTC_RGBA_10X6]|=i,this._formatFeatures[Hl.ASTC_RGBA_10X8]|=i,this._formatFeatures[Hl.ASTC_RGBA_10X10]|=i,this._formatFeatures[Hl.ASTC_RGBA_12X10]|=i,this._formatFeatures[Hl.ASTC_RGBA_12X12]|=i,this._formatFeatures[Hl.ASTC_SRGBA_4X4]|=i,this._formatFeatures[Hl.ASTC_SRGBA_5X4]|=i,this._formatFeatures[Hl.ASTC_SRGBA_5X5]|=i,this._formatFeatures[Hl.ASTC_SRGBA_6X5]|=i,this._formatFeatures[Hl.ASTC_SRGBA_6X6]|=i,this._formatFeatures[Hl.ASTC_SRGBA_8X5]|=i,this._formatFeatures[Hl.ASTC_SRGBA_8X6]|=i,this._formatFeatures[Hl.ASTC_SRGBA_8X8]|=i,this._formatFeatures[Hl.ASTC_SRGBA_10X5]|=i,this._formatFeatures[Hl.ASTC_SRGBA_10X6]|=i,this._formatFeatures[Hl.ASTC_SRGBA_10X8]|=i,this._formatFeatures[Hl.ASTC_SRGBA_10X10]|=i,this._formatFeatures[Hl.ASTC_SRGBA_12X10]|=i,this._formatFeatures[Hl.ASTC_SRGBA_12X12]|=i)},i.createCommandBuffer=function(t){var e=new(t.type===Ec.PRIMARY?b6:m6);return e.initialize(t),e},i.createSwapchain=function(t){var e=new M6;return this._swapchain=e,e.initialize(t),e},i.createBuffer=function(t){var e=new d6;return e.initialize(t),e},i.createTexture=function(t){var e=new B6;return e.initialize(t),e},i.createDescriptorSet=function(t){var e=new w8;return e.initialize(t),e},i.createShader=function(t){var e=new R6;return e.initialize(t),e},i.createInputAssembler=function(t){var e=new y6;return e.initialize(t),e},i.createRenderPass=function(t){var e=new C6;return e.initialize(t),e},i.createFramebuffer=function(t){var e=new g6;return e.initialize(t),e},i.createDescriptorSetLayout=function(t){var e=new v6;return e.initialize(t),e},i.createPipelineLayout=function(t){var e=new S6;return e.initialize(t),e},i.createPipelineState=function(t){var e=new A6;return e.initialize(t),e},i.createQueue=function(t){var e=new E6;return e.initialize(t),e},i.getSampler=function(t){var e=cd.computeHash(t);return this._samplers.has(e)||this._samplers.set(e,new x6(t,e)),this._samplers.get(e)},i.getSwapchains=function(){return[this._swapchain]},i.getGeneralBarrier=function(t){var e=fd.computeHash(t);return this._generalBarrierss.has(e)||this._generalBarrierss.set(e,new fd(t,e)),this._generalBarrierss.get(e)},i.getTextureBarrier=function(t){var e=pd.computeHash(t);return this._textureBarriers.has(e)||this._textureBarriers.set(e,new pd(t,e)),this._textureBarriers.get(e)},i.getBufferBarrier=function(t){var e=md.computeHash(t);return this._bufferBarriers.has(e)||this._bufferBarriers.set(e,new md(t,e)),this._bufferBarriers.get(e)},i.copyBuffersToTexture=function(t,e,i){u6(this,t,e.gpuTexture,i)},i.copyTextureToBuffers=function(t,e,i){!function(t,e,i,n){var r=t.gl,s=t.stateCache,o=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,o);var a=0,h=0,u=1,l=1;switch(e.glTarget){case r.TEXTURE_2D:for(var c=0;c<n.length;c++){var _=n[c];r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,e.glTarget,e.glTexture,_.texSubres.mipLevel),a=_.texOffset.x,h=_.texOffset.y,u=_.texExtent.width,l=_.texExtent.height,r.readPixels(a,h,u,l,e.glFormat,e.glType,i[c])}break;default:V("Unsupported GL texture type, copy texture to buffers failed.")}r.bindFramebuffer(r.FRAMEBUFFER,null),s.glFramebuffer=null,r.deleteFramebuffer(o)}(this,t.gpuTexture,e,i)},i.copyTexImagesToTexture=function(t,e,i){!function(t,e,i,n){var r=t.gl,s=t.stateCache.glTexUnits[t.stateCache.texUnit];s.glTexture!==i.glTexture&&(r.bindTexture(i.glTarget,i.glTexture),s.glTexture=i.glTexture);var o=0,a=0;switch(i.glTarget){case r.TEXTURE_2D:for(var h=0;h<n.length;h++){var u=n[h];r.texSubImage2D(r.TEXTURE_2D,u.texSubres.mipLevel,u.texOffset.x,u.texOffset.y,i.glFormat,i.glType,e[o++])}break;case r.TEXTURE_CUBE_MAP:for(var l=0;l<n.length;l++){var c=n[l],_=c.texSubres.baseArrayLayer+c.texSubres.layerCount;for(a=c.texSubres.baseArrayLayer;a<_;++a)r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+a,c.texSubres.mipLevel,c.texOffset.x,c.texOffset.y,i.glFormat,i.glType,e[o++])}break;default:V("Unsupported GL texture type, copy buffer to texture failed.")}i.flags&Zl.GEN_MIPMAP&&i.isPowerOf2&&r.generateMipmap(i.glTarget)}(this,t,e.gpuTexture,i)},n(e,[{key:"gl",get:function(){return this._context}},{key:"extensions",get:function(){return this._swapchain.extensions}},{key:"stateCache",get:function(){return this._swapchain.stateCache}},{key:"nullTex2D",get:function(){return this._swapchain.nullTex2D}},{key:"nullTexCube",get:function(){return this._swapchain.nullTexCube}},{key:"textureExclusive",get:function(){return this._textureExclusive}},{key:"bindingMappings",get:function(){return this._bindingMappings}},{key:"blitManager",get:function(){return this._swapchain.blitManager}}]),e}(K_));function N6(t,e,i,n){var r=(n.x-i.x)*(t.y-i.y)-(n.y-i.y)*(t.x-i.x),s=(e.x-t.x)*(t.y-i.y)-(e.y-t.y)*(t.x-i.x),o=(n.y-i.y)*(e.x-t.x)-(n.x-i.x)*(e.y-t.y);if(0!==o){var a=r/o,h=s/o;if(a>=0&&a<=1&&h>=0&&h<=1)return!0}return!1}v.WebGLDevice=L6;var F6=new Ln,k6=new Ln,V6=new Ln,G6=new Ln;function U6(t,e,i){for(var n=i.length,r=0;r<n;++r)if(N6(t,e,i[r],i[(r+1)%n]))return!0;return!1}function z6(t,e){for(var i=!1,n=t.x,r=t.y,s=e.length,o=0,a=s-1;o<s;a=o++){var h=e[o].x,u=e[o].y,l=e[a].x,c=e[a].y;u>r!=c>r&&n<(l-h)*(r-u)/(c-u)+h&&(i=!i)}return i}function H6(t,e,i,n){var r,s=i.x-e.x,o=i.y-e.y,a=s*s+o*o,h=((t.x-e.x)*s+(t.y-e.y)*o)/a;return r=n?a?h<0?e:h>1?i:F6.set(e.x+h*s,e.y+h*o):e:F6.set(e.x+h*s,e.y+h*o),s=t.x-r.x,o=t.y-r.y,Math.sqrt(s*s+o*o)}var W6=t("eQ",(function(){}));W6.lineLine=N6,W6.lineRect=function(t,e,i){var n=F6.set(i.x,i.y),r=k6.set(i.x,i.yMax),s=V6.set(i.xMax,i.yMax),o=G6.set(i.xMax,i.y);return!!(N6(t,e,n,r)||N6(t,e,r,s)||N6(t,e,s,o)||N6(t,e,o,n))},W6.linePolygon=U6,W6.rectRect=function(t,e){var i=t.x,n=t.y,r=t.x+t.width,s=t.y+t.height,o=e.x,a=e.y,h=e.x+e.width,u=e.y+e.height;return i<=h&&r>=o&&n<=u&&s>=a},W6.rectPolygon=function(t,e){var i=F6.set(t.x,t.y),n=k6.set(t.x,t.yMax),r=V6.set(t.xMax,t.yMax),s=G6.set(t.xMax,t.y);if(U6(i,n,e))return!0;if(U6(n,r,e))return!0;if(U6(r,s,e))return!0;if(U6(s,i,e))return!0;for(var o=0,a=e.length;o<a;++o)if(t.contains(e[o]))return!0;return!!(z6(i,e)||z6(n,e)||z6(r,e)||z6(s,e))},W6.rectCircle=function(t,e,i){var n=e.x,r=e.y,s=t.x,o=t.y,a=t.width,h=t.height,u=n,l=r;n<s?u=s:n>s+a&&(u=s+a),r<o?l=o:r>o+h&&(l=o+h);var c=n-u,_=r-l;return Math.sqrt(c*c+_*_)<=i},W6.polygonPolygon=function(t,e){var i,n;for(i=0,n=t.length;i<n;++i)if(U6(t[i],t[(i+1)%n],e))return!0;for(i=0,n=e.length;i<n;++i)if(z6(e[i],t))return!0;for(i=0,n=t.length;i<n;++i)if(z6(t[i],e))return!0;return!1},W6.circleCircle=function(t,e,i,n){return Ln.distance(t,i)<e+n},W6.polygonCircle=function(t,e,i){var n=e;if(z6(n,t))return!0;for(var r=0,s=t.length;r<s;r++)if(H6(n,0===r?t[t.length-1]:t[r-1],t[r],!0)<i)return!0;return!1},W6.pointInPolygon=z6,W6.pointLineDistance=H6;var j6,X6,q6,Y6=ge({GRAVITY:0,RADIUS:1}),K6=ge({FREE:0,RELATIVE:1,GROUPED:2}),J6=new Ln(0,0),Q6=new Ln,Z6=new Ln,$6=new Ln,t7=new Ln,e7=fk(lk),i7=function(){this.pos=new Ln(0,0),this.startPos=new Ln(0,0),this.color=new dn(0,0,0,255),this.deltaColor={r:0,g:0,b:0,a:255},this.size=0,this.deltaSize=0,this.rotation=0,this.deltaRotation=0,this.timeToLive=0,this.drawPos=new Ln(0,0),this.aspectRatio=1,this.dir=new Ln(0,0),this.radialAccel=0,this.tangentialAccel=0,this.angle=0,this.degreesPerSecond=0,this.radius=0,this.deltaRadius=0},n7=new(function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.get=function(){return this._get()||new i7},e}(re))((function(t){t.pos.set(J6),t.startPos.set(J6),t.color._val=4278190080,t.deltaColor.r=t.deltaColor.g=t.deltaColor.b=0,t.deltaColor.a=255,t.size=0,t.deltaSize=0,t.rotation=0,t.deltaRotation=0,t.timeToLive=0,t.drawPos.set(J6),t.aspectRatio=1,t.dir.set(J6),t.radialAccel=0,t.tangentialAccel=0,t.angle=0,t.degreesPerSecond=0,t.radius=0,t.deltaRadius=0}),1024),r7=function(){function t(t){this.particles=[],this.active=!1,this.uvFilled=0,this.finished=!1,this.readyToPlay=!0,this.elapsed=0,this.emitCounter=0,this._worldRotation=0,this.sys=t,this.particles=[],this.active=!1,this.readyToPlay=!0,this.finished=!1,this.elapsed=0,this.emitCounter=0,this.uvFilled=0,this._worldRotation=0}var e=t.prototype;return e.stop=function(){this.active=!1,this.readyToPlay=!1,this.elapsed=this.sys.duration,this.emitCounter=0},e.reset=function(){this.active=!0,this.readyToPlay=!0,this.elapsed=0,this.emitCounter=0,this.finished=!1;for(var t=this.particles,e=0;e<t.length;++e)n7.put(t[e]);t.length=0,this.renderData.resize(0,0)},e.emitParticle=function(t){var e=this.sys,i=n7.get();this.particles.push(i),i.timeToLive=e.life+e.lifeVar*(Pi()-.5)*2;var n=i.timeToLive=Math.max(0,i.timeToLive);i.pos.x=e.sourcePos.x+e.posVar.x*(Pi()-.5)*2,i.pos.y=e.sourcePos.y+e.posVar.y*(Pi()-.5)*2;var r,s,o,a,h=e.startColor,u=e.startColorVar,l=e.endColor,c=e.endColorVar;i.color.r=r=Fe(h.r+u.r*(Pi()-.5)*2,0,255),i.color.g=s=Fe(h.g+u.g*(Pi()-.5)*2,0,255),i.color.b=o=Fe(h.b+u.b*(Pi()-.5)*2,0,255),i.color.a=a=Fe(h.a+u.a*(Pi()-.5)*2,0,255),i.deltaColor.r=(Fe(l.r+c.r*(Pi()-.5)*2,0,255)-r)/n,i.deltaColor.g=(Fe(l.g+c.g*(Pi()-.5)*2,0,255)-s)/n,i.deltaColor.b=(Fe(l.b+c.b*(Pi()-.5)*2,0,255)-o)/n,i.deltaColor.a=(Fe(l.a+c.a*(Pi()-.5)*2,0,255)-a)/n;var _=e.startSize+e.startSizeVar*(Pi()-.5)*2;if(_=Math.max(0,_),i.size=_,-1===e.endSize)i.deltaSize=0;else{var d=e.endSize+e.endSizeVar*(Pi()-.5)*2;d=Math.max(0,d),i.deltaSize=(d-_)/n}var f=e.startSpin+e.startSpinVar*(Pi()-.5)*2,p=e.endSpin+e.endSpinVar*(Pi()-.5)*2;i.rotation=f,i.deltaRotation=(p-f)/n,i.startPos.x=t.x,i.startPos.y=t.y,i.aspectRatio=e.aspectRatio||1;var m=ke(e.angle+this._worldRotation+e.angleVar*(Pi()-.5)*2);if(e.emitterMode===Y6.GRAVITY){var g=e.speed+e.speedVar*(Pi()-.5)*2;i.dir.x=Math.cos(m),i.dir.y=Math.sin(m),i.dir.multiplyScalar(g),i.radialAccel=e.radialAccel+e.radialAccelVar*(Pi()-.5)*2,i.tangentialAccel=e.tangentialAccel+e.tangentialAccelVar*(Pi()-.5)*2,e.rotationIsDir&&(i.rotation=-Ve(Math.atan2(i.dir.y,i.dir.x)))}else{var y=e.startRadius+e.startRadiusVar*(Pi()-.5)*2,v=e.endRadius+e.endRadiusVar*(Pi()-.5)*2;i.radius=y,i.deltaRadius=-1===e.endRadius?0:(v-y)/n,i.angle=m,i.degreesPerSecond=ke(e.rotatePerS+e.rotatePerSVar*(Pi()-.5)*2)}},e.updateUVs=function(t){var e=this.renderData;if(e&&this.sys._renderSpriteFrame){for(var i=e.vData,n=this.sys._renderSpriteFrame.uv,r=t?0:this.uvFilled,s=this.particles.length,o=r;o<s;o++){var a=o*e7*4;i[a+3]=n[0],i[a+4]=n[1],i[a+12]=n[2],i[a+13]=n[3],i[a+21]=n[4],i[a+22]=n[5],i[a+30]=n[6],i[a+31]=n[7]}this.uvFilled=s}},e.updateParticleBuffer=function(t,e,i,n){var r=i.vData,s=e.x,o=e.y,a=t.size,h=a,u=t.aspectRatio;u>1?h=a/u:a=h*u;var l=a/2,c=h/2;if(t.rotation){var _=-l,d=-c,f=l,p=c,m=-ke(t.rotation),g=Math.cos(m),y=Math.sin(m);r[n]=_*g-d*y+s,r[n+1]=_*y+d*g+o,r[n+2]=0,r[n+9]=f*g-d*y+s,r[n+10]=f*y+d*g+o,r[n+11]=0,r[n+18]=_*g-p*y+s,r[n+19]=_*y+p*g+o,r[n+20]=0,r[n+27]=f*g-p*y+s,r[n+28]=f*y+p*g+o,r[n+29]=0}else r[n]=s-l,r[n+1]=o-c,r[n+2]=0,r[n+9]=s+l,r[n+10]=o-c,r[n+11]=0,r[n+18]=s-l,r[n+19]=o+c,r[n+20]=0,r[n+27]=s+l,r[n+28]=o+c,r[n+29]=0;dn.toArray(r,t.color,n+5),dn.toArray(r,t.color,n+14),dn.toArray(r,t.color,n+23),dn.toArray(r,t.color,n+32)},e.step=function(t){var e=this.sys.assembler,i=this.sys,n=i.node,r=this.particles;if(t=t>e.maxParticleDeltaTime?e.maxParticleDeltaTime:t,n.updateWorldTransform(),i.positionType===K6.FREE){this._worldRotation=function(t){for(var e=0,i=t;i;)e+=i.eulerAngles.z,i=i.parent;return e}(n);var s=n.worldMatrix;Q6.x=s.m12,Q6.y=s.m13}else i.positionType===K6.RELATIVE?(this._worldRotation=n.eulerAngles.z,Q6.x=n.position.x,Q6.y=n.position.y):this._worldRotation=0;if(this.active&&i.emissionRate){var o=1/i.emissionRate;for(r.length<i.totalParticles&&(this.emitCounter+=t);r.length<i.totalParticles&&this.emitCounter>o;)this.emitParticle(Q6),this.emitCounter-=o;this.elapsed+=t,-1!==i.duration&&i.duration<this.elapsed&&i.stopSystem()}var a=this.renderData,h=r.length;a.reset(),this.requestData(4*h,6*h),h>this.uvFilled&&this.updateUVs();for(var u=0;u<r.length;){Z6.x=Z6.y=$6.x=$6.y=t7.x=t7.y=0;var l=r[u];if(l.timeToLive-=t,l.timeToLive>0){if(i.emitterMode===Y6.GRAVITY){var c=t7,_=Z6,d=$6;(l.pos.x||l.pos.y)&&(_.set(l.pos),_.normalize()),d.set(_),_.multiplyScalar(l.radialAccel);var f=d.x;d.x=-d.y,d.y=f,d.multiplyScalar(l.tangentialAccel),c.set(_),c.add(d),c.add(i.gravity),c.multiplyScalar(t),l.dir.add(c),c.set(l.dir),c.multiplyScalar(t),l.pos.add(c)}else l.angle+=l.degreesPerSecond*t,l.radius+=l.deltaRadius*t,l.pos.x=-Math.cos(l.angle)*l.radius,l.pos.y=-Math.sin(l.angle)*l.radius;l.color.r+=l.deltaColor.r*t,l.color.g+=l.deltaColor.g*t,l.color.b+=l.deltaColor.b*t,l.color.a+=l.deltaColor.a*t,l.size+=l.deltaSize*t,l.size<0&&(l.size=0),l.rotation+=l.deltaRotation*t;var p=Z6;p.set(l.pos),i.positionType!==K6.GROUPED&&p.add(l.startPos);var m=e7*u*4;this.updateParticleBuffer(l,p,a,m),++u}else{var g=r[u];u!==r.length-1&&(r[u]=r[r.length-1]),n7.put(g),r.length--,a.resize(a.vertexCount-4,a.indexCount-6)}}this.renderData.material=this.sys.getRenderMaterial(0),this.renderData.frame=this.sys._renderSpriteFrame,a.setRenderDrawInfoAttributes(),0!==r.length||this.active||this.readyToPlay||(this.finished=!0,i._finishedSimulation())},e.requestData=function(t,e){var i=this.renderData.indexCount;this.renderData.request(t,e);for(var n=this.renderData.indexCount/6,r=this.renderData.iData,s=i;s<n;s++){var o=4*s;r[i++]=o,r[i++]=o+1,r[i++]=o+2,r[i++]=o+1,r[i++]=o+3,r[i++]=o+2}},e.initDrawInfo=function(){this.renderData.setRenderDrawInfoAttributes()},t}(),s7=io,o7=t("eV",qs("cc.ParticleAsset")((X6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).spriteFrame=q6&&q6(),e}return s(e,t),e}(of),q6=ks(X6.prototype,"spriteFrame",[s7],(function(){return null})),j6=X6))||j6);v.ParticleAsset=o7;for(var a7=function(){function t(t){var e,i=this;this.pos=8,this.palette=[],this.imgData=[],this.text={},this.width=0,this.height=0,this.bits=0,this.colorType=0,this.compressionMethod=0,this.filterMethod=0,this.interlaceMethod=0,this.colors=0,this.hasAlphaChannel=!1,this.pixelBitlength=0,this.data=t,this.transparency={indexed:[],rgb:0,grayscale:0};for(var n=0,r=0,s=0;;){s=this.readUInt32();var o=function(){var t=[];for(n=0;n<4;++n)t.push(String.fromCharCode(i.data[i.pos++]));return t}.call(this).join("");switch(o){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(s);break;case"fcTL":e&&this.animation.frames.push(e),this.pos+=4,e={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()};var a=this.readUInt16(),h=this.readUInt16()||100;e.delay=1e3*a/h,e.disposeOp=this.data[this.pos++],e.blendOp=this.data[this.pos++],e.data=[];break;case"IDAT":case"fdAT":for("fdAT"===o&&(this.pos+=4,s-=4),t=(null!=e?e.data:void 0)||this.imgData,n=0;s>=0?n<s:n>s;s>=0?++n:--n)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:this.transparency.indexed=this.read(s);var u=255-this.transparency.indexed.length;if(u>0)for(r=0;u>=0?r<u:r>u;u>=0?++r:--r)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(s)[0];break;case 2:this.transparency.rgb=this.read(s)}break;case"tEXt":var l=this.read(s),c=l.indexOf(0),_=String.fromCharCode.apply(String,l.slice(0,c));this.text[_]=String.fromCharCode.apply(String,l.slice(c+1));break;case"IEND":e&&this.animation.frames.push(e),this.colors=function(){switch(i.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this);var d=this.colorType;this.hasAlphaChannel=4===d||6===d;var f=this.colors+(this.hasAlphaChannel?1:0);return this.pixelBitlength=this.bits*f,this.colorSpace=function(){switch(i.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData instanceof Uint8Array||(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=s}if(this.pos+=4,this.pos>this.data.length)throw new Error(tt(6017))}}var e=t.prototype;return e.read=function(t){var e=0,i=[];for(e=0;t>=0?e<t:e>t;t>=0?++e:--e)i.push(this.data[this.pos++]);return i},e.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},e.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},e.decodePixels=function(t){if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);t=new UN.Inflate(t,{index:0,verify:!1}).decompress();for(var e=this.pixelBitlength/8,i=e*this.width,n=new Uint8Array(i*this.height),r=t.length,s=0,o=0,a=0,h=0,u=0,l=0,c=0,_=0,d=0,f=0,p=0,m=0,g=0,y=0,v=0,S=0,T=0,A=0,b=0;o<r;){switch(t[o++]){case 0:for(l=c=0;c<i;l=c+=1)n[a++]=t[o++];break;case 1:for(l=_=0;_<i;l=_+=1)h=t[o++],m=l<e?0:n[a-e],n[a++]=(h+m)%256;break;case 2:for(l=d=0;d<i;l=d+=1)h=t[o++],u=(l-l%e)/e,A=s&&n[(s-1)*i+u*e+l%e],n[a++]=(A+h)%256;break;case 3:for(l=f=0;f<i;l=f+=1)h=t[o++],u=(l-l%e)/e,m=l<e?0:n[a-e],A=s&&n[(s-1)*i+u*e+l%e],n[a++]=(h+Math.floor((m+A)/2))%256;break;case 4:for(l=p=0;p<i;l=p+=1)h=t[o++],u=(l-l%e)/e,m=l<e?0:n[a-e],0===s?A=b=0:(A=n[(s-1)*i+u*e+l%e],b=u&&n[(s-1)*i+(u-1)*e+l%e]),g=m+A-b,y=Math.abs(g-m),S=Math.abs(g-A),T=Math.abs(g-b),v=y<=S&&y<=T?m:S<=T?A:b,n[a++]=(h+v)%256;break;default:throw new Error(tt(6018,t[o-1]))}s++}return n},e.copyToImageData=function(t,e){var i,n=this.hasAlphaChannel,r=this.colors;this.palette.length&&(i=null!=this._decodedPalette?this._decodedPalette:this._decodedPalette=this.decodePalette(),r=4,n=!0);var s=t.data||t,o=s.length,a=i||e,h=0,u=0,l=0,c=0;if(1===r)for(;h<o;)l=i?4*e[h/4]:u,c=a[l++],s[h++]=c,s[h++]=c,s[h++]=c,s[h++]=n?a[l++]:255,u=l;else for(;h<o;)l=i?4*e[h/4]:u,s[h++]=a[l++],s[h++]=a[l++],s[h++]=a[l++],s[h++]=n?a[l++]:255,u=l},e.decodePalette=function(){for(var t=this.palette,e=this.transparency.indexed||[],i=new Uint8Array((e.length||0)+t.length),n=0,r=0,s=0,o=0,a=0,h=t.length;a<h;o=a+=3)i[n++]=t[o],i[n++]=t[o+1],i[n++]=t[o+2],s=e[r++],i[n++]=null!=s?s:255;return i},e.render=function(t){t.width=this.width,t.height=this.height;var e=t.getContext("2d"),i=e.createImageData(this.width,this.height);return this.copyToImageData(i,this.decodePixels(null)),e.putImageData(i,0,0)},t}(),h7=function(){function t(){this._littleEndian=!1,this._tiffData=[],this._fileDirectories=[]}var e=t.prototype;return e.getUint8=function(t){return this._tiffData[t]},e.getUint16=function(t){return this._littleEndian?this._tiffData[t+1]<<8|this._tiffData[t]:this._tiffData[t]<<8|this._tiffData[t+1]},e.getUint32=function(t){var e=this._tiffData;return this._littleEndian?e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]:e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]},e.checkLittleEndian=function(){var t=this.getUint16(0);if(18761===t)this._littleEndian=!0;else{if(19789!==t)throw console.log(t),TypeError(tt(6019));this._littleEndian=!1}return this._littleEndian},e.hasTowel=function(){if(42!==this.getUint16(2))throw RangeError(tt(6020));return!0},e.getFieldTypeName=function(t){return t in l7?l7[t]:null},e.getFieldTagName=function(t){return t in u7?u7[t]:(X(6021,t),"Tag"+t)},e.getFieldTypeLength=function(t){return-1!==["BYTE","ASCII","SBYTE","UNDEFINED"].indexOf(t)?1:-1!==["SHORT","SSHORT"].indexOf(t)?2:-1!==["LONG","SLONG","FLOAT"].indexOf(t)?4:-1!==["RATIONAL","SRATIONAL","DOUBLE"].indexOf(t)?8:0},e.getFieldValues=function(t,e,i,n){var r=[],s=this.getFieldTypeLength(e);if(s*i<=4)!1===this._littleEndian?r.push(n>>>8*(4-s)):r.push(n);else for(var o=0;o<i;o++){var a=s*o;s>=8?-1!==["RATIONAL","SRATIONAL"].indexOf(e)?(r.push(this.getUint32(n+a)),r.push(this.getUint32(n+a+4))):X(8e3):r.push(this.getBytes(s,n+a))}return"ASCII"===e&&r.forEach((function(t,e,i){i[e]=String.fromCharCode(t)})),r},e.getBytes=function(t,e){if(t<=0)X(8001);else{if(t<=1)return this.getUint8(e);if(t<=2)return this.getUint16(e);if(t<=3)return this.getUint32(e)>>>8;if(t<=4)return this.getUint32(e);X(8002)}return 0},e.getBits=function(t,e,i){i=i||0;var n=e+Math.floor(i/8),r=i+t,s=32-t,o=0,a=0;return r<=0?X(6023):r<=8?(o=24+i,a=this.getUint8(n)):r<=16?(o=16+i,a=this.getUint16(n)):r<=32?(o=i,a=this.getUint32(n)):X(6022),{bits:a<<o>>>s,byteOffset:n+Math.floor(r/8),bitOffset:r%8}},e.parseFileDirectory=function(t){var e=this.getUint16(t),i=[],n=0,r=0;for(n=t+2,r=0;r<e;n+=12,r++){var s=this.getUint16(n),o=this.getUint16(n+2),a=this.getUint32(n+4),h=this.getUint32(n+8),u=this.getFieldTagName(s),l=this.getFieldTypeName(o),c=this.getFieldValues(u,l,a,h);i[u]={type:l,values:c}}this._fileDirectories.push(i);var _=this.getUint32(n);0!==_&&this.parseFileDirectory(_)},e.clampColorSample=function(t,e){var i=Math.pow(2,8-e);return Math.floor(t*i+(i-1))},e.parseTIFF=function(t,e){var i=this;if(e=e||T.document.createElement("canvas"),this._tiffData=t,this._canvas=e,this.checkLittleEndian(),this.hasTowel()){var n=this.getUint32(4);this._fileDirectories.length=0,this.parseFileDirectory(n);var r=this._fileDirectories[0],s=r.ImageWidth.values[0],o=r.ImageLength.values[0];this._canvas.width=s,this._canvas.height=o;var a=[],h=r.Compression?r.Compression.values[0]:1,u=r.SamplesPerPixel.values[0],l=[],c=0,_=!1;r.BitsPerSample.values.forEach((function(t,e){l[e]={bitsPerSample:t,hasBytesPerSample:!1,bytesPerSample:void 0},t%8==0&&(l[e].hasBytesPerSample=!0,l[e].bytesPerSample=t/8),c+=t}),this);var d=0;c%8==0&&(_=!0,d=c/8);var f,p=r.StripOffsets.values,m=p.length;if(r.StripByteCounts)f=r.StripByteCounts.values;else{if(X(8003),1!==m)throw Error(tt(6024));f=[Math.ceil(s*o*c/8)]}for(var g=1,y=1,v=0;v<m;v++){var S=p[v];a[v]=[];for(var A=f[v],b=0,E=0,C=1,w=!0,x=[],R=0,I=0,B=0;b<A;b+=C)switch(h){case 1:x=[];for(var D=0;D<u;D++){var P=l[D];if(!P.hasBytesPerSample){var O=this.getBits(P.bitsPerSample,S+b,E);throw x.push(O.bits),b=O.byteOffset-S,E=O.bitOffset,RangeError(tt(6025))}var M=P.bytesPerSample*D;x.push(this.getBytes(P.bytesPerSample,S+b+M))}if(a[v].push(x),!_)throw C=0,RangeError(tt(6026));C=d;break;case 2:case 3:case 4:case 5:case 6:case 7:break;case 32773:if(w){w=!1;var L=this.getUint8(S+b);L>=0&&L<=127?g=L+1:L>=-127&&L<=-1?y=1-L:w=!0}else{for(var N=this.getUint8(S+b),F=0;F<y;F++){var k=l[I];if(!k.hasBytesPerSample)throw RangeError(tt(6025));B=B<<8*R|N,++R===k.bytesPerSample&&(x.push(B),B=R=0,I++),I===u&&(a[v].push(x),x=[],I=0)}0==--g&&(w=!0)}C=1}}if(e.getContext){var V=this._canvas.getContext("2d");V.fillStyle="rgba(255, 255, 255, 0)";var G=r.RowsPerStrip?r.RowsPerStrip.values[0]:o,U=a.length,z=o%G,H=0===z?G:z,W=G,j=0,q=r.PhotometricInterpretation.values[0],Y=[],K=0;r.ExtraSamples&&(Y=r.ExtraSamples.values,K=Y.length);var J=[],Q=0;r.ColorMap&&(J=r.ColorMap.values,Q=Math.pow(2,l[0].bitsPerSample));for(var Z=0;Z<U;Z++){Z+1===U&&(W=H);for(var $=a[Z].length,et=j*Z,it=0,nt=0;it<W&&nt<$;it++)for(var rt=function(){var t=a[Z][nt],e=0,n=0,r=0,s=1;if(K>0)for(var o=0;o<K;o++)if(1===Y[o]||2===Y[o]){s=t[3+o]/256;break}switch(q){case 0:var h=0;l[0].hasBytesPerSample&&(h=Math.pow(16,2*l[0].bytesPerSample)),t.forEach((function(t,e,i){i[e]=h-t}));case 1:e=n=r=i.clampColorSample(t[0],l[0].bitsPerSample);break;case 2:e=i.clampColorSample(t[0],l[0].bitsPerSample),n=i.clampColorSample(t[1],l[1].bitsPerSample),r=i.clampColorSample(t[2],l[2].bitsPerSample);break;case 3:if(void 0===J)throw Error(tt(6027));var u=t[0];e=i.clampColorSample(J[u],16),n=i.clampColorSample(J[Q+u],16),r=i.clampColorSample(J[2*Q+u],16);break;default:throw RangeError(tt(6028,q))}V.fillStyle="rgba("+e+", "+n+", "+r+", "+s+")",V.fillRect(st,et+it,1,1)},st=0;st<s;st++,nt++)rt();j=W}}return this._canvas}},t}(),u7={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop"},l7={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"},c7=new Array(123),_7=0;_7<123;++_7)c7[_7]=64;for(var d7=0;d7<64;++d7)c7["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(d7)]=d7;var f7={name:"Jacob__Codec__Base64",decode:function(t){var e,i,n,r,s,o,a=[],h=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");h<t.length;)e=c7[t.charCodeAt(h++)]<<2|(r=c7[t.charCodeAt(h++)])>>4,i=(15&r)<<4|(s=c7[t.charCodeAt(h++)])>>2,n=(3&s)<<6|(o=c7[t.charCodeAt(h++)]),a.push(String.fromCharCode(e)),64!==s&&a.push(String.fromCharCode(i)),64!==o&&a.push(String.fromCharCode(n));return a.join("")},decodeAsArray:function(t,e){var i,n,r,s=this.decode(t),o=[];for(i=0,r=s.length/e;i<r;i++)for(o[i]=0,n=e-1;n>=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o}},p7=function(t){this.data=t,this.debug=!1,this.gpflags=void 0,this.files=0,this.unzipped=[],this.buf32k=new Array(32768),this.bIdx=0,this.modeZIP=!1,this.bytepos=0,this.bb=1,this.bits=0,this.nameBuf=[],this.fileout=void 0,this.literalTree=new Array(p7.LITERALS),this.distanceTree=new Array(32),this.treepos=0,this.Places=null,this.len=0,this.fpos=new Array(17),this.fpos[0]=0,this.flens=void 0,this.fmax=void 0};p7.gunzip=function(t){return t.constructor===Array||t.constructor,new p7(t).gunzip()[0][0]},p7.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},p7.LITERALS=288,p7.NAMEMAX=256,p7.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],p7.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],p7.cplext=[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,99,99],p7.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],p7.cpdext=[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],p7.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],p7.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},p7.prototype.readByte=function(){return this.bits+=8,this.bytepos<this.data.length?this.data.charCodeAt(this.bytepos++):-1},p7.prototype.byteAlign=function(){this.bb=1},p7.prototype.readBit=function(){var t;return this.bits++,t=1&this.bb,this.bb>>=1,0===this.bb&&(this.bb=this.readByte(),t=1&this.bb,this.bb=this.bb>>1|128),t},p7.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=p7.bitReverse[e]>>8-t),e},p7.prototype.flushBuffer=function(){this.bIdx=0},p7.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},p7.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]===this.len)return this.fpos[this.len]++;this.fpos[this.len]++}},p7.prototype.Rec=function(){var t,e=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,(t=this.IsPat())>=0)e.b0=t;else if(e.b0=32768,this.Rec())return-1;if((t=this.IsPat())>=0)e.b1=t,e.jump=null;else if(e.b1=32768,e.jump=this.Places[this.treepos],e.jumppos=this.treepos,this.Rec())return-1;return this.len--,0},p7.prototype.CreateTree=function(t,e,i){var n;for(this.Places=t,this.treepos=0,this.flens=i,this.fmax=e,n=0;n<17;n++)this.fpos[n]=0;return this.len=0,this.Rec()?-1:0},p7.prototype.DecodeValue=function(t){for(var e,i,n=0,r=t[n];;)if(this.readBit()){if(!(32768&r.b1))return r.b1;for(r=r.jump,e=t.length,i=0;i<e;i++)if(t[i]===r){n=i;break}}else{if(!(32768&r.b0))return r.b0;r=t[++n]}return-1},p7.prototype.DeflateLoop=function(){var t,e,i;do{var n,r;if(t=this.readBit(),0===(e=this.readBits(2)))for(this.byteAlign(),n=this.readByte(),n|=this.readByte()<<8,r=this.readByte(),65535&(n^~(r|=this.readByte()<<8))&&document.write("BlockLen checksum mismatch\n");n--;)s=this.readByte(),this.addBuffer(s);else if(1===e)for(;;)if((o=p7.bitReverse[this.readBits(7)]>>1)>23?(o=o<<1|this.readBit())>199?o=(o-=128)<<1|this.readBit():(o-=48)>143&&(o+=136):o+=256,o<256)this.addBuffer(o);else{if(256===o)break;for(o-=257,f=this.readBits(p7.cplext[o])+p7.cplens[o],o=p7.bitReverse[this.readBits(5)]>>3,p7.cpdext[o]>8?(p=this.readBits(8),p|=this.readBits(p7.cpdext[o]-8)<<8):p=this.readBits(p7.cpdext[o]),p+=p7.cpdist[o],o=0;o<f;o++){var s=this.buf32k[this.bIdx-p&32767];this.addBuffer(s)}}else if(2===e){var o,a,h,u,l,c=new Array(320);for(h=257+this.readBits(5),u=1+this.readBits(5),l=4+this.readBits(4),o=0;o<19;o++)c[o]=0;for(o=0;o<l;o++)c[p7.border[o]]=this.readBits(3);for(f=this.distanceTree.length,i=0;i<f;i++)this.distanceTree[i]=new p7.HufNode;if(this.CreateTree(this.distanceTree,19,c,0))return this.flushBuffer(),1;for(a=h+u,i=0;i<a;)if((o=this.DecodeValue(this.distanceTree))<16)c[i++]=o;else if(16===o){var _;if(i+(o=3+this.readBits(2))>a)return this.flushBuffer(),1;for(_=i?c[i-1]:0;o--;)c[i++]=_}else{if(i+(o=17===o?3+this.readBits(3):11+this.readBits(7))>a)return this.flushBuffer(),1;for(;o--;)c[i++]=0}for(f=this.literalTree.length,i=0;i<f;i++)this.literalTree[i]=new p7.HufNode;if(this.CreateTree(this.literalTree,h,c,0))return this.flushBuffer(),1;for(f=this.literalTree.length,i=0;i<f;i++)this.distanceTree[i]=new p7.HufNode;var d=new Array;for(i=h;i<c.length;i++)d[i-h]=c[i];if(this.CreateTree(this.distanceTree,u,d,0))return this.flushBuffer(),1;for(;;)if((o=this.DecodeValue(this.literalTree))>=256){var f,p;if(0==(o-=256))break;for(o--,f=this.readBits(p7.cplext[o])+p7.cplens[o],o=this.DecodeValue(this.distanceTree),p7.cpdext[o]>8?(p=this.readBits(8),p|=this.readBits(p7.cpdext[o]-8)<<8):p=this.readBits(p7.cpdext[o]),p+=p7.cpdist[o];f--;)s=this.buf32k[this.bIdx-p&32767],this.addBuffer(s)}else this.addBuffer(o)}}while(!t);return this.flushBuffer(),this.byteAlign(),0},p7.prototype.unzipFile=function(t){var e;for(this.gunzip(),e=0;e<this.unzipped.length;e++)if(this.unzipped[e][1]===t)return this.unzipped[e][0]},p7.prototype.nextFile=function(){this.outputArr=[],this.modeZIP=!1;var t=[];if(t[0]=this.readByte(),t[1]=this.readByte(),120===t[0]&&218===t[1]&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),"geonext.gxt"],this.files++),31===t[0]&&139===t[1]&&(this.skipdir(),this.unzipped[this.files]=[this.outputArr.join(""),"file"],this.files++),80===t[0]&&75===t[1]&&(this.modeZIP=!0,t[2]=this.readByte(),t[3]=this.readByte(),3===t[2]&&4===t[3])){t[0]=this.readByte(),t[1]=this.readByte(),this.gpflags=this.readByte(),this.gpflags|=this.readByte()<<8;var e=this.readByte();e|=this.readByte()<<8,this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte();var i=this.readByte();i|=this.readByte()<<8;var n=this.readByte();for(n|=this.readByte()<<8,s=0,this.nameBuf=[];i--;){var r=this.readByte();"/"===r|":"===r?s=0:s<p7.NAMEMAX-1&&(this.nameBuf[s++]=String.fromCharCode(r))}this.fileout||(this.fileout=this.nameBuf);for(var s=0;s<n;)r=this.readByte(),s++;8===e&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),this.nameBuf.join("")],this.files++),this.skipdir()}},p7.prototype.skipdir=function(){var t,e,i=[];if(8&this.gpflags&&(i[0]=this.readByte(),i[1]=this.readByte(),i[2]=this.readByte(),i[3]=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte()),this.modeZIP&&this.nextFile(),i[0]=this.readByte(),8!==i[0])return 0;if(this.gpflags=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),4&this.gpflags)for(i[0]=this.readByte(),i[2]=this.readByte(),this.len=i[0]+256*i[1],t=0;t<this.len;t++)this.readByte();if(8&this.gpflags)for(t=0,this.nameBuf=[];e=this.readByte();)"7"!==e&&":"!==e||(t=0),t<p7.NAMEMAX-1&&(this.nameBuf[t++]=e);if(16&this.gpflags)for(;e=this.readByte(););2&this.gpflags&&(this.readByte(),this.readByte()),this.DeflateLoop(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.modeZIP&&this.nextFile()};var m7,g7,y7,v7,S7,T7,A7,b7,E7,C7,w7,x7,R7,I7,B7,D7,P7,O7,M7,L7,N7,F7,k7,V7,G7,U7,z7,H7,W7,j7,X7,q7,Y7,K7,J7,Q7,Z7,$7,t9,e9,i9,n9,r9,s9,o9,a9,h9,u9,l9,c9,_9,d9,f9,p9={name:"Jacob__Codec"};function m9(t){var e=t.parent,i=t.getComponent(R9);return e&&i?m9(e):t.getComponentsInChildren(R9)}p9.Base64=f7,p9.GZip=p7,p9.unzip=function(){return p9.GZip.gunzip.apply(p9.GZip,arguments)},p9.unzipBase64=function(){var t=p9.Base64.decode.apply(p9.Base64,arguments);try{return p9.GZip.gunzip.call(p9.GZip,t)}catch(e){return t.slice(7)}},p9.unzipBase64AsArray=function(t,e){e=e||1;var i,n,r,s=this.unzipBase64(t),o=[];for(i=0,r=s.length/e;i<r;i++)for(o[i]=0,n=e-1;n>=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},p9.unzipAsArray=function(t,e){e=e||1;var i,n,r,s=this.unzip(t),o=[];for(i=0,r=s.length/e;i<r;i++)for(o[i]=0,n=e-1;n>=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},function(t){t[t.JPG=0]="JPG",t[t.PNG=1]="PNG",t[t.TIFF=2]="TIFF",t[t.WEBP=3]="WEBP",t[t.PVR=4]="PVR",t[t.ETC=5]="ETC",t[t.S3TC=6]="S3TC",t[t.ATITC=7]="ATITC",t[t.TGA=8]="TGA",t[t.RAWDATA=9]="RAWDATA",t[t.UNKNOWN=10]="UNKNOWN"}(f9||(f9={}));var g9,y9,v9,S9,T9,A9,b9,E9,C9,w9,x9,R9=t("eR",(m7=qs("cc.ParticleSystem2D"),g7=xo(o7),y7=xo(pF),v7=xo(K6),S7=xo(Y6),T7=no("preview"),m7(((d9=function(t){function e(){var e;return(e=t.call(this)||this).duration=E7&&E7(),e.emissionRate=C7&&C7(),e.life=w7&&w7(),e.lifeVar=x7&&x7(),e.angle=R7&&R7(),e.angleVar=I7&&I7(),e.startSize=B7&&B7(),e.startSizeVar=D7&&D7(),e.endSize=P7&&P7(),e.endSizeVar=O7&&O7(),e.startSpin=M7&&M7(),e.startSpinVar=L7&&L7(),e.endSpin=N7&&N7(),e.endSpinVar=F7&&F7(),e.sourcePos=k7&&k7(),e.posVar=V7&&V7(),e.emitterMode=G7&&G7(),e.gravity=U7&&U7(),e.speed=z7&&z7(),e.speedVar=H7&&H7(),e.tangentialAccel=W7&&W7(),e.tangentialAccelVar=j7&&j7(),e.radialAccel=X7&&X7(),e.radialAccelVar=q7&&q7(),e.rotationIsDir=Y7&&Y7(),e.startRadius=K7&&K7(),e.startRadiusVar=J7&&J7(),e.endRadius=Q7&&Q7(),e.endRadiusVar=Z7&&Z7(),e.rotatePerS=$7&&$7(),e.rotatePerSVar=t9&&t9(),e.aspectRatio=1,e.playOnLoad=e9&&e9(),e.autoRemoveOnFinish=i9&&i9(),e._preview=n9&&n9(),e._custom=r9&&r9(),e._file=s9&&s9(),e._spriteFrame=o9&&o9(),e._totalParticles=a9&&a9(),e._startColor=h9&&h9(),e._startColorVar=u9&&u9(),e._endColor=l9&&l9(),e._endColorVar=c9&&c9(),e._positionType=_9&&_9(),e._stopped=!0,e._useFile=void 0,e.initProperties(),e._useFile=!1,e}s(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this._updateMaterial(),this._updatePositionType()},i.onDestroy=function(){t.prototype.onDestroy.call(this),this.autoRemoveOnFinish&&(this.autoRemoveOnFinish=!1),this._simulator.uvFilled=0,this._simulator.renderData&&this._assembler&&this._assembler.removeData(this._simulator.renderData)},i.initProperties=function(){this._previewTimer=null,this._focused=!1,this.aspectRatio=1,this._simulator=new r7(this)},i.onFocusInEditor=function(){this._focused=!0;for(var t=m9(this.node),e=0;e<t.length;++e)t[e]._startPreview()},i.onLostFocusInEditor=function(){this._focused=!1;for(var t=m9(this.node),e=0;e<t.length;++e)t[e]._stopPreview()},i._startPreview=function(){this._preview&&this.resetSystem()},i._stopPreview=function(){this._preview&&(this.resetSystem(),this.stopSystem()),this._previewTimer&&clearInterval(this._previewTimer)},i.__preload=function(){t.prototype.__preload.call(this),this._custom&&this.spriteFrame&&!this._renderSpriteFrame?this._applySpriteFrame():this._file&&(this._custom?!this._getTexture()&&this._applyFile():this._applyFile()),this.playOnLoad&&this.resetSystem()},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._assembler&&this._assembler.createData&&(this._simulator.renderData=this._assembler.createData(this),this._simulator.renderData.particleInitRenderDrawInfo(this.renderEntity),this._simulator.initDrawInfo())},i.lateUpdate=function(t){this._simulator.finished||this._simulator.step(t)},i.addParticle=function(){},i.stopSystem=function(){this._stopped=!0,this._simulator.stop()},i.resetSystem=function(){this._stopped=!1,this._simulator.reset(),this.markForUpdateRenderData()},i.isFull=function(){return this.particleCount>=this.totalParticles},i._applyFile=function(){var t=this._file;if(t){if(!t)return void J(6029);if(!this.isValid)return;this._plistFile=t.nativeUrl,this._custom||(this._spriteFrame!==t.spriteFrame&&(this.spriteFrame=t.spriteFrame),this._initWithDictionary(t._nativeAsset)),this._spriteFrame?!this._renderSpriteFrame&&this._spriteFrame&&this._applySpriteFrame():t.spriteFrame?this.spriteFrame=t.spriteFrame:this._custom&&this._initTextureWithDictionary(t._nativeAsset)}},i._initTextureWithDictionary=function(t){var e,i=this;if(t.spriteFrameUuid){var n=t.spriteFrameUuid;ZS.loadAny(n,(function(e,n){e?(t.spriteFrameUuid=void 0,i._initTextureWithDictionary(t),V(e)):i.spriteFrame=n}))}else{var r=dl(this._plistFile,t.textureFileName||"");if(t.textureFileName)ZS.loadRemote(r,(function(e,n){e?(t.textureFileName=void 0,i._initTextureWithDictionary(t),V(e)):i.spriteFrame=n?pF.createWithImage(n):pF.createWithImage(nT.get("white-texture"))}));else if(t.textureImageData){var s=t.textureImageData;if(!(s&&s.length>0))return!1;var o=r;this.file&&(o+="-"+this.file.uuid);var a=ZS.assets.get(o);if(!a){var h=p9.unzipBase64AsArray(s,1);if(!h)return Y(6030,this._file.name),!1;var u=(e=h).length>8&&137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]&&13===e[4]&&10===e[5]&&26===e[6]&&10===e[7]?f9.PNG:e.length>2&&(73===e[0]&&73===e[1]||77===e[0]&&77===e[1]||255===e[0]&&216===e[1])?f9.TIFF:f9.UNKNOWN;if(u!==f9.TIFF&&u!==f9.PNG)return Y(6031,this._file.name),!1;var l=T.document.createElement("canvas");u===f9.PNG?new a7(h).render(l):(this._tiffReader||(this._tiffReader=new h7),this._tiffReader.parseTIFF(h,l)),a=new Rf(l),ZS.assets.add(o,a)}a||Y(6032,this._file.name),this.spriteFrame=a?pF.createWithImage(a):pF.createWithImage(nT.get("white-texture"))}}return!0},i._initWithDictionary=function(t){this._useFile=!0,this.totalParticles=parseInt(t.maxParticles||0),this.life=parseFloat(t.particleLifespan||0),this.lifeVar=parseFloat(t.particleLifespanVariance||0);var e=t.emissionRate;this.emissionRate=e||Math.min(this.totalParticles/this.life,Number.MAX_VALUE),this.duration=parseFloat(t.duration||0),this._srcBlendFactor=parseInt(t.blendFuncSource||oc.SRC_ALPHA),this._dstBlendFactor=parseInt(t.blendFuncDestination||oc.ONE_MINUS_SRC_ALPHA);var i=this._startColor;i.r=255*parseFloat(t.startColorRed||0),i.g=255*parseFloat(t.startColorGreen||0),i.b=255*parseFloat(t.startColorBlue||0),i.a=255*parseFloat(t.startColorAlpha||0);var n=this._startColorVar;n.r=255*parseFloat(t.startColorVarianceRed||0),n.g=255*parseFloat(t.startColorVarianceGreen||0),n.b=255*parseFloat(t.startColorVarianceBlue||0),n.a=255*parseFloat(t.startColorVarianceAlpha||0);var r=this._endColor;r.r=255*parseFloat(t.finishColorRed||0),r.g=255*parseFloat(t.finishColorGreen||0),r.b=255*parseFloat(t.finishColorBlue||0),r.a=255*parseFloat(t.finishColorAlpha||0);var s=this._endColorVar;if(s.r=255*parseFloat(t.finishColorVarianceRed||0),s.g=255*parseFloat(t.finishColorVarianceGreen||0),s.b=255*parseFloat(t.finishColorVarianceBlue||0),s.a=255*parseFloat(t.finishColorVarianceAlpha||0),this.startSize=parseFloat(t.startParticleSize||0),this.startSizeVar=parseFloat(t.startParticleSizeVariance||0),this.endSize=parseFloat(t.finishParticleSize||0),this.endSizeVar=parseFloat(t.finishParticleSizeVariance||0),this.positionType=parseFloat(void 0!==t.positionType?t.positionType:K6.FREE),this.sourcePos.set(0,0),this.posVar.set(parseFloat(t.sourcePositionVariancex||0),parseFloat(t.sourcePositionVariancey||0)),this.angle=parseFloat(t.angle||0),this.angleVar=parseFloat(t.angleVariance||0),this.startSpin=parseFloat(t.rotationStart||0),this.startSpinVar=parseFloat(t.rotationStartVariance||0),this.endSpin=parseFloat(t.rotationEnd||0),this.endSpinVar=parseFloat(t.rotationEndVariance||0),this.emitterMode=parseInt(t.emitterType||Y6.GRAVITY),this.emitterMode===Y6.GRAVITY){this.gravity.set(parseFloat(t.gravityx||0),parseFloat(t.gravityy||0)),this.speed=parseFloat(t.speed||0),this.speedVar=parseFloat(t.speedVariance||0),this.radialAccel=parseFloat(t.radialAcceleration||0),this.radialAccelVar=parseFloat(t.radialAccelVariance||0),this.tangentialAccel=parseFloat(t.tangentialAcceleration||0),this.tangentialAccelVar=parseFloat(t.tangentialAccelVariance||0);var o=t.rotationIsDir||"";null!==o?(o=o.toString().toLowerCase(),this.rotationIsDir="true"===o||"1"===o):this.rotationIsDir=!1}else{if(this.emitterMode!==Y6.RADIUS)return Y(6009),!1;this.startRadius=parseFloat(t.maxRadius||0),this.startRadiusVar=parseFloat(t.maxRadiusVariance||0),this.endRadius=parseFloat(t.minRadius||0),this.endRadiusVar=parseFloat(t.minRadiusVariance||0),this.rotatePerS=parseFloat(t.rotatePerSecond||0),this.rotatePerSVar=parseFloat(t.rotatePerSecondVariance||0)}return this._initTextureWithDictionary(t),!0},i._syncAspect=function(){if(this._renderSpriteFrame){var t=this._renderSpriteFrame.rect;this.aspectRatio=t.width/t.height}},i._applySpriteFrame=function(){this._renderSpriteFrame=this._renderSpriteFrame||this._spriteFrame,this._renderSpriteFrame?this._renderSpriteFrame.texture&&(this._simulator&&this._simulator.updateUVs(!0),this._syncAspect(),this._updateMaterial(),this._stopped=!1,this.markForUpdateRenderData()):this.resetSystem()},i._getTexture=function(){return this._renderSpriteFrame&&this._renderSpriteFrame.texture},i._updateMaterial=function(){if(this._customMaterial){this.setSharedMaterial(this._customMaterial,0);var t=this.getRenderMaterial(0).passes[0].blendState.targets[0];this._dstBlendFactor=t.blendDst,this._srcBlendFactor=t.blendSrc}var e=this.getMaterialInstance(0);e&&e.recompileShaders({USE_LOCAL:this._positionType!==K6.FREE}),e&&e.passes.length>0&&this._updateBlendFunc()},i._finishedSimulation=function(){this.resetSystem(),this.stopSystem(),this.markForUpdateRenderData(),this.autoRemoveOnFinish&&this._stopped&&this.node.destroy()},i._canRender=function(){return t.prototype._canRender.call(this)&&!this._stopped&&null!==this._renderSpriteFrame&&void 0!==this._renderSpriteFrame},i._render=function(t){this._positionType===K6.RELATIVE?t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node.parent):this.positionType===K6.GROUPED?t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node):t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,null)},i._updatePositionType=function(){this._positionType===K6.RELATIVE?(this._renderEntity.setRenderTransform(this.node.parent),this._renderEntity.setUseLocal(!0)):this.positionType===K6.GROUPED?(this._renderEntity.setRenderTransform(this.node),this._renderEntity.setUseLocal(!0)):(this._renderEntity.setRenderTransform(null),this._renderEntity.setUseLocal(!1))},n(e,[{key:"custom",get:function(){return this._custom},set:function(t){this._custom!==t&&(this._custom=t,this._applyFile(),this._updateMaterial())}},{key:"file",get:function(){return this._file},set:function(t){this._file!==t&&(this._file=t,t?this._applyFile():this.custom=!0)}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._renderSpriteFrame!==t&&(this._renderSpriteFrame=t,t&&!t._uuid||(this._spriteFrame=t),this._applySpriteFrame())}},{key:"particleCount",get:function(){return this._simulator.particles.length}},{key:"totalParticles",get:function(){return this._totalParticles},set:function(t){this._totalParticles!==t&&(this._totalParticles=t)}},{key:"startColor",get:function(){return this._startColor},set:function(t){this._startColor.r=t.r,this._startColor.g=t.g,this._startColor.b=t.b,this._startColor.a=t.a}},{key:"startColorVar",get:function(){return this._startColorVar},set:function(t){this._startColorVar.r=t.r,this._startColorVar.g=t.g,this._startColorVar.b=t.b,this._startColorVar.a=t.a}},{key:"color",get:function(){return this._color},set:function(){}},{key:"endColor",get:function(){return this._endColor},set:function(t){this._endColor.r=t.r,this._endColor.g=t.g,this._endColor.b=t.b,this._endColor.a=t.a}},{key:"endColorVar",get:function(){return this._endColorVar},set:function(t){this._endColorVar.r=t.r,this._endColorVar.g=t.g,this._endColorVar.b=t.b,this._endColorVar.a=t.a}},{key:"positionType",get:function(){return this._positionType},set:function(t){this._positionType=t,this._updateMaterial(),this._updatePositionType()}},{key:"preview",get:function(){return this._preview},set:function(t){t?this._startPreview():this._stopPreview(),this._preview=t}},{key:"stopped",get:function(){return this._stopped}},{key:"active",get:function(){return this._simulator.active}},{key:"assembler",get:function(){return this._assembler}}]),e}(TV)).EmitterMode=Y6,d9.PositionType=K6,d9.DURATION_INFINITY=-1,d9.START_SIZE_EQUAL_TO_END_SIZE=-1,d9.START_RADIUS_EQUAL_TO_END_RADIUS=-1,p((b7=d9).prototype,"file",[g7],Object.getOwnPropertyDescriptor(b7.prototype,"file"),b7.prototype),p(b7.prototype,"spriteFrame",[y7],Object.getOwnPropertyDescriptor(b7.prototype,"spriteFrame"),b7.prototype),E7=ks(b7.prototype,"duration",[io],(function(){return-1})),C7=ks(b7.prototype,"emissionRate",[io],(function(){return 10})),w7=ks(b7.prototype,"life",[io],(function(){return 1})),x7=ks(b7.prototype,"lifeVar",[io],(function(){return 0})),p(b7.prototype,"color",[Ro],Object.getOwnPropertyDescriptor(b7.prototype,"color"),b7.prototype),R7=ks(b7.prototype,"angle",[io],(function(){return 90})),I7=ks(b7.prototype,"angleVar",[io],(function(){return 20})),B7=ks(b7.prototype,"startSize",[io],(function(){return 50})),D7=ks(b7.prototype,"startSizeVar",[io],(function(){return 0})),P7=ks(b7.prototype,"endSize",[io],(function(){return 0})),O7=ks(b7.prototype,"endSizeVar",[io],(function(){return 0})),M7=ks(b7.prototype,"startSpin",[io],(function(){return 0})),L7=ks(b7.prototype,"startSpinVar",[io],(function(){return 0})),N7=ks(b7.prototype,"endSpin",[io],(function(){return 0})),F7=ks(b7.prototype,"endSpinVar",[io],(function(){return 0})),k7=ks(b7.prototype,"sourcePos",[io],(function(){return Ln.ZERO.clone()})),V7=ks(b7.prototype,"posVar",[io],(function(){return Ln.ZERO.clone()})),p(b7.prototype,"positionType",[v7],Object.getOwnPropertyDescriptor(b7.prototype,"positionType"),b7.prototype),G7=ks(b7.prototype,"emitterMode",[io,S7],(function(){return Y6.GRAVITY})),U7=ks(b7.prototype,"gravity",[io],(function(){return Ln.ZERO.clone()})),z7=ks(b7.prototype,"speed",[io],(function(){return 180})),H7=ks(b7.prototype,"speedVar",[io],(function(){return 50})),W7=ks(b7.prototype,"tangentialAccel",[io],(function(){return 80})),j7=ks(b7.prototype,"tangentialAccelVar",[io],(function(){return 0})),X7=ks(b7.prototype,"radialAccel",[io],(function(){return 0})),q7=ks(b7.prototype,"radialAccelVar",[io],(function(){return 0})),Y7=ks(b7.prototype,"rotationIsDir",[io],(function(){return!1})),K7=ks(b7.prototype,"startRadius",[io],(function(){return 0})),J7=ks(b7.prototype,"startRadiusVar",[io],(function(){return 0})),Q7=ks(b7.prototype,"endRadius",[io],(function(){return 0})),Z7=ks(b7.prototype,"endRadiusVar",[io],(function(){return 0})),$7=ks(b7.prototype,"rotatePerS",[io],(function(){return 0})),t9=ks(b7.prototype,"rotatePerSVar",[io],(function(){return 0})),e9=ks(b7.prototype,"playOnLoad",[io],(function(){return!0})),i9=ks(b7.prototype,"autoRemoveOnFinish",[io],(function(){return!1})),n9=ks(b7.prototype,"_preview",[T7],(function(){return!0})),r9=ks(b7.prototype,"_custom",[io],(function(){return!1})),s9=ks(b7.prototype,"_file",[io],(function(){return null})),o9=ks(b7.prototype,"_spriteFrame",[io],(function(){return null})),a9=ks(b7.prototype,"_totalParticles",[io],(function(){return 150})),h9=ks(b7.prototype,"_startColor",[io],(function(){return new dn(255,255,255,255)})),u9=ks(b7.prototype,"_startColorVar",[io],(function(){return new dn(0,0,0,0)})),l9=ks(b7.prototype,"_endColor",[io],(function(){return new dn(255,255,255,0)})),c9=ks(b7.prototype,"_endColorVar",[io],(function(){return new dn(0,0,0,0)})),_9=ks(b7.prototype,"_positionType",[io],(function(){return K6.FREE})),A7=b7))||A7)),I9=function(){function t(t,e){this.point=new Ln,this.dir=new Ln,this.distance=0,this.time=0,t&&this.point.set(t),e&&this.dir.set(e)}var e=t.prototype;return e.setPoint=function(t,e){this.point.x=t,this.point.y=e},e.setDir=function(t,e){this.dir.x=t,this.dir.y=e},t}(),B9=t("eS",(g9=qs("cc.MotionStreak"),y9=xo(Zp),g9(((x9=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._preview=T9&&T9(),e._fadeTime=A9&&A9(),e._minSeg=b9&&b9(),e._stroke=E9&&E9(),e._texture=C9&&C9(),e._fastMode=w9&&w9(),e._points=[],e}s(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this.reset()},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._renderData.material=this.material,this._updateColor())},i.onFocusInEditor=function(){this._preview&&this.reset()},i.onLostFocusInEditor=function(){this._preview&&this.reset()},i.reset=function(){this._points.length=0,this._renderData&&this._renderData.clear()},i.lateUpdate=function(t){this._assembler&&this._assembler.update(this,t)},i._render=function(t){t.commitComp(this,this._renderData,this._texture,this._assembler,null)},n(e,[{key:"preview",get:function(){return this._preview},set:function(t){this._preview=t,this.reset()}},{key:"fadeTime",get:function(){return this._fadeTime},set:function(t){this._fadeTime=t,this.reset()}},{key:"minSeg",get:function(){return this._minSeg},set:function(t){this._minSeg=t}},{key:"stroke",get:function(){return this._stroke},set:function(t){this._stroke=t}},{key:"texture",get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t)}},{key:"fastMode",get:function(){return this._fastMode},set:function(t){this._fastMode=t}},{key:"points",get:function(){return this._points}}]),e}(TV)).Point=I9,p((S9=x9).prototype,"texture",[y9],Object.getOwnPropertyDescriptor(S9.prototype,"texture"),S9.prototype),T9=ks(S9.prototype,"_preview",[io],(function(){return!1})),A9=ks(S9.prototype,"_fadeTime",[io],(function(){return 1})),b9=ks(S9.prototype,"_minSeg",[io],(function(){return 1})),E9=ks(S9.prototype,"_stroke",[io],(function(){return 64})),C9=ks(S9.prototype,"_texture",[io],(function(){return null})),w9=ks(S9.prototype,"_fastMode",[io],(function(){return!1})),v9=S9))||v9));new Ln;var D9,P9=new Ln,O9=new Ln;function M9(t,e){return t.x=-e.y,t.y=e.x,t}var L9={createData:function(t){var e=t.requestRenderData();return e.dataLength=4,e.resize(16,42),e},update:function(t,e){var i,n=t.stroke/2,r=t.node.worldMatrix,s=r.m12,o=r.m13,a=t.points;if(a.length>1){var h=a[0],u=h.point.x-s,l=h.point.y-o;u*u+l*l<t.minSeg&&(i=h)}i||(i=new B9.Point,a.unshift(i)),i.setPoint(s,o),i.time=t.fadeTime+e;var c,_=0;if(!(a.length<2)){var d=t.renderData;this.updateRenderDataCache(t,d);var f=t.color,p=f.r,m=f.g,g=f.b,y=f.a,v=a[1];v.distance=Ln.subtract(O9,i.point,v.point).length(),O9.normalize(),v.setDir(O9.x,O9.y),i.setDir(O9.x,O9.y),d.dataLength=2*a.length;for(var S=d.data,T=t.fadeTime,A=!1,b=a.length-1;b>=0;b--){var E=a[b],C=E.point,w=E.dir;if(E.time-=e,E.time<0)a.splice(b,1);else{var x=E.time/T,R=a[b-1];if(!A){if(!R){a.splice(b,1);continue}C.x=R.point.x-w.x*x,C.y=R.point.y-w.y*x}A=!0,M9(P9,w);var I=(x*y<<24>>>0)+(g<<16)+(m<<8)+p,B=_;S[B].x=C.x+P9.x*n,S[B].y=C.y+P9.y*n,S[B].u=1,S[B].v=x,S[B].color._val=I,S[B+=1].x=C.x-P9.x*n,S[B].y=C.y-P9.y*n,S[B].u=0,S[B].v=x,S[B].color._val=I,_+=2}}c=_<=2?0:3*(_-2),d.resize(_,c)}},updateWorldVertexAllData:function(t){for(var e=t.renderData,i=e.floatStride,n=e.data,r=e.chunk.vb,s=0;s<n.length;s++){var o=s*i;r[o+0]=n[s].x,r[o+1]=n[s].y,r[o+2]=n[s].z,r[o+3]=n[s].u,r[o+4]=n[s].v,dn.toArray(r,n[s].color,o+5)}},createQuadIndices:function(t,e){var i=t.renderData.chunk.meshBuffer.indexOffset;D9=null,D9=new Uint16Array(e);for(var n=0,r=e;n<r;n+=2){var s=0+n;D9[i++]=s,D9[i++]=s+2,D9[i++]=s+1,D9[i++]=s+1,D9[i++]=s+2,D9[i++]=s+3}},updateRenderDataCache:function(t,e){e.passDirty&&e.updatePass(t),e.nodeDirty&&e.updateNode(t),e.textureDirty&&t.texture&&(e.updateTexture(t.texture),e.material=t.getRenderMaterial(0)),e.hashDirty&&e.updateHash()},updateRenderData:function(){},updateColor:function(){},fillBuffers:function(t){for(var e=t.renderData,i=e.chunk,n=e.data,r=e.vertexCount,s=e.indexCount,o=i.vb,a=0,h=0;h<r;h++){var u=n[h];o[a++]=u.x,o[a++]=u.y,o[a++]=u.z,o[a++]=u.u,o[a++]=u.v,dn.toArray(o,u.color,a),a+=4}i.bufferId;for(var l=i.vertexOffset,c=i.meshBuffer,_=i.meshBuffer.iData,d=c.indexOffset,f=0,p=s;f<p;f+=2){var m=l+f;_[d++]=m,_[d++]=m+2,_[d++]=m+1,_[d++]=m+1,_[d++]=m+2,_[d++]=m+3}c.indexOffset+=e.indexCount,c.setDirty()}},N9=t("eT",{getAssembler:function(){return L9}});B9.Assembler=N9;var F9,k9,V9,G9,U9,z9={maxParticleDeltaTime:0,createData:function(){return Yk.add()},removeData:function(t){Yk.remove(t)},updateRenderData:function(){},fillBuffers:function(){}},H9=t("eU",{getAssembler:function(){return z9.maxParticleDeltaTime||(z9.maxParticleDeltaTime=v.game.frameTime/1e3*2),z9}});R9.Assembler=H9,t("eY",F9),function(t){t[t.Static=0]="Static",t[t.Kinematic=1]="Kinematic",t[t.Dynamic=2]="Dynamic",t[t.Animated=3]="Animated"}(F9||t("eY",F9={})),ge(F9),t("eZ",k9),function(t){t[t.None=0]="None",t[t.BOX=1]="BOX",t[t.CIRCLE=2]="CIRCLE",t[t.POLYGON=3]="POLYGON"}(k9||t("eZ",k9={})),ge(k9),t("e_",V9),function(t){t[t.None=0]="None",t[t.DISTANCE=1]="DISTANCE",t[t.SPRING=2]="SPRING",t[t.WHEEL=3]="WHEEL",t[t.MOUSE=4]="MOUSE",t[t.FIXED=5]="FIXED",t[t.SLIDER=6]="SLIDER",t[t.RELATIVE=7]="RELATIVE",t[t.HINGE=8]="HINGE"}(V9||t("e_",V9={})),ge(V9),t("e$",G9),function(t){t[t.DEFAULT=1]="DEFAULT"}(G9||t("e$",G9={})),ge(G9),t("f0",U9),function(t){t[t.Closest=0]="Closest",t[t.Any=1]="Any",t[t.AllClosest=2]="AllClosest",t[t.All=3]="All"}(U9||t("f0",U9={}));var W9,j9=t("f1",{None:"none-contact",BEGIN_CONTACT:"begin-contact",END_CONTACT:"end-contact",PRE_SOLVE:"pre-solve",POST_SOLVE:"post-solve"});t("f2",W9),function(t){t[t.None=0]="None",t[t.Shape=1]="Shape",t[t.Joint=2]="Joint",t[t.Aabb=4]="Aabb",t[t.Pair=8]="Pair",t[t.CenterOfMass=16]="CenterOfMass",t[t.Particle=32]="Particle",t[t.Controller=64]="Controller",t[t.All=63]="All"}(W9||t("f2",W9={}));var X9=t("f3",32),q9=t("eX",{id:"",switchTo:function(t){var e=q9;q9.physicsWorld&&t!==q9.id&&null!=q9.backend[t]?(F("[PHYSICS2D]: switch from "+q9.id+" to "+t+"."),e.id=t,e.wrapper=q9.backend[t],e.physicsWorld=K9()):(F("[PHYSICS2D]: using "+e.id+"."),e.physicsWorld=K9())},register:function(t,e){if(F("[PHYSICS2D]: register "+t+"."),q9.backend[t]=e,!q9.physicsWorld||q9.id===t){var i=q9;i.id=t,i.wrapper=e}},wrapper:{},backend:{},physicsWorld:null,runInEditor:!0}),Y9=function(){return 0};function K9(){return new q9.wrapper.PhysicsWorld}var J9={impl:null,rigidBody:null,isAwake:!1,isSleeping:!1,initialize:Y9,setType:Y9,setLinearDamping:Y9,setAngularDamping:Y9,setGravityScale:Y9,setFixedRotation:Y9,setAllowSleep:Y9,isActive:Y9,setActive:Y9,wakeUp:Y9,sleep:Y9,getMass:Y9,getInertia:Y9,getLinearVelocity:Y9,setLinearVelocity:Y9,getLinearVelocityFromWorldPoint:Y9,getAngularVelocity:Y9,setAngularVelocity:Y9,getLocalVector:Y9,getWorldVector:Y9,getLocalPoint:Y9,getWorldPoint:Y9,getLocalCenter:Y9,getWorldCenter:Y9,applyForce:Y9,applyForceToCenter:Y9,applyTorque:Y9,applyLinearImpulse:Y9,applyLinearImpulseToCenter:Y9,applyAngularImpulse:Y9,onEnable:Y9,onDisable:Y9,onDestroy:Y9},Q9={INITED:!1};var Z9={INITED:!1},$9={impl:null,initialize:Y9,apply:Y9,setDampingRatio:Y9,setFrequency:Y9,setMaxForce:Y9,setTarget:Y9,setDistance:Y9,setAngularOffset:Y9,setCorrectionFactor:Y9,setLinearOffset:Y9,setMaxLength:Y9,setMaxTorque:Y9,setLowerLimit:Y9,setUpperLimit:Y9,setMaxMotorForce:Y9,setMaxMotorTorque:Y9,setMotorSpeed:Y9,enableLimit:Y9,enableMotor:Y9,setLowerAngle:Y9,setUpperAngle:Y9};function ttt(t,e){return t(e={exports:{}},e.exports),e.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var ett,itt=ttt((function(t,e){!function(t){function e(t,e){return void 0!==t?t:e}var i=1e37,r=1e-5,o=r*r,a=3.14159265359,h=.1,l=.008,c=2/180*a,_=.016,f=.2,p=8/180*a,m=.5*a,g=2.4674011002726646,y=-1,v=.75,S=.25,T=256,A=.01,b=2/180*a;var E=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.major=0,this.minor=0,this.revision=0,this.major=t,this.minor=e,this.revision=i}return t.prototype.toString=function(){return this.major+"."+this.minor+"."+this.revision},t}(),C=new E(2,3,2);function w(t,e){for(var i=new Array(t),n=0;n<t;++n)i[n]=e(n);return i}function x(t,e){void 0===e&&(e=0);for(var i=new Array(t),n=0;n<t;++n)i[n]=e;return i}var R=a/180,I=180/a,B=2*a,D=Math.abs;function P(t,e){return t<e?t:e}function O(t,e){return t>e?t:e}function M(t,e,i){return t<e?e:t>i?i:t}var L=isFinite;function N(t){return t*t}function F(t){return 1/Math.sqrt(t)}var k=Math.sqrt,V=Math.pow;var G=Math.cos,U=Math.sin,z=Math.acos,H=Math.asin,W=Math.atan2;var j=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(e[0]instanceof Float32Array){if(2!==e[0].length)throw new Error;this.data=e[0]}else{var n="number"==typeof e[0]?e[0]:0,r="number"==typeof e[1]?e[1]:0;this.data=new Float32Array([n,r])}}var e=t.prototype;return e.Clone=function(){return new t(this.x,this.y)},e.SetZero=function(){return this.x=0,this.y=0,this},e.Set=function(t,e){return this.x=t,this.y=e,this},e.Copy=function(t){return this.x=t.x,this.y=t.y,this},e.SelfAdd=function(t){return this.x+=t.x,this.y+=t.y,this},e.SelfAddXY=function(t,e){return this.x+=t,this.y+=e,this},e.SelfSub=function(t){return this.x-=t.x,this.y-=t.y,this},e.SelfSubXY=function(t,e){return this.x-=t,this.y-=e,this},e.SelfMul=function(t){return this.x*=t,this.y*=t,this},e.SelfMulAdd=function(t,e){return this.x+=t*e.x,this.y+=t*e.y,this},e.SelfMulSub=function(t,e){return this.x-=t*e.x,this.y-=t*e.y,this},e.Dot=function(t){return this.x*t.x+this.y*t.y},e.Cross=function(t){return this.x*t.y-this.y*t.x},e.Length=function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},e.LengthSquared=function(){var t=this.x,e=this.y;return t*t+e*e},e.Normalize=function(){var t=this.Length();if(t>=r){var e=1/t;this.x*=e,this.y*=e}return t},e.SelfNormalize=function(){var t=this.Length();if(t>=r){var e=1/t;this.x*=e,this.y*=e}return this},e.SelfRotate=function(t){var e=Math.cos(t),i=Math.sin(t),n=this.x;return this.x=e*n-i*this.y,this.y=i*n+e*this.y,this},e.SelfRotateCosSin=function(t,e){var i=this.x;return this.x=t*i-e*this.y,this.y=e*i+t*this.y,this},e.IsValid=function(){return isFinite(this.x)&&isFinite(this.y)},e.SelfCrossVS=function(t){var e=this.x;return this.x=t*this.y,this.y=-t*e,this},e.SelfCrossSV=function(t){var e=this.x;return this.x=-t*this.y,this.y=t*e,this},e.SelfMinV=function(t){return this.x=P(this.x,t.x),this.y=P(this.y,t.y),this},e.SelfMaxV=function(t){return this.x=O(this.x,t.x),this.y=O(this.y,t.y),this},e.SelfAbs=function(){return this.x=D(this.x),this.y=D(this.y),this},e.SelfNeg=function(){return this.x=-this.x,this.y=-this.y,this},e.SelfSkew=function(){var t=this.x;return this.x=-this.y,this.y=t,this},t.MakeArray=function(e){return w(e,(function(){return new t}))},t.AbsV=function(t,e){return e.x=D(t.x),e.y=D(t.y),e},t.MinV=function(t,e,i){return i.x=P(t.x,e.x),i.y=P(t.y,e.y),i},t.MaxV=function(t,e,i){return i.x=O(t.x,e.x),i.y=O(t.y,e.y),i},t.ClampV=function(t,e,i,n){return n.x=M(t.x,e.x,i.x),n.y=M(t.y,e.y,i.y),n},t.RotateV=function(t,e,i){var n=t.x,r=t.y,s=Math.cos(e),o=Math.sin(e);return i.x=s*n-o*r,i.y=o*n+s*r,i},t.DotVV=function(t,e){return t.x*e.x+t.y*e.y},t.CrossVV=function(t,e){return t.x*e.y-t.y*e.x},t.CrossVS=function(t,e,i){var n=t.x;return i.x=e*t.y,i.y=-e*n,i},t.CrossVOne=function(t,e){var i=t.x;return e.x=t.y,e.y=-i,e},t.CrossSV=function(t,e,i){var n=e.x;return i.x=-t*e.y,i.y=t*n,i},t.CrossOneV=function(t,e){var i=t.x;return e.x=-t.y,e.y=i,e},t.AddVV=function(t,e,i){return i.x=t.x+e.x,i.y=t.y+e.y,i},t.SubVV=function(t,e,i){return i.x=t.x-e.x,i.y=t.y-e.y,i},t.MulSV=function(t,e,i){return i.x=e.x*t,i.y=e.y*t,i},t.MulVS=function(t,e,i){return i.x=t.x*e,i.y=t.y*e,i},t.AddVMulSV=function(t,e,i,n){return n.x=t.x+e*i.x,n.y=t.y+e*i.y,n},t.SubVMulSV=function(t,e,i,n){return n.x=t.x-e*i.x,n.y=t.y-e*i.y,n},t.AddVCrossSV=function(t,e,i,n){var r=i.x;return n.x=t.x-e*i.y,n.y=t.y+e*r,n},t.MidVV=function(t,e,i){return i.x=.5*(t.x+e.x),i.y=.5*(t.y+e.y),i},t.ExtVV=function(t,e,i){return i.x=.5*(e.x-t.x),i.y=.5*(e.y-t.y),i},t.IsEqualToV=function(t,e){return t.x===e.x&&t.y===e.y},t.DistanceVV=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},t.DistanceSquaredVV=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},t.NegV=function(t,e){return e.x=-t.x,e.y=-t.y,e},n(t,[{key:"x",get:function(){return this.data[0]},set:function(t){this.data[0]=t}},{key:"y",get:function(){return this.data[1]},set:function(t){this.data[1]=t}}]),t}();j.ZERO=new j(0,0),j.UNITX=new j(1,0),j.UNITY=new j(0,1),j.s_t0=new j,j.s_t1=new j,j.s_t2=new j,j.s_t3=new j;var X=new j(0,0),q=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(e[0]instanceof Float32Array){if(3!==e[0].length)throw new Error;this.data=e[0]}else{var n="number"==typeof e[0]?e[0]:0,r="number"==typeof e[1]?e[1]:0,s="number"==typeof e[2]?e[2]:0;this.data=new Float32Array([n,r,s])}}var e=t.prototype;return e.Clone=function(){return new t(this.x,this.y,this.z)},e.SetZero=function(){return this.x=0,this.y=0,this.z=0,this},e.SetXYZ=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},e.Copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},e.SelfNeg=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.SelfAdd=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},e.SelfAddXYZ=function(t,e,i){return this.x+=t,this.y+=e,this.z+=i,this},e.SelfSub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},e.SelfSubXYZ=function(t,e,i){return this.x-=t,this.y-=e,this.z-=i,this},e.SelfMul=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.DotV3V3=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},t.CrossV3V3=function(t,e,i){var n=t.x,r=t.y,s=t.z,o=e.x,a=e.y,h=e.z;return i.x=r*h-s*a,i.y=s*o-n*h,i.z=n*a-r*o,i},n(t,[{key:"x",get:function(){return this.data[0]},set:function(t){this.data[0]=t}},{key:"y",get:function(){return this.data[1]},set:function(t){this.data[1]=t}},{key:"z",get:function(){return this.data[2]},set:function(t){this.data[2]=t}}]),t}();q.ZERO=new q(0,0,0),q.s_t0=new q;var Y=function(){function t(){this.data=new Float32Array([1,0,0,1]),this.ex=new j(this.data.subarray(0,2)),this.ey=new j(this.data.subarray(2,4))}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},t.FromVV=function(e,i){return(new t).SetVV(e,i)},t.FromSSSS=function(e,i,n,r){return(new t).SetSSSS(e,i,n,r)},t.FromAngle=function(e){return(new t).SetAngle(e)},e.SetSSSS=function(t,e,i,n){return this.ex.Set(t,i),this.ey.Set(e,n),this},e.SetVV=function(t,e){return this.ex.Copy(t),this.ey.Copy(e),this},e.SetAngle=function(t){var e=Math.cos(t),i=Math.sin(t);return this.ex.Set(e,i),this.ey.Set(-i,e),this},e.Copy=function(t){return this.ex.Copy(t.ex),this.ey.Copy(t.ey),this},e.SetIdentity=function(){return this.ex.Set(1,0),this.ey.Set(0,1),this},e.SetZero=function(){return this.ex.SetZero(),this.ey.SetZero(),this},e.GetAngle=function(){return Math.atan2(this.ex.y,this.ex.x)},e.GetInverse=function(t){var e=this.ex.x,i=this.ey.x,n=this.ex.y,r=this.ey.y,s=e*r-i*n;return 0!==s&&(s=1/s),t.ex.x=s*r,t.ey.x=-s*i,t.ex.y=-s*n,t.ey.y=s*e,t},e.Solve=function(t,e,i){var n=this.ex.x,r=this.ey.x,s=this.ex.y,o=this.ey.y,a=n*o-r*s;return 0!==a&&(a=1/a),i.x=a*(o*t-r*e),i.y=a*(n*e-s*t),i},e.SelfAbs=function(){return this.ex.SelfAbs(),this.ey.SelfAbs(),this},e.SelfInv=function(){return this.GetInverse(this),this},e.SelfAddM=function(t){return this.ex.SelfAdd(t.ex),this.ey.SelfAdd(t.ey),this},e.SelfSubM=function(t){return this.ex.SelfSub(t.ex),this.ey.SelfSub(t.ey),this},t.AbsM=function(t,e){var i=t.ex,n=t.ey;return e.ex.x=D(i.x),e.ex.y=D(i.y),e.ey.x=D(n.x),e.ey.y=D(n.y),e},t.MulMV=function(t,e,i){var n=t.ex,r=t.ey,s=e.x,o=e.y;return i.x=n.x*s+r.x*o,i.y=n.y*s+r.y*o,i},t.MulTMV=function(t,e,i){var n=t.ex,r=t.ey,s=e.x,o=e.y;return i.x=n.x*s+n.y*o,i.y=r.x*s+r.y*o,i},t.AddMM=function(t,e,i){var n=t.ex,r=t.ey,s=e.ex,o=e.ey;return i.ex.x=n.x+s.x,i.ex.y=n.y+s.y,i.ey.x=r.x+o.x,i.ey.y=r.y+o.y,i},t.MulMM=function(t,e,i){var n=t.ex.x,r=t.ex.y,s=t.ey.x,o=t.ey.y,a=e.ex.x,h=e.ex.y,u=e.ey.x,l=e.ey.y;return i.ex.x=n*a+s*h,i.ex.y=r*a+o*h,i.ey.x=n*u+s*l,i.ey.y=r*u+o*l,i},t.MulTMM=function(t,e,i){var n=t.ex.x,r=t.ex.y,s=t.ey.x,o=t.ey.y,a=e.ex.x,h=e.ex.y,u=e.ey.x,l=e.ey.y;return i.ex.x=n*a+r*h,i.ex.y=s*a+o*h,i.ey.x=n*u+r*l,i.ey.y=s*u+o*l,i},t}();Y.IDENTITY=new Y;var K=function(){function t(){this.data=new Float32Array([1,0,0,0,1,0,0,0,1]),this.ex=new q(this.data.subarray(0,3)),this.ey=new q(this.data.subarray(3,6)),this.ez=new q(this.data.subarray(6,9))}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.SetVVV=function(t,e,i){return this.ex.Copy(t),this.ey.Copy(e),this.ez.Copy(i),this},e.Copy=function(t){return this.ex.Copy(t.ex),this.ey.Copy(t.ey),this.ez.Copy(t.ez),this},e.SetIdentity=function(){return this.ex.SetXYZ(1,0,0),this.ey.SetXYZ(0,1,0),this.ez.SetXYZ(0,0,1),this},e.SetZero=function(){return this.ex.SetZero(),this.ey.SetZero(),this.ez.SetZero(),this},e.SelfAddM=function(t){return this.ex.SelfAdd(t.ex),this.ey.SelfAdd(t.ey),this.ez.SelfAdd(t.ez),this},e.Solve33=function(t,e,i,n){var r=this.ex.x,s=this.ex.y,o=this.ex.z,a=this.ey.x,h=this.ey.y,u=this.ey.z,l=this.ez.x,c=this.ez.y,_=this.ez.z,d=r*(h*_-u*c)+s*(u*l-a*_)+o*(a*c-h*l);return 0!==d&&(d=1/d),n.x=d*(t*(h*_-u*c)+e*(u*l-a*_)+i*(a*c-h*l)),n.y=d*(r*(e*_-i*c)+s*(i*l-t*_)+o*(t*c-e*l)),n.z=d*(r*(h*i-u*e)+s*(u*t-a*i)+o*(a*e-h*t)),n},e.Solve22=function(t,e,i){var n=this.ex.x,r=this.ey.x,s=this.ex.y,o=this.ey.y,a=n*o-r*s;return 0!==a&&(a=1/a),i.x=a*(o*t-r*e),i.y=a*(n*e-s*t),i},e.GetInverse22=function(t){var e=this.ex.x,i=this.ey.x,n=this.ex.y,r=this.ey.y,s=e*r-i*n;0!==s&&(s=1/s),t.ex.x=s*r,t.ey.x=-s*i,t.ex.z=0,t.ex.y=-s*n,t.ey.y=s*e,t.ey.z=0,t.ez.x=0,t.ez.y=0,t.ez.z=0},e.GetSymInverse33=function(t){var e=q.DotV3V3(this.ex,q.CrossV3V3(this.ey,this.ez,q.s_t0));0!==e&&(e=1/e);var i=this.ex.x,n=this.ey.x,r=this.ez.x,s=this.ey.y,o=this.ez.y,a=this.ez.z;t.ex.x=e*(s*a-o*o),t.ex.y=e*(r*o-n*a),t.ex.z=e*(n*o-r*s),t.ey.x=t.ex.y,t.ey.y=e*(i*a-r*r),t.ey.z=e*(r*n-i*o),t.ez.x=t.ex.z,t.ez.y=t.ey.z,t.ez.z=e*(i*s-n*n)},t.MulM33V3=function(t,e,i){var n=e.x,r=e.y,s=e.z;return i.x=t.ex.x*n+t.ey.x*r+t.ez.x*s,i.y=t.ex.y*n+t.ey.y*r+t.ez.y*s,i.z=t.ex.z*n+t.ey.z*r+t.ez.z*s,i},t.MulM33XYZ=function(t,e,i,n,r){return r.x=t.ex.x*e+t.ey.x*i+t.ez.x*n,r.y=t.ex.y*e+t.ey.y*i+t.ez.y*n,r.z=t.ex.z*e+t.ey.z*i+t.ez.z*n,r},t.MulM33V2=function(t,e,i){var n=e.x,r=e.y;return i.x=t.ex.x*n+t.ey.x*r,i.y=t.ex.y*n+t.ey.y*r,i},t.MulM33XY=function(t,e,i,n){return n.x=t.ex.x*e+t.ey.x*i,n.y=t.ex.y*e+t.ey.y*i,n},t}();K.IDENTITY=new K;var J=function(){function t(t){void 0===t&&(t=0),this.s=0,this.c=1,t&&(this.s=Math.sin(t),this.c=Math.cos(t))}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.s=t.s,this.c=t.c,this},e.SetAngle=function(t){return this.s=Math.sin(t),this.c=Math.cos(t),this},e.SetIdentity=function(){return this.s=0,this.c=1,this},e.GetAngle=function(){return Math.atan2(this.s,this.c)},e.GetXAxis=function(t){return t.x=this.c,t.y=this.s,t},e.GetYAxis=function(t){return t.x=-this.s,t.y=this.c,t},t.MulRR=function(t,e,i){var n=t.c,r=t.s,s=e.c,o=e.s;return i.s=r*s+n*o,i.c=n*s-r*o,i},t.MulTRR=function(t,e,i){var n=t.c,r=t.s,s=e.c,o=e.s;return i.s=n*o-r*s,i.c=n*s+r*o,i},t.MulRV=function(t,e,i){var n=t.c,r=t.s,s=e.x,o=e.y;return i.x=n*s-r*o,i.y=r*s+n*o,i},t.MulTRV=function(t,e,i){var n=t.c,r=t.s,s=e.x,o=e.y;return i.x=n*s+r*o,i.y=-r*s+n*o,i},t}();J.IDENTITY=new J;var Q=function(){function t(){this.p=new j,this.q=new J}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.p.Copy(t.p),this.q.Copy(t.q),this},e.SetIdentity=function(){return this.p.SetZero(),this.q.SetIdentity(),this},e.SetPositionRotation=function(t,e){return this.p.Copy(t),this.q.Copy(e),this},e.SetPositionAngle=function(t,e){return this.p.Copy(t),this.q.SetAngle(e),this},e.SetPosition=function(t){return this.p.Copy(t),this},e.SetPositionXY=function(t,e){return this.p.Set(t,e),this},e.SetRotation=function(t){return this.q.Copy(t),this},e.SetRotationAngle=function(t){return this.q.SetAngle(t),this},e.GetPosition=function(){return this.p},e.GetRotation=function(){return this.q},e.GetRotationAngle=function(){return this.q.GetAngle()},e.GetAngle=function(){return this.q.GetAngle()},t.MulXV=function(t,e,i){var n=t.q.c,r=t.q.s,s=e.x,o=e.y;return i.x=n*s-r*o+t.p.x,i.y=r*s+n*o+t.p.y,i},t.MulTXV=function(t,e,i){var n=t.q.c,r=t.q.s,s=e.x-t.p.x,o=e.y-t.p.y;return i.x=n*s+r*o,i.y=-r*s+n*o,i},t.MulXX=function(t,e,i){return J.MulRR(t.q,e.q,i.q),j.AddVV(J.MulRV(t.q,e.p,i.p),t.p,i.p),i},t.MulTXX=function(t,e,i){return J.MulTRR(t.q,e.q,i.q),J.MulTRV(t.q,j.SubVV(e.p,t.p,i.p),i.p),i},t}();Q.IDENTITY=new Q;var Z,$=function(){function t(){this.localCenter=new j,this.c0=new j,this.c=new j,this.a0=0,this.a=0,this.alpha0=0}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.localCenter.Copy(t.localCenter),this.c0.Copy(t.c0),this.c.Copy(t.c),this.a0=t.a0,this.a=t.a,this.alpha0=t.alpha0,this},e.GetTransform=function(t,e){var i=1-e;t.p.x=i*this.c0.x+e*this.c.x,t.p.y=i*this.c0.y+e*this.c.y;var n=i*this.a0+e*this.a;return t.q.SetAngle(n),t.p.SelfSub(J.MulRV(t.q,this.localCenter,j.s_t0)),t},e.Advance=function(t){var e=(t-this.alpha0)/(1-this.alpha0),i=1-e;this.c0.x=i*this.c0.x+e*this.c.x,this.c0.y=i*this.c0.y+e*this.c.y,this.a0=i*this.a0+e*this.a,this.alpha0=t},e.Normalize=function(){var t=B*Math.floor(this.a0/B);this.a0-=t,this.a-=t},t}(),tt=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if(e[0]instanceof Float32Array){if(4!==e[0].length)throw new Error;this.data=e[0]}else{var n="number"==typeof e[0]?e[0]:.5,r="number"==typeof e[1]?e[1]:.5,s="number"==typeof e[2]?e[2]:.5,o="number"==typeof e[3]?e[3]:1;this.data=new Float32Array([n,r,s,o])}}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},e.IsEqual=function(t){return this.r===t.r&&this.g===t.g&&this.b===t.b&&this.a===t.a},e.IsZero=function(){return 0===this.r&&0===this.g&&0===this.b&&0===this.a},e.Set=function(t,e,i,n){void 0===n&&(n=this.a),this.SetRGBA(t,e,i,n)},e.SetByteRGB=function(t,e,i){return this.r=t/255,this.g=e/255,this.b=i/255,this},e.SetByteRGBA=function(t,e,i,n){return this.r=t/255,this.g=e/255,this.b=i/255,this.a=n/255,this},e.SetRGB=function(t,e,i){return this.r=t,this.g=e,this.b=i,this},e.SetRGBA=function(t,e,i,n){return this.r=t,this.g=e,this.b=i,this.a=n,this},e.SelfAdd=function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a,this},e.Add=function(t,e){return e.r=this.r+t.r,e.g=this.g+t.g,e.b=this.b+t.b,e.a=this.a+t.a,e},e.SelfSub=function(t){return this.r-=t.r,this.g-=t.g,this.b-=t.b,this.a-=t.a,this},e.Sub=function(t,e){return e.r=this.r-t.r,e.g=this.g-t.g,e.b=this.b-t.b,e.a=this.a-t.a,e},e.SelfMul=function(t){return this.r*=t,this.g*=t,this.b*=t,this.a*=t,this},e.Mul=function(t,e){return e.r=this.r*t,e.g=this.g*t,e.b=this.b*t,e.a=this.a*t,e},e.Mix=function(e,i){t.MixColors(this,e,i)},t.MixColors=function(t,e,i){var n=i*(e.r-t.r),r=i*(e.g-t.g),s=i*(e.b-t.b),o=i*(e.a-t.a);t.r+=n,t.g+=r,t.b+=s,t.a+=o,e.r-=n,e.g-=r,e.b-=s,e.a-=o},e.MakeStyleString=function(e){return void 0===e&&(e=this.a),t.MakeStyleString(this.r,this.g,this.b,e)},t.MakeStyleString=function(t,e,i,n){return void 0===n&&(n=1),t*=255,e*=255,i*=255,n<1?"rgba("+t+","+e+","+i+","+n+")":"rgb("+t+","+e+","+i+")"},n(t,[{key:"r",get:function(){return this.data[0]},set:function(t){this.data[0]=t}},{key:"g",get:function(){return this.data[1]},set:function(t){this.data[1]=t}},{key:"b",get:function(){return this.data[2]},set:function(t){this.data[2]=t}},{key:"a",get:function(){return this.data[3]},set:function(t){this.data[3]=t}}]),t}();tt.ZERO=new tt(0,0,0,0),tt.RED=new tt(1,0,0),tt.GREEN=new tt(0,1,0),tt.BLUE=new tt(0,0,1),(Z=t.b2DrawFlags||(t.b2DrawFlags={}))[Z.e_none=0]="e_none",Z[Z.e_shapeBit=1]="e_shapeBit",Z[Z.e_jointBit=2]="e_jointBit",Z[Z.e_aabbBit=4]="e_aabbBit",Z[Z.e_pairBit=8]="e_pairBit",Z[Z.e_centerOfMassBit=16]="e_centerOfMassBit",Z[Z.e_particleBit=32]="e_particleBit",Z[Z.e_controllerBit=64]="e_controllerBit",Z[Z.e_all=63]="e_all";var et=function(){function t(){this.m_drawFlags=0}var e=t.prototype;return e.SetFlags=function(t){this.m_drawFlags=t},e.GetFlags=function(){return this.m_drawFlags},e.AppendFlags=function(t){this.m_drawFlags|=t},e.ClearFlags=function(t){this.m_drawFlags&=~t},t}(),it=function(){function t(){this.m_start=Date.now()}var e=t.prototype;return e.Reset=function(){return this.m_start=Date.now(),this},e.GetMilliseconds=function(){return Date.now()-this.m_start},t}(),nt=function(){function t(){this.m_count=0,this.m_min_count=0,this.m_max_count=0}var e=t.prototype;return e.GetCount=function(){return this.m_count},e.GetMinCount=function(){return this.m_min_count},e.GetMaxCount=function(){return this.m_max_count},e.ResetCount=function(){var t=this.m_count;return this.m_count=0,t},e.ResetMinCount=function(){this.m_min_count=0},e.ResetMaxCount=function(){this.m_max_count=0},e.Increment=function(){this.m_count++,this.m_max_count<this.m_count&&(this.m_max_count=this.m_count)},e.Decrement=function(){this.m_count--,this.m_min_count>this.m_count&&(this.m_min_count=this.m_count)},t}(),rt=function(){function t(t){this.m_stack=[],this.m_count=0,this.m_stack=w(t,(function(){return null})),this.m_count=0}var e=t.prototype;return e.Reset=function(){return this.m_count=0,this},e.Push=function(t){this.m_stack[this.m_count]=t,this.m_count++},e.Pop=function(){this.m_count--;var t=this.m_stack[this.m_count];if(this.m_stack[this.m_count]=null,null===t)throw new Error;return t},e.GetCount=function(){return this.m_count},t}(),st=function(){function t(){this.m_buffer=j.MakeArray(2),this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0}var e=t.prototype;return e.Copy=function(t){return t.m_vertices===t.m_buffer?(this.m_vertices=this.m_buffer,this.m_buffer[0].Copy(t.m_buffer[0]),this.m_buffer[1].Copy(t.m_buffer[1])):this.m_vertices=t.m_vertices,this.m_count=t.m_count,this.m_radius=t.m_radius,this},e.Reset=function(){return this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0,this},e.SetShape=function(t,e){t.SetupDistanceProxy(this,e)},e.SetVerticesRadius=function(t,e,i){this.m_vertices=t,this.m_count=e,this.m_radius=i},e.GetSupport=function(t){for(var e=0,i=j.DotVV(this.m_vertices[0],t),n=1;n<this.m_count;++n){var r=j.DotVV(this.m_vertices[n],t);r>i&&(e=n,i=r)}return e},e.GetSupportVertex=function(t){for(var e=0,i=j.DotVV(this.m_vertices[0],t),n=1;n<this.m_count;++n){var r=j.DotVV(this.m_vertices[n],t);r>i&&(e=n,i=r)}return this.m_vertices[e]},e.GetVertexCount=function(){return this.m_count},e.GetVertex=function(t){return this.m_vertices[t]},t}(),ot=function(){function t(){this.metric=0,this.count=0,this.indexA=[0,0,0],this.indexB=[0,0,0]}return t.prototype.Reset=function(){return this.metric=0,this.count=0,this},t}(),at=function(){function t(){this.proxyA=new st,this.proxyB=new st,this.transformA=new Q,this.transformB=new Q,this.useRadii=!1}return t.prototype.Reset=function(){return this.proxyA.Reset(),this.proxyB.Reset(),this.transformA.SetIdentity(),this.transformB.SetIdentity(),this.useRadii=!1,this},t}(),ht=function(){function t(){this.pointA=new j,this.pointB=new j,this.distance=0,this.iterations=0}return t.prototype.Reset=function(){return this.pointA.SetZero(),this.pointB.SetZero(),this.distance=0,this.iterations=0,this},t}();t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0;var ut=function(){function t(){this.wA=new j,this.wB=new j,this.w=new j,this.a=0,this.indexA=0,this.indexB=0}return t.prototype.Copy=function(t){return this.wA.Copy(t.wA),this.wB.Copy(t.wB),this.w.Copy(t.w),this.a=t.a,this.indexA=t.indexA,this.indexB=t.indexB,this},t}(),lt=function(){function t(){this.m_v1=new ut,this.m_v2=new ut,this.m_v3=new ut,this.m_vertices=[],this.m_count=0,this.m_vertices[0]=this.m_v1,this.m_vertices[1]=this.m_v2,this.m_vertices[2]=this.m_v3}var e=t.prototype;return e.ReadCache=function(t,e,i,n,s){this.m_count=t.count;for(var o=this.m_vertices,a=0;a<this.m_count;++a){var h=o[a];h.indexA=t.indexA[a],h.indexB=t.indexB[a];var u=e.GetVertex(h.indexA),l=n.GetVertex(h.indexB);Q.MulXV(i,u,h.wA),Q.MulXV(s,l,h.wB),j.SubVV(h.wB,h.wA,h.w),h.a=0}if(this.m_count>1){var c=t.metric,_=this.GetMetric();(_<.5*c||2*c<_||_<r)&&(this.m_count=0)}if(0===this.m_count){var d=o[0];d.indexA=0,d.indexB=0;var f=e.GetVertex(0),p=n.GetVertex(0);Q.MulXV(i,f,d.wA),Q.MulXV(s,p,d.wB),j.SubVV(d.wB,d.wA,d.w),d.a=1,this.m_count=1}},e.WriteCache=function(t){t.metric=this.GetMetric(),t.count=this.m_count;for(var e=this.m_vertices,i=0;i<this.m_count;++i)t.indexA[i]=e[i].indexA,t.indexB[i]=e[i].indexB},e.GetSearchDirection=function(t){switch(this.m_count){case 1:return j.NegV(this.m_v1.w,t);case 2:var e=j.SubVV(this.m_v2.w,this.m_v1.w,t);return j.CrossVV(e,j.NegV(this.m_v1.w,j.s_t0))>0?j.CrossOneV(e,t):j.CrossVOne(e,t);default:return t.SetZero()}},e.GetClosestPoint=function(t){switch(this.m_count){case 0:return t.SetZero();case 1:return t.Copy(this.m_v1.w);case 2:return t.Set(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);case 3:default:return t.SetZero()}},e.GetWitnessPoints=function(t,e){switch(this.m_count){case 0:break;case 1:t.Copy(this.m_v1.wA),e.Copy(this.m_v1.wB);break;case 2:t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,e.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,e.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:e.x=t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x,e.y=t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y}},e.GetMetric=function(){switch(this.m_count){case 0:case 1:return 0;case 2:return j.DistanceVV(this.m_v1.w,this.m_v2.w);case 3:return j.CrossVV(j.SubVV(this.m_v2.w,this.m_v1.w,j.s_t0),j.SubVV(this.m_v3.w,this.m_v1.w,j.s_t1));default:return 0}},e.Solve2=function(){var e=this.m_v1.w,i=this.m_v2.w,n=j.SubVV(i,e,t.s_e12),r=-j.DotVV(e,n);if(r<=0)return this.m_v1.a=1,void(this.m_count=1);var s=j.DotVV(i,n);if(s<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);var o=1/(s+r);this.m_v1.a=s*o,this.m_v2.a=r*o,this.m_count=2},e.Solve3=function(){var e=this.m_v1.w,i=this.m_v2.w,n=this.m_v3.w,r=j.SubVV(i,e,t.s_e12),s=j.DotVV(e,r),o=j.DotVV(i,r),a=-s,h=j.SubVV(n,e,t.s_e13),u=j.DotVV(e,h),l=j.DotVV(n,h),c=-u,_=j.SubVV(n,i,t.s_e23),d=j.DotVV(i,_),f=j.DotVV(n,_),p=-d,m=j.CrossVV(r,h),g=m*j.CrossVV(i,n),y=m*j.CrossVV(n,e),v=m*j.CrossVV(e,i);if(a<=0&&c<=0)return this.m_v1.a=1,void(this.m_count=1);if(o>0&&a>0&&v<=0){var S=1/(o+a);return this.m_v1.a=o*S,this.m_v2.a=a*S,void(this.m_count=2)}if(l>0&&c>0&&y<=0){var T=1/(l+c);return this.m_v1.a=l*T,this.m_v3.a=c*T,this.m_count=2,void this.m_v2.Copy(this.m_v3)}if(o<=0&&p<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);if(l<=0&&f<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v3);if(f>0&&p>0&&g<=0){var A=1/(f+p);return this.m_v2.a=f*A,this.m_v3.a=p*A,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var b=1/(g+y+v);this.m_v1.a=g*b,this.m_v2.a=y*b,this.m_v3.a=v*b,this.m_count=3},t}();lt.s_e12=new j,lt.s_e13=new j,lt.s_e23=new j;var ct=new lt,_t=[0,0,0],dt=[0,0,0],ft=new j,pt=new j,mt=new j,gt=new j,yt=new j;function vt(e,i,n){++t.b2_gjkCalls;var s=n.proxyA,a=n.proxyB,h=n.transformA,u=n.transformB,l=ct;l.ReadCache(i,s,h,a,u);for(var c=l.m_vertices,_=_t,d=dt,f=0,p=0;p<20;){f=l.m_count;for(var m=0;m<f;++m)_[m]=c[m].indexA,d[m]=c[m].indexB;switch(l.m_count){case 1:break;case 2:l.Solve2();break;case 3:l.Solve3()}if(3===l.m_count)break;var g=l.GetSearchDirection(pt);if(g.LengthSquared()<o)break;var y=c[l.m_count];y.indexA=s.GetSupport(J.MulTRV(h.q,j.NegV(g,j.s_t0),gt)),Q.MulXV(h,s.GetVertex(y.indexA),y.wA),y.indexB=a.GetSupport(J.MulTRV(u.q,g,yt)),Q.MulXV(u,a.GetVertex(y.indexB),y.wB),j.SubVV(y.wB,y.wA,y.w),++p,++t.b2_gjkIters;for(var v=!1,S=0;S<f;++S)if(y.indexA===_[S]&&y.indexB===d[S]){v=!0;break}if(v)break;++l.m_count}if(t.b2_gjkMaxIters=O(t.b2_gjkMaxIters,p),l.GetWitnessPoints(e.pointA,e.pointB),e.distance=j.DistanceVV(e.pointA,e.pointB),e.iterations=p,l.WriteCache(i),n.useRadii){var T=s.m_radius,A=a.m_radius;if(e.distance>T+A&&e.distance>r){e.distance-=T+A;var b=j.SubVV(e.pointB,e.pointA,mt);b.Normalize(),e.pointA.SelfMulAdd(T,b),e.pointB.SelfMulSub(A,b)}else{var E=j.MidVV(e.pointA,e.pointB,ft);e.pointA.Copy(E),e.pointB.Copy(E),e.distance=0}}}var St,Tt=new j,At=new lt,bt=new j,Et=new j,Ct=new j,wt=new j,xt=new j,Rt=new j;(St=t.b2ContactFeatureType||(t.b2ContactFeatureType={}))[St.e_vertex=0]="e_vertex",St[St.e_face=1]="e_face";var It,Bt=function(){function t(){this._key=0,this._key_invalid=!1,this._indexA=0,this._indexB=0,this._typeA=0,this._typeB=0}return n(t,[{key:"key",get:function(){return this._key_invalid&&(this._key_invalid=!1,this._key=this._indexA|this._indexB<<8|this._typeA<<16|this._typeB<<24),this._key},set:function(t){this._key=t,this._key_invalid=!1,this._indexA=255&this._key,this._indexB=this._key>>8&255,this._typeA=this._key>>16&255,this._typeB=this._key>>24&255}},{key:"indexA",get:function(){return this._indexA},set:function(t){this._indexA=t,this._key_invalid=!0}},{key:"indexB",get:function(){return this._indexB},set:function(t){this._indexB=t,this._key_invalid=!0}},{key:"typeA",get:function(){return this._typeA},set:function(t){this._typeA=t,this._key_invalid=!0}},{key:"typeB",get:function(){return this._typeB},set:function(t){this._typeB=t,this._key_invalid=!0}}]),t}(),Dt=function(){function t(){this.cf=new Bt}var e=t.prototype;return e.Copy=function(t){return this.key=t.key,this},e.Clone=function(){return(new t).Copy(this)},n(t,[{key:"key",get:function(){return this.cf.key},set:function(t){this.cf.key=t}}]),t}(),Pt=function(){function t(){this.localPoint=new j,this.normalImpulse=0,this.tangentImpulse=0,this.id=new Dt}t.MakeArray=function(e){return w(e,(function(){return new t}))};var e=t.prototype;return e.Reset=function(){this.localPoint.SetZero(),this.normalImpulse=0,this.tangentImpulse=0,this.id.key=0},e.Copy=function(t){return this.localPoint.Copy(t.localPoint),this.normalImpulse=t.normalImpulse,this.tangentImpulse=t.tangentImpulse,this.id.Copy(t.id),this},t}();(It=t.b2ManifoldType||(t.b2ManifoldType={}))[It.e_unknown=-1]="e_unknown",It[It.e_circles=0]="e_circles",It[It.e_faceA=1]="e_faceA",It[It.e_faceB=2]="e_faceB";var Ot,Mt=function(){function e(){this.points=Pt.MakeArray(2),this.localNormal=new j,this.localPoint=new j,this.type=t.b2ManifoldType.e_unknown,this.pointCount=0}var i=e.prototype;return i.Reset=function(){for(var e=0;e<2;++e)this.points[e].Reset();this.localNormal.SetZero(),this.localPoint.SetZero(),this.type=t.b2ManifoldType.e_unknown,this.pointCount=0},i.Copy=function(t){this.pointCount=t.pointCount;for(var e=0;e<2;++e)this.points[e].Copy(t.points[e]);return this.localNormal.Copy(t.localNormal),this.localPoint.Copy(t.localPoint),this.type=t.type,this},i.Clone=function(){return(new e).Copy(this)},e}(),Lt=function(){function e(){this.normal=new j,this.points=j.MakeArray(2),this.separations=x(2)}return e.prototype.Initialize=function(i,n,r,s,a){if(0!==i.pointCount)switch(i.type){case t.b2ManifoldType.e_circles:this.normal.Set(1,0);var h=Q.MulXV(n,i.localPoint,e.Initialize_s_pointA),u=Q.MulXV(s,i.points[0].localPoint,e.Initialize_s_pointB);j.DistanceSquaredVV(h,u)>o&&j.SubVV(u,h,this.normal).SelfNormalize();var l=j.AddVMulSV(h,r,this.normal,e.Initialize_s_cA),c=j.SubVMulSV(u,a,this.normal,e.Initialize_s_cB);j.MidVV(l,c,this.points[0]),this.separations[0]=j.DotVV(j.SubVV(c,l,j.s_t0),this.normal);break;case t.b2ManifoldType.e_faceA:J.MulRV(n.q,i.localNormal,this.normal);for(var _=Q.MulXV(n,i.localPoint,e.Initialize_s_planePoint),d=0;d<i.pointCount;++d){var f=Q.MulXV(s,i.points[d].localPoint,e.Initialize_s_clipPoint),p=r-j.DotVV(j.SubVV(f,_,j.s_t0),this.normal),m=j.AddVMulSV(f,p,this.normal,e.Initialize_s_cA),g=j.SubVMulSV(f,a,this.normal,e.Initialize_s_cB);j.MidVV(m,g,this.points[d]),this.separations[d]=j.DotVV(j.SubVV(g,m,j.s_t0),this.normal)}break;case t.b2ManifoldType.e_faceB:J.MulRV(s.q,i.localNormal,this.normal);for(var y=Q.MulXV(s,i.localPoint,e.Initialize_s_planePoint),v=0;v<i.pointCount;++v){var S=Q.MulXV(n,i.points[v].localPoint,e.Initialize_s_clipPoint),T=a-j.DotVV(j.SubVV(S,y,j.s_t0),this.normal),A=j.AddVMulSV(S,T,this.normal,e.Initialize_s_cB),b=j.SubVMulSV(S,r,this.normal,e.Initialize_s_cA);j.MidVV(b,A,this.points[v]),this.separations[v]=j.DotVV(j.SubVV(b,A,j.s_t0),this.normal)}this.normal.SelfNeg()}},e}();Lt.Initialize_s_pointA=new j,Lt.Initialize_s_pointB=new j,Lt.Initialize_s_cA=new j,Lt.Initialize_s_cB=new j,Lt.Initialize_s_planePoint=new j,Lt.Initialize_s_clipPoint=new j,(Ot=t.b2PointState||(t.b2PointState={}))[Ot.b2_nullState=0]="b2_nullState",Ot[Ot.b2_addState=1]="b2_addState",Ot[Ot.b2_persistState=2]="b2_persistState",Ot[Ot.b2_removeState=3]="b2_removeState";var Nt=function(){function t(){this.v=new j,this.id=new Dt}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t.prototype.Copy=function(t){return this.v.Copy(t.v),this.id.Copy(t.id),this},t}(),Ft=function(){function t(){this.p1=new j,this.p2=new j,this.maxFraction=1}return t.prototype.Copy=function(t){return this.p1.Copy(t.p1),this.p2.Copy(t.p2),this.maxFraction=t.maxFraction,this},t}(),kt=function(){function t(){this.normal=new j,this.fraction=0}return t.prototype.Copy=function(t){return this.normal.Copy(t.normal),this.fraction=t.fraction,this},t}(),Vt=function(){function t(){this.lowerBound=new j,this.upperBound=new j,this.m_cache_center=new j,this.m_cache_extent=new j}var e=t.prototype;return e.Copy=function(t){return this.lowerBound.Copy(t.lowerBound),this.upperBound.Copy(t.upperBound),this},e.IsValid=function(){return!(!this.lowerBound.IsValid()||!this.upperBound.IsValid()||this.upperBound.x<this.lowerBound.x||this.upperBound.y<this.lowerBound.y)},e.GetCenter=function(){return j.MidVV(this.lowerBound,this.upperBound,this.m_cache_center)},e.GetExtents=function(){return j.ExtVV(this.lowerBound,this.upperBound,this.m_cache_extent)},e.GetPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+(this.upperBound.y-this.lowerBound.y))},e.Combine1=function(t){return this.lowerBound.x=P(this.lowerBound.x,t.lowerBound.x),this.lowerBound.y=P(this.lowerBound.y,t.lowerBound.y),this.upperBound.x=O(this.upperBound.x,t.upperBound.x),this.upperBound.y=O(this.upperBound.y,t.upperBound.y),this},e.Combine2=function(t,e){return this.lowerBound.x=P(t.lowerBound.x,e.lowerBound.x),this.lowerBound.y=P(t.lowerBound.y,e.lowerBound.y),this.upperBound.x=O(t.upperBound.x,e.upperBound.x),this.upperBound.y=O(t.upperBound.y,e.upperBound.y),this},t.Combine=function(t,e,i){return i.Combine2(t,e),i},e.Contains=function(t){return!(this.lowerBound.x<=t.lowerBound.x||this.lowerBound.y<=t.lowerBound.y||t.upperBound.x<=this.upperBound.x||t.upperBound.y<=this.upperBound.y)},e.RayCast=function(t,e){var n=-i,s=i,o=e.p1.x,a=e.p1.y,h=e.p2.x-e.p1.x,u=e.p2.y-e.p1.y,l=D(h),c=D(u),_=t.normal;if(l<r){if(o<this.lowerBound.x||this.upperBound.x<o)return!1}else{var d=1/h,f=(this.lowerBound.x-o)*d,p=(this.upperBound.x-o)*d,m=-1;if(f>p){var g=f;f=p,p=g,m=1}if(f>n&&(_.x=m,_.y=0,n=f),n>(s=P(s,p)))return!1}if(c<r){if(a<this.lowerBound.y||this.upperBound.y<a)return!1}else{var y=1/u,v=(this.lowerBound.y-a)*y,S=(this.upperBound.y-a)*y,T=-1;if(v>S){var A=v;v=S,S=A,T=1}if(v>n&&(_.x=0,_.y=T,n=v),n>(s=P(s,S)))return!1}return!(n<0||e.maxFraction<n||(t.fraction=n,0))},e.TestContain=function(t){return!(t.x<this.lowerBound.x||this.upperBound.x<t.x||t.y<this.lowerBound.y||this.upperBound.y<t.y)},e.TestOverlap=function(t){return!(this.upperBound.x<t.lowerBound.x||this.upperBound.y<t.lowerBound.y||t.upperBound.x<this.lowerBound.x||t.upperBound.y<this.lowerBound.y)},t}();function Gt(t,e){return!(t.upperBound.x<e.lowerBound.x||t.upperBound.y<e.lowerBound.y||e.upperBound.x<t.lowerBound.x||e.upperBound.y<t.lowerBound.y)}function Ut(e,i,n,r,s){var o=0,a=i[0],h=i[1],u=j.DotVV(n,a.v)-r,l=j.DotVV(n,h.v)-r;if(u<=0&&e[o++].Copy(a),l<=0&&e[o++].Copy(h),u*l<0){var c=u/(u-l),_=e[o].v;_.x=a.v.x+c*(h.v.x-a.v.x),_.y=a.v.y+c*(h.v.y-a.v.y);var d=e[o].id;d.cf.indexA=s,d.cf.indexB=a.id.cf.indexB,d.cf.typeA=t.b2ContactFeatureType.e_vertex,d.cf.typeB=t.b2ContactFeatureType.e_face,++o}return o}var zt=new at,Ht=new ot,Wt=new ht;function jt(t,e,i,n,r,s){var o=zt.Reset();o.proxyA.SetShape(t,e),o.proxyB.SetShape(i,n),o.transformA.Copy(r),o.transformB.Copy(s),o.useRadii=!0;var a=Ht.Reset();a.count=0;var h=Wt.Reset();return vt(h,a,o),h.distance<1e-4}function Xt(t){if(null===t)throw new Error;return t}var qt=function(){function t(t){void 0===t&&(t=0),this.m_id=0,this.aabb=new Vt,this._userData=null,this.parent=null,this.child1=null,this.child2=null,this.height=0,this.m_id=t}var e=t.prototype;return e.Reset=function(){this._userData=null},e.IsLeaf=function(){return null===this.child1},n(t,[{key:"userData",get:function(){if(null===this._userData)throw new Error;return this._userData},set:function(t){if(null!==this._userData)throw new Error;this._userData=t}}]),t}(),Yt=function(){function t(){this.m_root=null,this.m_freeList=null,this.m_path=0,this.m_insertionCount=0,this.m_stack=new rt(256)}var e=t.prototype;return e.Query=function(t,e){var i=this.m_stack.Reset();for(i.Push(this.m_root);i.GetCount()>0;){var n=i.Pop();if(null!==n&&n.aabb.TestOverlap(t))if(n.IsLeaf()){if(!e(n))return}else i.Push(n.child1),i.Push(n.child2)}},e.QueryPoint=function(t,e){var i=this.m_stack.Reset();for(i.Push(this.m_root);i.GetCount()>0;){var n=i.Pop();if(null!==n&&n.aabb.TestContain(t))if(n.IsLeaf()){if(!e(n))return}else i.Push(n.child1),i.Push(n.child2)}},e.RayCast=function(e,i){var n=e.p1,r=e.p2,s=j.SubVV(r,n,t.s_r);s.Normalize();var o=j.CrossOneV(s,t.s_v),a=j.AbsV(o,t.s_abs_v),h=e.maxFraction,u=t.s_segmentAABB,l=n.x+h*(r.x-n.x),c=n.y+h*(r.y-n.y);u.lowerBound.x=P(n.x,l),u.lowerBound.y=P(n.y,c),u.upperBound.x=O(n.x,l),u.upperBound.y=O(n.y,c);var _=this.m_stack.Reset();for(_.Push(this.m_root);_.GetCount()>0;){var d=_.Pop();if(null!==d&&Gt(d.aabb,u)){var f=d.aabb.GetCenter(),p=d.aabb.GetExtents();if(!(D(j.DotVV(o,j.SubVV(n,f,j.s_t0)))-j.DotVV(a,p)>0))if(d.IsLeaf()){var m=t.s_subInput;m.p1.Copy(e.p1),m.p2.Copy(e.p2),m.maxFraction=h;var g=i(m,d);if(0===g)return;g>0&&(h=g,l=n.x+h*(r.x-n.x),c=n.y+h*(r.y-n.y),u.lowerBound.x=P(n.x,l),u.lowerBound.y=P(n.y,c),u.upperBound.x=O(n.x,l),u.upperBound.y=O(n.y,c))}else _.Push(d.child1),_.Push(d.child2)}}},e.AllocateNode=function(){if(null!==this.m_freeList){var e=this.m_freeList;return this.m_freeList=e.parent,e.parent=null,e.child1=null,e.child2=null,e.height=0,e}return new qt(t.s_node_id++)},e.FreeNode=function(t){t.parent=this.m_freeList,t.child1=null,t.child2=null,t.height=-1,t.Reset(),this.m_freeList=t},e.CreateProxy=function(t,e){var i=this.AllocateNode();return i.aabb.lowerBound.x=t.lowerBound.x-.1,i.aabb.lowerBound.y=t.lowerBound.y-.1,i.aabb.upperBound.x=t.upperBound.x+.1,i.aabb.upperBound.y=t.upperBound.y+.1,i.userData=e,i.height=0,this.InsertLeaf(i),i},e.DestroyProxy=function(t){this.RemoveLeaf(t),this.FreeNode(t)},e.MoveProxy=function(t,e,i){if(t.aabb.Contains(e))return!1;this.RemoveLeaf(t);t.aabb.lowerBound.x=e.lowerBound.x-.1,t.aabb.lowerBound.y=e.lowerBound.y-.1,t.aabb.upperBound.x=e.upperBound.x+.1,t.aabb.upperBound.y=e.upperBound.y+.1;var n=2*i.x,r=2*i.y;return n<0?t.aabb.lowerBound.x+=n:t.aabb.upperBound.x+=n,r<0?t.aabb.lowerBound.y+=r:t.aabb.upperBound.y+=r,this.InsertLeaf(t),!0},e.InsertLeaf=function(e){if(++this.m_insertionCount,null===this.m_root)return this.m_root=e,void(this.m_root.parent=null);for(var i=e.aabb,n=this.m_root;!n.IsLeaf();){var r=Xt(n.child1),s=Xt(n.child2),o=n.aabb.GetPerimeter(),a=t.s_combinedAABB;a.Combine2(n.aabb,i);var h=a.GetPerimeter(),u=2*h,l=2*(h-o),c=void 0,_=t.s_aabb,d=void 0;r.IsLeaf()?(_.Combine2(i,r.aabb),c=_.GetPerimeter()+l):(_.Combine2(i,r.aabb),d=r.aabb.GetPerimeter(),c=_.GetPerimeter()-d+l);var f=void 0;if(s.IsLeaf()?(_.Combine2(i,s.aabb),f=_.GetPerimeter()+l):(_.Combine2(i,s.aabb),d=s.aabb.GetPerimeter(),f=_.GetPerimeter()-d+l),u<c&&u<f)break;n=c<f?r:s}var p=n.parent,m=this.AllocateNode();m.parent=p,m.aabb.Combine2(i,n.aabb),m.height=n.height+1,null!==p?(p.child1===n?p.child1=m:p.child2=m,m.child1=n,m.child2=e,n.parent=m,e.parent=m):(m.child1=n,m.child2=e,n.parent=m,e.parent=m,this.m_root=m);for(var g=e.parent;null!==g;){var y=Xt((g=this.Balance(g)).child1),v=Xt(g.child2);g.height=1+O(y.height,v.height),g.aabb.Combine2(y.aabb,v.aabb),g=g.parent}},e.RemoveLeaf=function(t){if(t!==this.m_root){var e=Xt(t.parent),i=e&&e.parent,n=Xt(e.child1===t?e.child2:e.child1);if(null!==i){i.child1===e?i.child1=n:i.child2=n,n.parent=i,this.FreeNode(e);for(var r=i;null!==r;){var s=Xt((r=this.Balance(r)).child1),o=Xt(r.child2);r.aabb.Combine2(s.aabb,o.aabb),r.height=1+O(s.height,o.height),r=r.parent}}else this.m_root=n,n.parent=null,this.FreeNode(e)}else this.m_root=null},e.Balance=function(t){if(t.IsLeaf()||t.height<2)return t;var e=Xt(t.child1),i=Xt(t.child2),n=i.height-e.height;if(n>1){var r=Xt(i.child1),s=Xt(i.child2);return i.child1=t,i.parent=t.parent,t.parent=i,null!==i.parent?i.parent.child1===t?i.parent.child1=i:i.parent.child2=i:this.m_root=i,r.height>s.height?(i.child2=r,t.child2=s,s.parent=t,t.aabb.Combine2(e.aabb,s.aabb),i.aabb.Combine2(t.aabb,r.aabb),t.height=1+O(e.height,s.height),i.height=1+O(t.height,r.height)):(i.child2=s,t.child2=r,r.parent=t,t.aabb.Combine2(e.aabb,r.aabb),i.aabb.Combine2(t.aabb,s.aabb),t.height=1+O(e.height,r.height),i.height=1+O(t.height,s.height)),i}if(n<-1){var o=Xt(e.child1),a=Xt(e.child2);return e.child1=t,e.parent=t.parent,t.parent=e,null!==e.parent?e.parent.child1===t?e.parent.child1=e:e.parent.child2=e:this.m_root=e,o.height>a.height?(e.child2=o,t.child1=a,a.parent=t,t.aabb.Combine2(i.aabb,a.aabb),e.aabb.Combine2(t.aabb,o.aabb),t.height=1+O(i.height,a.height),e.height=1+O(t.height,o.height)):(e.child2=a,t.child1=o,o.parent=t,t.aabb.Combine2(i.aabb,o.aabb),e.aabb.Combine2(t.aabb,a.aabb),t.height=1+O(i.height,o.height),e.height=1+O(t.height,a.height)),e}return t},e.GetHeight=function(){return null===this.m_root?0:this.m_root.height},t.GetAreaNode=function(e){if(null===e)return 0;if(e.IsLeaf())return 0;var i=e.aabb.GetPerimeter();return(i+=t.GetAreaNode(e.child1))+t.GetAreaNode(e.child2)},e.GetAreaRatio=function(){if(null===this.m_root)return 0;var e=this.m_root.aabb.GetPerimeter();return t.GetAreaNode(this.m_root)/e},t.ComputeHeightNode=function(e){return null===e||e.IsLeaf()?0:1+O(t.ComputeHeightNode(e.child1),t.ComputeHeightNode(e.child2))},e.ComputeHeight=function(){return t.ComputeHeightNode(this.m_root)},e.ValidateStructure=function(t){if(null!==t&&(this.m_root,!t.IsLeaf())){var e=Xt(t.child1),i=Xt(t.child2);this.ValidateStructure(e),this.ValidateStructure(i)}},e.ValidateMetrics=function(e){if(null!==e&&!e.IsLeaf()){var i=Xt(e.child1),n=Xt(e.child2);t.s_aabb.Combine2(i.aabb,n.aabb),this.ValidateMetrics(i),this.ValidateMetrics(n)}},e.Validate=function(){},t.GetMaxBalanceNode=function(t,e){if(null===t)return e;if(t.height<=1)return e;var i=Xt(t.child1),n=Xt(t.child2);return O(e,D(n.height-i.height))},e.GetMaxBalance=function(){return t.GetMaxBalanceNode(this.m_root,0)},e.RebuildBottomUp=function(){this.Validate()},t.ShiftOriginNode=function(e,i){if(null!==e&&!(e.height<=1)){var n=e.child1,r=e.child2;t.ShiftOriginNode(n,i),t.ShiftOriginNode(r,i),e.aabb.lowerBound.SelfSub(i),e.aabb.upperBound.SelfSub(i)}},e.ShiftOrigin=function(e){t.ShiftOriginNode(this.m_root,e)},t}();function Kt(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Jt(t,e){return t<e}Yt.s_r=new j,Yt.s_v=new j,Yt.s_abs_v=new j,Yt.s_segmentAABB=new Vt,Yt.s_subInput=new Ft,Yt.s_combinedAABB=new Vt,Yt.s_aabb=new Vt,Yt.s_node_id=0;var Qt=function(t,e){this.proxyA=t,this.proxyB=e},Zt=function(){function t(){this.m_tree=new Yt,this.m_proxyCount=0,this.m_moveCount=0,this.m_moveBuffer=[],this.m_pairCount=0,this.m_pairBuffer=[]}var e=t.prototype;return e.CreateProxy=function(t,e){var i=this.m_tree.CreateProxy(t,e);return++this.m_proxyCount,this.BufferMove(i),i},e.DestroyProxy=function(t){this.UnBufferMove(t),--this.m_proxyCount,this.m_tree.DestroyProxy(t)},e.MoveProxy=function(t,e,i){this.m_tree.MoveProxy(t,e,i)&&this.BufferMove(t)},e.TouchProxy=function(t){this.BufferMove(t)},e.GetProxyCount=function(){return this.m_proxyCount},e.UpdatePairs=function(t){var e=this;this.m_pairCount=0;for(var i=function(){var t=e.m_moveBuffer[n];if(null===t)return 1;var i=t.aabb;e.m_tree.Query(i,(function(i){if(i.m_id===t.m_id)return!0;var n,r;if(i.m_id<t.m_id?(n=i,r=t):(n=t,r=i),e.m_pairCount===e.m_pairBuffer.length)e.m_pairBuffer[e.m_pairCount]=new Qt(n,r);else{var s=e.m_pairBuffer[e.m_pairCount];s.proxyA=n,s.proxyB=r}return++e.m_pairCount,!0}))},n=0;n<this.m_moveCount;++n)i();this.m_moveCount=0,function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===n&&(n=Jt);for(var r=e,s=[],o=0;;){for(;r+1<i;i++){var a=t[r+Math.floor(Math.random()*(i-r))];s[o++]=i;for(var h=r-1;;){for(;n(t[++h],a););for(;n(a,t[--i]););if(h>=i)break;Kt(t,h,i)}}if(0===o)break;r=i,i=s[--o]}}(this.m_pairBuffer,0,this.m_pairCount,$t);for(var r=0;r<this.m_pairCount;){var s=this.m_pairBuffer[r];for(t(s.proxyA.userData,s.proxyB.userData),++r;r<this.m_pairCount;){var o=this.m_pairBuffer[r];if(o.proxyA.m_id!==s.proxyA.m_id||o.proxyB.m_id!==s.proxyB.m_id)break;++r}}},e.Query=function(t,e){this.m_tree.Query(t,e)},e.QueryPoint=function(t,e){this.m_tree.QueryPoint(t,e)},e.RayCast=function(t,e){this.m_tree.RayCast(t,e)},e.GetTreeHeight=function(){return this.m_tree.GetHeight()},e.GetTreeBalance=function(){return this.m_tree.GetMaxBalance()},e.GetTreeQuality=function(){return this.m_tree.GetAreaRatio()},e.ShiftOrigin=function(t){this.m_tree.ShiftOrigin(t)},e.BufferMove=function(t){this.m_moveBuffer[this.m_moveCount]=t,++this.m_moveCount},e.UnBufferMove=function(t){var e=this.m_moveBuffer.indexOf(t);this.m_moveBuffer[e]=null},t}();function $t(t,e){return t.proxyA.m_id<e.proxyA.m_id||t.proxyA.m_id===e.proxyA.m_id&&t.proxyB.m_id<e.proxyB.m_id}t.b2_toiTime=0,t.b2_toiMaxTime=0,t.b2_toiCalls=0,t.b2_toiIters=0,t.b2_toiMaxIters=0,t.b2_toiRootIters=0,t.b2_toiMaxRootIters=0;var te,ee=new Q,ie=new Q,ne=new j,re=new j,se=new j,oe=new j,ae=new j,he=function(){this.proxyA=new st,this.proxyB=new st,this.sweepA=new $,this.sweepB=new $,this.tMax=0};(te=t.b2TOIOutputState||(t.b2TOIOutputState={}))[te.e_unknown=0]="e_unknown",te[te.e_failed=1]="e_failed",te[te.e_overlapped=2]="e_overlapped",te[te.e_touching=3]="e_touching",te[te.e_separated=4]="e_separated";var ue,le=function(){this.state=t.b2TOIOutputState.e_unknown,this.t=0};(ue=t.b2SeparationFunctionType||(t.b2SeparationFunctionType={}))[ue.e_unknown=-1]="e_unknown",ue[ue.e_points=0]="e_points",ue[ue.e_faceA=1]="e_faceA",ue[ue.e_faceB=2]="e_faceB";var ce=function(){function e(){this.m_sweepA=new $,this.m_sweepB=new $,this.m_type=t.b2SeparationFunctionType.e_unknown,this.m_localPoint=new j,this.m_axis=new j}var i=e.prototype;return i.Initialize=function(e,i,n,r,s,o){this.m_proxyA=i,this.m_proxyB=r;var a=e.count;this.m_sweepA.Copy(n),this.m_sweepB.Copy(s);var h=ee,u=ie;if(this.m_sweepA.GetTransform(h,o),this.m_sweepB.GetTransform(u,o),1===a){this.m_type=t.b2SeparationFunctionType.e_points;var l=this.m_proxyA.GetVertex(e.indexA[0]),c=this.m_proxyB.GetVertex(e.indexB[0]),_=Q.MulXV(h,l,ne),d=Q.MulXV(u,c,re);j.SubVV(d,_,this.m_axis);var f=this.m_axis.Normalize();return this.m_localPoint.SetZero(),f}if(e.indexA[0]===e.indexA[1]){this.m_type=t.b2SeparationFunctionType.e_faceB;var p=this.m_proxyB.GetVertex(e.indexB[0]),m=this.m_proxyB.GetVertex(e.indexB[1]);j.CrossVOne(j.SubVV(m,p,j.s_t0),this.m_axis).SelfNormalize();var g=J.MulRV(u.q,this.m_axis,se);j.MidVV(p,m,this.m_localPoint);var y=Q.MulXV(u,this.m_localPoint,re),v=this.m_proxyA.GetVertex(e.indexA[0]),S=Q.MulXV(h,v,ne),T=j.DotVV(j.SubVV(S,y,j.s_t0),g);return T<0&&(this.m_axis.SelfNeg(),T=-T),T}this.m_type=t.b2SeparationFunctionType.e_faceA;var A=this.m_proxyA.GetVertex(e.indexA[0]),b=this.m_proxyA.GetVertex(e.indexA[1]);j.CrossVOne(j.SubVV(b,A,j.s_t0),this.m_axis).SelfNormalize();var E=J.MulRV(h.q,this.m_axis,se);j.MidVV(A,b,this.m_localPoint);var C=Q.MulXV(h,this.m_localPoint,ne),w=this.m_proxyB.GetVertex(e.indexB[0]),x=Q.MulXV(u,w,re),R=j.DotVV(j.SubVV(x,C,j.s_t0),E);return R<0&&(this.m_axis.SelfNeg(),R=-R),R},i.FindMinSeparation=function(e,i,n){var r=ee,s=ie;switch(this.m_sweepA.GetTransform(r,n),this.m_sweepB.GetTransform(s,n),this.m_type){case t.b2SeparationFunctionType.e_points:var o=J.MulTRV(r.q,this.m_axis,oe),a=J.MulTRV(s.q,j.NegV(this.m_axis,j.s_t0),ae);e[0]=this.m_proxyA.GetSupport(o),i[0]=this.m_proxyB.GetSupport(a);var h=this.m_proxyA.GetVertex(e[0]),u=this.m_proxyB.GetVertex(i[0]),l=Q.MulXV(r,h,ne),c=Q.MulXV(s,u,re);return j.DotVV(j.SubVV(c,l,j.s_t0),this.m_axis);case t.b2SeparationFunctionType.e_faceA:var _=J.MulRV(r.q,this.m_axis,se),d=Q.MulXV(r,this.m_localPoint,ne),f=J.MulTRV(s.q,j.NegV(_,j.s_t0),ae);e[0]=-1,i[0]=this.m_proxyB.GetSupport(f);var p=this.m_proxyB.GetVertex(i[0]),m=Q.MulXV(s,p,re);return j.DotVV(j.SubVV(m,d,j.s_t0),_);case t.b2SeparationFunctionType.e_faceB:var g=J.MulRV(s.q,this.m_axis,se),y=Q.MulXV(s,this.m_localPoint,re),v=J.MulTRV(r.q,j.NegV(g,j.s_t0),oe);i[0]=-1,e[0]=this.m_proxyA.GetSupport(v);var S=this.m_proxyA.GetVertex(e[0]),T=Q.MulXV(r,S,ne);return j.DotVV(j.SubVV(T,y,j.s_t0),g);default:return e[0]=-1,i[0]=-1,0}},i.Evaluate=function(e,i,n){var r=ee,s=ie;switch(this.m_sweepA.GetTransform(r,n),this.m_sweepB.GetTransform(s,n),this.m_type){case t.b2SeparationFunctionType.e_points:var o=this.m_proxyA.GetVertex(e),a=this.m_proxyB.GetVertex(i),h=Q.MulXV(r,o,ne),u=Q.MulXV(s,a,re);return j.DotVV(j.SubVV(u,h,j.s_t0),this.m_axis);case t.b2SeparationFunctionType.e_faceA:var l=J.MulRV(r.q,this.m_axis,se),c=Q.MulXV(r,this.m_localPoint,ne),_=this.m_proxyB.GetVertex(i),d=Q.MulXV(s,_,re);return j.DotVV(j.SubVV(d,c,j.s_t0),l);case t.b2SeparationFunctionType.e_faceB:var f=J.MulRV(s.q,this.m_axis,se),p=Q.MulXV(s,this.m_localPoint,re),m=this.m_proxyA.GetVertex(e),g=Q.MulXV(r,m,ne);return j.DotVV(j.SubVV(g,p,j.s_t0),f);default:return 0}},e}(),_e=new it,de=new ot,fe=new at,pe=new ht,me=new ce,ge=[0],ye=[0],ve=new $,Se=new $;function Te(e,i){var n=_e.Reset();++t.b2_toiCalls,e.state=t.b2TOIOutputState.e_unknown,e.t=i.tMax;var r=i.proxyA,s=i.proxyB,o=O(8,O(r.m_count,s.m_count)),a=ve.Copy(i.sweepA),h=Se.Copy(i.sweepB);a.Normalize(),h.Normalize();var u=i.tMax,c=r.m_radius+s.m_radius,_=O(l,c-.024),d=.002,f=0,p=0,m=de;m.count=0;var g=fe;for(g.proxyA.Copy(i.proxyA),g.proxyB.Copy(i.proxyB),g.useRadii=!1;;){var y=ee,v=ie;a.GetTransform(y,f),h.GetTransform(v,f),g.transformA.Copy(y),g.transformB.Copy(v);var S=pe;if(vt(S,m,g),S.distance<=0){e.state=t.b2TOIOutputState.e_overlapped,e.t=0;break}if(S.distance<_+d){e.state=t.b2TOIOutputState.e_touching,e.t=f;break}var T=me;T.Initialize(m,r,a,s,h,f);for(var A=!1,b=u,E=0;;){var C=ge,w=ye,x=T.FindMinSeparation(C,w,b);if(x>_+d){e.state=t.b2TOIOutputState.e_separated,e.t=u,A=!0;break}if(x>_-d){f=b;break}var R=T.Evaluate(C[0],w[0],f);if(R<_-d){e.state=t.b2TOIOutputState.e_failed,e.t=f,A=!0;break}if(R<=_+d){e.state=t.b2TOIOutputState.e_touching,e.t=f,A=!0;break}for(var I=0,B=f,P=b;;){var M;M=1&I?B+(_-R)*(P-B)/(x-R):.5*(B+P),++I,++t.b2_toiRootIters;var L=T.Evaluate(C[0],w[0],M);if(D(L-_)<d){b=M;break}if(L>_?(B=M,R=L):(P=M,x=L),50===I)break}if(t.b2_toiMaxRootIters=O(t.b2_toiMaxRootIters,I),++E===o)break}if(++p,++t.b2_toiIters,A)break;if(20===p){e.state=t.b2TOIOutputState.e_failed,e.t=f;break}}t.b2_toiMaxIters=O(t.b2_toiMaxIters,p);var N=n.GetMilliseconds();t.b2_toiMaxTime=O(t.b2_toiMaxTime,N),t.b2_toiTime+=N}var Ae=new j,be=new j;function Ee(e,i,n,r,s){e.pointCount=0;var o=Q.MulXV(n,i.m_p,Ae),a=Q.MulXV(s,r.m_p,be),h=j.DistanceSquaredVV(o,a),u=i.m_radius+r.m_radius;h>u*u||(e.type=t.b2ManifoldType.e_circles,e.localPoint.Copy(i.m_p),e.localNormal.SetZero(),e.pointCount=1,e.points[0].localPoint.Copy(r.m_p),e.points[0].id.key=0)}var Ce=new j,we=new j,xe=new j;function Re(e,n,s,o,a){e.pointCount=0;for(var h=Q.MulXV(a,o.m_p,Ce),u=Q.MulTXV(s,h,we),l=0,c=-i,_=n.m_radius+o.m_radius,d=n.m_count,f=n.m_vertices,p=n.m_normals,m=0;m<d;++m){var g=j.DotVV(p[m],j.SubVV(u,f[m],j.s_t0));if(g>_)return;g>c&&(c=g,l=m)}var y=l,v=(y+1)%d,S=f[y],T=f[v];if(c<r)return e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(p[l]),j.MidVV(S,T,e.localPoint),e.points[0].localPoint.Copy(o.m_p),void(e.points[0].id.key=0);var A=j.DotVV(j.SubVV(u,S,j.s_t0),j.SubVV(T,S,j.s_t1)),b=j.DotVV(j.SubVV(u,T,j.s_t0),j.SubVV(S,T,j.s_t1));if(A<=0){if(j.DistanceSquaredVV(u,S)>_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,j.SubVV(u,S,e.localNormal).SelfNormalize(),e.localPoint.Copy(S),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}else if(b<=0){if(j.DistanceSquaredVV(u,T)>_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,j.SubVV(u,T,e.localNormal).SelfNormalize(),e.localPoint.Copy(T),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}else{var E=j.MidVV(S,T,xe);if(j.DotVV(j.SubVV(u,E,j.s_t1),p[y])>_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(p[y]).SelfNormalize(),e.localPoint.Copy(E),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}}var Ie=new j,Be=new j,De=new j,Pe=new j;function Oe(t,e,n,r,s){for(var o=t.m_vertices,a=t.m_normals,h=r.m_count,u=r.m_vertices,l=J.MulRV(e.q,a[n],Ie),c=J.MulTRV(s.q,l,Be),_=0,d=i,f=0;f<h;++f){var p=j.DotVV(u[f],c);p<d&&(d=p,_=f)}var m=Q.MulXV(e,o[n],De),g=Q.MulXV(s,u[_],Pe);return j.DotVV(j.SubVV(g,m,j.s_t0),l)}var Me=new j,Le=new j;function Ne(t,e,n,r,s){for(var o=e.m_count,a=e.m_normals,h=j.SubVV(Q.MulXV(s,r.m_centroid,j.s_t0),Q.MulXV(n,e.m_centroid,j.s_t1),Me),u=J.MulTRV(n.q,h,Le),l=0,c=-i,_=0;_<o;++_){var d=j.DotVV(a[_],u);d>c&&(c=d,l=_)}var f=Oe(e,n,l,r,s),p=(l+o-1)%o,m=Oe(e,n,p,r,s),g=(l+1)%o,y=Oe(e,n,g,r,s),v=0,S=0,T=0;if(m>f&&m>y)T=-1,v=p,S=m;else{if(!(y>f))return t[0]=l,f;T=1,v=g,S=y}for(;(f=Oe(e,n,l=-1===T?(v+o-1)%o:(v+1)%o,r,s))>S;)v=l,S=f;return t[0]=v,S}var Fe=new j;var ke=Nt.MakeArray(2),Ve=Nt.MakeArray(2),Ge=Nt.MakeArray(2),Ue=[0],ze=[0],He=new j,We=new j,je=new j,Xe=new j,qe=new j,Ye=new j,Ke=new j,Je=new j;function Qe(e,n,r,s,o){e.pointCount=0;var a=n.m_radius+s.m_radius,h=Ue;h[0]=0;var u=Ne(h,n,r,s,o);if(!(u>a)){var l=ze;l[0]=0;var c=Ne(l,s,o,n,r);if(!(c>a)){var _,d,f,p,m=0,g=0;c>.98*u+.001?(_=s,d=n,f=o,p=r,m=l[0],e.type=t.b2ManifoldType.e_faceB,g=1):(_=n,d=s,f=r,p=o,m=h[0],e.type=t.b2ManifoldType.e_faceA,g=0);var y=ke;!function(e,n,r,s,o,a){for(var h=n.m_normals,u=o.m_count,l=o.m_vertices,c=o.m_normals,_=J.MulTRV(a.q,J.MulRV(r.q,h[s],j.s_t0),Fe),d=0,f=i,p=0;p<u;++p){var m=j.DotVV(_,c[p]);m<f&&(f=m,d=p)}var g=d,y=(g+1)%u,v=e[0];Q.MulXV(a,l[g],v.v);var S=v.id.cf;S.indexA=s,S.indexB=g,S.typeA=t.b2ContactFeatureType.e_face,S.typeB=t.b2ContactFeatureType.e_vertex;var T=e[1];Q.MulXV(a,l[y],T.v);var A=T.id.cf;A.indexA=s,A.indexB=y,A.typeA=t.b2ContactFeatureType.e_face,A.typeB=t.b2ContactFeatureType.e_vertex}(y,_,f,m,d,p);var v=_.m_count,S=_.m_vertices,T=m,A=(m+1)%v,b=S[T],E=S[A],C=j.SubVV(E,b,He);C.Normalize();var w=j.CrossVOne(C,We),x=j.MidVV(b,E,je),R=J.MulRV(f.q,C,qe),I=j.CrossVOne(R,Xe),B=Q.MulXV(f,b,Ke),D=Q.MulXV(f,E,Je),P=j.DotVV(I,B),O=-j.DotVV(R,B)+a,M=j.DotVV(R,D)+a,L=Ve,N=Ge;if(!(Ut(L,y,j.NegV(R,Ye),O,T)<2||Ut(N,L,R,M,A)<2)){e.localNormal.Copy(w),e.localPoint.Copy(x);for(var F=0,k=0;k<2;++k){var V=N[k];if(j.DotVV(I,V.v)-P<=a){var G=e.points[F];if(Q.MulTXV(p,V.v,G.localPoint),G.id.Copy(V.id),g){var U=G.id.cf;G.id.cf.indexA=U.indexB,G.id.cf.indexB=U.indexA,G.id.cf.typeA=U.typeB,G.id.cf.typeB=U.typeA}++F}}e.pointCount=F}}}}var Ze,$e=new j,ti=new j,ei=new j,ii=new j,ni=new j,ri=new j,si=new j,oi=new Dt;function ai(e,i,n,r,s){e.pointCount=0;var o=Q.MulTXV(n,Q.MulXV(s,r.m_p,j.s_t0),$e),a=i.m_vertex1,h=i.m_vertex2,u=j.SubVV(h,a,ti),l=j.DotVV(u,j.SubVV(h,o,j.s_t0)),c=j.DotVV(u,j.SubVV(o,a,j.s_t0)),_=i.m_radius+r.m_radius,d=oi;if(d.cf.indexB=0,d.cf.typeB=t.b2ContactFeatureType.e_vertex,c<=0){var f=a,p=j.SubVV(o,f,ei);if(j.DotVV(p,p)>_*_)return;if(i.m_hasVertex0){var m=i.m_vertex0,g=a,y=j.SubVV(g,m,ii);if(j.DotVV(y,j.SubVV(g,o,j.s_t0))>0)return}return d.cf.indexA=0,d.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(f),e.points[0].id.Copy(d),void e.points[0].localPoint.Copy(r.m_p)}if(l<=0){var v=h,S=j.SubVV(o,v,ei);if(j.DotVV(S,S)>_*_)return;if(i.m_hasVertex3){var T=i.m_vertex3,A=h,b=j.SubVV(T,A,ni);if(j.DotVV(b,j.SubVV(o,A,j.s_t0))>0)return}return d.cf.indexA=1,d.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(v),e.points[0].id.Copy(d),void e.points[0].localPoint.Copy(r.m_p)}var E=j.DotVV(u,u),C=ri;C.x=1/E*(l*a.x+c*h.x),C.y=1/E*(l*a.y+c*h.y);var w=j.SubVV(o,C,ei);if(!(j.DotVV(w,w)>_*_)){var x=si.Set(-u.y,u.x);j.DotVV(x,j.SubVV(o,a,j.s_t0))<0&&x.Set(-x.x,-x.y),x.Normalize(),d.cf.indexA=0,d.cf.typeA=t.b2ContactFeatureType.e_face,e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(x),e.localPoint.Copy(a),e.points[0].id.Copy(d),e.points[0].localPoint.Copy(r.m_p)}}!function(t){t[t.e_unknown=0]="e_unknown",t[t.e_edgeA=1]="e_edgeA",t[t.e_edgeB=2]="e_edgeB"}(Ze||(Ze={}));var hi,ui=function(){this.type=Ze.e_unknown,this.index=0,this.separation=0},li=function(){this.vertices=[],this.normals=[],this.count=0};!function(t){t[t.e_isolated=0]="e_isolated",t[t.e_concave=1]="e_concave",t[t.e_convex=2]="e_convex"}(hi||(hi={}));var ci=function(){function e(){this.m_polygonB=new li,this.m_xf=new Q,this.m_centroidB=new j,this.m_v0=new j,this.m_v1=new j,this.m_v2=new j,this.m_v3=new j,this.m_normal0=new j,this.m_normal1=new j,this.m_normal2=new j,this.m_normal=new j,this.m_type1=hi.e_isolated,this.m_type2=hi.e_isolated,this.m_lowerLimit=new j,this.m_upperLimit=new j,this.m_radius=0,this.m_front=!1}var n=e.prototype;return n.Collide=function(i,n,r,s,o){Q.MulTXX(r,o,this.m_xf),Q.MulXV(this.m_xf,s.m_centroid,this.m_centroidB),this.m_v0.Copy(n.m_vertex0),this.m_v1.Copy(n.m_vertex1),this.m_v2.Copy(n.m_vertex2),this.m_v3.Copy(n.m_vertex3);var a=n.m_hasVertex0,h=n.m_hasVertex3,u=j.SubVV(this.m_v2,this.m_v1,e.s_edge1);u.Normalize(),this.m_normal1.Set(u.y,-u.x);var l=j.DotVV(this.m_normal1,j.SubVV(this.m_centroidB,this.m_v1,j.s_t0)),c=0,_=0,d=!1,f=!1;if(a){var p=j.SubVV(this.m_v1,this.m_v0,e.s_edge0);p.Normalize(),this.m_normal0.Set(p.y,-p.x),d=j.CrossVV(p,u)>=0,c=j.DotVV(this.m_normal0,j.SubVV(this.m_centroidB,this.m_v0,j.s_t0))}if(h){var m=j.SubVV(this.m_v3,this.m_v2,e.s_edge2);m.Normalize(),this.m_normal2.Set(m.y,-m.x),f=j.CrossVV(u,m)>0,_=j.DotVV(this.m_normal2,j.SubVV(this.m_centroidB,this.m_v2,j.s_t0))}a&&h?d&&f?(this.m_front=c>=0||l>=0||_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):d?(this.m_front=c>=0||l>=0&&_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):f?(this.m_front=_>=0||c>=0&&l>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):(this.m_front=c>=0&&l>=0&&_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):a?d?(this.m_front=c>=0||l>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):(this.m_front=c>=0&&l>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):h?f?(this.m_front=l>=0||_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=l>=0&&_>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=l>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1))),this.m_polygonB.count=s.m_count;for(var g=0;g<s.m_count;++g)this.m_polygonB.vertices.length<=g&&this.m_polygonB.vertices.push(new j),this.m_polygonB.normals.length<=g&&this.m_polygonB.normals.push(new j),Q.MulXV(this.m_xf,s.m_vertices[g],this.m_polygonB.vertices[g]),J.MulRV(this.m_xf.q,s.m_normals[g],this.m_polygonB.normals[g]);this.m_radius=s.m_radius+n.m_radius,i.pointCount=0;var y=this.ComputeEdgeSeparation(e.s_edgeAxis);if(y.type!==Ze.e_unknown&&!(y.separation>this.m_radius)){var v=this.ComputePolygonSeparation(e.s_polygonAxis);if(!(v.type!==Ze.e_unknown&&v.separation>this.m_radius)){var S;S=v.type===Ze.e_unknown?y:v.separation>.98*y.separation+.001?v:y;var T=e.s_ie,A=e.s_rf;if(S.type===Ze.e_edgeA){i.type=t.b2ManifoldType.e_faceA;for(var b=0,E=j.DotVV(this.m_normal,this.m_polygonB.normals[0]),C=1;C<this.m_polygonB.count;++C){var w=j.DotVV(this.m_normal,this.m_polygonB.normals[C]);w<E&&(E=w,b=C)}var x=b,R=(x+1)%this.m_polygonB.count,I=T[0];I.v.Copy(this.m_polygonB.vertices[x]),I.id.cf.indexA=0,I.id.cf.indexB=x,I.id.cf.typeA=t.b2ContactFeatureType.e_face,I.id.cf.typeB=t.b2ContactFeatureType.e_vertex;var B=T[1];B.v.Copy(this.m_polygonB.vertices[R]),B.id.cf.indexA=0,B.id.cf.indexB=R,B.id.cf.typeA=t.b2ContactFeatureType.e_face,B.id.cf.typeB=t.b2ContactFeatureType.e_vertex,this.m_front?(A.i1=0,A.i2=1,A.v1.Copy(this.m_v1),A.v2.Copy(this.m_v2),A.normal.Copy(this.m_normal1)):(A.i1=1,A.i2=0,A.v1.Copy(this.m_v2),A.v2.Copy(this.m_v1),A.normal.Copy(this.m_normal1).SelfNeg())}else{i.type=t.b2ManifoldType.e_faceB;var D=T[0];D.v.Copy(this.m_v1),D.id.cf.indexA=0,D.id.cf.indexB=S.index,D.id.cf.typeA=t.b2ContactFeatureType.e_vertex,D.id.cf.typeB=t.b2ContactFeatureType.e_face;var P=T[1];P.v.Copy(this.m_v2),P.id.cf.indexA=0,P.id.cf.indexB=S.index,P.id.cf.typeA=t.b2ContactFeatureType.e_vertex,P.id.cf.typeB=t.b2ContactFeatureType.e_face,A.i1=S.index,A.i2=(A.i1+1)%this.m_polygonB.count,A.v1.Copy(this.m_polygonB.vertices[A.i1]),A.v2.Copy(this.m_polygonB.vertices[A.i2]),A.normal.Copy(this.m_polygonB.normals[A.i1])}A.sideNormal1.Set(A.normal.y,-A.normal.x),A.sideNormal2.Copy(A.sideNormal1).SelfNeg(),A.sideOffset1=j.DotVV(A.sideNormal1,A.v1),A.sideOffset2=j.DotVV(A.sideNormal2,A.v2);var O=e.s_clipPoints1,M=e.s_clipPoints2;if(!(Ut(O,T,A.sideNormal1,A.sideOffset1,A.i1)<2||Ut(M,O,A.sideNormal2,A.sideOffset2,A.i2)<2)){S.type===Ze.e_edgeA?(i.localNormal.Copy(A.normal),i.localPoint.Copy(A.v1)):(i.localNormal.Copy(s.m_normals[A.i1]),i.localPoint.Copy(s.m_vertices[A.i1]));for(var L=0,N=0;N<2;++N)if(j.DotVV(A.normal,j.SubVV(M[N].v,A.v1,j.s_t0))<=this.m_radius){var F=i.points[L];S.type===Ze.e_edgeA?(Q.MulTXV(this.m_xf,M[N].v,F.localPoint),F.id.Copy(M[N].id)):(F.localPoint.Copy(M[N].v),F.id.cf.typeA=M[N].id.cf.typeB,F.id.cf.typeB=M[N].id.cf.typeA,F.id.cf.indexA=M[N].id.cf.indexB,F.id.cf.indexB=M[N].id.cf.indexA),++L}i.pointCount=L}}}},n.ComputeEdgeSeparation=function(t){var e=t;e.type=Ze.e_edgeA,e.index=this.m_front?0:1,e.separation=i;for(var n=0;n<this.m_polygonB.count;++n){var r=j.DotVV(this.m_normal,j.SubVV(this.m_polygonB.vertices[n],this.m_v1,j.s_t0));r<e.separation&&(e.separation=r)}return e},n.ComputePolygonSeparation=function(t){var n=t;n.type=Ze.e_unknown,n.index=-1,n.separation=-i;for(var r=e.s_perp.Set(-this.m_normal.y,this.m_normal.x),s=0;s<this.m_polygonB.count;++s){var o=j.NegV(this.m_polygonB.normals[s],e.s_n),a=P(j.DotVV(o,j.SubVV(this.m_polygonB.vertices[s],this.m_v1,j.s_t0)),j.DotVV(o,j.SubVV(this.m_polygonB.vertices[s],this.m_v2,j.s_t0)));if(a>this.m_radius)return n.type=Ze.e_edgeB,n.index=s,n.separation=a,n;if(j.DotVV(o,r)>=0){if(j.DotVV(j.SubVV(o,this.m_upperLimit,j.s_t0),this.m_normal)<-c)continue}else if(j.DotVV(j.SubVV(o,this.m_lowerLimit,j.s_t0),this.m_normal)<-c)continue;a>n.separation&&(n.type=Ze.e_edgeB,n.index=s,n.separation=a)}return n},e}();ci.s_edge1=new j,ci.s_edge0=new j,ci.s_edge2=new j,ci.s_ie=Nt.MakeArray(2),ci.s_rf=new function(){this.i1=0,this.i2=0,this.v1=new j,this.v2=new j,this.normal=new j,this.sideNormal1=new j,this.sideOffset1=0,this.sideNormal2=new j,this.sideOffset2=0},ci.s_clipPoints1=Nt.MakeArray(2),ci.s_clipPoints2=Nt.MakeArray(2),ci.s_edgeAxis=new ui,ci.s_polygonAxis=new ui,ci.s_n=new j,ci.s_perp=new j;var _i=new ci;function di(t,e,i,n,r){_i.Collide(t,e,i,n,r)}var fi,pi=function(){this.mass=0,this.center=new j(0,0),this.I=0};(fi=t.b2ShapeType||(t.b2ShapeType={}))[fi.e_unknown=-1]="e_unknown",fi[fi.e_circleShape=0]="e_circleShape",fi[fi.e_edgeShape=1]="e_edgeShape",fi[fi.e_polygonShape=2]="e_polygonShape",fi[fi.e_chainShape=3]="e_chainShape",fi[fi.e_shapeTypeCount=4]="e_shapeTypeCount";var mi=function(){function e(e,i){this.m_type=t.b2ShapeType.e_unknown,this.m_radius=0,this.m_type=e,this.m_radius=i}var i=e.prototype;return i.Copy=function(t){return this.m_radius=t.m_radius,this},i.GetType=function(){return this.m_type},e}(),gi=function(e){function i(i){var n;return void 0===i&&(i=0),(n=e.call(this,t.b2ShapeType.e_circleShape,i)||this).m_p=new j,n}s(i,e);var n=i.prototype;return n.Set=function(t,e){return void 0===e&&(e=this.m_radius),this.m_p.Copy(t),this.m_radius=e,this},n.Clone=function(){return(new i).Copy(this)},n.Copy=function(t){return e.prototype.Copy.call(this,t),this.m_p.Copy(t.m_p),this},n.GetChildCount=function(){return 1},n.TestPoint=function(t,e){var n=Q.MulXV(t,this.m_p,i.TestPoint_s_center),r=j.SubVV(e,n,i.TestPoint_s_d);return j.DotVV(r,r)<=N(this.m_radius)},n.ComputeDistance=function(t,e,n){var r=Q.MulXV(t,this.m_p,i.ComputeDistance_s_center);return j.SubVV(e,r,n),n.Normalize()-this.m_radius},n.RayCast=function(t,e,n){var s=Q.MulXV(n,this.m_p,i.RayCast_s_position),o=j.SubVV(e.p1,s,i.RayCast_s_s),a=j.DotVV(o,o)-N(this.m_radius),h=j.SubVV(e.p2,e.p1,i.RayCast_s_r),u=j.DotVV(o,h),l=j.DotVV(h,h),c=u*u-l*a;if(c<0||l<r)return!1;var _=-(u+k(c));return 0<=_&&_<=e.maxFraction*l&&(_/=l,t.fraction=_,j.AddVMulSV(o,_,h,t.normal).SelfNormalize(),!0)},n.ComputeAABB=function(t,e){var n=Q.MulXV(e,this.m_p,i.ComputeAABB_s_p);t.lowerBound.Set(n.x-this.m_radius,n.y-this.m_radius),t.upperBound.Set(n.x+this.m_radius,n.y+this.m_radius)},n.ComputeMass=function(t,e){var i=N(this.m_radius);t.mass=e*a*i,t.center.Copy(this.m_p),t.I=t.mass*(.5*i+j.DotVV(this.m_p,this.m_p))},n.SetupDistanceProxy=function(t){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_p),t.m_count=1,t.m_radius=this.m_radius},n.ComputeSubmergedArea=function(t,e,i,n){var s=Q.MulXV(i,this.m_p,new j),o=-(j.DotVV(t,s)-e);if(o<-this.m_radius+r)return 0;if(o>this.m_radius)return n.Copy(s),a*this.m_radius*this.m_radius;var h=this.m_radius*this.m_radius,u=o*o,l=h*(H(o/this.m_radius)+a/2)+o*k(h-u),c=-2/3*V(h-u,1.5)/l;return n.x=s.x+t.x*c,n.y=s.y+t.y*c,l},n.Dump=function(t){t(" const shape: b2CircleShape = new b2CircleShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_p.Set(%.15f, %.15f);\n",this.m_p.x,this.m_p.y)},i}(mi);gi.TestPoint_s_center=new j,gi.TestPoint_s_d=new j,gi.ComputeDistance_s_center=new j,gi.RayCast_s_position=new j,gi.RayCast_s_s=new j,gi.RayCast_s_r=new j,gi.ComputeAABB_s_p=new j;var yi=function(e){function n(){var i;return(i=e.call(this,t.b2ShapeType.e_polygonShape,_)||this).m_centroid=new j(0,0),i.m_vertices=[],i.m_normals=[],i.m_count=0,i}s(n,e);var r=n.prototype;return r.Clone=function(){return(new n).Copy(this)},r.Copy=function(t){e.prototype.Copy.call(this,t),this.m_centroid.Copy(t.m_centroid),this.m_count=t.m_count,this.m_vertices=j.MakeArray(this.m_count),this.m_normals=j.MakeArray(this.m_count);for(var i=0;i<this.m_count;++i)this.m_vertices[i].Copy(t.m_vertices[i]),this.m_normals[i].Copy(t.m_normals[i]);return this},r.GetChildCount=function(){return 1},r.Set=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if("number"==typeof e[0][0]){var n=e[0];if(n.length%2!=0)throw new Error;return this._Set((function(t){return{x:n[2*t],y:n[2*t+1]}}),n.length/2)}var r=e[0],s=e[1]||r.length;return this._Set((function(t){return r[t]}),s)},r._Set=function(t,e){if(e<3)return this.SetAsBox(1,1);for(var i=e,r=[],s=0;s<i;++s){for(var o=t(s),a=!0,h=0;h<r.length;++h)if(j.DistanceSquaredVV(o,r[h])<16e-6){a=!1;break}a&&r.push(o)}if((i=r.length)<3)return this.SetAsBox(1,1);for(var u=0,l=r[0].x,c=1;c<i;++c){var _=r[c].x;(_>l||_===l&&r[c].y<r[u].y)&&(u=c,l=_)}for(var d=[],f=0,p=u;;){d[f]=p;for(var m=0,g=1;g<i;++g)if(m!==p){var y=j.SubVV(r[m],r[d[f]],n.Set_s_r),v=j.SubVV(r[g],r[d[f]],n.Set_s_v),S=j.CrossVV(y,v);S<0&&(m=g),0===S&&v.LengthSquared()>y.LengthSquared()&&(m=g)}else m=g;if(++f,p=m,m===u)break}this.m_count=f,this.m_vertices=j.MakeArray(this.m_count),this.m_normals=j.MakeArray(this.m_count);for(var T=0;T<f;++T)this.m_vertices[T].Copy(r[d[T]]);for(var A=0;A<f;++A){var b=this.m_vertices[A],E=this.m_vertices[(A+1)%f],C=j.SubVV(E,b,j.s_t0);j.CrossVOne(C,this.m_normals[A]).SelfNormalize()}return n.ComputeCentroid(this.m_vertices,f,this.m_centroid),this},r.SetAsBox=function(t,e,i,n){if(void 0===n&&(n=0),this.m_count=4,this.m_vertices=j.MakeArray(this.m_count),this.m_normals=j.MakeArray(this.m_count),this.m_vertices[0].Set(-t,-e),this.m_vertices[1].Set(t,-e),this.m_vertices[2].Set(t,e),this.m_vertices[3].Set(-t,e),this.m_normals[0].Set(0,-1),this.m_normals[1].Set(1,0),this.m_normals[2].Set(0,1),this.m_normals[3].Set(-1,0),this.m_centroid.SetZero(),i){this.m_centroid.Copy(i);var r=new Q;r.SetPosition(i),r.SetRotationAngle(n);for(var s=0;s<this.m_count;++s)Q.MulXV(r,this.m_vertices[s],this.m_vertices[s]),J.MulRV(r.q,this.m_normals[s],this.m_normals[s])}return this},r.TestPoint=function(t,e){for(var i=Q.MulTXV(t,e,n.TestPoint_s_pLocal),r=0;r<this.m_count;++r)if(j.DotVV(this.m_normals[r],j.SubVV(i,this.m_vertices[r],j.s_t0))>0)return!1;return!0},r.ComputeDistance=function(t,e,r){for(var s=Q.MulTXV(t,e,n.ComputeDistance_s_pLocal),o=-i,a=n.ComputeDistance_s_normalForMaxDistance.Copy(s),h=0;h<this.m_count;++h){var u=j.DotVV(this.m_normals[h],j.SubVV(s,this.m_vertices[h],j.s_t0));u>o&&(o=u,a.Copy(this.m_normals[h]))}if(o>0){for(var l=n.ComputeDistance_s_minDistance.Copy(a),c=o*o,_=0;_<this.m_count;++_){var d=j.SubVV(s,this.m_vertices[_],n.ComputeDistance_s_distance),f=d.LengthSquared();c>f&&(l.Copy(d),c=f)}return J.MulRV(t.q,l,r),r.Normalize(),Math.sqrt(c)}return J.MulRV(t.q,a,r),o},r.RayCast=function(t,e,i){for(var r=Q.MulTXV(i,e.p1,n.RayCast_s_p1),s=Q.MulTXV(i,e.p2,n.RayCast_s_p2),o=j.SubVV(s,r,n.RayCast_s_d),a=0,h=e.maxFraction,u=-1,l=0;l<this.m_count;++l){var c=j.DotVV(this.m_normals[l],j.SubVV(this.m_vertices[l],r,j.s_t0)),_=j.DotVV(this.m_normals[l],o);if(0===_){if(c<0)return!1}else _<0&&c<a*_?(a=c/_,u=l):_>0&&c<h*_&&(h=c/_);if(h<a)return!1}return u>=0&&(t.fraction=a,J.MulRV(i.q,this.m_normals[u],t.normal),!0)},r.ComputeAABB=function(t,e){for(var i=Q.MulXV(e,this.m_vertices[0],t.lowerBound),r=t.upperBound.Copy(i),s=0;s<this.m_count;++s){var o=Q.MulXV(e,this.m_vertices[s],n.ComputeAABB_s_v);j.MinV(o,i,i),j.MaxV(o,r,r)}var a=this.m_radius;i.SelfSubXY(a,a),r.SelfAddXY(a,a)},r.ComputeMass=function(t,e){for(var i=n.ComputeMass_s_center.SetZero(),r=0,s=0,o=n.ComputeMass_s_s.SetZero(),a=0;a<this.m_count;++a)o.SelfAdd(this.m_vertices[a]);o.SelfMul(1/this.m_count);for(var h=1/3,u=0;u<this.m_count;++u){var l=j.SubVV(this.m_vertices[u],o,n.ComputeMass_s_e1),c=j.SubVV(this.m_vertices[(u+1)%this.m_count],o,n.ComputeMass_s_e2),_=j.CrossVV(l,c),d=.5*_;r+=d,i.SelfAdd(j.MulSV(d*h,j.AddVV(l,c,j.s_t0),j.s_t1));var f=l.x,p=l.y,m=c.x,g=c.y;s+=.25*h*_*(f*f+m*f+m*m+p*p+g*p+g*g)}t.mass=e*r,i.SelfMul(1/r),j.AddVV(i,o,t.center),t.I=e*s,t.I+=t.mass*(j.DotVV(t.center,t.center)-j.DotVV(i,i))},r.Validate=function(){for(var t=0;t<this.m_count;++t)for(var e=t,i=(t+1)%this.m_count,r=this.m_vertices[e],s=j.SubVV(this.m_vertices[i],r,n.Validate_s_e),o=0;o<this.m_count;++o)if(o!==e&&o!==i){var a=j.SubVV(this.m_vertices[o],r,n.Validate_s_v);if(j.CrossVV(s,a)<0)return!1}return!0},r.SetupDistanceProxy=function(t){t.m_vertices=this.m_vertices,t.m_count=this.m_count,t.m_radius=this.m_radius},r.ComputeSubmergedArea=function(t,e,i,r){for(var s=J.MulTRV(i.q,t,n.ComputeSubmergedArea_s_normalL),o=e-j.DotVV(t,i.p),a=[],h=0,u=-1,l=-1,c=!1,_=0;_<this.m_count;++_){a[_]=j.DotVV(s,this.m_vertices[_])-o;var d=a[_]<-1e-5;_>0&&(d?c||(u=_-1,h++):c&&(l=_-1,h++)),c=d}switch(h){case 0:if(c){var f=n.ComputeSubmergedArea_s_md;return this.ComputeMass(f,1),Q.MulXV(i,f.center,r),f.mass}return 0;case 1:-1===u?u=this.m_count-1:l=this.m_count-1}for(var p,m=(u+1)%this.m_count,g=(l+1)%this.m_count,y=(0-a[u])/(a[m]-a[u]),v=(0-a[l])/(a[g]-a[l]),S=n.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[u].x*(1-y)+this.m_vertices[m].x*y,this.m_vertices[u].y*(1-y)+this.m_vertices[m].y*y),T=n.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[l].x*(1-v)+this.m_vertices[g].x*v,this.m_vertices[l].y*(1-v)+this.m_vertices[g].y*v),A=0,b=n.ComputeSubmergedArea_s_center.SetZero(),E=this.m_vertices[m],C=m;C!==g;){p=(C=(C+1)%this.m_count)===g?T:this.m_vertices[C];var w=.5*((E.x-S.x)*(p.y-S.y)-(E.y-S.y)*(p.x-S.x));A+=w,b.x+=w*(S.x+E.x+p.x)/3,b.y+=w*(S.y+E.y+p.y)/3,E=p}return b.SelfMul(1/A),Q.MulXV(i,b,r),A},r.Dump=function(t){t(" const shape: b2PolygonShape = new b2PolygonShape();\n"),t(" const vs: b2Vec2[] = [];\n");for(var e=0;e<this.m_count;++e)t(" vs[%d] = new b2Vec2(%.15f, %.15f);\n",e,this.m_vertices[e].x,this.m_vertices[e].y);t(" shape.Set(vs, %d);\n",this.m_count)},n.ComputeCentroid=function(t,e,i){var r=i;r.SetZero();for(var s=0,o=n.ComputeCentroid_s_pRef.SetZero(),a=1/3,h=0;h<e;++h){var u=o,l=t[h],c=t[(h+1)%e],_=j.SubVV(l,u,n.ComputeCentroid_s_e1),d=j.SubVV(c,u,n.ComputeCentroid_s_e2),f=.5*j.CrossVV(_,d);s+=f,r.x+=f*a*(u.x+l.x+c.x),r.y+=f*a*(u.y+l.y+c.y)}return r.SelfMul(1/s),r},n}(mi);yi.Set_s_r=new j,yi.Set_s_v=new j,yi.TestPoint_s_pLocal=new j,yi.ComputeDistance_s_pLocal=new j,yi.ComputeDistance_s_normalForMaxDistance=new j,yi.ComputeDistance_s_minDistance=new j,yi.ComputeDistance_s_distance=new j,yi.RayCast_s_p1=new j,yi.RayCast_s_p2=new j,yi.RayCast_s_d=new j,yi.ComputeAABB_s_v=new j,yi.ComputeMass_s_center=new j,yi.ComputeMass_s_s=new j,yi.ComputeMass_s_e1=new j,yi.ComputeMass_s_e2=new j,yi.Validate_s_e=new j,yi.Validate_s_v=new j,yi.ComputeSubmergedArea_s_normalL=new j,yi.ComputeSubmergedArea_s_md=new pi,yi.ComputeSubmergedArea_s_intoVec=new j,yi.ComputeSubmergedArea_s_outoVec=new j,yi.ComputeSubmergedArea_s_center=new j,yi.ComputeCentroid_s_pRef=new j,yi.ComputeCentroid_s_e1=new j,yi.ComputeCentroid_s_e2=new j;var vi=function(e){function i(){var i;return(i=e.call(this,t.b2ShapeType.e_edgeShape,_)||this).m_vertex1=new j,i.m_vertex2=new j,i.m_vertex0=new j,i.m_vertex3=new j,i.m_hasVertex0=!1,i.m_hasVertex3=!1,i}s(i,e);var n=i.prototype;return n.Set=function(t,e){return this.m_vertex1.Copy(t),this.m_vertex2.Copy(e),this.m_hasVertex0=!1,this.m_hasVertex3=!1,this},n.Clone=function(){return(new i).Copy(this)},n.Copy=function(t){return e.prototype.Copy.call(this,t),this.m_vertex1.Copy(t.m_vertex1),this.m_vertex2.Copy(t.m_vertex2),this.m_vertex0.Copy(t.m_vertex0),this.m_vertex3.Copy(t.m_vertex3),this.m_hasVertex0=t.m_hasVertex0,this.m_hasVertex3=t.m_hasVertex3,this},n.GetChildCount=function(){return 1},n.TestPoint=function(){return!1},n.ComputeDistance=function(t,e,n){var r=Q.MulXV(t,this.m_vertex1,i.ComputeDistance_s_v1),s=Q.MulXV(t,this.m_vertex2,i.ComputeDistance_s_v2),o=j.SubVV(e,r,i.ComputeDistance_s_d),a=j.SubVV(s,r,i.ComputeDistance_s_s),h=j.DotVV(o,a);if(h>0){var u=j.DotVV(a,a);h>u?j.SubVV(e,s,o):o.SelfMulSub(h/u,a)}return n.Copy(o),n.Normalize()},n.RayCast=function(t,e,n){var r=Q.MulTXV(n,e.p1,i.RayCast_s_p1),s=Q.MulTXV(n,e.p2,i.RayCast_s_p2),o=j.SubVV(s,r,i.RayCast_s_d),a=this.m_vertex1,h=this.m_vertex2,u=j.SubVV(h,a,i.RayCast_s_e),l=t.normal.Set(u.y,-u.x).SelfNormalize(),c=j.DotVV(l,j.SubVV(a,r,j.s_t0)),_=j.DotVV(l,o);if(0===_)return!1;var d=c/_;if(d<0||e.maxFraction<d)return!1;var f=j.AddVMulSV(r,d,o,i.RayCast_s_q),p=j.SubVV(h,a,i.RayCast_s_r),m=j.DotVV(p,p);if(0===m)return!1;var g=j.DotVV(j.SubVV(f,a,j.s_t0),p)/m;return!(g<0||1<g||(t.fraction=d,J.MulRV(n.q,t.normal,t.normal),c>0&&t.normal.SelfNeg(),0))},n.ComputeAABB=function(t,e){var n=Q.MulXV(e,this.m_vertex1,i.ComputeAABB_s_v1),r=Q.MulXV(e,this.m_vertex2,i.ComputeAABB_s_v2);j.MinV(n,r,t.lowerBound),j.MaxV(n,r,t.upperBound);var s=this.m_radius;t.lowerBound.SelfSubXY(s,s),t.upperBound.SelfAddXY(s,s)},n.ComputeMass=function(t){t.mass=0,j.MidVV(this.m_vertex1,this.m_vertex2,t.center),t.I=0},n.SetupDistanceProxy=function(t){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_vertex1),t.m_vertices[1].Copy(this.m_vertex2),t.m_count=2,t.m_radius=this.m_radius},n.ComputeSubmergedArea=function(t,e,i,n){return n.SetZero(),0},n.Dump=function(t){t(" const shape: b2EdgeShape = new b2EdgeShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_vertex0.Set(%.15f, %.15f);\n",this.m_vertex0.x,this.m_vertex0.y),t(" shape.m_vertex1.Set(%.15f, %.15f);\n",this.m_vertex1.x,this.m_vertex1.y),t(" shape.m_vertex2.Set(%.15f, %.15f);\n",this.m_vertex2.x,this.m_vertex2.y),t(" shape.m_vertex3.Set(%.15f, %.15f);\n",this.m_vertex3.x,this.m_vertex3.y),t(" shape.m_hasVertex0 = %s;\n",this.m_hasVertex0),t(" shape.m_hasVertex3 = %s;\n",this.m_hasVertex3)},i}(mi);vi.ComputeDistance_s_v1=new j,vi.ComputeDistance_s_v2=new j,vi.ComputeDistance_s_d=new j,vi.ComputeDistance_s_s=new j,vi.RayCast_s_p1=new j,vi.RayCast_s_p2=new j,vi.RayCast_s_d=new j,vi.RayCast_s_e=new j,vi.RayCast_s_q=new j,vi.RayCast_s_r=new j,vi.ComputeAABB_s_v1=new j,vi.ComputeAABB_s_v2=new j;var Si=function(e){function i(){var i;return(i=e.call(this,t.b2ShapeType.e_chainShape,_)||this).m_vertices=[],i.m_count=0,i.m_prevVertex=new j,i.m_nextVertex=new j,i.m_hasPrevVertex=!1,i.m_hasNextVertex=!1,i}s(i,e);var n=i.prototype;return n.CreateLoop=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if("number"==typeof e[0][0]){var n=e[0];if(n.length%2!=0)throw new Error;return this._CreateLoop((function(t){return{x:n[2*t],y:n[2*t+1]}}),n.length/2)}var r=e[0],s=e[1]||r.length;return this._CreateLoop((function(t){return r[t]}),s)},n._CreateLoop=function(t,e){if(e<3)return this;this.m_count=e+1,this.m_vertices=j.MakeArray(this.m_count);for(var i=0;i<e;++i)this.m_vertices[i].Copy(t(i));return this.m_vertices[e].Copy(this.m_vertices[0]),this.m_prevVertex.Copy(this.m_vertices[this.m_count-2]),this.m_nextVertex.Copy(this.m_vertices[1]),this.m_hasPrevVertex=!0,this.m_hasNextVertex=!0,this},n.CreateChain=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];if("number"==typeof e[0][0]){var n=e[0];if(n.length%2!=0)throw new Error;return this._CreateChain((function(t){return{x:n[2*t],y:n[2*t+1]}}),n.length/2)}var r=e[0],s=e[1]||r.length;return this._CreateChain((function(t){return r[t]}),s)},n._CreateChain=function(t,e){this.m_count=e,this.m_vertices=j.MakeArray(e);for(var i=0;i<e;++i)this.m_vertices[i].Copy(t(i));return this.m_hasPrevVertex=!1,this.m_hasNextVertex=!1,this.m_prevVertex.SetZero(),this.m_nextVertex.SetZero(),this},n.SetPrevVertex=function(t){return this.m_prevVertex.Copy(t),this.m_hasPrevVertex=!0,this},n.SetNextVertex=function(t){return this.m_nextVertex.Copy(t),this.m_hasNextVertex=!0,this},n.Clone=function(){return(new i).Copy(this)},n.Copy=function(t){return e.prototype.Copy.call(this,t),this._CreateChain((function(e){return t.m_vertices[e]}),t.m_count),this.m_prevVertex.Copy(t.m_prevVertex),this.m_nextVertex.Copy(t.m_nextVertex),this.m_hasPrevVertex=t.m_hasPrevVertex,this.m_hasNextVertex=t.m_hasNextVertex,this},n.GetChildCount=function(){return this.m_count-1},n.GetChildEdge=function(t,e){t.m_radius=this.m_radius,t.m_vertex1.Copy(this.m_vertices[e]),t.m_vertex2.Copy(this.m_vertices[e+1]),e>0?(t.m_vertex0.Copy(this.m_vertices[e-1]),t.m_hasVertex0=!0):(t.m_vertex0.Copy(this.m_prevVertex),t.m_hasVertex0=this.m_hasPrevVertex),e<this.m_count-2?(t.m_vertex3.Copy(this.m_vertices[e+2]),t.m_hasVertex3=!0):(t.m_vertex3.Copy(this.m_nextVertex),t.m_hasVertex3=this.m_hasNextVertex)},n.TestPoint=function(){return!1},n.ComputeDistance=function(t,e,n,r){var s=i.ComputeDistance_s_edgeShape;return this.GetChildEdge(s,r),s.ComputeDistance(t,e,n,0)},n.RayCast=function(t,e,n,r){var s=i.RayCast_s_edgeShape;return s.m_vertex1.Copy(this.m_vertices[r]),s.m_vertex2.Copy(this.m_vertices[(r+1)%this.m_count]),s.RayCast(t,e,n,0)},n.ComputeAABB=function(t,e,n){var r=this.m_vertices[n],s=this.m_vertices[(n+1)%this.m_count],o=Q.MulXV(e,r,i.ComputeAABB_s_v1),a=Q.MulXV(e,s,i.ComputeAABB_s_v2);j.MinV(o,a,t.lowerBound),j.MaxV(o,a,t.upperBound)},n.ComputeMass=function(t){t.mass=0,t.center.SetZero(),t.I=0},n.SetupDistanceProxy=function(t,e){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_vertices[e]),e+1<this.m_count?t.m_vertices[1].Copy(this.m_vertices[e+1]):t.m_vertices[1].Copy(this.m_vertices[0]),t.m_count=2,t.m_radius=this.m_radius},n.ComputeSubmergedArea=function(t,e,i,n){return n.SetZero(),0},n.Dump=function(t){t(" const shape: b2ChainShape = new b2ChainShape();\n"),t(" const vs: b2Vec2[] = [];\n");for(var e=0;e<this.m_count;++e)t(" vs[%d] = new bVec2(%.15f, %.15f);\n",e,this.m_vertices[e].x,this.m_vertices[e].y);t(" shape.CreateChain(vs, %d);\n",this.m_count),t(" shape.m_prevVertex.Set(%.15f, %.15f);\n",this.m_prevVertex.x,this.m_prevVertex.y),t(" shape.m_nextVertex.Set(%.15f, %.15f);\n",this.m_nextVertex.x,this.m_nextVertex.y),t(" shape.m_hasPrevVertex = %s;\n",this.m_hasPrevVertex?"true":"false"),t(" shape.m_hasNextVertex = %s;\n",this.m_hasNextVertex?"true":"false")},i}(mi);Si.ComputeDistance_s_edgeShape=new vi,Si.RayCast_s_edgeShape=new vi,Si.ComputeAABB_s_v1=new j,Si.ComputeAABB_s_v2=new j;var Ti=function(){function t(){this.categoryBits=1,this.maskBits=65535,this.groupIndex=0}var e=t.prototype;return e.Clone=function(){return(new t).Copy(this)},e.Copy=function(t){return this.categoryBits=t.categoryBits,this.maskBits=t.maskBits,this.groupIndex=t.groupIndex||0,this},t}();Ti.DEFAULT=new Ti;var Ai=function(){this.userData=null,this.friction=.2,this.restitution=0,this.density=0,this.isSensor=!1,this.filter=new Ti},bi=function(){function t(t,e){this.aabb=new Vt,this.childIndex=0,this.fixture=t,this.childIndex=e,this.fixture.m_shape.ComputeAABB(this.aabb,this.fixture.m_body.GetTransform(),e),this.treeNode=this.fixture.m_body.m_world.m_contactManager.m_broadPhase.CreateProxy(this.aabb,this)}var e=t.prototype;return e.Reset=function(){this.fixture.m_body.m_world.m_contactManager.m_broadPhase.DestroyProxy(this.treeNode)},e.Touch=function(){this.fixture.m_body.m_world.m_contactManager.m_broadPhase.TouchProxy(this.treeNode)},e.Synchronize=function(e,i,n){if(e===i)this.fixture.m_shape.ComputeAABB(this.aabb,e,this.childIndex),this.fixture.m_body.m_world.m_contactManager.m_broadPhase.MoveProxy(this.treeNode,this.aabb,n);else{var r=t.Synchronize_s_aabb1,s=t.Synchronize_s_aabb2;this.fixture.m_shape.ComputeAABB(r,e,this.childIndex),this.fixture.m_shape.ComputeAABB(s,i,this.childIndex),this.aabb.Combine2(r,s),this.fixture.m_body.m_world.m_contactManager.m_broadPhase.MoveProxy(this.treeNode,this.aabb,n)}},t}();bi.Synchronize_s_aabb1=new Vt,bi.Synchronize_s_aabb2=new Vt;var Ei,Ci=function(){function t(t,i){this.m_density=0,this.m_next=null,this.m_friction=0,this.m_restitution=0,this.m_proxies=[],this.m_filter=new Ti,this.m_isSensor=!1,this.m_userData=null,this.m_body=t,this.m_shape=i.shape.Clone(),this.m_userData=e(i.userData,null),this.m_friction=e(i.friction,.2),this.m_restitution=e(i.restitution,0),this.m_filter.Copy(e(i.filter,Ti.DEFAULT)),this.m_isSensor=e(i.isSensor,!1),this.m_density=e(i.density,0)}var i=t.prototype;return i.Reset=function(){},i.GetType=function(){return this.m_shape.GetType()},i.GetShape=function(){return this.m_shape},i.SetSensor=function(t){t!==this.m_isSensor&&(this.m_body.SetAwake(!0),this.m_isSensor=t)},i.IsSensor=function(){return this.m_isSensor},i.SetFilterData=function(t){this.m_filter.Copy(t),this.Refilter()},i.GetFilterData=function(){return this.m_filter},i.Refilter=function(){for(var t=this.m_body.GetContactList();t;){var e=t.contact,i=e.GetFixtureA(),n=e.GetFixtureB();i!==this&&n!==this||e.FlagForFiltering(),t=t.next}this.TouchProxies()},i.GetBody=function(){return this.m_body},i.GetNext=function(){return this.m_next},i.GetUserData=function(){return this.m_userData},i.SetUserData=function(t){this.m_userData=t},i.TestPoint=function(t){return this.m_shape.TestPoint(this.m_body.GetTransform(),t)},i.ComputeDistance=function(t,e,i){return this.m_shape.ComputeDistance(this.m_body.GetTransform(),t,e,i)},i.RayCast=function(t,e,i){return this.m_shape.RayCast(t,e,this.m_body.GetTransform(),i)},i.GetMassData=function(t){return void 0===t&&(t=new pi),this.m_shape.ComputeMass(t,this.m_density),t},i.SetDensity=function(t){this.m_density=t},i.GetDensity=function(){return this.m_density},i.GetFriction=function(){return this.m_friction},i.SetFriction=function(t){this.m_friction=t},i.GetRestitution=function(){return this.m_restitution},i.SetRestitution=function(t){this.m_restitution=t},i.GetAABB=function(t){return this.m_proxies[t].aabb},i.Dump=function(t,e){t(" const fd: b2FixtureDef = new b2FixtureDef();\n"),t(" fd.friction = %.15f;\n",this.m_friction),t(" fd.restitution = %.15f;\n",this.m_restitution),t(" fd.density = %.15f;\n",this.m_density),t(" fd.isSensor = %s;\n",this.m_isSensor?"true":"false"),t(" fd.filter.categoryBits = %d;\n",this.m_filter.categoryBits),t(" fd.filter.maskBits = %d;\n",this.m_filter.maskBits),t(" fd.filter.groupIndex = %d;\n",this.m_filter.groupIndex),this.m_shape.Dump(t),t("\n"),t(" fd.shape = shape;\n"),t("\n"),t(" bodies[%d].CreateFixture(fd);\n",e)},i.CreateProxies=function(){if(0!==this.m_proxies.length)throw new Error;for(var t=0;t<this.m_shape.GetChildCount();++t)this.m_proxies[t]=new bi(this,t)},i.DestroyProxies=function(){for(var t,e=d(this.m_proxies);!(t=e()).done;)t.value.Reset();this.m_proxies.length=0},i.TouchProxies=function(){for(var t,e=d(this.m_proxies);!(t=e()).done;)t.value.Touch()},i.SynchronizeProxies=function(t,e,i){for(var n,r=d(this.m_proxies);!(n=r()).done;)n.value.Synchronize(t,e,i)},n(t,[{key:"m_proxyCount",get:function(){return this.m_proxies.length}}]),t}();(Ei=t.b2BodyType||(t.b2BodyType={}))[Ei.b2_unknown=-1]="b2_unknown",Ei[Ei.b2_staticBody=0]="b2_staticBody",Ei[Ei.b2_kinematicBody=1]="b2_kinematicBody",Ei[Ei.b2_dynamicBody=2]="b2_dynamicBody";var wi,xi,Ri=function(){function i(i,n){this.m_type=t.b2BodyType.b2_staticBody,this.m_islandFlag=!1,this.m_awakeFlag=!1,this.m_autoSleepFlag=!1,this.m_bulletFlag=!1,this.m_fixedRotationFlag=!1,this.m_activeFlag=!1,this.m_toiFlag=!1,this.m_islandIndex=0,this.m_xf=new Q,this.m_xf0=new Q,this.m_sweep=new $,this.m_linearVelocity=new j,this.m_angularVelocity=0,this.m_force=new j,this.m_torque=0,this.m_prev=null,this.m_next=null,this.m_fixtureList=null,this.m_fixtureCount=0,this.m_jointList=null,this.m_contactList=null,this.m_mass=1,this.m_invMass=1,this.m_I=0,this.m_invI=0,this.m_linearDamping=0,this.m_angularDamping=0,this.m_gravityScale=1,this.m_sleepTime=0,this.m_userData=null,this.m_controllerList=null,this.m_controllerCount=0,this.m_bulletFlag=e(i.bullet,!1),this.m_fixedRotationFlag=e(i.fixedRotation,!1),this.m_autoSleepFlag=e(i.allowSleep,!0),this.m_awakeFlag=e(i.awake,!0),this.m_activeFlag=e(i.active,!0),this.m_world=n,this.m_xf.p.Copy(e(i.position,j.ZERO)),this.m_xf.q.SetAngle(e(i.angle,0)),this.m_xf0.Copy(this.m_xf),this.m_sweep.localCenter.SetZero(),this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),this.m_sweep.a0=this.m_sweep.a=this.m_xf.q.GetAngle(),this.m_sweep.alpha0=0,this.m_linearVelocity.Copy(e(i.linearVelocity,j.ZERO)),this.m_angularVelocity=e(i.angularVelocity,0),this.m_linearDamping=e(i.linearDamping,0),this.m_angularDamping=e(i.angularDamping,0),this.m_gravityScale=e(i.gravityScale,1),this.m_force.SetZero(),this.m_torque=0,this.m_sleepTime=0,this.m_type=e(i.type,t.b2BodyType.b2_staticBody),i.type===t.b2BodyType.b2_dynamicBody?(this.m_mass=1,this.m_invMass=1):(this.m_mass=0,this.m_invMass=0),this.m_I=0,this.m_invI=0,this.m_userData=i.userData,this.m_fixtureList=null,this.m_fixtureCount=0,this.m_controllerList=null,this.m_controllerCount=0}var n=i.prototype;return n.CreateFixture=function(t,e){return void 0===e&&(e=0),t instanceof mi?this.CreateFixtureShapeDensity(t,e):this.CreateFixtureDef(t)},n.CreateFixtureDef=function(t){if(this.m_world.IsLocked())throw new Error;var e=new Ci(this,t);return this.m_activeFlag&&e.CreateProxies(),e.m_next=this.m_fixtureList,this.m_fixtureList=e,++this.m_fixtureCount,e.m_density>0&&this.ResetMassData(),this.m_world.m_newFixture=!0,e},n.CreateFixtureShapeDensity=function(t,e){void 0===e&&(e=0);var n=i.CreateFixtureShapeDensity_s_def;return n.shape=t,n.density=e,this.CreateFixtureDef(n)},n.DestroyFixture=function(t){if(this.m_world.IsLocked())throw new Error;for(var e=this.m_fixtureList,i=null;null!==e;){if(e===t){i?i.m_next=t.m_next:this.m_fixtureList=t.m_next;break}i=e,e=e.m_next}for(var n=this.m_contactList;n;){var r=n.contact;n=n.next;var s=r.GetFixtureA(),o=r.GetFixtureB();t!==s&&t!==o||this.m_world.m_contactManager.Destroy(r)}this.m_activeFlag&&t.DestroyProxies(),t.m_next=null,t.Reset(),--this.m_fixtureCount,this.ResetMassData()},n.SetTransformVec=function(t,e){this.SetTransformXY(t.x,t.y,e)},n.SetTransformXY=function(t,e,i){if(this.m_world.IsLocked())throw new Error;this.m_xf.q.SetAngle(i),this.m_xf.p.Set(t,e),this.m_xf0.Copy(this.m_xf),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.a=i,this.m_sweep.c0.Copy(this.m_sweep.c),this.m_sweep.a0=i;for(var n=this.m_fixtureList;n;n=n.m_next)n.SynchronizeProxies(this.m_xf,this.m_xf,j.ZERO);this.m_world.m_contactManager.FindNewContacts()},n.SetTransform=function(t){this.SetTransformVec(t.p,t.GetAngle())},n.GetTransform=function(){return this.m_xf},n.GetPosition=function(){return this.m_xf.p},n.SetPosition=function(t){this.SetTransformVec(t,this.GetAngle())},n.SetPositionXY=function(t,e){this.SetTransformXY(t,e,this.GetAngle())},n.GetAngle=function(){return this.m_sweep.a},n.SetAngle=function(t){this.SetTransformVec(this.GetPosition(),t)},n.GetWorldCenter=function(){return this.m_sweep.c},n.GetLocalCenter=function(){return this.m_sweep.localCenter},n.SetLinearVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(j.DotVV(e,e)>0&&this.SetAwake(!0),this.m_linearVelocity.Copy(e))},n.GetLinearVelocity=function(){return this.m_linearVelocity},n.SetAngularVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(e*e>0&&this.SetAwake(!0),this.m_angularVelocity=e)},n.GetAngularVelocity=function(){return this.m_angularVelocity},n.GetDefinition=function(t){return t.type=this.GetType(),t.allowSleep=this.m_autoSleepFlag,t.angle=this.GetAngle(),t.angularDamping=this.m_angularDamping,t.gravityScale=this.m_gravityScale,t.angularVelocity=this.m_angularVelocity,t.fixedRotation=this.m_fixedRotationFlag,t.bullet=this.m_bulletFlag,t.awake=this.m_awakeFlag,t.linearDamping=this.m_linearDamping,t.linearVelocity.Copy(this.GetLinearVelocity()),t.position.Copy(this.GetPosition()),t.userData=this.GetUserData(),t},n.ApplyForce=function(e,i,n){void 0===n&&(n=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y,this.m_torque+=(i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x))},n.ApplyForceToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y))},n.ApplyTorque=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_torque+=e))},n.ApplyLinearImpulse=function(e,i,n){void 0===n&&(n=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y,this.m_angularVelocity+=this.m_invI*((i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x)))},n.ApplyLinearImpulseToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y))},n.ApplyAngularImpulse=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_angularVelocity+=this.m_invI*e))},n.GetMass=function(){return this.m_mass},n.GetInertia=function(){return this.m_I+this.m_mass*j.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter)},n.GetMassData=function(t){return t.mass=this.m_mass,t.I=this.m_I+this.m_mass*j.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter),t.center.Copy(this.m_sweep.localCenter),t},n.SetMassData=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type===t.b2BodyType.b2_dynamicBody){this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&!this.m_fixedRotationFlag&&(this.m_I=e.I-this.m_mass*j.DotVV(e.center,e.center),this.m_invI=1/this.m_I);var n=i.SetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e.center),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(this.m_sweep.c,n,j.s_t0),this.m_linearVelocity)}},n.ResetMassData=function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero(),this.m_type===t.b2BodyType.b2_staticBody||this.m_type===t.b2BodyType.b2_kinematicBody)return this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);for(var e=i.ResetMassData_s_localCenter.SetZero(),n=this.m_fixtureList;n;n=n.m_next)if(0!==n.m_density){var r=n.GetMassData(i.ResetMassData_s_massData);this.m_mass+=r.mass,e.x+=r.center.x*r.mass,e.y+=r.center.y*r.mass,this.m_I+=r.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.x*=this.m_invMass,e.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&!this.m_fixedRotationFlag?(this.m_I-=this.m_mass*j.DotVV(e,e),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var s=i.ResetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(this.m_sweep.c,s,j.s_t0),this.m_linearVelocity)},n.GetWorldPoint=function(t,e){return Q.MulXV(this.m_xf,t,e)},n.GetWorldVector=function(t,e){return J.MulRV(this.m_xf.q,t,e)},n.GetLocalPoint=function(t,e){return Q.MulTXV(this.m_xf,t,e)},n.GetLocalVector=function(t,e){return J.MulTRV(this.m_xf.q,t,e)},n.GetLinearVelocityFromWorldPoint=function(t,e){return j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(t,this.m_sweep.c,j.s_t0),e)},n.GetLinearVelocityFromLocalPoint=function(t,e){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t,e),e)},n.GetLinearDamping=function(){return this.m_linearDamping},n.SetLinearDamping=function(t){this.m_linearDamping=t},n.GetAngularDamping=function(){return this.m_angularDamping},n.SetAngularDamping=function(t){this.m_angularDamping=t},n.GetGravityScale=function(){return this.m_gravityScale},n.SetGravityScale=function(t){this.m_gravityScale=t},n.SetType=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type!==e){this.m_type=e,this.ResetMassData(),this.m_type===t.b2BodyType.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Copy(this.m_sweep.c),this.SynchronizeFixtures()),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var i=this.m_contactList;i;){var n=i;i=i.next,this.m_world.m_contactManager.Destroy(n.contact)}this.m_contactList=null;for(var r=this.m_fixtureList;r;r=r.m_next)r.TouchProxies()}},n.GetType=function(){return this.m_type},n.SetBullet=function(t){this.m_bulletFlag=t},n.IsBullet=function(){return this.m_bulletFlag},n.SetSleepingAllowed=function(t){this.m_autoSleepFlag=t,t||this.SetAwake(!0)},n.IsSleepingAllowed=function(){return this.m_autoSleepFlag},n.SetAwake=function(t){t?(this.m_awakeFlag=!0,this.m_sleepTime=0):(this.m_awakeFlag=!1,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)},n.IsAwake=function(){return this.m_awakeFlag},n.SetActive=function(t){if(this.m_world.IsLocked())throw new Error;if(t!==this.IsActive())if(this.m_activeFlag=t,t)for(var e=this.m_fixtureList;e;e=e.m_next)e.CreateProxies();else{for(var i=this.m_fixtureList;i;i=i.m_next)i.DestroyProxies();for(var n=this.m_contactList;n;){var r=n;n=n.next,this.m_world.m_contactManager.Destroy(r.contact)}this.m_contactList=null}},n.IsActive=function(){return this.m_activeFlag},n.SetFixedRotation=function(t){this.m_fixedRotationFlag!==t&&(this.m_fixedRotationFlag=t,this.m_angularVelocity=0,this.ResetMassData())},n.IsFixedRotation=function(){return this.m_fixedRotationFlag},n.GetFixtureList=function(){return this.m_fixtureList},n.GetJointList=function(){return this.m_jointList},n.GetContactList=function(){return this.m_contactList},n.GetNext=function(){return this.m_next},n.GetUserData=function(){return this.m_userData},n.SetUserData=function(t){this.m_userData=t},n.GetWorld=function(){return this.m_world},n.Dump=function(e){var i=this.m_islandIndex;e("{\n"),e(" const bd: b2BodyDef = new b2BodyDef();\n");var n="";switch(this.m_type){case t.b2BodyType.b2_staticBody:n="b2BodyType.b2_staticBody";break;case t.b2BodyType.b2_kinematicBody:n="b2BodyType.b2_kinematicBody";break;case t.b2BodyType.b2_dynamicBody:n="b2BodyType.b2_dynamicBody"}e(" bd.type = %s;\n",n),e(" bd.position.Set(%.15f, %.15f);\n",this.m_xf.p.x,this.m_xf.p.y),e(" bd.angle = %.15f;\n",this.m_sweep.a),e(" bd.linearVelocity.Set(%.15f, %.15f);\n",this.m_linearVelocity.x,this.m_linearVelocity.y),e(" bd.angularVelocity = %.15f;\n",this.m_angularVelocity),e(" bd.linearDamping = %.15f;\n",this.m_linearDamping),e(" bd.angularDamping = %.15f;\n",this.m_angularDamping),e(" bd.allowSleep = %s;\n",this.m_autoSleepFlag?"true":"false"),e(" bd.awake = %s;\n",this.m_awakeFlag?"true":"false"),e(" bd.fixedRotation = %s;\n",this.m_fixedRotationFlag?"true":"false"),e(" bd.bullet = %s;\n",this.m_bulletFlag?"true":"false"),e(" bd.active = %s;\n",this.m_activeFlag?"true":"false"),e(" bd.gravityScale = %.15f;\n",this.m_gravityScale),e("\n"),e(" bodies[%d] = this.m_world.CreateBody(bd);\n",this.m_islandIndex),e("\n");for(var r=this.m_fixtureList;r;r=r.m_next)e(" {\n"),r.Dump(e,i),e(" }\n");e("}\n")},n.SynchronizeFixtures=function(){var t=i.SynchronizeFixtures_s_xf1;t.q.SetAngle(this.m_sweep.a0),J.MulRV(t.q,this.m_sweep.localCenter,t.p),j.SubVV(this.m_sweep.c0,t.p,t.p);for(var e=j.SubVV(this.m_sweep.c,this.m_sweep.c0,i.SynchronizeFixtures_s_displacement),n=this.m_fixtureList;n;n=n.m_next)n.SynchronizeProxies(t,this.m_xf,e)},n.SynchronizeTransform=function(){this.m_xf.q.SetAngle(this.m_sweep.a),J.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),j.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},n.ShouldCollide=function(e){return(this.m_type!==t.b2BodyType.b2_staticBody||e.m_type!==t.b2BodyType.b2_staticBody)&&this.ShouldCollideConnected(e)},n.ShouldCollideConnected=function(t){for(var e=this.m_jointList;e;e=e.next)if(e.other===t&&!e.joint.m_collideConnected)return!1;return!0},n.Advance=function(t){this.m_sweep.Advance(t),this.m_sweep.c.Copy(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.m_xf.q.SetAngle(this.m_sweep.a),J.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),j.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},n.GetControllerList=function(){return this.m_controllerList},n.GetControllerCount=function(){return this.m_controllerCount},i}();Ri.CreateFixtureShapeDensity_s_def=new Ai,Ri.SetMassData_s_oldCenter=new j,Ri.ResetMassData_s_localCenter=new j,Ri.ResetMassData_s_oldCenter=new j,Ri.ResetMassData_s_massData=new pi,Ri.SynchronizeFixtures_s_xf1=new Q,Ri.SynchronizeFixtures_s_displacement=new j,(xi=t.b2JointType||(t.b2JointType={}))[xi.e_unknownJoint=0]="e_unknownJoint",xi[xi.e_revoluteJoint=1]="e_revoluteJoint",xi[xi.e_prismaticJoint=2]="e_prismaticJoint",xi[xi.e_distanceJoint=3]="e_distanceJoint",xi[xi.e_pulleyJoint=4]="e_pulleyJoint",xi[xi.e_mouseJoint=5]="e_mouseJoint",xi[xi.e_gearJoint=6]="e_gearJoint",xi[xi.e_wheelJoint=7]="e_wheelJoint",xi[xi.e_weldJoint=8]="e_weldJoint",xi[xi.e_frictionJoint=9]="e_frictionJoint",xi[xi.e_ropeJoint=10]="e_ropeJoint",xi[xi.e_motorJoint=11]="e_motorJoint",xi[xi.e_areaJoint=12]="e_areaJoint",(wi=t.b2LimitState||(t.b2LimitState={}))[wi.e_inactiveLimit=0]="e_inactiveLimit",wi[wi.e_atLowerLimit=1]="e_atLowerLimit",wi[wi.e_atUpperLimit=2]="e_atUpperLimit",wi[wi.e_equalLimits=3]="e_equalLimits";var Ii=function(){function t(){this.linear=new j,this.angularA=0,this.angularB=0}var e=t.prototype;return e.SetZero=function(){return this.linear.SetZero(),this.angularA=0,this.angularB=0,this},e.Set=function(t,e,i){return this.linear.Copy(t),this.angularA=e,this.angularB=i,this},t}(),Bi=function(){function t(t){this._other=null,this.prev=null,this.next=null,this.joint=t}return t.prototype.Reset=function(){this._other=null,this.prev=null,this.next=null},n(t,[{key:"other",get:function(){if(null===this._other)throw new Error;return this._other},set:function(t){if(null!==this._other)throw new Error;this._other=t}}]),t}(),Di=function(e){this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=e},Pi=function(){function i(i){this.m_type=t.b2JointType.e_unknownJoint,this.m_prev=null,this.m_next=null,this.m_edgeA=new Bi(this),this.m_edgeB=new Bi(this),this.m_index=0,this.m_islandFlag=!1,this.m_collideConnected=!1,this.m_userData=null,this.m_type=i.type,this.m_edgeA.other=i.bodyB,this.m_edgeB.other=i.bodyA,this.m_bodyA=i.bodyA,this.m_bodyB=i.bodyB,this.m_collideConnected=e(i.collideConnected,!1),this.m_userData=e(i.userData,null)}var n=i.prototype;return n.GetType=function(){return this.m_type},n.GetBodyA=function(){return this.m_bodyA},n.GetBodyB=function(){return this.m_bodyB},n.GetNext=function(){return this.m_next},n.GetUserData=function(){return this.m_userData},n.SetUserData=function(t){this.m_userData=t},n.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()},n.GetCollideConnected=function(){return this.m_collideConnected},n.Dump=function(t){t("// Dump is not supported for this joint type.\n")},n.ShiftOrigin=function(){},i}(),Oi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_distanceJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.length=1,i.frequencyHz=0,i.dampingRatio=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB),this.length=j.DistanceVV(i,n),this.frequencyHz=0,this.dampingRatio=0},i}(Di),Mi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_frequencyHz=0,n.m_dampingRatio=0,n.m_bias=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_gamma=0,n.m_impulse=0,n.m_length=0,n.m_indexA=0,n.m_indexB=0,n.m_u=new j,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_localAnchorA.Copy(i.localAnchorA),n.m_localAnchorB.Copy(i.localAnchorB),n.m_length=i.length,n}s(i,t);var n=i.prototype;return n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_impulse*this.m_u.x,e.y=t*this.m_impulse*this.m_u.y,e},n.GetReactionTorque=function(){return 0},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.SetLength=function(t){this.m_length=t},n.Length=function(){return this.m_length},n.SetFrequency=function(t){this.m_frequencyHz=t},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t},n.GetDampingRatio=function(){return this.m_dampingRatio},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2DistanceJointDef = new b2DistanceJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.length = %.15f;\n",this.m_length),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c,h=t.positions[this.m_indexB].a,u=t.velocities[this.m_indexB].v,c=t.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(n),d=this.m_qB.SetAngle(h);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),J.MulRV(_,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.MulRV(d,this.m_lalcB,this.m_rB),this.m_u.x=o.x+this.m_rB.x-e.x-this.m_rA.x,this.m_u.y=o.y+this.m_rB.y-e.y-this.m_rA.y;var f=this.m_u.Length();f>l?this.m_u.SelfMul(1/f):this.m_u.SetZero();var p=j.CrossVV(this.m_rA,this.m_u),m=j.CrossVV(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==g?1/g:0,this.m_frequencyHz>0){var y=f-this.m_length,v=2*a*this.m_frequencyHz,S=2*this.m_mass*this.m_dampingRatio*v,T=this.m_mass*v*v,A=t.step.dt;this.m_gamma=A*(S+A*T),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=y*A*T*this.m_gamma,g+=this.m_gamma,this.m_mass=0!==g?1/g:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var b=j.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);r.SelfMulSub(this.m_invMassA,b),s-=this.m_invIA*j.CrossVV(this.m_rA,b),u.SelfMulAdd(this.m_invMassB,b),c+=this.m_invIB*j.CrossVV(this.m_rB,b)}else this.m_impulse=0;t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].w=c},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=j.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),a=j.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=j.DotVV(this.m_u,j.SubVV(a,o,j.s_t0)),u=-this.m_mass*(h+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=u;var l=j.MulSV(u,this.m_u,i.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,l),n-=this.m_invIA*j.CrossVV(this.m_rA,l),r.SelfMulAdd(this.m_invMassB,l),s+=this.m_invIB*j.CrossVV(this.m_rB,l),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){if(this.m_frequencyHz>0)return!0;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s),h=J.MulRV(o,this.m_lalcA,this.m_rA),u=J.MulRV(a,this.m_lalcB,this.m_rB),c=this.m_u;c.x=r.x+u.x-e.x-h.x,c.y=r.y+u.y-e.y-h.y;var _=this.m_u.Normalize()-this.m_length;_=M(_,-.2,f);var d=-this.m_mass*_,p=j.MulSV(d,c,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,p),n-=this.m_invIA*j.CrossVV(h,p),r.SelfMulAdd(this.m_invMassB,p),s+=this.m_invIB*j.CrossVV(u,p),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,D(_)<l},i}(Pi);Mi.InitVelocityConstraints_s_P=new j,Mi.SolveVelocityConstraints_s_vpA=new j,Mi.SolveVelocityConstraints_s_vpB=new j,Mi.SolveVelocityConstraints_s_P=new j,Mi.SolvePositionConstraints_s_P=new j;var Li=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_areaJoint)||this).bodies=[],i.frequencyHz=0,i.dampingRatio=0,i}return s(i,e),i.prototype.AddBody=function(t){this.bodies.push(t),1===this.bodies.length?this.bodyA=t:2===this.bodies.length&&(this.bodyB=t)},i}(Di),Ni=function(t){function i(i){var n;(n=t.call(this,i)||this).m_frequencyHz=0,n.m_dampingRatio=0,n.m_impulse=0,n.m_targetArea=0,n.m_delta=new j,n.m_bodies=i.bodies,n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_targetLengths=x(i.bodies.length),n.m_normals=j.MakeArray(i.bodies.length),n.m_joints=[],n.m_deltas=j.MakeArray(i.bodies.length);var r=new Oi;r.frequencyHz=n.m_frequencyHz,r.dampingRatio=n.m_dampingRatio,n.m_targetArea=0;for(var s=0;s<n.m_bodies.length;++s){var o=n.m_bodies[s],a=n.m_bodies[(s+1)%n.m_bodies.length],h=o.GetWorldCenter(),u=a.GetWorldCenter();n.m_targetLengths[s]=j.DistanceVV(h,u),n.m_targetArea+=j.CrossVV(h,u),r.Initialize(o,a,h,u),n.m_joints[s]=o.GetWorld().CreateJoint(r)}return n.m_targetArea*=.5,n}s(i,t);var n=i.prototype;return n.GetAnchorA=function(t){return t},n.GetAnchorB=function(t){return t},n.GetReactionForce=function(t,e){return e},n.GetReactionTorque=function(){return 0},n.SetFrequency=function(t){this.m_frequencyHz=t;for(var e=0;e<this.m_joints.length;++e)this.m_joints[e].SetFrequency(t)},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t;for(var e=0;e<this.m_joints.length;++e)this.m_joints[e].SetDampingRatio(t)},n.GetDampingRatio=function(){return this.m_dampingRatio},n.Dump=function(t){t("Area joint dumping is not supported.\n")},n.InitVelocityConstraints=function(t){for(var e=0;e<this.m_bodies.length;++e){var i=this.m_bodies[(e+this.m_bodies.length-1)%this.m_bodies.length],n=this.m_bodies[(e+1)%this.m_bodies.length],r=t.positions[i.m_islandIndex].c,s=t.positions[n.m_islandIndex].c,o=this.m_deltas[e];j.SubVV(s,r,o)}if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;for(var a=0;a<this.m_bodies.length;++a){var h=this.m_bodies[a],u=t.velocities[h.m_islandIndex].v,l=this.m_deltas[a];u.x+=h.m_invMass*l.y*.5*this.m_impulse,u.y+=h.m_invMass*-l.x*.5*this.m_impulse}}else this.m_impulse=0},n.SolveVelocityConstraints=function(t){for(var e=0,i=0,n=0;n<this.m_bodies.length;++n){var r=this.m_bodies[n],s=t.velocities[r.m_islandIndex].v,o=this.m_deltas[n];e+=o.LengthSquared()/r.GetMass(),i+=j.CrossVV(s,o)}var a=-2*i/e;this.m_impulse+=a;for(var h=0;h<this.m_bodies.length;++h){var u=this.m_bodies[h],l=t.velocities[u.m_islandIndex].v,c=this.m_deltas[h];l.x+=u.m_invMass*c.y*.5*a,l.y+=u.m_invMass*-c.x*.5*a}},n.SolvePositionConstraints=function(t){for(var e=0,i=0,n=0;n<this.m_bodies.length;++n){var s=this.m_bodies[n],o=this.m_bodies[(n+1)%this.m_bodies.length],a=t.positions[s.m_islandIndex].c,h=t.positions[o.m_islandIndex].c,u=j.SubVV(h,a,this.m_delta),c=u.Length();c<r&&(c=1),this.m_normals[n].x=u.y/c,this.m_normals[n].y=-u.x/c,e+=c,i+=j.CrossVV(a,h)}i*=.5;for(var _=.5*(this.m_targetArea-i)/e,d=!0,p=0;p<this.m_bodies.length;++p){var m=this.m_bodies[p],g=t.positions[m.m_islandIndex].c,y=(p+1)%this.m_bodies.length,v=j.AddVV(this.m_normals[p],this.m_normals[y],this.m_delta);v.SelfMul(_);var S=v.LengthSquared();S>N(f)&&v.SelfMul(f/k(S)),S>N(l)&&(d=!1),g.x+=v.x,g.y+=v.y}return d},i}(Pi),Fi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_frictionJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.maxForce=0,i.maxTorque=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB)},i}(Di),ki=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_linearImpulse=new j,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_indexA=0,n.m_indexB=0,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new Y,n.m_angularMass=0,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_K=new Y,n.m_localAnchorA.Copy(i.localAnchorA),n.m_localAnchorB.Copy(i.localAnchorB),n.m_linearImpulse.SetZero(),n.m_maxForce=e(i.maxForce,0),n.m_maxTorque=e(i.maxTorque,0),n.m_linearMass.SetZero(),n}s(i,t);var n=i.prototype;return n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.positions[this.m_indexB].a,s=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=this.m_qA.SetAngle(e),h=this.m_qB.SetAngle(r);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var u=J.MulRV(a,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var l=J.MulRV(h,this.m_lalcB,this.m_rB),c=this.m_invMassA,_=this.m_invMassB,d=this.m_invIA,f=this.m_invIB,p=this.m_K;if(p.ex.x=c+_+d*u.y*u.y+f*l.y*l.y,p.ex.y=-d*u.x*u.y-f*l.x*l.y,p.ey.x=p.ex.y,p.ey.y=c+_+d*u.x*u.x+f*l.x*l.x,p.GetInverse(this.m_linearMass),this.m_angularMass=d+f,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var m=this.m_linearImpulse;i.SelfMulSub(c,m),n-=d*(j.CrossVV(this.m_rA,m)+this.m_angularImpulse),s.SelfMulAdd(_,m),o+=f*(j.CrossVV(this.m_rB,m)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,h=this.m_invIA,u=this.m_invIB,l=t.step.dt,c=s-n,_=-this.m_angularMass*c,d=this.m_angularImpulse,f=l*this.m_maxTorque;this.m_angularImpulse=M(this.m_angularImpulse+_,-f,f),n-=h*(_=this.m_angularImpulse-d),s+=u*_;var p=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot_v2),m=Y.MulMV(this.m_linearMass,p,i.SolveVelocityConstraints_s_impulseV).SelfNeg(),g=i.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(m);var y=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>y*y&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(y)),j.SubVV(this.m_linearImpulse,g,m),e.SelfMulSub(o,m),n-=h*j.CrossVV(this.m_rA,m),r.SelfMulAdd(a,m),s+=u*j.CrossVV(this.m_rB,m),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(){return!0},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_linearImpulse.x,e.y=t*this.m_linearImpulse.y,e},n.GetReactionTorque=function(t){return t*this.m_angularImpulse},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetMaxTorque=function(t){this.m_maxTorque=t},n.GetMaxTorque=function(){return this.m_maxTorque},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2FrictionJointDef = new b2FrictionJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);ki.SolveVelocityConstraints_s_Cdot_v2=new j,ki.SolveVelocityConstraints_s_impulseV=new j,ki.SolveVelocityConstraints_s_oldImpulseV=new j;var Vi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_gearJoint)||this).ratio=1,i}return s(i,e),i}(Di),Gi=function(i){function n(n){var r,s,o;(r=i.call(this,n)||this).m_typeA=t.b2JointType.e_unknownJoint,r.m_typeB=t.b2JointType.e_unknownJoint,r.m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_localAnchorC=new j,r.m_localAnchorD=new j,r.m_localAxisC=new j,r.m_localAxisD=new j,r.m_referenceAngleA=0,r.m_referenceAngleB=0,r.m_constant=0,r.m_ratio=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_indexC=0,r.m_indexD=0,r.m_lcA=new j,r.m_lcB=new j,r.m_lcC=new j,r.m_lcD=new j,r.m_mA=0,r.m_mB=0,r.m_mC=0,r.m_mD=0,r.m_iA=0,r.m_iB=0,r.m_iC=0,r.m_iD=0,r.m_JvAC=new j,r.m_JvBD=new j,r.m_JwA=0,r.m_JwB=0,r.m_JwC=0,r.m_JwD=0,r.m_mass=0,r.m_qA=new J,r.m_qB=new J,r.m_qC=new J,r.m_qD=new J,r.m_lalcA=new j,r.m_lalcB=new j,r.m_lalcC=new j,r.m_lalcD=new j,r.m_joint1=n.joint1,r.m_joint2=n.joint2,r.m_typeA=r.m_joint1.GetType(),r.m_typeB=r.m_joint2.GetType(),r.m_bodyC=r.m_joint1.GetBodyA(),r.m_bodyA=r.m_joint1.GetBodyB();var a=r.m_bodyA.m_xf,h=r.m_bodyA.m_sweep.a,u=r.m_bodyC.m_xf,l=r.m_bodyC.m_sweep.a;if(r.m_typeA===t.b2JointType.e_revoluteJoint){var c=n.joint1;r.m_localAnchorC.Copy(c.m_localAnchorA),r.m_localAnchorA.Copy(c.m_localAnchorB),r.m_referenceAngleA=c.m_referenceAngle,r.m_localAxisC.SetZero(),s=h-l-r.m_referenceAngleA}else{var _=n.joint1;r.m_localAnchorC.Copy(_.m_localAnchorA),r.m_localAnchorA.Copy(_.m_localAnchorB),r.m_referenceAngleA=_.m_referenceAngle,r.m_localAxisC.Copy(_.m_localXAxisA);var d=r.m_localAnchorC,f=J.MulTRV(u.q,j.AddVV(J.MulRV(a.q,r.m_localAnchorA,j.s_t0),j.SubVV(a.p,u.p,j.s_t1),j.s_t0),j.s_t0);s=j.DotVV(j.SubVV(f,d,j.s_t0),r.m_localAxisC)}r.m_bodyD=r.m_joint2.GetBodyA(),r.m_bodyB=r.m_joint2.GetBodyB();var p=r.m_bodyB.m_xf,m=r.m_bodyB.m_sweep.a,g=r.m_bodyD.m_xf,y=r.m_bodyD.m_sweep.a;if(r.m_typeB===t.b2JointType.e_revoluteJoint){var v=n.joint2;r.m_localAnchorD.Copy(v.m_localAnchorA),r.m_localAnchorB.Copy(v.m_localAnchorB),r.m_referenceAngleB=v.m_referenceAngle,r.m_localAxisD.SetZero(),o=m-y-r.m_referenceAngleB}else{var S=n.joint2;r.m_localAnchorD.Copy(S.m_localAnchorA),r.m_localAnchorB.Copy(S.m_localAnchorB),r.m_referenceAngleB=S.m_referenceAngle,r.m_localAxisD.Copy(S.m_localXAxisA);var T=r.m_localAnchorD,A=J.MulTRV(g.q,j.AddVV(J.MulRV(p.q,r.m_localAnchorB,j.s_t0),j.SubVV(p.p,g.p,j.s_t1),j.s_t0),j.s_t0);o=j.DotVV(j.SubVV(A,T,j.s_t0),r.m_localAxisD)}return r.m_ratio=e(n.ratio,1),r.m_constant=s+r.m_ratio*o,r.m_impulse=0,r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_indexC=this.m_bodyC.m_islandIndex,this.m_indexD=this.m_bodyD.m_islandIndex,this.m_lcA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_lcB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_lcC.Copy(this.m_bodyC.m_sweep.localCenter),this.m_lcD.Copy(this.m_bodyD.m_sweep.localCenter),this.m_mA=this.m_bodyA.m_invMass,this.m_mB=this.m_bodyB.m_invMass,this.m_mC=this.m_bodyC.m_invMass,this.m_mD=this.m_bodyD.m_invMass,this.m_iA=this.m_bodyA.m_invI,this.m_iB=this.m_bodyB.m_invI,this.m_iC=this.m_bodyC.m_invI,this.m_iD=this.m_bodyD.m_invI;var i=e.positions[this.m_indexA].a,r=e.velocities[this.m_indexA].v,s=e.velocities[this.m_indexA].w,o=e.positions[this.m_indexB].a,a=e.velocities[this.m_indexB].v,h=e.velocities[this.m_indexB].w,u=e.positions[this.m_indexC].a,l=e.velocities[this.m_indexC].v,c=e.velocities[this.m_indexC].w,_=e.positions[this.m_indexD].a,d=e.velocities[this.m_indexD].v,f=e.velocities[this.m_indexD].w,p=this.m_qA.SetAngle(i),m=this.m_qB.SetAngle(o),g=this.m_qC.SetAngle(u),y=this.m_qD.SetAngle(_);if(this.m_mass=0,this.m_typeA===t.b2JointType.e_revoluteJoint)this.m_JvAC.SetZero(),this.m_JwA=1,this.m_JwC=1,this.m_mass+=this.m_iA+this.m_iC;else{var v=J.MulRV(g,this.m_localAxisC,n.InitVelocityConstraints_s_u);j.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var S=J.MulRV(g,this.m_lalcC,n.InitVelocityConstraints_s_rC);j.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var T=J.MulRV(p,this.m_lalcA,n.InitVelocityConstraints_s_rA);this.m_JvAC.Copy(v),this.m_JwC=j.CrossVV(S,v),this.m_JwA=j.CrossVV(T,v),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_typeB===t.b2JointType.e_revoluteJoint)this.m_JvBD.SetZero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{var A=J.MulRV(y,this.m_localAxisD,n.InitVelocityConstraints_s_u);j.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var b=J.MulRV(y,this.m_lalcD,n.InitVelocityConstraints_s_rD);j.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var E=J.MulRV(m,this.m_lalcB,n.InitVelocityConstraints_s_rB);j.MulSV(this.m_ratio,A,this.m_JvBD),this.m_JwD=this.m_ratio*j.CrossVV(b,A),this.m_JwB=this.m_ratio*j.CrossVV(E,A),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0,e.step.warmStarting?(r.SelfMulAdd(this.m_mA*this.m_impulse,this.m_JvAC),s+=this.m_iA*this.m_impulse*this.m_JwA,a.SelfMulAdd(this.m_mB*this.m_impulse,this.m_JvBD),h+=this.m_iB*this.m_impulse*this.m_JwB,l.SelfMulSub(this.m_mC*this.m_impulse,this.m_JvAC),c-=this.m_iC*this.m_impulse*this.m_JwC,d.SelfMulSub(this.m_mD*this.m_impulse,this.m_JvBD),f-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0,e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=h,e.velocities[this.m_indexC].w=c,e.velocities[this.m_indexD].w=f},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,r=t.velocities[this.m_indexB].w,s=t.velocities[this.m_indexC].v,o=t.velocities[this.m_indexC].w,a=t.velocities[this.m_indexD].v,h=t.velocities[this.m_indexD].w,u=j.DotVV(this.m_JvAC,j.SubVV(e,s,j.s_t0))+j.DotVV(this.m_JvBD,j.SubVV(n,a,j.s_t0));u+=this.m_JwA*i-this.m_JwC*o+(this.m_JwB*r-this.m_JwD*h);var l=-this.m_mass*u;this.m_impulse+=l,e.SelfMulAdd(this.m_mA*l,this.m_JvAC),i+=this.m_iA*l*this.m_JwA,n.SelfMulAdd(this.m_mB*l,this.m_JvBD),r+=this.m_iB*l*this.m_JwB,s.SelfMulSub(this.m_mC*l,this.m_JvAC),o-=this.m_iC*l*this.m_JwC,a.SelfMulSub(this.m_mD*l,this.m_JvBD),h-=this.m_iD*l*this.m_JwD,t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=r,t.velocities[this.m_indexC].w=o,t.velocities[this.m_indexD].w=h},r.SolvePositionConstraints=function(e){var i,r,s,o,a,h,u=e.positions[this.m_indexA].c,l=e.positions[this.m_indexA].a,c=e.positions[this.m_indexB].c,_=e.positions[this.m_indexB].a,d=e.positions[this.m_indexC].c,f=e.positions[this.m_indexC].a,p=e.positions[this.m_indexD].c,m=e.positions[this.m_indexD].a,g=this.m_qA.SetAngle(l),y=this.m_qB.SetAngle(_),v=this.m_qC.SetAngle(f),S=this.m_qD.SetAngle(m),T=this.m_JvAC,A=this.m_JvBD,b=0;if(this.m_typeA===t.b2JointType.e_revoluteJoint)T.SetZero(),s=1,a=1,b+=this.m_iA+this.m_iC,i=l-f-this.m_referenceAngleA;else{var E=J.MulRV(v,this.m_localAxisC,n.SolvePositionConstraints_s_u),C=J.MulRV(v,this.m_lalcC,n.SolvePositionConstraints_s_rC),w=J.MulRV(g,this.m_lalcA,n.SolvePositionConstraints_s_rA);T.Copy(E),a=j.CrossVV(C,E),s=j.CrossVV(w,E),b+=this.m_mC+this.m_mA+this.m_iC*a*a+this.m_iA*s*s;var x=this.m_lalcC,R=J.MulTRV(v,j.AddVV(w,j.SubVV(u,d,j.s_t0),j.s_t0),j.s_t0);i=j.DotVV(j.SubVV(R,x,j.s_t0),this.m_localAxisC)}if(this.m_typeB===t.b2JointType.e_revoluteJoint)A.SetZero(),o=this.m_ratio,h=this.m_ratio,b+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),r=_-m-this.m_referenceAngleB;else{var I=J.MulRV(S,this.m_localAxisD,n.SolvePositionConstraints_s_u),B=J.MulRV(S,this.m_lalcD,n.SolvePositionConstraints_s_rD),D=J.MulRV(y,this.m_lalcB,n.SolvePositionConstraints_s_rB);j.MulSV(this.m_ratio,I,A),h=this.m_ratio*j.CrossVV(B,I),o=this.m_ratio*j.CrossVV(D,I),b+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*h*h+this.m_iB*o*o;var P=this.m_lalcD,O=J.MulTRV(S,j.AddVV(D,j.SubVV(c,p,j.s_t0),j.s_t0),j.s_t0);r=j.DotVV(j.SubVV(O,P,j.s_t0),this.m_localAxisD)}var M=i+this.m_ratio*r-this.m_constant,L=0;return b>0&&(L=-M/b),u.SelfMulAdd(this.m_mA*L,T),l+=this.m_iA*L*s,c.SelfMulAdd(this.m_mB*L,A),_+=this.m_iB*L*o,d.SelfMulSub(this.m_mC*L,T),f-=this.m_iC*L*a,p.SelfMulSub(this.m_mD*L,A),m-=this.m_iD*L*h,e.positions[this.m_indexA].a=l,e.positions[this.m_indexB].a=_,e.positions[this.m_indexC].a=f,e.positions[this.m_indexD].a=m,!0},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return j.MulSV(t*this.m_impulse,this.m_JvAC,e)},r.GetReactionTorque=function(t){return t*this.m_impulse*this.m_JwA},r.GetJoint1=function(){return this.m_joint1},r.GetJoint2=function(){return this.m_joint2},r.GetRatio=function(){return this.m_ratio},r.SetRatio=function(t){this.m_ratio=t},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex,n=this.m_joint1.m_index,r=this.m_joint2.m_index;t(" const jd: b2GearJointDef = new b2GearJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.joint1 = joints[%d];\n",n),t(" jd.joint2 = joints[%d];\n",r),t(" jd.ratio = %.15f;\n",this.m_ratio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(Pi);Gi.InitVelocityConstraints_s_u=new j,Gi.InitVelocityConstraints_s_rA=new j,Gi.InitVelocityConstraints_s_rB=new j,Gi.InitVelocityConstraints_s_rC=new j,Gi.InitVelocityConstraints_s_rD=new j,Gi.SolvePositionConstraints_s_u=new j,Gi.SolvePositionConstraints_s_rA=new j,Gi.SolvePositionConstraints_s_rB=new j,Gi.SolvePositionConstraints_s_rC=new j,Gi.SolvePositionConstraints_s_rD=new j;var Ui=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_motorJoint)||this).linearOffset=new j(0,0),i.angularOffset=0,i.maxForce=1,i.maxTorque=1,i.correctionFactor=.3,i}return s(i,e),i.prototype.Initialize=function(t,e){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(this.bodyB.GetPosition(),this.linearOffset);var i=this.bodyA.GetAngle(),n=this.bodyB.GetAngle();this.angularOffset=n-i},i}(Di),zi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_linearOffset=new j,n.m_angularOffset=0,n.m_linearImpulse=new j,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_correctionFactor=.3,n.m_indexA=0,n.m_indexB=0,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_linearError=new j,n.m_angularError=0,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new Y,n.m_angularMass=0,n.m_qA=new J,n.m_qB=new J,n.m_K=new Y,n.m_linearOffset.Copy(e(i.linearOffset,j.ZERO)),n.m_linearImpulse.SetZero(),n.m_maxForce=e(i.maxForce,0),n.m_maxTorque=e(i.maxTorque,0),n.m_correctionFactor=e(i.correctionFactor,.3),n}s(i,t);var n=i.prototype;return n.GetAnchorA=function(t){var e=this.m_bodyA.GetPosition();return t.x=e.x,t.y=e.y,t},n.GetAnchorB=function(t){var e=this.m_bodyB.GetPosition();return t.x=e.x,t.y=e.y,t},n.GetReactionForce=function(t,e){return j.MulSV(t,this.m_linearImpulse,e)},n.GetReactionTorque=function(t){return t*this.m_angularImpulse},n.SetLinearOffset=function(t){j.IsEqualToV(t,this.m_linearOffset)||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_linearOffset.Copy(t))},n.GetLinearOffset=function(){return this.m_linearOffset},n.SetAngularOffset=function(t){t!==this.m_angularOffset&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_angularOffset=t)},n.GetAngularOffset=function(){return this.m_angularOffset},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetMaxTorque=function(t){this.m_maxTorque=t},n.GetMaxTorque=function(){return this.m_maxTorque},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,a=t.velocities[this.m_indexB].v,h=t.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(i),l=this.m_qB.SetAngle(o),c=J.MulRV(u,j.SubVV(this.m_linearOffset,this.m_localCenterA,j.s_t0),this.m_rA),_=J.MulRV(l,j.NegV(this.m_localCenterB,j.s_t0),this.m_rB),d=this.m_invMassA,f=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=this.m_K;if(g.ex.x=d+f+p*c.y*c.y+m*_.y*_.y,g.ex.y=-p*c.x*c.y-m*_.x*_.y,g.ey.x=g.ex.y,g.ey.y=d+f+p*c.x*c.x+m*_.x*_.x,g.GetInverse(this.m_linearMass),this.m_angularMass=p+m,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),j.SubVV(j.AddVV(s,_,j.s_t0),j.AddVV(e,c,j.s_t1),this.m_linearError),this.m_angularError=o-i-this.m_angularOffset,t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var y=this.m_linearImpulse;n.SelfMulSub(d,y),r-=p*(j.CrossVV(c,y)+this.m_angularImpulse),a.SelfMulAdd(f,y),h+=m*(j.CrossVV(_,y)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=h},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,h=this.m_invIA,u=this.m_invIB,l=t.step.dt,c=t.step.inv_dt,_=s-n+c*this.m_correctionFactor*this.m_angularError,d=-this.m_angularMass*_,f=this.m_angularImpulse,p=l*this.m_maxTorque;this.m_angularImpulse=M(this.m_angularImpulse+d,-p,p),n-=h*(d=this.m_angularImpulse-f),s+=u*d;var m=this.m_rA,g=this.m_rB,y=j.AddVV(j.SubVV(j.AddVV(r,j.CrossSV(s,g,j.s_t0),j.s_t0),j.AddVV(e,j.CrossSV(n,m,j.s_t1),j.s_t1),j.s_t2),j.MulSV(c*this.m_correctionFactor,this.m_linearError,j.s_t3),i.SolveVelocityConstraints_s_Cdot_v2),v=Y.MulMV(this.m_linearMass,y,i.SolveVelocityConstraints_s_impulse_v2).SelfNeg(),S=i.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(v);var T=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>T*T&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(T)),j.SubVV(this.m_linearImpulse,S,v),e.SelfMulSub(o,v),n-=h*j.CrossVV(m,v),r.SelfMulAdd(a,v),s+=u*j.CrossVV(g,v),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(){return!0},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2MotorJointDef = new b2MotorJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.linearOffset.Set(%.15f, %.15f);\n",this.m_linearOffset.x,this.m_linearOffset.y),t(" jd.angularOffset = %.15f;\n",this.m_angularOffset),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" jd.correctionFactor = %.15f;\n",this.m_correctionFactor),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);zi.SolveVelocityConstraints_s_Cdot_v2=new j,zi.SolveVelocityConstraints_s_impulse_v2=new j,zi.SolveVelocityConstraints_s_oldImpulse_v2=new j;var Hi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_mouseJoint)||this).target=new j,i.maxForce=0,i.frequencyHz=5,i.dampingRatio=.7,i}return s(i,e),i}(Di),Wi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_localAnchorB=new j,n.m_targetA=new j,n.m_frequencyHz=0,n.m_dampingRatio=0,n.m_beta=0,n.m_impulse=new j,n.m_maxForce=0,n.m_gamma=0,n.m_indexA=0,n.m_indexB=0,n.m_rB=new j,n.m_localCenterB=new j,n.m_invMassB=0,n.m_invIB=0,n.m_mass=new Y,n.m_C=new j,n.m_qB=new J,n.m_lalcB=new j,n.m_K=new Y,n.m_targetA.Copy(e(i.target,j.ZERO)),Q.MulTXV(n.m_bodyB.GetTransform(),n.m_targetA,n.m_localAnchorB),n.m_maxForce=e(i.maxForce,0),n.m_impulse.SetZero(),n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_beta=0,n.m_gamma=0,n}s(i,t);var n=i.prototype;return n.SetTarget=function(t){this.m_bodyB.IsAwake()||this.m_bodyB.SetAwake(!0),this.m_targetA.Copy(t)},n.GetTarget=function(){return this.m_targetA},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetFrequency=function(t){this.m_frequencyHz=t},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t},n.GetDampingRatio=function(){return this.m_dampingRatio},n.InitVelocityConstraints=function(t){this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexB].c,i=t.positions[this.m_indexB].a,n=t.velocities[this.m_indexB].v,r=t.velocities[this.m_indexB].w,s=this.m_qB.SetAngle(i),o=this.m_bodyB.GetMass(),h=2*a*this.m_frequencyHz,u=2*o*this.m_dampingRatio*h,l=o*h*h,c=t.step.dt;this.m_gamma=c*(u+c*l),0!==this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=c*l*this.m_gamma,j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.MulRV(s,this.m_lalcB,this.m_rB);var _=this.m_K;_.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,_.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,_.ey.x=_.ex.y,_.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,_.GetInverse(this.m_mass),this.m_C.x=e.x+this.m_rB.x-this.m_targetA.x,this.m_C.y=e.y+this.m_rB.y-this.m_targetA.y,this.m_C.SelfMul(this.m_beta),r*=.98,t.step.warmStarting?(this.m_impulse.SelfMul(t.step.dtRatio),n.x+=this.m_invMassB*this.m_impulse.x,n.y+=this.m_invMassB*this.m_impulse.y,r+=this.m_invIB*j.CrossVV(this.m_rB,this.m_impulse)):this.m_impulse.SetZero(),t.velocities[this.m_indexB].w=r},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexB].v,n=t.velocities[this.m_indexB].w,r=j.AddVCrossSV(e,n,this.m_rB,i.SolveVelocityConstraints_s_Cdot),s=Y.MulMV(this.m_mass,j.AddVV(r,j.AddVV(this.m_C,j.MulSV(this.m_gamma,this.m_impulse,j.s_t0),j.s_t0),j.s_t0).SelfNeg(),i.SolveVelocityConstraints_s_impulse),o=i.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse);this.m_impulse.SelfAdd(s);var a=t.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>a*a&&this.m_impulse.SelfMul(a/this.m_impulse.Length()),j.SubVV(this.m_impulse,o,s),e.SelfMulAdd(this.m_invMassB,s),n+=this.m_invIB*j.CrossVV(this.m_rB,s),t.velocities[this.m_indexB].w=n},n.SolvePositionConstraints=function(){return!0},n.GetAnchorA=function(t){return t.x=this.m_targetA.x,t.y=this.m_targetA.y,t},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return j.MulSV(t,this.m_impulse,e)},n.GetReactionTorque=function(){return 0},n.Dump=function(t){t("Mouse joint dumping is not supported.\n")},n.ShiftOrigin=function(t){this.m_targetA.SelfSub(t)},i}(Pi);Wi.SolveVelocityConstraints_s_Cdot=new j,Wi.SolveVelocityConstraints_s_impulse=new j,Wi.SolveVelocityConstraints_s_oldImpulse=new j;var ji=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_prismaticJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.localAxisA=new j(1,0),i.referenceAngle=0,i.enableLimit=!1,i.lowerTranslation=0,i.upperTranslation=0,i.enableMotor=!1,i.maxMotorForce=0,i.motorSpeed=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(n,this.localAxisA),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i}(Di),Xi=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_localXAxisA=new j,r.m_localYAxisA=new j,r.m_referenceAngle=0,r.m_impulse=new q(0,0,0),r.m_motorImpulse=0,r.m_lowerTranslation=0,r.m_upperTranslation=0,r.m_maxMotorForce=0,r.m_motorSpeed=0,r.m_enableLimit=!1,r.m_enableMotor=!1,r.m_limitState=t.b2LimitState.e_inactiveLimit,r.m_indexA=0,r.m_indexB=0,r.m_localCenterA=new j,r.m_localCenterB=new j,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_axis=new j(0,0),r.m_perp=new j(0,0),r.m_s1=0,r.m_s2=0,r.m_a1=0,r.m_a2=0,r.m_K=new K,r.m_K3=new K,r.m_K2=new Y,r.m_motorMass=0,r.m_qA=new J,r.m_qB=new J,r.m_lalcA=new j,r.m_lalcB=new j,r.m_rA=new j,r.m_rB=new j,r.m_localAnchorA.Copy(e(n.localAnchorA,j.ZERO)),r.m_localAnchorB.Copy(e(n.localAnchorB,j.ZERO)),r.m_localXAxisA.Copy(e(n.localAxisA,new j(1,0))).SelfNormalize(),j.CrossOneV(r.m_localXAxisA,r.m_localYAxisA),r.m_referenceAngle=e(n.referenceAngle,0),r.m_lowerTranslation=e(n.lowerTranslation,0),r.m_upperTranslation=e(n.upperTranslation,0),r.m_maxMotorForce=e(n.maxMotorForce,0),r.m_motorSpeed=e(n.motorSpeed,0),r.m_enableLimit=e(n.enableLimit,!1),r.m_enableMotor=e(n.enableMotor,!1),r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,o=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].c,h=e.positions[this.m_indexB].a,u=e.velocities[this.m_indexB].v,l=e.velocities[this.m_indexB].w,c=this.m_qA.SetAngle(r),_=this.m_qB.SetAngle(h);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var d=J.MulRV(c,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var f=J.MulRV(_,this.m_lalcB,this.m_rB),p=j.AddVV(j.SubVV(a,i,j.s_t0),j.SubVV(f,d,j.s_t1),n.InitVelocityConstraints_s_d),m=this.m_invMassA,g=this.m_invMassB,y=this.m_invIA,v=this.m_invIB;if(J.MulRV(c,this.m_localXAxisA,this.m_axis),this.m_a1=j.CrossVV(j.AddVV(p,d,j.s_t0),this.m_axis),this.m_a2=j.CrossVV(f,this.m_axis),this.m_motorMass=m+g+y*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),J.MulRV(c,this.m_localYAxisA,this.m_perp),this.m_s1=j.CrossVV(j.AddVV(p,d,j.s_t0),this.m_perp),this.m_s2=j.CrossVV(f,this.m_perp),this.m_K.ex.x=m+g+y*this.m_s1*this.m_s1+v*this.m_s2*this.m_s2,this.m_K.ex.y=y*this.m_s1+v*this.m_s2,this.m_K.ex.z=y*this.m_s1*this.m_a1+v*this.m_s2*this.m_a2,this.m_K.ey.x=this.m_K.ex.y,this.m_K.ey.y=y+v,0===this.m_K.ey.y&&(this.m_K.ey.y=1),this.m_K.ey.z=y*this.m_a1+v*this.m_a2,this.m_K.ez.x=this.m_K.ex.z,this.m_K.ez.y=this.m_K.ey.z,this.m_K.ez.z=m+g+y*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_enableLimit){var S=j.DotVV(this.m_axis,p);D(this.m_upperTranslation-this.m_lowerTranslation)<.016?this.m_limitState=t.b2LimitState.e_equalLimits:S<=this.m_lowerTranslation?this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_limitState=t.b2LimitState.e_atLowerLimit,this.m_impulse.z=0):S>=this.m_upperTranslation?this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_limitState=t.b2LimitState.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0;if(this.m_enableMotor||(this.m_motorImpulse=0),e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var T=j.AddVV(j.MulSV(this.m_impulse.x,this.m_perp,j.s_t0),j.MulSV(this.m_motorImpulse+this.m_impulse.z,this.m_axis,j.s_t1),n.InitVelocityConstraints_s_P),A=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,b=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;s.SelfMulSub(m,T),o-=y*A,u.SelfMulAdd(g,T),l+=v*b}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=o,e.velocities[this.m_indexB].w=l},r.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,o=e.velocities[this.m_indexB].w,a=this.m_invMassA,h=this.m_invMassB,u=this.m_invIA,l=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits){var c=j.DotVV(this.m_axis,j.SubVV(s,i,j.s_t0))+this.m_a2*o-this.m_a1*r,_=this.m_motorMass*(this.m_motorSpeed-c),d=this.m_motorImpulse,f=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=M(this.m_motorImpulse+_,-f,f),_=this.m_motorImpulse-d;var p=j.MulSV(_,this.m_axis,n.SolveVelocityConstraints_s_P),m=_*this.m_a1,g=_*this.m_a2;i.SelfMulSub(a,p),r-=u*m,s.SelfMulAdd(h,p),o+=l*g}var y=j.DotVV(this.m_perp,j.SubVV(s,i,j.s_t0))+this.m_s2*o-this.m_s1*r,v=o-r;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit){var S=j.DotVV(this.m_axis,j.SubVV(s,i,j.s_t0))+this.m_a2*o-this.m_a1*r,T=n.SolveVelocityConstraints_s_f1.Copy(this.m_impulse),A=this.m_K.Solve33(-y,-v,-S,n.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(A),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=O(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=P(this.m_impulse.z,0));var b=-y-(this.m_impulse.z-T.z)*this.m_K.ez.x,E=-v-(this.m_impulse.z-T.z)*this.m_K.ez.y,C=this.m_K.Solve22(b,E,n.SolveVelocityConstraints_s_f2r);C.x+=T.x,C.y+=T.y,this.m_impulse.x=C.x,this.m_impulse.y=C.y,A.x=this.m_impulse.x-T.x,A.y=this.m_impulse.y-T.y,A.z=this.m_impulse.z-T.z;var w=j.AddVV(j.MulSV(A.x,this.m_perp,j.s_t0),j.MulSV(A.z,this.m_axis,j.s_t1),n.SolveVelocityConstraints_s_P),x=A.x*this.m_s1+A.y+A.z*this.m_a1,R=A.x*this.m_s2+A.y+A.z*this.m_a2;i.SelfMulSub(a,w),r-=u*x,s.SelfMulAdd(h,w),o+=l*R}else{var I=this.m_K.Solve22(-y,-v,n.SolveVelocityConstraints_s_df2);this.m_impulse.x+=I.x,this.m_impulse.y+=I.y;var B=j.MulSV(I.x,this.m_perp,n.SolveVelocityConstraints_s_P),D=I.x*this.m_s1+I.y,L=I.x*this.m_s2+I.y;i.SelfMulSub(a,B),r-=u*D,s.SelfMulAdd(h,B),o+=l*L}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=o},r.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(i),a=this.m_qB.SetAngle(s),h=this.m_invMassA,u=this.m_invMassB,_=this.m_invIA,d=this.m_invIB,p=J.MulRV(o,this.m_lalcA,this.m_rA),m=J.MulRV(a,this.m_lalcB,this.m_rB),g=j.SubVV(j.AddVV(r,m,j.s_t0),j.AddVV(e,p,j.s_t1),n.SolvePositionConstraints_s_d),y=J.MulRV(o,this.m_localXAxisA,this.m_axis),v=j.CrossVV(j.AddVV(g,p,j.s_t0),y),S=j.CrossVV(m,y),T=J.MulRV(o,this.m_localYAxisA,this.m_perp),A=j.CrossVV(j.AddVV(g,p,j.s_t0),T),b=j.CrossVV(m,T),E=n.SolvePositionConstraints_s_impulse,C=j.DotVV(T,g),w=s-i-this.m_referenceAngle,x=D(C),R=D(w),I=!1,B=0;if(this.m_enableLimit){var P=j.DotVV(y,g);D(this.m_upperTranslation-this.m_lowerTranslation)<.016?(B=M(P,-.2,f),x=O(x,D(P)),I=!0):P<=this.m_lowerTranslation?(B=M(P-this.m_lowerTranslation+l,-.2,0),x=O(x,this.m_lowerTranslation-P),I=!0):P>=this.m_upperTranslation&&(B=M(P-this.m_upperTranslation-l,0,f),x=O(x,P-this.m_upperTranslation),I=!0)}if(I){var L=h+u+_*A*A+d*b*b,N=_*A+d*b,F=_*A*v+d*b*S,k=_+d;0===k&&(k=1);var V=_*v+d*S,G=h+u+_*v*v+d*S*S,U=this.m_K3;U.ex.SetXYZ(L,N,F),U.ey.SetXYZ(N,k,V),U.ez.SetXYZ(F,V,G),E=U.Solve33(-C,-w,-B,E)}else{var z=h+u+_*A*A+d*b*b,H=_*A+d*b,W=_+d;0===W&&(W=1);var X=this.m_K2;X.ex.Set(z,H),X.ey.Set(H,W);var q=X.Solve(-C,-w,n.SolvePositionConstraints_s_impulse1);E.x=q.x,E.y=q.y,E.z=0}var Y=j.AddVV(j.MulSV(E.x,T,j.s_t0),j.MulSV(E.z,y,j.s_t1),n.SolvePositionConstraints_s_P),K=E.x*A+E.y+E.z*v,Q=E.x*b+E.y+E.z*S;return e.SelfMulSub(h,Y),i-=_*K,r.SelfMulAdd(u,Y),s+=d*Q,t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,x<=l&&R<=c},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),e.y=t*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y),e},r.GetReactionTorque=function(t){return t*this.m_impulse.y},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.GetLocalAxisA=function(){return this.m_localXAxisA},r.GetReferenceAngle=function(){return this.m_referenceAngle},r.GetJointTranslation=function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,n.GetJointTranslation_s_pA),e=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,n.GetJointTranslation_s_pB),i=j.SubVV(e,t,n.GetJointTranslation_s_d),r=this.m_bodyA.GetWorldVector(this.m_localXAxisA,n.GetJointTranslation_s_axis);return j.DotVV(i,r)},r.GetJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;j.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=J.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=J.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=j.AddVV(t.m_sweep.c,i,j.s_t0),s=j.AddVV(e.m_sweep.c,n,j.s_t1),o=j.SubVV(s,r,j.s_t2),a=t.GetWorldVector(this.m_localXAxisA,this.m_axis),h=t.m_linearVelocity,u=e.m_linearVelocity,l=t.m_angularVelocity,c=e.m_angularVelocity;return j.DotVV(o,j.CrossSV(l,a,j.s_t0))+j.DotVV(a,j.SubVV(j.AddVCrossSV(u,c,n,j.s_t0),j.AddVCrossSV(h,l,i,j.s_t1),j.s_t0))},r.IsLimitEnabled=function(){return this.m_enableLimit},r.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},r.GetLowerLimit=function(){return this.m_lowerTranslation},r.GetUpperLimit=function(){return this.m_upperTranslation},r.SetLimits=function(t,e){t===this.m_lowerTranslation&&e===this.m_upperTranslation||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=e,this.m_impulse.z=0)},r.IsMotorEnabled=function(){return this.m_enableMotor},r.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},r.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},r.GetMotorSpeed=function(){return this.m_motorSpeed},r.SetMaxMotorForce=function(t){t!==this.m_maxMotorForce&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=t)},r.GetMaxMotorForce=function(){return this.m_maxMotorForce},r.GetMotorForce=function(t){return t*this.m_motorImpulse},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2PrismaticJointDef = new b2PrismaticJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerTranslation = %.15f;\n",this.m_lowerTranslation),t(" jd.upperTranslation = %.15f;\n",this.m_upperTranslation),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorForce = %.15f;\n",this.m_maxMotorForce),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(Pi);Xi.InitVelocityConstraints_s_d=new j,Xi.InitVelocityConstraints_s_P=new j,Xi.SolveVelocityConstraints_s_P=new j,Xi.SolveVelocityConstraints_s_f2r=new j,Xi.SolveVelocityConstraints_s_f1=new q,Xi.SolveVelocityConstraints_s_df3=new q,Xi.SolveVelocityConstraints_s_df2=new j,Xi.SolvePositionConstraints_s_d=new j,Xi.SolvePositionConstraints_s_impulse=new q,Xi.SolvePositionConstraints_s_impulse1=new j,Xi.SolvePositionConstraints_s_P=new j,Xi.GetJointTranslation_s_pA=new j,Xi.GetJointTranslation_s_pB=new j,Xi.GetJointTranslation_s_d=new j,Xi.GetJointTranslation_s_axis=new j;var qi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_pulleyJoint)||this).groundAnchorA=new j(-1,1),i.groundAnchorB=new j(1,1),i.localAnchorA=new j(-1,0),i.localAnchorB=new j(1,0),i.lengthA=0,i.lengthB=0,i.ratio=1,i.collideConnected=!0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n,r,s,o){this.bodyA=t,this.bodyB=e,this.groundAnchorA.Copy(i),this.groundAnchorB.Copy(n),this.bodyA.GetLocalPoint(r,this.localAnchorA),this.bodyB.GetLocalPoint(s,this.localAnchorB),this.lengthA=j.DistanceVV(r,i),this.lengthB=j.DistanceVV(s,n),this.ratio=o},i}(Di),Yi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_groundAnchorA=new j,n.m_groundAnchorB=new j,n.m_lengthA=0,n.m_lengthB=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_constant=0,n.m_ratio=0,n.m_impulse=0,n.m_indexA=0,n.m_indexB=0,n.m_uA=new j,n.m_uB=new j,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_groundAnchorA.Copy(e(i.groundAnchorA,new j(-1,1))),n.m_groundAnchorB.Copy(e(i.groundAnchorB,new j(1,0))),n.m_localAnchorA.Copy(e(i.localAnchorA,new j(-1,0))),n.m_localAnchorB.Copy(e(i.localAnchorB,new j(1,0))),n.m_lengthA=e(i.lengthA,0),n.m_lengthB=e(i.lengthB,0),n.m_ratio=e(i.ratio,1),n.m_constant=e(i.lengthA,0)+n.m_ratio*e(i.lengthB,0),n.m_impulse=0,n}s(i,t);var n=i.prototype;return n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c,a=t.positions[this.m_indexB].a,h=t.velocities[this.m_indexB].v,u=t.velocities[this.m_indexB].w,l=this.m_qA.SetAngle(n),c=this.m_qB.SetAngle(a);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),J.MulRV(l,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.MulRV(c,this.m_lalcB,this.m_rB),this.m_uA.Copy(e).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA),this.m_uB.Copy(o).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB);var _=this.m_uA.Length(),d=this.m_uB.Length();_>.08?this.m_uA.SelfMul(1/_):this.m_uA.SetZero(),d>.08?this.m_uB.SelfMul(1/d):this.m_uB.SetZero();var f=j.CrossVV(this.m_rA,this.m_uA),p=j.CrossVV(this.m_rB,this.m_uB),m=this.m_invMassA+this.m_invIA*f*f,g=this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=m+this.m_ratio*this.m_ratio*g,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var y=j.MulSV(-this.m_impulse,this.m_uA,i.InitVelocityConstraints_s_PA),v=j.MulSV(-this.m_ratio*this.m_impulse,this.m_uB,i.InitVelocityConstraints_s_PB);r.SelfMulAdd(this.m_invMassA,y),s+=this.m_invIA*j.CrossVV(this.m_rA,y),h.SelfMulAdd(this.m_invMassB,v),u+=this.m_invIB*j.CrossVV(this.m_rB,v)}else this.m_impulse=0;t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].w=u},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=j.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),a=j.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=-j.DotVV(this.m_uA,o)-this.m_ratio*j.DotVV(this.m_uB,a),u=-this.m_mass*h;this.m_impulse+=u;var l=j.MulSV(-u,this.m_uA,i.SolveVelocityConstraints_s_PA),c=j.MulSV(-this.m_ratio*u,this.m_uB,i.SolveVelocityConstraints_s_PB);e.SelfMulAdd(this.m_invMassA,l),n+=this.m_invIA*j.CrossVV(this.m_rA,l),r.SelfMulAdd(this.m_invMassB,c),s+=this.m_invIB*j.CrossVV(this.m_rB,c),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=J.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=J.MulRV(a,this.m_lalcB,this.m_rB),c=this.m_uA.Copy(e).SelfAdd(h).SelfSub(this.m_groundAnchorA),_=this.m_uB.Copy(r).SelfAdd(u).SelfSub(this.m_groundAnchorB),d=c.Length(),f=_.Length();d>.08?c.SelfMul(1/d):c.SetZero(),f>.08?_.SelfMul(1/f):_.SetZero();var p=j.CrossVV(h,c),m=j.CrossVV(u,_),g=this.m_invMassA+this.m_invIA*p*p,y=this.m_invMassB+this.m_invIB*m*m,v=g+this.m_ratio*this.m_ratio*y;v>0&&(v=1/v);var S=this.m_constant-d-this.m_ratio*f,T=D(S),A=-v*S,b=j.MulSV(-A,c,i.SolvePositionConstraints_s_PA),E=j.MulSV(-this.m_ratio*A,_,i.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,b),n+=this.m_invIA*j.CrossVV(h,b),r.SelfMulAdd(this.m_invMassB,E),s+=this.m_invIB*j.CrossVV(u,E),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,T<l},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_impulse*this.m_uB.x,e.y=t*this.m_impulse*this.m_uB.y,e},n.GetReactionTorque=function(){return 0},n.GetGroundAnchorA=function(){return this.m_groundAnchorA},n.GetGroundAnchorB=function(){return this.m_groundAnchorB},n.GetLengthA=function(){return this.m_lengthA},n.GetLengthB=function(){return this.m_lengthB},n.GetRatio=function(){return this.m_ratio},n.GetCurrentLengthA=function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,i.GetCurrentLengthA_s_p),e=this.m_groundAnchorA;return j.DistanceVV(t,e)},n.GetCurrentLengthB=function(){var t=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,i.GetCurrentLengthB_s_p),e=this.m_groundAnchorB;return j.DistanceVV(t,e)},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2PulleyJointDef = new b2PulleyJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.groundAnchorA.Set(%.15f, %.15f);\n",this.m_groundAnchorA.x,this.m_groundAnchorA.y),t(" jd.groundAnchorB.Set(%.15f, %.15f);\n",this.m_groundAnchorB.x,this.m_groundAnchorB.y),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.lengthA = %.15f;\n",this.m_lengthA),t(" jd.lengthB = %.15f;\n",this.m_lengthB),t(" jd.ratio = %.15f;\n",this.m_ratio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n.ShiftOrigin=function(t){this.m_groundAnchorA.SelfSub(t),this.m_groundAnchorB.SelfSub(t)},i}(Pi);Yi.InitVelocityConstraints_s_PA=new j,Yi.InitVelocityConstraints_s_PB=new j,Yi.SolveVelocityConstraints_s_vpA=new j,Yi.SolveVelocityConstraints_s_vpB=new j,Yi.SolveVelocityConstraints_s_PA=new j,Yi.SolveVelocityConstraints_s_PB=new j,Yi.SolvePositionConstraints_s_PA=new j,Yi.SolvePositionConstraints_s_PB=new j,Yi.GetCurrentLengthA_s_p=new j,Yi.GetCurrentLengthB_s_p=new j;var Ki=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_revoluteJoint)||this).localAnchorA=new j(0,0),i.localAnchorB=new j(0,0),i.referenceAngle=0,i.enableLimit=!1,i.lowerAngle=0,i.upperAngle=0,i.enableMotor=!1,i.motorSpeed=0,i.maxMotorTorque=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i}(Di),Ji=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_impulse=new q,r.m_motorImpulse=0,r.m_enableMotor=!1,r.m_maxMotorTorque=0,r.m_motorSpeed=0,r.m_enableLimit=!1,r.m_referenceAngle=0,r.m_lowerAngle=0,r.m_upperAngle=0,r.m_indexA=0,r.m_indexB=0,r.m_rA=new j,r.m_rB=new j,r.m_localCenterA=new j,r.m_localCenterB=new j,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_mass=new K,r.m_motorMass=0,r.m_limitState=t.b2LimitState.e_inactiveLimit,r.m_qA=new J,r.m_qB=new J,r.m_lalcA=new j,r.m_lalcB=new j,r.m_K=new Y,r.m_localAnchorA.Copy(e(n.localAnchorA,j.ZERO)),r.m_localAnchorB.Copy(e(n.localAnchorB,j.ZERO)),r.m_referenceAngle=e(n.referenceAngle,0),r.m_impulse.SetZero(),r.m_motorImpulse=0,r.m_lowerAngle=e(n.lowerAngle,0),r.m_upperAngle=e(n.upperAngle,0),r.m_maxMotorTorque=e(n.maxMotorTorque,0),r.m_motorSpeed=e(n.motorSpeed,0),r.m_enableLimit=e(n.enableLimit,!1),r.m_enableMotor=e(n.enableMotor,!1),r.m_limitState=t.b2LimitState.e_inactiveLimit,r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].a,r=e.velocities[this.m_indexA].v,s=e.velocities[this.m_indexA].w,o=e.positions[this.m_indexB].a,a=e.velocities[this.m_indexB].v,h=e.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(i),l=this.m_qB.SetAngle(o);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),J.MulRV(u,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.MulRV(l,this.m_lalcB,this.m_rB);var _=this.m_invMassA,d=this.m_invMassB,f=this.m_invIA,p=this.m_invIB,m=f+p===0;if(this.m_mass.ex.x=_+d+this.m_rA.y*this.m_rA.y*f+this.m_rB.y*this.m_rB.y*p,this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*f-this.m_rB.y*this.m_rB.x*p,this.m_mass.ez.x=-this.m_rA.y*f-this.m_rB.y*p,this.m_mass.ex.y=this.m_mass.ey.x,this.m_mass.ey.y=_+d+this.m_rA.x*this.m_rA.x*f+this.m_rB.x*this.m_rB.x*p,this.m_mass.ez.y=this.m_rA.x*f+this.m_rB.x*p,this.m_mass.ex.z=this.m_mass.ez.x,this.m_mass.ey.z=this.m_mass.ez.y,this.m_mass.ez.z=f+p,this.m_motorMass=f+p,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),this.m_enableMotor&&!m||(this.m_motorImpulse=0),this.m_enableLimit&&!m){var g=o-i-this.m_referenceAngle;D(this.m_upperAngle-this.m_lowerAngle)<2*c?this.m_limitState=t.b2LimitState.e_equalLimits:g<=this.m_lowerAngle?(this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atLowerLimit):g>=this.m_upperAngle?(this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atUpperLimit):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit;if(e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var y=n.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);r.SelfMulSub(_,y),s-=f*(j.CrossVV(this.m_rA,y)+this.m_motorImpulse+this.m_impulse.z),a.SelfMulAdd(d,y),h+=p*(j.CrossVV(this.m_rB,y)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=h},r.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,o=e.velocities[this.m_indexB].w,a=this.m_invMassA,h=this.m_invMassB,u=this.m_invIA,l=this.m_invIB,c=u+l===0;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits&&!c){var _=o-r-this.m_motorSpeed,d=-this.m_motorMass*_,f=this.m_motorImpulse,p=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=M(this.m_motorImpulse+d,-p,p),r-=u*(d=this.m_motorImpulse-f),o+=l*d}if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!c){var m=j.SubVV(j.AddVCrossSV(s,o,this.m_rB,j.s_t0),j.AddVCrossSV(i,r,this.m_rA,j.s_t1),n.SolveVelocityConstraints_s_Cdot1),g=o-r,y=this.m_mass.Solve33(m.x,m.y,g,n.SolveVelocityConstraints_s_impulse_v3).SelfNeg();if(this.m_limitState===t.b2LimitState.e_equalLimits)this.m_impulse.SelfAdd(y);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit)if(this.m_impulse.z+y.z<0){var v=-m.x+this.m_impulse.z*this.m_mass.ez.x,S=-m.y+this.m_impulse.z*this.m_mass.ez.y,T=this.m_mass.Solve22(v,S,n.SolveVelocityConstraints_s_reduced_v2);y.x=T.x,y.y=T.y,y.z=-this.m_impulse.z,this.m_impulse.x+=T.x,this.m_impulse.y+=T.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(y);else if(this.m_limitState===t.b2LimitState.e_atUpperLimit)if(this.m_impulse.z+y.z>0){var A=-m.x+this.m_impulse.z*this.m_mass.ez.x,b=-m.y+this.m_impulse.z*this.m_mass.ez.y,E=this.m_mass.Solve22(A,b,n.SolveVelocityConstraints_s_reduced_v2);y.x=E.x,y.y=E.y,y.z=-this.m_impulse.z,this.m_impulse.x+=E.x,this.m_impulse.y+=E.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(y);var C=n.SolveVelocityConstraints_s_P.Set(y.x,y.y);i.SelfMulSub(a,C),r-=u*(j.CrossVV(this.m_rA,C)+y.z),s.SelfMulAdd(h,C),o+=l*(j.CrossVV(this.m_rB,C)+y.z)}else{var w=j.SubVV(j.AddVCrossSV(s,o,this.m_rB,j.s_t0),j.AddVCrossSV(i,r,this.m_rA,j.s_t1),n.SolveVelocityConstraints_s_Cdot_v2),x=this.m_mass.Solve22(-w.x,-w.y,n.SolveVelocityConstraints_s_impulse_v2);this.m_impulse.x+=x.x,this.m_impulse.y+=x.y,i.SelfMulSub(a,x),r-=u*j.CrossVV(this.m_rA,x),s.SelfMulAdd(h,x),o+=l*j.CrossVV(this.m_rB,x)}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=o},r.SolvePositionConstraints=function(e){var i,r=e.positions[this.m_indexA].c,s=e.positions[this.m_indexA].a,o=e.positions[this.m_indexB].c,a=e.positions[this.m_indexB].a,h=this.m_qA.SetAngle(s),u=this.m_qB.SetAngle(a),_=0,d=this.m_invIA+this.m_invIB===0;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!d){var f=a-s-this.m_referenceAngle,m=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var g=M(f-this.m_lowerAngle,-.13962634015955555,p);m=-this.m_motorMass*g,_=D(g)}else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){var y=f-this.m_lowerAngle;_=-y,y=M(y+c,-.13962634015955555,0),m=-this.m_motorMass*y}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){var v=f-this.m_upperAngle;_=v,v=M(v-c,0,p),m=-this.m_motorMass*v}s-=this.m_invIA*m,a+=this.m_invIB*m}h.SetAngle(s),u.SetAngle(a),j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var S=J.MulRV(h,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var T=J.MulRV(u,this.m_lalcB,this.m_rB),A=j.SubVV(j.AddVV(o,T,j.s_t0),j.AddVV(r,S,j.s_t1),n.SolvePositionConstraints_s_C_v2);i=A.Length();var b=this.m_invMassA,E=this.m_invMassB,C=this.m_invIA,w=this.m_invIB,x=this.m_K;x.ex.x=b+E+C*S.y*S.y+w*T.y*T.y,x.ex.y=-C*S.x*S.y-w*T.x*T.y,x.ey.x=x.ex.y,x.ey.y=b+E+C*S.x*S.x+w*T.x*T.x;var R=x.Solve(A.x,A.y,n.SolvePositionConstraints_s_impulse).SelfNeg();return r.SelfMulSub(b,R),s-=C*j.CrossVV(S,R),o.SelfMulAdd(E,R),a+=w*j.CrossVV(T,R),e.positions[this.m_indexA].a=s,e.positions[this.m_indexB].a=a,i<=l&&_<=c},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e},r.GetReactionTorque=function(t){return t*this.m_impulse.z},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.GetReferenceAngle=function(){return this.m_referenceAngle},r.GetJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle},r.GetJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity},r.IsMotorEnabled=function(){return this.m_enableMotor},r.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},r.GetMotorTorque=function(t){return t*this.m_motorImpulse},r.GetMotorSpeed=function(){return this.m_motorSpeed},r.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},r.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},r.IsLimitEnabled=function(){return this.m_enableLimit},r.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},r.GetLowerLimit=function(){return this.m_lowerAngle},r.GetUpperLimit=function(){return this.m_upperAngle},r.SetLimits=function(t,e){t===this.m_lowerAngle&&e===this.m_upperAngle||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_impulse.z=0,this.m_lowerAngle=t,this.m_upperAngle=e)},r.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2RevoluteJointDef = new b2RevoluteJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerAngle = %.15f;\n",this.m_lowerAngle),t(" jd.upperAngle = %.15f;\n",this.m_upperAngle),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(Pi);Ji.InitVelocityConstraints_s_P=new j,Ji.SolveVelocityConstraints_s_P=new j,Ji.SolveVelocityConstraints_s_Cdot_v2=new j,Ji.SolveVelocityConstraints_s_Cdot1=new j,Ji.SolveVelocityConstraints_s_impulse_v3=new q,Ji.SolveVelocityConstraints_s_reduced_v2=new j,Ji.SolveVelocityConstraints_s_impulse_v2=new j,Ji.SolvePositionConstraints_s_C_v2=new j,Ji.SolvePositionConstraints_s_impulse=new j;var Qi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_ropeJoint)||this).localAnchorA=new j(-1,0),i.localAnchorB=new j(1,0),i.maxLength=0,i}return s(i,e),i}(Di),Zi=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_maxLength=0,r.m_length=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_u=new j,r.m_rA=new j,r.m_rB=new j,r.m_localCenterA=new j,r.m_localCenterB=new j,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_mass=0,r.m_state=t.b2LimitState.e_inactiveLimit,r.m_qA=new J,r.m_qB=new J,r.m_lalcA=new j,r.m_lalcB=new j,r.m_localAnchorA.Copy(e(n.localAnchorA,new j(-1,0))),r.m_localAnchorB.Copy(e(n.localAnchorB,new j(1,0))),r.m_maxLength=e(n.maxLength,0),r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,o=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].c,h=e.positions[this.m_indexB].a,u=e.velocities[this.m_indexB].v,c=e.velocities[this.m_indexB].w,_=this.m_qA.SetAngle(r),d=this.m_qB.SetAngle(h);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),J.MulRV(_,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.MulRV(d,this.m_lalcB,this.m_rB),this.m_u.Copy(a).SelfAdd(this.m_rB).SelfSub(i).SelfSub(this.m_rA),this.m_length=this.m_u.Length();var f=this.m_length-this.m_maxLength;if(this.m_state=f>0?t.b2LimitState.e_atUpperLimit:t.b2LimitState.e_inactiveLimit,!(this.m_length>l))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.SelfMul(1/this.m_length);var p=j.CrossVV(this.m_rA,this.m_u),m=j.CrossVV(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==g?1/g:0,e.step.warmStarting){this.m_impulse*=e.step.dtRatio;var y=j.MulSV(this.m_impulse,this.m_u,n.InitVelocityConstraints_s_P);s.SelfMulSub(this.m_invMassA,y),o-=this.m_invIA*j.CrossVV(this.m_rA,y),u.SelfMulAdd(this.m_invMassB,y),c+=this.m_invIB*j.CrossVV(this.m_rB,y)}else this.m_impulse=0;e.velocities[this.m_indexA].w=o,e.velocities[this.m_indexB].w=c},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=j.AddVCrossSV(e,i,this.m_rA,n.SolveVelocityConstraints_s_vpA),a=j.AddVCrossSV(r,s,this.m_rB,n.SolveVelocityConstraints_s_vpB),h=this.m_length-this.m_maxLength,u=j.DotVV(this.m_u,j.SubVV(a,o,j.s_t0));h<0&&(u+=t.step.inv_dt*h);var l=-this.m_mass*u,c=this.m_impulse;this.m_impulse=P(0,this.m_impulse+l),l=this.m_impulse-c;var _=j.MulSV(l,this.m_u,n.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,_),i-=this.m_invIA*j.CrossVV(this.m_rA,_),r.SelfMulAdd(this.m_invMassB,_),s+=this.m_invIB*j.CrossVV(this.m_rB,_),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=s},r.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(i),a=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=J.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=J.MulRV(a,this.m_lalcB,this.m_rB),c=this.m_u.Copy(r).SelfAdd(u).SelfSub(e).SelfSub(h),_=c.Normalize(),d=_-this.m_maxLength;d=M(d,0,f);var p=-this.m_mass*d,m=j.MulSV(p,c,n.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,m),i-=this.m_invIA*j.CrossVV(h,m),r.SelfMulAdd(this.m_invMassB,m),s+=this.m_invIB*j.CrossVV(u,m),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,_-this.m_maxLength<l},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return j.MulSV(t*this.m_impulse,this.m_u,e)},r.GetReactionTorque=function(){return 0},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.SetMaxLength=function(t){this.m_maxLength=t},r.GetMaxLength=function(){return this.m_maxLength},r.GetLimitState=function(){return this.m_state},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2RopeJointDef = new b2RopeJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxLength = %.15f;\n",this.m_maxLength),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(Pi);Zi.InitVelocityConstraints_s_P=new j,Zi.SolveVelocityConstraints_s_vpA=new j,Zi.SolveVelocityConstraints_s_vpB=new j,Zi.SolveVelocityConstraints_s_P=new j,Zi.SolvePositionConstraints_s_P=new j;var $i=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_weldJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.referenceAngle=0,i.frequencyHz=0,i.dampingRatio=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i}(Di),tn=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_frequencyHz=0,n.m_dampingRatio=0,n.m_bias=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_referenceAngle=0,n.m_gamma=0,n.m_impulse=new q(0,0,0),n.m_indexA=0,n.m_indexB=0,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=new K,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_K=new K,n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_localAnchorA.Copy(e(i.localAnchorA,j.ZERO)),n.m_localAnchorB.Copy(e(i.localAnchorB,j.ZERO)),n.m_referenceAngle=e(i.referenceAngle,0),n.m_impulse.SetZero(),n}s(i,t);var n=i.prototype;return n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v,h=t.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(e),l=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),J.MulRV(u,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.MulRV(l,this.m_lalcB,this.m_rB);var c=this.m_invMassA,_=this.m_invMassB,d=this.m_invIA,f=this.m_invIB,p=this.m_K;if(p.ex.x=c+_+this.m_rA.y*this.m_rA.y*d+this.m_rB.y*this.m_rB.y*f,p.ey.x=-this.m_rA.y*this.m_rA.x*d-this.m_rB.y*this.m_rB.x*f,p.ez.x=-this.m_rA.y*d-this.m_rB.y*f,p.ex.y=p.ey.x,p.ey.y=c+_+this.m_rA.x*this.m_rA.x*d+this.m_rB.x*this.m_rB.x*f,p.ez.y=this.m_rA.x*d+this.m_rB.x*f,p.ex.z=p.ez.x,p.ey.z=p.ez.y,p.ez.z=d+f,this.m_frequencyHz>0){p.GetInverse22(this.m_mass);var m=d+f,g=m>0?1/m:0,y=s-e-this.m_referenceAngle,v=2*a*this.m_frequencyHz,S=2*g*this.m_dampingRatio*v,T=g*v*v,A=t.step.dt;this.m_gamma=A*(S+A*T),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=y*A*T*this.m_gamma,m+=this.m_gamma,this.m_mass.ez.z=0!==m?1/m:0}else p.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse.SelfMul(t.step.dtRatio);var b=i.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);n.SelfMulSub(c,b),r-=d*(j.CrossVV(this.m_rA,b)+this.m_impulse.z),o.SelfMulAdd(_,b),h+=f*(j.CrossVV(this.m_rB,b)+this.m_impulse.z)}else this.m_impulse.SetZero();t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=h},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=this.m_invMassB,h=this.m_invIA,u=this.m_invIB;if(this.m_frequencyHz>0){var l=s-n,c=-this.m_mass.ez.z*(l+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=c,n-=h*c,s+=u*c;var _=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot1),d=K.MulM33XY(this.m_mass,_.x,_.y,i.SolveVelocityConstraints_s_impulse1).SelfNeg();this.m_impulse.x+=d.x,this.m_impulse.y+=d.y;var f=d;e.SelfMulSub(o,f),n-=h*j.CrossVV(this.m_rA,f),r.SelfMulAdd(a,f),s+=u*j.CrossVV(this.m_rB,f)}else{var p=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot1),m=s-n,g=K.MulM33XYZ(this.m_mass,p.x,p.y,m,i.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(g);var y=i.SolveVelocityConstraints_s_P.Set(g.x,g.y);e.SelfMulSub(o,y),n-=h*(j.CrossVV(this.m_rA,y)+g.z),r.SelfMulAdd(a,y),s+=u*(j.CrossVV(this.m_rB,y)+g.z)}t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s),h=this.m_invMassA,u=this.m_invMassB,_=this.m_invIA,d=this.m_invIB;j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var f=J.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p,m,g=J.MulRV(a,this.m_lalcB,this.m_rB),y=this.m_K;if(y.ex.x=h+u+f.y*f.y*_+g.y*g.y*d,y.ey.x=-f.y*f.x*_-g.y*g.x*d,y.ez.x=-f.y*_-g.y*d,y.ex.y=y.ey.x,y.ey.y=h+u+f.x*f.x*_+g.x*g.x*d,y.ez.y=f.x*_+g.x*d,y.ex.z=y.ez.x,y.ey.z=y.ez.y,y.ez.z=_+d,this.m_frequencyHz>0){var v=j.SubVV(j.AddVV(r,g,j.s_t0),j.AddVV(e,f,j.s_t1),i.SolvePositionConstraints_s_C1);p=v.Length(),m=0;var S=y.Solve22(v.x,v.y,i.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(h,S),n-=_*j.CrossVV(f,S),r.SelfMulAdd(u,S),s+=d*j.CrossVV(g,S)}else{var T=j.SubVV(j.AddVV(r,g,j.s_t0),j.AddVV(e,f,j.s_t1),i.SolvePositionConstraints_s_C1),A=s-n-this.m_referenceAngle;p=T.Length(),m=D(A);var b=y.Solve33(T.x,T.y,A,i.SolvePositionConstraints_s_impulse).SelfNeg(),E=i.SolvePositionConstraints_s_P.Set(b.x,b.y);e.SelfMulSub(h,E),n-=_*(j.CrossVV(this.m_rA,E)+b.z),r.SelfMulAdd(u,E),s+=d*(j.CrossVV(this.m_rB,E)+b.z)}return t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,p<=l&&m<=c},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e},n.GetReactionTorque=function(t){return t*this.m_impulse.z},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.GetReferenceAngle=function(){return this.m_referenceAngle},n.SetFrequency=function(t){this.m_frequencyHz=t},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t},n.GetDampingRatio=function(){return this.m_dampingRatio},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WeldJointDef = new b2WeldJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);tn.InitVelocityConstraints_s_P=new j,tn.SolveVelocityConstraints_s_Cdot1=new j,tn.SolveVelocityConstraints_s_impulse1=new j,tn.SolveVelocityConstraints_s_impulse=new q,tn.SolveVelocityConstraints_s_P=new j,tn.SolvePositionConstraints_s_C1=new j,tn.SolvePositionConstraints_s_P=new j,tn.SolvePositionConstraints_s_impulse=new q;var en=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_wheelJoint)||this).localAnchorA=new j(0,0),i.localAnchorB=new j(0,0),i.localAxisA=new j(1,0),i.enableMotor=!1,i.maxMotorTorque=0,i.motorSpeed=0,i.frequencyHz=2,i.dampingRatio=.7,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(n,this.localAxisA)},i}(Di),nn=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_frequencyHz=0,n.m_dampingRatio=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_localXAxisA=new j,n.m_localYAxisA=new j,n.m_impulse=0,n.m_motorImpulse=0,n.m_springImpulse=0,n.m_maxMotorTorque=0,n.m_motorSpeed=0,n.m_enableMotor=!1,n.m_indexA=0,n.m_indexB=0,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_ax=new j,n.m_ay=new j,n.m_sAx=0,n.m_sBx=0,n.m_sAy=0,n.m_sBy=0,n.m_mass=0,n.m_motorMass=0,n.m_springMass=0,n.m_bias=0,n.m_gamma=0,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_rA=new j,n.m_rB=new j,n.m_frequencyHz=e(i.frequencyHz,2),n.m_dampingRatio=e(i.dampingRatio,.7),n.m_localAnchorA.Copy(e(i.localAnchorA,j.ZERO)),n.m_localAnchorB.Copy(e(i.localAnchorB,j.ZERO)),n.m_localXAxisA.Copy(e(i.localAxisA,j.UNITX)),j.CrossOneV(n.m_localXAxisA,n.m_localYAxisA),n.m_maxMotorTorque=e(i.maxMotorTorque,0),n.m_motorSpeed=e(i.motorSpeed,0),n.m_enableMotor=e(i.enableMotor,!1),n.m_ax.SetZero(),n.m_ay.SetZero(),n}s(i,t);var n=i.prototype;return n.GetMotorSpeed=function(){return this.m_motorSpeed},n.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},n.SetSpringFrequencyHz=function(t){this.m_frequencyHz=t},n.GetSpringFrequencyHz=function(){return this.m_frequencyHz},n.SetSpringDampingRatio=function(t){this.m_dampingRatio=t},n.GetSpringDampingRatio=function(){return this.m_dampingRatio},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=this.m_invMassA,n=this.m_invMassB,r=this.m_invIA,s=this.m_invIB,o=t.positions[this.m_indexA].c,h=t.positions[this.m_indexA].a,u=t.velocities[this.m_indexA].v,l=t.velocities[this.m_indexA].w,c=t.positions[this.m_indexB].c,_=t.positions[this.m_indexB].a,d=t.velocities[this.m_indexB].v,f=t.velocities[this.m_indexB].w,p=this.m_qA.SetAngle(h),m=this.m_qB.SetAngle(_);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var g=J.MulRV(p,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var y=J.MulRV(m,this.m_lalcB,this.m_rB),v=j.SubVV(j.AddVV(c,y,j.s_t0),j.AddVV(o,g,j.s_t1),i.InitVelocityConstraints_s_d);if(J.MulRV(p,this.m_localYAxisA,this.m_ay),this.m_sAy=j.CrossVV(j.AddVV(v,g,j.s_t0),this.m_ay),this.m_sBy=j.CrossVV(y,this.m_ay),this.m_mass=e+n+r*this.m_sAy*this.m_sAy+s*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){J.MulRV(p,this.m_localXAxisA,this.m_ax),this.m_sAx=j.CrossVV(j.AddVV(v,g,j.s_t0),this.m_ax),this.m_sBx=j.CrossVV(y,this.m_ax);var S=e+n+r*this.m_sAx*this.m_sAx+s*this.m_sBx*this.m_sBx;if(S>0){this.m_springMass=1/S;var T=j.DotVV(v,this.m_ax),A=2*a*this.m_frequencyHz,b=2*this.m_springMass*this.m_dampingRatio*A,E=this.m_springMass*A*A,C=t.step.dt;this.m_gamma=C*(b+C*E),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=T*C*E*this.m_gamma,this.m_springMass=S+this.m_gamma,this.m_springMass>0&&(this.m_springMass=1/this.m_springMass)}}else this.m_springImpulse=0;if(this.m_enableMotor?(this.m_motorMass=r+s,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass)):(this.m_motorMass=0,this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse*=t.step.dtRatio,this.m_springImpulse*=t.step.dtRatio,this.m_motorImpulse*=t.step.dtRatio;var w=j.AddVV(j.MulSV(this.m_impulse,this.m_ay,j.s_t0),j.MulSV(this.m_springImpulse,this.m_ax,j.s_t1),i.InitVelocityConstraints_s_P),x=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,R=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;u.SelfMulSub(this.m_invMassA,w),l-=this.m_invIA*x,d.SelfMulAdd(this.m_invMassB,w),f+=this.m_invIB*R}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;t.velocities[this.m_indexA].w=l,t.velocities[this.m_indexB].w=f},n.SolveVelocityConstraints=function(t){var e=this.m_invMassA,n=this.m_invMassB,r=this.m_invIA,s=this.m_invIB,o=t.velocities[this.m_indexA].v,a=t.velocities[this.m_indexA].w,h=t.velocities[this.m_indexB].v,u=t.velocities[this.m_indexB].w,l=j.DotVV(this.m_ax,j.SubVV(h,o,j.s_t0))+this.m_sBx*u-this.m_sAx*a,c=-this.m_springMass*(l+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=c;var _=j.MulSV(c,this.m_ax,i.SolveVelocityConstraints_s_P),d=c*this.m_sAx,f=c*this.m_sBx;o.SelfMulSub(e,_),a-=r*d,h.SelfMulAdd(n,_);var p=(u+=s*f)-a-this.m_motorSpeed,m=-this.m_motorMass*p,g=this.m_motorImpulse,y=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=M(this.m_motorImpulse+m,-y,y),a-=r*(m=this.m_motorImpulse-g),u+=s*m;var v=j.DotVV(this.m_ay,j.SubVV(h,o,j.s_t0))+this.m_sBy*u-this.m_sAy*a,S=-this.m_mass*v;this.m_impulse+=S;var T=j.MulSV(S,this.m_ay,i.SolveVelocityConstraints_s_P),A=S*this.m_sAy,b=S*this.m_sBy;o.SelfMulSub(e,T),a-=r*A,h.SelfMulAdd(n,T),u+=s*b,t.velocities[this.m_indexA].w=a,t.velocities[this.m_indexB].w=u},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=J.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u,c=J.MulRV(a,this.m_lalcB,this.m_rB),_=j.AddVV(j.SubVV(r,e,j.s_t0),j.SubVV(c,h,j.s_t1),i.SolvePositionConstraints_s_d),d=J.MulRV(o,this.m_localYAxisA,this.m_ay),f=j.CrossVV(j.AddVV(_,h,j.s_t0),d),p=j.CrossVV(c,d),m=j.DotVV(_,this.m_ay),g=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;u=0!==g?-m/g:0;var y=j.MulSV(u,d,i.SolvePositionConstraints_s_P),v=u*f,S=u*p;return e.SelfMulSub(this.m_invMassA,y),n-=this.m_invIA*v,r.SelfMulAdd(this.m_invMassB,y),s+=this.m_invIB*S,t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,D(m)<=l},n.GetDefinition=function(t){return t},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse*this.m_ay.x+this.m_springImpulse*this.m_ax.x),e.y=t*(this.m_impulse*this.m_ay.y+this.m_springImpulse*this.m_ax.y),e},n.GetReactionTorque=function(t){return t*this.m_motorImpulse},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.GetLocalAxisA=function(){return this.m_localXAxisA},n.GetJointTranslation=function(){return this.GetPrismaticJointTranslation()},n.GetJointLinearSpeed=function(){return this.GetPrismaticJointSpeed()},n.GetJointAngle=function(){return this.GetRevoluteJointAngle()},n.GetJointAngularSpeed=function(){return this.GetRevoluteJointSpeed()},n.GetPrismaticJointTranslation=function(){var t=this.m_bodyA,e=this.m_bodyB,i=t.GetWorldPoint(this.m_localAnchorA,new j),n=e.GetWorldPoint(this.m_localAnchorB,new j),r=j.SubVV(n,i,new j),s=t.GetWorldVector(this.m_localXAxisA,new j);return j.DotVV(r,s)},n.GetPrismaticJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;j.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=J.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=J.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=j.AddVV(t.m_sweep.c,i,j.s_t0),s=j.AddVV(e.m_sweep.c,n,j.s_t1),o=j.SubVV(s,r,j.s_t2),a=t.GetWorldVector(this.m_localXAxisA,new j),h=t.m_linearVelocity,u=e.m_linearVelocity,l=t.m_angularVelocity,c=e.m_angularVelocity;return j.DotVV(o,j.CrossSV(l,a,j.s_t0))+j.DotVV(a,j.SubVV(j.AddVCrossSV(u,c,n,j.s_t0),j.AddVCrossSV(h,l,i,j.s_t1),j.s_t0))},n.GetRevoluteJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a},n.GetRevoluteJointSpeed=function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t},n.IsMotorEnabled=function(){return this.m_enableMotor},n.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},n.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},n.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},n.GetMotorTorque=function(t){return t*this.m_motorImpulse},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WheelJointDef = new b2WheelJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);function rn(t,e){return k(t*e)}function sn(t,e){return t>e?t:e}nn.InitVelocityConstraints_s_d=new j,nn.InitVelocityConstraints_s_P=new j,nn.SolveVelocityConstraints_s_P=new j,nn.SolvePositionConstraints_s_d=new j,nn.SolvePositionConstraints_s_P=new j;var on=function(){function t(t){this._other=null,this.prev=null,this.next=null,this.contact=t}return t.prototype.Reset=function(){this._other=null,this.prev=null,this.next=null},n(t,[{key:"other",get:function(){if(null===this._other)throw new Error;return this._other},set:function(t){if(null!==this._other)throw new Error;this._other=t}}]),t}(),an=function(){function t(){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!1,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_prev=null,this.m_next=null,this.m_nodeA=new on(this),this.m_nodeB=new on(this),this.m_indexA=0,this.m_indexB=0,this.m_manifold=new Mt,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new Mt}var e=t.prototype;return e.GetManifold=function(){return this.m_manifold},e.GetWorldManifold=function(t){var e=this.m_fixtureA.GetBody(),i=this.m_fixtureB.GetBody(),n=this.GetShapeA(),r=this.GetShapeB();t.Initialize(this.m_manifold,e.GetTransform(),n.m_radius,i.GetTransform(),r.m_radius)},e.IsTouching=function(){return this.m_touchingFlag},e.SetEnabled=function(t){this.m_enabledFlag=t},e.IsEnabled=function(){return this.m_enabledFlag},e.GetNext=function(){return this.m_next},e.GetFixtureA=function(){return this.m_fixtureA},e.GetChildIndexA=function(){return this.m_indexA},e.GetShapeA=function(){return this.m_fixtureA.GetShape()},e.GetFixtureB=function(){return this.m_fixtureB},e.GetChildIndexB=function(){return this.m_indexB},e.GetShapeB=function(){return this.m_fixtureB.GetShape()},e.FlagForFiltering=function(){this.m_filterFlag=!0},e.SetFriction=function(t){this.m_friction=t},e.GetFriction=function(){return this.m_friction},e.ResetFriction=function(){this.m_friction=rn(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction)},e.SetRestitution=function(t){this.m_restitution=t},e.GetRestitution=function(){return this.m_restitution},e.ResetRestitution=function(){this.m_restitution=sn(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},e.SetTangentSpeed=function(t){this.m_tangentSpeed=t},e.GetTangentSpeed=function(){return this.m_tangentSpeed},e.Reset=function(t,e,i,n){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!0,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_fixtureA=t,this.m_fixtureB=i,this.m_indexA=e,this.m_indexB=n,this.m_manifold.pointCount=0,this.m_prev=null,this.m_next=null,this.m_nodeA.Reset(),this.m_nodeB.Reset(),this.m_toiCount=0,this.m_friction=rn(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=sn(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},e.Update=function(t){var e=this.m_oldManifold;this.m_oldManifold=this.m_manifold,this.m_manifold=e,this.m_enabledFlag=!0;var i=!1,n=this.m_touchingFlag,r=this.m_fixtureA.IsSensor(),s=this.m_fixtureB.IsSensor(),o=r||s,a=this.m_fixtureA.GetBody(),h=this.m_fixtureB.GetBody(),u=a.GetTransform(),l=h.GetTransform();if(o){var c=this.GetShapeA(),_=this.GetShapeB();i=jt(c,this.m_indexA,_,this.m_indexB,u,l),this.m_manifold.pointCount=0}else{this.Evaluate(this.m_manifold,u,l),i=this.m_manifold.pointCount>0;for(var d=0;d<this.m_manifold.pointCount;++d){var f=this.m_manifold.points[d];f.normalImpulse=0,f.tangentImpulse=0;for(var p=f.id,m=0;m<this.m_oldManifold.pointCount;++m){var g=this.m_oldManifold.points[m];if(g.id.key===p.key){f.normalImpulse=g.normalImpulse,f.tangentImpulse=g.tangentImpulse;break}}}i!==n&&(a.SetAwake(!0),h.SetAwake(!0))}this.m_touchingFlag=i,!n&&i&&t&&t.BeginContact(this),n&&!i&&t&&t.EndContact(this),!o&&i&&t&&t.PreSolve(this,this.m_oldManifold)},e.ComputeTOI=function(e,i){var n=t.ComputeTOI_s_input;n.proxyA.SetShape(this.GetShapeA(),this.m_indexA),n.proxyB.SetShape(this.GetShapeB(),this.m_indexB),n.sweepA.Copy(e),n.sweepB.Copy(i),n.tMax=l;var r=t.ComputeTOI_s_output;return Te(r,n),r.t},t}();an.ComputeTOI_s_input=new he,an.ComputeTOI_s_output=new le;var hn=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){Ee(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(an),un=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){Qe(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(an),ln=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){Re(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(an),cn=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){ai(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(an),_n=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,e,i){di(t,this.GetShapeA(),e,this.GetShapeB(),i)},e}(an),dn=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,i,n){var r=e.Evaluate_s_edge;this.GetShapeA().GetChildEdge(r,this.m_indexA),ai(t,r,i,this.GetShapeB(),n)},e}(an);dn.Evaluate_s_edge=new vi;var fn=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.Create=function(){return new e},e.Destroy=function(){},e.prototype.Evaluate=function(t,i,n){var r=e.Evaluate_s_edge;this.GetShapeA().GetChildEdge(r,this.m_indexA),di(t,r,i,this.GetShapeB(),n)},e}(an);fn.Evaluate_s_edge=new vi;var pn=function(){this.pool=[],this.createFcn=null,this.destroyFcn=null,this.primary=!1},mn=function(){function e(){this.m_registers=[],this.InitializeRegisters()}var i=e.prototype;return i.AddType=function(t,e,i,n){var r=[];function s(){return r.pop()||t()}function o(t){r.push(t)}this.m_registers[i][n].pool=r,this.m_registers[i][n].createFcn=s,this.m_registers[i][n].destroyFcn=o,this.m_registers[i][n].primary=!0,i!==n&&(this.m_registers[n][i].pool=r,this.m_registers[n][i].createFcn=s,this.m_registers[n][i].destroyFcn=o,this.m_registers[n][i].primary=!1)},i.InitializeRegisters=function(){for(var e=0;e<t.b2ShapeType.e_shapeTypeCount;e++){this.m_registers[e]=[];for(var i=0;i<t.b2ShapeType.e_shapeTypeCount;i++)this.m_registers[e][i]=new pn}this.AddType(hn.Create,hn.Destroy,t.b2ShapeType.e_circleShape,t.b2ShapeType.e_circleShape),this.AddType(ln.Create,ln.Destroy,t.b2ShapeType.e_polygonShape,t.b2ShapeType.e_circleShape),this.AddType(un.Create,un.Destroy,t.b2ShapeType.e_polygonShape,t.b2ShapeType.e_polygonShape),this.AddType(cn.Create,cn.Destroy,t.b2ShapeType.e_edgeShape,t.b2ShapeType.e_circleShape),this.AddType(_n.Create,_n.Destroy,t.b2ShapeType.e_edgeShape,t.b2ShapeType.e_polygonShape),this.AddType(dn.Create,dn.Destroy,t.b2ShapeType.e_chainShape,t.b2ShapeType.e_circleShape),this.AddType(fn.Create,fn.Destroy,t.b2ShapeType.e_chainShape,t.b2ShapeType.e_polygonShape)},i.Create=function(t,e,i,n){var r=t.GetType(),s=i.GetType(),o=this.m_registers[r][s];if(o.createFcn){var a=o.createFcn();return o.primary?a.Reset(t,e,i,n):a.Reset(i,n,t,e),a}return null},i.Destroy=function(t){var e=t.m_fixtureA.GetType(),i=t.m_fixtureB.GetType(),n=this.m_registers[e][i];n.destroyFcn&&n.destroyFcn(t)},e}(),gn=function(){function t(){}var e=t.prototype;return e.SayGoodbyeJoint=function(){},e.SayGoodbyeFixture=function(){},e.SayGoodbyeParticleGroup=function(){},e.SayGoodbyeParticle=function(){},t}(),yn=function(){function e(){}var i=e.prototype;return i.ShouldCollide=function(e,i){var n=e.GetBody(),r=i.GetBody();if(r.GetType()===t.b2BodyType.b2_staticBody&&n.GetType()===t.b2BodyType.b2_staticBody)return!1;if(!r.ShouldCollideConnected(n))return!1;var s=e.GetFilterData(),o=i.GetFilterData();return s.groupIndex===o.groupIndex&&0!==s.groupIndex?s.groupIndex>0:0!=(s.maskBits&o.categoryBits)&&0!=(s.categoryBits&o.maskBits)},i.ShouldCollideFixtureParticle=function(){return!0},i.ShouldCollideParticleParticle=function(){return!0},e}();yn.b2_defaultFilter=new yn;var vn=function(){this.normalImpulses=x(2),this.tangentImpulses=x(2),this.count=0},Sn=function(){function t(){}var e=t.prototype;return e.BeginContact=function(){},e.EndContact=function(){},e.BeginContactFixtureParticle=function(){},e.EndContactFixtureParticle=function(){},e.BeginContactParticleParticle=function(){},e.EndContactParticleParticle=function(){},e.PreSolve=function(){},e.PostSolve=function(){},t}();Sn.b2_defaultListener=new Sn;var Tn=function(){function t(){}var e=t.prototype;return e.ReportFixture=function(){return!0},e.ReportParticle=function(){return!1},e.ShouldQueryParticleSystem=function(){return!0},t}(),An=function(){function t(){}var e=t.prototype;return e.ReportFixture=function(t,e,i,n){return n},e.ReportParticle=function(){return 0},e.ShouldQueryParticleSystem=function(){return!0},t}(),bn=function(){function e(){this.m_broadPhase=new Zt,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=yn.b2_defaultFilter,this.m_contactListener=Sn.b2_defaultListener,this.m_contactFactory=new mn}var i=e.prototype;return i.AddPair=function(t,e){var i=t.fixture,n=e.fixture,r=t.childIndex,s=e.childIndex,o=i.GetBody(),a=n.GetBody();if(o!==a){for(var h=a.GetContactList();h;){if(h.other===o){var u=h.contact.GetFixtureA(),l=h.contact.GetFixtureB(),c=h.contact.GetChildIndexA(),_=h.contact.GetChildIndexB();if(u===i&&l===n&&c===r&&_===s)return;if(u===n&&l===i&&c===s&&_===r)return}h=h.next}if(!this.m_contactFilter||this.m_contactFilter.ShouldCollide(i,n)){var d=this.m_contactFactory.Create(i,r,n,s);null!==d&&(i=d.GetFixtureA(),n=d.GetFixtureB(),r=d.GetChildIndexA(),s=d.GetChildIndexB(),o=i.m_body,a=n.m_body,d.m_prev=null,d.m_next=this.m_contactList,null!==this.m_contactList&&(this.m_contactList.m_prev=d),this.m_contactList=d,d.m_nodeA.other=a,d.m_nodeA.prev=null,d.m_nodeA.next=o.m_contactList,null!==o.m_contactList&&(o.m_contactList.prev=d.m_nodeA),o.m_contactList=d.m_nodeA,d.m_nodeB.other=o,d.m_nodeB.prev=null,d.m_nodeB.next=a.m_contactList,null!==a.m_contactList&&(a.m_contactList.prev=d.m_nodeB),a.m_contactList=d.m_nodeB,i.IsSensor()||n.IsSensor()||(o.SetAwake(!0),a.SetAwake(!0)),++this.m_contactCount)}}},i.FindNewContacts=function(){var t=this;this.m_broadPhase.UpdatePairs((function(e,i){t.AddPair(e,i)}))},i.Destroy=function(t){var e=t.GetFixtureA(),i=t.GetFixtureB(),n=e.GetBody(),r=i.GetBody();this.m_contactListener&&t.IsTouching()&&this.m_contactListener.EndContact(t),t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_contactList&&(this.m_contactList=t.m_next),t.m_nodeA.prev&&(t.m_nodeA.prev.next=t.m_nodeA.next),t.m_nodeA.next&&(t.m_nodeA.next.prev=t.m_nodeA.prev),t.m_nodeA===n.m_contactList&&(n.m_contactList=t.m_nodeA.next),t.m_nodeB.prev&&(t.m_nodeB.prev.next=t.m_nodeB.next),t.m_nodeB.next&&(t.m_nodeB.next.prev=t.m_nodeB.prev),t.m_nodeB===r.m_contactList&&(r.m_contactList=t.m_nodeB.next),t.m_manifold.pointCount>0&&!e.IsSensor()&&!i.IsSensor()&&(e.GetBody().SetAwake(!0),i.GetBody().SetAwake(!0)),this.m_contactFactory.Destroy(t),--this.m_contactCount},i.Collide=function(){for(var e=this.m_contactList;e;){var i=e.GetFixtureA(),n=e.GetFixtureB(),r=e.GetChildIndexA(),s=e.GetChildIndexB(),o=i.GetBody(),a=n.GetBody();if(e.m_filterFlag){if(this.m_contactFilter&&!this.m_contactFilter.ShouldCollide(i,n)){var h=e;e=h.m_next,this.Destroy(h);continue}e.m_filterFlag=!1}var u=o.IsAwake()&&o.m_type!==t.b2BodyType.b2_staticBody,l=a.IsAwake()&&a.m_type!==t.b2BodyType.b2_staticBody;if(u||l){var c=i.m_proxies[r].treeNode,_=n.m_proxies[s].treeNode;if(Gt(c.aabb,_.aabb))e.Update(this.m_contactListener),e=e.m_next;else{var d=e;e=d.m_next,this.Destroy(d)}}else e=e.m_next}},e}(),En=function(){function t(){this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0}return t.prototype.Reset=function(){return this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0,this},t}(),Cn=function(){function t(){this.dt=0,this.inv_dt=0,this.dtRatio=0,this.velocityIterations=0,this.positionIterations=0,this.particleIterations=0,this.warmStarting=!1}return t.prototype.Copy=function(t){return this.dt=t.dt,this.inv_dt=t.inv_dt,this.dtRatio=t.dtRatio,this.positionIterations=t.positionIterations,this.velocityIterations=t.velocityIterations,this.particleIterations=t.particleIterations,this.warmStarting=t.warmStarting,this},t}(),wn=function(){function t(){this.c=new j,this.a=0}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t}(),xn=function(){function t(){this.v=new j,this.w=0}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t}(),Rn=function(){this.step=new Cn},In=!1,Bn=function(){function t(){this.rA=new j,this.rB=new j,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t}(),Dn=function(){function t(){this.points=Bn.MakeArray(2),this.normal=new j,this.tangent=new j,this.normalMass=new Y,this.K=new Y,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.invIA=0,this.invIB=0,this.friction=0,this.restitution=0,this.tangentSpeed=0,this.pointCount=0,this.contactIndex=0}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t}(),Pn=function(){function e(){this.localPoints=j.MakeArray(2),this.localNormal=new j,this.localPoint=new j,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new j,this.localCenterB=new j,this.invIA=0,this.invIB=0,this.type=t.b2ManifoldType.e_unknown,this.radiusA=0,this.radiusB=0,this.pointCount=0}return e.MakeArray=function(t){return w(t,(function(){return new e}))},e}(),On=function(){this.step=new Cn,this.count=0},Mn=function(){function e(){this.normal=new j,this.point=new j,this.separation=0}return e.prototype.Initialize=function(i,n,r,s){var o=e.Initialize_s_pointA,a=e.Initialize_s_pointB,h=e.Initialize_s_planePoint,u=e.Initialize_s_clipPoint;switch(i.type){case t.b2ManifoldType.e_circles:Q.MulXV(n,i.localPoint,o),Q.MulXV(r,i.localPoints[0],a),j.SubVV(a,o,this.normal).SelfNormalize(),j.MidVV(o,a,this.point),this.separation=j.DotVV(j.SubVV(a,o,j.s_t0),this.normal)-i.radiusA-i.radiusB;break;case t.b2ManifoldType.e_faceA:J.MulRV(n.q,i.localNormal,this.normal),Q.MulXV(n,i.localPoint,h),Q.MulXV(r,i.localPoints[s],u),this.separation=j.DotVV(j.SubVV(u,h,j.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(u);break;case t.b2ManifoldType.e_faceB:J.MulRV(r.q,i.localNormal,this.normal),Q.MulXV(r,i.localPoint,h),Q.MulXV(n,i.localPoints[s],u),this.separation=j.DotVV(j.SubVV(u,h,j.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(u),this.normal.SelfNeg()}},e}();Mn.Initialize_s_pointA=new j,Mn.Initialize_s_pointB=new j,Mn.Initialize_s_planePoint=new j,Mn.Initialize_s_clipPoint=new j;var Ln=function(){function t(){this.m_step=new Cn,this.m_positionConstraints=Pn.MakeArray(1024),this.m_velocityConstraints=Dn.MakeArray(1024),this.m_count=0}var e=t.prototype;return e.Initialize=function(t){if(this.m_step.Copy(t.step),this.m_count=t.count,this.m_positionConstraints.length<this.m_count)for(var e=O(2*this.m_positionConstraints.length,this.m_count);this.m_positionConstraints.length<e;)this.m_positionConstraints[this.m_positionConstraints.length]=new Pn;if(this.m_velocityConstraints.length<this.m_count)for(var i=O(2*this.m_velocityConstraints.length,this.m_count);this.m_velocityConstraints.length<i;)this.m_velocityConstraints[this.m_velocityConstraints.length]=new Dn;this.m_positions=t.positions,this.m_velocities=t.velocities,this.m_contacts=t.contacts;for(var n=0;n<this.m_count;++n){var r=this.m_contacts[n],s=r.m_fixtureA,o=r.m_fixtureB,a=s.GetShape(),h=o.GetShape(),u=a.m_radius,l=h.m_radius,c=s.GetBody(),_=o.GetBody(),d=r.GetManifold(),f=d.pointCount,p=this.m_velocityConstraints[n];p.friction=r.m_friction,p.restitution=r.m_restitution,p.tangentSpeed=r.m_tangentSpeed,p.indexA=c.m_islandIndex,p.indexB=_.m_islandIndex,p.invMassA=c.m_invMass,p.invMassB=_.m_invMass,p.invIA=c.m_invI,p.invIB=_.m_invI,p.contactIndex=n,p.pointCount=f,p.K.SetZero(),p.normalMass.SetZero();var m=this.m_positionConstraints[n];m.indexA=c.m_islandIndex,m.indexB=_.m_islandIndex,m.invMassA=c.m_invMass,m.invMassB=_.m_invMass,m.localCenterA.Copy(c.m_sweep.localCenter),m.localCenterB.Copy(_.m_sweep.localCenter),m.invIA=c.m_invI,m.invIB=_.m_invI,m.localNormal.Copy(d.localNormal),m.localPoint.Copy(d.localPoint),m.pointCount=f,m.radiusA=u,m.radiusB=l,m.type=d.type;for(var g=0;g<f;++g){var y=d.points[g],v=p.points[g];this.m_step.warmStarting?(v.normalImpulse=this.m_step.dtRatio*y.normalImpulse,v.tangentImpulse=this.m_step.dtRatio*y.tangentImpulse):(v.normalImpulse=0,v.tangentImpulse=0),v.rA.SetZero(),v.rB.SetZero(),v.normalMass=0,v.tangentMass=0,v.velocityBias=0,m.localPoints[g].Copy(y.localPoint)}}return this},e.InitializeVelocityConstraints=function(){for(var e=t.InitializeVelocityConstraints_s_xfA,i=t.InitializeVelocityConstraints_s_xfB,n=t.InitializeVelocityConstraints_s_worldManifold,r=0;r<this.m_count;++r){var s=this.m_velocityConstraints[r],o=this.m_positionConstraints[r],a=o.radiusA,h=o.radiusB,u=this.m_contacts[s.contactIndex].GetManifold(),l=s.indexA,c=s.indexB,_=s.invMassA,d=s.invMassB,f=s.invIA,p=s.invIB,m=o.localCenterA,g=o.localCenterB,y=this.m_positions[l].c,v=this.m_positions[l].a,S=this.m_velocities[l].v,T=this.m_velocities[l].w,A=this.m_positions[c].c,b=this.m_positions[c].a,E=this.m_velocities[c].v,C=this.m_velocities[c].w;e.q.SetAngle(v),i.q.SetAngle(b),j.SubVV(y,J.MulRV(e.q,m,j.s_t0),e.p),j.SubVV(A,J.MulRV(i.q,g,j.s_t0),i.p),n.Initialize(u,e,a,i,h),s.normal.Copy(n.normal),j.CrossVOne(s.normal,s.tangent);for(var w=s.pointCount,x=0;x<w;++x){var R=s.points[x];j.SubVV(n.points[x],y,R.rA),j.SubVV(n.points[x],A,R.rB);var I=j.CrossVV(R.rA,s.normal),B=j.CrossVV(R.rB,s.normal),D=_+d+f*I*I+p*B*B;R.normalMass=D>0?1/D:0;var P=s.tangent,O=j.CrossVV(R.rA,P),M=j.CrossVV(R.rB,P),L=_+d+f*O*O+p*M*M;R.tangentMass=L>0?1/L:0,R.velocityBias=0;var N=j.DotVV(s.normal,j.SubVV(j.AddVCrossSV(E,C,R.rB,j.s_t0),j.AddVCrossSV(S,T,R.rA,j.s_t1),j.s_t0));N<-1&&(R.velocityBias+=-s.restitution*N)}s.pointCount}},e.WarmStart=function(){for(var e=t.WarmStart_s_P,i=0;i<this.m_count;++i){for(var n=this.m_velocityConstraints[i],r=n.indexA,s=n.indexB,o=n.invMassA,a=n.invIA,h=n.invMassB,u=n.invIB,l=n.pointCount,c=this.m_velocities[r].v,_=this.m_velocities[r].w,d=this.m_velocities[s].v,f=this.m_velocities[s].w,p=n.normal,m=n.tangent,g=0;g<l;++g){var y=n.points[g];j.AddVV(j.MulSV(y.normalImpulse,p,j.s_t0),j.MulSV(y.tangentImpulse,m,j.s_t1),e),_-=a*j.CrossVV(y.rA,e),c.SelfMulSub(o,e),f+=u*j.CrossVV(y.rB,e),d.SelfMulAdd(h,e)}this.m_velocities[r].w=_,this.m_velocities[s].w=f}},e.SolveVelocityConstraints=function(){for(var e=t.SolveVelocityConstraints_s_dv,i=(t.SolveVelocityConstraints_s_dv1,t.SolveVelocityConstraints_s_dv2,t.SolveVelocityConstraints_s_P),n=(t.SolveVelocityConstraints_s_a,t.SolveVelocityConstraints_s_b,t.SolveVelocityConstraints_s_x,t.SolveVelocityConstraints_s_d,t.SolveVelocityConstraints_s_P1,t.SolveVelocityConstraints_s_P2,t.SolveVelocityConstraints_s_P1P2,0);n<this.m_count;++n){for(var r=this.m_velocityConstraints[n],s=r.indexA,o=r.indexB,a=r.invMassA,h=r.invIA,u=r.invMassB,l=r.invIB,c=r.pointCount,_=this.m_velocities[s].v,d=this.m_velocities[s].w,f=this.m_velocities[o].v,p=this.m_velocities[o].w,m=r.normal,g=r.tangent,y=r.friction,v=0;v<c;++v){var S=r.points[v];j.SubVV(j.AddVCrossSV(f,p,S.rB,j.s_t0),j.AddVCrossSV(_,d,S.rA,j.s_t1),e);var T=j.DotVV(e,g)-r.tangentSpeed,A=S.tangentMass*-T,b=y*S.normalImpulse,E=M(S.tangentImpulse+A,-b,b);A=E-S.tangentImpulse,S.tangentImpulse=E,j.MulSV(A,g,i),_.SelfMulSub(a,i),d-=h*j.CrossVV(S.rA,i),f.SelfMulAdd(u,i),p+=l*j.CrossVV(S.rB,i)}r.pointCount;for(var C=0;C<c;++C){var w=r.points[C];j.SubVV(j.AddVCrossSV(f,p,w.rB,j.s_t0),j.AddVCrossSV(_,d,w.rA,j.s_t1),e);var x=j.DotVV(e,m),R=-w.normalMass*(x-w.velocityBias),I=O(w.normalImpulse+R,0);R=I-w.normalImpulse,w.normalImpulse=I,j.MulSV(R,m,i),_.SelfMulSub(a,i),d-=h*j.CrossVV(w.rA,i),f.SelfMulAdd(u,i),p+=l*j.CrossVV(w.rB,i)}this.m_velocities[s].w=d,this.m_velocities[o].w=p}},e.StoreImpulses=function(){for(var t=0;t<this.m_count;++t)for(var e=this.m_velocityConstraints[t],i=this.m_contacts[e.contactIndex].GetManifold(),n=0;n<e.pointCount;++n)i.points[n].normalImpulse=e.points[n].normalImpulse,i.points[n].tangentImpulse=e.points[n].tangentImpulse},e.SolvePositionConstraints=function(){for(var e=t.SolvePositionConstraints_s_xfA,i=t.SolvePositionConstraints_s_xfB,n=t.SolvePositionConstraints_s_psm,r=t.SolvePositionConstraints_s_rA,s=t.SolvePositionConstraints_s_rB,o=t.SolvePositionConstraints_s_P,a=0,h=0;h<this.m_count;++h){for(var u=this.m_positionConstraints[h],c=u.indexA,_=u.indexB,d=u.localCenterA,f=u.invMassA,p=u.invIA,m=u.localCenterB,g=u.invMassB,y=u.invIB,v=u.pointCount,S=this.m_positions[c].c,T=this.m_positions[c].a,A=this.m_positions[_].c,b=this.m_positions[_].a,E=0;E<v;++E){e.q.SetAngle(T),i.q.SetAngle(b),j.SubVV(S,J.MulRV(e.q,d,j.s_t0),e.p),j.SubVV(A,J.MulRV(i.q,m,j.s_t0),i.p),n.Initialize(u,e,i,E);var C=n.normal,w=n.point,x=n.separation;j.SubVV(w,S,r),j.SubVV(w,A,s),a=P(a,x);var R=M(.2*(x+l),-.2,0),I=j.CrossVV(r,C),B=j.CrossVV(s,C),D=f+g+p*I*I+y*B*B,O=D>0?-R/D:0;j.MulSV(O,C,o),S.SelfMulSub(f,o),T-=p*j.CrossVV(r,o),A.SelfMulAdd(g,o),b+=y*j.CrossVV(s,o)}this.m_positions[c].a=T,this.m_positions[_].a=b}return a>-.024},e.SolveTOIPositionConstraints=function(e,i){for(var n=t.SolveTOIPositionConstraints_s_xfA,r=t.SolveTOIPositionConstraints_s_xfB,s=t.SolveTOIPositionConstraints_s_psm,o=t.SolveTOIPositionConstraints_s_rA,a=t.SolveTOIPositionConstraints_s_rB,h=t.SolveTOIPositionConstraints_s_P,u=0,c=0;c<this.m_count;++c){var _=this.m_positionConstraints[c],d=_.indexA,f=_.indexB,p=_.localCenterA,m=_.localCenterB,g=_.pointCount,y=0,v=0;d!==e&&d!==i||(y=_.invMassA,v=_.invIA);var S=0,T=0;f!==e&&f!==i||(S=_.invMassB,T=_.invIB);for(var A=this.m_positions[d].c,b=this.m_positions[d].a,E=this.m_positions[f].c,C=this.m_positions[f].a,w=0;w<g;++w){n.q.SetAngle(b),r.q.SetAngle(C),j.SubVV(A,J.MulRV(n.q,p,j.s_t0),n.p),j.SubVV(E,J.MulRV(r.q,m,j.s_t0),r.p),s.Initialize(_,n,r,w);var x=s.normal,R=s.point,I=s.separation;j.SubVV(R,A,o),j.SubVV(R,E,a),u=P(u,I);var B=M(.75*(I+l),-.2,0),D=j.CrossVV(o,x),O=j.CrossVV(a,x),L=y+S+v*D*D+T*O*O,N=L>0?-B/L:0;j.MulSV(N,x,h),A.SelfMulSub(y,h),b-=v*j.CrossVV(o,h),E.SelfMulAdd(S,h),C+=T*j.CrossVV(a,h)}this.m_positions[d].a=b,this.m_positions[f].a=C}return u>=-.012},t}();Ln.InitializeVelocityConstraints_s_xfA=new Q,Ln.InitializeVelocityConstraints_s_xfB=new Q,Ln.InitializeVelocityConstraints_s_worldManifold=new Lt,Ln.WarmStart_s_P=new j,Ln.SolveVelocityConstraints_s_dv=new j,Ln.SolveVelocityConstraints_s_dv1=new j,Ln.SolveVelocityConstraints_s_dv2=new j,Ln.SolveVelocityConstraints_s_P=new j,Ln.SolveVelocityConstraints_s_a=new j,Ln.SolveVelocityConstraints_s_b=new j,Ln.SolveVelocityConstraints_s_x=new j,Ln.SolveVelocityConstraints_s_d=new j,Ln.SolveVelocityConstraints_s_P1=new j,Ln.SolveVelocityConstraints_s_P2=new j,Ln.SolveVelocityConstraints_s_P1P2=new j,Ln.SolvePositionConstraints_s_xfA=new Q,Ln.SolvePositionConstraints_s_xfB=new Q,Ln.SolvePositionConstraints_s_psm=new Mn,Ln.SolvePositionConstraints_s_rA=new j,Ln.SolvePositionConstraints_s_rB=new j,Ln.SolvePositionConstraints_s_P=new j,Ln.SolveTOIPositionConstraints_s_xfA=new Q,Ln.SolveTOIPositionConstraints_s_xfB=new Q,Ln.SolveTOIPositionConstraints_s_psm=new Mn,Ln.SolveTOIPositionConstraints_s_rA=new j,Ln.SolveTOIPositionConstraints_s_rB=new j,Ln.SolveTOIPositionConstraints_s_P=new j;var Nn,Fn=function(){function e(){this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=wn.MakeArray(1024),this.m_velocities=xn.MakeArray(1024),this.m_bodyCount=0,this.m_jointCount=0,this.m_contactCount=0,this.m_bodyCapacity=0,this.m_contactCapacity=0,this.m_jointCapacity=0}var n=e.prototype;return n.Initialize=function(t,e,i,n){if(this.m_bodyCapacity=t,this.m_contactCapacity=e,this.m_jointCapacity=i,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_listener=n,this.m_positions.length<t)for(var r=O(2*this.m_positions.length,t);this.m_positions.length<r;)this.m_positions[this.m_positions.length]=new wn;if(this.m_velocities.length<t)for(var s=O(2*this.m_velocities.length,t);this.m_velocities.length<s;)this.m_velocities[this.m_velocities.length]=new xn},n.Clear=function(){this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0},n.AddBody=function(t){t.m_islandIndex=this.m_bodyCount,this.m_bodies[this.m_bodyCount++]=t},n.AddContact=function(t){this.m_contacts[this.m_contactCount++]=t},n.AddJoint=function(t){this.m_joints[this.m_jointCount++]=t},n.Solve=function(n,r,s,o){for(var a=e.s_timer.Reset(),h=r.dt,u=0;u<this.m_bodyCount;++u){var l=this.m_bodies[u];this.m_positions[u].c.Copy(l.m_sweep.c);var c=l.m_sweep.a,_=this.m_velocities[u].v.Copy(l.m_linearVelocity),d=l.m_angularVelocity;l.m_sweep.c0.Copy(l.m_sweep.c),l.m_sweep.a0=l.m_sweep.a,l.m_type===t.b2BodyType.b2_dynamicBody&&(_.x+=h*(l.m_gravityScale*s.x+l.m_invMass*l.m_force.x),_.y+=h*(l.m_gravityScale*s.y+l.m_invMass*l.m_force.y),d+=h*l.m_invI*l.m_torque,_.SelfMul(1/(1+h*l.m_linearDamping)),d*=1/(1+h*l.m_angularDamping)),this.m_positions[u].a=c,this.m_velocities[u].w=d}a.Reset();var f=e.s_solverData;f.step.Copy(r),f.positions=this.m_positions,f.velocities=this.m_velocities;var p=e.s_contactSolverDef;p.step.Copy(r),p.contacts=this.m_contacts,p.count=this.m_contactCount,p.positions=this.m_positions,p.velocities=this.m_velocities;var y=e.s_contactSolver.Initialize(p);y.InitializeVelocityConstraints(),r.warmStarting&&y.WarmStart();for(var v=0;v<this.m_jointCount;++v)this.m_joints[v].InitVelocityConstraints(f);n.solveInit=a.GetMilliseconds(),a.Reset();for(var S=0;S<r.velocityIterations;++S){for(var T=0;T<this.m_jointCount;++T)this.m_joints[T].SolveVelocityConstraints(f);y.SolveVelocityConstraints()}y.StoreImpulses(),n.solveVelocity=a.GetMilliseconds();for(var A=0;A<this.m_bodyCount;++A){var b=this.m_positions[A].c,E=this.m_positions[A].a,C=this.m_velocities[A].v,w=this.m_velocities[A].w,x=j.MulSV(h,C,e.s_translation);if(j.DotVV(x,x)>4){var R=2/x.Length();C.SelfMul(R)}var I=h*w;I*I>g&&(w*=m/D(I)),b.x+=h*C.x,b.y+=h*C.y,E+=h*w,this.m_positions[A].a=E,this.m_velocities[A].w=w}a.Reset();for(var B=!1,O=0;O<r.positionIterations;++O){for(var M=y.SolvePositionConstraints(),L=!0,N=0;N<this.m_jointCount;++N){var F=this.m_joints[N].SolvePositionConstraints(f);L=L&&F}if(M&&L){B=!0;break}}for(var k=0;k<this.m_bodyCount;++k){var V=this.m_bodies[k];V.m_sweep.c.Copy(this.m_positions[k].c),V.m_sweep.a=this.m_positions[k].a,V.m_linearVelocity.Copy(this.m_velocities[k].v),V.m_angularVelocity=this.m_velocities[k].w,V.SynchronizeTransform()}if(n.solvePosition=a.GetMilliseconds(),this.Report(y.m_velocityConstraints),o){for(var G=i,U=0;U<this.m_bodyCount;++U){var z=this.m_bodies[U];z.GetType()!==t.b2BodyType.b2_staticBody&&(!z.m_autoSleepFlag||z.m_angularVelocity*z.m_angularVelocity>.0012184696791469947||j.DotVV(z.m_linearVelocity,z.m_linearVelocity)>1e-4?(z.m_sleepTime=0,G=0):(z.m_sleepTime+=h,G=P(G,z.m_sleepTime)))}if(G>=.5&&B)for(var H=0;H<this.m_bodyCount;++H)this.m_bodies[H].SetAwake(!1)}},n.SolveTOI=function(t,i,n){for(var r=0;r<this.m_bodyCount;++r){var s=this.m_bodies[r];this.m_positions[r].c.Copy(s.m_sweep.c),this.m_positions[r].a=s.m_sweep.a,this.m_velocities[r].v.Copy(s.m_linearVelocity),this.m_velocities[r].w=s.m_angularVelocity}var o=e.s_contactSolverDef;o.contacts=this.m_contacts,o.count=this.m_contactCount,o.step.Copy(t),o.positions=this.m_positions,o.velocities=this.m_velocities;for(var a=e.s_contactSolver.Initialize(o),h=0;h<t.positionIterations&&!a.SolveTOIPositionConstraints(i,n);++h);this.m_bodies[i].m_sweep.c0.Copy(this.m_positions[i].c),this.m_bodies[i].m_sweep.a0=this.m_positions[i].a,this.m_bodies[n].m_sweep.c0.Copy(this.m_positions[n].c),this.m_bodies[n].m_sweep.a0=this.m_positions[n].a,a.InitializeVelocityConstraints();for(var u=0;u<t.velocityIterations;++u)a.SolveVelocityConstraints();for(var l=t.dt,c=0;c<this.m_bodyCount;++c){var _=this.m_positions[c].c,d=this.m_positions[c].a,f=this.m_velocities[c].v,p=this.m_velocities[c].w,y=j.MulSV(l,f,e.s_translation);if(j.DotVV(y,y)>4){var v=2/y.Length();f.SelfMul(v)}var S=l*p;S*S>g&&(p*=m/D(S)),_.SelfMulAdd(l,f),d+=l*p,this.m_positions[c].a=d,this.m_velocities[c].w=p;var T=this.m_bodies[c];T.m_sweep.c.Copy(_),T.m_sweep.a=d,T.m_linearVelocity.Copy(f),T.m_angularVelocity=p,T.SynchronizeTransform()}this.Report(a.m_velocityConstraints)},n.Report=function(t){if(null!==this.m_listener)for(var i=0;i<this.m_contactCount;++i){var n=this.m_contacts[i];if(n){var r=t[i],s=e.s_impulse;s.count=r.pointCount;for(var o=0;o<r.pointCount;++o)s.normalImpulses[o]=r.points[o].normalImpulse,s.tangentImpulses[o]=r.points[o].tangentImpulse;this.m_listener.PostSolve(n,s)}}},e}();Fn.s_timer=new it,Fn.s_solverData=new Rn,Fn.s_contactSolverDef=new On,Fn.s_contactSolver=new Ln,Fn.s_translation=new j,Fn.s_impulse=new vn,(Nn=t.b2ParticleFlag||(t.b2ParticleFlag={}))[Nn.b2_waterParticle=0]="b2_waterParticle",Nn[Nn.b2_zombieParticle=2]="b2_zombieParticle",Nn[Nn.b2_wallParticle=4]="b2_wallParticle",Nn[Nn.b2_springParticle=8]="b2_springParticle",Nn[Nn.b2_elasticParticle=16]="b2_elasticParticle",Nn[Nn.b2_viscousParticle=32]="b2_viscousParticle",Nn[Nn.b2_powderParticle=64]="b2_powderParticle",Nn[Nn.b2_tensileParticle=128]="b2_tensileParticle",Nn[Nn.b2_colorMixingParticle=256]="b2_colorMixingParticle",Nn[Nn.b2_destructionListenerParticle=512]="b2_destructionListenerParticle",Nn[Nn.b2_barrierParticle=1024]="b2_barrierParticle",Nn[Nn.b2_staticPressureParticle=2048]="b2_staticPressureParticle",Nn[Nn.b2_reactiveParticle=4096]="b2_reactiveParticle",Nn[Nn.b2_repulsiveParticle=8192]="b2_repulsiveParticle",Nn[Nn.b2_fixtureContactListenerParticle=16384]="b2_fixtureContactListenerParticle",Nn[Nn.b2_particleContactListenerParticle=32768]="b2_particleContactListenerParticle",Nn[Nn.b2_fixtureContactFilterParticle=65536]="b2_fixtureContactFilterParticle",Nn[Nn.b2_particleContactFilterParticle=131072]="b2_particleContactFilterParticle";var kn=function(){this.flags=0,this.position=new j,this.velocity=new j,this.color=new tt(0,0,0,0),this.lifetime=0,this.userData=null,this.group=null};function Vn(t,e,i){return M(Math.ceil(Math.sqrt(t/(.01*e))*i),1,8)}var Gn,Un=function(){function t(){this.m_index=y}var e=t.prototype;return e.GetIndex=function(){return this.m_index},e.SetIndex=function(t){this.m_index=t},t}();(Gn=t.b2ParticleGroupFlag||(t.b2ParticleGroupFlag={}))[Gn.b2_solidParticleGroup=1]="b2_solidParticleGroup",Gn[Gn.b2_rigidParticleGroup=2]="b2_rigidParticleGroup",Gn[Gn.b2_particleGroupCanBeEmpty=4]="b2_particleGroupCanBeEmpty",Gn[Gn.b2_particleGroupWillBeDestroyed=8]="b2_particleGroupWillBeDestroyed",Gn[Gn.b2_particleGroupNeedsUpdateDepth=16]="b2_particleGroupNeedsUpdateDepth",Gn[Gn.b2_particleGroupInternalMask=24]="b2_particleGroupInternalMask";var zn=function(){this.flags=0,this.groupFlags=0,this.position=new j,this.angle=0,this.linearVelocity=new j,this.angularVelocity=0,this.color=new tt,this.strength=1,this.shapeCount=0,this.stride=0,this.particleCount=0,this.lifetime=0,this.userData=null,this.group=null},Hn=function(){function e(t){this.m_firstIndex=0,this.m_lastIndex=0,this.m_groupFlags=0,this.m_strength=1,this.m_prev=null,this.m_next=null,this.m_timestamp=-1,this.m_mass=0,this.m_inertia=0,this.m_center=new j,this.m_linearVelocity=new j,this.m_angularVelocity=0,this.m_transform=new Q,this.m_userData=null,this.m_system=t}var i=e.prototype;return i.GetNext=function(){return this.m_next},i.GetParticleSystem=function(){return this.m_system},i.GetParticleCount=function(){return this.m_lastIndex-this.m_firstIndex},i.GetBufferIndex=function(){return this.m_firstIndex},i.ContainsParticle=function(t){return this.m_firstIndex<=t&&t<this.m_lastIndex},i.GetAllParticleFlags=function(){if(!this.m_system.m_flagsBuffer.data)throw new Error;for(var t=0,e=this.m_firstIndex;e<this.m_lastIndex;e++)t|=this.m_system.m_flagsBuffer.data[e];return t},i.GetGroupFlags=function(){return this.m_groupFlags},i.SetGroupFlags=function(e){e|=this.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupInternalMask,this.m_system.SetGroupFlags(this,e)},i.GetMass=function(){return this.UpdateStatistics(),this.m_mass},i.GetInertia=function(){return this.UpdateStatistics(),this.m_inertia},i.GetCenter=function(){return this.UpdateStatistics(),this.m_center},i.GetLinearVelocity=function(){return this.UpdateStatistics(),this.m_linearVelocity},i.GetAngularVelocity=function(){return this.UpdateStatistics(),this.m_angularVelocity},i.GetTransform=function(){return this.m_transform},i.GetPosition=function(){return this.m_transform.p},i.GetAngle=function(){return this.m_transform.q.GetAngle()},i.GetLinearVelocityFromWorldPoint=function(t,i){var n=e.GetLinearVelocityFromWorldPoint_s_t0;return this.UpdateStatistics(),j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(t,this.m_center,n),i)},i.GetUserData=function(){return this.m_userData},i.SetUserData=function(t){this.m_userData=t},i.ApplyForce=function(t){this.m_system.ApplyForce(this.m_firstIndex,this.m_lastIndex,t)},i.ApplyLinearImpulse=function(t){this.m_system.ApplyLinearImpulse(this.m_firstIndex,this.m_lastIndex,t)},i.DestroyParticles=function(t){if(this.m_system.m_world.IsLocked())throw new Error;for(var e=this.m_firstIndex;e<this.m_lastIndex;e++)this.m_system.DestroyParticle(e,t)},i.UpdateStatistics=function(){if(!this.m_system.m_positionBuffer.data)throw new Error;if(!this.m_system.m_velocityBuffer.data)throw new Error;var t=new j,e=new j;if(this.m_timestamp!==this.m_system.m_timestamp){var i=this.m_system.GetParticleMass();this.m_mass=i*(this.m_lastIndex-this.m_firstIndex),this.m_center.SetZero(),this.m_linearVelocity.SetZero();for(var n=this.m_firstIndex;n<this.m_lastIndex;n++)this.m_center.SelfMulAdd(i,this.m_system.m_positionBuffer.data[n]),this.m_linearVelocity.SelfMulAdd(i,this.m_system.m_velocityBuffer.data[n]);if(this.m_mass>0){var r=1/this.m_mass;this.m_center.SelfMul(r),this.m_linearVelocity.SelfMul(r)}this.m_inertia=0,this.m_angularVelocity=0;for(var s=this.m_firstIndex;s<this.m_lastIndex;s++)j.SubVV(this.m_system.m_positionBuffer.data[s],this.m_center,t),j.SubVV(this.m_system.m_velocityBuffer.data[s],this.m_linearVelocity,e),this.m_inertia+=i*j.DotVV(t,t),this.m_angularVelocity+=i*j.CrossVV(t,e);this.m_inertia>0&&(this.m_angularVelocity*=1/this.m_inertia),this.m_timestamp=this.m_system.m_timestamp}},e}();Hn.GetLinearVelocityFromWorldPoint_s_t0=new j;var Wn=function(){function t(t){this.m_buffer=[],this.m_front=0,this.m_back=0,this.m_buffer.fill(null,0,t)}var e=t.prototype;return e.Push=function(t){if(this.m_back>=this.m_capacity){for(var e=this.m_front;e<this.m_back;e++)this.m_buffer[e-this.m_front]=this.m_buffer[e];this.m_back-=this.m_front,this.m_front=0}this.m_buffer[this.m_back]=t,this.m_back++},e.Pop=function(){this.m_buffer[this.m_front]=null,this.m_front++},e.Empty=function(){return this.m_front===this.m_back},e.Front=function(){var t=this.m_buffer[this.m_front];if(!t)throw new Error;return t},n(t,[{key:"m_capacity",get:function(){return this.m_buffer.length}}]),t}(),jn=function(){function t(t){this.m_generatorCapacity=0,this.m_generatorCount=0,this.m_countX=0,this.m_countY=0,this.m_diagram=[],this.m_generatorBuffer=w(t,(function(){return new Xn})),this.m_generatorCapacity=t}var e=t.prototype;return e.AddGenerator=function(t,e,i){var n=this.m_generatorBuffer[this.m_generatorCount++];n.center.Copy(t),n.tag=e,n.necessary=i},e.Generate=function(t,e){for(var n=1/t,r=new j(+i,+i),s=new j(-i,-i),o=0,a=0;a<this.m_generatorCount;a++){var h=this.m_generatorBuffer[a];h.necessary&&(j.MinV(r,h.center,r),j.MaxV(s,h.center,s),++o)}if(0===o)return this.m_countX=0,void(this.m_countY=0);r.x-=e,r.y-=e,s.x+=e,s.y+=e,this.m_countX=1+Math.floor(n*(s.x-r.x)),this.m_countY=1+Math.floor(n*(s.y-r.y)),this.m_diagram=[];for(var u=new Wn(4*this.m_countX*this.m_countY),l=0;l<this.m_generatorCount;l++){var c=this.m_generatorBuffer[l];c.center.SelfSub(r).SelfMul(n);var _=Math.floor(c.center.x),d=Math.floor(c.center.y);_>=0&&d>=0&&_<this.m_countX&&d<this.m_countY&&u.Push(new qn(_,d,_+d*this.m_countX,c))}for(;!u.Empty();){var f=u.Front(),p=f.m_x,m=f.m_y,g=f.m_i,y=f.m_generator;u.Pop(),this.m_diagram[g]||(this.m_diagram[g]=y,p>0&&u.Push(new qn(p-1,m,g-1,y)),m>0&&u.Push(new qn(p,m-1,g-this.m_countX,y)),p<this.m_countX-1&&u.Push(new qn(p+1,m,g+1,y)),m<this.m_countY-1&&u.Push(new qn(p,m+1,g+this.m_countX,y)))}for(var v=0;v<this.m_countY;v++)for(var S=0;S<this.m_countX-1;S++){var T=S+v*this.m_countX,A=this.m_diagram[T],b=this.m_diagram[T+1];A!==b&&(u.Push(new qn(S,v,T,b)),u.Push(new qn(S+1,v,T+1,A)))}for(var E=0;E<this.m_countY-1;E++)for(var C=0;C<this.m_countX;C++){var w=C+E*this.m_countX,x=this.m_diagram[w],R=this.m_diagram[w+this.m_countX];x!==R&&(u.Push(new qn(C,E,w,R)),u.Push(new qn(C,E+1,w+this.m_countX,x)))}for(;!u.Empty();){var I=u.Front(),B=I.m_x,D=I.m_y,P=I.m_i,O=I.m_generator;u.Pop();var M=this.m_diagram[P],L=O;if(M!==L){var N=M.center.x-B,F=M.center.y-D,k=L.center.x-B,V=L.center.y-D;N*N+F*F>k*k+V*V&&(this.m_diagram[P]=L,B>0&&u.Push(new qn(B-1,D,P-1,L)),D>0&&u.Push(new qn(B,D-1,P-this.m_countX,L)),B<this.m_countX-1&&u.Push(new qn(B+1,D,P+1,L)),D<this.m_countY-1&&u.Push(new qn(B,D+1,P+this.m_countX,L)))}}},e.GetNodes=function(t){for(var e=0;e<this.m_countY-1;e++)for(var i=0;i<this.m_countX-1;i++){var n=i+e*this.m_countX,r=this.m_diagram[n],s=this.m_diagram[n+1],o=this.m_diagram[n+this.m_countX],a=this.m_diagram[n+1+this.m_countX];s!==o&&(r!==s&&r!==o&&(r.necessary||s.necessary||o.necessary)&&t(r.tag,s.tag,o.tag),a!==s&&a!==o&&(r.necessary||s.necessary||o.necessary)&&t(s.tag,a.tag,o.tag))}},t}(),Xn=function(){this.center=new j,this.tag=0,this.necessary=!1},qn=function(t,e,i,n){this.m_x=t,this.m_y=e,this.m_i=i,this.m_generator=n};function Yn(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Kn(t,e){return t<e}function Jn(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===n&&(n=Kn);for(var r=e,s=[],o=0;;){for(;r+1<i;i++){var a=t[r+Math.floor(Math.random()*(i-r))];s[o++]=i;for(var h=r-1;;){for(;n(t[++h],a););for(;n(a,t[--i]););if(h>=i)break;Yn(t,h,i)}}if(0===o)break;r=i,i=s[--o]}return t}function Qn(t,e,i,n){return void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===n&&(n=Kn),Jn(t,e,i,n)}function Zn(t,e,i){void 0===i&&(i=t.length);for(var n=0,r=0;r<i;++r)e(t[r])||(r!==n?Yn(t,n++,r):++n);return n}function $n(t,e,i,n,r){for(var s=i-e;s>0;){var o=Math.floor(s/2),a=e+o;r(t[a],n)?(e=++a,s-=o+1):s=o}return e}function tr(t,e,i,n,r){for(var s=i-e;s>0;){var o=Math.floor(s/2),a=e+o;r(n,t[a])?s=o:(e=++a,s-=o+1)}return e}function er(t,e,i,n){for(var r=i;e!==r;)Yn(t,e++,r++),r===n?r=i:e===i&&(i=r)}var ir=function(){function t(t){this.data=[],this.count=0,this.capacity=0,this.allocator=t}var e=t.prototype;return e.Append=function(){return this.count>=this.capacity&&this.Grow(),this.count++},e.Reserve=function(t){if(!(this.capacity>=t)){for(var e=this.capacity;e<t;++e)this.data[e]=this.allocator();this.capacity=t}},e.Grow=function(){var t=this.capacity?2*this.capacity:T;this.Reserve(t)},e.Free=function(){0!==this.data.length&&(this.data=[],this.capacity=0,this.count=0)},e.Shorten=function(){},e.Data=function(){return this.data},e.GetCount=function(){return this.count},e.SetCount=function(t){this.count=t},e.GetCapacity=function(){return this.capacity},e.RemoveIf=function(t){this.count=Zn(this.data,t,this.count)},e.Unique=function(t){this.count=function(t,e,i,n){if(e===i)return i;for(var r=e;++e!==i;)n(t[r],t[e])||Yn(t,++r,e);return++r}(this.data,0,this.count,t)},t}(),nr=function(t){function e(e){var i;return(i=t.call(this)||this).m_system=e,i}s(e,t);var i=e.prototype;return i.ShouldQueryParticleSystem=function(){return!1},i.ReportFixture=function(t){if(t.IsSensor())return!0;for(var e=t.GetShape().GetChildCount(),i=0;i<e;i++)for(var n=t.GetAABB(i),r=this.m_system.GetInsideBoundsEnumerator(n),s=void 0;(s=r.GetNext())>=0;)this.ReportFixtureAndParticle(t,i,s);return!0},i.ReportParticle=function(){return!1},i.ReportFixtureAndParticle=function(){},e}(Tn),rr=function(){function t(){this.indexA=0,this.indexB=0,this.weight=0,this.normal=new j,this.flags=0}var e=t.prototype;return e.SetIndices=function(t,e){this.indexA=t,this.indexB=e},e.SetWeight=function(t){this.weight=t},e.SetNormal=function(t){this.normal.Copy(t)},e.SetFlags=function(t){this.flags=t},e.GetIndexA=function(){return this.indexA},e.GetIndexB=function(){return this.indexB},e.GetWeight=function(){return this.weight},e.GetNormal=function(){return this.normal},e.GetFlags=function(){return this.flags},e.IsEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&this.weight===t.weight&&this.normal.x===t.normal.x&&this.normal.y===t.normal.y},e.IsNotEqual=function(t){return!this.IsEqual(t)},e.ApproximatelyEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&D(this.weight-t.weight)<.01&&j.DistanceSquaredVV(this.normal,t.normal)<1e-4},t}(),sr=function(){this.index=0,this.weight=0,this.normal=new j,this.mass=0},or=function(){this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0},ar=function(){this.indexA=0,this.indexB=0,this.indexC=0,this.flags=0,this.strength=0,this.pa=new j(0,0),this.pb=new j(0,0),this.pc=new j(0,0),this.ka=0,this.kb=0,this.kc=0,this.s=0},hr=function(){function t(){this.strictContactCheck=!1,this.density=1,this.gravityScale=1,this.radius=1,this.maxCount=0,this.pressureStrength=.005,this.dampingStrength=1,this.elasticStrength=.25,this.springStrength=.25,this.viscousStrength=.25,this.surfaceTensionPressureStrength=.2,this.surfaceTensionNormalStrength=.2,this.repulsiveStrength=1,this.powderStrength=.5,this.ejectionStrength=.5,this.staticPressureStrength=.2,this.staticPressureRelaxation=.2,this.staticPressureIterations=8,this.colorMixingStrength=.5,this.destroyByAge=!0,this.lifetimeGranularity=1/60}var e=t.prototype;return e.Copy=function(t){return this.strictContactCheck=t.strictContactCheck,this.density=t.density,this.gravityScale=t.gravityScale,this.radius=t.radius,this.maxCount=t.maxCount,this.pressureStrength=t.pressureStrength,this.dampingStrength=t.dampingStrength,this.elasticStrength=t.elasticStrength,this.springStrength=t.springStrength,this.viscousStrength=t.viscousStrength,this.surfaceTensionPressureStrength=t.surfaceTensionPressureStrength,this.surfaceTensionNormalStrength=t.surfaceTensionNormalStrength,this.repulsiveStrength=t.repulsiveStrength,this.powderStrength=t.powderStrength,this.ejectionStrength=t.ejectionStrength,this.staticPressureStrength=t.staticPressureStrength,this.staticPressureRelaxation=t.staticPressureRelaxation,this.staticPressureIterations=t.staticPressureIterations,this.colorMixingStrength=t.colorMixingStrength,this.destroyByAge=t.destroyByAge,this.lifetimeGranularity=t.lifetimeGranularity,this},e.Clone=function(){return(new t).Copy(this)},t}(),ur=function(){function n(t,e){this.m_paused=!1,this.m_timestamp=0,this.m_allParticleFlags=0,this.m_needsUpdateAllParticleFlags=!1,this.m_allGroupFlags=0,this.m_needsUpdateAllGroupFlags=!1,this.m_hasForce=!1,this.m_iterationIndex=0,this.m_inverseDensity=0,this.m_particleDiameter=0,this.m_inverseDiameter=0,this.m_squaredDiameter=0,this.m_count=0,this.m_internalAllocatedCapacity=0,this.m_handleIndexBuffer=new lr,this.m_flagsBuffer=new lr,this.m_positionBuffer=new lr,this.m_velocityBuffer=new lr,this.m_forceBuffer=[],this.m_weightBuffer=[],this.m_staticPressureBuffer=[],this.m_accumulationBuffer=[],this.m_accumulation2Buffer=[],this.m_depthBuffer=[],this.m_colorBuffer=new lr,this.m_groupBuffer=[],this.m_userDataBuffer=new lr,this.m_stuckThreshold=0,this.m_lastBodyContactStepBuffer=new lr,this.m_bodyContactCountBuffer=new lr,this.m_consecutiveContactStepsBuffer=new lr,this.m_stuckParticleBuffer=new ir((function(){return 0})),this.m_proxyBuffer=new ir((function(){return new cr})),this.m_contactBuffer=new ir((function(){return new rr})),this.m_bodyContactBuffer=new ir((function(){return new sr})),this.m_pairBuffer=new ir((function(){return new or})),this.m_triadBuffer=new ir((function(){return new ar})),this.m_expirationTimeBuffer=new lr,this.m_indexByExpirationTimeBuffer=new lr,this.m_timeElapsed=0,this.m_expirationTimeBufferRequiresSorting=!1,this.m_groupCount=0,this.m_groupList=null,this.m_def=new hr,this.m_prev=null,this.m_next=null,this.UpdateBodyContacts_callback=null,this.SolveCollision_callback=null,this.SetStrictContactCheck(t.strictContactCheck),this.SetDensity(t.density),this.SetGravityScale(t.gravityScale),this.SetRadius(t.radius),this.SetMaxParticleCount(t.maxCount),this.m_def=t.Clone(),this.m_world=e,this.SetDestructionByAge(this.m_def.destroyByAge)}n.computeTag=function(t,e){return(e+n.yOffset>>>0<<n.yShift)+(n.xScale*t+n.xOffset>>>0)>>>0},n.computeRelativeTag=function(t,e,i){return t+(i<<n.yShift)+(e<<n.xShift)>>>0};var r=n.prototype;return r.Drop=function(){for(;this.m_groupList;)this.DestroyParticleGroup(this.m_groupList);this.FreeUserOverridableBuffer(this.m_handleIndexBuffer),this.FreeUserOverridableBuffer(this.m_flagsBuffer),this.FreeUserOverridableBuffer(this.m_lastBodyContactStepBuffer),this.FreeUserOverridableBuffer(this.m_bodyContactCountBuffer),this.FreeUserOverridableBuffer(this.m_consecutiveContactStepsBuffer),this.FreeUserOverridableBuffer(this.m_positionBuffer),this.FreeUserOverridableBuffer(this.m_velocityBuffer),this.FreeUserOverridableBuffer(this.m_colorBuffer),this.FreeUserOverridableBuffer(this.m_userDataBuffer),this.FreeUserOverridableBuffer(this.m_expirationTimeBuffer),this.FreeUserOverridableBuffer(this.m_indexByExpirationTimeBuffer),this.FreeBuffer(this.m_forceBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_weightBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_staticPressureBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulationBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulation2Buffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_depthBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_groupBuffer,this.m_internalAllocatedCapacity)},r.CreateParticle=function(t){if(this.m_world.IsLocked())throw new Error;if(this.m_count>=this.m_internalAllocatedCapacity){var i=this.m_count?2*this.m_count:T;this.ReallocateInternalAllocatedBuffers(i)}if(this.m_count>=this.m_internalAllocatedCapacity){if(!this.m_def.destroyByAge)return y;this.DestroyOldestParticle(0,!1),this.SolveZombie()}var n=this.m_count++;this.m_flagsBuffer.data[n]=0,this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[n]=0),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[n]=0),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[n]=0),this.m_positionBuffer.data[n]=(this.m_positionBuffer.data[n]||new j).Copy(e(t.position,j.ZERO)),this.m_velocityBuffer.data[n]=(this.m_velocityBuffer.data[n]||new j).Copy(e(t.velocity,j.ZERO)),this.m_weightBuffer[n]=0,this.m_forceBuffer[n]=(this.m_forceBuffer[n]||new j).SetZero(),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[n]=0),this.m_depthBuffer&&(this.m_depthBuffer[n]=0);var r=(new tt).Copy(e(t.color,tt.ZERO));!this.m_colorBuffer.data&&r.IsZero()||(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data[n]=(this.m_colorBuffer.data[n]||new tt).Copy(r)),(this.m_userDataBuffer.data||t.userData)&&(this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data[n]=t.userData),this.m_handleIndexBuffer.data&&(this.m_handleIndexBuffer.data[n]=null);var s=this.m_proxyBuffer.data[this.m_proxyBuffer.Append()],o=e(t.lifetime,0),a=o>0;(this.m_expirationTimeBuffer.data||a)&&(this.SetParticleLifetime(n,a?o:this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed())),this.m_indexByExpirationTimeBuffer.data[n]=n),s.index=n;var h=e(t.group,null);return this.m_groupBuffer[n]=h,h&&(h.m_firstIndex<h.m_lastIndex?(this.RotateBuffer(h.m_firstIndex,h.m_lastIndex,n),h.m_lastIndex=n+1):(h.m_firstIndex=n,h.m_lastIndex=n+1)),this.SetParticleFlags(n,e(t.flags,0)),n},r.GetParticleHandleFromIndex=function(t){this.m_handleIndexBuffer.data=this.RequestBuffer(this.m_handleIndexBuffer.data);var e=this.m_handleIndexBuffer.data[t];return e||((e=new Un).SetIndex(t),this.m_handleIndexBuffer.data[t]=e,e)},r.DestroyParticle=function(e,i){void 0===i&&(i=!1);var n=t.b2ParticleFlag.b2_zombieParticle;i&&(n|=t.b2ParticleFlag.b2_destructionListenerParticle),this.SetParticleFlags(e,this.m_flagsBuffer.data[e]|n)},r.DestroyOldestParticle=function(t,e){void 0===e&&(e=!1);var i=this.GetParticleCount(),n=this.m_indexByExpirationTimeBuffer.data[i-(t+1)],r=this.m_indexByExpirationTimeBuffer.data[t];this.DestroyParticle(this.m_expirationTimeBuffer.data[n]>0?n:r,e)},r.DestroyParticlesInShape=function(t,e,i){void 0===i&&(i=!1);var r=n.DestroyParticlesInShape_s_aabb;if(this.m_world.IsLocked())throw new Error;var s=new yr(this,t,e,i),o=r;return t.ComputeAABB(o,e,0),this.m_world.QueryAABB(s,o),s.Destroyed()},r.CreateParticleGroup=function(t){var i=n.CreateParticleGroup_s_transform;if(this.m_world.IsLocked())throw new Error;var r=i;r.SetPositionAngle(e(t.position,j.ZERO),e(t.angle,0));var s=this.m_count;if(t.shape&&this.CreateParticlesWithShapeForGroup(t.shape,t,r),t.shapes&&this.CreateParticlesWithShapesForGroup(t.shapes,e(t.shapeCount,t.shapes.length),t,r),t.positionData)for(var o=e(t.particleCount,t.positionData.length),a=0;a<o;a++){var h=t.positionData[a];this.CreateParticleForGroup(t,r,h)}var u=this.m_count,l=new Hn(this);l.m_firstIndex=s,l.m_lastIndex=u,l.m_strength=e(t.strength,1),l.m_userData=t.userData,l.m_transform.Copy(r),l.m_prev=null,l.m_next=this.m_groupList,this.m_groupList&&(this.m_groupList.m_prev=l),this.m_groupList=l,++this.m_groupCount;for(var c=s;c<u;c++)this.m_groupBuffer[c]=l;this.SetGroupFlags(l,e(t.groupFlags,0));var _=new gr;return this.UpdateContacts(!0),this.UpdatePairsAndTriads(s,u,_),t.group&&(this.JoinParticleGroups(t.group,l),l=t.group),l},r.JoinParticleGroups=function(t,e){if(this.m_world.IsLocked())throw new Error;this.RotateBuffer(e.m_firstIndex,e.m_lastIndex,this.m_count),this.RotateBuffer(t.m_firstIndex,t.m_lastIndex,e.m_firstIndex);var i=new vr(e.m_firstIndex);this.UpdateContacts(!0),this.UpdatePairsAndTriads(t.m_firstIndex,e.m_lastIndex,i);for(var n=e.m_firstIndex;n<e.m_lastIndex;n++)this.m_groupBuffer[n]=t;var r=t.m_groupFlags|e.m_groupFlags;this.SetGroupFlags(t,r),t.m_lastIndex=e.m_lastIndex,e.m_firstIndex=e.m_lastIndex,this.DestroyParticleGroup(e)},r.SplitParticleGroup=function(t){this.UpdateContacts(!0);var e=w(t.GetParticleCount(),(function(){return new dr}));n.InitializeParticleLists(t,e),this.MergeParticleListsInContact(t,e);var i=n.FindLongestParticleList(t,e);this.MergeZombieParticleListNodes(t,e,i),this.CreateParticleGroupsFromParticleList(t,e,i),this.UpdatePairsAndTriadsWithParticleList(t,e)},r.GetParticleGroupList=function(){return this.m_groupList},r.GetParticleGroupCount=function(){return this.m_groupCount},r.GetParticleCount=function(){return this.m_count},r.GetMaxParticleCount=function(){return this.m_def.maxCount},r.SetMaxParticleCount=function(t){this.m_def.maxCount=t},r.GetAllParticleFlags=function(){return this.m_allParticleFlags},r.GetAllGroupFlags=function(){return this.m_allGroupFlags},r.SetPaused=function(t){this.m_paused=t},r.GetPaused=function(){return this.m_paused},r.SetDensity=function(t){this.m_def.density=t,this.m_inverseDensity=1/this.m_def.density},r.GetDensity=function(){return this.m_def.density},r.SetGravityScale=function(t){this.m_def.gravityScale=t},r.GetGravityScale=function(){return this.m_def.gravityScale},r.SetDamping=function(t){this.m_def.dampingStrength=t},r.GetDamping=function(){return this.m_def.dampingStrength},r.SetStaticPressureIterations=function(t){this.m_def.staticPressureIterations=t},r.GetStaticPressureIterations=function(){return this.m_def.staticPressureIterations},r.SetRadius=function(t){this.m_particleDiameter=2*t,this.m_squaredDiameter=this.m_particleDiameter*this.m_particleDiameter,this.m_inverseDiameter=1/this.m_particleDiameter},r.GetRadius=function(){return this.m_particleDiameter/2},r.GetPositionBuffer=function(){return this.m_positionBuffer.data},r.GetVelocityBuffer=function(){return this.m_velocityBuffer.data},r.GetColorBuffer=function(){return this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data},r.GetGroupBuffer=function(){return this.m_groupBuffer},r.GetWeightBuffer=function(){return this.m_weightBuffer},r.GetUserDataBuffer=function(){return this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data},r.GetFlagsBuffer=function(){return this.m_flagsBuffer.data},r.SetParticleFlags=function(e,i){this.m_flagsBuffer.data[e]&~i&&(this.m_needsUpdateAllParticleFlags=!0),~this.m_allParticleFlags&i&&(i&t.b2ParticleFlag.b2_tensileParticle&&(this.m_accumulation2Buffer=this.RequestBuffer(this.m_accumulation2Buffer)),i&t.b2ParticleFlag.b2_colorMixingParticle&&(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data)),this.m_allParticleFlags|=i),this.m_flagsBuffer.data[e]=i},r.GetParticleFlags=function(t){return this.m_flagsBuffer.data[t]},r.SetFlagsBuffer=function(t){this.SetUserOverridableBuffer(this.m_flagsBuffer,t)},r.SetPositionBuffer=function(t){if(t instanceof Float32Array){if(t.length%2!=0)throw new Error;for(var e=t.length/2,i=new Array(e),n=0;n<e;++n)i[n]=new j(t.subarray(2*n,2*n+2));t=i}this.SetUserOverridableBuffer(this.m_positionBuffer,t)},r.SetVelocityBuffer=function(t){if(t instanceof Float32Array){if(t.length%2!=0)throw new Error;for(var e=t.length/2,i=new Array(e),n=0;n<e;++n)i[n]=new j(t.subarray(2*n,2*n+2));t=i}this.SetUserOverridableBuffer(this.m_velocityBuffer,t)},r.SetColorBuffer=function(t){if(t instanceof Float32Array){if(t.length%4!=0)throw new Error;for(var e=t.length/4,i=new Array(e),n=0;n<e;++n)i[n]=new tt(t.subarray(4*n,4*n+4));t=i}this.SetUserOverridableBuffer(this.m_colorBuffer,t)},r.SetUserDataBuffer=function(t){this.SetUserOverridableBuffer(this.m_userDataBuffer,t)},r.GetContacts=function(){return this.m_contactBuffer.data},r.GetContactCount=function(){return this.m_contactBuffer.count},r.GetBodyContacts=function(){return this.m_bodyContactBuffer.data},r.GetBodyContactCount=function(){return this.m_bodyContactBuffer.count},r.GetPairs=function(){return this.m_pairBuffer.data},r.GetPairCount=function(){return this.m_pairBuffer.count},r.GetTriads=function(){return this.m_triadBuffer.data},r.GetTriadCount=function(){return this.m_triadBuffer.count},r.SetStuckThreshold=function(t){this.m_stuckThreshold=t,t>0&&(this.m_lastBodyContactStepBuffer.data=this.RequestBuffer(this.m_lastBodyContactStepBuffer.data),this.m_bodyContactCountBuffer.data=this.RequestBuffer(this.m_bodyContactCountBuffer.data),this.m_consecutiveContactStepsBuffer.data=this.RequestBuffer(this.m_consecutiveContactStepsBuffer.data))},r.GetStuckCandidates=function(){return this.m_stuckParticleBuffer.Data()},r.GetStuckCandidateCount=function(){return this.m_stuckParticleBuffer.GetCount()},r.ComputeCollisionEnergy=function(){for(var t=n.ComputeCollisionEnergy_s_v,e=this.m_velocityBuffer.data,i=0,r=0;r<this.m_contactBuffer.count;r++){var s=this.m_contactBuffer.data[r],o=s.indexA,a=s.indexB,h=s.normal,u=j.SubVV(e[a],e[o],t),l=j.DotVV(u,h);l<0&&(i+=l*l)}return.5*this.GetParticleMass()*i},r.SetStrictContactCheck=function(t){this.m_def.strictContactCheck=t},r.GetStrictContactCheck=function(){return this.m_def.strictContactCheck},r.SetParticleLifetime=function(t,e){var i=null===this.m_indexByExpirationTimeBuffer.data;if(this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data),this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data),i)for(var n=this.GetParticleCount(),r=0;r<n;++r)this.m_indexByExpirationTimeBuffer.data[r]=r;var s=e/this.m_def.lifetimeGranularity,o=s>0?this.GetQuantizedTimeElapsed()+s:s;o!==this.m_expirationTimeBuffer.data[t]&&(this.m_expirationTimeBuffer.data[t]=o,this.m_expirationTimeBufferRequiresSorting=!0)},r.GetParticleLifetime=function(t){return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[t])},r.SetDestructionByAge=function(t){t&&this.GetExpirationTimeBuffer(),this.m_def.destroyByAge=t},r.GetDestructionByAge=function(){return this.m_def.destroyByAge},r.GetExpirationTimeBuffer=function(){return this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data),this.m_expirationTimeBuffer.data},r.ExpirationTimeToLifetime=function(t){return(t>0?t-this.GetQuantizedTimeElapsed():t)*this.m_def.lifetimeGranularity},r.GetIndexByExpirationTimeBuffer=function(){return this.GetParticleCount()?this.SetParticleLifetime(0,this.GetParticleLifetime(0)):this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data),this.m_indexByExpirationTimeBuffer.data},r.ParticleApplyLinearImpulse=function(t,e){this.ApplyLinearImpulse(t,t+1,e)},r.ApplyLinearImpulse=function(t,e,i){for(var n=this.m_velocityBuffer.data,r=(e-t)*this.GetParticleMass(),s=(new j).Copy(i).SelfMul(1/r),o=t;o<e;o++)n[o].SelfAdd(s)},n.IsSignificantForce=function(t){return 0!==t.x||0!==t.y},r.ParticleApplyForce=function(t,e){n.IsSignificantForce(e)&&this.ForceCanBeApplied(this.m_flagsBuffer.data[t])&&(this.PrepareForceBuffer(),this.m_forceBuffer[t].SelfAdd(e))},r.ApplyForce=function(t,e,i){var r=(new j).Copy(i).SelfMul(1/(e-t));if(n.IsSignificantForce(r)){this.PrepareForceBuffer();for(var s=t;s<e;s++)this.m_forceBuffer[s].SelfAdd(r)}},r.GetNext=function(){return this.m_next},r.QueryAABB=function(t,e){if(0!==this.m_proxyBuffer.count)for(var i=this.m_proxyBuffer.count,r=$n(this.m_proxyBuffer.data,0,i,n.computeTag(this.m_inverseDiameter*e.lowerBound.x,this.m_inverseDiameter*e.lowerBound.y),cr.CompareProxyTag),s=tr(this.m_proxyBuffer.data,r,i,n.computeTag(this.m_inverseDiameter*e.upperBound.x,this.m_inverseDiameter*e.upperBound.y),cr.CompareTagProxy),o=this.m_positionBuffer.data,a=r;a<s;++a){var h=this.m_proxyBuffer.data[a].index,u=o[h];if(e.lowerBound.x<u.x&&u.x<e.upperBound.x&&e.lowerBound.y<u.y&&u.y<e.upperBound.y&&!t.ReportParticle(this,h))break}},r.QueryShapeAABB=function(t,e,i,r){void 0===r&&(r=0);var s=n.QueryShapeAABB_s_aabb;e.ComputeAABB(s,i,r),this.QueryAABB(t,s)},r.QueryPointAABB=function(t,e,i){void 0===i&&(i=l);var r=n.QueryPointAABB_s_aabb;r.lowerBound.Set(e.x-i,e.y-i),r.upperBound.Set(e.x+i,e.y+i),this.QueryAABB(t,r)},r.RayCast=function(t,e,i){var r=n.RayCast_s_aabb,s=n.RayCast_s_p,o=n.RayCast_s_v,a=n.RayCast_s_n,h=n.RayCast_s_point;if(0!==this.m_proxyBuffer.count){var u=this.m_positionBuffer.data,l=r;j.MinV(e,i,l.lowerBound),j.MaxV(e,i,l.upperBound);for(var c,_=1,d=j.SubVV(i,e,o),f=j.DotVV(d,d),p=this.GetInsideBoundsEnumerator(l);(c=p.GetNext())>=0;){var m=j.SubVV(e,u[c],s),g=j.DotVV(m,d),y=g*g-f*(j.DotVV(m,m)-this.m_squaredDiameter);if(y>=0){var v=k(y),S=(-g-v)/f;if(S>_)continue;if(S<0&&((S=(-g+v)/f)<0||S>_))continue;var T=j.AddVMulSV(m,S,d,a);if(T.Normalize(),(_=P(_,t.ReportParticle(this,c,j.AddVMulSV(e,S,d,h),T,S)))<=0)break}}}},r.ComputeAABB=function(t){var e=this.GetParticleCount();t.lowerBound.x=+i,t.lowerBound.y=+i,t.upperBound.x=-i,t.upperBound.y=-i;for(var n=this.m_positionBuffer.data,r=0;r<e;r++){var s=n[r];j.MinV(t.lowerBound,s,t.lowerBound),j.MaxV(t.upperBound,s,t.upperBound)}t.lowerBound.x-=this.m_particleDiameter,t.lowerBound.y-=this.m_particleDiameter,t.upperBound.x+=this.m_particleDiameter,t.upperBound.y+=this.m_particleDiameter},r.FreeBuffer=function(t){null!==t&&(t.length=0)},r.FreeUserOverridableBuffer=function(t){0===t.userSuppliedCapacity&&this.FreeBuffer(t.data,this.m_internalAllocatedCapacity)},r.ReallocateBuffer3=function(t,e,i){if(i<=e)throw new Error;var n=t?t.slice():[];return n.length=i,n},r.ReallocateBuffer5=function(t,e,i,n,r){if(n<=i)throw new Error;if(e&&!(n<=e))throw new Error;return r&&!t||e||(t=this.ReallocateBuffer3(t,i,n)),t},r.ReallocateBuffer4=function(t,e,i,n){return this.ReallocateBuffer5(t.data,t.userSuppliedCapacity,e,i,n)},r.RequestBuffer=function(t){return t||(0===this.m_internalAllocatedCapacity&&this.ReallocateInternalAllocatedBuffers(T),(t=[]).length=this.m_internalAllocatedCapacity),t},r.ReallocateHandleBuffers=function(t){this.m_handleIndexBuffer.data=this.ReallocateBuffer4(this.m_handleIndexBuffer,this.m_internalAllocatedCapacity,t,!0)},r.ReallocateInternalAllocatedBuffers=function(t){function e(t,e){return e&&t>e?e:t}if(t=e(t,this.m_def.maxCount),t=e(t,this.m_flagsBuffer.userSuppliedCapacity),t=e(t,this.m_positionBuffer.userSuppliedCapacity),t=e(t,this.m_velocityBuffer.userSuppliedCapacity),t=e(t,this.m_colorBuffer.userSuppliedCapacity),t=e(t,this.m_userDataBuffer.userSuppliedCapacity),this.m_internalAllocatedCapacity<t){this.ReallocateHandleBuffers(t),this.m_flagsBuffer.data=this.ReallocateBuffer4(this.m_flagsBuffer,this.m_internalAllocatedCapacity,t,!1);var i=this.m_stuckThreshold>0;this.m_lastBodyContactStepBuffer.data=this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer,this.m_internalAllocatedCapacity,t,i),this.m_bodyContactCountBuffer.data=this.ReallocateBuffer4(this.m_bodyContactCountBuffer,this.m_internalAllocatedCapacity,t,i),this.m_consecutiveContactStepsBuffer.data=this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer,this.m_internalAllocatedCapacity,t,i),this.m_positionBuffer.data=this.ReallocateBuffer4(this.m_positionBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_velocityBuffer.data=this.ReallocateBuffer4(this.m_velocityBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_forceBuffer=this.ReallocateBuffer5(this.m_forceBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_weightBuffer=this.ReallocateBuffer5(this.m_weightBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_staticPressureBuffer=this.ReallocateBuffer5(this.m_staticPressureBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_accumulationBuffer=this.ReallocateBuffer5(this.m_accumulationBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_accumulation2Buffer=this.ReallocateBuffer5(this.m_accumulation2Buffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_depthBuffer=this.ReallocateBuffer5(this.m_depthBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_colorBuffer.data=this.ReallocateBuffer4(this.m_colorBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_groupBuffer=this.ReallocateBuffer5(this.m_groupBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_userDataBuffer.data=this.ReallocateBuffer4(this.m_userDataBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_expirationTimeBuffer.data=this.ReallocateBuffer4(this.m_expirationTimeBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_indexByExpirationTimeBuffer.data=this.ReallocateBuffer4(this.m_indexByExpirationTimeBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_internalAllocatedCapacity=t}},r.CreateParticleForGroup=function(t,i,n){var r=new kn;r.flags=e(t.flags,0),Q.MulXV(i,n,r.position),j.AddVV(e(t.linearVelocity,j.ZERO),j.CrossSV(e(t.angularVelocity,0),j.SubVV(r.position,e(t.position,j.ZERO),j.s_t0),j.s_t0),r.velocity),r.color.Copy(e(t.color,tt.ZERO)),r.lifetime=e(t.lifetime,0),r.userData=t.userData,this.CreateParticle(r)},r.CreateParticlesStrokeShapeForGroup=function(i,r,s){var o=n.CreateParticlesStrokeShapeForGroup_s_edge,a=n.CreateParticlesStrokeShapeForGroup_s_d,h=n.CreateParticlesStrokeShapeForGroup_s_p,u=e(r.stride,0);0===u&&(u=this.GetParticleStride());for(var l=0,c=i.GetChildCount(),_=0;_<c;_++){var d=null;i.GetType()===t.b2ShapeType.e_edgeShape?d=i:(d=o,i.GetChildEdge(d,_));for(var f=j.SubVV(d.m_vertex2,d.m_vertex1,a),p=f.Length();l<p;){var m=j.AddVMulSV(d.m_vertex1,l/p,f,h);this.CreateParticleForGroup(r,s,m),l+=u}l-=p}},r.CreateParticlesFillShapeForGroup=function(t,i,r){var s=n.CreateParticlesFillShapeForGroup_s_aabb,o=n.CreateParticlesFillShapeForGroup_s_p,a=e(i.stride,0);0===a&&(a=this.GetParticleStride());var h=Q.IDENTITY,u=s;t.ComputeAABB(u,h,0);for(var l=Math.floor(u.lowerBound.y/a)*a;l<u.upperBound.y;l+=a)for(var c=Math.floor(u.lowerBound.x/a)*a;c<u.upperBound.x;c+=a){var _=o.Set(c,l);t.TestPoint(h,_)&&this.CreateParticleForGroup(i,r,_)}},r.CreateParticlesWithShapeForGroup=function(e,i,n){switch(e.GetType()){case t.b2ShapeType.e_edgeShape:case t.b2ShapeType.e_chainShape:this.CreateParticlesStrokeShapeForGroup(e,i,n);break;case t.b2ShapeType.e_polygonShape:case t.b2ShapeType.e_circleShape:this.CreateParticlesFillShapeForGroup(e,i,n)}},r.CreateParticlesWithShapesForGroup=function(t,e,i,n){var r=new Sr(t,e);this.CreateParticlesFillShapeForGroup(r,i,n)},r.CloneParticle=function(t,e){var i=new kn;i.flags=this.m_flagsBuffer.data[t],i.position.Copy(this.m_positionBuffer.data[t]),i.velocity.Copy(this.m_velocityBuffer.data[t]),this.m_colorBuffer.data&&i.color.Copy(this.m_colorBuffer.data[t]),this.m_userDataBuffer.data&&(i.userData=this.m_userDataBuffer.data[t]),i.group=e;var n=this.CreateParticle(i);if(this.m_handleIndexBuffer.data){var r=this.m_handleIndexBuffer.data[t];r&&r.SetIndex(n),this.m_handleIndexBuffer.data[n]=r,this.m_handleIndexBuffer.data[t]=null}return this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[n]=this.m_lastBodyContactStepBuffer.data[t]),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[n]=this.m_bodyContactCountBuffer.data[t]),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[n]=this.m_consecutiveContactStepsBuffer.data[t]),this.m_hasForce&&this.m_forceBuffer[n].Copy(this.m_forceBuffer[t]),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[n]=this.m_staticPressureBuffer[t]),this.m_depthBuffer&&(this.m_depthBuffer[n]=this.m_depthBuffer[t]),this.m_expirationTimeBuffer.data&&(this.m_expirationTimeBuffer.data[n]=this.m_expirationTimeBuffer.data[t]),n},r.DestroyParticlesInGroup=function(t,e){void 0===e&&(e=!1);for(var i=t.m_firstIndex;i<t.m_lastIndex;i++)this.DestroyParticle(i,e)},r.DestroyParticleGroup=function(t){this.m_world.m_destructionListener&&this.m_world.m_destructionListener.SayGoodbyeParticleGroup(t),this.SetGroupFlags(t,0);for(var e=t.m_firstIndex;e<t.m_lastIndex;e++)this.m_groupBuffer[e]=null;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_groupList&&(this.m_groupList=t.m_next),--this.m_groupCount},n.ParticleCanBeConnected=function(e,i){return 0!=(e&(t.b2ParticleFlag.b2_wallParticle|t.b2ParticleFlag.b2_springParticle|t.b2ParticleFlag.b2_elasticParticle))||null!==i&&0!=(i.GetGroupFlags()&t.b2ParticleGroupFlag.b2_rigidParticleGroup)},r.UpdatePairsAndTriads=function(e,i,r){for(var s=n.UpdatePairsAndTriads_s_dab,o=n.UpdatePairsAndTriads_s_dbc,a=n.UpdatePairsAndTriads_s_dca,h=this.m_positionBuffer.data,u=0,l=e;l<i;l++)u|=this.m_flagsBuffer.data[l];if(u&n.k_pairFlags)for(var c=0;c<this.m_contactBuffer.count;c++){var _=this.m_contactBuffer.data[c],d=_.indexA,f=_.indexB,p=this.m_flagsBuffer.data[d],m=this.m_flagsBuffer.data[f],g=this.m_groupBuffer[d],y=this.m_groupBuffer[f];if(d>=e&&d<i&&f>=e&&f<i&&!((p|m)&t.b2ParticleFlag.b2_zombieParticle)&&(p|m)&n.k_pairFlags&&(r.IsNecessary(d)||r.IsNecessary(f))&&n.ParticleCanBeConnected(p,g)&&n.ParticleCanBeConnected(m,y)&&r.ShouldCreatePair(d,f)){var v=this.m_pairBuffer.data[this.m_pairBuffer.Append()];v.indexA=d,v.indexB=f,v.flags=_.flags,v.strength=P(g?g.m_strength:1,y?y.m_strength:1),v.distance=j.DistanceVV(h[d],h[f])}Qn(this.m_pairBuffer.data,0,this.m_pairBuffer.count,n.ComparePairIndices),this.m_pairBuffer.Unique(n.MatchPairIndices)}if(u&n.k_triadFlags){for(var S=new jn(i-e),T=e;T<i;T++){var A=this.m_flagsBuffer.data[T],b=this.m_groupBuffer[T];A&t.b2ParticleFlag.b2_zombieParticle||!n.ParticleCanBeConnected(A,b)||S.AddGenerator(h[T],T,r.IsNecessary(T))}var E=this.GetParticleStride();S.Generate(E/2,2*E);var C=this;S.GetNodes((function(t,e,i){var u=C.m_flagsBuffer.data[t],l=C.m_flagsBuffer.data[e],c=C.m_flagsBuffer.data[i];if((u|l|c)&n.k_triadFlags&&r.ShouldCreateTriad(t,e,i)){var _=h[t],d=h[e],f=h[i],p=j.SubVV(_,d,s),m=j.SubVV(d,f,o),g=j.SubVV(f,_,a),y=4*C.m_squaredDiameter;if(j.DotVV(p,p)>y||j.DotVV(m,m)>y||j.DotVV(g,g)>y)return;var v=C.m_groupBuffer[t],S=C.m_groupBuffer[e],T=C.m_groupBuffer[i],A=C.m_triadBuffer.data[C.m_triadBuffer.Append()];A.indexA=t,A.indexB=e,A.indexC=i,A.flags=u|l|c,A.strength=P(P(v?v.m_strength:1,S?S.m_strength:1),T?T.m_strength:1);var b=(_.x+d.x+f.x)/3,E=(_.y+d.y+f.y)/3;A.pa.x=_.x-b,A.pa.y=_.y-E,A.pb.x=d.x-b,A.pb.y=d.y-E,A.pc.x=f.x-b,A.pc.y=f.y-E,A.ka=-j.DotVV(g,p),A.kb=-j.DotVV(p,m),A.kc=-j.DotVV(m,g),A.s=j.CrossVV(_,d)+j.CrossVV(d,f)+j.CrossVV(f,_)}})),Qn(this.m_triadBuffer.data,0,this.m_triadBuffer.count,n.CompareTriadIndices),this.m_triadBuffer.Unique(n.MatchTriadIndices)}},r.UpdatePairsAndTriadsWithReactiveParticles=function(){var e=new Tr(this.m_flagsBuffer);this.UpdatePairsAndTriads(0,this.m_count,e);for(var i=0;i<this.m_count;i++)this.m_flagsBuffer.data[i]&=~t.b2ParticleFlag.b2_reactiveParticle;this.m_allParticleFlags&=~t.b2ParticleFlag.b2_reactiveParticle},n.ComparePairIndices=function(t,e){var i=t.indexA-e.indexA;return 0!==i?i<0:t.indexB<e.indexB},n.MatchPairIndices=function(t,e){return t.indexA===e.indexA&&t.indexB===e.indexB},n.CompareTriadIndices=function(t,e){var i=t.indexA-e.indexA;if(0!==i)return i<0;var n=t.indexB-e.indexB;return 0!==n?n<0:t.indexC<e.indexC},n.MatchTriadIndices=function(t,e){return t.indexA===e.indexA&&t.indexB===e.indexB&&t.indexC===e.indexC},n.InitializeParticleLists=function(t,e){for(var i=t.GetBufferIndex(),n=t.GetParticleCount(),r=0;r<n;r++){var s=e[r];s.list=s,s.next=null,s.count=1,s.index=r+i}},r.MergeParticleListsInContact=function(t,e){for(var i=t.GetBufferIndex(),r=0;r<this.m_contactBuffer.count;r++){var s=this.m_contactBuffer.data[r],o=s.indexA,a=s.indexB;if(t.ContainsParticle(o)&&t.ContainsParticle(a)){var h=e[o-i].list,u=e[a-i].list;if(h!==u){if(h.count<u.count){var l=h;h=u,u=l}n.MergeParticleLists(h,u)}}}},n.MergeParticleLists=function(t,e){for(var i=e;;){i.list=t;var n=i.next;if(!n){i.next=t.next;break}i=n}t.next=e,t.count+=e.count,e.count=0},n.FindLongestParticleList=function(t,e){for(var i=t.GetParticleCount(),n=e[0],r=0;r<i;r++){var s=e[r];n.count<s.count&&(n=s)}return n},r.MergeZombieParticleListNodes=function(e,i,r){for(var s=e.GetParticleCount(),o=0;o<s;o++){var a=i[o];a!==r&&this.m_flagsBuffer.data[a.index]&t.b2ParticleFlag.b2_zombieParticle&&n.MergeParticleListAndNode(r,a)}},n.MergeParticleListAndNode=function(t,e){e.list=t,e.next=t.next,t.next=e,t.count++,e.count=0},r.CreateParticleGroupsFromParticleList=function(e,i,n){var r=e.GetParticleCount(),s=new zn;s.groupFlags=e.GetGroupFlags(),s.userData=e.GetUserData();for(var o=0;o<r;o++){var a=i[o];if(a.count&&a!==n)for(var h=this.CreateParticleGroup(s),u=a;u;u=u.next){var l=u.index,c=this.CloneParticle(l,h);this.m_flagsBuffer.data[l]|=t.b2ParticleFlag.b2_zombieParticle,u.index=c}}},r.UpdatePairsAndTriadsWithParticleList=function(t,e){for(var i=t.GetBufferIndex(),n=0;n<this.m_pairBuffer.count;n++){var r=this.m_pairBuffer.data[n],s=r.indexA,o=r.indexB;t.ContainsParticle(s)&&(r.indexA=e[s-i].index),t.ContainsParticle(o)&&(r.indexB=e[o-i].index)}for(var a=0;a<this.m_triadBuffer.count;a++){var h=this.m_triadBuffer.data[a],u=h.indexA,l=h.indexB,c=h.indexC;t.ContainsParticle(u)&&(h.indexA=e[u-i].index),t.ContainsParticle(l)&&(h.indexB=e[l-i].index),t.ContainsParticle(c)&&(h.indexC=e[c-i].index)}},r.ComputeDepth=function(){for(var e=[],n=0,r=0;r<this.m_contactBuffer.count;r++){var s=this.m_contactBuffer.data[r],o=s.indexA,a=s.indexB,h=this.m_groupBuffer[o],u=this.m_groupBuffer[a];h&&h===u&&h.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth&&(e[n++]=s)}for(var l=[],c=0,_=this.m_groupList;_;_=_.GetNext())if(_.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth){l[c++]=_,this.SetGroupFlags(_,_.m_groupFlags&~t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth);for(var d=_.m_firstIndex;d<_.m_lastIndex;d++)this.m_accumulationBuffer[d]=0}for(var f=0;f<n;f++){var p=e[f],m=p.indexA,g=p.indexB,y=p.weight;this.m_accumulationBuffer[m]+=y,this.m_accumulationBuffer[g]+=y}for(var v=0;v<c;v++)for(var S=l[v],T=S.m_firstIndex;T<S.m_lastIndex;T++){var A=this.m_accumulationBuffer[T];this.m_depthBuffer[T]=A<.8?0:i}for(var b=k(this.m_count)>>0,E=0;E<b;E++){for(var C=!1,w=0;w<n;w++){var x=e[w],R=x.indexA,I=x.indexB,B=1-x.weight,D=this.m_depthBuffer[R],P=this.m_depthBuffer[I],O=P+B,M=D+B;D>O&&(this.m_depthBuffer[R]=O,C=!0),P>M&&(this.m_depthBuffer[I]=M,C=!0)}if(!C)break}for(var L=0;L<c;L++)for(var N=l[L],F=N.m_firstIndex;F<N.m_lastIndex;F++)this.m_depthBuffer[F]<i?this.m_depthBuffer[F]*=this.m_particleDiameter:this.m_depthBuffer[F]=0},r.GetInsideBoundsEnumerator=function(t){var e=n.computeTag(this.m_inverseDiameter*t.lowerBound.x-1,this.m_inverseDiameter*t.lowerBound.y-1),i=n.computeTag(this.m_inverseDiameter*t.upperBound.x+1,this.m_inverseDiameter*t.upperBound.y+1),r=this.m_proxyBuffer.count,s=$n(this.m_proxyBuffer.data,0,r,e,cr.CompareProxyTag),o=tr(this.m_proxyBuffer.data,0,r,i,cr.CompareTagProxy);return new _r(this,e,i,s,o)},r.UpdateAllParticleFlags=function(){this.m_allParticleFlags=0;for(var t=0;t<this.m_count;t++)this.m_allParticleFlags|=this.m_flagsBuffer.data[t];this.m_needsUpdateAllParticleFlags=!1},r.UpdateAllGroupFlags=function(){this.m_allGroupFlags=0;for(var t=this.m_groupList;t;t=t.GetNext())this.m_allGroupFlags|=t.m_groupFlags;this.m_needsUpdateAllGroupFlags=!1},r.AddContact=function(t,e){var i=this.m_flagsBuffer.data,r=this.m_positionBuffer.data,s=j.SubVV(r[e],r[t],n.AddContact_s_d),o=j.DotVV(s,s);if(0<o&&o<this.m_squaredDiameter){var a=F(o),h=this.m_contactBuffer.data[this.m_contactBuffer.Append()];h.indexA=t,h.indexB=e,h.flags=i[t]|i[e],h.weight=1-o*a*this.m_inverseDiameter,h.normal.x=a*s.x,h.normal.y=a*s.y}},r.FindContacts_Reference=function(){var t=this.m_proxyBuffer.count;this.m_contactBuffer.count=0;for(var e=0,i=0;e<t;e++){for(var r=n.computeRelativeTag(this.m_proxyBuffer.data[e].tag,1,0),s=e+1;s<t&&!(r<this.m_proxyBuffer.data[s].tag);s++)this.AddContact(this.m_proxyBuffer.data[e].index,this.m_proxyBuffer.data[s].index,this.m_contactBuffer);for(var o=n.computeRelativeTag(this.m_proxyBuffer.data[e].tag,-1,1);i<t&&!(o<=this.m_proxyBuffer.data[i].tag);i++);for(var a=n.computeRelativeTag(this.m_proxyBuffer.data[e].tag,1,1),h=i;h<t&&!(a<this.m_proxyBuffer.data[h].tag);h++)this.AddContact(this.m_proxyBuffer.data[e].index,this.m_proxyBuffer.data[h].index,this.m_contactBuffer)}},r.FindContacts=function(t){this.FindContacts_Reference(t)},r.UpdateProxies_Reference=function(){for(var t=this.m_positionBuffer.data,e=this.m_inverseDiameter,i=0;i<this.m_proxyBuffer.count;++i){var r=this.m_proxyBuffer.data[i],s=t[r.index];r.tag=n.computeTag(e*s.x,e*s.y)}},r.UpdateProxies=function(t){this.UpdateProxies_Reference(t)},r.SortProxies=function(){Jn(this.m_proxyBuffer.data,0,this.m_proxyBuffer.count,cr.CompareProxyProxy)},r.FilterContacts=function(){var e=this.GetParticleContactFilter();if(null!==e){var i=this;this.m_contactBuffer.RemoveIf((function(n){return 0!=(n.flags&t.b2ParticleFlag.b2_particleContactFilterParticle)&&!e.ShouldCollideParticleParticle(i,n.indexA,n.indexB)}))}},r.NotifyContactListenerPreContact=function(t){if(null!==this.GetParticleContactListener())throw t.Initialize(this.m_contactBuffer,this.m_flagsBuffer),new Error},r.NotifyContactListenerPostContact=function(){var t=this.GetParticleContactListener();if(null!==t){for(var e=0;e<this.m_contactBuffer.count;++e){var i=this.m_contactBuffer.data[e];t.BeginContactParticleParticle(this,i)}throw new Error}},n.b2ParticleContactIsZombie=function(e){return(e.flags&t.b2ParticleFlag.b2_zombieParticle)===t.b2ParticleFlag.b2_zombieParticle},r.UpdateContacts=function(t){this.UpdateProxies(this.m_proxyBuffer),this.SortProxies(this.m_proxyBuffer);var e=new mr;this.NotifyContactListenerPreContact(e),this.FindContacts(this.m_contactBuffer),this.FilterContacts(this.m_contactBuffer),this.NotifyContactListenerPostContact(e),t&&this.m_contactBuffer.RemoveIf(n.b2ParticleContactIsZombie)},r.NotifyBodyContactListenerPreContact=function(t){if(null!==this.GetFixtureContactListener())throw t.Initialize(this.m_bodyContactBuffer,this.m_flagsBuffer),new Error},r.NotifyBodyContactListenerPostContact=function(){var t=this.GetFixtureContactListener();if(null!==t){for(var e=0;e<this.m_bodyContactBuffer.count;e++){var i=this.m_bodyContactBuffer.data[e];t.BeginContactFixtureParticle(this,i)}throw new Error}},r.UpdateBodyContacts=function(){var t=n.UpdateBodyContacts_s_aabb,e=new pr;if(this.NotifyBodyContactListenerPreContact(e),this.m_stuckThreshold>0)for(var i=this.GetParticleCount(),r=0;r<i;r++)this.m_bodyContactCountBuffer.data[r]=0,this.m_timestamp>this.m_lastBodyContactStepBuffer.data[r]+1&&(this.m_consecutiveContactStepsBuffer.data[r]=0);this.m_bodyContactBuffer.SetCount(0),this.m_stuckParticleBuffer.SetCount(0);var s=t;this.ComputeAABB(s),null===this.UpdateBodyContacts_callback&&(this.UpdateBodyContacts_callback=new Ar(this));var o=this.UpdateBodyContacts_callback;o.m_contactFilter=this.GetFixtureContactFilter(),this.m_world.QueryAABB(o,s),this.m_def.strictContactCheck&&this.RemoveSpuriousBodyContacts(),this.NotifyBodyContactListenerPostContact(e)},r.Solve=function(e){var i=n.Solve_s_subStep;if(0!==this.m_count&&(this.m_expirationTimeBuffer.data&&this.SolveLifetimes(e),this.m_allParticleFlags&t.b2ParticleFlag.b2_zombieParticle&&this.SolveZombie(),this.m_needsUpdateAllParticleFlags&&this.UpdateAllParticleFlags(),this.m_needsUpdateAllGroupFlags&&this.UpdateAllGroupFlags(),!this.m_paused))for(this.m_iterationIndex=0;this.m_iterationIndex<e.particleIterations;this.m_iterationIndex++){++this.m_timestamp;var r=i.Copy(e);r.dt/=e.particleIterations,r.inv_dt*=e.particleIterations,this.UpdateContacts(!1),this.UpdateBodyContacts(),this.ComputeWeight(),this.m_allGroupFlags&t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth&&this.ComputeDepth(),this.m_allParticleFlags&t.b2ParticleFlag.b2_reactiveParticle&&this.UpdatePairsAndTriadsWithReactiveParticles(),this.m_hasForce&&this.SolveForce(r),this.m_allParticleFlags&t.b2ParticleFlag.b2_viscousParticle&&this.SolveViscous(),this.m_allParticleFlags&t.b2ParticleFlag.b2_repulsiveParticle&&this.SolveRepulsive(r),this.m_allParticleFlags&t.b2ParticleFlag.b2_powderParticle&&this.SolvePowder(r),this.m_allParticleFlags&t.b2ParticleFlag.b2_tensileParticle&&this.SolveTensile(r),this.m_allGroupFlags&t.b2ParticleGroupFlag.b2_solidParticleGroup&&this.SolveSolid(r),this.m_allParticleFlags&t.b2ParticleFlag.b2_colorMixingParticle&&this.SolveColorMixing(),this.SolveGravity(r),this.m_allParticleFlags&t.b2ParticleFlag.b2_staticPressureParticle&&this.SolveStaticPressure(r),this.SolvePressure(r),this.SolveDamping(r),this.m_allParticleFlags&n.k_extraDampingFlags&&this.SolveExtraDamping(),this.m_allParticleFlags&t.b2ParticleFlag.b2_elasticParticle&&this.SolveElastic(r),this.m_allParticleFlags&t.b2ParticleFlag.b2_springParticle&&this.SolveSpring(r),this.LimitVelocity(r),this.m_allGroupFlags&t.b2ParticleGroupFlag.b2_rigidParticleGroup&&this.SolveRigidDamping(),this.m_allParticleFlags&t.b2ParticleFlag.b2_barrierParticle&&this.SolveBarrier(r),this.SolveCollision(r),this.m_allGroupFlags&t.b2ParticleGroupFlag.b2_rigidParticleGroup&&this.SolveRigid(r),this.m_allParticleFlags&t.b2ParticleFlag.b2_wallParticle&&this.SolveWall();for(var s=0;s<this.m_count;s++)this.m_positionBuffer.data[s].SelfMulAdd(r.dt,this.m_velocityBuffer.data[s])}},r.SolveCollision=function(t){var e=n.SolveCollision_s_aabb,r=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,o=e;o.lowerBound.x=+i,o.lowerBound.y=+i,o.upperBound.x=-i,o.upperBound.y=-i;for(var a=0;a<this.m_count;a++){var h=s[a],u=r[a],l=u.x+t.dt*h.x,c=u.y+t.dt*h.y;o.lowerBound.x=P(o.lowerBound.x,P(u.x,l)),o.lowerBound.y=P(o.lowerBound.y,P(u.y,c)),o.upperBound.x=O(o.upperBound.x,O(u.x,l)),o.upperBound.y=O(o.upperBound.y,O(u.y,c))}null===this.SolveCollision_callback&&(this.SolveCollision_callback=new br(this,t));var _=this.SolveCollision_callback;_.m_step=t,this.m_world.QueryAABB(_,o)},r.LimitVelocity=function(t){for(var e=this.m_velocityBuffer.data,i=this.GetCriticalVelocitySquared(t),n=0;n<this.m_count;n++){var r=e[n],s=j.DotVV(r,r);s>i&&r.SelfMul(k(i/s))}},r.SolveGravity=function(t){for(var e=n.SolveGravity_s_gravity,i=this.m_velocityBuffer.data,r=j.MulSV(t.dt*this.m_def.gravityScale,this.m_world.GetGravity(),e),s=0;s<this.m_count;s++)i[s].SelfAdd(r)},r.SolveBarrier=function(e){for(var i=n.SolveBarrier_s_aabb,r=n.SolveBarrier_s_va,s=n.SolveBarrier_s_vb,o=n.SolveBarrier_s_pba,a=n.SolveBarrier_s_vba,h=n.SolveBarrier_s_vc,u=n.SolveBarrier_s_pca,l=n.SolveBarrier_s_vca,c=n.SolveBarrier_s_qba,_=n.SolveBarrier_s_qca,d=n.SolveBarrier_s_dv,f=n.SolveBarrier_s_f,p=this.m_positionBuffer.data,m=this.m_velocityBuffer.data,g=0;g<this.m_count;g++)0!=(this.m_flagsBuffer.data[g]&n.k_barrierWallFlags)&&m[g].SetZero();for(var y=2.5*e.dt,v=this.GetParticleMass(),S=0;S<this.m_pairBuffer.count;S++){var T=this.m_pairBuffer.data[S];if(T.flags&t.b2ParticleFlag.b2_barrierParticle){var A=T.indexA,b=T.indexB,E=p[A],C=p[b],w=i;j.MinV(E,C,w.lowerBound),j.MaxV(E,C,w.upperBound);for(var x=this.m_groupBuffer[A],R=this.m_groupBuffer[b],I=this.GetLinearVelocity(x,A,E,r),B=this.GetLinearVelocity(R,b,C,s),D=j.SubVV(C,E,o),P=j.SubVV(B,I,a),O=this.GetInsideBoundsEnumerator(w),M=void 0;(M=O.GetNext())>=0;){var L=p[M],N=this.m_groupBuffer[M];if(x!==N&&R!==N){var F=this.GetLinearVelocity(N,M,L,h),V=j.SubVV(L,E,u),G=j.SubVV(F,I,l),U=j.CrossVV(P,G),z=j.CrossVV(D,G)-j.CrossVV(V,P),H=j.CrossVV(D,V),W=void 0,X=void 0,q=c,Y=_;if(0===U){if(0===z)continue;if(!((X=-H/z)>=0&&X<y))continue;if(j.AddVMulSV(D,X,P,q),j.AddVMulSV(V,X,G,Y),!((W=j.DotVV(q,Y)/j.DotVV(q,q))>=0&&W<=1))continue}else{var K=z*z-4*H*U;if(K<0)continue;var J=k(K),Q=(-z-J)/(2*U),Z=(-z+J)/(2*U);if(Q>Z){var $=Q;Q=Z,Z=$}if(X=Q,j.AddVMulSV(D,X,P,q),j.AddVMulSV(V,X,G,Y),W=j.DotVV(q,Y)/j.DotVV(q,q),!(X>=0&&X<y&&W>=0&&W<=1)){if(!((X=Z)>=0&&X<y))continue;if(j.AddVMulSV(D,X,P,q),j.AddVMulSV(V,X,G,Y),!((W=j.DotVV(q,Y)/j.DotVV(q,q))>=0&&W<=1))continue}}var tt=d;tt.x=I.x+W*P.x-F.x,tt.y=I.y+W*P.y-F.y;var et=j.MulSV(v,tt,f);if(N&&this.IsRigidGroup(N)){var it=N.GetMass(),nt=N.GetInertia();it>0&&N.m_linearVelocity.SelfMulAdd(1/it,et),nt>0&&(N.m_angularVelocity+=j.CrossVV(j.SubVV(L,N.GetCenter(),j.s_t0),et)/nt)}else m[M].SelfAdd(tt);this.ParticleApplyForce(M,et.SelfMul(-e.inv_dt))}}}}},r.SolveStaticPressure=function(e){this.m_staticPressureBuffer=this.RequestBuffer(this.m_staticPressureBuffer);for(var i=this.GetCriticalPressure(e),n=this.m_def.staticPressureStrength*i,r=S*i,s=this.m_def.staticPressureRelaxation,o=0;o<this.m_def.staticPressureIterations;o++){for(var a=0;a<this.m_count;a++)this.m_accumulationBuffer[a]=0;for(var h=0;h<this.m_contactBuffer.count;h++){var u=this.m_contactBuffer.data[h];if(u.flags&t.b2ParticleFlag.b2_staticPressureParticle){var l=u.indexA,c=u.indexB,_=u.weight;this.m_accumulationBuffer[l]+=_*this.m_staticPressureBuffer[c],this.m_accumulationBuffer[c]+=_*this.m_staticPressureBuffer[l]}}for(var d=0;d<this.m_count;d++){var f=this.m_weightBuffer[d];if(this.m_flagsBuffer.data[d]&t.b2ParticleFlag.b2_staticPressureParticle){var p=(this.m_accumulationBuffer[d]+n*(f-1))/(f+s);this.m_staticPressureBuffer[d]=M(p,0,r)}else this.m_staticPressureBuffer[d]=0}}},r.ComputeWeight=function(){for(var t=0;t<this.m_count;t++)this.m_weightBuffer[t]=0;for(var e=0;e<this.m_bodyContactBuffer.count;e++){var i=this.m_bodyContactBuffer.data[e],n=i.index,r=i.weight;this.m_weightBuffer[n]+=r}for(var s=0;s<this.m_contactBuffer.count;s++){var o=this.m_contactBuffer.data[s],a=o.indexA,h=o.indexB,u=o.weight;this.m_weightBuffer[a]+=u,this.m_weightBuffer[h]+=u}},r.SolvePressure=function(e){for(var i=n.SolvePressure_s_f,r=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,o=this.GetCriticalPressure(e),a=this.m_def.pressureStrength*o,h=S*o,u=0;u<this.m_count;u++){var l=a*O(0,this.m_weightBuffer[u]-1);this.m_accumulationBuffer[u]=P(l,h)}if(this.m_allParticleFlags&n.k_noPressureFlags)for(var c=0;c<this.m_count;c++)this.m_flagsBuffer.data[c]&n.k_noPressureFlags&&(this.m_accumulationBuffer[c]=0);if(this.m_allParticleFlags&t.b2ParticleFlag.b2_staticPressureParticle)for(var _=0;_<this.m_count;_++)this.m_flagsBuffer.data[_]&t.b2ParticleFlag.b2_staticPressureParticle&&(this.m_accumulationBuffer[_]+=this.m_staticPressureBuffer[_]);for(var d=e.dt/(this.m_def.density*this.m_particleDiameter),f=this.GetParticleInvMass(),p=0;p<this.m_bodyContactBuffer.count;p++){var m=this.m_bodyContactBuffer.data[p],g=m.index,y=m.body,v=m.weight,T=m.mass,A=m.normal,b=r[g],E=this.m_accumulationBuffer[g]+a*v,C=j.MulSV(d*v*T*E,A,i);s[g].SelfMulSub(f,C),y.ApplyLinearImpulse(C,b,!0)}for(var w=0;w<this.m_contactBuffer.count;w++){var x=this.m_contactBuffer.data[w],R=x.indexA,I=x.indexB,B=x.weight,D=x.normal,M=this.m_accumulationBuffer[R]+this.m_accumulationBuffer[I],L=j.MulSV(d*B*M,D,i);s[R].SelfSub(L),s[I].SelfAdd(L)}},r.SolveDamping=function(t){for(var e=n.SolveDamping_s_v,i=n.SolveDamping_s_f,r=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,o=this.m_def.dampingStrength,a=1/this.GetCriticalVelocity(t),h=this.GetParticleInvMass(),u=0;u<this.m_bodyContactBuffer.count;u++){var l=this.m_bodyContactBuffer.data[u],c=l.index,_=l.body,d=l.weight,f=l.mass,p=l.normal,m=r[c],g=j.SubVV(_.GetLinearVelocityFromWorldPoint(m,j.s_t0),s[c],e),y=j.DotVV(g,p);if(y<0){var v=O(o*d,P(-a*y,.5)),S=j.MulSV(v*f*y,p,i);s[c].SelfMulAdd(h,S),_.ApplyLinearImpulse(S.SelfNeg(),m,!0)}}for(var T=0;T<this.m_contactBuffer.count;T++){var A=this.m_contactBuffer.data[T],b=A.indexA,E=A.indexB,C=A.weight,w=A.normal,x=j.SubVV(s[E],s[b],e),R=j.DotVV(x,w);if(R<0){var I=O(o*C,P(-a*R,.5)),B=j.MulSV(I*R,w,i);s[b].SelfAdd(B),s[E].SelfSub(B)}}},r.SolveRigidDamping=function(){for(var t=n.SolveRigidDamping_s_t0,e=n.SolveRigidDamping_s_t1,i=n.SolveRigidDamping_s_p,r=n.SolveRigidDamping_s_v,s=[0],o=[0],a=[0],h=[0],u=[0],l=[0],c=this.m_positionBuffer.data,_=this.m_def.dampingStrength,d=0;d<this.m_bodyContactBuffer.count;d++){var f=this.m_bodyContactBuffer.data[d],p=f.index,m=this.m_groupBuffer[p];if(m&&this.IsRigidGroup(m)){var g=f.body,y=f.normal,v=f.weight,S=c[p],T=j.SubVV(g.GetLinearVelocityFromWorldPoint(S,t),m.GetLinearVelocityFromWorldPoint(S,e),r),A=j.DotVV(T,y);if(A<0){this.InitDampingParameterWithRigidGroupOrParticle(s,o,a,!0,m,p,S,y),this.InitDampingParameter(h,u,l,g.GetMass(),g.GetInertia()-g.GetMass()*g.GetLocalCenter().LengthSquared(),g.GetWorldCenter(),S,y);var b=_*P(v,1)*this.ComputeDampingImpulse(s[0],o[0],a[0],h[0],u[0],l[0],A);this.ApplyDamping(s[0],o[0],a[0],!0,m,p,b,y),g.ApplyLinearImpulse(j.MulSV(-b,y,j.s_t0),S,!0)}}}for(var E=0;E<this.m_contactBuffer.count;E++){var C=this.m_contactBuffer.data[E],w=C.indexA,x=C.indexB,R=C.normal,I=C.weight,B=this.m_groupBuffer[w],D=this.m_groupBuffer[x],O=this.IsRigidGroup(B),M=this.IsRigidGroup(D);if(B!==D&&(O||M)){var L=j.MidVV(c[w],c[x],i),N=j.SubVV(this.GetLinearVelocity(D,x,L,t),this.GetLinearVelocity(B,w,L,e),r),F=j.DotVV(N,R);if(F<0){this.InitDampingParameterWithRigidGroupOrParticle(s,o,a,O,B,w,L,R),this.InitDampingParameterWithRigidGroupOrParticle(h,u,l,M,D,x,L,R);var k=_*I*this.ComputeDampingImpulse(s[0],o[0],a[0],h[0],u[0],l[0],F);this.ApplyDamping(s[0],o[0],a[0],O,B,w,k,R),this.ApplyDamping(h[0],u[0],l[0],M,D,x,-k,R)}}}},r.SolveExtraDamping=function(){for(var t=n.SolveExtraDamping_s_v,e=n.SolveExtraDamping_s_f,i=this.m_velocityBuffer.data,r=this.m_positionBuffer.data,s=this.GetParticleInvMass(),o=0;o<this.m_bodyContactBuffer.count;o++){var a=this.m_bodyContactBuffer.data[o],h=a.index;if(this.m_flagsBuffer.data[h]&n.k_extraDampingFlags){var u=a.body,l=a.mass,c=a.normal,_=r[h],d=j.SubVV(u.GetLinearVelocityFromWorldPoint(_,j.s_t0),i[h],t),f=j.DotVV(d,c);if(f<0){var p=j.MulSV(.5*l*f,c,e);i[h].SelfMulAdd(s,p),u.ApplyLinearImpulse(p.SelfNeg(),_,!0)}}}},r.SolveWall=function(){for(var e=this.m_velocityBuffer.data,i=0;i<this.m_count;i++)this.m_flagsBuffer.data[i]&t.b2ParticleFlag.b2_wallParticle&&e[i].SetZero()},r.SolveRigid=function(e){for(var i=n.SolveRigid_s_position,r=n.SolveRigid_s_rotation,s=n.SolveRigid_s_transform,o=n.SolveRigid_s_velocityTransform,a=this.m_positionBuffer.data,h=this.m_velocityBuffer.data,u=this.m_groupList;u;u=u.GetNext())if(u.m_groupFlags&t.b2ParticleGroupFlag.b2_rigidParticleGroup){u.UpdateStatistics();var l=r;l.SetAngle(e.dt*u.m_angularVelocity);var c=j.AddVV(u.m_center,j.SubVV(j.MulSV(e.dt,u.m_linearVelocity,j.s_t0),J.MulRV(l,u.m_center,j.s_t1),j.s_t0),i),_=s;_.SetPositionRotation(c,l),Q.MulXX(_,u.m_transform,u.m_transform);var d=o;d.p.x=e.inv_dt*_.p.x,d.p.y=e.inv_dt*_.p.y,d.q.s=e.inv_dt*_.q.s,d.q.c=e.inv_dt*(_.q.c-1);for(var f=u.m_firstIndex;f<u.m_lastIndex;f++)Q.MulXV(d,a[f],h[f])}},r.SolveElastic=function(e){for(var i=n.SolveElastic_s_pa,r=n.SolveElastic_s_pb,s=n.SolveElastic_s_pc,o=n.SolveElastic_s_r,a=n.SolveElastic_s_t0,h=this.m_positionBuffer.data,u=this.m_velocityBuffer.data,l=e.inv_dt*this.m_def.elasticStrength,c=0;c<this.m_triadBuffer.count;c++){var _=this.m_triadBuffer.data[c];if(_.flags&t.b2ParticleFlag.b2_elasticParticle){var d=_.indexA,f=_.indexB,p=_.indexC,m=_.pa,g=_.pb,y=_.pc,v=i.Copy(h[d]),S=r.Copy(h[f]),T=s.Copy(h[p]),A=u[d],b=u[f],E=u[p];v.SelfMulAdd(e.dt,A),S.SelfMulAdd(e.dt,b),T.SelfMulAdd(e.dt,E);var C=(v.x+S.x+T.x)/3,w=(v.y+S.y+T.y)/3;v.x-=C,v.y-=w,S.x-=C,S.y-=w,T.x-=C,T.y-=w;var x=o;x.s=j.CrossVV(m,v)+j.CrossVV(g,S)+j.CrossVV(y,T),x.c=j.DotVV(m,v)+j.DotVV(g,S)+j.DotVV(y,T);var R=F(x.s*x.s+x.c*x.c);isFinite(R)||(R=198177537e11),x.s*=R,x.c*=R;var I=l*_.strength;J.MulRV(x,m,a),j.SubVV(a,v,a),j.MulSV(I,a,a),A.SelfAdd(a),J.MulRV(x,g,a),j.SubVV(a,S,a),j.MulSV(I,a,a),b.SelfAdd(a),J.MulRV(x,y,a),j.SubVV(a,T,a),j.MulSV(I,a,a),E.SelfAdd(a)}}},r.SolveSpring=function(e){for(var i=n.SolveSpring_s_pa,r=n.SolveSpring_s_pb,s=n.SolveSpring_s_d,o=n.SolveSpring_s_f,a=this.m_positionBuffer.data,h=this.m_velocityBuffer.data,u=e.inv_dt*this.m_def.springStrength,l=0;l<this.m_pairBuffer.count;l++){var c=this.m_pairBuffer.data[l];if(c.flags&t.b2ParticleFlag.b2_springParticle){var _=c.indexA,d=c.indexB,f=i.Copy(a[_]),p=r.Copy(a[d]),m=h[_],g=h[d];f.SelfMulAdd(e.dt,m),p.SelfMulAdd(e.dt,g);var y=j.SubVV(p,f,s),v=c.distance,S=y.Length(),T=u*c.strength,A=j.MulSV(T*(v-S)/S,y,o);m.SelfSub(A),g.SelfAdd(A)}}},r.SolveTensile=function(e){for(var i=n.SolveTensile_s_weightedNormal,r=n.SolveTensile_s_s,s=n.SolveTensile_s_f,o=this.m_velocityBuffer.data,a=0;a<this.m_count;a++)this.m_accumulation2Buffer[a]=new j,this.m_accumulation2Buffer[a].SetZero();for(var h=0;h<this.m_contactBuffer.count;h++){var u=this.m_contactBuffer.data[h];if(u.flags&t.b2ParticleFlag.b2_tensileParticle){var l=u.indexA,c=u.indexB,_=u.weight,d=u.normal,f=j.MulSV((1-_)*_,d,i);this.m_accumulation2Buffer[l].SelfSub(f),this.m_accumulation2Buffer[c].SelfAdd(f)}}for(var p=this.GetCriticalVelocity(e),m=this.m_def.surfaceTensionPressureStrength*p,g=this.m_def.surfaceTensionNormalStrength*p,y=.5*p,v=0;v<this.m_contactBuffer.count;v++){var S=this.m_contactBuffer.data[v];if(S.flags&t.b2ParticleFlag.b2_tensileParticle){var T=S.indexA,A=S.indexB,b=S.weight,E=S.normal,C=this.m_weightBuffer[T]+this.m_weightBuffer[A],w=j.SubVV(this.m_accumulation2Buffer[A],this.m_accumulation2Buffer[T],r),x=P(m*(C-2)+g*j.DotVV(w,E),y)*b,R=j.MulSV(x,E,s);o[T].SelfSub(R),o[A].SelfAdd(R)}}},r.SolveViscous=function(){for(var e=n.SolveViscous_s_v,i=n.SolveViscous_s_f,r=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,o=this.m_def.viscousStrength,a=this.GetParticleInvMass(),h=0;h<this.m_bodyContactBuffer.count;h++){var u=this.m_bodyContactBuffer.data[h],l=u.index;if(this.m_flagsBuffer.data[l]&t.b2ParticleFlag.b2_viscousParticle){var c=u.body,_=u.weight,d=u.mass,f=r[l],p=j.SubVV(c.GetLinearVelocityFromWorldPoint(f,j.s_t0),s[l],e),m=j.MulSV(o*d*_,p,i);s[l].SelfMulAdd(a,m),c.ApplyLinearImpulse(m.SelfNeg(),f,!0)}}for(var g=0;g<this.m_contactBuffer.count;g++){var y=this.m_contactBuffer.data[g];if(y.flags&t.b2ParticleFlag.b2_viscousParticle){var v=y.indexA,S=y.indexB,T=y.weight,A=j.SubVV(s[S],s[v],e),b=j.MulSV(o*T,A,i);s[v].SelfAdd(b),s[S].SelfSub(b)}}},r.SolveRepulsive=function(e){for(var i=n.SolveRepulsive_s_f,r=this.m_velocityBuffer.data,s=this.m_def.repulsiveStrength*this.GetCriticalVelocity(e),o=0;o<this.m_contactBuffer.count;o++){var a=this.m_contactBuffer.data[o];if(a.flags&t.b2ParticleFlag.b2_repulsiveParticle){var h=a.indexA,u=a.indexB;if(this.m_groupBuffer[h]!==this.m_groupBuffer[u]){var l=a.weight,c=a.normal,_=j.MulSV(s*l,c,i);r[h].SelfSub(_),r[u].SelfAdd(_)}}}},r.SolvePowder=function(e){for(var i=n.SolvePowder_s_f,r=this.m_positionBuffer.data,s=this.m_velocityBuffer.data,o=this.m_def.powderStrength*this.GetCriticalVelocity(e),a=.25,h=this.GetParticleInvMass(),u=0;u<this.m_bodyContactBuffer.count;u++){var l=this.m_bodyContactBuffer.data[u],c=l.index;if(this.m_flagsBuffer.data[c]&t.b2ParticleFlag.b2_powderParticle){var _=l.weight;if(_>a){var d=l.body,f=l.mass,p=r[c],m=l.normal,g=j.MulSV(o*f*(_-a),m,i);s[c].SelfMulSub(h,g),d.ApplyLinearImpulse(g,p,!0)}}}for(var y=0;y<this.m_contactBuffer.count;y++){var v=this.m_contactBuffer.data[y];if(v.flags&t.b2ParticleFlag.b2_powderParticle){var S=v.weight;if(S>a){var T=v.indexA,A=v.indexB,b=v.normal,E=j.MulSV(o*(S-a),b,i);s[T].SelfSub(E),s[A].SelfAdd(E)}}}},r.SolveSolid=function(t){var e=n.SolveSolid_s_f,i=this.m_velocityBuffer.data;this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer);for(var r=t.inv_dt*this.m_def.ejectionStrength,s=0;s<this.m_contactBuffer.count;s++){var o=this.m_contactBuffer.data[s],a=o.indexA,h=o.indexB;if(this.m_groupBuffer[a]!==this.m_groupBuffer[h]){var u=o.weight,l=o.normal,c=this.m_depthBuffer[a]+this.m_depthBuffer[h],_=j.MulSV(r*c*u,l,e);i[a].SelfSub(_),i[h].SelfAdd(_)}}},r.SolveForce=function(t){for(var e=this.m_velocityBuffer.data,i=t.dt*this.GetParticleInvMass(),n=0;n<this.m_count;n++)e[n].SelfMulAdd(i,this.m_forceBuffer[n]);this.m_hasForce=!1},r.SolveColorMixing=function(){var e=.5*this.m_def.colorMixingStrength;if(e)for(var i=0;i<this.m_contactBuffer.count;i++){var n=this.m_contactBuffer.data[i],r=n.indexA,s=n.indexB;if(this.m_flagsBuffer.data[r]&this.m_flagsBuffer.data[s]&t.b2ParticleFlag.b2_colorMixingParticle){var o=this.m_colorBuffer.data[r],a=this.m_colorBuffer.data[s];tt.MixColors(o,a,e)}}},r.SolveZombie=function(){for(var e=0,i=[],n=0;n<this.m_count;n++)i[n]=y;for(var r=0,s=0;s<this.m_count;s++){var o=this.m_flagsBuffer.data[s];if(o&t.b2ParticleFlag.b2_zombieParticle){var a=this.m_world.m_destructionListener;if(o&t.b2ParticleFlag.b2_destructionListenerParticle&&a&&a.SayGoodbyeParticle(this,s),this.m_handleIndexBuffer.data){var h=this.m_handleIndexBuffer.data[s];h&&(h.SetIndex(y),this.m_handleIndexBuffer.data[s]=null)}i[s]=y}else{if(i[s]=e,s!==e){if(this.m_handleIndexBuffer.data){var u=this.m_handleIndexBuffer.data[s];u&&u.SetIndex(e),this.m_handleIndexBuffer.data[e]=u}this.m_flagsBuffer.data[e]=this.m_flagsBuffer.data[s],this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[e]=this.m_lastBodyContactStepBuffer.data[s]),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[e]=this.m_bodyContactCountBuffer.data[s]),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[e]=this.m_consecutiveContactStepsBuffer.data[s]),this.m_positionBuffer.data[e].Copy(this.m_positionBuffer.data[s]),this.m_velocityBuffer.data[e].Copy(this.m_velocityBuffer.data[s]),this.m_groupBuffer[e]=this.m_groupBuffer[s],this.m_hasForce&&this.m_forceBuffer[e].Copy(this.m_forceBuffer[s]),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[e]=this.m_staticPressureBuffer[s]),this.m_depthBuffer&&(this.m_depthBuffer[e]=this.m_depthBuffer[s]),this.m_colorBuffer.data&&this.m_colorBuffer.data[e].Copy(this.m_colorBuffer.data[s]),this.m_userDataBuffer.data&&(this.m_userDataBuffer.data[e]=this.m_userDataBuffer.data[s]),this.m_expirationTimeBuffer.data&&(this.m_expirationTimeBuffer.data[e]=this.m_expirationTimeBuffer.data[s])}e++,r|=o}}for(var l={IsProxyInvalid:function(t){return t.index<0},IsContactInvalid:function(t){return t.indexA<0||t.indexB<0},IsBodyContactInvalid:function(t){return t.index<0},IsPairInvalid:function(t){return t.indexA<0||t.indexB<0},IsTriadInvalid:function(t){return t.indexA<0||t.indexB<0||t.indexC<0}},c=0;c<this.m_proxyBuffer.count;c++){var _=this.m_proxyBuffer.data[c];_.index=i[_.index]}this.m_proxyBuffer.RemoveIf(l.IsProxyInvalid);for(var d=0;d<this.m_contactBuffer.count;d++){var f=this.m_contactBuffer.data[d];f.indexA=i[f.indexA],f.indexB=i[f.indexB]}this.m_contactBuffer.RemoveIf(l.IsContactInvalid);for(var p=0;p<this.m_bodyContactBuffer.count;p++){var m=this.m_bodyContactBuffer.data[p];m.index=i[m.index]}this.m_bodyContactBuffer.RemoveIf(l.IsBodyContactInvalid);for(var g=0;g<this.m_pairBuffer.count;g++){var v=this.m_pairBuffer.data[g];v.indexA=i[v.indexA],v.indexB=i[v.indexB]}this.m_pairBuffer.RemoveIf(l.IsPairInvalid);for(var S=0;S<this.m_triadBuffer.count;S++){var T=this.m_triadBuffer.data[S];T.indexA=i[T.indexA],T.indexB=i[T.indexB],T.indexC=i[T.indexC]}if(this.m_triadBuffer.RemoveIf(l.IsTriadInvalid),this.m_indexByExpirationTimeBuffer.data)for(var A=0,b=0;b<this.m_count;b++){var E=i[this.m_indexByExpirationTimeBuffer.data[b]];E!==y&&(this.m_indexByExpirationTimeBuffer.data[A++]=E)}for(var C=this.m_groupList;C;C=C.GetNext()){for(var w=e,x=0,R=!1,I=C.m_firstIndex;I<C.m_lastIndex;I++){var B=i[I];B>=0?(w=P(w,B),x=O(x,B+1)):R=!0}w<x?(C.m_firstIndex=w,C.m_lastIndex=x,R&&C.m_groupFlags&t.b2ParticleGroupFlag.b2_solidParticleGroup&&this.SetGroupFlags(C,C.m_groupFlags|t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth)):(C.m_firstIndex=0,C.m_lastIndex=0,C.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupCanBeEmpty||this.SetGroupFlags(C,C.m_groupFlags|t.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed))}this.m_count=e,this.m_allParticleFlags=r,this.m_needsUpdateAllParticleFlags=!1;for(var D=this.m_groupList;D;){var M=D.GetNext();D.m_groupFlags&t.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed&&this.DestroyParticleGroup(D),D=M}},r.SolveLifetimes=function(t){this.m_timeElapsed=this.LifetimeToExpirationTime(t.dt);var e=this.GetQuantizedTimeElapsed(),i=this.m_expirationTimeBuffer.data,n=this.m_indexByExpirationTimeBuffer.data,r=this.GetParticleCount();this.m_expirationTimeBufferRequiresSorting&&(Jn(n,0,r,(function(t,e){var n=i[t],r=i[e],s=n<=0;return s===r<=0?n>r:s})),this.m_expirationTimeBufferRequiresSorting=!1);for(var s=r-1;s>=0;--s){var o=n[s],a=i[o];if(e<a||a<=0)break;this.DestroyParticle(o)}},r.RotateBuffer=function(t,e,i){if(t!==e&&e!==i){if(er(this.m_flagsBuffer.data,t,e,i),this.m_lastBodyContactStepBuffer.data&&er(this.m_lastBodyContactStepBuffer.data,t,e,i),this.m_bodyContactCountBuffer.data&&er(this.m_bodyContactCountBuffer.data,t,e,i),this.m_consecutiveContactStepsBuffer.data&&er(this.m_consecutiveContactStepsBuffer.data,t,e,i),er(this.m_positionBuffer.data,t,e,i),er(this.m_velocityBuffer.data,t,e,i),er(this.m_groupBuffer,t,e,i),this.m_hasForce&&er(this.m_forceBuffer,t,e,i),this.m_staticPressureBuffer&&er(this.m_staticPressureBuffer,t,e,i),this.m_depthBuffer&&er(this.m_depthBuffer,t,e,i),this.m_colorBuffer.data&&er(this.m_colorBuffer.data,t,e,i),this.m_userDataBuffer.data&&er(this.m_userDataBuffer.data,t,e,i),this.m_handleIndexBuffer.data){er(this.m_handleIndexBuffer.data,t,e,i);for(var n=t;n<i;++n){var r=this.m_handleIndexBuffer.data[n];r&&r.SetIndex(v(r.GetIndex()))}}if(this.m_expirationTimeBuffer.data){er(this.m_expirationTimeBuffer.data,t,e,i);for(var s=this.GetParticleCount(),o=this.m_indexByExpirationTimeBuffer.data,a=0;a<s;++a)o[a]=v(o[a])}for(var h=0;h<this.m_proxyBuffer.count;h++){var u=this.m_proxyBuffer.data[h];u.index=v(u.index)}for(var l=0;l<this.m_contactBuffer.count;l++){var c=this.m_contactBuffer.data[l];c.indexA=v(c.indexA),c.indexB=v(c.indexB)}for(var _=0;_<this.m_bodyContactBuffer.count;_++){var d=this.m_bodyContactBuffer.data[_];d.index=v(d.index)}for(var f=0;f<this.m_pairBuffer.count;f++){var p=this.m_pairBuffer.data[f];p.indexA=v(p.indexA),p.indexB=v(p.indexB)}for(var m=0;m<this.m_triadBuffer.count;m++){var g=this.m_triadBuffer.data[m];g.indexA=v(g.indexA),g.indexB=v(g.indexB),g.indexC=v(g.indexC)}for(var y=this.m_groupList;y;y=y.GetNext())y.m_firstIndex=v(y.m_firstIndex),y.m_lastIndex=v(y.m_lastIndex-1)+1}function v(n){return n<t?n:n<e?n+i-e:n<i?n+t-e:n}},r.GetCriticalVelocity=function(t){return this.m_particleDiameter*t.inv_dt},r.GetCriticalVelocitySquared=function(t){var e=this.GetCriticalVelocity(t);return e*e},r.GetCriticalPressure=function(t){return this.m_def.density*this.GetCriticalVelocitySquared(t)},r.GetParticleStride=function(){return v*this.m_particleDiameter},r.GetParticleMass=function(){var t=this.GetParticleStride();return this.m_def.density*t*t},r.GetParticleInvMass=function(){var t=1.3333333333333333*this.m_inverseDiameter;return this.m_inverseDensity*t*t},r.GetFixtureContactFilter=function(){return this.m_allParticleFlags&t.b2ParticleFlag.b2_fixtureContactFilterParticle?this.m_world.m_contactManager.m_contactFilter:null},r.GetParticleContactFilter=function(){return this.m_allParticleFlags&t.b2ParticleFlag.b2_particleContactFilterParticle?this.m_world.m_contactManager.m_contactFilter:null},r.GetFixtureContactListener=function(){return this.m_allParticleFlags&t.b2ParticleFlag.b2_fixtureContactListenerParticle?this.m_world.m_contactManager.m_contactListener:null},r.GetParticleContactListener=function(){return this.m_allParticleFlags&t.b2ParticleFlag.b2_particleContactListenerParticle?this.m_world.m_contactManager.m_contactListener:null},r.SetUserOverridableBuffer=function(t,e){t.data=e,t.userSuppliedCapacity=e.length},r.SetGroupFlags=function(e,i){var n=e.m_groupFlags;(n^i)&t.b2ParticleGroupFlag.b2_solidParticleGroup&&(i|=t.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth),n&~i&&(this.m_needsUpdateAllGroupFlags=!0),~this.m_allGroupFlags&i&&(i&t.b2ParticleGroupFlag.b2_solidParticleGroup&&(this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer)),this.m_allGroupFlags|=i),e.m_groupFlags=i},n.BodyContactCompare=function(t,e){return t.index===e.index?t.weight>e.weight:t.index<e.index},r.RemoveSpuriousBodyContacts=function(){Jn(this.m_bodyContactBuffer.data,0,this.m_bodyContactBuffer.count,n.BodyContactCompare);var t=n.RemoveSpuriousBodyContacts_s_n,e=n.RemoveSpuriousBodyContacts_s_pos,i=n.RemoveSpuriousBodyContacts_s_normal,r=this,s=-1,o=0;this.m_bodyContactBuffer.count=Zn(this.m_bodyContactBuffer.data,(function(n){if(n.index!==s&&(o=0,s=n.index),o++>3)return!0;var a=t.Copy(n.normal);a.SelfMul(r.m_particleDiameter*(1-n.weight));var h=j.AddVV(r.m_positionBuffer.data[n.index],a,e);if(!n.fixture.TestPoint(h)){for(var u=n.fixture.GetShape().GetChildCount(),c=0;c<u;c++){var _=i;if(n.fixture.ComputeDistance(h,_,c)<l)return!1}return!0}return!1}),this.m_bodyContactBuffer.count)},r.DetectStuckParticle=function(t){this.m_stuckThreshold<=0||(++this.m_bodyContactCountBuffer.data[t],2===this.m_bodyContactCountBuffer.data[t]&&(++this.m_consecutiveContactStepsBuffer.data[t],this.m_consecutiveContactStepsBuffer.data[t]>this.m_stuckThreshold&&(this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()]=t)),this.m_lastBodyContactStepBuffer.data[t]=this.m_timestamp)},r.ValidateParticleIndex=function(t){return t>=0&&t<this.GetParticleCount()&&t!==y},r.GetQuantizedTimeElapsed=function(){return Math.floor(this.m_timeElapsed/4294967296)},r.LifetimeToExpirationTime=function(t){return this.m_timeElapsed+Math.floor(t/this.m_def.lifetimeGranularity*4294967296)},r.ForceCanBeApplied=function(e){return!(e&t.b2ParticleFlag.b2_wallParticle)},r.PrepareForceBuffer=function(){if(!this.m_hasForce){for(var t=0;t<this.m_count;t++)this.m_forceBuffer[t].SetZero();this.m_hasForce=!0}},r.IsRigidGroup=function(e){return null!==e&&0!=(e.m_groupFlags&t.b2ParticleGroupFlag.b2_rigidParticleGroup)},r.GetLinearVelocity=function(t,e,i,n){return t&&this.IsRigidGroup(t)?t.GetLinearVelocityFromWorldPoint(i,n):n.Copy(this.m_velocityBuffer.data[e])},r.InitDampingParameter=function(t,e,i,n,r,s,o,a){t[0]=n>0?1/n:0,e[0]=r>0?1/r:0,i[0]=j.CrossVV(j.SubVV(o,s,j.s_t0),a)},r.InitDampingParameterWithRigidGroupOrParticle=function(e,i,n,r,s,o,a,h){if(s&&r)this.InitDampingParameter(e,i,n,s.GetMass(),s.GetInertia(),s.GetCenter(),a,h);else{var u=this.m_flagsBuffer.data[o];this.InitDampingParameter(e,i,n,u&t.b2ParticleFlag.b2_wallParticle?0:this.GetParticleMass(),0,a,a,h)}},r.ComputeDampingImpulse=function(t,e,i,n,r,s,o){var a=t+e*i*i+n+r*s*s;return a>0?o/a:0},r.ApplyDamping=function(t,e,i,n,r,s,o,a){r&&n?(r.m_linearVelocity.SelfMulAdd(o*t,a),r.m_angularVelocity+=o*i*e):this.m_velocityBuffer.data[s].SelfMulAdd(o*t,a)},n}();ur.xTruncBits=12,ur.yTruncBits=12,ur.tagBits=32,ur.yOffset=1<<ur.yTruncBits-1,ur.yShift=ur.tagBits-ur.yTruncBits,ur.xShift=ur.tagBits-ur.yTruncBits-ur.xTruncBits,ur.xScale=1<<ur.xShift,ur.xOffset=ur.xScale*(1<<ur.xTruncBits-1),ur.yMask=(1<<ur.yTruncBits)-1<<ur.yShift,ur.xMask=~ur.yMask,ur.DestroyParticlesInShape_s_aabb=new Vt,ur.CreateParticleGroup_s_transform=new Q,ur.ComputeCollisionEnergy_s_v=new j,ur.QueryShapeAABB_s_aabb=new Vt,ur.QueryPointAABB_s_aabb=new Vt,ur.RayCast_s_aabb=new Vt,ur.RayCast_s_p=new j,ur.RayCast_s_v=new j,ur.RayCast_s_n=new j,ur.RayCast_s_point=new j,ur.k_pairFlags=t.b2ParticleFlag.b2_springParticle,ur.k_triadFlags=t.b2ParticleFlag.b2_elasticParticle,ur.k_noPressureFlags=t.b2ParticleFlag.b2_powderParticle|t.b2ParticleFlag.b2_tensileParticle,ur.k_extraDampingFlags=t.b2ParticleFlag.b2_staticPressureParticle,ur.k_barrierWallFlags=t.b2ParticleFlag.b2_barrierParticle|t.b2ParticleFlag.b2_wallParticle,ur.CreateParticlesStrokeShapeForGroup_s_edge=new vi,ur.CreateParticlesStrokeShapeForGroup_s_d=new j,ur.CreateParticlesStrokeShapeForGroup_s_p=new j,ur.CreateParticlesFillShapeForGroup_s_aabb=new Vt,ur.CreateParticlesFillShapeForGroup_s_p=new j,ur.UpdatePairsAndTriads_s_dab=new j,ur.UpdatePairsAndTriads_s_dbc=new j,ur.UpdatePairsAndTriads_s_dca=new j,ur.AddContact_s_d=new j,ur.UpdateBodyContacts_s_aabb=new Vt,ur.Solve_s_subStep=new Cn,ur.SolveCollision_s_aabb=new Vt,ur.SolveGravity_s_gravity=new j,ur.SolveBarrier_s_aabb=new Vt,ur.SolveBarrier_s_va=new j,ur.SolveBarrier_s_vb=new j,ur.SolveBarrier_s_pba=new j,ur.SolveBarrier_s_vba=new j,ur.SolveBarrier_s_vc=new j,ur.SolveBarrier_s_pca=new j,ur.SolveBarrier_s_vca=new j,ur.SolveBarrier_s_qba=new j,ur.SolveBarrier_s_qca=new j,ur.SolveBarrier_s_dv=new j,ur.SolveBarrier_s_f=new j,ur.SolvePressure_s_f=new j,ur.SolveDamping_s_v=new j,ur.SolveDamping_s_f=new j,ur.SolveRigidDamping_s_t0=new j,ur.SolveRigidDamping_s_t1=new j,ur.SolveRigidDamping_s_p=new j,ur.SolveRigidDamping_s_v=new j,ur.SolveExtraDamping_s_v=new j,ur.SolveExtraDamping_s_f=new j,ur.SolveRigid_s_position=new j,ur.SolveRigid_s_rotation=new J,ur.SolveRigid_s_transform=new Q,ur.SolveRigid_s_velocityTransform=new Q,ur.SolveElastic_s_pa=new j,ur.SolveElastic_s_pb=new j,ur.SolveElastic_s_pc=new j,ur.SolveElastic_s_r=new J,ur.SolveElastic_s_t0=new j,ur.SolveSpring_s_pa=new j,ur.SolveSpring_s_pb=new j,ur.SolveSpring_s_d=new j,ur.SolveSpring_s_f=new j,ur.SolveTensile_s_weightedNormal=new j,ur.SolveTensile_s_s=new j,ur.SolveTensile_s_f=new j,ur.SolveViscous_s_v=new j,ur.SolveViscous_s_f=new j,ur.SolveRepulsive_s_f=new j,ur.SolvePowder_s_f=new j,ur.SolveSolid_s_f=new j,ur.RemoveSpuriousBodyContacts_s_n=new j,ur.RemoveSpuriousBodyContacts_s_pos=new j,ur.RemoveSpuriousBodyContacts_s_normal=new j;var lr=function(){function t(){this._data=null,this.userSuppliedCapacity=0}return n(t,[{key:"data",get:function(){return this._data},set:function(t){this._data=t}}]),t}(),cr=function(){function t(){this.index=y,this.tag=0}return t.CompareProxyProxy=function(t,e){return t.tag<e.tag},t.CompareTagProxy=function(t,e){return t<e.tag},t.CompareProxyTag=function(t,e){return t.tag<e},t}(),_r=function(){function t(t,e,i,n,r){this.m_system=t,this.m_xLower=(e&ur.xMask)>>>0,this.m_xUpper=(i&ur.xMask)>>>0,this.m_yLower=(e&ur.yMask)>>>0,this.m_yUpper=(i&ur.yMask)>>>0,this.m_first=n,this.m_last=r}return t.prototype.GetNext=function(){for(;this.m_first<this.m_last;){var t=(this.m_system.m_proxyBuffer.data[this.m_first].tag&ur.xMask)>>>0;if(t>=this.m_xLower&&t<=this.m_xUpper)return this.m_system.m_proxyBuffer.data[this.m_first++].index;this.m_first++}return y},t}(),dr=function(){this.next=null,this.count=0,this.index=0},fr=function(){function t(){}var e=t.prototype;return e.Allocate=function(t,e){return e},e.Clear=function(){},e.GetCount=function(){return 0},e.Invalidate=function(){},e.GetValidBuffer=function(){return[]},e.GetBuffer=function(){return[]},e.SetCount=function(){},t}(),pr=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.Initialize=function(){},i.Find=function(){return y},e}(fr),mr=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.Initialize=function(){},i.Find=function(){return y},e}(fr),gr=function(){function t(){}var e=t.prototype;return e.IsNecessary=function(){return!0},e.ShouldCreatePair=function(){return!0},e.ShouldCreateTriad=function(){return!0},t}(),yr=function(t){function e(e,i,n,r){var s;return(s=t.call(this)||this).m_callDestructionListener=!1,s.m_destroyed=0,s.m_system=e,s.m_shape=i,s.m_xf=n,s.m_callDestructionListener=r,s.m_destroyed=0,s}s(e,t);var i=e.prototype;return i.ReportFixture=function(){return!1},i.ReportParticle=function(t,e){return t===this.m_system&&(this.m_shape.TestPoint(this.m_xf,this.m_system.m_positionBuffer.data[e])&&(this.m_system.DestroyParticle(e,this.m_callDestructionListener),this.m_destroyed++),!0)},i.Destroyed=function(){return this.m_destroyed},e}(Tn),vr=function(t){function e(e){var i;return(i=t.call(this)||this).m_threshold=0,i.m_threshold=e,i}s(e,t);var i=e.prototype;return i.ShouldCreatePair=function(t,e){return t<this.m_threshold&&this.m_threshold<=e||e<this.m_threshold&&this.m_threshold<=t},i.ShouldCreateTriad=function(t,e,i){return(t<this.m_threshold||e<this.m_threshold||i<this.m_threshold)&&(this.m_threshold<=t||this.m_threshold<=e||this.m_threshold<=i)},e}(gr),Sr=function(e){function n(i,n){var r;return void 0===n&&(n=i.length),(r=e.call(this,t.b2ShapeType.e_unknown,0)||this).m_shapeCount=0,r.m_shapes=i,r.m_shapeCount=n,r}s(n,e);var r=n.prototype;return r.Clone=function(){throw new Error},r.GetChildCount=function(){return 1},r.TestPoint=function(t,e){for(var i=0;i<this.m_shapeCount;i++)if(this.m_shapes[i].TestPoint(t,e))return!0;return!1},r.ComputeDistance=function(){return 0},r.RayCast=function(){return!1},r.ComputeAABB=function(t,e){var n=new Vt;t.lowerBound.x=+i,t.lowerBound.y=+i,t.upperBound.x=-i,t.upperBound.y=-i;for(var r=0;r<this.m_shapeCount;r++)for(var s=this.m_shapes[r].GetChildCount(),o=0;o<s;o++){var a=n;this.m_shapes[r].ComputeAABB(a,e,o),t.Combine1(a)}},r.ComputeMass=function(){},r.SetupDistanceProxy=function(){},r.ComputeSubmergedArea=function(){return 0},r.Dump=function(){},n}(mi),Tr=function(e){function i(t){var i;return(i=e.call(this)||this).m_flagsBuffer=t,i}return s(i,e),i.prototype.IsNecessary=function(e){return 0!=(this.m_flagsBuffer.data[e]&t.b2ParticleFlag.b2_reactiveParticle)},i}(gr),Ar=function(e){function i(t,i){var n;return void 0===i&&(i=null),(n=e.call(this,t)||this).m_contactFilter=null,n.m_contactFilter=i,n}s(i,e);var n=i.prototype;return n.ShouldCollideFixtureParticle=function(e,i,n){return!(this.m_contactFilter&&this.m_system.GetFlagsBuffer()[n]&t.b2ParticleFlag.b2_fixtureContactFilterParticle)||this.m_contactFilter.ShouldCollideFixtureParticle(e,this.m_system,n)},n.ReportFixtureAndParticle=function(e,n,r){var s=i.ReportFixtureAndParticle_s_n,o=i.ReportFixtureAndParticle_s_rp,a=this.m_system.m_positionBuffer.data[r],h=s,u=e.ComputeDistance(a,h,n);if(u<this.m_system.m_particleDiameter&&this.ShouldCollideFixtureParticle(e,this.m_system,r)){var l=e.GetBody(),c=l.GetWorldCenter(),_=l.GetMass(),d=l.GetInertia()-_*l.GetLocalCenter().LengthSquared(),f=_>0?1/_:0,p=d>0?1/d:0,m=this.m_system.m_flagsBuffer.data[r]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),g=j.SubVV(a,c,o),y=j.CrossVV(g,h),v=m+f+p*y*y,S=this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];S.index=r,S.body=l,S.fixture=e,S.weight=1-u*this.m_system.m_inverseDiameter,S.normal.Copy(h.SelfNeg()),S.mass=v>0?1/v:0,this.m_system.DetectStuckParticle(r)}},i}(nr);Ar.ReportFixtureAndParticle_s_n=new j,Ar.ReportFixtureAndParticle_s_rp=new j;var br=function(e){function i(t,i){var n;return(n=e.call(this,t)||this).m_step=i,n}s(i,e);var n=i.prototype;return n.ReportFixtureAndParticle=function(e,n,r){var s=i.ReportFixtureAndParticle_s_p1,o=i.ReportFixtureAndParticle_s_output,a=i.ReportFixtureAndParticle_s_input,h=i.ReportFixtureAndParticle_s_p,u=i.ReportFixtureAndParticle_s_v,c=i.ReportFixtureAndParticle_s_f,_=e.GetBody(),d=this.m_system.m_positionBuffer.data[r],f=this.m_system.m_velocityBuffer.data[r],p=o,m=a;if(0===this.m_system.m_iterationIndex){var g=Q.MulTXV(_.m_xf0,d,s);e.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(g.SelfSub(_.GetLocalCenter()),J.MulRV(_.m_xf0.q,g,g),J.MulTRV(_.m_xf.q,g,g),g.SelfAdd(_.GetLocalCenter())),Q.MulXV(_.m_xf,g,m.p1)}else m.p1.Copy(d);if(j.AddVMulSV(d,this.m_step.dt,f,m.p2),m.maxFraction=1,e.RayCast(p,m,n)){var y=p.normal,v=h;v.x=(1-p.fraction)*m.p1.x+p.fraction*m.p2.x+l*y.x,v.y=(1-p.fraction)*m.p1.y+p.fraction*m.p2.y+l*y.y;var S=u;S.x=this.m_step.inv_dt*(v.x-d.x),S.y=this.m_step.inv_dt*(v.y-d.y),this.m_system.m_velocityBuffer.data[r].Copy(S);var T=c;T.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(f.x-S.x),T.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(f.y-S.y),this.m_system.ParticleApplyForce(r,T)}},n.ReportParticle=function(){return!1},i}(nr);br.ReportFixtureAndParticle_s_p1=new j,br.ReportFixtureAndParticle_s_output=new kt,br.ReportFixtureAndParticle_s_input=new Ft,br.ReportFixtureAndParticle_s_p=new j,br.ReportFixtureAndParticle_s_v=new j,br.ReportFixtureAndParticle_s_f=new j;var Er=function(){function e(t){this.m_newFixture=!1,this.m_locked=!1,this.m_clearForces=!0,this.m_contactManager=new bn,this.m_bodyList=null,this.m_jointList=null,this.m_particleSystemList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_gravity=new j,this.m_allowSleep=!0,this.m_destructionListener=null,this.m_debugDraw=null,this.m_inv_dt0=0,this.m_warmStarting=!0,this.m_continuousPhysics=!0,this.m_subStepping=!1,this.m_stepComplete=!0,this.m_profile=new En,this.m_island=new Fn,this.s_stack=[],this.m_controllerList=null,this.m_controllerCount=0,this.m_gravity.Copy(t)}var n=e.prototype;return n.SetDestructionListener=function(t){this.m_destructionListener=t},n.SetContactFilter=function(t){this.m_contactManager.m_contactFilter=t},n.SetContactListener=function(t){this.m_contactManager.m_contactListener=t},n.SetDebugDraw=function(t){this.m_debugDraw=t},n.CreateBody=function(t){if(void 0===t&&(t={}),this.IsLocked())throw new Error;var e=new Ri(t,this);return e.m_prev=null,e.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=e),this.m_bodyList=e,++this.m_bodyCount,e},n.DestroyBody=function(t){if(this.IsLocked())throw new Error;for(var e=t.m_jointList;e;){var i=e;e=e.next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(i.joint),this.DestroyJoint(i.joint),t.m_jointList=e}t.m_jointList=null;for(var n=t.m_controllerList;n;){var r=n;n=n.nextController,r.controller.RemoveBody(t)}for(var s=t.m_contactList;s;){var o=s;s=s.next,this.m_contactManager.Destroy(o.contact)}t.m_contactList=null;for(var a=t.m_fixtureList;a;){var h=a;a=a.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(h),h.DestroyProxies(),h.Reset(),t.m_fixtureList=a,t.m_fixtureCount-=1}t.m_fixtureList=null,t.m_fixtureCount=0,t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_bodyList&&(this.m_bodyList=t.m_next),--this.m_bodyCount},e._Joint_Create=function(e){switch(e.type){case t.b2JointType.e_distanceJoint:return new Mi(e);case t.b2JointType.e_mouseJoint:return new Wi(e);case t.b2JointType.e_prismaticJoint:return new Xi(e);case t.b2JointType.e_revoluteJoint:return new Ji(e);case t.b2JointType.e_pulleyJoint:return new Yi(e);case t.b2JointType.e_gearJoint:return new Gi(e);case t.b2JointType.e_wheelJoint:return new nn(e);case t.b2JointType.e_weldJoint:return new tn(e);case t.b2JointType.e_frictionJoint:return new ki(e);case t.b2JointType.e_ropeJoint:return new Zi(e);case t.b2JointType.e_motorJoint:return new zi(e);case t.b2JointType.e_areaJoint:return new Ni(e)}throw new Error},e._Joint_Destroy=function(){},n.CreateJoint=function(t){if(this.IsLocked())throw new Error;var i=e._Joint_Create(t);i.m_prev=null,i.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=i),this.m_jointList=i,++this.m_jointCount,i.m_edgeA.prev=null,i.m_edgeA.next=i.m_bodyA.m_jointList,i.m_bodyA.m_jointList&&(i.m_bodyA.m_jointList.prev=i.m_edgeA),i.m_bodyA.m_jointList=i.m_edgeA,i.m_edgeB.prev=null,i.m_edgeB.next=i.m_bodyB.m_jointList,i.m_bodyB.m_jointList&&(i.m_bodyB.m_jointList.prev=i.m_edgeB),i.m_bodyB.m_jointList=i.m_edgeB;var n=i.m_bodyA,r=i.m_bodyB;if(!i.m_collideConnected)for(var s=r.GetContactList();s;)s.other===n&&s.contact.FlagForFiltering(),s=s.next;return i},n.DestroyJoint=function(t){if(this.IsLocked())throw new Error;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_jointList&&(this.m_jointList=t.m_next);var i=t.m_bodyA,n=t.m_bodyB,r=t.m_collideConnected;if(i.SetAwake(!0),n.SetAwake(!0),t.m_edgeA.prev&&(t.m_edgeA.prev.next=t.m_edgeA.next),t.m_edgeA.next&&(t.m_edgeA.next.prev=t.m_edgeA.prev),t.m_edgeA===i.m_jointList&&(i.m_jointList=t.m_edgeA.next),t.m_edgeA.Reset(),t.m_edgeB.prev&&(t.m_edgeB.prev.next=t.m_edgeB.next),t.m_edgeB.next&&(t.m_edgeB.next.prev=t.m_edgeB.prev),t.m_edgeB===n.m_jointList&&(n.m_jointList=t.m_edgeB.next),t.m_edgeB.Reset(),e._Joint_Destroy(t),--this.m_jointCount,!r)for(var s=n.GetContactList();s;)s.other===i&&s.contact.FlagForFiltering(),s=s.next},n.CreateParticleSystem=function(t){if(this.IsLocked())throw new Error;var e=new ur(t,this);return e.m_prev=null,e.m_next=this.m_particleSystemList,this.m_particleSystemList&&(this.m_particleSystemList.m_prev=e),this.m_particleSystemList=e,e},n.DestroyParticleSystem=function(t){if(this.IsLocked())throw new Error;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_particleSystemList&&(this.m_particleSystemList=t.m_next)},n.CalculateReasonableParticleIterations=function(t){if(null===this.m_particleSystemList)return 1;return Vn(this.m_gravity.Length(),function(t){for(var e=i,n=t.GetParticleSystemList();null!==n;n=n.m_next)e=P(e,n.GetRadius());return e}(this),t)},n.Step=function(t,i,n,r){void 0===r&&(r=this.CalculateReasonableParticleIterations(t));var s=e.Step_s_stepTimer.Reset();this.m_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_newFixture=!1),this.m_locked=!0;var o=e.Step_s_step;o.dt=t,o.velocityIterations=i,o.positionIterations=n,o.particleIterations=r,o.inv_dt=t>0?1/t:0,o.dtRatio=this.m_inv_dt0*t,o.warmStarting=this.m_warmStarting;var a=e.Step_s_timer.Reset();if(this.m_contactManager.Collide(),this.m_profile.collide=a.GetMilliseconds(),this.m_stepComplete&&o.dt>0){for(var h=e.Step_s_timer.Reset(),u=this.m_particleSystemList;u;u=u.m_next)u.Solve(o);this.Solve(o),this.m_profile.solve=h.GetMilliseconds()}if(this.m_continuousPhysics&&o.dt>0){var l=e.Step_s_timer.Reset();this.SolveTOI(o),this.m_profile.solveTOI=l.GetMilliseconds()}o.dt>0&&(this.m_inv_dt0=o.inv_dt),this.m_clearForces&&this.ClearForces(),this.m_locked=!1,this.m_profile.step=s.GetMilliseconds()},n.ClearForces=function(){for(var t=this.m_bodyList;t;t=t.m_next)t.m_force.SetZero(),t.m_torque=0},n.DrawParticleSystem=function(t){if(null!==this.m_debugDraw){var e=t.GetParticleCount();if(e){var i=t.GetRadius(),n=t.GetPositionBuffer();if(t.m_colorBuffer.data){var r=t.GetColorBuffer();this.m_debugDraw.DrawParticles(n,i,r,e)}else this.m_debugDraw.DrawParticles(n,i,null,e)}}},n.DrawDebugData=function(){if(null!==this.m_debugDraw){var i=this.m_debugDraw.GetFlags(),n=e.DrawDebugData_s_color.SetRGB(0,0,0);if(i&t.b2DrawFlags.e_shapeBit)for(var r=this.m_bodyList;r;r=r.m_next){var s=r.m_xf;this.m_debugDraw.PushTransform(s);for(var o=r.GetFixtureList();o;o=o.m_next)r.IsActive()?r.GetType()===t.b2BodyType.b2_staticBody?(n.SetRGB(.5,.9,.5),this.DrawShape(o,n)):r.GetType()===t.b2BodyType.b2_kinematicBody?(n.SetRGB(.5,.5,.9),this.DrawShape(o,n)):r.IsAwake()?(n.SetRGB(.9,.7,.7),this.DrawShape(o,n)):(n.SetRGB(.6,.6,.6),this.DrawShape(o,n)):(n.SetRGB(.5,.5,.3),this.DrawShape(o,n));this.m_debugDraw.PopTransform(s)}if(i&t.b2DrawFlags.e_particleBit)for(var a=this.m_particleSystemList;a;a=a.m_next)this.DrawParticleSystem(a);if(i&t.b2DrawFlags.e_jointBit)for(var h=this.m_jointList;h;h=h.m_next)this.DrawJoint(h);if(i&t.b2DrawFlags.e_aabbBit){n.SetRGB(.9,.3,.9);for(var u=e.DrawDebugData_s_vs,l=this.m_bodyList;l;l=l.m_next)if(l.IsActive())for(var c=l.GetFixtureList();c;c=c.m_next)for(var _=0;_<c.m_proxyCount;++_){var d=c.m_proxies[_].treeNode.aabb;u[0].Set(d.lowerBound.x,d.lowerBound.y),u[1].Set(d.upperBound.x,d.lowerBound.y),u[2].Set(d.upperBound.x,d.upperBound.y),u[3].Set(d.lowerBound.x,d.upperBound.y),this.m_debugDraw.DrawPolygon(u,4,n)}}if(i&t.b2DrawFlags.e_centerOfMassBit)for(var f=this.m_bodyList;f;f=f.m_next){var p=e.DrawDebugData_s_xf;p.q.Copy(f.m_xf.q),p.p.Copy(f.GetWorldCenter()),this.m_debugDraw.DrawTransform(p)}if(i&t.b2DrawFlags.e_controllerBit)for(var m=this.m_controllerList;m;m=m.m_next)m.Draw(this.m_debugDraw)}},n.QueryAABB=function(){(arguments.length<=0?void 0:arguments[0])instanceof Tn?this._QueryAABB(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]):this._QueryAABB(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])},n._QueryAABB=function(t,e,i){if(this.m_contactManager.m_broadPhase.Query(e,(function(e){var n=e.userData.fixture;return t?t.ReportFixture(n):!i||i(n)})),t instanceof Tn)for(var n=this.m_particleSystemList;n;n=n.m_next)t.ShouldQueryParticleSystem(n)&&n.QueryAABB(t,e)},n.QueryAllAABB=function(t,e){return void 0===e&&(e=[]),this.QueryAABB(t,(function(t){return e.push(t),!0})),e},n.QueryPointAABB=function(){(arguments.length<=0?void 0:arguments[0])instanceof Tn?this._QueryPointAABB(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]):this._QueryPointAABB(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])},n._QueryPointAABB=function(t,e,i){if(this.m_contactManager.m_broadPhase.QueryPoint(e,(function(e){var n=e.userData.fixture;return t?t.ReportFixture(n):!i||i(n)})),t instanceof Tn)for(var n=this.m_particleSystemList;n;n=n.m_next)t.ShouldQueryParticleSystem(n)&&n.QueryPointAABB(t,e)},n.QueryAllPointAABB=function(t,e){return void 0===e&&(e=[]),this.QueryPointAABB(t,(function(t){return e.push(t),!0})),e},n.QueryFixtureShape=function(){(arguments.length<=0?void 0:arguments[0])instanceof Tn?this._QueryFixtureShape(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3]):this._QueryFixtureShape(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],arguments.length<=3?void 0:arguments[3])},n._QueryFixtureShape=function(t,i,n,r,s){var o=e.QueryFixtureShape_s_aabb;if(i.ComputeAABB(o,r,n),this.m_contactManager.m_broadPhase.Query(o,(function(e){var o=e.userData,a=o.fixture;if(jt(i,n,a.GetShape(),o.childIndex,r,a.GetBody().GetTransform())){if(t)return t.ReportFixture(a);if(s)return s(a)}return!0})),t instanceof Tn)for(var a=this.m_particleSystemList;a;a=a.m_next)t.ShouldQueryParticleSystem(a)&&a.QueryAABB(t,o)},n.QueryAllFixtureShape=function(t,e,i,n){return void 0===n&&(n=[]),this.QueryFixtureShape(t,e,i,(function(t){return n.push(t),!0})),n},n.QueryFixturePoint=function(){(arguments.length<=0?void 0:arguments[0])instanceof Tn?this._QueryFixturePoint(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1]):this._QueryFixturePoint(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1])},n._QueryFixturePoint=function(t,e,i){if(this.m_contactManager.m_broadPhase.QueryPoint(e,(function(n){var r=n.userData.fixture;if(r.TestPoint(e)){if(t)return t.ReportFixture(r);if(i)return i(r)}return!0})),t)for(var n=this.m_particleSystemList;n;n=n.m_next)t.ShouldQueryParticleSystem(n)&&n.QueryPointAABB(t,e)},n.QueryAllFixturePoint=function(t,e){return void 0===e&&(e=[]),this.QueryFixturePoint(t,(function(t){return e.push(t),!0})),e},n.RayCast=function(){(arguments.length<=0?void 0:arguments[0])instanceof An?this._RayCast(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2]):this._RayCast(null,arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2])},n._RayCast=function(t,i,n,r){var s=e.RayCast_s_input;if(s.maxFraction=1,s.p1.Copy(i),s.p2.Copy(n),this.m_contactManager.m_broadPhase.RayCast(s,(function(s,o){var a=o.userData,h=a.fixture,u=a.childIndex,l=e.RayCast_s_output;if(h.RayCast(l,s,u)){var c=l.fraction,_=e.RayCast_s_point;if(_.Set((1-c)*i.x+c*n.x,(1-c)*i.y+c*n.y),t)return t.ReportFixture(h,_,l.normal,c);if(r)return r(h,_,l.normal,c)}return s.maxFraction})),t)for(var o=this.m_particleSystemList;o;o=o.m_next)t.ShouldQueryParticleSystem(o)&&o.RayCast(t,i,n)},n.RayCastOne=function(t,e){var i=null,n=1;return this.RayCast(t,e,(function(t,e,r,s){return s<n&&(n=s,i=t),n})),i},n.RayCastAll=function(t,e,i){return void 0===i&&(i=[]),this.RayCast(t,e,(function(t){return i.push(t),1})),i},n.GetBodyList=function(){return this.m_bodyList},n.GetJointList=function(){return this.m_jointList},n.GetParticleSystemList=function(){return this.m_particleSystemList},n.GetContactList=function(){return this.m_contactManager.m_contactList},n.SetAllowSleeping=function(t){if(t!==this.m_allowSleep&&(this.m_allowSleep=t,!this.m_allowSleep))for(var e=this.m_bodyList;e;e=e.m_next)e.SetAwake(!0)},n.GetAllowSleeping=function(){return this.m_allowSleep},n.SetWarmStarting=function(t){this.m_warmStarting=t},n.GetWarmStarting=function(){return this.m_warmStarting},n.SetContinuousPhysics=function(t){this.m_continuousPhysics=t},n.GetContinuousPhysics=function(){return this.m_continuousPhysics},n.SetSubStepping=function(t){this.m_subStepping=t},n.GetSubStepping=function(){return this.m_subStepping},n.GetProxyCount=function(){return this.m_contactManager.m_broadPhase.GetProxyCount()},n.GetBodyCount=function(){return this.m_bodyCount},n.GetJointCount=function(){return this.m_jointCount},n.GetContactCount=function(){return this.m_contactManager.m_contactCount},n.GetTreeHeight=function(){return this.m_contactManager.m_broadPhase.GetTreeHeight()},n.GetTreeBalance=function(){return this.m_contactManager.m_broadPhase.GetTreeBalance()},n.GetTreeQuality=function(){return this.m_contactManager.m_broadPhase.GetTreeQuality()},n.SetGravity=function(t,e){if(void 0===e&&(e=!0),!j.IsEqualToV(this.m_gravity,t)&&(this.m_gravity.Copy(t),e))for(var i=this.m_bodyList;i;i=i.m_next)i.SetAwake(!0)},n.GetGravity=function(){return this.m_gravity},n.IsLocked=function(){return this.m_locked},n.SetAutoClearForces=function(t){this.m_clearForces=t},n.GetAutoClearForces=function(){return this.m_clearForces},n.ShiftOrigin=function(t){if(this.IsLocked())throw new Error;for(var e=this.m_bodyList;e;e=e.m_next)e.m_xf.p.SelfSub(t),e.m_sweep.c0.SelfSub(t),e.m_sweep.c.SelfSub(t);for(var i=this.m_jointList;i;i=i.m_next)i.ShiftOrigin(t);this.m_contactManager.m_broadPhase.ShiftOrigin(t)},n.GetContactManager=function(){return this.m_contactManager},n.GetProfile=function(){return this.m_profile},n.Dump=function(e){if(!this.m_locked){e("const g: b2Vec2 = new b2Vec2(%.15f, %.15f);\n",this.m_gravity.x,this.m_gravity.y),e("this.m_world.SetGravity(g);\n"),e("const bodies: b2Body[] = [];\n"),e("const joints: b2Joint[] = [];\n");for(var i=0,n=this.m_bodyList;n;n=n.m_next)n.m_islandIndex=i,n.Dump(e),++i;i=0;for(var r=this.m_jointList;r;r=r.m_next)r.m_index=i,++i;for(var s=this.m_jointList;s;s=s.m_next)s.m_type!==t.b2JointType.e_gearJoint&&(e("{\n"),s.Dump(e),e("}\n"));for(var o=this.m_jointList;o;o=o.m_next)o.m_type===t.b2JointType.e_gearJoint&&(e("{\n"),o.Dump(e),e("}\n"))}},n.DrawJoint=function(i){if(null!==this.m_debugDraw){var n=i.GetBodyA(),r=i.GetBodyB(),s=n.m_xf,o=r.m_xf,a=s.p,h=o.p,u=i.GetAnchorA(e.DrawJoint_s_p1),l=i.GetAnchorB(e.DrawJoint_s_p2),c=e.DrawJoint_s_color.SetRGB(.5,.8,.8);switch(i.m_type){case t.b2JointType.e_distanceJoint:this.m_debugDraw.DrawSegment(u,l,c);break;case t.b2JointType.e_pulleyJoint:var _=i,d=_.GetGroundAnchorA(),f=_.GetGroundAnchorB();this.m_debugDraw.DrawSegment(d,u,c),this.m_debugDraw.DrawSegment(f,l,c),this.m_debugDraw.DrawSegment(d,f,c);break;case t.b2JointType.e_mouseJoint:var p=e.DrawJoint_s_c;p.Set(0,1,0),this.m_debugDraw.DrawPoint(u,4,p),this.m_debugDraw.DrawPoint(l,4,p),p.Set(.8,.8,.8),this.m_debugDraw.DrawSegment(u,l,p);break;default:this.m_debugDraw.DrawSegment(a,u,c),this.m_debugDraw.DrawSegment(u,l,c),this.m_debugDraw.DrawSegment(h,l,c)}}},n.DrawShape=function(i,n){if(null!==this.m_debugDraw){var r=i.GetShape();switch(r.m_type){case t.b2ShapeType.e_circleShape:var s=r,o=s.m_p,a=s.m_radius,h=j.UNITX;this.m_debugDraw.DrawSolidCircle(o,a,h,n);break;case t.b2ShapeType.e_edgeShape:var u=r,l=u.m_vertex1,c=u.m_vertex2;this.m_debugDraw.DrawSegment(l,c,n);break;case t.b2ShapeType.e_chainShape:var _=r,d=_.m_count,f=_.m_vertices,p=e.DrawShape_s_ghostColor.SetRGBA(.75*n.r,.75*n.g,.75*n.b,n.a),m=f[0];if(this.m_debugDraw.DrawPoint(m,4,n),_.m_hasPrevVertex){var g=_.m_prevVertex;this.m_debugDraw.DrawSegment(g,m,p),this.m_debugDraw.DrawCircle(g,.1,p)}for(var y=1;y<d;++y){var v=f[y];this.m_debugDraw.DrawSegment(m,v,n),this.m_debugDraw.DrawPoint(v,4,n),m=v}if(_.m_hasNextVertex){var S=_.m_nextVertex;this.m_debugDraw.DrawSegment(S,m,p),this.m_debugDraw.DrawCircle(S,.1,p)}break;case t.b2ShapeType.e_polygonShape:var T=r,A=T.m_count,b=T.m_vertices;this.m_debugDraw.DrawSolidPolygon(b,A,n)}}},n.Solve=function(e){for(var i=this.m_bodyList;i;i=i.m_next)i.m_xf0.Copy(i.m_xf);for(var n=this.m_controllerList;n;n=n.m_next)n.Step(e);this.m_profile.solveInit=0,this.m_profile.solveVelocity=0,this.m_profile.solvePosition=0;var r=this.m_island;r.Initialize(this.m_bodyCount,this.m_contactManager.m_contactCount,this.m_jointCount,this.m_contactManager.m_contactListener);for(var s=this.m_bodyList;s;s=s.m_next)s.m_islandFlag=!1;for(var o=this.m_contactManager.m_contactList;o;o=o.m_next)o.m_islandFlag=!1;for(var a=this.m_jointList;a;a=a.m_next)a.m_islandFlag=!1;for(var h=this.s_stack,u=this.m_bodyList;u;u=u.m_next)if(!u.m_islandFlag&&u.IsAwake()&&u.IsActive()&&u.GetType()!==t.b2BodyType.b2_staticBody){r.Clear();var l=0;for(h[l++]=u,u.m_islandFlag=!0;l>0;){var c=h[--l];if(!c)throw new Error;if(r.AddBody(c),c.m_awakeFlag=!0,c.GetType()!==t.b2BodyType.b2_staticBody){for(var _=c.m_contactList;_;_=_.next){var d=_.contact;if(!d.m_islandFlag&&d.IsEnabled()&&d.IsTouching()){var f=d.m_fixtureA.m_isSensor,p=d.m_fixtureB.m_isSensor;if(!f&&!p){r.AddContact(d),d.m_islandFlag=!0;var m=_.other;m.m_islandFlag||(h[l++]=m,m.m_islandFlag=!0)}}}for(var g=c.m_jointList;g;g=g.next)if(!g.joint.m_islandFlag){var y=g.other;y.IsActive()&&(r.AddJoint(g.joint),g.joint.m_islandFlag=!0,y.m_islandFlag||(h[l++]=y,y.m_islandFlag=!0))}}}var v=new En;r.Solve(v,e,this.m_gravity,this.m_allowSleep),this.m_profile.solveInit+=v.solveInit,this.m_profile.solveVelocity+=v.solveVelocity,this.m_profile.solvePosition+=v.solvePosition;for(var S=0;S<r.m_bodyCount;++S){var T=r.m_bodies[S];T.GetType()===t.b2BodyType.b2_staticBody&&(T.m_islandFlag=!1)}}for(var A=0;A<h.length&&h[A];++A)h[A]=null;for(var b=new it,E=this.m_bodyList;E;E=E.m_next)E.m_islandFlag&&E.GetType()!==t.b2BodyType.b2_staticBody&&E.SynchronizeFixtures();this.m_contactManager.FindNewContacts(),this.m_profile.broadphase=b.GetMilliseconds()},n.SolveTOI=function(i){var n=this.m_island;if(n.Initialize(64,32,0,this.m_contactManager.m_contactListener),this.m_stepComplete){for(var r=this.m_bodyList;r;r=r.m_next)r.m_islandFlag=!1,r.m_sweep.alpha0=0;for(var s=this.m_contactManager.m_contactList;s;s=s.m_next)s.m_toiFlag=!1,s.m_islandFlag=!1,s.m_toiCount=0,s.m_toi=1}for(;;){for(var o=null,a=1,h=this.m_contactManager.m_contactList;h;h=h.m_next)if(h.IsEnabled()&&!(h.m_toiCount>8)){var u=1;if(h.m_toiFlag)u=h.m_toi;else{var l=h.GetFixtureA(),c=h.GetFixtureB();if(l.IsSensor()||c.IsSensor())continue;var _=l.GetBody(),d=c.GetBody(),f=_.m_type,p=d.m_type,m=_.IsAwake()&&f!==t.b2BodyType.b2_staticBody,g=d.IsAwake()&&p!==t.b2BodyType.b2_staticBody;if(!m&&!g)continue;var y=_.IsBullet()||f!==t.b2BodyType.b2_dynamicBody,v=d.IsBullet()||p!==t.b2BodyType.b2_dynamicBody;if(!y&&!v)continue;var S=_.m_sweep.alpha0;_.m_sweep.alpha0<d.m_sweep.alpha0?(S=d.m_sweep.alpha0,_.m_sweep.Advance(S)):d.m_sweep.alpha0<_.m_sweep.alpha0&&(S=_.m_sweep.alpha0,d.m_sweep.Advance(S));var T=h.GetChildIndexA(),A=h.GetChildIndexB(),b=e.SolveTOI_s_toi_input;b.proxyA.SetShape(l.GetShape(),T),b.proxyB.SetShape(c.GetShape(),A),b.sweepA.Copy(_.m_sweep),b.sweepB.Copy(d.m_sweep),b.tMax=1;var E=e.SolveTOI_s_toi_output;Te(E,b);var C=E.t;u=E.state===t.b2TOIOutputState.e_touching?P(S+(1-S)*C,1):1,h.m_toi=u,h.m_toiFlag=!0}u<a&&(o=h,a=u)}if(null===o||.9999<a){this.m_stepComplete=!0;break}var w=o.GetFixtureA(),x=o.GetFixtureB(),R=w.GetBody(),I=x.GetBody(),B=e.SolveTOI_s_backup1.Copy(R.m_sweep),D=e.SolveTOI_s_backup2.Copy(I.m_sweep);if(R.Advance(a),I.Advance(a),o.Update(this.m_contactManager.m_contactListener),o.m_toiFlag=!1,++o.m_toiCount,o.IsEnabled()&&o.IsTouching()){R.SetAwake(!0),I.SetAwake(!0),n.Clear(),n.AddBody(R),n.AddBody(I),n.AddContact(o),R.m_islandFlag=!0,I.m_islandFlag=!0,o.m_islandFlag=!0;for(var O=0;O<2;++O){var M=0===O?R:I;if(M.m_type===t.b2BodyType.b2_dynamicBody)for(var L=M.m_contactList;L&&n.m_bodyCount!==n.m_bodyCapacity&&n.m_contactCount!==n.m_contactCapacity;L=L.next){var N=L.contact;if(!N.m_islandFlag){var F=L.other;if(F.m_type!==t.b2BodyType.b2_dynamicBody||M.IsBullet()||F.IsBullet()){var k=N.m_fixtureA.m_isSensor,V=N.m_fixtureB.m_isSensor;if(!k&&!V){var G=e.SolveTOI_s_backup.Copy(F.m_sweep);F.m_islandFlag||F.Advance(a),N.Update(this.m_contactManager.m_contactListener),N.IsEnabled()&&N.IsTouching()?(N.m_islandFlag=!0,n.AddContact(N),F.m_islandFlag||(F.m_islandFlag=!0,F.m_type!==t.b2BodyType.b2_staticBody&&F.SetAwake(!0),n.AddBody(F))):(F.m_sweep.Copy(G),F.SynchronizeTransform())}}}}}var U=e.SolveTOI_s_subStep;U.dt=(1-a)*i.dt,U.inv_dt=1/U.dt,U.dtRatio=1,U.positionIterations=20,U.velocityIterations=i.velocityIterations,U.particleIterations=i.particleIterations,U.warmStarting=!1,n.SolveTOI(U,R.m_islandIndex,I.m_islandIndex);for(var z=0;z<n.m_bodyCount;++z){var H=n.m_bodies[z];if(H.m_islandFlag=!1,H.m_type===t.b2BodyType.b2_dynamicBody){H.SynchronizeFixtures();for(var W=H.m_contactList;W;W=W.next)W.contact.m_toiFlag=!1,W.contact.m_islandFlag=!1}}if(this.m_contactManager.FindNewContacts(),this.m_subStepping){this.m_stepComplete=!1;break}}else o.SetEnabled(!1),R.m_sweep.Copy(B),I.m_sweep.Copy(D),R.SynchronizeTransform(),I.SynchronizeTransform()}},n.AddController=function(t){return t.m_next=this.m_controllerList,t.m_prev=null,this.m_controllerList&&(this.m_controllerList.m_prev=t),this.m_controllerList=t,++this.m_controllerCount,t},n.RemoveController=function(t){return t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),this.m_controllerList===t&&(this.m_controllerList=t.m_next),--this.m_controllerCount,t.m_prev=null,t.m_next=null,t},e}();Er.Step_s_step=new Cn,Er.Step_s_stepTimer=new it,Er.Step_s_timer=new it,Er.DrawDebugData_s_color=new tt(0,0,0),Er.DrawDebugData_s_vs=j.MakeArray(4),Er.DrawDebugData_s_xf=new Q,Er.QueryFixtureShape_s_aabb=new Vt,Er.RayCast_s_input=new Ft,Er.RayCast_s_output=new kt,Er.RayCast_s_point=new j,Er.DrawJoint_s_p1=new j,Er.DrawJoint_s_p2=new j,Er.DrawJoint_s_color=new tt(.5,.8,.8),Er.DrawJoint_s_c=new tt,Er.DrawShape_s_ghostColor=new tt,Er.SolveTOI_s_subStep=new Cn,Er.SolveTOI_s_backup=new $,Er.SolveTOI_s_backup1=new $,Er.SolveTOI_s_backup2=new $,Er.SolveTOI_s_toi_input=new he,Er.SolveTOI_s_toi_output=new le;var Cr=function(t,e){this.prevBody=null,this.nextBody=null,this.prevController=null,this.nextController=null,this.controller=t,this.body=e},wr=function(){function t(){this.m_bodyList=null,this.m_bodyCount=0,this.m_prev=null,this.m_next=null}var e=t.prototype;return e.GetNext=function(){return this.m_next},e.GetPrev=function(){return this.m_prev},e.GetBodyList=function(){return this.m_bodyList},e.AddBody=function(t){var e=new Cr(this,t);e.nextBody=this.m_bodyList,e.prevBody=null,this.m_bodyList&&(this.m_bodyList.prevBody=e),this.m_bodyList=e,++this.m_bodyCount,e.nextController=t.m_controllerList,e.prevController=null,t.m_controllerList&&(t.m_controllerList.prevController=e),t.m_controllerList=e,++t.m_controllerCount},e.RemoveBody=function(t){if(this.m_bodyCount<=0)throw new Error;for(var e=this.m_bodyList;e&&e.body!==t;)e=e.nextBody;if(null===e)throw new Error;e.prevBody&&(e.prevBody.nextBody=e.nextBody),e.nextBody&&(e.nextBody.prevBody=e.prevBody),this.m_bodyList===e&&(this.m_bodyList=e.nextBody),--this.m_bodyCount,e.nextController&&(e.nextController.prevController=e.prevController),e.prevController&&(e.prevController.nextController=e.nextController),t.m_controllerList===e&&(t.m_controllerList=e.nextController),--t.m_controllerCount},e.Clear=function(){for(;this.m_bodyList;)this.RemoveBody(this.m_bodyList.body);this.m_bodyCount=0},t}(),xr=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).normal=new j(0,1),e.offset=0,e.density=0,e.velocity=new j(0,0),e.linearDrag=0,e.angularDrag=0,e.useDensity=!1,e.useWorldGravity=!0,e.gravity=new j(0,0),e}s(e,t);var i=e.prototype;return i.Step=function(){if(this.m_bodyList){this.useWorldGravity&&this.gravity.Copy(this.m_bodyList.body.GetWorld().GetGravity());for(var t=this.m_bodyList;t;t=t.nextBody){var e=t.body;if(e.IsAwake()){for(var i=new j,n=new j,s=0,o=0,a=e.GetFixtureList();a;a=a.m_next){var h=new j,u=a.GetShape().ComputeSubmergedArea(this.normal,this.offset,e.GetTransform(),h);s+=u,i.x+=u*h.x,i.y+=u*h.y;var l;o+=u*(l=this.useDensity?a.GetDensity():1),n.x+=u*h.x*l,n.y+=u*h.y*l}if(i.x/=s,i.y/=s,n.x/=o,n.y/=o,!(s<r)){var c=this.gravity.Clone().SelfNeg();c.SelfMul(this.density*s),e.ApplyForce(c,n);var _=e.GetLinearVelocityFromWorldPoint(i,new j);_.SelfSub(this.velocity),_.SelfMul(-this.linearDrag*s),e.ApplyForce(_,i),e.ApplyTorque(-e.GetInertia()/e.GetMass()*s*e.GetAngularVelocity()*this.angularDrag)}}}}},i.Draw=function(t){var e=100,i=new j,n=new j;i.x=this.normal.x*this.offset+this.normal.y*e,i.y=this.normal.y*this.offset-this.normal.x*e,n.x=this.normal.x*this.offset-this.normal.y*e,n.y=this.normal.y*this.offset+this.normal.x*e;var r=new tt(0,0,.8);t.DrawSegment(i,n,r)},e}(wr),Rr=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).A=new j(0,0),e}s(e,t);var i=e.prototype;return i.Step=function(t){for(var i=j.MulSV(t.dt,this.A,e.Step_s_dtA),n=this.m_bodyList;n;n=n.nextBody){var r=n.body;r.IsAwake()&&r.SetLinearVelocity(j.AddVV(r.GetLinearVelocity(),i,j.s_t0))}},i.Draw=function(){},e}(wr);Rr.Step_s_dtA=new j;var Ir=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).F=new j(0,0),e}s(e,t);var i=e.prototype;return i.Step=function(){for(var t=this.m_bodyList;t;t=t.nextBody){var e=t.body;e.IsAwake()&&e.ApplyForce(this.F,e.GetWorldCenter())}},i.Draw=function(){},e}(wr),Br=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).G=1,e.invSqr=!0,e}s(e,t);var i=e.prototype;return i.Step=function(){if(this.invSqr)for(var t=this.m_bodyList;t;t=t.nextBody)for(var i=t.body,n=i.GetWorldCenter(),s=i.GetMass(),o=this.m_bodyList;o&&o!==t;o=o.nextBody){var a=o.body,h=a.GetWorldCenter(),u=a.GetMass(),l=h.x-n.x,c=h.y-n.y,_=l*l+c*c;if(!(_<r)){var d=e.Step_s_f.Set(l,c);d.SelfMul(this.G/_/k(_)*s*u),i.IsAwake()&&i.ApplyForce(d,n),a.IsAwake()&&a.ApplyForce(d.SelfMul(-1),h)}}else for(var f=this.m_bodyList;f;f=f.nextBody)for(var p=f.body,m=p.GetWorldCenter(),g=p.GetMass(),y=this.m_bodyList;y&&y!==f;y=y.nextBody){var v=y.body,S=v.GetWorldCenter(),T=v.GetMass(),A=S.x-m.x,b=S.y-m.y,E=A*A+b*b;if(!(E<r)){var C=e.Step_s_f.Set(A,b);C.SelfMul(this.G/E*g*T),p.IsAwake()&&p.ApplyForce(C,m),v.IsAwake()&&v.ApplyForce(C.SelfMul(-1),S)}}},i.Draw=function(){},e}(wr);Br.Step_s_f=new j;var Dr=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).T=new Y,e.maxTimestep=0,e}s(e,t);var i=e.prototype;return i.Step=function(t){var i=t.dt;if(!(i<=r)){i>this.maxTimestep&&this.maxTimestep>0&&(i=this.maxTimestep);for(var n=this.m_bodyList;n;n=n.nextBody){var s=n.body;if(s.IsAwake()){var o=s.GetWorldVector(Y.MulMV(this.T,s.GetLocalVector(s.GetLinearVelocity(),j.s_t0),j.s_t1),e.Step_s_damping);s.SetLinearVelocity(j.AddVV(s.GetLinearVelocity(),j.MulSV(i,o,j.s_t0),j.s_t1))}}}},i.Draw=function(){},i.SetAxisAligned=function(t,e){this.T.ex.x=-t,this.T.ex.y=0,this.T.ey.x=0,this.T.ey.y=-e,this.maxTimestep=t>0||e>0?1/O(t,e):0},e}(wr);Dr.Step_s_damping=new j;var Pr=function(){function t(){this.m_count=0,this.m_ps=[],this.m_p0s=[],this.m_vs=[],this.m_ims=[],this.m_Ls=[],this.m_as=[],this.m_gravity=new j,this.m_damping=0,this.m_k2=1,this.m_k3=.1}var e=t.prototype;return e.GetVertexCount=function(){return this.m_count},e.GetVertices=function(){return this.m_ps},e.Initialize=function(t){this.m_count=t.count,this.m_ps=j.MakeArray(this.m_count),this.m_p0s=j.MakeArray(this.m_count),this.m_vs=j.MakeArray(this.m_count),this.m_ims=x(this.m_count);for(var e=0;e<this.m_count;++e){this.m_ps[e].Copy(t.vertices[e]),this.m_p0s[e].Copy(t.vertices[e]),this.m_vs[e].SetZero();var i=t.masses[e];this.m_ims[e]=i>0?1/i:0}var n=this.m_count-1,r=this.m_count-2;this.m_Ls=x(n),this.m_as=x(r);for(var s=0;s<n;++s){var o=this.m_ps[s],a=this.m_ps[s+1];this.m_Ls[s]=j.DistanceVV(o,a)}for(var h=0;h<r;++h){var u=this.m_ps[h],l=this.m_ps[h+1],c=this.m_ps[h+2],_=j.SubVV(l,u,j.s_t0),d=j.SubVV(c,l,j.s_t1),f=j.CrossVV(_,d),p=j.DotVV(_,d);this.m_as[h]=W(f,p)}this.m_gravity.Copy(t.gravity),this.m_damping=t.damping,this.m_k2=t.k2,this.m_k3=t.k3},e.Step=function(t,e){if(0!==t){for(var i=Math.exp(-t*this.m_damping),n=0;n<this.m_count;++n)this.m_p0s[n].Copy(this.m_ps[n]),this.m_ims[n]>0&&this.m_vs[n].SelfMulAdd(t,this.m_gravity),this.m_vs[n].SelfMul(i),this.m_ps[n].SelfMulAdd(t,this.m_vs[n]);for(var r=0;r<e;++r)this.SolveC2(),this.SolveC3(),this.SolveC2();for(var s=1/t,o=0;o<this.m_count;++o)j.MulSV(s,j.SubVV(this.m_ps[o],this.m_p0s[o],j.s_t0),this.m_vs[o])}},e.SolveC2=function(){for(var e=this.m_count-1,i=0;i<e;++i){var n=this.m_ps[i],r=this.m_ps[i+1],s=j.SubVV(r,n,t.s_d),o=s.Normalize(),a=this.m_ims[i],h=this.m_ims[i+1];if(a+h!==0){var u=a/(a+h),l=h/(a+h);n.SelfMulSub(this.m_k2*u*(this.m_Ls[i]-o),s),r.SelfMulAdd(this.m_k2*l*(this.m_Ls[i]-o),s)}}},e.SetAngle=function(t){for(var e=this.m_count-2,i=0;i<e;++i)this.m_as[i]=t},e.SolveC3=function(){for(var e=this.m_count-2,i=0;i<e;++i){var n=this.m_ps[i],r=this.m_ps[i+1],s=this.m_ps[i+2],o=this.m_ims[i],h=this.m_ims[i+1],u=this.m_ims[i+2],l=j.SubVV(r,n,t.s_d1),c=j.SubVV(s,r,t.s_d2),_=l.LengthSquared(),d=c.LengthSquared();if(_*d!=0){var f=j.CrossVV(l,c),p=j.DotVV(l,c),m=W(f,p),g=j.MulSV(-1/_,l.SelfSkew(),t.s_Jd1),y=j.MulSV(1/d,c.SelfSkew(),t.s_Jd2),v=j.NegV(g,t.s_J1),S=j.SubVV(g,y,t.s_J2),T=y,A=o*j.DotVV(v,v)+h*j.DotVV(S,S)+u*j.DotVV(T,T);if(0!==A){A=1/A;for(var b=m-this.m_as[i];b>a;)b=(m-=2*a)-this.m_as[i];for(;b<-a;)b=(m+=2*a)-this.m_as[i];var E=-this.m_k3*A*b;n.SelfMulAdd(o*E,v),r.SelfMulAdd(h*E,S),s.SelfMulAdd(u*E,T)}}}},e.Draw=function(t){for(var e=new tt(.4,.5,.7),i=0;i<this.m_count-1;++i)t.DrawSegment(this.m_ps[i],this.m_ps[i+1],e)},t}();Pr.s_d=new j,Pr.s_d1=new j,Pr.s_d2=new j,Pr.s_Jd1=new j,Pr.s_Jd2=new j,Pr.s_J1=new j,Pr.s_J2=new j,t.b2AABB=Vt,t.b2Abs=D,t.b2Acos=z,t.b2Alloc=function(){return null},t.b2AreaJoint=Ni,t.b2AreaJointDef=Li,t.b2Asin=H,t.b2Assert=function(t){if(!t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];throw u(Error,i)}},t.b2Atan2=W,t.b2BlockAllocator=function(){},t.b2Body=Ri,t.b2BodyDef=function(){this.type=t.b2BodyType.b2_staticBody,this.position=new j(0,0),this.angle=0,this.linearVelocity=new j(0,0),this.angularVelocity=0,this.linearDamping=0,this.angularDamping=0,this.allowSleep=!0,this.awake=!0,this.fixedRotation=!1,this.bullet=!1,this.active=!0,this.userData=null,this.gravityScale=1},t.b2BroadPhase=Zt,t.b2BuoyancyController=xr,t.b2CalculateParticleIterations=Vn,t.b2ChainAndCircleContact=dn,t.b2ChainAndPolygonContact=fn,t.b2ChainShape=Si,t.b2CircleContact=hn,t.b2CircleShape=gi,t.b2Clamp=M,t.b2ClipSegmentToLine=Ut,t.b2ClipVertex=Nt,t.b2CollideCircles=Ee,t.b2CollideEdgeAndCircle=ai,t.b2CollideEdgeAndPolygon=di,t.b2CollidePolygonAndCircle=Re,t.b2CollidePolygons=Qe,t.b2Color=tt,t.b2ConstantAccelController=Rr,t.b2ConstantForceController=Ir,t.b2Contact=an,t.b2ContactEdge=on,t.b2ContactFactory=mn,t.b2ContactFeature=Bt,t.b2ContactFilter=yn,t.b2ContactID=Dt,t.b2ContactImpulse=vn,t.b2ContactListener=Sn,t.b2ContactManager=bn,t.b2ContactPositionConstraint=Pn,t.b2ContactRegister=pn,t.b2ContactSolver=Ln,t.b2ContactSolverDef=On,t.b2ContactVelocityConstraint=Dn,t.b2Controller=wr,t.b2ControllerEdge=Cr,t.b2Cos=G,t.b2Counter=nt,t.b2DegToRad=function(t){return t*R},t.b2DestructionListener=gn,t.b2Distance=vt,t.b2DistanceInput=at,t.b2DistanceJoint=Mi,t.b2DistanceJointDef=Oi,t.b2DistanceOutput=ht,t.b2DistanceProxy=st,t.b2Draw=et,t.b2DynamicTree=Yt,t.b2EdgeAndCircleContact=cn,t.b2EdgeAndPolygonContact=_n,t.b2EdgeShape=vi,t.b2Filter=Ti,t.b2Fixture=Ci,t.b2FixtureDef=Ai,t.b2FixtureParticleQueryCallback=nr,t.b2FixtureProxy=bi,t.b2Free=function(){},t.b2FrictionJoint=ki,t.b2FrictionJointDef=Fi,t.b2GearJoint=Gi,t.b2GearJointDef=Vi,t.b2GetPointStates=function(e,i,n,r){var s;for(s=0;s<n.pointCount;++s){var o=n.points[s].id.key;e[s]=t.b2PointState.b2_removeState;for(var a=0,h=r.pointCount;a<h;++a)if(r.points[a].id.key===o){e[s]=t.b2PointState.b2_persistState;break}}for(;s<2;++s)e[s]=t.b2PointState.b2_nullState;for(s=0;s<r.pointCount;++s){var u=r.points[s].id.key;i[s]=t.b2PointState.b2_addState;for(var l=0,c=n.pointCount;l<c;++l)if(n.points[l].id.key===u){i[s]=t.b2PointState.b2_persistState;break}}for(;s<2;++s)i[s]=t.b2PointState.b2_nullState},t.b2GravityController=Br,t.b2GrowableBuffer=ir,t.b2GrowableStack=rt,t.b2InvSqrt=F,t.b2IsPowerOfTwo=function(t){return t>0&&0==(t&t-1)},t.b2IsValid=L,t.b2Island=Fn,t.b2Jacobian=Ii,t.b2Joint=Pi,t.b2JointDef=Di,t.b2JointEdge=Bi,t.b2Log=function(){},t.b2MakeArray=w,t.b2MakeNullArray=function(t){for(var e=new Array(t),i=0;i<t;++i)e[i]=null;return e},t.b2MakeNumberArray=x,t.b2Manifold=Mt,t.b2ManifoldPoint=Pt,t.b2MassData=pi,t.b2Mat22=Y,t.b2Mat33=K,t.b2Max=O,t.b2Maybe=e,t.b2Min=P,t.b2MixFriction=rn,t.b2MixRestitution=sn,t.b2MotorJoint=zi,t.b2MotorJointDef=Ui,t.b2MouseJoint=Wi,t.b2MouseJointDef=Hi,t.b2NextPowerOfTwo=function(t){return t|=t>>1&2147483647,t|=t>>2&1073741823,t|=t>>4&268435455,1+((t|=t>>8&16777215)|t>>16&65535)},t.b2Pair=Qt,t.b2PairLessThan=$t,t.b2ParseInt=function(t){return parseInt(t,10)},t.b2ParseUInt=function(t){return Math.abs(parseInt(t,10))},t.b2ParticleBodyContact=sr,t.b2ParticleContact=rr,t.b2ParticleDef=kn,t.b2ParticleGroup=Hn,t.b2ParticleGroupDef=zn,t.b2ParticleHandle=Un,t.b2ParticlePair=or,t.b2ParticlePairSet=mr,t.b2ParticleSystem=ur,t.b2ParticleSystemDef=hr,t.b2ParticleSystem_CompositeShape=Sr,t.b2ParticleSystem_ConnectionFilter=gr,t.b2ParticleSystem_DestroyParticlesInShapeCallback=yr,t.b2ParticleSystem_FixedSetAllocator=fr,t.b2ParticleSystem_FixtureParticle=function(t,e){this.second=y,this.first=t,this.second=e},t.b2ParticleSystem_FixtureParticleSet=pr,t.b2ParticleSystem_InsideBoundsEnumerator=_r,t.b2ParticleSystem_JoinParticleGroupsFilter=vr,t.b2ParticleSystem_ParticleListNode=dr,t.b2ParticleSystem_ParticlePair=function(t,e){this.first=y,this.second=y,this.first=t,this.second=e},t.b2ParticleSystem_Proxy=cr,t.b2ParticleSystem_ReactiveFilter=Tr,t.b2ParticleSystem_SolveCollisionCallback=br,t.b2ParticleSystem_UpdateBodyContactsCallback=Ar,t.b2ParticleSystem_UserOverridableBuffer=lr,t.b2ParticleTriad=ar,t.b2PolygonAndCircleContact=ln,t.b2PolygonContact=un,t.b2PolygonShape=yi,t.b2Position=wn,t.b2PositionSolverManifold=Mn,t.b2Pow=V,t.b2PrismaticJoint=Xi,t.b2PrismaticJointDef=ji,t.b2Profile=En,t.b2PulleyJoint=Yi,t.b2PulleyJointDef=qi,t.b2QueryCallback=Tn,t.b2RadToDeg=function(t){return t*I},t.b2Random=function(){return 2*Math.random()-1},t.b2RandomRange=function(t,e){return(e-t)*Math.random()+t},t.b2RayCastCallback=An,t.b2RayCastInput=Ft,t.b2RayCastOutput=kt,t.b2RevoluteJoint=Ji,t.b2RevoluteJointDef=Ki,t.b2Rope=Pr,t.b2RopeDef=function(){this.vertices=[],this.count=0,this.masses=[],this.gravity=new j(0,0),this.damping=.1,this.k2=.9,this.k3=.1},t.b2RopeJoint=Zi,t.b2RopeJointDef=Qi,t.b2Rot=J,t.b2SeparationFunction=ce,t.b2Shape=mi,t.b2ShapeCast=function(t,e){t.iterations=0,t.lambda=1,t.normal.SetZero(),t.point.SetZero();var i=e.proxyA,n=e.proxyB,r=O(i.m_radius,_)+O(n.m_radius,_),s=e.transformA,o=e.transformB,a=e.translationB,h=Tt.Set(0,0),u=0,l=At;l.m_count=0;for(var c=l.m_vertices,d=i.GetSupport(J.MulTRV(s.q,j.NegV(a,j.s_t1),j.s_t0)),f=Q.MulXV(s,i.GetVertex(d),bt),p=n.GetSupport(J.MulTRV(o.q,a,j.s_t0)),m=Q.MulXV(o,n.GetVertex(p),Et),g=j.SubVV(f,m,Ct),y=O(_,r-_),v=0;v<20&&D(g.Length()-y)>.004;){t.iterations+=1,d=i.GetSupport(J.MulTRV(s.q,j.NegV(g,j.s_t1),j.s_t0)),f=Q.MulXV(s,i.GetVertex(d),bt),p=n.GetSupport(J.MulTRV(o.q,g,j.s_t0)),m=Q.MulXV(o,n.GetVertex(p),Et);var S=j.SubVV(f,m,wt);g.Normalize();var T=j.DotVV(g,S),A=j.DotVV(g,a);if(T-y>u*A){if(A<=0)return!1;if((u=(T-y)/A)>1)return!1;h.Copy(g).SelfNeg(),l.m_count=0}var b=c[l.m_count];switch(b.indexA=p,b.wA.Copy(m).SelfMulAdd(u,a),b.indexB=d,b.wB.Copy(f),b.w.Copy(b.wB).SelfSub(b.wA),b.a=1,l.m_count+=1,l.m_count){case 1:break;case 2:l.Solve2();break;case 3:l.Solve3()}if(3===l.m_count)return!1;l.GetClosestPoint(g),++v}var E=xt,C=Rt;return l.GetWitnessPoints(E,C),g.LengthSquared()>0&&(h.Copy(g).SelfNeg(),h.Normalize()),t.normal.Copy(h),t.lambda=u,t.iterations=v,!0},t.b2ShapeCastInput=function(){this.proxyA=new st,this.proxyB=new st,this.transformA=new Q,this.transformB=new Q,this.translationB=new j},t.b2ShapeCastOutput=function(){this.point=new j,this.normal=new j,this.lambda=0,this.iterations=0},t.b2Simplex=lt,t.b2SimplexCache=ot,t.b2SimplexVertex=ut,t.b2Sin=U,t.b2SolverData=Rn,t.b2Sq=N,t.b2Sqrt=k,t.b2StackAllocator=function(){},t.b2Swap=function(t,e){var i=t[0];t[0]=e[0],e[0]=i},t.b2Sweep=$,t.b2TOIInput=he,t.b2TOIOutput=le,t.b2TensorDampingController=Dr,t.b2TestOverlapAABB=Gt,t.b2TestOverlapShape=jt,t.b2TimeOfImpact=Te,t.b2TimeStep=Cn,t.b2Timer=it,t.b2Transform=Q,t.b2TreeNode=qt,t.b2Vec2=j,t.b2Vec2_zero=X,t.b2Vec3=q,t.b2Velocity=xn,t.b2VelocityConstraintPoint=Bn,t.b2Version=E,t.b2WeldJoint=tn,t.b2WeldJointDef=$i,t.b2WheelJoint=nn,t.b2WheelJointDef=en,t.b2World=Er,t.b2WorldManifold=Lt,t.b2_180_over_pi=I,t.b2_aabbExtension=h,t.b2_aabbMultiplier=2,t.b2_angularSleepTolerance=b,t.b2_angularSlop=c,t.b2_barrierCollisionTime=2.5,t.b2_baumgarte=.2,t.b2_branch="master",t.b2_commit="fbf51801d80fc389d43dc46524520e89043b6faf",t.b2_epsilon=r,t.b2_epsilon_sq=o,t.b2_gjk_reset=function(){t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0},t.b2_invalidParticleIndex=y,t.b2_linearSleepTolerance=A,t.b2_linearSlop=l,t.b2_maxAngularCorrection=p,t.b2_maxFloat=i,t.b2_maxLinearCorrection=f,t.b2_maxManifoldPoints=2,t.b2_maxParticleForce=.5,t.b2_maxParticleIndex=2147483647,t.b2_maxParticlePressure=S,t.b2_maxPolygonVertices=8,t.b2_maxRotation=m,t.b2_maxRotationSquared=g,t.b2_maxSubSteps=8,t.b2_maxTOIContacts=32,t.b2_maxTranslation=2,t.b2_maxTranslationSquared=4,t.b2_maxTriadDistance=2,t.b2_maxTriadDistanceSquared=4,t.b2_minParticleSystemBufferCapacity=T,t.b2_minParticleWeight=1,t.b2_minPulleyLength=2,t.b2_particleStride=v,t.b2_pi=a,t.b2_pi_over_180=R,t.b2_polygonRadius=_,t.b2_timeToSleep=.5,t.b2_toiBaumgarte=.75,t.b2_toi_reset=function(){t.b2_toiTime=0,t.b2_toiMaxTime=0,t.b2_toiCalls=0,t.b2_toiIters=0,t.b2_toiMaxIters=0,t.b2_toiRootIters=0,t.b2_toiMaxRootIters=0},t.b2_two_pi=B,t.b2_velocityThreshold=1,t.b2_version=C,t.g_blockSolve=In,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));(ett=itt)&&ett.__esModule&&Object.prototype.hasOwnProperty.call(ett,"default")&&ett.default;var ntt={};for(var rtt in itt)-1===rtt.indexOf("b2_")&&(ntt[rtt.replace("b2","")]=itt[rtt]);var stt=ntt,ott=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._contactFixtures=[],e._BeginContact=null,e._EndContact=null,e._PreSolve=null,e._PostSolve=null,e}s(e,t);var i=e.prototype;return i.setBeginContact=function(t){this._BeginContact=t},i.setEndContact=function(t){this._EndContact=t},i.setPreSolve=function(t){this._PreSolve=t},i.setPostSolve=function(t){this._PostSolve=t},i.BeginContact=function(t){if(this._BeginContact){var e=t.GetFixtureA(),i=t.GetFixtureB(),n=this._contactFixtures;t._shouldReport=!1,-1===n.indexOf(e)&&-1===n.indexOf(i)||(t._shouldReport=!0,this._BeginContact(t))}},i.EndContact=function(t){this._EndContact&&t._shouldReport&&(t._shouldReport=!1,this._EndContact(t))},i.PreSolve=function(t,e){this._PreSolve&&t._shouldReport&&this._PreSolve(t,e)},i.PostSolve=function(t,e){this._PostSolve&&t._shouldReport&&this._PostSolve(t,e)},i.registerContactFixture=function(t){this._contactFixtures.push(t)},i.unregisterContactFixture=function(t){he(this._contactFixtures,t)},e}(stt.ContactListener),att=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._point=new stt.Vec2,e._isPoint=!1,e._fixtures=[],e}s(e,t);var i=e.prototype;return i.init=function(t){t?(this._isPoint=!0,this._point.x=t.x,this._point.y=t.y):this._isPoint=!1,this._fixtures.length=0},i.ReportFixture=function(t){return this._isPoint?t.TestPoint(this._point)&&this._fixtures.push(t):this._fixtures.push(t),!0},i.getFixture=function(){return this._fixtures[0]},i.getFixtures=function(){return this._fixtures},e}(stt.QueryCallback);function htt(t,e){var i=e.length;return e[t<0?i- -t%i:t%i]}function utt(t,e,i){for(var n=[];e<t;)e+=i.length;for(;t<=e;++t)n.push(htt(t,i));return n}function ltt(t,e,i){if(ctt(t,i)){if(ftt(htt(t,i),htt(t-1,i),htt(e,i))&&ptt(htt(t,i),htt(t+1,i),htt(e,i)))return!1}else if(ptt(htt(t,i),htt(t+1,i),htt(e,i))||ftt(htt(t,i),htt(t-1,i),htt(e,i)))return!1;if(ctt(e,i)){if(ftt(htt(e,i),htt(e-1,i),htt(t,i))&&ptt(htt(e,i),htt(e+1,i),htt(t,i)))return!1}else if(ptt(htt(e,i),htt(e+1,i),htt(t,i))||ftt(htt(e,i),htt(e-1,i),htt(t,i)))return!1;for(var n=0;n<i.length;++n)if((n+1)%i.length!=t&&n!=t&&(n+1)%i.length!=e&&n!=e){var r=new Ln;if(Stt(htt(t,i),htt(e,i),htt(n,i),htt(n+1,i),r))return!1}return!0}function ctt(t,e){return _tt(t,e)}function _tt(t,e,i){if(void 0===i){var n=t,r=e;t=htt(n-1,r),e=htt(n,r),void 0===t&&(t=e),void 0===(i=htt(n+1,r))&&(i=e)}return Ttt(t,e,i)<0}function dtt(t,e,i){return Ttt(t,e,i)>0}function ftt(t,e,i){return Ttt(t,e,i)>=0}function ptt(t,e,i){return Ttt(t,e,i)<=0}function mtt(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function gtt(t){ytt(t)||t.reverse()}function ytt(t){return t.length<3||function(t){var e,i=0;for(e=0;e<t.length;e++){var n=(e+1)%t.length;i+=t[e].x*t[n].y,i-=t[e].y*t[n].x}return i/2}(t)>0}function vtt(t,e,i,n){var r,s=new Ln,o=e.y-t.y,a=t.x-e.x,h=o*t.x+a*t.y,u=n.y-i.y,l=i.x-n.x,c=u*i.x+l*i.y,_=o*l-u*a;return r=_,0,Math.abs(r-0)<=1e-6||(s.x=(l*h-a*c)/_,s.y=(o*c-u*h)/_),s}function Stt(t,e,i,n,r){if(t==i||t==n||e==i||e==n)return!1;var s=t.x,o=t.y,a=e.x,h=e.y,u=i.x,l=i.y,c=n.x,_=n.y;if(Math.max(s,a)<Math.min(u,c)||Math.max(u,c)<Math.min(s,a))return!1;if(Math.max(o,h)<Math.min(l,_)||Math.max(l,_)<Math.min(o,h))return!1;var d=(c-u)*(o-l)-(_-l)*(s-u),f=(a-s)*(o-l)-(h-o)*(s-u),p=(_-l)*(a-s)-(c-u)*(h-o);return!(Math.abs(p)<1e-6)&&(f/=p,(d/=p)>0&&d<1&&f>0&&f<1&&(r.x=s+d*(a-s),r.y=o+d*(h-o),!0))}function Ttt(t,e,i){return t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y)}var Att=Object.freeze({__proto__:null,ConvexPartition:function t(e){gtt(e);for(var i,n,r,s,o,a,h=[],u=new Ln,l=new Ln,c=0,_=0,d=0;d<e.length;++d)if(ctt(d,e)){n=r=1e8;for(var f=0;f<e.length;++f)dtt(htt(d-1,e),htt(d,e),htt(f,e))&&ptt(htt(d-1,e),htt(d,e),htt(f-1,e))&&(s=vtt(htt(d-1,e),htt(d,e),htt(f,e),htt(f-1,e)),_tt(htt(d+1,e),htt(d,e),s)&&(i=mtt(htt(d,e),s))<n&&(n=i,u=s,c=f)),dtt(htt(d+1,e),htt(d,e),htt(f+1,e))&&ptt(htt(d+1,e),htt(d,e),htt(f,e))&&(s=vtt(htt(d+1,e),htt(d,e),htt(f,e),htt(f+1,e)),dtt(htt(d-1,e),htt(d,e),s)&&(i=mtt(htt(d,e),s))<r&&(r=i,_=f,l=s));if(c==(_+1)%e.length){var p=u.add(l).multiplyScalar(.5);(o=utt(d,_,e)).push(p),(a=utt(c,d,e)).push(p)}else{for(var m=0,g=c;_<c;)_+=e.length;for(var y=c;y<=_;++y)if(ltt(d,y,e)){var v=1/(mtt(htt(d,e),htt(y,e))+1);ctt(y,e)?ptt(htt(y-1,e),htt(y,e),htt(d,e))&&ftt(htt(y+1,e),htt(y,e),htt(d,e))?v+=3:v+=2:v+=1,v>m&&(g=y,m=v)}o=utt(d,g,e),a=utt(g,d,e)}return(h=h.concat(t(o))).concat(t(a))}h.push(e);for(var S=h.length-1;S>=0;S--)0==h[S].length&&h.splice(S,0);return h},ForceCounterClockWise:gtt,IsCounterClockWise:ytt});function btt(t){Rtt(t);for(var e=!0,i=0,n=t.length;i<n;++i)if(!wtt(t[(i+n-1)%n],t[i],t[(i+1)%n])){e=!1;break}if(e)return[t];var r=[],s=function(t){if(Rtt(t),t.length<4)return[t];for(var e=t.length,i=[],n=[],r=0;r<e;++r){var s=new Ett;s.isActive=!0,s.isConvex=!1,s.isEar=!1,s.point=t[r],s.angleCos=0,s.shouldUpdate=!0,s.index=r,i.push(s)}for(var o=0;o<e;++o){var a=i[o];a.prev=i[(o+e-1)%e],a.next=i[(o+1)%e]}i.forEach((function(t){return Itt(t,i)}));for(var h=0;h<e-3;++h){for(var u=void 0,l=0;l<e;++l){var c=i[l];c.isActive&&c.isEar&&(u?c.angleCos>u.angleCos&&(u=c):u=c)}if(!u){for(var _=0;_<e;++_){var d=i[_];if(d.isActive){var f=d.prev.point,p=d.point,m=d.next.point;if(Math.abs(Ctt(f,p,m))>1e-5)return console.log("Failed to find ear. There might be self-intersection in the polygon."),null}}break}if(n.push([u.prev.point,u.point,u.next.point]),u.isActive=!1,u.prev.next=u.next,u.next.prev=u.prev,u.prev.shouldUpdate=!0,u.next.shouldUpdate=!0,Btt(u.next),h===e-4)break;for(var g=0;g<e;++g)Itt(i[g],i)}for(var y=0;y<e;++y){var v=i[y];if(v.isActive){v.prev.isActive=!1,v.next.isActive=!1;var S=v.prev.point,T=v.point,A=v.next.point;Math.abs(Ctt(S,T,A))>1e-5&&n.push([S,T,A])}}return n}(t);if(!s)return null;for(;s.length;){for(var o=s.splice(0,1)[0],a=0,h=o.length;a<h;++a){for(var u=o[a],l=o[(a+1)%h],c=null,_=0;_<s.length;++_){for(var d=s[_],f=0;f<3;++f){var p=d[f];if(xtt(u,d[(f+1)%3])&&xtt(l,p)){c=d[(f+2)%3];break}}if(c)break}if(c&&!(Ctt(o[(a+h-1)%h],u,c)>0||Ctt(c,l,o[(a+2)%h])>0)){for(var m=[],g=(a+1)%h;g!==a;g=(g+1)%h)m.push(o[g]);m.push(u,c),o=m,h=m.length,a=-1,s.splice(_,1)}}r.push(o)}return r}var Ett=function(){this.isActive=!1,this.isConvex=!1,this.isEar=!1,this.point=null,this.angleCos=0,this.shouldUpdate=!1,this.index=0,this.prev=null,this.next=null};function Ctt(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function wtt(t,e,i){return Ctt(t,e,i)<0}function xtt(t,e){return t.x===e.x&&t.y===e.y}function Rtt(t){(function(t){for(var e=0,i=0,n=t.length;i<n;++i){var r=t[i],s=t[(i+1)%n];e+=(s.x-r.x)*(s.y+r.y)}return e>0})(t)&&t.reverse()}function Itt(t,e){if(t.shouldUpdate){t.shouldUpdate=!1;var i=t.prev.point,n=t.point,r=t.next.point;t.isConvex=wtt(i,n,r);var s=i.x-n.x,o=i.y-n.y,a=Math.sqrt(s*s+o*o);s/=a,o/=a;var h=r.x-n.x,u=r.y-n.y,l=Math.sqrt(h*h+u*u);if(h/=l,u/=l,t.angleCos=s*h+o*u,t.isConvex){t.isEar=!0;for(var c=0,_=e.length;c<_;++c){var d=e[c];if(d.isActive&&d!==t){var f=d.point;if(!(xtt(i,f)||xtt(n,f)||xtt(r,f))){var p=Ctt(i,f,n),m=Ctt(n,f,r),g=Ctt(r,f,i);if(p>0&&m>0&&g>0){t.isEar=!1;break}if(0===p&&m>=0&&g>=0&&(Ctt(i,d.prev.point,n)>0||Ctt(i,d.next.point,n)>0)){t.isEar=!1;break}if(0===m&&p>=0&&g>=0&&(Ctt(n,d.prev.point,r)>0||Ctt(n,d.next.point,r)>0)){t.isEar=!1;break}if(0===g&&p>=0&&m>=0&&(Ctt(r,d.prev.point,i)>0||Ctt(r,d.next.point,i)>0)){t.isEar=!1;break}}}}}else t.isEar=!1}}function Btt(t){for(var e=t,i=t;;)if(xtt(e.point,e.next.point)||0===Ctt(e.prev.point,e.point,e.next.point)){if(e.prev.next=e.next,e.next.prev=e.prev,e.prev.shouldUpdate=!0,e.next.shouldUpdate=!0,e===e.next)break;i=e.prev,e=e.next}else if((e=e.next)===i)break}var Dtt,Ptt,Ott,Mtt,Ltt,Ntt,Ftt,ktt,Vtt,Gtt,Utt,ztt=Object.freeze({__proto__:null,ConvexPartition:btt});t("fK",Dtt),function(t){t[t.DYNAMIC=1]="DYNAMIC",t[t.STATIC=2]="STATIC",t[t.KINEMATIC=4]="KINEMATIC"}(Dtt||t("fK",Dtt={})),ge(Dtt),t("fJ",Ptt),function(t){t[t.X_AXIS=0]="X_AXIS",t[t.Y_AXIS=1]="Y_AXIS",t[t.Z_AXIS=2]="Z_AXIS"}(Ptt||t("fJ",Ptt={})),ge(Ptt),function(t){t[t.X=0]="X",t[t.Y=1]="Y",t[t.Z=2]="Z",t[t.SWING1=3]="SWING1",t[t.SWING2=4]="SWING2",t[t.TWIST=5]="TWIST"}(Ott||(Ott={})),ge(Ott),function(t){t[t.VERTEX=1]="VERTEX",t[t.LINE=2]="LINE",t[t.TRIANGLE=3]="TRIANGLE",t[t.TETRAHEDRON=4]="TETRAHEDRON"}(Mtt||(Mtt={})),ge(Mtt),t("fL",Ltt),function(t){t[t.BOX=0]="BOX",t[t.SPHERE=1]="SPHERE",t[t.CAPSULE=2]="CAPSULE",t[t.CYLINDER=3]="CYLINDER",t[t.CONE=4]="CONE",t[t.MESH=5]="MESH",t[t.PLANE=6]="PLANE",t[t.SIMPLEX=7]="SIMPLEX",t[t.TERRAIN=8]="TERRAIN"}(Ltt||t("fL",Ltt={})),ge(Ltt),function(t){t[t.POINT_TO_POINT=0]="POINT_TO_POINT",t[t.HINGE=1]="HINGE",t[t.FIXED=2]="FIXED",t[t.CONFIGURABLE=3]="CONFIGURABLE"}(Ntt||(Ntt={})),ge(Ntt),function(t){t[t.FREE=0]="FREE",t[t.LIMITED=1]="LIMITED",t[t.LOCKED=2]="LOCKED"}(Ftt||(Ftt={})),ge(Ftt),function(t){t[t.DISABLED=0]="DISABLED",t[t.SERVO=1]="SERVO",t[t.INDUCTION=2]="INDUCTION"}(ktt||(ktt={})),ge(ktt),function(t){t[t.BOX=0]="BOX",t[t.CAPSULE=1]="CAPSULE"}(Vtt||(Vtt={})),ge(Vtt),function(t){t[t.DEFAULT=1]="DEFAULT"}(Gtt||(Gtt={})),ge(Gtt),t("fM",Utt),function(t){t[t.NONE=0]="NONE",t[t.WIRE_FRAME=1]="WIRE_FRAME",t[t.CONSTRAINT=2]="CONSTRAINT",t[t.AABB=4]="AABB"}(Utt||t("fM",Utt={})),ge(Utt);var Htt=function(t){if(1===t){for(var e=this,i=function(t){var i="_"+(1<<t);e[i]=0,e.updateArray=[],Object.defineProperty(e,1<<t,{get:function(){return this[i]},set:function(e){this[i]!==e&&(this[i]=e,this.updateArray.indexOf(t)<0&&this.updateArray.push(t))}})},n=0;n<32;n++)i(n);this._1=Gtt.DEFAULT}else{for(var r=0;r<32;r++)this[""+(1<<r)]=0;this[1]=Gtt.DEFAULT}},Wtt=null;v.internal.PhysicsGroup2D=G9;var jtt,Xtt,qtt,Ytt,Ktt,Jtt,Qtt,Ztt,$tt,tet,eet,iet,net,ret,set,oet,aet,het,uet,cet,_et,det,fet,pet,met,get=t("f4",function(t){function e(){var e,i,n,r,s;(s=t.call(this)||this).velocityIterations=10,s.positionIterations=10,s.collisionMatrix=new Htt,s._enable=!0,s._allowSleep=!0,s._maxSubSteps=1,s._fixedTimeStep=1/60,s._autoSimulation=!0,s._accumulator=0,s._steping=!1,s._gravity=new Ln(0,-10*X9),s._delayEvents=[];var o=Ee.querySettings(be.Category.PHYSICS,"gravity");o&&(Ln.copy(s._gravity,o),s._gravity.multiplyScalar(X9)),s._allowSleep=null!==(e=Ee.querySettings(be.Category.PHYSICS,"allowSleep"))&&void 0!==e?e:s._allowSleep,s._fixedTimeStep=null!==(i=Ee.querySettings(be.Category.PHYSICS,"fixedTimeStep"))&&void 0!==i?i:s._fixedTimeStep,s._maxSubSteps=null!==(n=Ee.querySettings(be.Category.PHYSICS,"maxSubSteps"))&&void 0!==n?n:s._maxSubSteps,s._autoSimulation=null!==(r=Ee.querySettings(be.Category.PHYSICS,"autoSimulation"))&&void 0!==r?r:s._autoSimulation;var a=Ee.querySettings(be.Category.PHYSICS,"collisionMatrix");if(a)for(var h in a){var u=parseInt(h),l=1<<parseInt(h);s.collisionMatrix[""+l]=a[u]}var c=Ee.querySettings(be.Category.PHYSICS,"collisionGroups");return c&&c instanceof Array&&(c.forEach((function(t){G9[t.name]=1<<t.index})),ge.update(G9)),q9.physicsWorld=K9(),s.gravity=s._gravity,s.allowSleep=s._allowSleep,s}s(e,t);var i=e.prototype;return i.postUpdate=function(t){if(this._enable&&this._autoSimulation){fN.emit(dN.EVENT_BEFORE_PHYSICS),this.physicsWorld.syncSceneToPhysics(),this._steping=!0;var e=this._fixedTimeStep,i=this.velocityIterations,n=this.positionIterations;this._accumulator+=t;for(var r=0;r++<this._maxSubSteps&&this._accumulator>e;)this.physicsWorld.step(e,i,n),this._accumulator-=e;for(var s=this._delayEvents,o=0,a=s.length;o<a;o++){var h=s[o];h.func.call(h.target)}s.length=0,this.physicsWorld.syncPhysicsToScene(),this.debugDrawFlags&&this.physicsWorld.drawDebug(),this._steping=!1,fN.emit(dN.EVENT_AFTER_PHYSICS)}},i._callAfterStep=function(t,e){this._steping?this._delayEvents.push({target:t,func:e}):e.call(t)},i.resetAccumulator=function(t){void 0===t&&(t=0),this._accumulator=t},i.step=function(t){this.physicsWorld.step(t,this.velocityIterations,this.positionIterations)},i.raycast=function(t,e,i,n){return void 0===i&&(i=U9.Closest),void 0===n&&(n=4294967295),this.physicsWorld.raycast(t,e,i,n)},i.testPoint=function(t){return this.physicsWorld.testPoint(t)},i.testAABB=function(t){return this.physicsWorld.testAABB(t)},e.constructAndRegister=function(){fN.registerSystem(e.ID,e.instance,Ou.Priority.LOW)},n(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this.physicsWorld.setAllowSleep(t)}},{key:"gravity",get:function(){return this._gravity},set:function(t){this._gravity.set(t),this.physicsWorld.setGravity(new Ln(t.x/X9,t.y/X9))}},{key:"maxSubSteps",get:function(){return this._maxSubSteps},set:function(t){this._maxSubSteps=t}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(t){this._fixedTimeStep=t}},{key:"autoSimulation",get:function(){return this._autoSimulation},set:function(t){this._autoSimulation=t}},{key:"debugDrawFlags",get:function(){return this.physicsWorld.debugDrawFlags},set:function(t){this.physicsWorld.debugDrawFlags=t}},{key:"physicsWorld",get:function(){return q9.physicsWorld}},{key:"stepping",get:function(){return this._steping}}],[{key:"PHYSICS_NONE",get:function(){return!q9.id}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===q9.id}},{key:"PHYSICS_BOX2D",get:function(){return"box2d"===q9.id}},{key:"PHYSICS_BOX2D_WASM",get:function(){return"box2d-wasm"===q9.id}},{key:"PhysicsGroup",get:function(){return G9}},{key:"instance",get:function(){return Wtt||(Wtt=new e),Wtt}}]),e}(Yu(Ou)));get.ID="PHYSICS_2D",fN.once(dN.EVENT_INIT,(function(){get.constructAndRegister()})),t("f5",jtt),function(t){t[t.Circles=0]="Circles",t[t.FaceA=1]="FaceA",t[t.FaceB=2]="FaceB"}(jtt||t("f5",jtt={}));var yet,vet,Tet,Aet,bet,Eet,Cet,wet,xet,Ret,Iet,Bet,Det,Pet,Oet,Met,Let,Net,Fet,ket,Vet,Get,Uet,zet,Het,Wet,jet,Xet,qet,Yet,Ket,Jet,Qet,Zet,$et,tit,eit,iit,nit,rit,sit,oit,ait,hit,uit,lit,cit,_it,dit,fit,pit,mit,git,yit,vit,Sit,Tit,Ait,bit,Eit,Cit,wit,xit,Rit,Iit,Bit,Dit,Pit,Oit,Mit,Lit,Nit,Fit,kit,Vit,Git,Uit,zit,Hit,Wit,jit,Xit,qit,Yit,Kit,Jit,Qit,Zit,$it,tnt,ent,int,nnt,rnt,snt,ont,ant,hnt,unt,lnt,cnt,_nt,dnt,fnt,pnt,mnt,gnt,ynt,vnt,Snt,Tnt,Ant,bnt,Ent,Cnt,wnt,xnt,Rnt,Int,Bnt,Dnt,Pnt,Ont,Mnt,Lnt,Nnt,Fnt,knt,Vnt,Gnt,Unt,znt,Hnt,Wnt,jnt,Xnt,qnt,Ynt,Knt,Jnt,Qnt=xo,Znt=t("f6",(Xtt=qs("cc.RigidBody2D"),qtt=Qnt(Gtt),Ytt=Qnt(F9),Ktt=Qnt(Ke),Jtt=Qnt(Ye),Qtt=Qnt(Ye),Ztt=Qnt(Ye),$tt=Qnt(Ln),tet=Qnt(Ye),eet=Qnt(Ke),Xtt((p((net=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).enabledContactListener=ret&&ret(),e.bullet=set&&set(),e.awakeOnLoad=oet&&oet(),e._body=null,e._group=aet&&aet(),e._type=het&&het(),e._allowSleep=uet&&uet(),e._gravityScale=cet&&cet(),e._linearDamping=_et&&_et(),e._angularDamping=det&&det(),e._linearVelocity=fet&&fet(),e._angularVelocity=pet&&pet(),e._fixedRotation=met&&met(),e}s(e,t);var i=e.prototype;return i.isAwake=function(){return!!this._body&&this._body.isAwake},i.wakeUp=function(){this._body&&this._body.wakeUp()},i.sleep=function(){this._body&&this._body.sleep()},i.getMass=function(){return this._body?this._body.getMass():0},i.applyForce=function(t,e,i){this._body&&this._body.applyForce(t,e,i)},i.applyForceToCenter=function(t,e){this._body&&this._body.applyForceToCenter(t,e)},i.applyTorque=function(t,e){this._body&&this._body.applyTorque(t,e)},i.applyLinearImpulse=function(t,e,i){this._body&&this._body.applyLinearImpulse(t,e,i)},i.applyLinearImpulseToCenter=function(t,e){this._body&&this._body.applyLinearImpulseToCenter(t,e)},i.applyAngularImpulse=function(t,e){this._body&&this._body.applyAngularImpulse(t,e)},i.getLinearVelocityFromWorldPoint=function(t,e){return this._body?this._body.getLinearVelocityFromWorldPoint(t,e):e},i.getLocalVector=function(t,e){return this._body?this._body.getLocalVector(t,e):e},i.getWorldVector=function(t,e){return this._body?this._body.getWorldVector(t,e):e},i.getLocalPoint=function(t,e){return this._body?this._body.getLocalPoint(t,e):e},i.getWorldPoint=function(t,e){return this._body?this._body.getWorldPoint(t,e):e},i.getLocalCenter=function(t){return this._body?this._body.getLocalCenter(t):t},i.getWorldCenter=function(t){return this._body?this._body.getWorldCenter(t):t},i.getInertia=function(){return this._body&&this._body.getInertia(),0},i.onLoad=function(){this._body="builtin"===q9.id?J9:new q9.wrapper.RigidBody,this._body.initialize(this)},i.onEnable=function(){this._body&&this._body.onEnable()},i.onDisable=function(){this._body&&this._body.onDisable()},i.onDestroy=function(){this._body&&this._body.onDestroy()},n(e,[{key:"group",get:function(){return this._group},set:function(t){this._group=t}},{key:"type",get:function(){return this._type},set:function(t){this._type=t,this._body&&(t===F9.Animated?this._body.setType(F9.Kinematic):this._body.setType(t))}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this._body&&this._body.setAllowSleep(t)}},{key:"gravityScale",get:function(){return this._gravityScale},set:function(t){this._gravityScale=t,this._body&&this._body.setGravityScale(t)}},{key:"linearDamping",get:function(){return this._linearDamping},set:function(t){this._linearDamping=t,this._body&&this._body.setLinearDamping(t)}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(t){this._angularDamping=t,this._body&&this._body.setAngularDamping(t)}},{key:"linearVelocity",get:function(){return this._body&&this._body.getLinearVelocity(this._linearVelocity),this._linearVelocity},set:function(t){this._linearVelocity=t,this._body&&this._body.setLinearVelocity(t)}},{key:"angularVelocity",get:function(){return this._body&&(this._angularVelocity=this._body.getAngularVelocity()),this._angularVelocity},set:function(t){this._angularVelocity=t,this._body&&this._body.setAngularVelocity(t)}},{key:"fixedRotation",get:function(){return this._fixedRotation},set:function(t){this._fixedRotation=t,this._body&&this._body.setFixedRotation(t)}},{key:"impl",get:function(){return this._body}}]),e}(rp)).prototype,"group",[qtt],Object.getOwnPropertyDescriptor(net.prototype,"group"),net.prototype),ret=ks(net.prototype,"enabledContactListener",[io],(function(){return!1})),set=ks(net.prototype,"bullet",[io],(function(){return!1})),p(net.prototype,"type",[Ytt],Object.getOwnPropertyDescriptor(net.prototype,"type"),net.prototype),p(net.prototype,"allowSleep",[Ktt],Object.getOwnPropertyDescriptor(net.prototype,"allowSleep"),net.prototype),p(net.prototype,"gravityScale",[Jtt],Object.getOwnPropertyDescriptor(net.prototype,"gravityScale"),net.prototype),p(net.prototype,"linearDamping",[Qtt],Object.getOwnPropertyDescriptor(net.prototype,"linearDamping"),net.prototype),p(net.prototype,"angularDamping",[Ztt],Object.getOwnPropertyDescriptor(net.prototype,"angularDamping"),net.prototype),p(net.prototype,"linearVelocity",[$tt],Object.getOwnPropertyDescriptor(net.prototype,"linearVelocity"),net.prototype),p(net.prototype,"angularVelocity",[tet],Object.getOwnPropertyDescriptor(net.prototype,"angularVelocity"),net.prototype),p(net.prototype,"fixedRotation",[eet],Object.getOwnPropertyDescriptor(net.prototype,"fixedRotation"),net.prototype),oet=ks(net.prototype,"awakeOnLoad",[io],(function(){return!0})),aet=ks(net.prototype,"_group",[io],(function(){return Gtt.DEFAULT})),het=ks(net.prototype,"_type",[io],(function(){return F9.Dynamic})),uet=ks(net.prototype,"_allowSleep",[io],(function(){return!0})),cet=ks(net.prototype,"_gravityScale",[io],(function(){return 1})),_et=ks(net.prototype,"_linearDamping",[io],(function(){return 0})),det=ks(net.prototype,"_angularDamping",[io],(function(){return 0})),fet=ks(net.prototype,"_linearVelocity",[io],(function(){return new Ln})),pet=ks(net.prototype,"_angularVelocity",[io],(function(){return 0})),met=ks(net.prototype,"_fixedRotation",[io],(function(){return!1})),iet=net))||iet)),$nt=xo,trt=t("f7",(yet=qs("cc.Collider2D"),vet=$nt(Ye),Tet=$nt(Gtt),Aet=$nt(Ye),bet=$nt(Ke),Eet=$nt(Ye),Cet=$nt(Ye),wet=$nt(Ln),yet((Ret=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).editing=!1,e.tag=Iet&&Iet(),e.TYPE=k9.None,e._shape=null,e._body=null,e._group=Bet&&Bet(),e._density=Det&&Det(),e._sensor=Pet&&Pet(),e._friction=Oet&&Oet(),e._restitution=Met&&Met(),e._offset=Let&&Let(),e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._shape=function(t){return Q9.INITED||(Q9.INITED=!0,Q9[k9.BOX]=function(){return new q9.wrapper.BoxShape},Q9[k9.CIRCLE]=function(){return new q9.wrapper.CircleShape},Q9[k9.POLYGON]=function(){return new q9.wrapper.PolygonShape}),Q9[t]()}(this.TYPE),this._shape.initialize(this),this._shape.onLoad&&this._shape.onLoad(),this._body=this.getComponent(Znt)},i.onEnable=function(){this._shape&&this._shape.onEnable()},i.onDisable=function(){this._shape&&this._shape.onDisable&&this._shape.onDisable()},i.onDestroy=function(){this._shape&&this._shape.onDestroy&&this._shape.onDestroy()},i.apply=function(){this._shape&&this._shape.apply&&this._shape.apply()},n(e,[{key:"group",get:function(){return this._group},set:function(t){this._group=t,this._shape&&this._shape.onGroupChanged&&this._shape.onGroupChanged()}},{key:"density",get:function(){return this._density},set:function(t){this._density=t}},{key:"sensor",get:function(){return this._sensor},set:function(t){this._sensor=t}},{key:"friction",get:function(){return this._friction},set:function(t){this._friction=t}},{key:"restitution",get:function(){return this._restitution},set:function(t){this._restitution=t}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset=t}},{key:"body",get:function(){return this._body}},{key:"impl",get:function(){return this._shape}},{key:"worldAABB",get:function(){return this._shape?this._shape.worldAABB:new Un}}]),e}(Yu(rp)),Iet=ks(Ret.prototype,"tag",[vet,io],(function(){return 0})),p(Ret.prototype,"group",[Tet],Object.getOwnPropertyDescriptor(Ret.prototype,"group"),Ret.prototype),p(Ret.prototype,"density",[Aet],Object.getOwnPropertyDescriptor(Ret.prototype,"density"),Ret.prototype),p(Ret.prototype,"sensor",[bet],Object.getOwnPropertyDescriptor(Ret.prototype,"sensor"),Ret.prototype),p(Ret.prototype,"friction",[Eet],Object.getOwnPropertyDescriptor(Ret.prototype,"friction"),Ret.prototype),p(Ret.prototype,"restitution",[Cet],Object.getOwnPropertyDescriptor(Ret.prototype,"restitution"),Ret.prototype),p(Ret.prototype,"offset",[wet],Object.getOwnPropertyDescriptor(Ret.prototype,"offset"),Ret.prototype),Bet=ks(Ret.prototype,"_group",[io],(function(){return Gtt.DEFAULT})),Det=ks(Ret.prototype,"_density",[io],(function(){return 1})),Pet=ks(Ret.prototype,"_sensor",[io],(function(){return!1})),Oet=ks(Ret.prototype,"_friction",[io],(function(){return.2})),Met=ks(Ret.prototype,"_restitution",[io],(function(){return 0})),Let=ks(Ret.prototype,"_offset",[io],(function(){return new Ln})),xet=Ret))||xet)),ert=(t("f8",(Net=qs("cc.BoxCollider2D"),Fet=xo(Vn),Net((Vet=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._size=Get&&Get(),e.TYPE=k9.BOX,e}return s(e,t),n(e,[{key:"size",get:function(){return this._size},set:function(t){this._size=t}},{key:"worldPoints",get:function(){return this._shape?this._shape.worldPoints:[]}}]),e}(trt),Get=ks(Vet.prototype,"_size",[io],(function(){return new Vn(1,1)})),p(Vet.prototype,"size",[Fet],Object.getOwnPropertyDescriptor(Vet.prototype,"size"),Vet.prototype),ket=Vet))||ket)),t("f9",(Uet=qs("cc.CircleCollider2D"),zet=xo(Ye),Uet((Wet=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._radius=jet&&jet(),e.TYPE=k9.CIRCLE,e}return s(e,t),n(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius=t<0?0:t}},{key:"worldPosition",get:function(){return this._shape?this._shape.worldPosition:new Ln}},{key:"worldRadius",get:function(){return this._shape?this._shape.worldRadius:0}}]),e}(trt),jet=ks(Wet.prototype,"_radius",[io],(function(){return 1})),p(Wet.prototype,"radius",[zet],Object.getOwnPropertyDescriptor(Wet.prototype,"radius"),Wet.prototype),Het=Wet))||Het)),t("fa",(Xet=qs("cc.PolygonCollider2D"),qet=xo(Ye),Yet=xo([Ln]),Xet((Jet=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).threshold=Qet&&Qet(),e._points=Zet&&Zet(),e.TYPE=k9.POLYGON,e}return s(e,t),n(e,[{key:"points",get:function(){return this._points},set:function(t){this._points=t}},{key:"worldPoints",get:function(){return this._shape?this._shape.worldPoints:[]}}]),e}(trt),Qet=ks(Jet.prototype,"threshold",[qet],(function(){return 1})),Zet=ks(Jet.prototype,"_points",[io],(function(){return[new Ln(-1,-1),new Ln(1,-1),new Ln(1,1),new Ln(-1,1)]})),p(Jet.prototype,"points",[Yet],Object.getOwnPropertyDescriptor(Jet.prototype,"points"),Jet.prototype),Ket=Jet))||Ket)),xo),irt=t("fb",($et=qs("cc.Joint2D"),tit=ert(Znt),$et((iit=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).anchor=nit&&nit(),e.connectedAnchor=rit&&rit(),e.collideConnected=sit&&sit(),e.connectedBody=oit&&oit(),e._body=null,e._joint=null,e.TYPE=V9.None,e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._joint=function(t){return function(){if(!Z9.INITED){Z9.INITED=!0;var t="builtin"===q9.id;Z9[V9.SPRING]=function(){return t?$9:new q9.wrapper.SpringJoint},Z9[V9.DISTANCE]=function(){return t?$9:new q9.wrapper.DistanceJoint},Z9[V9.FIXED]=function(){return t?$9:new q9.wrapper.FixedJoint},Z9[V9.MOUSE]=function(){return t?$9:new q9.wrapper.MouseJoint},Z9[V9.RELATIVE]=function(){return t?$9:new q9.wrapper.RelativeJoint},Z9[V9.SLIDER]=function(){return t?$9:new q9.wrapper.SliderJoint},Z9[V9.WHEEL]=function(){return t?$9:new q9.wrapper.WheelJoint},Z9[V9.HINGE]=function(){return t?$9:new q9.wrapper.HingeJoint}}}(),Z9[t]()}(this.TYPE),this._joint.initialize(this),this._body=this.getComponent(Znt)},i.onEnable=function(){this._joint&&this._joint.onEnable&&this._joint.onEnable()},i.onDisable=function(){this._joint&&this._joint.onDisable&&this._joint.onDisable()},i.start=function(){this._joint&&this._joint.start&&this._joint.start()},i.onDestroy=function(){this._joint&&this._joint.onDestroy&&this._joint.onDestroy()},i.apply=function(){this._joint&&this._joint.apply&&this._joint.apply()},n(e,[{key:"body",get:function(){return this._body}},{key:"impl",get:function(){return this._joint}}]),e}(rp),nit=ks(iit.prototype,"anchor",[io],(function(){return new Ln})),rit=ks(iit.prototype,"connectedAnchor",[io],(function(){return new Ln})),sit=ks(iit.prototype,"collideConnected",[io],(function(){return!1})),oit=ks(iit.prototype,"connectedBody",[tit,io],(function(){return null})),eit=iit))||eit)),nrt=(t("fc",(ait=qs("cc.DistanceJoint2D"),hit=xo(Ye),uit=xo(Ke),ait((p((cit=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=V9.DISTANCE,e._maxLength=_it&&_it(),e._autoCalcDistance=dit&&dit(),e}return s(e,t),n(e,[{key:"maxLength",get:function(){return this._autoCalcDistance?this.connectedBody?on.distance(this.node.worldPosition,this.connectedBody.node.worldPosition):on.len(this.node.worldPosition):this._maxLength},set:function(t){this._maxLength=t,this._joint&&this._joint.setMaxLength(t)}},{key:"autoCalcDistance",get:function(){return this._autoCalcDistance},set:function(t){this._autoCalcDistance=t}}]),e}(irt)).prototype,"maxLength",[hit],Object.getOwnPropertyDescriptor(cit.prototype,"maxLength"),cit.prototype),p(cit.prototype,"autoCalcDistance",[uit],Object.getOwnPropertyDescriptor(cit.prototype,"autoCalcDistance"),cit.prototype),_it=ks(cit.prototype,"_maxLength",[io],(function(){return 5})),dit=ks(cit.prototype,"_autoCalcDistance",[io],(function(){return!0})),lit=cit))||lit)),t("fd",(fit=qs("cc.SpringJoint2D"),pit=xo(Ye),mit=xo(Ye),git=xo(Ye),yit=xo(Ke),fit((p((Sit=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=V9.SPRING,e._frequency=Tit&&Tit(),e._dampingRatio=Ait&&Ait(),e._distance=bit&&bit(),e._autoCalcDistance=Eit&&Eit(),e}return s(e,t),n(e,[{key:"frequency",get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.setFrequency(t)}},{key:"dampingRatio",get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.setDampingRatio(t)}},{key:"distance",get:function(){return this._autoCalcDistance?this.connectedBody?on.distance(this.node.worldPosition,this.connectedBody.node.worldPosition):on.len(this.node.worldPosition):this._distance},set:function(t){this._distance=t,this._joint&&this._joint.setDistance(t)}},{key:"autoCalcDistance",get:function(){return this._autoCalcDistance},set:function(t){this._autoCalcDistance=t}}]),e}(irt)).prototype,"frequency",[pit],Object.getOwnPropertyDescriptor(Sit.prototype,"frequency"),Sit.prototype),p(Sit.prototype,"dampingRatio",[mit],Object.getOwnPropertyDescriptor(Sit.prototype,"dampingRatio"),Sit.prototype),p(Sit.prototype,"distance",[git],Object.getOwnPropertyDescriptor(Sit.prototype,"distance"),Sit.prototype),p(Sit.prototype,"autoCalcDistance",[yit],Object.getOwnPropertyDescriptor(Sit.prototype,"autoCalcDistance"),Sit.prototype),Tit=ks(Sit.prototype,"_frequency",[io],(function(){return 5})),Ait=ks(Sit.prototype,"_dampingRatio",[io],(function(){return.7})),bit=ks(Sit.prototype,"_distance",[io],(function(){return 10})),Eit=ks(Sit.prototype,"_autoCalcDistance",[io],(function(){return!0})),vit=Sit))||vit)),t("fe",(Cit=qs("cc.MouseJoint2D"),wit=xo(Ye),xit=xo(Ye),Rit=xo(Ye),Cit((p((Bit=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=V9.MOUSE,e._maxForce=Dit&&Dit(),e._dampingRatio=Pit&&Pit(),e._frequency=Oit&&Oit(),e._target=new Ln,e}return s(e,t),e.prototype.update=function(t){this._joint.update(t)},n(e,[{key:"target",get:function(){return this._target},set:function(t){this._target=t,this._joint&&this._joint.setTarget(t)}},{key:"frequency",get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.setFrequency(t)}},{key:"dampingRatio",get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.setDampingRatio(t)}},{key:"maxForce",get:function(){return this._maxForce},set:function(t){this._maxForce=t,this._joint&&this._joint.setMaxForce(t)}}]),e}(irt)).prototype,"frequency",[wit],Object.getOwnPropertyDescriptor(Bit.prototype,"frequency"),Bit.prototype),p(Bit.prototype,"dampingRatio",[xit],Object.getOwnPropertyDescriptor(Bit.prototype,"dampingRatio"),Bit.prototype),p(Bit.prototype,"maxForce",[Rit],Object.getOwnPropertyDescriptor(Bit.prototype,"maxForce"),Bit.prototype),Dit=ks(Bit.prototype,"_maxForce",[io],(function(){return 1e3})),Pit=ks(Bit.prototype,"_dampingRatio",[io],(function(){return.7})),Oit=ks(Bit.prototype,"_frequency",[io],(function(){return 5})),Iit=Bit))||Iit)),new on),rrt=new on,srt=(t("ff",(Mit=qs("cc.RelativeJoint2D"),Lit=xo(Ye),Nit=xo(Ye),Fit=xo(Ye),kit=xo(Ln),Vit=xo(Ye),Git=xo(Ke),Mit((p((zit=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=V9.RELATIVE,e._maxForce=Hit&&Hit(),e._maxTorque=Wit&&Wit(),e._correctionFactor=jit&&jit(),e._angularOffset=Xit&&Xit(),e._linearOffset=qit&&qit(),e._autoCalcOffset=Yit&&Yit(),e}return s(e,t),n(e,[{key:"maxForce",get:function(){return this._maxForce},set:function(t){this._maxForce=t,this._joint&&this._joint.setMaxForce(t)}},{key:"maxTorque",get:function(){return this._maxTorque},set:function(t){this._maxTorque=t,this._joint&&this._joint.setMaxTorque(t)}},{key:"correctionFactor",get:function(){return this._correctionFactor},set:function(t){this._correctionFactor=t,this._joint&&this._joint.setCorrectionFactor(t)}},{key:"linearOffset",get:function(){return this._autoCalcOffset?this.connectedBody?Ln.subtract(this._linearOffset,this.connectedBody.node.worldPosition,this.node.worldPosition):Ln.subtract(this._linearOffset,new Ln(0,0),this.node.worldPosition):this._linearOffset},set:function(t){this._linearOffset.set(t),this._joint&&this._joint.setLinearOffset(t)}},{key:"angularOffset",get:function(){return this._autoCalcOffset&&(Sn.toEuler(nrt,this.node.worldRotation),this.connectedBody?Sn.toEuler(rrt,this.connectedBody.node.worldRotation):Sn.toEuler(rrt,new Sn),this._angularOffset=rrt.z-nrt.z),this._angularOffset},set:function(t){this._angularOffset=t,this._joint&&this._joint.setAngularOffset(t)}},{key:"autoCalcOffset",get:function(){return this._autoCalcOffset},set:function(t){this._autoCalcOffset=t}}]),e}(irt)).prototype,"maxForce",[Lit],Object.getOwnPropertyDescriptor(zit.prototype,"maxForce"),zit.prototype),p(zit.prototype,"maxTorque",[Nit],Object.getOwnPropertyDescriptor(zit.prototype,"maxTorque"),zit.prototype),p(zit.prototype,"correctionFactor",[Fit],Object.getOwnPropertyDescriptor(zit.prototype,"correctionFactor"),zit.prototype),p(zit.prototype,"linearOffset",[kit],Object.getOwnPropertyDescriptor(zit.prototype,"linearOffset"),zit.prototype),p(zit.prototype,"angularOffset",[Vit],Object.getOwnPropertyDescriptor(zit.prototype,"angularOffset"),zit.prototype),p(zit.prototype,"autoCalcOffset",[Git],Object.getOwnPropertyDescriptor(zit.prototype,"autoCalcOffset"),zit.prototype),Hit=ks(zit.prototype,"_maxForce",[io],(function(){return 5})),Wit=ks(zit.prototype,"_maxTorque",[io],(function(){return.7})),jit=ks(zit.prototype,"_correctionFactor",[io],(function(){return.3})),Xit=ks(zit.prototype,"_angularOffset",[io],(function(){return 0})),qit=ks(zit.prototype,"_linearOffset",[io],(function(){return new Ln})),Yit=ks(zit.prototype,"_autoCalcOffset",[io],(function(){return!0})),Uit=zit))||Uit)),new Ln);t("fg",(Kit=qs("cc.SliderJoint2D"),Jit=xo(Ye),Qit=xo(Ke),Zit=xo(Ke),$it=xo(Ye),tnt=xo(Ye),ent=xo(Ke),int=xo(Ye),nnt=xo(Ye),Kit((p((snt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=V9.SLIDER,e._angle=ont&&ont(),e._autoCalcAngle=ant&&ant(),e._enableMotor=hnt&&hnt(),e._maxMotorForce=unt&&unt(),e._motorSpeed=lnt&&lnt(),e._enableLimit=cnt&&cnt(),e._lowerLimit=_nt&&_nt(),e._upperLimit=dnt&&dnt(),e}return s(e,t),n(e,[{key:"angle",get:function(){return this._autoCalcAngle&&(this.connectedBody?Ln.subtract(srt,this.connectedBody.node.worldPosition,this.node.worldPosition):Ln.subtract(srt,new Ln(0,0),this.node.worldPosition),this._angle=Di(Math.atan2(srt.y,srt.x))),this._angle},set:function(t){this._angle=t}},{key:"autoCalcAngle",get:function(){return this._autoCalcAngle},set:function(t){this._autoCalcAngle=t}},{key:"enableMotor",get:function(){return this._enableMotor},set:function(t){this._enableMotor=t}},{key:"maxMotorForce",get:function(){return this._maxMotorForce},set:function(t){this._maxMotorForce=t,this._joint&&this._joint.setMaxMotorForce(t)}},{key:"motorSpeed",get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.setMotorSpeed(t)}},{key:"enableLimit",get:function(){return this._enableLimit},set:function(t){this._enableLimit=t}},{key:"lowerLimit",get:function(){return this._lowerLimit},set:function(t){this._lowerLimit=t,this._joint&&this._joint.setLowerLimit(t)}},{key:"upperLimit",get:function(){return this._upperLimit},set:function(t){this._upperLimit=t,this._joint&&this._joint.setUpperLimit(t)}}]),e}(irt)).prototype,"angle",[Jit],Object.getOwnPropertyDescriptor(snt.prototype,"angle"),snt.prototype),p(snt.prototype,"autoCalcAngle",[Qit],Object.getOwnPropertyDescriptor(snt.prototype,"autoCalcAngle"),snt.prototype),p(snt.prototype,"enableMotor",[Zit],Object.getOwnPropertyDescriptor(snt.prototype,"enableMotor"),snt.prototype),p(snt.prototype,"maxMotorForce",[$it],Object.getOwnPropertyDescriptor(snt.prototype,"maxMotorForce"),snt.prototype),p(snt.prototype,"motorSpeed",[tnt],Object.getOwnPropertyDescriptor(snt.prototype,"motorSpeed"),snt.prototype),p(snt.prototype,"enableLimit",[ent],Object.getOwnPropertyDescriptor(snt.prototype,"enableLimit"),snt.prototype),p(snt.prototype,"lowerLimit",[int],Object.getOwnPropertyDescriptor(snt.prototype,"lowerLimit"),snt.prototype),p(snt.prototype,"upperLimit",[nnt],Object.getOwnPropertyDescriptor(snt.prototype,"upperLimit"),snt.prototype),ont=ks(snt.prototype,"_angle",[io],(function(){return 0})),ant=ks(snt.prototype,"_autoCalcAngle",[io],(function(){return!0})),hnt=ks(snt.prototype,"_enableMotor",[io],(function(){return!1})),unt=ks(snt.prototype,"_maxMotorForce",[io],(function(){return 1e3})),lnt=ks(snt.prototype,"_motorSpeed",[io],(function(){return 1e3})),cnt=ks(snt.prototype,"_enableLimit",[io],(function(){return!1})),_nt=ks(snt.prototype,"_lowerLimit",[io],(function(){return 0})),dnt=ks(snt.prototype,"_upperLimit",[io],(function(){return 0})),rnt=snt))||rnt)),t("fh",(fnt=qs("cc.FixedJoint2D"),pnt=xo(Ye),mnt=xo(Ye),fnt((p((ynt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=V9.FIXED,e._frequency=vnt&&vnt(),e._dampingRatio=Snt&&Snt(),e}return s(e,t),n(e,[{key:"frequency",get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.setFrequency(t)}},{key:"dampingRatio",get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.setDampingRatio(t)}}]),e}(irt)).prototype,"frequency",[pnt],Object.getOwnPropertyDescriptor(ynt.prototype,"frequency"),ynt.prototype),p(ynt.prototype,"dampingRatio",[mnt],Object.getOwnPropertyDescriptor(ynt.prototype,"dampingRatio"),ynt.prototype),vnt=ks(ynt.prototype,"_frequency",[io],(function(){return.7})),Snt=ks(ynt.prototype,"_dampingRatio",[io],(function(){return.5})),gnt=ynt))||gnt)),t("fi",(Tnt=qs("cc.WheelJoint2D"),Ant=xo(Ye),bnt=xo(Ke),Ent=xo(Ye),Cnt=xo(Ye),wnt=xo(Ye),xnt=xo(Ye),Tnt((p((Int=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=V9.WHEEL,e._angle=Bnt&&Bnt(),e._enableMotor=Dnt&&Dnt(),e._maxMotorTorque=Pnt&&Pnt(),e._motorSpeed=Ont&&Ont(),e._frequency=Mnt&&Mnt(),e._dampingRatio=Lnt&&Lnt(),e}return s(e,t),n(e,[{key:"angle",get:function(){return this._angle},set:function(t){this._angle=t}},{key:"enableMotor",get:function(){return this._enableMotor},set:function(t){this._enableMotor=t,this._joint&&this._joint.enableMotor(t)}},{key:"maxMotorTorque",get:function(){return this._maxMotorTorque},set:function(t){this._maxMotorTorque=t,this._joint&&this._joint.setMaxMotorTorque(t)}},{key:"motorSpeed",get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.setMotorSpeed(t)}},{key:"frequency",get:function(){return this._frequency},set:function(t){this._frequency=t,this._joint&&this._joint.setFrequency(t)}},{key:"dampingRatio",get:function(){return this._dampingRatio},set:function(t){this._dampingRatio=t,this._joint&&this._joint.setDampingRatio(t)}}]),e}(irt)).prototype,"angle",[Ant],Object.getOwnPropertyDescriptor(Int.prototype,"angle"),Int.prototype),p(Int.prototype,"enableMotor",[bnt],Object.getOwnPropertyDescriptor(Int.prototype,"enableMotor"),Int.prototype),p(Int.prototype,"maxMotorTorque",[Ent],Object.getOwnPropertyDescriptor(Int.prototype,"maxMotorTorque"),Int.prototype),p(Int.prototype,"motorSpeed",[Cnt],Object.getOwnPropertyDescriptor(Int.prototype,"motorSpeed"),Int.prototype),p(Int.prototype,"frequency",[wnt],Object.getOwnPropertyDescriptor(Int.prototype,"frequency"),Int.prototype),p(Int.prototype,"dampingRatio",[xnt],Object.getOwnPropertyDescriptor(Int.prototype,"dampingRatio"),Int.prototype),Bnt=ks(Int.prototype,"_angle",[io],(function(){return 90})),Dnt=ks(Int.prototype,"_enableMotor",[io],(function(){return!1})),Pnt=ks(Int.prototype,"_maxMotorTorque",[io],(function(){return 1e3})),Ont=ks(Int.prototype,"_motorSpeed",[io],(function(){return 0})),Mnt=ks(Int.prototype,"_frequency",[io],(function(){return 5})),Lnt=ks(Int.prototype,"_dampingRatio",[io],(function(){return.7})),Rnt=Int))||Rnt)),t("fj",(Nnt=qs("cc.HingeJoint2D"),Fnt=xo(Ke),knt=xo(Ye),Vnt=xo(Ye),Gnt=xo(Ke),Unt=xo(Ye),znt=xo(Ye),Nnt((p((Wnt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).TYPE=V9.HINGE,e._enableLimit=jnt&&jnt(),e._lowerAngle=Xnt&&Xnt(),e._upperAngle=qnt&&qnt(),e._enableMotor=Ynt&&Ynt(),e._maxMotorTorque=Knt&&Knt(),e._motorSpeed=Jnt&&Jnt(),e}return s(e,t),n(e,[{key:"enableLimit",get:function(){return this._enableLimit},set:function(t){this._enableLimit=t}},{key:"lowerAngle",get:function(){return this._lowerAngle},set:function(t){this._lowerAngle=t,this._joint&&this._joint.setLowerAngle(t)}},{key:"upperAngle",get:function(){return this._upperAngle},set:function(t){this._upperAngle=t,this._joint&&this._joint.setUpperAngle(t)}},{key:"enableMotor",get:function(){return this._enableMotor},set:function(t){this._enableMotor=t,this._joint&&this._joint.enableMotor(t)}},{key:"maxMotorTorque",get:function(){return this._maxMotorTorque},set:function(t){this._maxMotorTorque=t,this._joint&&this._joint.setMaxMotorTorque(t)}},{key:"motorSpeed",get:function(){return this._motorSpeed},set:function(t){this._motorSpeed=t,this._joint&&this._joint.setMotorSpeed(t)}}]),e}(irt)).prototype,"enableLimit",[Fnt],Object.getOwnPropertyDescriptor(Wnt.prototype,"enableLimit"),Wnt.prototype),p(Wnt.prototype,"lowerAngle",[knt],Object.getOwnPropertyDescriptor(Wnt.prototype,"lowerAngle"),Wnt.prototype),p(Wnt.prototype,"upperAngle",[Vnt],Object.getOwnPropertyDescriptor(Wnt.prototype,"upperAngle"),Wnt.prototype),p(Wnt.prototype,"enableMotor",[Gnt],Object.getOwnPropertyDescriptor(Wnt.prototype,"enableMotor"),Wnt.prototype),p(Wnt.prototype,"maxMotorTorque",[Unt],Object.getOwnPropertyDescriptor(Wnt.prototype,"maxMotorTorque"),Wnt.prototype),p(Wnt.prototype,"motorSpeed",[znt],Object.getOwnPropertyDescriptor(Wnt.prototype,"motorSpeed"),Wnt.prototype),jnt=ks(Wnt.prototype,"_enableLimit",[io],(function(){return!1})),Xnt=ks(Wnt.prototype,"_lowerAngle",[io],(function(){return 0})),qnt=ks(Wnt.prototype,"_upperAngle",[io],(function(){return 0})),Ynt=ks(Wnt.prototype,"_enableMotor",[io],(function(){return!1})),Knt=ks(Wnt.prototype,"_maxMotorTorque",[io],(function(){return 1e3})),Jnt=ks(Wnt.prototype,"_motorSpeed",[io],(function(){return 0})),Hnt=Wnt))||Hnt)),t("eW",{PolygonSeparator:Att,PolygonPartition:ztt}),v.internal.physics2d={selector:q9};var ort=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._type=U9.Closest,e._fixtures=[],e._points=[],e._normals=[],e._fractions=[],e._mask=4294967295,e}s(e,t);var i=e.prototype;return i.init=function(t,e){this._type=t,this._mask=e,this._fixtures.length=0,this._points.length=0,this._normals.length=0,this._fractions.length=0},i.ReportFixture=function(t,e,i,n){return 0==(t.GetFilterData().categoryBits&this._mask)?0:this._type===U9.Closest?(this._fixtures[0]=t,this._points[0]=e,this._normals[0]=i,this._fractions[0]=n,n):(this._fixtures.push(t),this._points.push(new Ln(e.x,e.y)),this._normals.push(new Ln(i.x,i.y)),this._fractions.push(n),this._type===U9.Any?0:this._type>=U9.All?1:n)},i.getFixtures=function(){return this._fixtures},i.getPoints=function(){return this._points},i.getNormals=function(){return this._normals},i.getFractions=function(){return this._fractions},e}(stt.RayCastCallback),art=[],hrt=[new Ln,new Ln],urt=new stt.WorldManifold,lrt={points:[],separations:[],normal:new Ln},crt=function(){this.localPoint=new Ln,this.normalImpulse=0,this.tangentImpulse=0},_rt=[new crt,new crt],drt={type:0,localPoint:new Ln,localNormal:new Ln,points:[]},frt={normalImpulses:[],tangentImpulses:[]},prt=function(){function t(){this.colliderA=null,this.colliderB=null,this.disabled=!1,this.disabledOnce=!1,this._impulse=null,this._inverted=!1,this._b2contact=null}t.get=function(e){var i=art.pop();return i||(i=new t),i.init(e),i},t.put=function(t){var e=t.m_userData;e&&(art.push(e),e.reset())};var e=t.prototype;return e._setImpulse=function(t){this._impulse=t},e.init=function(t){this.colliderA=t.m_fixtureA.m_userData.collider,this.colliderB=t.m_fixtureB.m_userData.collider,this.disabled=!1,this.disabledOnce=!1,this._impulse=null,this._inverted=!1,this._b2contact=t,t.m_userData=this},e.reset=function(){this.setTangentSpeed(0),this.resetFriction(),this.resetRestitution(),this.colliderA=null,this.colliderB=null,this.disabled=!1,this._impulse=null,this._b2contact.m_userData=null,this._b2contact=null},e.getWorldManifold=function(){var t=lrt.points,e=lrt.separations,i=lrt.normal;this._b2contact.GetWorldManifold(urt);var n=urt.points,r=urt.separations,s=this._b2contact.GetManifold().pointCount;t.length=e.length=s;for(var o=0;o<s;o++){var a=hrt[o];a.x=n[o].x*X9,a.y=n[o].y*X9,t[o]=a,e[o]=r[o]*X9}return i.x=urt.normal.x,i.y=urt.normal.y,this._inverted&&(i.x*=-1,i.y*=-1),lrt},e.getManifold=function(){for(var t=drt.points,e=drt.localNormal,i=drt.localPoint,n=this._b2contact.GetManifold(),r=n.points,s=t.length=n.pointCount,o=0;o<s;o++){var a=_rt[o],h=r[o];a.localPoint.x=h.localPoint.x*X9,a.localPoint.y=h.localPoint.y*X9,a.normalImpulse=h.normalImpulse*X9,a.tangentImpulse=h.tangentImpulse,t[o]=a}return i.x=n.localPoint.x*X9,i.y=n.localPoint.y*X9,e.x=n.localNormal.x,e.y=n.localNormal.y,drt.type=n.type,this._inverted&&(e.x*=-1,e.y*=-1),drt},e.getImpulse=function(){var t=this._impulse;if(!t)return null;for(var e=frt.normalImpulses,i=frt.tangentImpulses,n=t.count,r=0;r<n;r++)e[r]=t.normalImpulses[r]*X9,i[r]=t.tangentImpulses[r];return i.length=e.length=n,frt},e.emit=function(t){switch(t){case j9.BEGIN_CONTACT:case j9.END_CONTACT:case j9.PRE_SOLVE:case j9.POST_SOLVE:}var e=this.colliderA,i=this.colliderB,n=e.body,r=i.body;n.enabledContactListener&&(null==e||e.emit(t,e,i,this)),r.enabledContactListener&&(null==i||i.emit(t,i,e,this)),(n.enabledContactListener||r.enabledContactListener)&&get.instance.emit(t,e,i,this),(this.disabled||this.disabledOnce)&&(this.setEnabled(!1),this.disabledOnce=!1)},e.setEnabled=function(t){this._b2contact.SetEnabled(t)},e.isTouching=function(){return this._b2contact.IsTouching()},e.setTangentSpeed=function(t){this._b2contact.SetTangentSpeed(t)},e.getTangentSpeed=function(){return this._b2contact.GetTangentSpeed()},e.setFriction=function(t){this._b2contact.SetFriction(t)},e.getFriction=function(){return this._b2contact.GetFriction()},e.resetFriction=function(){return this._b2contact.ResetFriction()},e.setRestitution=function(t){this._b2contact.SetRestitution(t)},e.getRestitution=function(){return this._b2contact.GetRestitution()},e.resetRestitution=function(){return this._b2contact.ResetRestitution()},t}(),mrt=new stt.Vec2,grt=new dn,yrt=dn.GREEN,vrt=dn.RED,Srt=function(t){function e(e){var i;return(i=t.call(this)||this)._drawer=null,i._xf=new stt.Transform,i._dxf=new stt.Transform,i._drawer=e,i}s(e,t);var i=e.prototype;return i._DrawPolygon=function(t,e){for(var i=this._drawer,n=0;n<e;n++){stt.Transform.MulXV(this._xf,t[n],mrt);var r=mrt.x*X9,s=mrt.y*X9;0===n?i.moveTo(r,s):i.lineTo(r,s)}i.close()},i.DrawPolygon=function(t,e,i){this._applyStrokeColor(i),this._DrawPolygon(t,e),this._drawer.stroke()},i.DrawSolidPolygon=function(t,e,i){this._applyFillColor(i),this._DrawPolygon(t,e),this._drawer.fill(),this._drawer.stroke()},i._DrawCircle=function(t,e){stt.Transform.MulXV(this._xf,t,mrt),this._drawer.circle(mrt.x*X9,mrt.y*X9,e*X9)},i.DrawCircle=function(t,e,i){this._applyStrokeColor(i),this._DrawCircle(t,e),this._drawer.stroke()},i.DrawSolidCircle=function(t,e,i,n){this._applyFillColor(n),this._DrawCircle(t,e),this._drawer.fill()},i.DrawSegment=function(t,e,i){var n=this._drawer;if(t.x===e.x&&t.y===e.y)return this._applyFillColor(i),this._DrawCircle(t,2/X9),void n.fill();this._applyStrokeColor(i),stt.Transform.MulXV(this._xf,t,mrt),n.moveTo(mrt.x*X9,mrt.y*X9),stt.Transform.MulXV(this._xf,e,mrt),n.lineTo(mrt.x*X9,mrt.y*X9),n.stroke()},i.DrawTransform=function(t){var e=this._drawer;e.strokeColor=vrt,mrt.x=mrt.y=0,stt.Transform.MulXV(t,mrt,mrt),e.moveTo(mrt.x*X9,mrt.y*X9),mrt.x=1,mrt.y=0,stt.Transform.MulXV(t,mrt,mrt),e.lineTo(mrt.x*X9,mrt.y*X9),e.stroke(),e.strokeColor=yrt,mrt.x=mrt.y=0,stt.Transform.MulXV(t,mrt,mrt),e.moveTo(mrt.x*X9,mrt.y*X9),mrt.x=0,mrt.y=1,stt.Transform.MulXV(t,mrt,mrt),e.lineTo(mrt.x*X9,mrt.y*X9),e.stroke()},i.DrawPoint=function(){},i.DrawParticles=function(){},i._applyStrokeColor=function(t){this._drawer.strokeColor=grt.set(255*t.r,255*t.g,255*t.b,150)},i._applyFillColor=function(t){this._drawer.fillColor=grt.set(255*t.r,255*t.g,255*t.b,150)},i.PushTransform=function(t){this._xf=t},i.PopTransform=function(){this._xf=this._dxf},e}(stt.Draw),Trt=new on,Art=new Ln,brt=new Ln,Ert=new stt.BodyDef,Crt=new stt.AABB,wrt=[],xrt=function(){function t(){this._world=void 0,this._bodies=[],this._animatedBodies=[],this._rotationAxis=new on,this._physicsGroundBody=void 0,this._contactListener=void 0,this._aabbQueryCallback=void 0,this._raycastQueryCallback=void 0,this._debugGraphics=null,this._b2DebugDrawer=null,this._debugDrawFlags=0,this._world=new stt.World(new stt.Vec2(0,-10));var t=new stt.BodyDef;this._physicsGroundBody=this._world.CreateBody(t);var e=new ott;e.setBeginContact(this._onBeginContact),e.setEndContact(this._onEndContact),e.setPreSolve(this._onPreSolve),e.setPostSolve(this._onPostSolve),this._world.SetContactListener(e),this._contactListener=e,this._aabbQueryCallback=new att,this._raycastQueryCallback=new ort}var e=t.prototype;return e._checkDebugDrawValid=function(){if(!this._debugGraphics||!this._debugGraphics.isValid){var t=aL("Canvas");if(!t){var e=fN.getScene();if(!e)return;(t=new Jm("Canvas")).addComponent("cc.Canvas"),t.parent=e}var i=new Jm("PHYSICS_2D_DEBUG_DRAW");i.hideFlags|=Ho.Flags.DontSave,i.parent=t,i.worldPosition=on.ZERO,i.layer=im.Enum.UI_2D,this._debugGraphics=i.addComponent("cc.Graphics"),this._debugGraphics.lineWidth=3;var n=new Srt(this._debugGraphics);this._b2DebugDrawer=n,this._world.SetDebugDraw(n)}var r=this._debugGraphics.node.parent;this._debugGraphics.node.setSiblingIndex(r.children.length-1),this._b2DebugDrawer&&this._b2DebugDrawer.SetFlags(this.debugDrawFlags)},e.setGravity=function(t){this._world.SetGravity(t)},e.setAllowSleep=function(){this._world.SetAllowSleeping(!0)},e.step=function(t,e,i){void 0===e&&(e=10),void 0===i&&(i=10);for(var n=this._animatedBodies,r=0,s=n.length;r<s;r++)n[r].animate(t);this._world.Step(t,e,i)},e.raycast=function(t,e,i,n){if(t.equals(e))return[];i=i||U9.Closest,Art.x=t.x/X9,Art.y=t.y/X9,brt.x=e.x/X9,brt.y=e.y/X9;var r=this._raycastQueryCallback;r.init(i,n),this._world.RayCast(r,Art,brt);var s=r.getFixtures();if(s.length>0){for(var o=r.getPoints(),a=r.getNormals(),h=r.getFractions(),u=[],l=0,c=s.length;l<c;l++){var _=s[l],d=_.m_userData,f=d.collider;if(i===U9.AllClosest){for(var p=void 0,m=0;m<u.length;m++)u[m].collider===f&&(p=u[m]);if(p){h[l]<p.fraction&&(p.fixtureIndex=d.getFixtureIndex(_),p.point.x=o[l].x*X9,p.point.y=o[l].y*X9,p.normal.x=a[l].x,p.normal.y=a[l].y,p.fraction=h[l]);continue}}u.push({collider:f,fixtureIndex:d.getFixtureIndex(_),point:new Ln(o[l].x*X9,o[l].y*X9),normal:new Ln(a[l].x,a[l].y),fraction:h[l]})}return u}return[]},e.syncPhysicsToScene=function(){for(var t=this._bodies,e=0,i=t.length;e<i;e++){var n=t[e],r=n.rigidBody;if(r.type!==F9.Animated){var s=r.node,o=n.impl,a=o.GetPosition();Trt.x=a.x*X9,Trt.y=a.y*X9,Trt.z=0,s.worldPosition=Trt;var h=Di(o.GetAngle());s.setWorldRotationFromEuler(0,0,h)}else n.resetVelocity()}},e.syncSceneToPhysics=function(){for(var t=this._bodies,e=0;e<t.length;e++)t[e].syncSceneToPhysics()},e.addBody=function(t){if(!this._bodies.includes(t)){var e=Ert,i=t.rigidBody;e.allowSleep=i.allowSleep,e.gravityScale=i.gravityScale,e.linearDamping=i.linearDamping,e.angularDamping=i.angularDamping,e.fixedRotation=i.fixedRotation,e.bullet=i.bullet;var n=i.node,r=n.worldPosition;e.position.Set(r.x/X9,r.y/X9),Trt.z=Sn.getAxisAngle(this._rotationAxis,n.worldRotation),this._rotationAxis.z<0&&(Trt.z=2*Math.PI-Trt.z),e.angle=Trt.z,e.awake=i.awakeOnLoad,i.type===F9.Animated?(e.type=F9.Kinematic,this._animatedBodies.push(t),t._animatedPos.set(e.position.x,e.position.y),t._animatedAngle=e.angle):e.type=i.type;var s=i,o=s._linearVelocity;e.linearVelocity.Set(o.x,o.y),e.angularVelocity=Bi(s._angularVelocity);var a=this._world.CreateBody(e);a.m_userData=t,t._imp=a,this._bodies.push(t)}},e.removeBody=function(t){this._bodies.includes(t)&&(t.impl&&(t.impl.m_userData=null,this._world.DestroyBody(t.impl),t._imp=null),he(this._bodies,t),t.rigidBody.type===F9.Animated&&he(this._animatedBodies,t))},e.registerContactFixture=function(t){this._contactListener.registerContactFixture(t)},e.unregisterContactFixture=function(t){this._contactListener.unregisterContactFixture(t)},e.testPoint=function(t){var e=Art.x=t.x/X9,i=Art.y=t.y/X9,n=.2/X9;Crt.lowerBound.x=e-n,Crt.lowerBound.y=i-n,Crt.upperBound.x=e+n,Crt.upperBound.y=i+n;var r=this._aabbQueryCallback;r.init(Art),this._world.QueryAABB(r,Crt);var s=r.getFixtures();wrt.length=0;for(var o=0;o<s.length;o++){var a=s[o].m_userData.collider;wrt.includes(a)||wrt.push(a)}return wrt},e.testAABB=function(t){Crt.lowerBound.x=t.xMin/X9,Crt.lowerBound.y=t.yMin/X9,Crt.upperBound.x=t.xMax/X9,Crt.upperBound.y=t.yMax/X9;var e=this._aabbQueryCallback;e.init(),this._world.QueryAABB(e,Crt);var i=e.getFixtures();wrt.length=0;for(var n=0;n<i.length;n++){var r=i[n].m_userData.collider;wrt.includes(r)||wrt.push(r)}return wrt},e.drawDebug=function(){this._checkDebugDrawValid(),this._debugGraphics&&(this._debugGraphics.clear(),this._world.DrawDebugData())},e._onBeginContact=function(t){prt.get(t).emit(j9.BEGIN_CONTACT)},e._onEndContact=function(t){var e=t.m_userData;e&&(e.emit(j9.END_CONTACT),prt.put(t))},e._onPreSolve=function(t){var e=t.m_userData;e&&e.emit(j9.PRE_SOLVE)},e._onPostSolve=function(t,e){var i=t.m_userData;i&&(i._setImpulse(e),i.emit(j9.POST_SOLVE),i._setImpulse(null))},n(t,[{key:"impl",get:function(){return this._world}},{key:"groundBodyImpl",get:function(){return this._physicsGroundBody}},{key:"debugDrawFlags",get:function(){return this._debugDrawFlags},set:function(t){t||this._debugGraphics&&(this._debugGraphics.node.parent=null),this._debugDrawFlags=t}}]),t}(),Rrt=new on,Irt=new stt.Vec2,Brt=function(){function t(){this._animatedPos=new Ln,this._animatedAngle=0,this._body=null,this._rigidBody=void 0,this._inited=!1}var e=t.prototype;return e.initialize=function(t){this._rigidBody=t,get.instance._callAfterStep(this,this._init)},e.onDestroy=function(){get.instance._callAfterStep(this,this._destroy)},e.onEnable=function(){this.setActive(!0)},e.onDisable=function(){this.setActive(!1)},e.nodeTransformChanged=function(t){if(!get.instance.stepping){if(t&Jm.TransformBit.SCALE)for(var e=this.rigidBody.getComponents(trt),i=0;i<e.length;i++)e[i].apply();t&Jm.TransformBit.POSITION&&this.syncPositionToPhysics(!0),t&Jm.TransformBit.ROTATION&&this.syncRotationToPhysics(!0)}},e._init=function(){this._inited||(get.instance.physicsWorld.addBody(this),this.setActive(!1),this._inited=!0)},e._destroy=function(){this._inited&&(get.instance.physicsWorld.removeBody(this),this._inited=!1)},e.animate=function(t){var e=this._body;if(e){var i=e.GetPosition();e.SetAwake(!0);var n=1/t;Irt.x=(this._animatedPos.x-i.x)*n,Irt.y=(this._animatedPos.y-i.y)*n,e.SetLinearVelocity(Irt);var r=e.GetAngle()%bi;r>Math.PI&&(r-=bi);var s=(this._animatedAngle-r)*n;this._animatedAngle<-Ai&&r>Ai&&(s=(this._animatedAngle+bi-r)*n),this._animatedAngle>Ai&&r<-Ai&&(s=(this._animatedAngle-bi-r)*n),e.SetAngularVelocity(s)}},e.syncSceneToPhysics=function(){var t=this._rigidBody.node.hasChangedFlags;t&&this.nodeTransformChanged(t)},e.syncPositionToPhysics=function(t){void 0===t&&(t=!1);var e=this._body;if(e){var i,n=this._rigidBody.node.worldPosition,r=this._rigidBody.type;(i=r===F9.Animated?e.GetLinearVelocity():e.GetPosition()).x=n.x/X9,i.y=n.y/X9,r===F9.Animated&&t?this._animatedPos.set(i.x,i.y):e.SetTransformVec(i,e.GetAngle())}},e.syncRotationToPhysics=function(t){void 0===t&&(t=!1);var e=this._body;if(e){var i=this._rigidBody.node.worldRotation,n=Rrt;Sn.toEulerInYXZOrder(n,i);var r=Bi(n.z);this._rigidBody.type===F9.Animated&&t?this._animatedAngle=r:e.SetTransformVec(e.GetPosition(),r)}},e.resetVelocity=function(){var t=this._body;if(t){var e=t.m_linearVelocity;e.Set(0,0),t.SetLinearVelocity(e),t.SetAngularVelocity(0)}},e.setType=function(t){this._body.SetType(t)},e.setLinearDamping=function(t){this._body.SetLinearDamping(t)},e.setAngularDamping=function(t){this._body.SetAngularDamping(t)},e.setGravityScale=function(t){this._body.SetGravityScale(t)},e.setFixedRotation=function(t){this._body.SetFixedRotation(t)},e.setAllowSleep=function(t){this._body.SetSleepingAllowed(t)},e.isActive=function(){return this._body.IsActive()},e.setActive=function(t){this._body.SetActive(t)},e.wakeUp=function(){this._body.SetAwake(!0)},e.sleep=function(){this._body.SetAwake(!1)},e.getMass=function(){return this._body.GetMass()},e.setLinearVelocity=function(t){this._body.SetLinearVelocity(t)},e.getLinearVelocity=function(t){var e=this._body.GetLinearVelocity();return t.x=e.x,t.y=e.y,t},e.getLinearVelocityFromWorldPoint=function(t,e){return Irt.Set(t.x/X9,t.y/X9),this._body.GetLinearVelocityFromWorldPoint(Irt,e),e.x*=X9,e.y*=X9,e},e.setAngularVelocity=function(t){this._body.SetAngularVelocity(t)},e.getAngularVelocity=function(){return Di(this._body.GetAngularVelocity())},e.getLocalVector=function(t,e){return e=e||new Ln,Irt.Set(t.x/X9,t.y/X9),this._body.GetLocalVector(Irt,e),e.x*=X9,e.y*=X9,e},e.getWorldVector=function(t,e){return Irt.Set(t.x/X9,t.y/X9),this._body.GetWorldVector(Irt,e),e.x*=X9,e.y*=X9,e},e.getLocalPoint=function(t,e){return e=e||new Ln,Irt.Set(t.x/X9,t.y/X9),this._body.GetLocalPoint(Irt,e),e.x*=X9,e.y*=X9,e},e.getWorldPoint=function(t,e){return e=e||new Ln,Irt.Set(t.x/X9,t.y/X9),this._body.GetWorldPoint(Irt,e),e.x*=X9,e.y*=X9,e},e.getLocalCenter=function(t){t=t||new Ln;var e=this._body.GetLocalCenter();return t.x=e.x*X9,t.y=e.y*X9,t},e.getWorldCenter=function(t){t=t||new Ln;var e=this._body.GetWorldCenter();return t.x=e.x*X9,t.y=e.y*X9,t},e.getInertia=function(){return this._body.GetInertia()},e.applyForce=function(t,e,i){this._body&&(Irt.Set(e.x/X9,e.y/X9),this._body.ApplyForce(t,Irt,i))},e.applyForceToCenter=function(t,e){this._body&&this._body.ApplyForceToCenter(t,e)},e.applyTorque=function(t,e){this._body&&this._body.ApplyTorque(t,e)},e.applyLinearImpulse=function(t,e,i){this._body&&(Irt.Set(e.x/X9,e.y/X9),this._body.ApplyLinearImpulse(t,Irt,i))},e.applyLinearImpulseToCenter=function(t,e){this._body&&this._body.ApplyLinearImpulse(t,this._body.GetPosition(),e)},e.applyAngularImpulse=function(t,e){this._body&&this._body.ApplyAngularImpulse(t,e)},n(t,[{key:"impl",get:function(){return this._body}},{key:"_imp",set:function(t){this._body=t}},{key:"rigidBody",get:function(){return this._rigidBody}},{key:"isAwake",get:function(){return this._body.IsAwake()}},{key:"isSleeping",get:function(){return!this._body.IsAwake()}}]),t}(),Drt=new stt.Filter,Prt=new stt.Vec2,Ort=new stt.Vec2;function Mrt(t){var e=t.collider;return e.body?Drt.categoryBits=e.group===Gtt.DEFAULT?e.body.group:e.group:Drt.categoryBits=e.group,Drt.maskBits=get.instance.collisionMatrix[Drt.categoryBits],Drt}var Lrt,Nrt=function(){function t(){this._shapes=[],this._fixtures=[],this._collider=null,this._body=null,this._inited=!1,this._rect=new Un}var e=t.prototype;return e.initialize=function(t){this._collider=t},e.onLoad=function(){},e.onEnable=function(){get.instance._callAfterStep(this,this._init)},e.onDisable=function(){get.instance._callAfterStep(this,this._destroy)},e.start=function(){},e.onGroupChanged=function(){var t=Mrt(this);this._fixtures.forEach((function(e){e.SetFilterData(t)}))},e.apply=function(){this._destroy(),this.collider.enabledInHierarchy&&this._init()},e.getFixtureIndex=function(t){return this._fixtures.indexOf(t)},e._createShapes=function(){return[]},e._init=function(){if(!this._inited){var t=this.collider,e=t.node.worldScale,i=on.ZERO,n=t.getComponent(Znt);n&&n.impl&&n.impl.impl?this._body=n.impl.impl:(this._body=get.instance.physicsWorld.groundBodyImpl,i=t.node.worldPosition);for(var r=0===e.x&&0===e.y?[]:this._createShapes(e.x,e.y,i.x,i.y),s=Mrt(this),o=0;o<r.length;o++){var a=r[o],h={density:t.density,isSensor:t.sensor,friction:t.friction,restitution:t.restitution,shape:a,filter:s},u=this._body.CreateFixture(h);u.m_userData=this,null!=n&&n.enabledContactListener&&get.instance.physicsWorld.registerContactFixture(u),this._shapes.push(a),this._fixtures.push(u)}this._inited=!0}},e._destroy=function(){if(this._inited){for(var t=this._fixtures,e=this._body,i=t.length-1;i>=0;i--){var n=t[i];n.m_userData=null,get.instance.physicsWorld.unregisterContactFixture(n),e&&e.DestroyFixture(n)}this._body=null,this._fixtures.length=0,this._shapes.length=0,this._inited=!1}},n(t,[{key:"impl",get:function(){return this._shapes}},{key:"collider",get:function(){return this._collider}},{key:"worldAABB",get:function(){for(var t=1e7,e=t,i=t,n=-t,r=-t,s=this._fixtures,o=0;o<s.length;o++)for(var a=s[o],h=a.GetShape().GetChildCount(),u=0;u<h;u++){if(Prt.Copy(a.GetAABB(u).lowerBound),Ort.Copy(a.GetAABB(u).upperBound),2===a.GetShape().m_type){var l=a.GetShape().m_radius;Prt.SelfAddXY(l,l),Ort.SelfSubXY(l,l)}Prt.x<e&&(e=Prt.x),Prt.y<i&&(i=Prt.y),Ort.x>n&&(n=Ort.x),Ort.y>r&&(r=Ort.y)}e*=X9,i*=X9,n*=X9,r*=X9;var c=this._rect;return c.x=e,c.y=i,c.width=n-e,c.height=r-i,c}}]),t}(),Frt=new Un,krt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._worldPoints=[new Ln,new Ln,new Ln,new Ln],e}return s(e,t),e.prototype._createShapes=function(t,e,i,n){t=Math.abs(t),e=Math.abs(e);var r=this.collider,s=r.size.width/2/X9*t,o=r.size.height/2/X9*e,a=(i+r.offset.x*t)/X9,h=(n+r.offset.y*e)/X9,u=new stt.PolygonShape;return u.SetAsBox(s,o,new stt.Vec2(a,h),0),[u]},n(e,[{key:"worldPoints",get:function(){var t=Frt,e=this.collider,i=e.size,n=e.offset;t.x=n.x-i.width/2,t.y=n.y-i.height/2,t.width=i.width,t.height=i.height;var r=this._worldPoints,s=r[0],o=r[1],a=r[2],h=r[3];return t.transformMat4ToPoints(e.node.worldMatrix,s,o,a,h),r}}]),e}(Nrt),Vrt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._worldPosition=new Ln,e}return s(e,t),e.prototype._createShapes=function(t,e,i,n){t=Math.abs(t),e=Math.abs(e);var r=this.collider,s=(i+r.offset.x*t)/X9,o=(n+r.offset.y*e)/X9,a=new stt.CircleShape;return a.m_radius=r.radius/X9*t,a.m_p.Set(s,o),[a]},n(e,[{key:"worldRadius",get:function(){return this._shapes[0].m_radius*X9}},{key:"worldPosition",get:function(){var t=this._shapes[0].m_p;return this._worldPosition.set(t.x*X9,t.y*X9)}}]),e}(Nrt),Grt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._worldPoints=[],e}return s(e,t),e.prototype._createShapes=function(t,e,i,n){var r=[],s=this.collider,o=s.points;o.length>0&&o[0].equals(o[o.length-1])&&(o.length-=1);var a=btt(o);if(!a)return console.log("[Physics2D] b2PolygonShape failed to decompose polygon into convex polygons, node name: ",s.node.name),r;for(var h=s.offset,u=0;u<a.length;u++){for(var l=a[u],c=null,_=[],d=null,f=0,p=l.length;f<p;f++){c||(c=new stt.PolygonShape);var m=l[f],g=(i+(m.x+h.x)*t)/X9,y=(n+(m.y+h.y)*e)/X9,v=new stt.Vec2(g,y);_.push(v),d||(d=v),_.length===stt.maxPolygonVertices&&(c.Set(_,_.length),r.push(c),c=null,f<p-1&&(_=[d,_[_.length-1]]))}c&&(c.Set(_,_.length),r.push(c))}return r},n(e,[{key:"worldPoints",get:function(){for(var t=this.collider,e=t.points,i=this._worldPoints,n=t.node.worldMatrix,r=0;r<e.length;r++)i[r]||(i[r]=new Ln),Ln.transformMat4(i[r],e[r],n);return i.length=e.length,this._worldPoints}}]),e}(Nrt),Urt=function(){function t(){this._b2joint=null,this._jointComp=null,this._body=null,this._inited=!1}var e=t.prototype;return e.initialize=function(t){this._jointComp=t},e.onEnable=function(){get.instance._callAfterStep(this,this._init)},e.onDisable=function(){get.instance._callAfterStep(this,this._destroy)},e.start=function(){get.instance._callAfterStep(this,this._init)},e.apply=function(){get.instance._callAfterStep(this,this._destroy),this.comp.enabledInHierarchy&&get.instance._callAfterStep(this,this._init)},e._init=function(){if(!this._inited){var t=this._jointComp;if(t.isValid){this._body=t.getComponent(Znt);var e=this._createJointDef();if(e){e.bodyA=this._body.impl.impl;var i=t.connectedBody;i&&!i.enabledInHierarchy||(e.bodyB=i?i.impl.impl:get.instance.physicsWorld.groundBodyImpl,e.collideConnected=t.collideConnected,this._b2joint=get.instance.physicsWorld.impl.CreateJoint(e),this._inited=!0)}}}},e._destroy=function(){this._inited&&(get.instance.physicsWorld.impl.DestroyJoint(this._b2joint),this._b2joint=null,this._inited=!1)},e._createJointDef=function(){return null},e.isValid=function(){return this._b2joint&&this._body&&this._body.impl&&this._jointComp},n(t,[{key:"impl",get:function(){return this._b2joint}},{key:"comp",get:function(){return this._jointComp}},{key:"body",get:function(){return this._body}}]),t}(),zrt=new stt.Vec2,Hrt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._touchPoint=new Ln,e._isTouched=!1,e}s(e,t);var i=e.prototype;return i.setTarget=function(t){this._b2joint&&(zrt.x=t.x/X9,zrt.y=t.y/X9,this._b2joint.SetTarget(zrt))},i.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetDampingRatio(t)},i.setFrequency=function(t){this._b2joint&&this._b2joint.SetFrequency(t)},i.setMaxForce=function(t){this._b2joint&&this._b2joint.SetMaxForce(t)},i._createJointDef=function(){var t=new stt.MouseJointDef,e=this._jointComp;return t.target.Set(this._touchPoint.x/X9,this._touchPoint.y/X9),t.maxForce=e.maxForce,t.dampingRatio=e.dampingRatio,t.frequencyHz=e.frequency,t},i.initialize=function(e){t.prototype.initialize.call(this,e);var i=aL("Canvas");i&&(i.on(om.TOUCH_START,this.onTouchBegan,this),i.on(om.TOUCH_MOVE,this.onTouchMove,this),i.on(om.TOUCH_END,this.onTouchEnd,this),i.on(om.TOUCH_CANCEL,this.onTouchEnd,this))},i.onEnable=function(){},i.start=function(){},i.onTouchBegan=function(t){this._isTouched=!0;var e=this._touchPoint.set(t.getUILocation()),i=get.instance.physicsWorld.testPoint(e);if(!(i.length<=0)){var n=i[0].body;n.wakeUp();var r=this._jointComp;r.connectedBody=n,this._init(),this.setMaxForce(r.maxForce*n.getMass()),this.setTarget(e)}},i.onTouchMove=function(t){this._touchPoint=t.getUILocation()},i.onTouchEnd=function(){this._destroy(),this._isTouched=!1},i.update=function(){this._isTouched&&this.isValid()&&this.setTarget(this._touchPoint)},e}(Urt),Wrt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setMaxLength=function(t){this._b2joint&&this._b2joint.SetMaxLength(t)},i._createJointDef=function(){var t=this._jointComp,e=new stt.RopeJointDef;return e.localAnchorA.Set(t.anchor.x/X9,t.anchor.y/X9),e.localAnchorB.Set(t.connectedAnchor.x/X9,t.connectedAnchor.y/X9),e.maxLength=t.maxLength/X9,e},e}(Urt),jrt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetDampingRatio(t)},i.setFrequency=function(t){this._b2joint&&this._b2joint.SetFrequency(t)},i.setDistance=function(t){this._b2joint&&this._b2joint.SetLength(t)},i._createJointDef=function(){var t=this._jointComp,e=new stt.DistanceJointDef;return e.localAnchorA.Set(t.anchor.x/X9,t.anchor.y/X9),e.localAnchorB.Set(t.connectedAnchor.x/X9,t.connectedAnchor.y/X9),e.length=t.distance/X9,e.dampingRatio=t.dampingRatio,e.frequencyHz=t.frequency,e},e}(Urt),Xrt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setMaxForce=function(t){this._b2joint&&this._b2joint.SetMaxForce(t)},i.setAngularOffset=function(t){this._b2joint&&this._b2joint.SetAngularOffset(Bi(t))},i.setLinearOffset=function(t){this._b2joint&&this._b2joint.SetLinearOffset(new stt.Vec2(t.x/X9,t.y/X9))},i.setCorrectionFactor=function(t){this._b2joint&&(this._b2joint.m_correctionFactor=t)},i.setMaxTorque=function(t){this._b2joint&&this._b2joint.SetMaxTorque(t)},i._createJointDef=function(){var t=this._jointComp,e=new stt.MotorJointDef;return e.linearOffset.Set(t.linearOffset.x/X9,t.linearOffset.y/X9),e.angularOffset=Bi(t.angularOffset),e.maxForce=t.maxForce,e.maxTorque=t.maxTorque,e.correctionFactor=t.correctionFactor,e},e}(Urt),qrt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.enableLimit=function(t){this._b2joint&&this._b2joint.EnableLimit(t)},i.setLowerLimit=function(){this.updateLimits()},i.setUpperLimit=function(){this.updateLimits()},i.updateLimits=function(){if(this._b2joint){var t=this._jointComp;this._b2joint.SetLimits(t.lowerLimit/X9,t.upperLimit/X9)}},i.enableMotor=function(t){this._b2joint&&this._b2joint.EnableMotor(t)},i.setMaxMotorForce=function(t){this._b2joint&&this._b2joint.SetMaxMotorForce(t)},i.setMotorSpeed=function(t){this._b2joint&&this._b2joint.SetMotorSpeed(t)},i._createJointDef=function(){var t=this._jointComp,e=new stt.PrismaticJointDef;e.localAnchorA.Set(t.anchor.x/X9,t.anchor.y/X9),e.localAnchorB.Set(t.connectedAnchor.x/X9,t.connectedAnchor.y/X9);var i=Bi(t.angle);return e.localAxisA.Set(Math.cos(i),Math.sin(i)),e.referenceAngle=0,e.enableLimit=t.enableLimit,e.lowerTranslation=t.lowerLimit/X9,e.upperTranslation=t.upperLimit/X9,e.enableMotor=t.enableMotor,e.maxMotorForce=t.maxMotorForce,e.motorSpeed=t.motorSpeed,e},e}(Urt),Yrt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setFrequency=function(t){this._b2joint&&this._b2joint.SetFrequency(t)},i.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetDampingRatio(t)},i._createJointDef=function(){var t=this._jointComp,e=new stt.WeldJointDef;return e.localAnchorA.Set(t.anchor.x/X9,t.anchor.y/X9),e.localAnchorB.Set(t.connectedAnchor.x/X9,t.connectedAnchor.y/X9),e.referenceAngle=0,e.frequencyHz=t.frequency,e.dampingRatio=t.dampingRatio,e},e}(Urt),Krt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setDampingRatio=function(t){this._b2joint&&this._b2joint.SetSpringDampingRatio(t)},i.setFrequency=function(t){this._b2joint&&this._b2joint.SetSpringFrequencyHz(t)},i.enableMotor=function(t){this._b2joint&&this._b2joint.EnableMotor(t)},i.setMaxMotorTorque=function(t){this._b2joint&&this._b2joint.SetMaxMotorTorque(t)},i.setMotorSpeed=function(t){this._b2joint&&this._b2joint.SetMotorSpeed(t)},i._createJointDef=function(){var t=this._jointComp,e=new stt.WheelJointDef;e.localAnchorA.Set(t.anchor.x/X9,t.anchor.y/X9),e.localAnchorB.Set(t.connectedAnchor.x/X9,t.connectedAnchor.y/X9);var i=Bi(t.angle);return e.localAxisA.Set(Math.cos(i),Math.sin(i)),e.maxMotorTorque=t.maxMotorTorque,e.motorSpeed=Bi(t.motorSpeed),e.enableMotor=t.enableMotor,e.dampingRatio=t.dampingRatio,e.frequencyHz=t.frequency,e},e}(Urt),Jrt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.enableLimit=function(t){this._b2joint&&this._b2joint.EnableLimit(t)},i.setLowerAngle=function(){this.updateLimits()},i.setUpperAngle=function(){this.updateLimits()},i.updateLimits=function(){if(this._b2joint){var t=this._jointComp;this._b2joint.SetLimits(Bi(t.lowerAngle),Bi(t.upperAngle))}},i.enableMotor=function(t){this._b2joint&&this._b2joint.EnableMotor(t)},i.setMaxMotorTorque=function(t){this._b2joint&&this._b2joint.SetMaxMotorTorque(t)},i.setMotorSpeed=function(t){this._b2joint&&this._b2joint.SetMotorSpeed(t)},i._createJointDef=function(){var t=this._jointComp,e=new stt.RevoluteJointDef;return e.localAnchorA.Set(t.anchor.x/X9,t.anchor.y/X9),e.localAnchorB.Set(t.connectedAnchor.x/X9,t.connectedAnchor.y/X9),e.enableMotor=t.enableMotor,e.maxMotorTorque=t.maxMotorTorque,e.motorSpeed=Bi(t.motorSpeed),e.enableLimit=t.enableLimit,e.lowerAngle=Bi(t.lowerAngle),e.upperAngle=Bi(t.upperAngle),e},e}(Urt);function Qrt(t){v._global.CC_PHYSICS_BUILTIN="builtin"===t,v._global.CC_PHYSICS_CANNON="cannon.js"===t,v._global.CC_PHYSICS_AMMO="bullet"===t}SN.once(vN.EVENT_PRE_SUBSYSTEM_INIT,(function(){q9.register("box2d",{PhysicsWorld:xrt,RigidBody:Brt,BoxShape:krt,CircleShape:Vrt,PolygonShape:Grt,MouseJoint:Hrt,DistanceJoint:Wrt,SpringJoint:jrt,RelativeJoint:Xrt,SliderJoint:qrt,FixedJoint:Yrt,WheelJoint:Krt,HingeJoint:Jrt})}));var Zrt,$rt={id:"",switchTo:function(t){if($rt.runInEditor){var e=$rt;if($rt.physicsWorld&&t!==$rt.id&&null!=$rt.backend[t]?($rt.physicsWorld.destroy(),F("[PHYSICS]: switch from "+$rt.id+" to "+t+"."),Qrt(t),e.id=t,e.wrapper=$rt.backend[t],e.physicsWorld=nst()):(F("[PHYSICS]: using "+t+"."),e.physicsWorld=nst()),Lrt){var i=e.physicsWorld;i.setGravity(Lrt.gravity),i.setAllowSleep(Lrt.allowSleep)}}},register:function(t,e){if(F("[PHYSICS]: register "+t+"."),$rt.backend[t]=e,!$rt.physicsWorld||$rt.id===t){Qrt(t);var i=$rt;i.id=t,i.wrapper=e}},wrapper:{},backend:{},physicsWorld:null,runInEditor:!0},tst=function(){return 0},est={impl:null,debugDrawFlags:0,debugDrawConstraintSize:0,setGravity:tst,setAllowSleep:tst,setDefaultMaterial:tst,step:tst,syncAfterEvents:tst,syncSceneToPhysics:tst,raycast:tst,raycastClosest:tst,sweepBox:tst,sweepBoxClosest:tst,sweepSphere:tst,sweepSphereClosest:tst,sweepCapsule:tst,sweepCapsuleClosest:tst,emitEvents:tst,destroy:tst};function ist(t,e){return null==t&&($rt.id?k($rt.id+" physics does not support "+Zrt[e]):J(9600),!0)}function nst(){return ist($rt.wrapper.PhysicsWorld,Zrt.World)?est:new $rt.wrapper.PhysicsWorld}!function(t){t[t.World=0]="World",t[t.RigidBody=1]="RigidBody",t[t.BoxCollider=2]="BoxCollider",t[t.SphereCollider=3]="SphereCollider",t[t.CapsuleCollider=4]="CapsuleCollider",t[t.MeshCollider=5]="MeshCollider",t[t.CylinderCollider=6]="CylinderCollider",t[t.ConeCollider=7]="ConeCollider",t[t.TerrainCollider=8]="TerrainCollider",t[t.SimplexCollider=9]="SimplexCollider",t[t.PlaneCollider=10]="PlaneCollider",t[t.PointToPointConstraint=11]="PointToPointConstraint",t[t.HingeConstraint=12]="HingeConstraint",t[t.FixedConstraint=13]="FixedConstraint",t[t.ConfigurableConstraint=14]="ConfigurableConstraint",t[t.BoxCharacterController=15]="BoxCharacterController",t[t.CapsuleCharacterController=16]="CapsuleCharacterController"}(Zrt||(Zrt={}));var rst={impl:null,rigidBody:null,isAwake:!1,isSleepy:!1,isSleeping:!1,initialize:tst,onEnable:tst,onDisable:tst,onDestroy:tst,setType:tst,setMass:tst,setLinearDamping:tst,setAngularDamping:tst,useGravity:tst,setLinearFactor:tst,setAngularFactor:tst,setAllowSleep:tst,wakeUp:tst,sleep:tst,clearState:tst,clearForces:tst,clearVelocity:tst,setSleepThreshold:tst,getSleepThreshold:tst,getLinearVelocity:tst,setLinearVelocity:tst,getAngularVelocity:tst,setAngularVelocity:tst,applyForce:tst,applyLocalForce:tst,applyImpulse:tst,applyLocalImpulse:tst,applyTorque:tst,applyLocalTorque:tst,setGroup:tst,getGroup:tst,addGroup:tst,removeGroup:tst,setMask:tst,getMask:tst,addMask:tst,removeMask:tst,isUsingCCD:tst,useCCD:tst},sst={INITED:!1},ost={impl:null,collider:null,attachedRigidBody:null,initialize:tst,onLoad:tst,onEnable:tst,onDisable:tst,onDestroy:tst,setGroup:tst,getGroup:tst,addGroup:tst,removeGroup:tst,setMask:tst,getMask:tst,addMask:tst,removeMask:tst,setMaterial:tst,setAsTrigger:tst,setCenter:tst,getAABB:tst,getBoundingSphere:tst,updateSize:tst,updateRadius:tst,setRadius:tst,setCylinderHeight:tst,setDirection:tst,setHeight:tst,setShapeType:tst,setVertices:tst,setMesh:tst,setTerrain:tst,setNormal:tst,setConstant:tst,updateEventListener:tst};var ast={INITED:!1},hst={impl:null,initialize:tst,onLoad:tst,onEnable:tst,onDisable:tst,onDestroy:tst,setEnableCollision:tst,setConnectedBody:tst,setPivotA:tst,setPivotB:tst,setAxis:tst,setSecondaryAxis:tst,setBreakForce:tst,setBreakTorque:tst,setConstraintMode:tst,setLinearLimit:tst,setAngularExtent:tst,setLinearSoftConstraint:tst,setLinearStiffness:tst,setLinearDamping:tst,setLinearRestitution:tst,setSwingSoftConstraint:tst,setTwistSoftConstraint:tst,setSwingStiffness:tst,setSwingDamping:tst,setSwingRestitution:tst,setTwistStiffness:tst,setTwistDamping:tst,setTwistRestitution:tst,setDriverMode:tst,setLinearMotorTarget:tst,setLinearMotorVelocity:tst,setLinearMotorForceLimit:tst,setAngularMotorTarget:tst,setAngularMotorVelocity:tst,setAngularMotorForceLimit:tst,setAutoPivotB:tst,setLimitEnabled:tst,setLowerLimit:tst,setUpperLimit:tst,setMotorEnabled:tst,setMotorVelocity:tst,setMotorForceLimit:tst};var ust,lst,cst,_st={INITED:!1},dst={initialize:tst,onLoad:tst,onEnable:tst,onDisable:tst,onDestroy:tst,onGround:tst,getPosition:tst,setPosition:tst,setStepOffset:tst,setSlopeLimit:tst,setContactOffset:tst,setDetectCollisions:tst,setOverlapRecovery:tst,setGroup:tst,getGroup:tst,addGroup:tst,removeGroup:tst,setMask:tst,getMask:tst,addMask:tst,removeMask:tst,move:tst,syncPhysicsToScene:tst,updateEventListener:tst,setHalfHeight:tst,setHalfSideExtent:tst,setHalfForwardExtent:tst,setRadius:tst,setHeight:tst};!function(t){t[t.EBulletTypeVec3=0]="EBulletTypeVec3",t[t.EBulletTypeQuat=1]="EBulletTypeQuat",t[t.EBulletTypeTransform=2]="EBulletTypeTransform",t[t.EBulletTypeMotionState=3]="EBulletTypeMotionState",t[t.EBulletTypeCollisionObject=4]="EBulletTypeCollisionObject",t[t.EBulletTypeCollisionShape=5]="EBulletTypeCollisionShape",t[t.EBulletTypeCharacterController=6]="EBulletTypeCharacterController",t[t.EBulletTypeStridingMeshInterface=7]="EBulletTypeStridingMeshInterface",t[t.EBulletTypeTriangleMesh=8]="EBulletTypeTriangleMesh",t[t.EBulletTypeCollisionDispatcher=9]="EBulletTypeCollisionDispatcher",t[t.EBulletTypeDbvtBroadPhase=10]="EBulletTypeDbvtBroadPhase",t[t.EBulletTypeSequentialImpulseConstraintSolver=11]="EBulletTypeSequentialImpulseConstraintSolver",t[t.EBulletTypeCollisionWorld=12]="EBulletTypeCollisionWorld",t[t.EBulletTypeTypedConstraint=13]="EBulletTypeTypedConstraint",t[t.EBulletTypeDebugDraw=14]="EBulletTypeDebugDraw"}(ust||(ust={})),function(t){t[t.NONE=0]="NONE",t[t.FilterBackfaces=1]="FilterBackfaces",t[t.KeepUnflippedNormal=2]="KeepUnflippedNormal",t[t.UseSubSimplexConvexCastRaytest=4]="UseSubSimplexConvexCastRaytest",t[t.UseGjkConvexCastRaytest=8]="UseGjkConvexCastRaytest"}(lst||(lst={})),function(t){t[t.DBG_NoDebug=0]="DBG_NoDebug",t[t.DBG_DrawWireframe=1]="DBG_DrawWireframe",t[t.DBG_DrawAabb=2]="DBG_DrawAabb",t[t.DBG_DrawFeaturesText=4]="DBG_DrawFeaturesText",t[t.DBG_DrawContactPoints=8]="DBG_DrawContactPoints",t[t.DBG_NoDeactivation=16]="DBG_NoDeactivation",t[t.DBG_NoHelpText=32]="DBG_NoHelpText",t[t.DBG_DrawText=64]="DBG_DrawText",t[t.DBG_ProfileTimings=128]="DBG_ProfileTimings",t[t.DBG_EnableSatComparison=256]="DBG_EnableSatComparison",t[t.DBG_DisableBulletLCP=512]="DBG_DisableBulletLCP",t[t.DBG_EnableCCD=1024]="DBG_EnableCCD",t[t.DBG_DrawConstraints=2048]="DBG_DrawConstraints",t[t.DBG_DrawConstraintLimits=4096]="DBG_DrawConstraintLimits",t[t.DBG_FastWireframe=8192]="DBG_FastWireframe",t[t.DBG_DrawNormals=16384]="DBG_DrawNormals",t[t.DBG_DrawFrames=32768]="DBG_DrawFrames",t[t.DBG_MAX_DEBUG_DRAW_MODE=32769]="DBG_MAX_DEBUG_DRAW_MODE"}(cst||(cst={}));var fst={},pst={BODY_CACHE_NAME:"body",CCT_CACHE_NAME:"cct"};SN.onPostInfrastructureInitDelegate.add((function(){return ON().then((function(){return Promise.all([e.import("./bullet.release.wasm-db4b8437.js"),e.import("./bullet.release.wasm-e702f478.js"),e.import("./bullet.release.asm-891ce7c7.js")]).then((function(t){var e,i,n,r=t[0].default,s=t[1].default,o=t[2].default;return xl.hasFeature(xl.Feature.WASM)?(i=r,n=s,new Promise((function(t,e){var r=function(t){return"[bullet]: bullet wasm lib load failed: "+t};i({instantiateWasm:function(t,i){PN(n,t).then((function(t){i(t.instance,t.module)})).catch((function(t){return e(r(t))}))}}).then((function(t){F("[bullet]:bullet wasm lib loaded."),fst=t})).then(t).catch((function(t){return e(r(t))}))}))):null!=(e=o)?e().then((function(t){F("[bullet]:bullet asm lib loaded."),fst=t})):new Promise((function(t){t()}))}))})).catch((function(t){V(t)}))}));var mst={type:"onTriggerEnter",selfCollider:null,otherCollider:null,impl:null},gst={type:"onCollisionEnter",selfCollider:null,otherCollider:null,contacts:[],impl:null},yst={type:"onControllerTriggerEnter",collider:null,characterController:null,impl:null},vst=function(){function t(){this.BT_TRANSFORM_0=fst.Transform_new(),this.BT_TRANSFORM_1=fst.Transform_new(),this.BT_V3_0=fst.Vec3_new(0,0,0),this.BT_V3_1=fst.Vec3_new(0,0,0),this.BT_V3_2=fst.Vec3_new(0,0,0),this.BT_QUAT_0=fst.Quat_new(0,0,0,1)}return t.setWrapper=function(t,e,i){this.ROOT[e]||(this.ROOT[e]={}),this.ROOT[e][t]=i},t.delWrapper=function(t,e){delete this.ROOT[e][t]},t.getWrapper=function(t,e){return this.ROOT[e][t]},t.isNotEmptyShape=function(t){return t!==fst.EmptyShape_static()},n(t,null,[{key:"instance",get:function(){return null==t._instance&&(t._instance=new t),t._instance}}]),t}();vst._instance=void 0,vst.ROOT={};var Sst=new on,Tst=new on,Ast=new on,bst=new Sn,Est=new Sn,Cst=new In;new In;var wst,xst,Rst,Ist,Bst,Dst,Pst,Ost,Mst,Lst,Nst,Fst,kst=new dn;function Vst(t,e){return fst.Vec3_set(t,e.x,e.y,e.z),t}function Gst(t,e){var i=fst.HEAPF32.subarray(e/4,e/4+3);return t.x=i[0],t.y=i[1],t.z=i[2],t}function Ust(t,e){return fst.Quat_set(t,e.x,e.y,e.z,e.w),t}function zst(t,e){var i=fst.HEAPF32.subarray(e/4,e/4+4);return t.x=i[0],t.y=i[1],t.z=i[2],t.w=i[3],t}function Hst(t,e){for(var i=e.renderingSubMeshes.length,n=0;n<i;n++){var r=e.renderingSubMeshes[n],s=r.geometricInfo;if(s){var o=r.primitiveMode,a=s.positions,h=s.indices,u=vst.instance.BT_V3_0,l=vst.instance.BT_V3_1,c=vst.instance.BT_V3_2;if(o===pc.TRIANGLE_LIST)for(var _=h.length,d=0;d<_;d+=3){var f=3*h[d],p=3*h[d+1],m=3*h[d+2];fst.Vec3_set(u,a[f],a[f+1],a[f+2]),fst.Vec3_set(l,a[p],a[p+1],a[p+2]),fst.Vec3_set(c,a[m],a[m+1],a[m+2]),fst.TriangleMesh_addTriangle(t,u,l,c,!1)}else if(o===pc.TRIANGLE_STRIP)for(var g=h.length-2,y=0,v=0;v<g;v+=1){var S=3*h[v-y],T=3*h[v+y+1],A=3*h[v+2];y=~y,fst.Vec3_set(u,a[S],a[S+1],a[S+2]),fst.Vec3_set(l,a[T],a[T+1],a[T+2]),fst.Vec3_set(c,a[A],a[A+1],a[A+2]),fst.TriangleMesh_addTriangle(t,u,l,c,!1)}else if(o===pc.TRIANGLE_FAN){var b=h.length-1,E=3*h[0];fst.Vec3_set(u,a[E],a[E+1],a[E+2]);for(var C=1;C<b;C+=1){var w=3*h[C],x=3*h[C+1];fst.Vec3_set(l,a[w],a[w+1],a[w+2]),fst.Vec3_set(c,a[x],a[x+1],a[x+2]),fst.TriangleMesh_addTriangle(t,u,l,c,!1)}}}}return t}function Wst(t,e){return t*e}pst.CACHE=vst;var jst=t("fp",(wst=qs("cc.PhysicsMaterial"),xst=xo(Ye),Rst=xo(Ye),Ist=xo(Ye),Bst=xo(Ye),wst(((Fst=function(t){function e(){var i;return(i=t.call(this)||this).id=void 0,i._friction=Ost&&Ost(),i._rollingFriction=Mst&&Mst(),i._spinningFriction=Lst&&Lst(),i._restitution=Nst&&Nst(),e.allMaterials.push(c(i)),i.id=e._idCounter++,i._uuid||(i._uuid="pm_"+i.id),i}s(e,t);var i=e.prototype;return i.clone=function(){var t=new e;return t._friction=this._friction,t._restitution=this._restitution,t._rollingFriction=this._rollingFriction,t._spinningFriction=this._spinningFriction,t},i.destroy=function(){if(t.prototype.destroy.call(this)){var i=e.allMaterials.indexOf(this);return i>=0&&e.allMaterials.splice(i,1),!0}return!1},i.setValues=function(t,i,n,r){var s=this._friction!==t||this._rollingFriction!==i||this._spinningFriction!==n||this._restitution!==r;this._friction=t,this._rollingFriction=i,this._spinningFriction=n,this._restitution=r,s&&this.emit(e.EVENT_UPDATE)},n(e,[{key:"friction",get:function(){return this._friction},set:function(t){Ci(this._friction,t)||(this._friction=t,this.emit(e.EVENT_UPDATE))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){Ci(this._rollingFriction,t)||(this._rollingFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"spinningFriction",get:function(){return this._spinningFriction},set:function(t){Ci(this._spinningFriction,t)||(this._spinningFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"restitution",get:function(){return this._restitution},set:function(t){Ci(this._restitution,t)||(this._restitution=t,this.emit(e.EVENT_UPDATE))}}]),e}(of)).allMaterials=[],Fst.EVENT_UPDATE="event_update",Fst._idCounter=0,p((Pst=Fst).prototype,"friction",[xst],Object.getOwnPropertyDescriptor(Pst.prototype,"friction"),Pst.prototype),p(Pst.prototype,"rollingFriction",[Rst],Object.getOwnPropertyDescriptor(Pst.prototype,"rollingFriction"),Pst.prototype),p(Pst.prototype,"spinningFriction",[Ist],Object.getOwnPropertyDescriptor(Pst.prototype,"spinningFriction"),Pst.prototype),p(Pst.prototype,"restitution",[Bst],Object.getOwnPropertyDescriptor(Pst.prototype,"restitution"),Pst.prototype),Ost=ks(Pst.prototype,"_friction",[io],(function(){return.6})),Mst=ks(Pst.prototype,"_rollingFriction",[io],(function(){return 0})),Lst=ks(Pst.prototype,"_spinningFriction",[io],(function(){return 0})),Nst=ks(Pst.prototype,"_restitution",[io],(function(){return 0})),Dst=Pst))||Dst)),Xst=t("fq",function(){function t(){this._hitPoint=new on,this._hitNormal=new on,this._distance=0,this._collider=null}var e=t.prototype;return e._assign=function(t,e,i,n){on.copy(this._hitPoint,t),on.copy(this._hitNormal,n),this._distance=e,this._collider=i},e.clone=function(){var e=new t;return on.copy(e._hitPoint,this._hitPoint),on.copy(e._hitNormal,this._hitNormal),e._distance=this._distance,e._collider=this._collider,e},n(t,[{key:"hitPoint",get:function(){return this._hitPoint}},{key:"distance",get:function(){return this._distance}},{key:"collider",get:function(){return this._collider}},{key:"hitNormal",get:function(){return this._hitNormal}}]),t}()),qst=t("fr",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._id=0,e}s(e,t);var i=e.prototype;return i._assign=function(e,i,n,r,s){void 0===s&&(s=0),t.prototype._assign.call(this,e,i,n,r),this._id=s},i.clone=function(){var t=new e;return on.copy(t._hitPoint,this._hitPoint),on.copy(t._hitNormal,this._hitNormal),t._distance=this._distance,t._collider=this._collider,t._id=this._id,t},n(e,[{key:"id",get:function(){return this._id}}]),e}(Xst));v.internal.PhysicsGroup=Gtt;var Yst,Kst,Jst,Qst,Zst,$st,tot,eot,iot,not,rot,sot,oot,aot,hot,uot,lot=t("fl",function(t){s(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this)||this).raycastClosestResult=new Xst,e.raycastResults=[],e.lineStripCastClosestResult=new qst,e.lineStripCastResults=[],e.sweepCastClosestResult=new Xst,e.sweepCastResults=[],e.collisionMatrix=new Htt(1),e.minVolumeSize=1e-5,e.useNodeChains=!1,e._enable=!0,e._allowSleep=!0,e._maxSubSteps=1,e._subStepCount=0,e._fixedTimeStep=1/60,e._autoSimulation=!0,e._accumulator=0,e._sleepThreshold=.1,e._gravity=new on(0,-10,0),e._material=void 0,e.raycastOptions={group:-1,mask:-1,queryTrigger:!0,maxDistance:1e7},e.raycastResultPool=new Du((function(){return new Xst}),1),e.sweepResultPool=new Du((function(){return new Xst}),1),e}return e.setDefaultPhysicsMaterial=function(t){this._material=t,this.physicsWorld.setDefaultMaterial(this._material),this._material.on(jst.EVENT_UPDATE,this._updateMaterial,this)},e.initDefaultMaterial=function(){var t=this;if(null!=this._material)return Promise.resolve();var e=nT.get("default-physics-material");if(!e)return console.error("PhysicsSystem initDefaultMaterial() Failed to load builtinMaterial"),Promise.resolve();var i=Ee.querySettings(be.Category.PHYSICS,"defaultMaterial");return i?new Promise((function(t,e){ZS.loadAny(i,(function(i,n){return!i&&n instanceof jst?t(n):e(i)}))})).then((function(e){t.setDefaultPhysicsMaterial(e)})).catch((function(n){k(n),k("Failed to load user customized default physics material: "+i+", will fallback to built-in default physics material"),t.setDefaultPhysicsMaterial(e)})):(this.setDefaultPhysicsMaterial(e),Promise.resolve())},e.postUpdate=function(t){if(this.physicsWorld)if(this._enable){if(this._autoSimulation){for(this._subStepCount=0,this._accumulator+=t,fN.emit(dN.EVENT_BEFORE_PHYSICS);this._subStepCount<this._maxSubSteps;){if(!(this._accumulator>=this._fixedTimeStep)){this.physicsWorld.syncSceneToPhysics();break}this.physicsWorld.syncSceneToPhysics(),this.physicsWorld.step(this._fixedTimeStep),this.physicsWorld.emitEvents(),this.physicsWorld.syncAfterEvents(),this._accumulator-=this._fixedTimeStep,this._subStepCount++}fN.emit(dN.EVENT_AFTER_PHYSICS)}}else this.physicsWorld.syncSceneToPhysics()},e.resetConfiguration=function(t){var e=t?t.allowSleep:Ee.querySettings(be.Category.PHYSICS,"allowSleep");"boolean"==typeof e&&(this._allowSleep=e);var i=t?t.fixedTimeStep:Ee.querySettings(be.Category.PHYSICS,"fixedTimeStep");"number"==typeof i&&(this._fixedTimeStep=i);var n=t?t.maxSubSteps:Ee.querySettings(be.Category.PHYSICS,"maxSubSteps");"number"==typeof n&&(this._maxSubSteps=n);var r=t?t.sleepThreshold:Ee.querySettings(be.Category.PHYSICS,"sleepThreshold");"number"==typeof r&&(this._sleepThreshold=r);var s=t?t.autoSimulation:Ee.querySettings(be.Category.PHYSICS,"autoSimulation");"boolean"==typeof s&&(this.autoSimulation=s);var o=t?t.gravity:Ee.querySettings(be.Category.PHYSICS,"gravity");o&&on.copy(this._gravity,o);var a=t?t.collisionMatrix:Ee.querySettings(be.Category.PHYSICS,"collisionMatrix");if(a)for(var h in a)this.collisionMatrix[""+(1<<parseInt(h))]=a[h];var u=t?t.collisionGroups:Ee.querySettings(be.Category.PHYSICS,"collisionGroups");u&&u instanceof Array&&(u.forEach((function(t){Gtt[t.name]=1<<t.index})),ge.update(Gtt)),this.physicsWorld&&(this.physicsWorld.setGravity(this._gravity),this.physicsWorld.setAllowSleep(this._allowSleep))},e.resetAccumulator=function(t){void 0===t&&(t=0),this._accumulator=t},e.step=function(t,e,i){this.physicsWorld&&this.physicsWorld.step(t,e,i)},e.syncSceneToPhysics=function(){this.physicsWorld&&this.physicsWorld.syncSceneToPhysics()},e.emitEvents=function(){this.physicsWorld&&this.physicsWorld.emitEvents()},e.raycast=function(t,e,i,n){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),!!this.physicsWorld&&(this.raycastResultPool.reset(),this.raycastResults.length=0,this.raycastOptions.mask=e>>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=n,this.physicsWorld.raycast(t,this.raycastOptions,this.raycastResultPool,this.raycastResults))},e.raycastClosest=function(t,e,i,n){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),!!this.physicsWorld&&(this.raycastOptions.mask=e>>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=n,this.physicsWorld.raycastClosest(t,this.raycastOptions,this.raycastClosestResult))},e.lineStripCast=function(t,e,i,n){if(void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),t.length<2)return!1;this.lineStripCastResults=[];for(var r=0,s=new or,o=1;o<t.length&&!(r>i);++o){var a=t[o-1],h=t[o],u=new on;on.subtract(u,h,a);var l=on.len(u);if(r+=l,on.multiplyScalar(u,u,1/l),s.d=u,s.o=a,this.raycast(s,e,l,n))for(var c=0;c<this.raycastResults.length;c++){var _=this.raycastResults[c];if(0!==c||!on.equals(a,_.hitPoint)){var d=new qst;d._assign(_.hitPoint,_.distance,_.collider,_.hitNormal,o-1),this.lineStripCastResults.push(d)}}}return this.lineStripCastResults.length>0},e.lineStripCastClosest=function(t,e,i,n){if(void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),t.length<2)return!1;for(var r=0,s=new or,o=!1,a=1;a<t.length&&!(r>i);++a){var h=t[a-1],u=t[a],l=new on;on.subtract(l,u,h);var c=on.len(l);if(r+=c,on.multiplyScalar(l,l,1/c),s.d=l,s.o=h,o=this.raycastClosest(s,e,c,n)){var _=this.raycastClosestResult,d=new qst;d._assign(_.hitPoint,_.distance,_.collider,_.hitNormal,a-1),this.lineStripCastClosestResult=d;break}}return o},e.sweepBox=function(t,e,i,n,r,s){return void 0===n&&(n=4294967295),void 0===r&&(r=1e7),void 0===s&&(s=!0),!!this.physicsWorld&&(this.sweepResultPool.reset(),this.sweepCastResults.length=0,this.raycastOptions.mask=n>>>0,this.raycastOptions.maxDistance=r,this.raycastOptions.queryTrigger=s,this.physicsWorld.sweepBox(t,e,i,this.raycastOptions,this.sweepResultPool,this.sweepCastResults))},e.sweepBoxClosest=function(t,e,i,n,r,s){return void 0===n&&(n=4294967295),void 0===r&&(r=1e7),void 0===s&&(s=!0),!!this.physicsWorld&&(this.raycastOptions.mask=n>>>0,this.raycastOptions.maxDistance=r,this.raycastOptions.queryTrigger=s,this.physicsWorld.sweepBoxClosest(t,e,i,this.raycastOptions,this.sweepCastClosestResult))},e.sweepSphere=function(t,e,i,n,r){return void 0===i&&(i=4294967295),void 0===n&&(n=1e7),void 0===r&&(r=!0),!!this.physicsWorld&&(this.sweepResultPool.reset(),this.sweepCastResults.length=0,this.raycastOptions.mask=i>>>0,this.raycastOptions.maxDistance=n,this.raycastOptions.queryTrigger=r,this.physicsWorld.sweepSphere(t,e,this.raycastOptions,this.sweepResultPool,this.sweepCastResults))},e.sweepSphereClosest=function(t,e,i,n,r){return void 0===i&&(i=4294967295),void 0===n&&(n=1e7),void 0===r&&(r=!0),!!this.physicsWorld&&(this.raycastOptions.mask=i>>>0,this.raycastOptions.maxDistance=n,this.raycastOptions.queryTrigger=r,this.physicsWorld.sweepSphereClosest(t,e,this.raycastOptions,this.sweepCastClosestResult))},e.sweepCapsule=function(t,e,i,n,r,s,o){return void 0===r&&(r=4294967295),void 0===s&&(s=1e7),void 0===o&&(o=!0),!!this.physicsWorld&&(this.sweepResultPool.reset(),this.sweepCastResults.length=0,this.raycastOptions.mask=r>>>0,this.raycastOptions.maxDistance=s,this.raycastOptions.queryTrigger=o,this.physicsWorld.sweepCapsule(t,e,i,n,this.raycastOptions,this.sweepResultPool,this.sweepCastResults))},e.sweepCapsuleClosest=function(t,e,i,n,r,s,o){return void 0===r&&(r=4294967295),void 0===s&&(s=1e7),void 0===o&&(o=!0),!!this.physicsWorld&&(this.raycastOptions.mask=r>>>0,this.raycastOptions.maxDistance=s,this.raycastOptions.queryTrigger=o,this.physicsWorld.sweepCapsuleClosest(t,e,i,n,this.raycastOptions,this.sweepCastClosestResult))},e._updateMaterial=function(){this.physicsWorld&&this.physicsWorld.setDefaultMaterial(this._material)},i.constructAndRegister=function(){var t;if((null===(t=Ee.querySettings(be.Category.PHYSICS,"enabled"))||void 0===t||t)&&!i._instance){var e=new i;i._instance=e,e.resetConfiguration(),function(t){if(Lrt||(Lrt=t),$rt.runInEditor&&!$rt.physicsWorld){F("[PHYSICS]: using "+$rt.id+".");var e=$rt.physicsWorld=nst();e.setGravity(Lrt.gravity),e.setAllowSleep(Lrt.allowSleep)}}(e),fN.registerSystem(i.ID,e,e.priority),SN.onPostProjectInitDelegate.add(e.initDefaultMaterial.bind(e))}},n(i,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this.physicsWorld&&this.physicsWorld.setAllowSleep(t)}},{key:"maxSubSteps",get:function(){return this._maxSubSteps},set:function(t){this._maxSubSteps=t}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(t){this._fixedTimeStep=t}},{key:"gravity",get:function(){return this._gravity},set:function(t){this._gravity.set(t),this.physicsWorld&&this.physicsWorld.setGravity(t)}},{key:"sleepThreshold",get:function(){return this._sleepThreshold},set:function(t){this._sleepThreshold=t}},{key:"autoSimulation",get:function(){return this._autoSimulation},set:function(t){this._autoSimulation=t}},{key:"defaultMaterial",get:function(){return this._material}},{key:"physicsWorld",get:function(){return $rt.physicsWorld}},{key:"debugDrawFlags",get:function(){return this.physicsWorld.debugDrawFlags},set:function(t){this.physicsWorld.debugDrawFlags=t}},{key:"debugDrawConstraintSize",get:function(){return this.physicsWorld.debugDrawConstraintSize},set:function(t){this.physicsWorld.debugDrawConstraintSize=t}}],[{key:"PHYSICS_NONE",get:function(){return!$rt.id}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===$rt.id}},{key:"PHYSICS_CANNON",get:function(){return"cannon.js"===$rt.id}},{key:"PHYSICS_BULLET",get:function(){return"bullet"===$rt.id}},{key:"PHYSICS_PHYSX",get:function(){return"physx"===$rt.id}},{key:"PhysicsGroup",get:function(){return Gtt}},{key:"instance",get:function(){return i._instance}}]),i}(Ou));lot.ID="PHYSICS",lot._instance=null,fN.once(dN.EVENT_INIT,(function(){lot.constructAndRegister()}));var cot,_ot,dot,fot,pot,mot,got,yot,vot,Sot,Tot,Aot=t("fm",(Yst=qs("cc.RigidBody"),Kst=Ks(-1),Jst=xo(lot.PhysicsGroup),Qst=xo(Dtt),Yst(Zst=Js(Zst=Kst(((uot=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._body=null,e._group=tot&&tot(),e._type=eot&&eot(),e._mass=iot&&iot(),e._allowSleep=not&&not(),e._linearDamping=rot&&rot(),e._angularDamping=sot&&sot(),e._useGravity=oot&&oot(),e._linearFactor=aot&&aot(),e._angularFactor=hot&&hot(),e}s(e,t);var i=e.prototype;return i.onLoad=function(){$rt.runInEditor&&(this._body=ist($rt.wrapper.RigidBody,Zrt.RigidBody)?rst:new $rt.wrapper.RigidBody,this._body.initialize(this))},i.onEnable=function(){this._body&&this._body.onEnable()},i.onDisable=function(){this._body&&this._body.onDisable()},i.onDestroy=function(){this._body&&this._body.onDestroy()},i.applyForce=function(t,e){this._isInitialized&&this._body.applyForce(t,e)},i.applyLocalForce=function(t,e){this._isInitialized&&this._body.applyLocalForce(t,e)},i.applyImpulse=function(t,e){this._isInitialized&&this._body.applyImpulse(t,e)},i.applyLocalImpulse=function(t,e){this._isInitialized&&this._body.applyLocalImpulse(t,e)},i.applyTorque=function(t){this._isInitialized&&this._body.applyTorque(t)},i.applyLocalTorque=function(t){this._isInitialized&&this._body.applyLocalTorque(t)},i.wakeUp=function(){this._isInitialized&&this._body.wakeUp()},i.sleep=function(){this._isInitialized&&this._body.sleep()},i.clearState=function(){this._isInitialized&&this._body.clearState()},i.clearForces=function(){this._isInitialized&&this._body.clearForces()},i.clearVelocity=function(){this._isInitialized&&this._body.clearVelocity()},i.getLinearVelocity=function(t){this._isInitialized&&this._body.getLinearVelocity(t)},i.setLinearVelocity=function(t){this._isInitialized&&this._body.setLinearVelocity(t)},i.getAngularVelocity=function(t){this._isInitialized&&this._body.getAngularVelocity(t)},i.setAngularVelocity=function(t){this._isInitialized&&this._body.setAngularVelocity(t)},i.getGroup=function(){return this._isInitialized?this._body.getGroup():0},i.setGroup=function(t){this._isInitialized&&this._body.setGroup(t)},i.addGroup=function(t){this._isInitialized&&this._body.addGroup(t)},i.removeGroup=function(t){this._isInitialized&&this._body.removeGroup(t)},i.getMask=function(){return this._isInitialized?this._body.getMask():0},i.setMask=function(t){this._isInitialized&&this._body.setMask(t)},i.addMask=function(t){this._isInitialized&&this._body.addMask(t)},i.removeMask=function(t){this._isInitialized&&this._body.removeMask(t)},n(e,[{key:"group",get:function(){return this._group},set:function(t){this._group=t,this._body&&this._body.getGroup()!==t&&this._body.setGroup(t)}},{key:"type",get:function(){return this._type},set:function(t){this._type!==t&&(this._type=t,this._body&&this._body.setType(t))}},{key:"mass",get:function(){return this._mass},set:function(t){this._mass!==t&&(t=t<=0?1e-4:t,this._mass=t,this._body&&this._body.setMass(t))}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this._body&&this._body.setAllowSleep(t)}},{key:"linearDamping",get:function(){return this._linearDamping},set:function(t){this._linearDamping=t,this._body&&this._body.setLinearDamping(t)}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(t){this._angularDamping=t,this._body&&this._body.setAngularDamping(t)}},{key:"useGravity",get:function(){return this._useGravity},set:function(t){this._useGravity=t,this._body&&this._body.useGravity(t)}},{key:"linearFactor",get:function(){return this._linearFactor},set:function(t){on.copy(this._linearFactor,t),this._body&&this._body.setLinearFactor(this._linearFactor)}},{key:"angularFactor",get:function(){return this._angularFactor},set:function(t){on.copy(this._angularFactor,t),this._body&&this._body.setAngularFactor(this._angularFactor)}},{key:"sleepThreshold",get:function(){return this._isInitialized?this._body.getSleepThreshold():.1},set:function(t){this._isInitialized&&this._body.setSleepThreshold(t)}},{key:"useCCD",get:function(){return!!this._isInitialized&&this._body.isUsingCCD()},set:function(t){this._isInitialized&&this._body.useCCD(t)}},{key:"isAwake",get:function(){return!!this._isInitialized&&this._body.isAwake}},{key:"isSleepy",get:function(){return!!this._isInitialized&&this._body.isSleepy}},{key:"isSleeping",get:function(){return!!this._isInitialized&&this._body.isSleeping}},{key:"isStatic",get:function(){return this._type===Dtt.STATIC},set:function(t){t&&this.isStatic||!t&&!this.isStatic||(this.type=t?Dtt.STATIC:Dtt.DYNAMIC)}},{key:"isDynamic",get:function(){return this._type===Dtt.DYNAMIC},set:function(t){t&&this.isDynamic||!t&&!this.isDynamic||(this.type=t?Dtt.DYNAMIC:Dtt.KINEMATIC)}},{key:"isKinematic",get:function(){return this._type===Dtt.KINEMATIC},set:function(t){t&&this.isKinematic||!t&&!this.isKinematic||(this.type=t?Dtt.KINEMATIC:Dtt.DYNAMIC)}},{key:"body",get:function(){return this._body}},{key:"_isInitialized",get:function(){var t=null===this._body;return t&&V("[Physics]: This component has not been call onLoad yet, please make sure the node has been added to the scene."),!t}}]),e}(rp)).Type=Dtt,p(($st=uot).prototype,"group",[Jst],Object.getOwnPropertyDescriptor($st.prototype,"group"),$st.prototype),p($st.prototype,"type",[Qst],Object.getOwnPropertyDescriptor($st.prototype,"type"),$st.prototype),tot=ks($st.prototype,"_group",[io],(function(){return lot.PhysicsGroup.DEFAULT})),eot=ks($st.prototype,"_type",[io],(function(){return Dtt.DYNAMIC})),iot=ks($st.prototype,"_mass",[io],(function(){return 1})),not=ks($st.prototype,"_allowSleep",[io],(function(){return!0})),rot=ks($st.prototype,"_linearDamping",[io],(function(){return.1})),sot=ks($st.prototype,"_angularDamping",[io],(function(){return.1})),oot=ks($st.prototype,"_useGravity",[io],(function(){return!0})),aot=ks($st.prototype,"_linearFactor",[io],(function(){return new on(1,1,1)})),hot=ks($st.prototype,"_angularFactor",[io],(function(){return new on(1,1,1)})),Zst=$st))||Zst)||Zst)||Zst));Aot||t("fm",Aot={});var bot,Eot,Cot,wot,xot,Rot=t("fs",(cot=qs("cc.Collider"),_ot=xo(Aot),dot=xo(jst),fot=xo(on),pot=xo(jst),cot(((Tot=function(t){function e(e){var i;return(i=t.call(this)||this).type=void 0,i._shape=null,i._aabb=null,i._boundingSphere=null,i._isSharedMaterial=!0,i._needTriggerEvent=!1,i._needCollisionEvent=!1,i._material=yot&&yot(),i._isTrigger=vot&&vot(),i._center=Sot&&Sot(),i.type=e,i}s(e,t);var i=e.prototype;return i.on=function(e,i,n,r){var s=t.prototype.on.call(this,e,i,n,r);return this._updateNeedEvent(e),s},i.off=function(e,i,n){t.prototype.off.call(this,e,i,n),this._updateNeedEvent()},i.once=function(e,i,n){var r=t.prototype.once.call(this,e,i,n);return this._updateNeedEvent(e),r},i.removeAll=function(e){t.prototype.removeAll.call(this,e),this._updateNeedEvent()},i.getGroup=function(){return this._isInitialized?this._shape.getGroup():0},i.setGroup=function(t){this._isInitialized&&this._shape.setGroup(t)},i.addGroup=function(t){this._isInitialized&&this._shape.addGroup(t)},i.removeGroup=function(t){this._isInitialized&&this._shape.removeGroup(t)},i.getMask=function(){return this._isInitialized?this._shape.getMask():0},i.setMask=function(t){this._isInitialized&&this._shape.setMask(t)},i.addMask=function(t){this._isInitialized&&this._shape.addMask(t)},i.removeMask=function(t){this._isInitialized&&this._shape.removeMask(t)},i.onLoad=function(){$rt.runInEditor&&(this.sharedMaterial=this._material,this._shape=function(t){return sst.INITED||(sst.INITED=!0,sst[Ltt.BOX]=function(){return ist($rt.wrapper.BoxShape,Zrt.BoxCollider)?ost:new $rt.wrapper.BoxShape},sst[Ltt.SPHERE]=function(){return ist($rt.wrapper.SphereShape,Zrt.SphereCollider)?ost:new $rt.wrapper.SphereShape},sst[Ltt.CAPSULE]=function(){return ist($rt.wrapper.CapsuleShape,Zrt.CapsuleCollider)?ost:new $rt.wrapper.CapsuleShape},sst[Ltt.CYLINDER]=function(){return ist($rt.wrapper.CylinderShape,Zrt.CylinderCollider)?ost:new $rt.wrapper.CylinderShape},sst[Ltt.CONE]=function(){return ist($rt.wrapper.ConeShape,Zrt.ConeCollider)?ost:new $rt.wrapper.ConeShape},sst[Ltt.MESH]=function(){return ist($rt.wrapper.TrimeshShape,Zrt.MeshCollider)?ost:new $rt.wrapper.TrimeshShape},sst[Ltt.TERRAIN]=function(){return ist($rt.wrapper.TerrainShape,Zrt.TerrainCollider)?ost:new $rt.wrapper.TerrainShape},sst[Ltt.SIMPLEX]=function(){return ist($rt.wrapper.SimplexShape,Zrt.SimplexCollider)?ost:new $rt.wrapper.SimplexShape},sst[Ltt.PLANE]=function(){return ist($rt.wrapper.PlaneShape,Zrt.PlaneCollider)?ost:new $rt.wrapper.PlaneShape}),sst[t]()}(this.type),this._shape.initialize(this),this._shape.onLoad())},i.onEnable=function(){this._shape&&this._shape.onEnable()},i.onDisable=function(){this._shape&&this._shape.onDisable()},i.onDestroy=function(){this._shape&&(this._needTriggerEvent=!1,this._needCollisionEvent=!1,this._shape.updateEventListener(),this._material&&this._material.off(jst.EVENT_UPDATE,this._updateMaterial,this),this._shape.onDestroy()),this._boundingSphere&&this._boundingSphere.destroy()},i._updateMaterial=function(){this._shape&&this._shape.setMaterial(this._material)},i._updateNeedEvent=function(t){this.isValid&&(void 0!==t?("onCollisionEnter"!==t&&"onCollisionStay"!==t&&"onCollisionExit"!==t||(this._needCollisionEvent=!0),"onTriggerEnter"!==t&&"onTriggerStay"!==t&&"onTriggerExit"!==t&&"onControllerTriggerEnter"!==t&&"onControllerTriggerStay"!==t&&"onControllerTriggerExit"!==t||(this._needTriggerEvent=!0)):(this.hasEventListener("onTriggerEnter")||this.hasEventListener("onTriggerStay")||this.hasEventListener("onTriggerExit")||this.hasEventListener("onControllerTriggerEnter")||this.hasEventListener("onControllerTriggerStay")||this.hasEventListener("onControllerTriggerExit")||(this._needTriggerEvent=!1),this.hasEventListener("onCollisionEnter")||this.hasEventListener("onCollisionStay")||this.hasEventListener("onCollisionExit")||(this._needCollisionEvent=!1)),this._shape&&this._shape.updateEventListener())},n(e,[{key:"attachedRigidBody",get:function(){return t=this.node,(e=t.getComponent(Aot))&&e.isValid?e:null;var t,e}},{key:"sharedMaterial",get:function(){return this._material},set:function(t){this.material=t}},{key:"material",get:function(){return this._isSharedMaterial&&this._material&&(this._material.off(jst.EVENT_UPDATE,this._updateMaterial,this),this._material=this._material.clone(),this._material.on(jst.EVENT_UPDATE,this._updateMaterial,this),this._isSharedMaterial=!1),this._material},set:function(t){this._shape?(t&&this._material?this._material.id!==t.id&&(this._material.off(jst.EVENT_UPDATE,this._updateMaterial,this),t.on(jst.EVENT_UPDATE,this._updateMaterial,this),this._isSharedMaterial=!1,this._material=t):t&&!this._material?(t.on(jst.EVENT_UPDATE,this._updateMaterial,this),this._material=t):!t&&this._material&&(this._material.off(jst.EVENT_UPDATE,this._updateMaterial,this),this._material=t),this._updateMaterial()):this._material=t}},{key:"isTrigger",get:function(){return this._isTrigger},set:function(t){this._isTrigger=t,this._shape&&this._shape.setAsTrigger(this._isTrigger)}},{key:"center",get:function(){return this._center},set:function(t){on.copy(this._center,t),this._shape&&this._shape.setCenter(this._center)}},{key:"shape",get:function(){return this._shape}},{key:"worldBounds",get:function(){return null==this._aabb&&(this._aabb=new Ss),this._shape&&this._shape.getAABB(this._aabb),this._aabb}},{key:"boundingSphere",get:function(){return null==this._boundingSphere&&(this._boundingSphere=new gr),this._shape&&this._shape.getBoundingSphere(this._boundingSphere),this._boundingSphere}},{key:"needTriggerEvent",get:function(){return this._needTriggerEvent}},{key:"needCollisionEvent",get:function(){return this._needCollisionEvent}},{key:"_isInitialized",get:function(){var t=null===this._shape;return t&&V("[Physics]: This component has not been call onLoad yet, please make sure the node has been added to the scene."),!t}}]),e}(Yu(rp))).Type=Ltt,Tot.Axis=Ptt,p((got=Tot).prototype,"attachedRigidBody",[_ot],Object.getOwnPropertyDescriptor(got.prototype,"attachedRigidBody"),got.prototype),p(got.prototype,"sharedMaterial",[dot],Object.getOwnPropertyDescriptor(got.prototype,"sharedMaterial"),got.prototype),p(got.prototype,"center",[fot],Object.getOwnPropertyDescriptor(got.prototype,"center"),got.prototype),yot=ks(got.prototype,"_material",[pot],(function(){return null})),vot=ks(got.prototype,"_isTrigger",[io],(function(){return!1})),Sot=ks(got.prototype,"_center",[io],(function(){return new on})),mot=got))||mot));Rot||t("fs",Rot={});var Iot,Bot,Dot,Pot,Oot,Mot,Lot,Not,Fot,kot,Vot,Got,Uot,zot,Hot,Wot,jot,Xot,qot,Yot,Kot,Jot,Qot,Zot,$ot,tat,eat,iat,nat,rat,sat,oat,aat,hat,uat,lat,cat,_at,dat,fat,pat,mat,gat,yat,vat,Sat,Tat,Aat=t("ft",(bot=qs("cc.BoxCollider"),Eot=xo(on),bot((p((wot=function(t){function e(){var e;return(e=t.call(this,Ltt.BOX)||this)._size=xot&&xot(),e}return s(e,t),n(e,[{key:"size",get:function(){return this._size},set:function(t){on.strictEquals(this._size,t)||(on.copy(this._size,t),H$(this._size),this._shape&&this.shape.updateSize())}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"size",[Eot],Object.getOwnPropertyDescriptor(wot.prototype,"size"),wot.prototype),xot=ks(wot.prototype,"_size",[io],(function(){return new on(1,1,1)})),Cot=wot))||Cot)),bat=t("fu",qs("cc.SphereCollider")((Bot=function(t){function e(){var e;return(e=t.call(this,Ltt.SPHERE)||this)._radius=Dot&&Dot(),e}return s(e,t),n(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.updateRadius())}},{key:"shape",get:function(){return this._shape}}]),e}(Rot),Dot=ks(Bot.prototype,"_radius",[io],(function(){return.5})),Iot=Bot))||Iot),Eat=t("fv",(Pot=qs("cc.CapsuleCollider"),Oot=xo(Ptt),Pot((p((Lot=function(t){function e(){var e;return(e=t.call(this,Ltt.CAPSULE)||this)._radius=Not&&Not(),e._cylinderHeight=Fot&&Fot(),e._direction=kot&&kot(),e}s(e,t);var i=e.prototype;return i._getRadiusScale=function(){if(null==this.node)return 1;var t=this.node.worldScale;return this._direction===Ptt.Y_AXIS?Math.abs(Wi(t.x,t.z)):this._direction===Ptt.X_AXIS?Math.abs(Wi(t.y,t.z)):Math.abs(Wi(t.x,t.y))},i._getHeightScale=function(){if(null==this.node)return 1;var t=this.node.worldScale;return this._direction===Ptt.Y_AXIS?Math.abs(t.y):this._direction===Ptt.X_AXIS?Math.abs(t.x):Math.abs(t.z)},n(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"cylinderHeight",get:function(){return this._cylinderHeight},set:function(t){this._cylinderHeight!==t&&(this._cylinderHeight=Math.abs(t),this._shape&&this.shape.setCylinderHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){(t=Math.floor(t))<Ptt.X_AXIS||t>Ptt.Z_AXIS||this._direction!==t&&(this._direction=t,this._shape&&this.shape.setDirection(t))}},{key:"height",get:function(){return 2*this._radius+this._cylinderHeight},set:function(t){var e=t-2*this._radius;e<0&&(e=0),this.cylinderHeight=e}},{key:"worldHeight",get:function(){return 2*this._radius*this._getRadiusScale()+this._cylinderHeight*this._getHeightScale()}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"direction",[Oot],Object.getOwnPropertyDescriptor(Lot.prototype,"direction"),Lot.prototype),Not=ks(Lot.prototype,"_radius",[io],(function(){return.5})),Fot=ks(Lot.prototype,"_cylinderHeight",[io],(function(){return 1})),kot=ks(Lot.prototype,"_direction",[io],(function(){return Ptt.Y_AXIS})),Mot=Lot))||Mot)),Cat=t("fx",(Vot=qs("cc.CylinderCollider"),Got=xo(Ptt),Vot((p((zot=function(t){function e(){var e;return(e=t.call(this,Ltt.CYLINDER)||this)._radius=Hot&&Hot(),e._height=Wot&&Wot(),e._direction=jot&&jot(),e}return s(e,t),n(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(this._height=Math.abs(t),this._shape&&this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<Ptt.X_AXIS||t>Ptt.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"direction",[Got],Object.getOwnPropertyDescriptor(zot.prototype,"direction"),zot.prototype),Hot=ks(zot.prototype,"_radius",[io],(function(){return.5})),Wot=ks(zot.prototype,"_height",[io],(function(){return 2})),jot=ks(zot.prototype,"_direction",[io],(function(){return Ptt.Y_AXIS})),Uot=zot))||Uot)),wat=t("fy",(Xot=qs("cc.ConeCollider"),qot=xo(Ptt),Xot((p((Kot=function(t){function e(){var e;return(e=t.call(this,Ltt.CONE)||this)._radius=Jot&&Jot(),e._height=Qot&&Qot(),e._direction=Zot&&Zot(),e}return s(e,t),n(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(t<0&&(t=0),this._height=t,this._shape&&this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<Ptt.X_AXIS||t>Ptt.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"direction",[qot],Object.getOwnPropertyDescriptor(Kot.prototype,"direction"),Kot.prototype),Jot=ks(Kot.prototype,"_radius",[io],(function(){return.5})),Qot=ks(Kot.prototype,"_height",[io],(function(){return 1})),Zot=ks(Kot.prototype,"_direction",[io],(function(){return Ptt.Y_AXIS})),Yot=Kot))||Yot)),xat=t("fw",($ot=qs("cc.MeshCollider"),tat=xo(XN),$ot((p((iat=function(t){function e(){var e;return(e=t.call(this,Ltt.MESH)||this)._mesh=nat&&nat(),e._convex=rat&&rat(),e}return s(e,t),e.prototype.onEnable=function(){if(t.prototype.onEnable.call(this),this.node){var e=this.node.getComponent(Aot);e&&e.isValid&&e.type===Dtt.DYNAMIC&&!this.convex&&Y(9630,this.node.name)}},n(e,[{key:"mesh",get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh=t,this._shape&&this.shape.setMesh(this._mesh))}},{key:"convex",get:function(){return this._convex},set:function(t){this._convex!==t&&(this._convex=t,this._shape&&this._mesh&&this.shape.setMesh(this._mesh))}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"mesh",[tat],Object.getOwnPropertyDescriptor(iat.prototype,"mesh"),iat.prototype),nat=ks(iat.prototype,"_mesh",[io],(function(){return null})),rat=ks(iat.prototype,"_convex",[io],(function(){return!1})),eat=iat))||eat)),Rat=t("fo",qs("cc.ConstantForce")(sat=Ys(Aot)(sat=Js((oat=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._rigidBody=null,e._force=aat&&aat(),e._localForce=hat&&hat(),e._torque=uat&&uat(),e._localTorque=lat&&lat(),e._mask=0,e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._rigidBody=this.node.getComponent(Aot),this._maskUpdate(this._force,1),this._maskUpdate(this._localForce,2),this._maskUpdate(this._torque,4),this._maskUpdate(this._localTorque,8)},i.lateUpdate=function(){null!=this._rigidBody&&0!==this._mask&&(1&this._mask&&this._rigidBody.applyForce(this._force),2&this._mask&&this._rigidBody.applyLocalForce(this.localForce),4&this._mask&&this._rigidBody.applyTorque(this._torque),8&this._mask&&this._rigidBody.applyLocalTorque(this._localTorque))},i._maskUpdate=function(t,e){t.strictEquals(on.ZERO)?this._mask&=~e:this._mask|=e},n(e,[{key:"force",get:function(){return this._force},set:function(t){on.copy(this._force,t),this._maskUpdate(this._force,1)}},{key:"localForce",get:function(){return this._localForce},set:function(t){on.copy(this._localForce,t),this._maskUpdate(this.localForce,2)}},{key:"torque",get:function(){return this._torque},set:function(t){on.copy(this._torque,t),this._maskUpdate(this._torque,4)}},{key:"localTorque",get:function(){return this._localTorque},set:function(t){on.copy(this._localTorque,t),this._maskUpdate(this._localTorque,8)}}]),e}(rp),aat=ks(oat.prototype,"_force",[io],(function(){return new on})),hat=ks(oat.prototype,"_localForce",[io],(function(){return new on})),uat=ks(oat.prototype,"_torque",[io],(function(){return new on})),lat=ks(oat.prototype,"_localTorque",[io],(function(){return new on})),sat=oat))||sat)||sat)||sat),Iat=32768,Bat=1/128,Dat=16842754,Pat=16842755,Oat=16842756,Mat=16842758,Lat=16842759,Nat=16842760,Fat=16843025,kat=function(){function t(){this.length=0,this.buffer=new Uint8Array(2048),this._buffView=new DataView(this.buffer.buffer),this._seekPos=0}var e=t.prototype;return e.reserve=function(t){if(!(this.buffer.byteLength>t)){for(var e=this.buffer.byteLength;e<t;)e+=e;for(var i=new Uint8Array(e),n=0;n<this.length;++n)i[n]=this.buffer[n];this.buffer=i,this._buffView=new DataView(this.buffer.buffer)}},e.assign=function(t){this.buffer=t,this.length=t.length,this._seekPos=t.byteOffset,this._buffView=new DataView(t.buffer)},e.writeInt8=function(t){this.reserve(this.length+1),this._buffView.setInt8(this.length,t),this.length+=1},e.writeInt16=function(t){this.reserve(this.length+2),this._buffView.setInt16(this.length,t,!0),this.length+=2},e.writeInt32=function(t){this.reserve(this.length+4),this._buffView.setInt32(this.length,t,!0),this.length+=4},e.writeIntArray=function(t){this.reserve(this.length+4*t.length);for(var e=0;e<t.length;++e)this._buffView.setInt32(this.length+4*e,t[e],!0);this.length+=4*t.length},e.writeFloat=function(t){this.reserve(this.length+4),this._buffView.setFloat32(this.length,t,!0),this.length+=4},e.writeFloatArray=function(t){this.reserve(this.length+4*t.length);for(var e=0;e<t.length;++e)this._buffView.setFloat32(this.length+4*e,t[e],!0);this.length+=4*t.length},e.writeDouble=function(t){this.reserve(this.length+8),this._buffView.setFloat64(this.length,t,!0),this.length+=8},e.writeDoubleArray=function(t){this.reserve(this.length+8*t.length);for(var e=0;e<t.length;++e)this._buffView.setFloat64(this.length+8*e,t[e],!0);this.length+=8*t.length},e.writeString=function(t){this.reserve(this.length+t.length+4),this._buffView.setInt32(this.length,t.length,!0);for(var e=0;e<t.length;++e)this._buffView.setInt8(this.length+4+e,t.charCodeAt(e));this.length+=t.length+4},e.readInt8=function(){var t=this._buffView.getInt8(this._seekPos);return this._seekPos+=1,t},e.readInt16=function(){var t=this._buffView.getInt16(this._seekPos,!0);return this._seekPos+=2,t},e.readInt=function(){var t=this._buffView.getInt32(this._seekPos,!0);return this._seekPos+=4,t},e.readIntArray=function(t){for(var e=0;e<t.length;++e)t[e]=this._buffView.getInt32(this._seekPos+4*e,!0);return this._seekPos+=4*t.length,t},e.readFloat=function(){var t=this._buffView.getFloat32(this._seekPos,!0);return this._seekPos+=4,t},e.readFloatArray=function(t){for(var e=0;e<t.length;++e)t[e]=this._buffView.getFloat32(this._seekPos+4*e,!0);return this._seekPos+=4*t.length,t},e.readDouble=function(){var t=this._buffView.getFloat64(this._seekPos,!0);return this._seekPos+=8,t},e.readDoubleArray=function(t){for(var e=0;e<t.length;++e)t[e]=this._buffView.getFloat64(this._seekPos+4*e,!0);return this._seekPos+=8*t.length,t},e.readString=function(){for(var t=this.readInt(),e="",i=0;i<t;++i)e+=String.fromCharCode(this.readInt8());return e},t}();qs("cc.TerrainLayerInfo")((cat=function(){this.slot=_at&&_at(),this.tileSize=dat&&dat(),this.detailMap=fat&&fat(),this.normalMap=pat&&pat(),this.roughness=mat&&mat(),this.metallic=gat&&gat()},_at=ks(cat.prototype,"slot",[io],(function(){return 0})),dat=ks(cat.prototype,"tileSize",[io],(function(){return 1})),fat=ks(cat.prototype,"detailMap",[io],(function(){return null})),pat=ks(cat.prototype,"normalMap",[io],(function(){return null})),mat=ks(cat.prototype,"roughness",[io],(function(){return 1})),gat=ks(cat.prototype,"metallic",[io],(function(){return 0})),cat));var Vat,Gat,Uat,zat,Hat,Wat,jat,Xat,qat,Yat,Kat,Jat,Qat,Zat,$at,tht,eht,iht,nht=qs("cc.TerrainLayerBinaryInfo")(yat=function(){this.slot=0,this.tileSize=1,this.roughness=1,this.metallic=0,this.detailMapId="",this.normalMapId=""})||yat,rht=qs("cc.TerrainAsset")((Sat=function(t){function e(){var e;return(e=t.call(this)||this)._version=0,e._data=null,e._tileSize=1,e._blockCount=[1,1],e._weightMapSize=128,e._lightMapSize=128,e._heights=new Uint16Array,e._normals=new Float32Array,e._weights=new Uint8Array,e._layerBuffer=[-1,-1,-1,-1],e._layerBinaryInfos=[],e._layerInfos=Tat&&Tat(),e}s(e,t);var i=e.prototype;return i.getLayer=function(t,e,i){var n=4*(e*this.blockCount[0]+t)+i;return t<this.blockCount[0]&&e<this.blockCount[1]&&n<this._layerBuffer.length?this._layerBuffer[n]:-1},i.getHeight=function(t,e){var i=32*this._blockCount[0]+1;return(this._heights[e*i+t]-Iat)*Bat},i.getVertexCountI=function(){return this._blockCount.length<1?0:32*this._blockCount[0]+1},i.getVertexCountJ=function(){return this._blockCount.length<2?0:32*this._blockCount[1]+1},i._setNativeData=function(t){this._data=t},i._loadNativeData=function(t){if(!t||0===t.length)return!1;var e=new kat;if(e.assign(t),this._version=e.readInt(),this._version===Fat)return!0;if(16842753!==this._version&&this._version!==Dat&&this._version!==Pat&&this._version!==Oat&&16842757!==this._version&&this._version!==Mat&&this._version!==Lat&&this._version!==Nat)return!1;this._version>=Lat?this.tileSize=e.readDouble():this.tileSize=e.readFloat(),this.tileSize=Math.floor(100*this.tileSize)/100,e.readIntArray(this._blockCount),this.weightMapSize=e.readInt16(),this.lightMapSize=e.readInt16();var i=e.readInt();this.heights=new Uint16Array(i);for(var n=0;n<this.heights.length;++n)this.heights[n]=e.readInt16();if(this._version<Nat)for(var r=0;r<this.heights.length;++r){var s=.001953125*(this._heights[r]-Iat),o=Iat+s/Bat;this.heights[r]=o}if(this._version>=Mat){var a=e.readInt();this.normals=new Float32Array(a);for(var h=0;h<this.normals.length;++h)this.normals[h]=e.readFloat()}var u=e.readInt();this.weights=new Uint8Array(u);for(var l=0;l<this.weights.length;++l)this.weights[l]=e.readInt8();if(this._version>=Dat){var c=e.readInt();this.layerBuffer=new Array(c);for(var _=0;_<this.layerBuffer.length;++_)this.layerBuffer[_]=e.readInt16()}if(this._version>=Pat){var d=e.readInt();this._layerBinaryInfos=new Array(d);for(var f=0;f<this._layerBinaryInfos.length;++f)this._layerBinaryInfos[f]=new nht,this._layerBinaryInfos[f].slot=e.readInt(),this._version>=Lat?this._layerBinaryInfos[f].tileSize=e.readDouble():this._layerBinaryInfos[f].tileSize=e.readFloat(),this._layerBinaryInfos[f].detailMapId=e.readString(),this._version>=Oat&&(this._layerBinaryInfos[f].normalMapId=e.readString(),this._version>=Lat?(this._layerBinaryInfos[f].roughness=e.readDouble(),this._layerBinaryInfos[f].metallic=e.readDouble()):(this._layerBinaryInfos[f].roughness=e.readFloat(),this._layerBinaryInfos[f].metallic=e.readFloat()))}return!0},i._exportNativeData=function(){var t=new kat;t.writeInt32(Nat),t.writeDouble(this.tileSize),t.writeIntArray(this._blockCount),t.writeInt16(this.weightMapSize),t.writeInt16(this.lightMapSize),t.writeInt32(this.heights.length);for(var e=0;e<this.heights.length;++e)t.writeInt16(this.heights[e]);t.writeInt32(this.normals.length);for(var i=0;i<this.normals.length;++i)t.writeFloat(this.normals[i]);t.writeInt32(this.weights.length);for(var n=0;n<this.weights.length;++n)t.writeInt8(this.weights[n]);t.writeInt32(this.layerBuffer.length);for(var r=0;r<this.layerBuffer.length;++r)t.writeInt16(this.layerBuffer[r]);var s=[];s.length=this.layerInfos.length;for(var o=0;o<s.length;++o){var a=this.layerInfos[o],h=new nht;h.slot=o,h.tileSize=a.tileSize,h.detailMapId=a.detailMap?a.detailMap._uuid:"",h.normalMapId=a.normalMap?a.normalMap._uuid:"",h.metallic=a.metallic,h.roughness=a.roughness,s[o]=h}t.writeInt32(s.length);for(var u=0;u<s.length;++u)t.writeInt32(s[u].slot),t.writeDouble(s[u].tileSize),t.writeString(s[u].detailMapId),t.writeString(s[u].normalMapId),t.writeDouble(s[u].roughness),t.writeDouble(s[u].metallic);return t.buffer},i._exportDefaultNativeData=function(){var t=new kat;return t.writeInt32(Fat),t.buffer},n(e,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(t){this._data&&this._data.byteLength===t.byteLength?this._data.set(new Uint8Array(t)):this._data=new Uint8Array(t),this._loadNativeData(this._data)}},{key:"version",get:function(){return this._version}},{key:"tileSize",get:function(){return this._tileSize},set:function(t){this._tileSize=t}},{key:"blockCount",get:function(){return this._blockCount},set:function(t){this._blockCount=t}},{key:"lightMapSize",get:function(){return this._lightMapSize},set:function(t){this._lightMapSize=t}},{key:"weightMapSize",get:function(){return this._weightMapSize},set:function(t){this._weightMapSize=t}},{key:"heights",get:function(){return this._heights},set:function(t){this._heights=t}},{key:"normals",get:function(){return this._normals},set:function(t){this._normals=t}},{key:"weights",get:function(){return this._weights},set:function(t){this._weights=t}},{key:"layerBuffer",get:function(){return this._layerBuffer},set:function(t){this._layerBuffer=t}},{key:"layerInfos",get:function(){return this._layerInfos},set:function(t){this._layerInfos=t}},{key:"layerBinaryInfos",get:function(){return this._layerBinaryInfos}}]),e}(of),Tat=ks(Sat.prototype,"_layerInfos",[io],(function(){return[]})),vat=Sat))||vat,sht=t("fz",(Vat=qs("cc.TerrainCollider"),Gat=xo(rht),Vat((p((zat=function(t){function e(){var e;return(e=t.call(this,Ltt.TERRAIN)||this)._terrain=Hat&&Hat(),e}return s(e,t),e.prototype.onEnable=function(){if(t.prototype.onEnable.call(this),this.node){var e=this.node.getComponent(Aot);e&&e.isValid&&e.type===Dtt.DYNAMIC&&Y(9630,this.node.name)}},n(e,[{key:"terrain",get:function(){return this._terrain},set:function(t){this._terrain=t,this._shape&&this.shape.setTerrain(this._terrain)}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"terrain",[Gat],Object.getOwnPropertyDescriptor(zat.prototype,"terrain"),zat.prototype),Hat=ks(zat.prototype,"_terrain",[io],(function(){return null})),Uat=zat))||Uat)),oht=t("fA",(Wat=qs("cc.SimplexCollider"),jat=xo(Mtt),Wat(((Jat=function(t){function e(){var e;return(e=t.call(this,Ltt.SIMPLEX)||this)._shapeType=Yat&&Yat(),e._vertices=Kat&&Kat(),e}return s(e,t),e.prototype.updateVertices=function(){this._shape&&this.shape.setVertices(this._vertices)},n(e,[{key:"shapeType",get:function(){return this._shapeType},set:function(t){this._shapeType=t,this._shape&&this.shape.setShapeType(t)}},{key:"vertex0",get:function(){return this._vertices[0]},set:function(t){on.copy(this._vertices[0],t),this.updateVertices()}},{key:"vertex1",get:function(){return this._vertices[1]},set:function(t){on.copy(this._vertices[1],t),this.updateVertices()}},{key:"vertex2",get:function(){return this._vertices[2]},set:function(t){on.copy(this._vertices[2],t),this.updateVertices()}},{key:"vertex3",get:function(){return this._vertices[3]},set:function(t){on.copy(this._vertices[3],t),this.updateVertices()}},{key:"shape",get:function(){return this._shape}},{key:"vertices",get:function(){return this._vertices}}]),e}(Rot)).ESimplexType=Mtt,p((qat=Jat).prototype,"shapeType",[jat],Object.getOwnPropertyDescriptor(qat.prototype,"shapeType"),qat.prototype),Yat=ks(qat.prototype,"_shapeType",[io],(function(){return Mtt.TETRAHEDRON})),Kat=ks(qat.prototype,"_vertices",[io],(function(){return[new on(0,0,0),new on(0,0,1),new on(1,0,0),new on(0,1,0)]})),Xat=qat))||Xat));oht||t("fA",oht={});var aht,hht,uht,lht,cht,_ht,dht,fht,pht,mht,ght,yht,vht,Sht,Tht,Aht,bht,Eht,Cht,wht,xht,Rht,Iht,Bht,Dht,Pht,Oht,Mht,Lht,Nht,Fht,kht,Vht,Ght,Uht,zht,Hht,Wht,jht,Xht,qht,Yht,Kht,Jht,Qht,Zht,$ht,tut,eut,iut,nut,rut,sut,out,aut,hut,uut=t("fB",(Qat=qs("cc.PlaneCollider"),Zat=xo(on),Qat((p((tht=function(t){function e(){var e;return(e=t.call(this,Ltt.PLANE)||this)._normal=eht&&eht(),e._constant=iht&&iht(),e}return s(e,t),e.prototype.onEnable=function(){if(t.prototype.onEnable.call(this),this.node){var e=this.node.getComponent(Aot);e&&e.isValid&&e.type===Dtt.DYNAMIC&&Y(9630,this.node.name)}},n(e,[{key:"normal",get:function(){return this._normal},set:function(t){on.strictEquals(this._normal,t)||(on.copy(this._normal,t),this._shape&&this.shape.setNormal(this._normal))}},{key:"constant",get:function(){return this._constant},set:function(t){this._constant!==t&&(this._constant=t,this._shape&&this.shape.setConstant(this._constant))}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"normal",[Zat],Object.getOwnPropertyDescriptor(tht.prototype,"normal"),tht.prototype),eht=ks(tht.prototype,"_normal",[io],(function(){return new on(0,1,0)})),iht=ks(tht.prototype,"_constant",[io],(function(){return 0})),$at=tht))||$at)),lut=t("fC",(aht=qs("cc.Constraint"),hht=Ys(Aot),uht=xo(Aot),lht=xo(Aot),cht=xo(Aot),aht(_ht=hht(((mht=function(t){function e(e){var i;return(i=t.call(this)||this).TYPE=void 0,i._enableCollision=fht&&fht(),i._connectedBody=pht&&pht(),i._constraint=null,i.TYPE=e,i}s(e,t);var i=e.prototype;return i.onLoad=function(){$rt.runInEditor&&(this._constraint=function(t){return ast.INITED||(ast.INITED=!0,ast[Ntt.POINT_TO_POINT]=function(){return ist($rt.wrapper.PointToPointConstraint,Zrt.PointToPointConstraint)?hst:new $rt.wrapper.PointToPointConstraint},ast[Ntt.HINGE]=function(){return ist($rt.wrapper.HingeConstraint,Zrt.HingeConstraint)?hst:new $rt.wrapper.HingeConstraint},ast[Ntt.FIXED]=function(){return ist($rt.wrapper.FixedConstraint,Zrt.FixedConstraint)?hst:new $rt.wrapper.FixedConstraint},ast[Ntt.CONFIGURABLE]=function(){return ist($rt.wrapper.ConfigurableConstraint,Zrt.ConfigurableConstraint)?hst:new $rt.wrapper.ConfigurableConstraint}),ast[t]()}(this.TYPE),this._constraint.initialize(this))},i.onEnable=function(){this._constraint&&this._constraint.onEnable()},i.onDisable=function(){this._constraint&&this._constraint.onDisable()},i.onDestroy=function(){this._constraint&&this._constraint.onDestroy()},n(e,[{key:"attachedBody",get:function(){return this.getComponent(Aot)}},{key:"connectedBody",get:function(){return this._connectedBody},set:function(t){this._connectedBody=t,this._constraint&&this._constraint.setConnectedBody(t)}},{key:"enableCollision",get:function(){return this._enableCollision},set:function(t){this._enableCollision=t,this._constraint&&this._constraint.setEnableCollision(t)}}]),e}(Yu(rp))).Type=Ntt,p((dht=mht).prototype,"attachedBody",[uht],Object.getOwnPropertyDescriptor(dht.prototype,"attachedBody"),dht.prototype),p(dht.prototype,"connectedBody",[lht],Object.getOwnPropertyDescriptor(dht.prototype,"connectedBody"),dht.prototype),fht=ks(dht.prototype,"_enableCollision",[io],(function(){return!0})),pht=ks(dht.prototype,"_connectedBody",[cht],(function(){return null})),_ht=dht))||_ht)||_ht));lut||t("fC",lut={});var cut,_ut,dut,fut,put,mut,gut,yut,vut,Sut,Tut,Aut,but,Eut,Cut,wut,xut,Rut,Iut,But,Dut,Put,Out,Mut,Lut,Nut,Fut,kut,Vut,Gut,Uut,zut,Hut,Wut,jut,Xut,qut,Yut,Kut,Jut,Qut,Zut,$ut,tlt,elt,ilt,nlt,rlt,slt,olt,alt,hlt,ult,llt,clt,_lt,dlt,flt,plt,mlt,glt,ylt,vlt,Slt,Tlt,Alt,blt,Elt,Clt,wlt,xlt,Rlt,Ilt,Blt,Dlt,Plt,Olt,Mlt,Llt,Nlt,Flt,klt,Vlt,Glt,Ult,zlt,Hlt,Wlt,jlt,Xlt,qlt,Ylt,Klt,Jlt,Qlt,Zlt,$lt,tct,ect,ict,nct,rct,sct,oct,act,hct,uct,lct,cct,_ct,dct,fct,pct,mct,gct,yct,vct,Sct,Tct,Act,bct,Ect,Cct,wct,xct,Rct,Ict,Bct,Dct,Pct,Oct,Mct,Lct,Nct,Fct,kct,Vct,Gct,Uct,zct,Hct,Wct,jct=(ght=qs("cc.HingeLimitData"),yht=no("enabled"),vht=no("upperLimit"),Sht=no("lowerLimit"),Tht=xo(Ke),Aht=xo(Ye),bht=xo(Ye),ght((Cht=function(){function t(){this._enabled=wht&&wht(),this._upperLimit=xht&&xht(),this._lowerLimit=Rht&&Rht()}return n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"upperLimit",get:function(){return this._upperLimit},set:function(t){this._upperLimit=t}},{key:"lowerLimit",get:function(){return this._lowerLimit},set:function(t){this._lowerLimit=t}}]),t}(),wht=ks(Cht.prototype,"_enabled",[io,yht],(function(){return!1})),xht=ks(Cht.prototype,"_upperLimit",[io,vht],(function(){return Number.MAX_VALUE})),Rht=ks(Cht.prototype,"_lowerLimit",[io,Sht],(function(){return-Number.MAX_VALUE})),p(Cht.prototype,"enabled",[Tht],Object.getOwnPropertyDescriptor(Cht.prototype,"enabled"),Cht.prototype),p(Cht.prototype,"upperLimit",[Aht],Object.getOwnPropertyDescriptor(Cht.prototype,"upperLimit"),Cht.prototype),p(Cht.prototype,"lowerLimit",[bht],Object.getOwnPropertyDescriptor(Cht.prototype,"lowerLimit"),Cht.prototype),Eht=Cht))||Eht),Xct=(Iht=qs("cc.HingeMotorData"),Bht=no("enabled"),Dht=no("motorVelocity"),Pht=no("motorForceLimit"),Oht=xo(Ke),Mht=xo(Ye),Lht=xo(Ye),Iht((Fht=function(){function t(){this._enabled=kht&&kht(),this._motorVelocity=Vht&&Vht(),this._motorForceLimit=Ght&&Ght()}return n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"motorVelocity",get:function(){return this._motorVelocity},set:function(t){this._motorVelocity=t}},{key:"motorForceLimit",get:function(){return this._motorForceLimit},set:function(t){this._motorForceLimit=t}}]),t}(),kht=ks(Fht.prototype,"_enabled",[io,Bht],(function(){return!1})),Vht=ks(Fht.prototype,"_motorVelocity",[io,Dht],(function(){return 0})),Ght=ks(Fht.prototype,"_motorForceLimit",[io,Pht],(function(){return 0})),p(Fht.prototype,"enabled",[Oht],Object.getOwnPropertyDescriptor(Fht.prototype,"enabled"),Fht.prototype),p(Fht.prototype,"motorVelocity",[Mht],Object.getOwnPropertyDescriptor(Fht.prototype,"motorVelocity"),Fht.prototype),p(Fht.prototype,"motorForceLimit",[Lht],Object.getOwnPropertyDescriptor(Fht.prototype,"motorForceLimit"),Fht.prototype),Nht=Fht))||Nht),qct=t("fD",(Uht=qs("cc.HingeConstraint"),zht=xo(on),Hht=xo(on),Wht=xo(on),jht=xo(Ke),Xht=xo(Ye),qht=xo(Ye),Yht=xo(Ke),Kht=xo(Ye),Jht=xo(Ye),Qht=no("axisA"),Zht=no("pivotA"),$ht=no("pivotB"),tut=no("limitData"),eut=no("motorData"),Uht((p((nut=function(t){function e(){var e;return(e=t.call(this,Ntt.HINGE)||this)._axis=rut&&rut(),e._pivotA=sut&&sut(),e._pivotB=out&&out(),e._limitData=aut&&aut(),e._motorData=hut&&hut(),e}return s(e,t),n(e,[{key:"pivotA",get:function(){return this._pivotA},set:function(t){on.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){on.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"axis",get:function(){return this._axis},set:function(t){on.copy(this._axis,t),this.constraint.setAxis(this._axis)}},{key:"limitEnabled",get:function(){return this._limitData.enabled},set:function(t){this._limitData.enabled=t,this.constraint.setLimitEnabled(t)}},{key:"upperLimit",get:function(){return this._limitData.upperLimit},set:function(t){this._limitData.upperLimit=t,this.constraint.setUpperLimit(t)}},{key:"lowerLimit",get:function(){return this._limitData.lowerLimit},set:function(t){this._limitData.lowerLimit=t,this.constraint.setLowerLimit(t)}},{key:"motorEnabled",get:function(){return this._motorData.enabled},set:function(t){this._motorData.enabled=t,this.constraint.setMotorEnabled(t)}},{key:"motorVelocity",get:function(){return this._motorData.motorVelocity},set:function(t){this._motorData.motorVelocity=t,this.constraint.setMotorVelocity(t)}},{key:"motorForceLimit",get:function(){return this._motorData.motorForceLimit},set:function(t){this._motorData.motorForceLimit=t,this.constraint.setMotorForceLimit(t)}},{key:"constraint",get:function(){return this._constraint}}]),e}(lut)).prototype,"pivotA",[zht],Object.getOwnPropertyDescriptor(nut.prototype,"pivotA"),nut.prototype),p(nut.prototype,"pivotB",[Hht],Object.getOwnPropertyDescriptor(nut.prototype,"pivotB"),nut.prototype),p(nut.prototype,"axis",[Wht],Object.getOwnPropertyDescriptor(nut.prototype,"axis"),nut.prototype),p(nut.prototype,"limitEnabled",[jht],Object.getOwnPropertyDescriptor(nut.prototype,"limitEnabled"),nut.prototype),p(nut.prototype,"upperLimit",[Xht],Object.getOwnPropertyDescriptor(nut.prototype,"upperLimit"),nut.prototype),p(nut.prototype,"lowerLimit",[qht],Object.getOwnPropertyDescriptor(nut.prototype,"lowerLimit"),nut.prototype),p(nut.prototype,"motorEnabled",[Yht],Object.getOwnPropertyDescriptor(nut.prototype,"motorEnabled"),nut.prototype),p(nut.prototype,"motorVelocity",[Kht],Object.getOwnPropertyDescriptor(nut.prototype,"motorVelocity"),nut.prototype),p(nut.prototype,"motorForceLimit",[Jht],Object.getOwnPropertyDescriptor(nut.prototype,"motorForceLimit"),nut.prototype),rut=ks(nut.prototype,"_axis",[io,Qht],(function(){return new on})),sut=ks(nut.prototype,"_pivotA",[io,Zht],(function(){return new on})),out=ks(nut.prototype,"_pivotB",[io,$ht],(function(){return new on})),aut=ks(nut.prototype,"_limitData",[io,tut],(function(){return new jct})),hut=ks(nut.prototype,"_motorData",[io,eut],(function(){return new Xct})),iut=nut))||iut)),Yct=t("fF",(cut=qs("cc.FixedConstraint"),_ut=xo(Ye),dut=xo(Ye),fut=no("breakForce"),put=no("breakTorque"),cut((p((gut=function(t){function e(){var e;return(e=t.call(this,Ntt.FIXED)||this)._breakForce=yut&&yut(),e._breakTorque=vut&&vut(),e}return s(e,t),n(e,[{key:"breakForce",get:function(){return this._breakForce},set:function(t){this._breakForce=t,this.constraint.setBreakForce(t)}},{key:"breakTorque",get:function(){return this._breakTorque},set:function(t){this._breakTorque=t,this.constraint.setBreakTorque(t)}},{key:"constraint",get:function(){return this._constraint}}]),e}(lut)).prototype,"breakForce",[_ut],Object.getOwnPropertyDescriptor(gut.prototype,"breakForce"),gut.prototype),p(gut.prototype,"breakTorque",[dut],Object.getOwnPropertyDescriptor(gut.prototype,"breakTorque"),gut.prototype),yut=ks(gut.prototype,"_breakForce",[io,fut],(function(){return 1e8})),vut=ks(gut.prototype,"_breakTorque",[io,put],(function(){return 1e8})),mut=gut))||mut)),Kct=(Sut=qs("cc.LinearLimitSettings"),Tut=xo(Ftt),Aut=xo(Ftt),but=xo(Ftt),Eut=xo(on),Cut=xo(on),wut=xo(Ye),xut=xo(Ke),Rut=xo(Ye),Iut=xo(Ye),Sut((p((Dut=function(){function t(t){this._xMotion=Put&&Put(),this._yMotion=Out&&Out(),this._zMotion=Mut&&Mut(),this._upper=Lut&&Lut(),this._lower=Nut&&Nut(),this._enableSoftConstraint=Fut&&Fut(),this._bounciness=kut&&kut(),this._stiffness=Vut&&Vut(),this._damping=Gut&&Gut(),this._impl=void 0,this._impl=t}return n(t,[{key:"xMotion",get:function(){return this._xMotion},set:function(t){this._xMotion=t,this._impl.setConstraintMode(0,t)}},{key:"yMotion",get:function(){return this._yMotion},set:function(t){this._yMotion=t,this._impl.setConstraintMode(1,t)}},{key:"zMotion",get:function(){return this._zMotion},set:function(t){this._zMotion=t,this._impl.setConstraintMode(2,t)}},{key:"upper",get:function(){return this._upper},set:function(t){on.copy(this._upper,t);var e=this.lower;this._impl.setLinearLimit(0,e.x,t.x),this._impl.setLinearLimit(1,e.y,t.y),this._impl.setLinearLimit(2,e.z,t.z)}},{key:"lower",get:function(){return this._lower},set:function(t){on.copy(this._lower,t);var e=this.upper;this._impl.setLinearLimit(0,t.x,e.x),this._impl.setLinearLimit(1,t.y,e.y),this._impl.setLinearLimit(2,t.z,e.z)}},{key:"restitution",get:function(){return this._bounciness},set:function(t){this._bounciness=t,this._impl.setLinearRestitution(t)}},{key:"enableSoftConstraint",get:function(){return this._enableSoftConstraint},set:function(t){this._enableSoftConstraint=t,this._impl.setLinearSoftConstraint(t)}},{key:"stiffness",get:function(){return this._stiffness},set:function(t){this._stiffness=t,this._impl.setLinearStiffness(t)}},{key:"damping",get:function(){return this._damping},set:function(t){this._damping=t,this._impl.setLinearDamping(t)}},{key:"impl",set:function(t){this._impl=t}}]),t}()).prototype,"xMotion",[Tut],Object.getOwnPropertyDescriptor(Dut.prototype,"xMotion"),Dut.prototype),p(Dut.prototype,"yMotion",[Aut],Object.getOwnPropertyDescriptor(Dut.prototype,"yMotion"),Dut.prototype),p(Dut.prototype,"zMotion",[but],Object.getOwnPropertyDescriptor(Dut.prototype,"zMotion"),Dut.prototype),p(Dut.prototype,"upper",[Eut],Object.getOwnPropertyDescriptor(Dut.prototype,"upper"),Dut.prototype),p(Dut.prototype,"lower",[Cut],Object.getOwnPropertyDescriptor(Dut.prototype,"lower"),Dut.prototype),p(Dut.prototype,"restitution",[wut],Object.getOwnPropertyDescriptor(Dut.prototype,"restitution"),Dut.prototype),p(Dut.prototype,"enableSoftConstraint",[xut],Object.getOwnPropertyDescriptor(Dut.prototype,"enableSoftConstraint"),Dut.prototype),p(Dut.prototype,"stiffness",[Rut],Object.getOwnPropertyDescriptor(Dut.prototype,"stiffness"),Dut.prototype),p(Dut.prototype,"damping",[Iut],Object.getOwnPropertyDescriptor(Dut.prototype,"damping"),Dut.prototype),Put=ks(Dut.prototype,"_xMotion",[io],(function(){return Ftt.FREE})),Out=ks(Dut.prototype,"_yMotion",[io],(function(){return Ftt.FREE})),Mut=ks(Dut.prototype,"_zMotion",[io],(function(){return Ftt.FREE})),Lut=ks(Dut.prototype,"_upper",[io],(function(){return new on})),Nut=ks(Dut.prototype,"_lower",[io],(function(){return new on})),Fut=ks(Dut.prototype,"_enableSoftConstraint",[io],(function(){return!1})),kut=ks(Dut.prototype,"_bounciness",[io],(function(){return 0})),Vut=ks(Dut.prototype,"_stiffness",[io],(function(){return 0})),Gut=ks(Dut.prototype,"_damping",[io],(function(){return 0})),But=Dut))||But),Jct=(Uut=qs("cc.AngularLimitSettings"),zut=xo(Ftt),Hut=xo(Ftt),Wut=xo(Ftt),jut=xo(Ye),Xut=xo(Ye),qut=xo(Ye),Yut=xo(Ye),Kut=xo(Ye),Jut=xo(Ke),Qut=xo(Ye),Zut=xo(Ye),$ut=xo(Ke),tlt=xo(Ye),elt=xo(Ye),Uut((p((nlt=function(){function t(t){this._swing1Motion=rlt&&rlt(),this._swing2Motion=slt&&slt(),this._twistMotion=olt&&olt(),this._twistExtent=alt&&alt(),this._swingExtent1=hlt&&hlt(),this._swingExtent2=ult&&ult(),this._enableSoftConstraintSwing=llt&&llt(),this._swingBounciness=clt&&clt(),this._swingStiffness=_lt&&_lt(),this._swingDamping=dlt&&dlt(),this._enableSoftConstraintTwist=flt&&flt(),this._twistBounciness=plt&&plt(),this._twistStiffness=mlt&&mlt(),this._twistDamping=glt&&glt(),this._impl=void 0,this._impl=t}return n(t,[{key:"twistMotion",get:function(){return this._twistMotion},set:function(t){this._twistMotion=t,this._impl.setConstraintMode(3,t)}},{key:"swingMotion1",get:function(){return this._swing1Motion},set:function(t){this._swing1Motion=t,this._impl.setConstraintMode(4,t)}},{key:"swingMotion2",get:function(){return this._swing2Motion},set:function(t){this._swing2Motion=t,this._impl.setConstraintMode(5,t)}},{key:"twistExtent",get:function(){return this._twistExtent},set:function(t){this._twistExtent=t,this._impl.setAngularExtent(t,this.swingExtent1,this.swingExtent2)}},{key:"swingExtent1",get:function(){return this._swingExtent1},set:function(t){this._swingExtent1=t,this._impl.setAngularExtent(this.twistExtent,t,this.swingExtent2)}},{key:"swingExtent2",get:function(){return this._swingExtent2},set:function(t){this._swingExtent2=t,this._impl.setAngularExtent(this.twistExtent,this.swingExtent1,t)}},{key:"twistRestitution",get:function(){return this._twistBounciness},set:function(t){this._twistBounciness=t,this._impl.setTwistRestitution(t)}},{key:"swingRestitution",get:function(){return this._swingBounciness},set:function(t){this._swingBounciness=t,this._impl.setSwingRestitution(t)}},{key:"enableSoftConstraintTwist",get:function(){return this._enableSoftConstraintTwist},set:function(t){this._enableSoftConstraintTwist=t,this._impl.setTwistSoftConstraint(t)}},{key:"twistStiffness",get:function(){return this._twistStiffness},set:function(t){this._twistStiffness=t,this._impl.setTwistStiffness(t)}},{key:"twistDamping",get:function(){return this._twistDamping},set:function(t){this._twistDamping=t,this._impl.setTwistDamping(t)}},{key:"enableSoftConstraintSwing",get:function(){return this._enableSoftConstraintSwing},set:function(t){this._enableSoftConstraintSwing=t,this._impl.setSwingSoftConstraint(t)}},{key:"swingStiffness",get:function(){return this._swingStiffness},set:function(t){this._swingStiffness=t,this._impl.setSwingStiffness(t)}},{key:"swingDamping",get:function(){return this._swingDamping},set:function(t){this._swingDamping=t,this._impl.setSwingDamping(t)}},{key:"impl",set:function(t){this._impl=t}}]),t}()).prototype,"twistMotion",[zut],Object.getOwnPropertyDescriptor(nlt.prototype,"twistMotion"),nlt.prototype),p(nlt.prototype,"swingMotion1",[Hut],Object.getOwnPropertyDescriptor(nlt.prototype,"swingMotion1"),nlt.prototype),p(nlt.prototype,"swingMotion2",[Wut],Object.getOwnPropertyDescriptor(nlt.prototype,"swingMotion2"),nlt.prototype),p(nlt.prototype,"twistExtent",[jut],Object.getOwnPropertyDescriptor(nlt.prototype,"twistExtent"),nlt.prototype),p(nlt.prototype,"swingExtent1",[Xut],Object.getOwnPropertyDescriptor(nlt.prototype,"swingExtent1"),nlt.prototype),p(nlt.prototype,"swingExtent2",[qut],Object.getOwnPropertyDescriptor(nlt.prototype,"swingExtent2"),nlt.prototype),p(nlt.prototype,"twistRestitution",[Yut],Object.getOwnPropertyDescriptor(nlt.prototype,"twistRestitution"),nlt.prototype),p(nlt.prototype,"swingRestitution",[Kut],Object.getOwnPropertyDescriptor(nlt.prototype,"swingRestitution"),nlt.prototype),p(nlt.prototype,"enableSoftConstraintTwist",[Jut],Object.getOwnPropertyDescriptor(nlt.prototype,"enableSoftConstraintTwist"),nlt.prototype),p(nlt.prototype,"twistStiffness",[Qut],Object.getOwnPropertyDescriptor(nlt.prototype,"twistStiffness"),nlt.prototype),p(nlt.prototype,"twistDamping",[Zut],Object.getOwnPropertyDescriptor(nlt.prototype,"twistDamping"),nlt.prototype),p(nlt.prototype,"enableSoftConstraintSwing",[$ut],Object.getOwnPropertyDescriptor(nlt.prototype,"enableSoftConstraintSwing"),nlt.prototype),p(nlt.prototype,"swingStiffness",[tlt],Object.getOwnPropertyDescriptor(nlt.prototype,"swingStiffness"),nlt.prototype),p(nlt.prototype,"swingDamping",[elt],Object.getOwnPropertyDescriptor(nlt.prototype,"swingDamping"),nlt.prototype),rlt=ks(nlt.prototype,"_swing1Motion",[io],(function(){return Ftt.FREE})),slt=ks(nlt.prototype,"_swing2Motion",[io],(function(){return Ftt.FREE})),olt=ks(nlt.prototype,"_twistMotion",[io],(function(){return Ftt.FREE})),alt=ks(nlt.prototype,"_twistExtent",[io],(function(){return 0})),hlt=ks(nlt.prototype,"_swingExtent1",[io],(function(){return 0})),ult=ks(nlt.prototype,"_swingExtent2",[io],(function(){return 0})),llt=ks(nlt.prototype,"_enableSoftConstraintSwing",[io],(function(){return!1})),clt=ks(nlt.prototype,"_swingBounciness",[io],(function(){return 0})),_lt=ks(nlt.prototype,"_swingStiffness",[io],(function(){return 0})),dlt=ks(nlt.prototype,"_swingDamping",[io],(function(){return 0})),flt=ks(nlt.prototype,"_enableSoftConstraintTwist",[io],(function(){return!1})),plt=ks(nlt.prototype,"_twistBounciness",[io],(function(){return 0})),mlt=ks(nlt.prototype,"_twistStiffness",[io],(function(){return 0})),glt=ks(nlt.prototype,"_twistDamping",[io],(function(){return 0})),ilt=nlt))||ilt),Qct=(ylt=qs("cc.LinearDriverSettings"),vlt=xo(ktt),Slt=xo(ktt),Tlt=xo(ktt),Alt=xo(on),blt=xo(on),Elt=xo(Ye),ylt((p((wlt=function(){function t(t){this._target=xlt&&xlt(),this._velocity=Rlt&&Rlt(),this._xDrive=Ilt&&Ilt(),this._yDrive=Blt&&Blt(),this._zDrive=Dlt&&Dlt(),this._strength=Plt&&Plt(),this._impl=void 0,this._impl=t}return n(t,[{key:"xDrive",get:function(){return this._xDrive},set:function(t){this._xDrive=t,this._impl.setDriverMode(0,t)}},{key:"yDrive",get:function(){return this._yDrive},set:function(t){this._yDrive=t,this._impl.setDriverMode(1,t)}},{key:"zDrive",get:function(){return this._zDrive},set:function(t){this._zDrive=t,this._impl.setDriverMode(2,t)}},{key:"targetPosition",get:function(){return this._target},set:function(t){on.copy(this._target,t),this._impl.setLinearMotorTarget(t)}},{key:"targetVelocity",get:function(){return this._velocity},set:function(t){on.copy(this._velocity,t),this._impl.setLinearMotorVelocity(t)}},{key:"strength",get:function(){return this._strength},set:function(t){this._strength=t,this._impl.setLinearMotorForceLimit(t)}},{key:"impl",set:function(t){this._impl=t}}]),t}()).prototype,"xDrive",[vlt],Object.getOwnPropertyDescriptor(wlt.prototype,"xDrive"),wlt.prototype),p(wlt.prototype,"yDrive",[Slt],Object.getOwnPropertyDescriptor(wlt.prototype,"yDrive"),wlt.prototype),p(wlt.prototype,"zDrive",[Tlt],Object.getOwnPropertyDescriptor(wlt.prototype,"zDrive"),wlt.prototype),p(wlt.prototype,"targetPosition",[Alt],Object.getOwnPropertyDescriptor(wlt.prototype,"targetPosition"),wlt.prototype),p(wlt.prototype,"targetVelocity",[blt],Object.getOwnPropertyDescriptor(wlt.prototype,"targetVelocity"),wlt.prototype),p(wlt.prototype,"strength",[Elt],Object.getOwnPropertyDescriptor(wlt.prototype,"strength"),wlt.prototype),xlt=ks(wlt.prototype,"_target",[io],(function(){return new on})),Rlt=ks(wlt.prototype,"_velocity",[io],(function(){return new on})),Ilt=ks(wlt.prototype,"_xDrive",[io],(function(){return ktt.DISABLED})),Blt=ks(wlt.prototype,"_yDrive",[io],(function(){return ktt.DISABLED})),Dlt=ks(wlt.prototype,"_zDrive",[io],(function(){return ktt.DISABLED})),Plt=ks(wlt.prototype,"_strength",[io],(function(){return 0})),Clt=wlt))||Clt),Zct=(Olt=qs("cc.AngularDriverSettings"),Mlt=xo(ktt),Llt=xo(ktt),Nlt=xo(ktt),Flt=xo(on),klt=xo(on),Vlt=xo(Ye),Olt((p((Ult=function(){function t(t){this._swingDrive1=zlt&&zlt(),this._swingDrive2=Hlt&&Hlt(),this._twistDrive=Wlt&&Wlt(),this._targetOrientation=jlt&&jlt(),this._targetVelocity=Xlt&&Xlt(),this._strength=qlt&&qlt(),this._impl=void 0,this._impl=t}return n(t,[{key:"twistDrive",get:function(){return this._twistDrive},set:function(t){this._twistDrive=t,this._impl.setDriverMode(3,t)}},{key:"swingDrive1",get:function(){return this._swingDrive1},set:function(t){this._swingDrive1=t,this._impl.setDriverMode(4,t)}},{key:"swingDrive2",get:function(){return this._swingDrive2},set:function(t){this._swingDrive2=t,this._impl.setDriverMode(5,t)}},{key:"targetOrientation",get:function(){return this._targetOrientation},set:function(t){on.copy(this._targetOrientation,t),this._impl.setAngularMotorTarget(t)}},{key:"targetVelocity",get:function(){return this._targetVelocity},set:function(t){on.copy(this._targetVelocity,t),this._impl.setAngularMotorVelocity(t)}},{key:"strength",get:function(){return this._strength},set:function(t){this._strength=t,this._impl.setAngularMotorForceLimit(t)}},{key:"impl",set:function(t){this._impl=t}}]),t}()).prototype,"twistDrive",[Mlt],Object.getOwnPropertyDescriptor(Ult.prototype,"twistDrive"),Ult.prototype),p(Ult.prototype,"swingDrive1",[Llt],Object.getOwnPropertyDescriptor(Ult.prototype,"swingDrive1"),Ult.prototype),p(Ult.prototype,"swingDrive2",[Nlt],Object.getOwnPropertyDescriptor(Ult.prototype,"swingDrive2"),Ult.prototype),p(Ult.prototype,"targetOrientation",[Flt],Object.getOwnPropertyDescriptor(Ult.prototype,"targetOrientation"),Ult.prototype),p(Ult.prototype,"targetVelocity",[klt],Object.getOwnPropertyDescriptor(Ult.prototype,"targetVelocity"),Ult.prototype),p(Ult.prototype,"strength",[Vlt],Object.getOwnPropertyDescriptor(Ult.prototype,"strength"),Ult.prototype),zlt=ks(Ult.prototype,"_swingDrive1",[io],(function(){return ktt.DISABLED})),Hlt=ks(Ult.prototype,"_swingDrive2",[io],(function(){return ktt.DISABLED})),Wlt=ks(Ult.prototype,"_twistDrive",[io],(function(){return ktt.DISABLED})),jlt=ks(Ult.prototype,"_targetOrientation",[io],(function(){return new on})),Xlt=ks(Ult.prototype,"_targetVelocity",[io],(function(){return new on})),qlt=ks(Ult.prototype,"_strength",[io],(function(){return 0})),Glt=Ult))||Glt),$ct=t("fE",(Ylt=qs("cc.ConfigurableConstraint"),Klt=xo(on),Jlt=xo(on),Qlt=xo(on),Zlt=xo(on),$lt=xo(Ke),tct=xo(Ye),ect=xo(Ye),ict=xo(Kct),nct=xo(Jct),rct=xo(Qct),sct=xo(Zct),oct=no("linearLimitSettings"),act=no("angularLimitSettings"),hct=no("linearDriverSettings"),uct=no("angularDriverSettings"),Ylt((p((cct=function(t){function e(){var e;return(e=t.call(this,Ntt.CONFIGURABLE)||this)._breakForce=_ct&&_ct(),e._breakTorque=dct&&dct(),e._linearLimitSettings=fct&&fct(),e._angularLimitSettings=pct&&pct(),e._linearDriverSettings=mct&&mct(),e._angularDriverSettings=gct&&gct(),e._pivotA=yct&&yct(),e._pivotB=vct&&vct(),e._autoPivotB=Sct&&Sct(),e._axis=Tct&&Tct(),e._secondaryAxis=Act&&Act(),e._linearLimitSettings=new Kct(e.constraint),e._angularLimitSettings=new Jct(e.constraint),e._linearDriverSettings=new Qct(e.constraint),e._angularDriverSettings=new Zct(e.constraint),e}return s(e,t),e.prototype.onLoad=function(){t.prototype.onLoad.call(this),this.linearLimitSettings.impl=this.constraint,this.angularLimitSettings.impl=this.constraint,this.linearDriverSettings.impl=this.constraint,this.angularDriverSettings.impl=this.constraint},n(e,[{key:"axis",get:function(){return this._axis},set:function(t){on.copy(this._axis,t),this.constraint.setAxis(this._axis)}},{key:"secondaryAxis",get:function(){return this._secondaryAxis},set:function(t){on.copy(this._secondaryAxis,t),this.constraint.setSecondaryAxis(this._secondaryAxis)}},{key:"pivotA",get:function(){return this._pivotA},set:function(t){on.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){on.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"autoPivotB",get:function(){return this._autoPivotB},set:function(t){this._autoPivotB=t,this.constraint.setAutoPivotB(this._autoPivotB)}},{key:"breakForce",get:function(){return this._breakForce},set:function(t){this._breakForce=t,this.constraint.setBreakForce(t)}},{key:"breakTorque",get:function(){return this._breakTorque},set:function(t){this._breakTorque=t,this.constraint.setBreakTorque(t)}},{key:"linearLimitSettings",get:function(){return this._linearLimitSettings},set:function(t){this._linearLimitSettings=t;var e=this.constraint;e.setConstraintMode(0,t.xMotion),e.setConstraintMode(1,t.yMotion),e.setConstraintMode(2,t.zMotion);var i=t.upper,n=t.lower;e.setLinearLimit(0,n.x,i.x),e.setLinearLimit(1,n.y,i.y),e.setLinearLimit(2,n.z,i.z),e.setLinearSoftConstraint(t.enableSoftConstraint),e.setLinearDamping(t.damping),e.setLinearStiffness(t.stiffness),e.setLinearRestitution(t.restitution)}},{key:"angularLimitSettings",get:function(){return this._angularLimitSettings},set:function(t){this._angularLimitSettings=t;var e=this.constraint;e.setConstraintMode(3,t.twistMotion),e.setConstraintMode(4,t.swingMotion1),e.setConstraintMode(5,t.swingMotion2),e.setAngularExtent(t.twistExtent,t.swingExtent1,t.swingExtent2),e.setTwistRestitution(t.twistRestitution),e.setSwingRestitution(t.swingRestitution),e.setTwistSoftConstraint(t.enableSoftConstraintTwist),e.setSwingSoftConstraint(t.enableSoftConstraintSwing),e.setTwistDamping(t.twistDamping),e.setSwingDamping(t.swingDamping),e.setTwistStiffness(t.twistStiffness),e.setSwingStiffness(t.swingStiffness)}},{key:"linearDriverSettings",get:function(){return this._linearDriverSettings},set:function(t){this._linearDriverSettings=t;var e=this.constraint;e.setDriverMode(0,t.xDrive),e.setDriverMode(1,t.yDrive),e.setDriverMode(2,t.zDrive),e.setLinearMotorTarget(t.targetPosition),e.setLinearMotorVelocity(t.targetVelocity),e.setLinearMotorForceLimit(t.strength)}},{key:"angularDriverSettings",get:function(){return this._angularDriverSettings},set:function(t){this._angularDriverSettings=t;var e=this.constraint;e.setDriverMode(3,t.twistDrive),e.setDriverMode(4,t.swingDrive1),e.setDriverMode(5,t.swingDrive2),e.setAngularMotorTarget(t.targetOrientation),e.setAngularMotorVelocity(t.targetVelocity),e.setAngularMotorForceLimit(t.strength)}},{key:"constraint",get:function(){return this._constraint}}]),e}(lut)).prototype,"axis",[Klt],Object.getOwnPropertyDescriptor(cct.prototype,"axis"),cct.prototype),p(cct.prototype,"secondaryAxis",[Jlt],Object.getOwnPropertyDescriptor(cct.prototype,"secondaryAxis"),cct.prototype),p(cct.prototype,"pivotA",[Qlt],Object.getOwnPropertyDescriptor(cct.prototype,"pivotA"),cct.prototype),p(cct.prototype,"pivotB",[Zlt],Object.getOwnPropertyDescriptor(cct.prototype,"pivotB"),cct.prototype),p(cct.prototype,"autoPivotB",[$lt],Object.getOwnPropertyDescriptor(cct.prototype,"autoPivotB"),cct.prototype),p(cct.prototype,"breakForce",[tct],Object.getOwnPropertyDescriptor(cct.prototype,"breakForce"),cct.prototype),p(cct.prototype,"breakTorque",[ect],Object.getOwnPropertyDescriptor(cct.prototype,"breakTorque"),cct.prototype),p(cct.prototype,"linearLimitSettings",[ict],Object.getOwnPropertyDescriptor(cct.prototype,"linearLimitSettings"),cct.prototype),p(cct.prototype,"angularLimitSettings",[nct],Object.getOwnPropertyDescriptor(cct.prototype,"angularLimitSettings"),cct.prototype),p(cct.prototype,"linearDriverSettings",[rct],Object.getOwnPropertyDescriptor(cct.prototype,"linearDriverSettings"),cct.prototype),p(cct.prototype,"angularDriverSettings",[sct],Object.getOwnPropertyDescriptor(cct.prototype,"angularDriverSettings"),cct.prototype),_ct=ks(cct.prototype,"_breakForce",[io],(function(){return 1e8})),dct=ks(cct.prototype,"_breakTorque",[io],(function(){return 1e8})),fct=ks(cct.prototype,"_linearLimitSettings",[io,oct],null),pct=ks(cct.prototype,"_angularLimitSettings",[io,act],null),mct=ks(cct.prototype,"_linearDriverSettings",[io,hct],null),gct=ks(cct.prototype,"_angularDriverSettings",[io,uct],null),yct=ks(cct.prototype,"_pivotA",[io],(function(){return new on})),vct=ks(cct.prototype,"_pivotB",[io],(function(){return new on})),Sct=ks(cct.prototype,"_autoPivotB",[io],(function(){return!1})),Tct=ks(cct.prototype,"_axis",[io],(function(){return new on(0,1,0)})),Act=ks(cct.prototype,"_secondaryAxis",[io],(function(){return new on(1,0,0)})),lct=cct))||lct)),t_t=t("fG",(bct=qs("cc.PointToPointConstraint"),Ect=xo(on),Cct=xo(on),bct((p((xct=function(t){function e(){var e;return(e=t.call(this,Ntt.POINT_TO_POINT)||this)._pivotA=Rct&&Rct(),e._pivotB=Ict&&Ict(),e}return s(e,t),n(e,[{key:"pivotA",get:function(){return this._pivotA},set:function(t){on.copy(this._pivotA,t),this.constraint.setPivotA(this._pivotA)}},{key:"pivotB",get:function(){return this._pivotB},set:function(t){on.copy(this._pivotB,t),this.constraint.setPivotB(this._pivotB)}},{key:"constraint",get:function(){return this._constraint}}]),e}(lut)).prototype,"pivotA",[Ect],Object.getOwnPropertyDescriptor(xct.prototype,"pivotA"),xct.prototype),p(xct.prototype,"pivotB",[Cct],Object.getOwnPropertyDescriptor(xct.prototype,"pivotB"),xct.prototype),Rct=ks(xct.prototype,"_pivotA",[io],(function(){return new on})),Ict=ks(xct.prototype,"_pivotB",[io],(function(){return new on})),wct=xct))||wct));new on(0,0,0),new on(0,0,0);var e_t,i_t,n_t,r_t,s_t,o_t,a_t,h_t,u_t,l_t,c_t=t("fn",(Bct=qs("cc.CharacterController"),Dct=xo(lot.PhysicsGroup),Pct=xo(Ye),Oct=xo(Ye),Mct=xo(Ye),Lct=xo(Ye),Nct=xo(on),Bct(Fct=Js((p((kct=function(t){function e(e){var i;return(i=t.call(this)||this).type=void 0,i._cct=null,i._group=Vct&&Vct(),i._minMoveDistance=Gct&&Gct(),i._stepOffset=Uct&&Uct(),i._slopeLimit=zct&&zct(),i._skinWidth=Hct&&Hct(),i._center=Wct&&Wct(),i._initialized=!1,i._prevPos=new on,i._currentPos=new on,i._velocity=new on,i._centerWorldPosition=new on,i._needCollisionEvent=!1,i._needTriggerEvent=!1,i.type=e,i}s(e,t);var i=e.prototype;return i.onLoad=function(){$rt.runInEditor&&(this._cct=function(t){return _st.INITED||(_st.INITED=!0,_st[Vtt.BOX]=function(){return ist($rt.wrapper.BoxCharacterController,Zrt.BoxCharacterController)?dst:new $rt.wrapper.BoxCharacterController},_st[Vtt.CAPSULE]=function(){return ist($rt.wrapper.CapsuleCharacterController,Zrt.CapsuleCharacterController)?dst:new $rt.wrapper.CapsuleCharacterController}),_st[t]()}(this.type),this._initialized=this._cct.initialize(this),this._cct.onLoad())},i.onEnable=function(){this._cct&&this._cct.onEnable()},i.onDisable=function(){this._cct&&this._cct.onDisable()},i.onDestroy=function(){this._cct&&(this._needCollisionEvent=!1,this._needTriggerEvent=!1,this._cct.updateEventListener(),this._cct.onDestroy(),this._cct=null)},i.move=function(t){if(this._isInitialized){this._prevPos.set(this.centerWorldPosition);var e=lot.instance.fixedTimeStep;this._cct.move(t,this._minMoveDistance,e),this._currentPos.set(this.centerWorldPosition),this._velocity=this._currentPos.subtract(this._prevPos).multiplyScalar(1/e),this._cct.syncPhysicsToScene()}},i.on=function(e,i,n,r){var s=t.prototype.on.call(this,e,i,n,r);return this._updateNeedEvent(e),s},i.off=function(e,i,n){t.prototype.off.call(this,e,i,n),this._updateNeedEvent()},i.once=function(e,i,n){var r=t.prototype.once.call(this,e,i,n);return this._updateNeedEvent(e),r},i.getGroup=function(){return this._isInitialized?this._cct.getGroup():0},i.setGroup=function(t){this._isInitialized&&this._cct.setGroup(t)},i.addGroup=function(t){this._isInitialized&&this._cct.addGroup(t)},i.removeGroup=function(t){this._isInitialized&&this._cct.removeGroup(t)},i.getMask=function(){return this._isInitialized?this._cct.getMask():0},i.setMask=function(t){this._isInitialized&&this._cct.setMask(t)},i.addMask=function(t){this._isInitialized&&this._cct.addMask(t)},i.removeMask=function(t){this._isInitialized&&this._cct.removeMask(t)},i._updateNeedEvent=function(t){this.isValid&&(void 0!==t?("onControllerColliderHit"===t&&(this._needCollisionEvent=!0),"onControllerTriggerEnter"!==t&&"onControllerTriggerStay"!==t&&"onControllerTriggerExit"!==t||(this._needTriggerEvent=!0)):(this.hasEventListener("onControllerColliderHit")||(this._needCollisionEvent=!1),this.hasEventListener("onControllerTriggerEnter")||this.hasEventListener("onControllerTriggerStay")||this.hasEventListener("onControllerTriggerExit")||(this._needTriggerEvent=!1)),this._cct&&this._cct.updateEventListener())},n(e,[{key:"group",get:function(){return this._group},set:function(t){this._group=t,this._cct&&this._cct.getGroup()!==t&&this._cct.setGroup(t)}},{key:"minMoveDistance",get:function(){return this._minMoveDistance},set:function(t){this._minMoveDistance!==t&&(this._minMoveDistance=Math.abs(t))}},{key:"stepOffset",get:function(){return this._stepOffset},set:function(t){this._stepOffset!==t&&(this._stepOffset=Math.abs(t),this._cct&&this._cct.setStepOffset(t))}},{key:"slopeLimit",get:function(){return this._slopeLimit},set:function(t){this._slopeLimit!==t&&(this._slopeLimit=Math.abs(t),this._cct&&this._cct.setSlopeLimit(t))}},{key:"skinWidth",get:function(){return this._skinWidth},set:function(t){this._skinWidth!==t&&(this._skinWidth=Math.abs(t),this._cct&&this._cct.setContactOffset(Math.max(1e-4,t)))}},{key:"center",get:function(){return this._center},set:function(t){on.equals(this._center,t)||on.copy(this._center,t)}},{key:"_isInitialized",get:function(){return!(null===this._cct||!this._initialized)}},{key:"centerWorldPosition",get:function(){return this._isInitialized&&this._cct.getPosition(this._centerWorldPosition),this._centerWorldPosition},set:function(t){this._isInitialized&&this._cct.setPosition(t)}},{key:"velocity",get:function(){return this._velocity}},{key:"isGrounded",get:function(){return this._cct.onGround()}},{key:"needCollisionEvent",get:function(){return this._needCollisionEvent}},{key:"needTriggerEvent",get:function(){return this._needTriggerEvent}}]),e}(Yu(rp))).prototype,"group",[Dct],Object.getOwnPropertyDescriptor(kct.prototype,"group"),kct.prototype),p(kct.prototype,"minMoveDistance",[Pct],Object.getOwnPropertyDescriptor(kct.prototype,"minMoveDistance"),kct.prototype),p(kct.prototype,"stepOffset",[Oct],Object.getOwnPropertyDescriptor(kct.prototype,"stepOffset"),kct.prototype),p(kct.prototype,"slopeLimit",[Mct],Object.getOwnPropertyDescriptor(kct.prototype,"slopeLimit"),kct.prototype),p(kct.prototype,"skinWidth",[Lct],Object.getOwnPropertyDescriptor(kct.prototype,"skinWidth"),kct.prototype),p(kct.prototype,"center",[Nct],Object.getOwnPropertyDescriptor(kct.prototype,"center"),kct.prototype),Vct=ks(kct.prototype,"_group",[io],(function(){return lot.PhysicsGroup.DEFAULT})),Gct=ks(kct.prototype,"_minMoveDistance",[io],(function(){return.001})),Uct=ks(kct.prototype,"_stepOffset",[io],(function(){return.5})),zct=ks(kct.prototype,"_slopeLimit",[io],(function(){return 45})),Hct=ks(kct.prototype,"_skinWidth",[io],(function(){return.01})),Wct=ks(kct.prototype,"_center",[io],(function(){return new on})),Fct=kct))||Fct)||Fct));new on(0,0,0);var __t,d_t,f_t,p_t,m_t,g_t,y_t,v_t,S_t=t("fI",(e_t=qs("cc.BoxCharacterController"),i_t=Ks(-1),n_t=xo(Ye),r_t=xo(Ye),s_t=xo(Ye),e_t(o_t=i_t((p((a_t=function(t){function e(){var e;return(e=t.call(this,Vtt.BOX)||this)._halfHeight=h_t&&h_t(),e._halfSideExtent=u_t&&u_t(),e._halfForwardExtent=l_t&&l_t(),e}return s(e,t),n(e,[{key:"halfHeight",get:function(){return this._halfHeight},set:function(t){this._halfHeight!==t&&(this._halfHeight=Math.abs(t),this._cct&&this._cct.setHalfHeight(t))}},{key:"halfSideExtent",get:function(){return this._halfSideExtent},set:function(t){this._halfSideExtent!==t&&(this._halfSideExtent=Math.abs(t),this._cct&&this._cct.setHalfSideExtent(t))}},{key:"halfForwardExtent",get:function(){return this._halfForwardExtent},set:function(t){this._halfForwardExtent!==t&&(this._halfForwardExtent=Math.abs(t),this._cct&&this._cct.setHalfForwardExtent(t))}}]),e}(c_t)).prototype,"halfHeight",[n_t],Object.getOwnPropertyDescriptor(a_t.prototype,"halfHeight"),a_t.prototype),p(a_t.prototype,"halfSideExtent",[r_t],Object.getOwnPropertyDescriptor(a_t.prototype,"halfSideExtent"),a_t.prototype),p(a_t.prototype,"halfForwardExtent",[s_t],Object.getOwnPropertyDescriptor(a_t.prototype,"halfForwardExtent"),a_t.prototype),h_t=ks(a_t.prototype,"_halfHeight",[io],(function(){return.5})),u_t=ks(a_t.prototype,"_halfSideExtent",[io],(function(){return.5})),l_t=ks(a_t.prototype,"_halfForwardExtent",[io],(function(){return.5})),o_t=a_t))||o_t)||o_t));new on(0,0,0);var T_t=t("fH",(__t=qs("cc.CapsuleCharacterController"),d_t=Ks(-1),f_t=xo(Ye),p_t=xo(Ye),__t(m_t=d_t((p((g_t=function(t){function e(){var e;return(e=t.call(this,Vtt.CAPSULE)||this)._radius=y_t&&y_t(),e._height=v_t&&v_t(),e}return s(e,t),n(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._cct&&this._cct.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(this._height=Math.abs(t),this._cct&&this._cct.setHeight(t))}}]),e}(c_t)).prototype,"radius",[f_t],Object.getOwnPropertyDescriptor(g_t.prototype,"radius"),g_t.prototype),p(g_t.prototype,"height",[p_t],Object.getOwnPropertyDescriptor(g_t.prototype,"height"),g_t.prototype),y_t=ks(g_t.prototype,"_radius",[io],(function(){return.5})),v_t=ks(g_t.prototype,"_height",[io],(function(){return 1})),m_t=g_t))||m_t)||m_t)),A_t=function(){this.worldPosition=new on,this.worldNormal=new on,this.motionDirection=new on,this.motionLength=0};v.PhysicsSystem=lot,v.PhysicsMaterial=jst,v.PhysicsRayResult=Xst,v.ConstantForce=Rat;var b_t,E_t,C_t,w_t,x_t,R_t=Object.freeze({__proto__:null,PhysicsSystem:lot,PhysicsRayResult:Xst,PhysicsLineStripCastResult:qst,get Collider(){return Rot},BoxCollider:Aat,SphereCollider:bat,CapsuleCollider:Eat,MeshCollider:xat,CylinderCollider:Cat,ConeCollider:wat,TerrainCollider:sht,get SimplexCollider(){return oht},PlaneCollider:uut,get Constraint(){return lut},HingeConstraint:qct,FixedConstraint:Yct,PointToPointConstraint:t_t,ConfigurableConstraint:$ct,get RigidBody(){return Aot},PhysicsMaterial:jst,ConstantForce:Rat,CharacterController:c_t,BoxCharacterController:S_t,CapsuleCharacterController:T_t,selector:$rt,utils:f0,CharacterControllerContact:A_t,get ERigidBodyType(){return Dtt},get EAxisDirection(){return Ptt},get ED6Axis(){return Ott},get ESimplexType(){return Mtt},get EColliderType(){return Ltt},get EConstraintType(){return Ntt},get EConstraintMode(){return Ftt},get EDriverMode(){return ktt},get ECharacterControllerType(){return Vtt},get PhysicsGroup(){return Gtt},get EPhysicsDrawFlags(){return Utt}});t("fk",R_t),nt(lot,"PhysicsSystem",[{name:"ins",newName:"instance"},{name:"PHYSICS_AMMO",newName:"PHYSICS_BULLET"}]),nt(lot.prototype,"PhysicsSystem.prototype",[{name:"deltaTime",newName:"fixedTimeStep"},{name:"maxSubStep",newName:"maxSubSteps"}]),rt(lot.prototype,"PhysicsSystem.prototype",[{name:"useFixedTime"},{name:"useCollisionMatrix"},{name:"updateCollisionMatrix"},{name:"resetCollisionMatrix"},{name:"isCollisionGroup"},{name:"setCollisionGroup"}]),nt(Rot.prototype,"Collider.prototype",[{name:"attachedRigidbody",newName:"attachedRigidBody"},{name:"TYPE",newName:"type"}]),nt(Rot,"Collider",[{name:"EColliderType",newName:"Type"},{name:"EAxisDirection",newName:"Axis"}]),nt(lut,"Constraint",[{name:"EConstraintType",newName:"Type"}]),nt(Aat.prototype,"BoxCollider.prototype",[{name:"boxShape",newName:"shape"}]),nt(bat.prototype,"SphereCollider.prototype",[{name:"sphereShape",newName:"shape"}]),nt(Eat.prototype,"CapsuleCollider.prototype",[{name:"capsuleShape",newName:"shape"}]),nt(Aot.prototype,"RigidBody.prototype",[{name:"rigidBody",newName:"body"}]),nt(Aot,"RigidBody",[{name:"ERigidBodyType",newName:"Type"}]),rt(Aot.prototype,"RigidBody.prototype",[{name:"fixedRotation"}]),v.RigidBodyComponent=Aot,Qt(Aot,"cc.RigidBodyComponent"),v.ColliderComponent=Rot,Qt(Rot,"cc.ColliderComponent"),v.BoxColliderComponent=Aat,Qt(Aat,"cc.BoxColliderComponent"),v.SphereColliderComponent=bat,Qt(bat,"cc.SphereColliderComponent"),Qt(Eat,"cc.CapsuleColliderComponent"),Qt(xat,"cc.MeshColliderComponent"),Qt(Cat,"cc.CylinderColliderComponent"),v.PhysicMaterial=jst,Qt(jst,"cc.PhysicMaterial"),v.physics=R_t,function(t){t[t.BODY_RE_ADD=1]="BODY_RE_ADD",t[t.GHOST_RE_ADD=2]="GHOST_RE_ADD"}(b_t||(b_t={})),function(t){t[t.CF_STATIC_OBJECT=1]="CF_STATIC_OBJECT",t[t.CF_KINEMATIC_OBJECT=2]="CF_KINEMATIC_OBJECT",t[t.CF_NO_CONTACT_RESPONSE=4]="CF_NO_CONTACT_RESPONSE",t[t.CF_CUSTOM_MATERIAL_CALLBACK=8]="CF_CUSTOM_MATERIAL_CALLBACK",t[t.CF_CHARACTER_OBJECT=16]="CF_CHARACTER_OBJECT",t[t.CF_DISABLE_VISUALIZE_OBJECT=32]="CF_DISABLE_VISUALIZE_OBJECT",t[t.CF_DISABLE_SPU_COLLISION_PROCESSING=64]="CF_DISABLE_SPU_COLLISION_PROCESSING"}(E_t||(E_t={})),function(t){t[t.CO_COLLISION_OBJECT=1]="CO_COLLISION_OBJECT",t[t.CO_RIGID_BODY=2]="CO_RIGID_BODY",t[t.CO_GHOST_OBJECT=4]="CO_GHOST_OBJECT",t[t.CO_SOFT_BODY=8]="CO_SOFT_BODY",t[t.CO_HF_FLUID=16]="CO_HF_FLUID",t[t.CO_USER_TYPE=32]="CO_USER_TYPE",t[t.CO_FEATHERSTONE_LINK=64]="CO_FEATHERSTONE_LINK"}(C_t||(C_t={})),function(t){t[t.ACTIVE_TAG=1]="ACTIVE_TAG",t[t.ISLAND_SLEEPING=2]="ISLAND_SLEEPING",t[t.WANTS_DEACTIVATION=3]="WANTS_DEACTIVATION",t[t.DISABLE_DEACTIVATION=4]="DISABLE_DEACTIVATION",t[t.DISABLE_SIMULATION=5]="DISABLE_SIMULATION"}(w_t||(w_t={})),function(t){t[t.BT_DISABLE_WORLD_GRAVITY=1]="BT_DISABLE_WORLD_GRAVITY",t[t.BT_ENABLE_GYROPSCOPIC_FORCE=2]="BT_ENABLE_GYROPSCOPIC_FORCE"}(x_t||(x_t={}));var I_t=Sst,B_t=Tst,D_t=function(){var t=e.prototype;function e(){this.id=void 0,this._isEnabled=!1,this._isUsingCCD=!1,this._sharedBody=void 0,this._rigidBody=void 0,this.id=e.idCounter++}return t.setMass=function(t){this._rigidBody.isDynamic&&(fst.RigidBody_setMass(this.impl,t),this._wakeUpIfSleep(),this._sharedBody.dirty|=b_t.BODY_RE_ADD)},t.setType=function(t){this._sharedBody.setType(t)},t.setLinearDamping=function(){fst.RigidBody_setDamping(this.impl,this._rigidBody.linearDamping,this._rigidBody.angularDamping)},t.setAngularDamping=function(){fst.RigidBody_setDamping(this.impl,this._rigidBody.linearDamping,this._rigidBody.angularDamping)},t.useGravity=function(t){if(this._rigidBody.isDynamic){var e=fst.RigidBody_getFlags(this.impl);t?e&=~x_t.BT_DISABLE_WORLD_GRAVITY:(fst.RigidBody_setGravity(this.impl,Vst(vst.instance.BT_V3_0,on.ZERO)),e|=x_t.BT_DISABLE_WORLD_GRAVITY),fst.RigidBody_setFlags(this.impl,e),this._wakeUpIfSleep(),this._sharedBody.dirty|=b_t.BODY_RE_ADD}},t.useCCD=function(t){fst.CollisionObject_setCcdMotionThreshold(this.impl,t?.01:0),fst.CollisionObject_setCcdSweptSphereRadius(this.impl,t?.1:0),this._isUsingCCD=t},t.isUsingCCD=function(){return this._isUsingCCD},t.setLinearFactor=function(t){fst.RigidBody_setLinearFactor(this.impl,Vst(vst.instance.BT_V3_0,t)),this._wakeUpIfSleep()},t.setAngularFactor=function(t){fst.RigidBody_setAngularFactor(this.impl,Vst(vst.instance.BT_V3_0,t)),this._wakeUpIfSleep()},t.setAllowSleep=function(t){this._rigidBody.isDynamic&&(t?fst.CollisionObject_forceActivationState(this.impl,w_t.ACTIVE_TAG):fst.CollisionObject_forceActivationState(this.impl,w_t.DISABLE_DEACTIVATION),this._wakeUpIfSleep())},t.clearState=function(){fst.RigidBody_clearState(this.impl)},t.clearVelocity=function(){this.setLinearVelocity(on.ZERO),this.setAngularVelocity(on.ZERO)},t.clearForces=function(){fst.RigidBody_clearForces(this.impl)},t.initialize=function(t){this._rigidBody=t,this._sharedBody=lot.instance.physicsWorld.getSharedBody(this._rigidBody.node,this),this._sharedBody.reference=!0},t.onEnable=function(){this._isEnabled=!0,this.setMass(this._rigidBody.mass),this.setAllowSleep(this._rigidBody.allowSleep),this.setLinearDamping(this._rigidBody.linearDamping),this.setAngularDamping(this._rigidBody.angularDamping),this.setLinearFactor(this._rigidBody.linearFactor),this.setAngularFactor(this._rigidBody.angularFactor),this.useGravity(this._rigidBody.useGravity),this._sharedBody.bodyEnabled=!0},t.onDisable=function(){this._isEnabled=!1,this._sharedBody.bodyEnabled=!1},t.onDestroy=function(){this._sharedBody.reference=!1,this._rigidBody=null,this._sharedBody=null},t.wakeUp=function(t){void 0===t&&(t=!0),fst.CollisionObject_activate(this.impl,t)},t.sleep=function(){var t=fst.CollisionObject_getActivationState(this.impl);t!==w_t.DISABLE_DEACTIVATION&&t!==w_t.DISABLE_SIMULATION&&fst.CollisionObject_forceActivationState(this.impl,w_t.ISLAND_SLEEPING)},t.setSleepThreshold=function(t){this._wakeUpIfSleep(),fst.RigidBody_setSleepingThresholds(this.impl,t,t)},t.getSleepThreshold=function(){return fst.RigidBody_getLinearSleepingThreshold(this.impl)},t.getLinearVelocity=function(t){return Gst(t,fst.RigidBody_getLinearVelocity(this.impl))},t.setLinearVelocity=function(t){this._wakeUpIfSleep(),Vst(fst.RigidBody_getLinearVelocity(this.impl),t)},t.getAngularVelocity=function(t){return Gst(t,fst.RigidBody_getAngularVelocity(this.impl))},t.setAngularVelocity=function(t){this._wakeUpIfSleep(),Vst(fst.RigidBody_getAngularVelocity(this.impl),t)},t.applyLocalForce=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=this._sharedBody.node.worldRotation,n=on.transformQuat(I_t,t,i),r=e?on.transformQuat(B_t,e,i):on.ZERO;fst.RigidBody_applyForce(this.impl,Vst(vst.instance.BT_V3_0,n),Vst(vst.instance.BT_V3_1,r))},t.applyLocalTorque=function(t){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep(),on.transformQuat(I_t,t,this._sharedBody.node.worldRotation),fst.RigidBody_applyTorque(this.impl,Vst(vst.instance.BT_V3_0,I_t))},t.applyLocalImpulse=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=this._sharedBody.node.worldRotation,n=on.transformQuat(I_t,t,i),r=e?on.transformQuat(B_t,e,i):on.ZERO;fst.RigidBody_applyImpulse(this.impl,Vst(vst.instance.BT_V3_0,n),Vst(vst.instance.BT_V3_1,r))},t.applyForce=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=e||on.ZERO;fst.RigidBody_applyForce(this.impl,Vst(vst.instance.BT_V3_0,t),Vst(vst.instance.BT_V3_1,i))},t.applyTorque=function(t){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep(),fst.RigidBody_applyTorque(this.impl,Vst(vst.instance.BT_V3_0,t))},t.applyImpulse=function(t,e){this._sharedBody.syncSceneToPhysics(),this._wakeUpIfSleep();var i=e||on.ZERO;fst.RigidBody_applyImpulse(this.impl,Vst(vst.instance.BT_V3_0,t),Vst(vst.instance.BT_V3_1,i))},t.getGroup=function(){return this._sharedBody.collisionFilterGroup},t.setGroup=function(t){this._sharedBody.collisionFilterGroup=t},t.addGroup=function(t){this._sharedBody.collisionFilterGroup|=t},t.removeGroup=function(t){this._sharedBody.collisionFilterGroup&=~t},t.getMask=function(){return this._sharedBody.collisionFilterMask},t.setMask=function(t){this._sharedBody.collisionFilterMask=t},t.addMask=function(t){this._sharedBody.collisionFilterMask|=t},t.removeMask=function(t){this._sharedBody.collisionFilterMask&=~t},t._wakeUpIfSleep=function(){this.isAwake||fst.CollisionObject_activate(this.impl,!0)},n(e,[{key:"isAwake",get:function(){var t=fst.CollisionObject_getActivationState(this.impl);return t===w_t.ACTIVE_TAG||t===w_t.DISABLE_DEACTIVATION}},{key:"isSleepy",get:function(){return fst.CollisionObject_getActivationState(this.impl)===w_t.WANTS_DEACTIVATION}},{key:"isSleeping",get:function(){return fst.CollisionObject_getActivationState(this.impl)===w_t.ISLAND_SLEEPING}},{key:"impl",get:function(){return this._sharedBody.body}},{key:"rigidBody",get:function(){return this._rigidBody}},{key:"sharedBody",get:function(){return this._sharedBody}},{key:"isEnabled",get:function(){return this._isEnabled}}]),e}();D_t.idCounter=0;var P_t={syncPhysicsToGraphics:function(t){pst.CACHE.getWrapper(t,pst.BODY_CACHE_NAME).syncPhysicsToGraphics()},onShapeHitExt:function(t,e){pst.CACHE.getWrapper(e,pst.CCT_CACHE_NAME).onShapeHitExt(t)},onDebugDrawLine:function(t,e,i){var n=pst.CACHE.world;n&&n.onDebugDrawLine(t,e,i)},clearLines:function(){var t=pst.CACHE.world;t&&t.onClearLines()},flushLines:function(){}},O_t=Sst,M_t=bst,L_t=0,N_t=function(){function t(e,i){this.id=void 0,this.node=void 0,this.wrappedWorld=void 0,this.wrappedJoints0=[],this.wrappedJoints1=[],this.dirty=0,this._collisionFilterGroup=lot.PhysicsGroup.DEFAULT,this._collisionFilterMask=-1,this.ref=0,this.bodyIndex=-1,this.ghostIndex=-1,this._bodyStruct=void 0,this._ghostStruct=void 0,this._wrappedBody=null,this.id=t.idCounter++,this.wrappedWorld=i,this.node=e}t.getSharedBody=function(e,i,n){var r,s=e.uuid;if(t.sharedBodesMap.has(s))r=t.sharedBodesMap.get(s);else{r=new t(e,i);var o=Gtt.DEFAULT,a=lot.instance.collisionMatrix[o];r._collisionFilterGroup=o,r._collisionFilterMask=a,t.sharedBodesMap.set(e.uuid,r)}if(n){r._wrappedBody=n;var h=n.rigidBody.group,u=lot.instance.collisionMatrix[h];r._collisionFilterGroup=h,r._collisionFilterMask=u}return r};var e=t.prototype;return e._instantiateBodyStruct=function(){if(!this._bodyStruct){var t=0;this._wrappedBody&&this._wrappedBody.rigidBody.enabled&&this._wrappedBody.rigidBody.isDynamic&&(t=this._wrappedBody.rigidBody.mass);var e=vst.instance.BT_TRANSFORM_0,i=vst.instance.BT_QUAT_0;Vst(fst.Transform_getOrigin(e),this.node.worldPosition),Ust(i,this.node.worldRotation),fst.Transform_setRotation(e,i);var n=fst.MotionState.implement(P_t).$$.ptr;fst.ccMotionState_setup(n,this.id,e);var r=fst.RigidBody_new(t,n),s=lot.instance.sleepThreshold;fst.RigidBody_setSleepingThresholds(r,s,s),this._bodyStruct={id:L_t++,body:r,motionState:n,compound:fst.ccCompoundShape_new(),wrappedShapes:[],useCompound:!1},vst.setWrapper(this.id,pst.BODY_CACHE_NAME,this),this._ghostStruct&&fst.CollisionObject_setIgnoreCollisionCheck(this.ghost,this.body,!0),this._wrappedBody&&this.setBodyType(this._wrappedBody.rigidBody.type)}},e._instantiateGhostStruct=function(){if(!this._ghostStruct){var t=fst.CollisionObject_new(),e=fst.ccCompoundShape_new();fst.CollisionObject_setCollisionShape(t,e),fst.CollisionObject_setCollisionFlags(t,E_t.CF_STATIC_OBJECT|E_t.CF_NO_CONTACT_RESPONSE),this._ghostStruct={id:L_t++,ghost:t,compound:e,wrappedShapes:[]},this._bodyStruct&&fst.CollisionObject_setIgnoreCollisionCheck(this.body,this.ghost,!0),this._wrappedBody&&this.setGhostType(this._wrappedBody.rigidBody.type)}},e.setType=function(t){this.setBodyType(t),this.setGhostType(t)},e.setBodyType=function(t){if(this._bodyStruct&&this._wrappedBody){var e=this._bodyStruct.body,i=this._wrappedBody,n=i.rigidBody,r=fst.CollisionObject_getCollisionFlags(e),s=vst.instance.BT_V3_0;switch(t){case Dtt.DYNAMIC:r&=~E_t.CF_KINEMATIC_OBJECT,r&=~E_t.CF_STATIC_OBJECT,fst.CollisionObject_setCollisionFlags(e,r),i.setMass(n.mass),i.useGravity(n.useGravity),i.setAllowSleep(n.allowSleep);break;case Dtt.KINEMATIC:fst.Vec3_set(s,0,0,0),fst.RigidBody_setMassProps(e,0,s),r|=E_t.CF_KINEMATIC_OBJECT,r&=~E_t.CF_STATIC_OBJECT,fst.CollisionObject_setCollisionFlags(e,r),fst.CollisionObject_forceActivationState(e,w_t.DISABLE_DEACTIVATION);break;case Dtt.STATIC:default:fst.Vec3_set(s,0,0,0),fst.RigidBody_setMassProps(e,0,s),r|=E_t.CF_STATIC_OBJECT,r&=~E_t.CF_KINEMATIC_OBJECT,fst.CollisionObject_setCollisionFlags(e,r),fst.CollisionObject_forceActivationState(e,w_t.ISLAND_SLEEPING)}this.dirty|=b_t.BODY_RE_ADD}},e.setGhostType=function(t){if(this._ghostStruct){var e=this._ghostStruct.ghost,i=fst.CollisionObject_getCollisionFlags(e);switch(t){case Dtt.DYNAMIC:case Dtt.KINEMATIC:i&=~E_t.CF_STATIC_OBJECT,i|=E_t.CF_KINEMATIC_OBJECT,fst.CollisionObject_setCollisionFlags(e,i),fst.CollisionObject_forceActivationState(e,w_t.DISABLE_DEACTIVATION);break;case Dtt.STATIC:default:i&=~E_t.CF_KINEMATIC_OBJECT,i|=E_t.CF_STATIC_OBJECT,fst.CollisionObject_setCollisionFlags(e,i),fst.CollisionObject_forceActivationState(e,w_t.ISLAND_SLEEPING)}this.dirty|=b_t.GHOST_RE_ADD}},e.addShape=function(t,e){function i(t,e){fst.CollisionObject_setCollisionShape(t.body,e),t.dirty|=b_t.BODY_RE_ADD,t._wrappedBody&&t._wrappedBody.isEnabled&&t._wrappedBody.setMass(t._wrappedBody.rigidBody.mass)}if(e)this.ghostStruct.wrappedShapes.indexOf(t)<0&&(this.ghostStruct.wrappedShapes.push(t),t.setCompound(this.ghostCompoundShape),this.ghostEnabled=!0);else if(this.bodyStruct.wrappedShapes.indexOf(t)<0){if(this.bodyStruct.wrappedShapes.push(t),this.bodyStruct.useCompound)t.setCompound(this.bodyCompoundShape);else{var n=this.bodyStruct.wrappedShapes.length;if(1!==n||t.needCompound()){this.bodyStruct.useCompound=!0;for(var r=0;r<n;r++)this.bodyStruct.wrappedShapes[r].setCompound(this.bodyCompoundShape);i(this,this.bodyStruct.compound)}else i(this,t.impl)}this.bodyEnabled=!0}},e.removeShape=function(t,e){if(e){var i=this.ghostStruct.wrappedShapes.indexOf(t);i>=0&&(ae(this.ghostStruct.wrappedShapes,i),t.setCompound(0),this.ghostEnabled=!1)}else{var n=this.bodyStruct.wrappedShapes.indexOf(t);n>=0&&(this.bodyStruct.useCompound?t.setCompound(0):fst.CollisionObject_setCollisionShape(this.body,fst.EmptyShape_static()),fst.CollisionObject_activate(this.body,!0),this.dirty|=b_t.BODY_RE_ADD,ae(this.bodyStruct.wrappedShapes,n),this.bodyEnabled=!1)}},e.addJoint=function(t,e){e?this.wrappedJoints1.indexOf(t)<0&&this.wrappedJoints1.push(t):this.wrappedJoints0.indexOf(t)<0&&this.wrappedJoints0.push(t)},e.removeJoint=function(t,e){if(e){var i=this.wrappedJoints1.indexOf(t);i>=0&&ae(this.wrappedJoints1,i)}else{var n=this.wrappedJoints0.indexOf(t);n>=0&&ae(this.wrappedJoints0,n)}},e.updateDirty=function(){this.dirty&&(this.bodyIndex>=0&&this.dirty&b_t.BODY_RE_ADD&&this.updateBodyByReAdd(),this.ghostIndex>=0&&this.dirty&b_t.GHOST_RE_ADD&&this.updateGhostByReAdd(),this.dirty=0)},e.syncSceneToPhysics=function(){if(this.node.hasChangedFlags){var t=vst.instance.BT_QUAT_0,e=fst.CollisionObject_getWorldTransform(this.body);if(Ust(t,this.node.worldRotation),Vst(fst.Transform_getOrigin(e),this.node.worldPosition),fst.Transform_setRotation(e,t),this.node.hasChangedFlags&rm.SCALE&&this.syncBodyScale(),fst.CollisionObject_isKinematicObject(this.body)){var i=fst.RigidBody_getMotionState(this.body);i&&fst.MotionState_setWorldTransform(i,e)}else this.isBodySleeping()&&fst.CollisionObject_activate(this.body,!1)}},e.syncPhysicsToScene=function(){fst.CollisionObject_isStaticOrKinematicObject(this.body)||this.syncPhysicsToGraphics()},e.syncPhysicsToGraphics=function(){if(!this.isBodySleeping()){var t=vst.instance.BT_QUAT_0,e=vst.instance.BT_TRANSFORM_0;fst.RigidBody_getWorldTransform(this.body,e);var i=fst.Transform_getRotationAndOrigin(e,t);if(this.node.worldRotation=zst(M_t,t),this.node.worldPosition=Gst(O_t,i),this._ghostStruct){var n=fst.CollisionObject_getWorldTransform(this.ghost);Vst(fst.Transform_getOrigin(n),this.node.worldPosition),Ust(t,this.node.worldRotation),fst.Transform_setRotation(n,t)}}},e.syncSceneToGhost=function(){if(this.node.hasChangedFlags){var t=vst.instance.BT_QUAT_0,e=fst.CollisionObject_getWorldTransform(this.ghost);Vst(fst.Transform_getOrigin(e),this.node.worldPosition),Ust(t,this.node.worldRotation),fst.Transform_setRotation(e,t),this.node.hasChangedFlags&rm.SCALE&&this.syncGhostScale(),fst.CollisionObject_activate(this.ghost,!1)}},e.syncInitialBody=function(){var t=vst.instance.BT_QUAT_0,e=fst.CollisionObject_getWorldTransform(this.body);Vst(fst.Transform_getOrigin(e),this.node.worldPosition),Ust(t,this.node.worldRotation),fst.Transform_setRotation(e,t),this.syncBodyScale(),fst.CollisionObject_activate(this.body,!1)},e.syncInitialGhost=function(){var t=vst.instance.BT_QUAT_0,e=fst.CollisionObject_getWorldTransform(this.ghost);Vst(fst.Transform_getOrigin(e),this.node.worldPosition),Ust(t,this.node.worldRotation),fst.Transform_setRotation(e,t),this.syncGhostScale(),fst.CollisionObject_activate(this.body,!1)},e.syncBodyScale=function(){for(var t=0;t<this.bodyStruct.wrappedShapes.length;t++)this.bodyStruct.wrappedShapes[t].updateScale();for(var e=0;e<this.wrappedJoints0.length;e++)this.wrappedJoints0[e].updateScale0();for(var i=0;i<this.wrappedJoints1.length;i++)this.wrappedJoints1[i].updateScale1()},e.syncGhostScale=function(){for(var t=0;t<this.ghostStruct.wrappedShapes.length;t++)this.ghostStruct.wrappedShapes[t].updateScale()},e.updateBodyByReAdd=function(){this.bodyIndex>=0&&(this.wrappedWorld.removeSharedBody(this),this.bodyIndex=this.wrappedWorld.bodies.length,this.wrappedWorld.addSharedBody(this))},e.updateGhostByReAdd=function(){this.ghostIndex>=0&&(this.wrappedWorld.removeGhostObject(this),this.ghostIndex=this.wrappedWorld.ghosts.length,this.wrappedWorld.addGhostObject(this))},e.destroy=function(){if(t.sharedBodesMap.delete(this.node.uuid),this.node=null,this.wrappedWorld=null,this._bodyStruct){var e=this._bodyStruct;vst.delWrapper(e.body,pst.BODY_CACHE_NAME),fst._safe_delete(e.motionState,ust.EBulletTypeMotionState),fst._safe_delete(e.compound,ust.EBulletTypeCollisionShape),fst._safe_delete(e.body,ust.EBulletTypeCollisionObject),this._bodyStruct=null}if(this._ghostStruct){var i=this._ghostStruct;fst._safe_delete(i.compound,ust.EBulletTypeCollisionShape),fst._safe_delete(i.ghost,ust.EBulletTypeCollisionObject),this._ghostStruct=null}},e.isBodySleeping=function(){return fst.CollisionObject_isSleeping(this.body)},n(t,[{key:"wrappedBody",get:function(){return this._wrappedBody}},{key:"bodyCompoundShape",get:function(){return this.bodyStruct.compound}},{key:"ghostCompoundShape",get:function(){return this.ghostStruct.compound}},{key:"body",get:function(){return this.bodyStruct.body}},{key:"ghost",get:function(){return this.ghostStruct.ghost}},{key:"collisionFilterGroup",get:function(){return this._collisionFilterGroup},set:function(t){t!==this._collisionFilterGroup&&(this._collisionFilterGroup=t,this.dirty|=b_t.BODY_RE_ADD,this.dirty|=b_t.GHOST_RE_ADD)}},{key:"collisionFilterMask",get:function(){return this._collisionFilterMask},set:function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this.dirty|=b_t.BODY_RE_ADD,this.dirty|=b_t.GHOST_RE_ADD)}},{key:"bodyStruct",get:function(){return this._instantiateBodyStruct(),this._bodyStruct}},{key:"ghostStruct",get:function(){return this._instantiateGhostStruct(),this._ghostStruct}},{key:"bodyEnabled",set:function(t){if(t){if(this.bodyIndex<0){if(0===this.bodyStruct.wrappedShapes.length){if(!this.wrappedBody)return;if(!this.wrappedBody.rigidBody.isDynamic)return}this.bodyIndex=this.wrappedWorld.bodies.length,this.wrappedWorld.addSharedBody(this),this.syncInitialBody()}}else this.bodyIndex>=0&&(0===this.bodyStruct.wrappedShapes.length&&null==this.wrappedBody||0===this.bodyStruct.wrappedShapes.length&&null!=this.wrappedBody&&!this.wrappedBody.isEnabled||0===this.bodyStruct.wrappedShapes.length&&null!=this.wrappedBody&&!this.wrappedBody.rigidBody.enabledInHierarchy)&&(fst.RigidBody_clearState(this.body),this.bodyIndex=-1,this.wrappedWorld.removeSharedBody(this))}},{key:"ghostEnabled",set:function(t){t?this.ghostIndex<0&&this.ghostStruct.wrappedShapes.length>0&&(this.ghostIndex=1,this.wrappedWorld.addGhostObject(this),this.syncInitialGhost()):this.ghostIndex>=0&&0===this.ghostStruct.wrappedShapes.length&&this.ghost&&(this.ghostIndex=-1,this.wrappedWorld.removeGhostObject(this))}},{key:"reference",set:function(t){t?this.ref++:this.ref--,0===this.ref&&this.destroy()}}]),t}();N_t.idCounter=0,N_t.sharedBodesMap=new Map;var F_t=Sst,k_t={},V_t=function(){function t(){this.id=t.idCounter++,this._isEnabled=!1,this._isTrigger=!1,this._isInitialized=!1,this._impl=0,this._compound=0,this.quat=fst.Quat_new(0,0,0,1),this.transform=fst.Transform_new(),this._collider=void 0,this._sharedBody=void 0}var e=t.prototype;return e.updateEventListener=function(){this._sharedBody.wrappedWorld.updateNeedEmitEvents(this.collider.needCollisionEvent||this.collider.needTriggerEvent)},e.setMaterial=function(t){var e=null==t?lot.instance.defaultMaterial:t;if(!this._isTrigger&&this._isEnabled)if(this._compound){k_t[e._uuid]||(k_t[e._uuid]=fst.ccMaterial_new());var i=k_t[e._uuid];fst.ccMaterial_set(i,e.restitution,e.friction,e.rollingFriction,e.spinningFriction),fst.CollisionShape_setMaterial(this._impl,i)}else fst.CollisionObject_setMaterial(this._sharedBody.body,e.restitution,e.friction,e.rollingFriction,e.spinningFriction)},e.setCenter=function(t){on.copy(F_t,t),F_t.multiply(this._collider.node.worldScale),Vst(fst.Transform_getOrigin(this.transform),F_t),this.updateCompoundTransform()},e.setAsTrigger=function(t){this._isTrigger!==t&&(this._isEnabled&&(this._sharedBody.removeShape(this,!t),this._sharedBody.addShape(this,t)),this._isTrigger=t)},e.getAABB=function(t){var e=vst.instance.BT_TRANSFORM_0;fst.Transform_setIdentity(e),fst.Transform_setRotation(e,Ust(vst.instance.BT_QUAT_0,this._collider.node.worldRotation));var i=vst.instance.BT_V3_0,n=vst.instance.BT_V3_1;fst.CollisionShape_getAabb(this._impl,e,i,n),t.halfExtents.x=(fst.Vec3_x(n)-fst.Vec3_x(i))/2,t.halfExtents.y=(fst.Vec3_y(n)-fst.Vec3_y(i))/2,t.halfExtents.z=(fst.Vec3_z(n)-fst.Vec3_z(i))/2,on.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.getBoundingSphere=function(t){t.radius=fst.CollisionShape_getLocalBoundingSphere(this._impl),on.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.initialize=function(t){this._collider=t,this._isInitialized=!0,this._sharedBody=lot.instance.physicsWorld.getSharedBody(this._collider.node),this._sharedBody.reference=!0,this.onComponentSet(),this.setWrapper()},e.setWrapper=function(){vst.isNotEmptyShape(this._impl)&&(fst.CollisionShape_setUserPointer(this._impl,this._impl),vst.setWrapper(this._impl,t.TYPE,this))},e.onLoad=function(){this.setCenter(this._collider.center),this.setAsTrigger(this._collider.isTrigger)},e.onEnable=function(){this._isEnabled=!0,this._sharedBody.addShape(this,this._isTrigger),this.setMaterial(this.collider.sharedMaterial)},e.onDisable=function(){this._isEnabled=!1,this._sharedBody.removeShape(this,this._isTrigger)},e.onDestroy=function(){this._sharedBody.reference=!1,this._collider=null,fst._safe_delete(this.quat,ust.EBulletTypeQuat),fst._safe_delete(this.transform,ust.EBulletTypeTransform),this._compound&&fst._safe_delete(this._compound,ust.EBulletTypeCollisionShape),vst.isNotEmptyShape(this._impl)&&(fst._safe_delete(this._impl,ust.EBulletTypeCollisionShape),vst.delWrapper(this._impl,t.TYPE))},e.updateByReAdd=function(){this._isEnabled&&(this._sharedBody.removeShape(this,this._isTrigger),this._sharedBody.addShape(this,this._isTrigger))},e.getGroup=function(){return this._sharedBody.collisionFilterGroup},e.setGroup=function(t){this._sharedBody.collisionFilterGroup=t},e.addGroup=function(t){this._sharedBody.collisionFilterGroup|=t},e.removeGroup=function(t){this._sharedBody.collisionFilterGroup&=~t},e.getMask=function(){return this._sharedBody.collisionFilterMask},e.setMask=function(t){this._sharedBody.collisionFilterMask=t},e.addMask=function(t){this._sharedBody.collisionFilterMask|=t},e.removeMask=function(t){this._sharedBody.collisionFilterMask&=~t},e.setCompound=function(t){this._compound&&fst.CompoundShape_removeChildShape(this._compound,this._impl),t&&fst.CompoundShape_addChildShape(t,this.transform,this._impl),this._compound=t},e.updateScale=function(){this.setCenter(this._collider.center)},e.updateCompoundTransform=function(){this._compound?fst.CompoundShape_updateChildTransform(this._compound,this._impl,this.transform,!0):this._isEnabled&&!this._isTrigger&&this._sharedBody&&!this._sharedBody.bodyStruct.useCompound&&(this._sharedBody.dirty|=b_t.BODY_RE_ADD)},e.needCompound=function(){return this._collider.type===Ltt.TERRAIN||!this._collider.center.equals(on.ZERO)},n(t,[{key:"attachedRigidBody",get:function(){return this._sharedBody.wrappedBody?this._sharedBody.wrappedBody.rigidBody:null}},{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}},{key:"sharedBody",get:function(){return this._sharedBody}}]),t}();V_t.TYPE="shape",V_t.idCounter=0;var G_t=function(){function t(){this.matrix=[]}var e=t.prototype;return e.get=function(t,e){if(e>t){var i=e;e=t,t=i}return this.matrix[(t*(t+1)>>1)+e-1]},e.set=function(t,e,i){if(e>t){var n=e;e=t,t=n}this.matrix[(t*(t+1)>>1)+e-1]=i?1:0},e.reset=function(){this.matrix.length=0},e.setNumObjects=function(t){this.matrix.length=t*(t-1)>>1},t}(),U_t=function(){function t(){this.data=void 0,this.data={keys:[]}}var e=t.prototype;return e.get=function(t,e){if(t>e){var i=e;e=t,t=i}return this.data[t+"-"+e]},e.set=function(t,e,i){if(t>e){var n=e;e=t,t=n}var r=t+"-"+e;if(null==i){var s=this.data.keys.indexOf(r);if(-1!==s)return this.data.keys.splice(s,1),delete this.data[r],i}return this.get(t,e)||this.data.keys.push(r),this.data[r]=i,this.data[r]},e.reset=function(){this.data={keys:[]}},e.getLength=function(){return this.data.keys.length},e.getKeyByIndex=function(t){return this.data.keys[t]},e.getDataByKey=function(t){return this.data[t]},t}(),z_t=function(){function t(t){this.impl=0,this.event=void 0,this.event=t}var e=t.prototype;return e.getLocalPointOnA=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_localPointA(this.impl))},e.getLocalPointOnB=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_localPointB(this.impl))},e.getWorldPointOnA=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_positionWorldOnA(this.impl))},e.getWorldPointOnB=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_positionWorldOnB(this.impl))},e.getLocalNormalOnA=function(t){if(this.impl){var e=vst.instance.BT_QUAT_0,i=fst.PersistentManifold_getBody0(this.event.impl),n=fst.CollisionObject_getWorldTransform(i);fst.Transform_getRotation(n,e);var r=bst;zst(r,e),Sn.conjugate(r,r),Gst(t,fst.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||on.negate(t,t),on.transformQuat(t,t,r)}},e.getLocalNormalOnB=function(t){if(this.impl){var e=vst.instance.BT_QUAT_0,i=fst.PersistentManifold_getBody1(this.event.impl),n=fst.CollisionObject_getWorldTransform(i);fst.Transform_getRotation(n,e);var r=bst;zst(r,e),Sn.conjugate(r,r),Gst(t,fst.ManifoldPoint_get_m_normalWorldOnB(this.impl)),on.transformQuat(t,t,r)}},e.getWorldNormalOnA=function(t){this.impl&&(Gst(t,fst.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||on.negate(t,t))},e.getWorldNormalOnB=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_normalWorldOnB(this.impl))},n(t,[{key:"isBodyA",get:function(){return this.event.selfCollider.shape.sharedBody.body===fst.PersistentManifold_getBody0(this.event.impl)}}]),t}(),H_t=[],W_t=Sst,j_t=Tst,X_t=Ast,q_t=kst,Y_t=new A_t,K_t=function(){var t=e.prototype;function e(){this._world=void 0,this._broadphase=void 0,this._solver=void 0,this._dispatcher=void 0,this._debugDraw=void 0,this._debugLineCount=0,this._MAX_DEBUG_LINE_COUNT=16384,this._debugDrawFlags=Utt.NONE,this._debugConstraintSize=.3,this._needEmitEvents=!1,this._needSyncAfterEvents=!1,this._needEmitCCTEvents=!1,this.bodies=[],this.ghosts=[],this.ccts=[],this.constraints=[],this.triggerArrayMat=new G_t,this.collisionArrayMat=new G_t,this.contactsDic=new U_t,this.oldContactsDic=new U_t,this.cctShapeEventDic=new U_t,this.cctContactsDic=new U_t,this.cctOldContactsDic=new U_t,pst.CACHE.world=this,this._broadphase=fst.DbvtBroadphase_new(),this._dispatcher=fst.CollisionDispatcher_new(),this._solver=fst.SequentialImpulseConstraintSolver_new(),this._world=fst.ccDiscreteDynamicsWorld_new(this._dispatcher,this._broadphase,this._solver);var t=fst.DebugDraw.implement(P_t);this._debugDraw=t.$$.ptr,fst.CollisionWorld_setDebugDrawer(this._world,this._debugDraw),fst.DebugDraw_setDebugMode(this._debugDraw,cst.DBG_NoDebug),fst.DebugDraw_setAABBColor(this._debugDraw,0,1,1),fst.DebugDraw_setActiveObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setDeactiveObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setWantsDeactivationObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setDisabledDeactivationObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setDisabledSimulationObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setConstraintLimitColor(this._debugDraw,.5,.5,.5)}return t.setDefaultMaterial=function(){},t.setAllowSleep=function(t){fst.ccDiscreteDynamicsWorld_setAllowSleep(this._world,t)},t.setGravity=function(t){fst.DynamicsWorld_setGravity(this._world,Vst(vst.instance.BT_V3_0,t))},t.updateNeedEmitEvents=function(t){if(this.ghosts)if(t)this._needEmitEvents=!0;else{this._needEmitEvents=!1;for(var e=0;e<this.ghosts.length;e++)for(var i=this.ghosts[e].ghostStruct.wrappedShapes,n=0;n<i.length;n++){var r=i[n].collider;if(r.needCollisionEvent||r.needTriggerEvent)return void(this._needEmitEvents=!0)}for(var s=0;s<this.bodies.length;s++)for(var o=this.bodies[s].bodyStruct.wrappedShapes,a=0;a<o.length;a++){var h=o[a].collider;if(h.needCollisionEvent||h.needTriggerEvent)return void(this._needEmitEvents=!0)}}},t.updateNeedEmitCCTEvents=function(t){if(this.ccts)if(t)this._needEmitCCTEvents=!0;else{this._needEmitCCTEvents=!1;for(var e=this.ccts,i=e.length,n=0;n<i;n++)if(e[n].characterController.needCollisionEvent)return void(this._needEmitCCTEvents=!0)}},t.destroy=function(){(this.constraints.length||this.bodies.length||this.ccts.length)&&V("You should destroy all physics component first."),fst._safe_delete(this._world,ust.EBulletTypeCollisionWorld),fst._safe_delete(this._broadphase,ust.EBulletTypeDbvtBroadPhase),fst._safe_delete(this._dispatcher,ust.EBulletTypeCollisionDispatcher),fst._safe_delete(this._solver,ust.EBulletTypeSequentialImpulseConstraintSolver),fst._safe_delete(this._debugDraw,ust.EBulletTypeDebugDraw),this.bodies=null,this.ghosts=null,this.ccts=null,this.constraints=null,this.triggerArrayMat=null,this.collisionArrayMat=null,this.contactsDic=null,this.oldContactsDic=null,this.cctShapeEventDic=null,this.cctShapeEventPool=null,H_t.length=0},t.step=function(t,e,i){void 0===i&&(i=0),(this.bodies.length||this.ghosts.length)&&(void 0===e&&(e=t),fst.DynamicsWorld_stepSimulation(this._world,e,i,t),fst.CollisionWorld_debugDrawWorld(this._world))},t.syncSceneToPhysics=function(){for(var t=this.ghosts.length-1;t>=0;t--){var e=this.ghosts[t];e.updateDirty(),e.syncSceneToGhost()}for(var i=this.bodies.length-1;i>=0;i--){var n=this.bodies[i];n.updateDirty(),n.syncSceneToPhysics()}for(var r=this.ccts,s=r.length-1;s>=0;s--){var o=r[s];o.updateDirty(),o.syncSceneToPhysics()}},t.syncAfterEvents=function(){this._needSyncAfterEvents&&this.syncSceneToPhysics()},t.raycast=function(t,e,i,n){t.computeHit(W_t,e.maxDistance);var r=Vst(vst.instance.BT_V3_0,W_t),s=Vst(vst.instance.BT_V3_1,t.o),o=fst.ccAllRayCallback_static();if(fst.ccAllRayCallback_reset(o,s,r,e.mask>>>0,e.queryTrigger),fst.ccAllRayCallback_setFlags(o,lst.UseSubSimplexConvexCastRaytest),fst.CollisionWorld_rayTest(this._world,s,r,o),fst.RayCallback_hasHit(o)){for(var a=fst.ccAllRayCallback_getHitPointWorld(o),h=fst.ccAllRayCallback_getHitNormalWorld(o),u=fst.ccAllRayCallback_getCollisionShapePtrs(o),l=0,c=fst.int_array_size(u);l<c;l++){Gst(W_t,fst.Vec3_array_at(a,l)),Gst(j_t,fst.Vec3_array_at(h,l));var _=vst.getWrapper(fst.int_array_at(u,l),V_t.TYPE),d=i.add();n.push(d),d._assign(W_t,on.distance(t.o,W_t),_.collider,j_t)}return!0}return!1},t.raycastClosest=function(t,e,i){t.computeHit(W_t,e.maxDistance);var n=Vst(vst.instance.BT_V3_0,W_t),r=Vst(vst.instance.BT_V3_1,t.o),s=fst.ccClosestRayCallback_static();if(fst.ccClosestRayCallback_reset(s,r,n,e.mask>>>0,e.queryTrigger),fst.ccClosestRayCallback_setFlags(s,lst.UseSubSimplexConvexCastRaytest),fst.CollisionWorld_rayTest(this._world,r,n,s),fst.RayCallback_hasHit(s)){Gst(W_t,fst.ccClosestRayCallback_getHitPointWorld(s)),Gst(j_t,fst.ccClosestRayCallback_getHitNormalWorld(s));var o=vst.getWrapper(fst.ccClosestRayCallback_getCollisionShapePtr(s),V_t.TYPE);return i._assign(W_t,on.distance(t.o,W_t),o.collider,j_t),!0}return!1},t.sweepBox=function(t,i,n,r,s,o){var a=vst.instance.BT_V3_0;return Vst(a,i),e._sweepBoxGeometry||(e._sweepBoxGeometry=fst.BoxShape_new(a)),fst.BoxShape_setUnscaledHalfExtents(e._sweepBoxGeometry,a),this.sweep(t,e._sweepBoxGeometry,n,r,s,o)},t.sweepBoxClosest=function(t,i,n,r,s){var o=vst.instance.BT_V3_0;return Vst(o,i),e._sweepBoxGeometry||(e._sweepBoxGeometry=fst.BoxShape_new(o)),fst.BoxShape_setUnscaledHalfExtents(e._sweepBoxGeometry,o),this.sweepClosest(t,e._sweepBoxGeometry,n,r,s)},t.sweepSphere=function(t,i,n,r,s){return e._sweepSphereGeometry||(e._sweepSphereGeometry=fst.SphereShape_new(i)),fst.SphereShape_setUnscaledRadius(e._sweepSphereGeometry,i),this.sweep(t,e._sweepSphereGeometry,Sn.IDENTITY,n,r,s)},t.sweepSphereClosest=function(t,i,n,r){return e._sweepSphereGeometry||(e._sweepSphereGeometry=fst.SphereShape_new(i)),fst.SphereShape_setUnscaledRadius(e._sweepSphereGeometry,i),this.sweepClosest(t,e._sweepSphereGeometry,Sn.IDENTITY,n,r)},t.sweepCapsule=function(t,i,n,r,s,o,a){return e._sweepCapsuleGeometry||(e._sweepCapsuleGeometry=fst.CapsuleShape_new(i,n)),fst.CapsuleShape_updateProp(e._sweepCapsuleGeometry,i,.5*n,1),this.sweep(t,e._sweepCapsuleGeometry,r,s,o,a)},t.sweepCapsuleClosest=function(t,i,n,r,s,o){return e._sweepCapsuleGeometry||(e._sweepCapsuleGeometry=fst.CapsuleShape_new(i,n)),fst.CapsuleShape_updateProp(e._sweepCapsuleGeometry,i,.5*n,1),this.sweepClosest(t,e._sweepCapsuleGeometry,r,s,o)},t.sweep=function(t,e,i,n,r,s){var o=vst.instance.BT_TRANSFORM_0,a=vst.instance.BT_TRANSFORM_1,h=vst.instance.BT_QUAT_0;Vst(fst.Transform_getOrigin(o),t.o),Ust(h,i),fst.Transform_setRotation(o,h),t.computeHit(W_t,n.maxDistance),Vst(fst.Transform_getOrigin(a),W_t),Ust(h,i),fst.Transform_setRotation(a,h);var u=fst.ccAllConvexCallback_static();if(fst.ccAllConvexCallback_reset(u,o,a,n.mask>>>0,n.queryTrigger),fst.CollisionWorld_convexSweepTest(this._world,e,o,a,u,0),fst.ConvexCallback_hasHit(u)){for(var l=fst.ccAllConvexCallback_getHitPointWorld(u),c=fst.ccAllConvexCallback_getHitNormalWorld(u),_=fst.ccAllConvexCallback_getCollisionShapePtrs(u),d=0,f=fst.int_array_size(_);d<f;d++){Gst(W_t,fst.Vec3_array_at(l,d)),Gst(j_t,fst.Vec3_array_at(c,d));var p=vst.getWrapper(fst.int_array_at(_,d),V_t.TYPE),m=r.add();s.push(m),m._assign(W_t,on.distance(t.o,W_t),p.collider,j_t)}return!0}return!1},t.sweepClosest=function(t,e,i,n,r){var s=vst.instance.BT_TRANSFORM_0,o=vst.instance.BT_TRANSFORM_1,a=vst.instance.BT_QUAT_0;Vst(fst.Transform_getOrigin(s),t.o),Ust(a,i),fst.Transform_setRotation(s,a),t.computeHit(W_t,n.maxDistance),Vst(fst.Transform_getOrigin(o),W_t),Ust(a,i),fst.Transform_setRotation(o,a);var h=fst.ccClosestConvexCallback_static();if(fst.ccClosestConvexCallback_reset(h,s,o,n.mask>>>0,n.queryTrigger),fst.CollisionWorld_convexSweepTest(this._world,e,s,o,h,0),fst.ConvexCallback_hasHit(h)){Gst(W_t,fst.ccClosestConvexCallback_getHitPointWorld(h)),Gst(j_t,fst.ccClosestConvexCallback_getHitNormalWorld(h));var u=vst.getWrapper(fst.ccClosestConvexCallback_getCollisionShapePtr(h),V_t.TYPE);return r._assign(W_t,on.distance(t.o,W_t),u.collider,j_t),!0}return!1},t.getSharedBody=function(t,e){return N_t.getSharedBody(t,this,e)},t.addSharedBody=function(t){if(this.bodies.indexOf(t)<0){this.bodies.push(t);var e=t.collisionFilterGroup,i=t.collisionFilterMask;fst.DynamicsWorld_addRigidBody(this._world,t.body,e>>>0,i>>>0)}},t.removeSharedBody=function(t){var e=this.bodies.indexOf(t);e>=0&&(ae(this.bodies,e),fst.DynamicsWorld_removeRigidBody(this._world,t.body))},t.addGhostObject=function(t){if(this.ghosts.indexOf(t)<0){this.ghosts.push(t);var e=t.collisionFilterGroup,i=t.collisionFilterMask;fst.CollisionWorld_addCollisionObject(this._world,t.ghost,e>>>0,i>>>0)}},t.removeGhostObject=function(t){var e=this.ghosts.indexOf(t);e>=0&&(ae(this.ghosts,e),fst.CollisionWorld_removeCollisionObject(this._world,t.ghost))},t.addCCT=function(t){if(this.ccts.indexOf(t)<0){this.ccts.push(t);var e=fst.CharacterController_getGhostObject(t.impl),i=t.getGroup(),n=t.getMask();fst.CollisionWorld_addCollisionObject(this._world,e,i>>>0,n>>>0),fst.DynamicsWorld_addAction(this._world,t.impl)}},t.removeCCT=function(t){var e=this.ccts.indexOf(t);if(e>=0){ae(this.ccts,e);var i=fst.CharacterController_getGhostObject(t.impl);fst.CollisionWorld_removeCollisionObject(this._world,i),fst.DynamicsWorld_removeAction(this._world,t.impl)}},t.addConstraint=function(t){var e=this.constraints.indexOf(t);e<0&&(this.constraints.push(t),fst.DynamicsWorld_addConstraint(this.impl,t.impl,!t.constraint.enableCollision),t.index=e)},t.removeConstraint=function(t){var e=this.constraints.indexOf(t);e>=0&&(this.constraints.splice(e,1),fst.DynamicsWorld_removeConstraint(this.impl,t.impl),t.index=-1)},t.emitEvents=function(){this._needSyncAfterEvents=!1,this._needEmitEvents&&(this.gatherConatactData(),this.emitCollisionAndTriggerEvent(),this.emitCCTTriggerEvent()),this._needEmitCCTEvents&&this.emitCCTCollisionEvent()},t.emitCollisionAndTriggerEvent=function(){for(var t=this.contactsDic.getLength();t--;){H_t.push.apply(H_t,gst.contacts),gst.contacts.length=0;var e=this.contactsDic.getKeyByIndex(t),i=this.contactsDic.getDataByKey(e),n=i.shape0,r=i.shape1;this.oldContactsDic.set(n.id,r.id,i);var s=n.collider,o=r.collider;if(s&&o){if(s.isTrigger||o.isTrigger)this.triggerArrayMat.get(n.id,r.id)?mst.type="onTriggerStay":(mst.type="onTriggerEnter",this.triggerArrayMat.set(n.id,r.id,!0)),mst.impl=i.impl,mst.selfCollider=s,mst.otherCollider=o,s.emit(mst.type,mst),mst.selfCollider=o,mst.otherCollider=s,o.emit(mst.type,mst),this._needSyncAfterEvents=!0;else{var a=s.attachedRigidBody,h=o.attachedRigidBody;if(a&&h){if(a.isSleeping&&h.isSleeping)continue}else if(!a&&h){if(h.isSleeping)continue}else if(!h&&a&&a.isSleeping)continue;this.collisionArrayMat.get(n.id,r.id)?gst.type="onCollisionStay":(gst.type="onCollisionEnter",this.collisionArrayMat.set(n.id,r.id,!0));for(var u=0;u<i.contacts.length;u++){var l=i.contacts[u];if(H_t.length>0){var c=H_t.pop();c.impl=l,gst.contacts.push(c)}else{var _=new z_t(gst);_.impl=l,gst.contacts.push(_)}}gst.impl=i.impl,gst.selfCollider=s,gst.otherCollider=o,s.emit(gst.type,gst),gst.selfCollider=o,gst.otherCollider=s,o.emit(gst.type,gst),this._needSyncAfterEvents=!0}null==this.oldContactsDic.get(n.id,r.id)&&this.oldContactsDic.set(n.id,r.id,i)}}for(var d=this.oldContactsDic.getLength();d--;){var f=this.oldContactsDic.getKeyByIndex(d),p=this.oldContactsDic.getDataByKey(f),m=p.shape0,g=p.shape1,y=m.collider,v=g.collider;if(y&&v){var S=y.isTrigger||v.isTrigger;null==this.contactsDic.getDataByKey(f)&&(S?this.triggerArrayMat.get(m.id,g.id)&&(mst.type="onTriggerExit",mst.selfCollider=y,mst.otherCollider=v,y.emit(mst.type,mst),mst.selfCollider=v,mst.otherCollider=y,v.emit(mst.type,mst),this.triggerArrayMat.set(m.id,g.id,!1),this.oldContactsDic.set(m.id,g.id,null),this._needSyncAfterEvents=!0):this.collisionArrayMat.get(m.id,g.id)&&(H_t.push.apply(H_t,gst.contacts),gst.contacts.length=0,gst.type="onCollisionExit",gst.selfCollider=y,gst.otherCollider=v,y.emit(gst.type,gst),gst.selfCollider=v,gst.otherCollider=y,v.emit(gst.type,gst),this.collisionArrayMat.set(m.id,g.id,!1),this.oldContactsDic.set(m.id,g.id,null),this._needSyncAfterEvents=!0))}}this.contactsDic.reset()},t.emitCCTTriggerEvent=function(){for(var t=this.cctContactsDic.getLength();t--;){var e=this.cctContactsDic.getKeyByIndex(t),i=this.cctContactsDic.getDataByKey(e),n=i.shape,r=i.cct;this.cctOldContactsDic.set(n.id,r.id,i);var s=n.collider,o=r.characterController;s&&o&&(s.isTrigger&&(this.triggerArrayMat.get(n.id,r.id)?yst.type="onControllerTriggerStay":(yst.type="onControllerTriggerEnter",this.triggerArrayMat.set(n.id,r.id,!0)),yst.impl=i.impl,yst.collider=s,yst.characterController=o,s.emit(yst.type,yst),yst.collider=s,yst.characterController=o,o.emit(yst.type,yst),this._needSyncAfterEvents=!0),null==this.cctOldContactsDic.get(n.id,r.id)&&this.cctOldContactsDic.set(n.id,r.id,i))}for(var a=this.cctOldContactsDic.getLength();a--;){var h=this.cctOldContactsDic.getKeyByIndex(a),u=this.cctOldContactsDic.getDataByKey(h),l=u.shape,c=u.cct,_=l.collider,d=c.characterController;if(_&&d){var f=_.isTrigger;null==this.cctContactsDic.getDataByKey(h)&&f&&this.triggerArrayMat.get(l.id,c.id)&&(yst.type="onControllerTriggerExit",yst.collider=_,yst.characterController=d,_.emit(yst.type,yst),yst.collider=_,yst.characterController=d,d.emit(yst.type,yst),this.triggerArrayMat.set(l.id,c.id,!1),this.cctOldContactsDic.set(l.id,c.id,null),this._needSyncAfterEvents=!0)}}this.cctContactsDic.reset()},t.emitCCTCollisionEvent=function(){for(var t=this.cctShapeEventDic.getLength();t--;){var e,i=this.cctShapeEventDic.getKeyByIndex(t),n=this.cctShapeEventDic.getDataByKey(i),r=n.BulletCharacterController,s=n.BulletShape,o=n.worldPos,a=n.worldNormal,h=n.motionDir,u=n.motionLength;Y_t.controller=r.characterController,Y_t.collider=s.collider,Y_t.worldPosition.set(o.x,o.y,o.z),Y_t.worldNormal.set(a.x,a.y,a.z),Y_t.motionDirection.set(h.x,h.y,h.z),Y_t.motionLength=u,null===(e=Y_t.controller)||void 0===e||e.emit("onControllerColliderHit",Y_t),this._needSyncAfterEvents=!0}this.cctShapeEventDic.reset()},t.gatherConatactData=function(){for(var t=fst.Dispatcher_getNumManifolds(this._dispatcher),e=0;e<t;e++)for(var i=fst.Dispatcher_getManifoldByIndexInternal(this._dispatcher,e),n=fst.PersistentManifold_getNumContacts(i),r=0;r<n;r++){var s=fst.PersistentManifold_getContactPoint(i,r),o=fst.ManifoldPoint_getShape0(s),a=fst.ManifoldPoint_getShape1(s),h=!1;if(!h){var u=vst.getWrapper(o,V_t.TYPE),l=vst.getWrapper(a,V_t.TYPE);if(u&&l&&(h=!0,u.collider.needTriggerEvent||l.collider.needTriggerEvent||u.collider.needCollisionEvent||l.collider.needCollisionEvent)){var c=this.contactsDic.get(u.id,l.id);c||(c=this.contactsDic.set(u.id,l.id,{shape0:u,shape1:l,contacts:[],impl:i})),c.contacts.push(s)}}if(!h){var _=vst.getWrapper(o,V_t.TYPE),d=vst.getWrapper(a,pst.CCT_CACHE_NAME);if(_&&d&&(h=!0,_.collider.needTriggerEvent)){var f=this.cctContactsDic.get(_.id,d.id);f||(f=this.cctContactsDic.set(_.id,d.id,{shape:_,cct:d,contacts:[],impl:i})),f.contacts.push(s),h=!0}}if(!h){var p=vst.getWrapper(o,pst.CCT_CACHE_NAME),m=vst.getWrapper(a,V_t.TYPE);if(m&&p&&(h=!0,m.collider.needTriggerEvent)){var g=this.cctContactsDic.get(m.id,p.id);g||(g=this.cctContactsDic.set(m.id,p.id,{shape:m,cct:p,contacts:[],impl:i})),g.contacts.push(s),h=!0}}}},t._setDebugDrawMode=function(){var t=0;this._debugDrawFlags&Utt.WIRE_FRAME&&(t|=cst.DBG_DrawWireframe),this._debugDrawFlags&Utt.CONSTRAINT&&(t|=cst.DBG_DrawConstraints,t|=cst.DBG_DrawConstraintLimits),this._debugDrawFlags&Utt.AABB&&(t|=cst.DBG_DrawAabb),fst.DebugDraw_setDebugMode(this._debugDraw,t)},t._getDebugRenderer=function(){var t,e=null===(t=fN.root.mainWindow)||void 0===t?void 0:t.cameras;return e?0===e.length?null:e[0]?(e[0].initGeometryRenderer(),e[0].geometryRenderer):null:null},t.onDebugDrawLine=function(t,e,i){var n=this._getDebugRenderer();n&&this._debugLineCount<this._MAX_DEBUG_LINE_COUNT&&(this._debugLineCount++,Gst(W_t,t),Gst(j_t,e),Gst(X_t,i),q_t.set(255*X_t.x,255*X_t.y,255*X_t.z,255),n.addLine(W_t,j_t,q_t))},t.onClearLines=function(){this._debugLineCount=0},n(e,[{key:"impl",get:function(){return this._world}},{key:"debugDrawFlags",get:function(){return this._debugDrawFlags},set:function(t){this._debugDrawFlags=t,this._debugDraw&&this._setDebugDrawMode()}},{key:"debugDrawConstraintSize",get:function(){return this._debugConstraintSize},set:function(t){this._debugConstraintSize=t;for(var e=0;e<this.constraints.length;e++)this.constraints[e].updateDebugDrawSize()}}]),e}();K_t._sweepBoxGeometry=void 0,K_t._sweepSphereGeometry=void 0,K_t._sweepCapsuleGeometry=void 0;var J_t=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.updateSize=function(){var t=vst.instance.BT_V3_0;Vst(t,this.getMinUnscaledHalfExtents(z$)),fst.BoxShape_setUnscaledHalfExtents(this.impl,t),this.updateCompoundTransform()},i.onComponentSet=function(){var t=vst.instance.BT_V3_0;Vst(t,this.getMinUnscaledHalfExtents(z$)),this._impl=fst.BoxShape_new(t),this.updateScale()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=vst.instance.BT_V3_0;fst.CollisionShape_setLocalScaling(this._impl,Vst(e,this.getMinScale(z$))),this.updateCompoundTransform()},i.getMinUnscaledHalfExtents=function(t){var e=this.collider.size,i=H$(z$.set(this._collider.node.worldScale)),n=lot.instance.minVolumeSize,r=e.x/2,s=e.y/2,o=e.z/2,a=r*i.x<n?n/i.x:r,h=s*i.y<n?n/i.y:s,u=o*i.z<n?n/i.z:o;return t.set(a,h,u),t},i.getMinScale=function(t){var e=this.collider.size,i=H$(z$.set(this._collider.node.worldScale)),n=lot.instance.minVolumeSize,r=e.x/2,s=e.y/2,o=e.z/2,a=r*i.x<n?n/r:i.x,h=s*i.y<n?n/s:i.y,u=o*i.z<n?n/o:i.z;return t.set(a,h,u),t},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),Q_t=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.updateRadius=function(){fst.SphereShape_setUnscaledRadius(this.impl,this.getMinUnscaledRadius()),this.updateCompoundTransform()},i.onComponentSet=function(){this._impl=fst.SphereShape_new(this.getMinUnscaledRadius()),this.updateScale()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=this.getMinScale();Sst.set(e,e,e);var i=vst.instance.BT_V3_0;fst.CollisionShape_setLocalScaling(this._impl,Vst(i,Sst)),this.updateCompoundTransform()},i.getMinUnscaledRadius=function(){var t=this.collider.radius,e=Math.abs(Hi(this._collider.node.worldScale)),i=lot.instance.minVolumeSize;return e*t<i?i/e:t},i.getMinScale=function(){var t=this.collider.radius,e=Math.abs(Hi(this._collider.node.worldScale)),i=lot.instance.minVolumeSize;return e*t<i?i/t:e},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),Z_t=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setCylinderHeight=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.cylinderHeight,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){this._impl=fst.CapsuleShape_new(.5,1),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,n){var r,s,o=n,a=i;1===a?(r=t*Math.abs(Wi(o.x,o.z)),s=e/2*Math.abs(o.y)):0===a?(r=t*Math.abs(Wi(o.y,o.z)),s=e/2*Math.abs(o.x)):(r=t*Math.abs(Wi(o.x,o.y)),s=e/2*Math.abs(o.z)),fst.CapsuleShape_updateProp(this._impl,r,s,a),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),$_t=function(){function t(t,e){this.key=void 0,this.ref=0,this.bulletBvhTriangleMeshShapePtr=void 0,this.btTriangleMeshPtr=0,this.reference=!0,this.key=t,this.btTriangleMeshPtr=fst.TriangleMesh_new(),Hst(this.btTriangleMeshPtr,e),this.bulletBvhTriangleMeshShapePtr=fst.BvhTriangleMeshShape_new(this.btTriangleMeshPtr,!0,!0)}return t.getBulletBvhTriangleMeshShape=function(e,i){var n;return t.BulletBvhTriangleMeshShapeMap.has(e)?(n=t.BulletBvhTriangleMeshShapeMap.get(e)).reference=!0:(n=new t(e,i),t.BulletBvhTriangleMeshShapeMap.set(e,n)),n},t.prototype.destroy=function(){this.bulletBvhTriangleMeshShapePtr&&fst._safe_delete(ust.EBulletTypeCollisionShape,this.bulletBvhTriangleMeshShapePtr),this.btTriangleMeshPtr&&fst._safe_delete(ust.EBulletTypeTriangleMesh,this.btTriangleMeshPtr),t.BulletBvhTriangleMeshShapeMap.delete(this.key)},n(t,[{key:"reference",set:function(t){t?this.ref++:this.ref--,0===this.ref&&this.destroy()}}]),t}();$_t.BulletBvhTriangleMeshShapeMap=new Map;var tdt,edt,idt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).btBVHMeshShape=void 0,e.refBtTriangleMesh=0,e}s(e,t);var i=e.prototype;return i.setMesh=function(t){if(this._isInitialized){this._impl&&vst.isNotEmptyShape(this._impl)&&(this._compound&&fst.CompoundShape_removeChildShape(this._compound,this._impl),fst._safe_delete(this._impl,ust.EBulletTypeCollisionShape),vst.delWrapper(this._impl,V_t.TYPE),this._impl=0);var e=t;if(e&&e.renderingSubMeshes.length>0){if(this.collider.convex){var i=this._getBtTriangleMesh(e);this._impl=fst.ConvexTriangleMeshShape_new(i)}else this.btBVHMeshShape=$_t.getBulletBvhTriangleMeshShape(e.hash,e),this._impl=fst.ScaledBvhTriangleMeshShape_new(this.btBVHMeshShape.bulletBvhTriangleMeshShapePtr,1,1,1);var n=vst.instance.BT_V3_0;Vst(n,this._collider.node.worldScale),fst.CollisionShape_setLocalScaling(this._impl,n),fst.CollisionShape_setMargin(this._impl,.01),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=fst.EmptyShape_static()}},i.onComponentSet=function(){this.setMesh(this.collider.mesh)},i.onDestroy=function(){this.collider.convex?this.refBtTriangleMesh&&fst._safe_delete(this.refBtTriangleMesh,ust.EBulletTypeTriangleMesh):this.btBVHMeshShape&&(this.btBVHMeshShape.reference=!1),t.prototype.onDestroy.call(this)},i.updateScale=function(){t.prototype.updateScale.call(this);var e=vst.instance.BT_V3_0;Vst(e,this._collider.node.worldScale),fst.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i._getBtTriangleMesh=function(t){return this.refBtTriangleMesh=fst.TriangleMesh_new(),Hst(this.refBtTriangleMesh,t),this.refBtTriangleMesh},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),ndt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){var t=vst.instance.BT_V3_0;fst.Vec3_set(t,.5,1,.5),this._impl=fst.CylinderShape_new(t),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,n){var r,s,o=n,a=i;1===a?(s=e*Math.abs(o.y),r=t*Math.abs(Wi(o.x,o.z))):0===a?(s=e*Math.abs(o.x),r=t*Math.abs(Wi(o.y,o.z))):(s=e*Math.abs(o.z),r=t*Math.abs(Wi(o.x,o.y))),fst.CylinderShape_updateProp(this._impl,r,s/2,a),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),rdt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){this._impl=fst.ConeShape_new(.5,1),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,n){var r,s,o=n,a=i;1===a?(s=e*Math.abs(o.y),r=t*Math.abs(Wi(o.x,o.z))):0===a?(s=e*Math.abs(o.x),r=t*Math.abs(Wi(o.y,o.z))):(s=e*Math.abs(o.z),r=t*Math.abs(Wi(o.x,o.y))),fst.ConeShape_setRadius(this._impl,r),fst.ConeShape_setHeight(this._impl,s),fst.ConeShape_setConeUpIndex(this._impl,a);var h=vst.instance.BT_V3_0;fst.Vec3_set(h,1,1,1),fst.CollisionShape_setLocalScaling(this._impl,h),this.updateCompoundTransform()},n(e,[{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}}]),e}(V_t),sdt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._bufPtr=0,e._tileSize=0,e._localOffset=new on,e}s(e,t);var i=e.prototype;return i.setTerrain=function(t){if(this._isInitialized)if(this._impl&&vst.isNotEmptyShape(this._impl))k("[Physics][Bullet]: change the terrain asset after initialization is not support.");else{var e=t;if(e){this._tileSize=e.tileSize;var i=e.getVertexCountI(),n=e.getVertexCountJ();this._bufPtr=fst._malloc(4*i*n);for(var r=0,s=Number.MAX_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER,a=0;a<n;a++)for(var h=0;h<i;h++){var u=e.getHeight(h,a);fst._write_f32(this._bufPtr+r,u),s>u&&(s=u),u>o&&(o=u),r+=4}o+=.01,s-=.01,this._localOffset.set((i-1)/2*this._tileSize,(o+s)/2,(n-1)/2*this._tileSize),this._impl=fst.TerrainShape_new(i,n,this._bufPtr,1,s,o);var l=vst.instance.BT_V3_0;fst.Vec3_set(l,this._tileSize,1,this._tileSize),fst.CollisionShape_setLocalScaling(this._impl,l),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=fst.EmptyShape_static()}},i.onComponentSet=function(){this.setTerrain(this.collider.terrain)},i.onDestroy=function(){this._bufPtr&&fst._free(this._bufPtr),t.prototype.onDestroy.call(this)},i.setCenter=function(t){on.copy(Sst,t),Sst.add(this._localOffset),Vst(fst.Transform_getOrigin(this.transform),Sst),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),odt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setShapeType=function(){},i.setVertices=function(){},i.onComponentSet=function(){this._impl=fst.SimplexShape_new();for(var t=this.collider.shapeType,e=this.collider.vertices,i=vst.instance.BT_V3_0,n=0;n<t;n++)fst.SimplexShape_addVertex(this._impl,Vst(i,e[n]));fst.CollisionShape_setLocalScaling(this._impl,Vst(i,this._collider.node.worldScale))},i.onLoad=function(){t.prototype.onLoad.call(this),this.collider.updateVertices()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=vst.instance.BT_V3_0;fst.CollisionShape_setLocalScaling(this._impl,Vst(e,this._collider.node.worldScale))},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),adt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setNormal=function(t){Vst(fst.StaticPlaneShape_getPlaneNormal(this.impl),t),this.updateCompoundTransform()},i.setConstant=function(t){fst.StaticPlaneShape_setPlaneConstant(this.impl,t),this.updateCompoundTransform()},i.updateScale=function(){t.prototype.updateScale.call(this);var e=vst.instance.BT_V3_0;Vst(e,this._collider.node.worldScale),fst.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i.onComponentSet=function(){var t=vst.instance.BT_V3_0;Vst(t,this.collider.normal),this._impl=fst.StaticPlaneShape_new(t,this.collider.constant),this.updateScale()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),hdt=function(){function t(){this.dirty=0,this.index=-1,this._impl=0,this._com=void 0,this._rigidBody=void 0,this._connectedBody=null,this._collided=!1}var e=t.prototype;return e.setConnectedBody=function(t){if(this._connectedBody!==t){var e=this._connectedBody;e&&e.body.sharedBody.removeJoint(this,1);var i=this._rigidBody.body.sharedBody;i.removeJoint(this,0),this._impl&&(i.wrappedWorld.removeConstraint(this),fst._safe_delete(this._impl,ust.EBulletTypeTypedConstraint)),this._connectedBody=t;var n=this._connectedBody;this.onComponentSet(),this.setEnableCollision(this._collided),i.wrappedWorld.addConstraint(this),i.addJoint(this,0),n&&n.body.sharedBody.addJoint(this,1)}},e.setEnableCollision=function(t){this._collided!==t&&(this._collided=t,this.updateByReAdd())},e.updateByReAdd=function(){if(this._rigidBody&&this.index>=0){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.removeConstraint(this),t.wrappedWorld.addConstraint(this)}},e.initialize=function(t){this._com=t,this._rigidBody=t.attachedBody,this._connectedBody=t.connectedBody,this._collided=t.enableCollision,this.onComponentSet(),this.setEnableCollision(this._collided)},e.updateDebugDrawSize=function(){if(this.impl){var t=lot.instance.physicsWorld.debugDrawConstraintSize;fst.TypedConstraint_setDbgDrawSize(this.impl,t)}},e.onEnable=function(){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.addConstraint(this),t.addJoint(this,0);var e=this._connectedBody;e&&e.body.sharedBody.addJoint(this,1)},e.onDisable=function(){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.removeConstraint(this),t.removeJoint(this,0);var e=this._connectedBody;e&&e.body.sharedBody.removeJoint(this,1)},e.onDestroy=function(){fst._safe_delete(this._impl,ust.EBulletTypeTypedConstraint),this._com=null,this._rigidBody=null,this._connectedBody=null},n(t,[{key:"impl",get:function(){return this._impl}},{key:"constraint",get:function(){return this._com}}]),t}(),udt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setPivotA=function(){var t=this.constraint,e=vst.instance.BT_V3_0;on.multiply(Sst,t.node.worldScale,t.pivotA),Vst(e,Sst),fst.P2PConstraint_setPivotA(this._impl,e),t.connectedBody||this.setPivotB(t.pivotB)},i.setPivotB=function(){var t=this.constraint,e=this._rigidBody.node,i=vst.instance.BT_V3_0,n=t.connectedBody;n?(on.multiply(Sst,n.node.worldScale,t.pivotB),Vst(i,Sst)):(on.multiply(Sst,e.worldScale,t.pivotA),on.transformQuat(Sst,Sst,e.worldRotation),on.add(Sst,Sst,e.worldPosition),Vst(i,Sst)),fst.P2PConstraint_setPivotB(this._impl,i)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:fst.TypedConstraint_getFixedBody(),n=vst.instance.BT_V3_0,r=vst.instance.BT_V3_1;this._impl=fst.P2PConstraint_new(e,i,n,r),this.setPivotA(this.constraint.pivotA),this.setPivotB(this.constraint.pivotB),this.updateDebugDrawSize()},i.updateScale0=function(){this.setPivotA(this.constraint.pivotA)},i.updateScale1=function(){this.setPivotB(this.constraint.pivotB)},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(hdt),ldt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setBreakForce=function(t){fst.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.setBreakTorque=function(){},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:fst.TypedConstraint_getFixedBody(),n=vst.instance.BT_TRANSFORM_0,r=vst.instance.BT_TRANSFORM_1;this._impl=fst.FixedConstraint_new(e,i,n,r),this.setBreakForce(this.constraint.breakForce),this.setBreakTorque(this.constraint.breakTorque),this.updateFrames(),this.updateDebugDrawSize()},i.updateFrames=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.sharedBody,i=Sst,n=bst,r=vst.instance.BT_TRANSFORM_0,s=vst.instance.BT_TRANSFORM_1,o=vst.instance.BT_QUAT_0,a=Cst;if(In.fromRT(a,e.node.worldRotation,e.node.worldPosition),In.invert(a,a),In.getRotation(n,a),In.getTranslation(i,a),Vst(fst.Transform_getOrigin(r),i),Ust(o,n),fst.Transform_setRotation(r,o),t){var h=t.body.sharedBody;In.fromRT(a,h.node.worldRotation,h.node.worldPosition),In.invert(a,a),In.getRotation(n,a),In.getTranslation(i,a),Vst(fst.Transform_getOrigin(s),i),Ust(o,n),fst.Transform_setRotation(s,o)}else fst.Transform_setIdentity(s);fst.FixedConstraint_setFrames(this._impl,r,s)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(hdt),cdt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setPivotA=function(){this.updateFrames()},i.setPivotB=function(){this.updateFrames()},i.setAxis=function(){this.updateFrames()},i.setLimitEnabled=function(){this.constraint.limitEnabled?fst.HingeConstraint_setLimit(this._impl,Bi(this.constraint.lowerLimit),Bi(this.constraint.upperLimit),.9,.3,1):fst.HingeConstraint_setLimit(this._impl,1,0,.9,.3,1)},i.setLowerLimit=function(){this.constraint.limitEnabled&&fst.HingeConstraint_setLimit(this._impl,Bi(this.constraint.lowerLimit),Bi(this.constraint.upperLimit),.9,.3,1)},i.setUpperLimit=function(){this.constraint.limitEnabled&&fst.HingeConstraint_setLimit(this._impl,Bi(this.constraint.lowerLimit),Bi(this.constraint.upperLimit),.9,.3,1)},i.setMotorEnabled=function(t){fst.HingeConstraint_enableMotor(this._impl,t);var e=-this.constraint.motorVelocity/60,i=Wst(this.constraint.motorForceLimit,lot.instance.fixedTimeStep);fst.HingeConstraint_setMotorVelocity(this._impl,e),fst.HingeConstraint_setMaxMotorImpulse(this._impl,i)},i.setMotorVelocity=function(t){if(this.constraint.motorEnabled){var e=-t/60;fst.HingeConstraint_setMotorVelocity(this._impl,e)}},i.setMotorForceLimit=function(t){if(this.constraint.motorEnabled){var e=Wst(t,lot.instance.fixedTimeStep);fst.HingeConstraint_setMaxMotorImpulse(this._impl,e)}},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:fst.TypedConstraint_getFixedBody(),n=vst.instance.BT_TRANSFORM_0,r=vst.instance.BT_TRANSFORM_1;this._impl=fst.HingeConstraint_new(e,i,n,r),this.setLimitEnabled(this.constraint.limitEnabled),this.setLowerLimit(this.constraint.lowerLimit),this.setUpperLimit(this.constraint.upperLimit),this.setMotorEnabled(this.constraint.motorEnabled),this.setMotorVelocity(this.constraint.motorVelocity),this.setMotorForceLimit(this.constraint.motorForceLimit),this.updateFrames(),this.updateDebugDrawSize()},i.updateFrames=function(){var t=this.constraint,e=t.node,i=Sst,n=bst,r=Est,s=vst.instance.BT_TRANSFORM_0;on.multiply(i,e.worldScale,t.pivotA),Vst(fst.Transform_getOrigin(s),i);var o=vst.instance.BT_QUAT_0;on.normalize(i,t.axis),Sn.rotationTo(r,on.UNIT_Z,i),Ust(o,r),fst.Transform_setRotation(s,o);var a=vst.instance.BT_TRANSFORM_1,h=this.constraint.connectedBody;h?(on.multiply(i,h.node.worldScale,t.pivotB),Sn.multiply(r,e.worldRotation,r),Sn.invert(n,h.node.worldRotation),Sn.multiply(r,n,r)):(on.multiply(i,e.worldScale,t.pivotA),on.transformQuat(i,i,e.worldRotation),on.add(i,i,e.worldPosition),Sn.multiply(r,e.worldRotation,r)),Vst(fst.Transform_getOrigin(a),i),Ust(o,r),fst.Transform_setRotation(a,o),fst.HingeConstraint_setFrames(this._impl,s,a)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(hdt);!function(t){t[t.RO_XYZ=0]="RO_XYZ",t[t.RO_XZY=1]="RO_XZY",t[t.RO_YXZ=2]="RO_YXZ",t[t.RO_YZX=3]="RO_YZX",t[t.RO_ZXY=4]="RO_ZXY",t[t.RO_ZYX=5]="RO_ZYX"}(tdt||(tdt={})),function(t){t[t.X=0]="X",t[t.Y=1]="Y",t[t.Z=2]="Z",t[t.TWIST=3]="TWIST",t[t.SWING1=4]="SWING1",t[t.SWING2=5]="SWING2"}(edt||(edt={}));var _dt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i._setLimit=function(t,e,i,n){switch(t){case Ftt.LOCKED:fst.Generic6DofSpring2Constraint_setLimit(this._impl,e,0,0);break;case Ftt.LIMITED:fst.Generic6DofSpring2Constraint_setLimit(this._impl,e,i,n);break;case Ftt.FREE:fst.Generic6DofSpring2Constraint_setLimit(this._impl,e,1,0)}},i.setConstraintMode=function(t,e){var i=this.constraint.linearLimitSettings,n=this.constraint.angularLimitSettings,r=[0,0,0],s=[0,0,0],o=0,a=0;switch(t){case 0:case 1:case 2:on.toArray(r,i.lower),on.toArray(s,i.upper),a=r[t],o=s[t];break;case 3:a=-(o=.5*Bi(n.twistExtent));break;case 4:a=-(o=.5*Bi(n.swingExtent1));break;case 5:a=-(o=.5*Bi(n.swingExtent2));break;default:V("idx should be in [0, 5], but give "+t)}this._setLimit(e,t,a,o)},i.setLinearLimit=function(t,e,i){var n=0,r=this.constraint.linearLimitSettings;switch(t){case 0:n=r.xMotion;break;case 1:n=r.yMotion;break;case 2:n=r.zMotion}this._setLimit(n,t,e,i)},i.setAngularExtent=function(t,e,i){var n=this.constraint.angularLimitSettings;this._setLimit(n.twistMotion,edt.TWIST,.5*-Bi(t),.5*Bi(t)),this._setLimit(n.swingMotion1,edt.SWING1,.5*-Bi(e),.5*Bi(e)),this._setLimit(n.swingMotion2,edt.SWING2,.5*-Bi(i),.5*Bi(i))},i.setSwingSoftConstraint=function(t){fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.SWING2,t)},i.setTwistSoftConstraint=function(t){fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.TWIST,t)},i.setLinearSoftConstraint=function(t){fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.Z,t)},i.setLinearStiffness=function(t){fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.Z,t)},i.setLinearDamping=function(t){fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.Z,t)},i.setLinearRestitution=function(t){fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.Z,t)},i.setSwingStiffness=function(t){fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.SWING2,t)},i.setSwingDamping=function(t){fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.SWING2,t)},i.setSwingRestitution=function(t){fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.SWING2,t)},i.setTwistStiffness=function(t){fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.TWIST,t)},i.setTwistDamping=function(t){fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.TWIST,t)},i.setTwistRestitution=function(t){fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.TWIST,t)},i.setDriverMode=function(t,e){e===ktt.DISABLED?fst.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!1):e===ktt.SERVO?(fst.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!0),fst.Generic6DofSpring2Constraint_setServo(this._impl,t,!0)):e===ktt.INDUCTION&&(fst.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!0),fst.Generic6DofSpring2Constraint_setServo(this._impl,t,!1))},i._updateMotorTargetAndVelocity=function(t){var e=ktt.DISABLED,i=0,n=0,r=0,s=this.constraint.linearDriverSettings,o=this.constraint.angularDriverSettings;switch(t){case 0:i=edt.X,e=s.xDrive,n=s.targetPosition.x,r=-s.targetVelocity.x;break;case 1:i=edt.Y,e=s.yDrive,n=s.targetPosition.y,r=-s.targetVelocity.y;break;case 2:i=edt.Z,e=s.zDrive,n=s.targetPosition.z,r=-s.targetVelocity.z;break;case 3:i=edt.TWIST,e=o.twistDrive,n=-Bi(o.targetOrientation.x),r=-Bi(o.targetVelocity.x);break;case 4:i=edt.SWING1,e=o.swingDrive1,n=-Bi(o.targetOrientation.y),r=-Bi(o.targetVelocity.y);break;case 5:i=edt.SWING2,e=o.swingDrive2,n=-Bi(o.targetOrientation.z),r=-Bi(o.targetVelocity.z)}var a=t>2?o.strength:s.strength;fst.Generic6DofSpring2Constraint_setServoTarget(this._impl,i,n),e===ktt.SERVO?t>2?fst.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,-n*a*.1):fst.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,n*a*.1):e===ktt.INDUCTION&&fst.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,r)},i.setLinearMotorTarget=function(){this._updateMotorTargetAndVelocity(0),this._updateMotorTargetAndVelocity(1),this._updateMotorTargetAndVelocity(2)},i.setLinearMotorVelocity=function(){this._updateMotorTargetAndVelocity(0),this._updateMotorTargetAndVelocity(1),this._updateMotorTargetAndVelocity(2)},i.setLinearMotorForceLimit=function(t){fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.Z,t)},i.setAngularMotorTarget=function(){this._updateMotorTargetAndVelocity(3),this._updateMotorTargetAndVelocity(4),this._updateMotorTargetAndVelocity(5)},i.setAngularMotorVelocity=function(){this._updateMotorTargetAndVelocity(3),this._updateMotorTargetAndVelocity(4),this._updateMotorTargetAndVelocity(5)},i.setAngularMotorForceLimit=function(t){fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.TWIST,t),fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.SWING2,t)},i.setPivotA=function(){this.updateFrames()},i.setPivotB=function(){this.updateFrames()},i.setAutoPivotB=function(){this.updateFrames()},i.setAxis=function(){this.updateFrames()},i.setSecondaryAxis=function(){this.updateFrames()},i.setBreakForce=function(){var t=Wst(Math.max(this.constraint.breakForce,this.constraint.breakTorque),lot.instance.fixedTimeStep);fst.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.setBreakTorque=function(){var t=Wst(Math.max(this.constraint.breakForce,this.constraint.breakTorque),lot.instance.fixedTimeStep);fst.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t&&t.body.impl||fst.TypedConstraint_getFixedBody(),n=vst.instance.BT_TRANSFORM_0,r=vst.instance.BT_TRANSFORM_1;this._impl=fst.Generic6DofSpring2Constraint_new(e,i,n,r,tdt.RO_YZX);var s=this.constraint.linearLimitSettings,o=this.constraint.angularLimitSettings;this.setConstraintMode(0,s.xMotion),this.setConstraintMode(1,s.yMotion),this.setConstraintMode(2,s.zMotion),this.setConstraintMode(3,o.twistMotion),this.setConstraintMode(4,o.swingMotion1),this.setConstraintMode(5,o.swingMotion2),this.setLinearSoftConstraint(s.enableSoftConstraint),this.setLinearStiffness(s.stiffness),this.setLinearDamping(s.damping),this.setLinearRestitution(s.restitution),this.setSwingSoftConstraint(o.enableSoftConstraintSwing),this.setSwingRestitution(o.swingRestitution),this.setSwingStiffness(o.swingStiffness),this.setSwingDamping(o.swingDamping),this.setTwistSoftConstraint(o.enableSoftConstraintTwist),this.setTwistRestitution(o.twistRestitution),this.setTwistStiffness(o.twistStiffness),this.setTwistDamping(o.twistDamping);var a=this.constraint.linearDriverSettings,h=this.constraint.angularDriverSettings;this.setDriverMode(0,a.xDrive),this.setDriverMode(1,a.yDrive),this.setDriverMode(2,a.zDrive),this.setDriverMode(3,h.twistDrive),this.setDriverMode(4,h.swingDrive1),this.setDriverMode(5,h.swingDrive2),this.setLinearMotorTarget(a.targetPosition),this.setLinearMotorVelocity(a.targetVelocity),this.setLinearMotorForceLimit(a.strength),this.setAngularMotorTarget(h.targetOrientation),this.setAngularMotorVelocity(h.targetVelocity),this.setAngularMotorForceLimit(h.strength),this.setBreakForce(this.constraint.breakForce),this.setBreakTorque(this.constraint.breakTorque),this.updateFrames(),this.updateDebugDrawSize()},i.updateFrames=function(){var t=this.constraint,e=t.node,i=Sst,n=bst,r=Est,s=vst.instance.BT_TRANSFORM_0;on.multiply(i,e.worldScale,t.pivotA),Vst(fst.Transform_getOrigin(s),i);var o=vst.instance.BT_QUAT_0,a=t.axis,h=t.secondaryAxis,u=on.cross(Tst,a,h);In.set(Cst,a.x,a.y,a.z,0,h.x,h.y,h.z,0,u.x,u.y,u.z,0,0,0,0,1).getRotation(n),Ust(o,n),fst.Transform_setRotation(s,o);var l=vst.instance.BT_TRANSFORM_1,c=this.constraint.connectedBody;c?(Sn.multiply(n,e.worldRotation,n),Sn.invert(r,c.node.worldRotation),Sn.multiply(n,r,n),t.autoPivotB?(on.multiply(i,t.node.worldScale,t.pivotA),on.transformQuat(i,i,e.worldRotation),on.add(i,i,t.node.worldPosition),on.subtract(i,i,c.node.worldPosition),on.transformQuat(i,i,r)):on.multiply(i,c.node.worldScale,t.pivotB)):(on.multiply(i,e.worldScale,t.pivotA),on.transformQuat(i,i,e.worldRotation),on.add(i,i,e.worldPosition),Sn.multiply(n,e.worldRotation,n)),Vst(fst.Transform_getOrigin(l),i),Ust(o,n),fst.Transform_setRotation(l,o),fst.Generic6DofSpring2Constraint_setFrames(this._impl,s,l)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(hdt),ddt=new on(0,0,0),fdt=new on(0,0,0);new on(0,0,0);var pdt=function(){function t(){this.wrappedWorld=void 0,this._isEnabled=!1,this._impl=0,this._comp=null,this._btCollisionFlags=0,this._word3=0,this._dirty=!1,this._collisionFilterGroup=Gtt.DEFAULT,this._collisionFilterMask=-1,this.id=t.idCounter++,this.wrappedWorld=lot.instance.physicsWorld}var e=t.prototype;return e.onComponentSet=function(){},e.updateScale=function(){},e.initialize=function(t){this._comp=t;var e=this._comp.group,i=lot.instance.collisionMatrix[e];return this._collisionFilterGroup=e,this._collisionFilterMask=i,this.onComponentSet(),0!==this._impl||(V("[Physics]: Initialize BulletCharacterController failed"),!1)},e.setWrapper=function(){vst.setWrapper(this._impl,pst.CCT_CACHE_NAME,this);var t=fst.CharacterController_getCollisionShape(this.impl);vst.setWrapper(t,pst.CCT_CACHE_NAME,this)},e.onEnable=function(){this._isEnabled=!0,this._impl||this.onComponentSet(),this.setDetectCollisions(!1),this.setOverlapRecovery(!0),lot.instance.physicsWorld.addCCT(this),this.setWrapper()},e.onDisable=function(){this._isEnabled=!1,this.wrappedWorld.removeCCT(this),this.onDestroy()},e.onDestroy=function(){fst._safe_delete(this._impl,ust.EBulletTypeCharacterController),vst.delWrapper(this._impl,pst.CCT_CACHE_NAME),this._impl=0},e.onLoad=function(){},e.getPosition=function(t){this._impl&&Gst(t,fst.CharacterController_getPosition(this.impl))},e.setPosition=function(t){this._impl&&(Vst(fst.CharacterController_getPosition(this.impl),t),this.syncPhysicsToScene())},e.setContactOffset=function(t){this._impl&&fst.CharacterController_setContactOffset(this._impl,t)},e.setStepOffset=function(t){this._impl&&fst.CharacterController_setStepOffset(this._impl,t)},e.setSlopeLimit=function(t){this._impl&&fst.CharacterController_setSlopeLimit(this._impl,ke(t))},e.setDetectCollisions=function(t){this._impl&&fst.CharacterController_setCollision(this.impl,t)},e.setOverlapRecovery=function(t){this._impl&&fst.CharacterController_setOverlapRecovery(this.impl,t)},e.onGround=function(){return(4&this._btCollisionFlags)>0},e.syncSceneToPhysics=function(){var t=this.characterController.node;t.hasChangedFlags&&(t.hasChangedFlags&rm.SCALE&&this.syncScale(),t.hasChangedFlags&rm.POSITION&&(on.add(ddt,t.worldPosition,this.scaledCenter),this.setPosition(ddt)))},e.syncPhysicsToScene=function(){this.getPosition(ddt),ddt.subtract(this.scaledCenter),this._comp.node.setWorldPosition(ddt)},e.syncScale=function(){this.updateScale()},e.move=function(t,e,i){if(this._isEnabled){var n=vst.instance.BT_V3_0;fst.Vec3_set(n,t.x,t.y,t.z),this._btCollisionFlags=fst.CharacterController_move(this.impl,n,e,i)}},e.setGroup=function(t){t!==this._collisionFilterGroup&&(this._collisionFilterGroup=t,this._dirty=!0)},e.getGroup=function(){return this._collisionFilterGroup},e.addGroup=function(t){this._collisionFilterGroup|=t,this._dirty=!0},e.removeGroup=function(t){this._collisionFilterGroup&=~t,this._dirty=!0},e.setMask=function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this._dirty=!0)},e.getMask=function(){return this._collisionFilterMask},e.addMask=function(t){this._collisionFilterMask|=t,this._dirty=!0},e.removeMask=function(t){this._collisionFilterMask&=~t,this._dirty=!0},e.updateEventListener=function(){this.wrappedWorld.updateNeedEmitCCTEvents(this.characterController.needCollisionEvent)},e.updateDirty=function(){this._dirty&&(lot.instance.physicsWorld.removeCCT(this),lot.instance.physicsWorld.addCCT(this),this._dirty=!1)},e.onShapeHitExt=function(t){var e=fst.ControllerShapeHit_getHitShape(t),i=lot.instance.physicsWorld;i.cctShapeEventDic.get(this.impl,e);var n=new on;Gst(n,fst.ControllerHit_getHitWorldPos(t));var r=new on;Gst(r,fst.ControllerHit_getHitWorldNormal(t));var s=new on;Gst(s,fst.ControllerHit_getHitMotionDir(t));var o=fst.ControllerHit_getHitMotionLength(t),a=vst.getWrapper(e,V_t.TYPE);a&&i.cctShapeEventDic.set(this.impl,e,{BulletCharacterController:this,BulletShape:a,worldPos:n,worldNormal:r,motionDir:s,motionLength:o})},n(t,[{key:"isEnabled",get:function(){return this._isEnabled}},{key:"impl",get:function(){return this._impl}},{key:"characterController",get:function(){return this._comp}},{key:"scaledCenter",get:function(){return on.multiply(fdt,this._comp.center,this._comp.node.worldScale),fdt}}]),t}();pdt.idCounter=0;var mdt,gdt,ydt,vdt,Sdt,Tdt,Adt,bdt,Edt=new on(0,0,0),Cdt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onComponentSet=function(){this.component.node.getWorldPosition(Edt),Edt.add(this.scaledCenter);var t=vst.instance.BT_V3_0;fst.Vec3_set(t,Edt.x,Edt.y,Edt.z);var e=on.UNIT_Y,i=vst.instance.BT_V3_1;fst.Vec3_set(i,e.x,e.y,e.z);var n=fst.ControllerHitReport.implement(P_t).$$.ptr,r=lot.instance.physicsWorld,s=fst.CapsuleCharacterControllerDesc_new(ke(this.component.slopeLimit),this.component.stepOffset,this.component.skinWidth,i,t,n,this.component.radius,this.component.height);this._impl=fst.CapsuleCharacterController_new(r.impl,s,0),this.updateScale()},i.setRadius=function(){this.updateScale()},i.setHeight=function(){this.updateScale()},i.updateScale=function(){this.updateGeometry()},i.updateGeometry=function(){var t=this.component.node.worldScale,e=this.component.radius*Wi(t.x,t.z),i=this.component.height*Math.abs(t.y);fst.CapsuleCharacterController_setRadius(this.impl,e),fst.CapsuleCharacterController_setHeight(this.impl,i),this._dirty=!0},n(e,[{key:"component",get:function(){return this._comp}}]),e}(pdt),wdt=new on(0,0,0),xdt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onComponentSet=function(){this.component.node.getWorldPosition(wdt),wdt.add(this.scaledCenter);var t=vst.instance.BT_V3_0;fst.Vec3_set(t,wdt.x,wdt.y,wdt.z);var e=on.UNIT_Y,i=vst.instance.BT_V3_1;fst.Vec3_set(i,e.x,e.y,e.z);var n=fst.ControllerHitReport.implement(P_t).$$.ptr,r=lot.instance.physicsWorld,s=fst.BoxCharacterControllerDesc_new(ke(this.component.slopeLimit),this.component.stepOffset,this.component.skinWidth,i,t,n,this.component.halfHeight,this.component.halfSideExtent,this.component.halfForwardExtent);this._impl=fst.BoxCharacterController_new(r.impl,s,0),this.updateScale()},i.setHalfHeight=function(){this.updateScale()},i.setHalfSideExtent=function(){this.updateScale()},i.setHalfForwardExtent=function(){this.updateScale()},i.updateScale=function(){this.updateGeometry()},i.updateGeometry=function(){var t=this.component.node.worldScale;fst.BoxCharacterController_setHalfSideExtent(this.impl,this.component.halfSideExtent*t.x),fst.BoxCharacterController_setHalfHeight(this.impl,this.component.halfHeight*t.y),fst.BoxCharacterController_setHalfForwardExtent(this.impl,this.component.halfForwardExtent*t.z),this._dirty=!0},n(e,[{key:"component",get:function(){return this._comp}}]),e}(pdt);SN.once(vN.EVENT_PRE_SUBSYSTEM_INIT,(function(){$rt.register("bullet",{PhysicsWorld:K_t,RigidBody:D_t,BoxShape:J_t,SphereShape:Q_t,CapsuleShape:Z_t,TrimeshShape:idt,CylinderShape:ndt,ConeShape:rdt,TerrainShape:sdt,SimplexShape:odt,PlaneShape:adt,PointToPointConstraint:udt,HingeConstraint:cdt,FixedConstraint:ldt,ConfigurableConstraint:_dt,BoxCharacterController:xdt,CapsuleCharacterController:Cdt})})),function(t){t[t.BOX=0]="BOX",t[t.SPHERE=1]="SPHERE",t[t.CYLINDER=2]="CYLINDER",t[t.CONE=3]="CONE",t[t.CAPSULE=4]="CAPSULE",t[t.TORUS=5]="TORUS",t[t.PLANE=6]="PLANE",t[t.QUAD=7]="QUAD"}(bdt||(bdt={})),Se(bdt);var Rdt=t("fO",(mdt=qs("cc.Primitive"),gdt=xo(bdt),mdt(((Adt=function(t){function e(e){var i;return void 0===e&&(e=bdt.BOX),(i=t.call(this)||this).type=Sdt&&Sdt(),i.info=Tdt&&Tdt(),i.type=e,i}return s(e,t),e.prototype.onLoaded=function(){iF(U$[bdt[this.type].toLowerCase()](this.info),this)},e}(XN)).PrimitiveType=bdt,Sdt=ks((vdt=Adt).prototype,"type",[gdt],(function(){return bdt.BOX})),Tdt=ks(vdt.prototype,"info",[io],(function(){return{}})),ydt=vdt))||ydt));v.Primitive=Rdt,v.primitives=U$;var Idt,Bdt=function(){function t(t,e,i){this._opts=void 0,this._total=0,this._value=0,this._averageValue=0,this._accumValue=0,this._accumSamples=0,this._id=t,this._opts=e,this._accumStart=i}var e=t.prototype;return e.sample=function(t){this._average(this._value,t)},e.human=function(){var t=this._opts,e=t.average,i=t.isInteger,n=e?this._averageValue:this._value;return i?Math.round(n):Math.round(100*n)/100},e.alarm=function(){return this._opts.below&&this._value<this._opts.below||this._opts.over&&this._value>this._opts.over},e._average=function(t,e){if(void 0===e&&(e=0),this._opts.average){this._accumValue+=t,++this._accumSamples;var i=e;i-this._accumStart>=this._opts.average&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=i,this._accumSamples=0)}},n(t,[{key:"value",get:function(){return this._value},set:function(t){this._value=t}}]),t}(),Ddt=qs("cc.PerfCounter")(Idt=function(t){function e(e,i,n){var r;return(r=t.call(this,e,i,n)||this)._time=n,r}s(e,t);var i=e.prototype;return i.start=function(t){void 0===t&&(t=0),this._time=t},i.end=function(t){void 0===t&&(t=0),this._value=t-this._time,this._average(this._value)},i.tick=function(){this.end(),this.start()},i.frame=function(t){var e=t,i=e-this._time;this._total++,i>(this._opts.average||1e3)&&(this._value=1e3*this._total/i,this._total=0,this._time=e,this._average(this._value))},e}(Bdt))||Idt,Pdt="0123456789. ",Odt=500,Mdt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,".":10},Ldt={fps:{desc:"Framerate (FPS)",below:30,average:Odt,isInteger:!0},draws:{desc:"Draw call",isInteger:!0},frame:{desc:"Frame time (ms)",min:0,max:50,average:Odt},instances:{desc:"Instance Count",isInteger:!0},tricount:{desc:"Triangle",isInteger:!0},logic:{desc:"Game Logic (ms)",min:0,max:50,average:Odt,color:"#080"},physics:{desc:"Physics (ms)",min:0,max:50,average:Odt},render:{desc:"Renderer (ms)",min:0,max:50,average:Odt,color:"#f90"},present:{desc:"Present (ms)",min:0,max:50,average:Odt,color:"#f90"},textureMemory:{desc:"GFX Texture Mem(M)"},bufferMemory:{desc:"GFX Buffer Mem(M)"}},Ndt=t("fP",function(t){function e(){var e;return(e=t.call(this)||this)._profilerStats=null,e._showFPS=!1,e._rootNode=null,e._device=null,e._swapchain=null,e._meshRenderer=null,e._canvas=null,e._ctx=null,e._texture=null,e._region=new Gc,e._canvasArr=[],e._regionArr=[e._region],e.digitsData=null,e.offsetData=null,e.pass=null,e._canvasDone=!1,e._statsDone=!1,e._inited=!1,e._lineHeight=280/(Object.keys(Ldt).length+1),e._wordHeight=0,e._eachNumWidth=0,e._totalLines=0,e.lastTime=0,e._canvas=T.document.createElement("canvas"),e._ctx=e._canvas.getContext("2d"),e._canvasArr.push(e._canvas),e}s(e,t);var i=e.prototype;return i.init=function(){Ee.querySettings(be.Category.PROFILING,"showFPS")?this.showStats():this.hideStats()},i.isShowingStats=function(){return this._showFPS},i.hideStats=function(){this._showFPS&&(this._rootNode&&(this._rootNode.active=!1),v.director.off(v.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),v.director.off(v.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),v.director.off(v.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),v.director.off(v.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),v.director.off(v.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),v.director.off(v.Director.EVENT_AFTER_RENDER,this.afterRender,this),v.director.off(v.Director.EVENT_AFTER_DRAW,this.afterPresent,this),this._showFPS=!1,fN.root.pipeline.profiler=null,v.game.config.showFPS=!1)},i.showStats=function(){if(!this._showFPS){if(!this._device){var t=v.director.root;this._device=Ed.gfxDevice,this._swapchain=t.mainWindow.swapchain}this.generateCanvas(),this.generateStats(),v.game.once(v.Game.EVENT_ENGINE_INITED,this.generateNode,this),v.game.on(v.Game.EVENT_RESTART,this.generateNode,this),this._rootNode&&(this._rootNode.active=!0),v.director.on(v.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),v.director.on(v.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),v.director.on(v.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),v.director.on(v.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),v.director.on(v.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),v.director.on(v.Director.EVENT_AFTER_RENDER,this.afterRender,this),v.director.on(v.Director.EVENT_AFTER_DRAW,this.afterPresent,this),this._showFPS=!0,this._canvasDone=!0,this._statsDone=!0,v.game.config.showFPS=!0}},i.generateCanvas=function(){if(!this._canvasDone){this._ctx&&this._canvas&&(this._canvas.width=280,this._canvas.height=280,this._canvas.style.width=""+this._canvas.width,this._canvas.style.height=""+this._canvas.height,this._ctx.font="23px Arial",this._ctx.textBaseline="top",this._ctx.fillStyle="#fff",this._texture=this._device.createTexture(new Qc(Jl.TEX2D,Ql.SAMPLED|Ql.TRANSFER_DST,Hl.RGBA8,280,280)),this._region.texExtent.width=280,this._region.texExtent.height=280)}},i.generateStats=function(){if(!this._statsDone&&this._ctx&&this._canvas){this._profilerStats=null;var t=performance.now();this._ctx.textAlign="left";var e=0;for(var i in Ldt){var n=Ldt[i];this._ctx.fillText(n.desc,0,e*this._lineHeight),n.counter=new Ddt(i,n,t),e++}this._totalLines=e,this._wordHeight=this._totalLines*this._lineHeight/this._canvas.height;for(var r=0;r<Pdt.length;++r){var s=this._ctx.measureText(Pdt[r]).width;this._eachNumWidth=Math.max(this._eachNumWidth,s)}for(var o=0;o<Pdt.length;++o)this._ctx.fillText(Pdt[o],o*this._eachNumWidth,this._totalLines*this._lineHeight);this._eachNumWidth/=this._canvas.width,this._profilerStats=Ldt,this._canvasArr[0]=this._canvas,this._device.copyTexImagesToTexture(this._canvasArr,this._texture,this._regionArr)}},i.generateNode=function(){if(!this._rootNode||!this._rootNode.isValid){this._rootNode=new Jm("PROFILER_NODE"),this._rootNode._objFlags=v.Object.Flags.DontSave|v.Object.Flags.HideInHierarchy,v.game.addPersistRootNode(this._rootNode);var t=new Jm("Profiler_Root");t.parent=this._rootNode;for(var e=.4,i=e/this._totalLines,n=e/this._wordHeight,r=i/23,s=this._eachNumWidth*this._canvas.width*r,o=[0,e,0,n,e,0,n,0,0,0,0,0],a=[0,2,1,0,3,2],h=[0,0,-1,0,1,0,-1,0,1,this._wordHeight,-1,0,0,this._wordHeight,-1,0],u=0,l=0;l<this._totalLines;l++)for(var c=0;c<8;c++){o.push(n+c*s,e-l*i,0),o.push(n+(c+1)*s,e-l*i,0),o.push(n+(c+1)*s,e-(l+1)*i,0),o.push(n+c*s,e-(l+1)*i,0),u=4*(8*l+c+1),a.push(0+u,2+u,1+u,0+u,3+u,2+u);var _=8*l+c,d=Math.floor(_/4),f=_-4*d;h.push(0,this._wordHeight,d,f),h.push(this._eachNumWidth,this._wordHeight,d,f),h.push(this._eachNumWidth,1,d,f),h.push(0,1,d,f)}this._meshRenderer=t.addComponent(VY),this._meshRenderer.mesh=iF({positions:o,indices:a,colors:h});var p=new xT;p.initialize({effectName:"util/profiler"});var m=this.pass=p.passes[0],g=m.getBinding("mainTexture"),y=m.getBinding("digits"),S=m.getBinding("offset");m.bindTexture(g,this._texture),this.digitsData=m.blocks[y],this.offsetData=m.blocks[S],this.offsetData[3]=-1,this._meshRenderer.material=p,this._meshRenderer.node.layer=im.Enum.PROFILER,this._inited=!0}},i.beforeUpdate=function(){if(this._profilerStats){var t=performance.now();this._profilerStats.frame.counter.start(t),this._profilerStats.logic.counter.start(t)}},i.afterUpdate=function(){if(this._profilerStats){var t=performance.now();v.director.isPaused()?this._profilerStats.frame.counter.start(t):this._profilerStats.logic.counter.end(t)}},i.beforePhysics=function(){if(this._profilerStats){var t=performance.now();this._profilerStats.physics.counter.start(t)}},i.afterPhysics=function(){if(this._profilerStats){var t=performance.now();this._profilerStats.physics.counter.end(t)}},i.beforeDraw=function(){if(this._profilerStats&&this._inited){var t=this._swapchain.surfaceTransform,e=this._device.capabilities.clipSpaceSignY;if(t!==this.offsetData[3]){var i=Rn[t],n=-.9,r=-.9*e;xl.isXR&&(n=-.5,r=-.5*e),this.offsetData[0]=n*i[0]+r*i[2],this.offsetData[1]=n*i[1]+r*i[3],this.offsetData[2]=this._eachNumWidth,this.offsetData[3]=t}this.pass.setRootBufferDirty(!0),this._meshRenderer.model?fN.root.pipeline.profiler=this._meshRenderer.model:fN.root.pipeline.profiler=null;var s=performance.now();this._profilerStats.render.counter.start(s)}},i.afterRender=function(){if(this._profilerStats&&this._inited){var t=performance.now();this._profilerStats.render.counter.end(t),this._profilerStats.present.counter.start(t)}},i.afterPresent=function(){if(this._profilerStats&&this._inited){var t=performance.now();if(this._profilerStats.frame.counter.end(t),this._profilerStats.fps.counter.frame(t),this._profilerStats.present.counter.end(t),!(t-this.lastTime<Odt)){this.lastTime=t;var e=this._device;this._profilerStats.draws.counter.value=e.numDrawCalls,this._profilerStats.instances.counter.value=e.numInstances,this._profilerStats.bufferMemory.counter.value=e.memoryStatus.bufferSize/1048576,this._profilerStats.textureMemory.counter.value=e.memoryStatus.textureSize/1048576,this._profilerStats.tricount.counter.value=e.numTris;var i=0,n=this.digitsData;for(var r in this._profilerStats){var s=this._profilerStats[r];s.counter.sample(t);for(var o=s.counter.human().toString(),a=7;a>=0;a--){var h=8*i+a,u=o[o.length-(8-a)],l=Mdt[u];void 0===l&&(l=11),n[h]=l}i++}}}},n(e,[{key:"_stats",get:function(){return k("Profiler._stats is deprecated, please use Profiler.stats instead."),this._profilerStats}},{key:"stats",get:function(){return this._profilerStats}}]),e}(Ou)),Fdt=t("fQ",new Ndt);fN.registerSystem("profiler",Fdt,0),v.profiler=Fdt;var kdt=function(){function t(t){this.jointTexturePool=void 0,this.jointAnimationInfo=void 0,this.jointTexturePool=new HQ(t),this.jointAnimationInfo=new WQ(t)}var e=t.prototype;return e.releaseSkeleton=function(t){this.jointTexturePool.releaseSkeleton(t)},e.releaseAnimationClip=function(t){this.jointTexturePool.releaseAnimationClip(t)},e.clear=function(){this.jointTexturePool.clear(),this.jointAnimationInfo.clear()},t}();v.internal.DataPoolManager=kdt;var Vdt,Gdt,Udt,zdt,Hdt,Wdt,jdt,Xdt,qdt,Ydt,Kdt,Jdt,Qdt,Zdt,$dt,tft=new In,eft=new In,ift=t("fS",function(t){function e(e,i){var n;return void 0===i&&(i=""),(n=t.call(this,e,i)||this)._frames=1,n._bakedDuration=0,n._animInfo=null,n._sockets=[],n._animInfoMgr=void 0,n._parent=null,n._curvesInited=!1,n._animInfoMgr=v.director.root.dataPoolManager.jointAnimationInfo,n}s(e,t);var i=e.prototype;return i.initialize=function(e){if(!this._curveLoaded){this._parent=e.getComponent("cc.SkeletalAnimation");var i=this._parent.useBakedAnimation;this._doNotCreateEval=i,t.prototype.initialize.call(this,e),this._curvesInited=!i;var n=IQ.getOrExtract(this.clip),r=n.frames,s=n.samples;this._frames=r-1,this._animInfo=this._animInfoMgr.getData(e.uuid),this._bakedDuration=this._frames/s,this.setUseBaked(i)}},i.onPlay=function(){var e=this;t.prototype.onPlay.call(this),this._parent.useBakedAnimation&&(this._animInfoMgr.switchClip(this._animInfo,this.clip),this._parent.getUsers().forEach((function(t){t.uploadAnimation(e.clip)})))},i.setUseBaked=function(e){e?(this._sampleCurves=this._sampleCurvesBaked,this.duration=this._bakedDuration):(this._sampleCurves=t.prototype._sampleCurves,this.duration=this.clip.duration,this._curvesInited||(this._curveLoaded=!1,t.prototype.initialize.call(this,this._targetNode),this._curvesInited=!0))},i.rebuildSocketCurves=function(t){if(this._sockets.length=0,this._targetNode)for(var e=this._targetNode,i=0;i<t.length;++i){var n=t[i],r=e.getChildByPath(n.path);if(n.target){for(var s=IQ.getOrExtract(this.clip),o=n.path,a=s.joints[o],h=r,u=void 0;!a;){var l=o.lastIndexOf("/");if(o=o.substring(0,l),a=s.joints[o],h&&(u||(u=In.identity(eft)),In.fromRTS(tft,h.rotation,h.position,h.scale),In.multiply(u,tft,u),h=h.parent),l<0)break}for(var c=a&&a.transforms,_=s.frames,d=[],f=0;f<_;f++){var p;p=c&&u?In.multiply(tft,c[f],u):c?c[f]:u||new In;var m={pos:new on,rot:new Sn,scale:new on};In.toRTS(p,m.rot,m.pos,m.scale),d.push(m)}this._sockets.push({target:n.target,frames:d})}}},i._sampleCurvesBaked=function(t){var e=t/this.duration,i=this._animInfo,n=this.clip;i.currentClip!==n&&(this._animInfoMgr.switchClip(this._animInfo,n),this._parent.getUsers().forEach((function(t){t.uploadAnimation(n)})),i.data[0]=-1);var r=e*this._frames+.5|0;if(r!==i.data[0]){i.data[0]=r,i.dirty=!0;for(var s=0;s<this._sockets.length;++s){var o=this._sockets[s],a=o.target,h=o.frames[r],u=h.pos,l=h.rot,c=h.scale;a.setRTS(l,u,c)}}},e}(P0)),nft=t("fT",(Vdt=qs("cc.SkeletalAnimation.Socket"),Gdt=xo(Jm),Vdt((zdt=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),this.path=Hdt&&Hdt(),this.target=Wdt&&Wdt(),this.path=t,this.target=e},Hdt=ks(zdt.prototype,"path",[io],(function(){return""})),Wdt=ks(zdt.prototype,"target",[Gdt],(function(){return null})),Udt=zdt))||Udt));Qt(nft,"cc.SkeletalAnimationComponent.Socket");var rft=new In,sft=new In;function oft(t,e,i){void 0===e&&(e=""),void 0===i&&(i=[]);for(var n=0;n<t.children.length;n++){var r=t.children[n];if(r){var s=e?e+"/"+r.name:r.name;i.push(s),oft(r,s,i)}}return i}var aft=t("fU",(jdt=qs("cc.SkeletalAnimation"),Xdt=Ks(99),qdt=xo([nft]),Ydt=xo([nft]),jdt(Kdt=Xdt((($dt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._useBakedAnimation=Qdt&&Qdt(),e._sockets=Zdt&&Zdt(),e._users=new Set,e._currentBakedState=null,e}s(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this);for(var e=this.node.getComponentsInChildren(UZ),i=0;i<e.length;++i){var n=e[i];n.skinningRoot===this.node&&this.notifySkinnedMeshAdded(n)}},i.onDestroy=function(){t.prototype.onDestroy.call(this),v.director.root.dataPoolManager.jointAnimationInfo.destroy(this.node.uuid),R0().removeSockets(this.node,this._sockets),this._removeAllUsers()},i.onEnable=function(){var e;t.prototype.onEnable.call(this),null===(e=this._currentBakedState)||void 0===e||e.resume()},i.onDisable=function(){var e;t.prototype.onDisable.call(this),null===(e=this._currentBakedState)||void 0===e||e.pause()},i.start=function(){this.sockets=this._sockets,this._applyBakeFlagChange(),t.prototype.start.call(this)},i.pause=function(){var e;this._useBakedEffectively?null===(e=this._currentBakedState)||void 0===e||e.pause():t.prototype.pause.call(this)},i.resume=function(){var e;this._useBakedEffectively?null===(e=this._currentBakedState)||void 0===e||e.resume():t.prototype.resume.call(this)},i.stop=function(){this._useBakedEffectively?this._currentBakedState&&(this._currentBakedState.stop(),this._currentBakedState=null):t.prototype.stop.call(this)},i.querySockets=function(){var t=this._defaultClip&&Object.keys(IQ.getOrExtract(this._defaultClip).joints).sort().reduce((function(t,e){return e.startsWith(t[t.length-1]+"/")||t.push(e),t}),[])||[];if(!t.length)return["please specify a valid default animation clip first"];for(var e=[],i=0;i<t.length;i++){var n=t[i],r=this.node.getChildByPath(n);r&&(e.push(n),oft(r,n,e))}return e},i.rebuildSocketAnimations=function(){for(var t,e=d(this._sockets);!(t=e()).done;){var i=t.value,n=this.node.getChildByPath(i.path),r=i.target;n&&r&&(r.name=i.path.substring(i.path.lastIndexOf("/")+1)+" Socket",r.parent=this.node,DQ(n,this.node,rft),In.fromRTS(sft,r.rotation,r.position,r.scale),In.equals(sft,rft)||(r.matrix=rft))}for(var s=0,o=Object.keys(this._nameToState);s<o.length;s++){var a=o[s];this._nameToState[a].rebuildSocketCurves(this._sockets)}},i.createSocket=function(t){var e=this._sockets.find((function(e){return e.path===t}));if(e)return e.target;if(!this.node.getChildByPath(t))return k("illegal socket path"),null;var i=new Jm;return i.parent=this.node,this._sockets.push(new nft(t,i)),this.rebuildSocketAnimations(),i},i.notifySkinnedMeshAdded=function(t){var e=this._useBakedEffectively,i=t.associatedAnimation;if(i&&i._users.delete(t),t.associatedAnimation=this,t.setUseBakedAnimation(e,!0),e){var n=this._currentBakedState;n&&t.uploadAnimation(n.clip)}this._users.add(t)},i.notifySkinnedMeshRemoved=function(t){t.associatedAnimation===this||t.associatedAnimation,t.setUseBakedAnimation(!1),t.associatedAnimation=null,this._users.delete(t)},i.getUsers=function(){return this._users},i._createState=function(t,e){return new ift(t,e)},i._doCreateState=function(e,i){var n=t.prototype._doCreateState.call(this,e,i);return n.rebuildSocketCurves(this._sockets),n},i.doPlayOrCrossFade=function(e,i){if(this._useBakedEffectively){this._currentBakedState&&this._currentBakedState.stop();var n=e;this._currentBakedState=n,n.play()}else t.prototype.doPlayOrCrossFade.call(this,e,i)},i._removeAllUsers=function(){var t=this;Array.from(this._users).forEach((function(e){t.notifySkinnedMeshRemoved(e)}))},i._applyBakeFlagChange=function(){var t=this._useBakedEffectively;for(var e in this._nameToState)this._nameToState[e].setUseBaked(t);this._users.forEach((function(e){e.setUseBakedAnimation(t)})),t?R0().removeSockets(this.node,this._sockets):(R0().addSockets(this.node,this._sockets),this._currentBakedState=null)},n(e,[{key:"sockets",get:function(){return this._sockets},set:function(t){if(!this._useBakedEffectively){var e=R0();e.removeSockets(this.node,this._sockets),e.addSockets(this.node,t)}this._sockets=t,this.rebuildSocketAnimations()}},{key:"useBakedAnimation",get:function(){return this._useBakedAnimation},set:function(t){this._useBakedAnimation=t,this._applyBakeFlagChange()}},{key:"_useBakedEffectively",get:function(){return this._useBakedAnimation}}]),e}(n4)).Socket=nft,p((Jdt=$dt).prototype,"sockets",[qdt],Object.getOwnPropertyDescriptor(Jdt.prototype,"sockets"),Jdt.prototype),Qdt=ks(Jdt.prototype,"_useBakedAnimation",[io],(function(){return!0})),Zdt=ks(Jdt.prototype,"_sockets",[Ydt],(function(){return[]})),Kdt=Jdt))||Kdt)||Kdt));v.SkeletalAnimationComponent=aft,Qt(aft,"cc.SkeletalAnimationComponent");var hft=function(){function t(){this.originalTarget=null,this.target=null,this.tag=t.TAG_INVALID}var e=t.prototype;return e.clone=function(){var e=new t;return e.originalTarget=null,e.target=null,e.tag=this.tag,e},e.isDone=function(){return!0},e.startWithTarget=function(t){this.originalTarget=t,this.target=t},e.stop=function(){this.target=null},e.step=function(){X(1006)},e.update=function(){X(1007)},e.getTarget=function(){return this.target},e.setTarget=function(t){this.target=t},e.getOriginalTarget=function(){return this.originalTarget},e.setOriginalTarget=function(t){this.originalTarget=t},e.getTag=function(){return this.tag},e.setTag=function(t){this.tag=t},e.reverse=function(){return X(1008),null},e.retain=function(){},e.release=function(){},t}();hft.TAG_INVALID=-1;var uft=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._duration=0,e._timesForRepeat=1,e}s(e,t);var i=e.prototype;return i.getDuration=function(){return this._duration*(this._timesForRepeat||1)},i.setDuration=function(t){this._duration=t},i.clone=function(){return new e},e}(hft);!function(t){function e(e,i){var n;return void 0===i&&(i=1),(n=t.call(this)||this)._speed=0,n._innerAction=null,e&&n.initWithAction(e,i),n}s(e,t);var i=e.prototype;i.getSpeed=function(){return this._speed},i.setSpeed=function(t){this._speed=t},i.initWithAction=function(t,e){return t?(this._innerAction=t,this._speed=e,!0):(J(1021),!1)},i.clone=function(){var t=new e;return t.initWithAction(this._innerAction.clone(),this._speed),t},i.startWithTarget=function(t){hft.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),hft.prototype.stop.call(this)},i.step=function(t){this._innerAction.step(t*this._speed)},i.isDone=function(){return this._innerAction.isDone()},i.reverse=function(){return new e(this._innerAction.reverse(),this._speed)},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction}}(hft);var lft=0,cft=function(){this.actions=[],this.target=null,this.actionIndex=0,this.currentAction=null,this.paused=!1,this.lock=!1},_ft=function(){function t(){this._hashTargets=new Map,this._arrayTargets=[],this._currentTarget=void 0,this._elementPool=[]}var e=t.prototype;return e._searchElementByTarget=function(t,e){for(var i=0;i<t.length;i++)if(e===t[i].target)return t[i];return null},e._getElement=function(t,e){var i=this._elementPool.pop();return i||(i=new cft),i.target=t,i.paused=!!e,i},e._putElement=function(t){t.actions.length=0,t.actionIndex=0,t.currentAction=null,t.paused=!1,t.target=null,t.lock=!1,this._elementPool.push(t)},e.addAction=function(t,e,i){if(t&&e){null==e.uuid&&(e.uuid="_TWEEN_UUID_"+lft++);var n=this._hashTargets.get(e);n?n.actions||(n.actions=[]):(n=this._getElement(e,i),this._hashTargets.set(e,n),this._arrayTargets.push(n)),n.target=e,n.actions.push(t),t.startWithTarget(e)}else J(1e3)},e.removeAllActions=function(){for(var t=this._arrayTargets,e=0;e<t.length;e++){var i=t[e];i&&this._putElement(i)}this._arrayTargets.length=0,this._hashTargets=new Map},e.removeAllActionsFromTarget=function(t){if(null!=t){var e=this._hashTargets.get(t);e&&(e.actions.length=0,this._deleteHashElement(e))}},e.removeAction=function(t){if(null!=t){var e=t.getOriginalTarget(),i=this._hashTargets.get(e);if(i)for(var n=0;n<i.actions.length;n++)if(i.actions[n]===t){i.actions.splice(n,1),i.actionIndex>=n&&i.actionIndex--;break}}},e._removeActionByTag=function(t,e,i){for(var n=0,r=e.actions.length;n<r;++n){var s=e.actions[n];if(s&&s.getTag()===t){if(i&&s.getOriginalTarget()!==i)continue;this._removeActionAtIndex(n,e);break}}},e._removeAllActionsByTag=function(t,e,i){for(var n=e.actions.length-1;n>=0;--n){var r=e.actions[n];if(r&&r.getTag()===t){if(i&&r.getOriginalTarget()!==i)continue;this._removeActionAtIndex(n,e)}}},e.removeActionByTag=function(t,e){var i=this;t===hft.TAG_INVALID&&X(1002);var n=this._hashTargets;if(e){var r=n.get(e);r&&this._removeActionByTag(t,r,e)}else n.forEach((function(e){i._removeActionByTag(t,e)}))},e.removeAllActionsByTag=function(t,e){var i=this;t===hft.TAG_INVALID&&X(1002);var n=this._hashTargets;if(e){var r=n.get(e);r&&this._removeAllActionsByTag(t,r,e)}else n.forEach((function(e){i._removeAllActionsByTag(t,e)}))},e.getActionByTag=function(t,e){t===hft.TAG_INVALID&&X(1004);var i=this._hashTargets.get(e);if(i){if(null!=i.actions)for(var n=0;n<i.actions.length;++n){var r=i.actions[n];if(r&&r.getTag()===t)return r}X(1005,t)}return null},e.getNumberOfRunningActionsInTarget=function(t){var e=this._hashTargets.get(t);return e&&e.actions?e.actions.length:0},e.pauseTarget=function(t){var e=this._hashTargets.get(t);e&&(e.paused=!0)},e.resumeTarget=function(t){var e=this._hashTargets.get(t);e&&(e.paused=!1)},e.pauseAllRunningActions=function(){for(var t=[],e=this._arrayTargets,i=0;i<e.length;i++){var n=e[i];n&&!n.paused&&(n.paused=!0,t.push(n.target))}return t},e.resumeTargets=function(t){if(t)for(var e=0;e<t.length;e++)t[e]&&this.resumeTarget(t[e])},e.pauseTargets=function(t){if(t)for(var e=0;e<t.length;e++)t[e]&&this.pauseTarget(t[e])},e.purgeSharedManager=function(){v.director.getScheduler().unscheduleUpdate(this)},e._removeActionAtIndex=function(t,e){e.actions[t],e.actions.splice(t,1),e.actionIndex>=t&&e.actionIndex--,0===e.actions.length&&this._deleteHashElement(e)},e._deleteHashElement=function(t){var e=!1;if(t&&!t.lock&&this._hashTargets.get(t.target)){this._hashTargets.delete(t.target);for(var i=this._arrayTargets,n=0,r=i.length;n<r;n++)if(i[n]===t){i.splice(n,1);break}this._putElement(t),e=!0}return e},e.update=function(t){for(var e,i=this._arrayTargets,n=0;n<i.length;n++){this._currentTarget=i[n];var r=(e=this._currentTarget).target;if(!Wo(r)||r.isValid){if(!e.paused&&e.actions){for(e.lock=!0,e.actionIndex=0;e.actionIndex<e.actions.length;e.actionIndex++)if(e.currentAction=e.actions[e.actionIndex],e.currentAction){if(e.currentAction.step(t*(this._isActionInternal(e.currentAction)?e.currentAction.getSpeed():1)),e.currentAction&&e.currentAction.isDone()){e.currentAction.stop();var s=e.currentAction;e.currentAction=null,this.removeAction(s)}e.currentAction=null}e.lock=!1}0===e.actions.length&&this._deleteHashElement(e)&&n--}else this.removeAllActionsFromTarget(r),n--}},e._isActionInternal=function(t){return void 0!==t._speedMethod},t}(),dft=t("fV",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).actionMgr=new _ft,e}return s(e,t),e.prototype.update=function(t){this.actionMgr.update(t)},n(e,[{key:"ActionManager",get:function(){return this.actionMgr}}]),e}(Ou));dft.ID="TWEEN",dft.instance=void 0,fN.on(dN.EVENT_INIT,(function(){var t=new dft;dft.instance=t,fN.registerSystem(dft.ID,t,Ou.Priority.MEDIUM)}));var fft=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.isDone=function(){return!0},i.step=function(){this.update(1)},i.update=function(){},i.reverse=function(){return this.clone()},i.clone=function(){return new e},e}(uft),pft=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.update=function(){for(var t=this.target.getComponentsInChildren(SV),e=0;e<t.length;++e)t[e].enabled=!0},i.reverse=function(){return new mft},i.clone=function(){return new e},e}(fft),mft=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.update=function(){for(var t=this.target.getComponentsInChildren(SV),e=0;e<t.length;++e)t[e].enabled=!1},i.reverse=function(){return new pft},i.clone=function(){return new e},e}(fft);!function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;i.update=function(){for(var t=this.target.getComponentsInChildren(SV),e=0;e<t.length;++e){var i=t[e];i.enabled=!i.enabled}},i.reverse=function(){return new e},i.clone=function(){return new e}}(fft);var gft=function(t){function e(e){var i;return(i=t.call(this)||this)._isNeedCleanUp=!0,void 0!==e&&i.init(e),i}s(e,t);var i=e.prototype;return i.update=function(){this.target.removeFromParent(),this._isNeedCleanUp&&this.target.destroy()},i.init=function(t){return this._isNeedCleanUp=t,!0},i.reverse=function(){return new e(this._isNeedCleanUp)},i.clone=function(){return new e(this._isNeedCleanUp)},e}(fft);function yft(t){return new gft(t)}var vft,Sft,Tft=function(t){function e(e,i,n){var r;return(r=t.call(this)||this)._selectorTarget=null,r._function=null,r._data=null,r.initWithFunction(e,i,n),r}s(e,t);var i=e.prototype;return i.initWithFunction=function(t,e,i){return t&&(this._function=t),e&&(this._selectorTarget=e),void 0!==i&&(this._data=i),!0},i.execute=function(){this._function&&this._function.call(this._selectorTarget,this.target,this._data)},i.update=function(){this.execute()},i.getTargetCallback=function(){return this._selectorTarget},i.setTargetCallback=function(t){t!==this._selectorTarget&&(this._selectorTarget&&(this._selectorTarget=null),this._selectorTarget=t)},i.clone=function(){var t=new e;return t.initWithFunction(this._function,this._selectorTarget,this._data),t},e}(fft),Aft=function(t){function e(e){var i;return(i=t.call(this)||this).MAX_VALUE=2,i._elapsed=0,i._firstTick=!1,i._easeList=[],i._speed=1,i._repeatForever=!1,i._repeatMethod=!1,i._speedMethod=!1,void 0===e||Number.isNaN(e)||i.initWithDuration(e),i}s(e,t);var i=e.prototype;return i.getElapsed=function(){return this._elapsed},i.initWithDuration=function(t){return this._duration=0===t?Ce.FLT_EPSILON:t,this._elapsed=0,this._firstTick=!0,!0},i.isDone=function(){return this._elapsed>=this._duration},i._cloneDecoration=function(t){t._repeatForever=this._repeatForever,t._speed=this._speed,t._timesForRepeat=this._timesForRepeat,t._easeList=this._easeList,t._speedMethod=this._speedMethod,t._repeatMethod=this._repeatMethod},i._reverseEaseList=function(t){if(this._easeList){t._easeList=[];for(var e=0;e<this._easeList.length;e++)t._easeList.push(this._easeList[e])}},i.clone=function(){var t=new e(this._duration);return this._cloneDecoration(t),t},i.easing=function(t){this._easeList?this._easeList.length=0:this._easeList=[];for(var e=0;e<arguments.length;e++)this._easeList.push(arguments[e]);return this},i._computeEaseTime=function(t){return t},i.step=function(t){this._firstTick?(this._firstTick=!1,this._elapsed=0):this._elapsed+=t;var e=this._elapsed/(this._duration>1.192092896e-7?this._duration:1.192092896e-7);e=e<1?e:1,this.update(e>0?e:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},i.startWithTarget=function(t){hft.prototype.startWithTarget.call(this,t),this._elapsed=0,this._firstTick=!0},i.reverse=function(){return X(1010),this},i.setAmplitudeRate=function(){X(1011)},i.getAmplitudeRate=function(){return X(1012),0},i.speed=function(t){return t<=0?(X(1013),this):(this._speedMethod=!0,this._speed*=t,this)},i.getSpeed=function(){return this._speed},i.setSpeed=function(t){return this._speed=t,this},i.repeat=function(t){return t=Math.round(t),Number.isNaN(t)||t<1?(X(1014),this):(this._repeatMethod=!0,this._timesForRepeat*=t,this)},i.repeatForever=function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this},e}(uft),bft=function(t){function e(i){var n;(n=t.call(this)||this)._actions=[],n._split=0,n._last=0,n._reversed=!1;var r=i instanceof Array?i:arguments;if(1===r.length)return J(1019),c(n);var s=r.length-1;if(s>=0&&null==r[s]&&X(1015),s>=0){for(var o,a=r[0],h=1;h<s;h++)r[h]&&(o=a,a=e._actionOneTwo(o,r[h]));n.initWithTwoActions(a,r[s])}return n}s(e,t);var i=e.prototype;return i.initWithTwoActions=function(t,e){if(!t||!e)return J(1025),!1;var i=t._duration,n=e._duration,r=(i*=t._repeatMethod?t._timesForRepeat:1)+(n*=e._repeatMethod?e._timesForRepeat:1);return this.initWithDuration(r),this._actions[0]=t,this._actions[1]=e,!0},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithTwoActions(this._actions[0].clone(),this._actions[1].clone()),t},i.startWithTarget=function(t){Aft.prototype.startWithTarget.call(this,t),this._split=this._actions[0]._duration/this._duration,this._split*=this._actions[0]._repeatMethod?this._actions[0]._timesForRepeat:1,this._last=-1},i.stop=function(){-1!==this._last&&this._actions[this._last].stop(),hft.prototype.stop.call(this)},i.update=function(t){var e,i,n=0,r=this._split,s=this._actions,o=this._last;(t=this._computeEaseTime(t))<r?(e=0!==r?t/r:1,0===n&&1===o&&this._reversed&&(s[1].update(0),s[1].stop())):(n=1,e=1===r?1:(t-r)/(1-r),-1===o&&(s[0].startWithTarget(this.target),s[0].update(1),s[0].stop()),0===o&&(s[0].update(1),s[0].stop())),i=s[n],o===n&&i.isDone()||(o!==n&&i.startWithTarget(this.target),e*=i._timesForRepeat,i.update(e>1?e%1:e),this._last=n)},i.reverse=function(){var t=e._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t._reversed=!0,t},e}(Aft);function Eft(t){var e=t instanceof Array?t:arguments;if(1===e.length)return e[0];var i=e.length-1;i>=0&&null==e[i]&&X(1015);var n=null;if(i>=0){n=e[0];for(var r=1;r<=i;r++)e[r]&&(n=bft._actionOneTwo(n,e[r]))}return n}vft=bft,bft._actionOneTwo=function(t,e){var i=new vft;return i.initWithTwoActions(t,e),i};var Cft=function(t){function e(e,i){var n;return(n=t.call(this)||this)._times=0,n._total=0,n._nextDt=0,n._actionInstant=!1,n._innerAction=null,void 0!==i&&n.initWithAction(e,i),n}s(e,t);var i=e.prototype;return i.initWithAction=function(t,e){var i=t._duration*e;return!!this.initWithDuration(i)&&(this._times=e,this._innerAction=t,t instanceof fft&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone(),this._times),t},i.startWithTarget=function(t){this._total=0,this._nextDt=this._innerAction._duration/this._duration,Aft.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),hft.prototype.stop.call(this)},i.update=function(t){t=this._computeEaseTime(t);var e=this._innerAction,i=this._duration,n=this._times,r=this._nextDt;if(t>=r){for(;t>r&&this._total<n;)e.update(1),this._total++,e.stop(),e.startWithTarget(this.target),r+=e._duration/i,this._nextDt=r>1?1:r;t>=1&&this._total<n&&(e.update(1),this._total++),this._actionInstant||(this._total===n?e.stop():e.update(t-(r-e._duration/i)))}else e.update(t*n%1)},i.isDone=function(){return this._total===this._times},i.reverse=function(){var t=new e(this._innerAction.reverse(),this._times);return this._cloneDecoration(t),this._reverseEaseList(t),t},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction},e}(Aft),wft=function(t){function e(e){var i;return(i=t.call(this)||this)._innerAction=null,e&&i.initWithAction(e),i}s(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?(this._innerAction=t,!0):(J(1026),!1)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone()),t},i.startWithTarget=function(t){Aft.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.step=function(t){var e=this._innerAction;e.step(t),e.isDone()&&(e.startWithTarget(this.target),e.step(e.getElapsed()-e._duration))},i.isDone=function(){return!1},i.reverse=function(){var t=new e(this._innerAction.reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction},e}(Aft),xft=function(t){function e(i){var n;(n=t.call(this)||this)._one=null,n._two=null;var r=i instanceof Array?i:arguments;if(1===r.length)return J(1020),c(n);var s=r.length-1;if(s>=0&&null==r[s]&&X(1015),s>=0){for(var o,a=r[0],h=1;h<s;h++)r[h]&&(o=a,a=e._actionOneTwo(o,r[h]));n.initWithTwoActions(a,r[s])}return n}s(e,t);var i=e.prototype;return i.initWithTwoActions=function(t,e){if(!t||!e)return J(1027),!1;var i=!1,n=t._duration,r=e._duration;return this.initWithDuration(Math.max(n,r))&&(this._one=t,this._two=e,n>r?this._two=bft._actionOneTwo(e,Bft(n-r)):n<r&&(this._one=bft._actionOneTwo(t,Bft(r-n))),i=!0),i},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithTwoActions(this._one.clone(),this._two.clone()),t},i.startWithTarget=function(t){Aft.prototype.startWithTarget.call(this,t),this._one.startWithTarget(t),this._two.startWithTarget(t)},i.stop=function(){this._one.stop(),this._two.stop(),hft.prototype.stop.call(this)},i.update=function(t){t=this._computeEaseTime(t),this._one&&this._one.update(t),this._two&&this._two.update(t)},i.reverse=function(){var t=e._actionOneTwo(this._one.reverse(),this._two.reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t},e}(Aft);function Rft(t){var e=t instanceof Array?t:arguments;if(1===e.length)return J(1020),null;e.length>0&&null==e[e.length-1]&&X(1015);for(var i=e[0],n=1;n<e.length;n++)null!=e[n]&&(i=xft._actionOneTwo(i,e[n]));return i}Sft=xft,xft._actionOneTwo=function(t,e){var i=new Sft;return i.initWithTwoActions(t,e),i};var Ift=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.update=function(){},i.reverse=function(){var t=new e(this._duration);return this._cloneDecoration(t),this._reverseEaseList(t),t},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithDuration(this._duration),t},e}(Aft);function Bft(t){return new Ift(t)}var Dft,Pft,Oft,Mft,Lft,Nft,Fft,kft,Vft,Gft,Uft,zft,Hft,Wft,jft,Xft,qft,Yft,Kft,Jft,Qft,Zft,$ft,tpt,ept,ipt,npt,rpt,spt,opt,apt,hpt=function(t){function e(e){var i;return(i=t.call(this)||this)._other=null,e&&i.initWithAction(e),i}s(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?t===this._other?(J(1029),!1):!!Aft.prototype.initWithDuration.call(this,t._duration)&&(this._other=t,!0):(J(1028),!1)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._other.clone()),t},i.startWithTarget=function(t){Aft.prototype.startWithTarget.call(this,t),this._other.startWithTarget(t)},i.update=function(t){t=this._computeEaseTime(t),this._other&&this._other.update(1-t)},i.reverse=function(){return this._other.clone()},i.stop=function(){this._other.stop(),hft.prototype.stop.call(this)},e}(Aft),upt=t("fZ",function(t){function e(e,i,n){var r;if((r=t.call(this)||this)._opts=void 0,r._props=void 0,r._originProps=void 0,null==n)n=Object.create(null);else if(function(t){var e=" [Tween:] ",i=" option is not support in v + "+S,n=t;n.delay&&k(e+"delay"+i),n.repeat&&k(e+"repeat"+i),n.repeatDelay&&k(e+"repeatDelay"+i),n.interpolation&&k(e+"interpolation"+i),n.onStop&&k(e+"onStop"+i)}(n),n.easing&&"string"==typeof n.easing&&(n.easing=function(t){var e=t.charAt(0);if(/[A-Z]/.test(e)){var i=(t=t.replace(e,e.toLowerCase())).split("-");if(2===i.length){var n=i[0];if("linear"===n)t="linear";else{var r=i[1];switch(n){case"quadratic":t="quad"+r;break;case"quartic":t="quart"+r;break;case"quintic":t="quint"+r;break;case"sinusoidal":t="sine"+r;break;case"exponential":t="expo"+r;break;case"circular":t="circ"+r;break;default:t=n+r}}}}return t}(n.easing)),n.progress||(n.progress=r.progress),n.easing&&"string"==typeof n.easing){var s=n.easing;n.easing=ja[s],n.easing||Y(1031,s)}for(var o in r._opts=n,r._props=Object.create(null),i)if(i.hasOwnProperty(o)){var a=i[o];if("function"==typeof a&&(a=a()),null!=a&&"string"!=typeof a){var h=void 0,u=void 0;void 0!==a.value&&(a.easing||a.progress)&&("string"==typeof a.easing?(h=ja[a.easing])||Y(1031,a.easing):h=a.easing,u=a.progress,a=a.value);var l=Object.create(null);l.value=a,l.easing=h,l.progress=u,r._props[o]=l}}return r._originProps=i,r.initWithDuration(e),r}s(e,t);var i=e.prototype;return i.clone=function(){var t=new e(this._duration,this._originProps,this._opts);return this._cloneDecoration(t),t},i.startWithTarget=function(t){Aft.prototype.startWithTarget.call(this,t);var e=!!this._opts.relative,i=this._props;for(var n in i){var r=t[n];if(void 0!==r){var s=i[n],o=s.value;if("number"==typeof r)s.start=r,s.current=r,s.end=e?r+o:o;else if("object"==typeof r)for(var a in null==s.start&&(s.start={},s.current={},s.end={}),o)isNaN(r[a])||(s.start[a]=r[a],s.current[a]=r[a],s.end[a]=e?r[a]+o[a]:o[a])}}this._opts.onStart&&this._opts.onStart(this.target)},i.update=function(t){var e=this.target;if(e){var i=this._props,n=this._opts,r=t;n.easing&&(r=n.easing(t));var s=n.progress;for(var o in i){var a=i[o],h=a.easing?a.easing(t):r,u=a.progress?a.progress:s,l=a.start,c=a.end;if("number"==typeof l)a.current=u(l,c,a.current,h);else if("object"==typeof l)for(var _ in l)a.current[_]=u(l[_],c[_],a.current[_],h);e[o]=a.current}n.onUpdate&&n.onUpdate(this.target,t),1===t&&n.onComplete&&n.onComplete(this.target)}},i.progress=function(t,e,i,n){return t+(e-t)*n},e}(Aft)),lpt=function(t){function e(e){var i;return(i=t.call(this)||this)._props=void 0,i._props={},void 0!==e&&i.init(e),i}s(e,t);var i=e.prototype;return i.init=function(t){for(var e in t)this._props[e]=t[e];return!0},i.update=function(){var t=this._props,e=this.target;for(var i in t)e[i]=t[i]},i.clone=function(){var t=new e;return t.init(this._props),t},e}(fft),cpt=t("fY",function(){function t(t){this._actions=[],this._finalAction=null,this._target=null,this._tag=hft.TAG_INVALID,this._target=void 0===t?null:t}var e=t.prototype;return e.tag=function(t){return this._tag=t,this},e.then=function(t){return t instanceof hft?this._actions.push(t.clone()):this._actions.push(t._union()),this},e.target=function(t){return this._target=t,this},e.start=function(){return this._target?(this._finalAction&&dft.instance.ActionManager.removeAction(this._finalAction),this._finalAction=this._union(),this._finalAction.setTag(this._tag),dft.instance.ActionManager.addAction(this._finalAction,this._target,!1),this):(k("Please set target to tween first"),this)},e.stop=function(){return this._finalAction&&dft.instance.ActionManager.removeAction(this._finalAction),this},e.clone=function(t){var e=this._union();return _pt(t).then(e.clone())},e.union=function(){var t=this._union();return this._actions.length=0,this._actions.push(t),this},e.to=function(t,e,i){(i=i||Object.create(null)).relative=!1;var n=new upt(t,e,i);return this._actions.push(n),this},e.by=function(t,e,i){(i=i||Object.create(null)).relative=!0;var n=new upt(t,e,i);return this._actions.push(n),this},e.set=function(t){var e=new lpt(t);return this._actions.push(e),this},e.delay=function(t){var e=Bft(t);return this._actions.push(e),this},e.call=function(t){var e=function(t){return new Tft(t,void 0,void 0)}(t);return this._actions.push(e),this},e.sequence=function(){var e=t._wrappedSequence.apply(t,arguments);return this._actions.push(e),this},e.parallel=function(){var e=t._wrappedParallel.apply(t,arguments);return this._actions.push(e),this},e.repeat=function(e,i){if(e===1/0)return this.repeatForever(i);var n,r=this._actions;return n=i instanceof t?i._union():r.pop(),r.push(function(t,e){return new Cft(t,e)}(n,e)),this},e.repeatForever=function(e){var i,n=this._actions;return i=e instanceof t?e._union():n.pop(),n.push(function(t){return new wft(t)}(i)),this},e.reverseTime=function(e){var i,n=this._actions;return i=e instanceof t?e._union():n.pop(),n.push(function(t){return new hpt(t)}(i)),this},e.hide=function(){var t=new mft;return this._actions.push(t),this},e.show=function(){var t=new pft;return this._actions.push(t),this},e.removeSelf=function(){var t=yft(!1);return this._actions.push(t),this},e.destroySelf=function(){var t=yft(!0);return this._actions.push(t),this},t.stopAll=function(){dft.instance.ActionManager.removeAllActions()},t.stopAllByTag=function(t,e){dft.instance.ActionManager.removeAllActionsByTag(t,e)},t.stopAllByTarget=function(t){dft.instance.ActionManager.removeAllActionsFromTarget(t)},e._union=function(){var t=this._actions;return 1===t.length?t[0]:Eft(t)},e._destroy=function(){this.stop()},t._wrappedSequence=function(){var e=t._tmp_args;e.length=0;for(var i=arguments.length,n=0;n<i;n++){var r=e[n]=n<0||arguments.length<=n?void 0:arguments[n];r instanceof t&&(e[n]=r._union())}return Eft.apply(Eft,e)},t._wrappedParallel=function(){var e=t._tmp_args;e.length=0;for(var i=arguments.length,n=0;n<i;n++){var r=e[n]=n<0||arguments.length<=n?void 0:arguments[n];r instanceof t&&(e[n]=r._union())}return Rft.apply(Rft,e)},t}());function _pt(t){return new cpt(t)}function dpt(t){return k("tweenUtil' is deprecated, please use 'tween' instead "),new cpt(t)}cpt._tmp_args=[],v.Tween=cpt,v.tween=_pt,v.tweenUtil=dpt,function(t){t[t.Other=0]="Other",t[t.Left=1]="Left",t[t.Right=2]="Right"}(Dft||(Dft={})),function(t){t.XRUI_HOVER_ENTERED="xrui-hover-entered",t.XRUI_HOVER_EXITED="xrui-hover-exited",t.XRUI_HOVER_STAY="xrui-hover-stay",t.XRUI_CLICK="xrui-click",t.XRUI_UNCLICK="xrui-unclick"}(Pft||(Pft={})),function(t){t.XR_CAPS_LOCK="xr-caps-lock",t.XR_KEYBOARD_INIT="xr-keyboard-init",t.XR_KEYBOARD_INPUT="xr-keyboard-input",t.TO_LATIN="to-latin",t.TO_SYMBOL="to-symbol",t.TO_MATH_SYMBOL="to-math-symbol"}(Oft||(Oft={})),s((function(){for(var t,e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return(t=apt.call.apply(apt,[this].concat(i))||this).deviceType=Dft.Other,t.hitPoint=new on,t}),apt=Ew);var fpt,ppt,mpt,gpt=new dn;!function(t){t[t.NONE=0]="NONE",t[t.COLOR=1]="COLOR",t[t.SPRITE=2]="SPRITE",t[t.SCALE=3]="SCALE"}(fpt||(fpt={})),Se(fpt),function(t){t.NORMAL="normal",t.HOVER="hover",t.PRESSED="pressed",t.DISABLED="disabled"}(ppt||(ppt={})),function(t){t.CLICK="click"}(mpt||(mpt={}));var ypt=t("f_",(Mft=qs("cc.Button"),Lft=Ks(110),Nft=Ys(nV),Fft=xo(Jm),kft=xo(fpt),Vft=xo(pF),Gft=xo(pF),Uft=xo(pF),zft=xo(pF),Hft=xo([ep]),Mft(Wft=Lft(Wft=Nft(((opt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).clickEvents=Xft&&Xft(),e._interactable=qft&&qft(),e._transition=Yft&&Yft(),e._normalColor=Kft&&Kft(),e._hoverColor=Jft&&Jft(),e._pressedColor=Qft&&Qft(),e._disabledColor=Zft&&Zft(),e._normalSprite=$ft&&$ft(),e._hoverSprite=tpt&&tpt(),e._pressedSprite=ept&&ept(),e._disabledSprite=ipt&&ipt(),e._duration=npt&&npt(),e._zoomScale=rpt&&rpt(),e._target=spt&&spt(),e._pressed=!1,e._hovered=!1,e._fromColor=new dn,e._toColor=new dn,e._time=0,e._transitionFinished=!0,e._fromScale=new on,e._toScale=new on,e._originalScale=null,e._sprite=null,e._targetScale=new on,e}s(e,t);var i=e.prototype;return i.__preload=function(){this.target||(this.target=this.node),this._applyTarget(),this._resetState()},i.onEnable=function(){this._registerNodeEvent()},i.onDisable=function(){this._resetState(),this._unregisterNodeEvent()},i.onDestroy=function(){this.target.isValid&&this._unregisterTargetEvent(this.target)},i.update=function(t){var e=this.target;if(!this._transitionFinished&&e&&(this._transition===fpt.COLOR||this._transition===fpt.SCALE)){this._time+=t;var i=1;if(this._duration>0&&(i=this._time/this._duration),i>=1&&(i=1),this._transition===fpt.COLOR){var n=e._uiProps.uiComp;dn.lerp(gpt,this._fromColor,this._toColor,i),n&&(n.color=gpt)}else this.transition===fpt.SCALE&&(e.getScale(this._targetScale),this._targetScale.x=Ii(this._fromScale.x,this._toScale.x,i),this._targetScale.y=Ii(this._fromScale.y,this._toScale.y,i),e.setScale(this._targetScale));1===i&&(this._transitionFinished=!0)}},i._resizeNodeToTargetNode=function(){this.target&&this.target._uiProps.uiTransformComp},i._resetState=function(){this._pressed=!1,this._hovered=!1;var t=this.target;if(t){var e=this._transition;if(e===fpt.COLOR&&this._interactable){var i=t.getComponent(TV);i&&(i.color=this._normalColor)}else e===fpt.SCALE&&this._originalScale&&t.setScale(this._originalScale);this._transitionFinished=!0}},i._registerNodeEvent=function(){this.node.on(om.TOUCH_START,this._onTouchBegan,this),this.node.on(om.TOUCH_MOVE,this._onTouchMove,this),this.node.on(om.TOUCH_END,this._onTouchEnded,this),this.node.on(om.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(om.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(om.MOUSE_LEAVE,this._onMouseMoveOut,this),this.node.on(Pft.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.on(Pft.XRUI_HOVER_EXITED,this._xrHoverExit,this),this.node.on(Pft.XRUI_CLICK,this._xrClick,this),this.node.on(Pft.XRUI_UNCLICK,this._xrUnClick,this)},i._registerTargetEvent=function(t){t.on(om.TRANSFORM_CHANGED,this._onTargetTransformChanged,this)},i._unregisterNodeEvent=function(){this.node.off(om.TOUCH_START,this._onTouchBegan,this),this.node.off(om.TOUCH_MOVE,this._onTouchMove,this),this.node.off(om.TOUCH_END,this._onTouchEnded,this),this.node.off(om.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(om.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(om.MOUSE_LEAVE,this._onMouseMoveOut,this),this.node.off(Pft.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.off(Pft.XRUI_HOVER_EXITED,this._xrHoverExit,this),this.node.off(Pft.XRUI_CLICK,this._xrClick,this),this.node.off(Pft.XRUI_UNCLICK,this._xrUnClick,this)},i._unregisterTargetEvent=function(t){t.off(om.TRANSFORM_CHANGED)},i._getTargetSprite=function(t){var e=null;return t&&(e=t.getComponent(uz)),e},i._applyTarget=function(){this.target&&(this._sprite=this._getTargetSprite(this.target),this._originalScale||(this._originalScale=new on),on.copy(this._originalScale,this.target.getScale()),this._registerTargetEvent(this.target))},i._onTargetSpriteFrameChanged=function(t){this._transition===fpt.SPRITE&&this._setCurrentStateSpriteFrame(t.spriteFrame)},i._setCurrentStateSpriteFrame=function(t){if(t)switch(this._getButtonState()){case ppt.NORMAL:this._normalSprite=t;break;case ppt.HOVER:this._hoverSprite=t;break;case ppt.PRESSED:this._pressedSprite=t;break;case ppt.DISABLED:this._disabledSprite=t}},i._onTargetColorChanged=function(t){this._transition===fpt.COLOR&&this._setCurrentStateColor(t)},i._setCurrentStateColor=function(t){switch(this._getButtonState()){case ppt.NORMAL:this._normalColor=t;break;case ppt.HOVER:this._hoverColor=t;break;case ppt.PRESSED:this._pressedColor=t;break;case ppt.DISABLED:this._disabledColor=t}},i._onTargetTransformChanged=function(t){t&rm.SCALE&&this._originalScale&&this._transition===fpt.SCALE&&this._transitionFinished&&on.copy(this._originalScale,this.target.getScale())},i._onTouchBegan=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState(),t&&(t.propagationStopped=!0))},i._onTouchMove=function(t){if(this._interactable&&this.enabledInHierarchy&&this._pressed&&t){var e=t.touch;if(e){var i,n=this.node._uiProps.uiTransformComp.hitTest(e.getLocation(),t.windowId);this._transition===fpt.SCALE&&this.target&&this._originalScale?n?(on.copy(this._fromScale,this._originalScale),on.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._transitionFinished=!1):(this._time=0,this._transitionFinished=!0,this.target.setScale(this._originalScale)):(i=n?ppt.PRESSED:ppt.NORMAL,this._applyTransition(i)),t&&(t.propagationStopped=!0)}}},i._onTouchEnded=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(ep.emitEvents(this.clickEvents,t),this.node.emit(mpt.CLICK,this)),this._pressed=!1,this._updateState(),t&&(t.propagationStopped=!0))},i._onTouchCancel=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed=!1,this._updateState())},i._onMouseMoveIn=function(){!this._pressed&&this.interactable&&this.enabledInHierarchy&&(this._transition!==fpt.SPRITE||this._hoverSprite)&&(this._hovered||(this._hovered=!0,this._updateState()))},i._onMouseMoveOut=function(){this._hovered&&(this._hovered=!1,this._updateState())},i._updateState=function(){var t=this._getButtonState();this._applyTransition(t)},i._getButtonState=function(){var t=ppt.NORMAL;return this._interactable?this._pressed?t=ppt.PRESSED:this._hovered&&(t=ppt.HOVER):t=ppt.DISABLED,t.toString()},i._updateColorTransition=function(t){var e,i=this[t+"Color"],n=null===(e=this.target)||void 0===e?void 0:e.getComponent(TV);n&&(t===ppt.DISABLED.toString()?n.color=i:(this._fromColor=n.color.clone(),this._toColor=i,this._time=0,this._transitionFinished=!1))},i._updateSpriteTransition=function(t){var e=this[t+"Sprite"];this._sprite&&e&&(this._sprite.spriteFrame=e)},i._updateScaleTransition=function(t){this._interactable&&(t===ppt.PRESSED.toString()?this._zoomUp():this._zoomBack())},i._zoomUp=function(){this._originalScale&&(on.copy(this._fromScale,this._originalScale),on.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._time=0,this._transitionFinished=!1)},i._zoomBack=function(){this.target&&this._originalScale&&(on.copy(this._fromScale,this.target.getScale()),on.copy(this._toScale,this._originalScale),this._time=0,this._transitionFinished=!1)},i._applyTransition=function(t){var e=this._transition;e===fpt.COLOR?this._updateColorTransition(t):e===fpt.SPRITE?this._updateSpriteTransition(t):e===fpt.SCALE&&this._updateScaleTransition(t)},i._xrHoverEnter=function(){this._onMouseMoveIn(),this._updateState()},i._xrHoverExit=function(){this._onMouseMoveOut(),this._pressed&&(this._pressed=!1,this._updateState())},i._xrClick=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState())},i._xrUnClick=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(ep.emitEvents(this.clickEvents,this),this.node.emit(mpt.CLICK,this)),this._pressed=!1,this._updateState())},n(e,[{key:"target",get:function(){return this._target||this.node},set:function(t){this._target!==t&&(this._target&&this._unregisterTargetEvent(this._target),this._target=t,this._applyTarget())}},{key:"interactable",get:function(){return this._interactable},set:function(t){this._interactable!==t&&(this._interactable=t,this._updateState(),this._interactable||this._resetState())}},{key:"_resizeToTarget",set:function(t){t&&this._resizeNodeToTargetNode()}},{key:"transition",get:function(){return this._transition},set:function(t){this._transition!==t&&(this._transition===fpt.COLOR?this._updateColorTransition(ppt.NORMAL):this._transition===fpt.SPRITE&&this._updateSpriteTransition(ppt.NORMAL),this._transition=t,this._updateState())}},{key:"normalColor",get:function(){return this._normalColor},set:function(t){this._normalColor!==t&&(this._normalColor.set(t),this._updateState())}},{key:"pressedColor",get:function(){return this._pressedColor},set:function(t){this._pressedColor!==t&&this._pressedColor.set(t)}},{key:"hoverColor",get:function(){return this._hoverColor},set:function(t){this._hoverColor!==t&&this._hoverColor.set(t)}},{key:"disabledColor",get:function(){return this._disabledColor},set:function(t){this._disabledColor!==t&&(this._disabledColor.set(t),this._updateState())}},{key:"duration",get:function(){return this._duration},set:function(t){this._duration!==t&&(this._duration=t)}},{key:"zoomScale",get:function(){return this._zoomScale},set:function(t){this._zoomScale!==t&&(this._zoomScale=t)}},{key:"normalSprite",get:function(){return this._normalSprite},set:function(t){if(this._normalSprite!==t){this._normalSprite=t;var e=this.node.getComponent(uz);e&&(e.spriteFrame=t),this._updateState()}}},{key:"pressedSprite",get:function(){return this._pressedSprite},set:function(t){this._pressedSprite!==t&&(this._pressedSprite=t,this._updateState())}},{key:"hoverSprite",get:function(){return this._hoverSprite},set:function(t){this._hoverSprite!==t&&(this._hoverSprite=t,this._updateState())}},{key:"disabledSprite",get:function(){return this._disabledSprite},set:function(t){this._disabledSprite!==t&&(this._disabledSprite=t,this._updateState())}}]),e}(rp)).Transition=fpt,opt.EventType=mpt,p((jft=opt).prototype,"target",[Fft],Object.getOwnPropertyDescriptor(jft.prototype,"target"),jft.prototype),p(jft.prototype,"transition",[kft],Object.getOwnPropertyDescriptor(jft.prototype,"transition"),jft.prototype),p(jft.prototype,"normalSprite",[Vft],Object.getOwnPropertyDescriptor(jft.prototype,"normalSprite"),jft.prototype),p(jft.prototype,"pressedSprite",[Gft],Object.getOwnPropertyDescriptor(jft.prototype,"pressedSprite"),jft.prototype),p(jft.prototype,"hoverSprite",[Uft],Object.getOwnPropertyDescriptor(jft.prototype,"hoverSprite"),jft.prototype),p(jft.prototype,"disabledSprite",[zft],Object.getOwnPropertyDescriptor(jft.prototype,"disabledSprite"),jft.prototype),Xft=ks(jft.prototype,"clickEvents",[Hft,io],(function(){return[]})),qft=ks(jft.prototype,"_interactable",[io],(function(){return!0})),Yft=ks(jft.prototype,"_transition",[io],(function(){return fpt.NONE})),Kft=ks(jft.prototype,"_normalColor",[io],(function(){return dn.WHITE.clone()})),Jft=ks(jft.prototype,"_hoverColor",[io],(function(){return new dn(211,211,211,255)})),Qft=ks(jft.prototype,"_pressedColor",[io],(function(){return dn.WHITE.clone()})),Zft=ks(jft.prototype,"_disabledColor",[io],(function(){return new dn(124,124,124,255)})),$ft=ks(jft.prototype,"_normalSprite",[io],(function(){return null})),tpt=ks(jft.prototype,"_hoverSprite",[io],(function(){return null})),ept=ks(jft.prototype,"_pressedSprite",[io],(function(){return null})),ipt=ks(jft.prototype,"_disabledSprite",[io],(function(){return null})),npt=ks(jft.prototype,"_duration",[io],(function(){return.1})),rpt=ks(jft.prototype,"_zoomScale",[io],(function(){return 1.2})),spt=ks(jft.prototype,"_target",[io],(function(){return null})),Wft=jft))||Wft)||Wft)||Wft));v.Button=ypt;var vpt,Spt,Tpt,Apt=function(){function t(){}return t.add=function(t){var e=this._tabIndexList;-1===e.indexOf(t)&&e.push(t)},t.remove=function(t){var e=this._tabIndexList,i=e.indexOf(t);-1!==i&&e.splice(i,1)},t.resort=function(){this._tabIndexList.sort((function(t,e){return t._delegate.tabIndex-e._delegate.tabIndex}))},t.next=function(t){var e=this._tabIndexList,i=e.indexOf(t);if(t.setFocus(!1),-1!==i){var n=e[i+1];n&&n._delegate.tabIndex>=0&&n.setFocus(!0)}},t}();Apt._tabIndexList=[],function(t){t[t.DEFAULT=0]="DEFAULT",t[t.DONE=1]="DONE",t[t.SEND=2]="SEND",t[t.SEARCH=3]="SEARCH",t[t.GO=4]="GO",t[t.NEXT=5]="NEXT"}(vpt||(vpt={})),ge(vpt),function(t){t[t.ANY=0]="ANY",t[t.EMAIL_ADDR=1]="EMAIL_ADDR",t[t.NUMERIC=2]="NUMERIC",t[t.PHONE_NUMBER=3]="PHONE_NUMBER",t[t.URL=4]="URL",t[t.DECIMAL=5]="DECIMAL",t[t.SINGLE_LINE=6]="SINGLE_LINE"}(Spt||(Spt={})),ge(Spt),function(t){t[t.PASSWORD=0]="PASSWORD",t[t.SENSITIVE=1]="SENSITIVE",t[t.INITIAL_CAPS_WORD=2]="INITIAL_CAPS_WORD",t[t.INITIAL_CAPS_SENTENCE=3]="INITIAL_CAPS_SENTENCE",t[t.INITIAL_CAPS_ALL_CHARACTERS=4]="INITIAL_CAPS_ALL_CHARACTERS",t[t.DEFAULT=5]="DEFAULT"}(Tpt||(Tpt={})),ge(Tpt);var bpt,Ept,Cpt,wpt,xpt,Rpt,Ipt,Bpt,Dpt,Ppt,Opt,Mpt,Lpt,Npt,Fpt,kpt,Vpt,Gpt,Upt,zpt,Hpt,Wpt,jpt,Xpt,qpt,Ypt,Kpt,Jpt,Qpt,Zpt,$pt=function(){function t(){this._editing=!1,this._delegate=null}var e=t.prototype;return e.init=function(){},e.onEnable=function(){},e.update=function(){},e.onDisable=function(){this._editing&&this.endEditing()},e.clear=function(){this._delegate=null},e.setTabIndex=function(){},e.setSize=function(){},e.setFocus=function(t){t?this.beginEditing():this.endEditing()},e.isFocused=function(){return this._editing},e.beginEditing=function(){},e.endEditing=function(){},t}(),tmt=T.document,emt=new In,imt=new In,nmt=new on,rmt=null,smt=0,omt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._delegate=null,e._inputMode=-1,e._inputFlag=-1,e._returnType=-1,e.__eventListeners={},e.__autoResize=!1,e.__orientationChanged=void 0,e._edTxt=null,e._isTextArea=!1,e._textLabelFont=null,e._textLabelFontSize=null,e._textLabelFontColor=null,e._textLabelAlign=null,e._placeholderLabelFont=null,e._placeholderLabelFontSize=null,e._placeholderLabelFontColor=null,e._placeholderLabelAlign=null,e._placeholderLineHeight=null,e._placeholderStyleSheet=null,e._domId="EditBoxId_"+ ++smt,e}s(e,t);var i=e.prototype;return i.init=function(t){t&&(this._delegate=t,t.inputMode===Spt.ANY?this._createTextArea():this._createInput(),Apt.add(this),this.setTabIndex(t.tabIndex),this._initStyleSheet(),this._registerEventListeners(),this._addDomToGameContainer(),SH.instance.on("canvas-resize",this._resize,this))},i.clear=function(){this._removeEventListeners(),this._removeDomFromGameContainer(),Apt.remove(this),rmt===this&&(rmt=null),this._delegate=null},i._resize=function(){this._delegate.node.hasChangedFlags=1},i.update=function(){this._delegate.node.hasChangedFlags&&this._updateMatrix()},i.setTabIndex=function(t){this._edTxt.tabIndex=t,Apt.resort()},i.setSize=function(t,e){var i=this._edTxt;i&&(i.style.width=t+"px",i.style.height=e+"px")},i.beginEditing=function(){rmt&&rmt!==this&&rmt.setFocus(!1),this._editing=!0,rmt=this,this._delegate._editBoxEditingDidBegan(),this._showDom(),this._edTxt.focus()},i.endEditing=function(){this._edTxt.blur()},i._createInput=function(){this._isTextArea=!1,this._edTxt=tmt.createElement("input")},i._createTextArea=function(){this._isTextArea=!0,this._edTxt=tmt.createElement("textarea")},i._addDomToGameContainer=function(){SN.container&&this._edTxt&&(SN.container.appendChild(this._edTxt),tmt.head.appendChild(this._placeholderStyleSheet))},i._removeDomFromGameContainer=function(){Oe(SN.container,this._edTxt)&&this._edTxt&&SN.container.removeChild(this._edTxt),Oe(tmt.head,this._placeholderStyleSheet)&&tmt.head.removeChild(this._placeholderStyleSheet),this._edTxt=null,this._placeholderStyleSheet=null},i._showDom=function(){this._updateMaxLength(),this._updateInputType(),this._updateStyleSheet(),this._edTxt&&this._delegate&&(this._edTxt.style.display="",this._delegate._hideLabels()),xl.isMobile&&this._showDomOnMobile()},i._hideDom=function(){var t=this._edTxt;t&&this._delegate&&(t.style.display="none",this._delegate._showLabels()),xl.isMobile&&this._hideDomOnMobile()},i._showDomOnMobile=function(){xl.os!==$u.ANDROID&&xl.os!==$u.OHOS||(El.handleResizeEvent=!1,this._adjustWindowScroll())},i._hideDomOnMobile=function(){xl.os!==$u.ANDROID&&xl.os!==$u.OHOS||(El.handleResizeEvent=!0),this._scrollBackWindow()},i._isElementInViewport=function(){if(this._edTxt){var t=this._edTxt.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(T.innerHeight||tmt.documentElement.clientHeight)&&t.right<=(T.innerWidth||tmt.documentElement.clientWidth)}return!1},i._adjustWindowScroll=function(){var t=this;setTimeout((function(){T.scrollY<40&&!t._isElementInViewport()&&t._edTxt.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}),400)},i._scrollBackWindow=function(){setTimeout((function(){xl.browserType!==Ju.WECHAT||xl.os!==$u.IOS?T.scrollTo(0,0):T.top&&T.top.scrollTo(0,0)}),400)},i._updateMatrix=function(){if(this._edTxt){var t=this._delegate.node,e=CH.getScaleX(),i=CH.getScaleY(),n=CH.getViewportRect(),r=El.devicePixelRatio;t.getWorldMatrix(emt);var s=t._uiProps.uiTransformComp;if(s&&(on.set(nmt,-s.anchorX*s.width,-s.anchorY*s.height,nmt.z),In.transform(emt,emt,nmt)),t._uiProps.uiTransformComp){var o=fN.root.batcher2D.getFirstRenderCamera(t);if(o){o.node.getWorldRT(imt);var a=imt.m12,h=imt.m13,u=Rl.center;imt.m12=u.x-(imt.m00*a+imt.m04*h),imt.m13=u.y-(imt.m01*a+imt.m05*h),e/=r,i/=r,on.set(nmt,e,i,1),In.scale(imt,imt,nmt);var l=SN.container,c=parseInt(l&&l.style.paddingLeft||"0");c+=n.x/r;var _=parseInt(l&&l.style.paddingBottom||"0");_+=n.y/r,imt.m12+=c,imt.m13+=_,In.multiply(imt,imt,emt);var d="matrix("+imt.m00+","+-imt.m01+","+-imt.m04+","+imt.m05+","+imt.m12+","+-imt.m13+")";this._edTxt.style.transform=d,this._edTxt.style["-webkit-transform"]=d,this._edTxt.style["transform-origin"]="0px 100% 0px",this._edTxt.style["-webkit-transform-origin"]="0px 100% 0px"}}}},i._updateInputType=function(){var t=this._delegate,e=t.inputMode,i=t.inputFlag,n=t.returnType,r=this._edTxt;if(this._inputMode!==e||this._inputFlag!==i||this._returnType!==n){if(this._inputMode=e,this._inputFlag=i,this._returnType=n,this._isTextArea){var s="none";return i===Tpt.INITIAL_CAPS_ALL_CHARACTERS?s="uppercase":i===Tpt.INITIAL_CAPS_WORD&&(s="capitalize"),void(r.style.textTransform=s)}if(r=r,i===Tpt.PASSWORD)return r.type="password",void(r.style.textTransform="none");var o=r.type;e===Spt.EMAIL_ADDR?o="email":e===Spt.NUMERIC?o="number":e===Spt.DECIMAL?o="digit":e===Spt.PHONE_NUMBER?(o="tel",r.addEventListener("wheel",(function(){return!1}))):e===Spt.URL?o="url":(o="text",n===vpt.SEARCH&&(o="search")),r.type=o;var a="none";i===Tpt.INITIAL_CAPS_ALL_CHARACTERS?a="uppercase":i===Tpt.INITIAL_CAPS_WORD&&(a="capitalize"),r.style.textTransform=a}},i._updateMaxLength=function(){var t=this._delegate.maxLength;t<0&&(t=65535),this._edTxt.maxLength=t},i._initStyleSheet=function(){if(this._edTxt){var t=this._edTxt;t.style.color="#000000",t.style.border="0px",t.style.background="transparent",t.style.width="100%",t.style.height="100%",t.style.outline="medium",t.style.padding="0",t.style.textTransform="none",t.style.display="none",t.style.position="absolute",t.style.bottom="0px",t.style.left="2px",t.className="cocosEditBox",t.style.fontFamily="Arial",t.id=this._domId,this._isTextArea?(t.style.resize="none",t.style.overflowY="scroll"):((t=t).type="text",t.style["-moz-appearance"]="textfield"),this._placeholderStyleSheet=tmt.createElement("style")}},i._updateStyleSheet=function(){var t=this._delegate,e=this._edTxt;e&&t&&(e.value=t.string,this._updateTextLabel(t.textLabel))},i._updateTextLabel=function(t){if(t){var e=t.font;e=!e||e instanceof MF?t.fontFamily:e._fontFamily;var i=t.fontSize*t.node.scale.y;if((this._textLabelFont!==e||this._textLabelFontSize!==i||this._textLabelFontColor!==t.fontColor||this._textLabelAlign!==t.horizontalAlign)&&(this._textLabelFont=e,this._textLabelFontSize=i,this._textLabelFontColor=t.fontColor,this._textLabelAlign=t.horizontalAlign,this._edTxt)){var n=this._edTxt;switch(n.style.fontSize=i+"px",n.style.color=t.color.toCSS(),n.style.fontFamily=e,t.horizontalAlign){case lG.HorizontalAlign.LEFT:n.style.textAlign="left";break;case lG.HorizontalAlign.CENTER:n.style.textAlign="center";break;case lG.HorizontalAlign.RIGHT:n.style.textAlign="right"}}}},i._updatePlaceholderLabel=function(t){if(t){var e=t.font;e=!e||e instanceof MF?t.fontFamily:t.font._fontFamily;var i=t.fontSize*t.node.scale.y;if(this._placeholderLabelFont!==e||this._placeholderLabelFontSize!==i||this._placeholderLabelFontColor!==t.fontColor||this._placeholderLabelAlign!==t.horizontalAlign||this._placeholderLineHeight!==t.fontSize){this._placeholderLabelFont=e,this._placeholderLabelFontSize=i,this._placeholderLabelFontColor=t.fontColor,this._placeholderLabelAlign=t.horizontalAlign,this._placeholderLineHeight=t.fontSize;var n=this._placeholderStyleSheet,r=t.color.toCSS(),s=t.fontSize,o="";switch(t.horizontalAlign){case lG.HorizontalAlign.LEFT:o="left";break;case lG.HorizontalAlign.CENTER:o="center";break;case lG.HorizontalAlign.RIGHT:o="right"}n.innerHTML="#"+this._domId+"::-webkit-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+o+";}#"+this._domId+"::-moz-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+o+";}#"+this._domId+"::-ms-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+o+";}",xl.browserType===Ju.EDGE&&(n.innerHTML+="#"+this._domId+"::-ms-clear{display: none;}")}}},i._registerEventListeners=function(){var t=this;if(this._edTxt){var e=this._edTxt,i=!1,n=this.__eventListeners;n.compositionStart=function(){i=!0},n.compositionEnd=function(){i=!1,t._delegate._editBoxTextChanged(e.value)},n.onInput=function(){if(!i){var n=t._delegate,r=n.maxLength;r>=0&&(e.value=e.value.slice(0,r)),n._editBoxTextChanged(e.value)}},n.onClick=function(){t._editing&&xl.isMobile&&t._adjustWindowScroll()},n.onKeydown=function(i){i.keyCode===Bw.ENTER?(i.propagationStopped=!0,t._delegate._editBoxEditingReturn(),t._isTextArea||e.blur()):i.keyCode===Bw.TAB&&(i.propagationStopped=!0,i.preventDefault(),Apt.next(t))},n.onBlur=function(){xl.isMobile&&i&&n.compositionEnd(),t._editing=!1,rmt=null,t._hideDom(),t._delegate._editBoxEditingDidEnded()},e.addEventListener("compositionstart",n.compositionStart),e.addEventListener("compositionend",n.compositionEnd),e.addEventListener("input",n.onInput),e.addEventListener("keydown",n.onKeydown),e.addEventListener("blur",n.onBlur),e.addEventListener("touchstart",n.onClick)}},i._removeEventListeners=function(){if(this._edTxt){var t=this._edTxt,e=this.__eventListeners;t.removeEventListener("compositionstart",e.compositionStart),t.removeEventListener("compositionend",e.compositionEnd),t.removeEventListener("input",e.onInput),t.removeEventListener("keydown",e.onKeydown),t.removeEventListener("blur",e.onBlur),t.removeEventListener("touchstart",e.onClick),e.compositionStart=null,e.compositionEnd=null,e.onInput=null,e.onKeydown=null,e.onBlur=null,e.onClick=null}},e}($pt);!function(t){t.EDITING_DID_BEGAN="editing-did-began",t.EDITING_DID_ENDED="editing-did-ended",t.TEXT_CHANGED="text-changed",t.EDITING_RETURN="editing-return",t.XR_EDITING_DID_BEGAN="xr-editing-did-began",t.XR_EDITING_DID_ENDED="xr-editing-did-ended"}(Zpt||(Zpt={}));var amt,hmt,umt,lmt,cmt,_mt,dmt,fmt,pmt,mmt,gmt,ymt,vmt,Smt,Tmt,Amt,bmt,Emt,Cmt,wmt,xmt,Rmt,Imt,Bmt,Dmt,Pmt,Omt,Mmt,Lmt,Nmt,Fmt,kmt,Vmt,Gmt,Umt=t("f$",(bpt=qs("cc.EditBox"),Ept=Ks(110),Cpt=Ys(nV),wpt=xo(lG),xpt=xo(lG),Rpt=xo(pF),Ipt=xo(Tpt),Bpt=xo(Spt),Dpt=xo(vpt),Ppt=xo([ep]),Opt=xo([ep]),Mpt=xo([ep]),Lpt=xo([ep]),bpt(Npt=Ept(Npt=Cpt(((Qpt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).editingDidBegan=kpt&&kpt(),e.textChanged=Vpt&&Vpt(),e.editingDidEnded=Gpt&&Gpt(),e.editingReturn=Upt&&Upt(),e._impl=null,e._background=null,e._textLabel=zpt&&zpt(),e._placeholderLabel=Hpt&&Hpt(),e._returnType=Wpt&&Wpt(),e._string=jpt&&jpt(),e._tabIndex=Xpt&&Xpt(),e._backgroundImage=qpt&&qpt(),e._inputFlag=Ypt&&Ypt(),e._inputMode=Kpt&&Kpt(),e._maxLength=Jpt&&Jpt(),e._isLabelVisible=!1,e}s(e,t);var i=e.prototype;return i.__preload=function(){this._init()},i.onEnable=function(){this._registerEvent(),this._ensureBackgroundSprite(),this._impl&&this._impl.onEnable()},i.update=function(){this._impl&&this._impl.update()},i.onDisable=function(){this._unregisterEvent(),this._unregisterBackgroundEvent(),this._impl&&this._impl.onDisable()},i.onDestroy=function(){this._impl&&this._impl.clear()},i.setFocus=function(){this._impl&&this._impl.setFocus(!0)},i.focus=function(){this._impl&&this._impl.setFocus(!0)},i.blur=function(){this._impl&&this._impl.setFocus(!1)},i.isFocused=function(){return!!this._impl&&this._impl.isFocused()},i._editBoxEditingDidBegan=function(){ep.emitEvents(this.editingDidBegan,this),this.node.emit(Zpt.EDITING_DID_BEGAN,this)},i._editBoxEditingDidEnded=function(t){ep.emitEvents(this.editingDidEnded,this),this.node.emit(Zpt.EDITING_DID_ENDED,this,t)},i._editBoxTextChanged=function(t){t=this._updateLabelStringStyle(t,!0),this.string=t,ep.emitEvents(this.textChanged,t,this),this.node.emit(Zpt.TEXT_CHANGED,this)},i._editBoxEditingReturn=function(t){ep.emitEvents(this.editingReturn,this),this.node.emit(Zpt.EDITING_RETURN,this,t)},i._showLabels=function(){this._isLabelVisible=!0,this._updateLabels()},i._hideLabels=function(){this._isLabelVisible=!1,this._textLabel&&(this._textLabel.node.active=!1),this._placeholderLabel&&(this._placeholderLabel.node.active=!1)},i._onTouchBegan=function(t){t.propagationStopped=!0},i._onTouchCancel=function(t){t.propagationStopped=!0},i._onTouchEnded=function(t){this._impl&&this._impl.beginEditing(),t.propagationStopped=!0},i._init=function(){this._updatePlaceholderLabel(),this._updateTextLabel(),this._isLabelVisible=!0,this.node.on(om.SIZE_CHANGED,this._resizeChildNodes,this),(this._impl=new e._EditBoxImpl).init(this),this._updateString(this._string),this._syncSize()},i._ensureBackgroundSprite=function(){if(!this._background){var t=this.node.getComponent(uz);t||(t=this.node.addComponent(uz)),t!==this._background&&(t.type=uz.Type.SLICED,t.spriteFrame=this._backgroundImage,this._background=t,this._registerBackgroundEvent())}},i._updateTextLabel=function(){var t=this._textLabel;if(!t){var e=this.node.getChildByName("TEXT_LABEL");e||((e=new Jm("TEXT_LABEL")).layer=this.node.layer),(t=e.getComponent(lG))||(t=e.addComponent(lG)),e.parent=this.node,this._textLabel=t}this._inputMode===Spt.ANY?(t.verticalAlign=nG.TOP,t.enableWrapText=!0):t.enableWrapText=!1,t.string=this._updateLabelStringStyle(this._string)},i._updatePlaceholderLabel=function(){var t=this._placeholderLabel;if(!t){var e=this.node.getChildByName("PLACEHOLDER_LABEL");e||((e=new Jm("PLACEHOLDER_LABEL")).layer=this.node.layer),(t=e.getComponent(lG))||(t=e.addComponent(lG)),e.parent=this.node,this._placeholderLabel=t}this._inputMode===Spt.ANY?t.enableWrapText=!0:t.enableWrapText=!1,t.string=this.placeholder},i._syncSize=function(){var t=this.node._uiProps.uiTransformComp,e=t.contentSize;if(this._background){var i=this._background.node._uiProps.uiTransformComp;i.anchorPoint=t.anchorPoint,i.setContentSize(e)}this._updateLabelPosition(e),this._impl&&this._impl.setSize(e.width,e.height)},i._updateLabels=function(){if(this._isLabelVisible){var t=this._string;this._textLabel&&(this._textLabel.node.active=""!==t),this._placeholderLabel&&(this._placeholderLabel.node.active=""===t)}},i._updateString=function(t){var e=this._textLabel;if(e){var i=t;i&&(i=this._updateLabelStringStyle(i)),e.string=i,this._updateLabels()}},i._updateLabelStringStyle=function(t,e){void 0===e&&(e=!1);var i,n=this._inputFlag;if(e||n!==Tpt.PASSWORD)n===Tpt.INITIAL_CAPS_ALL_CHARACTERS?t=t.toUpperCase():n===Tpt.INITIAL_CAPS_WORD?t=t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()})):n===Tpt.INITIAL_CAPS_SENTENCE&&(t=(i=t).charAt(0).toUpperCase()+i.slice(1));else{for(var r="",s=t.length,o=0;o<s;++o)r+="●";t=r}return t},i._registerEvent=function(){this.node.on(om.TOUCH_START,this._onTouchBegan,this),this.node.on(om.TOUCH_END,this._onTouchEnded,this),this.node.on(Pft.XRUI_UNCLICK,this._xrUnClick,this),this.node.on(Oft.XR_KEYBOARD_INPUT,this._xrKeyBoardInput,this)},i._unregisterEvent=function(){this.node.off(om.TOUCH_START,this._onTouchBegan,this),this.node.off(om.TOUCH_END,this._onTouchEnded,this),this.node.off(Pft.XRUI_UNCLICK,this._xrUnClick,this),this.node.off(Oft.XR_KEYBOARD_INPUT,this._xrKeyBoardInput,this)},i._onBackgroundSpriteFrameChanged=function(){this._background&&(this.backgroundImage=this._background.spriteFrame)},i._registerBackgroundEvent=function(){var t=this._background&&this._background.node;null==t||t.on(uz.EventType.SPRITE_FRAME_CHANGED,this._onBackgroundSpriteFrameChanged,this)},i._unregisterBackgroundEvent=function(){var t=this._background&&this._background.node;null==t||t.off(uz.EventType.SPRITE_FRAME_CHANGED,this._onBackgroundSpriteFrameChanged,this)},i._updateLabelPosition=function(t){var e=this.node._uiProps.uiTransformComp,i=-e.anchorX*e.width,n=-e.anchorY*e.height,r=this._placeholderLabel,s=this._textLabel;s&&(s.node._uiProps.uiTransformComp.setContentSize(t.width-2,t.height),s.node.setPosition(i+2,n+t.height,s.node.position.z),this._inputMode===Spt.ANY&&(s.verticalAlign=nG.TOP),s.enableWrapText=this._inputMode===Spt.ANY),r&&(r.node._uiProps.uiTransformComp.setContentSize(t.width-2,t.height),r.node.setPosition(i+2,n+t.height,r.node.position.z),r.enableWrapText=this._inputMode===Spt.ANY)},i._resizeChildNodes=function(){var t=this.node._uiProps.uiTransformComp,e=this._textLabel&&this._textLabel.node;e&&(e.setPosition(-t.width/2,t.height/2,e.position.z),e._uiProps.uiTransformComp.setContentSize(t.contentSize));var i=this._placeholderLabel&&this._placeholderLabel.node;i&&(i.setPosition(-t.width/2,t.height/2,i.position.z),i._uiProps.uiTransformComp.setContentSize(t.contentSize));var n=this._background&&this._background.node;n&&n._uiProps.uiTransformComp.setContentSize(t.contentSize),this._syncSize()},i._xrUnClick=function(){this.node.emit(Zpt.XR_EDITING_DID_BEGAN,this._maxLength,this.string)},i._xrKeyBoardInput=function(t){this.string=t},n(e,[{key:"string",get:function(){return this._string},set:function(t){this._maxLength>=0&&t.length>=this._maxLength&&(t=t.slice(0,this._maxLength)),this._string!==t&&(this._string=t,this._updateString(t))}},{key:"placeholder",get:function(){return this._placeholderLabel?this._placeholderLabel.string:""},set:function(t){this._placeholderLabel&&(this._placeholderLabel.string=t)}},{key:"textLabel",get:function(){return this._textLabel},set:function(t){this._textLabel!==t&&(this._textLabel=t,this._textLabel&&(this._updateTextLabel(),this._updateLabels()))}},{key:"placeholderLabel",get:function(){return this._placeholderLabel},set:function(t){this._placeholderLabel!==t&&(this._placeholderLabel=t,this._placeholderLabel&&(this._updatePlaceholderLabel(),this._updateLabels()))}},{key:"backgroundImage",get:function(){return this._backgroundImage},set:function(t){this._backgroundImage!==t&&(this._backgroundImage=t,this._ensureBackgroundSprite(),this._background.spriteFrame=t)}},{key:"inputFlag",get:function(){return this._inputFlag},set:function(t){this._inputFlag!==t&&(this._inputFlag=t,this._updateString(this._string))}},{key:"inputMode",get:function(){return this._inputMode},set:function(t){this._inputMode!==t&&(this._inputMode=t,this._updateTextLabel(),this._updatePlaceholderLabel())}},{key:"returnType",get:function(){return this._returnType},set:function(t){this._returnType=t}},{key:"maxLength",get:function(){return this._maxLength},set:function(t){this._maxLength=t}},{key:"tabIndex",get:function(){return this._tabIndex},set:function(t){this._tabIndex!==t&&(this._tabIndex=t,this._impl&&this._impl.setTabIndex(t))}}]),e}(rp))._EditBoxImpl=$pt,Qpt.KeyboardReturnType=vpt,Qpt.InputFlag=Tpt,Qpt.InputMode=Spt,Qpt.EventType=Zpt,p((Fpt=Qpt).prototype,"textLabel",[wpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"textLabel"),Fpt.prototype),p(Fpt.prototype,"placeholderLabel",[xpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"placeholderLabel"),Fpt.prototype),p(Fpt.prototype,"backgroundImage",[Rpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"backgroundImage"),Fpt.prototype),p(Fpt.prototype,"inputFlag",[Ipt],Object.getOwnPropertyDescriptor(Fpt.prototype,"inputFlag"),Fpt.prototype),p(Fpt.prototype,"inputMode",[Bpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"inputMode"),Fpt.prototype),p(Fpt.prototype,"returnType",[Dpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"returnType"),Fpt.prototype),kpt=ks(Fpt.prototype,"editingDidBegan",[Ppt,io],(function(){return[]})),Vpt=ks(Fpt.prototype,"textChanged",[Opt,io],(function(){return[]})),Gpt=ks(Fpt.prototype,"editingDidEnded",[Mpt,io],(function(){return[]})),Upt=ks(Fpt.prototype,"editingReturn",[Lpt,io],(function(){return[]})),zpt=ks(Fpt.prototype,"_textLabel",[io],(function(){return null})),Hpt=ks(Fpt.prototype,"_placeholderLabel",[io],(function(){return null})),Wpt=ks(Fpt.prototype,"_returnType",[io],(function(){return vpt.DEFAULT})),jpt=ks(Fpt.prototype,"_string",[io],(function(){return""})),Xpt=ks(Fpt.prototype,"_tabIndex",[io],(function(){return 0})),qpt=ks(Fpt.prototype,"_backgroundImage",[io],(function(){return null})),Ypt=ks(Fpt.prototype,"_inputFlag",[io],(function(){return Tpt.DEFAULT})),Kpt=ks(Fpt.prototype,"_inputMode",[io],(function(){return Spt.ANY})),Jpt=ks(Fpt.prototype,"_maxLength",[io],(function(){return 20})),Npt=Fpt))||Npt)||Npt)||Npt));"object"==typeof window&&"object"==typeof document&&(Umt._EditBoxImpl=omt),v.internal.EditBox=Umt,function(t){t[t.NONE=0]="NONE",t[t.HORIZONTAL=1]="HORIZONTAL",t[t.VERTICAL=2]="VERTICAL",t[t.GRID=3]="GRID"}(Lmt||(Lmt={})),Se(Lmt),function(t){t[t.NONE=0]="NONE",t[t.CONTAINER=1]="CONTAINER",t[t.CHILDREN=2]="CHILDREN"}(Nmt||(Nmt={})),Se(Nmt),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(Fmt||(Fmt={})),Se(Fmt),function(t){t[t.BOTTOM_TO_TOP=0]="BOTTOM_TO_TOP",t[t.TOP_TO_BOTTOM=1]="TOP_TO_BOTTOM"}(kmt||(kmt={})),Se(kmt),function(t){t[t.LEFT_TO_RIGHT=0]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=1]="RIGHT_TO_LEFT"}(Vmt||(Vmt={})),Se(Vmt),function(t){t[t.NONE=0]="NONE",t[t.FIXED_ROW=1]="FIXED_ROW",t[t.FIXED_COL=2]="FIXED_COL"}(Gmt||(Gmt={})),Se(Gmt);var zmt,Hmt,Wmt,jmt,Xmt,qmt,Ymt,Kmt,Jmt,Qmt,Zmt,$mt,tgt,egt,igt=new on,ngt=t("g0",(amt=qs("cc.Layout"),hmt=Ks(110),umt=Ys(nV),lmt=xo(Lmt),cmt=xo(Nmt),_mt=xo(Fmt),dmt=xo(kmt),fmt=xo(Vmt),pmt=xo(Gmt),amt(mmt=hmt(mmt=umt(((Mmt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._resizeMode=ymt&&ymt(),e._layoutType=vmt&&vmt(),e._cellSize=Smt&&Smt(),e._startAxis=Tmt&&Tmt(),e._paddingLeft=Amt&&Amt(),e._paddingRight=bmt&&bmt(),e._paddingTop=Emt&&Emt(),e._paddingBottom=Cmt&&Cmt(),e._spacingX=wmt&&wmt(),e._spacingY=xmt&&xmt(),e._verticalDirection=Rmt&&Rmt(),e._horizontalDirection=Imt&&Imt(),e._constraint=Bmt&&Bmt(),e._constraintNum=Dmt&&Dmt(),e._affectedByScale=Pmt&&Pmt(),e._isAlign=Omt&&Omt(),e._layoutSize=new Vn(300,200),e._layoutDirty=!0,e._childrenDirty=!1,e._usefulLayoutObj=[],e._init=!1,e}s(e,t);var i=e.prototype;return i.updateLayout=function(t){void 0===t&&(t=!1),(this._layoutDirty||t)&&(this._doLayout(),this._layoutDirty=!1)},i.onEnable=function(){this._addEventListeners();var t=this.node._uiProps.uiTransformComp;t.contentSize.equals(Vn.ZERO)&&t.setContentSize(this._layoutSize),this._childrenChanged()},i.onDisable=function(){this._usefulLayoutObj.length=0,this._removeEventListeners()},i._checkUsefulObj=function(){this._usefulLayoutObj.length=0;for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e],n=i._uiProps.uiTransformComp;i.activeInHierarchy&&n&&this._usefulLayoutObj.push(n)}},i._addEventListeners=function(){fN.on(dN.EVENT_AFTER_UPDATE,this.updateLayout,this),this.node.on(om.SIZE_CHANGED,this._resized,this),this.node.on(om.ANCHOR_CHANGED,this._doLayoutDirty,this),this.node.on(om.CHILD_ADDED,this._childAdded,this),this.node.on(om.CHILD_REMOVED,this._childRemoved,this),this.node.on(om.CHILDREN_ORDER_CHANGED,this._childrenChanged,this),this.node.on("childrenSiblingOrderChanged",this.updateLayout,this),this._addChildrenEventListeners()},i._removeEventListeners=function(){fN.off(dN.EVENT_AFTER_UPDATE,this.updateLayout,this),this.node.off(om.SIZE_CHANGED,this._resized,this),this.node.off(om.ANCHOR_CHANGED,this._doLayoutDirty,this),this.node.off(om.CHILD_ADDED,this._childAdded,this),this.node.off(om.CHILD_REMOVED,this._childRemoved,this),this.node.off(om.CHILDREN_ORDER_CHANGED,this._childrenChanged,this),this.node.off("childrenSiblingOrderChanged",this.updateLayout,this),this._removeChildrenEventListeners()},i._addChildrenEventListeners=function(){for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e];i.on(om.SIZE_CHANGED,this._doLayoutDirty,this),i.on(om.TRANSFORM_CHANGED,this._transformDirty,this),i.on(om.ANCHOR_CHANGED,this._doLayoutDirty,this),i.on(om.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this)}},i._removeChildrenEventListeners=function(){for(var t=this.node.children,e=0;e<t.length;++e){var i=t[e];i.off(om.SIZE_CHANGED,this._doLayoutDirty,this),i.off(om.TRANSFORM_CHANGED,this._transformDirty,this),i.off(om.ANCHOR_CHANGED,this._doLayoutDirty,this),i.off(om.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this)}},i._childAdded=function(t){t.on(om.SIZE_CHANGED,this._doLayoutDirty,this),t.on(om.TRANSFORM_CHANGED,this._transformDirty,this),t.on(om.ANCHOR_CHANGED,this._doLayoutDirty,this),t.on(om.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this),this._childrenChanged()},i._childRemoved=function(t){t.off(om.SIZE_CHANGED,this._doLayoutDirty,this),t.off(om.TRANSFORM_CHANGED,this._transformDirty,this),t.off(om.ANCHOR_CHANGED,this._doLayoutDirty,this),t.off(om.ACTIVE_IN_HIERARCHY_CHANGED,this._childrenChanged,this),this._childrenChanged()},i._resized=function(){this._layoutSize.set(this.node._uiProps.uiTransformComp.contentSize),this._doLayoutDirty()},i._doLayoutHorizontally=function(t,e,i,n){var r=this.node._uiProps.uiTransformComp.anchorPoint,s=this._getFixedBreakingNum(),o=1,a=this._paddingLeft;this._horizontalDirection===Vmt.RIGHT_TO_LEFT&&(o=-1,a=this._paddingRight);var h=(this._horizontalDirection-r.x)*t+o*a,u=h-o*this._spacingX,l=0,c=0,_=0,d=0,f=!1,p=this._usefulLayoutObj.length,m=this._cellSize.width,g=this._getPaddingH();this._layoutType!==Lmt.GRID&&this._resizeMode===Nmt.CHILDREN&&(m=(t-g-(p-1)*this._spacingX)/p);for(var y=this._usefulLayoutObj,v=0;v<y.length;++v){var S=y[v],T=S.node,A=T.scale,b=this._getUsedScaleValue(A.x),E=this._getUsedScaleValue(A.y);this._resizeMode===Nmt.CHILDREN&&(S.width=m/b,this._layoutType===Lmt.GRID&&(S.height=this._cellSize.height/E));var C=Math.abs(this._horizontalDirection-S.anchorX),w=S.width*b,x=S.height*E;x>_&&(d=Math.max(_,d),c=_||x,_=x),u+=o*(C*w+this._spacingX);var R=o*(1-C)*w;if(e){if(s>0)(f=v/s>0&&v%s==0)&&(c=_>x?_:c);else if(w>t-g)u>h+o*C*w&&(f=!0);else{var I=(1-this._horizontalDirection-r.x)*t,B=u+R+o*(o>0?this._paddingRight:this._paddingLeft);f=Math.abs(B)>Math.abs(I)}f&&(u=h+o*C*w,x!==_&&(c=_),l+=c+this._spacingY,c=_=x)}var D=i(T,S,l);n&&T.setPosition(u,D),u+=R}return c=Math.max(c,_),Math.max(d,l+c)+this._getPaddingV()},i._doLayoutVertically=function(t,e,i,n){var r=this.node._uiProps.uiTransformComp.anchorPoint,s=this._getFixedBreakingNum(),o=1,a=this._paddingBottom;this._verticalDirection===kmt.TOP_TO_BOTTOM&&(o=-1,a=this._paddingTop);var h=(this._verticalDirection-r.y)*t+o*a,u=h-o*this._spacingY,l=0,c=0,_=0,d=0,f=!1,p=this._usefulLayoutObj.length,m=this._cellSize.height,g=this._getPaddingV();this._layoutType!==Lmt.GRID&&this._resizeMode===Nmt.CHILDREN&&(m=(t-g-(p-1)*this._spacingY)/p);for(var y=this._usefulLayoutObj,v=0;v<y.length;++v){var S=y[v],T=S.node,A=T.scale,b=this._getUsedScaleValue(A.x),E=this._getUsedScaleValue(A.y);this._resizeMode===Nmt.CHILDREN&&(S.height=m/E,this._layoutType===Lmt.GRID&&(S.width=this._cellSize.width/b));var C=Math.abs(this._verticalDirection-S.anchorY),w=S.width*b,x=S.height*E;w>l&&(c=Math.max(l,c),_=l||w,l=w),u+=o*(C*x+this._spacingY);var R=o*(1-C)*x;if(e){if(s>0)(f=v/s>0&&v%s==0)&&(_=l>x?l:_);else if(x>t-g)u>h+o*C*x&&(f=!0);else{var I=(1-this._verticalDirection-r.y)*t,B=u+R+o*(o>0?this._paddingTop:this._paddingBottom);f=Math.abs(B)>Math.abs(I)}f&&(u=h+o*C*x,w!==l&&(_=l),d+=_+this._spacingX,_=l=w)}var D=i(T,S,d);n&&(T.getPosition(igt),T.setPosition(D,u,igt.z)),u+=R}return _=Math.max(_,l),Math.max(c,d+_)+this._getPaddingH()},i._doLayoutGridAxisHorizontal=function(t,e){var i=this,n=e.width,r=1,s=-t.y*e.height,o=this._paddingBottom;this._verticalDirection===kmt.TOP_TO_BOTTOM&&(r=-1,s=(1-t.y)*e.height,o=this._paddingTop);var a=function(t,e,n){return s+r*(n+(1-e.anchorY)*e.height*i._getUsedScaleValue(t.scale.y)+o)},h=0;this._resizeMode===Nmt.CONTAINER&&(h=this._doLayoutHorizontally(n,!0,a,!1),s=-t.y*h,this._verticalDirection===kmt.TOP_TO_BOTTOM&&(r=-1,s=(1-t.y)*h)),this._doLayoutHorizontally(n,!0,a,!0),this._resizeMode===Nmt.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(n,h)},i._doLayoutGridAxisVertical=function(t,e){var i=this,n=e.height,r=1,s=-t.x*e.width,o=this._paddingLeft;this._horizontalDirection===Vmt.RIGHT_TO_LEFT&&(r=-1,s=(1-t.x)*e.width,o=this._paddingRight);var a=function(t,e,n){return s+r*(n+(1-e.anchorX)*e.width*i._getUsedScaleValue(t.scale.x)+o)},h=0;this._resizeMode===Nmt.CONTAINER&&(h=this._doLayoutVertically(n,!0,a,!1),s=-t.x*h,this._horizontalDirection===Vmt.RIGHT_TO_LEFT&&(r=-1,s=(1-t.x)*h)),this._doLayoutVertically(n,!0,a,!0),this._resizeMode===Nmt.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(h,n)},i._doLayoutGrid=function(){var t=this.node._uiProps.uiTransformComp,e=t.anchorPoint,i=t.contentSize;this.startAxis===Fmt.HORIZONTAL?this._doLayoutGridAxisHorizontal(e,i):this.startAxis===Fmt.VERTICAL&&this._doLayoutGridAxisVertical(e,i)},i._getHorizontalBaseWidth=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===Nmt.CONTAINER){for(var n=0;n<t.length;++n){var r=t[n],s=r.node.scale;e+=r.width*this._getUsedScaleValue(s.x)}e+=(i-1)*this._spacingX+this._getPaddingH()}else e=this.node._uiProps.uiTransformComp.width;return e},i._getVerticalBaseHeight=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===Nmt.CONTAINER){for(var n=0;n<t.length;++n){var r=t[n],s=r.node.scale;e+=r.height*this._getUsedScaleValue(s.y)}e+=(i-1)*this._spacingY+this._getPaddingV()}else e=this.node._uiProps.uiTransformComp.height;return e},i._doLayout=function(){var t=this;if(this._init&&!this._childrenDirty||(this._checkUsefulObj(),this._init=!0,this._childrenDirty=!1),this._layoutType===Lmt.HORIZONTAL){var e=this._getHorizontalBaseWidth();this._doLayoutHorizontally(e,!1,(function(e){return(t._isAlign?on.ZERO:e.position).y}),!0),this.node._uiProps.uiTransformComp.width=e}else if(this._layoutType===Lmt.VERTICAL){var i=this._getVerticalBaseHeight();this._doLayoutVertically(i,!1,(function(e){return(t._isAlign?on.ZERO:e.position).x}),!0),this.node._uiProps.uiTransformComp.height=i}else this._layoutType===Lmt.GRID&&this._doLayoutGrid()},i._getUsedScaleValue=function(t){return this._affectedByScale?Math.abs(t):1},i._transformDirty=function(t){t&rm.SCALE&&t&rm.POSITION&&this._affectedByScale&&this._doLayoutDirty()},i._doLayoutDirty=function(){this._layoutDirty=!0},i._childrenChanged=function(){this._childrenDirty=!0,this._doLayoutDirty()},i._getPaddingH=function(){return this._paddingLeft+this._paddingRight},i._getPaddingV=function(){return this._paddingTop+this._paddingBottom},i._getFixedBreakingNum=function(){if(this._layoutType!==Lmt.GRID||this._constraint===Gmt.NONE||this._constraintNum<=0)return 0;var t=this._constraint===Gmt.FIXED_ROW?Math.ceil(this._usefulLayoutObj.length/this._constraintNum):this._constraintNum;return this._startAxis===Fmt.VERTICAL&&(t=this._constraint===Gmt.FIXED_COL?Math.ceil(this._usefulLayoutObj.length/this._constraintNum):this._constraintNum),t},n(e,[{key:"alignHorizontal",get:function(){return this._isAlign},set:function(t){this._layoutType===Lmt.HORIZONTAL&&(this._isAlign=t,this._doLayoutDirty())}},{key:"alignVertical",get:function(){return this._isAlign},set:function(t){this._layoutType===Lmt.VERTICAL&&(this._isAlign=t,this._doLayoutDirty())}},{key:"type",get:function(){return this._layoutType},set:function(t){this._layoutType=t,this._doLayoutDirty()}},{key:"resizeMode",get:function(){return this._resizeMode},set:function(t){this._layoutType!==Lmt.NONE&&(this._resizeMode=t,this._doLayoutDirty())}},{key:"cellSize",get:function(){return this._cellSize},set:function(t){this._cellSize!==t&&(this._cellSize.set(t),this._doLayoutDirty())}},{key:"startAxis",get:function(){return this._startAxis},set:function(t){this._startAxis!==t&&(this._startAxis=t,this._doLayoutDirty())}},{key:"paddingLeft",get:function(){return this._paddingLeft},set:function(t){this._paddingLeft!==t&&(this._paddingLeft=t,this._doLayoutDirty())}},{key:"paddingRight",get:function(){return this._paddingRight},set:function(t){this._paddingRight!==t&&(this._paddingRight=t,this._doLayoutDirty())}},{key:"paddingTop",get:function(){return this._paddingTop},set:function(t){this._paddingTop!==t&&(this._paddingTop=t,this._doLayoutDirty())}},{key:"paddingBottom",get:function(){return this._paddingBottom},set:function(t){this._paddingBottom!==t&&(this._paddingBottom=t,this._doLayoutDirty())}},{key:"spacingX",get:function(){return this._spacingX},set:function(t){this._spacingX!==t&&(this._spacingX=t,this._doLayoutDirty())}},{key:"spacingY",get:function(){return this._spacingY},set:function(t){this._spacingY!==t&&(this._spacingY=t,this._doLayoutDirty())}},{key:"verticalDirection",get:function(){return this._verticalDirection},set:function(t){this._verticalDirection!==t&&(this._verticalDirection=t,this._doLayoutDirty())}},{key:"horizontalDirection",get:function(){return this._horizontalDirection},set:function(t){this._horizontalDirection!==t&&(this._horizontalDirection=t,this._doLayoutDirty())}},{key:"padding",get:function(){return this._paddingLeft},set:function(t){this.paddingLeft===t&&this._paddingRight===t&&this._paddingTop===t&&this._paddingBottom===t||(this._paddingLeft=this._paddingRight=this._paddingTop=this._paddingBottom=t,this._doLayoutDirty())}},{key:"constraint",get:function(){return this._constraint},set:function(t){this._layoutType!==Lmt.NONE&&this._constraint!==t&&(this._constraint=t,this._doLayoutDirty())}},{key:"constraintNum",get:function(){return this._constraintNum},set:function(t){this._constraint!==Gmt.NONE&&this._constraintNum!==t&&(t<=0&&k("Limit values to be greater than 0"),this._constraintNum=t,this._doLayoutDirty())}},{key:"affectedByScale",get:function(){return this._affectedByScale},set:function(t){this._affectedByScale=t,this._doLayoutDirty()}}]),e}(rp)).Type=Lmt,Mmt.VerticalDirection=kmt,Mmt.HorizontalDirection=Vmt,Mmt.ResizeMode=Nmt,Mmt.AxisDirection=Fmt,Mmt.Constraint=Gmt,p((gmt=Mmt).prototype,"type",[lmt],Object.getOwnPropertyDescriptor(gmt.prototype,"type"),gmt.prototype),p(gmt.prototype,"resizeMode",[cmt],Object.getOwnPropertyDescriptor(gmt.prototype,"resizeMode"),gmt.prototype),p(gmt.prototype,"startAxis",[_mt],Object.getOwnPropertyDescriptor(gmt.prototype,"startAxis"),gmt.prototype),p(gmt.prototype,"verticalDirection",[dmt],Object.getOwnPropertyDescriptor(gmt.prototype,"verticalDirection"),gmt.prototype),p(gmt.prototype,"horizontalDirection",[fmt],Object.getOwnPropertyDescriptor(gmt.prototype,"horizontalDirection"),gmt.prototype),p(gmt.prototype,"constraint",[pmt],Object.getOwnPropertyDescriptor(gmt.prototype,"constraint"),gmt.prototype),ymt=ks(gmt.prototype,"_resizeMode",[io],(function(){return Nmt.NONE})),vmt=ks(gmt.prototype,"_layoutType",[io],(function(){return Lmt.NONE})),Smt=ks(gmt.prototype,"_cellSize",[io],(function(){return new Vn(40,40)})),Tmt=ks(gmt.prototype,"_startAxis",[io],(function(){return Fmt.HORIZONTAL})),Amt=ks(gmt.prototype,"_paddingLeft",[io],(function(){return 0})),bmt=ks(gmt.prototype,"_paddingRight",[io],(function(){return 0})),Emt=ks(gmt.prototype,"_paddingTop",[io],(function(){return 0})),Cmt=ks(gmt.prototype,"_paddingBottom",[io],(function(){return 0})),wmt=ks(gmt.prototype,"_spacingX",[io],(function(){return 0})),xmt=ks(gmt.prototype,"_spacingY",[io],(function(){return 0})),Rmt=ks(gmt.prototype,"_verticalDirection",[io],(function(){return kmt.TOP_TO_BOTTOM})),Imt=ks(gmt.prototype,"_horizontalDirection",[io],(function(){return Vmt.LEFT_TO_RIGHT})),Bmt=ks(gmt.prototype,"_constraint",[io],(function(){return Gmt.NONE})),Dmt=ks(gmt.prototype,"_constraintNum",[io],(function(){return 2})),Pmt=ks(gmt.prototype,"_affectedByScale",[io],(function(){return!1})),Omt=ks(gmt.prototype,"_isAlign",[io],(function(){return!1})),mmt=gmt))||mmt)||mmt)||mmt));v.Layout=ngt,function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.FILLED=2]="FILLED"}(egt||(egt={})),ge(egt);var rgt,sgt,ogt,agt,hgt,ugt,lgt,cgt,_gt,dgt,fgt,pgt,mgt,ggt=t("g1",(zmt=qs("cc.ProgressBar"),Hmt=Ks(110),Wmt=Ys(nV),jmt=xo(uz),Xmt=xo(egt),zmt(qmt=Hmt(qmt=Wmt(((tgt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._barSprite=Kmt&&Kmt(),e._mode=Jmt&&Jmt(),e._totalLength=Qmt&&Qmt(),e._progress=Zmt&&Zmt(),e._reverse=$mt&&$mt(),e}s(e,t);var i=e.prototype;return i._initBarSprite=function(){if(this._barSprite){var t=this._barSprite.node;if(!t)return;var e=this.node._uiProps.uiTransformComp,i=e.contentSize,n=e.anchorPoint,r=t._uiProps.uiTransformComp.contentSize;if(this._barSprite.fillType===uz.FillType.RADIAL&&(this._mode=egt.FILLED),this._mode===egt.HORIZONTAL?this.totalLength=r.width:this._mode===egt.VERTICAL?this.totalLength=r.height:this.totalLength=this._barSprite.fillRange,t.parent===this.node){var s=-i.width*n.x;t.setPosition(s,0,0)}}},i._updateBarStatus=function(){if(this._barSprite){var t=this._barSprite.node;if(!t)return;var e=t._uiProps.uiTransformComp,i=e.anchorPoint,n=e.contentSize,r=t.getPosition(),s=new Ln(0,.5),o=Ri(this._progress),a=this._totalLength*o,h=n,u=0,l=0;switch(this._mode){case egt.HORIZONTAL:this._reverse&&(s=new Ln(1,.5)),h=new Vn(a,n.height),u=this._totalLength,l=n.height;break;case egt.VERTICAL:s=this._reverse?new Ln(.5,1):new Ln(.5,0),h=new Vn(n.width,a),u=n.width,l=this._totalLength}if(this._mode===egt.FILLED)this._barSprite.type!==uz.Type.FILLED?k("ProgressBar FILLED mode only works when barSprite's Type is FILLED!"):(this._reverse&&(a*=-1),this._barSprite.fillRange=a);else if(this._barSprite.type!==uz.Type.FILLED){var c=s.x-i.x,_=s.y-i.y,d=new on(u*c,l*_,0);t.setPosition(r.x+d.x,r.y+d.y,r.z),e.setAnchorPoint(s),e.setContentSize(h)}else k("ProgressBar non-FILLED mode only works when barSprite's Type is non-FILLED!")}},n(e,[{key:"barSprite",get:function(){return this._barSprite},set:function(t){this._barSprite!==t&&(this._barSprite=t,this._initBarSprite())}},{key:"mode",get:function(){return this._mode},set:function(t){if(this._mode!==t&&(this._mode=t,this._barSprite)){var e=this._barSprite.node;if(!e)return;var i=e._uiProps.uiTransformComp.contentSize;this._mode===egt.HORIZONTAL?this.totalLength=i.width:this._mode===egt.VERTICAL?this.totalLength=i.height:this._mode===egt.FILLED&&(this.totalLength=this._barSprite.fillRange)}}},{key:"totalLength",get:function(){return this._totalLength},set:function(t){this._mode===egt.FILLED&&(t=Ri(t)),this._totalLength!==t&&(this._totalLength=t,this._updateBarStatus())}},{key:"progress",get:function(){return this._progress},set:function(t){this._progress!==t&&(this._progress=t,this._updateBarStatus())}},{key:"reverse",get:function(){return this._reverse},set:function(t){this._reverse!==t&&(this._reverse=t,this._barSprite&&(this._barSprite.fillStart=1-this._barSprite.fillStart),this._updateBarStatus())}}]),e}(rp)).Mode=egt,p((Ymt=tgt).prototype,"barSprite",[jmt],Object.getOwnPropertyDescriptor(Ymt.prototype,"barSprite"),Ymt.prototype),p(Ymt.prototype,"mode",[Xmt],Object.getOwnPropertyDescriptor(Ymt.prototype,"mode"),Ymt.prototype),Kmt=ks(Ymt.prototype,"_barSprite",[io],(function(){return null})),Jmt=ks(Ymt.prototype,"_mode",[io],(function(){return egt.HORIZONTAL})),Qmt=ks(Ymt.prototype,"_totalLength",[io],(function(){return 1})),Zmt=ks(Ymt.prototype,"_progress",[io],(function(){return.1})),$mt=ks(Ymt.prototype,"_reverse",[io],(function(){return!1})),qmt=Ymt))||qmt)||qmt)||qmt));v.ProgressBar=ggt;var ygt,vgt=new on,Sgt=new on,Tgt=new on,Agt=new Ln,bgt=new dn,Egt=new Ln;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(ygt||(ygt={})),Se(ygt);var Cgt,wgt=t("g2",(rgt=qs("cc.ScrollBar"),sgt=Ks(110),ogt=Ys(nV),agt=xo(uz),hgt=xo(ygt),rgt(ugt=sgt(ugt=ogt(((mgt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._scrollView=cgt&&cgt(),e._handle=_gt&&_gt(),e._direction=dgt&&dgt(),e._enableAutoHide=fgt&&fgt(),e._autoHideTime=pgt&&pgt(),e._touching=!1,e._opacity=255,e._autoHideRemainingTime=0,e}s(e,t);var i=e.prototype;return i.hide=function(){this._autoHideRemainingTime=0,this._setOpacity(0)},i.show=function(){this._autoHideRemainingTime=this._autoHideTime,this._opacity=255,this._setOpacity(this._opacity)},i.onScroll=function(t){if(this._scrollView){var e=this._scrollView.content;if(e){var i=e._uiProps.uiTransformComp.contentSize,n=this._scrollView.node._uiProps.uiTransformComp.contentSize,r=this.node._uiProps.uiTransformComp.contentSize;if(!this._conditionalDisableScrollBar(i,n)){this._enableAutoHide&&(this._autoHideRemainingTime=this._autoHideTime,this._setOpacity(this._opacity));var s=0,o=0,a=0,h=0,u=0,l=Egt;l.set(0,0),this._direction===ygt.HORIZONTAL?(s=i.width,o=n.width,u=r.width,a=t.x,this._convertToScrollViewSpace(l,e),h=-l.x):this._direction===ygt.VERTICAL&&(s=i.height,o=n.height,u=r.height,a=t.y,this._convertToScrollViewSpace(l,e),h=-l.y);var c=this._calculateLength(s,o,u,a),_=Egt;this._calculatePosition(_,s,o,u,h,a,c),this._updateLength(c),this._updateHandlerPosition(_)}}}},i.setScrollView=function(t){this._scrollView=t},i.onTouchBegan=function(){this._enableAutoHide&&(this._touching=!0)},i.onTouchEnded=function(){if(this._enableAutoHide&&(this._touching=!1,!(this._autoHideTime<=0))){if(this._scrollView){var t=this._scrollView.content;if(t){var e=t._uiProps.uiTransformComp.contentSize,i=this._scrollView.node._uiProps.uiTransformComp.contentSize;if(this._conditionalDisableScrollBar(e,i))return}}this._autoHideRemainingTime=this._autoHideTime}},i.onEnable=function(){var t=this.node.getComponent(uz);t&&(this._opacity=t.color.a)},i.start=function(){this._enableAutoHide&&this._setOpacity(0)},i.update=function(t){this._processAutoHide(t)},i._convertToScrollViewSpace=function(t,e){var i=this._scrollView&&this._scrollView.node._uiProps.uiTransformComp,n=e._uiProps.uiTransformComp;if(i&&n){vgt.set(-n.anchorX*n.width,-n.anchorY*n.height,0),n.convertToWorldSpaceAR(vgt,Sgt);var r=i.convertToNodeSpaceAR(Sgt);r.x+=i.anchorX*i.width,r.y+=i.anchorY*i.height,t.set(r.x,r.y)}else t.set(Ln.ZERO)},i._setOpacity=function(t){if(this._handle){var e=this.node.getComponent(uz);e&&(bgt.set(e.color),bgt.a=t,e.color=bgt),(e=this._handle.getComponent(uz))&&(bgt.set(e.color),bgt.a=t,e.color=bgt)}},i._updateHandlerPosition=function(t){if(this._handle){var e=Tgt;this._fixupHandlerPosition(e),this._handle.node.setPosition(t.x+e.x,t.y+e.y,e.z)}},i._fixupHandlerPosition=function(t){var e=this.node._uiProps.uiTransformComp,i=e.contentSize,n=e.anchorPoint,r=this.handle.node._uiProps.uiTransformComp.contentSize,s=this.handle.node.parent;on.set(vgt,-i.width*n.x,-i.height*n.y,0);var o=this.node._uiProps.uiTransformComp.convertToWorldSpaceAR(vgt,Sgt),a=t;a.set(0,0,0),s._uiProps.uiTransformComp.convertToNodeSpaceAR(o,a),this.direction===ygt.HORIZONTAL?a.set(a.x,a.y+(i.height-r.height)/2,a.z):this.direction===ygt.VERTICAL&&a.set(a.x+(i.width-r.width)/2,a.y,a.z),this.handle.node.setPosition(a)},i._conditionalDisableScrollBar=function(t,e){return t.width<=e.width&&this._direction===ygt.HORIZONTAL||t.height<=e.height&&this._direction===ygt.VERTICAL},i._calculateLength=function(t,e,i,n){var r=t;return n&&(r+=20*(n>0?n:-n)),i*(e/r)},i._calculatePosition=function(t,e,i,n,r,s,o){var a=e-i;s&&(a+=Math.abs(s));var h=0;a&&(h=Ri(h=r/a));var u=(n-o)*h;this._direction===ygt.VERTICAL?t.set(0,u):t.set(u,0)},i._updateLength=function(t){if(this._handle){var e=this._handle.node._uiProps.uiTransformComp,i=e.contentSize,n=e.anchorPoint;n.x===Agt.x&&n.y===Agt.y||e.setAnchorPoint(Agt),this._direction===ygt.HORIZONTAL?e.setContentSize(t,i.height):e.setContentSize(i.width,t)}},i._processAutoHide=function(t){if(this._enableAutoHide&&!(this._autoHideRemainingTime<=0)&&!this._touching&&(this._autoHideRemainingTime-=t,this._autoHideRemainingTime<=this._autoHideTime)){this._autoHideRemainingTime=Math.max(0,this._autoHideRemainingTime);var e=this._opacity*(this._autoHideRemainingTime/this._autoHideTime);this._setOpacity(e)}},n(e,[{key:"handle",get:function(){return this._handle},set:function(t){this._handle!==t&&(this._handle=t,this.onScroll(Ln.ZERO))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this.onScroll(Ln.ZERO))}},{key:"enableAutoHide",get:function(){return this._enableAutoHide},set:function(t){this._enableAutoHide!==t&&(this._enableAutoHide=t,this._enableAutoHide&&this._setOpacity(0))}},{key:"autoHideTime",get:function(){return this._autoHideTime},set:function(t){this._autoHideTime!==t&&(this._autoHideTime=t)}}]),e}(rp)).Direction=ygt,p((lgt=mgt).prototype,"handle",[agt],Object.getOwnPropertyDescriptor(lgt.prototype,"handle"),lgt.prototype),p(lgt.prototype,"direction",[hgt],Object.getOwnPropertyDescriptor(lgt.prototype,"direction"),lgt.prototype),cgt=ks(lgt.prototype,"_scrollView",[io],(function(){return null})),_gt=ks(lgt.prototype,"_handle",[io],(function(){return null})),dgt=ks(lgt.prototype,"_direction",[io],(function(){return ygt.HORIZONTAL})),fgt=ks(lgt.prototype,"_enableAutoHide",[io],(function(){return!1})),pgt=ks(lgt.prototype,"_autoHideTime",[io],(function(){return 1})),ugt=lgt))||ugt)||ugt)||ugt));v.ScrollBar=wgt;var xgt,Rgt,Igt,Bgt,Dgt,Pgt,Ogt,Mgt,Lgt,Ngt,Fgt,kgt,Vgt,Ggt,Ugt,zgt,Hgt,Wgt,jgt,Xgt,qgt,Ygt=t("g7",qs("cc.ViewGroup")(Cgt=Ks(110)(Cgt=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(rp))||Cgt)||Cgt);v.ViewGroup=Ygt;var Kgt,Jgt,Qgt=1e-4,Zgt=new on,$gt=new on,tyt=new Ln,eyt=new Ln,iyt=function(){return(new Date).getMilliseconds()},nyt={"scroll-to-top":0,"scroll-to-bottom":1,"scroll-to-left":2,"scroll-to-right":3,scrolling:4,"bounce-bottom":6,"bounce-left":7,"bounce-right":8,"bounce-top":5,"scroll-ended":9,"touch-up":10,"scroll-ended-with-threshold":11,"scroll-began":12};!function(t){t.NONE="",t.SCROLL_TO_TOP="scroll-to-top",t.SCROLL_TO_BOTTOM="scroll-to-bottom",t.SCROLL_TO_LEFT="scroll-to-left",t.SCROLL_TO_RIGHT="scroll-to-right",t.SCROLL_BEGAN="scroll-began",t.SCROLL_ENDED="scroll-ended",t.BOUNCE_TOP="bounce-top",t.BOUNCE_BOTTOM="bounce-bottom",t.BOUNCE_LEFT="bounce-left",t.BOUNCE_RIGHT="bounce-right",t.SCROLLING="scrolling",t.SCROLL_ENG_WITH_THRESHOLD="scroll-ended-with-threshold",t.TOUCH_UP="touch-up"}(Kgt||(Kgt={})),function(t){t[t.NONE=0]="NONE",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT"}(Jgt||(Jgt={}));var ryt,syt,oyt,ayt,hyt,uyt,lyt,cyt,_yt,dyt,fyt,pyt,myt,gyt=t("g3",(xgt=qs("cc.ScrollView"),Rgt=Ks(110),Igt=Ys(nV),Bgt=xo(Jm),Dgt=xo(wgt),Pgt=xo(wgt),Ogt=xo([ep]),xgt(Mgt=Rgt(Mgt=Igt(((qgt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).bounceDuration=Ngt&&Ngt(),e.brake=Fgt&&Fgt(),e.elastic=kgt&&kgt(),e.inertia=Vgt&&Vgt(),e.horizontal=Ggt&&Ggt(),e.vertical=Ugt&&Ugt(),e.cancelInnerEvents=zgt&&zgt(),e.scrollEvents=Hgt&&Hgt(),e._autoScrolling=!1,e._scrolling=!1,e._content=Wgt&&Wgt(),e._horizontalScrollBar=jgt&&jgt(),e._verticalScrollBar=Xgt&&Xgt(),e._topBoundary=0,e._bottomBoundary=0,e._leftBoundary=0,e._rightBoundary=0,e._touchMoveDisplacements=[],e._touchMoveTimeDeltas=[],e._touchMovePreviousTimestamp=0,e._touchMoved=!1,e._autoScrollAttenuate=!1,e._autoScrollStartPosition=new on,e._autoScrollTargetDelta=new on,e._autoScrollTotalTime=0,e._autoScrollAccumulatedTime=0,e._autoScrollCurrentlyOutOfBoundary=!1,e._autoScrollBraking=!1,e._autoScrollBrakingStartPosition=new on,e._outOfBoundaryAmount=new on,e._outOfBoundaryAmountDirty=!0,e._stopMouseWheel=!1,e._mouseWheelEventElapsedTime=0,e._isScrollEndedWithThresholdEventFired=!1,e._scrollEventEmitMask=0,e._isBouncing=!1,e._contentPos=new on,e._deltaPos=new on,e._deltaAmount=new on,e._hoverIn=Jgt.NONE,e}s(e,t);var i=e.prototype;return i.scrollToBottom=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new Ln(0,0),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i,!0)},i.scrollToTop=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new Ln(0,1),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new Ln(0,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new Ln(1,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToTopLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new Ln(0,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToTopRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new Ln(1,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToBottomLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new Ln(0,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToBottomRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new Ln(1,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToOffset=function(t,e,i){void 0===i&&(i=!0);var n=this.getMaxScrollOffset(),r=new Ln(0,0);0===n.x?r.x=0:r.x=t.x/n.x,0===n.y?r.y=1:r.y=(n.y-t.y)/n.y,this.scrollTo(r,e,i)},i.getScrollOffset=function(){var t=this._getContentTopBoundary()-this._topBoundary,e=this._getContentLeftBoundary()-this._leftBoundary;return new Ln(e,t)},i.getMaxScrollOffset=function(){if(!this._content||!this.view)return Ln.ZERO;var t=this._content._uiProps.uiTransformComp.contentSize,e=t.width-this.view.width,i=t.height-this.view.height;return new Ln(e=e>=0?e:0,i=i>=0?i:0)},i.scrollToPercentHorizontal=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new Ln(t,0),applyToHorizontal:!0,applyToVertical:!1});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},i.scrollTo=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new Ln(t),applyToHorizontal:!0,applyToVertical:!0});e?this._startAutoScroll(n,e,i):this._moveContent(n)},i.scrollToPercentVertical=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new Ln(0,t),applyToHorizontal:!1,applyToVertical:!0});e?this._startAutoScroll(n,e,i):this._moveContent(n)},i.stopAutoScroll=function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},i.setContentPosition=function(t){this._setContentPosition(t)},i._setContentPosition=function(t){if(this._content){var e=this._getContentPosition();Math.abs(t.x-e.x)<Qgt&&Math.abs(t.y-e.y)<Qgt||(this._content.setPosition(t),this._outOfBoundaryAmountDirty=!0)}},i.getContentPosition=function(){return this._getContentPosition()},i._getContentPosition=function(){return this._content?(this._contentPos.set(this._content.position),this._contentPos):on.ZERO.clone()},i.isScrolling=function(){return this._scrolling},i.isAutoScrolling=function(){return this._autoScrolling},i.getScrollEndedEventTiming=function(){return Qgt},i.start=function(){this._calculateBoundary(),this._content&&fN.once(dN.EVENT_BEFORE_DRAW,this._adjustContentOutOfBoundary,this)},i.onEnable=function(){this._registerEvent(),this._content&&(this._content.on(om.SIZE_CHANGED,this._calculateBoundary,this),this._content.on(om.TRANSFORM_CHANGED,this._scaleChanged,this),this.view&&(this.view.node.on(om.TRANSFORM_CHANGED,this._scaleChanged,this),this.view.node.on(om.SIZE_CHANGED,this._calculateBoundary,this))),this._calculateBoundary(),this._updateScrollBarState()},i.update=function(t){var e=this._deltaAmount;this._autoScrolling?(this._processAutoScrolling(t),e.x=0,e.y=0):0===e.x&&0===e.y||(this._processDeltaMove(e),e.x=0,e.y=0)},i.onDisable=function(){this._unregisterEvent(),this._content&&(this._content.off(om.SIZE_CHANGED,this._calculateBoundary,this),this._content.off(om.TRANSFORM_CHANGED,this._scaleChanged,this),this.view&&(this.view.node.off(om.TRANSFORM_CHANGED,this._scaleChanged,this),this.view.node.off(om.SIZE_CHANGED,this._calculateBoundary,this))),this._deltaAmount.set(0,0),this._hideScrollBar(),this.stopAutoScroll()},i._registerEvent=function(){this.node.on(om.TOUCH_START,this._onTouchBegan,this,!0),this.node.on(om.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.on(om.TOUCH_END,this._onTouchEnded,this,!0),this.node.on(om.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.on(om.MOUSE_WHEEL,this._onMouseWheel,this,!0),this.node.on(Pft.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.on(Pft.XRUI_HOVER_EXITED,this._xrHoverExit,this),bx.on(Ax.EventType.HANDLE_INPUT,this._dispatchEventHandleInput,this),bx.on(Ax.EventType.GAMEPAD_INPUT,this._dispatchEventHandleInput,this)},i._unregisterEvent=function(){this.node.off(om.TOUCH_START,this._onTouchBegan,this,!0),this.node.off(om.TOUCH_MOVE,this._onTouchMoved,this,!0),this.node.off(om.TOUCH_END,this._onTouchEnded,this,!0),this.node.off(om.TOUCH_CANCEL,this._onTouchCancelled,this,!0),this.node.off(om.MOUSE_WHEEL,this._onMouseWheel,this,!0),this.node.off(Pft.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.off(Pft.XRUI_HOVER_EXITED,this._xrHoverExit,this),bx.off(Ax.EventType.HANDLE_INPUT,this._dispatchEventHandleInput,this),bx.off(Ax.EventType.GAMEPAD_INPUT,this._dispatchEventHandleInput,this)},i._onMouseWheel=function(t,e){if(this.enabledInHierarchy&&!this._hasNestedViewGroup(t,e)){var i=new on,n=t.getScrollY();this.vertical?i.set(0,-.1*n,0):this.horizontal&&i.set(-.1*n,0,0),this._mouseWheelEventElapsedTime=0,this._deltaAmount.add(i),this._stopMouseWheel||(this._handlePressLogic(),this.schedule(this._checkMouseWheel,1/60),this._stopMouseWheel=!0),this._stopPropagationIfTargetIsMe(t)}},i._onTouchBegan=function(t,e){this.enabledInHierarchy&&this._content&&(this._hasNestedViewGroup(t,e)||(this._handlePressLogic(),this._touchMoved=!1,this._stopPropagationIfTargetIsMe(t)))},i._onTouchMoved=function(t,e){if(this.enabledInHierarchy&&this._content&&!this._hasNestedViewGroup(t,e)){var i=t.touch;if(this._handleMoveLogic(i),this.cancelInnerEvents){var n=i.getUILocation(tyt);if(n.subtract(i.getUIStartLocation(eyt)),n.length()>7&&!this._touchMoved&&t.target!==this.node){var r=new Iw(t.getTouches(),t.bubbles,Aw.TOUCH_CANCEL);r.touch=t.touch,r.simulate=!0,t.target.dispatchEvent(r),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(t)}}},i._onTouchEnded=function(t,e){if(this.enabledInHierarchy&&this._content&&t&&!this._hasNestedViewGroup(t,e)){this._dispatchEvent(Kgt.TOUCH_UP);var i=t.touch;this._handleReleaseLogic(i),this._touchMoved?t.propagationStopped=!0:this._stopPropagationIfTargetIsMe(t)}},i._onTouchCancelled=function(t,e){if(this.enabledInHierarchy&&this._content&&!this._hasNestedViewGroup(t,e)){if(t&&!t.simulate){var i=t.touch;this._handleReleaseLogic(i)}this._stopPropagationIfTargetIsMe(t)}},i._calculateBoundary=function(){if(this._content&&this.view){var t=this._content.getComponent(ngt);t&&t.enabledInHierarchy&&t.updateLayout();var e=this.view,i=e.width*e.anchorX,n=e.height*e.anchorY;this._leftBoundary=-i,this._bottomBoundary=-n,this._rightBoundary=this._leftBoundary+e.width,this._topBoundary=this._bottomBoundary+e.height,this._moveContentToTopLeft(e.contentSize)}},i._hasNestedViewGroup=function(t,e){if(!t||t.eventPhase!==Ew.CAPTURING_PHASE)return!1;if(e)for(var i,n=d(e);!(i=n()).done;){var r=i.value;if(this.node===r)return!(!t.target||!t.target.getComponent(Ygt));if(r.getComponent(Ygt))return!0}return!1},i._startInertiaScroll=function(t){var e=new on(t);e.multiplyScalar(.7),this._startAttenuatingAutoScroll(e,t)},i._calculateAttenuatedFactor=function(t){return this.brake<=0?1-this.brake:(1-this.brake)*(1/(1+14e-6*t+t*t*8e-9))},i._startAttenuatingAutoScroll=function(t,e){var i=t.clone();if(i.normalize(),this._content&&this.view){var n=this._content._uiProps.uiTransformComp.contentSize,r=this.view.contentSize,s=n.width-r.width,o=n.height-r.height,a=this._calculateAttenuatedFactor(s),h=this._calculateAttenuatedFactor(o);i.x=i.x*s*(1-this.brake)*a,i.y=i.y*o*h*(1-this.brake),i.z=0}var u=t.length(),l=i.length()/u;if(i.add(t),this.brake>0&&l>7){l=Math.sqrt(l);var c=t.clone();c.multiplyScalar(l),i.set(c),i.add(t)}var _=this._calculateAutoScrollTimeByInitialSpeed(e.length());this.brake>0&&l>3&&(_*=l=3),0===this.brake&&l>1&&(_*=l),this._startAutoScroll(i,_,!0)},i._calculateAutoScrollTimeByInitialSpeed=function(t){return Math.sqrt(Math.sqrt(t/5))},i._startAutoScroll=function(t,e,i){void 0===i&&(i=!1);var n=this._flattenVectorByDirection(t);this._autoScrolling=!0,this._autoScrollTargetDelta=n,this._autoScrollAttenuate=i,on.copy(this._autoScrollStartPosition,this._getContentPosition()),this._autoScrollTotalTime=e,this._autoScrollAccumulatedTime=0,this._autoScrollBraking=!1,this._isScrollEndedWithThresholdEventFired=!1,this._autoScrollBrakingStartPosition.set(0,0,0),this._getHowMuchOutOfBoundary().equals(on.ZERO,Qgt)||(this._autoScrollCurrentlyOutOfBoundary=!0)},i._calculateTouchMoveVelocity=function(){var t=new on,e=0;if((e=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),e))<=0||e>=.5)t.set(on.ZERO);else{var i=new on;i=this._touchMoveDisplacements.reduce((function(t,e){return t.add(e),t}),i),t.set(i.x*(1-this.brake)/e,i.y*(1-this.brake)/e,i.z)}return t},i._flattenVectorByDirection=function(t){var e=t;return e.x=this.horizontal?e.x:0,e.y=this.vertical?e.y:0,e},i._moveContent=function(t,e){var i=this._flattenVectorByDirection(t);Zgt.set(this._getContentPosition()),Zgt.add(i),Zgt.set(Math.round(1e4*Zgt.x)*Qgt,Math.round(1e4*Zgt.y)*Qgt,Zgt.z),this._setContentPosition(Zgt);var n=this._getHowMuchOutOfBoundary();tyt.set(n.x,n.y),this._updateScrollBar(tyt),this.elastic&&e&&this._startBounceBackIfNeeded()},i._getContentLeftBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.x-e.anchorX*e.width},i._getContentRightBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentLeftBoundary()+t.width},i._getContentTopBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentBottomBoundary()+t.height},i._getContentBottomBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.y-e.anchorY*e.height},i._getHowMuchOutOfBoundary=function(t){if((t=t||new on).equals(on.ZERO,Qgt)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=new on,i=this._getContentLeftBoundary(),n=this._getContentRightBoundary();i+t.x>this._leftBoundary?e.x=this._leftBoundary-(i+t.x):n+t.x<this._rightBoundary&&(e.x=this._rightBoundary-(n+t.x));var r=this._getContentTopBoundary(),s=this._getContentBottomBoundary();return r+t.y<this._topBoundary?e.y=this._topBoundary-(r+t.y):s+t.y>this._bottomBoundary&&(e.y=this._bottomBoundary-(s+t.y)),t.equals(on.ZERO,Qgt)&&(this._outOfBoundaryAmount=e,this._outOfBoundaryAmountDirty=!1),this._clampDelta(e),e},i._updateScrollBar=function(t){this._horizontalScrollBar&&this._horizontalScrollBar.isValid&&this._horizontalScrollBar.onScroll(t),this._verticalScrollBar&&this._verticalScrollBar.isValid&&this._verticalScrollBar.onScroll(t)},i._onScrollBarTouchBegan=function(){this._horizontalScrollBar&&this._horizontalScrollBar.isValid&&this._horizontalScrollBar.onTouchBegan(),this._verticalScrollBar&&this._verticalScrollBar.isValid&&this._verticalScrollBar.onTouchBegan()},i._onScrollBarTouchEnded=function(){this._horizontalScrollBar&&this._horizontalScrollBar.isValid&&this._horizontalScrollBar.onTouchEnded(),this._verticalScrollBar&&this._verticalScrollBar.isValid&&this._verticalScrollBar.onTouchEnded()},i._dispatchEvent=function(t){if(t===Kgt.SCROLL_ENDED)this._scrollEventEmitMask=0;else if(t===Kgt.SCROLL_TO_TOP||t===Kgt.SCROLL_TO_BOTTOM||t===Kgt.SCROLL_TO_LEFT||t===Kgt.SCROLL_TO_RIGHT){var e=1<<nyt[t];if(this._scrollEventEmitMask&e)return;this._scrollEventEmitMask|=e}ep.emitEvents(this.scrollEvents,this,nyt[t]),this.node.emit(t,this)},i._adjustContentOutOfBoundary=function(){if(this._content){this._outOfBoundaryAmountDirty=!0;var t=this._getHowMuchOutOfBoundary();!t.equals(on.ZERO,Qgt)&&(Zgt.set(this._getContentPosition()),Zgt.add(t),this._setContentPosition(Zgt),this._updateScrollBar(Ln.ZERO))}},i._hideScrollBar=function(){this._horizontalScrollBar&&this._horizontalScrollBar.isValid&&this._horizontalScrollBar.hide(),this._verticalScrollBar&&this._verticalScrollBar.isValid&&this._verticalScrollBar.hide()},i._updateScrollBarState=function(){if(this._content&&this.view){var t=this.view,e=this._content._uiProps.uiTransformComp;this._verticalScrollBar&&this._verticalScrollBar.isValid&&(e.height<t.height||wi(e.height,t.height)?this._verticalScrollBar.hide():this._verticalScrollBar.show()),this._horizontalScrollBar&&this._horizontalScrollBar.isValid&&(e.width<t.width||wi(e.width,t.width)?this._horizontalScrollBar.hide():this._horizontalScrollBar.show())}},i._stopPropagationIfTargetIsMe=function(t){t.eventPhase===Ew.AT_TARGET&&t.target===this.node&&(t.propagationStopped=!0)},i._processDeltaMove=function(t){this._scrollChildren(t),this._gatherTouchMove(t)},i._handleMoveLogic=function(t){this._getLocalAxisAlignDelta(this._deltaPos,t),this._deltaAmount.add(this._deltaPos)},i._handleReleaseLogic=function(t){this._getLocalAxisAlignDelta(this._deltaPos,t),this._gatherTouchMove(this._deltaPos),this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(Kgt.SCROLL_ENDED))},i._getLocalAxisAlignDelta=function(t,e){var i=this.node._uiProps.uiTransformComp,n=new on;i&&(e.getUILocation(tyt),e.getUIPreviousLocation(eyt),Zgt.set(tyt.x,tyt.y,0),$gt.set(eyt.x,eyt.y,0),i.convertToNodeSpaceAR(Zgt,Zgt),i.convertToNodeSpaceAR($gt,$gt),on.subtract(n,Zgt,$gt)),t.set(n)},i._scrollChildren=function(t){this._clampDelta(t);var e,i=t;this.elastic&&(e=this._getHowMuchOutOfBoundary(),i.x*=0===e.x?1:.5,i.y*=0===e.y?1:.5),this.elastic||(e=this._getHowMuchOutOfBoundary(i),i.add(e));var n=Kgt.NONE,r=Kgt.NONE;if(this._content){var s=this._content._uiProps.uiTransformComp,o=s.anchorX,a=s.anchorY,h=s.width,u=s.height,l=this._content.position||on.ZERO;this.vertical&&(i.y>0?l.y-a*u+i.y>=this._bottomBoundary&&(n=Kgt.SCROLL_TO_BOTTOM):i.y<0&&l.y-a*u+u+i.y<=this._topBoundary&&(n=Kgt.SCROLL_TO_TOP)),this.horizontal&&(i.x<0?l.x-o*h+h+i.x<=this._rightBoundary&&(r=Kgt.SCROLL_TO_RIGHT):i.x>0&&l.x-o*h+i.x>=this._leftBoundary&&(r=Kgt.SCROLL_TO_LEFT))}this._moveContent(i,!1),(this.horizontal&&0!==i.x||this.vertical&&0!==i.y)&&(this._scrolling||(this._scrolling=!0,this._dispatchEvent(Kgt.SCROLL_BEGAN)),this._dispatchEvent(Kgt.SCROLLING)),n!==Kgt.NONE&&this._dispatchEvent(n),r!==Kgt.NONE&&this._dispatchEvent(r)},i._handlePressLogic=function(){this._autoScrolling&&this._dispatchEvent(Kgt.SCROLL_ENDED),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=iyt(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},i._clampDelta=function(t){if(this._content&&this.view){var e=this.view.contentSize,i=this._content._uiProps.uiTransformComp;i.width<e.width&&(t.x=0),i.height<e.height&&(t.y=0)}},i._gatherTouchMove=function(t){var e=t.clone();for(this._clampDelta(e);this._touchMoveDisplacements.length>=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(e);var i=iyt();this._touchMoveTimeDeltas.push((i-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=i},i._startBounceBackIfNeeded=function(){if(!this.elastic)return!1;var t=this._getHowMuchOutOfBoundary();if(this._clampDelta(t),t.equals(on.ZERO,Qgt))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent(Kgt.BOUNCE_TOP),t.y<0&&this._dispatchEvent(Kgt.BOUNCE_BOTTOM),t.x>0&&this._dispatchEvent(Kgt.BOUNCE_RIGHT),t.x<0&&this._dispatchEvent(Kgt.BOUNCE_LEFT),this._isBouncing=!0),!0},i._processInertiaScroll=function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!t.equals(Zgt,Qgt)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},i._isOutOfBoundary=function(){return!this._getHowMuchOutOfBoundary().equals(on.ZERO,Qgt)},i._isNecessaryAutoScrollBrake=function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,on.copy(this._autoScrollBrakingStartPosition,this._getContentPosition()),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},i._processAutoScrolling=function(t){var e=this._isNecessaryAutoScrollBrake(),i=e?.05:1;this._autoScrollAccumulatedTime+=t*(1/i);var n,r=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(n=r,r=(n-=1)*n*n*n*n+1);var s=this._autoScrollTargetDelta.clone();s.multiplyScalar(r);var o=this._autoScrollStartPosition.clone();o.add(s);var a=Math.abs(r-1)<=Qgt;if(Math.abs(r-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent(Kgt.SCROLL_ENG_WITH_THRESHOLD),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var h=o.clone();h.subtract(this._autoScrollBrakingStartPosition),e&&h.multiplyScalar(i),o.set(this._autoScrollBrakingStartPosition),o.add(h)}else{var u=o.clone();u.subtract(this.getContentPosition());var l=this._getHowMuchOutOfBoundary(u);l.equals(on.ZERO,Qgt)||(o.add(l),a=!0)}a&&(this._autoScrolling=!1);var c=o.clone();c.subtract(this._getContentPosition()),this._clampDelta(c),this._moveContent(c,a),this._dispatchEvent(Kgt.SCROLLING),this._autoScrolling||(this._isBouncing=!1,this._scrolling=!1,this._dispatchEvent(Kgt.SCROLL_ENDED))},i._checkMouseWheel=function(t){if(!this._getHowMuchOutOfBoundary().equals(on.ZERO,Qgt))return this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(Kgt.SCROLL_ENDED)),this.unschedule(this._checkMouseWheel),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(Kgt.SCROLL_ENDED)),this.unschedule(this._checkMouseWheel),this._stopMouseWheel=!1)},i._calculateMovePercentDelta=function(t){var e=t.anchor,i=t.applyToHorizontal,n=t.applyToVertical;this._calculateBoundary(),e.clampf(Ln.ZERO,Ln.ONE);var r=this._getContentBottomBoundary()-this._bottomBoundary;r=-r;var s=this._getContentLeftBoundary()-this._leftBoundary;s=-s;var o=new on;if(this._content&&this.view){var a=0,h=this._content._uiProps.uiTransformComp.contentSize,u=this.view.contentSize;i&&(a=h.width-u.width,o.x=s-a*e.x),n&&(a=h.height-u.height,o.y=r-a*e.y)}return o},i._moveContentToTopLeft=function(t){var e=this._getContentBottomBoundary()-this._bottomBoundary;e=-e;var i=new on,n=0,r=this._getContentLeftBoundary()-this._leftBoundary;if(r=-r,this._content){var s=this._content._uiProps.uiTransformComp.contentSize;s.height<t.height&&(n=s.height-t.height,i.y=e-n),s.width<t.width&&(n=s.width-t.width,i.x=r)}this._updateScrollBarState(),this._moveContent(i),this._adjustContentOutOfBoundary()},i._scaleChanged=function(t){t===rm.SCALE&&this._calculateBoundary()},i._xrHoverEnter=function(t){t.deviceType===Dft.Left?this._hoverIn=Jgt.LEFT:t.deviceType===Dft.Right&&(this._hoverIn=Jgt.RIGHT)},i._xrHoverExit=function(){this._hoverIn=Jgt.NONE},i._dispatchEventHandleInput=function(t){var e,i;t instanceof Dw?e=t.gamepad:t instanceof Pw&&(e=t.handleInputDevice),this.enabledInHierarchy&&this._hoverIn!==Jgt.NONE&&(this._hoverIn===Jgt.LEFT?(i=e.leftStick.getValue()).equals(Ln.ZERO)||this._xrThumbStickMove(i):this._hoverIn===Jgt.RIGHT&&((i=e.rightStick.getValue()).equals(Ln.ZERO)||this._xrThumbStickMove(i)))},i._xrThumbStickMove=function(t){if(this.enabledInHierarchy){var e=new on,i=t.y;this.vertical?e.set(0,-62.5*i,0):this.horizontal&&e.set(-62.5*i,0,0),this._mouseWheelEventElapsedTime=0,this._deltaAmount.add(e),this._stopMouseWheel||(this._handlePressLogic(),this.schedule(this._checkMouseWheel,1/60,NaN,0),this._stopMouseWheel=!0)}},n(e,[{key:"content",get:function(){return this._content},set:function(t){if(this._content!==t){var e=t&&t.parent&&t.parent._uiProps.uiTransformComp;!t||t&&e?(this._content=t,this._calculateBoundary()):X(4302)}}},{key:"horizontalScrollBar",get:function(){return this._horizontalScrollBar&&!this._horizontalScrollBar.isValid&&J(4303,"horizontal",this.node.name),this._horizontalScrollBar},set:function(t){this._horizontalScrollBar!==t&&(this._horizontalScrollBar=t,this._horizontalScrollBar&&(this._horizontalScrollBar.setScrollView(this),this._updateScrollBar(Ln.ZERO)))}},{key:"verticalScrollBar",get:function(){return this._verticalScrollBar&&!this._verticalScrollBar.isValid&&J(4303,"vertical",this.node.name),this._verticalScrollBar},set:function(t){this._verticalScrollBar!==t&&(this._verticalScrollBar=t,this._verticalScrollBar&&(this._verticalScrollBar.setScrollView(this),this._updateScrollBar(Ln.ZERO)))}},{key:"view",get:function(){var t=this._content&&this._content.parent;return t?t._uiProps.uiTransformComp:null}}]),e}(Ygt)).EventType=Kgt,Ngt=ks((Lgt=qgt).prototype,"bounceDuration",[io],(function(){return 1})),Fgt=ks(Lgt.prototype,"brake",[io],(function(){return.5})),kgt=ks(Lgt.prototype,"elastic",[io],(function(){return!0})),Vgt=ks(Lgt.prototype,"inertia",[io],(function(){return!0})),p(Lgt.prototype,"content",[Bgt],Object.getOwnPropertyDescriptor(Lgt.prototype,"content"),Lgt.prototype),Ggt=ks(Lgt.prototype,"horizontal",[io],(function(){return!0})),p(Lgt.prototype,"horizontalScrollBar",[Dgt],Object.getOwnPropertyDescriptor(Lgt.prototype,"horizontalScrollBar"),Lgt.prototype),Ugt=ks(Lgt.prototype,"vertical",[io],(function(){return!0})),p(Lgt.prototype,"verticalScrollBar",[Pgt],Object.getOwnPropertyDescriptor(Lgt.prototype,"verticalScrollBar"),Lgt.prototype),zgt=ks(Lgt.prototype,"cancelInnerEvents",[io],(function(){return!0})),Hgt=ks(Lgt.prototype,"scrollEvents",[Ogt,io],(function(){return[]})),Wgt=ks(Lgt.prototype,"_content",[io],(function(){return null})),jgt=ks(Lgt.prototype,"_horizontalScrollBar",[io],(function(){return null})),Xgt=ks(Lgt.prototype,"_verticalScrollBar",[io],(function(){return null})),Mgt=Lgt))||Mgt)||Mgt)||Mgt));v.ScrollView=gyt;var yyt,vyt=new on;!function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(yyt||(yyt={})),Se(yyt);var Syt,Tyt,Ayt,byt,Eyt,Cyt,wyt,xyt,Ryt,Iyt,Byt,Dyt,Pyt=t("g4",(ryt=qs("cc.Slider"),syt=Ks(110),oyt=Ys(nV),ayt=xo(uz),hyt=xo(yyt),uyt=xo([ep]),ryt(lyt=syt(lyt=oyt(((myt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).slideEvents=_yt&&_yt(),e._handle=dyt&&dyt(),e._direction=fyt&&fyt(),e._progress=pyt&&pyt(),e._offset=new on,e._dragging=!1,e._touchHandle=!1,e._handleLocalPos=new on,e._touchPos=new on,e}s(e,t);var i=e.prototype;return i.__preload=function(){this._updateHandlePosition()},i.onEnable=function(){this._updateHandlePosition(),this.node.on(om.TOUCH_START,this._onTouchBegan,this),this.node.on(om.TOUCH_MOVE,this._onTouchMoved,this),this.node.on(om.TOUCH_END,this._onTouchEnded,this),this.node.on(om.TOUCH_CANCEL,this._onTouchCancelled,this),this.node.on(Pft.XRUI_HOVER_STAY,this._xrHoverStay,this),this.node.on(Pft.XRUI_CLICK,this._xrClick,this),this.node.on(Pft.XRUI_UNCLICK,this._xrUnClick,this),this._handle&&this._handle.isValid&&(this._handle.node.on(om.TOUCH_START,this._onHandleDragStart,this),this._handle.node.on(om.TOUCH_MOVE,this._onTouchMoved,this),this._handle.node.on(om.TOUCH_END,this._onTouchEnded,this))},i.onDisable=function(){this.node.off(om.TOUCH_START,this._onTouchBegan,this),this.node.off(om.TOUCH_MOVE,this._onTouchMoved,this),this.node.off(om.TOUCH_END,this._onTouchEnded,this),this.node.off(om.TOUCH_CANCEL,this._onTouchCancelled,this),this.node.off(Pft.XRUI_HOVER_STAY,this._xrHoverStay,this),this.node.off(Pft.XRUI_CLICK,this._xrClick,this),this.node.off(Pft.XRUI_UNCLICK,this._xrUnClick,this),this._handle&&this._handle.isValid&&(this._handle.node.off(om.TOUCH_START,this._onHandleDragStart,this),this._handle.node.off(om.TOUCH_MOVE,this._onTouchMoved,this),this._handle.node.off(om.TOUCH_END,this._onTouchEnded,this))},i._onHandleDragStart=function(t){if(t&&this._handle&&this._handle.node._uiProps.uiTransformComp){this._dragging=!0,this._touchHandle=!0;var e=t.touch.getUILocation();on.set(this._touchPos,e.x,e.y,0),this._handle.node._uiProps.uiTransformComp.convertToNodeSpaceAR(this._touchPos,this._offset),t.propagationStopped=!0}},i._onTouchBegan=function(t){this._handle&&t&&(this._dragging=!0,this._touchHandle||this._handleSliderLogic(t.touch),t.propagationStopped=!0)},i._onTouchMoved=function(t){this._dragging&&t&&(this._handleSliderLogic(t.touch),t.propagationStopped=!0)},i._onTouchEnded=function(t){this._dragging=!1,this._touchHandle=!1,this._offset=new on,t&&(t.propagationStopped=!0)},i._onTouchCancelled=function(t){this._dragging=!1,t&&(t.propagationStopped=!0)},i._handleSliderLogic=function(t){this._updateProgress(t),this._emitSlideEvent()},i._emitSlideEvent=function(){ep.emitEvents(this.slideEvents,this),this.node.emit("slide",this)},i._updateProgress=function(t){if(this._handle&&t){var e=t.getUILocation();on.set(this._touchPos,e.x,e.y,0);var i=this.node._uiProps.uiTransformComp,n=i.convertToNodeSpaceAR(this._touchPos,vyt);this.direction===yyt.Horizontal?this.progress=Ri(.5+(n.x-this._offset.x)/i.width):this.progress=Ri(.5+(n.y-this._offset.y)/i.height)}},i._updateHandlePosition=function(){if(this._handle){this._handleLocalPos.set(this._handle.node.getPosition());var t=this.node._uiProps.uiTransformComp;this._direction===yyt.Horizontal?this._handleLocalPos.x=-t.width*t.anchorX+this.progress*t.width:this._handleLocalPos.y=-t.height*t.anchorY+this.progress*t.height,this._handle.node.setPosition(this._handleLocalPos)}},i._changeLayout=function(){var t=this.node._uiProps.uiTransformComp,e=t.contentSize;if(t.setContentSize(e.height,e.width),this._handle){var i=this._handle.node.position;this._direction===yyt.Horizontal?this._handle.node.setPosition(i.x,0,i.z):this._handle.node.setPosition(0,i.y,i.z),this._updateHandlePosition()}},i._xrHandleProgress=function(t){if(!this._touchHandle){var e=this.node._uiProps.uiTransformComp;e.convertToNodeSpaceAR(t,vyt),this.direction===yyt.Horizontal?this.progress=Ri(.5+(vyt.x-this.node.position.x)/e.width):this.progress=Ri(.5+(vyt.y-this.node.position.y)/e.height)}},i._xrClick=function(t){this._handle&&(this._dragging=!0,this._xrHandleProgress(t.hitPoint),this._emitSlideEvent())},i._xrUnClick=function(){this._dragging=!1,this._touchHandle=!1},i._xrHoverStay=function(t){this._dragging&&(this._xrHandleProgress(t.hitPoint),this._emitSlideEvent())},n(e,[{key:"handle",get:function(){return this._handle},set:function(t){this._handle!==t&&(this._handle=t)}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this._changeLayout())}},{key:"progress",get:function(){return this._progress},set:function(t){this._progress!==t&&(this._progress=t,this._updateHandlePosition())}}]),e}(rp)).Direction=yyt,p((cyt=myt).prototype,"handle",[ayt],Object.getOwnPropertyDescriptor(cyt.prototype,"handle"),cyt.prototype),p(cyt.prototype,"direction",[hyt],Object.getOwnPropertyDescriptor(cyt.prototype,"direction"),cyt.prototype),_yt=ks(cyt.prototype,"slideEvents",[uyt,io],(function(){return[]})),dyt=ks(cyt.prototype,"_handle",[io],(function(){return null})),fyt=ks(cyt.prototype,"_direction",[io],(function(){return yyt.Horizontal})),pyt=ks(cyt.prototype,"_progress",[io],(function(){return.1})),lyt=cyt))||lyt)||lyt)||lyt));function Oyt(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return Object.assign.apply(Object,[{}].concat(e))}v.Slider=Pyt,function(t){t.TOGGLE="toggle"}(Dyt||(Dyt={}));var Myt,Lyt,Nyt,Fyt,kyt,Vyt,Gyt,Uyt=t("g5",(Syt=qs("cc.Toggle"),Tyt=Ks(110),Ayt=Ys(nV),byt=xo(uz),Eyt=xo([ep]),Syt(Cyt=Tyt(Cyt=Ayt(((Byt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).checkEvents=xyt&&xyt(),e._isChecked=Ryt&&Ryt(),e._checkMark=Iyt&&Iyt(),e}s(e,t);var i=e.prototype;return i._internalToggle=function(){this.isChecked=!this.isChecked},i._set=function(t,e){if(void 0===e&&(e=!0),this._isChecked!=t){this._isChecked=t;var i=this._toggleContainer;i&&i.enabled&&this.enabled&&(t||!i.anyTogglesChecked()&&!i.allowSwitchOff)&&(this._isChecked=!0,i.notifyToggleCheck(this,e)),this.playEffect(),e&&this._emitToggleEvents()}},i.playEffect=function(){this._checkMark&&(this._checkMark.node.active=this._isChecked)},i.setIsCheckedWithoutNotify=function(t){this._set(t,!1)},i.onEnable=function(){t.prototype.onEnable.call(this),this.playEffect(),this.node.on(e.EventType.CLICK,this._internalToggle,this)},i.onDisable=function(){t.prototype.onDisable.call(this),this.node.off(e.EventType.CLICK,this._internalToggle,this)},i._emitToggleEvents=function(){this.node.emit(e.EventType.TOGGLE,this),this.checkEvents&&ep.emitEvents(this.checkEvents,this)},n(e,[{key:"isChecked",get:function(){return this._isChecked},set:function(t){this._set(t)}},{key:"checkMark",get:function(){return this._checkMark},set:function(t){this._checkMark!==t&&(this._checkMark=t)}},{key:"_resizeToTarget",set:function(t){t&&this._resizeNodeToTargetNode()}},{key:"_toggleContainer",get:function(){var t=this.node.parent;return v.Node.isNode(t)?t.getComponent("cc.ToggleContainer"):null}}]),e}(ypt)).EventType=Oyt(Dyt,mpt),p((wyt=Byt).prototype,"checkMark",[byt],Object.getOwnPropertyDescriptor(wyt.prototype,"checkMark"),wyt.prototype),xyt=ks(wyt.prototype,"checkEvents",[Eyt,io],(function(){return[]})),Ryt=ks(wyt.prototype,"_isChecked",[io],(function(){return!0})),Iyt=ks(wyt.prototype,"_checkMark",[io],(function(){return null})),Cyt=wyt))||Cyt)||Cyt)||Cyt));v.Toggle=Uyt;var zyt,Hyt,Wyt,jyt,Xyt,qyt,Yyt,Kyt,Jyt,Qyt,Zyt,$yt,tvt,evt,ivt,nvt,rvt,svt,ovt,avt,hvt,uvt,lvt,cvt,_vt,dvt,fvt=t("g6",(Myt=qs("cc.ToggleContainer"),Lyt=Ks(110),Nyt=xo([ep]),Myt(Fyt=Lyt((kyt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._allowSwitchOff=Vyt&&Vyt(),e.checkEvents=Gyt&&Gyt(),e}s(e,t);var i=e.prototype;return i.onEnable=function(){this.ensureValidState(),this.node.on(om.CHILD_ADDED,this.ensureValidState,this),this.node.on(om.CHILD_REMOVED,this.ensureValidState,this)},i.onDisable=function(){this.node.off(om.CHILD_ADDED,this.ensureValidState,this),this.node.off(om.CHILD_REMOVED,this.ensureValidState,this)},i.activeToggles=function(){return this.toggleItems.filter((function(t){return t.isChecked}))},i.anyTogglesChecked=function(){return!!this.toggleItems.find((function(t){return t.isChecked}))},i.notifyToggleCheck=function(t,e){if(void 0===e&&(e=!0),this.enabledInHierarchy){for(var i=0;i<this.toggleItems.length;i++){var n=this.toggleItems[i];n!==t&&(e?n.isChecked=!1:n.setIsCheckedWithoutNotify(!1))}this.checkEvents&&v.Component.EventHandler.emitEvents(this.checkEvents,t)}},i.ensureValidState=function(){var t=this.toggleItems;if(!this._allowSwitchOff&&!this.anyTogglesChecked()&&0!==t.length){var e=t[0];e.isChecked=!0,this.notifyToggleCheck(e)}var i=this.activeToggles();if(i.length>1)for(var n=i[0],r=0;r<i.length;++r){var s=i[r];s!==n&&(s.isChecked=!1)}},n(e,[{key:"allowSwitchOff",get:function(){return this._allowSwitchOff},set:function(t){this._allowSwitchOff=t}},{key:"toggleItems",get:function(){return this.node.children.map((function(t){var e=t.getComponent("cc.Toggle");return e&&e.enabled?e:null})).filter(Boolean)}}]),e}(rp),Vyt=ks(kyt.prototype,"_allowSwitchOff",[io],(function(){return!1})),Gyt=ks(kyt.prototype,"checkEvents",[Nyt,io],(function(){return[]})),Fyt=kyt))||Fyt)||Fyt));v.ToggleContainer=fvt;var pvt,mvt,gvt=new Ln;function yvt(t){return t instanceof Sw?Rl:t._uiProps.uiTransformComp?t._uiProps.uiTransformComp.contentSize:Vn.ZERO}function vvt(t,e,i,n){t.parent?gvt.set(t.parent.getScale().x,t.parent.getScale().y):gvt.set(0,0);for(var r=gvt.x,s=gvt.y,o=0,a=0,h=t.parent;;){if(!h)return i.x=i.y=0,void(n.x=n.y=1);var u=h.getPosition();if(o+=u.x,a+=u.y,(h=h.parent)===e)break;h?gvt.set(h.getScale().x,h.getScale().y):gvt.set(0,0);var l=gvt.x,c=gvt.y;o*=l,a*=c,r*=l,s*=c}n.x=0!==r?1/r:1,n.y=0!==s?1/s:1,i.x=-o,i.y=-a}!function(t){t[t.ONCE=0]="ONCE",t[t.ALWAYS=1]="ALWAYS",t[t.ON_WINDOW_RESIZE=2]="ON_WINDOW_RESIZE"}(pvt||(pvt={})),Se(pvt),function(t){t[t.TOP=1]="TOP",t[t.MID=2]="MID",t[t.BOT=4]="BOT",t[t.LEFT=8]="LEFT",t[t.CENTER=16]="CENTER",t[t.RIGHT=32]="RIGHT",t[t.HORIZONTAL=56]="HORIZONTAL",t[t.VERTICAL=7]="VERTICAL"}(mvt||(mvt={}));var Svt,Tvt,Avt,bvt,Evt,Cvt,wvt,xvt,Rvt,Ivt,Bvt,Dvt,Pvt=mvt.TOP|mvt.BOT,Ovt=mvt.LEFT|mvt.RIGHT,Mvt=t("g8",(zyt=qs("cc.Widget"),Hyt=Ks(110),Wyt=Ys(nV),jyt=xo(Jm),Xyt=xo(pvt),zyt(qyt=Hyt(qyt=Wyt(((dvt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this)._lastPos=new on,e._lastSize=new Vn,e._dirty=!0,e._hadAlignOnce=!1,e._alignFlags=Kyt&&Kyt(),e._target=Jyt&&Jyt(),e._left=Qyt&&Qyt(),e._right=Zyt&&Zyt(),e._top=$yt&&$yt(),e._bottom=tvt&&tvt(),e._horizontalCenter=evt&&evt(),e._verticalCenter=ivt&&ivt(),e._isAbsLeft=nvt&&nvt(),e._isAbsRight=rvt&&rvt(),e._isAbsTop=svt&&svt(),e._isAbsBottom=ovt&&ovt(),e._isAbsHorizontalCenter=avt&&avt(),e._isAbsVerticalCenter=hvt&&hvt(),e._originalWidth=uvt&&uvt(),e._originalHeight=lvt&&lvt(),e._alignMode=cvt&&cvt(),e._lockFlags=_vt&&_vt(),e}s(e,t);var i=e.prototype;return i.updateAlignment=function(){v._widgetManager.updateAlignment(this.node)},i._validateTargetInDEV=function(){},i.setDirty=function(){this._recursiveDirty()},i.onEnable=function(){this.node.getPosition(this._lastPos),this._lastSize.set(this.node._uiProps.uiTransformComp.contentSize),v._widgetManager.add(this),this._hadAlignOnce=!1,this._registerEvent(),this._registerTargetEvents()},i.onDisable=function(){v._widgetManager.remove(this),this._unregisterEvent(),this._unregisterTargetEvents()},i.onDestroy=function(){this._removeParentEvent()},i._adjustWidgetToAllowMovingInEditor=function(){},i._adjustWidgetToAllowResizingInEditor=function(){},i._adjustWidgetToAnchorChanged=function(){this.setDirty()},i._adjustTargetToParentChanged=function(t){t&&this._unregisterOldParentEvents(t),this.node.getParent()&&this._registerTargetEvents(),this._setDirtyByMode()},i._registerEvent=function(){this.node.on(om.TRANSFORM_CHANGED,this._setDirtyByMode,this),this.node.on(om.SIZE_CHANGED,this._setDirtyByMode,this),this.node.on(om.ANCHOR_CHANGED,this._adjustWidgetToAnchorChanged,this),this.node.on(om.PARENT_CHANGED,this._adjustTargetToParentChanged,this)},i._unregisterEvent=function(){this.node.off(om.TRANSFORM_CHANGED,this._setDirtyByMode,this),this.node.off(om.SIZE_CHANGED,this._setDirtyByMode,this),this.node.off(om.ANCHOR_CHANGED,this._adjustWidgetToAnchorChanged,this)},i._removeParentEvent=function(){this.node.off(om.PARENT_CHANGED,this._adjustTargetToParentChanged,this)},i._autoChangedValue=function(t,e){if((this._alignFlags&t)>0){var i=this.node.parent&&this.node.parent._uiProps,n=i&&i.uiTransformComp,r=n?n.contentSize:Rl;this.isAlignLeft&&t===mvt.LEFT?this._left=e?this._left*r.width:this._left/r.width:this.isAlignRight&&t===mvt.RIGHT?this._right=e?this._right*r.width:this._right/r.width:this.isAlignHorizontalCenter&&t===mvt.CENTER?this._horizontalCenter=e?this._horizontalCenter*r.width:this._horizontalCenter/r.width:this.isAlignTop&&t===mvt.TOP?this._top=e?this._top*r.height:this._top/r.height:this.isAlignBottom&&t===mvt.BOT?this._bottom=e?this._bottom*r.height:this._bottom/r.height:this.isAbsoluteVerticalCenter&&t===mvt.MID&&(this._verticalCenter=this._verticalCenter/r.height),this._recursiveDirty()}},i._registerTargetEvents=function(){var t=this._target||this.node.parent;t&&t.getComponent(nV)&&(t.on(om.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.on(om.SIZE_CHANGED,this._setDirtyByMode,this),t.on(om.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterTargetEvents=function(){var t=this._target||this.node.parent;t&&(t.off(om.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.off(om.SIZE_CHANGED,this._setDirtyByMode,this),t.off(om.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterOldParentEvents=function(t){var e=this._target||t;e&&(e.off(om.TRANSFORM_CHANGED,this._setDirtyByMode,this),e.off(om.SIZE_CHANGED,this._setDirtyByMode,this))},i._setDirtyByMode=function(){this.alignMode===pvt.ALWAYS&&this._recursiveDirty()},i._setAlign=function(t,e){if(e!==(this._alignFlags&t)>0){var i=(t&Ovt)>0,n=this.node._uiProps.uiTransformComp;e?(this._alignFlags|=t,i?(this.isAlignHorizontalCenter=!1,this.isStretchWidth&&(this._originalWidth=n.width)):(this.isAlignVerticalCenter=!1,this.isStretchHeight&&(this._originalHeight=n.height))):(i?this.isStretchWidth&&(n.width=this._originalWidth):this.isStretchHeight&&(n.height=this._originalHeight),this._alignFlags&=~t)}},i._recursiveDirty=function(){this._dirty||(this._dirty=!0)},n(e,[{key:"target",get:function(){return this._target},set:function(t){this._target!==t&&(this._unregisterTargetEvents(),this._target=t,this._registerTargetEvents(),this._validateTargetInDEV(),this._recursiveDirty())}},{key:"isAlignTop",get:function(){return(this._alignFlags&mvt.TOP)>0},set:function(t){this._setAlign(mvt.TOP,t),this._recursiveDirty()}},{key:"isAlignBottom",get:function(){return(this._alignFlags&mvt.BOT)>0},set:function(t){this._setAlign(mvt.BOT,t),this._recursiveDirty()}},{key:"isAlignLeft",get:function(){return(this._alignFlags&mvt.LEFT)>0},set:function(t){this._setAlign(mvt.LEFT,t),this._recursiveDirty()}},{key:"isAlignRight",get:function(){return(this._alignFlags&mvt.RIGHT)>0},set:function(t){this._setAlign(mvt.RIGHT,t),this._recursiveDirty()}},{key:"isAlignVerticalCenter",get:function(){return(this._alignFlags&mvt.MID)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=mvt.MID):this._alignFlags&=~mvt.MID,this._recursiveDirty()}},{key:"isAlignHorizontalCenter",get:function(){return(this._alignFlags&mvt.CENTER)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=mvt.CENTER):this._alignFlags&=~mvt.CENTER,this._recursiveDirty()}},{key:"isStretchWidth",get:function(){return(this._alignFlags&Ovt)===Ovt}},{key:"isStretchHeight",get:function(){return(this._alignFlags&Pvt)===Pvt}},{key:"top",get:function(){return this._top},set:function(t){this._top=t,this._recursiveDirty()}},{key:"editorTop",get:function(){return this._isAbsTop?this._top:100*this._top},set:function(t){this._top=this._isAbsTop?t:t/100,this._recursiveDirty()}},{key:"bottom",get:function(){return this._bottom},set:function(t){this._bottom=t,this._recursiveDirty()}},{key:"editorBottom",get:function(){return this._isAbsBottom?this._bottom:100*this._bottom},set:function(t){this._bottom=this._isAbsBottom?t:t/100,this._recursiveDirty()}},{key:"left",get:function(){return this._left},set:function(t){this._left=t,this._recursiveDirty()}},{key:"editorLeft",get:function(){return this._isAbsLeft?this._left:100*this._left},set:function(t){this._left=this._isAbsLeft?t:t/100,this._recursiveDirty()}},{key:"right",get:function(){return this._right},set:function(t){this._right=t,this._recursiveDirty()}},{key:"editorRight",get:function(){return this._isAbsRight?this._right:100*this._right},set:function(t){this._right=this._isAbsRight?t:t/100,this._recursiveDirty()}},{key:"horizontalCenter",get:function(){return this._horizontalCenter},set:function(t){this._horizontalCenter=t,this._recursiveDirty()}},{key:"editorHorizontalCenter",get:function(){return this._isAbsHorizontalCenter?this._horizontalCenter:100*this._horizontalCenter},set:function(t){this._horizontalCenter=this._isAbsHorizontalCenter?t:t/100,this._recursiveDirty()}},{key:"verticalCenter",get:function(){return this._verticalCenter},set:function(t){this._verticalCenter=t,this._recursiveDirty()}},{key:"editorVerticalCenter",get:function(){return this._isAbsVerticalCenter?this._verticalCenter:100*this._verticalCenter},set:function(t){this._verticalCenter=this._isAbsVerticalCenter?t:t/100,this._recursiveDirty()}},{key:"isAbsoluteTop",get:function(){return this._isAbsTop},set:function(t){this._isAbsTop!==t&&(this._isAbsTop=t,this._autoChangedValue(mvt.TOP,this._isAbsTop))}},{key:"isAbsoluteBottom",get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom!==t&&(this._isAbsBottom=t,this._autoChangedValue(mvt.BOT,this._isAbsBottom))}},{key:"isAbsoluteLeft",get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft!==t&&(this._isAbsLeft=t,this._autoChangedValue(mvt.LEFT,this._isAbsLeft))}},{key:"isAbsoluteRight",get:function(){return this._isAbsRight},set:function(t){this._isAbsRight!==t&&(this._isAbsRight=t,this._autoChangedValue(mvt.RIGHT,this._isAbsRight))}},{key:"isAbsoluteHorizontalCenter",get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter!==t&&(this._isAbsHorizontalCenter=t,this._autoChangedValue(mvt.CENTER,this._isAbsHorizontalCenter))}},{key:"isAbsoluteVerticalCenter",get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter!==t&&(this._isAbsVerticalCenter=t,this._autoChangedValue(mvt.MID,this._isAbsVerticalCenter))}},{key:"alignMode",get:function(){return this._alignMode},set:function(t){this._alignMode=t,this._recursiveDirty()}},{key:"alignFlags",get:function(){return this._alignFlags},set:function(t){this._alignFlags!==t&&(this._alignFlags=t,this._recursiveDirty())}}]),e}(rp)).AlignMode=pvt,p((Yyt=dvt).prototype,"target",[jyt],Object.getOwnPropertyDescriptor(Yyt.prototype,"target"),Yyt.prototype),p(Yyt.prototype,"alignMode",[Xyt],Object.getOwnPropertyDescriptor(Yyt.prototype,"alignMode"),Yyt.prototype),Kyt=ks(Yyt.prototype,"_alignFlags",[io],(function(){return 0})),Jyt=ks(Yyt.prototype,"_target",[io],(function(){return null})),Qyt=ks(Yyt.prototype,"_left",[io],(function(){return 0})),Zyt=ks(Yyt.prototype,"_right",[io],(function(){return 0})),$yt=ks(Yyt.prototype,"_top",[io],(function(){return 0})),tvt=ks(Yyt.prototype,"_bottom",[io],(function(){return 0})),evt=ks(Yyt.prototype,"_horizontalCenter",[io],(function(){return 0})),ivt=ks(Yyt.prototype,"_verticalCenter",[io],(function(){return 0})),nvt=ks(Yyt.prototype,"_isAbsLeft",[io],(function(){return!0})),rvt=ks(Yyt.prototype,"_isAbsRight",[io],(function(){return!0})),svt=ks(Yyt.prototype,"_isAbsTop",[io],(function(){return!0})),ovt=ks(Yyt.prototype,"_isAbsBottom",[io],(function(){return!0})),avt=ks(Yyt.prototype,"_isAbsHorizontalCenter",[io],(function(){return!0})),hvt=ks(Yyt.prototype,"_isAbsVerticalCenter",[io],(function(){return!0})),uvt=ks(Yyt.prototype,"_originalWidth",[io],(function(){return 0})),lvt=ks(Yyt.prototype,"_originalHeight",[io],(function(){return 0})),cvt=ks(Yyt.prototype,"_alignMode",[io],(function(){return pvt.ON_WINDOW_RESIZE})),_vt=ks(Yyt.prototype,"_lockFlags",[io,ro],(function(){return 0})),qyt=Yyt))||qyt)||qyt)||qyt));v.internal.computeInverseTransForTarget=vvt,v.internal.getReadonlyNodeSize=yvt,v.Widget=Mvt;var Lvt,Nvt=new dn;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(Lvt||(Lvt={})),Se(Lvt);var Fvt,kvt,Vvt,Gvt,Uvt,zvt,Hvt,Wvt,jvt,Xvt,qvt,Yvt,Kvt,Jvt,Qvt,Zvt,$vt,tSt,eSt,iSt,nSt,rSt,sSt,oSt,aSt=t("ga",(Svt=qs("cc.PageViewIndicator"),Tvt=Ks(110),Avt=xo(pF),bvt=xo(Lvt),Evt=xo(Vn),Svt(Cvt=Tvt(((Dvt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).spacing=xvt&&xvt(),e._spriteFrame=Rvt&&Rvt(),e._direction=Ivt&&Ivt(),e._cellSize=Bvt&&Bvt(),e._layout=null,e._pageView=null,e._indicators=[],e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._updateLayout()},i.setPageView=function(t){this._pageView=t,this._refresh()},i._updateLayout=function(){this._layout=this.getComponent(ngt),this._layout||(this._layout=this.addComponent(ngt));var t=this._layout;this.direction===Lvt.HORIZONTAL?(t.type=ngt.Type.HORIZONTAL,t.spacingX=this.spacing):this.direction===Lvt.VERTICAL&&(t.type=ngt.Type.VERTICAL,t.spacingY=this.spacing),t.resizeMode=ngt.ResizeMode.CONTAINER},i._createIndicator=function(){var t=new Jm;t.layer=this.node.layer;var e=t.addComponent(uz);return e.spriteFrame=this.spriteFrame,e.sizeMode=uz.SizeMode.CUSTOM,t.parent=this.node,t._uiProps.uiTransformComp.setContentSize(this._cellSize),t},i._changedState=function(){var t=this._indicators;if(0!==t.length&&this._pageView){var e=this._pageView.curPageIdx;if(!(e>=t.length)){for(var i=0;i<t.length;++i){var n=t[i];if(n._uiProps.uiComp){var r=n._uiProps.uiComp;Nvt.set(r.color),Nvt.a=127.5,r.color=Nvt}}if(t[e]._uiProps.uiComp){var s=t[e]._uiProps.uiComp;Nvt.set(s.color),Nvt.a=255,s.color=Nvt}}}},i._refresh=function(){if(this._pageView){var t=this._indicators,e=this._pageView.getPages();if(e.length!==t.length){var i=0;if(e.length>t.length)for(i=0;i<e.length;++i)t[i]||(t[i]=this._createIndicator());else for(i=t.length-e.length;i>0;--i){var n=t[i-1];this.node.removeChild(n),t.splice(i-1,1)}this._layout&&this._layout.enabledInHierarchy&&this._layout.updateLayout(),this._changedState()}}},n(e,[{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._spriteFrame!==t&&(this._spriteFrame=t)}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t)}},{key:"cellSize",get:function(){return this._cellSize},set:function(t){this._cellSize!==t&&(this._cellSize=t)}}]),e}(rp)).Direction=Lvt,p((wvt=Dvt).prototype,"spriteFrame",[Avt],Object.getOwnPropertyDescriptor(wvt.prototype,"spriteFrame"),wvt.prototype),p(wvt.prototype,"direction",[bvt],Object.getOwnPropertyDescriptor(wvt.prototype,"direction"),wvt.prototype),p(wvt.prototype,"cellSize",[Evt],Object.getOwnPropertyDescriptor(wvt.prototype,"cellSize"),wvt.prototype),xvt=ks(wvt.prototype,"spacing",[io],(function(){return 0})),Rvt=ks(wvt.prototype,"_spriteFrame",[io],(function(){return null})),Ivt=ks(wvt.prototype,"_direction",[io],(function(){return Lvt.HORIZONTAL})),Bvt=ks(wvt.prototype,"_cellSize",[io],(function(){return new Vn(20,20)})),Cvt=wvt))||Cvt)||Cvt));v.PageViewIndicator=aSt;var hSt,uSt,lSt,cSt=new Ln;!function(t){t[t.Unified=0]="Unified",t[t.Free=1]="Free"}(hSt||(hSt={})),Se(hSt),function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(uSt||(uSt={})),Se(uSt),function(t){t.PAGE_TURNING="page-turning"}(lSt||(lSt={}));var _St=t("g9",(Fvt=qs("cc.PageView"),kvt=Ks(110),Vvt=xo(hSt),Gvt=xo(uSt),Uvt=xo(aSt),zvt=xo(wgt),Hvt=xo(wgt),Wvt=xo([ep]),jvt=xo([ep]),Fvt(Xvt=kvt(((oSt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).autoPageTurningThreshold=Yvt&&Yvt(),e.horizontal=Kvt&&Kvt(),e.vertical=Jvt&&Jvt(),e.cancelInnerEvents=Qvt&&Qvt(),e.scrollEvents=Zvt&&Zvt(),e.pageTurningSpeed=$vt&&$vt(),e.pageEvents=tSt&&tSt(),e._sizeMode=eSt&&eSt(),e._direction=iSt&&iSt(),e._scrollThreshold=nSt&&nSt(),e._pageTurningEventTiming=rSt&&rSt(),e._indicator=sSt&&sSt(),e._curPageIdx=0,e._lastPageIdx=0,e._pages=[],e._initContentPos=new on,e._scrollCenterOffsetX=[],e._scrollCenterOffsetY=[],e._touchBeganPosition=new Ln,e._touchEndPosition=new Ln,e}s(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(om.SIZE_CHANGED,this._updateAllPagesSize,this),this.node.on(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},i.onDisable=function(){t.prototype.onDisable.call(this),this.node.off(om.SIZE_CHANGED,this._updateAllPagesSize,this),this.node.off(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},i.onLoad=function(){this._initPages(),this.indicator&&this.indicator.setPageView(this)},i.getCurrentPageIndex=function(){return this._curPageIdx},i.setCurrentPageIndex=function(t){this.scrollToPage(t,1)},i.getPages=function(){return this._pages},i.addPage=function(t){t&&-1===this._pages.indexOf(t)&&this.content&&(t._uiProps.uiTransformComp?(this.content.addChild(t),this._pages.push(t),this._updatePageView()):X(4301))},i.insertPage=function(t,e){if(!(e<0)&&t&&-1===this._pages.indexOf(t)&&this.content)if(e>=this._pages.length)this.addPage(t);else{if(!t._uiProps.uiTransformComp)return void X(4301);this._pages.splice(e,0,t),this.content.insertChild(t,e),this._updatePageView()}},i.removePage=function(t){if(t&&this.content){var e=this._pages.indexOf(t);-1!==e?this.removePageAtIndex(e):Y(4300,t.name)}},i.removePageAtIndex=function(t){var e=this._pages;if(!(t<0||t>=e.length)){var i=e[t];i&&this.content&&(this.content.removeChild(i),e.splice(t,1),this._updatePageView())}},i.removeAllPages=function(){if(this.content){for(var t=this._pages,e=0,i=t.length;e<i;e++)this.content.removeChild(t[e]);this._pages.length=0,this._updatePageView()}},i.scrollToPage=function(t,e){void 0===e&&(e=.3),t<0||t>=this._pages.length||(this._curPageIdx=t,this.scrollToOffset(this._moveOffsetValue(t),e,!0),this.indicator&&this.indicator._changedState())},i.getScrollEndedEventTiming=function(){return this.pageTurningEventTiming},i._updatePageView=function(){if(this.content){var t=this.content.getComponent(ngt);t&&t.enabled&&t.updateLayout();var e=this._pages.length;this._curPageIdx>=e&&(this._curPageIdx=0===e?0:e-1,this._lastPageIdx=this._curPageIdx);for(var i=this._initContentPos,n=0;n<e;++n){var r=this._pages[n].position;this.direction===uSt.Horizontal?this._scrollCenterOffsetX[n]=Math.abs(i.x+r.x):this._scrollCenterOffsetY[n]=Math.abs(i.y+r.y)}this.indicator&&this.indicator._refresh()}},i._updateAllPagesSize=function(){var t=this.view;if(this.content&&t&&this._sizeMode===hSt.Unified)for(var e=this._pages,i=t.contentSize,n=0,r=e.length;n<r;n++)e[n]._uiProps.uiTransformComp.setContentSize(i)},i._handleReleaseLogic=function(){this._autoScrollToPage(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(e.EventType.SCROLL_ENDED))},i._onTouchBegan=function(e,i){e.touch.getUILocation(cSt),Ln.set(this._touchBeganPosition,cSt.x,cSt.y),t.prototype._onTouchBegan.call(this,e,i)},i._onTouchMoved=function(e,i){t.prototype._onTouchMoved.call(this,e,i)},i._onTouchEnded=function(e,i){e.touch.getUILocation(cSt),Ln.set(this._touchEndPosition,cSt.x,cSt.y),t.prototype._onTouchEnded.call(this,e,i)},i._onTouchCancelled=function(e,i){e.touch.getUILocation(cSt),Ln.set(this._touchEndPosition,cSt.x,cSt.y),t.prototype._onTouchCancelled.call(this,e,i)},i._onMouseWheel=function(){},i._syncScrollDirection=function(){this.horizontal=this.direction===uSt.Horizontal,this.vertical=this.direction===uSt.Vertical},i._syncSizeMode=function(){var t=this.view;if(this.content&&t){var e=this.content.getComponent(ngt);if(e){if(this._sizeMode===hSt.Free&&this._pages.length>0){var i=this._pages[0]._uiProps.uiTransformComp,n=this._pages[this._pages.length-1]._uiProps.uiTransformComp;this.direction===uSt.Horizontal?(e.paddingLeft=(t.width-i.width)/2,e.paddingRight=(t.width-n.width)/2):this.direction===uSt.Vertical&&(e.paddingTop=(t.height-i.height)/2,e.paddingBottom=(t.height-n.height)/2)}e.updateLayout()}}},i._initPages=function(){if(this.content){this._initContentPos=this.content.position;for(var t=this.content.children,e=0;e<t.length;++e){var i=t[e];this._pages.indexOf(i)>=0||this._pages.push(i)}this._syncScrollDirection(),this._syncSizeMode(),this._updatePageView()}},i._dispatchPageTurningEvent=function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,ep.emitEvents(this.pageEvents,this,lSt.PAGE_TURNING),this.node.emit(lSt.PAGE_TURNING,this))},i._isQuicklyScrollable=function(t){if(this.direction===uSt.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===uSt.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},i._moveOffsetValue=function(t){var e=new Ln;if(this._sizeMode===hSt.Free)this.direction===uSt.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===uSt.Vertical&&(e.y=this._scrollCenterOffsetY[t]);else{var i=this.view;if(!i)return e;this.direction===uSt.Horizontal?e.x=t*i.width:this.direction===uSt.Vertical&&(e.y=t*i.height)}return e},i._getDragDirection=function(t){return this._direction===uSt.Horizontal?0===t.x?0:t.x>0?1:-1:0===t.y?0:t.y<0?1:-1},i._isScrollable=function(t,e,i){if(this._sizeMode===hSt.Free){var n=0,r=0;if(this.direction===uSt.Horizontal)return n=this._scrollCenterOffsetX[e],r=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(n-r)*this.scrollThreshold;if(this.direction===uSt.Vertical)return n=this._scrollCenterOffsetY[e],r=this._scrollCenterOffsetY[i],Math.abs(t.y)>=Math.abs(n-r)*this.scrollThreshold}else{var s=this.view;if(!s)return!1;if(this.direction===uSt.Horizontal)return Math.abs(t.x)>=s.width*this.scrollThreshold;if(this.direction===uSt.Vertical)return Math.abs(t.y)>=s.height*this.scrollThreshold}return!1},i._autoScrollToPage=function(){if(this._startBounceBackIfNeeded()){var t=this._getHowMuchOutOfBoundary();this._clampDelta(t),(t.x>0||t.y<0)&&(this._curPageIdx=0===this._pages.length?0:this._pages.length-1),(t.x<0||t.y>0)&&(this._curPageIdx=0),this.indicator&&this.indicator._changedState()}else{var e=new Ln;Ln.subtract(e,this._touchBeganPosition,this._touchEndPosition);var i=this._curPageIdx,n=i+this._getDragDirection(e),r=this.pageTurningSpeed*Math.abs(i-n);if(n<this._pages.length){if(this._isScrollable(e,i,n))return void this.scrollToPage(n,r);var s=this._calculateTouchMoveVelocity();if(this._isQuicklyScrollable(s))return void this.scrollToPage(n,r)}this.scrollToPage(i,r)}},n(e,[{key:"sizeMode",get:function(){return this._sizeMode},set:function(t){this._sizeMode!==t&&(this._sizeMode=t,this._syncSizeMode())}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this._syncScrollDirection())}},{key:"scrollThreshold",get:function(){return this._scrollThreshold},set:function(t){this._scrollThreshold!==t&&(this._scrollThreshold=t)}},{key:"pageTurningEventTiming",get:function(){return this._pageTurningEventTiming},set:function(t){this._pageTurningEventTiming!==t&&(this._pageTurningEventTiming=t)}},{key:"indicator",get:function(){return this._indicator},set:function(t){this._indicator!==t&&(this._indicator=t,this.indicator&&this.indicator.setPageView(this))}},{key:"curPageIdx",get:function(){return this._curPageIdx}},{key:"verticalScrollBar",get:function(){return t.prototype.verticalScrollBar},set:function(t){this.verticalScrollBar=t}},{key:"horizontalScrollBar",get:function(){return t.prototype.horizontalScrollBar},set:function(t){this.horizontalScrollBar=t}}]),e}(gyt)).SizeMode=hSt,oSt.Direction=uSt,oSt.EventType=Oyt(lSt,Kgt),p((qvt=oSt).prototype,"sizeMode",[Vvt],Object.getOwnPropertyDescriptor(qvt.prototype,"sizeMode"),qvt.prototype),p(qvt.prototype,"direction",[Gvt],Object.getOwnPropertyDescriptor(qvt.prototype,"direction"),qvt.prototype),p(qvt.prototype,"indicator",[Uvt],Object.getOwnPropertyDescriptor(qvt.prototype,"indicator"),qvt.prototype),Yvt=ks(qvt.prototype,"autoPageTurningThreshold",[io],(function(){return 100})),p(qvt.prototype,"verticalScrollBar",[zvt,Ro],Object.getOwnPropertyDescriptor(qvt.prototype,"verticalScrollBar"),qvt.prototype),p(qvt.prototype,"horizontalScrollBar",[Hvt,Ro],Object.getOwnPropertyDescriptor(qvt.prototype,"horizontalScrollBar"),qvt.prototype),Kvt=ks(qvt.prototype,"horizontal",[Ro,io],(function(){return!0})),Jvt=ks(qvt.prototype,"vertical",[Ro,io],(function(){return!0})),Qvt=ks(qvt.prototype,"cancelInnerEvents",[Ro,io],(function(){return!0})),Zvt=ks(qvt.prototype,"scrollEvents",[Wvt,io,Ro],(function(){return[]})),$vt=ks(qvt.prototype,"pageTurningSpeed",[io],(function(){return.3})),tSt=ks(qvt.prototype,"pageEvents",[jvt,io],(function(){return[]})),eSt=ks(qvt.prototype,"_sizeMode",[io],(function(){return hSt.Unified})),iSt=ks(qvt.prototype,"_direction",[io],(function(){return uSt.Horizontal})),nSt=ks(qvt.prototype,"_scrollThreshold",[io],(function(){return.5})),rSt=ks(qvt.prototype,"_pageTurningEventTiming",[io],(function(){return.1})),sSt=ks(qvt.prototype,"_indicator",[io],(function(){return null})),Xvt=qvt))||Xvt)||Xvt));v.PageView=_St;var dSt=new on,fSt=new Ln,pSt=new Ln,mSt=new Ln(1,1),gSt=new Ln,ySt=new Ln;function vSt(t,e){if(!e._hadAlignOnce){e.alignMode===pvt.ONCE&&(e._hadAlignOnce=!0);var i,n=e.target,r=pSt,s=mSt;n?vvt(t,i=n,r,s):i=t.parent;var o=yvt(i),a=i instanceof Sw||!i.getComponent(nV),h=a?fSt:i.getComponent(nV).anchorPoint,u=a;t.getPosition(dSt);var l=t._uiProps.uiTransformComp,c=dSt.x,_=dSt.y,d=l.anchorPoint,f=t.getScale();if(e.alignFlags&mvt.HORIZONTAL){var p=0,m=0,g=o.width;u?(p=Rl.left.x,m=Rl.right.x):m=(p=-h.x*g)+g,p+=e.isAbsoluteLeft?e.left:e.left*g,m-=e.isAbsoluteRight?e.right:e.right*g,n&&(p+=r.x,p*=s.x,m+=r.x,m*=s.x);var y=0,v=d.x,S=f.x;if(S<0&&(v=1-v,S=-S),e.isStretchWidth)y=m-p,0!==S&&(l.width=y/S),c=p+v*y;else{if(y=l.width*S,e.isAlignHorizontalCenter){var T=e.isAbsoluteHorizontalCenter?e.horizontalCenter:e.horizontalCenter*g,A=(.5-h.x)*o.width;n&&(T*=s.x,A+=r.x,A*=s.x),c=A+(v-.5)*y+T}else c=e.isAlignLeft?p+v*y:m+(v-1)*y;wi(S,0,Ei)?y=l.width:y/=S}e._lastSize.width=y}if(e.alignFlags&mvt.VERTICAL){var b=0,E=0,C=o.height;u?(E=Rl.bottom.y,b=Rl.top.y):b=(E=-h.y*C)+C,E+=e.isAbsoluteBottom?e.bottom:e.bottom*C,b-=e.isAbsoluteTop?e.top:e.top*C,n&&(E+=r.y,E*=s.y,b+=r.y,b*=s.y);var w=0,x=d.y,R=f.y;if(R<0&&(x=1-x,R=-R),e.isStretchHeight)w=b-E,0!==R&&(l.height=w/R),_=E+x*w;else{if(w=l.height*R,e.isAlignVerticalCenter){var I=e.isAbsoluteVerticalCenter?e.verticalCenter:e.verticalCenter*C,B=(.5-h.y)*o.height;n&&(I*=s.y,B+=r.y,B*=s.y),_=B+(x-.5)*w+I}else _=e.isAlignBottom?E+x*w:b+(x-1)*w;wi(R,0,Ei)?w=l.height:w/=R}e._lastSize.height=w}t.setPosition(c,_,dSt.z),on.set(e._lastPos,c,_,dSt.z)}}function SSt(t){var e=t.getComponent(Mvt);if(e&&e.enabled){if(!v.isValid(t,!0))return;bSt.push(e)}for(var i,n=d(t.children);!(i=n()).done;){var r=i.value;r.active&&SSt(r)}}function TSt(){var t=fN.getScene();if(t){ESt.isAligning=!0,ESt._nodesOrderDirty&&(bSt.length=0,SSt(t),ESt._nodesOrderDirty=!1);var e=null,i=ESt._activeWidgetsIterator;for(i.i=0;i.i<bSt.length;++i.i)(e=bSt[i.i])._dirty&&(vSt(e.node,e),e._dirty=!1);ESt.isAligning=!1}}var ASt,bSt=[],ESt=t("gf",v._widgetManager={isAligning:!1,_nodesOrderDirty:!1,_activeWidgetsIterator:new se(bSt),animationState:null,init:function(){fN.on(dN.EVENT_AFTER_SCENE_LAUNCH,TSt),fN.on(dN.EVENT_AFTER_UPDATE,TSt),SH.instance.on("design-resolution-changed",this.onResized,this);var t=this.onResized.bind(this);SH.instance.on("canvas-resize",t),El.on("window-resize",t)},add:function(){this._nodesOrderDirty=!0},remove:function(t){this._activeWidgetsIterator.remove(t)},onResized:function(){var t=fN.getScene();t&&this.refreshWidgetOnResized(t)},refreshWidgetOnResized:function(t){var e=Jm.isNode(t)&&t.getComponent(Mvt);e&&e.enabled&&(e.alignMode===pvt.ON_WINDOW_RESIZE||e.alignMode===pvt.ALWAYS)&&e.setDirty();for(var i,n=d(t.children);!(i=n()).done;){var r=i.value;this.refreshWidgetOnResized(r)}},updateOffsetsToStayPut:function(t,e){function i(t,e){return Math.abs(t-e)>1e-10?e:t}var n=t.node,r=n.parent;if(r){var s=gSt;s.set(0,0);var o=ySt;if(o.set(1,1),t.target&&vvt(n,r=t.target,s,o),!e)return;var a=r._uiProps&&r._uiProps.uiTransformComp,h=a?a.anchorPoint:fSt,u=n._uiProps.uiTransformComp,l=yvt(r),c=u.anchorPoint,_=n.getPosition(),d=mvt,f=n.getScale(),p=0;if(e&d.LEFT){var m=-h.x*l.width;m+=s.x,m*=o.x,p=_.x-c.x*u.width*Math.abs(f.x)-m,t.isAbsoluteLeft||(p/=l.width),p/=o.x,t.left=i(t.left,p)}if(e&d.RIGHT){var g=(1-h.x)*l.width;g+=s.x,p=(g*=o.x)-(_.x+(1-c.x)*u.width*Math.abs(f.x)),t.isAbsoluteRight||(p/=l.width),p/=o.x,t.right=i(t.right,p)}if(e&d.TOP){var y=(1-h.y)*l.height;y+=s.y,p=(y*=o.y)-(_.y+(1-c.y)*u.height*Math.abs(f.y)),t.isAbsoluteTop||(p/=l.height),p/=o.y,t.top=i(t.top,p)}if(e&d.BOT){var v=-h.y*l.height;v+=s.y,v*=o.y,p=_.y-c.y*u.height*Math.abs(f.y)-v,t.isAbsoluteBottom||(p/=l.height),p/=o.y,t.bottom=i(t.bottom,p)}}},updateAlignment:function t(e){var i=e.parent;i&&Jm.isNode(i)&&t(i);var n=e.getComponent(Mvt);n&&i&&vSt(e,n)},AlignMode:pvt,AlignFlags:mvt});fN.on(dN.EVENT_INIT,(function(){ESt.init()}));var CSt,wSt,xSt,RSt,ISt,BSt,DSt,PSt,OSt,MSt,LSt,NSt,FSt=t("gb",qs("cc.SafeArea")(ASt=Ks(110)(ASt=Ys(Mvt)(ASt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onEnable=function(){this.updateArea(),El.on("window-resize",this.updateArea,this),El.on("orientation-change",this.updateArea,this)},i.onDisable=function(){El.off("window-resize",this.updateArea,this),El.off("orientation-change",this.updateArea,this)},i.updateArea=function(){var t=this.node.getComponent(Mvt),e=this.node.getComponent(nV);if(t&&e){t.updateAlignment();var i=this.node.position.clone(),n=e.anchorPoint.clone();t.isAlignTop=t.isAlignBottom=t.isAlignLeft=t.isAlignRight=!0;var r=CH.getVisibleSize(),s=r.width,o=r.height,a=xl.getSafeAreaRect();t.top=o-a.y-a.height,t.bottom=a.y,t.left=a.x,t.right=s-a.x-a.width,t.updateAlignment();var h=this.node.position.clone(),u=n.x-(h.x-i.x)/e.width,l=n.y-(h.y-i.y)/e.height;e.setAnchorPoint(u,l),ESt.add(t)}},e}(rp))||ASt)||ASt)||ASt);v.SafeArea=FSt;var kSt,VSt=t("gc",(CSt=qs("cc.UICoordinateTracker"),wSt=Ks(110),xSt=xo(Jm),RSt=xo(gH),ISt=xo([ep]),CSt(BSt=wSt((p((DSt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).syncEvents=PSt&&PSt(),e._target=OSt&&OSt(),e._camera=MSt&&MSt(),e._useScale=LSt&&LSt(),e._distance=NSt&&NSt(),e._transformPos=new on,e._viewPos=new on,e._canMove=!0,e._lastWPos=new on,e._lastCameraPos=new on,e}s(e,t);var i=e.prototype;return i.onEnable=function(){this._checkCanMove()},i.update=function(){var t=this.node.worldPosition,e=this._camera;if(this._canMove&&e&&e.camera&&(!this._lastWPos.equals(t)||!this._lastCameraPos.equals(e.node.worldPosition))&&(this._lastWPos.set(t),this._lastCameraPos.set(e.node.worldPosition),e.camera.update(),e.convertToUINode(t,this._target,this._transformPos),this._useScale&&on.transformMat4(this._viewPos,this.node.worldPosition,e.camera.matView),this.syncEvents.length>0)){var i=this._distance/Math.abs(this._viewPos.z);ep.emitEvents(this.syncEvents,this._transformPos,i)}},i._checkCanMove=function(){this._canMove=!(!this._camera||!this._target)},n(e,[{key:"target",get:function(){return this._target},set:function(t){this._target!==t&&(this._target=t,this._checkCanMove())}},{key:"camera",get:function(){return this._camera},set:function(t){this._camera!==t&&(this._camera=t,this._checkCanMove())}},{key:"useScale",get:function(){return this._useScale},set:function(t){this._useScale!==t&&(this._useScale=t)}},{key:"distance",get:function(){return this._distance},set:function(t){this._distance!==t&&(this._distance=t)}}]),e}(rp)).prototype,"target",[xSt],Object.getOwnPropertyDescriptor(DSt.prototype,"target"),DSt.prototype),p(DSt.prototype,"camera",[RSt],Object.getOwnPropertyDescriptor(DSt.prototype,"camera"),DSt.prototype),PSt=ks(DSt.prototype,"syncEvents",[ISt,io],(function(){return[]})),OSt=ks(DSt.prototype,"_target",[io],(function(){return null})),MSt=ks(DSt.prototype,"_camera",[io],(function(){return null})),LSt=ks(DSt.prototype,"_useScale",[io],(function(){return!0})),NSt=ks(DSt.prototype,"_distance",[io],(function(){return 1})),BSt=DSt))||BSt)||BSt)),GSt=[om.TOUCH_START,om.TOUCH_END,om.TOUCH_MOVE,om.MOUSE_DOWN,om.MOUSE_MOVE,om.MOUSE_UP,om.MOUSE_ENTER,om.MOUSE_LEAVE,om.MOUSE_WHEEL];function USt(t){t.propagationStopped=!0}var zSt,HSt,WSt,jSt,XSt,qSt=t("gd",qs("cc.BlockInputEvents")(kSt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onEnable=function(){for(var t=0;t<GSt.length;t++)this.node.on(GSt[t],USt,this)},i.onDisable=function(){for(var t=0;t<GSt.length;t++)this.node.off(GSt[t],USt,this)},e}(rp))||kSt),YSt=t("ge",qs("cc.SubContextView")(zSt=Ks(110)(zSt=Ys(nV)((HSt=function(t){function e(){var e;return(e=t.call(this)||this)._fps=WSt&&WSt(),e._sprite=void 0,e._imageAsset=void 0,e._texture=void 0,e._updatedTime=0,e._updateInterval=0,e._openDataContext=void 0,e._content=void 0,e._designResolutionSize=jSt&&jSt(),e._content=new Jm("content"),e._content.hideFlags|=Ho.Flags.DontSave|Ho.Flags.HideInHierarchy,e._sprite=null,e._imageAsset=new Rf,e._openDataContext=null,e._updatedTime=performance.now(),e._texture=new Zp,e}s(e,t);var i=e.prototype;return i.onLoad=function(){xd.getOpenDataContext?(this._updateInterval=1e3/this._fps,this._openDataContext=xd.getOpenDataContext(),this._initSharedCanvas(),this._initContentNode(),this._updateSubContextView(),this._updateContentLayer()):this.enabled=!1},i.onEnable=function(){this._registerNodeEvent()},i.onDisable=function(){this._unregisterNodeEvent()},i._initSharedCanvas=function(){if(this._openDataContext){var t=this._openDataContext.canvas,e=this._designResolutionSize.width,i=this._designResolutionSize.height;t.width=e,t.height=i}},i._initContentNode=function(){if(this._openDataContext){var t=this._openDataContext.canvas,e=this._imageAsset;if(e.reset(t),this._texture.image=e,this._texture.create(t.width,t.height),this._sprite=this._content.getComponent(uz),this._sprite||(this._sprite=this._content.addComponent(uz)),this._sprite.spriteFrame)this._sprite.spriteFrame.texture=this._texture;else{var i=new pF;i.texture=this._texture,this._sprite.spriteFrame=i}this._content.parent=this.node}},i._updateSubContextView=function(){if(this._openDataContext){var t=this.node.getComponent(nV),e=this._content.getComponent(nV),i=t.width/e.width,n=t.height/e.height,r=i>n?n:i;e.width*=r,e.height*=r;var s=CH.getViewportRect(),o=e.getBoundingBoxToWorld(),a=CH.getVisibleSize(),h=El.devicePixelRatio,u=(s.width*(o.x/a.width)+s.x)/h,l=(s.height*(o.y/a.height)+s.y)/h,c=s.width*(o.width/a.width)/h,_=s.height*(o.height/a.height)/h;this._openDataContext.postMessage({fromEngine:!0,type:"engine",event:"viewport",x:u,y:l,width:c,height:_})}},i._updateSubContextTexture=function(){var t=this._imageAsset;if(t&&this._openDataContext&&!(t.width<=0||t.height<=0)){var e=this._openDataContext.canvas;t.reset(e),(e.width>t.width||e.height>t.height)&&this._texture.create(e.width,e.height),this._texture.uploadData(e)}},i._registerNodeEvent=function(){this.node.on(om.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.on(om.SIZE_CHANGED,this._updateSubContextView,this),this.node.on(om.LAYER_CHANGED,this._updateContentLayer,this)},i._unregisterNodeEvent=function(){this.node.off(om.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.off(om.SIZE_CHANGED,this._updateSubContextView,this),this.node.off(om.LAYER_CHANGED,this._updateContentLayer,this)},i._updateContentLayer=function(){this._content.layer=this.node.layer},i.update=function(t){void 0===t?this._updateSubContextTexture():performance.now()-this._updatedTime>=this._updateInterval&&(this._updatedTime+=this._updateInterval,this._updateSubContextTexture())},i.onDestroy=function(){this._content.destroy(),this._texture.destroy(),this._sprite&&this._sprite.destroy(),this._imageAsset.destroy(),this._openDataContext=null},n(e,[{key:"designResolutionSize",get:function(){return this._designResolutionSize},set:function(){}},{key:"fps",get:function(){return this._fps},set:function(t){this._fps!==t&&(this._fps=t,this._updateInterval=1e3/t)}}]),e}(rp),WSt=ks(HSt.prototype,"_fps",[io],(function(){return 60})),jSt=ks(HSt.prototype,"_designResolutionSize",[io],(function(){return new Vn(640,960)})),zSt=HSt))||zSt)||zSt)||zSt);v.SubContextView=YSt,pt({ButtonComponent:{newName:"Button",since:"1.2.0",removed:!1},EditBoxComponent:{newName:"EditBox",since:"1.2.0",removed:!1},LayoutComponent:{newName:"Layout",since:"1.2.0",removed:!1},ProgressBarComponent:{newName:"ProgressBar",since:"1.2.0",removed:!1},ScrollViewComponent:{newName:"ScrollView",since:"1.2.0",removed:!1},ScrollBarComponent:{newName:"ScrollBar",since:"1.2.0",removed:!1},SliderComponent:{newName:"Slider",since:"1.2.0",removed:!1},ToggleComponent:{newName:"Toggle",since:"1.2.0",removed:!1},ToggleContainerComponent:{newName:"ToggleContainer",since:"1.2.0",removed:!1},WidgetComponent:{newName:"Widget",since:"1.2.0",removed:!1},PageViewComponent:{newName:"PageView",since:"1.2.0",removed:!1},PageViewIndicatorComponent:{newName:"PageViewIndicator",since:"1.2.0",removed:!1},SafeAreaComponent:{newName:"SafeArea",since:"1.2.0",removed:!1},UICoordinateTrackerComponent:{newName:"UICoordinateTracker",since:"1.2.0",removed:!1},BlockInputEventsComponent:{newName:"BlockInputEvents",since:"1.2.0",removed:!1}});var KSt=t("gj",qs("cc.UIReorderComponent")(XSt=function(){Y(1408,"UIReorderComponent")})||XSt);v.UIReorderComponent=KSt,v.ButtonComponent=ypt,Qt(ypt,"cc.ButtonComponent"),v.EditBoxComponent=Umt,Qt(Umt,"cc.EditBoxComponent"),v.LayoutComponent=ngt,Qt(ngt,"cc.LayoutComponent"),v.ProgressBarComponent=ggt,Qt(ggt,"cc.ProgressBarComponent"),v.ScrollViewComponent=gyt,Qt(gyt,"cc.ScrollViewComponent"),v.ScrollBarComponent=wgt,Qt(wgt,"cc.ScrollBarComponent"),v.SliderComponent=Pyt,Qt(Pyt,"cc.SliderComponent"),v.ToggleComponent=Uyt,Qt(Uyt,"cc.ToggleComponent"),v.ToggleContainerComponent=fvt,Qt(fvt,"cc.ToggleContainerComponent"),v.WidgetComponent=Mvt,Qt(Mvt,"cc.WidgetComponent"),v.PageViewComponent=_St,Qt(_St,"cc.PageViewComponent"),v.PageViewIndicatorComponent=aSt,Qt(aSt,"cc.PageViewIndicatorComponent"),v.SafeAreaComponent=FSt,Qt(FSt,"cc.SafeAreaComponent"),Qt(VSt,"cc.UICoordinateTrackerComponent"),v.BlockInputEventsComponent=qSt,Qt(qSt,"cc.BlockInputEventsComponent"),rt(SH.prototype,"View.prototype",[{name:"isAntiAliasEnabled",suggest:"The API of Texture2d have been largely modified, no alternative"},{name:"enableAntiAlias",suggest:"The API of Texture2d have been largely modified, no alternative"}]),st(SH.prototype,"View.prototype",[{name:"adjustViewportMeta"},{name:"enableAutoFullScreen",suggest:"use screen.requestFullScreen() instead."},{name:"isAutoFullScreenEnabled"},{name:"setCanvasSize",suggest:"setting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"getCanvasSize",suggest:"please use screen.windowSize instead."},{name:"getFrameSize",suggest:"getting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"setFrameSize",suggest:"setting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"getDevicePixelRatio",suggest:"use screen.devicePixelRatio instead."},{name:"convertToLocationInView"},{name:"enableRetina"},{name:"isRetinaEnabled"},{name:"setRealPixelResolution"}])}}}));